Blame view

bower_components/polymer/polymer.html 115 KB
73bcce88   luigser   COMPONENTS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  <!--
  @license
  Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
  This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
  The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
  The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
  Code distributed by Google as part of the polymer project is also
  subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
  --><!--
  @license
  Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
  This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
  The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
  The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
  Code distributed by Google as part of the polymer project is also
  subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
  --><link rel="import" href="polymer-mini.html">
  
  <script>Polymer.nar = [];
  Polymer.Annotations = {
  parseAnnotations: function (template) {
  var list = [];
  var content = template._content || template.content;
a1a3bc73   Luigi Serra   graphs updates
24
  this._parseNodeAnnotations(content, list, template.hasAttribute('strip-whitespace'));
73bcce88   luigser   COMPONENTS
25
26
  return list;
  },
a1a3bc73   Luigi Serra   graphs updates
27
28
  _parseNodeAnnotations: function (node, list, stripWhiteSpace) {
  return node.nodeType === Node.TEXT_NODE ? this._parseTextNodeAnnotation(node, list) : this._parseElementAnnotations(node, list, stripWhiteSpace);
73bcce88   luigser   COMPONENTS
29
  },
a1a3bc73   Luigi Serra   graphs updates
30
  _bindingRegex: /([^{[]*)(\{\{|\[\[)(?!\}\}|\]\])(.+?)(?:\]\]|\}\})/g,
f748e9cf   Luigi Serra   new controllet an...
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
  _parseBindings: function (text) {
  var re = this._bindingRegex;
  var parts = [];
  var m, lastIndex;
  while ((m = re.exec(text)) !== null) {
  if (m[1]) {
  parts.push({ literal: m[1] });
  }
  var mode = m[2][0];
  var value = m[3].trim();
  var negate = false;
  if (value[0] == '!') {
  negate = true;
  value = value.substring(1).trim();
  }
  var customEvent, notifyEvent, colon;
  if (mode == '{' && (colon = value.indexOf('::')) > 0) {
  notifyEvent = value.substring(colon + 2);
  value = value.substring(0, colon);
  customEvent = true;
  }
  parts.push({
  compoundIndex: parts.length,
  value: value,
  mode: mode,
  negate: negate,
  event: notifyEvent,
  customEvent: customEvent
  });
  lastIndex = re.lastIndex;
  }
  if (lastIndex && lastIndex < text.length) {
  var literal = text.substring(lastIndex);
  if (literal) {
  parts.push({ literal: literal });
  }
  }
  if (parts.length) {
  return parts;
73bcce88   luigser   COMPONENTS
70
71
  }
  },
f748e9cf   Luigi Serra   new controllet an...
72
73
74
75
76
77
78
79
  _literalFromParts: function (parts) {
  var s = '';
  for (var i = 0; i < parts.length; i++) {
  var literal = parts[i].literal;
  s += literal || '';
  }
  return s;
  },
73bcce88   luigser   COMPONENTS
80
  _parseTextNodeAnnotation: function (node, list) {
f748e9cf   Luigi Serra   new controllet an...
81
82
83
  var parts = this._parseBindings(node.textContent);
  if (parts) {
  node.textContent = this._literalFromParts(parts) || ' ';
73bcce88   luigser   COMPONENTS
84
85
86
  var annote = {
  bindings: [{
  kind: 'text',
f748e9cf   Luigi Serra   new controllet an...
87
88
89
  name: 'textContent',
  parts: parts,
  isCompound: parts.length !== 1
73bcce88   luigser   COMPONENTS
90
91
92
93
94
95
  }]
  };
  list.push(annote);
  return annote;
  }
  },
a1a3bc73   Luigi Serra   graphs updates
96
  _parseElementAnnotations: function (element, list, stripWhiteSpace) {
73bcce88   luigser   COMPONENTS
97
98
99
100
101
102
103
  var annote = {
  bindings: [],
  events: []
  };
  if (element.localName === 'content') {
  list._hasContent = true;
  }
a1a3bc73   Luigi Serra   graphs updates
104
  this._parseChildNodesAnnotations(element, annote, list, stripWhiteSpace);
73bcce88   luigser   COMPONENTS
105
106
107
108
109
110
111
112
113
114
115
  if (element.attributes) {
  this._parseNodeAttributeAnnotations(element, annote, list);
  if (this.prepElement) {
  this.prepElement(element);
  }
  }
  if (annote.bindings.length || annote.events.length || annote.id) {
  list.push(annote);
  }
  return annote;
  },
a1a3bc73   Luigi Serra   graphs updates
116
  _parseChildNodesAnnotations: function (root, annote, list, stripWhiteSpace) {
73bcce88   luigser   COMPONENTS
117
  if (root.firstChild) {
a1a3bc73   Luigi Serra   graphs updates
118
119
120
121
  var node = root.firstChild;
  var i = 0;
  while (node) {
  var next = node.nextSibling;
73bcce88   luigser   COMPONENTS
122
123
124
125
  if (node.localName === 'template' && !node.hasAttribute('preserve-content')) {
  this._parseTemplate(node, i, list, annote);
  }
  if (node.nodeType === Node.TEXT_NODE) {
a1a3bc73   Luigi Serra   graphs updates
126
  var n = next;
73bcce88   luigser   COMPONENTS
127
128
  while (n && n.nodeType === Node.TEXT_NODE) {
  node.textContent += n.textContent;
a1a3bc73   Luigi Serra   graphs updates
129
  next = n.nextSibling;
73bcce88   luigser   COMPONENTS
130
  root.removeChild(n);
a1a3bc73   Luigi Serra   graphs updates
131
  n = next;
73bcce88   luigser   COMPONENTS
132
  }
a1a3bc73   Luigi Serra   graphs updates
133
134
135
  if (stripWhiteSpace && !node.textContent.trim()) {
  root.removeChild(node);
  i--;
73bcce88   luigser   COMPONENTS
136
  }
a1a3bc73   Luigi Serra   graphs updates
137
138
139
  }
  if (node.parentNode) {
  var childAnnotation = this._parseNodeAnnotations(node, list, stripWhiteSpace);
73bcce88   luigser   COMPONENTS
140
141
142
143
144
  if (childAnnotation) {
  childAnnotation.parent = annote;
  childAnnotation.index = i;
  }
  }
a1a3bc73   Luigi Serra   graphs updates
145
146
147
  node = next;
  i++;
  }
73bcce88   luigser   COMPONENTS
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
  }
  },
  _parseTemplate: function (node, index, list, parent) {
  var content = document.createDocumentFragment();
  content._notes = this.parseAnnotations(node);
  content.appendChild(node.content);
  list.push({
  bindings: Polymer.nar,
  events: Polymer.nar,
  templateContent: content,
  parent: parent,
  index: index
  });
  },
  _parseNodeAttributeAnnotations: function (node, annotation) {
f748e9cf   Luigi Serra   new controllet an...
163
164
165
166
167
168
  var attrs = Array.prototype.slice.call(node.attributes);
  for (var i = attrs.length - 1, a; a = attrs[i]; i--) {
  var n = a.name;
  var v = a.value;
  var b;
  if (n.slice(0, 3) === 'on-') {
73bcce88   luigser   COMPONENTS
169
170
171
172
173
  node.removeAttribute(n);
  annotation.events.push({
  name: n.slice(3),
  value: v
  });
f748e9cf   Luigi Serra   new controllet an...
174
  } else if (b = this._parseNodeAttributeAnnotation(node, n, v)) {
73bcce88   luigser   COMPONENTS
175
  annotation.bindings.push(b);
f748e9cf   Luigi Serra   new controllet an...
176
177
  } else if (n === 'id') {
  annotation.id = v;
73bcce88   luigser   COMPONENTS
178
179
180
  }
  }
  },
f748e9cf   Luigi Serra   new controllet an...
181
182
183
184
  _parseNodeAttributeAnnotation: function (node, name, value) {
  var parts = this._parseBindings(value);
  if (parts) {
  var origName = name;
73bcce88   luigser   COMPONENTS
185
  var kind = 'property';
f748e9cf   Luigi Serra   new controllet an...
186
187
  if (name[name.length - 1] == '$') {
  name = name.slice(0, -1);
73bcce88   luigser   COMPONENTS
188
189
  kind = 'attribute';
  }
f748e9cf   Luigi Serra   new controllet an...
190
191
192
  var literal = this._literalFromParts(parts);
  if (literal && kind == 'attribute') {
  node.setAttribute(name, literal);
73bcce88   luigser   COMPONENTS
193
  }
f748e9cf   Luigi Serra   new controllet an...
194
195
  if (node.localName == 'input' && name == 'value') {
  node.setAttribute(origName, '');
73bcce88   luigser   COMPONENTS
196
  }
f748e9cf   Luigi Serra   new controllet an...
197
  node.removeAttribute(origName);
73bcce88   luigser   COMPONENTS
198
199
200
201
202
  if (kind === 'property') {
  name = Polymer.CaseMap.dashToCamelCase(name);
  }
  return {
  kind: kind,
73bcce88   luigser   COMPONENTS
203
  name: name,
f748e9cf   Luigi Serra   new controllet an...
204
205
206
  parts: parts,
  literal: literal,
  isCompound: parts.length !== 1
73bcce88   luigser   COMPONENTS
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
  };
  }
  },
  _localSubTree: function (node, host) {
  return node === host ? node.childNodes : node._lightChildren || node.childNodes;
  },
  findAnnotatedNode: function (root, annote) {
  var parent = annote.parent && Polymer.Annotations.findAnnotatedNode(root, annote.parent);
  return !parent ? root : Polymer.Annotations._localSubTree(parent, root)[annote.index];
  }
  };
  (function () {
  function resolveCss(cssText, ownerDocument) {
  return cssText.replace(CSS_URL_RX, function (m, pre, url, post) {
  return pre + '\'' + resolve(url.replace(/["']/g, ''), ownerDocument) + '\'' + post;
  });
  }
  function resolveAttrs(element, ownerDocument) {
  for (var name in URL_ATTRS) {
  var a$ = URL_ATTRS[name];
  for (var i = 0, l = a$.length, a, at, v; i < l && (a = a$[i]); i++) {
  if (name === '*' || element.localName === name) {
  at = element.attributes[a];
  v = at && at.value;
  if (v && v.search(BINDING_RX) < 0) {
  at.value = a === 'style' ? resolveCss(v, ownerDocument) : resolve(v, ownerDocument);
  }
  }
  }
  }
  }
  function resolve(url, ownerDocument) {
  if (url && url[0] === '#') {
  return url;
  }
  var resolver = getUrlResolver(ownerDocument);
  resolver.href = url;
  return resolver.href || url;
  }
  var tempDoc;
  var tempDocBase;
  function resolveUrl(url, baseUri) {
  if (!tempDoc) {
  tempDoc = document.implementation.createHTMLDocument('temp');
  tempDocBase = tempDoc.createElement('base');
  tempDoc.head.appendChild(tempDocBase);
  }
  tempDocBase.href = baseUri;
  return resolve(url, tempDoc);
  }
  function getUrlResolver(ownerDocument) {
  return ownerDocument.__urlResolver || (ownerDocument.__urlResolver = ownerDocument.createElement('a'));
  }
  var CSS_URL_RX = /(url\()([^)]*)(\))/g;
  var URL_ATTRS = {
  '*': [
  'href',
  'src',
  'style',
  'url'
  ],
  form: ['action']
  };
  var BINDING_RX = /\{\{|\[\[/;
  Polymer.ResolveUrl = {
  resolveCss: resolveCss,
  resolveAttrs: resolveAttrs,
  resolveUrl: resolveUrl
  };
  }());
  Polymer.Base._addFeature({
  _prepAnnotations: function () {
  if (!this._template) {
  this._notes = [];
  } else {
a1a3bc73   Luigi Serra   graphs updates
282
283
284
285
  var self = this;
  Polymer.Annotations.prepElement = function (element) {
  self._prepElement(element);
  };
73bcce88   luigser   COMPONENTS
286
287
288
289
290
291
292
293
294
295
296
297
298
299
  if (this._template._content && this._template._content._notes) {
  this._notes = this._template._content._notes;
  } else {
  this._notes = Polymer.Annotations.parseAnnotations(this._template);
  }
  this._processAnnotations(this._notes);
  Polymer.Annotations.prepElement = null;
  }
  },
  _processAnnotations: function (notes) {
  for (var i = 0; i < notes.length; i++) {
  var note = notes[i];
  for (var j = 0; j < note.bindings.length; j++) {
  var b = note.bindings[j];
f748e9cf   Luigi Serra   new controllet an...
300
301
302
303
304
305
306
307
  for (var k = 0; k < b.parts.length; k++) {
  var p = b.parts[k];
  if (!p.literal) {
  p.signature = this._parseMethod(p.value);
  if (!p.signature) {
  p.model = this._modelForPath(p.value);
  }
  }
73bcce88   luigser   COMPONENTS
308
309
310
311
312
313
314
315
316
317
  }
  }
  if (note.templateContent) {
  this._processAnnotations(note.templateContent._notes);
  var pp = note.templateContent._parentProps = this._discoverTemplateParentProps(note.templateContent._notes);
  var bindings = [];
  for (var prop in pp) {
  bindings.push({
  index: note.index,
  kind: 'property',
73bcce88   luigser   COMPONENTS
318
  name: '_parent_' + prop,
f748e9cf   Luigi Serra   new controllet an...
319
320
  parts: [{
  mode: '{',
73bcce88   luigser   COMPONENTS
321
322
  model: prop,
  value: prop
f748e9cf   Luigi Serra   new controllet an...
323
  }]
73bcce88   luigser   COMPONENTS
324
325
326
327
328
329
330
331
  });
  }
  note.bindings = note.bindings.concat(bindings);
  }
  }
  },
  _discoverTemplateParentProps: function (notes) {
  var pp = {};
a1a3bc73   Luigi Serra   graphs updates
332
333
334
  for (var i = 0, n; i < notes.length && (n = notes[i]); i++) {
  for (var j = 0, b$ = n.bindings, b; j < b$.length && (b = b$[j]); j++) {
  for (var k = 0, p$ = b.parts, p; k < p$.length && (p = p$[k]); k++) {
f748e9cf   Luigi Serra   new controllet an...
335
336
  if (p.signature) {
  var args = p.signature.args;
a1a3bc73   Luigi Serra   graphs updates
337
338
  for (var kk = 0; kk < args.length; kk++) {
  pp[args[kk].model] = true;
73bcce88   luigser   COMPONENTS
339
340
  }
  } else {
f748e9cf   Luigi Serra   new controllet an...
341
  pp[p.model] = true;
73bcce88   luigser   COMPONENTS
342
  }
a1a3bc73   Luigi Serra   graphs updates
343
344
  }
  }
73bcce88   luigser   COMPONENTS
345
346
347
348
  if (n.templateContent) {
  var tpp = n.templateContent._parentProps;
  Polymer.Base.mixin(pp, tpp);
  }
a1a3bc73   Luigi Serra   graphs updates
349
  }
73bcce88   luigser   COMPONENTS
350
351
352
353
354
355
356
357
358
359
360
361
362
  return pp;
  },
  _prepElement: function (element) {
  Polymer.ResolveUrl.resolveAttrs(element, this._template.ownerDocument);
  },
  _findAnnotatedNode: Polymer.Annotations.findAnnotatedNode,
  _marshalAnnotationReferences: function () {
  if (this._template) {
  this._marshalIdNodes();
  this._marshalAnnotatedNodes();
  this._marshalAnnotatedListeners();
  }
  },
f748e9cf   Luigi Serra   new controllet an...
363
364
365
366
367
368
369
370
371
  _configureAnnotationReferences: function (config) {
  var notes = this._notes;
  var nodes = this._nodes;
  for (var i = 0; i < notes.length; i++) {
  var note = notes[i];
  var node = nodes[i];
  this._configureTemplateContent(note, node);
  this._configureCompoundBindings(note, node);
  }
73bcce88   luigser   COMPONENTS
372
  },
f748e9cf   Luigi Serra   new controllet an...
373
  _configureTemplateContent: function (note, node) {
73bcce88   luigser   COMPONENTS
374
  if (note.templateContent) {
f748e9cf   Luigi Serra   new controllet an...
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
  node._content = note.templateContent;
  }
  },
  _configureCompoundBindings: function (note, node) {
  var bindings = note.bindings;
  for (var i = 0; i < bindings.length; i++) {
  var binding = bindings[i];
  if (binding.isCompound) {
  var storage = node.__compoundStorage__ || (node.__compoundStorage__ = {});
  var parts = binding.parts;
  var literals = new Array(parts.length);
  for (var j = 0; j < parts.length; j++) {
  literals[j] = parts[j].literal;
  }
  var name = binding.name;
  storage[name] = literals;
  if (binding.literal && binding.kind == 'property') {
  if (node._configValue) {
  node._configValue(name, binding.literal);
  } else {
  node[name] = binding.literal;
  }
  }
  }
73bcce88   luigser   COMPONENTS
399
  }
73bcce88   luigser   COMPONENTS
400
401
402
  },
  _marshalIdNodes: function () {
  this.$ = {};
a1a3bc73   Luigi Serra   graphs updates
403
  for (var i = 0, l = this._notes.length, a; i < l && (a = this._notes[i]); i++) {
73bcce88   luigser   COMPONENTS
404
405
406
  if (a.id) {
  this.$[a.id] = this._findAnnotatedNode(this.root, a);
  }
a1a3bc73   Luigi Serra   graphs updates
407
  }
73bcce88   luigser   COMPONENTS
408
409
  },
  _marshalAnnotatedNodes: function () {
a1a3bc73   Luigi Serra   graphs updates
410
411
412
413
414
415
  if (this._notes && this._notes.length) {
  var r = new Array(this._notes.length);
  for (var i = 0; i < this._notes.length; i++) {
  r[i] = this._findAnnotatedNode(this.root, this._notes[i]);
  }
  this._nodes = r;
73bcce88   luigser   COMPONENTS
416
417
418
  }
  },
  _marshalAnnotatedListeners: function () {
a1a3bc73   Luigi Serra   graphs updates
419
  for (var i = 0, l = this._notes.length, a; i < l && (a = this._notes[i]); i++) {
73bcce88   luigser   COMPONENTS
420
421
  if (a.events && a.events.length) {
  var node = this._findAnnotatedNode(this.root, a);
a1a3bc73   Luigi Serra   graphs updates
422
  for (var j = 0, e$ = a.events, e; j < e$.length && (e = e$[j]); j++) {
73bcce88   luigser   COMPONENTS
423
  this.listen(node, e.name, e.value);
73bcce88   luigser   COMPONENTS
424
  }
a1a3bc73   Luigi Serra   graphs updates
425
426
  }
  }
73bcce88   luigser   COMPONENTS
427
428
429
430
431
  }
  });
  Polymer.Base._addFeature({
  listeners: {},
  _listenListeners: function (listeners) {
a1a3bc73   Luigi Serra   graphs updates
432
433
434
  var node, name, eventName;
  for (eventName in listeners) {
  if (eventName.indexOf('.') < 0) {
73bcce88   luigser   COMPONENTS
435
  node = this;
a1a3bc73   Luigi Serra   graphs updates
436
  name = eventName;
73bcce88   luigser   COMPONENTS
437
  } else {
a1a3bc73   Luigi Serra   graphs updates
438
  name = eventName.split('.');
73bcce88   luigser   COMPONENTS
439
440
441
  node = this.$[name[0]];
  name = name[1];
  }
a1a3bc73   Luigi Serra   graphs updates
442
  this.listen(node, name, listeners[eventName]);
73bcce88   luigser   COMPONENTS
443
444
445
  }
  },
  listen: function (node, eventName, methodName) {
eb240478   Luigi Serra   public room cards...
446
447
448
449
450
451
452
453
454
  var handler = this._recallEventHandler(this, eventName, node, methodName);
  if (!handler) {
  handler = this._createEventHandler(node, eventName, methodName);
  }
  if (handler._listening) {
  return;
  }
  this._listen(node, eventName, handler);
  handler._listening = true;
73bcce88   luigser   COMPONENTS
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
  },
  _boundListenerKey: function (eventName, methodName) {
  return eventName + ':' + methodName;
  },
  _recordEventHandler: function (host, eventName, target, methodName, handler) {
  var hbl = host.__boundListeners;
  if (!hbl) {
  hbl = host.__boundListeners = new WeakMap();
  }
  var bl = hbl.get(target);
  if (!bl) {
  bl = {};
  hbl.set(target, bl);
  }
  var key = this._boundListenerKey(eventName, methodName);
  bl[key] = handler;
  },
  _recallEventHandler: function (host, eventName, target, methodName) {
  var hbl = host.__boundListeners;
  if (!hbl) {
  return;
  }
  var bl = hbl.get(target);
  if (!bl) {
  return;
  }
  var key = this._boundListenerKey(eventName, methodName);
  return bl[key];
  },
  _createEventHandler: function (node, eventName, methodName) {
  var host = this;
  var handler = function (e) {
  if (host[methodName]) {
  host[methodName](e, e.detail);
  } else {
  host._warn(host._logf('_createEventHandler', 'listener method `' + methodName + '` not defined'));
  }
  };
eb240478   Luigi Serra   public room cards...
493
  handler._listening = false;
73bcce88   luigser   COMPONENTS
494
495
496
497
498
499
500
  this._recordEventHandler(host, eventName, node, methodName, handler);
  return handler;
  },
  unlisten: function (node, eventName, methodName) {
  var handler = this._recallEventHandler(this, eventName, node, methodName);
  if (handler) {
  this._unlisten(node, eventName, handler);
eb240478   Luigi Serra   public room cards...
501
  handler._listening = false;
73bcce88   luigser   COMPONENTS
502
503
504
505
506
507
508
509
510
511
512
  }
  },
  _listen: function (node, eventName, handler) {
  node.addEventListener(eventName, handler);
  },
  _unlisten: function (node, eventName, handler) {
  node.removeEventListener(eventName, handler);
  }
  });
  (function () {
  'use strict';
a1a3bc73   Luigi Serra   graphs updates
513
  var wrap = Polymer.DomApi.wrap;
73bcce88   luigser   COMPONENTS
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
  var HAS_NATIVE_TA = typeof document.head.style.touchAction === 'string';
  var GESTURE_KEY = '__polymerGestures';
  var HANDLED_OBJ = '__polymerGesturesHandled';
  var TOUCH_ACTION = '__polymerGesturesTouchAction';
  var TAP_DISTANCE = 25;
  var TRACK_DISTANCE = 5;
  var TRACK_LENGTH = 2;
  var MOUSE_TIMEOUT = 2500;
  var MOUSE_EVENTS = [
  'mousedown',
  'mousemove',
  'mouseup',
  'click'
  ];
  var MOUSE_WHICH_TO_BUTTONS = [
  0,
  1,
  4,
  2
  ];
  var MOUSE_HAS_BUTTONS = function () {
  try {
  return new MouseEvent('test', { buttons: 1 }).buttons === 1;
  } catch (e) {
  return false;
  }
  }();
  var IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/);
  var mouseCanceller = function (mouseEvent) {
  mouseEvent[HANDLED_OBJ] = { skip: true };
  if (mouseEvent.type === 'click') {
  var path = Polymer.dom(mouseEvent).path;
  for (var i = 0; i < path.length; i++) {
  if (path[i] === POINTERSTATE.mouse.target) {
  return;
  }
  }
  mouseEvent.preventDefault();
  mouseEvent.stopPropagation();
  }
  };
  function setupTeardownMouseCanceller(setup) {
  for (var i = 0, en; i < MOUSE_EVENTS.length; i++) {
  en = MOUSE_EVENTS[i];
  if (setup) {
  document.addEventListener(en, mouseCanceller, true);
  } else {
  document.removeEventListener(en, mouseCanceller, true);
  }
  }
  }
  function ignoreMouse() {
  if (IS_TOUCH_ONLY) {
  return;
  }
  if (!POINTERSTATE.mouse.mouseIgnoreJob) {
  setupTeardownMouseCanceller(true);
  }
  var unset = function () {
  setupTeardownMouseCanceller();
  POINTERSTATE.mouse.target = null;
  POINTERSTATE.mouse.mouseIgnoreJob = null;
  };
  POINTERSTATE.mouse.mouseIgnoreJob = Polymer.Debounce(POINTERSTATE.mouse.mouseIgnoreJob, unset, MOUSE_TIMEOUT);
  }
  function hasLeftMouseButton(ev) {
  var type = ev.type;
  if (MOUSE_EVENTS.indexOf(type) === -1) {
  return false;
  }
  if (type === 'mousemove') {
  var buttons = ev.buttons === undefined ? 1 : ev.buttons;
  if (ev instanceof window.MouseEvent && !MOUSE_HAS_BUTTONS) {
  buttons = MOUSE_WHICH_TO_BUTTONS[ev.which] || 0;
  }
  return Boolean(buttons & 1);
  } else {
  var button = ev.button === undefined ? 0 : ev.button;
  return button === 0;
  }
  }
  function isSyntheticClick(ev) {
  if (ev.type === 'click') {
  if (ev.detail === 0) {
  return true;
  }
  var t = Gestures.findOriginalTarget(ev);
  var bcr = t.getBoundingClientRect();
  var x = ev.pageX, y = ev.pageY;
  return !(x >= bcr.left && x <= bcr.right && (y >= bcr.top && y <= bcr.bottom));
  }
  return false;
  }
  var POINTERSTATE = {
  mouse: {
  target: null,
  mouseIgnoreJob: null
  },
  touch: {
  x: 0,
  y: 0,
  id: -1,
  scrollDecided: false
  }
  };
  function firstTouchAction(ev) {
  var path = Polymer.dom(ev).path;
  var ta = 'auto';
  for (var i = 0, n; i < path.length; i++) {
  n = path[i];
  if (n[TOUCH_ACTION]) {
  ta = n[TOUCH_ACTION];
  break;
  }
  }
  return ta;
  }
  function trackDocument(stateObj, movefn, upfn) {
  stateObj.movefn = movefn;
  stateObj.upfn = upfn;
  document.addEventListener('mousemove', movefn);
  document.addEventListener('mouseup', upfn);
  }
  function untrackDocument(stateObj) {
  document.removeEventListener('mousemove', stateObj.movefn);
  document.removeEventListener('mouseup', stateObj.upfn);
  }
  var Gestures = {
  gestures: {},
  recognizers: [],
  deepTargetFind: function (x, y) {
  var node = document.elementFromPoint(x, y);
  var next = node;
  while (next && next.shadowRoot) {
  next = next.shadowRoot.elementFromPoint(x, y);
  if (next) {
  node = next;
  }
  }
  return node;
  },
  findOriginalTarget: function (ev) {
  if (ev.path) {
  return ev.path[0];
  }
  return ev.target;
  },
  handleNative: function (ev) {
  var handled;
  var type = ev.type;
a1a3bc73   Luigi Serra   graphs updates
664
  var node = wrap(ev.currentTarget);
73bcce88   luigser   COMPONENTS
665
  var gobj = node[GESTURE_KEY];
a1a3bc73   Luigi Serra   graphs updates
666
667
668
  if (!gobj) {
  return;
  }
73bcce88   luigser   COMPONENTS
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
  var gs = gobj[type];
  if (!gs) {
  return;
  }
  if (!ev[HANDLED_OBJ]) {
  ev[HANDLED_OBJ] = {};
  if (type.slice(0, 5) === 'touch') {
  var t = ev.changedTouches[0];
  if (type === 'touchstart') {
  if (ev.touches.length === 1) {
  POINTERSTATE.touch.id = t.identifier;
  }
  }
  if (POINTERSTATE.touch.id !== t.identifier) {
  return;
  }
  if (!HAS_NATIVE_TA) {
  if (type === 'touchstart' || type === 'touchmove') {
  Gestures.handleTouchAction(ev);
  }
  }
  if (type === 'touchend') {
  POINTERSTATE.mouse.target = Polymer.dom(ev).rootTarget;
  ignoreMouse(true);
  }
  }
  }
  handled = ev[HANDLED_OBJ];
  if (handled.skip) {
  return;
  }
  var recognizers = Gestures.recognizers;
  for (var i = 0, r; i < recognizers.length; i++) {
  r = recognizers[i];
  if (gs[r.name] && !handled[r.name]) {
  if (r.flow && r.flow.start.indexOf(ev.type) > -1) {
  if (r.reset) {
  r.reset();
  }
  }
  }
  }
  for (var i = 0, r; i < recognizers.length; i++) {
  r = recognizers[i];
  if (gs[r.name] && !handled[r.name]) {
  handled[r.name] = true;
  r[type](ev);
  }
  }
  },
  handleTouchAction: function (ev) {
  var t = ev.changedTouches[0];
  var type = ev.type;
  if (type === 'touchstart') {
  POINTERSTATE.touch.x = t.clientX;
  POINTERSTATE.touch.y = t.clientY;
  POINTERSTATE.touch.scrollDecided = false;
  } else if (type === 'touchmove') {
  if (POINTERSTATE.touch.scrollDecided) {
  return;
  }
  POINTERSTATE.touch.scrollDecided = true;
  var ta = firstTouchAction(ev);
  var prevent = false;
  var dx = Math.abs(POINTERSTATE.touch.x - t.clientX);
  var dy = Math.abs(POINTERSTATE.touch.y - t.clientY);
  if (!ev.cancelable) {
  } else if (ta === 'none') {
  prevent = true;
  } else if (ta === 'pan-x') {
  prevent = dy > dx;
  } else if (ta === 'pan-y') {
  prevent = dx > dy;
  }
  if (prevent) {
  ev.preventDefault();
  } else {
  Gestures.prevent('track');
  }
  }
  },
  add: function (node, evType, handler) {
a1a3bc73   Luigi Serra   graphs updates
751
  node = wrap(node);
73bcce88   luigser   COMPONENTS
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
  var recognizer = this.gestures[evType];
  var deps = recognizer.deps;
  var name = recognizer.name;
  var gobj = node[GESTURE_KEY];
  if (!gobj) {
  node[GESTURE_KEY] = gobj = {};
  }
  for (var i = 0, dep, gd; i < deps.length; i++) {
  dep = deps[i];
  if (IS_TOUCH_ONLY && MOUSE_EVENTS.indexOf(dep) > -1) {
  continue;
  }
  gd = gobj[dep];
  if (!gd) {
  gobj[dep] = gd = { _count: 0 };
  }
  if (gd._count === 0) {
  node.addEventListener(dep, this.handleNative);
  }
  gd[name] = (gd[name] || 0) + 1;
  gd._count = (gd._count || 0) + 1;
  }
  node.addEventListener(evType, handler);
  if (recognizer.touchAction) {
  this.setTouchAction(node, recognizer.touchAction);
  }
  },
  remove: function (node, evType, handler) {
a1a3bc73   Luigi Serra   graphs updates
780
  node = wrap(node);
73bcce88   luigser   COMPONENTS
781
782
783
784
785
786
787
788
789
790
791
  var recognizer = this.gestures[evType];
  var deps = recognizer.deps;
  var name = recognizer.name;
  var gobj = node[GESTURE_KEY];
  if (gobj) {
  for (var i = 0, dep, gd; i < deps.length; i++) {
  dep = deps[i];
  gd = gobj[dep];
  if (gd && gd[name]) {
  gd[name] = (gd[name] || 1) - 1;
  gd._count = (gd._count || 1) - 1;
73bcce88   luigser   COMPONENTS
792
793
794
795
796
  if (gd._count === 0) {
  node.removeEventListener(dep, this.handleNative);
  }
  }
  }
e619a3b0   Luigi Serra   Controllet cross ...
797
  }
73bcce88   luigser   COMPONENTS
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
  node.removeEventListener(evType, handler);
  },
  register: function (recog) {
  this.recognizers.push(recog);
  for (var i = 0; i < recog.emits.length; i++) {
  this.gestures[recog.emits[i]] = recog;
  }
  },
  findRecognizerByEvent: function (evName) {
  for (var i = 0, r; i < this.recognizers.length; i++) {
  r = this.recognizers[i];
  for (var j = 0, n; j < r.emits.length; j++) {
  n = r.emits[j];
  if (n === evName) {
  return r;
  }
  }
  }
  return null;
  },
  setTouchAction: function (node, value) {
  if (HAS_NATIVE_TA) {
  node.style.touchAction = value;
  }
  node[TOUCH_ACTION] = value;
  },
  fire: function (target, type, detail) {
  var ev = Polymer.Base.fire(type, detail, {
  node: target,
  bubbles: true,
  cancelable: true
  });
  if (ev.defaultPrevented) {
  var se = detail.sourceEvent;
  if (se && se.preventDefault) {
  se.preventDefault();
  }
  }
  },
  prevent: function (evName) {
  var recognizer = this.findRecognizerByEvent(evName);
  if (recognizer.info) {
  recognizer.info.prevent = true;
  }
  }
  };
  Gestures.register({
  name: 'downup',
  deps: [
  'mousedown',
  'touchstart',
  'touchend'
  ],
  flow: {
  start: [
  'mousedown',
  'touchstart'
  ],
  end: [
  'mouseup',
  'touchend'
  ]
  },
  emits: [
  'down',
  'up'
  ],
  info: {
  movefn: function () {
  },
  upfn: function () {
  }
  },
  reset: function () {
  untrackDocument(this.info);
  },
  mousedown: function (e) {
  if (!hasLeftMouseButton(e)) {
  return;
  }
  var t = Gestures.findOriginalTarget(e);
  var self = this;
  var movefn = function movefn(e) {
  if (!hasLeftMouseButton(e)) {
  self.fire('up', t, e);
  untrackDocument(self.info);
  }
  };
  var upfn = function upfn(e) {
  if (hasLeftMouseButton(e)) {
  self.fire('up', t, e);
  }
  untrackDocument(self.info);
  };
  trackDocument(this.info, movefn, upfn);
  this.fire('down', t, e);
  },
  touchstart: function (e) {
  this.fire('down', Gestures.findOriginalTarget(e), e.changedTouches[0]);
  },
  touchend: function (e) {
  this.fire('up', Gestures.findOriginalTarget(e), e.changedTouches[0]);
  },
  fire: function (type, target, event) {
  var self = this;
  Gestures.fire(target, type, {
  x: event.clientX,
  y: event.clientY,
  sourceEvent: event,
a1a3bc73   Luigi Serra   graphs updates
907
908
909
  prevent: function (e) {
  return Gestures.prevent(e);
  }
73bcce88   luigser   COMPONENTS
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
  });
  }
  });
  Gestures.register({
  name: 'track',
  touchAction: 'none',
  deps: [
  'mousedown',
  'touchstart',
  'touchmove',
  'touchend'
  ],
  flow: {
  start: [
  'mousedown',
  'touchstart'
  ],
  end: [
  'mouseup',
  'touchend'
  ]
  },
  emits: ['track'],
  info: {
  x: 0,
  y: 0,
  state: 'start',
  started: false,
  moves: [],
  addMove: function (move) {
  if (this.moves.length > TRACK_LENGTH) {
  this.moves.shift();
  }
  this.moves.push(move);
  },
  movefn: function () {
  },
  upfn: function () {
  },
  prevent: false
  },
  reset: function () {
  this.info.state = 'start';
  this.info.started = false;
  this.info.moves = [];
  this.info.x = 0;
  this.info.y = 0;
  this.info.prevent = false;
  untrackDocument(this.info);
  },
  hasMovedEnough: function (x, y) {
  if (this.info.prevent) {
  return false;
  }
  if (this.info.started) {
  return true;
  }
  var dx = Math.abs(this.info.x - x);
  var dy = Math.abs(this.info.y - y);
  return dx >= TRACK_DISTANCE || dy >= TRACK_DISTANCE;
  },
  mousedown: function (e) {
  if (!hasLeftMouseButton(e)) {
  return;
  }
  var t = Gestures.findOriginalTarget(e);
  var self = this;
  var movefn = function movefn(e) {
  var x = e.clientX, y = e.clientY;
  if (self.hasMovedEnough(x, y)) {
  self.info.state = self.info.started ? e.type === 'mouseup' ? 'end' : 'track' : 'start';
  self.info.addMove({
  x: x,
  y: y
  });
  if (!hasLeftMouseButton(e)) {
  self.info.state = 'end';
  untrackDocument(self.info);
  }
  self.fire(t, e);
  self.info.started = true;
  }
  };
  var upfn = function upfn(e) {
  if (self.info.started) {
  Gestures.prevent('tap');
  movefn(e);
  }
  untrackDocument(self.info);
  };
  trackDocument(this.info, movefn, upfn);
  this.info.x = e.clientX;
  this.info.y = e.clientY;
  },
  touchstart: function (e) {
  var ct = e.changedTouches[0];
  this.info.x = ct.clientX;
  this.info.y = ct.clientY;
  },
  touchmove: function (e) {
  var t = Gestures.findOriginalTarget(e);
  var ct = e.changedTouches[0];
  var x = ct.clientX, y = ct.clientY;
  if (this.hasMovedEnough(x, y)) {
  this.info.addMove({
  x: x,
  y: y
  });
  this.fire(t, ct);
  this.info.state = 'track';
  this.info.started = true;
  }
  },
  touchend: function (e) {
  var t = Gestures.findOriginalTarget(e);
  var ct = e.changedTouches[0];
  if (this.info.started) {
  Gestures.prevent('tap');
  this.info.state = 'end';
  this.info.addMove({
  x: ct.clientX,
  y: ct.clientY
  });
  this.fire(t, ct);
  }
  },
  fire: function (target, touch) {
  var secondlast = this.info.moves[this.info.moves.length - 2];
  var lastmove = this.info.moves[this.info.moves.length - 1];
  var dx = lastmove.x - this.info.x;
  var dy = lastmove.y - this.info.y;
  var ddx, ddy = 0;
  if (secondlast) {
  ddx = lastmove.x - secondlast.x;
  ddy = lastmove.y - secondlast.y;
  }
  return Gestures.fire(target, 'track', {
  state: this.info.state,
  x: touch.clientX,
  y: touch.clientY,
  dx: dx,
  dy: dy,
  ddx: ddx,
  ddy: ddy,
  sourceEvent: touch,
  hover: function () {
  return Gestures.deepTargetFind(touch.clientX, touch.clientY);
  }
  });
  }
  });
  Gestures.register({
  name: 'tap',
  deps: [
  'mousedown',
  'click',
  'touchstart',
  'touchend'
  ],
  flow: {
  start: [
  'mousedown',
  'touchstart'
  ],
  end: [
  'click',
  'touchend'
  ]
  },
  emits: ['tap'],
  info: {
  x: NaN,
  y: NaN,
  prevent: false
  },
  reset: function () {
  this.info.x = NaN;
  this.info.y = NaN;
  this.info.prevent = false;
  },
  save: function (e) {
  this.info.x = e.clientX;
  this.info.y = e.clientY;
  },
  mousedown: function (e) {
  if (hasLeftMouseButton(e)) {
  this.save(e);
  }
  },
  click: function (e) {
  if (hasLeftMouseButton(e)) {
  this.forward(e);
  }
  },
  touchstart: function (e) {
  this.save(e.changedTouches[0]);
  },
  touchend: function (e) {
  this.forward(e.changedTouches[0]);
  },
  forward: function (e) {
  var dx = Math.abs(e.clientX - this.info.x);
  var dy = Math.abs(e.clientY - this.info.y);
  var t = Gestures.findOriginalTarget(e);
  if (isNaN(dx) || isNaN(dy) || dx <= TAP_DISTANCE && dy <= TAP_DISTANCE || isSyntheticClick(e)) {
  if (!this.info.prevent) {
  Gestures.fire(t, 'tap', {
  x: e.clientX,
  y: e.clientY,
  sourceEvent: e
  });
  }
  }
  }
  });
  var DIRECTION_MAP = {
  x: 'pan-x',
  y: 'pan-y',
  none: 'none',
  all: 'auto'
  };
  Polymer.Base._addFeature({
  _listen: function (node, eventName, handler) {
  if (Gestures.gestures[eventName]) {
  Gestures.add(node, eventName, handler);
  } else {
  node.addEventListener(eventName, handler);
  }
  },
  _unlisten: function (node, eventName, handler) {
  if (Gestures.gestures[eventName]) {
  Gestures.remove(node, eventName, handler);
  } else {
  node.removeEventListener(eventName, handler);
  }
  },
  setScrollDirection: function (direction, node) {
  node = node || this;
  Gestures.setTouchAction(node, DIRECTION_MAP[direction] || 'auto');
  }
  });
  Polymer.Gestures = Gestures;
  }());
  Polymer.Async = {
  _currVal: 0,
  _lastVal: 0,
  _callbacks: [],
  _twiddleContent: 0,
  _twiddle: document.createTextNode(''),
  run: function (callback, waitTime) {
  if (waitTime > 0) {
  return ~setTimeout(callback, waitTime);
  } else {
  this._twiddle.textContent = this._twiddleContent++;
  this._callbacks.push(callback);
  return this._currVal++;
  }
  },
  cancel: function (handle) {
  if (handle < 0) {
  clearTimeout(~handle);
  } else {
  var idx = handle - this._lastVal;
  if (idx >= 0) {
  if (!this._callbacks[idx]) {
  throw 'invalid async handle: ' + handle;
  }
  this._callbacks[idx] = null;
  }
  }
  },
  _atEndOfMicrotask: function () {
  var len = this._callbacks.length;
  for (var i = 0; i < len; i++) {
  var cb = this._callbacks[i];
  if (cb) {
  try {
  cb();
  } catch (e) {
  i++;
  this._callbacks.splice(0, i);
  this._lastVal += i;
  this._twiddle.textContent = this._twiddleContent++;
  throw e;
  }
  }
  }
  this._callbacks.splice(0, len);
  this._lastVal += len;
  }
  };
f748e9cf   Luigi Serra   new controllet an...
1201
1202
1203
  new window.MutationObserver(function () {
  Polymer.Async._atEndOfMicrotask();
  }).observe(Polymer.Async._twiddle, { characterData: true });
73bcce88   luigser   COMPONENTS
1204
1205
1206
1207
  Polymer.Debounce = function () {
  var Async = Polymer.Async;
  var Debouncer = function (context) {
  this.context = context;
a1a3bc73   Luigi Serra   graphs updates
1208
1209
1210
1211
  var self = this;
  this.boundComplete = function () {
  self.complete();
  };
73bcce88   luigser   COMPONENTS
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
  };
  Debouncer.prototype = {
  go: function (callback, wait) {
  var h;
  this.finish = function () {
  Async.cancel(h);
  };
  h = Async.run(this.boundComplete, wait);
  this.callback = callback;
  },
  stop: function () {
  if (this.finish) {
  this.finish();
  this.finish = null;
  }
  },
  complete: function () {
  if (this.finish) {
  this.stop();
  this.callback.call(this.context);
  }
  }
  };
  function debounce(debouncer, callback, wait) {
  if (debouncer) {
  debouncer.stop();
  } else {
  debouncer = new Debouncer(this);
  }
  debouncer.go(callback, wait);
  return debouncer;
  }
  return debounce;
  }();
  Polymer.Base._addFeature({
  $$: function (slctr) {
  return Polymer.dom(this.root).querySelector(slctr);
  },
  toggleClass: function (name, bool, node) {
  node = node || this;
  if (arguments.length == 1) {
  bool = !node.classList.contains(name);
  }
  if (bool) {
  Polymer.dom(node).classList.add(name);
  } else {
  Polymer.dom(node).classList.remove(name);
  }
  },
  toggleAttribute: function (name, bool, node) {
  node = node || this;
  if (arguments.length == 1) {
  bool = !node.hasAttribute(name);
  }
  if (bool) {
  Polymer.dom(node).setAttribute(name, '');
  } else {
  Polymer.dom(node).removeAttribute(name);
  }
  },
  classFollows: function (name, toElement, fromElement) {
  if (fromElement) {
  Polymer.dom(fromElement).classList.remove(name);
  }
  if (toElement) {
  Polymer.dom(toElement).classList.add(name);
  }
  },
  attributeFollows: function (name, toElement, fromElement) {
  if (fromElement) {
  Polymer.dom(fromElement).removeAttribute(name);
  }
  if (toElement) {
  Polymer.dom(toElement).setAttribute(name, '');
  }
  },
f748e9cf   Luigi Serra   new controllet an...
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
  getEffectiveChildNodes: function () {
  return Polymer.dom(this).getEffectiveChildNodes();
  },
  getEffectiveChildren: function () {
  var list = Polymer.dom(this).getEffectiveChildNodes();
  return list.filter(function (n) {
  return n.nodeType === Node.ELEMENT_NODE;
  });
  },
  getEffectiveTextContent: function () {
  var cn = this.getEffectiveChildNodes();
  var tc = [];
  for (var i = 0, c; c = cn[i]; i++) {
  if (c.nodeType !== Node.COMMENT_NODE) {
  tc.push(Polymer.dom(c).textContent);
  }
  }
  return tc.join('');
  },
  queryEffectiveChildren: function (slctr) {
  var e$ = Polymer.dom(this).queryDistributedElements(slctr);
  return e$ && e$[0];
  },
  queryAllEffectiveChildren: function (slctr) {
a1a3bc73   Luigi Serra   graphs updates
1312
  return Polymer.dom(this).queryDistributedElements(slctr);
f748e9cf   Luigi Serra   new controllet an...
1313
  },
73bcce88   luigser   COMPONENTS
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
  getContentChildNodes: function (slctr) {
  var content = Polymer.dom(this.root).querySelector(slctr || 'content');
  return content ? Polymer.dom(content).getDistributedNodes() : [];
  },
  getContentChildren: function (slctr) {
  return this.getContentChildNodes(slctr).filter(function (n) {
  return n.nodeType === Node.ELEMENT_NODE;
  });
  },
  fire: function (type, detail, options) {
  options = options || Polymer.nob;
  var node = options.node || this;
a1a3bc73   Luigi Serra   graphs updates
1326
  var detail = detail === null || detail === undefined ? {} : detail;
73bcce88   luigser   COMPONENTS
1327
1328
  var bubbles = options.bubbles === undefined ? true : options.bubbles;
  var cancelable = Boolean(options.cancelable);
a1a3bc73   Luigi Serra   graphs updates
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
  var useCache = options._useCache;
  var event = this._getEvent(type, bubbles, cancelable, useCache);
  event.detail = detail;
  if (useCache) {
  this.__eventCache[type] = null;
  }
  node.dispatchEvent(event);
  if (useCache) {
  this.__eventCache[type] = event;
  }
  return event;
  },
  __eventCache: {},
  _getEvent: function (type, bubbles, cancelable, useCache) {
  var event = useCache && this.__eventCache[type];
  if (!event || (event.bubbles != bubbles || event.cancelable != cancelable)) {
  event = new Event(type, {
73bcce88   luigser   COMPONENTS
1346
  bubbles: Boolean(bubbles),
a1a3bc73   Luigi Serra   graphs updates
1347
  cancelable: cancelable
73bcce88   luigser   COMPONENTS
1348
  });
a1a3bc73   Luigi Serra   graphs updates
1349
  }
73bcce88   luigser   COMPONENTS
1350
1351
1352
  return event;
  },
  async: function (callback, waitTime) {
a1a3bc73   Luigi Serra   graphs updates
1353
1354
1355
1356
  var self = this;
  return Polymer.Async.run(function () {
  callback.call(self);
  }, waitTime);
73bcce88   luigser   COMPONENTS
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
  },
  cancelAsync: function (handle) {
  Polymer.Async.cancel(handle);
  },
  arrayDelete: function (path, item) {
  var index;
  if (Array.isArray(path)) {
  index = path.indexOf(item);
  if (index >= 0) {
  return path.splice(index, 1);
  }
  } else {
f748e9cf   Luigi Serra   new controllet an...
1369
  var arr = this._get(path);
73bcce88   luigser   COMPONENTS
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
  index = arr.indexOf(item);
  if (index >= 0) {
  return this.splice(path, index, 1);
  }
  }
  },
  transform: function (transform, node) {
  node = node || this;
  node.style.webkitTransform = transform;
  node.style.transform = transform;
  },
  translate3d: function (x, y, z, node) {
  node = node || this;
  this.transform('translate3d(' + x + ',' + y + ',' + z + ')', node);
  },
  importHref: function (href, onload, onerror) {
  var l = document.createElement('link');
  l.rel = 'import';
  l.href = href;
a1a3bc73   Luigi Serra   graphs updates
1389
  var self = this;
73bcce88   luigser   COMPONENTS
1390
  if (onload) {
a1a3bc73   Luigi Serra   graphs updates
1391
1392
1393
  l.onload = function (e) {
  return onload.call(self, e);
  };
73bcce88   luigser   COMPONENTS
1394
1395
  }
  if (onerror) {
a1a3bc73   Luigi Serra   graphs updates
1396
1397
1398
  l.onerror = function (e) {
  return onerror.call(self, e);
  };
73bcce88   luigser   COMPONENTS
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
  }
  document.head.appendChild(l);
  return l;
  },
  create: function (tag, props) {
  var elt = document.createElement(tag);
  if (props) {
  for (var n in props) {
  elt[n] = props[n];
  }
  }
  return elt;
eb240478   Luigi Serra   public room cards...
1411
1412
  },
  isLightDescendant: function (node) {
a1a3bc73   Luigi Serra   graphs updates
1413
  return this !== node && this.contains(node) && Polymer.dom(this).getOwnerRoot() === Polymer.dom(node).getOwnerRoot();
eb240478   Luigi Serra   public room cards...
1414
1415
1416
  },
  isLocalDescendant: function (node) {
  return this.root === Polymer.dom(node).getOwnerRoot();
73bcce88   luigser   COMPONENTS
1417
1418
1419
  }
  });
  Polymer.Bind = {
a1a3bc73   Luigi Serra   graphs updates
1420
  _dataEventCache: {},
73bcce88   luigser   COMPONENTS
1421
  prepareModel: function (model) {
73bcce88   luigser   COMPONENTS
1422
1423
1424
  Polymer.Base.mixin(model, this._modelApi);
  },
  _modelApi: {
a1a3bc73   Luigi Serra   graphs updates
1425
1426
1427
1428
  _notifyChange: function (source, event, value) {
  value = value === undefined ? this[source] : value;
  event = event || Polymer.CaseMap.camelToDashCase(source) + '-changed';
  this.fire(event, { value: value }, {
73bcce88   luigser   COMPONENTS
1429
  bubbles: false,
a1a3bc73   Luigi Serra   graphs updates
1430
1431
  cancelable: false,
  _useCache: true
73bcce88   luigser   COMPONENTS
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
  });
  },
  _propertySetter: function (property, value, effects, fromAbove) {
  var old = this.__data__[property];
  if (old !== value && (old === old || value === value)) {
  this.__data__[property] = value;
  if (typeof value == 'object') {
  this._clearPath(property);
  }
  if (this._propertyChanged) {
  this._propertyChanged(property, value, old);
  }
  if (effects) {
  this._effectEffects(property, value, effects, old, fromAbove);
  }
  }
  return old;
  },
  __setProperty: function (property, value, quiet, node) {
  node = node || this;
  var effects = node._propertyEffects && node._propertyEffects[property];
  if (effects) {
  node._propertySetter(property, value, effects, quiet);
  } else {
  node[property] = value;
  }
  },
  _effectEffects: function (property, value, effects, old, fromAbove) {
a1a3bc73   Luigi Serra   graphs updates
1460
1461
  for (var i = 0, l = effects.length, fx; i < l && (fx = effects[i]); i++) {
  fx.fn.call(this, property, value, fx.effect, old, fromAbove);
73bcce88   luigser   COMPONENTS
1462
  }
73bcce88   luigser   COMPONENTS
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
  },
  _clearPath: function (path) {
  for (var prop in this.__data__) {
  if (prop.indexOf(path + '.') === 0) {
  this.__data__[prop] = undefined;
  }
  }
  }
  },
  ensurePropertyEffects: function (model, property) {
a1a3bc73   Luigi Serra   graphs updates
1473
1474
1475
  if (!model._propertyEffects) {
  model._propertyEffects = {};
  }
73bcce88   luigser   COMPONENTS
1476
1477
1478
1479
1480
1481
1482
1483
  var fx = model._propertyEffects[property];
  if (!fx) {
  fx = model._propertyEffects[property] = [];
  }
  return fx;
  },
  addPropertyEffect: function (model, property, kind, effect) {
  var fx = this.ensurePropertyEffects(model, property);
a1a3bc73   Luigi Serra   graphs updates
1484
  var propEffect = {
73bcce88   luigser   COMPONENTS
1485
  kind: kind,
a1a3bc73   Luigi Serra   graphs updates
1486
1487
1488
1489
1490
  effect: effect,
  fn: Polymer.Bind['_' + kind + 'Effect']
  };
  fx.push(propEffect);
  return propEffect;
73bcce88   luigser   COMPONENTS
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
  },
  createBindings: function (model) {
  var fx$ = model._propertyEffects;
  if (fx$) {
  for (var n in fx$) {
  var fx = fx$[n];
  fx.sort(this._sortPropertyEffects);
  this._createAccessors(model, n, fx);
  }
  }
  },
  _sortPropertyEffects: function () {
  var EFFECT_ORDER = {
  'compute': 0,
  'annotation': 1,
  'computedAnnotation': 2,
  'reflect': 3,
  'notify': 4,
  'observer': 5,
  'complexObserver': 6,
  'function': 7
  };
  return function (a, b) {
  return EFFECT_ORDER[a.kind] - EFFECT_ORDER[b.kind];
  };
  }(),
  _createAccessors: function (model, property, effects) {
  var defun = {
  get: function () {
  return this.__data__[property];
  }
  };
  var setter = function (value) {
  this._propertySetter(property, value, effects);
  };
  var info = model.getPropertyInfo && model.getPropertyInfo(property);
  if (info && info.readOnly) {
  if (!info.computed) {
  model['_set' + this.upper(property)] = setter;
  }
  } else {
  defun.set = setter;
  }
  Object.defineProperty(model, property, defun);
  },
  upper: function (name) {
  return name[0].toUpperCase() + name.substring(1);
  },
  _addAnnotatedListener: function (model, index, property, path, event) {
a1a3bc73   Luigi Serra   graphs updates
1540
1541
1542
1543
  if (!model._bindListeners) {
  model._bindListeners = [];
  }
  var fn = this._notedListenerFactory(property, path, this._isStructured(path));
73bcce88   luigser   COMPONENTS
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
  var eventName = event || Polymer.CaseMap.camelToDashCase(property) + '-changed';
  model._bindListeners.push({
  index: index,
  property: property,
  path: path,
  changedFn: fn,
  event: eventName
  });
  },
  _isStructured: function (path) {
  return path.indexOf('.') > 0;
  },
  _isEventBogus: function (e, target) {
  return e.path && e.path[0] !== target;
  },
a1a3bc73   Luigi Serra   graphs updates
1559
1560
1561
1562
  _notedListenerFactory: function (property, path, isStructured) {
  return function (target, value, targetPath) {
  if (targetPath) {
  this._notifyPath(this._fixPath(path, property, targetPath), value);
73bcce88   luigser   COMPONENTS
1563
  } else {
a1a3bc73   Luigi Serra   graphs updates
1564
  value = target[property];
73bcce88   luigser   COMPONENTS
1565
  if (!isStructured) {
a1a3bc73   Luigi Serra   graphs updates
1566
  this[path] = value;
73bcce88   luigser   COMPONENTS
1567
1568
1569
1570
1571
1572
  } else {
  if (this.__data__[path] != value) {
  this.set(path, value);
  }
  }
  }
73bcce88   luigser   COMPONENTS
1573
1574
1575
1576
1577
1578
  };
  },
  prepareInstance: function (inst) {
  inst.__data__ = Object.create(null);
  },
  setupBindListeners: function (inst) {
a1a3bc73   Luigi Serra   graphs updates
1579
1580
  var b$ = inst._bindListeners;
  for (var i = 0, l = b$.length, info; i < l && (info = b$[i]); i++) {
73bcce88   luigser   COMPONENTS
1581
  var node = inst._nodes[info.index];
a1a3bc73   Luigi Serra   graphs updates
1582
1583
1584
1585
1586
1587
1588
  this._addNotifyListener(node, inst, info.event, info.changedFn);
  }
  ;
  },
  _addNotifyListener: function (element, context, event, changedFn) {
  element.addEventListener(event, function (e) {
  return context._notifyListener(changedFn, e);
73bcce88   luigser   COMPONENTS
1589
1590
1591
1592
1593
  });
  }
  };
  Polymer.Base.extend(Polymer.Bind, {
  _shouldAddListener: function (effect) {
f748e9cf   Luigi Serra   new controllet an...
1594
  return effect.name && effect.kind != 'attribute' && effect.kind != 'text' && !effect.isCompound && effect.parts[0].mode === '{' && !effect.parts[0].negate;
73bcce88   luigser   COMPONENTS
1595
1596
1597
  },
  _annotationEffect: function (source, value, effect) {
  if (source != effect.value) {
f748e9cf   Luigi Serra   new controllet an...
1598
  value = this._get(effect.value);
73bcce88   luigser   COMPONENTS
1599
1600
1601
1602
  this.__data__[effect.value] = value;
  }
  var calc = effect.negate ? !value : value;
  if (!effect.customEvent || this._nodes[effect.index][effect.name] !== calc) {
f748e9cf   Luigi Serra   new controllet an...
1603
  return this._applyEffectValue(effect, calc);
73bcce88   luigser   COMPONENTS
1604
1605
  }
  },
a1a3bc73   Luigi Serra   graphs updates
1606
1607
  _reflectEffect: function (source, value, effect) {
  this.reflectPropertyToAttribute(source, effect.attribute, value);
73bcce88   luigser   COMPONENTS
1608
1609
1610
  },
  _notifyEffect: function (source, value, effect, old, fromAbove) {
  if (!fromAbove) {
a1a3bc73   Luigi Serra   graphs updates
1611
  this._notifyChange(source, effect.event, value);
73bcce88   luigser   COMPONENTS
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
  }
  },
  _functionEffect: function (source, value, fn, old, fromAbove) {
  fn.call(this, source, value, old, fromAbove);
  },
  _observerEffect: function (source, value, effect, old) {
  var fn = this[effect.method];
  if (fn) {
  fn.call(this, value, old);
  } else {
  this._warn(this._logf('_observerEffect', 'observer method `' + effect.method + '` not defined'));
  }
  },
  _complexObserverEffect: function (source, value, effect) {
  var fn = this[effect.method];
  if (fn) {
  var args = Polymer.Bind._marshalArgs(this.__data__, effect, source, value);
  if (args) {
  fn.apply(this, args);
  }
  } else {
  this._warn(this._logf('_complexObserverEffect', 'observer method `' + effect.method + '` not defined'));
  }
  },
  _computeEffect: function (source, value, effect) {
  var args = Polymer.Bind._marshalArgs(this.__data__, effect, source, value);
  if (args) {
  var fn = this[effect.method];
  if (fn) {
f748e9cf   Luigi Serra   new controllet an...
1641
  this.__setProperty(effect.name, fn.apply(this, args));
73bcce88   luigser   COMPONENTS
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
  } else {
  this._warn(this._logf('_computeEffect', 'compute method `' + effect.method + '` not defined'));
  }
  }
  },
  _annotatedComputationEffect: function (source, value, effect) {
  var computedHost = this._rootDataHost || this;
  var fn = computedHost[effect.method];
  if (fn) {
  var args = Polymer.Bind._marshalArgs(this.__data__, effect, source, value);
  if (args) {
  var computedvalue = fn.apply(computedHost, args);
  if (effect.negate) {
  computedvalue = !computedvalue;
  }
f748e9cf   Luigi Serra   new controllet an...
1657
  this._applyEffectValue(effect, computedvalue);
73bcce88   luigser   COMPONENTS
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
  }
  } else {
  computedHost._warn(computedHost._logf('_annotatedComputationEffect', 'compute method `' + effect.method + '` not defined'));
  }
  },
  _marshalArgs: function (model, effect, path, value) {
  var values = [];
  var args = effect.args;
  for (var i = 0, l = args.length; i < l; i++) {
  var arg = args[i];
  var name = arg.name;
  var v;
  if (arg.literal) {
  v = arg.value;
  } else if (arg.structured) {
f748e9cf   Luigi Serra   new controllet an...
1673
  v = Polymer.Base._get(name, model);
73bcce88   luigser   COMPONENTS
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
  } else {
  v = model[name];
  }
  if (args.length > 1 && v === undefined) {
  return;
  }
  if (arg.wildcard) {
  var baseChanged = name.indexOf(path + '.') === 0;
  var matches = effect.trigger.name.indexOf(name) === 0 && !baseChanged;
  values[i] = {
  path: matches ? path : name,
  value: matches ? value : v,
  base: v
  };
  } else {
  values[i] = v;
  }
  }
  return values;
  }
  });
  Polymer.Base._addFeature({
  _addPropertyEffect: function (property, kind, effect) {
a1a3bc73   Luigi Serra   graphs updates
1697
1698
  var prop = Polymer.Bind.addPropertyEffect(this, property, kind, effect);
  prop.pathFn = this['_' + prop.kind + 'PathEffect'];
73bcce88   luigser   COMPONENTS
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
  },
  _prepEffects: function () {
  Polymer.Bind.prepareModel(this);
  this._addAnnotationEffects(this._notes);
  },
  _prepBindings: function () {
  Polymer.Bind.createBindings(this);
  },
  _addPropertyEffects: function (properties) {
  if (properties) {
  for (var p in properties) {
  var prop = properties[p];
  if (prop.observer) {
  this._addObserverEffect(p, prop.observer);
  }
  if (prop.computed) {
  prop.readOnly = true;
  this._addComputedEffect(p, prop.computed);
  }
  if (prop.notify) {
a1a3bc73   Luigi Serra   graphs updates
1719
  this._addPropertyEffect(p, 'notify', { event: Polymer.CaseMap.camelToDashCase(p) + '-changed' });
73bcce88   luigser   COMPONENTS
1720
1721
  }
  if (prop.reflectToAttribute) {
a1a3bc73   Luigi Serra   graphs updates
1722
  this._addPropertyEffect(p, 'reflect', { attribute: Polymer.CaseMap.camelToDashCase(p) });
73bcce88   luigser   COMPONENTS
1723
1724
1725
1726
1727
1728
1729
1730
1731
  }
  if (prop.readOnly) {
  Polymer.Bind.ensurePropertyEffects(this, p);
  }
  }
  }
  },
  _addComputedEffect: function (name, expression) {
  var sig = this._parseMethod(expression);
a1a3bc73   Luigi Serra   graphs updates
1732
  for (var i = 0, arg; i < sig.args.length && (arg = sig.args[i]); i++) {
73bcce88   luigser   COMPONENTS
1733
1734
1735
1736
  this._addPropertyEffect(arg.model, 'compute', {
  method: sig.method,
  args: sig.args,
  trigger: arg,
f748e9cf   Luigi Serra   new controllet an...
1737
  name: name
73bcce88   luigser   COMPONENTS
1738
  });
a1a3bc73   Luigi Serra   graphs updates
1739
  }
73bcce88   luigser   COMPONENTS
1740
1741
1742
1743
1744
1745
1746
1747
1748
  },
  _addObserverEffect: function (property, observer) {
  this._addPropertyEffect(property, 'observer', {
  method: observer,
  property: property
  });
  },
  _addComplexObserverEffects: function (observers) {
  if (observers) {
a1a3bc73   Luigi Serra   graphs updates
1749
1750
1751
  for (var i = 0, o; i < observers.length && (o = observers[i]); i++) {
  this._addComplexObserverEffect(o);
  }
73bcce88   luigser   COMPONENTS
1752
1753
1754
1755
  }
  },
  _addComplexObserverEffect: function (observer) {
  var sig = this._parseMethod(observer);
a1a3bc73   Luigi Serra   graphs updates
1756
  for (var i = 0, arg; i < sig.args.length && (arg = sig.args[i]); i++) {
73bcce88   luigser   COMPONENTS
1757
1758
1759
1760
1761
  this._addPropertyEffect(arg.model, 'complexObserver', {
  method: sig.method,
  args: sig.args,
  trigger: arg
  });
a1a3bc73   Luigi Serra   graphs updates
1762
  }
73bcce88   luigser   COMPONENTS
1763
1764
  },
  _addAnnotationEffects: function (notes) {
a1a3bc73   Luigi Serra   graphs updates
1765
1766
1767
1768
1769
1770
  for (var i = 0, note; i < notes.length && (note = notes[i]); i++) {
  var b$ = note.bindings;
  for (var j = 0, binding; j < b$.length && (binding = b$[j]); j++) {
  this._addAnnotationEffect(binding, i);
  }
  }
73bcce88   luigser   COMPONENTS
1771
1772
1773
  },
  _addAnnotationEffect: function (note, index) {
  if (Polymer.Bind._shouldAddListener(note)) {
f748e9cf   Luigi Serra   new controllet an...
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
  Polymer.Bind._addAnnotatedListener(this, index, note.name, note.parts[0].value, note.parts[0].event);
  }
  for (var i = 0; i < note.parts.length; i++) {
  var part = note.parts[i];
  if (part.signature) {
  this._addAnnotatedComputationEffect(note, part, index);
  } else if (!part.literal) {
  this._addPropertyEffect(part.model, 'annotation', {
  kind: note.kind,
  index: index,
  name: note.name,
  value: part.value,
  isCompound: note.isCompound,
  compoundIndex: part.compoundIndex,
  event: part.event,
  customEvent: part.customEvent,
  negate: part.negate
  });
73bcce88   luigser   COMPONENTS
1792
  }
73bcce88   luigser   COMPONENTS
1793
1794
  }
  },
f748e9cf   Luigi Serra   new controllet an...
1795
1796
  _addAnnotatedComputationEffect: function (note, part, index) {
  var sig = part.signature;
73bcce88   luigser   COMPONENTS
1797
  if (sig.static) {
f748e9cf   Luigi Serra   new controllet an...
1798
  this.__addAnnotatedComputationEffect('__static__', index, note, part, null);
73bcce88   luigser   COMPONENTS
1799
  } else {
a1a3bc73   Luigi Serra   graphs updates
1800
  for (var i = 0, arg; i < sig.args.length && (arg = sig.args[i]); i++) {
73bcce88   luigser   COMPONENTS
1801
  if (!arg.literal) {
f748e9cf   Luigi Serra   new controllet an...
1802
  this.__addAnnotatedComputationEffect(arg.model, index, note, part, arg);
73bcce88   luigser   COMPONENTS
1803
  }
a1a3bc73   Luigi Serra   graphs updates
1804
  }
73bcce88   luigser   COMPONENTS
1805
1806
  }
  },
f748e9cf   Luigi Serra   new controllet an...
1807
  __addAnnotatedComputationEffect: function (property, index, note, part, trigger) {
73bcce88   luigser   COMPONENTS
1808
1809
  this._addPropertyEffect(property, 'annotatedComputation', {
  index: index,
f748e9cf   Luigi Serra   new controllet an...
1810
1811
  isCompound: note.isCompound,
  compoundIndex: part.compoundIndex,
73bcce88   luigser   COMPONENTS
1812
  kind: note.kind,
f748e9cf   Luigi Serra   new controllet an...
1813
1814
1815
1816
  name: note.name,
  negate: part.negate,
  method: part.signature.method,
  args: part.signature.args,
73bcce88   luigser   COMPONENTS
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
  trigger: trigger
  });
  },
  _parseMethod: function (expression) {
  var m = expression.match(/([^\s]+)\((.*)\)/);
  if (m) {
  var sig = {
  method: m[1],
  static: true
  };
  if (m[2].trim()) {
  var args = m[2].replace(/\\,/g, '&comma;').split(',');
  return this._parseArgs(args, sig);
  } else {
  sig.args = Polymer.nar;
  return sig;
  }
  }
  },
  _parseArgs: function (argList, sig) {
  sig.args = argList.map(function (rawArg) {
  var arg = this._parseArg(rawArg);
  if (!arg.literal) {
  sig.static = false;
  }
  return arg;
  }, this);
  return sig;
  },
  _parseArg: function (rawArg) {
  var arg = rawArg.trim().replace(/&comma;/g, ',').replace(/\\(.)/g, '$1');
  var a = {
  name: arg,
  model: this._modelForPath(arg)
  };
  var fc = arg[0];
  if (fc === '-') {
  fc = arg[1];
  }
  if (fc >= '0' && fc <= '9') {
  fc = '#';
  }
  switch (fc) {
  case '\'':
  case '"':
  a.value = arg.slice(1, -1);
  a.literal = true;
  break;
  case '#':
  a.value = Number(arg);
  a.literal = true;
  break;
  }
  if (!a.literal) {
  a.structured = arg.indexOf('.') > 0;
  if (a.structured) {
  a.wildcard = arg.slice(-2) == '.*';
  if (a.wildcard) {
  a.name = arg.slice(0, -2);
  }
  }
  }
  return a;
  },
  _marshalInstanceEffects: function () {
  Polymer.Bind.prepareInstance(this);
a1a3bc73   Luigi Serra   graphs updates
1883
  if (this._bindListeners) {
73bcce88   luigser   COMPONENTS
1884
  Polymer.Bind.setupBindListeners(this);
a1a3bc73   Luigi Serra   graphs updates
1885
  }
73bcce88   luigser   COMPONENTS
1886
  },
f748e9cf   Luigi Serra   new controllet an...
1887
  _applyEffectValue: function (info, value) {
73bcce88   luigser   COMPONENTS
1888
  var node = this._nodes[info.index];
f748e9cf   Luigi Serra   new controllet an...
1889
1890
1891
1892
1893
1894
  var property = info.name;
  if (info.isCompound) {
  var storage = node.__compoundStorage__[property];
  storage[info.compoundIndex] = value;
  value = storage.join('');
  }
73bcce88   luigser   COMPONENTS
1895
1896
1897
1898
1899
1900
1901
1902
1903
  if (info.kind == 'attribute') {
  this.serializeValueToAttribute(value, property, node);
  } else {
  if (property === 'className') {
  value = this._scopeElementClass(node, value);
  }
  if (property === 'textContent' || node.localName == 'input' && property == 'value') {
  value = value == undefined ? '' : value;
  }
a1a3bc73   Luigi Serra   graphs updates
1904
1905
1906
1907
  var pinfo;
  if (!node._propertyInfo || !(pinfo = node._propertyInfo[property]) || !pinfo.readOnly) {
  this.__setProperty(property, value, true, node);
  }
73bcce88   luigser   COMPONENTS
1908
1909
1910
  }
  },
  _executeStaticEffects: function () {
a1a3bc73   Luigi Serra   graphs updates
1911
  if (this._propertyEffects && this._propertyEffects.__static__) {
73bcce88   luigser   COMPONENTS
1912
1913
1914
1915
1916
1917
1918
  this._effectEffects('__static__', null, this._propertyEffects.__static__);
  }
  }
  });
  Polymer.Base._addFeature({
  _setupConfigure: function (initialConfig) {
  this._config = {};
a1a3bc73   Luigi Serra   graphs updates
1919
1920
  this._handlers = [];
  if (initialConfig) {
73bcce88   luigser   COMPONENTS
1921
1922
1923
1924
1925
  for (var i in initialConfig) {
  if (initialConfig[i] !== undefined) {
  this._config[i] = initialConfig[i];
  }
  }
a1a3bc73   Luigi Serra   graphs updates
1926
  }
73bcce88   luigser   COMPONENTS
1927
1928
1929
1930
1931
1932
1933
1934
1935
  },
  _marshalAttributes: function () {
  this._takeAttributesToModel(this._config);
  },
  _attributeChangedImpl: function (name) {
  var model = this._clientsReadied ? this : this._config;
  this._setAttributeToProperty(model, name);
  },
  _configValue: function (name, value) {
a1a3bc73   Luigi Serra   graphs updates
1936
1937
  var info = this._propertyInfo[name];
  if (!info || !info.readOnly) {
73bcce88   luigser   COMPONENTS
1938
  this._config[name] = value;
a1a3bc73   Luigi Serra   graphs updates
1939
  }
73bcce88   luigser   COMPONENTS
1940
1941
1942
1943
1944
1945
1946
1947
  },
  _beforeClientsReady: function () {
  this._configure();
  },
  _configure: function () {
  this._configureAnnotationReferences();
  this._aboveConfig = this.mixin({}, this._config);
  var config = {};
a1a3bc73   Luigi Serra   graphs updates
1948
1949
1950
  for (var i = 0; i < this.behaviors.length; i++) {
  this._configureProperties(this.behaviors[i].properties, config);
  }
73bcce88   luigser   COMPONENTS
1951
  this._configureProperties(this.properties, config);
a1a3bc73   Luigi Serra   graphs updates
1952
  this.mixin(config, this._aboveConfig);
73bcce88   luigser   COMPONENTS
1953
  this._config = config;
a1a3bc73   Luigi Serra   graphs updates
1954
  if (this._clients && this._clients.length) {
73bcce88   luigser   COMPONENTS
1955
  this._distributeConfig(this._config);
a1a3bc73   Luigi Serra   graphs updates
1956
  }
73bcce88   luigser   COMPONENTS
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
  },
  _configureProperties: function (properties, config) {
  for (var i in properties) {
  var c = properties[i];
  if (c.value !== undefined) {
  var value = c.value;
  if (typeof value == 'function') {
  value = value.call(this, this._config);
  }
  config[i] = value;
  }
  }
  },
73bcce88   luigser   COMPONENTS
1970
1971
1972
1973
1974
1975
1976
  _distributeConfig: function (config) {
  var fx$ = this._propertyEffects;
  if (fx$) {
  for (var p in config) {
  var fx = fx$[p];
  if (fx) {
  for (var i = 0, l = fx.length, x; i < l && (x = fx[i]); i++) {
f748e9cf   Luigi Serra   new controllet an...
1977
  if (x.kind === 'annotation' && !x.isCompound) {
73bcce88   luigser   COMPONENTS
1978
1979
  var node = this._nodes[x.effect.index];
  if (node._configValue) {
f748e9cf   Luigi Serra   new controllet an...
1980
  var value = p === x.effect.value ? config[p] : this._get(x.effect.value, config);
73bcce88   luigser   COMPONENTS
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
  node._configValue(x.effect.name, value);
  }
  }
  }
  }
  }
  }
  },
  _afterClientsReady: function () {
  this._executeStaticEffects();
  this._applyConfig(this._config, this._aboveConfig);
  this._flushHandlers();
  },
  _applyConfig: function (config, aboveConfig) {
  for (var n in config) {
  if (this[n] === undefined) {
  this.__setProperty(n, config[n], n in aboveConfig);
  }
  }
  },
  _notifyListener: function (fn, e) {
a1a3bc73   Luigi Serra   graphs updates
2002
2003
2004
2005
2006
2007
  if (!Polymer.Bind._isEventBogus(e, e.target)) {
  var value, path;
  if (e.detail) {
  value = e.detail.value;
  path = e.detail.path;
  }
73bcce88   luigser   COMPONENTS
2008
2009
2010
  if (!this._clientsReadied) {
  this._queueHandler([
  fn,
a1a3bc73   Luigi Serra   graphs updates
2011
2012
2013
  e.target,
  value,
  path
73bcce88   luigser   COMPONENTS
2014
2015
  ]);
  } else {
a1a3bc73   Luigi Serra   graphs updates
2016
2017
  return fn.call(this, e.target, value, path);
  }
73bcce88   luigser   COMPONENTS
2018
2019
2020
2021
2022
2023
2024
2025
  }
  },
  _queueHandler: function (args) {
  this._handlers.push(args);
  },
  _flushHandlers: function () {
  var h$ = this._handlers;
  for (var i = 0, l = h$.length, h; i < l && (h = h$[i]); i++) {
a1a3bc73   Luigi Serra   graphs updates
2026
  h[0].call(this, h[1], h[2], h[3]);
73bcce88   luigser   COMPONENTS
2027
  }
e619a3b0   Luigi Serra   Controllet cross ...
2028
  this._handlers = [];
73bcce88   luigser   COMPONENTS
2029
2030
2031
2032
2033
2034
  }
  });
  (function () {
  'use strict';
  Polymer.Base._addFeature({
  notifyPath: function (path, value, fromAbove) {
f748e9cf   Luigi Serra   new controllet an...
2035
  var info = {};
a1a3bc73   Luigi Serra   graphs updates
2036
  this._get(path, this, info);
f748e9cf   Luigi Serra   new controllet an...
2037
2038
2039
  this._notifyPath(info.path, value, fromAbove);
  },
  _notifyPath: function (path, value, fromAbove) {
73bcce88   luigser   COMPONENTS
2040
2041
2042
2043
  var old = this._propertySetter(path, value);
  if (old !== value && (old === old || value === value)) {
  this._pathEffector(path, value);
  if (!fromAbove) {
f748e9cf   Luigi Serra   new controllet an...
2044
  this._notifyPathUp(path, value);
73bcce88   luigser   COMPONENTS
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
  }
  return true;
  }
  },
  _getPathParts: function (path) {
  if (Array.isArray(path)) {
  var parts = [];
  for (var i = 0; i < path.length; i++) {
  var args = path[i].toString().split('.');
  for (var j = 0; j < args.length; j++) {
  parts.push(args[j]);
  }
  }
  return parts;
  } else {
  return path.toString().split('.');
  }
  },
  set: function (path, value, root) {
  var prop = root || this;
  var parts = this._getPathParts(path);
  var array;
  var last = parts[parts.length - 1];
  if (parts.length > 1) {
  for (var i = 0; i < parts.length - 1; i++) {
  var part = parts[i];
f748e9cf   Luigi Serra   new controllet an...
2071
2072
2073
  if (array && part[0] == '#') {
  prop = Polymer.Collection.get(array).getItem(part);
  } else {
73bcce88   luigser   COMPONENTS
2074
  prop = prop[part];
f748e9cf   Luigi Serra   new controllet an...
2075
  if (array && parseInt(part, 10) == part) {
73bcce88   luigser   COMPONENTS
2076
2077
  parts[i] = Polymer.Collection.get(array).getKey(prop);
  }
f748e9cf   Luigi Serra   new controllet an...
2078
  }
73bcce88   luigser   COMPONENTS
2079
2080
2081
2082
2083
  if (!prop) {
  return;
  }
  array = Array.isArray(prop) ? prop : null;
  }
f748e9cf   Luigi Serra   new controllet an...
2084
  if (array) {
73bcce88   luigser   COMPONENTS
2085
  var coll = Polymer.Collection.get(array);
f748e9cf   Luigi Serra   new controllet an...
2086
2087
2088
2089
2090
2091
  if (last[0] == '#') {
  var key = last;
  var old = coll.getItem(key);
  last = array.indexOf(old);
  coll.setItem(key, value);
  } else if (parseInt(last, 10) == last) {
73bcce88   luigser   COMPONENTS
2092
2093
2094
2095
2096
  var old = prop[last];
  var key = coll.getKey(old);
  parts[i] = key;
  coll.setItem(key, value);
  }
f748e9cf   Luigi Serra   new controllet an...
2097
  }
73bcce88   luigser   COMPONENTS
2098
2099
  prop[last] = value;
  if (!root) {
f748e9cf   Luigi Serra   new controllet an...
2100
  this._notifyPath(parts.join('.'), value);
73bcce88   luigser   COMPONENTS
2101
2102
2103
2104
2105
2106
  }
  } else {
  prop[path] = value;
  }
  },
  get: function (path, root) {
f748e9cf   Luigi Serra   new controllet an...
2107
2108
2109
  return this._get(path, root);
  },
  _get: function (path, root, info) {
73bcce88   luigser   COMPONENTS
2110
2111
  var prop = root || this;
  var parts = this._getPathParts(path);
f748e9cf   Luigi Serra   new controllet an...
2112
2113
  var array;
  for (var i = 0; i < parts.length; i++) {
73bcce88   luigser   COMPONENTS
2114
2115
2116
  if (!prop) {
  return;
  }
f748e9cf   Luigi Serra   new controllet an...
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
  var part = parts[i];
  if (array && part[0] == '#') {
  prop = Polymer.Collection.get(array).getItem(part);
  } else {
  prop = prop[part];
  if (info && array && parseInt(part, 10) == part) {
  parts[i] = Polymer.Collection.get(array).getKey(prop);
  }
  }
  array = Array.isArray(prop) ? prop : null;
  }
  if (info) {
  info.path = parts.join('.');
73bcce88   luigser   COMPONENTS
2130
  }
f748e9cf   Luigi Serra   new controllet an...
2131
  return prop;
73bcce88   luigser   COMPONENTS
2132
2133
2134
  },
  _pathEffector: function (path, value) {
  var model = this._modelForPath(path);
a1a3bc73   Luigi Serra   graphs updates
2135
  var fx$ = this._propertyEffects && this._propertyEffects[model];
73bcce88   luigser   COMPONENTS
2136
  if (fx$) {
a1a3bc73   Luigi Serra   graphs updates
2137
2138
  for (var i = 0, fx; i < fx$.length && (fx = fx$[i]); i++) {
  var fxFn = fx.pathFn;
73bcce88   luigser   COMPONENTS
2139
2140
2141
  if (fxFn) {
  fxFn.call(this, path, value, fx.effect);
  }
a1a3bc73   Luigi Serra   graphs updates
2142
  }
73bcce88   luigser   COMPONENTS
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
  }
  if (this._boundPaths) {
  this._notifyBoundPaths(path, value);
  }
  },
  _annotationPathEffect: function (path, value, effect) {
  if (effect.value === path || effect.value.indexOf(path + '.') === 0) {
  Polymer.Bind._annotationEffect.call(this, path, value, effect);
  } else if (path.indexOf(effect.value + '.') === 0 && !effect.negate) {
  var node = this._nodes[effect.index];
a1a3bc73   Luigi Serra   graphs updates
2153
  if (node && node._notifyPath) {
73bcce88   luigser   COMPONENTS
2154
  var p = this._fixPath(effect.name, effect.value, path);
a1a3bc73   Luigi Serra   graphs updates
2155
  node._notifyPath(p, value, true);
73bcce88   luigser   COMPONENTS
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
  }
  }
  },
  _complexObserverPathEffect: function (path, value, effect) {
  if (this._pathMatchesEffect(path, effect)) {
  Polymer.Bind._complexObserverEffect.call(this, path, value, effect);
  }
  },
  _computePathEffect: function (path, value, effect) {
  if (this._pathMatchesEffect(path, effect)) {
  Polymer.Bind._computeEffect.call(this, path, value, effect);
  }
  },
  _annotatedComputationPathEffect: function (path, value, effect) {
  if (this._pathMatchesEffect(path, effect)) {
  Polymer.Bind._annotatedComputationEffect.call(this, path, value, effect);
  }
  },
  _pathMatchesEffect: function (path, effect) {
  var effectArg = effect.trigger.name;
  return effectArg == path || effectArg.indexOf(path + '.') === 0 || effect.trigger.wildcard && path.indexOf(effectArg) === 0;
  },
  linkPaths: function (to, from) {
  this._boundPaths = this._boundPaths || {};
  if (from) {
  this._boundPaths[to] = from;
  } else {
e619a3b0   Luigi Serra   Controllet cross ...
2183
  this.unlinkPaths(to);
73bcce88   luigser   COMPONENTS
2184
2185
2186
2187
2188
2189
2190
2191
  }
  },
  unlinkPaths: function (path) {
  if (this._boundPaths) {
  delete this._boundPaths[path];
  }
  },
  _notifyBoundPaths: function (path, value) {
73bcce88   luigser   COMPONENTS
2192
2193
2194
  for (var a in this._boundPaths) {
  var b = this._boundPaths[a];
  if (path.indexOf(a + '.') == 0) {
a1a3bc73   Luigi Serra   graphs updates
2195
  this._notifyPath(this._fixPath(b, a, path), value);
e619a3b0   Luigi Serra   Controllet cross ...
2196
  } else if (path.indexOf(b + '.') == 0) {
a1a3bc73   Luigi Serra   graphs updates
2197
  this._notifyPath(this._fixPath(a, b, path), value);
73bcce88   luigser   COMPONENTS
2198
  }
73bcce88   luigser   COMPONENTS
2199
2200
2201
2202
2203
  }
  },
  _fixPath: function (property, root, path) {
  return property + path.slice(root.length);
  },
f748e9cf   Luigi Serra   new controllet an...
2204
  _notifyPathUp: function (path, value) {
73bcce88   luigser   COMPONENTS
2205
2206
2207
2208
2209
2210
  var rootName = this._modelForPath(path);
  var dashCaseName = Polymer.CaseMap.camelToDashCase(rootName);
  var eventName = dashCaseName + this._EVENT_CHANGED;
  this.fire(eventName, {
  path: path,
  value: value
a1a3bc73   Luigi Serra   graphs updates
2211
2212
2213
2214
  }, {
  bubbles: false,
  _useCache: true
  });
73bcce88   luigser   COMPONENTS
2215
2216
2217
2218
2219
2220
  },
  _modelForPath: function (path) {
  var dot = path.indexOf('.');
  return dot < 0 ? path : path.slice(0, dot);
  },
  _EVENT_CHANGED: '-changed',
f748e9cf   Luigi Serra   new controllet an...
2221
2222
2223
2224
2225
2226
  notifySplices: function (path, splices) {
  var info = {};
  var array = this._get(path, this, info);
  this._notifySplices(array, info.path, splices);
  },
  _notifySplices: function (array, path, splices) {
73bcce88   luigser   COMPONENTS
2227
2228
2229
2230
  var change = {
  keySplices: Polymer.Collection.applySplices(array, splices),
  indexSplices: splices
  };
f748e9cf   Luigi Serra   new controllet an...
2231
2232
2233
2234
2235
  if (!array.hasOwnProperty('splices')) {
  Object.defineProperty(array, 'splices', {
  configurable: true,
  writable: true
  });
73bcce88   luigser   COMPONENTS
2236
  }
f748e9cf   Luigi Serra   new controllet an...
2237
2238
2239
  array.splices = change;
  this._notifyPath(path + '.splices', change);
  this._notifyPath(path + '.length', array.length);
73bcce88   luigser   COMPONENTS
2240
2241
2242
  change.keySplices = null;
  change.indexSplices = null;
  },
f748e9cf   Luigi Serra   new controllet an...
2243
2244
2245
2246
2247
2248
2249
2250
2251
  _notifySplice: function (array, path, index, added, removed) {
  this._notifySplices(array, path, [{
  index: index,
  addedCount: added,
  removed: removed,
  object: array,
  type: 'splice'
  }]);
  },
73bcce88   luigser   COMPONENTS
2252
  push: function (path) {
f748e9cf   Luigi Serra   new controllet an...
2253
2254
  var info = {};
  var array = this._get(path, this, info);
73bcce88   luigser   COMPONENTS
2255
2256
2257
2258
  var args = Array.prototype.slice.call(arguments, 1);
  var len = array.length;
  var ret = array.push.apply(array, args);
  if (args.length) {
f748e9cf   Luigi Serra   new controllet an...
2259
  this._notifySplice(array, info.path, len, args.length, []);
73bcce88   luigser   COMPONENTS
2260
2261
2262
2263
  }
  return ret;
  },
  pop: function (path) {
f748e9cf   Luigi Serra   new controllet an...
2264
2265
  var info = {};
  var array = this._get(path, this, info);
73bcce88   luigser   COMPONENTS
2266
2267
2268
2269
  var hadLength = Boolean(array.length);
  var args = Array.prototype.slice.call(arguments, 1);
  var ret = array.pop.apply(array, args);
  if (hadLength) {
f748e9cf   Luigi Serra   new controllet an...
2270
  this._notifySplice(array, info.path, array.length, 0, [ret]);
73bcce88   luigser   COMPONENTS
2271
2272
2273
2274
  }
  return ret;
  },
  splice: function (path, start, deleteCount) {
f748e9cf   Luigi Serra   new controllet an...
2275
2276
  var info = {};
  var array = this._get(path, this, info);
73bcce88   luigser   COMPONENTS
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
  if (start < 0) {
  start = array.length - Math.floor(-start);
  } else {
  start = Math.floor(start);
  }
  if (!start) {
  start = 0;
  }
  var args = Array.prototype.slice.call(arguments, 1);
  var ret = array.splice.apply(array, args);
  var addedCount = Math.max(args.length - 2, 0);
  if (addedCount || ret.length) {
f748e9cf   Luigi Serra   new controllet an...
2289
  this._notifySplice(array, info.path, start, addedCount, ret);
73bcce88   luigser   COMPONENTS
2290
2291
2292
2293
  }
  return ret;
  },
  shift: function (path) {
f748e9cf   Luigi Serra   new controllet an...
2294
2295
  var info = {};
  var array = this._get(path, this, info);
73bcce88   luigser   COMPONENTS
2296
2297
2298
2299
  var hadLength = Boolean(array.length);
  var args = Array.prototype.slice.call(arguments, 1);
  var ret = array.shift.apply(array, args);
  if (hadLength) {
f748e9cf   Luigi Serra   new controllet an...
2300
  this._notifySplice(array, info.path, 0, 0, [ret]);
73bcce88   luigser   COMPONENTS
2301
2302
2303
2304
  }
  return ret;
  },
  unshift: function (path) {
f748e9cf   Luigi Serra   new controllet an...
2305
2306
  var info = {};
  var array = this._get(path, this, info);
73bcce88   luigser   COMPONENTS
2307
2308
2309
  var args = Array.prototype.slice.call(arguments, 1);
  var ret = array.unshift.apply(array, args);
  if (args.length) {
f748e9cf   Luigi Serra   new controllet an...
2310
  this._notifySplice(array, info.path, 0, args.length, []);
73bcce88   luigser   COMPONENTS
2311
2312
  }
  return ret;
eb240478   Luigi Serra   public room cards...
2313
2314
2315
2316
  },
  prepareModelNotifyPath: function (model) {
  this.mixin(model, {
  fire: Polymer.Base.fire,
a1a3bc73   Luigi Serra   graphs updates
2317
2318
  _getEvent: Polymer.Base._getEvent,
  __eventCache: Polymer.Base.__eventCache,
eb240478   Luigi Serra   public room cards...
2319
  notifyPath: Polymer.Base.notifyPath,
f748e9cf   Luigi Serra   new controllet an...
2320
  _get: Polymer.Base._get,
eb240478   Luigi Serra   public room cards...
2321
2322
  _EVENT_CHANGED: Polymer.Base._EVENT_CHANGED,
  _notifyPath: Polymer.Base._notifyPath,
f748e9cf   Luigi Serra   new controllet an...
2323
  _notifyPathUp: Polymer.Base._notifyPathUp,
eb240478   Luigi Serra   public room cards...
2324
2325
2326
2327
2328
2329
2330
  _pathEffector: Polymer.Base._pathEffector,
  _annotationPathEffect: Polymer.Base._annotationPathEffect,
  _complexObserverPathEffect: Polymer.Base._complexObserverPathEffect,
  _annotatedComputationPathEffect: Polymer.Base._annotatedComputationPathEffect,
  _computePathEffect: Polymer.Base._computePathEffect,
  _modelForPath: Polymer.Base._modelForPath,
  _pathMatchesEffect: Polymer.Base._pathMatchesEffect,
f748e9cf   Luigi Serra   new controllet an...
2331
2332
  _notifyBoundPaths: Polymer.Base._notifyBoundPaths,
  _getPathParts: Polymer.Base._getPathParts
eb240478   Luigi Serra   public room cards...
2333
  });
73bcce88   luigser   COMPONENTS
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
  }
  });
  }());
  Polymer.Base._addFeature({
  resolveUrl: function (url) {
  var module = Polymer.DomModule.import(this.is);
  var root = '';
  if (module) {
  var assetPath = module.getAttribute('assetpath') || '';
  root = Polymer.ResolveUrl.resolveUrl(assetPath, module.ownerDocument.baseURI);
  }
  return Polymer.ResolveUrl.resolveUrl(url, root);
  }
  });
  Polymer.CssParse = function () {
  var api = {
  parse: function (text) {
  text = this._clean(text);
  return this._parseCss(this._lex(text), text);
  },
  _clean: function (cssText) {
  return cssText.replace(this._rx.comments, '').replace(this._rx.port, '');
  },
  _lex: function (text) {
  var root = {
  start: 0,
  end: text.length
  };
  var n = root;
  for (var i = 0, s = 0, l = text.length; i < l; i++) {
  switch (text[i]) {
  case this.OPEN_BRACE:
  if (!n.rules) {
  n.rules = [];
  }
  var p = n;
  var previous = p.rules[p.rules.length - 1];
  n = {
  start: i + 1,
  parent: p,
  previous: previous
  };
  p.rules.push(n);
  break;
  case this.CLOSE_BRACE:
  n.end = i + 1;
  n = n.parent || root;
  break;
  }
  }
  return root;
  },
  _parseCss: function (node, text) {
  var t = text.substring(node.start, node.end - 1);
  node.parsedCssText = node.cssText = t.trim();
  if (node.parent) {
  var ss = node.previous ? node.previous.end : node.parent.start;
  t = text.substring(ss, node.start - 1);
a1a3bc73   Luigi Serra   graphs updates
2392
2393
  t = this._expandUnicodeEscapes(t);
  t = t.replace(this._rx.multipleSpaces, ' ');
73bcce88   luigser   COMPONENTS
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
  t = t.substring(t.lastIndexOf(';') + 1);
  var s = node.parsedSelector = node.selector = t.trim();
  node.atRule = s.indexOf(this.AT_START) === 0;
  if (node.atRule) {
  if (s.indexOf(this.MEDIA_START) === 0) {
  node.type = this.types.MEDIA_RULE;
  } else if (s.match(this._rx.keyframesRule)) {
  node.type = this.types.KEYFRAMES_RULE;
  }
  } else {
  if (s.indexOf(this.VAR_START) === 0) {
  node.type = this.types.MIXIN_RULE;
  } else {
  node.type = this.types.STYLE_RULE;
  }
  }
  }
  var r$ = node.rules;
  if (r$) {
  for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) {
  this._parseCss(r, text);
  }
  }
  return node;
  },
a1a3bc73   Luigi Serra   graphs updates
2419
2420
2421
2422
2423
2424
2425
2426
2427
  _expandUnicodeEscapes: function (s) {
  return s.replace(/\\([0-9a-f]{1,6})\s/gi, function () {
  var code = arguments[1], repeat = 6 - code.length;
  while (repeat--) {
  code = '0' + code;
  }
  return '\\' + code;
  });
  },
73bcce88   luigser   COMPONENTS
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
  stringify: function (node, preserveProperties, text) {
  text = text || '';
  var cssText = '';
  if (node.cssText || node.rules) {
  var r$ = node.rules;
  if (r$ && (preserveProperties || !this._hasMixinRules(r$))) {
  for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) {
  cssText = this.stringify(r, preserveProperties, cssText);
  }
  } else {
  cssText = preserveProperties ? node.cssText : this.removeCustomProps(node.cssText);
  cssText = cssText.trim();
  if (cssText) {
  cssText = '  ' + cssText + '\n';
  }
  }
  }
  if (cssText) {
  if (node.selector) {
  text += node.selector + ' ' + this.OPEN_BRACE + '\n';
  }
  text += cssText;
  if (node.selector) {
  text += this.CLOSE_BRACE + '\n\n';
  }
  }
  return text;
  },
  _hasMixinRules: function (rules) {
a1a3bc73   Luigi Serra   graphs updates
2457
  return rules[0].selector.indexOf(this.VAR_START) === 0;
73bcce88   luigser   COMPONENTS
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
  },
  removeCustomProps: function (cssText) {
  cssText = this.removeCustomPropAssignment(cssText);
  return this.removeCustomPropApply(cssText);
  },
  removeCustomPropAssignment: function (cssText) {
  return cssText.replace(this._rx.customProp, '').replace(this._rx.mixinProp, '');
  },
  removeCustomPropApply: function (cssText) {
  return cssText.replace(this._rx.mixinApply, '').replace(this._rx.varApply, '');
  },
  types: {
  STYLE_RULE: 1,
  KEYFRAMES_RULE: 7,
  MEDIA_RULE: 4,
  MIXIN_RULE: 1000
  },
  OPEN_BRACE: '{',
  CLOSE_BRACE: '}',
  _rx: {
e619a3b0   Luigi Serra   Controllet cross ...
2478
  comments: /\/\*[^*]*\*+([^\/*][^*]*\*+)*\//gim,
73bcce88   luigser   COMPONENTS
2479
2480
  port: /@import[^;]*;/gim,
  customProp: /(?:^|[\s;])--[^;{]*?:[^{};]*?(?:[;\n]|$)/gim,
a1a3bc73   Luigi Serra   graphs updates
2481
  mixinProp: /(?:^|[\s;])?--[^;{]*?:[^{;]*?{[^}]*?}(?:[;\n]|$)?/gim,
73bcce88   luigser   COMPONENTS
2482
  mixinApply: /@apply[\s]*\([^)]*?\)[\s]*(?:[;\n]|$)?/gim,
a1a3bc73   Luigi Serra   graphs updates
2483
2484
2485
  varApply: /[^;:]*?:[^;]*?var\([^;]*\)(?:[;\n]|$)?/gim,
  keyframesRule: /^@[^\s]*keyframes/,
  multipleSpaces: /\s+/g
73bcce88   luigser   COMPONENTS
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
  },
  VAR_START: '--',
  MEDIA_START: '@media',
  AT_START: '@'
  };
  return api;
  }();
  Polymer.StyleUtil = function () {
  return {
  MODULE_STYLES_SELECTOR: 'style, link[rel=import][type~=css], template',
  INCLUDE_ATTR: 'include',
  toCssText: function (rules, callback, preserveProperties) {
  if (typeof rules === 'string') {
  rules = this.parser.parse(rules);
  }
  if (callback) {
  this.forEachStyleRule(rules, callback);
  }
  return this.parser.stringify(rules, preserveProperties);
  },
  forRulesInStyles: function (styles, callback) {
  if (styles) {
  for (var i = 0, l = styles.length, s; i < l && (s = styles[i]); i++) {
  this.forEachStyleRule(this.rulesForStyle(s), callback);
  }
  }
  },
  rulesForStyle: function (style) {
  if (!style.__cssRules && style.textContent) {
  style.__cssRules = this.parser.parse(style.textContent);
  }
  return style.__cssRules;
  },
  clearStyleRules: function (style) {
  style.__cssRules = null;
  },
  forEachStyleRule: function (node, callback) {
  if (!node) {
  return;
  }
  var s = node.parsedSelector;
  var skipRules = false;
  if (node.type === this.ruleTypes.STYLE_RULE) {
  callback(node);
  } else if (node.type === this.ruleTypes.KEYFRAMES_RULE || node.type === this.ruleTypes.MIXIN_RULE) {
  skipRules = true;
  }
  var r$ = node.rules;
  if (r$ && !skipRules) {
  for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) {
  this.forEachStyleRule(r, callback);
  }
  }
  },
  applyCss: function (cssText, moniker, target, afterNode) {
  var style = document.createElement('style');
  if (moniker) {
  style.setAttribute('scope', moniker);
  }
  style.textContent = cssText;
  target = target || document.head;
  if (!afterNode) {
  var n$ = target.querySelectorAll('style[scope]');
  afterNode = n$[n$.length - 1];
  }
  target.insertBefore(style, afterNode && afterNode.nextSibling || target.firstChild);
  return style;
  },
  cssFromModules: function (moduleIds, warnIfNotFound) {
  var modules = moduleIds.trim().split(' ');
  var cssText = '';
  for (var i = 0; i < modules.length; i++) {
  cssText += this.cssFromModule(modules[i], warnIfNotFound);
  }
  return cssText;
  },
  cssFromModule: function (moduleId, warnIfNotFound) {
  var m = Polymer.DomModule.import(moduleId);
  if (m && !m._cssText) {
a1a3bc73   Luigi Serra   graphs updates
2565
  m._cssText = this.cssFromElement(m);
73bcce88   luigser   COMPONENTS
2566
2567
2568
2569
2570
2571
  }
  if (!m && warnIfNotFound) {
  console.warn('Could not find style data in module named', moduleId);
  }
  return m && m._cssText || '';
  },
a1a3bc73   Luigi Serra   graphs updates
2572
  cssFromElement: function (element) {
73bcce88   luigser   COMPONENTS
2573
2574
  var cssText = '';
  var content = element.content || element;
a1a3bc73   Luigi Serra   graphs updates
2575
  var e$ = Polymer.DomApi.arrayCopy(content.querySelectorAll(this.MODULE_STYLES_SELECTOR));
73bcce88   luigser   COMPONENTS
2576
2577
2578
  for (var i = 0, e; i < e$.length; i++) {
  e = e$[i];
  if (e.localName === 'template') {
a1a3bc73   Luigi Serra   graphs updates
2579
  cssText += this.cssFromElement(e);
73bcce88   luigser   COMPONENTS
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
  } else {
  if (e.localName === 'style') {
  var include = e.getAttribute(this.INCLUDE_ATTR);
  if (include) {
  cssText += this.cssFromModules(include, true);
  }
  e = e.__appliedElement || e;
  e.parentNode.removeChild(e);
  cssText += this.resolveCss(e.textContent, element.ownerDocument);
  } else if (e.import && e.import.body) {
  cssText += this.resolveCss(e.import.body.textContent, e.import);
  }
  }
  }
  return cssText;
  },
  resolveCss: Polymer.ResolveUrl.resolveCss,
  parser: Polymer.CssParse,
  ruleTypes: Polymer.CssParse.types
  };
  }();
  Polymer.StyleTransformer = function () {
  var nativeShadow = Polymer.Settings.useNativeShadow;
  var styleUtil = Polymer.StyleUtil;
  var api = {
  dom: function (node, scope, useAttr, shouldRemoveScope) {
  this._transformDom(node, scope || '', useAttr, shouldRemoveScope);
  },
  _transformDom: function (node, selector, useAttr, shouldRemoveScope) {
  if (node.setAttribute) {
  this.element(node, selector, useAttr, shouldRemoveScope);
  }
  var c$ = Polymer.dom(node).childNodes;
  for (var i = 0; i < c$.length; i++) {
  this._transformDom(c$[i], selector, useAttr, shouldRemoveScope);
  }
  },
  element: function (element, scope, useAttr, shouldRemoveScope) {
  if (useAttr) {
  if (shouldRemoveScope) {
  element.removeAttribute(SCOPE_NAME);
  } else {
  element.setAttribute(SCOPE_NAME, scope);
  }
  } else {
  if (scope) {
  if (element.classList) {
  if (shouldRemoveScope) {
  element.classList.remove(SCOPE_NAME);
  element.classList.remove(scope);
  } else {
  element.classList.add(SCOPE_NAME);
  element.classList.add(scope);
  }
  } else if (element.getAttribute) {
  var c = element.getAttribute(CLASS);
  if (shouldRemoveScope) {
  if (c) {
  element.setAttribute(CLASS, c.replace(SCOPE_NAME, '').replace(scope, ''));
  }
  } else {
  element.setAttribute(CLASS, c + (c ? ' ' : '') + SCOPE_NAME + ' ' + scope);
  }
  }
  }
  }
  },
  elementStyles: function (element, callback) {
  var styles = element._styles;
  var cssText = '';
  for (var i = 0, l = styles.length, s, text; i < l && (s = styles[i]); i++) {
  var rules = styleUtil.rulesForStyle(s);
  cssText += nativeShadow ? styleUtil.toCssText(rules, callback) : this.css(rules, element.is, element.extends, callback, element._scopeCssViaAttr) + '\n\n';
  }
  return cssText.trim();
  },
  css: function (rules, scope, ext, callback, useAttr) {
  var hostScope = this._calcHostScope(scope, ext);
  scope = this._calcElementScope(scope, useAttr);
  var self = this;
  return styleUtil.toCssText(rules, function (rule) {
  if (!rule.isScoped) {
  self.rule(rule, scope, hostScope);
  rule.isScoped = true;
  }
  if (callback) {
  callback(rule, scope, hostScope);
  }
  });
  },
  _calcElementScope: function (scope, useAttr) {
  if (scope) {
  return useAttr ? CSS_ATTR_PREFIX + scope + CSS_ATTR_SUFFIX : CSS_CLASS_PREFIX + scope;
  } else {
  return '';
  }
  },
  _calcHostScope: function (scope, ext) {
  return ext ? '[is=' + scope + ']' : scope;
  },
  rule: function (rule, scope, hostScope) {
  this._transformRule(rule, this._transformComplexSelector, scope, hostScope);
  },
  _transformRule: function (rule, transformer, scope, hostScope) {
  var p$ = rule.selector.split(COMPLEX_SELECTOR_SEP);
  for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) {
  p$[i] = transformer.call(this, p, scope, hostScope);
  }
  rule.selector = rule.transformedSelector = p$.join(COMPLEX_SELECTOR_SEP);
  },
  _transformComplexSelector: function (selector, scope, hostScope) {
  var stop = false;
  var hostContext = false;
  var self = this;
  selector = selector.replace(SIMPLE_SELECTOR_SEP, function (m, c, s) {
  if (!stop) {
  var info = self._transformCompoundSelector(s, c, scope, hostScope);
  stop = stop || info.stop;
  hostContext = hostContext || info.hostContext;
  c = info.combinator;
  s = info.value;
  } else {
  s = s.replace(SCOPE_JUMP, ' ');
  }
  return c + s;
  });
  if (hostContext) {
  selector = selector.replace(HOST_CONTEXT_PAREN, function (m, pre, paren, post) {
  return pre + paren + ' ' + hostScope + post + COMPLEX_SELECTOR_SEP + ' ' + pre + hostScope + paren + post;
  });
  }
  return selector;
  },
  _transformCompoundSelector: function (selector, combinator, scope, hostScope) {
  var jumpIndex = selector.search(SCOPE_JUMP);
  var hostContext = false;
  if (selector.indexOf(HOST_CONTEXT) >= 0) {
  hostContext = true;
  } else if (selector.indexOf(HOST) >= 0) {
  selector = selector.replace(HOST_PAREN, function (m, host, paren) {
  return hostScope + paren;
  });
  selector = selector.replace(HOST, hostScope);
  } else if (jumpIndex !== 0) {
  selector = scope ? this._transformSimpleSelector(selector, scope) : selector;
  }
  if (selector.indexOf(CONTENT) >= 0) {
  combinator = '';
  }
  var stop;
  if (jumpIndex >= 0) {
  selector = selector.replace(SCOPE_JUMP, ' ');
  stop = true;
  }
  return {
  value: selector,
  combinator: combinator,
  stop: stop,
  hostContext: hostContext
  };
  },
  _transformSimpleSelector: function (selector, scope) {
  var p$ = selector.split(PSEUDO_PREFIX);
  p$[0] += scope;
  return p$.join(PSEUDO_PREFIX);
  },
  documentRule: function (rule) {
  rule.selector = rule.parsedSelector;
  this.normalizeRootSelector(rule);
  if (!nativeShadow) {
  this._transformRule(rule, this._transformDocumentSelector);
  }
  },
  normalizeRootSelector: function (rule) {
  if (rule.selector === ROOT) {
  rule.selector = 'body';
  }
  },
  _transformDocumentSelector: function (selector) {
  return selector.match(SCOPE_JUMP) ? this._transformComplexSelector(selector, SCOPE_DOC_SELECTOR) : this._transformSimpleSelector(selector.trim(), SCOPE_DOC_SELECTOR);
  },
  SCOPE_NAME: 'style-scope'
  };
  var SCOPE_NAME = api.SCOPE_NAME;
  var SCOPE_DOC_SELECTOR = ':not([' + SCOPE_NAME + '])' + ':not(.' + SCOPE_NAME + ')';
  var COMPLEX_SELECTOR_SEP = ',';
  var SIMPLE_SELECTOR_SEP = /(^|[\s>+~]+)([^\s>+~]+)/g;
  var HOST = ':host';
  var ROOT = ':root';
  var HOST_PAREN = /(\:host)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/g;
  var HOST_CONTEXT = ':host-context';
  var HOST_CONTEXT_PAREN = /(.*)(?:\:host-context)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))(.*)/;
  var CONTENT = '::content';
  var SCOPE_JUMP = /\:\:content|\:\:shadow|\/deep\//;
  var CSS_CLASS_PREFIX = '.';
  var CSS_ATTR_PREFIX = '[' + SCOPE_NAME + '~=';
  var CSS_ATTR_SUFFIX = ']';
  var PSEUDO_PREFIX = ':';
  var CLASS = 'class';
  return api;
  }();
  Polymer.StyleExtends = function () {
  var styleUtil = Polymer.StyleUtil;
  return {
  hasExtends: function (cssText) {
  return Boolean(cssText.match(this.rx.EXTEND));
  },
  transform: function (style) {
  var rules = styleUtil.rulesForStyle(style);
  var self = this;
  styleUtil.forEachStyleRule(rules, function (rule) {
  var map = self._mapRule(rule);
  if (rule.parent) {
  var m;
  while (m = self.rx.EXTEND.exec(rule.cssText)) {
  var extend = m[1];
  var extendor = self._findExtendor(extend, rule);
  if (extendor) {
  self._extendRule(rule, extendor);
  }
  }
  }
  rule.cssText = rule.cssText.replace(self.rx.EXTEND, '');
  });
  return styleUtil.toCssText(rules, function (rule) {
  if (rule.selector.match(self.rx.STRIP)) {
  rule.cssText = '';
  }
  }, true);
  },
  _mapRule: function (rule) {
  if (rule.parent) {
  var map = rule.parent.map || (rule.parent.map = {});
  var parts = rule.selector.split(',');
  for (var i = 0, p; i < parts.length; i++) {
  p = parts[i];
  map[p.trim()] = rule;
  }
  return map;
  }
  },
  _findExtendor: function (extend, rule) {
  return rule.parent && rule.parent.map && rule.parent.map[extend] || this._findExtendor(extend, rule.parent);
  },
  _extendRule: function (target, source) {
  if (target.parent !== source.parent) {
  this._cloneAndAddRuleToParent(source, target.parent);
  }
a1a3bc73   Luigi Serra   graphs updates
2828
  target.extends = target.extends || [];
73bcce88   luigser   COMPONENTS
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
  target.extends.push(source);
  source.selector = source.selector.replace(this.rx.STRIP, '');
  source.selector = (source.selector && source.selector + ',\n') + target.selector;
  if (source.extends) {
  source.extends.forEach(function (e) {
  this._extendRule(target, e);
  }, this);
  }
  },
  _cloneAndAddRuleToParent: function (rule, parent) {
  rule = Object.create(rule);
  rule.parent = parent;
  if (rule.extends) {
  rule.extends = rule.extends.slice();
  }
  parent.rules.push(rule);
  },
  rx: {
  EXTEND: /@extends\(([^)]*)\)\s*?;/gim,
  STRIP: /%[^,]*$/
  }
  };
  }();
  (function () {
  var prepElement = Polymer.Base._prepElement;
  var nativeShadow = Polymer.Settings.useNativeShadow;
  var styleUtil = Polymer.StyleUtil;
  var styleTransformer = Polymer.StyleTransformer;
  var styleExtends = Polymer.StyleExtends;
  Polymer.Base._addFeature({
  _prepElement: function (element) {
  if (this._encapsulateStyle) {
  styleTransformer.element(element, this.is, this._scopeCssViaAttr);
  }
  prepElement.call(this, element);
  },
  _prepStyles: function () {
  if (this._encapsulateStyle === undefined) {
  this._encapsulateStyle = !nativeShadow && Boolean(this._template);
  }
a1a3bc73   Luigi Serra   graphs updates
2869
  if (this._template) {
73bcce88   luigser   COMPONENTS
2870
2871
  this._styles = this._collectStyles();
  var cssText = styleTransformer.elementStyles(this);
a1a3bc73   Luigi Serra   graphs updates
2872
  if (cssText) {
73bcce88   luigser   COMPONENTS
2873
2874
2875
2876
2877
  var style = styleUtil.applyCss(cssText, this.is, nativeShadow ? this._template.content : null);
  if (!nativeShadow) {
  this._scopeStyle = style;
  }
  }
a1a3bc73   Luigi Serra   graphs updates
2878
2879
2880
  } else {
  this._styles = [];
  }
73bcce88   luigser   COMPONENTS
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
  },
  _collectStyles: function () {
  var styles = [];
  var cssText = '', m$ = this.styleModules;
  if (m$) {
  for (var i = 0, l = m$.length, m; i < l && (m = m$[i]); i++) {
  cssText += styleUtil.cssFromModule(m);
  }
  }
  cssText += styleUtil.cssFromModule(this.is);
a1a3bc73   Luigi Serra   graphs updates
2891
2892
2893
2894
  var p = this._template && this._template.parentNode;
  if (this._template && (!p || p.id.toLowerCase() !== this.is)) {
  cssText += styleUtil.cssFromElement(this._template);
  }
73bcce88   luigser   COMPONENTS
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
  if (cssText) {
  var style = document.createElement('style');
  style.textContent = cssText;
  if (styleExtends.hasExtends(style.textContent)) {
  cssText = styleExtends.transform(style);
  }
  styles.push(style);
  }
  return styles;
  },
  _elementAdd: function (node) {
  if (this._encapsulateStyle) {
  if (node.__styleScoped) {
  node.__styleScoped = false;
  } else {
  styleTransformer.dom(node, this.is, this._scopeCssViaAttr);
  }
  }
  },
  _elementRemove: function (node) {
  if (this._encapsulateStyle) {
  styleTransformer.dom(node, this.is, this._scopeCssViaAttr, true);
  }
  },
  scopeSubtree: function (container, shouldObserve) {
  if (nativeShadow) {
  return;
  }
  var self = this;
  var scopify = function (node) {
  if (node.nodeType === Node.ELEMENT_NODE) {
  node.className = self._scopeElementClass(node, node.className);
  var n$ = node.querySelectorAll('*');
a1a3bc73   Luigi Serra   graphs updates
2928
  for (var i = 0, n; i < n$.length && (n = n$[i]); i++) {
73bcce88   luigser   COMPONENTS
2929
  n.className = self._scopeElementClass(n, n.className);
a1a3bc73   Luigi Serra   graphs updates
2930
  }
73bcce88   luigser   COMPONENTS
2931
2932
2933
2934
2935
  }
  };
  scopify(container);
  if (shouldObserve) {
  var mo = new MutationObserver(function (mxns) {
a1a3bc73   Luigi Serra   graphs updates
2936
  for (var i = 0, m; i < mxns.length && (m = mxns[i]); i++) {
73bcce88   luigser   COMPONENTS
2937
  if (m.addedNodes) {
a1a3bc73   Luigi Serra   graphs updates
2938
2939
2940
  for (var j = 0; j < m.addedNodes.length; j++) {
  scopify(m.addedNodes[j]);
  }
73bcce88   luigser   COMPONENTS
2941
2942
  }
  }
73bcce88   luigser   COMPONENTS
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
  });
  mo.observe(container, {
  childList: true,
  subtree: true
  });
  return mo;
  }
  }
  });
  }());
  Polymer.StyleProperties = function () {
  'use strict';
  var nativeShadow = Polymer.Settings.useNativeShadow;
  var matchesSelector = Polymer.DomApi.matchesSelector;
  var styleUtil = Polymer.StyleUtil;
  var styleTransformer = Polymer.StyleTransformer;
  return {
  decorateStyles: function (styles) {
  var self = this, props = {};
  styleUtil.forRulesInStyles(styles, function (rule) {
  self.decorateRule(rule);
  self.collectPropertiesInCssText(rule.propertyInfo.cssText, props);
  });
  var names = [];
  for (var i in props) {
  names.push(i);
  }
  return names;
  },
  decorateRule: function (rule) {
  if (rule.propertyInfo) {
  return rule.propertyInfo;
  }
  var info = {}, properties = {};
  var hasProperties = this.collectProperties(rule, properties);
  if (hasProperties) {
  info.properties = properties;
  rule.rules = null;
  }
  info.cssText = this.collectCssText(rule);
  rule.propertyInfo = info;
  return info;
  },
  collectProperties: function (rule, properties) {
  var info = rule.propertyInfo;
  if (info) {
  if (info.properties) {
  Polymer.Base.mixin(properties, info.properties);
  return true;
  }
  } else {
  var m, rx = this.rx.VAR_ASSIGN;
  var cssText = rule.parsedCssText;
  var any;
  while (m = rx.exec(cssText)) {
  properties[m[1]] = (m[2] || m[3]).trim();
  any = true;
  }
  return any;
  }
  },
  collectCssText: function (rule) {
  var customCssText = '';
  var cssText = rule.parsedCssText;
  cssText = cssText.replace(this.rx.BRACKETED, '').replace(this.rx.VAR_ASSIGN, '');
  var parts = cssText.split(';');
  for (var i = 0, p; i < parts.length; i++) {
  p = parts[i];
  if (p.match(this.rx.MIXIN_MATCH) || p.match(this.rx.VAR_MATCH)) {
  customCssText += p + ';\n';
  }
  }
  return customCssText;
  },
  collectPropertiesInCssText: function (cssText, props) {
  var m;
  while (m = this.rx.VAR_CAPTURE.exec(cssText)) {
  props[m[1]] = true;
  var def = m[2];
  if (def && def.match(this.rx.IS_VAR)) {
  props[def] = true;
  }
  }
  },
  reify: function (props) {
  var names = Object.getOwnPropertyNames(props);
  for (var i = 0, n; i < names.length; i++) {
  n = names[i];
  props[n] = this.valueForProperty(props[n], props);
  }
  },
  valueForProperty: function (property, props) {
  if (property) {
  if (property.indexOf(';') >= 0) {
  property = this.valueForProperties(property, props);
  } else {
  var self = this;
  var fn = function (all, prefix, value, fallback) {
  var propertyValue = self.valueForProperty(props[value], props) || (props[fallback] ? self.valueForProperty(props[fallback], props) : fallback);
  return prefix + (propertyValue || '');
  };
  property = property.replace(this.rx.VAR_MATCH, fn);
  }
  }
  return property && property.trim() || '';
  },
  valueForProperties: function (property, props) {
  var parts = property.split(';');
  for (var i = 0, p, m; i < parts.length; i++) {
  if (p = parts[i]) {
  m = p.match(this.rx.MIXIN_MATCH);
  if (m) {
  p = this.valueForProperty(props[m[1]], props);
  } else {
  var pp = p.split(':');
  if (pp[1]) {
  pp[1] = pp[1].trim();
  pp[1] = this.valueForProperty(pp[1], props) || pp[1];
  }
  p = pp.join(':');
  }
  parts[i] = p && p.lastIndexOf(';') === p.length - 1 ? p.slice(0, -1) : p || '';
  }
  }
a1a3bc73   Luigi Serra   graphs updates
3067
3068
3069
  return parts.filter(function (v) {
  return v;
  }).join(';');
73bcce88   luigser   COMPONENTS
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
  },
  applyProperties: function (rule, props) {
  var output = '';
  if (!rule.propertyInfo) {
  this.decorateRule(rule);
  }
  if (rule.propertyInfo.cssText) {
  output = this.valueForProperties(rule.propertyInfo.cssText, props);
  }
  rule.cssText = output;
  },
  propertyDataFromStyles: function (styles, element) {
  var props = {}, self = this;
  var o = [], i = 0;
  styleUtil.forRulesInStyles(styles, function (rule) {
  if (!rule.propertyInfo) {
  self.decorateRule(rule);
  }
  if (element && rule.propertyInfo.properties && matchesSelector.call(element, rule.transformedSelector || rule.parsedSelector)) {
  self.collectProperties(rule, props);
  addToBitMask(i, o);
  }
  i++;
  });
  return {
  properties: props,
  key: o
  };
  },
  scopePropertiesFromStyles: function (styles) {
  if (!styles._scopeStyleProperties) {
  styles._scopeStyleProperties = this.selectedPropertiesFromStyles(styles, this.SCOPE_SELECTORS);
  }
  return styles._scopeStyleProperties;
  },
  hostPropertiesFromStyles: function (styles) {
  if (!styles._hostStyleProperties) {
  styles._hostStyleProperties = this.selectedPropertiesFromStyles(styles, this.HOST_SELECTORS);
  }
  return styles._hostStyleProperties;
  },
  selectedPropertiesFromStyles: function (styles, selectors) {
  var props = {}, self = this;
  styleUtil.forRulesInStyles(styles, function (rule) {
  if (!rule.propertyInfo) {
  self.decorateRule(rule);
  }
  for (var i = 0; i < selectors.length; i++) {
  if (rule.parsedSelector === selectors[i]) {
  self.collectProperties(rule, props);
  return;
  }
  }
  });
  return props;
  },
  transformStyles: function (element, properties, scopeSelector) {
  var self = this;
  var hostSelector = styleTransformer._calcHostScope(element.is, element.extends);
  var rxHostSelector = element.extends ? '\\' + hostSelector.slice(0, -1) + '\\]' : hostSelector;
  var hostRx = new RegExp(this.rx.HOST_PREFIX + rxHostSelector + this.rx.HOST_SUFFIX);
  return styleTransformer.elementStyles(element, function (rule) {
  self.applyProperties(rule, properties);
  if (rule.cssText && !nativeShadow) {
  self._scopeSelector(rule, hostRx, hostSelector, element._scopeCssViaAttr, scopeSelector);
  }
  });
  },
  _scopeSelector: function (rule, hostRx, hostSelector, viaAttr, scopeId) {
  rule.transformedSelector = rule.transformedSelector || rule.selector;
  var selector = rule.transformedSelector;
  var scope = viaAttr ? '[' + styleTransformer.SCOPE_NAME + '~=' + scopeId + ']' : '.' + scopeId;
  var parts = selector.split(',');
  for (var i = 0, l = parts.length, p; i < l && (p = parts[i]); i++) {
  parts[i] = p.match(hostRx) ? p.replace(hostSelector, hostSelector + scope) : scope + ' ' + p;
  }
  rule.selector = parts.join(',');
  },
  applyElementScopeSelector: function (element, selector, old, viaAttr) {
  var c = viaAttr ? element.getAttribute(styleTransformer.SCOPE_NAME) : element.className;
  var v = old ? c.replace(old, selector) : (c ? c + ' ' : '') + this.XSCOPE_NAME + ' ' + selector;
  if (c !== v) {
  if (viaAttr) {
  element.setAttribute(styleTransformer.SCOPE_NAME, v);
  } else {
  element.className = v;
  }
  }
  },
  applyElementStyle: function (element, properties, selector, style) {
  var cssText = style ? style.textContent || '' : this.transformStyles(element, properties, selector);
  var s = element._customStyle;
  if (s && !nativeShadow && s !== style) {
  s._useCount--;
  if (s._useCount <= 0 && s.parentNode) {
  s.parentNode.removeChild(s);
  }
  }
  if (nativeShadow || (!style || !style.parentNode)) {
  if (nativeShadow && element._customStyle) {
  element._customStyle.textContent = cssText;
  style = element._customStyle;
  } else if (cssText) {
  style = styleUtil.applyCss(cssText, selector, nativeShadow ? element.root : null, element._scopeStyle);
  }
  }
  if (style) {
  style._useCount = style._useCount || 0;
  if (element._customStyle != style) {
  style._useCount++;
  }
  element._customStyle = style;
  }
  return style;
  },
  mixinCustomStyle: function (props, customStyle) {
  var v;
  for (var i in customStyle) {
  v = customStyle[i];
  if (v || v === 0) {
  props[i] = v;
  }
  }
  },
  rx: {
a1a3bc73   Luigi Serra   graphs updates
3195
  VAR_ASSIGN: /(?:^|[;\s{]\s*)(--[\w-]*?)\s*:\s*(?:([^;{]*)|{([^}]*)})(?:(?=[;\s}])|$)/gi,
73bcce88   luigser   COMPONENTS
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
  MIXIN_MATCH: /(?:^|\W+)@apply[\s]*\(([^)]*)\)/i,
  VAR_MATCH: /(^|\W+)var\([\s]*([^,)]*)[\s]*,?[\s]*((?:[^,)]*)|(?:[^;]*\([^;)]*\)))[\s]*?\)/gi,
  VAR_CAPTURE: /\([\s]*(--[^,\s)]*)(?:,[\s]*(--[^,\s)]*))?(?:\)|,)/gi,
  IS_VAR: /^--/,
  BRACKETED: /\{[^}]*\}/g,
  HOST_PREFIX: '(?:^|[^.#[:])',
  HOST_SUFFIX: '($|[.:[\\s>+~])'
  },
  HOST_SELECTORS: [':host'],
  SCOPE_SELECTORS: [':root'],
  XSCOPE_NAME: 'x-scope'
  };
  function addToBitMask(n, bits) {
  var o = parseInt(n / 32);
  var v = 1 << n % 32;
  bits[o] = (bits[o] || 0) | v;
  }
  }();
  (function () {
  Polymer.StyleCache = function () {
  this.cache = {};
  };
  Polymer.StyleCache.prototype = {
  MAX: 100,
  store: function (is, data, keyValues, keyStyles) {
  data.keyValues = keyValues;
  data.styles = keyStyles;
  var s$ = this.cache[is] = this.cache[is] || [];
  s$.push(data);
  if (s$.length > this.MAX) {
  s$.shift();
  }
  },
  retrieve: function (is, keyValues, keyStyles) {
  var cache = this.cache[is];
  if (cache) {
  for (var i = cache.length - 1, data; i >= 0; i--) {
  data = cache[i];
  if (keyStyles === data.styles && this._objectsEqual(keyValues, data.keyValues)) {
  return data;
  }
  }
  }
  },
  clear: function () {
  this.cache = {};
  },
  _objectsEqual: function (target, source) {
  var t, s;
  for (var i in target) {
  t = target[i], s = source[i];
  if (!(typeof t === 'object' && t ? this._objectsStrictlyEqual(t, s) : t === s)) {
  return false;
  }
  }
  if (Array.isArray(target)) {
  return target.length === source.length;
  }
  return true;
  },
  _objectsStrictlyEqual: function (target, source) {
  return this._objectsEqual(target, source) && this._objectsEqual(source, target);
  }
  };
  }());
  Polymer.StyleDefaults = function () {
  var styleProperties = Polymer.StyleProperties;
  var styleUtil = Polymer.StyleUtil;
  var StyleCache = Polymer.StyleCache;
  var api = {
  _styles: [],
  _properties: null,
  customStyle: {},
  _styleCache: new StyleCache(),
  addStyle: function (style) {
  this._styles.push(style);
  this._properties = null;
  },
  get _styleProperties() {
  if (!this._properties) {
  styleProperties.decorateStyles(this._styles);
  this._styles._scopeStyleProperties = null;
  this._properties = styleProperties.scopePropertiesFromStyles(this._styles);
  styleProperties.mixinCustomStyle(this._properties, this.customStyle);
  styleProperties.reify(this._properties);
  }
  return this._properties;
  },
  _needsStyleProperties: function () {
  },
  _computeStyleProperties: function () {
  return this._styleProperties;
  },
  updateStyles: function (properties) {
  this._properties = null;
  if (properties) {
  Polymer.Base.mixin(this.customStyle, properties);
  }
  this._styleCache.clear();
  for (var i = 0, s; i < this._styles.length; i++) {
  s = this._styles[i];
  s = s.__importElement || s;
  s._apply();
  }
  }
  };
  return api;
  }();
  (function () {
  'use strict';
  var serializeValueToAttribute = Polymer.Base.serializeValueToAttribute;
  var propertyUtils = Polymer.StyleProperties;
  var styleTransformer = Polymer.StyleTransformer;
  var styleUtil = Polymer.StyleUtil;
  var styleDefaults = Polymer.StyleDefaults;
  var nativeShadow = Polymer.Settings.useNativeShadow;
  Polymer.Base._addFeature({
  _prepStyleProperties: function () {
a1a3bc73   Luigi Serra   graphs updates
3314
3315
3316
3317
3318
  this._ownStylePropertyNames = this._styles ? propertyUtils.decorateStyles(this._styles) : null;
  },
  customStyle: null,
  getComputedStyleValue: function (property) {
  return this._styleProperties && this._styleProperties[property] || getComputedStyle(this).getPropertyValue(property);
73bcce88   luigser   COMPONENTS
3319
  },
73bcce88   luigser   COMPONENTS
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
  _setupStyleProperties: function () {
  this.customStyle = {};
  },
  _needsStyleProperties: function () {
  return Boolean(this._ownStylePropertyNames && this._ownStylePropertyNames.length);
  },
  _beforeAttached: function () {
  if (!this._scopeSelector && this._needsStyleProperties()) {
  this._updateStyleProperties();
  }
  },
  _findStyleHost: function () {
  var e = this, root;
  while (root = Polymer.dom(e).getOwnerRoot()) {
  if (Polymer.isInstance(root.host)) {
  return root.host;
  }
  e = root.host;
  }
  return styleDefaults;
  },
  _updateStyleProperties: function () {
  var info, scope = this._findStyleHost();
  if (!scope._styleCache) {
  scope._styleCache = new Polymer.StyleCache();
  }
  var scopeData = propertyUtils.propertyDataFromStyles(scope._styles, this);
  scopeData.key.customStyle = this.customStyle;
  info = scope._styleCache.retrieve(this.is, scopeData.key, this._styles);
  var scopeCached = Boolean(info);
  if (scopeCached) {
  this._styleProperties = info._styleProperties;
  } else {
  this._computeStyleProperties(scopeData.properties);
  }
  this._computeOwnStyleProperties();
  if (!scopeCached) {
  info = styleCache.retrieve(this.is, this._ownStyleProperties, this._styles);
  }
  var globalCached = Boolean(info) && !scopeCached;
  var style = this._applyStyleProperties(info);
  if (!scopeCached) {
  style = style && nativeShadow ? style.cloneNode(true) : style;
  info = {
  style: style,
  _scopeSelector: this._scopeSelector,
  _styleProperties: this._styleProperties
  };
  scopeData.key.customStyle = {};
  this.mixin(scopeData.key.customStyle, this.customStyle);
  scope._styleCache.store(this.is, info, scopeData.key, this._styles);
  if (!globalCached) {
  styleCache.store(this.is, Object.create(info), this._ownStyleProperties, this._styles);
  }
  }
  },
  _computeStyleProperties: function (scopeProps) {
  var scope = this._findStyleHost();
  if (!scope._styleProperties) {
  scope._computeStyleProperties();
  }
  var props = Object.create(scope._styleProperties);
  this.mixin(props, propertyUtils.hostPropertiesFromStyles(this._styles));
  scopeProps = scopeProps || propertyUtils.propertyDataFromStyles(scope._styles, this).properties;
  this.mixin(props, scopeProps);
  this.mixin(props, propertyUtils.scopePropertiesFromStyles(this._styles));
  propertyUtils.mixinCustomStyle(props, this.customStyle);
  propertyUtils.reify(props);
  this._styleProperties = props;
  },
  _computeOwnStyleProperties: function () {
  var props = {};
  for (var i = 0, n; i < this._ownStylePropertyNames.length; i++) {
  n = this._ownStylePropertyNames[i];
  props[n] = this._styleProperties[n];
  }
  this._ownStyleProperties = props;
  },
  _scopeCount: 0,
  _applyStyleProperties: function (info) {
  var oldScopeSelector = this._scopeSelector;
  this._scopeSelector = info ? info._scopeSelector : this.is + '-' + this.__proto__._scopeCount++;
  var style = propertyUtils.applyElementStyle(this, this._styleProperties, this._scopeSelector, info && info.style);
  if (!nativeShadow) {
  propertyUtils.applyElementScopeSelector(this, this._scopeSelector, oldScopeSelector, this._scopeCssViaAttr);
  }
  return style;
  },
  serializeValueToAttribute: function (value, attribute, node) {
  node = node || this;
  if (attribute === 'class' && !nativeShadow) {
  var host = node === this ? this.domHost || this.dataHost : this;
  if (host) {
  value = host._scopeElementClass(node, value);
  }
  }
a1a3bc73   Luigi Serra   graphs updates
3416
  node = this.shadyRoot && this.shadyRoot._hasDistributed ? Polymer.dom(node) : node;
73bcce88   luigser   COMPONENTS
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
  serializeValueToAttribute.call(this, value, attribute, node);
  },
  _scopeElementClass: function (element, selector) {
  if (!nativeShadow && !this._scopeCssViaAttr) {
  selector += (selector ? ' ' : '') + SCOPE_NAME + ' ' + this.is + (element._scopeSelector ? ' ' + XSCOPE_NAME + ' ' + element._scopeSelector : '');
  }
  return selector;
  },
  updateStyles: function (properties) {
  if (this.isAttached) {
  if (properties) {
  this.mixin(this.customStyle, properties);
  }
  if (this._needsStyleProperties()) {
  this._updateStyleProperties();
  } else {
  this._styleProperties = null;
  }
  if (this._styleCache) {
  this._styleCache.clear();
  }
  this._updateRootStyles();
  }
  },
  _updateRootStyles: function (root) {
  root = root || this.root;
  var c$ = Polymer.dom(root)._query(function (e) {
  return e.shadyRoot || e.shadowRoot;
  });
  for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
  if (c.updateStyles) {
  c.updateStyles();
  }
  }
  }
  });
  Polymer.updateStyles = function (properties) {
  styleDefaults.updateStyles(properties);
  Polymer.Base._updateRootStyles(document);
  };
  var styleCache = new Polymer.StyleCache();
  Polymer.customStyleCache = styleCache;
  var SCOPE_NAME = styleTransformer.SCOPE_NAME;
  var XSCOPE_NAME = propertyUtils.XSCOPE_NAME;
  }());
  Polymer.Base._addFeature({
  _registerFeatures: function () {
  this._prepIs();
73bcce88   luigser   COMPONENTS
3465
3466
3467
3468
3469
3470
3471
  this._prepConstructor();
  this._prepTemplate();
  this._prepStyles();
  this._prepStyleProperties();
  this._prepAnnotations();
  this._prepEffects();
  this._prepBehaviors();
a1a3bc73   Luigi Serra   graphs updates
3472
  this._prepPropertyInfo();
73bcce88   luigser   COMPONENTS
3473
3474
3475
3476
3477
3478
3479
3480
3481
  this._prepBindings();
  this._prepShady();
  },
  _prepBehavior: function (b) {
  this._addPropertyEffects(b.properties);
  this._addComplexObserverEffects(b.observers);
  this._addHostAttributes(b.hostAttributes);
  },
  _initFeatures: function () {
73bcce88   luigser   COMPONENTS
3482
3483
  this._setupConfigure();
  this._setupStyleProperties();
a1a3bc73   Luigi Serra   graphs updates
3484
3485
3486
3487
3488
  this._setupDebouncers();
  this._registerHost();
  if (this._template) {
  this._poolContent();
  this._beginHosting();
73bcce88   luigser   COMPONENTS
3489
  this._stampTemplate();
a1a3bc73   Luigi Serra   graphs updates
3490
  this._endHosting();
73bcce88   luigser   COMPONENTS
3491
  this._marshalAnnotationReferences();
a1a3bc73   Luigi Serra   graphs updates
3492
  }
73bcce88   luigser   COMPONENTS
3493
  this._marshalInstanceEffects();
73bcce88   luigser   COMPONENTS
3494
  this._marshalBehaviors();
a1a3bc73   Luigi Serra   graphs updates
3495
  this._marshalHostAttributes();
73bcce88   luigser   COMPONENTS
3496
3497
3498
3499
  this._marshalAttributes();
  this._tryReady();
  },
  _marshalBehavior: function (b) {
a1a3bc73   Luigi Serra   graphs updates
3500
  if (b.listeners) {
73bcce88   luigser   COMPONENTS
3501
3502
  this._listenListeners(b.listeners);
  }
a1a3bc73   Luigi Serra   graphs updates
3503
  }
73bcce88   luigser   COMPONENTS
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
  });
  (function () {
  var nativeShadow = Polymer.Settings.useNativeShadow;
  var propertyUtils = Polymer.StyleProperties;
  var styleUtil = Polymer.StyleUtil;
  var cssParse = Polymer.CssParse;
  var styleDefaults = Polymer.StyleDefaults;
  var styleTransformer = Polymer.StyleTransformer;
  Polymer({
  is: 'custom-style',
  extends: 'style',
a1a3bc73   Luigi Serra   graphs updates
3515
  _template: null,
73bcce88   luigser   COMPONENTS
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
  properties: { include: String },
  ready: function () {
  this._tryApply();
  },
  attached: function () {
  this._tryApply();
  },
  _tryApply: function () {
  if (!this._appliesToDocument) {
  if (this.parentNode && this.parentNode.localName !== 'dom-module') {
  this._appliesToDocument = true;
  var e = this.__appliedElement || this;
  styleDefaults.addStyle(e);
  if (e.textContent || this.include) {
a1a3bc73   Luigi Serra   graphs updates
3530
  this._apply(true);
73bcce88   luigser   COMPONENTS
3531
  } else {
a1a3bc73   Luigi Serra   graphs updates
3532
  var self = this;
73bcce88   luigser   COMPONENTS
3533
3534
  var observer = new MutationObserver(function () {
  observer.disconnect();
a1a3bc73   Luigi Serra   graphs updates
3535
3536
  self._apply(true);
  });
73bcce88   luigser   COMPONENTS
3537
3538
3539
3540
3541
  observer.observe(e, { childList: true });
  }
  }
  }
  },
a1a3bc73   Luigi Serra   graphs updates
3542
  _apply: function (deferProperties) {
73bcce88   luigser   COMPONENTS
3543
3544
3545
3546
3547
3548
3549
3550
  var e = this.__appliedElement || this;
  if (this.include) {
  e.textContent = styleUtil.cssFromModules(this.include, true) + e.textContent;
  }
  if (e.textContent) {
  styleUtil.forEachStyleRule(styleUtil.rulesForStyle(e), function (rule) {
  styleTransformer.documentRule(rule);
  });
a1a3bc73   Luigi Serra   graphs updates
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
  var self = this;
  function fn() {
  self._applyCustomProperties(e);
  }
  if (this._pendingApplyProperties) {
  cancelAnimationFrame(this._pendingApplyProperties);
  this._pendingApplyProperties = null;
  }
  if (deferProperties) {
  this._pendingApplyProperties = requestAnimationFrame(fn);
  } else {
  fn();
  }
73bcce88   luigser   COMPONENTS
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
  }
  },
  _applyCustomProperties: function (element) {
  this._computeStyleProperties();
  var props = this._styleProperties;
  var rules = styleUtil.rulesForStyle(element);
  element.textContent = styleUtil.toCssText(rules, function (rule) {
  var css = rule.cssText = rule.parsedCssText;
  if (rule.propertyInfo && rule.propertyInfo.cssText) {
  css = cssParse.removeCustomPropAssignment(css);
  rule.cssText = propertyUtils.valueForProperties(css, props);
  }
  });
  }
  });
  }());
  Polymer.Templatizer = {
  properties: { __hideTemplateChildren__: { observer: '_showHideChildren' } },
  _instanceProps: Polymer.nob,
  _parentPropPrefix: '_parent_',
  templatize: function (template) {
eb240478   Luigi Serra   public room cards...
3585
  this._templatized = template;
73bcce88   luigser   COMPONENTS
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
  if (!template._content) {
  template._content = template.content;
  }
  if (template._content._ctor) {
  this.ctor = template._content._ctor;
  this._prepParentProperties(this.ctor.prototype, template);
  return;
  }
  var archetype = Object.create(Polymer.Base);
  this._customPrepAnnotations(archetype, template);
eb240478   Luigi Serra   public room cards...
3596
  this._prepParentProperties(archetype, template);
73bcce88   luigser   COMPONENTS
3597
3598
3599
  archetype._prepEffects();
  this._customPrepEffects(archetype);
  archetype._prepBehaviors();
a1a3bc73   Luigi Serra   graphs updates
3600
  archetype._prepPropertyInfo();
73bcce88   luigser   COMPONENTS
3601
  archetype._prepBindings();
f748e9cf   Luigi Serra   new controllet an...
3602
  archetype._notifyPathUp = this._notifyPathUpImpl;
73bcce88   luigser   COMPONENTS
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
  archetype._scopeElementClass = this._scopeElementClassImpl;
  archetype.listen = this._listenImpl;
  archetype._showHideChildren = this._showHideChildrenImpl;
  var _constructor = this._constructorImpl;
  var ctor = function TemplateInstance(model, host) {
  _constructor.call(this, model, host);
  };
  ctor.prototype = archetype;
  archetype.constructor = ctor;
  template._content._ctor = ctor;
  this.ctor = ctor;
  },
  _getRootDataHost: function () {
  return this.dataHost && this.dataHost._rootDataHost || this.dataHost;
  },
  _showHideChildrenImpl: function (hide) {
  var c = this._children;
  for (var i = 0; i < c.length; i++) {
  var n = c[i];
  if (Boolean(hide) != Boolean(n.__hideTemplateChildren__)) {
  if (n.nodeType === Node.TEXT_NODE) {
  if (hide) {
  n.__polymerTextContent__ = n.textContent;
  n.textContent = '';
  } else {
  n.textContent = n.__polymerTextContent__;
  }
  } else if (n.style) {
  if (hide) {
  n.__polymerDisplay__ = n.style.display;
  n.style.display = 'none';
  } else {
  n.style.display = n.__polymerDisplay__;
  }
  }
  }
  n.__hideTemplateChildren__ = hide;
  }
  },
  _debounceTemplate: function (fn) {
  Polymer.dom.addDebouncer(this.debounce('_debounceTemplate', fn));
  },
  _flushTemplates: function (debouncerExpired) {
  Polymer.dom.flush();
  },
  _customPrepEffects: function (archetype) {
  var parentProps = archetype._parentProps;
  for (var prop in parentProps) {
  archetype._addPropertyEffect(prop, 'function', this._createHostPropEffector(prop));
  }
  for (var prop in this._instanceProps) {
  archetype._addPropertyEffect(prop, 'function', this._createInstancePropEffector(prop));
  }
  },
  _customPrepAnnotations: function (archetype, template) {
  archetype._template = template;
  var c = template._content;
  if (!c._notes) {
  var rootDataHost = archetype._rootDataHost;
  if (rootDataHost) {
a1a3bc73   Luigi Serra   graphs updates
3663
3664
3665
  Polymer.Annotations.prepElement = function () {
  rootDataHost._prepElement();
  };
73bcce88   luigser   COMPONENTS
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
  }
  c._notes = Polymer.Annotations.parseAnnotations(template);
  Polymer.Annotations.prepElement = null;
  this._processAnnotations(c._notes);
  }
  archetype._notes = c._notes;
  archetype._parentProps = c._parentProps;
  },
  _prepParentProperties: function (archetype, template) {
  var parentProps = this._parentProps = archetype._parentProps;
  if (this._forwardParentProp && parentProps) {
  var proto = archetype._parentPropProto;
  var prop;
  if (!proto) {
  for (prop in this._instanceProps) {
  delete parentProps[prop];
  }
  proto = archetype._parentPropProto = Object.create(null);
  if (template != this) {
  Polymer.Bind.prepareModel(proto);
eb240478   Luigi Serra   public room cards...
3686
  Polymer.Base.prepareModelNotifyPath(proto);
73bcce88   luigser   COMPONENTS
3687
3688
3689
3690
3691
3692
  }
  for (prop in parentProps) {
  var parentProp = this._parentPropPrefix + prop;
  var effects = [
  {
  kind: 'function',
a1a3bc73   Luigi Serra   graphs updates
3693
3694
  effect: this._createForwardPropEffector(prop),
  fn: Polymer.Bind._functionEffect
73bcce88   luigser   COMPONENTS
3695
  },
a1a3bc73   Luigi Serra   graphs updates
3696
3697
3698
3699
3700
  {
  kind: 'notify',
  fn: Polymer.Bind._notifyEffect,
  effect: { event: Polymer.CaseMap.camelToDashCase(parentProp) + '-changed' }
  }
73bcce88   luigser   COMPONENTS
3701
3702
3703
3704
  ];
  Polymer.Bind._createAccessors(proto, parentProp, effects);
  }
  }
a1a3bc73   Luigi Serra   graphs updates
3705
  var self = this;
73bcce88   luigser   COMPONENTS
3706
3707
  if (template != this) {
  Polymer.Bind.prepareInstance(template);
a1a3bc73   Luigi Serra   graphs updates
3708
3709
3710
  template._forwardParentProp = function (source, value) {
  self._forwardParentProp(source, value);
  };
73bcce88   luigser   COMPONENTS
3711
3712
  }
  this._extendTemplate(template, proto);
a1a3bc73   Luigi Serra   graphs updates
3713
3714
3715
  template._pathEffector = function (path, value, fromAbove) {
  return self._pathEffectorImpl(path, value, fromAbove);
  };
73bcce88   luigser   COMPONENTS
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
  }
  },
  _createForwardPropEffector: function (prop) {
  return function (source, value) {
  this._forwardParentProp(prop, value);
  };
  },
  _createHostPropEffector: function (prop) {
  var prefix = this._parentPropPrefix;
  return function (source, value) {
eb240478   Luigi Serra   public room cards...
3726
  this.dataHost._templatized[prefix + prop] = value;
73bcce88   luigser   COMPONENTS
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
  };
  },
  _createInstancePropEffector: function (prop) {
  return function (source, value, old, fromAbove) {
  if (!fromAbove) {
  this.dataHost._forwardInstanceProp(this, prop, value);
  }
  };
  },
  _extendTemplate: function (template, proto) {
a1a3bc73   Luigi Serra   graphs updates
3737
3738
  var n$ = Object.getOwnPropertyNames(proto);
  for (var i = 0, n; i < n$.length && (n = n$[i]); i++) {
73bcce88   luigser   COMPONENTS
3739
3740
3741
3742
3743
3744
  var val = template[n];
  var pd = Object.getOwnPropertyDescriptor(proto, n);
  Object.defineProperty(template, n, pd);
  if (val !== undefined) {
  template._propertySetter(n, val);
  }
a1a3bc73   Luigi Serra   graphs updates
3745
  }
73bcce88   luigser   COMPONENTS
3746
3747
3748
3749
3750
3751
3752
  },
  _showHideChildren: function (hidden) {
  },
  _forwardInstancePath: function (inst, path, value) {
  },
  _forwardInstanceProp: function (inst, prop, value) {
  },
f748e9cf   Luigi Serra   new controllet an...
3753
  _notifyPathUpImpl: function (path, value) {
73bcce88   luigser   COMPONENTS
3754
3755
3756
3757
3758
  var dataHost = this.dataHost;
  var dot = path.indexOf('.');
  var root = dot < 0 ? path : path.slice(0, dot);
  dataHost._forwardInstancePath.call(dataHost, this, path, value);
  if (root in dataHost._parentProps) {
eb240478   Luigi Serra   public room cards...
3759
  dataHost._templatized.notifyPath(dataHost._parentPropPrefix + path, value);
73bcce88   luigser   COMPONENTS
3760
3761
  }
  },
eb240478   Luigi Serra   public room cards...
3762
  _pathEffectorImpl: function (path, value, fromAbove) {
73bcce88   luigser   COMPONENTS
3763
3764
  if (this._forwardParentPath) {
  if (path.indexOf(this._parentPropPrefix) === 0) {
eb240478   Luigi Serra   public room cards...
3765
  var subPath = path.substring(this._parentPropPrefix.length);
a1a3bc73   Luigi Serra   graphs updates
3766
3767
  var model = this._modelForPath(subPath);
  if (model in this._parentProps) {
eb240478   Luigi Serra   public room cards...
3768
  this._forwardParentPath(subPath, value);
73bcce88   luigser   COMPONENTS
3769
3770
  }
  }
a1a3bc73   Luigi Serra   graphs updates
3771
  }
eb240478   Luigi Serra   public room cards...
3772
  Polymer.Base._pathEffector.call(this._templatized, path, value, fromAbove);
73bcce88   luigser   COMPONENTS
3773
3774
3775
3776
  },
  _constructorImpl: function (model, host) {
  this._rootDataHost = host._getRootDataHost();
  this._setupConfigure(model);
a1a3bc73   Luigi Serra   graphs updates
3777
3778
  this._registerHost(host);
  this._beginHosting();
73bcce88   luigser   COMPONENTS
3779
3780
3781
  this.root = this.instanceTemplate(this._template);
  this.root.__noContent = !this._notes._hasContent;
  this.root.__styleScoped = true;
a1a3bc73   Luigi Serra   graphs updates
3782
  this._endHosting();
73bcce88   luigser   COMPONENTS
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
  this._marshalAnnotatedNodes();
  this._marshalInstanceEffects();
  this._marshalAnnotatedListeners();
  var children = [];
  for (var n = this.root.firstChild; n; n = n.nextSibling) {
  children.push(n);
  n._templateInstance = this;
  }
  this._children = children;
  if (host.__hideTemplateChildren__) {
  this._showHideChildren(true);
  }
  this._tryReady();
  },
  _listenImpl: function (node, eventName, methodName) {
  var model = this;
  var host = this._rootDataHost;
  var handler = host._createEventHandler(node, eventName, methodName);
  var decorated = function (e) {
  e.model = model;
  handler(e);
  };
  host._listen(node, eventName, decorated);
  },
  _scopeElementClassImpl: function (node, value) {
  var host = this._rootDataHost;
  if (host) {
  return host._scopeElementClass(node, value);
  }
  },
  stamp: function (model) {
  model = model || {};
  if (this._parentProps) {
eb240478   Luigi Serra   public room cards...
3816
  var templatized = this._templatized;
73bcce88   luigser   COMPONENTS
3817
  for (var prop in this._parentProps) {
eb240478   Luigi Serra   public room cards...
3818
  model[prop] = templatized[this._parentPropPrefix + prop];
73bcce88   luigser   COMPONENTS
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
  }
  }
  return new this.ctor(model, this);
  },
  modelForElement: function (el) {
  var model;
  while (el) {
  if (model = el._templateInstance) {
  if (model.dataHost != this) {
  el = model.dataHost;
  } else {
  return model;
  }
  } else {
  el = el.parentNode;
  }
  }
  }
  };
  Polymer({
  is: 'dom-template',
  extends: 'template',
a1a3bc73   Luigi Serra   graphs updates
3841
  _template: null,
73bcce88   luigser   COMPONENTS
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
  behaviors: [Polymer.Templatizer],
  ready: function () {
  this.templatize(this);
  }
  });
  Polymer._collections = new WeakMap();
  Polymer.Collection = function (userArray) {
  Polymer._collections.set(userArray, this);
  this.userArray = userArray;
  this.store = userArray.slice();
  this.initMap();
  };
  Polymer.Collection.prototype = {
  constructor: Polymer.Collection,
  initMap: function () {
  var omap = this.omap = new WeakMap();
  var pmap = this.pmap = {};
  var s = this.store;
  for (var i = 0; i < s.length; i++) {
  var item = s[i];
  if (item && typeof item == 'object') {
  omap.set(item, i);
  } else {
  pmap[item] = i;
  }
  }
  },
  add: function (item) {
  var key = this.store.push(item) - 1;
  if (item && typeof item == 'object') {
  this.omap.set(item, key);
  } else {
  this.pmap[item] = key;
  }
f748e9cf   Luigi Serra   new controllet an...
3876
  return '#' + key;
73bcce88   luigser   COMPONENTS
3877
3878
  },
  removeKey: function (key) {
f748e9cf   Luigi Serra   new controllet an...
3879
  key = this._parseKey(key);
73bcce88   luigser   COMPONENTS
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
  this._removeFromMap(this.store[key]);
  delete this.store[key];
  },
  _removeFromMap: function (item) {
  if (item && typeof item == 'object') {
  this.omap.delete(item);
  } else {
  delete this.pmap[item];
  }
  },
  remove: function (item) {
  var key = this.getKey(item);
  this.removeKey(key);
  return key;
  },
  getKey: function (item) {
f748e9cf   Luigi Serra   new controllet an...
3896
  var key;
73bcce88   luigser   COMPONENTS
3897
  if (item && typeof item == 'object') {
f748e9cf   Luigi Serra   new controllet an...
3898
  key = this.omap.get(item);
73bcce88   luigser   COMPONENTS
3899
  } else {
f748e9cf   Luigi Serra   new controllet an...
3900
3901
3902
3903
  key = this.pmap[item];
  }
  if (key != undefined) {
  return '#' + key;
73bcce88   luigser   COMPONENTS
3904
3905
3906
  }
  },
  getKeys: function () {
f748e9cf   Luigi Serra   new controllet an...
3907
3908
3909
3910
3911
3912
3913
3914
3915
  return Object.keys(this.store).map(function (key) {
  return '#' + key;
  });
  },
  _parseKey: function (key) {
  if (key[0] == '#') {
  return key.slice(1);
  }
  throw new Error('unexpected key ' + key);
73bcce88   luigser   COMPONENTS
3916
3917
  },
  setItem: function (key, item) {
f748e9cf   Luigi Serra   new controllet an...
3918
  key = this._parseKey(key);
73bcce88   luigser   COMPONENTS
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
  var old = this.store[key];
  if (old) {
  this._removeFromMap(old);
  }
  if (item && typeof item == 'object') {
  this.omap.set(item, key);
  } else {
  this.pmap[item] = key;
  }
  this.store[key] = item;
  },
  getItem: function (key) {
f748e9cf   Luigi Serra   new controllet an...
3931
  key = this._parseKey(key);
73bcce88   luigser   COMPONENTS
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
  return this.store[key];
  },
  getItems: function () {
  var items = [], store = this.store;
  for (var key in store) {
  items.push(store[key]);
  }
  return items;
  },
  _applySplices: function (splices) {
a1a3bc73   Luigi Serra   graphs updates
3942
3943
  var keyMap = {}, key;
  for (var i = 0, s; i < splices.length && (s = splices[i]); i++) {
73bcce88   luigser   COMPONENTS
3944
  s.addedKeys = [];
a1a3bc73   Luigi Serra   graphs updates
3945
3946
  for (var j = 0; j < s.removed.length; j++) {
  key = this.getKey(s.removed[j]);
73bcce88   luigser   COMPONENTS
3947
3948
  keyMap[key] = keyMap[key] ? null : -1;
  }
a1a3bc73   Luigi Serra   graphs updates
3949
3950
  for (var j = 0; j < s.addedCount; j++) {
  var item = this.userArray[s.index + j];
73bcce88   luigser   COMPONENTS
3951
3952
3953
3954
3955
  key = this.getKey(item);
  key = key === undefined ? this.add(item) : key;
  keyMap[key] = keyMap[key] ? null : 1;
  s.addedKeys.push(key);
  }
a1a3bc73   Luigi Serra   graphs updates
3956
  }
73bcce88   luigser   COMPONENTS
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
  var removed = [];
  var added = [];
  for (var key in keyMap) {
  if (keyMap[key] < 0) {
  this.removeKey(key);
  removed.push(key);
  }
  if (keyMap[key] > 0) {
  added.push(key);
  }
  }
  return [{
  removed: removed,
  added: added
  }];
  }
  };
  Polymer.Collection.get = function (userArray) {
  return Polymer._collections.get(userArray) || new Polymer.Collection(userArray);
  };
  Polymer.Collection.applySplices = function (userArray, splices) {
  var coll = Polymer._collections.get(userArray);
  return coll ? coll._applySplices(splices) : null;
  };
  Polymer({
  is: 'dom-repeat',
  extends: 'template',
a1a3bc73   Luigi Serra   graphs updates
3984
  _template: null,
73bcce88   luigser   COMPONENTS
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
  properties: {
  items: { type: Array },
  as: {
  type: String,
  value: 'item'
  },
  indexAs: {
  type: String,
  value: 'index'
  },
  sort: {
  type: Function,
  observer: '_sortChanged'
  },
  filter: {
  type: Function,
  observer: '_filterChanged'
  },
  observe: {
  type: String,
  observer: '_observeChanged'
  },
a1a3bc73   Luigi Serra   graphs updates
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
  delay: Number,
  initialCount: {
  type: Number,
  observer: '_initializeChunking'
  },
  targetFramerate: {
  type: Number,
  value: 20
  },
  _targetFrameTime: { computed: '_computeFrameTime(targetFramerate)' }
73bcce88   luigser   COMPONENTS
4017
4018
4019
4020
4021
  },
  behaviors: [Polymer.Templatizer],
  observers: ['_itemsChanged(items.*)'],
  created: function () {
  this._instances = [];
a1a3bc73   Luigi Serra   graphs updates
4022
4023
4024
4025
4026
4027
  this._pool = [];
  this._limit = Infinity;
  var self = this;
  this._boundRenderChunk = function () {
  self._renderChunk();
  };
73bcce88   luigser   COMPONENTS
4028
4029
4030
  },
  detached: function () {
  for (var i = 0; i < this._instances.length; i++) {
a1a3bc73   Luigi Serra   graphs updates
4031
  this._detachInstance(i);
73bcce88   luigser   COMPONENTS
4032
4033
4034
  }
  },
  attached: function () {
a1a3bc73   Luigi Serra   graphs updates
4035
  var parent = Polymer.dom(Polymer.dom(this).parentNode);
73bcce88   luigser   COMPONENTS
4036
  for (var i = 0; i < this._instances.length; i++) {
a1a3bc73   Luigi Serra   graphs updates
4037
  this._attachInstance(i, parent);
73bcce88   luigser   COMPONENTS
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
  }
  },
  ready: function () {
  this._instanceProps = { __key__: true };
  this._instanceProps[this.as] = true;
  this._instanceProps[this.indexAs] = true;
  if (!this.ctor) {
  this.templatize(this);
  }
  },
a1a3bc73   Luigi Serra   graphs updates
4048
  _sortChanged: function (sort) {
73bcce88   luigser   COMPONENTS
4049
  var dataHost = this._getRootDataHost();
73bcce88   luigser   COMPONENTS
4050
4051
4052
4053
4054
4055
4056
4057
  this._sortFn = sort && (typeof sort == 'function' ? sort : function () {
  return dataHost[sort].apply(dataHost, arguments);
  });
  this._needFullRefresh = true;
  if (this.items) {
  this._debounceTemplate(this._render);
  }
  },
a1a3bc73   Luigi Serra   graphs updates
4058
  _filterChanged: function (filter) {
73bcce88   luigser   COMPONENTS
4059
  var dataHost = this._getRootDataHost();
73bcce88   luigser   COMPONENTS
4060
4061
4062
4063
4064
4065
4066
4067
  this._filterFn = filter && (typeof filter == 'function' ? filter : function () {
  return dataHost[filter].apply(dataHost, arguments);
  });
  this._needFullRefresh = true;
  if (this.items) {
  this._debounceTemplate(this._render);
  }
  },
a1a3bc73   Luigi Serra   graphs updates
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
  _computeFrameTime: function (rate) {
  return Math.ceil(1000 / rate);
  },
  _initializeChunking: function () {
  if (this.initialCount) {
  this._limit = this.initialCount;
  this._chunkCount = this.initialCount;
  this._lastChunkTime = performance.now();
  }
  },
  _tryRenderChunk: function () {
  if (this.items && this._limit < this.items.length) {
  this.debounce('renderChunk', this._requestRenderChunk);
  }
  },
  _requestRenderChunk: function () {
  requestAnimationFrame(this._boundRenderChunk);
  },
  _renderChunk: function () {
  var currChunkTime = performance.now();
  var ratio = this._targetFrameTime / (currChunkTime - this._lastChunkTime);
  this._chunkCount = Math.round(this._chunkCount * ratio) || 1;
  this._limit += this._chunkCount;
  this._lastChunkTime = currChunkTime;
  this._debounceTemplate(this._render);
  },
73bcce88   luigser   COMPONENTS
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
  _observeChanged: function () {
  this._observePaths = this.observe && this.observe.replace('.*', '.').split(' ');
  },
  _itemsChanged: function (change) {
  if (change.path == 'items') {
  if (Array.isArray(this.items)) {
  this.collection = Polymer.Collection.get(this.items);
  } else if (!this.items) {
  this.collection = null;
  } else {
  this._error(this._logf('dom-repeat', 'expected array for `items`,' + ' found', this.items));
  }
  this._keySplices = [];
  this._indexSplices = [];
  this._needFullRefresh = true;
a1a3bc73   Luigi Serra   graphs updates
4109
  this._initializeChunking();
73bcce88   luigser   COMPONENTS
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
  this._debounceTemplate(this._render);
  } else if (change.path == 'items.splices') {
  this._keySplices = this._keySplices.concat(change.value.keySplices);
  this._indexSplices = this._indexSplices.concat(change.value.indexSplices);
  this._debounceTemplate(this._render);
  } else {
  var subpath = change.path.slice(6);
  this._forwardItemPath(subpath, change.value);
  this._checkObservedPaths(subpath);
  }
  },
  _checkObservedPaths: function (path) {
  if (this._observePaths) {
  path = path.substring(path.indexOf('.') + 1);
  var paths = this._observePaths;
  for (var i = 0; i < paths.length; i++) {
  if (path.indexOf(paths[i]) === 0) {
  this._needFullRefresh = true;
  if (this.delay) {
  this.debounce('render', this._render, this.delay);
  } else {
  this._debounceTemplate(this._render);
  }
  return;
  }
  }
  }
  },
  render: function () {
  this._needFullRefresh = true;
  this._debounceTemplate(this._render);
  this._flushTemplates();
  },
  _render: function () {
  var c = this.collection;
  if (this._needFullRefresh) {
  this._applyFullRefresh();
  this._needFullRefresh = false;
a1a3bc73   Luigi Serra   graphs updates
4148
  } else if (this._keySplices.length) {
73bcce88   luigser   COMPONENTS
4149
4150
4151
4152
4153
4154
4155
4156
4157
  if (this._sortFn) {
  this._applySplicesUserSort(this._keySplices);
  } else {
  if (this._filterFn) {
  this._applyFullRefresh();
  } else {
  this._applySplicesArrayOrder(this._indexSplices);
  }
  }
a1a3bc73   Luigi Serra   graphs updates
4158
  } else {
73bcce88   luigser   COMPONENTS
4159
4160
4161
4162
  }
  this._keySplices = [];
  this._indexSplices = [];
  var keyToIdx = this._keyToInstIdx = {};
a1a3bc73   Luigi Serra   graphs updates
4163
  for (var i = this._instances.length - 1; i >= 0; i--) {
73bcce88   luigser   COMPONENTS
4164
  var inst = this._instances[i];
a1a3bc73   Luigi Serra   graphs updates
4165
4166
4167
4168
4169
  if (inst.isPlaceholder && i < this._limit) {
  inst = this._insertInstance(i, inst.__key__);
  } else if (!inst.isPlaceholder && i >= this._limit) {
  inst = this._downgradeInstance(i, inst.__key__);
  }
73bcce88   luigser   COMPONENTS
4170
  keyToIdx[inst.__key__] = i;
a1a3bc73   Luigi Serra   graphs updates
4171
  if (!inst.isPlaceholder) {
73bcce88   luigser   COMPONENTS
4172
4173
  inst.__setProperty(this.indexAs, i, true);
  }
a1a3bc73   Luigi Serra   graphs updates
4174
4175
  }
  this._pool.length = 0;
73bcce88   luigser   COMPONENTS
4176
  this.fire('dom-change');
a1a3bc73   Luigi Serra   graphs updates
4177
  this._tryRenderChunk();
73bcce88   luigser   COMPONENTS
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
  },
  _applyFullRefresh: function () {
  var c = this.collection;
  var keys;
  if (this._sortFn) {
  keys = c ? c.getKeys() : [];
  } else {
  keys = [];
  var items = this.items;
  if (items) {
  for (var i = 0; i < items.length; i++) {
  keys.push(c.getKey(items[i]));
  }
  }
  }
a1a3bc73   Luigi Serra   graphs updates
4193
  var self = this;
73bcce88   luigser   COMPONENTS
4194
4195
  if (this._filterFn) {
  keys = keys.filter(function (a) {
a1a3bc73   Luigi Serra   graphs updates
4196
4197
  return self._filterFn(c.getItem(a));
  });
73bcce88   luigser   COMPONENTS
4198
4199
4200
  }
  if (this._sortFn) {
  keys.sort(function (a, b) {
a1a3bc73   Luigi Serra   graphs updates
4201
4202
  return self._sortFn(c.getItem(a), c.getItem(b));
  });
73bcce88   luigser   COMPONENTS
4203
4204
4205
4206
4207
  }
  for (var i = 0; i < keys.length; i++) {
  var key = keys[i];
  var inst = this._instances[i];
  if (inst) {
a1a3bc73   Luigi Serra   graphs updates
4208
4209
  inst.__key__ = key;
  if (!inst.isPlaceholder && i < this._limit) {
73bcce88   luigser   COMPONENTS
4210
  inst.__setProperty(this.as, c.getItem(key), true);
a1a3bc73   Luigi Serra   graphs updates
4211
4212
4213
  }
  } else if (i < this._limit) {
  this._insertInstance(i, key);
73bcce88   luigser   COMPONENTS
4214
  } else {
a1a3bc73   Luigi Serra   graphs updates
4215
  this._insertPlaceholder(i, key);
73bcce88   luigser   COMPONENTS
4216
4217
  }
  }
a1a3bc73   Luigi Serra   graphs updates
4218
4219
  for (var j = this._instances.length - 1; j >= i; j--) {
  this._detachAndRemoveInstance(j);
73bcce88   luigser   COMPONENTS
4220
  }
73bcce88   luigser   COMPONENTS
4221
4222
4223
4224
4225
4226
4227
4228
  },
  _numericSort: function (a, b) {
  return a - b;
  },
  _applySplicesUserSort: function (splices) {
  var c = this.collection;
  var instances = this._instances;
  var keyMap = {};
a1a3bc73   Luigi Serra   graphs updates
4229
4230
4231
  for (var i = 0, s; i < splices.length && (s = splices[i]); i++) {
  for (var j = 0; j < s.removed.length; j++) {
  var key = s.removed[j];
73bcce88   luigser   COMPONENTS
4232
4233
  keyMap[key] = keyMap[key] ? null : -1;
  }
a1a3bc73   Luigi Serra   graphs updates
4234
4235
  for (var j = 0; j < s.added.length; j++) {
  var key = s.added[j];
73bcce88   luigser   COMPONENTS
4236
4237
  keyMap[key] = keyMap[key] ? null : 1;
  }
a1a3bc73   Luigi Serra   graphs updates
4238
  }
73bcce88   luigser   COMPONENTS
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
  var removedIdxs = [];
  var addedKeys = [];
  for (var key in keyMap) {
  if (keyMap[key] === -1) {
  removedIdxs.push(this._keyToInstIdx[key]);
  }
  if (keyMap[key] === 1) {
  addedKeys.push(key);
  }
  }
  if (removedIdxs.length) {
  removedIdxs.sort(this._numericSort);
  for (var i = removedIdxs.length - 1; i >= 0; i--) {
  var idx = removedIdxs[i];
  if (idx !== undefined) {
a1a3bc73   Luigi Serra   graphs updates
4254
  this._detachAndRemoveInstance(idx);
73bcce88   luigser   COMPONENTS
4255
4256
4257
  }
  }
  }
a1a3bc73   Luigi Serra   graphs updates
4258
  var self = this;
73bcce88   luigser   COMPONENTS
4259
4260
4261
  if (addedKeys.length) {
  if (this._filterFn) {
  addedKeys = addedKeys.filter(function (a) {
a1a3bc73   Luigi Serra   graphs updates
4262
4263
  return self._filterFn(c.getItem(a));
  });
73bcce88   luigser   COMPONENTS
4264
4265
  }
  addedKeys.sort(function (a, b) {
a1a3bc73   Luigi Serra   graphs updates
4266
4267
  return self._sortFn(c.getItem(a), c.getItem(b));
  });
73bcce88   luigser   COMPONENTS
4268
4269
  var start = 0;
  for (var i = 0; i < addedKeys.length; i++) {
a1a3bc73   Luigi Serra   graphs updates
4270
  start = this._insertRowUserSort(start, addedKeys[i]);
73bcce88   luigser   COMPONENTS
4271
4272
4273
  }
  }
  },
a1a3bc73   Luigi Serra   graphs updates
4274
  _insertRowUserSort: function (start, key) {
73bcce88   luigser   COMPONENTS
4275
4276
4277
4278
  var c = this.collection;
  var item = c.getItem(key);
  var end = this._instances.length - 1;
  var idx = -1;
73bcce88   luigser   COMPONENTS
4279
4280
4281
  while (start <= end) {
  var mid = start + end >> 1;
  var midKey = this._instances[mid].__key__;
a1a3bc73   Luigi Serra   graphs updates
4282
  var cmp = this._sortFn(c.getItem(midKey), item);
73bcce88   luigser   COMPONENTS
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
  if (cmp < 0) {
  start = mid + 1;
  } else if (cmp > 0) {
  end = mid - 1;
  } else {
  idx = mid;
  break;
  }
  }
  if (idx < 0) {
  idx = end + 1;
  }
a1a3bc73   Luigi Serra   graphs updates
4295
  this._insertPlaceholder(idx, key);
73bcce88   luigser   COMPONENTS
4296
4297
4298
  return idx;
  },
  _applySplicesArrayOrder: function (splices) {
73bcce88   luigser   COMPONENTS
4299
  var c = this.collection;
a1a3bc73   Luigi Serra   graphs updates
4300
4301
4302
  for (var i = 0, s; i < splices.length && (s = splices[i]); i++) {
  for (var j = 0; j < s.removed.length; j++) {
  this._detachAndRemoveInstance(s.index);
73bcce88   luigser   COMPONENTS
4303
  }
a1a3bc73   Luigi Serra   graphs updates
4304
4305
  for (var j = 0; j < s.addedKeys.length; j++) {
  this._insertPlaceholder(s.index + j, s.addedKeys[j]);
73bcce88   luigser   COMPONENTS
4306
4307
4308
  }
  }
  },
a1a3bc73   Luigi Serra   graphs updates
4309
  _detachInstance: function (idx) {
73bcce88   luigser   COMPONENTS
4310
4311
  var inst = this._instances[idx];
  if (!inst.isPlaceholder) {
73bcce88   luigser   COMPONENTS
4312
4313
4314
4315
  for (var i = 0; i < inst._children.length; i++) {
  var el = inst._children[i];
  Polymer.dom(inst.root).appendChild(el);
  }
73bcce88   luigser   COMPONENTS
4316
  return inst;
a1a3bc73   Luigi Serra   graphs updates
4317
4318
4319
4320
4321
4322
4323
  }
  },
  _attachInstance: function (idx, parent) {
  var inst = this._instances[idx];
  if (!inst.isPlaceholder) {
  parent.insertBefore(inst.root, this);
  }
73bcce88   luigser   COMPONENTS
4324
  },
a1a3bc73   Luigi Serra   graphs updates
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
  _detachAndRemoveInstance: function (idx) {
  var inst = this._detachInstance(idx);
  if (inst) {
  this._pool.push(inst);
  }
  this._instances.splice(idx, 1);
  },
  _insertPlaceholder: function (idx, key) {
  this._instances.splice(idx, 0, {
  isPlaceholder: true,
  __key__: key
  });
  },
  _stampInstance: function (idx, key) {
  var model = { __key__: key };
  model[this.as] = this.collection.getItem(key);
  model[this.indexAs] = idx;
  return this.stamp(model);
  },
  _insertInstance: function (idx, key) {
  var inst = this._pool.pop();
  if (inst) {
73bcce88   luigser   COMPONENTS
4347
4348
4349
  inst.__setProperty(this.as, this.collection.getItem(key), true);
  inst.__setProperty('__key__', key, true);
  } else {
a1a3bc73   Luigi Serra   graphs updates
4350
  inst = this._stampInstance(idx, key);
73bcce88   luigser   COMPONENTS
4351
  }
a1a3bc73   Luigi Serra   graphs updates
4352
4353
  var beforeRow = this._instances[idx + 1];
  var beforeNode = beforeRow && !beforeRow.isPlaceholder ? beforeRow._children[0] : this;
73bcce88   luigser   COMPONENTS
4354
4355
  var parentNode = Polymer.dom(this).parentNode;
  Polymer.dom(parentNode).insertBefore(inst.root, beforeNode);
a1a3bc73   Luigi Serra   graphs updates
4356
  this._instances[idx] = inst;
73bcce88   luigser   COMPONENTS
4357
4358
  return inst;
  },
a1a3bc73   Luigi Serra   graphs updates
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
  _downgradeInstance: function (idx, key) {
  var inst = this._detachInstance(idx);
  if (inst) {
  this._pool.push(inst);
  }
  inst = {
  isPlaceholder: true,
  __key__: key
  };
  this._instances[idx] = inst;
73bcce88   luigser   COMPONENTS
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
  return inst;
  },
  _showHideChildren: function (hidden) {
  for (var i = 0; i < this._instances.length; i++) {
  this._instances[i]._showHideChildren(hidden);
  }
  },
  _forwardInstanceProp: function (inst, prop, value) {
  if (prop == this.as) {
  var idx;
  if (this._sortFn || this._filterFn) {
  idx = this.items.indexOf(this.collection.getItem(inst.__key__));
  } else {
  idx = inst[this.indexAs];
  }
  this.set('items.' + idx, value);
  }
  },
  _forwardInstancePath: function (inst, path, value) {
  if (path.indexOf(this.as + '.') === 0) {
f748e9cf   Luigi Serra   new controllet an...
4389
  this._notifyPath('items.' + inst.__key__ + '.' + path.slice(this.as.length + 1), value);
73bcce88   luigser   COMPONENTS
4390
4391
4392
  }
  },
  _forwardParentProp: function (prop, value) {
a1a3bc73   Luigi Serra   graphs updates
4393
4394
4395
  var i$ = this._instances;
  for (var i = 0, inst; i < i$.length && (inst = i$[i]); i++) {
  if (!inst.isPlaceholder) {
73bcce88   luigser   COMPONENTS
4396
  inst.__setProperty(prop, value, true);
a1a3bc73   Luigi Serra   graphs updates
4397
4398
  }
  }
73bcce88   luigser   COMPONENTS
4399
4400
  },
  _forwardParentPath: function (path, value) {
a1a3bc73   Luigi Serra   graphs updates
4401
4402
4403
  var i$ = this._instances;
  for (var i = 0, inst; i < i$.length && (inst = i$[i]); i++) {
  if (!inst.isPlaceholder) {
f748e9cf   Luigi Serra   new controllet an...
4404
  inst._notifyPath(path, value, true);
a1a3bc73   Luigi Serra   graphs updates
4405
4406
  }
  }
73bcce88   luigser   COMPONENTS
4407
4408
4409
4410
4411
4412
4413
  },
  _forwardItemPath: function (path, value) {
  if (this._keyToInstIdx) {
  var dot = path.indexOf('.');
  var key = path.substring(0, dot < 0 ? path.length : dot);
  var idx = this._keyToInstIdx[key];
  var inst = this._instances[idx];
a1a3bc73   Luigi Serra   graphs updates
4414
  if (inst && !inst.isPlaceholder) {
73bcce88   luigser   COMPONENTS
4415
4416
  if (dot >= 0) {
  path = this.as + '.' + path.substring(dot + 1);
f748e9cf   Luigi Serra   new controllet an...
4417
  inst._notifyPath(path, value, true);
73bcce88   luigser   COMPONENTS
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
  } else {
  inst.__setProperty(this.as, value, true);
  }
  }
  }
  },
  itemForElement: function (el) {
  var instance = this.modelForElement(el);
  return instance && instance[this.as];
  },
  keyForElement: function (el) {
  var instance = this.modelForElement(el);
  return instance && instance.__key__;
  },
  indexForElement: function (el) {
  var instance = this.modelForElement(el);
  return instance && instance[this.indexAs];
  }
  });
  Polymer({
  is: 'array-selector',
a1a3bc73   Luigi Serra   graphs updates
4439
  _template: null,
73bcce88   luigser   COMPONENTS
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
  properties: {
  items: {
  type: Array,
  observer: 'clearSelection'
  },
  multi: {
  type: Boolean,
  value: false,
  observer: 'clearSelection'
  },
  selected: {
  type: Object,
  notify: true
  },
  selectedItem: {
  type: Object,
  notify: true
  },
  toggle: {
  type: Boolean,
  value: false
  }
  },
  clearSelection: function () {
  if (Array.isArray(this.selected)) {
  for (var i = 0; i < this.selected.length; i++) {
  this.unlinkPaths('selected.' + i);
  }
  } else {
  this.unlinkPaths('selected');
f748e9cf   Luigi Serra   new controllet an...
4470
  this.unlinkPaths('selectedItem');
73bcce88   luigser   COMPONENTS
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
  }
  if (this.multi) {
  if (!this.selected || this.selected.length) {
  this.selected = [];
  this._selectedColl = Polymer.Collection.get(this.selected);
  }
  } else {
  this.selected = null;
  this._selectedColl = null;
  }
  this.selectedItem = null;
  },
  isSelected: function (item) {
  if (this.multi) {
  return this._selectedColl.getKey(item) !== undefined;
  } else {
  return this.selected == item;
  }
  },
  deselect: function (item) {
  if (this.multi) {
  if (this.isSelected(item)) {
  var skey = this._selectedColl.getKey(item);
  this.arrayDelete('selected', item);
  this.unlinkPaths('selected.' + skey);
  }
  } else {
  this.selected = null;
  this.selectedItem = null;
  this.unlinkPaths('selected');
  this.unlinkPaths('selectedItem');
  }
  },
  select: function (item) {
  var icol = Polymer.Collection.get(this.items);
  var key = icol.getKey(item);
  if (this.multi) {
  if (this.isSelected(item)) {
  if (this.toggle) {
  this.deselect(item);
  }
  } else {
  this.push('selected', item);
eb240478   Luigi Serra   public room cards...
4514
  var skey = this._selectedColl.getKey(item);
73bcce88   luigser   COMPONENTS
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
  this.linkPaths('selected.' + skey, 'items.' + key);
  }
  } else {
  if (this.toggle && item == this.selected) {
  this.deselect();
  } else {
  this.selected = item;
  this.selectedItem = item;
  this.linkPaths('selected', 'items.' + key);
  this.linkPaths('selectedItem', 'items.' + key);
  }
  }
  }
  });
  Polymer({
  is: 'dom-if',
  extends: 'template',
a1a3bc73   Luigi Serra   graphs updates
4532
  _template: null,
73bcce88   luigser   COMPONENTS
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
  properties: {
  'if': {
  type: Boolean,
  value: false,
  observer: '_queueRender'
  },
  restamp: {
  type: Boolean,
  value: false,
  observer: '_queueRender'
  }
  },
  behaviors: [Polymer.Templatizer],
  _queueRender: function () {
  this._debounceTemplate(this._render);
  },
  detached: function () {
  this._teardownInstance();
  },
  attached: function () {
  if (this.if && this.ctor) {
  this.async(this._ensureInstance);
  }
  },
  render: function () {
  this._flushTemplates();
  },
  _render: function () {
  if (this.if) {
  if (!this.ctor) {
  this.templatize(this);
  }
  this._ensureInstance();
  this._showHideChildren();
  } else if (this.restamp) {
  this._teardownInstance();
  }
  if (!this.restamp && this._instance) {
  this._showHideChildren();
  }
  if (this.if != this._lastIf) {
  this.fire('dom-change');
  this._lastIf = this.if;
  }
  },
  _ensureInstance: function () {
  if (!this._instance) {
a1a3bc73   Luigi Serra   graphs updates
4580
4581
4582
  var parentNode = Polymer.dom(this).parentNode;
  if (parentNode) {
  var parent = Polymer.dom(parentNode);
73bcce88   luigser   COMPONENTS
4583
4584
  this._instance = this.stamp();
  var root = this._instance.root;
73bcce88   luigser   COMPONENTS
4585
4586
  parent.insertBefore(root, this);
  }
a1a3bc73   Luigi Serra   graphs updates
4587
  }
73bcce88   luigser   COMPONENTS
4588
4589
4590
  },
  _teardownInstance: function () {
  if (this._instance) {
a1a3bc73   Luigi Serra   graphs updates
4591
4592
4593
4594
  var c$ = this._instance._children;
  if (c$) {
  var parent = Polymer.dom(Polymer.dom(c$[0]).parentNode);
  for (var i = 0, n; i < c$.length && (n = c$[i]); i++) {
73bcce88   luigser   COMPONENTS
4595
  parent.removeChild(n);
a1a3bc73   Luigi Serra   graphs updates
4596
  }
73bcce88   luigser   COMPONENTS
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
  }
  this._instance = null;
  }
  },
  _showHideChildren: function () {
  var hidden = this.__hideTemplateChildren__ || !this.if;
  if (this._instance) {
  this._instance._showHideChildren(hidden);
  }
  },
  _forwardParentProp: function (prop, value) {
  if (this._instance) {
  this._instance[prop] = value;
  }
  },
  _forwardParentPath: function (path, value) {
  if (this._instance) {
f748e9cf   Luigi Serra   new controllet an...
4614
  this._instance._notifyPath(path, value, true);
73bcce88   luigser   COMPONENTS
4615
4616
4617
4618
4619
4620
  }
  }
  });
  Polymer({
  is: 'dom-bind',
  extends: 'template',
a1a3bc73   Luigi Serra   graphs updates
4621
  _template: null,
73bcce88   luigser   COMPONENTS
4622
  created: function () {
a1a3bc73   Luigi Serra   graphs updates
4623
4624
4625
4626
  var self = this;
  Polymer.RenderStatus.whenReady(function () {
  self._markImportsReady();
  });
73bcce88   luigser   COMPONENTS
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
  },
  _ensureReady: function () {
  if (!this._readied) {
  this._readySelf();
  }
  },
  _markImportsReady: function () {
  this._importsReady = true;
  this._ensureReady();
  },
  _registerFeatures: function () {
  this._prepConstructor();
  },
  _insertChildren: function () {
  var parentDom = Polymer.dom(Polymer.dom(this).parentNode);
  parentDom.insertBefore(this.root, this);
  },
  _removeChildren: function () {
  if (this._children) {
  for (var i = 0; i < this._children.length; i++) {
  this.root.appendChild(this._children[i]);
  }
  }
  },
  _initFeatures: function () {
  },
  _scopeElementClass: function (element, selector) {
  if (this.dataHost) {
  return this.dataHost._scopeElementClass(element, selector);
  } else {
  return selector;
  }
  },
  _prepConfigure: function () {
  var config = {};
  for (var prop in this._propertyEffects) {
  config[prop] = this[prop];
  }
a1a3bc73   Luigi Serra   graphs updates
4665
4666
4667
4668
  var setupConfigure = this._setupConfigure;
  this._setupConfigure = function () {
  setupConfigure.call(this, config);
  };
73bcce88   luigser   COMPONENTS
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
  },
  attached: function () {
  if (this._importsReady) {
  this.render();
  }
  },
  detached: function () {
  this._removeChildren();
  },
  render: function () {
  this._ensureReady();
  if (!this._children) {
  this._template = this;
  this._prepAnnotations();
  this._prepEffects();
  this._prepBehaviors();
  this._prepConfigure();
  this._prepBindings();
a1a3bc73   Luigi Serra   graphs updates
4687
  this._prepPropertyInfo();
73bcce88   luigser   COMPONENTS
4688
  Polymer.Base._initFeatures.call(this);
a1a3bc73   Luigi Serra   graphs updates
4689
  this._children = Polymer.DomApi.arrayCopyChildNodes(this.root);
73bcce88   luigser   COMPONENTS
4690
4691
4692
4693
4694
  }
  this._insertChildren();
  this.fire('dom-change');
  }
  });</script>