Blame view

bower_components/webcomponentsjs/webcomponents.js 251 KB
73bcce88   luigser   COMPONENTS
1
2
3
4
5
6
7
8
9
  /**
   * @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
   */
c5169e0e   Renato De Donato   a new hope
10
  // @version 0.7.15
eb240478   Luigi Serra   public room cards...
11
12
13
14
  (function() {
    window.WebComponents = window.WebComponents || {
      flags: {}
    };
73bcce88   luigser   COMPONENTS
15
16
    var file = "webcomponents.js";
    var script = document.querySelector('script[src*="' + file + '"]');
eb240478   Luigi Serra   public room cards...
17
    var flags = {};
73bcce88   luigser   COMPONENTS
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
    if (!flags.noOpts) {
      location.search.slice(1).split("&").forEach(function(option) {
        var parts = option.split("=");
        var match;
        if (parts[0] && (match = parts[0].match(/wc-(.+)/))) {
          flags[match[1]] = parts[1] || true;
        }
      });
      if (script) {
        for (var i = 0, a; a = script.attributes[i]; i++) {
          if (a.name !== "src") {
            flags[a.name] = a.value || true;
          }
        }
      }
      if (flags.log && flags.log.split) {
        var parts = flags.log.split(",");
        flags.log = {};
        parts.forEach(function(f) {
          flags.log[f] = true;
        });
      } else {
        flags.log = {};
      }
    }
    flags.shadow = flags.shadow || flags.shadowdom || flags.polyfill;
    if (flags.shadow === "native") {
      flags.shadow = false;
    } else {
      flags.shadow = flags.shadow || !HTMLElement.prototype.createShadowRoot;
    }
    if (flags.register) {
      window.CustomElements = window.CustomElements || {
        flags: {}
      };
      window.CustomElements.flags.register = flags.register;
    }
eb240478   Luigi Serra   public room cards...
55
56
    WebComponents.flags = flags;
  })();
73bcce88   luigser   COMPONENTS
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
  
  if (WebComponents.flags.shadow) {
    if (typeof WeakMap === "undefined") {
      (function() {
        var defineProperty = Object.defineProperty;
        var counter = Date.now() % 1e9;
        var WeakMap = function() {
          this.name = "__st" + (Math.random() * 1e9 >>> 0) + (counter++ + "__");
        };
        WeakMap.prototype = {
          set: function(key, value) {
            var entry = key[this.name];
            if (entry && entry[0] === key) entry[1] = value; else defineProperty(key, this.name, {
              value: [ key, value ],
              writable: true
            });
            return this;
          },
          get: function(key) {
            var entry;
            return (entry = key[this.name]) && entry[0] === key ? entry[1] : undefined;
          },
          "delete": function(key) {
            var entry = key[this.name];
            if (!entry || entry[0] !== key) return false;
            entry[0] = entry[1] = undefined;
            return true;
          },
          has: function(key) {
            var entry = key[this.name];
            if (!entry) return false;
            return entry[0] === key;
          }
        };
        window.WeakMap = WeakMap;
      })();
    }
    window.ShadowDOMPolyfill = {};
    (function(scope) {
      "use strict";
      var constructorTable = new WeakMap();
      var nativePrototypeTable = new WeakMap();
      var wrappers = Object.create(null);
      function detectEval() {
        if (typeof chrome !== "undefined" && chrome.app && chrome.app.runtime) {
          return false;
        }
        if (navigator.getDeviceStorage) {
          return false;
        }
        try {
          var f = new Function("return true;");
          return f();
        } catch (ex) {
          return false;
        }
      }
      var hasEval = detectEval();
      function assert(b) {
        if (!b) throw new Error("Assertion failed");
      }
      var defineProperty = Object.defineProperty;
      var getOwnPropertyNames = Object.getOwnPropertyNames;
      var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
      function mixin(to, from) {
        var names = getOwnPropertyNames(from);
        for (var i = 0; i < names.length; i++) {
          var name = names[i];
          defineProperty(to, name, getOwnPropertyDescriptor(from, name));
        }
        return to;
      }
      function mixinStatics(to, from) {
        var names = getOwnPropertyNames(from);
        for (var i = 0; i < names.length; i++) {
          var name = names[i];
          switch (name) {
           case "arguments":
           case "caller":
           case "length":
           case "name":
           case "prototype":
           case "toString":
            continue;
          }
          defineProperty(to, name, getOwnPropertyDescriptor(from, name));
        }
        return to;
      }
      function oneOf(object, propertyNames) {
        for (var i = 0; i < propertyNames.length; i++) {
          if (propertyNames[i] in object) return propertyNames[i];
        }
      }
      var nonEnumerableDataDescriptor = {
        value: undefined,
        configurable: true,
        enumerable: false,
        writable: true
      };
      function defineNonEnumerableDataProperty(object, name, value) {
        nonEnumerableDataDescriptor.value = value;
        defineProperty(object, name, nonEnumerableDataDescriptor);
      }
      getOwnPropertyNames(window);
      function getWrapperConstructor(node, opt_instance) {
        var nativePrototype = node.__proto__ || Object.getPrototypeOf(node);
        if (isFirefox) {
          try {
            getOwnPropertyNames(nativePrototype);
          } catch (error) {
            nativePrototype = nativePrototype.__proto__;
          }
        }
        var wrapperConstructor = constructorTable.get(nativePrototype);
        if (wrapperConstructor) return wrapperConstructor;
        var parentWrapperConstructor = getWrapperConstructor(nativePrototype);
        var GeneratedWrapper = createWrapperConstructor(parentWrapperConstructor);
        registerInternal(nativePrototype, GeneratedWrapper, opt_instance);
        return GeneratedWrapper;
      }
      function addForwardingProperties(nativePrototype, wrapperPrototype) {
        installProperty(nativePrototype, wrapperPrototype, true);
      }
      function registerInstanceProperties(wrapperPrototype, instanceObject) {
        installProperty(instanceObject, wrapperPrototype, false);
      }
      var isFirefox = /Firefox/.test(navigator.userAgent);
      var dummyDescriptor = {
        get: function() {},
        set: function(v) {},
        configurable: true,
        enumerable: true
      };
      function isEventHandlerName(name) {
        return /^on[a-z]+$/.test(name);
      }
      function isIdentifierName(name) {
        return /^[a-zA-Z_$][a-zA-Z_$0-9]*$/.test(name);
      }
      function getGetter(name) {
        return hasEval && isIdentifierName(name) ? new Function("return this.__impl4cf1e782hg__." + name) : function() {
          return this.__impl4cf1e782hg__[name];
        };
      }
      function getSetter(name) {
        return hasEval && isIdentifierName(name) ? new Function("v", "this.__impl4cf1e782hg__." + name + " = v") : function(v) {
          this.__impl4cf1e782hg__[name] = v;
        };
      }
      function getMethod(name) {
        return hasEval && isIdentifierName(name) ? new Function("return this.__impl4cf1e782hg__." + name + ".apply(this.__impl4cf1e782hg__, arguments)") : function() {
          return this.__impl4cf1e782hg__[name].apply(this.__impl4cf1e782hg__, arguments);
        };
      }
      function getDescriptor(source, name) {
        try {
          return Object.getOwnPropertyDescriptor(source, name);
        } catch (ex) {
          return dummyDescriptor;
        }
      }
      var isBrokenSafari = function() {
        var descr = Object.getOwnPropertyDescriptor(Node.prototype, "nodeType");
        return descr && !descr.get && !descr.set;
      }();
      function installProperty(source, target, allowMethod, opt_blacklist) {
        var names = getOwnPropertyNames(source);
        for (var i = 0; i < names.length; i++) {
          var name = names[i];
          if (name === "polymerBlackList_") continue;
          if (name in target) continue;
          if (source.polymerBlackList_ && source.polymerBlackList_[name]) continue;
          if (isFirefox) {
            source.__lookupGetter__(name);
          }
          var descriptor = getDescriptor(source, name);
          var getter, setter;
          if (typeof descriptor.value === "function") {
            if (allowMethod) {
              target[name] = getMethod(name);
            }
            continue;
          }
          var isEvent = isEventHandlerName(name);
          if (isEvent) getter = scope.getEventHandlerGetter(name); else getter = getGetter(name);
          if (descriptor.writable || descriptor.set || isBrokenSafari) {
            if (isEvent) setter = scope.getEventHandlerSetter(name); else setter = getSetter(name);
          }
          var configurable = isBrokenSafari || descriptor.configurable;
          defineProperty(target, name, {
            get: getter,
            set: setter,
            configurable: configurable,
            enumerable: descriptor.enumerable
          });
        }
      }
      function register(nativeConstructor, wrapperConstructor, opt_instance) {
        if (nativeConstructor == null) {
          return;
        }
        var nativePrototype = nativeConstructor.prototype;
        registerInternal(nativePrototype, wrapperConstructor, opt_instance);
        mixinStatics(wrapperConstructor, nativeConstructor);
      }
      function registerInternal(nativePrototype, wrapperConstructor, opt_instance) {
        var wrapperPrototype = wrapperConstructor.prototype;
        assert(constructorTable.get(nativePrototype) === undefined);
        constructorTable.set(nativePrototype, wrapperConstructor);
        nativePrototypeTable.set(wrapperPrototype, nativePrototype);
        addForwardingProperties(nativePrototype, wrapperPrototype);
        if (opt_instance) registerInstanceProperties(wrapperPrototype, opt_instance);
        defineNonEnumerableDataProperty(wrapperPrototype, "constructor", wrapperConstructor);
        wrapperConstructor.prototype = wrapperPrototype;
      }
      function isWrapperFor(wrapperConstructor, nativeConstructor) {
        return constructorTable.get(nativeConstructor.prototype) === wrapperConstructor;
      }
      function registerObject(object) {
        var nativePrototype = Object.getPrototypeOf(object);
        var superWrapperConstructor = getWrapperConstructor(nativePrototype);
        var GeneratedWrapper = createWrapperConstructor(superWrapperConstructor);
        registerInternal(nativePrototype, GeneratedWrapper, object);
        return GeneratedWrapper;
      }
      function createWrapperConstructor(superWrapperConstructor) {
        function GeneratedWrapper(node) {
          superWrapperConstructor.call(this, node);
        }
        var p = Object.create(superWrapperConstructor.prototype);
        p.constructor = GeneratedWrapper;
        GeneratedWrapper.prototype = p;
        return GeneratedWrapper;
      }
      function isWrapper(object) {
        return object && object.__impl4cf1e782hg__;
      }
      function isNative(object) {
        return !isWrapper(object);
      }
      function wrap(impl) {
        if (impl === null) return null;
        assert(isNative(impl));
        var wrapper = impl.__wrapper8e3dd93a60__;
        if (wrapper != null) {
          return wrapper;
        }
        return impl.__wrapper8e3dd93a60__ = new (getWrapperConstructor(impl, impl))(impl);
      }
      function unwrap(wrapper) {
        if (wrapper === null) return null;
        assert(isWrapper(wrapper));
        return wrapper.__impl4cf1e782hg__;
      }
      function unsafeUnwrap(wrapper) {
        return wrapper.__impl4cf1e782hg__;
      }
      function setWrapper(impl, wrapper) {
        wrapper.__impl4cf1e782hg__ = impl;
        impl.__wrapper8e3dd93a60__ = wrapper;
      }
      function unwrapIfNeeded(object) {
        return object && isWrapper(object) ? unwrap(object) : object;
      }
      function wrapIfNeeded(object) {
        return object && !isWrapper(object) ? wrap(object) : object;
      }
      function rewrap(node, wrapper) {
        if (wrapper === null) return;
        assert(isNative(node));
        assert(wrapper === undefined || isWrapper(wrapper));
        node.__wrapper8e3dd93a60__ = wrapper;
      }
      var getterDescriptor = {
        get: undefined,
        configurable: true,
        enumerable: true
      };
      function defineGetter(constructor, name, getter) {
        getterDescriptor.get = getter;
        defineProperty(constructor.prototype, name, getterDescriptor);
      }
      function defineWrapGetter(constructor, name) {
        defineGetter(constructor, name, function() {
          return wrap(this.__impl4cf1e782hg__[name]);
        });
      }
      function forwardMethodsToWrapper(constructors, names) {
        constructors.forEach(function(constructor) {
          names.forEach(function(name) {
            constructor.prototype[name] = function() {
              var w = wrapIfNeeded(this);
              return w[name].apply(w, arguments);
            };
          });
        });
      }
73bcce88   luigser   COMPONENTS
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
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
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
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
664
665
666
667
668
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
751
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
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
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
907
908
909
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
      scope.assert = assert;
      scope.constructorTable = constructorTable;
      scope.defineGetter = defineGetter;
      scope.defineWrapGetter = defineWrapGetter;
      scope.forwardMethodsToWrapper = forwardMethodsToWrapper;
      scope.isIdentifierName = isIdentifierName;
      scope.isWrapper = isWrapper;
      scope.isWrapperFor = isWrapperFor;
      scope.mixin = mixin;
      scope.nativePrototypeTable = nativePrototypeTable;
      scope.oneOf = oneOf;
      scope.registerObject = registerObject;
      scope.registerWrapper = register;
      scope.rewrap = rewrap;
      scope.setWrapper = setWrapper;
      scope.unsafeUnwrap = unsafeUnwrap;
      scope.unwrap = unwrap;
      scope.unwrapIfNeeded = unwrapIfNeeded;
      scope.wrap = wrap;
      scope.wrapIfNeeded = wrapIfNeeded;
      scope.wrappers = wrappers;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      function newSplice(index, removed, addedCount) {
        return {
          index: index,
          removed: removed,
          addedCount: addedCount
        };
      }
      var EDIT_LEAVE = 0;
      var EDIT_UPDATE = 1;
      var EDIT_ADD = 2;
      var EDIT_DELETE = 3;
      function ArraySplice() {}
      ArraySplice.prototype = {
        calcEditDistances: function(current, currentStart, currentEnd, old, oldStart, oldEnd) {
          var rowCount = oldEnd - oldStart + 1;
          var columnCount = currentEnd - currentStart + 1;
          var distances = new Array(rowCount);
          for (var i = 0; i < rowCount; i++) {
            distances[i] = new Array(columnCount);
            distances[i][0] = i;
          }
          for (var j = 0; j < columnCount; j++) distances[0][j] = j;
          for (var i = 1; i < rowCount; i++) {
            for (var j = 1; j < columnCount; j++) {
              if (this.equals(current[currentStart + j - 1], old[oldStart + i - 1])) distances[i][j] = distances[i - 1][j - 1]; else {
                var north = distances[i - 1][j] + 1;
                var west = distances[i][j - 1] + 1;
                distances[i][j] = north < west ? north : west;
              }
            }
          }
          return distances;
        },
        spliceOperationsFromEditDistances: function(distances) {
          var i = distances.length - 1;
          var j = distances[0].length - 1;
          var current = distances[i][j];
          var edits = [];
          while (i > 0 || j > 0) {
            if (i == 0) {
              edits.push(EDIT_ADD);
              j--;
              continue;
            }
            if (j == 0) {
              edits.push(EDIT_DELETE);
              i--;
              continue;
            }
            var northWest = distances[i - 1][j - 1];
            var west = distances[i - 1][j];
            var north = distances[i][j - 1];
            var min;
            if (west < north) min = west < northWest ? west : northWest; else min = north < northWest ? north : northWest;
            if (min == northWest) {
              if (northWest == current) {
                edits.push(EDIT_LEAVE);
              } else {
                edits.push(EDIT_UPDATE);
                current = northWest;
              }
              i--;
              j--;
            } else if (min == west) {
              edits.push(EDIT_DELETE);
              i--;
              current = west;
            } else {
              edits.push(EDIT_ADD);
              j--;
              current = north;
            }
          }
          edits.reverse();
          return edits;
        },
        calcSplices: function(current, currentStart, currentEnd, old, oldStart, oldEnd) {
          var prefixCount = 0;
          var suffixCount = 0;
          var minLength = Math.min(currentEnd - currentStart, oldEnd - oldStart);
          if (currentStart == 0 && oldStart == 0) prefixCount = this.sharedPrefix(current, old, minLength);
          if (currentEnd == current.length && oldEnd == old.length) suffixCount = this.sharedSuffix(current, old, minLength - prefixCount);
          currentStart += prefixCount;
          oldStart += prefixCount;
          currentEnd -= suffixCount;
          oldEnd -= suffixCount;
          if (currentEnd - currentStart == 0 && oldEnd - oldStart == 0) return [];
          if (currentStart == currentEnd) {
            var splice = newSplice(currentStart, [], 0);
            while (oldStart < oldEnd) splice.removed.push(old[oldStart++]);
            return [ splice ];
          } else if (oldStart == oldEnd) return [ newSplice(currentStart, [], currentEnd - currentStart) ];
          var ops = this.spliceOperationsFromEditDistances(this.calcEditDistances(current, currentStart, currentEnd, old, oldStart, oldEnd));
          var splice = undefined;
          var splices = [];
          var index = currentStart;
          var oldIndex = oldStart;
          for (var i = 0; i < ops.length; i++) {
            switch (ops[i]) {
             case EDIT_LEAVE:
              if (splice) {
                splices.push(splice);
                splice = undefined;
              }
              index++;
              oldIndex++;
              break;
  
             case EDIT_UPDATE:
              if (!splice) splice = newSplice(index, [], 0);
              splice.addedCount++;
              index++;
              splice.removed.push(old[oldIndex]);
              oldIndex++;
              break;
  
             case EDIT_ADD:
              if (!splice) splice = newSplice(index, [], 0);
              splice.addedCount++;
              index++;
              break;
  
             case EDIT_DELETE:
              if (!splice) splice = newSplice(index, [], 0);
              splice.removed.push(old[oldIndex]);
              oldIndex++;
              break;
            }
          }
          if (splice) {
            splices.push(splice);
          }
          return splices;
        },
        sharedPrefix: function(current, old, searchLength) {
          for (var i = 0; i < searchLength; i++) if (!this.equals(current[i], old[i])) return i;
          return searchLength;
        },
        sharedSuffix: function(current, old, searchLength) {
          var index1 = current.length;
          var index2 = old.length;
          var count = 0;
          while (count < searchLength && this.equals(current[--index1], old[--index2])) count++;
          return count;
        },
        calculateSplices: function(current, previous) {
          return this.calcSplices(current, 0, current.length, previous, 0, previous.length);
        },
        equals: function(currentValue, previousValue) {
          return currentValue === previousValue;
        }
      };
      scope.ArraySplice = ArraySplice;
    })(window.ShadowDOMPolyfill);
    (function(context) {
      "use strict";
      var OriginalMutationObserver = window.MutationObserver;
      var callbacks = [];
      var pending = false;
      var timerFunc;
      function handle() {
        pending = false;
        var copies = callbacks.slice(0);
        callbacks = [];
        for (var i = 0; i < copies.length; i++) {
          (0, copies[i])();
        }
      }
      if (OriginalMutationObserver) {
        var counter = 1;
        var observer = new OriginalMutationObserver(handle);
        var textNode = document.createTextNode(counter);
        observer.observe(textNode, {
          characterData: true
        });
        timerFunc = function() {
          counter = (counter + 1) % 2;
          textNode.data = counter;
        };
      } else {
        timerFunc = window.setTimeout;
      }
      function setEndOfMicrotask(func) {
        callbacks.push(func);
        if (pending) return;
        pending = true;
        timerFunc(handle, 0);
      }
      context.setEndOfMicrotask = setEndOfMicrotask;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var setEndOfMicrotask = scope.setEndOfMicrotask;
      var wrapIfNeeded = scope.wrapIfNeeded;
      var wrappers = scope.wrappers;
      var registrationsTable = new WeakMap();
      var globalMutationObservers = [];
      var isScheduled = false;
      function scheduleCallback(observer) {
        if (observer.scheduled_) return;
        observer.scheduled_ = true;
        globalMutationObservers.push(observer);
        if (isScheduled) return;
        setEndOfMicrotask(notifyObservers);
        isScheduled = true;
      }
      function notifyObservers() {
        isScheduled = false;
        while (globalMutationObservers.length) {
          var notifyList = globalMutationObservers;
          globalMutationObservers = [];
          notifyList.sort(function(x, y) {
            return x.uid_ - y.uid_;
          });
          for (var i = 0; i < notifyList.length; i++) {
            var mo = notifyList[i];
            mo.scheduled_ = false;
            var queue = mo.takeRecords();
            removeTransientObserversFor(mo);
            if (queue.length) {
              mo.callback_(queue, mo);
            }
          }
        }
      }
      function MutationRecord(type, target) {
        this.type = type;
        this.target = target;
        this.addedNodes = new wrappers.NodeList();
        this.removedNodes = new wrappers.NodeList();
        this.previousSibling = null;
        this.nextSibling = null;
        this.attributeName = null;
        this.attributeNamespace = null;
        this.oldValue = null;
      }
      function registerTransientObservers(ancestor, node) {
        for (;ancestor; ancestor = ancestor.parentNode) {
          var registrations = registrationsTable.get(ancestor);
          if (!registrations) continue;
          for (var i = 0; i < registrations.length; i++) {
            var registration = registrations[i];
            if (registration.options.subtree) registration.addTransientObserver(node);
          }
        }
      }
      function removeTransientObserversFor(observer) {
        for (var i = 0; i < observer.nodes_.length; i++) {
          var node = observer.nodes_[i];
          var registrations = registrationsTable.get(node);
          if (!registrations) return;
          for (var j = 0; j < registrations.length; j++) {
            var registration = registrations[j];
            if (registration.observer === observer) registration.removeTransientObservers();
          }
        }
      }
      function enqueueMutation(target, type, data) {
        var interestedObservers = Object.create(null);
        var associatedStrings = Object.create(null);
        for (var node = target; node; node = node.parentNode) {
          var registrations = registrationsTable.get(node);
          if (!registrations) continue;
          for (var j = 0; j < registrations.length; j++) {
            var registration = registrations[j];
            var options = registration.options;
            if (node !== target && !options.subtree) continue;
            if (type === "attributes" && !options.attributes) continue;
            if (type === "attributes" && options.attributeFilter && (data.namespace !== null || options.attributeFilter.indexOf(data.name) === -1)) {
              continue;
            }
            if (type === "characterData" && !options.characterData) continue;
            if (type === "childList" && !options.childList) continue;
            var observer = registration.observer;
            interestedObservers[observer.uid_] = observer;
            if (type === "attributes" && options.attributeOldValue || type === "characterData" && options.characterDataOldValue) {
              associatedStrings[observer.uid_] = data.oldValue;
            }
          }
        }
        for (var uid in interestedObservers) {
          var observer = interestedObservers[uid];
          var record = new MutationRecord(type, target);
          if ("name" in data && "namespace" in data) {
            record.attributeName = data.name;
            record.attributeNamespace = data.namespace;
          }
          if (data.addedNodes) record.addedNodes = data.addedNodes;
          if (data.removedNodes) record.removedNodes = data.removedNodes;
          if (data.previousSibling) record.previousSibling = data.previousSibling;
          if (data.nextSibling) record.nextSibling = data.nextSibling;
          if (associatedStrings[uid] !== undefined) record.oldValue = associatedStrings[uid];
          scheduleCallback(observer);
          observer.records_.push(record);
        }
      }
      var slice = Array.prototype.slice;
      function MutationObserverOptions(options) {
        this.childList = !!options.childList;
        this.subtree = !!options.subtree;
        if (!("attributes" in options) && ("attributeOldValue" in options || "attributeFilter" in options)) {
          this.attributes = true;
        } else {
          this.attributes = !!options.attributes;
        }
        if ("characterDataOldValue" in options && !("characterData" in options)) this.characterData = true; else this.characterData = !!options.characterData;
        if (!this.attributes && (options.attributeOldValue || "attributeFilter" in options) || !this.characterData && options.characterDataOldValue) {
          throw new TypeError();
        }
        this.characterData = !!options.characterData;
        this.attributeOldValue = !!options.attributeOldValue;
        this.characterDataOldValue = !!options.characterDataOldValue;
        if ("attributeFilter" in options) {
          if (options.attributeFilter == null || typeof options.attributeFilter !== "object") {
            throw new TypeError();
          }
          this.attributeFilter = slice.call(options.attributeFilter);
        } else {
          this.attributeFilter = null;
        }
      }
      var uidCounter = 0;
      function MutationObserver(callback) {
        this.callback_ = callback;
        this.nodes_ = [];
        this.records_ = [];
        this.uid_ = ++uidCounter;
        this.scheduled_ = false;
      }
      MutationObserver.prototype = {
        constructor: MutationObserver,
        observe: function(target, options) {
          target = wrapIfNeeded(target);
          var newOptions = new MutationObserverOptions(options);
          var registration;
          var registrations = registrationsTable.get(target);
          if (!registrations) registrationsTable.set(target, registrations = []);
          for (var i = 0; i < registrations.length; i++) {
            if (registrations[i].observer === this) {
              registration = registrations[i];
              registration.removeTransientObservers();
              registration.options = newOptions;
            }
          }
          if (!registration) {
            registration = new Registration(this, target, newOptions);
            registrations.push(registration);
            this.nodes_.push(target);
          }
        },
        disconnect: function() {
          this.nodes_.forEach(function(node) {
            var registrations = registrationsTable.get(node);
            for (var i = 0; i < registrations.length; i++) {
              var registration = registrations[i];
              if (registration.observer === this) {
                registrations.splice(i, 1);
                break;
              }
            }
          }, this);
          this.records_ = [];
        },
        takeRecords: function() {
          var copyOfRecords = this.records_;
          this.records_ = [];
          return copyOfRecords;
        }
      };
      function Registration(observer, target, options) {
        this.observer = observer;
        this.target = target;
        this.options = options;
        this.transientObservedNodes = [];
      }
      Registration.prototype = {
        addTransientObserver: function(node) {
          if (node === this.target) return;
          scheduleCallback(this.observer);
          this.transientObservedNodes.push(node);
          var registrations = registrationsTable.get(node);
          if (!registrations) registrationsTable.set(node, registrations = []);
          registrations.push(this);
        },
        removeTransientObservers: function() {
          var transientObservedNodes = this.transientObservedNodes;
          this.transientObservedNodes = [];
          for (var i = 0; i < transientObservedNodes.length; i++) {
            var node = transientObservedNodes[i];
            var registrations = registrationsTable.get(node);
            for (var j = 0; j < registrations.length; j++) {
              if (registrations[j] === this) {
                registrations.splice(j, 1);
                break;
              }
            }
          }
        }
      };
      scope.enqueueMutation = enqueueMutation;
      scope.registerTransientObservers = registerTransientObservers;
      scope.wrappers.MutationObserver = MutationObserver;
      scope.wrappers.MutationRecord = MutationRecord;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      function TreeScope(root, parent) {
        this.root = root;
        this.parent = parent;
      }
      TreeScope.prototype = {
        get renderer() {
          if (this.root instanceof scope.wrappers.ShadowRoot) {
            return scope.getRendererForHost(this.root.host);
          }
          return null;
        },
        contains: function(treeScope) {
          for (;treeScope; treeScope = treeScope.parent) {
            if (treeScope === this) return true;
          }
          return false;
        }
      };
      function setTreeScope(node, treeScope) {
        if (node.treeScope_ !== treeScope) {
          node.treeScope_ = treeScope;
          for (var sr = node.shadowRoot; sr; sr = sr.olderShadowRoot) {
            sr.treeScope_.parent = treeScope;
          }
          for (var child = node.firstChild; child; child = child.nextSibling) {
            setTreeScope(child, treeScope);
          }
        }
      }
      function getTreeScope(node) {
        if (node instanceof scope.wrappers.Window) {
          debugger;
        }
        if (node.treeScope_) return node.treeScope_;
        var parent = node.parentNode;
        var treeScope;
        if (parent) treeScope = getTreeScope(parent); else treeScope = new TreeScope(node, null);
        return node.treeScope_ = treeScope;
      }
      scope.TreeScope = TreeScope;
      scope.getTreeScope = getTreeScope;
      scope.setTreeScope = setTreeScope;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var forwardMethodsToWrapper = scope.forwardMethodsToWrapper;
      var getTreeScope = scope.getTreeScope;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var setWrapper = scope.setWrapper;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var unwrap = scope.unwrap;
      var wrap = scope.wrap;
      var wrappers = scope.wrappers;
      var wrappedFuns = new WeakMap();
      var listenersTable = new WeakMap();
      var handledEventsTable = new WeakMap();
      var currentlyDispatchingEvents = new WeakMap();
      var targetTable = new WeakMap();
      var currentTargetTable = new WeakMap();
      var relatedTargetTable = new WeakMap();
      var eventPhaseTable = new WeakMap();
      var stopPropagationTable = new WeakMap();
      var stopImmediatePropagationTable = new WeakMap();
      var eventHandlersTable = new WeakMap();
      var eventPathTable = new WeakMap();
      function isShadowRoot(node) {
        return node instanceof wrappers.ShadowRoot;
      }
      function rootOfNode(node) {
        return getTreeScope(node).root;
      }
      function getEventPath(node, event) {
        var path = [];
        var current = node;
        path.push(current);
        while (current) {
          var destinationInsertionPoints = getDestinationInsertionPoints(current);
          if (destinationInsertionPoints && destinationInsertionPoints.length > 0) {
            for (var i = 0; i < destinationInsertionPoints.length; i++) {
              var insertionPoint = destinationInsertionPoints[i];
              if (isShadowInsertionPoint(insertionPoint)) {
                var shadowRoot = rootOfNode(insertionPoint);
                var olderShadowRoot = shadowRoot.olderShadowRoot;
                if (olderShadowRoot) path.push(olderShadowRoot);
              }
              path.push(insertionPoint);
            }
            current = destinationInsertionPoints[destinationInsertionPoints.length - 1];
          } else {
            if (isShadowRoot(current)) {
              if (inSameTree(node, current) && eventMustBeStopped(event)) {
                break;
              }
              current = current.host;
              path.push(current);
            } else {
              current = current.parentNode;
              if (current) path.push(current);
            }
          }
        }
        return path;
      }
      function eventMustBeStopped(event) {
        if (!event) return false;
        switch (event.type) {
         case "abort":
         case "error":
         case "select":
         case "change":
         case "load":
         case "reset":
         case "resize":
         case "scroll":
         case "selectstart":
          return true;
        }
        return false;
      }
      function isShadowInsertionPoint(node) {
        return node instanceof HTMLShadowElement;
      }
      function getDestinationInsertionPoints(node) {
        return scope.getDestinationInsertionPoints(node);
      }
      function eventRetargetting(path, currentTarget) {
        if (path.length === 0) return currentTarget;
        if (currentTarget instanceof wrappers.Window) currentTarget = currentTarget.document;
        var currentTargetTree = getTreeScope(currentTarget);
        var originalTarget = path[0];
        var originalTargetTree = getTreeScope(originalTarget);
        var relativeTargetTree = lowestCommonInclusiveAncestor(currentTargetTree, originalTargetTree);
        for (var i = 0; i < path.length; i++) {
          var node = path[i];
          if (getTreeScope(node) === relativeTargetTree) return node;
        }
        return path[path.length - 1];
      }
      function getTreeScopeAncestors(treeScope) {
        var ancestors = [];
        for (;treeScope; treeScope = treeScope.parent) {
          ancestors.push(treeScope);
        }
        return ancestors;
      }
      function lowestCommonInclusiveAncestor(tsA, tsB) {
        var ancestorsA = getTreeScopeAncestors(tsA);
        var ancestorsB = getTreeScopeAncestors(tsB);
        var result = null;
        while (ancestorsA.length > 0 && ancestorsB.length > 0) {
          var a = ancestorsA.pop();
          var b = ancestorsB.pop();
          if (a === b) result = a; else break;
        }
        return result;
      }
      function getTreeScopeRoot(ts) {
        if (!ts.parent) return ts;
        return getTreeScopeRoot(ts.parent);
      }
      function relatedTargetResolution(event, currentTarget, relatedTarget) {
        if (currentTarget instanceof wrappers.Window) currentTarget = currentTarget.document;
        var currentTargetTree = getTreeScope(currentTarget);
        var relatedTargetTree = getTreeScope(relatedTarget);
        var relatedTargetEventPath = getEventPath(relatedTarget, event);
        var lowestCommonAncestorTree;
        var lowestCommonAncestorTree = lowestCommonInclusiveAncestor(currentTargetTree, relatedTargetTree);
        if (!lowestCommonAncestorTree) lowestCommonAncestorTree = relatedTargetTree.root;
        for (var commonAncestorTree = lowestCommonAncestorTree; commonAncestorTree; commonAncestorTree = commonAncestorTree.parent) {
          var adjustedRelatedTarget;
          for (var i = 0; i < relatedTargetEventPath.length; i++) {
            var node = relatedTargetEventPath[i];
            if (getTreeScope(node) === commonAncestorTree) return node;
          }
        }
        return null;
      }
      function inSameTree(a, b) {
        return getTreeScope(a) === getTreeScope(b);
      }
      var NONE = 0;
      var CAPTURING_PHASE = 1;
      var AT_TARGET = 2;
      var BUBBLING_PHASE = 3;
      var pendingError;
      function dispatchOriginalEvent(originalEvent) {
        if (handledEventsTable.get(originalEvent)) return;
        handledEventsTable.set(originalEvent, true);
        dispatchEvent(wrap(originalEvent), wrap(originalEvent.target));
        if (pendingError) {
          var err = pendingError;
          pendingError = null;
          throw err;
        }
      }
      function isLoadLikeEvent(event) {
        switch (event.type) {
         case "load":
         case "beforeunload":
         case "unload":
          return true;
        }
        return false;
      }
      function dispatchEvent(event, originalWrapperTarget) {
        if (currentlyDispatchingEvents.get(event)) throw new Error("InvalidStateError");
        currentlyDispatchingEvents.set(event, true);
        scope.renderAllPending();
        var eventPath;
        var overrideTarget;
        var win;
        if (isLoadLikeEvent(event) && !event.bubbles) {
          var doc = originalWrapperTarget;
          if (doc instanceof wrappers.Document && (win = doc.defaultView)) {
            overrideTarget = doc;
            eventPath = [];
          }
        }
        if (!eventPath) {
          if (originalWrapperTarget instanceof wrappers.Window) {
            win = originalWrapperTarget;
            eventPath = [];
          } else {
            eventPath = getEventPath(originalWrapperTarget, event);
            if (!isLoadLikeEvent(event)) {
              var doc = eventPath[eventPath.length - 1];
              if (doc instanceof wrappers.Document) win = doc.defaultView;
            }
          }
        }
        eventPathTable.set(event, eventPath);
        if (dispatchCapturing(event, eventPath, win, overrideTarget)) {
          if (dispatchAtTarget(event, eventPath, win, overrideTarget)) {
            dispatchBubbling(event, eventPath, win, overrideTarget);
          }
        }
        eventPhaseTable.set(event, NONE);
        currentTargetTable.delete(event, null);
        currentlyDispatchingEvents.delete(event);
        return event.defaultPrevented;
      }
      function dispatchCapturing(event, eventPath, win, overrideTarget) {
        var phase = CAPTURING_PHASE;
        if (win) {
          if (!invoke(win, event, phase, eventPath, overrideTarget)) return false;
        }
        for (var i = eventPath.length - 1; i > 0; i--) {
          if (!invoke(eventPath[i], event, phase, eventPath, overrideTarget)) return false;
        }
        return true;
      }
      function dispatchAtTarget(event, eventPath, win, overrideTarget) {
        var phase = AT_TARGET;
        var currentTarget = eventPath[0] || win;
        return invoke(currentTarget, event, phase, eventPath, overrideTarget);
      }
      function dispatchBubbling(event, eventPath, win, overrideTarget) {
        var phase = BUBBLING_PHASE;
        for (var i = 1; i < eventPath.length; i++) {
          if (!invoke(eventPath[i], event, phase, eventPath, overrideTarget)) return;
        }
        if (win && eventPath.length > 0) {
          invoke(win, event, phase, eventPath, overrideTarget);
        }
      }
      function invoke(currentTarget, event, phase, eventPath, overrideTarget) {
        var listeners = listenersTable.get(currentTarget);
        if (!listeners) return true;
        var target = overrideTarget || eventRetargetting(eventPath, currentTarget);
        if (target === currentTarget) {
          if (phase === CAPTURING_PHASE) return true;
          if (phase === BUBBLING_PHASE) phase = AT_TARGET;
        } else if (phase === BUBBLING_PHASE && !event.bubbles) {
          return true;
        }
        if ("relatedTarget" in event) {
          var originalEvent = unwrap(event);
          var unwrappedRelatedTarget = originalEvent.relatedTarget;
          if (unwrappedRelatedTarget) {
            if (unwrappedRelatedTarget instanceof Object && unwrappedRelatedTarget.addEventListener) {
              var relatedTarget = wrap(unwrappedRelatedTarget);
              var adjusted = relatedTargetResolution(event, currentTarget, relatedTarget);
              if (adjusted === target) return true;
            } else {
              adjusted = null;
            }
            relatedTargetTable.set(event, adjusted);
          }
        }
        eventPhaseTable.set(event, phase);
        var type = event.type;
        var anyRemoved = false;
        targetTable.set(event, target);
        currentTargetTable.set(event, currentTarget);
        listeners.depth++;
        for (var i = 0, len = listeners.length; i < len; i++) {
          var listener = listeners[i];
          if (listener.removed) {
            anyRemoved = true;
            continue;
          }
          if (listener.type !== type || !listener.capture && phase === CAPTURING_PHASE || listener.capture && phase === BUBBLING_PHASE) {
            continue;
          }
          try {
            if (typeof listener.handler === "function") listener.handler.call(currentTarget, event); else listener.handler.handleEvent(event);
            if (stopImmediatePropagationTable.get(event)) return false;
          } catch (ex) {
            if (!pendingError) pendingError = ex;
          }
        }
        listeners.depth--;
        if (anyRemoved && listeners.depth === 0) {
          var copy = listeners.slice();
          listeners.length = 0;
          for (var i = 0; i < copy.length; i++) {
            if (!copy[i].removed) listeners.push(copy[i]);
          }
        }
        return !stopPropagationTable.get(event);
      }
      function Listener(type, handler, capture) {
        this.type = type;
        this.handler = handler;
        this.capture = Boolean(capture);
      }
      Listener.prototype = {
        equals: function(that) {
          return this.handler === that.handler && this.type === that.type && this.capture === that.capture;
        },
        get removed() {
          return this.handler === null;
        },
        remove: function() {
          this.handler = null;
        }
      };
      var OriginalEvent = window.Event;
      OriginalEvent.prototype.polymerBlackList_ = {
        returnValue: true,
        keyLocation: true
      };
      function Event(type, options) {
        if (type instanceof OriginalEvent) {
          var impl = type;
          if (!OriginalBeforeUnloadEvent && impl.type === "beforeunload" && !(this instanceof BeforeUnloadEvent)) {
            return new BeforeUnloadEvent(impl);
          }
          setWrapper(impl, this);
        } else {
          return wrap(constructEvent(OriginalEvent, "Event", type, options));
        }
      }
      Event.prototype = {
        get target() {
          return targetTable.get(this);
        },
        get currentTarget() {
          return currentTargetTable.get(this);
        },
        get eventPhase() {
          return eventPhaseTable.get(this);
        },
        get path() {
          var eventPath = eventPathTable.get(this);
          if (!eventPath) return [];
          return eventPath.slice();
        },
        stopPropagation: function() {
          stopPropagationTable.set(this, true);
        },
        stopImmediatePropagation: function() {
          stopPropagationTable.set(this, true);
          stopImmediatePropagationTable.set(this, true);
        }
      };
73bcce88   luigser   COMPONENTS
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
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
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
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
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
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
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
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
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
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
      registerWrapper(OriginalEvent, Event, document.createEvent("Event"));
      function unwrapOptions(options) {
        if (!options || !options.relatedTarget) return options;
        return Object.create(options, {
          relatedTarget: {
            value: unwrap(options.relatedTarget)
          }
        });
      }
      function registerGenericEvent(name, SuperEvent, prototype) {
        var OriginalEvent = window[name];
        var GenericEvent = function(type, options) {
          if (type instanceof OriginalEvent) setWrapper(type, this); else return wrap(constructEvent(OriginalEvent, name, type, options));
        };
        GenericEvent.prototype = Object.create(SuperEvent.prototype);
        if (prototype) mixin(GenericEvent.prototype, prototype);
        if (OriginalEvent) {
          try {
            registerWrapper(OriginalEvent, GenericEvent, new OriginalEvent("temp"));
          } catch (ex) {
            registerWrapper(OriginalEvent, GenericEvent, document.createEvent(name));
          }
        }
        return GenericEvent;
      }
      var UIEvent = registerGenericEvent("UIEvent", Event);
      var CustomEvent = registerGenericEvent("CustomEvent", Event);
      var relatedTargetProto = {
        get relatedTarget() {
          var relatedTarget = relatedTargetTable.get(this);
          if (relatedTarget !== undefined) return relatedTarget;
          return wrap(unwrap(this).relatedTarget);
        }
      };
      function getInitFunction(name, relatedTargetIndex) {
        return function() {
          arguments[relatedTargetIndex] = unwrap(arguments[relatedTargetIndex]);
          var impl = unwrap(this);
          impl[name].apply(impl, arguments);
        };
      }
      var mouseEventProto = mixin({
        initMouseEvent: getInitFunction("initMouseEvent", 14)
      }, relatedTargetProto);
      var focusEventProto = mixin({
        initFocusEvent: getInitFunction("initFocusEvent", 5)
      }, relatedTargetProto);
      var MouseEvent = registerGenericEvent("MouseEvent", UIEvent, mouseEventProto);
      var FocusEvent = registerGenericEvent("FocusEvent", UIEvent, focusEventProto);
      var defaultInitDicts = Object.create(null);
      var supportsEventConstructors = function() {
        try {
          new window.FocusEvent("focus");
        } catch (ex) {
          return false;
        }
        return true;
      }();
      function constructEvent(OriginalEvent, name, type, options) {
        if (supportsEventConstructors) return new OriginalEvent(type, unwrapOptions(options));
        var event = unwrap(document.createEvent(name));
        var defaultDict = defaultInitDicts[name];
        var args = [ type ];
        Object.keys(defaultDict).forEach(function(key) {
          var v = options != null && key in options ? options[key] : defaultDict[key];
          if (key === "relatedTarget") v = unwrap(v);
          args.push(v);
        });
        event["init" + name].apply(event, args);
        return event;
      }
      if (!supportsEventConstructors) {
        var configureEventConstructor = function(name, initDict, superName) {
          if (superName) {
            var superDict = defaultInitDicts[superName];
            initDict = mixin(mixin({}, superDict), initDict);
          }
          defaultInitDicts[name] = initDict;
        };
        configureEventConstructor("Event", {
          bubbles: false,
          cancelable: false
        });
        configureEventConstructor("CustomEvent", {
          detail: null
        }, "Event");
        configureEventConstructor("UIEvent", {
          view: null,
          detail: 0
        }, "Event");
        configureEventConstructor("MouseEvent", {
          screenX: 0,
          screenY: 0,
          clientX: 0,
          clientY: 0,
          ctrlKey: false,
          altKey: false,
          shiftKey: false,
          metaKey: false,
          button: 0,
          relatedTarget: null
        }, "UIEvent");
        configureEventConstructor("FocusEvent", {
          relatedTarget: null
        }, "UIEvent");
      }
      var OriginalBeforeUnloadEvent = window.BeforeUnloadEvent;
      function BeforeUnloadEvent(impl) {
        Event.call(this, impl);
      }
      BeforeUnloadEvent.prototype = Object.create(Event.prototype);
      mixin(BeforeUnloadEvent.prototype, {
        get returnValue() {
          return unsafeUnwrap(this).returnValue;
        },
        set returnValue(v) {
          unsafeUnwrap(this).returnValue = v;
        }
      });
      if (OriginalBeforeUnloadEvent) registerWrapper(OriginalBeforeUnloadEvent, BeforeUnloadEvent);
      function isValidListener(fun) {
        if (typeof fun === "function") return true;
        return fun && fun.handleEvent;
      }
      function isMutationEvent(type) {
        switch (type) {
         case "DOMAttrModified":
         case "DOMAttributeNameChanged":
         case "DOMCharacterDataModified":
         case "DOMElementNameChanged":
         case "DOMNodeInserted":
         case "DOMNodeInsertedIntoDocument":
         case "DOMNodeRemoved":
         case "DOMNodeRemovedFromDocument":
         case "DOMSubtreeModified":
          return true;
        }
        return false;
      }
      var OriginalEventTarget = window.EventTarget;
      function EventTarget(impl) {
        setWrapper(impl, this);
      }
      var methodNames = [ "addEventListener", "removeEventListener", "dispatchEvent" ];
      [ Node, Window ].forEach(function(constructor) {
        var p = constructor.prototype;
        methodNames.forEach(function(name) {
          Object.defineProperty(p, name + "_", {
            value: p[name]
          });
        });
      });
      function getTargetToListenAt(wrapper) {
        if (wrapper instanceof wrappers.ShadowRoot) wrapper = wrapper.host;
        return unwrap(wrapper);
      }
      EventTarget.prototype = {
        addEventListener: function(type, fun, capture) {
          if (!isValidListener(fun) || isMutationEvent(type)) return;
          var listener = new Listener(type, fun, capture);
          var listeners = listenersTable.get(this);
          if (!listeners) {
            listeners = [];
            listeners.depth = 0;
            listenersTable.set(this, listeners);
          } else {
            for (var i = 0; i < listeners.length; i++) {
              if (listener.equals(listeners[i])) return;
            }
          }
          listeners.push(listener);
          var target = getTargetToListenAt(this);
          target.addEventListener_(type, dispatchOriginalEvent, true);
        },
        removeEventListener: function(type, fun, capture) {
          capture = Boolean(capture);
          var listeners = listenersTable.get(this);
          if (!listeners) return;
          var count = 0, found = false;
          for (var i = 0; i < listeners.length; i++) {
            if (listeners[i].type === type && listeners[i].capture === capture) {
              count++;
              if (listeners[i].handler === fun) {
                found = true;
                listeners[i].remove();
              }
            }
          }
          if (found && count === 1) {
            var target = getTargetToListenAt(this);
            target.removeEventListener_(type, dispatchOriginalEvent, true);
          }
        },
        dispatchEvent: function(event) {
          var nativeEvent = unwrap(event);
          var eventType = nativeEvent.type;
          handledEventsTable.set(nativeEvent, false);
          scope.renderAllPending();
          var tempListener;
          if (!hasListenerInAncestors(this, eventType)) {
            tempListener = function() {};
            this.addEventListener(eventType, tempListener, true);
          }
          try {
            return unwrap(this).dispatchEvent_(nativeEvent);
          } finally {
            if (tempListener) this.removeEventListener(eventType, tempListener, true);
          }
        }
      };
      function hasListener(node, type) {
        var listeners = listenersTable.get(node);
        if (listeners) {
          for (var i = 0; i < listeners.length; i++) {
            if (!listeners[i].removed && listeners[i].type === type) return true;
          }
        }
        return false;
      }
      function hasListenerInAncestors(target, type) {
        for (var node = unwrap(target); node; node = node.parentNode) {
          if (hasListener(wrap(node), type)) return true;
        }
        return false;
      }
      if (OriginalEventTarget) registerWrapper(OriginalEventTarget, EventTarget);
      function wrapEventTargetMethods(constructors) {
        forwardMethodsToWrapper(constructors, methodNames);
      }
      var originalElementFromPoint = document.elementFromPoint;
      function elementFromPoint(self, document, x, y) {
        scope.renderAllPending();
        var element = wrap(originalElementFromPoint.call(unsafeUnwrap(document), x, y));
        if (!element) return null;
        var path = getEventPath(element, null);
        var idx = path.lastIndexOf(self);
        if (idx == -1) return null; else path = path.slice(0, idx);
        return eventRetargetting(path, self);
      }
      function getEventHandlerGetter(name) {
        return function() {
          var inlineEventHandlers = eventHandlersTable.get(this);
          return inlineEventHandlers && inlineEventHandlers[name] && inlineEventHandlers[name].value || null;
        };
      }
      function getEventHandlerSetter(name) {
        var eventType = name.slice(2);
        return function(value) {
          var inlineEventHandlers = eventHandlersTable.get(this);
          if (!inlineEventHandlers) {
            inlineEventHandlers = Object.create(null);
            eventHandlersTable.set(this, inlineEventHandlers);
          }
          var old = inlineEventHandlers[name];
          if (old) this.removeEventListener(eventType, old.wrapped, false);
          if (typeof value === "function") {
            var wrapped = function(e) {
              var rv = value.call(this, e);
              if (rv === false) e.preventDefault(); else if (name === "onbeforeunload" && typeof rv === "string") e.returnValue = rv;
            };
            this.addEventListener(eventType, wrapped, false);
            inlineEventHandlers[name] = {
              value: value,
              wrapped: wrapped
            };
          }
        };
      }
      scope.elementFromPoint = elementFromPoint;
      scope.getEventHandlerGetter = getEventHandlerGetter;
      scope.getEventHandlerSetter = getEventHandlerSetter;
      scope.wrapEventTargetMethods = wrapEventTargetMethods;
      scope.wrappers.BeforeUnloadEvent = BeforeUnloadEvent;
      scope.wrappers.CustomEvent = CustomEvent;
      scope.wrappers.Event = Event;
      scope.wrappers.EventTarget = EventTarget;
      scope.wrappers.FocusEvent = FocusEvent;
      scope.wrappers.MouseEvent = MouseEvent;
      scope.wrappers.UIEvent = UIEvent;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var UIEvent = scope.wrappers.UIEvent;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var setWrapper = scope.setWrapper;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var wrap = scope.wrap;
      var OriginalTouchEvent = window.TouchEvent;
      if (!OriginalTouchEvent) return;
      var nativeEvent;
      try {
        nativeEvent = document.createEvent("TouchEvent");
      } catch (ex) {
        return;
      }
      var nonEnumDescriptor = {
        enumerable: false
      };
      function nonEnum(obj, prop) {
        Object.defineProperty(obj, prop, nonEnumDescriptor);
      }
      function Touch(impl) {
        setWrapper(impl, this);
      }
      Touch.prototype = {
        get target() {
          return wrap(unsafeUnwrap(this).target);
        }
      };
      var descr = {
        configurable: true,
        enumerable: true,
        get: null
      };
      [ "clientX", "clientY", "screenX", "screenY", "pageX", "pageY", "identifier", "webkitRadiusX", "webkitRadiusY", "webkitRotationAngle", "webkitForce" ].forEach(function(name) {
        descr.get = function() {
          return unsafeUnwrap(this)[name];
        };
        Object.defineProperty(Touch.prototype, name, descr);
      });
      function TouchList() {
        this.length = 0;
        nonEnum(this, "length");
      }
      TouchList.prototype = {
        item: function(index) {
          return this[index];
        }
      };
      function wrapTouchList(nativeTouchList) {
        var list = new TouchList();
        for (var i = 0; i < nativeTouchList.length; i++) {
          list[i] = new Touch(nativeTouchList[i]);
        }
        list.length = i;
        return list;
      }
      function TouchEvent(impl) {
        UIEvent.call(this, impl);
      }
      TouchEvent.prototype = Object.create(UIEvent.prototype);
      mixin(TouchEvent.prototype, {
        get touches() {
          return wrapTouchList(unsafeUnwrap(this).touches);
        },
        get targetTouches() {
          return wrapTouchList(unsafeUnwrap(this).targetTouches);
        },
        get changedTouches() {
          return wrapTouchList(unsafeUnwrap(this).changedTouches);
        },
        initTouchEvent: function() {
          throw new Error("Not implemented");
        }
      });
      registerWrapper(OriginalTouchEvent, TouchEvent, nativeEvent);
      scope.wrappers.Touch = Touch;
      scope.wrappers.TouchEvent = TouchEvent;
      scope.wrappers.TouchList = TouchList;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var unsafeUnwrap = scope.unsafeUnwrap;
      var wrap = scope.wrap;
      var nonEnumDescriptor = {
        enumerable: false
      };
      function nonEnum(obj, prop) {
        Object.defineProperty(obj, prop, nonEnumDescriptor);
      }
      function NodeList() {
        this.length = 0;
        nonEnum(this, "length");
      }
      NodeList.prototype = {
        item: function(index) {
          return this[index];
        }
      };
      nonEnum(NodeList.prototype, "item");
      function wrapNodeList(list) {
        if (list == null) return list;
        var wrapperList = new NodeList();
        for (var i = 0, length = list.length; i < length; i++) {
          wrapperList[i] = wrap(list[i]);
        }
        wrapperList.length = length;
        return wrapperList;
      }
      function addWrapNodeListMethod(wrapperConstructor, name) {
        wrapperConstructor.prototype[name] = function() {
          return wrapNodeList(unsafeUnwrap(this)[name].apply(unsafeUnwrap(this), arguments));
        };
      }
      scope.wrappers.NodeList = NodeList;
      scope.addWrapNodeListMethod = addWrapNodeListMethod;
      scope.wrapNodeList = wrapNodeList;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      scope.wrapHTMLCollection = scope.wrapNodeList;
      scope.wrappers.HTMLCollection = scope.wrappers.NodeList;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var EventTarget = scope.wrappers.EventTarget;
      var NodeList = scope.wrappers.NodeList;
      var TreeScope = scope.TreeScope;
      var assert = scope.assert;
      var defineWrapGetter = scope.defineWrapGetter;
      var enqueueMutation = scope.enqueueMutation;
      var getTreeScope = scope.getTreeScope;
      var isWrapper = scope.isWrapper;
      var mixin = scope.mixin;
      var registerTransientObservers = scope.registerTransientObservers;
      var registerWrapper = scope.registerWrapper;
      var setTreeScope = scope.setTreeScope;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var unwrap = scope.unwrap;
      var unwrapIfNeeded = scope.unwrapIfNeeded;
      var wrap = scope.wrap;
      var wrapIfNeeded = scope.wrapIfNeeded;
      var wrappers = scope.wrappers;
      function assertIsNodeWrapper(node) {
        assert(node instanceof Node);
      }
      function createOneElementNodeList(node) {
        var nodes = new NodeList();
        nodes[0] = node;
        nodes.length = 1;
        return nodes;
      }
      var surpressMutations = false;
      function enqueueRemovalForInsertedNodes(node, parent, nodes) {
        enqueueMutation(parent, "childList", {
          removedNodes: nodes,
          previousSibling: node.previousSibling,
          nextSibling: node.nextSibling
        });
      }
      function enqueueRemovalForInsertedDocumentFragment(df, nodes) {
        enqueueMutation(df, "childList", {
          removedNodes: nodes
        });
      }
      function collectNodes(node, parentNode, previousNode, nextNode) {
        if (node instanceof DocumentFragment) {
          var nodes = collectNodesForDocumentFragment(node);
          surpressMutations = true;
          for (var i = nodes.length - 1; i >= 0; i--) {
            node.removeChild(nodes[i]);
            nodes[i].parentNode_ = parentNode;
          }
          surpressMutations = false;
          for (var i = 0; i < nodes.length; i++) {
            nodes[i].previousSibling_ = nodes[i - 1] || previousNode;
            nodes[i].nextSibling_ = nodes[i + 1] || nextNode;
          }
          if (previousNode) previousNode.nextSibling_ = nodes[0];
          if (nextNode) nextNode.previousSibling_ = nodes[nodes.length - 1];
          return nodes;
        }
        var nodes = createOneElementNodeList(node);
        var oldParent = node.parentNode;
        if (oldParent) {
          oldParent.removeChild(node);
        }
        node.parentNode_ = parentNode;
        node.previousSibling_ = previousNode;
        node.nextSibling_ = nextNode;
        if (previousNode) previousNode.nextSibling_ = node;
        if (nextNode) nextNode.previousSibling_ = node;
        return nodes;
      }
      function collectNodesNative(node) {
        if (node instanceof DocumentFragment) return collectNodesForDocumentFragment(node);
        var nodes = createOneElementNodeList(node);
        var oldParent = node.parentNode;
        if (oldParent) enqueueRemovalForInsertedNodes(node, oldParent, nodes);
        return nodes;
      }
      function collectNodesForDocumentFragment(node) {
        var nodes = new NodeList();
        var i = 0;
        for (var child = node.firstChild; child; child = child.nextSibling) {
          nodes[i++] = child;
        }
        nodes.length = i;
        enqueueRemovalForInsertedDocumentFragment(node, nodes);
        return nodes;
      }
      function snapshotNodeList(nodeList) {
        return nodeList;
      }
      function nodeWasAdded(node, treeScope) {
        setTreeScope(node, treeScope);
        node.nodeIsInserted_();
      }
      function nodesWereAdded(nodes, parent) {
        var treeScope = getTreeScope(parent);
        for (var i = 0; i < nodes.length; i++) {
          nodeWasAdded(nodes[i], treeScope);
        }
      }
      function nodeWasRemoved(node) {
        setTreeScope(node, new TreeScope(node, null));
      }
      function nodesWereRemoved(nodes) {
        for (var i = 0; i < nodes.length; i++) {
          nodeWasRemoved(nodes[i]);
        }
      }
      function ensureSameOwnerDocument(parent, child) {
        var ownerDoc = parent.nodeType === Node.DOCUMENT_NODE ? parent : parent.ownerDocument;
        if (ownerDoc !== child.ownerDocument) ownerDoc.adoptNode(child);
      }
      function adoptNodesIfNeeded(owner, nodes) {
        if (!nodes.length) return;
        var ownerDoc = owner.ownerDocument;
        if (ownerDoc === nodes[0].ownerDocument) return;
        for (var i = 0; i < nodes.length; i++) {
          scope.adoptNodeNoRemove(nodes[i], ownerDoc);
        }
      }
      function unwrapNodesForInsertion(owner, nodes) {
        adoptNodesIfNeeded(owner, nodes);
        var length = nodes.length;
        if (length === 1) return unwrap(nodes[0]);
        var df = unwrap(owner.ownerDocument.createDocumentFragment());
        for (var i = 0; i < length; i++) {
          df.appendChild(unwrap(nodes[i]));
        }
        return df;
      }
      function clearChildNodes(wrapper) {
        if (wrapper.firstChild_ !== undefined) {
          var child = wrapper.firstChild_;
          while (child) {
            var tmp = child;
            child = child.nextSibling_;
            tmp.parentNode_ = tmp.previousSibling_ = tmp.nextSibling_ = undefined;
          }
        }
        wrapper.firstChild_ = wrapper.lastChild_ = undefined;
      }
      function removeAllChildNodes(wrapper) {
        if (wrapper.invalidateShadowRenderer()) {
          var childWrapper = wrapper.firstChild;
          while (childWrapper) {
            assert(childWrapper.parentNode === wrapper);
            var nextSibling = childWrapper.nextSibling;
            var childNode = unwrap(childWrapper);
            var parentNode = childNode.parentNode;
            if (parentNode) originalRemoveChild.call(parentNode, childNode);
            childWrapper.previousSibling_ = childWrapper.nextSibling_ = childWrapper.parentNode_ = null;
            childWrapper = nextSibling;
          }
          wrapper.firstChild_ = wrapper.lastChild_ = null;
        } else {
          var node = unwrap(wrapper);
          var child = node.firstChild;
          var nextSibling;
          while (child) {
            nextSibling = child.nextSibling;
            originalRemoveChild.call(node, child);
            child = nextSibling;
          }
        }
      }
      function invalidateParent(node) {
        var p = node.parentNode;
        return p && p.invalidateShadowRenderer();
      }
      function cleanupNodes(nodes) {
        for (var i = 0, n; i < nodes.length; i++) {
          n = nodes[i];
          n.parentNode.removeChild(n);
        }
      }
      var originalImportNode = document.importNode;
      var originalCloneNode = window.Node.prototype.cloneNode;
      function cloneNode(node, deep, opt_doc) {
        var clone;
        if (opt_doc) clone = wrap(originalImportNode.call(opt_doc, unsafeUnwrap(node), false)); else clone = wrap(originalCloneNode.call(unsafeUnwrap(node), false));
        if (deep) {
          for (var child = node.firstChild; child; child = child.nextSibling) {
            clone.appendChild(cloneNode(child, true, opt_doc));
          }
          if (node instanceof wrappers.HTMLTemplateElement) {
            var cloneContent = clone.content;
            for (var child = node.content.firstChild; child; child = child.nextSibling) {
              cloneContent.appendChild(cloneNode(child, true, opt_doc));
            }
          }
        }
        return clone;
      }
      function contains(self, child) {
        if (!child || getTreeScope(self) !== getTreeScope(child)) return false;
        for (var node = child; node; node = node.parentNode) {
          if (node === self) return true;
        }
        return false;
      }
      var OriginalNode = window.Node;
      function Node(original) {
        assert(original instanceof OriginalNode);
        EventTarget.call(this, original);
        this.parentNode_ = undefined;
        this.firstChild_ = undefined;
        this.lastChild_ = undefined;
        this.nextSibling_ = undefined;
        this.previousSibling_ = undefined;
        this.treeScope_ = undefined;
      }
      var OriginalDocumentFragment = window.DocumentFragment;
      var originalAppendChild = OriginalNode.prototype.appendChild;
      var originalCompareDocumentPosition = OriginalNode.prototype.compareDocumentPosition;
      var originalIsEqualNode = OriginalNode.prototype.isEqualNode;
      var originalInsertBefore = OriginalNode.prototype.insertBefore;
      var originalRemoveChild = OriginalNode.prototype.removeChild;
      var originalReplaceChild = OriginalNode.prototype.replaceChild;
e619a3b0   Luigi Serra   Controllet cross ...
1785
1786
      var isIEOrEdge = /Trident|Edge/.test(navigator.userAgent);
      var removeChildOriginalHelper = isIEOrEdge ? function(parent, child) {
73bcce88   luigser   COMPONENTS
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
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
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
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
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
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
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
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
2392
2393
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
2419
2420
2421
2422
2423
2424
2425
2426
2427
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
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
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
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
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
        try {
          originalRemoveChild.call(parent, child);
        } catch (ex) {
          if (!(parent instanceof OriginalDocumentFragment)) throw ex;
        }
      } : function(parent, child) {
        originalRemoveChild.call(parent, child);
      };
      Node.prototype = Object.create(EventTarget.prototype);
      mixin(Node.prototype, {
        appendChild: function(childWrapper) {
          return this.insertBefore(childWrapper, null);
        },
        insertBefore: function(childWrapper, refWrapper) {
          assertIsNodeWrapper(childWrapper);
          var refNode;
          if (refWrapper) {
            if (isWrapper(refWrapper)) {
              refNode = unwrap(refWrapper);
            } else {
              refNode = refWrapper;
              refWrapper = wrap(refNode);
            }
          } else {
            refWrapper = null;
            refNode = null;
          }
          refWrapper && assert(refWrapper.parentNode === this);
          var nodes;
          var previousNode = refWrapper ? refWrapper.previousSibling : this.lastChild;
          var useNative = !this.invalidateShadowRenderer() && !invalidateParent(childWrapper);
          if (useNative) nodes = collectNodesNative(childWrapper); else nodes = collectNodes(childWrapper, this, previousNode, refWrapper);
          if (useNative) {
            ensureSameOwnerDocument(this, childWrapper);
            clearChildNodes(this);
            originalInsertBefore.call(unsafeUnwrap(this), unwrap(childWrapper), refNode);
          } else {
            if (!previousNode) this.firstChild_ = nodes[0];
            if (!refWrapper) {
              this.lastChild_ = nodes[nodes.length - 1];
              if (this.firstChild_ === undefined) this.firstChild_ = this.firstChild;
            }
            var parentNode = refNode ? refNode.parentNode : unsafeUnwrap(this);
            if (parentNode) {
              originalInsertBefore.call(parentNode, unwrapNodesForInsertion(this, nodes), refNode);
            } else {
              adoptNodesIfNeeded(this, nodes);
            }
          }
          enqueueMutation(this, "childList", {
            addedNodes: nodes,
            nextSibling: refWrapper,
            previousSibling: previousNode
          });
          nodesWereAdded(nodes, this);
          return childWrapper;
        },
        removeChild: function(childWrapper) {
          assertIsNodeWrapper(childWrapper);
          if (childWrapper.parentNode !== this) {
            var found = false;
            var childNodes = this.childNodes;
            for (var ieChild = this.firstChild; ieChild; ieChild = ieChild.nextSibling) {
              if (ieChild === childWrapper) {
                found = true;
                break;
              }
            }
            if (!found) {
              throw new Error("NotFoundError");
            }
          }
          var childNode = unwrap(childWrapper);
          var childWrapperNextSibling = childWrapper.nextSibling;
          var childWrapperPreviousSibling = childWrapper.previousSibling;
          if (this.invalidateShadowRenderer()) {
            var thisFirstChild = this.firstChild;
            var thisLastChild = this.lastChild;
            var parentNode = childNode.parentNode;
            if (parentNode) removeChildOriginalHelper(parentNode, childNode);
            if (thisFirstChild === childWrapper) this.firstChild_ = childWrapperNextSibling;
            if (thisLastChild === childWrapper) this.lastChild_ = childWrapperPreviousSibling;
            if (childWrapperPreviousSibling) childWrapperPreviousSibling.nextSibling_ = childWrapperNextSibling;
            if (childWrapperNextSibling) {
              childWrapperNextSibling.previousSibling_ = childWrapperPreviousSibling;
            }
            childWrapper.previousSibling_ = childWrapper.nextSibling_ = childWrapper.parentNode_ = undefined;
          } else {
            clearChildNodes(this);
            removeChildOriginalHelper(unsafeUnwrap(this), childNode);
          }
          if (!surpressMutations) {
            enqueueMutation(this, "childList", {
              removedNodes: createOneElementNodeList(childWrapper),
              nextSibling: childWrapperNextSibling,
              previousSibling: childWrapperPreviousSibling
            });
          }
          registerTransientObservers(this, childWrapper);
          return childWrapper;
        },
        replaceChild: function(newChildWrapper, oldChildWrapper) {
          assertIsNodeWrapper(newChildWrapper);
          var oldChildNode;
          if (isWrapper(oldChildWrapper)) {
            oldChildNode = unwrap(oldChildWrapper);
          } else {
            oldChildNode = oldChildWrapper;
            oldChildWrapper = wrap(oldChildNode);
          }
          if (oldChildWrapper.parentNode !== this) {
            throw new Error("NotFoundError");
          }
          var nextNode = oldChildWrapper.nextSibling;
          var previousNode = oldChildWrapper.previousSibling;
          var nodes;
          var useNative = !this.invalidateShadowRenderer() && !invalidateParent(newChildWrapper);
          if (useNative) {
            nodes = collectNodesNative(newChildWrapper);
          } else {
            if (nextNode === newChildWrapper) nextNode = newChildWrapper.nextSibling;
            nodes = collectNodes(newChildWrapper, this, previousNode, nextNode);
          }
          if (!useNative) {
            if (this.firstChild === oldChildWrapper) this.firstChild_ = nodes[0];
            if (this.lastChild === oldChildWrapper) this.lastChild_ = nodes[nodes.length - 1];
            oldChildWrapper.previousSibling_ = oldChildWrapper.nextSibling_ = oldChildWrapper.parentNode_ = undefined;
            if (oldChildNode.parentNode) {
              originalReplaceChild.call(oldChildNode.parentNode, unwrapNodesForInsertion(this, nodes), oldChildNode);
            }
          } else {
            ensureSameOwnerDocument(this, newChildWrapper);
            clearChildNodes(this);
            originalReplaceChild.call(unsafeUnwrap(this), unwrap(newChildWrapper), oldChildNode);
          }
          enqueueMutation(this, "childList", {
            addedNodes: nodes,
            removedNodes: createOneElementNodeList(oldChildWrapper),
            nextSibling: nextNode,
            previousSibling: previousNode
          });
          nodeWasRemoved(oldChildWrapper);
          nodesWereAdded(nodes, this);
          return oldChildWrapper;
        },
        nodeIsInserted_: function() {
          for (var child = this.firstChild; child; child = child.nextSibling) {
            child.nodeIsInserted_();
          }
        },
        hasChildNodes: function() {
          return this.firstChild !== null;
        },
        get parentNode() {
          return this.parentNode_ !== undefined ? this.parentNode_ : wrap(unsafeUnwrap(this).parentNode);
        },
        get firstChild() {
          return this.firstChild_ !== undefined ? this.firstChild_ : wrap(unsafeUnwrap(this).firstChild);
        },
        get lastChild() {
          return this.lastChild_ !== undefined ? this.lastChild_ : wrap(unsafeUnwrap(this).lastChild);
        },
        get nextSibling() {
          return this.nextSibling_ !== undefined ? this.nextSibling_ : wrap(unsafeUnwrap(this).nextSibling);
        },
        get previousSibling() {
          return this.previousSibling_ !== undefined ? this.previousSibling_ : wrap(unsafeUnwrap(this).previousSibling);
        },
        get parentElement() {
          var p = this.parentNode;
          while (p && p.nodeType !== Node.ELEMENT_NODE) {
            p = p.parentNode;
          }
          return p;
        },
        get textContent() {
          var s = "";
          for (var child = this.firstChild; child; child = child.nextSibling) {
            if (child.nodeType != Node.COMMENT_NODE) {
              s += child.textContent;
            }
          }
          return s;
        },
        set textContent(textContent) {
          if (textContent == null) textContent = "";
          var removedNodes = snapshotNodeList(this.childNodes);
          if (this.invalidateShadowRenderer()) {
            removeAllChildNodes(this);
            if (textContent !== "") {
              var textNode = unsafeUnwrap(this).ownerDocument.createTextNode(textContent);
              this.appendChild(textNode);
            }
          } else {
            clearChildNodes(this);
            unsafeUnwrap(this).textContent = textContent;
          }
          var addedNodes = snapshotNodeList(this.childNodes);
          enqueueMutation(this, "childList", {
            addedNodes: addedNodes,
            removedNodes: removedNodes
          });
          nodesWereRemoved(removedNodes);
          nodesWereAdded(addedNodes, this);
        },
        get childNodes() {
          var wrapperList = new NodeList();
          var i = 0;
          for (var child = this.firstChild; child; child = child.nextSibling) {
            wrapperList[i++] = child;
          }
          wrapperList.length = i;
          return wrapperList;
        },
        cloneNode: function(deep) {
          return cloneNode(this, deep);
        },
        contains: function(child) {
          return contains(this, wrapIfNeeded(child));
        },
        compareDocumentPosition: function(otherNode) {
          return originalCompareDocumentPosition.call(unsafeUnwrap(this), unwrapIfNeeded(otherNode));
        },
        isEqualNode: function(otherNode) {
          return originalIsEqualNode.call(unsafeUnwrap(this), unwrapIfNeeded(otherNode));
        },
        normalize: function() {
          var nodes = snapshotNodeList(this.childNodes);
          var remNodes = [];
          var s = "";
          var modNode;
          for (var i = 0, n; i < nodes.length; i++) {
            n = nodes[i];
            if (n.nodeType === Node.TEXT_NODE) {
              if (!modNode && !n.data.length) this.removeChild(n); else if (!modNode) modNode = n; else {
                s += n.data;
                remNodes.push(n);
              }
            } else {
              if (modNode && remNodes.length) {
                modNode.data += s;
                cleanupNodes(remNodes);
              }
              remNodes = [];
              s = "";
              modNode = null;
              if (n.childNodes.length) n.normalize();
            }
          }
          if (modNode && remNodes.length) {
            modNode.data += s;
            cleanupNodes(remNodes);
          }
        }
      });
      defineWrapGetter(Node, "ownerDocument");
      registerWrapper(OriginalNode, Node, document.createDocumentFragment());
      delete Node.prototype.querySelector;
      delete Node.prototype.querySelectorAll;
      Node.prototype = mixin(Object.create(EventTarget.prototype), Node.prototype);
      scope.cloneNode = cloneNode;
      scope.nodeWasAdded = nodeWasAdded;
      scope.nodeWasRemoved = nodeWasRemoved;
      scope.nodesWereAdded = nodesWereAdded;
      scope.nodesWereRemoved = nodesWereRemoved;
      scope.originalInsertBefore = originalInsertBefore;
      scope.originalRemoveChild = originalRemoveChild;
      scope.snapshotNodeList = snapshotNodeList;
      scope.wrappers.Node = Node;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var HTMLCollection = scope.wrappers.HTMLCollection;
      var NodeList = scope.wrappers.NodeList;
      var getTreeScope = scope.getTreeScope;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var wrap = scope.wrap;
      var originalDocumentQuerySelector = document.querySelector;
      var originalElementQuerySelector = document.documentElement.querySelector;
      var originalDocumentQuerySelectorAll = document.querySelectorAll;
      var originalElementQuerySelectorAll = document.documentElement.querySelectorAll;
      var originalDocumentGetElementsByTagName = document.getElementsByTagName;
      var originalElementGetElementsByTagName = document.documentElement.getElementsByTagName;
      var originalDocumentGetElementsByTagNameNS = document.getElementsByTagNameNS;
      var originalElementGetElementsByTagNameNS = document.documentElement.getElementsByTagNameNS;
      var OriginalElement = window.Element;
      var OriginalDocument = window.HTMLDocument || window.Document;
      function filterNodeList(list, index, result, deep) {
        var wrappedItem = null;
        var root = null;
        for (var i = 0, length = list.length; i < length; i++) {
          wrappedItem = wrap(list[i]);
          if (!deep && (root = getTreeScope(wrappedItem).root)) {
            if (root instanceof scope.wrappers.ShadowRoot) {
              continue;
            }
          }
          result[index++] = wrappedItem;
        }
        return index;
      }
      function shimSelector(selector) {
        return String(selector).replace(/\/deep\/|::shadow|>>>/g, " ");
      }
      function shimMatchesSelector(selector) {
        return String(selector).replace(/:host\(([^\s]+)\)/g, "$1").replace(/([^\s]):host/g, "$1").replace(":host", "*").replace(/\^|\/shadow\/|\/shadow-deep\/|::shadow|\/deep\/|::content|>>>/g, " ");
      }
      function findOne(node, selector) {
        var m, el = node.firstElementChild;
        while (el) {
          if (el.matches(selector)) return el;
          m = findOne(el, selector);
          if (m) return m;
          el = el.nextElementSibling;
        }
        return null;
      }
      function matchesSelector(el, selector) {
        return el.matches(selector);
      }
      var XHTML_NS = "http://www.w3.org/1999/xhtml";
      function matchesTagName(el, localName, localNameLowerCase) {
        var ln = el.localName;
        return ln === localName || ln === localNameLowerCase && el.namespaceURI === XHTML_NS;
      }
      function matchesEveryThing() {
        return true;
      }
      function matchesLocalNameOnly(el, ns, localName) {
        return el.localName === localName;
      }
      function matchesNameSpace(el, ns) {
        return el.namespaceURI === ns;
      }
      function matchesLocalNameNS(el, ns, localName) {
        return el.namespaceURI === ns && el.localName === localName;
      }
      function findElements(node, index, result, p, arg0, arg1) {
        var el = node.firstElementChild;
        while (el) {
          if (p(el, arg0, arg1)) result[index++] = el;
          index = findElements(el, index, result, p, arg0, arg1);
          el = el.nextElementSibling;
        }
        return index;
      }
      function querySelectorAllFiltered(p, index, result, selector, deep) {
        var target = unsafeUnwrap(this);
        var list;
        var root = getTreeScope(this).root;
        if (root instanceof scope.wrappers.ShadowRoot) {
          return findElements(this, index, result, p, selector, null);
        } else if (target instanceof OriginalElement) {
          list = originalElementQuerySelectorAll.call(target, selector);
        } else if (target instanceof OriginalDocument) {
          list = originalDocumentQuerySelectorAll.call(target, selector);
        } else {
          return findElements(this, index, result, p, selector, null);
        }
        return filterNodeList(list, index, result, deep);
      }
      var SelectorsInterface = {
        querySelector: function(selector) {
          var shimmed = shimSelector(selector);
          var deep = shimmed !== selector;
          selector = shimmed;
          var target = unsafeUnwrap(this);
          var wrappedItem;
          var root = getTreeScope(this).root;
          if (root instanceof scope.wrappers.ShadowRoot) {
            return findOne(this, selector);
          } else if (target instanceof OriginalElement) {
            wrappedItem = wrap(originalElementQuerySelector.call(target, selector));
          } else if (target instanceof OriginalDocument) {
            wrappedItem = wrap(originalDocumentQuerySelector.call(target, selector));
          } else {
            return findOne(this, selector);
          }
          if (!wrappedItem) {
            return wrappedItem;
          } else if (!deep && (root = getTreeScope(wrappedItem).root)) {
            if (root instanceof scope.wrappers.ShadowRoot) {
              return findOne(this, selector);
            }
          }
          return wrappedItem;
        },
        querySelectorAll: function(selector) {
          var shimmed = shimSelector(selector);
          var deep = shimmed !== selector;
          selector = shimmed;
          var result = new NodeList();
          result.length = querySelectorAllFiltered.call(this, matchesSelector, 0, result, selector, deep);
          return result;
        }
      };
      var MatchesInterface = {
        matches: function(selector) {
          selector = shimMatchesSelector(selector);
          return scope.originalMatches.call(unsafeUnwrap(this), selector);
        }
      };
      function getElementsByTagNameFiltered(p, index, result, localName, lowercase) {
        var target = unsafeUnwrap(this);
        var list;
        var root = getTreeScope(this).root;
        if (root instanceof scope.wrappers.ShadowRoot) {
          return findElements(this, index, result, p, localName, lowercase);
        } else if (target instanceof OriginalElement) {
          list = originalElementGetElementsByTagName.call(target, localName, lowercase);
        } else if (target instanceof OriginalDocument) {
          list = originalDocumentGetElementsByTagName.call(target, localName, lowercase);
        } else {
          return findElements(this, index, result, p, localName, lowercase);
        }
        return filterNodeList(list, index, result, false);
      }
      function getElementsByTagNameNSFiltered(p, index, result, ns, localName) {
        var target = unsafeUnwrap(this);
        var list;
        var root = getTreeScope(this).root;
        if (root instanceof scope.wrappers.ShadowRoot) {
          return findElements(this, index, result, p, ns, localName);
        } else if (target instanceof OriginalElement) {
          list = originalElementGetElementsByTagNameNS.call(target, ns, localName);
        } else if (target instanceof OriginalDocument) {
          list = originalDocumentGetElementsByTagNameNS.call(target, ns, localName);
        } else {
          return findElements(this, index, result, p, ns, localName);
        }
        return filterNodeList(list, index, result, false);
      }
      var GetElementsByInterface = {
        getElementsByTagName: function(localName) {
          var result = new HTMLCollection();
          var match = localName === "*" ? matchesEveryThing : matchesTagName;
          result.length = getElementsByTagNameFiltered.call(this, match, 0, result, localName, localName.toLowerCase());
          return result;
        },
        getElementsByClassName: function(className) {
          return this.querySelectorAll("." + className);
        },
        getElementsByTagNameNS: function(ns, localName) {
          var result = new HTMLCollection();
          var match = null;
          if (ns === "*") {
            match = localName === "*" ? matchesEveryThing : matchesLocalNameOnly;
          } else {
            match = localName === "*" ? matchesNameSpace : matchesLocalNameNS;
          }
          result.length = getElementsByTagNameNSFiltered.call(this, match, 0, result, ns || null, localName);
          return result;
        }
      };
      scope.GetElementsByInterface = GetElementsByInterface;
      scope.SelectorsInterface = SelectorsInterface;
      scope.MatchesInterface = MatchesInterface;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var NodeList = scope.wrappers.NodeList;
      function forwardElement(node) {
        while (node && node.nodeType !== Node.ELEMENT_NODE) {
          node = node.nextSibling;
        }
        return node;
      }
      function backwardsElement(node) {
        while (node && node.nodeType !== Node.ELEMENT_NODE) {
          node = node.previousSibling;
        }
        return node;
      }
      var ParentNodeInterface = {
        get firstElementChild() {
          return forwardElement(this.firstChild);
        },
        get lastElementChild() {
          return backwardsElement(this.lastChild);
        },
        get childElementCount() {
          var count = 0;
          for (var child = this.firstElementChild; child; child = child.nextElementSibling) {
            count++;
          }
          return count;
        },
        get children() {
          var wrapperList = new NodeList();
          var i = 0;
          for (var child = this.firstElementChild; child; child = child.nextElementSibling) {
            wrapperList[i++] = child;
          }
          wrapperList.length = i;
          return wrapperList;
        },
        remove: function() {
          var p = this.parentNode;
          if (p) p.removeChild(this);
        }
      };
      var ChildNodeInterface = {
        get nextElementSibling() {
          return forwardElement(this.nextSibling);
        },
        get previousElementSibling() {
          return backwardsElement(this.previousSibling);
        }
      };
      var NonElementParentNodeInterface = {
        getElementById: function(id) {
          if (/[ \t\n\r\f]/.test(id)) return null;
          return this.querySelector('[id="' + id + '"]');
        }
      };
      scope.ChildNodeInterface = ChildNodeInterface;
      scope.NonElementParentNodeInterface = NonElementParentNodeInterface;
      scope.ParentNodeInterface = ParentNodeInterface;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var ChildNodeInterface = scope.ChildNodeInterface;
      var Node = scope.wrappers.Node;
      var enqueueMutation = scope.enqueueMutation;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var OriginalCharacterData = window.CharacterData;
      function CharacterData(node) {
        Node.call(this, node);
      }
      CharacterData.prototype = Object.create(Node.prototype);
      mixin(CharacterData.prototype, {
        get nodeValue() {
          return this.data;
        },
        set nodeValue(data) {
          this.data = data;
        },
        get textContent() {
          return this.data;
        },
        set textContent(value) {
          this.data = value;
        },
        get data() {
          return unsafeUnwrap(this).data;
        },
        set data(value) {
          var oldValue = unsafeUnwrap(this).data;
          enqueueMutation(this, "characterData", {
            oldValue: oldValue
          });
          unsafeUnwrap(this).data = value;
        }
      });
      mixin(CharacterData.prototype, ChildNodeInterface);
      registerWrapper(OriginalCharacterData, CharacterData, document.createTextNode(""));
      scope.wrappers.CharacterData = CharacterData;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var CharacterData = scope.wrappers.CharacterData;
      var enqueueMutation = scope.enqueueMutation;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      function toUInt32(x) {
        return x >>> 0;
      }
      var OriginalText = window.Text;
      function Text(node) {
        CharacterData.call(this, node);
      }
      Text.prototype = Object.create(CharacterData.prototype);
      mixin(Text.prototype, {
        splitText: function(offset) {
          offset = toUInt32(offset);
          var s = this.data;
          if (offset > s.length) throw new Error("IndexSizeError");
          var head = s.slice(0, offset);
          var tail = s.slice(offset);
          this.data = head;
          var newTextNode = this.ownerDocument.createTextNode(tail);
          if (this.parentNode) this.parentNode.insertBefore(newTextNode, this.nextSibling);
          return newTextNode;
        }
      });
      registerWrapper(OriginalText, Text, document.createTextNode(""));
      scope.wrappers.Text = Text;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      if (!window.DOMTokenList) {
        console.warn("Missing DOMTokenList prototype, please include a " + "compatible classList polyfill such as http://goo.gl/uTcepH.");
        return;
      }
      var unsafeUnwrap = scope.unsafeUnwrap;
      var enqueueMutation = scope.enqueueMutation;
      function getClass(el) {
        return unsafeUnwrap(el).getAttribute("class");
      }
      function enqueueClassAttributeChange(el, oldValue) {
        enqueueMutation(el, "attributes", {
          name: "class",
          namespace: null,
          oldValue: oldValue
        });
      }
      function invalidateClass(el) {
        scope.invalidateRendererBasedOnAttribute(el, "class");
      }
      function changeClass(tokenList, method, args) {
        var ownerElement = tokenList.ownerElement_;
        if (ownerElement == null) {
          return method.apply(tokenList, args);
        }
        var oldValue = getClass(ownerElement);
        var retv = method.apply(tokenList, args);
        if (getClass(ownerElement) !== oldValue) {
          enqueueClassAttributeChange(ownerElement, oldValue);
          invalidateClass(ownerElement);
        }
        return retv;
      }
      var oldAdd = DOMTokenList.prototype.add;
      DOMTokenList.prototype.add = function() {
        changeClass(this, oldAdd, arguments);
      };
      var oldRemove = DOMTokenList.prototype.remove;
      DOMTokenList.prototype.remove = function() {
        changeClass(this, oldRemove, arguments);
      };
      var oldToggle = DOMTokenList.prototype.toggle;
      DOMTokenList.prototype.toggle = function() {
        return changeClass(this, oldToggle, arguments);
      };
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var ChildNodeInterface = scope.ChildNodeInterface;
      var GetElementsByInterface = scope.GetElementsByInterface;
      var Node = scope.wrappers.Node;
      var ParentNodeInterface = scope.ParentNodeInterface;
      var SelectorsInterface = scope.SelectorsInterface;
      var MatchesInterface = scope.MatchesInterface;
      var addWrapNodeListMethod = scope.addWrapNodeListMethod;
      var enqueueMutation = scope.enqueueMutation;
      var mixin = scope.mixin;
      var oneOf = scope.oneOf;
      var registerWrapper = scope.registerWrapper;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var wrappers = scope.wrappers;
      var OriginalElement = window.Element;
      var matchesNames = [ "matches", "mozMatchesSelector", "msMatchesSelector", "webkitMatchesSelector" ].filter(function(name) {
        return OriginalElement.prototype[name];
      });
      var matchesName = matchesNames[0];
      var originalMatches = OriginalElement.prototype[matchesName];
      function invalidateRendererBasedOnAttribute(element, name) {
        var p = element.parentNode;
        if (!p || !p.shadowRoot) return;
        var renderer = scope.getRendererForHost(p);
        if (renderer.dependsOnAttribute(name)) renderer.invalidate();
      }
      function enqueAttributeChange(element, name, oldValue) {
        enqueueMutation(element, "attributes", {
          name: name,
          namespace: null,
          oldValue: oldValue
        });
      }
      var classListTable = new WeakMap();
      function Element(node) {
        Node.call(this, node);
      }
      Element.prototype = Object.create(Node.prototype);
      mixin(Element.prototype, {
        createShadowRoot: function() {
          var newShadowRoot = new wrappers.ShadowRoot(this);
          unsafeUnwrap(this).polymerShadowRoot_ = newShadowRoot;
          var renderer = scope.getRendererForHost(this);
          renderer.invalidate();
          return newShadowRoot;
        },
        get shadowRoot() {
          return unsafeUnwrap(this).polymerShadowRoot_ || null;
        },
        setAttribute: function(name, value) {
          var oldValue = unsafeUnwrap(this).getAttribute(name);
          unsafeUnwrap(this).setAttribute(name, value);
          enqueAttributeChange(this, name, oldValue);
          invalidateRendererBasedOnAttribute(this, name);
        },
        removeAttribute: function(name) {
          var oldValue = unsafeUnwrap(this).getAttribute(name);
          unsafeUnwrap(this).removeAttribute(name);
          enqueAttributeChange(this, name, oldValue);
          invalidateRendererBasedOnAttribute(this, name);
        },
        get classList() {
          var list = classListTable.get(this);
          if (!list) {
            list = unsafeUnwrap(this).classList;
            if (!list) return;
            list.ownerElement_ = this;
            classListTable.set(this, list);
          }
          return list;
        },
        get className() {
          return unsafeUnwrap(this).className;
        },
        set className(v) {
          this.setAttribute("class", v);
        },
        get id() {
          return unsafeUnwrap(this).id;
        },
        set id(v) {
          this.setAttribute("id", v);
        }
      });
      matchesNames.forEach(function(name) {
        if (name !== "matches") {
          Element.prototype[name] = function(selector) {
            return this.matches(selector);
          };
        }
      });
      if (OriginalElement.prototype.webkitCreateShadowRoot) {
        Element.prototype.webkitCreateShadowRoot = Element.prototype.createShadowRoot;
      }
      mixin(Element.prototype, ChildNodeInterface);
      mixin(Element.prototype, GetElementsByInterface);
      mixin(Element.prototype, ParentNodeInterface);
      mixin(Element.prototype, SelectorsInterface);
      mixin(Element.prototype, MatchesInterface);
      registerWrapper(OriginalElement, Element, document.createElementNS(null, "x"));
      scope.invalidateRendererBasedOnAttribute = invalidateRendererBasedOnAttribute;
      scope.matchesNames = matchesNames;
      scope.originalMatches = originalMatches;
      scope.wrappers.Element = Element;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var Element = scope.wrappers.Element;
      var defineGetter = scope.defineGetter;
      var enqueueMutation = scope.enqueueMutation;
      var mixin = scope.mixin;
      var nodesWereAdded = scope.nodesWereAdded;
      var nodesWereRemoved = scope.nodesWereRemoved;
      var registerWrapper = scope.registerWrapper;
      var snapshotNodeList = scope.snapshotNodeList;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var unwrap = scope.unwrap;
      var wrap = scope.wrap;
      var wrappers = scope.wrappers;
      var escapeAttrRegExp = /[&\u00A0"]/g;
      var escapeDataRegExp = /[&\u00A0<>]/g;
      function escapeReplace(c) {
        switch (c) {
         case "&":
          return "&amp;";
  
         case "<":
          return "&lt;";
  
         case ">":
          return "&gt;";
  
         case '"':
          return "&quot;";
  
         case " ":
          return "&nbsp;";
        }
      }
      function escapeAttr(s) {
        return s.replace(escapeAttrRegExp, escapeReplace);
      }
      function escapeData(s) {
        return s.replace(escapeDataRegExp, escapeReplace);
      }
      function makeSet(arr) {
        var set = {};
        for (var i = 0; i < arr.length; i++) {
          set[arr[i]] = true;
        }
        return set;
      }
      var voidElements = makeSet([ "area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr" ]);
      var plaintextParents = makeSet([ "style", "script", "xmp", "iframe", "noembed", "noframes", "plaintext", "noscript" ]);
      var XHTML_NS = "http://www.w3.org/1999/xhtml";
      function needsSelfClosingSlash(node) {
        if (node.namespaceURI !== XHTML_NS) return true;
        var doctype = node.ownerDocument.doctype;
        return doctype && doctype.publicId && doctype.systemId;
      }
      function getOuterHTML(node, parentNode) {
        switch (node.nodeType) {
         case Node.ELEMENT_NODE:
          var tagName = node.tagName.toLowerCase();
          var s = "<" + tagName;
          var attrs = node.attributes;
          for (var i = 0, attr; attr = attrs[i]; i++) {
            s += " " + attr.name + '="' + escapeAttr(attr.value) + '"';
          }
          if (voidElements[tagName]) {
            if (needsSelfClosingSlash(node)) s += "/";
            return s + ">";
          }
          return s + ">" + getInnerHTML(node) + "</" + tagName + ">";
  
         case Node.TEXT_NODE:
          var data = node.data;
          if (parentNode && plaintextParents[parentNode.localName]) return data;
          return escapeData(data);
  
         case Node.COMMENT_NODE:
          return "<!--" + node.data + "-->";
  
         default:
          console.error(node);
          throw new Error("not implemented");
        }
      }
      function getInnerHTML(node) {
        if (node instanceof wrappers.HTMLTemplateElement) node = node.content;
        var s = "";
        for (var child = node.firstChild; child; child = child.nextSibling) {
          s += getOuterHTML(child, node);
        }
        return s;
      }
      function setInnerHTML(node, value, opt_tagName) {
        var tagName = opt_tagName || "div";
        node.textContent = "";
        var tempElement = unwrap(node.ownerDocument.createElement(tagName));
        tempElement.innerHTML = value;
        var firstChild;
        while (firstChild = tempElement.firstChild) {
          node.appendChild(wrap(firstChild));
        }
      }
      var oldIe = /MSIE/.test(navigator.userAgent);
      var OriginalHTMLElement = window.HTMLElement;
      var OriginalHTMLTemplateElement = window.HTMLTemplateElement;
      function HTMLElement(node) {
        Element.call(this, node);
      }
      HTMLElement.prototype = Object.create(Element.prototype);
      mixin(HTMLElement.prototype, {
        get innerHTML() {
          return getInnerHTML(this);
        },
        set innerHTML(value) {
          if (oldIe && plaintextParents[this.localName]) {
            this.textContent = value;
            return;
          }
          var removedNodes = snapshotNodeList(this.childNodes);
          if (this.invalidateShadowRenderer()) {
            if (this instanceof wrappers.HTMLTemplateElement) setInnerHTML(this.content, value); else setInnerHTML(this, value, this.tagName);
          } else if (!OriginalHTMLTemplateElement && this instanceof wrappers.HTMLTemplateElement) {
            setInnerHTML(this.content, value);
          } else {
            unsafeUnwrap(this).innerHTML = value;
          }
          var addedNodes = snapshotNodeList(this.childNodes);
          enqueueMutation(this, "childList", {
            addedNodes: addedNodes,
            removedNodes: removedNodes
          });
          nodesWereRemoved(removedNodes);
          nodesWereAdded(addedNodes, this);
        },
        get outerHTML() {
          return getOuterHTML(this, this.parentNode);
        },
        set outerHTML(value) {
          var p = this.parentNode;
          if (p) {
            p.invalidateShadowRenderer();
            var df = frag(p, value);
            p.replaceChild(df, this);
          }
        },
        insertAdjacentHTML: function(position, text) {
          var contextElement, refNode;
          switch (String(position).toLowerCase()) {
           case "beforebegin":
            contextElement = this.parentNode;
            refNode = this;
            break;
  
           case "afterend":
            contextElement = this.parentNode;
            refNode = this.nextSibling;
            break;
  
           case "afterbegin":
            contextElement = this;
            refNode = this.firstChild;
            break;
  
           case "beforeend":
            contextElement = this;
            refNode = null;
            break;
  
           default:
            return;
          }
          var df = frag(contextElement, text);
          contextElement.insertBefore(df, refNode);
        },
        get hidden() {
          return this.hasAttribute("hidden");
        },
        set hidden(v) {
          if (v) {
            this.setAttribute("hidden", "");
          } else {
            this.removeAttribute("hidden");
          }
        }
      });
      function frag(contextElement, html) {
        var p = unwrap(contextElement.cloneNode(false));
        p.innerHTML = html;
        var df = unwrap(document.createDocumentFragment());
        var c;
        while (c = p.firstChild) {
          df.appendChild(c);
        }
        return wrap(df);
      }
      function getter(name) {
        return function() {
          scope.renderAllPending();
          return unsafeUnwrap(this)[name];
        };
      }
      function getterRequiresRendering(name) {
        defineGetter(HTMLElement, name, getter(name));
      }
      [ "clientHeight", "clientLeft", "clientTop", "clientWidth", "offsetHeight", "offsetLeft", "offsetTop", "offsetWidth", "scrollHeight", "scrollWidth" ].forEach(getterRequiresRendering);
      function getterAndSetterRequiresRendering(name) {
        Object.defineProperty(HTMLElement.prototype, name, {
          get: getter(name),
          set: function(v) {
            scope.renderAllPending();
            unsafeUnwrap(this)[name] = v;
          },
          configurable: true,
          enumerable: true
        });
      }
      [ "scrollLeft", "scrollTop" ].forEach(getterAndSetterRequiresRendering);
      function methodRequiresRendering(name) {
        Object.defineProperty(HTMLElement.prototype, name, {
          value: function() {
            scope.renderAllPending();
            return unsafeUnwrap(this)[name].apply(unsafeUnwrap(this), arguments);
          },
          configurable: true,
          enumerable: true
        });
      }
c5169e0e   Renato De Donato   a new hope
2756
      [ "getBoundingClientRect", "getClientRects", "scrollIntoView" ].forEach(methodRequiresRendering);
73bcce88   luigser   COMPONENTS
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
2828
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
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
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
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
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
3067
3068
3069
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
      registerWrapper(OriginalHTMLElement, HTMLElement, document.createElement("b"));
      scope.wrappers.HTMLElement = HTMLElement;
      scope.getInnerHTML = getInnerHTML;
      scope.setInnerHTML = setInnerHTML;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var HTMLElement = scope.wrappers.HTMLElement;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var wrap = scope.wrap;
      var OriginalHTMLCanvasElement = window.HTMLCanvasElement;
      function HTMLCanvasElement(node) {
        HTMLElement.call(this, node);
      }
      HTMLCanvasElement.prototype = Object.create(HTMLElement.prototype);
      mixin(HTMLCanvasElement.prototype, {
        getContext: function() {
          var context = unsafeUnwrap(this).getContext.apply(unsafeUnwrap(this), arguments);
          return context && wrap(context);
        }
      });
      registerWrapper(OriginalHTMLCanvasElement, HTMLCanvasElement, document.createElement("canvas"));
      scope.wrappers.HTMLCanvasElement = HTMLCanvasElement;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var HTMLElement = scope.wrappers.HTMLElement;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var OriginalHTMLContentElement = window.HTMLContentElement;
      function HTMLContentElement(node) {
        HTMLElement.call(this, node);
      }
      HTMLContentElement.prototype = Object.create(HTMLElement.prototype);
      mixin(HTMLContentElement.prototype, {
        constructor: HTMLContentElement,
        get select() {
          return this.getAttribute("select");
        },
        set select(value) {
          this.setAttribute("select", value);
        },
        setAttribute: function(n, v) {
          HTMLElement.prototype.setAttribute.call(this, n, v);
          if (String(n).toLowerCase() === "select") this.invalidateShadowRenderer(true);
        }
      });
      if (OriginalHTMLContentElement) registerWrapper(OriginalHTMLContentElement, HTMLContentElement);
      scope.wrappers.HTMLContentElement = HTMLContentElement;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var HTMLElement = scope.wrappers.HTMLElement;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var wrapHTMLCollection = scope.wrapHTMLCollection;
      var unwrap = scope.unwrap;
      var OriginalHTMLFormElement = window.HTMLFormElement;
      function HTMLFormElement(node) {
        HTMLElement.call(this, node);
      }
      HTMLFormElement.prototype = Object.create(HTMLElement.prototype);
      mixin(HTMLFormElement.prototype, {
        get elements() {
          return wrapHTMLCollection(unwrap(this).elements);
        }
      });
      registerWrapper(OriginalHTMLFormElement, HTMLFormElement, document.createElement("form"));
      scope.wrappers.HTMLFormElement = HTMLFormElement;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var HTMLElement = scope.wrappers.HTMLElement;
      var registerWrapper = scope.registerWrapper;
      var unwrap = scope.unwrap;
      var rewrap = scope.rewrap;
      var OriginalHTMLImageElement = window.HTMLImageElement;
      function HTMLImageElement(node) {
        HTMLElement.call(this, node);
      }
      HTMLImageElement.prototype = Object.create(HTMLElement.prototype);
      registerWrapper(OriginalHTMLImageElement, HTMLImageElement, document.createElement("img"));
      function Image(width, height) {
        if (!(this instanceof Image)) {
          throw new TypeError("DOM object constructor cannot be called as a function.");
        }
        var node = unwrap(document.createElement("img"));
        HTMLElement.call(this, node);
        rewrap(node, this);
        if (width !== undefined) node.width = width;
        if (height !== undefined) node.height = height;
      }
      Image.prototype = HTMLImageElement.prototype;
      scope.wrappers.HTMLImageElement = HTMLImageElement;
      scope.wrappers.Image = Image;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var HTMLElement = scope.wrappers.HTMLElement;
      var mixin = scope.mixin;
      var NodeList = scope.wrappers.NodeList;
      var registerWrapper = scope.registerWrapper;
      var OriginalHTMLShadowElement = window.HTMLShadowElement;
      function HTMLShadowElement(node) {
        HTMLElement.call(this, node);
      }
      HTMLShadowElement.prototype = Object.create(HTMLElement.prototype);
      HTMLShadowElement.prototype.constructor = HTMLShadowElement;
      if (OriginalHTMLShadowElement) registerWrapper(OriginalHTMLShadowElement, HTMLShadowElement);
      scope.wrappers.HTMLShadowElement = HTMLShadowElement;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var HTMLElement = scope.wrappers.HTMLElement;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var unwrap = scope.unwrap;
      var wrap = scope.wrap;
      var contentTable = new WeakMap();
      var templateContentsOwnerTable = new WeakMap();
      function getTemplateContentsOwner(doc) {
        if (!doc.defaultView) return doc;
        var d = templateContentsOwnerTable.get(doc);
        if (!d) {
          d = doc.implementation.createHTMLDocument("");
          while (d.lastChild) {
            d.removeChild(d.lastChild);
          }
          templateContentsOwnerTable.set(doc, d);
        }
        return d;
      }
      function extractContent(templateElement) {
        var doc = getTemplateContentsOwner(templateElement.ownerDocument);
        var df = unwrap(doc.createDocumentFragment());
        var child;
        while (child = templateElement.firstChild) {
          df.appendChild(child);
        }
        return df;
      }
      var OriginalHTMLTemplateElement = window.HTMLTemplateElement;
      function HTMLTemplateElement(node) {
        HTMLElement.call(this, node);
        if (!OriginalHTMLTemplateElement) {
          var content = extractContent(node);
          contentTable.set(this, wrap(content));
        }
      }
      HTMLTemplateElement.prototype = Object.create(HTMLElement.prototype);
      mixin(HTMLTemplateElement.prototype, {
        constructor: HTMLTemplateElement,
        get content() {
          if (OriginalHTMLTemplateElement) return wrap(unsafeUnwrap(this).content);
          return contentTable.get(this);
        }
      });
      if (OriginalHTMLTemplateElement) registerWrapper(OriginalHTMLTemplateElement, HTMLTemplateElement);
      scope.wrappers.HTMLTemplateElement = HTMLTemplateElement;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var HTMLElement = scope.wrappers.HTMLElement;
      var registerWrapper = scope.registerWrapper;
      var OriginalHTMLMediaElement = window.HTMLMediaElement;
      if (!OriginalHTMLMediaElement) return;
      function HTMLMediaElement(node) {
        HTMLElement.call(this, node);
      }
      HTMLMediaElement.prototype = Object.create(HTMLElement.prototype);
      registerWrapper(OriginalHTMLMediaElement, HTMLMediaElement, document.createElement("audio"));
      scope.wrappers.HTMLMediaElement = HTMLMediaElement;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var HTMLMediaElement = scope.wrappers.HTMLMediaElement;
      var registerWrapper = scope.registerWrapper;
      var unwrap = scope.unwrap;
      var rewrap = scope.rewrap;
      var OriginalHTMLAudioElement = window.HTMLAudioElement;
      if (!OriginalHTMLAudioElement) return;
      function HTMLAudioElement(node) {
        HTMLMediaElement.call(this, node);
      }
      HTMLAudioElement.prototype = Object.create(HTMLMediaElement.prototype);
      registerWrapper(OriginalHTMLAudioElement, HTMLAudioElement, document.createElement("audio"));
      function Audio(src) {
        if (!(this instanceof Audio)) {
          throw new TypeError("DOM object constructor cannot be called as a function.");
        }
        var node = unwrap(document.createElement("audio"));
        HTMLMediaElement.call(this, node);
        rewrap(node, this);
        node.setAttribute("preload", "auto");
        if (src !== undefined) node.setAttribute("src", src);
      }
      Audio.prototype = HTMLAudioElement.prototype;
      scope.wrappers.HTMLAudioElement = HTMLAudioElement;
      scope.wrappers.Audio = Audio;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var HTMLElement = scope.wrappers.HTMLElement;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var rewrap = scope.rewrap;
      var unwrap = scope.unwrap;
      var wrap = scope.wrap;
      var OriginalHTMLOptionElement = window.HTMLOptionElement;
      function trimText(s) {
        return s.replace(/\s+/g, " ").trim();
      }
      function HTMLOptionElement(node) {
        HTMLElement.call(this, node);
      }
      HTMLOptionElement.prototype = Object.create(HTMLElement.prototype);
      mixin(HTMLOptionElement.prototype, {
        get text() {
          return trimText(this.textContent);
        },
        set text(value) {
          this.textContent = trimText(String(value));
        },
        get form() {
          return wrap(unwrap(this).form);
        }
      });
      registerWrapper(OriginalHTMLOptionElement, HTMLOptionElement, document.createElement("option"));
      function Option(text, value, defaultSelected, selected) {
        if (!(this instanceof Option)) {
          throw new TypeError("DOM object constructor cannot be called as a function.");
        }
        var node = unwrap(document.createElement("option"));
        HTMLElement.call(this, node);
        rewrap(node, this);
        if (text !== undefined) node.text = text;
        if (value !== undefined) node.setAttribute("value", value);
        if (defaultSelected === true) node.setAttribute("selected", "");
        node.selected = selected === true;
      }
      Option.prototype = HTMLOptionElement.prototype;
      scope.wrappers.HTMLOptionElement = HTMLOptionElement;
      scope.wrappers.Option = Option;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var HTMLElement = scope.wrappers.HTMLElement;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var unwrap = scope.unwrap;
      var wrap = scope.wrap;
      var OriginalHTMLSelectElement = window.HTMLSelectElement;
      function HTMLSelectElement(node) {
        HTMLElement.call(this, node);
      }
      HTMLSelectElement.prototype = Object.create(HTMLElement.prototype);
      mixin(HTMLSelectElement.prototype, {
        add: function(element, before) {
          if (typeof before === "object") before = unwrap(before);
          unwrap(this).add(unwrap(element), before);
        },
        remove: function(indexOrNode) {
          if (indexOrNode === undefined) {
            HTMLElement.prototype.remove.call(this);
            return;
          }
          if (typeof indexOrNode === "object") indexOrNode = unwrap(indexOrNode);
          unwrap(this).remove(indexOrNode);
        },
        get form() {
          return wrap(unwrap(this).form);
        }
      });
      registerWrapper(OriginalHTMLSelectElement, HTMLSelectElement, document.createElement("select"));
      scope.wrappers.HTMLSelectElement = HTMLSelectElement;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var HTMLElement = scope.wrappers.HTMLElement;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var unwrap = scope.unwrap;
      var wrap = scope.wrap;
      var wrapHTMLCollection = scope.wrapHTMLCollection;
      var OriginalHTMLTableElement = window.HTMLTableElement;
      function HTMLTableElement(node) {
        HTMLElement.call(this, node);
      }
      HTMLTableElement.prototype = Object.create(HTMLElement.prototype);
      mixin(HTMLTableElement.prototype, {
        get caption() {
          return wrap(unwrap(this).caption);
        },
        createCaption: function() {
          return wrap(unwrap(this).createCaption());
        },
        get tHead() {
          return wrap(unwrap(this).tHead);
        },
        createTHead: function() {
          return wrap(unwrap(this).createTHead());
        },
        createTFoot: function() {
          return wrap(unwrap(this).createTFoot());
        },
        get tFoot() {
          return wrap(unwrap(this).tFoot);
        },
        get tBodies() {
          return wrapHTMLCollection(unwrap(this).tBodies);
        },
        createTBody: function() {
          return wrap(unwrap(this).createTBody());
        },
        get rows() {
          return wrapHTMLCollection(unwrap(this).rows);
        },
        insertRow: function(index) {
          return wrap(unwrap(this).insertRow(index));
        }
      });
      registerWrapper(OriginalHTMLTableElement, HTMLTableElement, document.createElement("table"));
      scope.wrappers.HTMLTableElement = HTMLTableElement;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var HTMLElement = scope.wrappers.HTMLElement;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var wrapHTMLCollection = scope.wrapHTMLCollection;
      var unwrap = scope.unwrap;
      var wrap = scope.wrap;
      var OriginalHTMLTableSectionElement = window.HTMLTableSectionElement;
      function HTMLTableSectionElement(node) {
        HTMLElement.call(this, node);
      }
      HTMLTableSectionElement.prototype = Object.create(HTMLElement.prototype);
      mixin(HTMLTableSectionElement.prototype, {
        constructor: HTMLTableSectionElement,
        get rows() {
          return wrapHTMLCollection(unwrap(this).rows);
        },
        insertRow: function(index) {
          return wrap(unwrap(this).insertRow(index));
        }
      });
      registerWrapper(OriginalHTMLTableSectionElement, HTMLTableSectionElement, document.createElement("thead"));
      scope.wrappers.HTMLTableSectionElement = HTMLTableSectionElement;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var HTMLElement = scope.wrappers.HTMLElement;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var wrapHTMLCollection = scope.wrapHTMLCollection;
      var unwrap = scope.unwrap;
      var wrap = scope.wrap;
      var OriginalHTMLTableRowElement = window.HTMLTableRowElement;
      function HTMLTableRowElement(node) {
        HTMLElement.call(this, node);
      }
      HTMLTableRowElement.prototype = Object.create(HTMLElement.prototype);
      mixin(HTMLTableRowElement.prototype, {
        get cells() {
          return wrapHTMLCollection(unwrap(this).cells);
        },
        insertCell: function(index) {
          return wrap(unwrap(this).insertCell(index));
        }
      });
      registerWrapper(OriginalHTMLTableRowElement, HTMLTableRowElement, document.createElement("tr"));
      scope.wrappers.HTMLTableRowElement = HTMLTableRowElement;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var HTMLContentElement = scope.wrappers.HTMLContentElement;
      var HTMLElement = scope.wrappers.HTMLElement;
      var HTMLShadowElement = scope.wrappers.HTMLShadowElement;
      var HTMLTemplateElement = scope.wrappers.HTMLTemplateElement;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var OriginalHTMLUnknownElement = window.HTMLUnknownElement;
      function HTMLUnknownElement(node) {
        switch (node.localName) {
         case "content":
          return new HTMLContentElement(node);
  
         case "shadow":
          return new HTMLShadowElement(node);
  
         case "template":
          return new HTMLTemplateElement(node);
        }
        HTMLElement.call(this, node);
      }
      HTMLUnknownElement.prototype = Object.create(HTMLElement.prototype);
      registerWrapper(OriginalHTMLUnknownElement, HTMLUnknownElement);
      scope.wrappers.HTMLUnknownElement = HTMLUnknownElement;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var Element = scope.wrappers.Element;
      var HTMLElement = scope.wrappers.HTMLElement;
e619a3b0   Luigi Serra   Controllet cross ...
3163
      var registerWrapper = scope.registerWrapper;
73bcce88   luigser   COMPONENTS
3164
      var defineWrapGetter = scope.defineWrapGetter;
e619a3b0   Luigi Serra   Controllet cross ...
3165
3166
3167
      var unsafeUnwrap = scope.unsafeUnwrap;
      var wrap = scope.wrap;
      var mixin = scope.mixin;
73bcce88   luigser   COMPONENTS
3168
      var SVG_NS = "http://www.w3.org/2000/svg";
e619a3b0   Luigi Serra   Controllet cross ...
3169
      var OriginalSVGElement = window.SVGElement;
73bcce88   luigser   COMPONENTS
3170
      var svgTitleElement = document.createElementNS(SVG_NS, "title");
73bcce88   luigser   COMPONENTS
3171
3172
3173
3174
3175
      if (!("classList" in svgTitleElement)) {
        var descr = Object.getOwnPropertyDescriptor(Element.prototype, "classList");
        Object.defineProperty(HTMLElement.prototype, "classList", descr);
        delete Element.prototype.classList;
      }
e619a3b0   Luigi Serra   Controllet cross ...
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
      function SVGElement(node) {
        Element.call(this, node);
      }
      SVGElement.prototype = Object.create(Element.prototype);
      mixin(SVGElement.prototype, {
        get ownerSVGElement() {
          return wrap(unsafeUnwrap(this).ownerSVGElement);
        }
      });
      registerWrapper(OriginalSVGElement, SVGElement, document.createElementNS(SVG_NS, "title"));
73bcce88   luigser   COMPONENTS
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
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
      scope.wrappers.SVGElement = SVGElement;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var unwrap = scope.unwrap;
      var wrap = scope.wrap;
      var OriginalSVGUseElement = window.SVGUseElement;
      var SVG_NS = "http://www.w3.org/2000/svg";
      var gWrapper = wrap(document.createElementNS(SVG_NS, "g"));
      var useElement = document.createElementNS(SVG_NS, "use");
      var SVGGElement = gWrapper.constructor;
      var parentInterfacePrototype = Object.getPrototypeOf(SVGGElement.prototype);
      var parentInterface = parentInterfacePrototype.constructor;
      function SVGUseElement(impl) {
        parentInterface.call(this, impl);
      }
      SVGUseElement.prototype = Object.create(parentInterfacePrototype);
      if ("instanceRoot" in useElement) {
        mixin(SVGUseElement.prototype, {
          get instanceRoot() {
            return wrap(unwrap(this).instanceRoot);
          },
          get animatedInstanceRoot() {
            return wrap(unwrap(this).animatedInstanceRoot);
          }
        });
      }
      registerWrapper(OriginalSVGUseElement, SVGUseElement, useElement);
      scope.wrappers.SVGUseElement = SVGUseElement;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var EventTarget = scope.wrappers.EventTarget;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var wrap = scope.wrap;
      var OriginalSVGElementInstance = window.SVGElementInstance;
      if (!OriginalSVGElementInstance) return;
      function SVGElementInstance(impl) {
        EventTarget.call(this, impl);
      }
      SVGElementInstance.prototype = Object.create(EventTarget.prototype);
      mixin(SVGElementInstance.prototype, {
        get correspondingElement() {
          return wrap(unsafeUnwrap(this).correspondingElement);
        },
        get correspondingUseElement() {
          return wrap(unsafeUnwrap(this).correspondingUseElement);
        },
        get parentNode() {
          return wrap(unsafeUnwrap(this).parentNode);
        },
        get childNodes() {
          throw new Error("Not implemented");
        },
        get firstChild() {
          return wrap(unsafeUnwrap(this).firstChild);
        },
        get lastChild() {
          return wrap(unsafeUnwrap(this).lastChild);
        },
        get previousSibling() {
          return wrap(unsafeUnwrap(this).previousSibling);
        },
        get nextSibling() {
          return wrap(unsafeUnwrap(this).nextSibling);
        }
      });
      registerWrapper(OriginalSVGElementInstance, SVGElementInstance);
      scope.wrappers.SVGElementInstance = SVGElementInstance;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var setWrapper = scope.setWrapper;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var unwrap = scope.unwrap;
      var unwrapIfNeeded = scope.unwrapIfNeeded;
      var wrap = scope.wrap;
      var OriginalCanvasRenderingContext2D = window.CanvasRenderingContext2D;
      function CanvasRenderingContext2D(impl) {
        setWrapper(impl, this);
      }
      mixin(CanvasRenderingContext2D.prototype, {
        get canvas() {
          return wrap(unsafeUnwrap(this).canvas);
        },
        drawImage: function() {
          arguments[0] = unwrapIfNeeded(arguments[0]);
          unsafeUnwrap(this).drawImage.apply(unsafeUnwrap(this), arguments);
        },
        createPattern: function() {
          arguments[0] = unwrap(arguments[0]);
          return unsafeUnwrap(this).createPattern.apply(unsafeUnwrap(this), arguments);
        }
      });
      registerWrapper(OriginalCanvasRenderingContext2D, CanvasRenderingContext2D, document.createElement("canvas").getContext("2d"));
      scope.wrappers.CanvasRenderingContext2D = CanvasRenderingContext2D;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
73bcce88   luigser   COMPONENTS
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var setWrapper = scope.setWrapper;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var unwrapIfNeeded = scope.unwrapIfNeeded;
      var wrap = scope.wrap;
      var OriginalWebGLRenderingContext = window.WebGLRenderingContext;
      if (!OriginalWebGLRenderingContext) return;
      function WebGLRenderingContext(impl) {
        setWrapper(impl, this);
      }
      mixin(WebGLRenderingContext.prototype, {
        get canvas() {
          return wrap(unsafeUnwrap(this).canvas);
        },
        texImage2D: function() {
          arguments[5] = unwrapIfNeeded(arguments[5]);
          unsafeUnwrap(this).texImage2D.apply(unsafeUnwrap(this), arguments);
        },
        texSubImage2D: function() {
          arguments[6] = unwrapIfNeeded(arguments[6]);
          unsafeUnwrap(this).texSubImage2D.apply(unsafeUnwrap(this), arguments);
        }
      });
73bcce88   luigser   COMPONENTS
3315
3316
3317
3318
3319
3320
3321
3322
3323
      var instanceProperties = /WebKit/.test(navigator.userAgent) ? {
        drawingBufferHeight: null,
        drawingBufferWidth: null
      } : {};
      registerWrapper(OriginalWebGLRenderingContext, WebGLRenderingContext, instanceProperties);
      scope.wrappers.WebGLRenderingContext = WebGLRenderingContext;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
e619a3b0   Luigi Serra   Controllet cross ...
3324
      var Node = scope.wrappers.Node;
73bcce88   luigser   COMPONENTS
3325
3326
3327
3328
3329
3330
      var GetElementsByInterface = scope.GetElementsByInterface;
      var NonElementParentNodeInterface = scope.NonElementParentNodeInterface;
      var ParentNodeInterface = scope.ParentNodeInterface;
      var SelectorsInterface = scope.SelectorsInterface;
      var mixin = scope.mixin;
      var registerObject = scope.registerObject;
e619a3b0   Luigi Serra   Controllet cross ...
3331
3332
3333
3334
3335
3336
      var registerWrapper = scope.registerWrapper;
      var OriginalDocumentFragment = window.DocumentFragment;
      function DocumentFragment(node) {
        Node.call(this, node);
      }
      DocumentFragment.prototype = Object.create(Node.prototype);
73bcce88   luigser   COMPONENTS
3337
3338
3339
3340
      mixin(DocumentFragment.prototype, ParentNodeInterface);
      mixin(DocumentFragment.prototype, SelectorsInterface);
      mixin(DocumentFragment.prototype, GetElementsByInterface);
      mixin(DocumentFragment.prototype, NonElementParentNodeInterface);
e619a3b0   Luigi Serra   Controllet cross ...
3341
3342
      registerWrapper(OriginalDocumentFragment, DocumentFragment, document.createDocumentFragment());
      scope.wrappers.DocumentFragment = DocumentFragment;
73bcce88   luigser   COMPONENTS
3343
3344
      var Comment = registerObject(document.createComment(""));
      scope.wrappers.Comment = Comment;
73bcce88   luigser   COMPONENTS
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var DocumentFragment = scope.wrappers.DocumentFragment;
      var TreeScope = scope.TreeScope;
      var elementFromPoint = scope.elementFromPoint;
      var getInnerHTML = scope.getInnerHTML;
      var getTreeScope = scope.getTreeScope;
      var mixin = scope.mixin;
      var rewrap = scope.rewrap;
      var setInnerHTML = scope.setInnerHTML;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var unwrap = scope.unwrap;
73bcce88   luigser   COMPONENTS
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
      var shadowHostTable = new WeakMap();
      var nextOlderShadowTreeTable = new WeakMap();
      function ShadowRoot(hostWrapper) {
        var node = unwrap(unsafeUnwrap(hostWrapper).ownerDocument.createDocumentFragment());
        DocumentFragment.call(this, node);
        rewrap(node, this);
        var oldShadowRoot = hostWrapper.shadowRoot;
        nextOlderShadowTreeTable.set(this, oldShadowRoot);
        this.treeScope_ = new TreeScope(this, getTreeScope(oldShadowRoot || hostWrapper));
        shadowHostTable.set(this, hostWrapper);
      }
      ShadowRoot.prototype = Object.create(DocumentFragment.prototype);
      mixin(ShadowRoot.prototype, {
        constructor: ShadowRoot,
        get innerHTML() {
          return getInnerHTML(this);
        },
        set innerHTML(value) {
          setInnerHTML(this, value);
          this.invalidateShadowRenderer();
        },
        get olderShadowRoot() {
          return nextOlderShadowTreeTable.get(this) || null;
        },
        get host() {
          return shadowHostTable.get(this) || null;
        },
        invalidateShadowRenderer: function() {
          return shadowHostTable.get(this).invalidateShadowRenderer();
        },
        elementFromPoint: function(x, y) {
          return elementFromPoint(this, this.ownerDocument, x, y);
73bcce88   luigser   COMPONENTS
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
3416
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
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
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
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
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
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
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
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
        }
      });
      scope.wrappers.ShadowRoot = ShadowRoot;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var registerWrapper = scope.registerWrapper;
      var setWrapper = scope.setWrapper;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var unwrap = scope.unwrap;
      var unwrapIfNeeded = scope.unwrapIfNeeded;
      var wrap = scope.wrap;
      var getTreeScope = scope.getTreeScope;
      var OriginalRange = window.Range;
      var ShadowRoot = scope.wrappers.ShadowRoot;
      function getHost(node) {
        var root = getTreeScope(node).root;
        if (root instanceof ShadowRoot) {
          return root.host;
        }
        return null;
      }
      function hostNodeToShadowNode(refNode, offset) {
        if (refNode.shadowRoot) {
          offset = Math.min(refNode.childNodes.length - 1, offset);
          var child = refNode.childNodes[offset];
          if (child) {
            var insertionPoint = scope.getDestinationInsertionPoints(child);
            if (insertionPoint.length > 0) {
              var parentNode = insertionPoint[0].parentNode;
              if (parentNode.nodeType == Node.ELEMENT_NODE) {
                refNode = parentNode;
              }
            }
          }
        }
        return refNode;
      }
      function shadowNodeToHostNode(node) {
        node = wrap(node);
        return getHost(node) || node;
      }
      function Range(impl) {
        setWrapper(impl, this);
      }
      Range.prototype = {
        get startContainer() {
          return shadowNodeToHostNode(unsafeUnwrap(this).startContainer);
        },
        get endContainer() {
          return shadowNodeToHostNode(unsafeUnwrap(this).endContainer);
        },
        get commonAncestorContainer() {
          return shadowNodeToHostNode(unsafeUnwrap(this).commonAncestorContainer);
        },
        setStart: function(refNode, offset) {
          refNode = hostNodeToShadowNode(refNode, offset);
          unsafeUnwrap(this).setStart(unwrapIfNeeded(refNode), offset);
        },
        setEnd: function(refNode, offset) {
          refNode = hostNodeToShadowNode(refNode, offset);
          unsafeUnwrap(this).setEnd(unwrapIfNeeded(refNode), offset);
        },
        setStartBefore: function(refNode) {
          unsafeUnwrap(this).setStartBefore(unwrapIfNeeded(refNode));
        },
        setStartAfter: function(refNode) {
          unsafeUnwrap(this).setStartAfter(unwrapIfNeeded(refNode));
        },
        setEndBefore: function(refNode) {
          unsafeUnwrap(this).setEndBefore(unwrapIfNeeded(refNode));
        },
        setEndAfter: function(refNode) {
          unsafeUnwrap(this).setEndAfter(unwrapIfNeeded(refNode));
        },
        selectNode: function(refNode) {
          unsafeUnwrap(this).selectNode(unwrapIfNeeded(refNode));
        },
        selectNodeContents: function(refNode) {
          unsafeUnwrap(this).selectNodeContents(unwrapIfNeeded(refNode));
        },
        compareBoundaryPoints: function(how, sourceRange) {
          return unsafeUnwrap(this).compareBoundaryPoints(how, unwrap(sourceRange));
        },
        extractContents: function() {
          return wrap(unsafeUnwrap(this).extractContents());
        },
        cloneContents: function() {
          return wrap(unsafeUnwrap(this).cloneContents());
        },
        insertNode: function(node) {
          unsafeUnwrap(this).insertNode(unwrapIfNeeded(node));
        },
        surroundContents: function(newParent) {
          unsafeUnwrap(this).surroundContents(unwrapIfNeeded(newParent));
        },
        cloneRange: function() {
          return wrap(unsafeUnwrap(this).cloneRange());
        },
        isPointInRange: function(node, offset) {
          return unsafeUnwrap(this).isPointInRange(unwrapIfNeeded(node), offset);
        },
        comparePoint: function(node, offset) {
          return unsafeUnwrap(this).comparePoint(unwrapIfNeeded(node), offset);
        },
        intersectsNode: function(node) {
          return unsafeUnwrap(this).intersectsNode(unwrapIfNeeded(node));
        },
        toString: function() {
          return unsafeUnwrap(this).toString();
        }
      };
      if (OriginalRange.prototype.createContextualFragment) {
        Range.prototype.createContextualFragment = function(html) {
          return wrap(unsafeUnwrap(this).createContextualFragment(html));
        };
      }
      registerWrapper(window.Range, Range, document.createRange());
      scope.wrappers.Range = Range;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var Element = scope.wrappers.Element;
      var HTMLContentElement = scope.wrappers.HTMLContentElement;
      var HTMLShadowElement = scope.wrappers.HTMLShadowElement;
      var Node = scope.wrappers.Node;
      var ShadowRoot = scope.wrappers.ShadowRoot;
      var assert = scope.assert;
      var getTreeScope = scope.getTreeScope;
      var mixin = scope.mixin;
      var oneOf = scope.oneOf;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var unwrap = scope.unwrap;
      var wrap = scope.wrap;
      var ArraySplice = scope.ArraySplice;
      function updateWrapperUpAndSideways(wrapper) {
        wrapper.previousSibling_ = wrapper.previousSibling;
        wrapper.nextSibling_ = wrapper.nextSibling;
        wrapper.parentNode_ = wrapper.parentNode;
      }
      function updateWrapperDown(wrapper) {
        wrapper.firstChild_ = wrapper.firstChild;
        wrapper.lastChild_ = wrapper.lastChild;
      }
      function updateAllChildNodes(parentNodeWrapper) {
        assert(parentNodeWrapper instanceof Node);
        for (var childWrapper = parentNodeWrapper.firstChild; childWrapper; childWrapper = childWrapper.nextSibling) {
          updateWrapperUpAndSideways(childWrapper);
        }
        updateWrapperDown(parentNodeWrapper);
      }
      function insertBefore(parentNodeWrapper, newChildWrapper, refChildWrapper) {
        var parentNode = unwrap(parentNodeWrapper);
        var newChild = unwrap(newChildWrapper);
        var refChild = refChildWrapper ? unwrap(refChildWrapper) : null;
        remove(newChildWrapper);
        updateWrapperUpAndSideways(newChildWrapper);
        if (!refChildWrapper) {
          parentNodeWrapper.lastChild_ = parentNodeWrapper.lastChild;
          if (parentNodeWrapper.lastChild === parentNodeWrapper.firstChild) parentNodeWrapper.firstChild_ = parentNodeWrapper.firstChild;
          var lastChildWrapper = wrap(parentNode.lastChild);
          if (lastChildWrapper) lastChildWrapper.nextSibling_ = lastChildWrapper.nextSibling;
        } else {
          if (parentNodeWrapper.firstChild === refChildWrapper) parentNodeWrapper.firstChild_ = refChildWrapper;
          refChildWrapper.previousSibling_ = refChildWrapper.previousSibling;
        }
        scope.originalInsertBefore.call(parentNode, newChild, refChild);
      }
      function remove(nodeWrapper) {
        var node = unwrap(nodeWrapper);
        var parentNode = node.parentNode;
        if (!parentNode) return;
        var parentNodeWrapper = wrap(parentNode);
        updateWrapperUpAndSideways(nodeWrapper);
        if (nodeWrapper.previousSibling) nodeWrapper.previousSibling.nextSibling_ = nodeWrapper;
        if (nodeWrapper.nextSibling) nodeWrapper.nextSibling.previousSibling_ = nodeWrapper;
        if (parentNodeWrapper.lastChild === nodeWrapper) parentNodeWrapper.lastChild_ = nodeWrapper;
        if (parentNodeWrapper.firstChild === nodeWrapper) parentNodeWrapper.firstChild_ = nodeWrapper;
        scope.originalRemoveChild.call(parentNode, node);
      }
      var distributedNodesTable = new WeakMap();
      var destinationInsertionPointsTable = new WeakMap();
      var rendererForHostTable = new WeakMap();
      function resetDistributedNodes(insertionPoint) {
        distributedNodesTable.set(insertionPoint, []);
      }
      function getDistributedNodes(insertionPoint) {
        var rv = distributedNodesTable.get(insertionPoint);
        if (!rv) distributedNodesTable.set(insertionPoint, rv = []);
        return rv;
      }
      function getChildNodesSnapshot(node) {
        var result = [], i = 0;
        for (var child = node.firstChild; child; child = child.nextSibling) {
          result[i++] = child;
        }
        return result;
      }
      var request = oneOf(window, [ "requestAnimationFrame", "mozRequestAnimationFrame", "webkitRequestAnimationFrame", "setTimeout" ]);
      var pendingDirtyRenderers = [];
      var renderTimer;
      function renderAllPending() {
        for (var i = 0; i < pendingDirtyRenderers.length; i++) {
          var renderer = pendingDirtyRenderers[i];
          var parentRenderer = renderer.parentRenderer;
          if (parentRenderer && parentRenderer.dirty) continue;
          renderer.render();
        }
        pendingDirtyRenderers = [];
      }
      function handleRequestAnimationFrame() {
        renderTimer = null;
        renderAllPending();
      }
      function getRendererForHost(host) {
        var renderer = rendererForHostTable.get(host);
        if (!renderer) {
          renderer = new ShadowRenderer(host);
          rendererForHostTable.set(host, renderer);
        }
        return renderer;
      }
      function getShadowRootAncestor(node) {
        var root = getTreeScope(node).root;
        if (root instanceof ShadowRoot) return root;
        return null;
      }
      function getRendererForShadowRoot(shadowRoot) {
        return getRendererForHost(shadowRoot.host);
      }
      var spliceDiff = new ArraySplice();
      spliceDiff.equals = function(renderNode, rawNode) {
        return unwrap(renderNode.node) === rawNode;
      };
      function RenderNode(node) {
        this.skip = false;
        this.node = node;
        this.childNodes = [];
      }
      RenderNode.prototype = {
        append: function(node) {
          var rv = new RenderNode(node);
          this.childNodes.push(rv);
          return rv;
        },
        sync: function(opt_added) {
          if (this.skip) return;
          var nodeWrapper = this.node;
          var newChildren = this.childNodes;
          var oldChildren = getChildNodesSnapshot(unwrap(nodeWrapper));
          var added = opt_added || new WeakMap();
          var splices = spliceDiff.calculateSplices(newChildren, oldChildren);
          var newIndex = 0, oldIndex = 0;
          var lastIndex = 0;
          for (var i = 0; i < splices.length; i++) {
            var splice = splices[i];
            for (;lastIndex < splice.index; lastIndex++) {
              oldIndex++;
              newChildren[newIndex++].sync(added);
            }
            var removedCount = splice.removed.length;
            for (var j = 0; j < removedCount; j++) {
              var wrapper = wrap(oldChildren[oldIndex++]);
              if (!added.get(wrapper)) remove(wrapper);
            }
            var addedCount = splice.addedCount;
            var refNode = oldChildren[oldIndex] && wrap(oldChildren[oldIndex]);
            for (var j = 0; j < addedCount; j++) {
              var newChildRenderNode = newChildren[newIndex++];
              var newChildWrapper = newChildRenderNode.node;
              insertBefore(nodeWrapper, newChildWrapper, refNode);
              added.set(newChildWrapper, true);
              newChildRenderNode.sync(added);
            }
            lastIndex += addedCount;
          }
          for (var i = lastIndex; i < newChildren.length; i++) {
            newChildren[i].sync(added);
          }
        }
      };
      function ShadowRenderer(host) {
        this.host = host;
        this.dirty = false;
        this.invalidateAttributes();
        this.associateNode(host);
      }
      ShadowRenderer.prototype = {
        render: function(opt_renderNode) {
          if (!this.dirty) return;
          this.invalidateAttributes();
          var host = this.host;
          this.distribution(host);
          var renderNode = opt_renderNode || new RenderNode(host);
          this.buildRenderTree(renderNode, host);
          var topMostRenderer = !opt_renderNode;
          if (topMostRenderer) renderNode.sync();
          this.dirty = false;
        },
        get parentRenderer() {
          return getTreeScope(this.host).renderer;
        },
        invalidate: function() {
          if (!this.dirty) {
            this.dirty = true;
            var parentRenderer = this.parentRenderer;
            if (parentRenderer) parentRenderer.invalidate();
            pendingDirtyRenderers.push(this);
            if (renderTimer) return;
            renderTimer = window[request](handleRequestAnimationFrame, 0);
          }
        },
        distribution: function(root) {
          this.resetAllSubtrees(root);
          this.distributionResolution(root);
        },
        resetAll: function(node) {
          if (isInsertionPoint(node)) resetDistributedNodes(node); else resetDestinationInsertionPoints(node);
          this.resetAllSubtrees(node);
        },
        resetAllSubtrees: function(node) {
          for (var child = node.firstChild; child; child = child.nextSibling) {
            this.resetAll(child);
          }
          if (node.shadowRoot) this.resetAll(node.shadowRoot);
          if (node.olderShadowRoot) this.resetAll(node.olderShadowRoot);
        },
        distributionResolution: function(node) {
          if (isShadowHost(node)) {
            var shadowHost = node;
            var pool = poolPopulation(shadowHost);
            var shadowTrees = getShadowTrees(shadowHost);
            for (var i = 0; i < shadowTrees.length; i++) {
              this.poolDistribution(shadowTrees[i], pool);
            }
            for (var i = shadowTrees.length - 1; i >= 0; i--) {
              var shadowTree = shadowTrees[i];
              var shadow = getShadowInsertionPoint(shadowTree);
              if (shadow) {
                var olderShadowRoot = shadowTree.olderShadowRoot;
                if (olderShadowRoot) {
                  pool = poolPopulation(olderShadowRoot);
                }
                for (var j = 0; j < pool.length; j++) {
                  destributeNodeInto(pool[j], shadow);
                }
              }
              this.distributionResolution(shadowTree);
            }
          }
          for (var child = node.firstChild; child; child = child.nextSibling) {
            this.distributionResolution(child);
          }
        },
        poolDistribution: function(node, pool) {
          if (node instanceof HTMLShadowElement) return;
          if (node instanceof HTMLContentElement) {
            var content = node;
            this.updateDependentAttributes(content.getAttribute("select"));
            var anyDistributed = false;
            for (var i = 0; i < pool.length; i++) {
              var node = pool[i];
              if (!node) continue;
              if (matches(node, content)) {
                destributeNodeInto(node, content);
                pool[i] = undefined;
                anyDistributed = true;
              }
            }
            if (!anyDistributed) {
              for (var child = content.firstChild; child; child = child.nextSibling) {
                destributeNodeInto(child, content);
              }
            }
            return;
          }
          for (var child = node.firstChild; child; child = child.nextSibling) {
            this.poolDistribution(child, pool);
          }
        },
        buildRenderTree: function(renderNode, node) {
          var children = this.compose(node);
          for (var i = 0; i < children.length; i++) {
            var child = children[i];
            var childRenderNode = renderNode.append(child);
            this.buildRenderTree(childRenderNode, child);
          }
          if (isShadowHost(node)) {
            var renderer = getRendererForHost(node);
            renderer.dirty = false;
          }
        },
        compose: function(node) {
          var children = [];
          var p = node.shadowRoot || node;
          for (var child = p.firstChild; child; child = child.nextSibling) {
            if (isInsertionPoint(child)) {
              this.associateNode(p);
              var distributedNodes = getDistributedNodes(child);
              for (var j = 0; j < distributedNodes.length; j++) {
                var distributedNode = distributedNodes[j];
                if (isFinalDestination(child, distributedNode)) children.push(distributedNode);
              }
            } else {
              children.push(child);
            }
          }
          return children;
        },
        invalidateAttributes: function() {
          this.attributes = Object.create(null);
        },
        updateDependentAttributes: function(selector) {
          if (!selector) return;
          var attributes = this.attributes;
          if (/\.\w+/.test(selector)) attributes["class"] = true;
          if (/#\w+/.test(selector)) attributes["id"] = true;
          selector.replace(/\[\s*([^\s=\|~\]]+)/g, function(_, name) {
            attributes[name] = true;
          });
        },
        dependsOnAttribute: function(name) {
          return this.attributes[name];
        },
        associateNode: function(node) {
          unsafeUnwrap(node).polymerShadowRenderer_ = this;
        }
      };
      function poolPopulation(node) {
        var pool = [];
        for (var child = node.firstChild; child; child = child.nextSibling) {
          if (isInsertionPoint(child)) {
            pool.push.apply(pool, getDistributedNodes(child));
          } else {
            pool.push(child);
          }
        }
        return pool;
      }
      function getShadowInsertionPoint(node) {
        if (node instanceof HTMLShadowElement) return node;
        if (node instanceof HTMLContentElement) return null;
        for (var child = node.firstChild; child; child = child.nextSibling) {
          var res = getShadowInsertionPoint(child);
          if (res) return res;
        }
        return null;
      }
      function destributeNodeInto(child, insertionPoint) {
        getDistributedNodes(insertionPoint).push(child);
        var points = destinationInsertionPointsTable.get(child);
        if (!points) destinationInsertionPointsTable.set(child, [ insertionPoint ]); else points.push(insertionPoint);
      }
      function getDestinationInsertionPoints(node) {
        return destinationInsertionPointsTable.get(node);
      }
      function resetDestinationInsertionPoints(node) {
        destinationInsertionPointsTable.set(node, undefined);
      }
      var selectorStartCharRe = /^(:not\()?[*.#[a-zA-Z_|]/;
      function matches(node, contentElement) {
        var select = contentElement.getAttribute("select");
        if (!select) return true;
        select = select.trim();
        if (!select) return true;
        if (!(node instanceof Element)) return false;
        if (!selectorStartCharRe.test(select)) return false;
        try {
          return node.matches(select);
        } catch (ex) {
          return false;
        }
      }
      function isFinalDestination(insertionPoint, node) {
        var points = getDestinationInsertionPoints(node);
        return points && points[points.length - 1] === insertionPoint;
      }
      function isInsertionPoint(node) {
        return node instanceof HTMLContentElement || node instanceof HTMLShadowElement;
      }
      function isShadowHost(shadowHost) {
        return shadowHost.shadowRoot;
      }
      function getShadowTrees(host) {
        var trees = [];
        for (var tree = host.shadowRoot; tree; tree = tree.olderShadowRoot) {
          trees.push(tree);
        }
        return trees;
      }
      function render(host) {
        new ShadowRenderer(host).render();
      }
      Node.prototype.invalidateShadowRenderer = function(force) {
        var renderer = unsafeUnwrap(this).polymerShadowRenderer_;
        if (renderer) {
          renderer.invalidate();
          return true;
        }
        return false;
      };
      HTMLContentElement.prototype.getDistributedNodes = HTMLShadowElement.prototype.getDistributedNodes = function() {
        renderAllPending();
        return getDistributedNodes(this);
      };
      Element.prototype.getDestinationInsertionPoints = function() {
        renderAllPending();
        return getDestinationInsertionPoints(this) || [];
      };
      HTMLContentElement.prototype.nodeIsInserted_ = HTMLShadowElement.prototype.nodeIsInserted_ = function() {
        this.invalidateShadowRenderer();
        var shadowRoot = getShadowRootAncestor(this);
        var renderer;
        if (shadowRoot) renderer = getRendererForShadowRoot(shadowRoot);
        unsafeUnwrap(this).polymerShadowRenderer_ = renderer;
        if (renderer) renderer.invalidate();
      };
      scope.getRendererForHost = getRendererForHost;
      scope.getShadowTrees = getShadowTrees;
      scope.renderAllPending = renderAllPending;
      scope.getDestinationInsertionPoints = getDestinationInsertionPoints;
      scope.visual = {
        insertBefore: insertBefore,
        remove: remove
      };
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var HTMLElement = scope.wrappers.HTMLElement;
      var assert = scope.assert;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var unwrap = scope.unwrap;
      var wrap = scope.wrap;
      var elementsWithFormProperty = [ "HTMLButtonElement", "HTMLFieldSetElement", "HTMLInputElement", "HTMLKeygenElement", "HTMLLabelElement", "HTMLLegendElement", "HTMLObjectElement", "HTMLOutputElement", "HTMLTextAreaElement" ];
      function createWrapperConstructor(name) {
        if (!window[name]) return;
        assert(!scope.wrappers[name]);
        var GeneratedWrapper = function(node) {
          HTMLElement.call(this, node);
        };
        GeneratedWrapper.prototype = Object.create(HTMLElement.prototype);
        mixin(GeneratedWrapper.prototype, {
          get form() {
            return wrap(unwrap(this).form);
          }
        });
        registerWrapper(window[name], GeneratedWrapper, document.createElement(name.slice(4, -7)));
        scope.wrappers[name] = GeneratedWrapper;
      }
      elementsWithFormProperty.forEach(createWrapperConstructor);
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var registerWrapper = scope.registerWrapper;
      var setWrapper = scope.setWrapper;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var unwrap = scope.unwrap;
      var unwrapIfNeeded = scope.unwrapIfNeeded;
      var wrap = scope.wrap;
      var OriginalSelection = window.Selection;
      function Selection(impl) {
        setWrapper(impl, this);
      }
      Selection.prototype = {
        get anchorNode() {
          return wrap(unsafeUnwrap(this).anchorNode);
        },
        get focusNode() {
          return wrap(unsafeUnwrap(this).focusNode);
        },
        addRange: function(range) {
          unsafeUnwrap(this).addRange(unwrapIfNeeded(range));
        },
        collapse: function(node, index) {
          unsafeUnwrap(this).collapse(unwrapIfNeeded(node), index);
        },
        containsNode: function(node, allowPartial) {
          return unsafeUnwrap(this).containsNode(unwrapIfNeeded(node), allowPartial);
        },
        getRangeAt: function(index) {
          return wrap(unsafeUnwrap(this).getRangeAt(index));
        },
        removeRange: function(range) {
          unsafeUnwrap(this).removeRange(unwrap(range));
        },
        selectAllChildren: function(node) {
c5169e0e   Renato De Donato   a new hope
3977
          unsafeUnwrap(this).selectAllChildren(unwrapIfNeeded(node));
73bcce88   luigser   COMPONENTS
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
        },
        toString: function() {
          return unsafeUnwrap(this).toString();
        }
      };
      if (OriginalSelection.prototype.extend) {
        Selection.prototype.extend = function(node, offset) {
          unsafeUnwrap(this).extend(unwrapIfNeeded(node), offset);
        };
      }
      registerWrapper(window.Selection, Selection, window.getSelection());
      scope.wrappers.Selection = Selection;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var registerWrapper = scope.registerWrapper;
      var setWrapper = scope.setWrapper;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var unwrapIfNeeded = scope.unwrapIfNeeded;
      var wrap = scope.wrap;
      var OriginalTreeWalker = window.TreeWalker;
      function TreeWalker(impl) {
        setWrapper(impl, this);
      }
      TreeWalker.prototype = {
        get root() {
          return wrap(unsafeUnwrap(this).root);
        },
        get currentNode() {
          return wrap(unsafeUnwrap(this).currentNode);
        },
        set currentNode(node) {
          unsafeUnwrap(this).currentNode = unwrapIfNeeded(node);
        },
        get filter() {
          return unsafeUnwrap(this).filter;
        },
        parentNode: function() {
          return wrap(unsafeUnwrap(this).parentNode());
        },
        firstChild: function() {
          return wrap(unsafeUnwrap(this).firstChild());
        },
        lastChild: function() {
          return wrap(unsafeUnwrap(this).lastChild());
        },
        previousSibling: function() {
          return wrap(unsafeUnwrap(this).previousSibling());
        },
        previousNode: function() {
          return wrap(unsafeUnwrap(this).previousNode());
        },
        nextNode: function() {
          return wrap(unsafeUnwrap(this).nextNode());
        }
      };
      registerWrapper(OriginalTreeWalker, TreeWalker);
      scope.wrappers.TreeWalker = TreeWalker;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var GetElementsByInterface = scope.GetElementsByInterface;
      var Node = scope.wrappers.Node;
      var ParentNodeInterface = scope.ParentNodeInterface;
      var NonElementParentNodeInterface = scope.NonElementParentNodeInterface;
      var Selection = scope.wrappers.Selection;
      var SelectorsInterface = scope.SelectorsInterface;
      var ShadowRoot = scope.wrappers.ShadowRoot;
      var TreeScope = scope.TreeScope;
      var cloneNode = scope.cloneNode;
73bcce88   luigser   COMPONENTS
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
      var defineWrapGetter = scope.defineWrapGetter;
      var elementFromPoint = scope.elementFromPoint;
      var forwardMethodsToWrapper = scope.forwardMethodsToWrapper;
      var matchesNames = scope.matchesNames;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var renderAllPending = scope.renderAllPending;
      var rewrap = scope.rewrap;
      var setWrapper = scope.setWrapper;
      var unsafeUnwrap = scope.unsafeUnwrap;
      var unwrap = scope.unwrap;
      var wrap = scope.wrap;
      var wrapEventTargetMethods = scope.wrapEventTargetMethods;
      var wrapNodeList = scope.wrapNodeList;
      var implementationTable = new WeakMap();
      function Document(node) {
        Node.call(this, node);
        this.treeScope_ = new TreeScope(this, null);
      }
      Document.prototype = Object.create(Node.prototype);
      defineWrapGetter(Document, "documentElement");
      defineWrapGetter(Document, "body");
      defineWrapGetter(Document, "head");
73bcce88   luigser   COMPONENTS
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
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
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
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
4470
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
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
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
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
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
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
      function wrapMethod(name) {
        var original = document[name];
        Document.prototype[name] = function() {
          return wrap(original.apply(unsafeUnwrap(this), arguments));
        };
      }
      [ "createComment", "createDocumentFragment", "createElement", "createElementNS", "createEvent", "createEventNS", "createRange", "createTextNode" ].forEach(wrapMethod);
      var originalAdoptNode = document.adoptNode;
      function adoptNodeNoRemove(node, doc) {
        originalAdoptNode.call(unsafeUnwrap(doc), unwrap(node));
        adoptSubtree(node, doc);
      }
      function adoptSubtree(node, doc) {
        if (node.shadowRoot) doc.adoptNode(node.shadowRoot);
        if (node instanceof ShadowRoot) adoptOlderShadowRoots(node, doc);
        for (var child = node.firstChild; child; child = child.nextSibling) {
          adoptSubtree(child, doc);
        }
      }
      function adoptOlderShadowRoots(shadowRoot, doc) {
        var oldShadowRoot = shadowRoot.olderShadowRoot;
        if (oldShadowRoot) doc.adoptNode(oldShadowRoot);
      }
      var originalGetSelection = document.getSelection;
      mixin(Document.prototype, {
        adoptNode: function(node) {
          if (node.parentNode) node.parentNode.removeChild(node);
          adoptNodeNoRemove(node, this);
          return node;
        },
        elementFromPoint: function(x, y) {
          return elementFromPoint(this, this, x, y);
        },
        importNode: function(node, deep) {
          return cloneNode(node, deep, unsafeUnwrap(this));
        },
        getSelection: function() {
          renderAllPending();
          return new Selection(originalGetSelection.call(unwrap(this)));
        },
        getElementsByName: function(name) {
          return SelectorsInterface.querySelectorAll.call(this, "[name=" + JSON.stringify(String(name)) + "]");
        }
      });
      var originalCreateTreeWalker = document.createTreeWalker;
      var TreeWalkerWrapper = scope.wrappers.TreeWalker;
      Document.prototype.createTreeWalker = function(root, whatToShow, filter, expandEntityReferences) {
        var newFilter = null;
        if (filter) {
          if (filter.acceptNode && typeof filter.acceptNode === "function") {
            newFilter = {
              acceptNode: function(node) {
                return filter.acceptNode(wrap(node));
              }
            };
          } else if (typeof filter === "function") {
            newFilter = function(node) {
              return filter(wrap(node));
            };
          }
        }
        return new TreeWalkerWrapper(originalCreateTreeWalker.call(unwrap(this), unwrap(root), whatToShow, newFilter, expandEntityReferences));
      };
      if (document.registerElement) {
        var originalRegisterElement = document.registerElement;
        Document.prototype.registerElement = function(tagName, object) {
          var prototype, extendsOption;
          if (object !== undefined) {
            prototype = object.prototype;
            extendsOption = object.extends;
          }
          if (!prototype) prototype = Object.create(HTMLElement.prototype);
          if (scope.nativePrototypeTable.get(prototype)) {
            throw new Error("NotSupportedError");
          }
          var proto = Object.getPrototypeOf(prototype);
          var nativePrototype;
          var prototypes = [];
          while (proto) {
            nativePrototype = scope.nativePrototypeTable.get(proto);
            if (nativePrototype) break;
            prototypes.push(proto);
            proto = Object.getPrototypeOf(proto);
          }
          if (!nativePrototype) {
            throw new Error("NotSupportedError");
          }
          var newPrototype = Object.create(nativePrototype);
          for (var i = prototypes.length - 1; i >= 0; i--) {
            newPrototype = Object.create(newPrototype);
          }
          [ "createdCallback", "attachedCallback", "detachedCallback", "attributeChangedCallback" ].forEach(function(name) {
            var f = prototype[name];
            if (!f) return;
            newPrototype[name] = function() {
              if (!(wrap(this) instanceof CustomElementConstructor)) {
                rewrap(this);
              }
              f.apply(wrap(this), arguments);
            };
          });
          var p = {
            prototype: newPrototype
          };
          if (extendsOption) p.extends = extendsOption;
          function CustomElementConstructor(node) {
            if (!node) {
              if (extendsOption) {
                return document.createElement(extendsOption, tagName);
              } else {
                return document.createElement(tagName);
              }
            }
            setWrapper(node, this);
          }
          CustomElementConstructor.prototype = prototype;
          CustomElementConstructor.prototype.constructor = CustomElementConstructor;
          scope.constructorTable.set(newPrototype, CustomElementConstructor);
          scope.nativePrototypeTable.set(prototype, newPrototype);
          var nativeConstructor = originalRegisterElement.call(unwrap(this), tagName, p);
          return CustomElementConstructor;
        };
        forwardMethodsToWrapper([ window.HTMLDocument || window.Document ], [ "registerElement" ]);
      }
      forwardMethodsToWrapper([ window.HTMLBodyElement, window.HTMLDocument || window.Document, window.HTMLHeadElement, window.HTMLHtmlElement ], [ "appendChild", "compareDocumentPosition", "contains", "getElementsByClassName", "getElementsByTagName", "getElementsByTagNameNS", "insertBefore", "querySelector", "querySelectorAll", "removeChild", "replaceChild" ]);
      forwardMethodsToWrapper([ window.HTMLBodyElement, window.HTMLHeadElement, window.HTMLHtmlElement ], matchesNames);
      forwardMethodsToWrapper([ window.HTMLDocument || window.Document ], [ "adoptNode", "importNode", "contains", "createComment", "createDocumentFragment", "createElement", "createElementNS", "createEvent", "createEventNS", "createRange", "createTextNode", "createTreeWalker", "elementFromPoint", "getElementById", "getElementsByName", "getSelection" ]);
      mixin(Document.prototype, GetElementsByInterface);
      mixin(Document.prototype, ParentNodeInterface);
      mixin(Document.prototype, SelectorsInterface);
      mixin(Document.prototype, NonElementParentNodeInterface);
      mixin(Document.prototype, {
        get implementation() {
          var implementation = implementationTable.get(this);
          if (implementation) return implementation;
          implementation = new DOMImplementation(unwrap(this).implementation);
          implementationTable.set(this, implementation);
          return implementation;
        },
        get defaultView() {
          return wrap(unwrap(this).defaultView);
        }
      });
      registerWrapper(window.Document, Document, document.implementation.createHTMLDocument(""));
      if (window.HTMLDocument) registerWrapper(window.HTMLDocument, Document);
      wrapEventTargetMethods([ window.HTMLBodyElement, window.HTMLDocument || window.Document, window.HTMLHeadElement ]);
      function DOMImplementation(impl) {
        setWrapper(impl, this);
      }
      var originalCreateDocument = document.implementation.createDocument;
      DOMImplementation.prototype.createDocument = function() {
        arguments[2] = unwrap(arguments[2]);
        return wrap(originalCreateDocument.apply(unsafeUnwrap(this), arguments));
      };
      function wrapImplMethod(constructor, name) {
        var original = document.implementation[name];
        constructor.prototype[name] = function() {
          return wrap(original.apply(unsafeUnwrap(this), arguments));
        };
      }
      function forwardImplMethod(constructor, name) {
        var original = document.implementation[name];
        constructor.prototype[name] = function() {
          return original.apply(unsafeUnwrap(this), arguments);
        };
      }
      wrapImplMethod(DOMImplementation, "createDocumentType");
      wrapImplMethod(DOMImplementation, "createHTMLDocument");
      forwardImplMethod(DOMImplementation, "hasFeature");
      registerWrapper(window.DOMImplementation, DOMImplementation);
      forwardMethodsToWrapper([ window.DOMImplementation ], [ "createDocument", "createDocumentType", "createHTMLDocument", "hasFeature" ]);
      scope.adoptNodeNoRemove = adoptNodeNoRemove;
      scope.wrappers.DOMImplementation = DOMImplementation;
      scope.wrappers.Document = Document;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var EventTarget = scope.wrappers.EventTarget;
      var Selection = scope.wrappers.Selection;
      var mixin = scope.mixin;
      var registerWrapper = scope.registerWrapper;
      var renderAllPending = scope.renderAllPending;
      var unwrap = scope.unwrap;
      var unwrapIfNeeded = scope.unwrapIfNeeded;
      var wrap = scope.wrap;
      var OriginalWindow = window.Window;
      var originalGetComputedStyle = window.getComputedStyle;
      var originalGetDefaultComputedStyle = window.getDefaultComputedStyle;
      var originalGetSelection = window.getSelection;
      function Window(impl) {
        EventTarget.call(this, impl);
      }
      Window.prototype = Object.create(EventTarget.prototype);
      OriginalWindow.prototype.getComputedStyle = function(el, pseudo) {
        return wrap(this || window).getComputedStyle(unwrapIfNeeded(el), pseudo);
      };
      if (originalGetDefaultComputedStyle) {
        OriginalWindow.prototype.getDefaultComputedStyle = function(el, pseudo) {
          return wrap(this || window).getDefaultComputedStyle(unwrapIfNeeded(el), pseudo);
        };
      }
      OriginalWindow.prototype.getSelection = function() {
        return wrap(this || window).getSelection();
      };
      delete window.getComputedStyle;
      delete window.getDefaultComputedStyle;
      delete window.getSelection;
      [ "addEventListener", "removeEventListener", "dispatchEvent" ].forEach(function(name) {
        OriginalWindow.prototype[name] = function() {
          var w = wrap(this || window);
          return w[name].apply(w, arguments);
        };
        delete window[name];
      });
      mixin(Window.prototype, {
        getComputedStyle: function(el, pseudo) {
          renderAllPending();
          return originalGetComputedStyle.call(unwrap(this), unwrapIfNeeded(el), pseudo);
        },
        getSelection: function() {
          renderAllPending();
          return new Selection(originalGetSelection.call(unwrap(this)));
        },
        get document() {
          return wrap(unwrap(this).document);
        }
      });
      if (originalGetDefaultComputedStyle) {
        Window.prototype.getDefaultComputedStyle = function(el, pseudo) {
          renderAllPending();
          return originalGetDefaultComputedStyle.call(unwrap(this), unwrapIfNeeded(el), pseudo);
        };
      }
      registerWrapper(OriginalWindow, Window, window);
      scope.wrappers.Window = Window;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var unwrap = scope.unwrap;
      var OriginalDataTransfer = window.DataTransfer || window.Clipboard;
      var OriginalDataTransferSetDragImage = OriginalDataTransfer.prototype.setDragImage;
      if (OriginalDataTransferSetDragImage) {
        OriginalDataTransfer.prototype.setDragImage = function(image, x, y) {
          OriginalDataTransferSetDragImage.call(this, unwrap(image), x, y);
        };
      }
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var registerWrapper = scope.registerWrapper;
      var setWrapper = scope.setWrapper;
      var unwrap = scope.unwrap;
      var OriginalFormData = window.FormData;
      if (!OriginalFormData) return;
      function FormData(formElement) {
        var impl;
        if (formElement instanceof OriginalFormData) {
          impl = formElement;
        } else {
          impl = new OriginalFormData(formElement && unwrap(formElement));
        }
        setWrapper(impl, this);
      }
      registerWrapper(OriginalFormData, FormData, new OriginalFormData());
      scope.wrappers.FormData = FormData;
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var unwrapIfNeeded = scope.unwrapIfNeeded;
      var originalSend = XMLHttpRequest.prototype.send;
      XMLHttpRequest.prototype.send = function(obj) {
        return originalSend.call(this, unwrapIfNeeded(obj));
      };
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      "use strict";
      var isWrapperFor = scope.isWrapperFor;
      var elements = {
        a: "HTMLAnchorElement",
        area: "HTMLAreaElement",
        audio: "HTMLAudioElement",
        base: "HTMLBaseElement",
        body: "HTMLBodyElement",
        br: "HTMLBRElement",
        button: "HTMLButtonElement",
        canvas: "HTMLCanvasElement",
        caption: "HTMLTableCaptionElement",
        col: "HTMLTableColElement",
        content: "HTMLContentElement",
        data: "HTMLDataElement",
        datalist: "HTMLDataListElement",
        del: "HTMLModElement",
        dir: "HTMLDirectoryElement",
        div: "HTMLDivElement",
        dl: "HTMLDListElement",
        embed: "HTMLEmbedElement",
        fieldset: "HTMLFieldSetElement",
        font: "HTMLFontElement",
        form: "HTMLFormElement",
        frame: "HTMLFrameElement",
        frameset: "HTMLFrameSetElement",
        h1: "HTMLHeadingElement",
        head: "HTMLHeadElement",
        hr: "HTMLHRElement",
        html: "HTMLHtmlElement",
        iframe: "HTMLIFrameElement",
        img: "HTMLImageElement",
        input: "HTMLInputElement",
        keygen: "HTMLKeygenElement",
        label: "HTMLLabelElement",
        legend: "HTMLLegendElement",
        li: "HTMLLIElement",
        link: "HTMLLinkElement",
        map: "HTMLMapElement",
        marquee: "HTMLMarqueeElement",
        menu: "HTMLMenuElement",
        menuitem: "HTMLMenuItemElement",
        meta: "HTMLMetaElement",
        meter: "HTMLMeterElement",
        object: "HTMLObjectElement",
        ol: "HTMLOListElement",
        optgroup: "HTMLOptGroupElement",
        option: "HTMLOptionElement",
        output: "HTMLOutputElement",
        p: "HTMLParagraphElement",
        param: "HTMLParamElement",
        pre: "HTMLPreElement",
        progress: "HTMLProgressElement",
        q: "HTMLQuoteElement",
        script: "HTMLScriptElement",
        select: "HTMLSelectElement",
        shadow: "HTMLShadowElement",
        source: "HTMLSourceElement",
        span: "HTMLSpanElement",
        style: "HTMLStyleElement",
        table: "HTMLTableElement",
        tbody: "HTMLTableSectionElement",
        template: "HTMLTemplateElement",
        textarea: "HTMLTextAreaElement",
        thead: "HTMLTableSectionElement",
        time: "HTMLTimeElement",
        title: "HTMLTitleElement",
        tr: "HTMLTableRowElement",
        track: "HTMLTrackElement",
        ul: "HTMLUListElement",
        video: "HTMLVideoElement"
      };
      function overrideConstructor(tagName) {
        var nativeConstructorName = elements[tagName];
        var nativeConstructor = window[nativeConstructorName];
        if (!nativeConstructor) return;
        var element = document.createElement(tagName);
        var wrapperConstructor = element.constructor;
        window[nativeConstructorName] = wrapperConstructor;
      }
      Object.keys(elements).forEach(overrideConstructor);
      Object.getOwnPropertyNames(scope.wrappers).forEach(function(name) {
        window[name] = scope.wrappers[name];
      });
    })(window.ShadowDOMPolyfill);
    (function(scope) {
      var ShadowCSS = {
        strictStyling: false,
        registry: {},
        shimStyling: function(root, name, extendsName) {
          var scopeStyles = this.prepareRoot(root, name, extendsName);
          var typeExtension = this.isTypeExtension(extendsName);
          var scopeSelector = this.makeScopeSelector(name, typeExtension);
          var cssText = stylesToCssText(scopeStyles, true);
          cssText = this.scopeCssText(cssText, scopeSelector);
          if (root) {
            root.shimmedStyle = cssText;
          }
          this.addCssToDocument(cssText, name);
        },
        shimStyle: function(style, selector) {
          return this.shimCssText(style.textContent, selector);
        },
        shimCssText: function(cssText, selector) {
          cssText = this.insertDirectives(cssText);
          return this.scopeCssText(cssText, selector);
        },
        makeScopeSelector: function(name, typeExtension) {
          if (name) {
            return typeExtension ? "[is=" + name + "]" : name;
          }
          return "";
        },
        isTypeExtension: function(extendsName) {
          return extendsName && extendsName.indexOf("-") < 0;
        },
        prepareRoot: function(root, name, extendsName) {
          var def = this.registerRoot(root, name, extendsName);
          this.replaceTextInStyles(def.rootStyles, this.insertDirectives);
          this.removeStyles(root, def.rootStyles);
          if (this.strictStyling) {
            this.applyScopeToContent(root, name);
          }
          return def.scopeStyles;
        },
        removeStyles: function(root, styles) {
          for (var i = 0, l = styles.length, s; i < l && (s = styles[i]); i++) {
            s.parentNode.removeChild(s);
          }
        },
        registerRoot: function(root, name, extendsName) {
          var def = this.registry[name] = {
            root: root,
            name: name,
            extendsName: extendsName
          };
          var styles = this.findStyles(root);
          def.rootStyles = styles;
          def.scopeStyles = def.rootStyles;
          var extendee = this.registry[def.extendsName];
          if (extendee) {
            def.scopeStyles = extendee.scopeStyles.concat(def.scopeStyles);
          }
          return def;
        },
        findStyles: function(root) {
          if (!root) {
            return [];
          }
          var styles = root.querySelectorAll("style");
          return Array.prototype.filter.call(styles, function(s) {
            return !s.hasAttribute(NO_SHIM_ATTRIBUTE);
          });
        },
        applyScopeToContent: function(root, name) {
          if (root) {
            Array.prototype.forEach.call(root.querySelectorAll("*"), function(node) {
              node.setAttribute(name, "");
            });
            Array.prototype.forEach.call(root.querySelectorAll("template"), function(template) {
              this.applyScopeToContent(template.content, name);
            }, this);
          }
        },
        insertDirectives: function(cssText) {
          cssText = this.insertPolyfillDirectivesInCssText(cssText);
          return this.insertPolyfillRulesInCssText(cssText);
        },
        insertPolyfillDirectivesInCssText: function(cssText) {
          cssText = cssText.replace(cssCommentNextSelectorRe, function(match, p1) {
            return p1.slice(0, -2) + "{";
          });
          return cssText.replace(cssContentNextSelectorRe, function(match, p1) {
            return p1 + " {";
          });
        },
        insertPolyfillRulesInCssText: function(cssText) {
          cssText = cssText.replace(cssCommentRuleRe, function(match, p1) {
            return p1.slice(0, -1);
          });
          return cssText.replace(cssContentRuleRe, function(match, p1, p2, p3) {
            var rule = match.replace(p1, "").replace(p2, "");
            return p3 + rule;
          });
        },
        scopeCssText: function(cssText, scopeSelector) {
          var unscoped = this.extractUnscopedRulesFromCssText(cssText);
          cssText = this.insertPolyfillHostInCssText(cssText);
          cssText = this.convertColonHost(cssText);
          cssText = this.convertColonHostContext(cssText);
          cssText = this.convertShadowDOMSelectors(cssText);
          if (scopeSelector) {
            var self = this, cssText;
            withCssRules(cssText, function(rules) {
              cssText = self.scopeRules(rules, scopeSelector);
            });
          }
          cssText = cssText + "\n" + unscoped;
          return cssText.trim();
        },
        extractUnscopedRulesFromCssText: function(cssText) {
          var r = "", m;
          while (m = cssCommentUnscopedRuleRe.exec(cssText)) {
            r += m[1].slice(0, -1) + "\n\n";
          }
          while (m = cssContentUnscopedRuleRe.exec(cssText)) {
            r += m[0].replace(m[2], "").replace(m[1], m[3]) + "\n\n";
          }
          return r;
        },
        convertColonHost: function(cssText) {
          return this.convertColonRule(cssText, cssColonHostRe, this.colonHostPartReplacer);
        },
        convertColonHostContext: function(cssText) {
          return this.convertColonRule(cssText, cssColonHostContextRe, this.colonHostContextPartReplacer);
        },
        convertColonRule: function(cssText, regExp, partReplacer) {
          return cssText.replace(regExp, function(m, p1, p2, p3) {
            p1 = polyfillHostNoCombinator;
            if (p2) {
              var parts = p2.split(","), r = [];
              for (var i = 0, l = parts.length, p; i < l && (p = parts[i]); i++) {
                p = p.trim();
                r.push(partReplacer(p1, p, p3));
              }
              return r.join(",");
            } else {
              return p1 + p3;
            }
          });
        },
        colonHostContextPartReplacer: function(host, part, suffix) {
          if (part.match(polyfillHost)) {
            return this.colonHostPartReplacer(host, part, suffix);
          } else {
            return host + part + suffix + ", " + part + " " + host + suffix;
          }
        },
        colonHostPartReplacer: function(host, part, suffix) {
          return host + part.replace(polyfillHost, "") + suffix;
        },
        convertShadowDOMSelectors: function(cssText) {
          for (var i = 0; i < shadowDOMSelectorsRe.length; i++) {
            cssText = cssText.replace(shadowDOMSelectorsRe[i], " ");
          }
          return cssText;
        },
        scopeRules: function(cssRules, scopeSelector) {
          var cssText = "";
          if (cssRules) {
            Array.prototype.forEach.call(cssRules, function(rule) {
              if (rule.selectorText && (rule.style && rule.style.cssText !== undefined)) {
                cssText += this.scopeSelector(rule.selectorText, scopeSelector, this.strictStyling) + " {\n	";
                cssText += this.propertiesFromRule(rule) + "\n}\n\n";
              } else if (rule.type === CSSRule.MEDIA_RULE) {
                cssText += "@media " + rule.media.mediaText + " {\n";
                cssText += this.scopeRules(rule.cssRules, scopeSelector);
                cssText += "\n}\n\n";
              } else {
                try {
                  if (rule.cssText) {
                    cssText += rule.cssText + "\n\n";
                  }
                } catch (x) {
                  if (rule.type === CSSRule.KEYFRAMES_RULE && rule.cssRules) {
                    cssText += this.ieSafeCssTextFromKeyFrameRule(rule);
                  }
                }
              }
            }, this);
          }
          return cssText;
        },
        ieSafeCssTextFromKeyFrameRule: function(rule) {
          var cssText = "@keyframes " + rule.name + " {";
          Array.prototype.forEach.call(rule.cssRules, function(rule) {
            cssText += " " + rule.keyText + " {" + rule.style.cssText + "}";
          });
          cssText += " }";
          return cssText;
        },
        scopeSelector: function(selector, scopeSelector, strict) {
          var r = [], parts = selector.split(",");
          parts.forEach(function(p) {
            p = p.trim();
            if (this.selectorNeedsScoping(p, scopeSelector)) {
              p = strict && !p.match(polyfillHostNoCombinator) ? this.applyStrictSelectorScope(p, scopeSelector) : this.applySelectorScope(p, scopeSelector);
            }
            r.push(p);
          }, this);
          return r.join(", ");
        },
        selectorNeedsScoping: function(selector, scopeSelector) {
          if (Array.isArray(scopeSelector)) {
            return true;
          }
          var re = this.makeScopeMatcher(scopeSelector);
          return !selector.match(re);
        },
        makeScopeMatcher: function(scopeSelector) {
          scopeSelector = scopeSelector.replace(/\[/g, "\\[").replace(/\]/g, "\\]");
          return new RegExp("^(" + scopeSelector + ")" + selectorReSuffix, "m");
        },
        applySelectorScope: function(selector, selectorScope) {
          return Array.isArray(selectorScope) ? this.applySelectorScopeList(selector, selectorScope) : this.applySimpleSelectorScope(selector, selectorScope);
        },
        applySelectorScopeList: function(selector, scopeSelectorList) {
          var r = [];
          for (var i = 0, s; s = scopeSelectorList[i]; i++) {
            r.push(this.applySimpleSelectorScope(selector, s));
          }
          return r.join(", ");
        },
        applySimpleSelectorScope: function(selector, scopeSelector) {
          if (selector.match(polyfillHostRe)) {
            selector = selector.replace(polyfillHostNoCombinator, scopeSelector);
            return selector.replace(polyfillHostRe, scopeSelector + " ");
          } else {
            return scopeSelector + " " + selector;
          }
        },
        applyStrictSelectorScope: function(selector, scopeSelector) {
          scopeSelector = scopeSelector.replace(/\[is=([^\]]*)\]/g, "$1");
          var splits = [ " ", ">", "+", "~" ], scoped = selector, attrName = "[" + scopeSelector + "]";
          splits.forEach(function(sep) {
            var parts = scoped.split(sep);
            scoped = parts.map(function(p) {
              var t = p.trim().replace(polyfillHostRe, "");
              if (t && splits.indexOf(t) < 0 && t.indexOf(attrName) < 0) {
                p = t.replace(/([^:]*)(:*)(.*)/, "$1" + attrName + "$2$3");
              }
              return p;
            }).join(sep);
          });
          return scoped;
        },
        insertPolyfillHostInCssText: function(selector) {
          return selector.replace(colonHostContextRe, polyfillHostContext).replace(colonHostRe, polyfillHost);
        },
        propertiesFromRule: function(rule) {
          var cssText = rule.style.cssText;
          if (rule.style.content && !rule.style.content.match(/['"]+|attr/)) {
            cssText = cssText.replace(/content:[^;]*;/g, "content: '" + rule.style.content + "';");
          }
          var style = rule.style;
          for (var i in style) {
            if (style[i] === "initial") {
              cssText += i + ": initial; ";
            }
          }
          return cssText;
        },
        replaceTextInStyles: function(styles, action) {
          if (styles && action) {
            if (!(styles instanceof Array)) {
              styles = [ styles ];
            }
            Array.prototype.forEach.call(styles, function(s) {
              s.textContent = action.call(this, s.textContent);
            }, this);
          }
        },
        addCssToDocument: function(cssText, name) {
          if (cssText.match("@import")) {
            addOwnSheet(cssText, name);
          } else {
            addCssToDocument(cssText);
          }
        }
      };
      var selectorRe = /([^{]*)({[\s\S]*?})/gim, cssCommentRe = /\/\*[^*]*\*+([^\/*][^*]*\*+)*\//gim, cssCommentNextSelectorRe = /\/\*\s*@polyfill ([^*]*\*+([^\/*][^*]*\*+)*\/)([^{]*?){/gim, cssContentNextSelectorRe = /polyfill-next-selector[^}]*content\:[\s]*?['"](.*?)['"][;\s]*}([^{]*?){/gim, cssCommentRuleRe = /\/\*\s@polyfill-rule([^*]*\*+([^\/*][^*]*\*+)*)\//gim, cssContentRuleRe = /(polyfill-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim, cssCommentUnscopedRuleRe = /\/\*\s@polyfill-unscoped-rule([^*]*\*+([^\/*][^*]*\*+)*)\//gim, cssContentUnscopedRuleRe = /(polyfill-unscoped-rule)[^}]*(content\:[\s]*['"](.*?)['"])[;\s]*[^}]*}/gim, cssPseudoRe = /::(x-[^\s{,(]*)/gim, cssPartRe = /::part\(([^)]*)\)/gim, polyfillHost = "-shadowcsshost", polyfillHostContext = "-shadowcsscontext", parenSuffix = ")(?:\\((" + "(?:\\([^)(]*\\)|[^)(]*)+?" + ")\\))?([^,{]*)";
      var cssColonHostRe = new RegExp("(" + polyfillHost + parenSuffix, "gim"), cssColonHostContextRe = new RegExp("(" + polyfillHostContext + parenSuffix, "gim"), selectorReSuffix = "([>\\s~+[.,{:][\\s\\S]*)?$", colonHostRe = /\:host/gim, colonHostContextRe = /\:host-context/gim, polyfillHostNoCombinator = polyfillHost + "-no-combinator", polyfillHostRe = new RegExp(polyfillHost, "gim"), polyfillHostContextRe = new RegExp(polyfillHostContext, "gim"), shadowDOMSelectorsRe = [ />>>/g, /::shadow/g, /::content/g, /\/deep\//g, /\/shadow\//g, /\/shadow-deep\//g, /\^\^/g, /\^/g ];
      function stylesToCssText(styles, preserveComments) {
        var cssText = "";
        Array.prototype.forEach.call(styles, function(s) {
          cssText += s.textContent + "\n\n";
        });
        if (!preserveComments) {
          cssText = cssText.replace(cssCommentRe, "");
        }
        return cssText;
      }
      function cssTextToStyle(cssText) {
        var style = document.createElement("style");
        style.textContent = cssText;
        return style;
      }
      function cssToRules(cssText) {
        var style = cssTextToStyle(cssText);
        document.head.appendChild(style);
        var rules = [];
        if (style.sheet) {
          try {
            rules = style.sheet.cssRules;
          } catch (e) {}
        } else {
          console.warn("sheet not found", style);
        }
        style.parentNode.removeChild(style);
        return rules;
      }
      var frame = document.createElement("iframe");
      frame.style.display = "none";
      function initFrame() {
        frame.initialized = true;
        document.body.appendChild(frame);
        var doc = frame.contentDocument;
        var base = doc.createElement("base");
        base.href = document.baseURI;
        doc.head.appendChild(base);
      }
      function inFrame(fn) {
        if (!frame.initialized) {
          initFrame();
        }
        document.body.appendChild(frame);
        fn(frame.contentDocument);
        document.body.removeChild(frame);
      }
      var isChrome = navigator.userAgent.match("Chrome");
      function withCssRules(cssText, callback) {
        if (!callback) {
          return;
        }
        var rules;
        if (cssText.match("@import") && isChrome) {
          var style = cssTextToStyle(cssText);
          inFrame(function(doc) {
            doc.head.appendChild(style.impl);
            rules = Array.prototype.slice.call(style.sheet.cssRules, 0);
            callback(rules);
          });
        } else {
          rules = cssToRules(cssText);
          callback(rules);
        }
      }
      function rulesToCss(cssRules) {
        for (var i = 0, css = []; i < cssRules.length; i++) {
          css.push(cssRules[i].cssText);
        }
        return css.join("\n\n");
      }
      function addCssToDocument(cssText) {
        if (cssText) {
          getSheet().appendChild(document.createTextNode(cssText));
        }
      }
      function addOwnSheet(cssText, name) {
        var style = cssTextToStyle(cssText);
        style.setAttribute(name, "");
        style.setAttribute(SHIMMED_ATTRIBUTE, "");
        document.head.appendChild(style);
      }
      var SHIM_ATTRIBUTE = "shim-shadowdom";
      var SHIMMED_ATTRIBUTE = "shim-shadowdom-css";
      var NO_SHIM_ATTRIBUTE = "no-shim";
      var sheet;
      function getSheet() {
        if (!sheet) {
          sheet = document.createElement("style");
          sheet.setAttribute(SHIMMED_ATTRIBUTE, "");
          sheet[SHIMMED_ATTRIBUTE] = true;
        }
        return sheet;
      }
      if (window.ShadowDOMPolyfill) {
        addCssToDocument("style { display: none !important; }\n");
        var doc = ShadowDOMPolyfill.wrap(document);
        var head = doc.querySelector("head");
        head.insertBefore(getSheet(), head.childNodes[0]);
        document.addEventListener("DOMContentLoaded", function() {
          var urlResolver = scope.urlResolver;
          if (window.HTMLImports && !HTMLImports.useNative) {
            var SHIM_SHEET_SELECTOR = "link[rel=stylesheet]" + "[" + SHIM_ATTRIBUTE + "]";
            var SHIM_STYLE_SELECTOR = "style[" + SHIM_ATTRIBUTE + "]";
            HTMLImports.importer.documentPreloadSelectors += "," + SHIM_SHEET_SELECTOR;
            HTMLImports.importer.importsPreloadSelectors += "," + SHIM_SHEET_SELECTOR;
            HTMLImports.parser.documentSelectors = [ HTMLImports.parser.documentSelectors, SHIM_SHEET_SELECTOR, SHIM_STYLE_SELECTOR ].join(",");
            var originalParseGeneric = HTMLImports.parser.parseGeneric;
            HTMLImports.parser.parseGeneric = function(elt) {
              if (elt[SHIMMED_ATTRIBUTE]) {
                return;
              }
              var style = elt.__importElement || elt;
              if (!style.hasAttribute(SHIM_ATTRIBUTE)) {
                originalParseGeneric.call(this, elt);
                return;
              }
              if (elt.__resource) {
                style = elt.ownerDocument.createElement("style");
                style.textContent = elt.__resource;
              }
              HTMLImports.path.resolveUrlsInStyle(style, elt.href);
              style.textContent = ShadowCSS.shimStyle(style);
              style.removeAttribute(SHIM_ATTRIBUTE, "");
              style.setAttribute(SHIMMED_ATTRIBUTE, "");
              style[SHIMMED_ATTRIBUTE] = true;
              if (style.parentNode !== head) {
                if (elt.parentNode === head) {
                  head.replaceChild(style, elt);
                } else {
                  this.addElementToDocument(style);
                }
              }
              style.__importParsed = true;
              this.markParsingComplete(elt);
              this.parseNext();
            };
            var hasResource = HTMLImports.parser.hasResource;
            HTMLImports.parser.hasResource = function(node) {
              if (node.localName === "link" && node.rel === "stylesheet" && node.hasAttribute(SHIM_ATTRIBUTE)) {
                return node.__resource;
              } else {
                return hasResource.call(this, node);
              }
            };
          }
        });
      }
      scope.ShadowCSS = ShadowCSS;
    })(window.WebComponents);
  }
  
  (function(scope) {
    if (window.ShadowDOMPolyfill) {
      window.wrap = ShadowDOMPolyfill.wrapIfNeeded;
      window.unwrap = ShadowDOMPolyfill.unwrapIfNeeded;
    } else {
      window.wrap = window.unwrap = function(n) {
        return n;
      };
    }
  })(window.WebComponents);
  
  (function(scope) {
    "use strict";
    var hasWorkingUrl = false;
    if (!scope.forceJURL) {
      try {
        var u = new URL("b", "http://a");
        u.pathname = "c%20d";
        hasWorkingUrl = u.href === "http://a/c%20d";
      } catch (e) {}
    }
    if (hasWorkingUrl) return;
    var relative = Object.create(null);
    relative["ftp"] = 21;
    relative["file"] = 0;
    relative["gopher"] = 70;
    relative["http"] = 80;
    relative["https"] = 443;
    relative["ws"] = 80;
    relative["wss"] = 443;
    var relativePathDotMapping = Object.create(null);
    relativePathDotMapping["%2e"] = ".";
    relativePathDotMapping[".%2e"] = "..";
    relativePathDotMapping["%2e."] = "..";
    relativePathDotMapping["%2e%2e"] = "..";
    function isRelativeScheme(scheme) {
      return relative[scheme] !== undefined;
    }
    function invalid() {
      clear.call(this);
      this._isInvalid = true;
    }
    function IDNAToASCII(h) {
      if ("" == h) {
        invalid.call(this);
      }
      return h.toLowerCase();
    }
    function percentEscape(c) {
      var unicode = c.charCodeAt(0);
      if (unicode > 32 && unicode < 127 && [ 34, 35, 60, 62, 63, 96 ].indexOf(unicode) == -1) {
        return c;
      }
      return encodeURIComponent(c);
    }
    function percentEscapeQuery(c) {
      var unicode = c.charCodeAt(0);
      if (unicode > 32 && unicode < 127 && [ 34, 35, 60, 62, 96 ].indexOf(unicode) == -1) {
        return c;
      }
      return encodeURIComponent(c);
    }
    var EOF = undefined, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
    function parse(input, stateOverride, base) {
      function err(message) {
        errors.push(message);
      }
      var state = stateOverride || "scheme start", cursor = 0, buffer = "", seenAt = false, seenBracket = false, errors = [];
      loop: while ((input[cursor - 1] != EOF || cursor == 0) && !this._isInvalid) {
        var c = input[cursor];
        switch (state) {
         case "scheme start":
          if (c && ALPHA.test(c)) {
            buffer += c.toLowerCase();
            state = "scheme";
          } else if (!stateOverride) {
            buffer = "";
            state = "no scheme";
            continue;
          } else {
            err("Invalid scheme.");
            break loop;
          }
          break;
  
         case "scheme":
          if (c && ALPHANUMERIC.test(c)) {
            buffer += c.toLowerCase();
          } else if (":" == c) {
            this._scheme = buffer;
            buffer = "";
            if (stateOverride) {
              break loop;
            }
            if (isRelativeScheme(this._scheme)) {
              this._isRelative = true;
            }
            if ("file" == this._scheme) {
              state = "relative";
            } else if (this._isRelative && base && base._scheme == this._scheme) {
              state = "relative or authority";
            } else if (this._isRelative) {
              state = "authority first slash";
            } else {
              state = "scheme data";
            }
          } else if (!stateOverride) {
            buffer = "";
            cursor = 0;
            state = "no scheme";
            continue;
          } else if (EOF == c) {
            break loop;
          } else {
            err("Code point not allowed in scheme: " + c);
            break loop;
          }
          break;
  
         case "scheme data":
          if ("?" == c) {
            this._query = "?";
            state = "query";
          } else if ("#" == c) {
            this._fragment = "#";
            state = "fragment";
          } else {
            if (EOF != c && "	" != c && "\n" != c && "\r" != c) {
              this._schemeData += percentEscape(c);
            }
          }
          break;
  
         case "no scheme":
          if (!base || !isRelativeScheme(base._scheme)) {
            err("Missing scheme.");
            invalid.call(this);
          } else {
            state = "relative";
            continue;
          }
          break;
  
         case "relative or authority":
          if ("/" == c && "/" == input[cursor + 1]) {
            state = "authority ignore slashes";
          } else {
            err("Expected /, got: " + c);
            state = "relative";
            continue;
          }
          break;
  
         case "relative":
          this._isRelative = true;
          if ("file" != this._scheme) this._scheme = base._scheme;
          if (EOF == c) {
            this._host = base._host;
            this._port = base._port;
            this._path = base._path.slice();
            this._query = base._query;
            this._username = base._username;
            this._password = base._password;
            break loop;
          } else if ("/" == c || "\\" == c) {
            if ("\\" == c) err("\\ is an invalid code point.");
            state = "relative slash";
          } else if ("?" == c) {
            this._host = base._host;
            this._port = base._port;
            this._path = base._path.slice();
            this._query = "?";
            this._username = base._username;
            this._password = base._password;
            state = "query";
          } else if ("#" == c) {
            this._host = base._host;
            this._port = base._port;
            this._path = base._path.slice();
            this._query = base._query;
            this._fragment = "#";
            this._username = base._username;
            this._password = base._password;
            state = "fragment";
          } else {
            var nextC = input[cursor + 1];
            var nextNextC = input[cursor + 2];
            if ("file" != this._scheme || !ALPHA.test(c) || nextC != ":" && nextC != "|" || EOF != nextNextC && "/" != nextNextC && "\\" != nextNextC && "?" != nextNextC && "#" != nextNextC) {
              this._host = base._host;
              this._port = base._port;
              this._username = base._username;
              this._password = base._password;
              this._path = base._path.slice();
              this._path.pop();
            }
            state = "relative path";
            continue;
          }
          break;
  
         case "relative slash":
          if ("/" == c || "\\" == c) {
            if ("\\" == c) {
              err("\\ is an invalid code point.");
            }
            if ("file" == this._scheme) {
              state = "file host";
            } else {
              state = "authority ignore slashes";
            }
          } else {
            if ("file" != this._scheme) {
              this._host = base._host;
              this._port = base._port;
              this._username = base._username;
              this._password = base._password;
            }
            state = "relative path";
            continue;
          }
          break;
  
         case "authority first slash":
          if ("/" == c) {
            state = "authority second slash";
          } else {
            err("Expected '/', got: " + c);
            state = "authority ignore slashes";
            continue;
          }
          break;
  
         case "authority second slash":
          state = "authority ignore slashes";
          if ("/" != c) {
            err("Expected '/', got: " + c);
            continue;
          }
          break;
  
         case "authority ignore slashes":
          if ("/" != c && "\\" != c) {
            state = "authority";
            continue;
          } else {
            err("Expected authority, got: " + c);
          }
          break;
  
         case "authority":
          if ("@" == c) {
            if (seenAt) {
              err("@ already seen.");
              buffer += "%40";
            }
            seenAt = true;
            for (var i = 0; i < buffer.length; i++) {
              var cp = buffer[i];
              if ("	" == cp || "\n" == cp || "\r" == cp) {
                err("Invalid whitespace in authority.");
                continue;
              }
              if (":" == cp && null === this._password) {
                this._password = "";
                continue;
              }
              var tempC = percentEscape(cp);
              null !== this._password ? this._password += tempC : this._username += tempC;
            }
            buffer = "";
          } else if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c) {
            cursor -= buffer.length;
            buffer = "";
            state = "host";
            continue;
          } else {
            buffer += c;
          }
          break;
  
         case "file host":
          if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c) {
            if (buffer.length == 2 && ALPHA.test(buffer[0]) && (buffer[1] == ":" || buffer[1] == "|")) {
              state = "relative path";
            } else if (buffer.length == 0) {
              state = "relative path start";
            } else {
              this._host = IDNAToASCII.call(this, buffer);
              buffer = "";
              state = "relative path start";
            }
            continue;
          } else if ("	" == c || "\n" == c || "\r" == c) {
            err("Invalid whitespace in file host.");
          } else {
            buffer += c;
          }
          break;
  
         case "host":
         case "hostname":
          if (":" == c && !seenBracket) {
            this._host = IDNAToASCII.call(this, buffer);
            buffer = "";
            state = "port";
            if ("hostname" == stateOverride) {
              break loop;
            }
          } else if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c) {
            this._host = IDNAToASCII.call(this, buffer);
            buffer = "";
            state = "relative path start";
            if (stateOverride) {
              break loop;
            }
            continue;
          } else if ("	" != c && "\n" != c && "\r" != c) {
            if ("[" == c) {
              seenBracket = true;
            } else if ("]" == c) {
              seenBracket = false;
            }
            buffer += c;
          } else {
            err("Invalid code point in host/hostname: " + c);
          }
          break;
  
         case "port":
          if (/[0-9]/.test(c)) {
            buffer += c;
          } else if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c || stateOverride) {
            if ("" != buffer) {
              var temp = parseInt(buffer, 10);
              if (temp != relative[this._scheme]) {
                this._port = temp + "";
              }
              buffer = "";
            }
            if (stateOverride) {
              break loop;
            }
            state = "relative path start";
            continue;
          } else if ("	" == c || "\n" == c || "\r" == c) {
            err("Invalid code point in port: " + c);
          } else {
            invalid.call(this);
          }
          break;
  
         case "relative path start":
          if ("\\" == c) err("'\\' not allowed in path.");
          state = "relative path";
          if ("/" != c && "\\" != c) {
            continue;
          }
          break;
  
         case "relative path":
          if (EOF == c || "/" == c || "\\" == c || !stateOverride && ("?" == c || "#" == c)) {
            if ("\\" == c) {
              err("\\ not allowed in relative path.");
            }
            var tmp;
            if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
              buffer = tmp;
            }
            if (".." == buffer) {
              this._path.pop();
              if ("/" != c && "\\" != c) {
                this._path.push("");
              }
            } else if ("." == buffer && "/" != c && "\\" != c) {
              this._path.push("");
            } else if ("." != buffer) {
              if ("file" == this._scheme && this._path.length == 0 && buffer.length == 2 && ALPHA.test(buffer[0]) && buffer[1] == "|") {
                buffer = buffer[0] + ":";
              }
              this._path.push(buffer);
            }
            buffer = "";
            if ("?" == c) {
              this._query = "?";
              state = "query";
            } else if ("#" == c) {
              this._fragment = "#";
              state = "fragment";
            }
          } else if ("	" != c && "\n" != c && "\r" != c) {
            buffer += percentEscape(c);
          }
          break;
  
         case "query":
          if (!stateOverride && "#" == c) {
            this._fragment = "#";
            state = "fragment";
          } else if (EOF != c && "	" != c && "\n" != c && "\r" != c) {
            this._query += percentEscapeQuery(c);
          }
          break;
  
         case "fragment":
          if (EOF != c && "	" != c && "\n" != c && "\r" != c) {
            this._fragment += c;
          }
          break;
        }
        cursor++;
      }
    }
    function clear() {
      this._scheme = "";
      this._schemeData = "";
      this._username = "";
      this._password = null;
      this._host = "";
      this._port = "";
      this._path = [];
      this._query = "";
      this._fragment = "";
      this._isInvalid = false;
      this._isRelative = false;
    }
    function jURL(url, base) {
      if (base !== undefined && !(base instanceof jURL)) base = new jURL(String(base));
      this._url = url;
      clear.call(this);
      var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, "");
      parse.call(this, input, null, base);
    }
    jURL.prototype = {
      toString: function() {
        return this.href;
      },
      get href() {
        if (this._isInvalid) return this._url;
        var authority = "";
        if ("" != this._username || null != this._password) {
          authority = this._username + (null != this._password ? ":" + this._password : "") + "@";
        }
        return this.protocol + (this._isRelative ? "//" + authority + this.host : "") + this.pathname + this._query + this._fragment;
      },
      set href(href) {
        clear.call(this);
        parse.call(this, href);
      },
      get protocol() {
        return this._scheme + ":";
      },
      set protocol(protocol) {
        if (this._isInvalid) return;
        parse.call(this, protocol + ":", "scheme start");
      },
      get host() {
        return this._isInvalid ? "" : this._port ? this._host + ":" + this._port : this._host;
      },
      set host(host) {
        if (this._isInvalid || !this._isRelative) return;
        parse.call(this, host, "host");
      },
      get hostname() {
        return this._host;
      },
      set hostname(hostname) {
        if (this._isInvalid || !this._isRelative) return;
        parse.call(this, hostname, "hostname");
      },
      get port() {
        return this._port;
      },
      set port(port) {
        if (this._isInvalid || !this._isRelative) return;
        parse.call(this, port, "port");
      },
      get pathname() {
        return this._isInvalid ? "" : this._isRelative ? "/" + this._path.join("/") : this._schemeData;
      },
      set pathname(pathname) {
        if (this._isInvalid || !this._isRelative) return;
        this._path = [];
        parse.call(this, pathname, "relative path start");
      },
      get search() {
        return this._isInvalid || !this._query || "?" == this._query ? "" : this._query;
      },
      set search(search) {
        if (this._isInvalid || !this._isRelative) return;
        this._query = "?";
        if ("?" == search[0]) search = search.slice(1);
        parse.call(this, search, "query");
      },
      get hash() {
        return this._isInvalid || !this._fragment || "#" == this._fragment ? "" : this._fragment;
      },
      set hash(hash) {
        if (this._isInvalid) return;
        this._fragment = "#";
        if ("#" == hash[0]) hash = hash.slice(1);
        parse.call(this, hash, "fragment");
      },
      get origin() {
        var host;
        if (this._isInvalid || !this._scheme) {
          return "";
        }
        switch (this._scheme) {
         case "data":
         case "file":
         case "javascript":
         case "mailto":
          return "null";
        }
        host = this.host;
        if (!host) {
          return "";
        }
        return this._scheme + "://" + host;
      }
    };
    var OriginalURL = scope.URL;
    if (OriginalURL) {
      jURL.createObjectURL = function(blob) {
        return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
      };
      jURL.revokeObjectURL = function(url) {
        OriginalURL.revokeObjectURL(url);
      };
    }
    scope.URL = jURL;
e619a3b0   Luigi Serra   Controllet cross ...
5401
  })(self);
73bcce88   luigser   COMPONENTS
5402
5403
  
  (function(global) {
eb240478   Luigi Serra   public room cards...
5404
5405
5406
    if (global.JsMutationObserver) {
      return;
    }
73bcce88   luigser   COMPONENTS
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
    var registrationsTable = new WeakMap();
    var setImmediate;
    if (/Trident|Edge/.test(navigator.userAgent)) {
      setImmediate = setTimeout;
    } else if (window.setImmediate) {
      setImmediate = window.setImmediate;
    } else {
      var setImmediateQueue = [];
      var sentinel = String(Math.random());
      window.addEventListener("message", function(e) {
        if (e.data === sentinel) {
          var queue = setImmediateQueue;
          setImmediateQueue = [];
          queue.forEach(function(func) {
            func();
          });
        }
      });
      setImmediate = function(func) {
        setImmediateQueue.push(func);
        window.postMessage(sentinel, "*");
      };
    }
    var isScheduled = false;
    var scheduledObservers = [];
    function scheduleCallback(observer) {
      scheduledObservers.push(observer);
      if (!isScheduled) {
        isScheduled = true;
        setImmediate(dispatchCallbacks);
      }
    }
    function wrapIfNeeded(node) {
      return window.ShadowDOMPolyfill && window.ShadowDOMPolyfill.wrapIfNeeded(node) || node;
    }
    function dispatchCallbacks() {
      isScheduled = false;
      var observers = scheduledObservers;
      scheduledObservers = [];
      observers.sort(function(o1, o2) {
        return o1.uid_ - o2.uid_;
      });
      var anyNonEmpty = false;
      observers.forEach(function(observer) {
        var queue = observer.takeRecords();
        removeTransientObserversFor(observer);
        if (queue.length) {
          observer.callback_(queue, observer);
          anyNonEmpty = true;
        }
      });
      if (anyNonEmpty) dispatchCallbacks();
    }
    function removeTransientObserversFor(observer) {
      observer.nodes_.forEach(function(node) {
        var registrations = registrationsTable.get(node);
        if (!registrations) return;
        registrations.forEach(function(registration) {
          if (registration.observer === observer) registration.removeTransientObservers();
        });
      });
    }
    function forEachAncestorAndObserverEnqueueRecord(target, callback) {
      for (var node = target; node; node = node.parentNode) {
        var registrations = registrationsTable.get(node);
        if (registrations) {
          for (var j = 0; j < registrations.length; j++) {
            var registration = registrations[j];
            var options = registration.options;
            if (node !== target && !options.subtree) continue;
            var record = callback(options);
            if (record) registration.enqueue(record);
          }
        }
      }
    }
    var uidCounter = 0;
    function JsMutationObserver(callback) {
      this.callback_ = callback;
      this.nodes_ = [];
      this.records_ = [];
      this.uid_ = ++uidCounter;
    }
    JsMutationObserver.prototype = {
      observe: function(target, options) {
        target = wrapIfNeeded(target);
        if (!options.childList && !options.attributes && !options.characterData || options.attributeOldValue && !options.attributes || options.attributeFilter && options.attributeFilter.length && !options.attributes || options.characterDataOldValue && !options.characterData) {
          throw new SyntaxError();
        }
        var registrations = registrationsTable.get(target);
        if (!registrations) registrationsTable.set(target, registrations = []);
        var registration;
        for (var i = 0; i < registrations.length; i++) {
          if (registrations[i].observer === this) {
            registration = registrations[i];
            registration.removeListeners();
            registration.options = options;
            break;
          }
        }
        if (!registration) {
          registration = new Registration(this, target, options);
          registrations.push(registration);
          this.nodes_.push(target);
        }
        registration.addListeners();
      },
      disconnect: function() {
        this.nodes_.forEach(function(node) {
          var registrations = registrationsTable.get(node);
          for (var i = 0; i < registrations.length; i++) {
            var registration = registrations[i];
            if (registration.observer === this) {
              registration.removeListeners();
              registrations.splice(i, 1);
              break;
            }
          }
        }, this);
        this.records_ = [];
      },
      takeRecords: function() {
        var copyOfRecords = this.records_;
        this.records_ = [];
        return copyOfRecords;
      }
    };
    function MutationRecord(type, target) {
      this.type = type;
      this.target = target;
      this.addedNodes = [];
      this.removedNodes = [];
      this.previousSibling = null;
      this.nextSibling = null;
      this.attributeName = null;
      this.attributeNamespace = null;
      this.oldValue = null;
    }
    function copyMutationRecord(original) {
      var record = new MutationRecord(original.type, original.target);
      record.addedNodes = original.addedNodes.slice();
      record.removedNodes = original.removedNodes.slice();
      record.previousSibling = original.previousSibling;
      record.nextSibling = original.nextSibling;
      record.attributeName = original.attributeName;
      record.attributeNamespace = original.attributeNamespace;
      record.oldValue = original.oldValue;
      return record;
    }
    var currentRecord, recordWithOldValue;
    function getRecord(type, target) {
      return currentRecord = new MutationRecord(type, target);
    }
    function getRecordWithOldValue(oldValue) {
      if (recordWithOldValue) return recordWithOldValue;
      recordWithOldValue = copyMutationRecord(currentRecord);
      recordWithOldValue.oldValue = oldValue;
      return recordWithOldValue;
    }
    function clearRecords() {
      currentRecord = recordWithOldValue = undefined;
    }
    function recordRepresentsCurrentMutation(record) {
      return record === recordWithOldValue || record === currentRecord;
    }
    function selectRecord(lastRecord, newRecord) {
      if (lastRecord === newRecord) return lastRecord;
      if (recordWithOldValue && recordRepresentsCurrentMutation(lastRecord)) return recordWithOldValue;
      return null;
    }
    function Registration(observer, target, options) {
      this.observer = observer;
      this.target = target;
      this.options = options;
      this.transientObservedNodes = [];
    }
    Registration.prototype = {
      enqueue: function(record) {
        var records = this.observer.records_;
        var length = records.length;
        if (records.length > 0) {
          var lastRecord = records[length - 1];
          var recordToReplaceLast = selectRecord(lastRecord, record);
          if (recordToReplaceLast) {
            records[length - 1] = recordToReplaceLast;
            return;
          }
        } else {
          scheduleCallback(this.observer);
        }
        records[length] = record;
      },
      addListeners: function() {
        this.addListeners_(this.target);
      },
      addListeners_: function(node) {
        var options = this.options;
        if (options.attributes) node.addEventListener("DOMAttrModified", this, true);
        if (options.characterData) node.addEventListener("DOMCharacterDataModified", this, true);
        if (options.childList) node.addEventListener("DOMNodeInserted", this, true);
        if (options.childList || options.subtree) node.addEventListener("DOMNodeRemoved", this, true);
      },
      removeListeners: function() {
        this.removeListeners_(this.target);
      },
      removeListeners_: function(node) {
        var options = this.options;
        if (options.attributes) node.removeEventListener("DOMAttrModified", this, true);
        if (options.characterData) node.removeEventListener("DOMCharacterDataModified", this, true);
        if (options.childList) node.removeEventListener("DOMNodeInserted", this, true);
        if (options.childList || options.subtree) node.removeEventListener("DOMNodeRemoved", this, true);
      },
      addTransientObserver: function(node) {
        if (node === this.target) return;
        this.addListeners_(node);
        this.transientObservedNodes.push(node);
        var registrations = registrationsTable.get(node);
        if (!registrations) registrationsTable.set(node, registrations = []);
        registrations.push(this);
      },
      removeTransientObservers: function() {
        var transientObservedNodes = this.transientObservedNodes;
        this.transientObservedNodes = [];
        transientObservedNodes.forEach(function(node) {
          this.removeListeners_(node);
          var registrations = registrationsTable.get(node);
          for (var i = 0; i < registrations.length; i++) {
            if (registrations[i] === this) {
              registrations.splice(i, 1);
              break;
            }
          }
        }, this);
      },
      handleEvent: function(e) {
        e.stopImmediatePropagation();
        switch (e.type) {
         case "DOMAttrModified":
          var name = e.attrName;
          var namespace = e.relatedNode.namespaceURI;
          var target = e.target;
          var record = new getRecord("attributes", target);
          record.attributeName = name;
          record.attributeNamespace = namespace;
          var oldValue = e.attrChange === MutationEvent.ADDITION ? null : e.prevValue;
          forEachAncestorAndObserverEnqueueRecord(target, function(options) {
            if (!options.attributes) return;
            if (options.attributeFilter && options.attributeFilter.length && options.attributeFilter.indexOf(name) === -1 && options.attributeFilter.indexOf(namespace) === -1) {
              return;
            }
            if (options.attributeOldValue) return getRecordWithOldValue(oldValue);
            return record;
          });
          break;
  
         case "DOMCharacterDataModified":
          var target = e.target;
          var record = getRecord("characterData", target);
          var oldValue = e.prevValue;
          forEachAncestorAndObserverEnqueueRecord(target, function(options) {
            if (!options.characterData) return;
            if (options.characterDataOldValue) return getRecordWithOldValue(oldValue);
            return record;
          });
          break;
  
         case "DOMNodeRemoved":
          this.addTransientObserver(e.target);
  
         case "DOMNodeInserted":
          var changedNode = e.target;
          var addedNodes, removedNodes;
          if (e.type === "DOMNodeInserted") {
            addedNodes = [ changedNode ];
            removedNodes = [];
          } else {
            addedNodes = [];
            removedNodes = [ changedNode ];
          }
          var previousSibling = changedNode.previousSibling;
          var nextSibling = changedNode.nextSibling;
          var record = getRecord("childList", e.target.parentNode);
          record.addedNodes = addedNodes;
          record.removedNodes = removedNodes;
          record.previousSibling = previousSibling;
          record.nextSibling = nextSibling;
          forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function(options) {
            if (!options.childList) return;
            return record;
          });
        }
        clearRecords();
      }
    };
    global.JsMutationObserver = JsMutationObserver;
eb240478   Luigi Serra   public room cards...
5702
5703
5704
5705
    if (!global.MutationObserver) {
      global.MutationObserver = JsMutationObserver;
      JsMutationObserver._isPolyfilled = true;
    }
e619a3b0   Luigi Serra   Controllet cross ...
5706
  })(self);
73bcce88   luigser   COMPONENTS
5707
  
73bcce88   luigser   COMPONENTS
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
  window.HTMLImports = window.HTMLImports || {
    flags: {}
  };
  
  (function(scope) {
    var IMPORT_LINK_TYPE = "import";
    var useNative = Boolean(IMPORT_LINK_TYPE in document.createElement("link"));
    var hasShadowDOMPolyfill = Boolean(window.ShadowDOMPolyfill);
    var wrap = function(node) {
      return hasShadowDOMPolyfill ? window.ShadowDOMPolyfill.wrapIfNeeded(node) : node;
    };
    var rootDocument = wrap(document);
    var currentScriptDescriptor = {
      get: function() {
        var script = window.HTMLImports.currentScript || document.currentScript || (document.readyState !== "complete" ? document.scripts[document.scripts.length - 1] : null);
        return wrap(script);
      },
      configurable: true
    };
    Object.defineProperty(document, "_currentScript", currentScriptDescriptor);
    Object.defineProperty(rootDocument, "_currentScript", currentScriptDescriptor);
    var isIE = /Trident/.test(navigator.userAgent);
    function whenReady(callback, doc) {
      doc = doc || rootDocument;
      whenDocumentReady(function() {
        watchImportsLoad(callback, doc);
      }, doc);
    }
    var requiredReadyState = isIE ? "complete" : "interactive";
    var READY_EVENT = "readystatechange";
    function isDocumentReady(doc) {
      return doc.readyState === "complete" || doc.readyState === requiredReadyState;
    }
    function whenDocumentReady(callback, doc) {
      if (!isDocumentReady(doc)) {
        var checkReady = function() {
          if (doc.readyState === "complete" || doc.readyState === requiredReadyState) {
            doc.removeEventListener(READY_EVENT, checkReady);
            whenDocumentReady(callback, doc);
          }
        };
        doc.addEventListener(READY_EVENT, checkReady);
      } else if (callback) {
        callback();
      }
    }
    function markTargetLoaded(event) {
      event.target.__loaded = true;
    }
    function watchImportsLoad(callback, doc) {
      var imports = doc.querySelectorAll("link[rel=import]");
      var parsedCount = 0, importCount = imports.length, newImports = [], errorImports = [];
      function checkDone() {
        if (parsedCount == importCount && callback) {
          callback({
            allImports: imports,
            loadedImports: newImports,
            errorImports: errorImports
          });
        }
      }
      function loadedImport(e) {
        markTargetLoaded(e);
        newImports.push(this);
        parsedCount++;
        checkDone();
      }
      function errorLoadingImport(e) {
        errorImports.push(this);
        parsedCount++;
        checkDone();
      }
      if (importCount) {
        for (var i = 0, imp; i < importCount && (imp = imports[i]); i++) {
          if (isImportLoaded(imp)) {
73bcce88   luigser   COMPONENTS
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
            parsedCount++;
            checkDone();
          } else {
            imp.addEventListener("load", loadedImport);
            imp.addEventListener("error", errorLoadingImport);
          }
        }
      } else {
        checkDone();
      }
    }
    function isImportLoaded(link) {
      return useNative ? link.__loaded || link.import && link.import.readyState !== "loading" : link.__importParsed;
    }
    if (useNative) {
      new MutationObserver(function(mxns) {
        for (var i = 0, l = mxns.length, m; i < l && (m = mxns[i]); i++) {
          if (m.addedNodes) {
            handleImports(m.addedNodes);
          }
        }
      }).observe(document.head, {
        childList: true
      });
      function handleImports(nodes) {
        for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) {
          if (isImport(n)) {
            handleImport(n);
          }
        }
      }
      function isImport(element) {
        return element.localName === "link" && element.rel === "import";
      }
      function handleImport(element) {
        var loaded = element.import;
        if (loaded) {
          markTargetLoaded({
            target: element
          });
        } else {
          element.addEventListener("load", markTargetLoaded);
          element.addEventListener("error", markTargetLoaded);
        }
      }
      (function() {
        if (document.readyState === "loading") {
          var imports = document.querySelectorAll("link[rel=import]");
          for (var i = 0, l = imports.length, imp; i < l && (imp = imports[i]); i++) {
            handleImport(imp);
          }
        }
      })();
    }
    whenReady(function(detail) {
      window.HTMLImports.ready = true;
      window.HTMLImports.readyTime = new Date().getTime();
      var evt = rootDocument.createEvent("CustomEvent");
      evt.initCustomEvent("HTMLImportsLoaded", true, true, detail);
      rootDocument.dispatchEvent(evt);
    });
    scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE;
    scope.useNative = useNative;
    scope.rootDocument = rootDocument;
    scope.whenReady = whenReady;
    scope.isIE = isIE;
  })(window.HTMLImports);
  
  (function(scope) {
    var modules = [];
    var addModule = function(module) {
      modules.push(module);
    };
    var initializeModules = function() {
      modules.forEach(function(module) {
        module(scope);
      });
    };
    scope.addModule = addModule;
    scope.initializeModules = initializeModules;
  })(window.HTMLImports);
  
  window.HTMLImports.addModule(function(scope) {
    var CSS_URL_REGEXP = /(url\()([^)]*)(\))/g;
    var CSS_IMPORT_REGEXP = /(@import[\s]+(?!url\())([^;]*)(;)/g;
    var path = {
      resolveUrlsInStyle: function(style, linkUrl) {
        var doc = style.ownerDocument;
        var resolver = doc.createElement("a");
        style.textContent = this.resolveUrlsInCssText(style.textContent, linkUrl, resolver);
        return style;
      },
      resolveUrlsInCssText: function(cssText, linkUrl, urlObj) {
        var r = this.replaceUrls(cssText, urlObj, linkUrl, CSS_URL_REGEXP);
        r = this.replaceUrls(r, urlObj, linkUrl, CSS_IMPORT_REGEXP);
        return r;
      },
      replaceUrls: function(text, urlObj, linkUrl, regexp) {
        return text.replace(regexp, function(m, pre, url, post) {
          var urlPath = url.replace(/["']/g, "");
          if (linkUrl) {
            urlPath = new URL(urlPath, linkUrl).href;
          }
          urlObj.href = urlPath;
          urlPath = urlObj.href;
          return pre + "'" + urlPath + "'" + post;
        });
      }
    };
    scope.path = path;
  });
  
  window.HTMLImports.addModule(function(scope) {
    var xhr = {
      async: true,
      ok: function(request) {
        return request.status >= 200 && request.status < 300 || request.status === 304 || request.status === 0;
      },
      load: function(url, next, nextContext) {
        var request = new XMLHttpRequest();
        if (scope.flags.debug || scope.flags.bust) {
          url += "?" + Math.random();
        }
        request.open("GET", url, xhr.async);
        request.addEventListener("readystatechange", function(e) {
          if (request.readyState === 4) {
c5169e0e   Renato De Donato   a new hope
5909
            var locationHeader = request.getResponseHeader("Location");
73bcce88   luigser   COMPONENTS
5910
            var redirectedUrl = null;
c5169e0e   Renato De Donato   a new hope
5911
5912
            if (locationHeader) {
              var redirectedUrl = locationHeader.substr(0, 1) === "/" ? location.origin + locationHeader : locationHeader;
73bcce88   luigser   COMPONENTS
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
            }
            next.call(nextContext, !xhr.ok(request) && request, request.response || request.responseText, redirectedUrl);
          }
        });
        request.send();
        return request;
      },
      loadDocument: function(url, next, nextContext) {
        this.load(url, next, nextContext).responseType = "document";
      }
    };
    scope.xhr = xhr;
  });
  
  window.HTMLImports.addModule(function(scope) {
    var xhr = scope.xhr;
    var flags = scope.flags;
    var Loader = function(onLoad, onComplete) {
      this.cache = {};
      this.onload = onLoad;
      this.oncomplete = onComplete;
      this.inflight = 0;
      this.pending = {};
    };
    Loader.prototype = {
      addNodes: function(nodes) {
        this.inflight += nodes.length;
        for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) {
          this.require(n);
        }
        this.checkDone();
      },
      addNode: function(node) {
        this.inflight++;
        this.require(node);
        this.checkDone();
      },
      require: function(elt) {
        var url = elt.src || elt.href;
        elt.__nodeUrl = url;
        if (!this.dedupe(url, elt)) {
          this.fetch(url, elt);
        }
      },
      dedupe: function(url, elt) {
        if (this.pending[url]) {
          this.pending[url].push(elt);
          return true;
        }
        var resource;
        if (this.cache[url]) {
          this.onload(url, elt, this.cache[url]);
          this.tail();
          return true;
        }
        this.pending[url] = [ elt ];
        return false;
      },
      fetch: function(url, elt) {
        flags.load && console.log("fetch", url, elt);
        if (!url) {
          setTimeout(function() {
            this.receive(url, elt, {
              error: "href must be specified"
            }, null);
          }.bind(this), 0);
        } else if (url.match(/^data:/)) {
          var pieces = url.split(",");
          var header = pieces[0];
          var body = pieces[1];
          if (header.indexOf(";base64") > -1) {
            body = atob(body);
          } else {
            body = decodeURIComponent(body);
          }
          setTimeout(function() {
            this.receive(url, elt, null, body);
          }.bind(this), 0);
        } else {
          var receiveXhr = function(err, resource, redirectedUrl) {
            this.receive(url, elt, err, resource, redirectedUrl);
          }.bind(this);
          xhr.load(url, receiveXhr);
        }
      },
      receive: function(url, elt, err, resource, redirectedUrl) {
        this.cache[url] = resource;
        var $p = this.pending[url];
        for (var i = 0, l = $p.length, p; i < l && (p = $p[i]); i++) {
          this.onload(url, p, resource, err, redirectedUrl);
          this.tail();
        }
        this.pending[url] = null;
      },
      tail: function() {
        --this.inflight;
        this.checkDone();
      },
      checkDone: function() {
        if (!this.inflight) {
          this.oncomplete();
        }
      }
    };
    scope.Loader = Loader;
  });
  
  window.HTMLImports.addModule(function(scope) {
    var Observer = function(addCallback) {
      this.addCallback = addCallback;
      this.mo = new MutationObserver(this.handler.bind(this));
    };
    Observer.prototype = {
      handler: function(mutations) {
        for (var i = 0, l = mutations.length, m; i < l && (m = mutations[i]); i++) {
          if (m.type === "childList" && m.addedNodes.length) {
            this.addedNodes(m.addedNodes);
          }
        }
      },
      addedNodes: function(nodes) {
        if (this.addCallback) {
          this.addCallback(nodes);
        }
        for (var i = 0, l = nodes.length, n, loading; i < l && (n = nodes[i]); i++) {
          if (n.children && n.children.length) {
            this.addedNodes(n.children);
          }
        }
      },
      observe: function(root) {
        this.mo.observe(root, {
          childList: true,
          subtree: true
        });
      }
    };
    scope.Observer = Observer;
  });
  
  window.HTMLImports.addModule(function(scope) {
    var path = scope.path;
    var rootDocument = scope.rootDocument;
    var flags = scope.flags;
    var isIE = scope.isIE;
    var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE;
    var IMPORT_SELECTOR = "link[rel=" + IMPORT_LINK_TYPE + "]";
    var importParser = {
      documentSelectors: IMPORT_SELECTOR,
e619a3b0   Luigi Serra   Controllet cross ...
6062
      importsSelectors: [ IMPORT_SELECTOR, "link[rel=stylesheet]:not([type])", "style:not([type])", "script:not([type])", 'script[type="application/javascript"]', 'script[type="text/javascript"]' ].join(","),
73bcce88   luigser   COMPONENTS
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
      map: {
        link: "parseLink",
        script: "parseScript",
        style: "parseStyle"
      },
      dynamicElements: [],
      parseNext: function() {
        var next = this.nextToParse();
        if (next) {
          this.parse(next);
        }
      },
      parse: function(elt) {
        if (this.isParsed(elt)) {
          flags.parse && console.log("[%s] is already parsed", elt.localName);
          return;
        }
        var fn = this[this.map[elt.localName]];
        if (fn) {
          this.markParsing(elt);
          fn.call(this, elt);
        }
      },
      parseDynamic: function(elt, quiet) {
        this.dynamicElements.push(elt);
        if (!quiet) {
          this.parseNext();
        }
      },
      markParsing: function(elt) {
        flags.parse && console.log("parsing", elt);
        this.parsingElement = elt;
      },
      markParsingComplete: function(elt) {
        elt.__importParsed = true;
        this.markDynamicParsingComplete(elt);
        if (elt.__importElement) {
          elt.__importElement.__importParsed = true;
          this.markDynamicParsingComplete(elt.__importElement);
        }
        this.parsingElement = null;
        flags.parse && console.log("completed", elt);
      },
      markDynamicParsingComplete: function(elt) {
        var i = this.dynamicElements.indexOf(elt);
        if (i >= 0) {
          this.dynamicElements.splice(i, 1);
        }
      },
      parseImport: function(elt) {
e619a3b0   Luigi Serra   Controllet cross ...
6113
        elt.import = elt.__doc;
73bcce88   luigser   COMPONENTS
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
        if (window.HTMLImports.__importsParsingHook) {
          window.HTMLImports.__importsParsingHook(elt);
        }
        if (elt.import) {
          elt.import.__importParsed = true;
        }
        this.markParsingComplete(elt);
        if (elt.__resource && !elt.__error) {
          elt.dispatchEvent(new CustomEvent("load", {
            bubbles: false
          }));
        } else {
          elt.dispatchEvent(new CustomEvent("error", {
            bubbles: false
          }));
        }
        if (elt.__pending) {
          var fn;
          while (elt.__pending.length) {
            fn = elt.__pending.shift();
            if (fn) {
              fn({
                target: elt
              });
            }
          }
        }
        this.parseNext();
      },
      parseLink: function(linkElt) {
        if (nodeIsImport(linkElt)) {
          this.parseImport(linkElt);
        } else {
          linkElt.href = linkElt.href;
          this.parseGeneric(linkElt);
        }
      },
      parseStyle: function(elt) {
        var src = elt;
        elt = cloneStyle(elt);
        src.__appliedElement = elt;
        elt.__importElement = src;
        this.parseGeneric(elt);
      },
      parseGeneric: function(elt) {
        this.trackElement(elt);
        this.addElementToDocument(elt);
      },
      rootImportForElement: function(elt) {
        var n = elt;
        while (n.ownerDocument.__importLink) {
          n = n.ownerDocument.__importLink;
        }
        return n;
      },
      addElementToDocument: function(elt) {
        var port = this.rootImportForElement(elt.__importElement || elt);
        port.parentNode.insertBefore(elt, port);
      },
      trackElement: function(elt, callback) {
        var self = this;
        var done = function(e) {
e619a3b0   Luigi Serra   Controllet cross ...
6176
6177
          elt.removeEventListener("load", done);
          elt.removeEventListener("error", done);
73bcce88   luigser   COMPONENTS
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
          if (callback) {
            callback(e);
          }
          self.markParsingComplete(elt);
          self.parseNext();
        };
        elt.addEventListener("load", done);
        elt.addEventListener("error", done);
        if (isIE && elt.localName === "style") {
          var fakeLoad = false;
          if (elt.textContent.indexOf("@import") == -1) {
            fakeLoad = true;
          } else if (elt.sheet) {
            fakeLoad = true;
            var csr = elt.sheet.cssRules;
            var len = csr ? csr.length : 0;
            for (var i = 0, r; i < len && (r = csr[i]); i++) {
              if (r.type === CSSRule.IMPORT_RULE) {
                fakeLoad = fakeLoad && Boolean(r.styleSheet);
              }
            }
          }
          if (fakeLoad) {
            setTimeout(function() {
              elt.dispatchEvent(new CustomEvent("load", {
                bubbles: false
              }));
            });
          }
        }
      },
      parseScript: function(scriptElt) {
        var script = document.createElement("script");
        script.__importElement = scriptElt;
        script.src = scriptElt.src ? scriptElt.src : generateScriptDataUrl(scriptElt);
        scope.currentScript = scriptElt;
        this.trackElement(script, function(e) {
          if (script.parentNode) {
            script.parentNode.removeChild(script);
          }
          scope.currentScript = null;
        });
        this.addElementToDocument(script);
      },
      nextToParse: function() {
        this._mayParse = [];
        return !this.parsingElement && (this.nextToParseInDoc(rootDocument) || this.nextToParseDynamic());
      },
      nextToParseInDoc: function(doc, link) {
        if (doc && this._mayParse.indexOf(doc) < 0) {
          this._mayParse.push(doc);
          var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc));
          for (var i = 0, l = nodes.length, p = 0, n; i < l && (n = nodes[i]); i++) {
            if (!this.isParsed(n)) {
              if (this.hasResource(n)) {
e619a3b0   Luigi Serra   Controllet cross ...
6233
                return nodeIsImport(n) ? this.nextToParseInDoc(n.__doc, n) : n;
73bcce88   luigser   COMPONENTS
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
              } else {
                return;
              }
            }
          }
        }
        return link;
      },
      nextToParseDynamic: function() {
        return this.dynamicElements[0];
      },
      parseSelectorsForNode: function(node) {
        var doc = node.ownerDocument || node;
        return doc === rootDocument ? this.documentSelectors : this.importsSelectors;
      },
      isParsed: function(node) {
        return node.__importParsed;
      },
      needsDynamicParsing: function(elt) {
        return this.dynamicElements.indexOf(elt) >= 0;
      },
      hasResource: function(node) {
e619a3b0   Luigi Serra   Controllet cross ...
6256
        if (nodeIsImport(node) && node.__doc === undefined) {
73bcce88   luigser   COMPONENTS
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
          return false;
        }
        return true;
      }
    };
    function nodeIsImport(elt) {
      return elt.localName === "link" && elt.rel === IMPORT_LINK_TYPE;
    }
    function generateScriptDataUrl(script) {
      var scriptContent = generateScriptContent(script);
      return "data:text/javascript;charset=utf-8," + encodeURIComponent(scriptContent);
    }
    function generateScriptContent(script) {
      return script.textContent + generateSourceMapHint(script);
    }
    function generateSourceMapHint(script) {
      var owner = script.ownerDocument;
      owner.__importedScripts = owner.__importedScripts || 0;
      var moniker = script.ownerDocument.baseURI;
      var num = owner.__importedScripts ? "-" + owner.__importedScripts : "";
      owner.__importedScripts++;
      return "\n//# sourceURL=" + moniker + num + ".js\n";
    }
    function cloneStyle(style) {
      var clone = style.ownerDocument.createElement("style");
      clone.textContent = style.textContent;
      path.resolveUrlsInStyle(clone);
      return clone;
    }
    scope.parser = importParser;
    scope.IMPORT_SELECTOR = IMPORT_SELECTOR;
  });
  
  window.HTMLImports.addModule(function(scope) {
    var flags = scope.flags;
    var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE;
    var IMPORT_SELECTOR = scope.IMPORT_SELECTOR;
    var rootDocument = scope.rootDocument;
    var Loader = scope.Loader;
    var Observer = scope.Observer;
    var parser = scope.parser;
    var importer = {
      documents: {},
      documentPreloadSelectors: IMPORT_SELECTOR,
      importsPreloadSelectors: [ IMPORT_SELECTOR ].join(","),
      loadNode: function(node) {
        importLoader.addNode(node);
      },
      loadSubtree: function(parent) {
        var nodes = this.marshalNodes(parent);
        importLoader.addNodes(nodes);
      },
      marshalNodes: function(parent) {
        return parent.querySelectorAll(this.loadSelectorsForNode(parent));
      },
      loadSelectorsForNode: function(node) {
        var doc = node.ownerDocument || node;
        return doc === rootDocument ? this.documentPreloadSelectors : this.importsPreloadSelectors;
      },
      loaded: function(url, elt, resource, err, redirectedUrl) {
        flags.load && console.log("loaded", url, elt);
        elt.__resource = resource;
        elt.__error = err;
        if (isImportLink(elt)) {
          var doc = this.documents[url];
          if (doc === undefined) {
            doc = err ? null : makeDocument(resource, redirectedUrl || url);
            if (doc) {
              doc.__importLink = elt;
              this.bootDocument(doc);
            }
            this.documents[url] = doc;
          }
e619a3b0   Luigi Serra   Controllet cross ...
6330
          elt.__doc = doc;
73bcce88   luigser   COMPONENTS
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
        }
        parser.parseNext();
      },
      bootDocument: function(doc) {
        this.loadSubtree(doc);
        this.observer.observe(doc);
        parser.parseNext();
      },
      loadedAll: function() {
        parser.parseNext();
      }
    };
    var importLoader = new Loader(importer.loaded.bind(importer), importer.loadedAll.bind(importer));
    importer.observer = new Observer();
    function isImportLink(elt) {
      return isLinkRel(elt, IMPORT_LINK_TYPE);
    }
    function isLinkRel(elt, rel) {
      return elt.localName === "link" && elt.getAttribute("rel") === rel;
    }
    function hasBaseURIAccessor(doc) {
      return !!Object.getOwnPropertyDescriptor(doc, "baseURI");
    }
    function makeDocument(resource, url) {
      var doc = document.implementation.createHTMLDocument(IMPORT_LINK_TYPE);
      doc._URL = url;
      var base = doc.createElement("base");
      base.setAttribute("href", url);
      if (!doc.baseURI && !hasBaseURIAccessor(doc)) {
        Object.defineProperty(doc, "baseURI", {
          value: url
        });
      }
      var meta = doc.createElement("meta");
      meta.setAttribute("charset", "utf-8");
      doc.head.appendChild(meta);
      doc.head.appendChild(base);
      doc.body.innerHTML = resource;
      if (window.HTMLTemplateElement && HTMLTemplateElement.bootstrap) {
        HTMLTemplateElement.bootstrap(doc);
      }
      return doc;
    }
    if (!document.baseURI) {
      var baseURIDescriptor = {
        get: function() {
          var base = document.querySelector("base");
          return base ? base.href : window.location.href;
        },
        configurable: true
      };
      Object.defineProperty(document, "baseURI", baseURIDescriptor);
      Object.defineProperty(rootDocument, "baseURI", baseURIDescriptor);
    }
    scope.importer = importer;
    scope.importLoader = importLoader;
  });
  
  window.HTMLImports.addModule(function(scope) {
    var parser = scope.parser;
    var importer = scope.importer;
    var dynamic = {
      added: function(nodes) {
        var owner, parsed, loading;
        for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) {
          if (!owner) {
            owner = n.ownerDocument;
            parsed = parser.isParsed(owner);
          }
          loading = this.shouldLoadNode(n);
          if (loading) {
            importer.loadNode(n);
          }
          if (this.shouldParseNode(n) && parsed) {
            parser.parseDynamic(n, loading);
          }
        }
      },
      shouldLoadNode: function(node) {
        return node.nodeType === 1 && matches.call(node, importer.loadSelectorsForNode(node));
      },
      shouldParseNode: function(node) {
        return node.nodeType === 1 && matches.call(node, parser.parseSelectorsForNode(node));
      }
    };
    importer.observer.addCallback = dynamic.added.bind(dynamic);
    var matches = HTMLElement.prototype.matches || HTMLElement.prototype.matchesSelector || HTMLElement.prototype.webkitMatchesSelector || HTMLElement.prototype.mozMatchesSelector || HTMLElement.prototype.msMatchesSelector;
  });
  
  (function(scope) {
    var initializeModules = scope.initializeModules;
    var isIE = scope.isIE;
    if (scope.useNative) {
      return;
    }
c5169e0e   Renato De Donato   a new hope
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
    if (!window.CustomEvent || isIE && typeof window.CustomEvent !== "function") {
      window.CustomEvent = function(inType, params) {
        params = params || {};
        var e = document.createEvent("CustomEvent");
        e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail);
        e.preventDefault = function() {
          Object.defineProperty(this, "defaultPrevented", {
            get: function() {
              return true;
            }
          });
        };
        return e;
      };
      window.CustomEvent.prototype = window.Event.prototype;
    }
73bcce88   luigser   COMPONENTS
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
    initializeModules();
    var rootDocument = scope.rootDocument;
    function bootstrap() {
      window.HTMLImports.importer.bootDocument(rootDocument);
    }
    if (document.readyState === "complete" || document.readyState === "interactive" && !window.attachEvent) {
      bootstrap();
    } else {
      document.addEventListener("DOMContentLoaded", bootstrap);
    }
  })(window.HTMLImports);
  
  window.CustomElements = window.CustomElements || {
    flags: {}
  };
  
  (function(scope) {
    var flags = scope.flags;
    var modules = [];
    var addModule = function(module) {
      modules.push(module);
    };
    var initializeModules = function() {
      modules.forEach(function(module) {
        module(scope);
      });
    };
    scope.addModule = addModule;
    scope.initializeModules = initializeModules;
    scope.hasNative = Boolean(document.registerElement);
e619a3b0   Luigi Serra   Controllet cross ...
6472
    scope.isIE = /Trident/.test(navigator.userAgent);
73bcce88   luigser   COMPONENTS
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
    scope.useNative = !flags.register && scope.hasNative && !window.ShadowDOMPolyfill && (!window.HTMLImports || window.HTMLImports.useNative);
  })(window.CustomElements);
  
  window.CustomElements.addModule(function(scope) {
    var IMPORT_LINK_TYPE = window.HTMLImports ? window.HTMLImports.IMPORT_LINK_TYPE : "none";
    function forSubtree(node, cb) {
      findAllElements(node, function(e) {
        if (cb(e)) {
          return true;
        }
        forRoots(e, cb);
      });
      forRoots(node, cb);
    }
    function findAllElements(node, find, data) {
      var e = node.firstElementChild;
      if (!e) {
        e = node.firstChild;
        while (e && e.nodeType !== Node.ELEMENT_NODE) {
          e = e.nextSibling;
        }
      }
      while (e) {
        if (find(e, data) !== true) {
          findAllElements(e, find, data);
        }
        e = e.nextElementSibling;
      }
      return null;
    }
    function forRoots(node, cb) {
      var root = node.shadowRoot;
      while (root) {
        forSubtree(root, cb);
        root = root.olderShadowRoot;
      }
    }
    function forDocumentTree(doc, cb) {
      _forDocumentTree(doc, cb, []);
    }
    function _forDocumentTree(doc, cb, processingDocuments) {
      doc = window.wrap(doc);
      if (processingDocuments.indexOf(doc) >= 0) {
        return;
      }
      processingDocuments.push(doc);
      var imports = doc.querySelectorAll("link[rel=" + IMPORT_LINK_TYPE + "]");
      for (var i = 0, l = imports.length, n; i < l && (n = imports[i]); i++) {
        if (n.import) {
          _forDocumentTree(n.import, cb, processingDocuments);
        }
      }
      cb(doc);
    }
    scope.forDocumentTree = forDocumentTree;
    scope.forSubtree = forSubtree;
  });
  
  window.CustomElements.addModule(function(scope) {
    var flags = scope.flags;
    var forSubtree = scope.forSubtree;
    var forDocumentTree = scope.forDocumentTree;
    function addedNode(node, isAttached) {
      return added(node, isAttached) || addedSubtree(node, isAttached);
    }
    function added(node, isAttached) {
      if (scope.upgrade(node, isAttached)) {
        return true;
      }
      if (isAttached) {
        attached(node);
      }
    }
    function addedSubtree(node, isAttached) {
      forSubtree(node, function(e) {
        if (added(e, isAttached)) {
          return true;
        }
      });
    }
eb240478   Luigi Serra   public room cards...
6553
6554
6555
    var hasThrottledAttached = window.MutationObserver._isPolyfilled && flags["throttle-attached"];
    scope.hasPolyfillMutations = hasThrottledAttached;
    scope.hasThrottledAttached = hasThrottledAttached;
73bcce88   luigser   COMPONENTS
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
    var isPendingMutations = false;
    var pendingMutations = [];
    function deferMutation(fn) {
      pendingMutations.push(fn);
      if (!isPendingMutations) {
        isPendingMutations = true;
        setTimeout(takeMutations);
      }
    }
    function takeMutations() {
      isPendingMutations = false;
      var $p = pendingMutations;
      for (var i = 0, l = $p.length, p; i < l && (p = $p[i]); i++) {
        p();
      }
      pendingMutations = [];
    }
    function attached(element) {
eb240478   Luigi Serra   public room cards...
6574
      if (hasThrottledAttached) {
73bcce88   luigser   COMPONENTS
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
        deferMutation(function() {
          _attached(element);
        });
      } else {
        _attached(element);
      }
    }
    function _attached(element) {
      if (element.__upgraded__ && !element.__attached) {
        element.__attached = true;
        if (element.attachedCallback) {
          element.attachedCallback();
        }
      }
    }
    function detachedNode(node) {
      detached(node);
      forSubtree(node, function(e) {
        detached(e);
      });
    }
    function detached(element) {
eb240478   Luigi Serra   public room cards...
6597
      if (hasThrottledAttached) {
73bcce88   luigser   COMPONENTS
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
        deferMutation(function() {
          _detached(element);
        });
      } else {
        _detached(element);
      }
    }
    function _detached(element) {
      if (element.__upgraded__ && element.__attached) {
        element.__attached = false;
        if (element.detachedCallback) {
          element.detachedCallback();
        }
      }
    }
    function inDocument(element) {
      var p = element;
      var doc = window.wrap(document);
      while (p) {
        if (p == doc) {
          return true;
        }
        p = p.parentNode || p.nodeType === Node.DOCUMENT_FRAGMENT_NODE && p.host;
      }
    }
    function watchShadow(node) {
      if (node.shadowRoot && !node.shadowRoot.__watched) {
        flags.dom && console.log("watching shadow-root for: ", node.localName);
        var root = node.shadowRoot;
        while (root) {
          observe(root);
          root = root.olderShadowRoot;
        }
      }
    }
    function handler(root, mutations) {
      if (flags.dom) {
        var mx = mutations[0];
        if (mx && mx.type === "childList" && mx.addedNodes) {
          if (mx.addedNodes) {
            var d = mx.addedNodes[0];
            while (d && d !== document && !d.host) {
              d = d.parentNode;
            }
            var u = d && (d.URL || d._URL || d.host && d.host.localName) || "";
            u = u.split("/?").shift().split("/").pop();
          }
        }
        console.group("mutations (%d) [%s]", mutations.length, u || "");
      }
      var isAttached = inDocument(root);
      mutations.forEach(function(mx) {
        if (mx.type === "childList") {
          forEach(mx.addedNodes, function(n) {
            if (!n.localName) {
              return;
            }
            addedNode(n, isAttached);
          });
          forEach(mx.removedNodes, function(n) {
            if (!n.localName) {
              return;
            }
            detachedNode(n);
          });
        }
      });
      flags.dom && console.groupEnd();
    }
    function takeRecords(node) {
      node = window.wrap(node);
      if (!node) {
        node = window.wrap(document);
      }
      while (node.parentNode) {
        node = node.parentNode;
      }
      var observer = node.__observer;
      if (observer) {
        handler(node, observer.takeRecords());
        takeMutations();
      }
    }
    var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach);
    function observe(inRoot) {
      if (inRoot.__observer) {
        return;
      }
      var observer = new MutationObserver(handler.bind(this, inRoot));
      observer.observe(inRoot, {
        childList: true,
        subtree: true
      });
      inRoot.__observer = observer;
    }
    function upgradeDocument(doc) {
      doc = window.wrap(doc);
      flags.dom && console.group("upgradeDocument: ", doc.baseURI.split("/").pop());
      var isMainDocument = doc === window.wrap(document);
      addedNode(doc, isMainDocument);
      observe(doc);
      flags.dom && console.groupEnd();
    }
    function upgradeDocumentTree(doc) {
      forDocumentTree(doc, upgradeDocument);
    }
    var originalCreateShadowRoot = Element.prototype.createShadowRoot;
    if (originalCreateShadowRoot) {
      Element.prototype.createShadowRoot = function() {
        var root = originalCreateShadowRoot.call(this);
        window.CustomElements.watchShadow(this);
        return root;
      };
    }
    scope.watchShadow = watchShadow;
    scope.upgradeDocumentTree = upgradeDocumentTree;
e619a3b0   Luigi Serra   Controllet cross ...
6714
    scope.upgradeDocument = upgradeDocument;
73bcce88   luigser   COMPONENTS
6715
6716
6717
6718
6719
6720
6721
6722
6723
    scope.upgradeSubtree = addedSubtree;
    scope.upgradeAll = addedNode;
    scope.attached = attached;
    scope.takeRecords = takeRecords;
  });
  
  window.CustomElements.addModule(function(scope) {
    var flags = scope.flags;
    function upgrade(node, isAttached) {
73bcce88   luigser   COMPONENTS
6724
6725
      if (!node.__upgraded__ && node.nodeType === Node.ELEMENT_NODE) {
        var is = node.getAttribute("is");
e619a3b0   Luigi Serra   Controllet cross ...
6726
        var definition = scope.getRegisteredDefinition(node.localName) || scope.getRegisteredDefinition(is);
73bcce88   luigser   COMPONENTS
6727
        if (definition) {
e619a3b0   Luigi Serra   Controllet cross ...
6728
          if (is && definition.tag == node.localName || !is && !definition.extends) {
73bcce88   luigser   COMPONENTS
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
            return upgradeWithDefinition(node, definition, isAttached);
          }
        }
      }
    }
    function upgradeWithDefinition(element, definition, isAttached) {
      flags.upgrade && console.group("upgrade:", element.localName);
      if (definition.is) {
        element.setAttribute("is", definition.is);
      }
      implementPrototype(element, definition);
      element.__upgraded__ = true;
      created(element);
      if (isAttached) {
        scope.attached(element);
      }
      scope.upgradeSubtree(element, isAttached);
      flags.upgrade && console.groupEnd();
      return element;
    }
    function implementPrototype(element, definition) {
      if (Object.__proto__) {
        element.__proto__ = definition.prototype;
      } else {
        customMixin(element, definition.prototype, definition.native);
        element.__proto__ = definition.prototype;
      }
    }
    function customMixin(inTarget, inSrc, inNative) {
      var used = {};
      var p = inSrc;
      while (p !== inNative && p !== HTMLElement.prototype) {
        var keys = Object.getOwnPropertyNames(p);
        for (var i = 0, k; k = keys[i]; i++) {
          if (!used[k]) {
            Object.defineProperty(inTarget, k, Object.getOwnPropertyDescriptor(p, k));
            used[k] = 1;
          }
        }
        p = Object.getPrototypeOf(p);
      }
    }
    function created(element) {
      if (element.createdCallback) {
        element.createdCallback();
      }
    }
    scope.upgrade = upgrade;
    scope.upgradeWithDefinition = upgradeWithDefinition;
    scope.implementPrototype = implementPrototype;
  });
  
  window.CustomElements.addModule(function(scope) {
e619a3b0   Luigi Serra   Controllet cross ...
6782
    var isIE = scope.isIE;
73bcce88   luigser   COMPONENTS
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
    var upgradeDocumentTree = scope.upgradeDocumentTree;
    var upgradeAll = scope.upgradeAll;
    var upgradeWithDefinition = scope.upgradeWithDefinition;
    var implementPrototype = scope.implementPrototype;
    var useNative = scope.useNative;
    function register(name, options) {
      var definition = options || {};
      if (!name) {
        throw new Error("document.registerElement: first argument `name` must not be empty");
      }
      if (name.indexOf("-") < 0) {
        throw new Error("document.registerElement: first argument ('name') must contain a dash ('-'). Argument provided was '" + String(name) + "'.");
      }
      if (isReservedTag(name)) {
        throw new Error("Failed to execute 'registerElement' on 'Document': Registration failed for type '" + String(name) + "'. The type name is invalid.");
      }
      if (getRegisteredDefinition(name)) {
        throw new Error("DuplicateDefinitionError: a type with name '" + String(name) + "' is already registered");
      }
      if (!definition.prototype) {
        definition.prototype = Object.create(HTMLElement.prototype);
      }
      definition.__name = name.toLowerCase();
      definition.lifecycle = definition.lifecycle || {};
      definition.ancestry = ancestry(definition.extends);
      resolveTagName(definition);
      resolvePrototypeChain(definition);
      overrideAttributeApi(definition.prototype);
      registerDefinition(definition.__name, definition);
      definition.ctor = generateConstructor(definition);
      definition.ctor.prototype = definition.prototype;
      definition.prototype.constructor = definition.ctor;
      if (scope.ready) {
        upgradeDocumentTree(document);
      }
      return definition.ctor;
    }
    function overrideAttributeApi(prototype) {
      if (prototype.setAttribute._polyfilled) {
        return;
      }
      var setAttribute = prototype.setAttribute;
      prototype.setAttribute = function(name, value) {
        changeAttribute.call(this, name, value, setAttribute);
      };
      var removeAttribute = prototype.removeAttribute;
      prototype.removeAttribute = function(name) {
        changeAttribute.call(this, name, null, removeAttribute);
      };
      prototype.setAttribute._polyfilled = true;
    }
    function changeAttribute(name, value, operation) {
      name = name.toLowerCase();
      var oldValue = this.getAttribute(name);
      operation.apply(this, arguments);
      var newValue = this.getAttribute(name);
      if (this.attributeChangedCallback && newValue !== oldValue) {
        this.attributeChangedCallback(name, oldValue, newValue);
      }
    }
    function isReservedTag(name) {
      for (var i = 0; i < reservedTagList.length; i++) {
        if (name === reservedTagList[i]) {
          return true;
        }
      }
    }
    var reservedTagList = [ "annotation-xml", "color-profile", "font-face", "font-face-src", "font-face-uri", "font-face-format", "font-face-name", "missing-glyph" ];
    function ancestry(extnds) {
      var extendee = getRegisteredDefinition(extnds);
      if (extendee) {
        return ancestry(extendee.extends).concat([ extendee ]);
      }
      return [];
    }
    function resolveTagName(definition) {
      var baseTag = definition.extends;
      for (var i = 0, a; a = definition.ancestry[i]; i++) {
        baseTag = a.is && a.tag;
      }
      definition.tag = baseTag || definition.__name;
      if (baseTag) {
        definition.is = definition.__name;
      }
    }
    function resolvePrototypeChain(definition) {
      if (!Object.__proto__) {
        var nativePrototype = HTMLElement.prototype;
        if (definition.is) {
          var inst = document.createElement(definition.tag);
          nativePrototype = Object.getPrototypeOf(inst);
        }
        var proto = definition.prototype, ancestor;
        var foundPrototype = false;
        while (proto) {
          if (proto == nativePrototype) {
            foundPrototype = true;
          }
          ancestor = Object.getPrototypeOf(proto);
          if (ancestor) {
            proto.__proto__ = ancestor;
          }
          proto = ancestor;
        }
        if (!foundPrototype) {
          console.warn(definition.tag + " prototype not found in prototype chain for " + definition.is);
        }
        definition.native = nativePrototype;
      }
    }
    function instantiate(definition) {
      return upgradeWithDefinition(domCreateElement(definition.tag), definition);
    }
    var registry = {};
    function getRegisteredDefinition(name) {
      if (name) {
        return registry[name.toLowerCase()];
      }
    }
    function registerDefinition(name, definition) {
      registry[name] = definition;
    }
    function generateConstructor(definition) {
      return function() {
        return instantiate(definition);
      };
    }
    var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
    function createElementNS(namespace, tag, typeExtension) {
      if (namespace === HTML_NAMESPACE) {
        return createElement(tag, typeExtension);
      } else {
        return domCreateElementNS(namespace, tag);
      }
    }
    function createElement(tag, typeExtension) {
      if (tag) {
        tag = tag.toLowerCase();
      }
      if (typeExtension) {
        typeExtension = typeExtension.toLowerCase();
      }
      var definition = getRegisteredDefinition(typeExtension || tag);
      if (definition) {
        if (tag == definition.tag && typeExtension == definition.is) {
          return new definition.ctor();
        }
        if (!typeExtension && !definition.is) {
          return new definition.ctor();
        }
      }
      var element;
      if (typeExtension) {
        element = createElement(tag);
        element.setAttribute("is", typeExtension);
        return element;
      }
      element = domCreateElement(tag);
      if (tag.indexOf("-") >= 0) {
        implementPrototype(element, HTMLElement);
      }
      return element;
    }
    var domCreateElement = document.createElement.bind(document);
    var domCreateElementNS = document.createElementNS.bind(document);
    var isInstance;
    if (!Object.__proto__ && !useNative) {
      isInstance = function(obj, ctor) {
        if (obj instanceof ctor) {
          return true;
        }
        var p = obj;
        while (p) {
          if (p === ctor.prototype) {
            return true;
          }
          p = p.__proto__;
        }
        return false;
      };
    } else {
      isInstance = function(obj, base) {
        return obj instanceof base;
      };
    }
    function wrapDomMethodToForceUpgrade(obj, methodName) {
      var orig = obj[methodName];
      obj[methodName] = function() {
        var n = orig.apply(this, arguments);
        upgradeAll(n);
        return n;
      };
    }
    wrapDomMethodToForceUpgrade(Node.prototype, "cloneNode");
    wrapDomMethodToForceUpgrade(document, "importNode");
e619a3b0   Luigi Serra   Controllet cross ...
6978
    if (isIE) {
73bcce88   luigser   COMPONENTS
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
      (function() {
        var importNode = document.importNode;
        document.importNode = function() {
          var n = importNode.apply(document, arguments);
          if (n.nodeType == n.DOCUMENT_FRAGMENT_NODE) {
            var f = document.createDocumentFragment();
            f.appendChild(n);
            return f;
          } else {
            return n;
          }
        };
      })();
    }
    document.registerElement = register;
    document.createElement = createElement;
    document.createElementNS = createElementNS;
    scope.registry = registry;
    scope.instanceof = isInstance;
    scope.reservedTagList = reservedTagList;
    scope.getRegisteredDefinition = getRegisteredDefinition;
    document.register = document.registerElement;
  });
  
  (function(scope) {
    var useNative = scope.useNative;
    var initializeModules = scope.initializeModules;
e619a3b0   Luigi Serra   Controllet cross ...
7006
    var isIE = scope.isIE;
73bcce88   luigser   COMPONENTS
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
    if (useNative) {
      var nop = function() {};
      scope.watchShadow = nop;
      scope.upgrade = nop;
      scope.upgradeAll = nop;
      scope.upgradeDocumentTree = nop;
      scope.upgradeSubtree = nop;
      scope.takeRecords = nop;
      scope.instanceof = function(obj, base) {
        return obj instanceof base;
      };
    } else {
      initializeModules();
    }
    var upgradeDocumentTree = scope.upgradeDocumentTree;
e619a3b0   Luigi Serra   Controllet cross ...
7022
    var upgradeDocument = scope.upgradeDocument;
73bcce88   luigser   COMPONENTS
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
    if (!window.wrap) {
      if (window.ShadowDOMPolyfill) {
        window.wrap = window.ShadowDOMPolyfill.wrapIfNeeded;
        window.unwrap = window.ShadowDOMPolyfill.unwrapIfNeeded;
      } else {
        window.wrap = window.unwrap = function(node) {
          return node;
        };
      }
    }
e619a3b0   Luigi Serra   Controllet cross ...
7033
7034
7035
7036
7037
7038
7039
    if (window.HTMLImports) {
      window.HTMLImports.__importsParsingHook = function(elt) {
        if (elt.import) {
          upgradeDocument(wrap(elt.import));
        }
      };
    }
73bcce88   luigser   COMPONENTS
7040
7041
    function bootstrap() {
      upgradeDocumentTree(window.wrap(document));
73bcce88   luigser   COMPONENTS
7042
      window.CustomElements.ready = true;
e619a3b0   Luigi Serra   Controllet cross ...
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
      var requestAnimationFrame = window.requestAnimationFrame || function(f) {
        setTimeout(f, 16);
      };
      requestAnimationFrame(function() {
        setTimeout(function() {
          window.CustomElements.readyTime = Date.now();
          if (window.HTMLImports) {
            window.CustomElements.elapsed = window.CustomElements.readyTime - window.HTMLImports.readyTime;
          }
          document.dispatchEvent(new CustomEvent("WebComponentsReady", {
            bubbles: true
          }));
        });
73bcce88   luigser   COMPONENTS
7056
7057
      });
    }
c5169e0e   Renato De Donato   a new hope
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
    if (!window.CustomEvent || isIE && typeof window.CustomEvent !== "function") {
      window.CustomEvent = function(inType, params) {
        params = params || {};
        var e = document.createEvent("CustomEvent");
        e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail);
        e.preventDefault = function() {
          Object.defineProperty(this, "defaultPrevented", {
            get: function() {
              return true;
            }
          });
        };
        return e;
      };
      window.CustomEvent.prototype = window.Event.prototype;
    }
73bcce88   luigser   COMPONENTS
7074
7075
7076
7077
7078
7079
7080
7081
    if (document.readyState === "complete" || scope.flags.eager) {
      bootstrap();
    } else if (document.readyState === "interactive" && !window.attachEvent && (!window.HTMLImports || window.HTMLImports.ready)) {
      bootstrap();
    } else {
      var loadEvent = window.HTMLImports && !window.HTMLImports.ready ? "HTMLImportsLoaded" : "DOMContentLoaded";
      window.addEventListener(loadEvent, bootstrap);
    }
73bcce88   luigser   COMPONENTS
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
  })(window.CustomElements);
  
  (function(scope) {
    if (!Function.prototype.bind) {
      Function.prototype.bind = function(scope) {
        var self = this;
        var args = Array.prototype.slice.call(arguments, 1);
        return function() {
          var args2 = args.slice();
          args2.push.apply(args2, arguments);
          return self.apply(scope, args2);
        };
      };
    }
  })(window.WebComponents);
  
  (function(scope) {
c5169e0e   Renato De Donato   a new hope
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
    "use strict";
    if (!window.performance) {
      var start = Date.now();
      window.performance = {
        now: function() {
          return Date.now() - start;
        }
      };
    }
    if (!window.requestAnimationFrame) {
      window.requestAnimationFrame = function() {
        var nativeRaf = window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
        return nativeRaf ? function(callback) {
          return nativeRaf(function() {
            callback(performance.now());
          });
        } : function(callback) {
          return window.setTimeout(callback, 1e3 / 60);
        };
      }();
    }
    if (!window.cancelAnimationFrame) {
      window.cancelAnimationFrame = function() {
        return window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || function(id) {
          clearTimeout(id);
        };
      }();
    }
  })(window.WebComponents);
  
  (function(scope) {
73bcce88   luigser   COMPONENTS
7130
7131
7132
7133
7134
7135
7136
7137
7138
    var style = document.createElement("style");
    style.textContent = "" + "body {" + "transition: opacity ease-in 0.2s;" + " } \n" + "body[unresolved] {" + "opacity: 0; display: block; overflow: hidden; position: relative;" + " } \n";
    var head = document.querySelector("head");
    head.insertBefore(style, head.firstChild);
  })(window.WebComponents);
  
  (function(scope) {
    window.Platform = scope;
  })(window.WebComponents);