gobstones-board 1.8.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2152 @@
1
+ <!--
2
+ @license
3
+ Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
5
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
7
+ Code distributed by Google as part of the polymer project is also
8
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
9
+ --><link rel="import" href="polymer-micro.html"><script>Polymer.Base._addFeature({
10
+ _prepTemplate: function () {
11
+ if (this._template === undefined) {
12
+ this._template = Polymer.DomModule.import(this.is, 'template');
13
+ }
14
+ if (this._template && this._template.hasAttribute('is')) {
15
+ this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' + 'must not be a type-extension, found', this._template, 'Move inside simple <template>.'));
16
+ }
17
+ if (this._template && !this._template.content && window.HTMLTemplateElement && HTMLTemplateElement.decorate) {
18
+ HTMLTemplateElement.decorate(this._template);
19
+ }
20
+ },
21
+ _stampTemplate: function () {
22
+ if (this._template) {
23
+ this.root = this.instanceTemplate(this._template);
24
+ }
25
+ },
26
+ instanceTemplate: function (template) {
27
+ var dom = document.importNode(template._content || template.content, true);
28
+ return dom;
29
+ }
30
+ });(function () {
31
+ var baseAttachedCallback = Polymer.Base.attachedCallback;
32
+ Polymer.Base._addFeature({
33
+ _hostStack: [],
34
+ ready: function () {
35
+ },
36
+ _registerHost: function (host) {
37
+ this.dataHost = host = host || Polymer.Base._hostStack[Polymer.Base._hostStack.length - 1];
38
+ if (host && host._clients) {
39
+ host._clients.push(this);
40
+ }
41
+ this._clients = null;
42
+ this._clientsReadied = false;
43
+ },
44
+ _beginHosting: function () {
45
+ Polymer.Base._hostStack.push(this);
46
+ if (!this._clients) {
47
+ this._clients = [];
48
+ }
49
+ },
50
+ _endHosting: function () {
51
+ Polymer.Base._hostStack.pop();
52
+ },
53
+ _tryReady: function () {
54
+ this._readied = false;
55
+ if (this._canReady()) {
56
+ this._ready();
57
+ }
58
+ },
59
+ _canReady: function () {
60
+ return !this.dataHost || this.dataHost._clientsReadied;
61
+ },
62
+ _ready: function () {
63
+ this._beforeClientsReady();
64
+ if (this._template) {
65
+ this._setupRoot();
66
+ this._readyClients();
67
+ }
68
+ this._clientsReadied = true;
69
+ this._clients = null;
70
+ this._afterClientsReady();
71
+ this._readySelf();
72
+ },
73
+ _readyClients: function () {
74
+ this._beginDistribute();
75
+ var c$ = this._clients;
76
+ if (c$) {
77
+ for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
78
+ c._ready();
79
+ }
80
+ }
81
+ this._finishDistribute();
82
+ },
83
+ _readySelf: function () {
84
+ this._doBehavior('ready');
85
+ this._readied = true;
86
+ if (this._attachedPending) {
87
+ this._attachedPending = false;
88
+ this.attachedCallback();
89
+ }
90
+ },
91
+ _beforeClientsReady: function () {
92
+ },
93
+ _afterClientsReady: function () {
94
+ },
95
+ _beforeAttached: function () {
96
+ },
97
+ attachedCallback: function () {
98
+ if (this._readied) {
99
+ this._beforeAttached();
100
+ baseAttachedCallback.call(this);
101
+ } else {
102
+ this._attachedPending = true;
103
+ }
104
+ }
105
+ });
106
+ }());Polymer.ArraySplice = function () {
107
+ function newSplice(index, removed, addedCount) {
108
+ return {
109
+ index: index,
110
+ removed: removed,
111
+ addedCount: addedCount
112
+ };
113
+ }
114
+ var EDIT_LEAVE = 0;
115
+ var EDIT_UPDATE = 1;
116
+ var EDIT_ADD = 2;
117
+ var EDIT_DELETE = 3;
118
+ function ArraySplice() {
119
+ }
120
+ ArraySplice.prototype = {
121
+ calcEditDistances: function (current, currentStart, currentEnd, old, oldStart, oldEnd) {
122
+ var rowCount = oldEnd - oldStart + 1;
123
+ var columnCount = currentEnd - currentStart + 1;
124
+ var distances = new Array(rowCount);
125
+ for (var i = 0; i < rowCount; i++) {
126
+ distances[i] = new Array(columnCount);
127
+ distances[i][0] = i;
128
+ }
129
+ for (var j = 0; j < columnCount; j++)
130
+ distances[0][j] = j;
131
+ for (i = 1; i < rowCount; i++) {
132
+ for (j = 1; j < columnCount; j++) {
133
+ if (this.equals(current[currentStart + j - 1], old[oldStart + i - 1]))
134
+ distances[i][j] = distances[i - 1][j - 1];
135
+ else {
136
+ var north = distances[i - 1][j] + 1;
137
+ var west = distances[i][j - 1] + 1;
138
+ distances[i][j] = north < west ? north : west;
139
+ }
140
+ }
141
+ }
142
+ return distances;
143
+ },
144
+ spliceOperationsFromEditDistances: function (distances) {
145
+ var i = distances.length - 1;
146
+ var j = distances[0].length - 1;
147
+ var current = distances[i][j];
148
+ var edits = [];
149
+ while (i > 0 || j > 0) {
150
+ if (i == 0) {
151
+ edits.push(EDIT_ADD);
152
+ j--;
153
+ continue;
154
+ }
155
+ if (j == 0) {
156
+ edits.push(EDIT_DELETE);
157
+ i--;
158
+ continue;
159
+ }
160
+ var northWest = distances[i - 1][j - 1];
161
+ var west = distances[i - 1][j];
162
+ var north = distances[i][j - 1];
163
+ var min;
164
+ if (west < north)
165
+ min = west < northWest ? west : northWest;
166
+ else
167
+ min = north < northWest ? north : northWest;
168
+ if (min == northWest) {
169
+ if (northWest == current) {
170
+ edits.push(EDIT_LEAVE);
171
+ } else {
172
+ edits.push(EDIT_UPDATE);
173
+ current = northWest;
174
+ }
175
+ i--;
176
+ j--;
177
+ } else if (min == west) {
178
+ edits.push(EDIT_DELETE);
179
+ i--;
180
+ current = west;
181
+ } else {
182
+ edits.push(EDIT_ADD);
183
+ j--;
184
+ current = north;
185
+ }
186
+ }
187
+ edits.reverse();
188
+ return edits;
189
+ },
190
+ calcSplices: function (current, currentStart, currentEnd, old, oldStart, oldEnd) {
191
+ var prefixCount = 0;
192
+ var suffixCount = 0;
193
+ var minLength = Math.min(currentEnd - currentStart, oldEnd - oldStart);
194
+ if (currentStart == 0 && oldStart == 0)
195
+ prefixCount = this.sharedPrefix(current, old, minLength);
196
+ if (currentEnd == current.length && oldEnd == old.length)
197
+ suffixCount = this.sharedSuffix(current, old, minLength - prefixCount);
198
+ currentStart += prefixCount;
199
+ oldStart += prefixCount;
200
+ currentEnd -= suffixCount;
201
+ oldEnd -= suffixCount;
202
+ if (currentEnd - currentStart == 0 && oldEnd - oldStart == 0)
203
+ return [];
204
+ if (currentStart == currentEnd) {
205
+ var splice = newSplice(currentStart, [], 0);
206
+ while (oldStart < oldEnd)
207
+ splice.removed.push(old[oldStart++]);
208
+ return [splice];
209
+ } else if (oldStart == oldEnd)
210
+ return [newSplice(currentStart, [], currentEnd - currentStart)];
211
+ var ops = this.spliceOperationsFromEditDistances(this.calcEditDistances(current, currentStart, currentEnd, old, oldStart, oldEnd));
212
+ splice = undefined;
213
+ var splices = [];
214
+ var index = currentStart;
215
+ var oldIndex = oldStart;
216
+ for (var i = 0; i < ops.length; i++) {
217
+ switch (ops[i]) {
218
+ case EDIT_LEAVE:
219
+ if (splice) {
220
+ splices.push(splice);
221
+ splice = undefined;
222
+ }
223
+ index++;
224
+ oldIndex++;
225
+ break;
226
+ case EDIT_UPDATE:
227
+ if (!splice)
228
+ splice = newSplice(index, [], 0);
229
+ splice.addedCount++;
230
+ index++;
231
+ splice.removed.push(old[oldIndex]);
232
+ oldIndex++;
233
+ break;
234
+ case EDIT_ADD:
235
+ if (!splice)
236
+ splice = newSplice(index, [], 0);
237
+ splice.addedCount++;
238
+ index++;
239
+ break;
240
+ case EDIT_DELETE:
241
+ if (!splice)
242
+ splice = newSplice(index, [], 0);
243
+ splice.removed.push(old[oldIndex]);
244
+ oldIndex++;
245
+ break;
246
+ }
247
+ }
248
+ if (splice) {
249
+ splices.push(splice);
250
+ }
251
+ return splices;
252
+ },
253
+ sharedPrefix: function (current, old, searchLength) {
254
+ for (var i = 0; i < searchLength; i++)
255
+ if (!this.equals(current[i], old[i]))
256
+ return i;
257
+ return searchLength;
258
+ },
259
+ sharedSuffix: function (current, old, searchLength) {
260
+ var index1 = current.length;
261
+ var index2 = old.length;
262
+ var count = 0;
263
+ while (count < searchLength && this.equals(current[--index1], old[--index2]))
264
+ count++;
265
+ return count;
266
+ },
267
+ calculateSplices: function (current, previous) {
268
+ return this.calcSplices(current, 0, current.length, previous, 0, previous.length);
269
+ },
270
+ equals: function (currentValue, previousValue) {
271
+ return currentValue === previousValue;
272
+ }
273
+ };
274
+ return new ArraySplice();
275
+ }();Polymer.domInnerHTML = function () {
276
+ var escapeAttrRegExp = /[&\u00A0"]/g;
277
+ var escapeDataRegExp = /[&\u00A0<>]/g;
278
+ function escapeReplace(c) {
279
+ switch (c) {
280
+ case '&':
281
+ return '&amp;';
282
+ case '<':
283
+ return '&lt;';
284
+ case '>':
285
+ return '&gt;';
286
+ case '"':
287
+ return '&quot;';
288
+ case '\xA0':
289
+ return '&nbsp;';
290
+ }
291
+ }
292
+ function escapeAttr(s) {
293
+ return s.replace(escapeAttrRegExp, escapeReplace);
294
+ }
295
+ function escapeData(s) {
296
+ return s.replace(escapeDataRegExp, escapeReplace);
297
+ }
298
+ function makeSet(arr) {
299
+ var set = {};
300
+ for (var i = 0; i < arr.length; i++) {
301
+ set[arr[i]] = true;
302
+ }
303
+ return set;
304
+ }
305
+ var voidElements = makeSet([
306
+ 'area',
307
+ 'base',
308
+ 'br',
309
+ 'col',
310
+ 'command',
311
+ 'embed',
312
+ 'hr',
313
+ 'img',
314
+ 'input',
315
+ 'keygen',
316
+ 'link',
317
+ 'meta',
318
+ 'param',
319
+ 'source',
320
+ 'track',
321
+ 'wbr'
322
+ ]);
323
+ var plaintextParents = makeSet([
324
+ 'style',
325
+ 'script',
326
+ 'xmp',
327
+ 'iframe',
328
+ 'noembed',
329
+ 'noframes',
330
+ 'plaintext',
331
+ 'noscript'
332
+ ]);
333
+ function getOuterHTML(node, parentNode, composed) {
334
+ switch (node.nodeType) {
335
+ case Node.ELEMENT_NODE:
336
+ var tagName = node.localName;
337
+ var s = '<' + tagName;
338
+ var attrs = node.attributes;
339
+ for (var i = 0, attr; attr = attrs[i]; i++) {
340
+ s += ' ' + attr.name + '="' + escapeAttr(attr.value) + '"';
341
+ }
342
+ s += '>';
343
+ if (voidElements[tagName]) {
344
+ return s;
345
+ }
346
+ return s + getInnerHTML(node, composed) + '</' + tagName + '>';
347
+ case Node.TEXT_NODE:
348
+ var data = node.data;
349
+ if (parentNode && plaintextParents[parentNode.localName]) {
350
+ return data;
351
+ }
352
+ return escapeData(data);
353
+ case Node.COMMENT_NODE:
354
+ return '<!--' + node.data + '-->';
355
+ default:
356
+ console.error(node);
357
+ throw new Error('not implemented');
358
+ }
359
+ }
360
+ function getInnerHTML(node, composed) {
361
+ if (node instanceof HTMLTemplateElement)
362
+ node = node.content;
363
+ var s = '';
364
+ var c$ = Polymer.dom(node).childNodes;
365
+ for (var i = 0, l = c$.length, child; i < l && (child = c$[i]); i++) {
366
+ s += getOuterHTML(child, node, composed);
367
+ }
368
+ return s;
369
+ }
370
+ return { getInnerHTML: getInnerHTML };
371
+ }();(function () {
372
+ 'use strict';
373
+ var nativeInsertBefore = Element.prototype.insertBefore;
374
+ var nativeAppendChild = Element.prototype.appendChild;
375
+ var nativeRemoveChild = Element.prototype.removeChild;
376
+ Polymer.TreeApi = {
377
+ arrayCopyChildNodes: function (parent) {
378
+ var copy = [], i = 0;
379
+ for (var n = parent.firstChild; n; n = n.nextSibling) {
380
+ copy[i++] = n;
381
+ }
382
+ return copy;
383
+ },
384
+ arrayCopyChildren: function (parent) {
385
+ var copy = [], i = 0;
386
+ for (var n = parent.firstElementChild; n; n = n.nextElementSibling) {
387
+ copy[i++] = n;
388
+ }
389
+ return copy;
390
+ },
391
+ arrayCopy: function (a$) {
392
+ var l = a$.length;
393
+ var copy = new Array(l);
394
+ for (var i = 0; i < l; i++) {
395
+ copy[i] = a$[i];
396
+ }
397
+ return copy;
398
+ }
399
+ };
400
+ Polymer.TreeApi.Logical = {
401
+ hasParentNode: function (node) {
402
+ return Boolean(node.__dom && node.__dom.parentNode);
403
+ },
404
+ hasChildNodes: function (node) {
405
+ return Boolean(node.__dom && node.__dom.childNodes !== undefined);
406
+ },
407
+ getChildNodes: function (node) {
408
+ return this.hasChildNodes(node) ? this._getChildNodes(node) : node.childNodes;
409
+ },
410
+ _getChildNodes: function (node) {
411
+ if (!node.__dom.childNodes) {
412
+ node.__dom.childNodes = [];
413
+ for (var n = node.__dom.firstChild; n; n = n.__dom.nextSibling) {
414
+ node.__dom.childNodes.push(n);
415
+ }
416
+ }
417
+ return node.__dom.childNodes;
418
+ },
419
+ getParentNode: function (node) {
420
+ return node.__dom && node.__dom.parentNode !== undefined ? node.__dom.parentNode : node.parentNode;
421
+ },
422
+ getFirstChild: function (node) {
423
+ return node.__dom && node.__dom.firstChild !== undefined ? node.__dom.firstChild : node.firstChild;
424
+ },
425
+ getLastChild: function (node) {
426
+ return node.__dom && node.__dom.lastChild !== undefined ? node.__dom.lastChild : node.lastChild;
427
+ },
428
+ getNextSibling: function (node) {
429
+ return node.__dom && node.__dom.nextSibling !== undefined ? node.__dom.nextSibling : node.nextSibling;
430
+ },
431
+ getPreviousSibling: function (node) {
432
+ return node.__dom && node.__dom.previousSibling !== undefined ? node.__dom.previousSibling : node.previousSibling;
433
+ },
434
+ getFirstElementChild: function (node) {
435
+ return node.__dom && node.__dom.firstChild !== undefined ? this._getFirstElementChild(node) : node.firstElementChild;
436
+ },
437
+ _getFirstElementChild: function (node) {
438
+ var n = node.__dom.firstChild;
439
+ while (n && n.nodeType !== Node.ELEMENT_NODE) {
440
+ n = n.__dom.nextSibling;
441
+ }
442
+ return n;
443
+ },
444
+ getLastElementChild: function (node) {
445
+ return node.__dom && node.__dom.lastChild !== undefined ? this._getLastElementChild(node) : node.lastElementChild;
446
+ },
447
+ _getLastElementChild: function (node) {
448
+ var n = node.__dom.lastChild;
449
+ while (n && n.nodeType !== Node.ELEMENT_NODE) {
450
+ n = n.__dom.previousSibling;
451
+ }
452
+ return n;
453
+ },
454
+ getNextElementSibling: function (node) {
455
+ return node.__dom && node.__dom.nextSibling !== undefined ? this._getNextElementSibling(node) : node.nextElementSibling;
456
+ },
457
+ _getNextElementSibling: function (node) {
458
+ var n = node.__dom.nextSibling;
459
+ while (n && n.nodeType !== Node.ELEMENT_NODE) {
460
+ n = n.__dom.nextSibling;
461
+ }
462
+ return n;
463
+ },
464
+ getPreviousElementSibling: function (node) {
465
+ return node.__dom && node.__dom.previousSibling !== undefined ? this._getPreviousElementSibling(node) : node.previousElementSibling;
466
+ },
467
+ _getPreviousElementSibling: function (node) {
468
+ var n = node.__dom.previousSibling;
469
+ while (n && n.nodeType !== Node.ELEMENT_NODE) {
470
+ n = n.__dom.previousSibling;
471
+ }
472
+ return n;
473
+ },
474
+ saveChildNodes: function (node) {
475
+ if (!this.hasChildNodes(node)) {
476
+ node.__dom = node.__dom || {};
477
+ node.__dom.firstChild = node.firstChild;
478
+ node.__dom.lastChild = node.lastChild;
479
+ node.__dom.childNodes = [];
480
+ for (var n = node.firstChild; n; n = n.nextSibling) {
481
+ n.__dom = n.__dom || {};
482
+ n.__dom.parentNode = node;
483
+ node.__dom.childNodes.push(n);
484
+ n.__dom.nextSibling = n.nextSibling;
485
+ n.__dom.previousSibling = n.previousSibling;
486
+ }
487
+ }
488
+ },
489
+ recordInsertBefore: function (node, container, ref_node) {
490
+ container.__dom.childNodes = null;
491
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
492
+ for (var n = node.firstChild; n; n = n.nextSibling) {
493
+ this._linkNode(n, container, ref_node);
494
+ }
495
+ } else {
496
+ this._linkNode(node, container, ref_node);
497
+ }
498
+ },
499
+ _linkNode: function (node, container, ref_node) {
500
+ node.__dom = node.__dom || {};
501
+ container.__dom = container.__dom || {};
502
+ if (ref_node) {
503
+ ref_node.__dom = ref_node.__dom || {};
504
+ }
505
+ node.__dom.previousSibling = ref_node ? ref_node.__dom.previousSibling : container.__dom.lastChild;
506
+ if (node.__dom.previousSibling) {
507
+ node.__dom.previousSibling.__dom.nextSibling = node;
508
+ }
509
+ node.__dom.nextSibling = ref_node || null;
510
+ if (node.__dom.nextSibling) {
511
+ node.__dom.nextSibling.__dom.previousSibling = node;
512
+ }
513
+ node.__dom.parentNode = container;
514
+ if (ref_node) {
515
+ if (ref_node === container.__dom.firstChild) {
516
+ container.__dom.firstChild = node;
517
+ }
518
+ } else {
519
+ container.__dom.lastChild = node;
520
+ if (!container.__dom.firstChild) {
521
+ container.__dom.firstChild = node;
522
+ }
523
+ }
524
+ container.__dom.childNodes = null;
525
+ },
526
+ recordRemoveChild: function (node, container) {
527
+ node.__dom = node.__dom || {};
528
+ container.__dom = container.__dom || {};
529
+ if (node === container.__dom.firstChild) {
530
+ container.__dom.firstChild = node.__dom.nextSibling;
531
+ }
532
+ if (node === container.__dom.lastChild) {
533
+ container.__dom.lastChild = node.__dom.previousSibling;
534
+ }
535
+ var p = node.__dom.previousSibling;
536
+ var n = node.__dom.nextSibling;
537
+ if (p) {
538
+ p.__dom.nextSibling = n;
539
+ }
540
+ if (n) {
541
+ n.__dom.previousSibling = p;
542
+ }
543
+ node.__dom.parentNode = node.__dom.previousSibling = node.__dom.nextSibling = undefined;
544
+ container.__dom.childNodes = null;
545
+ }
546
+ };
547
+ Polymer.TreeApi.Composed = {
548
+ getChildNodes: function (node) {
549
+ return Polymer.TreeApi.arrayCopyChildNodes(node);
550
+ },
551
+ getParentNode: function (node) {
552
+ return node.parentNode;
553
+ },
554
+ clearChildNodes: function (node) {
555
+ node.textContent = '';
556
+ },
557
+ insertBefore: function (parentNode, newChild, refChild) {
558
+ return nativeInsertBefore.call(parentNode, newChild, refChild || null);
559
+ },
560
+ appendChild: function (parentNode, newChild) {
561
+ return nativeAppendChild.call(parentNode, newChild);
562
+ },
563
+ removeChild: function (parentNode, node) {
564
+ return nativeRemoveChild.call(parentNode, node);
565
+ }
566
+ };
567
+ }());Polymer.DomApi = function () {
568
+ 'use strict';
569
+ var Settings = Polymer.Settings;
570
+ var TreeApi = Polymer.TreeApi;
571
+ var DomApi = function (node) {
572
+ this.node = needsToWrap ? DomApi.wrap(node) : node;
573
+ };
574
+ var needsToWrap = Settings.hasShadow && !Settings.nativeShadow;
575
+ DomApi.wrap = window.wrap ? window.wrap : function (node) {
576
+ return node;
577
+ };
578
+ DomApi.prototype = {
579
+ flush: function () {
580
+ Polymer.dom.flush();
581
+ },
582
+ deepContains: function (node) {
583
+ if (this.node.contains(node)) {
584
+ return true;
585
+ }
586
+ var n = node;
587
+ var doc = node.ownerDocument;
588
+ while (n && n !== doc && n !== this.node) {
589
+ n = Polymer.dom(n).parentNode || n.host;
590
+ }
591
+ return n === this.node;
592
+ },
593
+ queryDistributedElements: function (selector) {
594
+ var c$ = this.getEffectiveChildNodes();
595
+ var list = [];
596
+ for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
597
+ if (c.nodeType === Node.ELEMENT_NODE && DomApi.matchesSelector.call(c, selector)) {
598
+ list.push(c);
599
+ }
600
+ }
601
+ return list;
602
+ },
603
+ getEffectiveChildNodes: function () {
604
+ var list = [];
605
+ var c$ = this.childNodes;
606
+ for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
607
+ if (c.localName === CONTENT) {
608
+ var d$ = dom(c).getDistributedNodes();
609
+ for (var j = 0; j < d$.length; j++) {
610
+ list.push(d$[j]);
611
+ }
612
+ } else {
613
+ list.push(c);
614
+ }
615
+ }
616
+ return list;
617
+ },
618
+ observeNodes: function (callback) {
619
+ if (callback) {
620
+ if (!this.observer) {
621
+ this.observer = this.node.localName === CONTENT ? new DomApi.DistributedNodesObserver(this) : new DomApi.EffectiveNodesObserver(this);
622
+ }
623
+ return this.observer.addListener(callback);
624
+ }
625
+ },
626
+ unobserveNodes: function (handle) {
627
+ if (this.observer) {
628
+ this.observer.removeListener(handle);
629
+ }
630
+ },
631
+ notifyObserver: function () {
632
+ if (this.observer) {
633
+ this.observer.notify();
634
+ }
635
+ },
636
+ _query: function (matcher, node, halter) {
637
+ node = node || this.node;
638
+ var list = [];
639
+ this._queryElements(TreeApi.Logical.getChildNodes(node), matcher, halter, list);
640
+ return list;
641
+ },
642
+ _queryElements: function (elements, matcher, halter, list) {
643
+ for (var i = 0, l = elements.length, c; i < l && (c = elements[i]); i++) {
644
+ if (c.nodeType === Node.ELEMENT_NODE) {
645
+ if (this._queryElement(c, matcher, halter, list)) {
646
+ return true;
647
+ }
648
+ }
649
+ }
650
+ },
651
+ _queryElement: function (node, matcher, halter, list) {
652
+ var result = matcher(node);
653
+ if (result) {
654
+ list.push(node);
655
+ }
656
+ if (halter && halter(result)) {
657
+ return result;
658
+ }
659
+ this._queryElements(TreeApi.Logical.getChildNodes(node), matcher, halter, list);
660
+ }
661
+ };
662
+ var CONTENT = DomApi.CONTENT = 'content';
663
+ var dom = DomApi.factory = function (node) {
664
+ node = node || document;
665
+ if (!node.__domApi) {
666
+ node.__domApi = new DomApi.ctor(node);
667
+ }
668
+ return node.__domApi;
669
+ };
670
+ DomApi.hasApi = function (node) {
671
+ return Boolean(node.__domApi);
672
+ };
673
+ DomApi.ctor = DomApi;
674
+ Polymer.dom = function (obj, patch) {
675
+ if (obj instanceof Event) {
676
+ return Polymer.EventApi.factory(obj);
677
+ } else {
678
+ return DomApi.factory(obj, patch);
679
+ }
680
+ };
681
+ var p = Element.prototype;
682
+ DomApi.matchesSelector = p.matches || p.matchesSelector || p.mozMatchesSelector || p.msMatchesSelector || p.oMatchesSelector || p.webkitMatchesSelector;
683
+ return DomApi;
684
+ }();(function () {
685
+ 'use strict';
686
+ var Settings = Polymer.Settings;
687
+ var DomApi = Polymer.DomApi;
688
+ var dom = DomApi.factory;
689
+ var TreeApi = Polymer.TreeApi;
690
+ var getInnerHTML = Polymer.domInnerHTML.getInnerHTML;
691
+ var CONTENT = DomApi.CONTENT;
692
+ if (Settings.useShadow) {
693
+ return;
694
+ }
695
+ var nativeCloneNode = Element.prototype.cloneNode;
696
+ var nativeImportNode = Document.prototype.importNode;
697
+ Polymer.Base.extend(DomApi.prototype, {
698
+ _lazyDistribute: function (host) {
699
+ if (host.shadyRoot && host.shadyRoot._distributionClean) {
700
+ host.shadyRoot._distributionClean = false;
701
+ Polymer.dom.addDebouncer(host.debounce('_distribute', host._distributeContent));
702
+ }
703
+ },
704
+ appendChild: function (node) {
705
+ return this.insertBefore(node);
706
+ },
707
+ insertBefore: function (node, ref_node) {
708
+ if (ref_node && TreeApi.Logical.getParentNode(ref_node) !== this.node) {
709
+ throw Error('The ref_node to be inserted before is not a child ' + 'of this node');
710
+ }
711
+ if (node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) {
712
+ var parent = TreeApi.Logical.getParentNode(node);
713
+ if (parent) {
714
+ if (DomApi.hasApi(parent)) {
715
+ dom(parent).notifyObserver();
716
+ }
717
+ this._removeNode(node);
718
+ } else {
719
+ this._removeOwnerShadyRoot(node);
720
+ }
721
+ }
722
+ if (!this._addNode(node, ref_node)) {
723
+ if (ref_node) {
724
+ ref_node = ref_node.localName === CONTENT ? this._firstComposedNode(ref_node) : ref_node;
725
+ }
726
+ var container = this.node._isShadyRoot ? this.node.host : this.node;
727
+ if (ref_node) {
728
+ TreeApi.Composed.insertBefore(container, node, ref_node);
729
+ } else {
730
+ TreeApi.Composed.appendChild(container, node);
731
+ }
732
+ }
733
+ this.notifyObserver();
734
+ return node;
735
+ },
736
+ _addNode: function (node, ref_node) {
737
+ var root = this.getOwnerRoot();
738
+ if (root) {
739
+ var ipAdded = this._maybeAddInsertionPoint(node, this.node);
740
+ if (!root._invalidInsertionPoints) {
741
+ root._invalidInsertionPoints = ipAdded;
742
+ }
743
+ this._addNodeToHost(root.host, node);
744
+ }
745
+ if (TreeApi.Logical.hasChildNodes(this.node)) {
746
+ TreeApi.Logical.recordInsertBefore(node, this.node, ref_node);
747
+ }
748
+ var handled = this._maybeDistribute(node) || this.node.shadyRoot;
749
+ if (handled) {
750
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
751
+ while (node.firstChild) {
752
+ TreeApi.Composed.removeChild(node, node.firstChild);
753
+ }
754
+ } else {
755
+ var parent = TreeApi.Composed.getParentNode(node);
756
+ if (parent) {
757
+ TreeApi.Composed.removeChild(parent, node);
758
+ }
759
+ }
760
+ }
761
+ return handled;
762
+ },
763
+ removeChild: function (node) {
764
+ if (TreeApi.Logical.getParentNode(node) !== this.node) {
765
+ throw Error('The node to be removed is not a child of this node: ' + node);
766
+ }
767
+ if (!this._removeNode(node)) {
768
+ var container = this.node._isShadyRoot ? this.node.host : this.node;
769
+ var parent = TreeApi.Composed.getParentNode(node);
770
+ if (container === parent) {
771
+ TreeApi.Composed.removeChild(container, node);
772
+ }
773
+ }
774
+ this.notifyObserver();
775
+ return node;
776
+ },
777
+ _removeNode: function (node) {
778
+ var logicalParent = TreeApi.Logical.hasParentNode(node) && TreeApi.Logical.getParentNode(node);
779
+ var distributed;
780
+ var root = this._ownerShadyRootForNode(node);
781
+ if (logicalParent) {
782
+ distributed = dom(node)._maybeDistributeParent();
783
+ TreeApi.Logical.recordRemoveChild(node, logicalParent);
784
+ if (root && this._removeDistributedChildren(root, node)) {
785
+ root._invalidInsertionPoints = true;
786
+ this._lazyDistribute(root.host);
787
+ }
788
+ }
789
+ this._removeOwnerShadyRoot(node);
790
+ if (root) {
791
+ this._removeNodeFromHost(root.host, node);
792
+ }
793
+ return distributed;
794
+ },
795
+ replaceChild: function (node, ref_node) {
796
+ this.insertBefore(node, ref_node);
797
+ this.removeChild(ref_node);
798
+ return node;
799
+ },
800
+ _hasCachedOwnerRoot: function (node) {
801
+ return Boolean(node._ownerShadyRoot !== undefined);
802
+ },
803
+ getOwnerRoot: function () {
804
+ return this._ownerShadyRootForNode(this.node);
805
+ },
806
+ _ownerShadyRootForNode: function (node) {
807
+ if (!node) {
808
+ return;
809
+ }
810
+ var root = node._ownerShadyRoot;
811
+ if (root === undefined) {
812
+ if (node._isShadyRoot) {
813
+ root = node;
814
+ } else {
815
+ var parent = TreeApi.Logical.getParentNode(node);
816
+ if (parent) {
817
+ root = parent._isShadyRoot ? parent : this._ownerShadyRootForNode(parent);
818
+ } else {
819
+ root = null;
820
+ }
821
+ }
822
+ if (root || document.documentElement.contains(node)) {
823
+ node._ownerShadyRoot = root;
824
+ }
825
+ }
826
+ return root;
827
+ },
828
+ _maybeDistribute: function (node) {
829
+ var fragContent = node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && !node.__noContent && dom(node).querySelector(CONTENT);
830
+ var wrappedContent = fragContent && TreeApi.Logical.getParentNode(fragContent).nodeType !== Node.DOCUMENT_FRAGMENT_NODE;
831
+ var hasContent = fragContent || node.localName === CONTENT;
832
+ if (hasContent) {
833
+ var root = this.getOwnerRoot();
834
+ if (root) {
835
+ this._lazyDistribute(root.host);
836
+ }
837
+ }
838
+ var needsDist = this._nodeNeedsDistribution(this.node);
839
+ if (needsDist) {
840
+ this._lazyDistribute(this.node);
841
+ }
842
+ return needsDist || hasContent && !wrappedContent;
843
+ },
844
+ _maybeAddInsertionPoint: function (node, parent) {
845
+ var added;
846
+ if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && !node.__noContent) {
847
+ var c$ = dom(node).querySelectorAll(CONTENT);
848
+ for (var i = 0, n, np, na; i < c$.length && (n = c$[i]); i++) {
849
+ np = TreeApi.Logical.getParentNode(n);
850
+ if (np === node) {
851
+ np = parent;
852
+ }
853
+ na = this._maybeAddInsertionPoint(n, np);
854
+ added = added || na;
855
+ }
856
+ } else if (node.localName === CONTENT) {
857
+ TreeApi.Logical.saveChildNodes(parent);
858
+ TreeApi.Logical.saveChildNodes(node);
859
+ added = true;
860
+ }
861
+ return added;
862
+ },
863
+ _updateInsertionPoints: function (host) {
864
+ var i$ = host.shadyRoot._insertionPoints = dom(host.shadyRoot).querySelectorAll(CONTENT);
865
+ for (var i = 0, c; i < i$.length; i++) {
866
+ c = i$[i];
867
+ TreeApi.Logical.saveChildNodes(c);
868
+ TreeApi.Logical.saveChildNodes(TreeApi.Logical.getParentNode(c));
869
+ }
870
+ },
871
+ _nodeNeedsDistribution: function (node) {
872
+ return node && node.shadyRoot && DomApi.hasInsertionPoint(node.shadyRoot);
873
+ },
874
+ _addNodeToHost: function (host, node) {
875
+ if (host._elementAdd) {
876
+ host._elementAdd(node);
877
+ }
878
+ },
879
+ _removeNodeFromHost: function (host, node) {
880
+ if (host._elementRemove) {
881
+ host._elementRemove(node);
882
+ }
883
+ },
884
+ _removeDistributedChildren: function (root, container) {
885
+ var hostNeedsDist;
886
+ var ip$ = root._insertionPoints;
887
+ for (var i = 0; i < ip$.length; i++) {
888
+ var content = ip$[i];
889
+ if (this._contains(container, content)) {
890
+ var dc$ = dom(content).getDistributedNodes();
891
+ for (var j = 0; j < dc$.length; j++) {
892
+ hostNeedsDist = true;
893
+ var node = dc$[j];
894
+ var parent = TreeApi.Composed.getParentNode(node);
895
+ if (parent) {
896
+ TreeApi.Composed.removeChild(parent, node);
897
+ }
898
+ }
899
+ }
900
+ }
901
+ return hostNeedsDist;
902
+ },
903
+ _contains: function (container, node) {
904
+ while (node) {
905
+ if (node == container) {
906
+ return true;
907
+ }
908
+ node = TreeApi.Logical.getParentNode(node);
909
+ }
910
+ },
911
+ _removeOwnerShadyRoot: function (node) {
912
+ if (this._hasCachedOwnerRoot(node)) {
913
+ var c$ = TreeApi.Logical.getChildNodes(node);
914
+ for (var i = 0, l = c$.length, n; i < l && (n = c$[i]); i++) {
915
+ this._removeOwnerShadyRoot(n);
916
+ }
917
+ }
918
+ node._ownerShadyRoot = undefined;
919
+ },
920
+ _firstComposedNode: function (content) {
921
+ var n$ = dom(content).getDistributedNodes();
922
+ for (var i = 0, l = n$.length, n, p$; i < l && (n = n$[i]); i++) {
923
+ p$ = dom(n).getDestinationInsertionPoints();
924
+ if (p$[p$.length - 1] === content) {
925
+ return n;
926
+ }
927
+ }
928
+ },
929
+ querySelector: function (selector) {
930
+ var result = this._query(function (n) {
931
+ return DomApi.matchesSelector.call(n, selector);
932
+ }, this.node, function (n) {
933
+ return Boolean(n);
934
+ })[0];
935
+ return result || null;
936
+ },
937
+ querySelectorAll: function (selector) {
938
+ return this._query(function (n) {
939
+ return DomApi.matchesSelector.call(n, selector);
940
+ }, this.node);
941
+ },
942
+ getDestinationInsertionPoints: function () {
943
+ return this.node._destinationInsertionPoints || [];
944
+ },
945
+ getDistributedNodes: function () {
946
+ return this.node._distributedNodes || [];
947
+ },
948
+ _clear: function () {
949
+ while (this.childNodes.length) {
950
+ this.removeChild(this.childNodes[0]);
951
+ }
952
+ },
953
+ setAttribute: function (name, value) {
954
+ this.node.setAttribute(name, value);
955
+ this._maybeDistributeParent();
956
+ },
957
+ removeAttribute: function (name) {
958
+ this.node.removeAttribute(name);
959
+ this._maybeDistributeParent();
960
+ },
961
+ _maybeDistributeParent: function () {
962
+ if (this._nodeNeedsDistribution(this.parentNode)) {
963
+ this._lazyDistribute(this.parentNode);
964
+ return true;
965
+ }
966
+ },
967
+ cloneNode: function (deep) {
968
+ var n = nativeCloneNode.call(this.node, false);
969
+ if (deep) {
970
+ var c$ = this.childNodes;
971
+ var d = dom(n);
972
+ for (var i = 0, nc; i < c$.length; i++) {
973
+ nc = dom(c$[i]).cloneNode(true);
974
+ d.appendChild(nc);
975
+ }
976
+ }
977
+ return n;
978
+ },
979
+ importNode: function (externalNode, deep) {
980
+ var doc = this.node instanceof Document ? this.node : this.node.ownerDocument;
981
+ var n = nativeImportNode.call(doc, externalNode, false);
982
+ if (deep) {
983
+ var c$ = TreeApi.Logical.getChildNodes(externalNode);
984
+ var d = dom(n);
985
+ for (var i = 0, nc; i < c$.length; i++) {
986
+ nc = dom(doc).importNode(c$[i], true);
987
+ d.appendChild(nc);
988
+ }
989
+ }
990
+ return n;
991
+ },
992
+ _getComposedInnerHTML: function () {
993
+ return getInnerHTML(this.node, true);
994
+ }
995
+ });
996
+ Object.defineProperties(DomApi.prototype, {
997
+ activeElement: {
998
+ get: function () {
999
+ var active = document.activeElement;
1000
+ if (!active) {
1001
+ return null;
1002
+ }
1003
+ var isShadyRoot = !!this.node._isShadyRoot;
1004
+ if (this.node !== document) {
1005
+ if (!isShadyRoot) {
1006
+ return null;
1007
+ }
1008
+ if (this.node.host === active || !this.node.host.contains(active)) {
1009
+ return null;
1010
+ }
1011
+ }
1012
+ var activeRoot = dom(active).getOwnerRoot();
1013
+ while (activeRoot && activeRoot !== this.node) {
1014
+ active = activeRoot.host;
1015
+ activeRoot = dom(active).getOwnerRoot();
1016
+ }
1017
+ if (this.node === document) {
1018
+ return activeRoot ? null : active;
1019
+ } else {
1020
+ return activeRoot === this.node ? active : null;
1021
+ }
1022
+ },
1023
+ configurable: true
1024
+ },
1025
+ childNodes: {
1026
+ get: function () {
1027
+ var c$ = TreeApi.Logical.getChildNodes(this.node);
1028
+ return Array.isArray(c$) ? c$ : TreeApi.arrayCopyChildNodes(this.node);
1029
+ },
1030
+ configurable: true
1031
+ },
1032
+ children: {
1033
+ get: function () {
1034
+ if (TreeApi.Logical.hasChildNodes(this.node)) {
1035
+ return Array.prototype.filter.call(this.childNodes, function (n) {
1036
+ return n.nodeType === Node.ELEMENT_NODE;
1037
+ });
1038
+ } else {
1039
+ return TreeApi.arrayCopyChildren(this.node);
1040
+ }
1041
+ },
1042
+ configurable: true
1043
+ },
1044
+ parentNode: {
1045
+ get: function () {
1046
+ return TreeApi.Logical.getParentNode(this.node);
1047
+ },
1048
+ configurable: true
1049
+ },
1050
+ firstChild: {
1051
+ get: function () {
1052
+ return TreeApi.Logical.getFirstChild(this.node);
1053
+ },
1054
+ configurable: true
1055
+ },
1056
+ lastChild: {
1057
+ get: function () {
1058
+ return TreeApi.Logical.getLastChild(this.node);
1059
+ },
1060
+ configurable: true
1061
+ },
1062
+ nextSibling: {
1063
+ get: function () {
1064
+ return TreeApi.Logical.getNextSibling(this.node);
1065
+ },
1066
+ configurable: true
1067
+ },
1068
+ previousSibling: {
1069
+ get: function () {
1070
+ return TreeApi.Logical.getPreviousSibling(this.node);
1071
+ },
1072
+ configurable: true
1073
+ },
1074
+ firstElementChild: {
1075
+ get: function () {
1076
+ return TreeApi.Logical.getFirstElementChild(this.node);
1077
+ },
1078
+ configurable: true
1079
+ },
1080
+ lastElementChild: {
1081
+ get: function () {
1082
+ return TreeApi.Logical.getLastElementChild(this.node);
1083
+ },
1084
+ configurable: true
1085
+ },
1086
+ nextElementSibling: {
1087
+ get: function () {
1088
+ return TreeApi.Logical.getNextElementSibling(this.node);
1089
+ },
1090
+ configurable: true
1091
+ },
1092
+ previousElementSibling: {
1093
+ get: function () {
1094
+ return TreeApi.Logical.getPreviousElementSibling(this.node);
1095
+ },
1096
+ configurable: true
1097
+ },
1098
+ textContent: {
1099
+ get: function () {
1100
+ var nt = this.node.nodeType;
1101
+ if (nt === Node.TEXT_NODE || nt === Node.COMMENT_NODE) {
1102
+ return this.node.textContent;
1103
+ } else {
1104
+ var tc = [];
1105
+ for (var i = 0, cn = this.childNodes, c; c = cn[i]; i++) {
1106
+ if (c.nodeType !== Node.COMMENT_NODE) {
1107
+ tc.push(c.textContent);
1108
+ }
1109
+ }
1110
+ return tc.join('');
1111
+ }
1112
+ },
1113
+ set: function (text) {
1114
+ var nt = this.node.nodeType;
1115
+ if (nt === Node.TEXT_NODE || nt === Node.COMMENT_NODE) {
1116
+ this.node.textContent = text;
1117
+ } else {
1118
+ this._clear();
1119
+ if (text) {
1120
+ this.appendChild(document.createTextNode(text));
1121
+ }
1122
+ }
1123
+ },
1124
+ configurable: true
1125
+ },
1126
+ innerHTML: {
1127
+ get: function () {
1128
+ var nt = this.node.nodeType;
1129
+ if (nt === Node.TEXT_NODE || nt === Node.COMMENT_NODE) {
1130
+ return null;
1131
+ } else {
1132
+ return getInnerHTML(this.node);
1133
+ }
1134
+ },
1135
+ set: function (text) {
1136
+ var nt = this.node.nodeType;
1137
+ if (nt !== Node.TEXT_NODE || nt !== Node.COMMENT_NODE) {
1138
+ this._clear();
1139
+ var d = document.createElement('div');
1140
+ d.innerHTML = text;
1141
+ var c$ = TreeApi.arrayCopyChildNodes(d);
1142
+ for (var i = 0; i < c$.length; i++) {
1143
+ this.appendChild(c$[i]);
1144
+ }
1145
+ }
1146
+ },
1147
+ configurable: true
1148
+ }
1149
+ });
1150
+ DomApi.hasInsertionPoint = function (root) {
1151
+ return Boolean(root && root._insertionPoints.length);
1152
+ };
1153
+ }());(function () {
1154
+ 'use strict';
1155
+ var Settings = Polymer.Settings;
1156
+ var TreeApi = Polymer.TreeApi;
1157
+ var DomApi = Polymer.DomApi;
1158
+ if (!Settings.useShadow) {
1159
+ return;
1160
+ }
1161
+ Polymer.Base.extend(DomApi.prototype, {
1162
+ querySelectorAll: function (selector) {
1163
+ return TreeApi.arrayCopy(this.node.querySelectorAll(selector));
1164
+ },
1165
+ getOwnerRoot: function () {
1166
+ var n = this.node;
1167
+ while (n) {
1168
+ if (n.nodeType === Node.DOCUMENT_FRAGMENT_NODE && n.host) {
1169
+ return n;
1170
+ }
1171
+ n = n.parentNode;
1172
+ }
1173
+ },
1174
+ importNode: function (externalNode, deep) {
1175
+ var doc = this.node instanceof Document ? this.node : this.node.ownerDocument;
1176
+ return doc.importNode(externalNode, deep);
1177
+ },
1178
+ getDestinationInsertionPoints: function () {
1179
+ var n$ = this.node.getDestinationInsertionPoints && this.node.getDestinationInsertionPoints();
1180
+ return n$ ? TreeApi.arrayCopy(n$) : [];
1181
+ },
1182
+ getDistributedNodes: function () {
1183
+ var n$ = this.node.getDistributedNodes && this.node.getDistributedNodes();
1184
+ return n$ ? TreeApi.arrayCopy(n$) : [];
1185
+ }
1186
+ });
1187
+ Object.defineProperties(DomApi.prototype, {
1188
+ activeElement: {
1189
+ get: function () {
1190
+ var node = DomApi.wrap(this.node);
1191
+ var activeElement = node.activeElement;
1192
+ return node.contains(activeElement) ? activeElement : null;
1193
+ },
1194
+ configurable: true
1195
+ },
1196
+ childNodes: {
1197
+ get: function () {
1198
+ return TreeApi.arrayCopyChildNodes(this.node);
1199
+ },
1200
+ configurable: true
1201
+ },
1202
+ children: {
1203
+ get: function () {
1204
+ return TreeApi.arrayCopyChildren(this.node);
1205
+ },
1206
+ configurable: true
1207
+ },
1208
+ textContent: {
1209
+ get: function () {
1210
+ return this.node.textContent;
1211
+ },
1212
+ set: function (value) {
1213
+ return this.node.textContent = value;
1214
+ },
1215
+ configurable: true
1216
+ },
1217
+ innerHTML: {
1218
+ get: function () {
1219
+ return this.node.innerHTML;
1220
+ },
1221
+ set: function (value) {
1222
+ return this.node.innerHTML = value;
1223
+ },
1224
+ configurable: true
1225
+ }
1226
+ });
1227
+ var forwardMethods = function (m$) {
1228
+ for (var i = 0; i < m$.length; i++) {
1229
+ forwardMethod(m$[i]);
1230
+ }
1231
+ };
1232
+ var forwardMethod = function (method) {
1233
+ DomApi.prototype[method] = function () {
1234
+ return this.node[method].apply(this.node, arguments);
1235
+ };
1236
+ };
1237
+ forwardMethods([
1238
+ 'cloneNode',
1239
+ 'appendChild',
1240
+ 'insertBefore',
1241
+ 'removeChild',
1242
+ 'replaceChild',
1243
+ 'setAttribute',
1244
+ 'removeAttribute',
1245
+ 'querySelector'
1246
+ ]);
1247
+ var forwardProperties = function (f$) {
1248
+ for (var i = 0; i < f$.length; i++) {
1249
+ forwardProperty(f$[i]);
1250
+ }
1251
+ };
1252
+ var forwardProperty = function (name) {
1253
+ Object.defineProperty(DomApi.prototype, name, {
1254
+ get: function () {
1255
+ return this.node[name];
1256
+ },
1257
+ configurable: true
1258
+ });
1259
+ };
1260
+ forwardProperties([
1261
+ 'parentNode',
1262
+ 'firstChild',
1263
+ 'lastChild',
1264
+ 'nextSibling',
1265
+ 'previousSibling',
1266
+ 'firstElementChild',
1267
+ 'lastElementChild',
1268
+ 'nextElementSibling',
1269
+ 'previousElementSibling'
1270
+ ]);
1271
+ }());Polymer.Base.extend(Polymer.dom, {
1272
+ _flushGuard: 0,
1273
+ _FLUSH_MAX: 100,
1274
+ _needsTakeRecords: !Polymer.Settings.useNativeCustomElements,
1275
+ _debouncers: [],
1276
+ _staticFlushList: [],
1277
+ _finishDebouncer: null,
1278
+ flush: function () {
1279
+ this._flushGuard = 0;
1280
+ this._prepareFlush();
1281
+ while (this._debouncers.length && this._flushGuard < this._FLUSH_MAX) {
1282
+ while (this._debouncers.length) {
1283
+ this._debouncers.shift().complete();
1284
+ }
1285
+ if (this._finishDebouncer) {
1286
+ this._finishDebouncer.complete();
1287
+ }
1288
+ this._prepareFlush();
1289
+ this._flushGuard++;
1290
+ }
1291
+ if (this._flushGuard >= this._FLUSH_MAX) {
1292
+ console.warn('Polymer.dom.flush aborted. Flush may not be complete.');
1293
+ }
1294
+ },
1295
+ _prepareFlush: function () {
1296
+ if (this._needsTakeRecords) {
1297
+ CustomElements.takeRecords();
1298
+ }
1299
+ for (var i = 0; i < this._staticFlushList.length; i++) {
1300
+ this._staticFlushList[i]();
1301
+ }
1302
+ },
1303
+ addStaticFlush: function (fn) {
1304
+ this._staticFlushList.push(fn);
1305
+ },
1306
+ removeStaticFlush: function (fn) {
1307
+ var i = this._staticFlushList.indexOf(fn);
1308
+ if (i >= 0) {
1309
+ this._staticFlushList.splice(i, 1);
1310
+ }
1311
+ },
1312
+ addDebouncer: function (debouncer) {
1313
+ this._debouncers.push(debouncer);
1314
+ this._finishDebouncer = Polymer.Debounce(this._finishDebouncer, this._finishFlush);
1315
+ },
1316
+ _finishFlush: function () {
1317
+ Polymer.dom._debouncers = [];
1318
+ }
1319
+ });Polymer.EventApi = function () {
1320
+ 'use strict';
1321
+ var DomApi = Polymer.DomApi.ctor;
1322
+ var Settings = Polymer.Settings;
1323
+ DomApi.Event = function (event) {
1324
+ this.event = event;
1325
+ };
1326
+ if (Settings.useShadow) {
1327
+ DomApi.Event.prototype = {
1328
+ get rootTarget() {
1329
+ return this.event.path[0];
1330
+ },
1331
+ get localTarget() {
1332
+ return this.event.target;
1333
+ },
1334
+ get path() {
1335
+ var path = this.event.path;
1336
+ if (!Array.isArray(path)) {
1337
+ path = Array.prototype.slice.call(path);
1338
+ }
1339
+ return path;
1340
+ }
1341
+ };
1342
+ } else {
1343
+ DomApi.Event.prototype = {
1344
+ get rootTarget() {
1345
+ return this.event.target;
1346
+ },
1347
+ get localTarget() {
1348
+ var current = this.event.currentTarget;
1349
+ var currentRoot = current && Polymer.dom(current).getOwnerRoot();
1350
+ var p$ = this.path;
1351
+ for (var i = 0; i < p$.length; i++) {
1352
+ if (Polymer.dom(p$[i]).getOwnerRoot() === currentRoot) {
1353
+ return p$[i];
1354
+ }
1355
+ }
1356
+ },
1357
+ get path() {
1358
+ if (!this.event._path) {
1359
+ var path = [];
1360
+ var current = this.rootTarget;
1361
+ while (current) {
1362
+ path.push(current);
1363
+ var insertionPoints = Polymer.dom(current).getDestinationInsertionPoints();
1364
+ if (insertionPoints.length) {
1365
+ for (var i = 0; i < insertionPoints.length - 1; i++) {
1366
+ path.push(insertionPoints[i]);
1367
+ }
1368
+ current = insertionPoints[insertionPoints.length - 1];
1369
+ } else {
1370
+ current = Polymer.dom(current).parentNode || current.host;
1371
+ }
1372
+ }
1373
+ path.push(window);
1374
+ this.event._path = path;
1375
+ }
1376
+ return this.event._path;
1377
+ }
1378
+ };
1379
+ }
1380
+ var factory = function (event) {
1381
+ if (!event.__eventApi) {
1382
+ event.__eventApi = new DomApi.Event(event);
1383
+ }
1384
+ return event.__eventApi;
1385
+ };
1386
+ return { factory: factory };
1387
+ }();(function () {
1388
+ 'use strict';
1389
+ var DomApi = Polymer.DomApi.ctor;
1390
+ var useShadow = Polymer.Settings.useShadow;
1391
+ Object.defineProperty(DomApi.prototype, 'classList', {
1392
+ get: function () {
1393
+ if (!this._classList) {
1394
+ this._classList = new DomApi.ClassList(this);
1395
+ }
1396
+ return this._classList;
1397
+ },
1398
+ configurable: true
1399
+ });
1400
+ DomApi.ClassList = function (host) {
1401
+ this.domApi = host;
1402
+ this.node = host.node;
1403
+ };
1404
+ DomApi.ClassList.prototype = {
1405
+ add: function () {
1406
+ this.node.classList.add.apply(this.node.classList, arguments);
1407
+ this._distributeParent();
1408
+ },
1409
+ remove: function () {
1410
+ this.node.classList.remove.apply(this.node.classList, arguments);
1411
+ this._distributeParent();
1412
+ },
1413
+ toggle: function () {
1414
+ this.node.classList.toggle.apply(this.node.classList, arguments);
1415
+ this._distributeParent();
1416
+ },
1417
+ _distributeParent: function () {
1418
+ if (!useShadow) {
1419
+ this.domApi._maybeDistributeParent();
1420
+ }
1421
+ },
1422
+ contains: function () {
1423
+ return this.node.classList.contains.apply(this.node.classList, arguments);
1424
+ }
1425
+ };
1426
+ }());(function () {
1427
+ 'use strict';
1428
+ var DomApi = Polymer.DomApi.ctor;
1429
+ var Settings = Polymer.Settings;
1430
+ DomApi.EffectiveNodesObserver = function (domApi) {
1431
+ this.domApi = domApi;
1432
+ this.node = this.domApi.node;
1433
+ this._listeners = [];
1434
+ };
1435
+ DomApi.EffectiveNodesObserver.prototype = {
1436
+ addListener: function (callback) {
1437
+ if (!this._isSetup) {
1438
+ this._setup();
1439
+ this._isSetup = true;
1440
+ }
1441
+ var listener = {
1442
+ fn: callback,
1443
+ _nodes: []
1444
+ };
1445
+ this._listeners.push(listener);
1446
+ this._scheduleNotify();
1447
+ return listener;
1448
+ },
1449
+ removeListener: function (handle) {
1450
+ var i = this._listeners.indexOf(handle);
1451
+ if (i >= 0) {
1452
+ this._listeners.splice(i, 1);
1453
+ handle._nodes = [];
1454
+ }
1455
+ if (!this._hasListeners()) {
1456
+ this._cleanup();
1457
+ this._isSetup = false;
1458
+ }
1459
+ },
1460
+ _setup: function () {
1461
+ this._observeContentElements(this.domApi.childNodes);
1462
+ },
1463
+ _cleanup: function () {
1464
+ this._unobserveContentElements(this.domApi.childNodes);
1465
+ },
1466
+ _hasListeners: function () {
1467
+ return Boolean(this._listeners.length);
1468
+ },
1469
+ _scheduleNotify: function () {
1470
+ if (this._debouncer) {
1471
+ this._debouncer.stop();
1472
+ }
1473
+ this._debouncer = Polymer.Debounce(this._debouncer, this._notify);
1474
+ this._debouncer.context = this;
1475
+ Polymer.dom.addDebouncer(this._debouncer);
1476
+ },
1477
+ notify: function () {
1478
+ if (this._hasListeners()) {
1479
+ this._scheduleNotify();
1480
+ }
1481
+ },
1482
+ _notify: function () {
1483
+ this._beforeCallListeners();
1484
+ this._callListeners();
1485
+ },
1486
+ _beforeCallListeners: function () {
1487
+ this._updateContentElements();
1488
+ },
1489
+ _updateContentElements: function () {
1490
+ this._observeContentElements(this.domApi.childNodes);
1491
+ },
1492
+ _observeContentElements: function (elements) {
1493
+ for (var i = 0, n; i < elements.length && (n = elements[i]); i++) {
1494
+ if (this._isContent(n)) {
1495
+ n.__observeNodesMap = n.__observeNodesMap || new WeakMap();
1496
+ if (!n.__observeNodesMap.has(this)) {
1497
+ n.__observeNodesMap.set(this, this._observeContent(n));
1498
+ }
1499
+ }
1500
+ }
1501
+ },
1502
+ _observeContent: function (content) {
1503
+ var self = this;
1504
+ var h = Polymer.dom(content).observeNodes(function () {
1505
+ self._scheduleNotify();
1506
+ });
1507
+ h._avoidChangeCalculation = true;
1508
+ return h;
1509
+ },
1510
+ _unobserveContentElements: function (elements) {
1511
+ for (var i = 0, n, h; i < elements.length && (n = elements[i]); i++) {
1512
+ if (this._isContent(n)) {
1513
+ h = n.__observeNodesMap.get(this);
1514
+ if (h) {
1515
+ Polymer.dom(n).unobserveNodes(h);
1516
+ n.__observeNodesMap.delete(this);
1517
+ }
1518
+ }
1519
+ }
1520
+ },
1521
+ _isContent: function (node) {
1522
+ return node.localName === 'content';
1523
+ },
1524
+ _callListeners: function () {
1525
+ var o$ = this._listeners;
1526
+ var nodes = this._getEffectiveNodes();
1527
+ for (var i = 0, o; i < o$.length && (o = o$[i]); i++) {
1528
+ var info = this._generateListenerInfo(o, nodes);
1529
+ if (info || o._alwaysNotify) {
1530
+ this._callListener(o, info);
1531
+ }
1532
+ }
1533
+ },
1534
+ _getEffectiveNodes: function () {
1535
+ return this.domApi.getEffectiveChildNodes();
1536
+ },
1537
+ _generateListenerInfo: function (listener, newNodes) {
1538
+ if (listener._avoidChangeCalculation) {
1539
+ return true;
1540
+ }
1541
+ var oldNodes = listener._nodes;
1542
+ var info = {
1543
+ target: this.node,
1544
+ addedNodes: [],
1545
+ removedNodes: []
1546
+ };
1547
+ var splices = Polymer.ArraySplice.calculateSplices(newNodes, oldNodes);
1548
+ for (var i = 0, s; i < splices.length && (s = splices[i]); i++) {
1549
+ for (var j = 0, n; j < s.removed.length && (n = s.removed[j]); j++) {
1550
+ info.removedNodes.push(n);
1551
+ }
1552
+ }
1553
+ for (i = 0, s; i < splices.length && (s = splices[i]); i++) {
1554
+ for (j = s.index; j < s.index + s.addedCount; j++) {
1555
+ info.addedNodes.push(newNodes[j]);
1556
+ }
1557
+ }
1558
+ listener._nodes = newNodes;
1559
+ if (info.addedNodes.length || info.removedNodes.length) {
1560
+ return info;
1561
+ }
1562
+ },
1563
+ _callListener: function (listener, info) {
1564
+ return listener.fn.call(this.node, info);
1565
+ },
1566
+ enableShadowAttributeTracking: function () {
1567
+ }
1568
+ };
1569
+ if (Settings.useShadow) {
1570
+ var baseSetup = DomApi.EffectiveNodesObserver.prototype._setup;
1571
+ var baseCleanup = DomApi.EffectiveNodesObserver.prototype._cleanup;
1572
+ Polymer.Base.extend(DomApi.EffectiveNodesObserver.prototype, {
1573
+ _setup: function () {
1574
+ if (!this._observer) {
1575
+ var self = this;
1576
+ this._mutationHandler = function (mxns) {
1577
+ if (mxns && mxns.length) {
1578
+ self._scheduleNotify();
1579
+ }
1580
+ };
1581
+ this._observer = new MutationObserver(this._mutationHandler);
1582
+ this._boundFlush = function () {
1583
+ self._flush();
1584
+ };
1585
+ Polymer.dom.addStaticFlush(this._boundFlush);
1586
+ this._observer.observe(this.node, { childList: true });
1587
+ }
1588
+ baseSetup.call(this);
1589
+ },
1590
+ _cleanup: function () {
1591
+ this._observer.disconnect();
1592
+ this._observer = null;
1593
+ this._mutationHandler = null;
1594
+ Polymer.dom.removeStaticFlush(this._boundFlush);
1595
+ baseCleanup.call(this);
1596
+ },
1597
+ _flush: function () {
1598
+ if (this._observer) {
1599
+ this._mutationHandler(this._observer.takeRecords());
1600
+ }
1601
+ },
1602
+ enableShadowAttributeTracking: function () {
1603
+ if (this._observer) {
1604
+ this._makeContentListenersAlwaysNotify();
1605
+ this._observer.disconnect();
1606
+ this._observer.observe(this.node, {
1607
+ childList: true,
1608
+ attributes: true,
1609
+ subtree: true
1610
+ });
1611
+ var root = this.domApi.getOwnerRoot();
1612
+ var host = root && root.host;
1613
+ if (host && Polymer.dom(host).observer) {
1614
+ Polymer.dom(host).observer.enableShadowAttributeTracking();
1615
+ }
1616
+ }
1617
+ },
1618
+ _makeContentListenersAlwaysNotify: function () {
1619
+ for (var i = 0, h; i < this._listeners.length; i++) {
1620
+ h = this._listeners[i];
1621
+ h._alwaysNotify = h._isContentListener;
1622
+ }
1623
+ }
1624
+ });
1625
+ }
1626
+ }());(function () {
1627
+ 'use strict';
1628
+ var DomApi = Polymer.DomApi.ctor;
1629
+ var Settings = Polymer.Settings;
1630
+ DomApi.DistributedNodesObserver = function (domApi) {
1631
+ DomApi.EffectiveNodesObserver.call(this, domApi);
1632
+ };
1633
+ DomApi.DistributedNodesObserver.prototype = Object.create(DomApi.EffectiveNodesObserver.prototype);
1634
+ Polymer.Base.extend(DomApi.DistributedNodesObserver.prototype, {
1635
+ _setup: function () {
1636
+ },
1637
+ _cleanup: function () {
1638
+ },
1639
+ _beforeCallListeners: function () {
1640
+ },
1641
+ _getEffectiveNodes: function () {
1642
+ return this.domApi.getDistributedNodes();
1643
+ }
1644
+ });
1645
+ if (Settings.useShadow) {
1646
+ Polymer.Base.extend(DomApi.DistributedNodesObserver.prototype, {
1647
+ _setup: function () {
1648
+ if (!this._observer) {
1649
+ var root = this.domApi.getOwnerRoot();
1650
+ var host = root && root.host;
1651
+ if (host) {
1652
+ var self = this;
1653
+ this._observer = Polymer.dom(host).observeNodes(function () {
1654
+ self._scheduleNotify();
1655
+ });
1656
+ this._observer._isContentListener = true;
1657
+ if (this._hasAttrSelect()) {
1658
+ Polymer.dom(host).observer.enableShadowAttributeTracking();
1659
+ }
1660
+ }
1661
+ }
1662
+ },
1663
+ _hasAttrSelect: function () {
1664
+ var select = this.node.getAttribute('select');
1665
+ return select && select.match(/[[.]+/);
1666
+ },
1667
+ _cleanup: function () {
1668
+ var root = this.domApi.getOwnerRoot();
1669
+ var host = root && root.host;
1670
+ if (host) {
1671
+ Polymer.dom(host).unobserveNodes(this._observer);
1672
+ }
1673
+ this._observer = null;
1674
+ }
1675
+ });
1676
+ }
1677
+ }());(function () {
1678
+ var DomApi = Polymer.DomApi;
1679
+ var TreeApi = Polymer.TreeApi;
1680
+ Polymer.Base._addFeature({
1681
+ _prepShady: function () {
1682
+ this._useContent = this._useContent || Boolean(this._template);
1683
+ },
1684
+ _setupShady: function () {
1685
+ this.shadyRoot = null;
1686
+ if (!this.__domApi) {
1687
+ this.__domApi = null;
1688
+ }
1689
+ if (!this.__dom) {
1690
+ this.__dom = null;
1691
+ }
1692
+ if (!this._ownerShadyRoot) {
1693
+ this._ownerShadyRoot = undefined;
1694
+ }
1695
+ },
1696
+ _poolContent: function () {
1697
+ if (this._useContent) {
1698
+ TreeApi.Logical.saveChildNodes(this);
1699
+ }
1700
+ },
1701
+ _setupRoot: function () {
1702
+ if (this._useContent) {
1703
+ this._createLocalRoot();
1704
+ if (!this.dataHost) {
1705
+ upgradeLogicalChildren(TreeApi.Logical.getChildNodes(this));
1706
+ }
1707
+ }
1708
+ },
1709
+ _createLocalRoot: function () {
1710
+ this.shadyRoot = this.root;
1711
+ this.shadyRoot._distributionClean = false;
1712
+ this.shadyRoot._hasDistributed = false;
1713
+ this.shadyRoot._isShadyRoot = true;
1714
+ this.shadyRoot._dirtyRoots = [];
1715
+ var i$ = this.shadyRoot._insertionPoints = !this._notes || this._notes._hasContent ? this.shadyRoot.querySelectorAll('content') : [];
1716
+ TreeApi.Logical.saveChildNodes(this.shadyRoot);
1717
+ for (var i = 0, c; i < i$.length; i++) {
1718
+ c = i$[i];
1719
+ TreeApi.Logical.saveChildNodes(c);
1720
+ TreeApi.Logical.saveChildNodes(c.parentNode);
1721
+ }
1722
+ this.shadyRoot.host = this;
1723
+ },
1724
+ get domHost() {
1725
+ var root = Polymer.dom(this).getOwnerRoot();
1726
+ return root && root.host;
1727
+ },
1728
+ distributeContent: function (updateInsertionPoints) {
1729
+ if (this.shadyRoot) {
1730
+ this.shadyRoot._invalidInsertionPoints = this.shadyRoot._invalidInsertionPoints || updateInsertionPoints;
1731
+ var host = getTopDistributingHost(this);
1732
+ Polymer.dom(this)._lazyDistribute(host);
1733
+ }
1734
+ },
1735
+ _distributeContent: function () {
1736
+ if (this._useContent && !this.shadyRoot._distributionClean) {
1737
+ if (this.shadyRoot._invalidInsertionPoints) {
1738
+ Polymer.dom(this)._updateInsertionPoints(this);
1739
+ this.shadyRoot._invalidInsertionPoints = false;
1740
+ }
1741
+ this._beginDistribute();
1742
+ this._distributeDirtyRoots();
1743
+ this._finishDistribute();
1744
+ }
1745
+ },
1746
+ _beginDistribute: function () {
1747
+ if (this._useContent && DomApi.hasInsertionPoint(this.shadyRoot)) {
1748
+ this._resetDistribution();
1749
+ this._distributePool(this.shadyRoot, this._collectPool());
1750
+ }
1751
+ },
1752
+ _distributeDirtyRoots: function () {
1753
+ var c$ = this.shadyRoot._dirtyRoots;
1754
+ for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
1755
+ c._distributeContent();
1756
+ }
1757
+ this.shadyRoot._dirtyRoots = [];
1758
+ },
1759
+ _finishDistribute: function () {
1760
+ if (this._useContent) {
1761
+ this.shadyRoot._distributionClean = true;
1762
+ if (DomApi.hasInsertionPoint(this.shadyRoot)) {
1763
+ this._composeTree();
1764
+ notifyContentObservers(this.shadyRoot);
1765
+ } else {
1766
+ if (!this.shadyRoot._hasDistributed) {
1767
+ TreeApi.Composed.clearChildNodes(this);
1768
+ this.appendChild(this.shadyRoot);
1769
+ } else {
1770
+ var children = this._composeNode(this);
1771
+ this._updateChildNodes(this, children);
1772
+ }
1773
+ }
1774
+ if (!this.shadyRoot._hasDistributed) {
1775
+ notifyInitialDistribution(this);
1776
+ }
1777
+ this.shadyRoot._hasDistributed = true;
1778
+ }
1779
+ },
1780
+ elementMatches: function (selector, node) {
1781
+ node = node || this;
1782
+ return DomApi.matchesSelector.call(node, selector);
1783
+ },
1784
+ _resetDistribution: function () {
1785
+ var children = TreeApi.Logical.getChildNodes(this);
1786
+ for (var i = 0; i < children.length; i++) {
1787
+ var child = children[i];
1788
+ if (child._destinationInsertionPoints) {
1789
+ child._destinationInsertionPoints = undefined;
1790
+ }
1791
+ if (isInsertionPoint(child)) {
1792
+ clearDistributedDestinationInsertionPoints(child);
1793
+ }
1794
+ }
1795
+ var root = this.shadyRoot;
1796
+ var p$ = root._insertionPoints;
1797
+ for (var j = 0; j < p$.length; j++) {
1798
+ p$[j]._distributedNodes = [];
1799
+ }
1800
+ },
1801
+ _collectPool: function () {
1802
+ var pool = [];
1803
+ var children = TreeApi.Logical.getChildNodes(this);
1804
+ for (var i = 0; i < children.length; i++) {
1805
+ var child = children[i];
1806
+ if (isInsertionPoint(child)) {
1807
+ pool.push.apply(pool, child._distributedNodes);
1808
+ } else {
1809
+ pool.push(child);
1810
+ }
1811
+ }
1812
+ return pool;
1813
+ },
1814
+ _distributePool: function (node, pool) {
1815
+ var p$ = node._insertionPoints;
1816
+ for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) {
1817
+ this._distributeInsertionPoint(p, pool);
1818
+ maybeRedistributeParent(p, this);
1819
+ }
1820
+ },
1821
+ _distributeInsertionPoint: function (content, pool) {
1822
+ var anyDistributed = false;
1823
+ for (var i = 0, l = pool.length, node; i < l; i++) {
1824
+ node = pool[i];
1825
+ if (!node) {
1826
+ continue;
1827
+ }
1828
+ if (this._matchesContentSelect(node, content)) {
1829
+ distributeNodeInto(node, content);
1830
+ pool[i] = undefined;
1831
+ anyDistributed = true;
1832
+ }
1833
+ }
1834
+ if (!anyDistributed) {
1835
+ var children = TreeApi.Logical.getChildNodes(content);
1836
+ for (var j = 0; j < children.length; j++) {
1837
+ distributeNodeInto(children[j], content);
1838
+ }
1839
+ }
1840
+ },
1841
+ _composeTree: function () {
1842
+ this._updateChildNodes(this, this._composeNode(this));
1843
+ var p$ = this.shadyRoot._insertionPoints;
1844
+ for (var i = 0, l = p$.length, p, parent; i < l && (p = p$[i]); i++) {
1845
+ parent = TreeApi.Logical.getParentNode(p);
1846
+ if (!parent._useContent && parent !== this && parent !== this.shadyRoot) {
1847
+ this._updateChildNodes(parent, this._composeNode(parent));
1848
+ }
1849
+ }
1850
+ },
1851
+ _composeNode: function (node) {
1852
+ var children = [];
1853
+ var c$ = TreeApi.Logical.getChildNodes(node.shadyRoot || node);
1854
+ for (var i = 0; i < c$.length; i++) {
1855
+ var child = c$[i];
1856
+ if (isInsertionPoint(child)) {
1857
+ var distributedNodes = child._distributedNodes;
1858
+ for (var j = 0; j < distributedNodes.length; j++) {
1859
+ var distributedNode = distributedNodes[j];
1860
+ if (isFinalDestination(child, distributedNode)) {
1861
+ children.push(distributedNode);
1862
+ }
1863
+ }
1864
+ } else {
1865
+ children.push(child);
1866
+ }
1867
+ }
1868
+ return children;
1869
+ },
1870
+ _updateChildNodes: function (container, children) {
1871
+ var composed = TreeApi.Composed.getChildNodes(container);
1872
+ var splices = Polymer.ArraySplice.calculateSplices(children, composed);
1873
+ for (var i = 0, d = 0, s; i < splices.length && (s = splices[i]); i++) {
1874
+ for (var j = 0, n; j < s.removed.length && (n = s.removed[j]); j++) {
1875
+ if (TreeApi.Composed.getParentNode(n) === container) {
1876
+ TreeApi.Composed.removeChild(container, n);
1877
+ }
1878
+ composed.splice(s.index + d, 1);
1879
+ }
1880
+ d -= s.addedCount;
1881
+ }
1882
+ for (var i = 0, s, next; i < splices.length && (s = splices[i]); i++) {
1883
+ next = composed[s.index];
1884
+ for (j = s.index, n; j < s.index + s.addedCount; j++) {
1885
+ n = children[j];
1886
+ TreeApi.Composed.insertBefore(container, n, next);
1887
+ composed.splice(j, 0, n);
1888
+ }
1889
+ }
1890
+ },
1891
+ _matchesContentSelect: function (node, contentElement) {
1892
+ var select = contentElement.getAttribute('select');
1893
+ if (!select) {
1894
+ return true;
1895
+ }
1896
+ select = select.trim();
1897
+ if (!select) {
1898
+ return true;
1899
+ }
1900
+ if (!(node instanceof Element)) {
1901
+ return false;
1902
+ }
1903
+ var validSelectors = /^(:not\()?[*.#[a-zA-Z_|]/;
1904
+ if (!validSelectors.test(select)) {
1905
+ return false;
1906
+ }
1907
+ return this.elementMatches(select, node);
1908
+ },
1909
+ _elementAdd: function () {
1910
+ },
1911
+ _elementRemove: function () {
1912
+ }
1913
+ });
1914
+ function distributeNodeInto(child, insertionPoint) {
1915
+ insertionPoint._distributedNodes.push(child);
1916
+ var points = child._destinationInsertionPoints;
1917
+ if (!points) {
1918
+ child._destinationInsertionPoints = [insertionPoint];
1919
+ } else {
1920
+ points.push(insertionPoint);
1921
+ }
1922
+ }
1923
+ function clearDistributedDestinationInsertionPoints(content) {
1924
+ var e$ = content._distributedNodes;
1925
+ if (e$) {
1926
+ for (var i = 0; i < e$.length; i++) {
1927
+ var d = e$[i]._destinationInsertionPoints;
1928
+ if (d) {
1929
+ d.splice(d.indexOf(content) + 1, d.length);
1930
+ }
1931
+ }
1932
+ }
1933
+ }
1934
+ function maybeRedistributeParent(content, host) {
1935
+ var parent = TreeApi.Logical.getParentNode(content);
1936
+ if (parent && parent.shadyRoot && DomApi.hasInsertionPoint(parent.shadyRoot) && parent.shadyRoot._distributionClean) {
1937
+ parent.shadyRoot._distributionClean = false;
1938
+ host.shadyRoot._dirtyRoots.push(parent);
1939
+ }
1940
+ }
1941
+ function isFinalDestination(insertionPoint, node) {
1942
+ var points = node._destinationInsertionPoints;
1943
+ return points && points[points.length - 1] === insertionPoint;
1944
+ }
1945
+ function isInsertionPoint(node) {
1946
+ return node.localName == 'content';
1947
+ }
1948
+ function getTopDistributingHost(host) {
1949
+ while (host && hostNeedsRedistribution(host)) {
1950
+ host = host.domHost;
1951
+ }
1952
+ return host;
1953
+ }
1954
+ function hostNeedsRedistribution(host) {
1955
+ var c$ = TreeApi.Logical.getChildNodes(host);
1956
+ for (var i = 0, c; i < c$.length; i++) {
1957
+ c = c$[i];
1958
+ if (c.localName && c.localName === 'content') {
1959
+ return host.domHost;
1960
+ }
1961
+ }
1962
+ }
1963
+ function notifyContentObservers(root) {
1964
+ for (var i = 0, c; i < root._insertionPoints.length; i++) {
1965
+ c = root._insertionPoints[i];
1966
+ if (DomApi.hasApi(c)) {
1967
+ Polymer.dom(c).notifyObserver();
1968
+ }
1969
+ }
1970
+ }
1971
+ function notifyInitialDistribution(host) {
1972
+ if (DomApi.hasApi(host)) {
1973
+ Polymer.dom(host).notifyObserver();
1974
+ }
1975
+ }
1976
+ var needsUpgrade = window.CustomElements && !CustomElements.useNative;
1977
+ function upgradeLogicalChildren(children) {
1978
+ if (needsUpgrade && children) {
1979
+ for (var i = 0; i < children.length; i++) {
1980
+ CustomElements.upgrade(children[i]);
1981
+ }
1982
+ }
1983
+ }
1984
+ }());if (Polymer.Settings.useShadow) {
1985
+ Polymer.Base._addFeature({
1986
+ _poolContent: function () {
1987
+ },
1988
+ _beginDistribute: function () {
1989
+ },
1990
+ distributeContent: function () {
1991
+ },
1992
+ _distributeContent: function () {
1993
+ },
1994
+ _finishDistribute: function () {
1995
+ },
1996
+ _createLocalRoot: function () {
1997
+ this.createShadowRoot();
1998
+ this.shadowRoot.appendChild(this.root);
1999
+ this.root = this.shadowRoot;
2000
+ }
2001
+ });
2002
+ }Polymer.Async = {
2003
+ _currVal: 0,
2004
+ _lastVal: 0,
2005
+ _callbacks: [],
2006
+ _twiddleContent: 0,
2007
+ _twiddle: document.createTextNode(''),
2008
+ run: function (callback, waitTime) {
2009
+ if (waitTime > 0) {
2010
+ return ~setTimeout(callback, waitTime);
2011
+ } else {
2012
+ this._twiddle.textContent = this._twiddleContent++;
2013
+ this._callbacks.push(callback);
2014
+ return this._currVal++;
2015
+ }
2016
+ },
2017
+ cancel: function (handle) {
2018
+ if (handle < 0) {
2019
+ clearTimeout(~handle);
2020
+ } else {
2021
+ var idx = handle - this._lastVal;
2022
+ if (idx >= 0) {
2023
+ if (!this._callbacks[idx]) {
2024
+ throw 'invalid async handle: ' + handle;
2025
+ }
2026
+ this._callbacks[idx] = null;
2027
+ }
2028
+ }
2029
+ },
2030
+ _atEndOfMicrotask: function () {
2031
+ var len = this._callbacks.length;
2032
+ for (var i = 0; i < len; i++) {
2033
+ var cb = this._callbacks[i];
2034
+ if (cb) {
2035
+ try {
2036
+ cb();
2037
+ } catch (e) {
2038
+ i++;
2039
+ this._callbacks.splice(0, i);
2040
+ this._lastVal += i;
2041
+ this._twiddle.textContent = this._twiddleContent++;
2042
+ throw e;
2043
+ }
2044
+ }
2045
+ }
2046
+ this._callbacks.splice(0, len);
2047
+ this._lastVal += len;
2048
+ }
2049
+ };
2050
+ new window.MutationObserver(function () {
2051
+ Polymer.Async._atEndOfMicrotask();
2052
+ }).observe(Polymer.Async._twiddle, { characterData: true });Polymer.Debounce = function () {
2053
+ var Async = Polymer.Async;
2054
+ var Debouncer = function (context) {
2055
+ this.context = context;
2056
+ var self = this;
2057
+ this.boundComplete = function () {
2058
+ self.complete();
2059
+ };
2060
+ };
2061
+ Debouncer.prototype = {
2062
+ go: function (callback, wait) {
2063
+ var h;
2064
+ this.finish = function () {
2065
+ Async.cancel(h);
2066
+ };
2067
+ h = Async.run(this.boundComplete, wait);
2068
+ this.callback = callback;
2069
+ },
2070
+ stop: function () {
2071
+ if (this.finish) {
2072
+ this.finish();
2073
+ this.finish = null;
2074
+ this.callback = null;
2075
+ }
2076
+ },
2077
+ complete: function () {
2078
+ if (this.finish) {
2079
+ var callback = this.callback;
2080
+ this.stop();
2081
+ callback.call(this.context);
2082
+ }
2083
+ }
2084
+ };
2085
+ function debounce(debouncer, callback, wait) {
2086
+ if (debouncer) {
2087
+ debouncer.stop();
2088
+ } else {
2089
+ debouncer = new Debouncer(this);
2090
+ }
2091
+ debouncer.go(callback, wait);
2092
+ return debouncer;
2093
+ }
2094
+ return debounce;
2095
+ }();Polymer.Base._addFeature({
2096
+ _setupDebouncers: function () {
2097
+ this._debouncers = {};
2098
+ },
2099
+ debounce: function (jobName, callback, wait) {
2100
+ return this._debouncers[jobName] = Polymer.Debounce.call(this, this._debouncers[jobName], callback, wait);
2101
+ },
2102
+ isDebouncerActive: function (jobName) {
2103
+ var debouncer = this._debouncers[jobName];
2104
+ return !!(debouncer && debouncer.finish);
2105
+ },
2106
+ flushDebouncer: function (jobName) {
2107
+ var debouncer = this._debouncers[jobName];
2108
+ if (debouncer) {
2109
+ debouncer.complete();
2110
+ }
2111
+ },
2112
+ cancelDebouncer: function (jobName) {
2113
+ var debouncer = this._debouncers[jobName];
2114
+ if (debouncer) {
2115
+ debouncer.stop();
2116
+ }
2117
+ }
2118
+ });Polymer.DomModule = document.createElement('dom-module');
2119
+ Polymer.Base._addFeature({
2120
+ _registerFeatures: function () {
2121
+ this._prepIs();
2122
+ this._prepBehaviors();
2123
+ this._prepConstructor();
2124
+ this._prepTemplate();
2125
+ this._prepShady();
2126
+ this._prepPropertyInfo();
2127
+ },
2128
+ _prepBehavior: function (b) {
2129
+ this._addHostAttributes(b.hostAttributes);
2130
+ },
2131
+ _initFeatures: function () {
2132
+ this._registerHost();
2133
+ if (this._template) {
2134
+ this._poolContent();
2135
+ this._beginHosting();
2136
+ this._stampTemplate();
2137
+ this._endHosting();
2138
+ }
2139
+ this._marshalHostAttributes();
2140
+ this._setupDebouncers();
2141
+ this._marshalBehaviors();
2142
+ this._tryReady();
2143
+ },
2144
+ _marshalBehavior: function (b) {
2145
+ }
2146
+ });</script>
2147
+
2148
+
2149
+
2150
+
2151
+
2152
+