@webtides/element-js 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1483 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __publicField = (obj, key, value) => {
3
+ if (typeof key !== "symbol")
4
+ key += "";
5
+ if (key in obj)
6
+ return __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value});
7
+ return obj[key] = value;
8
+ };
9
+
10
+ // src/util/AttributeParser.js
11
+ function isObjectLike(value) {
12
+ return typeof value == "object" && value !== null;
13
+ }
14
+ function isJSON(str) {
15
+ try {
16
+ return JSON.parse(str) && !!str;
17
+ } catch (e) {
18
+ return false;
19
+ }
20
+ }
21
+ function isBoolean(value) {
22
+ return value === "true" || value === "false";
23
+ }
24
+ function parseBoolean(value) {
25
+ return value === "true";
26
+ }
27
+ function isString(value) {
28
+ return typeof value === "string" || !!value && typeof value === "object" && Object.prototype.toString.call(value) === "[object String]";
29
+ }
30
+ function isNumber(value) {
31
+ return new RegExp("^-?(0|0\\.\\d+|[1-9]\\d*(\\.\\d+)?)$").test(value);
32
+ }
33
+ function isNaN(value) {
34
+ return Number.isNaN(value);
35
+ }
36
+ function parseAttribute(value) {
37
+ if (!isString(value)) {
38
+ return value;
39
+ }
40
+ let parsedValue = value;
41
+ if (isJSON(value))
42
+ parsedValue = JSON.parse(value);
43
+ else if (isBoolean(value))
44
+ parsedValue = parseBoolean(value);
45
+ else if (isNumber(value))
46
+ parsedValue = parseFloat(value);
47
+ return parsedValue;
48
+ }
49
+ function dashToCamel(string) {
50
+ if (string.indexOf("-") === -1)
51
+ return string;
52
+ return string.replace(/-[a-z]/g, (matches) => matches[1].toUpperCase());
53
+ }
54
+ function camelToDash(string) {
55
+ return string.replace(/([A-Z])/g, "-$1").toLowerCase();
56
+ }
57
+
58
+ // src/util/DOMHelper.js
59
+ function getShadowParentOrBody(element) {
60
+ if (element instanceof ShadowRoot) {
61
+ return element;
62
+ }
63
+ while (element.parentNode && (element = element.parentNode)) {
64
+ if (element instanceof ShadowRoot) {
65
+ return element;
66
+ }
67
+ }
68
+ return document.body;
69
+ }
70
+ var supportsAdoptingStyleSheets = () => "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype;
71
+ var supportsAppendingStyleSheets = !window.ShadyDOM;
72
+
73
+ // src/util/defineElement.js
74
+ function defineElement(name, constructor) {
75
+ try {
76
+ customElements.define(name, constructor);
77
+ } catch (e) {
78
+ }
79
+ }
80
+
81
+ // src/util/toString.js
82
+ function toString(value) {
83
+ try {
84
+ return JSON.stringify(value);
85
+ } catch (e) {
86
+ return "";
87
+ }
88
+ }
89
+
90
+ // src/BaseElement.js
91
+ var BaseElement = class extends HTMLElement {
92
+ constructor(options = {}) {
93
+ super();
94
+ this.$refs = {};
95
+ this._state = {};
96
+ this._mutationObserver = null;
97
+ this._registeredEvents = [];
98
+ this._batchUpdate = null;
99
+ this._requestedUpdates = [];
100
+ this._options = {
101
+ autoUpdate: true,
102
+ deferUpdate: true,
103
+ mutationObserverOptions: {
104
+ attributes: true,
105
+ childList: true,
106
+ subtree: false,
107
+ ...options.mutationObserverOptions
108
+ },
109
+ propertyOptions: {},
110
+ ...options
111
+ };
112
+ if (options.childListUpdate !== void 0 && options.childListUpdate !== null) {
113
+ this._options.mutationObserverOptions.childList = options.childListUpdate;
114
+ console.warn(`[${this.localName}] Using the "childListUpdate" option is deprecated and will be removed before 1.0! Please use the "mutationObserverOptions" dictionary instead. See the docs for more info`);
115
+ }
116
+ }
117
+ connectedCallback() {
118
+ this.defineAttributesAsProperties();
119
+ this.defineProperties();
120
+ this.defineComputedProperties();
121
+ this.defineObserver();
122
+ if (this.hasAttribute("defer-update") || this._options.deferUpdate) {
123
+ this.registerEventsAndRefs();
124
+ this.triggerHook("connected");
125
+ } else {
126
+ this.requestUpdate({notify: false}).then(() => {
127
+ this.triggerHook("connected");
128
+ });
129
+ }
130
+ }
131
+ defineObserver() {
132
+ this._mutationObserver = new MutationObserver((mutations) => {
133
+ mutations.forEach((mutation) => {
134
+ if (mutation.type === "attributes" && mutation.target === this && this._state.hasOwnProperty(dashToCamel(mutation.attributeName))) {
135
+ this[dashToCamel(mutation.attributeName)] = parseAttribute(this.getAttribute(mutation.attributeName));
136
+ }
137
+ if (mutation.type === "attributes" && mutation.target !== this) {
138
+ this.requestUpdate();
139
+ }
140
+ if (mutation.type === "childList") {
141
+ this.requestUpdate();
142
+ }
143
+ });
144
+ });
145
+ this._mutationObserver.observe(this, {
146
+ attributes: true,
147
+ childList: true,
148
+ subtree: false,
149
+ ...this._options.mutationObserverOptions
150
+ });
151
+ }
152
+ disconnectedCallback() {
153
+ this.removeEvents();
154
+ if (this._mutationObserver)
155
+ this._mutationObserver.disconnect();
156
+ this.triggerHook("disconnected");
157
+ }
158
+ requestUpdate(options = {notify: true}) {
159
+ if (options.notify === true) {
160
+ this.triggerHook("beforeUpdate");
161
+ }
162
+ if (this._batchUpdate) {
163
+ cancelAnimationFrame(this._batchUpdate);
164
+ this._batchUpdate = false;
165
+ }
166
+ return new Promise((resolve, reject) => {
167
+ this._requestedUpdates.push({resolve, reject});
168
+ this._batchUpdate = requestAnimationFrame(() => {
169
+ try {
170
+ this.update(options);
171
+ this._requestedUpdates.forEach(({resolve: resolve2, reject: reject2}) => resolve2());
172
+ } catch (e) {
173
+ this._requestedUpdates.forEach(({resolve: resolve2, reject: reject2}) => reject2(e));
174
+ }
175
+ this._requestedUpdates = [];
176
+ });
177
+ });
178
+ }
179
+ update(options = {notify: true}) {
180
+ this.registerEventsAndRefs();
181
+ if (options.notify === true) {
182
+ this.triggerHook("afterUpdate");
183
+ }
184
+ }
185
+ registerEventsAndRefs() {
186
+ this.registerEvents();
187
+ this.registerRefs();
188
+ }
189
+ defineAttributesAsProperties() {
190
+ const ignoreAttributes = ["class", "style"];
191
+ Array.from(this.attributes).filter((attribute) => {
192
+ return !ignoreAttributes.includes(attribute.name);
193
+ }).forEach((attribute) => {
194
+ this.defineProperty(dashToCamel(attribute.name), parseAttribute(attribute.value), true);
195
+ });
196
+ }
197
+ properties() {
198
+ return {};
199
+ }
200
+ defineProperties() {
201
+ Object.keys(this.properties()).forEach((prop) => {
202
+ const value = this[prop] || this.properties()[prop];
203
+ this.defineProperty(prop, value);
204
+ });
205
+ }
206
+ defineProperty(property, value, reflectAttribute = false) {
207
+ var _a, _b;
208
+ if (this._state.hasOwnProperty(property)) {
209
+ return;
210
+ }
211
+ if (!reflectAttribute && ((_a = this._options.propertyOptions[property]) == null ? void 0 : _a.reflect) === true) {
212
+ this.reflectProperty({property, newValue: value});
213
+ }
214
+ if (((_b = this._options.propertyOptions[property]) == null ? void 0 : _b.reflect) === false) {
215
+ this.removeAttribute(camelToDash(property));
216
+ }
217
+ this._state[property] = value;
218
+ Object.defineProperty(this, property, {
219
+ get: () => {
220
+ return this._state[property];
221
+ },
222
+ set: (newValue) => {
223
+ var _a2;
224
+ const oldValue = this._state[property];
225
+ const newValueString = JSON.stringify(newValue);
226
+ if (JSON.stringify(oldValue) !== newValueString) {
227
+ this._state[property] = newValue;
228
+ if (reflectAttribute || ((_a2 = this._options.propertyOptions[property]) == null ? void 0 : _a2.reflect) === true) {
229
+ this.reflectProperty({property, newValue, newValueString});
230
+ }
231
+ const informWatchedPropertiesAndDispatchChangeEvent = () => {
232
+ if (property in this.watch()) {
233
+ this.watch()[property](newValue, oldValue);
234
+ }
235
+ if (property in this._options["propertyOptions"] && this._options["propertyOptions"][property]["notify"] === true) {
236
+ this.dispatch(`${camelToDash(property)}-changed`, newValue, true);
237
+ }
238
+ };
239
+ if (this._options.autoUpdate) {
240
+ this.requestUpdate({
241
+ notify: true,
242
+ property,
243
+ newValue,
244
+ newValueString,
245
+ oldValue
246
+ }).finally(() => {
247
+ informWatchedPropertiesAndDispatchChangeEvent();
248
+ });
249
+ } else {
250
+ informWatchedPropertiesAndDispatchChangeEvent();
251
+ }
252
+ }
253
+ return this;
254
+ }
255
+ });
256
+ }
257
+ reflectProperty(options) {
258
+ const {property, newValue} = options;
259
+ const newValueString = options.newValueString || JSON.stringify(newValue);
260
+ if (newValue === void 0 || newValue === null || isNaN(newValue)) {
261
+ this.setAttribute(camelToDash(property), "");
262
+ } else {
263
+ const attributeValue = isObjectLike(newValue) ? newValueString : newValue;
264
+ this.setAttribute(camelToDash(property), attributeValue);
265
+ }
266
+ }
267
+ hooks() {
268
+ return {};
269
+ }
270
+ connected() {
271
+ }
272
+ beforeUpdate() {
273
+ }
274
+ afterUpdate() {
275
+ }
276
+ disconnected() {
277
+ }
278
+ triggerHook(name) {
279
+ if (this.hooks && name in this.hooks()) {
280
+ console.warn(`[${this.localName}] Using the hooks() map for lifecycle hooks is deprecated! Please overwrite the existing lifecycle hook functions. See the docs for more info`);
281
+ this.hooks()[name]();
282
+ return;
283
+ }
284
+ if (name in this) {
285
+ this[name]();
286
+ }
287
+ }
288
+ watch() {
289
+ return {};
290
+ }
291
+ computed() {
292
+ return {};
293
+ }
294
+ defineComputedProperties() {
295
+ Object.keys(this.computed()).forEach((prop) => {
296
+ if (!this.hasOwnProperty(prop)) {
297
+ console.warn(`[${this.localName}] Using the computed() map for computed properties is deprecated! Please use regular JS getters and return the computed value. See the docs for more info`);
298
+ Object.defineProperty(this, prop, {
299
+ get: () => this.computed()[prop]()
300
+ });
301
+ }
302
+ });
303
+ }
304
+ events() {
305
+ return {};
306
+ }
307
+ registerEvents() {
308
+ this.removeEvents();
309
+ const eventDefinitions = this.events();
310
+ Object.keys(eventDefinitions).forEach((elementSelector) => {
311
+ const events = eventDefinitions[elementSelector];
312
+ const selectorWhiteList = {window, document, this: this.getRoot()};
313
+ const whiteListElement = selectorWhiteList[elementSelector];
314
+ const eventTargets = whiteListElement ? [whiteListElement] : this.getRoot().querySelectorAll(elementSelector);
315
+ eventTargets.forEach((eventTarget) => {
316
+ Object.keys(events).forEach((eventName) => {
317
+ var _a;
318
+ const notation = events[eventName];
319
+ if (typeof notation === "function") {
320
+ const callback = notation.bind(this);
321
+ eventTarget.addEventListener(eventName, callback);
322
+ this._registeredEvents.push({eventTarget, eventName, callback});
323
+ } else if (typeof notation === "object" && typeof notation.listener === "function") {
324
+ const callback = notation.listener.bind(this);
325
+ eventTarget.addEventListener(eventName, callback, (_a = notation.options) != null ? _a : {});
326
+ this._registeredEvents.push({eventTarget, eventName, callback});
327
+ }
328
+ });
329
+ });
330
+ });
331
+ }
332
+ removeEvents() {
333
+ this._registeredEvents.forEach(({eventTarget, eventName, callback}) => {
334
+ if (eventTarget === window || eventTarget === document || this.getRoot().contains(eventTarget)) {
335
+ eventTarget.removeEventListener(eventName, callback);
336
+ }
337
+ });
338
+ this._registeredEvents = [];
339
+ }
340
+ registerRefs() {
341
+ const refsNodeList = this.getRoot().querySelectorAll("[ref]");
342
+ const refsArray = Array.from(refsNodeList);
343
+ const refsMap = {};
344
+ refsArray.forEach((refNode) => {
345
+ const refKey = refNode.getAttribute("ref");
346
+ refsMap[refKey] = refNode;
347
+ });
348
+ this.$refs = refsMap;
349
+ }
350
+ dispatch(name, data, bubble = false, cancelable = false, composed = false) {
351
+ const event = new CustomEvent(name, {
352
+ bubbles: bubble,
353
+ cancelable,
354
+ composed,
355
+ detail: data
356
+ });
357
+ this.dispatchEvent(event);
358
+ }
359
+ getRoot() {
360
+ return this;
361
+ }
362
+ };
363
+
364
+ // src/util/i18n.js
365
+ function i18n(key, fallback) {
366
+ try {
367
+ const translations = window.elementjs.i18n();
368
+ if (translations[key] === void 0) {
369
+ throw "Translation Missing";
370
+ }
371
+ return translations[key];
372
+ } catch (err) {
373
+ if (fallback)
374
+ return fallback;
375
+ else
376
+ return key;
377
+ }
378
+ }
379
+
380
+ // src/StyledElement.js
381
+ var _StyledElement = class extends BaseElement {
382
+ static updateGlobalStyles() {
383
+ _StyledElement.globalStyles = document.getElementById("globalStyles");
384
+ if (_StyledElement.globalStyles && _StyledElement["globalStyleSheet"]) {
385
+ _StyledElement["globalStyleSheet"].replaceSync(_StyledElement.globalStyles.textContent);
386
+ }
387
+ }
388
+ constructor(options) {
389
+ super({
390
+ deferUpdate: false,
391
+ shadowRender: false,
392
+ styles: [],
393
+ adoptGlobalStyles: true,
394
+ ...options
395
+ });
396
+ this._styles = [...this._options.styles, ...this.styles()];
397
+ }
398
+ connectedCallback() {
399
+ super.connectedCallback();
400
+ if (supportsAdoptingStyleSheets() && this._options.shadowRender) {
401
+ this.adoptStyleSheets();
402
+ } else if (this._options.shadowRender && window.ShadyCSS !== void 0) {
403
+ window.ShadyCSS.ScopingShim.prepareAdoptedCssText(this._styles, this.localName);
404
+ }
405
+ if (window.ShadyCSS !== void 0) {
406
+ window.ShadyCSS.styleElement(this);
407
+ }
408
+ }
409
+ styles() {
410
+ return [];
411
+ }
412
+ update(options) {
413
+ var _a, _b;
414
+ if (!supportsAdoptingStyleSheets() || this._options.shadowRender === false) {
415
+ const appendableStyles = [...this._styles];
416
+ if (this._options.shadowRender && this._options.adoptGlobalStyles && !window.ShadyCSS) {
417
+ appendableStyles.unshift((_b = (_a = _StyledElement.globalStyles) == null ? void 0 : _a.textContent) != null ? _b : "");
418
+ }
419
+ this.appendStyleSheets(appendableStyles);
420
+ }
421
+ super.update(options);
422
+ }
423
+ adoptStyleSheets() {
424
+ if (!this.constructor["cssStyleSheets"]) {
425
+ this.constructor["cssStyleSheets"] = this._styles.map((style) => {
426
+ const sheet = new CSSStyleSheet();
427
+ if (sheet && sheet.cssRules.length === 0) {
428
+ sheet.replaceSync(style);
429
+ }
430
+ return sheet;
431
+ });
432
+ }
433
+ if (_StyledElement.globalStyles && !_StyledElement["globalStyleSheet"]) {
434
+ _StyledElement["globalStyleSheet"] = new CSSStyleSheet();
435
+ _StyledElement["globalStyleSheet"].replaceSync(_StyledElement.globalStyles.textContent);
436
+ }
437
+ this.getRoot().adoptedStyleSheets = [
438
+ ...this._options.shadowRender && this._options.adoptGlobalStyles && _StyledElement["globalStyleSheet"] ? [_StyledElement["globalStyleSheet"]] : [],
439
+ ...this.constructor["cssStyleSheets"]
440
+ ];
441
+ }
442
+ appendStyleSheets(styles) {
443
+ const parentDocument = getShadowParentOrBody(this.getRoot());
444
+ styles.forEach((style, index) => {
445
+ const identifier = this.tagName + index;
446
+ if (!parentDocument.querySelector(`#${identifier}`)) {
447
+ const styleElement = document.createElement("style");
448
+ styleElement.id = identifier;
449
+ styleElement.style.display = "none";
450
+ styleElement.textContent = style;
451
+ parentDocument.appendChild(styleElement);
452
+ }
453
+ });
454
+ }
455
+ };
456
+ var StyledElement = _StyledElement;
457
+ __publicField(StyledElement, "globalStyles", null);
458
+ StyledElement.updateGlobalStyles();
459
+
460
+ // node_modules/lit-html/lib/directive.js
461
+ /**
462
+ * @license
463
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
464
+ * This code may only be used under the BSD style license found at
465
+ * http://polymer.github.io/LICENSE.txt
466
+ * The complete set of authors may be found at
467
+ * http://polymer.github.io/AUTHORS.txt
468
+ * The complete set of contributors may be found at
469
+ * http://polymer.github.io/CONTRIBUTORS.txt
470
+ * Code distributed by Google as part of the polymer project is also
471
+ * subject to an additional IP rights grant found at
472
+ * http://polymer.github.io/PATENTS.txt
473
+ */
474
+ var directives = new WeakMap();
475
+ var isDirective = (o) => {
476
+ return typeof o === "function" && directives.has(o);
477
+ };
478
+
479
+ // node_modules/lit-html/lib/dom.js
480
+ /**
481
+ * @license
482
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
483
+ * This code may only be used under the BSD style license found at
484
+ * http://polymer.github.io/LICENSE.txt
485
+ * The complete set of authors may be found at
486
+ * http://polymer.github.io/AUTHORS.txt
487
+ * The complete set of contributors may be found at
488
+ * http://polymer.github.io/CONTRIBUTORS.txt
489
+ * Code distributed by Google as part of the polymer project is also
490
+ * subject to an additional IP rights grant found at
491
+ * http://polymer.github.io/PATENTS.txt
492
+ */
493
+ var isCEPolyfill = typeof window !== "undefined" && window.customElements != null && window.customElements.polyfillWrapFlushCallback !== void 0;
494
+ var removeNodes = (container, start, end = null) => {
495
+ while (start !== end) {
496
+ const n = start.nextSibling;
497
+ container.removeChild(start);
498
+ start = n;
499
+ }
500
+ };
501
+
502
+ // node_modules/lit-html/lib/part.js
503
+ /**
504
+ * @license
505
+ * Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
506
+ * This code may only be used under the BSD style license found at
507
+ * http://polymer.github.io/LICENSE.txt
508
+ * The complete set of authors may be found at
509
+ * http://polymer.github.io/AUTHORS.txt
510
+ * The complete set of contributors may be found at
511
+ * http://polymer.github.io/CONTRIBUTORS.txt
512
+ * Code distributed by Google as part of the polymer project is also
513
+ * subject to an additional IP rights grant found at
514
+ * http://polymer.github.io/PATENTS.txt
515
+ */
516
+ var noChange = {};
517
+ var nothing = {};
518
+
519
+ // node_modules/lit-html/lib/template.js
520
+ /**
521
+ * @license
522
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
523
+ * This code may only be used under the BSD style license found at
524
+ * http://polymer.github.io/LICENSE.txt
525
+ * The complete set of authors may be found at
526
+ * http://polymer.github.io/AUTHORS.txt
527
+ * The complete set of contributors may be found at
528
+ * http://polymer.github.io/CONTRIBUTORS.txt
529
+ * Code distributed by Google as part of the polymer project is also
530
+ * subject to an additional IP rights grant found at
531
+ * http://polymer.github.io/PATENTS.txt
532
+ */
533
+ var marker = `{{lit-${String(Math.random()).slice(2)}}}`;
534
+ var nodeMarker = `<!--${marker}-->`;
535
+ var markerRegex = new RegExp(`${marker}|${nodeMarker}`);
536
+ var boundAttributeSuffix = "$lit$";
537
+ var Template = class {
538
+ constructor(result, element) {
539
+ this.parts = [];
540
+ this.element = element;
541
+ const nodesToRemove = [];
542
+ const stack = [];
543
+ const walker = document.createTreeWalker(element.content, 133, null, false);
544
+ let lastPartIndex = 0;
545
+ let index = -1;
546
+ let partIndex = 0;
547
+ const {strings, values: {length}} = result;
548
+ while (partIndex < length) {
549
+ const node = walker.nextNode();
550
+ if (node === null) {
551
+ walker.currentNode = stack.pop();
552
+ continue;
553
+ }
554
+ index++;
555
+ if (node.nodeType === 1) {
556
+ if (node.hasAttributes()) {
557
+ const attributes = node.attributes;
558
+ const {length: length2} = attributes;
559
+ let count = 0;
560
+ for (let i = 0; i < length2; i++) {
561
+ if (endsWith(attributes[i].name, boundAttributeSuffix)) {
562
+ count++;
563
+ }
564
+ }
565
+ while (count-- > 0) {
566
+ const stringForPart = strings[partIndex];
567
+ const name = lastAttributeNameRegex.exec(stringForPart)[2];
568
+ const attributeLookupName = name.toLowerCase() + boundAttributeSuffix;
569
+ const attributeValue = node.getAttribute(attributeLookupName);
570
+ node.removeAttribute(attributeLookupName);
571
+ const statics = attributeValue.split(markerRegex);
572
+ this.parts.push({type: "attribute", index, name, strings: statics});
573
+ partIndex += statics.length - 1;
574
+ }
575
+ }
576
+ if (node.tagName === "TEMPLATE") {
577
+ stack.push(node);
578
+ walker.currentNode = node.content;
579
+ }
580
+ } else if (node.nodeType === 3) {
581
+ const data = node.data;
582
+ if (data.indexOf(marker) >= 0) {
583
+ const parent = node.parentNode;
584
+ const strings2 = data.split(markerRegex);
585
+ const lastIndex = strings2.length - 1;
586
+ for (let i = 0; i < lastIndex; i++) {
587
+ let insert;
588
+ let s = strings2[i];
589
+ if (s === "") {
590
+ insert = createMarker();
591
+ } else {
592
+ const match = lastAttributeNameRegex.exec(s);
593
+ if (match !== null && endsWith(match[2], boundAttributeSuffix)) {
594
+ s = s.slice(0, match.index) + match[1] + match[2].slice(0, -boundAttributeSuffix.length) + match[3];
595
+ }
596
+ insert = document.createTextNode(s);
597
+ }
598
+ parent.insertBefore(insert, node);
599
+ this.parts.push({type: "node", index: ++index});
600
+ }
601
+ if (strings2[lastIndex] === "") {
602
+ parent.insertBefore(createMarker(), node);
603
+ nodesToRemove.push(node);
604
+ } else {
605
+ node.data = strings2[lastIndex];
606
+ }
607
+ partIndex += lastIndex;
608
+ }
609
+ } else if (node.nodeType === 8) {
610
+ if (node.data === marker) {
611
+ const parent = node.parentNode;
612
+ if (node.previousSibling === null || index === lastPartIndex) {
613
+ index++;
614
+ parent.insertBefore(createMarker(), node);
615
+ }
616
+ lastPartIndex = index;
617
+ this.parts.push({type: "node", index});
618
+ if (node.nextSibling === null) {
619
+ node.data = "";
620
+ } else {
621
+ nodesToRemove.push(node);
622
+ index--;
623
+ }
624
+ partIndex++;
625
+ } else {
626
+ let i = -1;
627
+ while ((i = node.data.indexOf(marker, i + 1)) !== -1) {
628
+ this.parts.push({type: "node", index: -1});
629
+ partIndex++;
630
+ }
631
+ }
632
+ }
633
+ }
634
+ for (const n of nodesToRemove) {
635
+ n.parentNode.removeChild(n);
636
+ }
637
+ }
638
+ };
639
+ var endsWith = (str, suffix) => {
640
+ const index = str.length - suffix.length;
641
+ return index >= 0 && str.slice(index) === suffix;
642
+ };
643
+ var isTemplatePartActive = (part) => part.index !== -1;
644
+ var createMarker = () => document.createComment("");
645
+ var lastAttributeNameRegex = /([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;
646
+
647
+ // node_modules/lit-html/lib/template-instance.js
648
+ /**
649
+ * @license
650
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
651
+ * This code may only be used under the BSD style license found at
652
+ * http://polymer.github.io/LICENSE.txt
653
+ * The complete set of authors may be found at
654
+ * http://polymer.github.io/AUTHORS.txt
655
+ * The complete set of contributors may be found at
656
+ * http://polymer.github.io/CONTRIBUTORS.txt
657
+ * Code distributed by Google as part of the polymer project is also
658
+ * subject to an additional IP rights grant found at
659
+ * http://polymer.github.io/PATENTS.txt
660
+ */
661
+ var TemplateInstance = class {
662
+ constructor(template, processor, options) {
663
+ this.__parts = [];
664
+ this.template = template;
665
+ this.processor = processor;
666
+ this.options = options;
667
+ }
668
+ update(values) {
669
+ let i = 0;
670
+ for (const part of this.__parts) {
671
+ if (part !== void 0) {
672
+ part.setValue(values[i]);
673
+ }
674
+ i++;
675
+ }
676
+ for (const part of this.__parts) {
677
+ if (part !== void 0) {
678
+ part.commit();
679
+ }
680
+ }
681
+ }
682
+ _clone() {
683
+ const fragment = isCEPolyfill ? this.template.element.content.cloneNode(true) : document.importNode(this.template.element.content, true);
684
+ const stack = [];
685
+ const parts2 = this.template.parts;
686
+ const walker = document.createTreeWalker(fragment, 133, null, false);
687
+ let partIndex = 0;
688
+ let nodeIndex = 0;
689
+ let part;
690
+ let node = walker.nextNode();
691
+ while (partIndex < parts2.length) {
692
+ part = parts2[partIndex];
693
+ if (!isTemplatePartActive(part)) {
694
+ this.__parts.push(void 0);
695
+ partIndex++;
696
+ continue;
697
+ }
698
+ while (nodeIndex < part.index) {
699
+ nodeIndex++;
700
+ if (node.nodeName === "TEMPLATE") {
701
+ stack.push(node);
702
+ walker.currentNode = node.content;
703
+ }
704
+ if ((node = walker.nextNode()) === null) {
705
+ walker.currentNode = stack.pop();
706
+ node = walker.nextNode();
707
+ }
708
+ }
709
+ if (part.type === "node") {
710
+ const part2 = this.processor.handleTextExpression(this.options);
711
+ part2.insertAfterNode(node.previousSibling);
712
+ this.__parts.push(part2);
713
+ } else {
714
+ this.__parts.push(...this.processor.handleAttributeExpressions(node, part.name, part.strings, this.options));
715
+ }
716
+ partIndex++;
717
+ }
718
+ if (isCEPolyfill) {
719
+ document.adoptNode(fragment);
720
+ customElements.upgrade(fragment);
721
+ }
722
+ return fragment;
723
+ }
724
+ };
725
+
726
+ // node_modules/lit-html/lib/template-result.js
727
+ /**
728
+ * @license
729
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
730
+ * This code may only be used under the BSD style license found at
731
+ * http://polymer.github.io/LICENSE.txt
732
+ * The complete set of authors may be found at
733
+ * http://polymer.github.io/AUTHORS.txt
734
+ * The complete set of contributors may be found at
735
+ * http://polymer.github.io/CONTRIBUTORS.txt
736
+ * Code distributed by Google as part of the polymer project is also
737
+ * subject to an additional IP rights grant found at
738
+ * http://polymer.github.io/PATENTS.txt
739
+ */
740
+ var commentMarker = ` ${marker} `;
741
+ var TemplateResult = class {
742
+ constructor(strings, values, type, processor) {
743
+ this.strings = strings;
744
+ this.values = values;
745
+ this.type = type;
746
+ this.processor = processor;
747
+ }
748
+ getHTML() {
749
+ const l = this.strings.length - 1;
750
+ let html2 = "";
751
+ let isCommentBinding = false;
752
+ for (let i = 0; i < l; i++) {
753
+ const s = this.strings[i];
754
+ const commentOpen = s.lastIndexOf("<!--");
755
+ isCommentBinding = (commentOpen > -1 || isCommentBinding) && s.indexOf("-->", commentOpen + 1) === -1;
756
+ const attributeMatch = lastAttributeNameRegex.exec(s);
757
+ if (attributeMatch === null) {
758
+ html2 += s + (isCommentBinding ? commentMarker : nodeMarker);
759
+ } else {
760
+ html2 += s.substr(0, attributeMatch.index) + attributeMatch[1] + attributeMatch[2] + boundAttributeSuffix + attributeMatch[3] + marker;
761
+ }
762
+ }
763
+ html2 += this.strings[l];
764
+ return html2;
765
+ }
766
+ getTemplateElement() {
767
+ const template = document.createElement("template");
768
+ template.innerHTML = this.getHTML();
769
+ return template;
770
+ }
771
+ };
772
+
773
+ // node_modules/lit-html/lib/parts.js
774
+ /**
775
+ * @license
776
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
777
+ * This code may only be used under the BSD style license found at
778
+ * http://polymer.github.io/LICENSE.txt
779
+ * The complete set of authors may be found at
780
+ * http://polymer.github.io/AUTHORS.txt
781
+ * The complete set of contributors may be found at
782
+ * http://polymer.github.io/CONTRIBUTORS.txt
783
+ * Code distributed by Google as part of the polymer project is also
784
+ * subject to an additional IP rights grant found at
785
+ * http://polymer.github.io/PATENTS.txt
786
+ */
787
+ var isPrimitive = (value) => {
788
+ return value === null || !(typeof value === "object" || typeof value === "function");
789
+ };
790
+ var isIterable = (value) => {
791
+ return Array.isArray(value) || !!(value && value[Symbol.iterator]);
792
+ };
793
+ var AttributeCommitter = class {
794
+ constructor(element, name, strings) {
795
+ this.dirty = true;
796
+ this.element = element;
797
+ this.name = name;
798
+ this.strings = strings;
799
+ this.parts = [];
800
+ for (let i = 0; i < strings.length - 1; i++) {
801
+ this.parts[i] = this._createPart();
802
+ }
803
+ }
804
+ _createPart() {
805
+ return new AttributePart(this);
806
+ }
807
+ _getValue() {
808
+ const strings = this.strings;
809
+ const l = strings.length - 1;
810
+ let text = "";
811
+ for (let i = 0; i < l; i++) {
812
+ text += strings[i];
813
+ const part = this.parts[i];
814
+ if (part !== void 0) {
815
+ const v = part.value;
816
+ if (isPrimitive(v) || !isIterable(v)) {
817
+ text += typeof v === "string" ? v : String(v);
818
+ } else {
819
+ for (const t of v) {
820
+ text += typeof t === "string" ? t : String(t);
821
+ }
822
+ }
823
+ }
824
+ }
825
+ text += strings[l];
826
+ return text;
827
+ }
828
+ commit() {
829
+ if (this.dirty) {
830
+ this.dirty = false;
831
+ this.element.setAttribute(this.name, this._getValue());
832
+ }
833
+ }
834
+ };
835
+ var AttributePart = class {
836
+ constructor(committer) {
837
+ this.value = void 0;
838
+ this.committer = committer;
839
+ }
840
+ setValue(value) {
841
+ if (value !== noChange && (!isPrimitive(value) || value !== this.value)) {
842
+ this.value = value;
843
+ if (!isDirective(value)) {
844
+ this.committer.dirty = true;
845
+ }
846
+ }
847
+ }
848
+ commit() {
849
+ while (isDirective(this.value)) {
850
+ const directive2 = this.value;
851
+ this.value = noChange;
852
+ directive2(this);
853
+ }
854
+ if (this.value === noChange) {
855
+ return;
856
+ }
857
+ this.committer.commit();
858
+ }
859
+ };
860
+ var NodePart = class {
861
+ constructor(options) {
862
+ this.value = void 0;
863
+ this.__pendingValue = void 0;
864
+ this.options = options;
865
+ }
866
+ appendInto(container) {
867
+ this.startNode = container.appendChild(createMarker());
868
+ this.endNode = container.appendChild(createMarker());
869
+ }
870
+ insertAfterNode(ref) {
871
+ this.startNode = ref;
872
+ this.endNode = ref.nextSibling;
873
+ }
874
+ appendIntoPart(part) {
875
+ part.__insert(this.startNode = createMarker());
876
+ part.__insert(this.endNode = createMarker());
877
+ }
878
+ insertAfterPart(ref) {
879
+ ref.__insert(this.startNode = createMarker());
880
+ this.endNode = ref.endNode;
881
+ ref.endNode = this.startNode;
882
+ }
883
+ setValue(value) {
884
+ this.__pendingValue = value;
885
+ }
886
+ commit() {
887
+ if (this.startNode.parentNode === null) {
888
+ return;
889
+ }
890
+ while (isDirective(this.__pendingValue)) {
891
+ const directive2 = this.__pendingValue;
892
+ this.__pendingValue = noChange;
893
+ directive2(this);
894
+ }
895
+ const value = this.__pendingValue;
896
+ if (value === noChange) {
897
+ return;
898
+ }
899
+ if (isPrimitive(value)) {
900
+ if (value !== this.value) {
901
+ this.__commitText(value);
902
+ }
903
+ } else if (value instanceof TemplateResult) {
904
+ this.__commitTemplateResult(value);
905
+ } else if (value instanceof Node) {
906
+ this.__commitNode(value);
907
+ } else if (isIterable(value)) {
908
+ this.__commitIterable(value);
909
+ } else if (value === nothing) {
910
+ this.value = nothing;
911
+ this.clear();
912
+ } else {
913
+ this.__commitText(value);
914
+ }
915
+ }
916
+ __insert(node) {
917
+ this.endNode.parentNode.insertBefore(node, this.endNode);
918
+ }
919
+ __commitNode(value) {
920
+ if (this.value === value) {
921
+ return;
922
+ }
923
+ this.clear();
924
+ this.__insert(value);
925
+ this.value = value;
926
+ }
927
+ __commitText(value) {
928
+ const node = this.startNode.nextSibling;
929
+ value = value == null ? "" : value;
930
+ const valueAsString = typeof value === "string" ? value : String(value);
931
+ if (node === this.endNode.previousSibling && node.nodeType === 3) {
932
+ node.data = valueAsString;
933
+ } else {
934
+ this.__commitNode(document.createTextNode(valueAsString));
935
+ }
936
+ this.value = value;
937
+ }
938
+ __commitTemplateResult(value) {
939
+ const template = this.options.templateFactory(value);
940
+ if (this.value instanceof TemplateInstance && this.value.template === template) {
941
+ this.value.update(value.values);
942
+ } else {
943
+ const instance = new TemplateInstance(template, value.processor, this.options);
944
+ const fragment = instance._clone();
945
+ instance.update(value.values);
946
+ this.__commitNode(fragment);
947
+ this.value = instance;
948
+ }
949
+ }
950
+ __commitIterable(value) {
951
+ if (!Array.isArray(this.value)) {
952
+ this.value = [];
953
+ this.clear();
954
+ }
955
+ const itemParts = this.value;
956
+ let partIndex = 0;
957
+ let itemPart;
958
+ for (const item of value) {
959
+ itemPart = itemParts[partIndex];
960
+ if (itemPart === void 0) {
961
+ itemPart = new NodePart(this.options);
962
+ itemParts.push(itemPart);
963
+ if (partIndex === 0) {
964
+ itemPart.appendIntoPart(this);
965
+ } else {
966
+ itemPart.insertAfterPart(itemParts[partIndex - 1]);
967
+ }
968
+ }
969
+ itemPart.setValue(item);
970
+ itemPart.commit();
971
+ partIndex++;
972
+ }
973
+ if (partIndex < itemParts.length) {
974
+ itemParts.length = partIndex;
975
+ this.clear(itemPart && itemPart.endNode);
976
+ }
977
+ }
978
+ clear(startNode = this.startNode) {
979
+ removeNodes(this.startNode.parentNode, startNode.nextSibling, this.endNode);
980
+ }
981
+ };
982
+ var BooleanAttributePart = class {
983
+ constructor(element, name, strings) {
984
+ this.value = void 0;
985
+ this.__pendingValue = void 0;
986
+ if (strings.length !== 2 || strings[0] !== "" || strings[1] !== "") {
987
+ throw new Error("Boolean attributes can only contain a single expression");
988
+ }
989
+ this.element = element;
990
+ this.name = name;
991
+ this.strings = strings;
992
+ }
993
+ setValue(value) {
994
+ this.__pendingValue = value;
995
+ }
996
+ commit() {
997
+ while (isDirective(this.__pendingValue)) {
998
+ const directive2 = this.__pendingValue;
999
+ this.__pendingValue = noChange;
1000
+ directive2(this);
1001
+ }
1002
+ if (this.__pendingValue === noChange) {
1003
+ return;
1004
+ }
1005
+ const value = !!this.__pendingValue;
1006
+ if (this.value !== value) {
1007
+ if (value) {
1008
+ this.element.setAttribute(this.name, "");
1009
+ } else {
1010
+ this.element.removeAttribute(this.name);
1011
+ }
1012
+ this.value = value;
1013
+ }
1014
+ this.__pendingValue = noChange;
1015
+ }
1016
+ };
1017
+ var PropertyCommitter = class extends AttributeCommitter {
1018
+ constructor(element, name, strings) {
1019
+ super(element, name, strings);
1020
+ this.single = strings.length === 2 && strings[0] === "" && strings[1] === "";
1021
+ }
1022
+ _createPart() {
1023
+ return new PropertyPart(this);
1024
+ }
1025
+ _getValue() {
1026
+ if (this.single) {
1027
+ return this.parts[0].value;
1028
+ }
1029
+ return super._getValue();
1030
+ }
1031
+ commit() {
1032
+ if (this.dirty) {
1033
+ this.dirty = false;
1034
+ this.element[this.name] = this._getValue();
1035
+ }
1036
+ }
1037
+ };
1038
+ var PropertyPart = class extends AttributePart {
1039
+ };
1040
+ var eventOptionsSupported = false;
1041
+ (() => {
1042
+ try {
1043
+ const options = {
1044
+ get capture() {
1045
+ eventOptionsSupported = true;
1046
+ return false;
1047
+ }
1048
+ };
1049
+ window.addEventListener("test", options, options);
1050
+ window.removeEventListener("test", options, options);
1051
+ } catch (_e) {
1052
+ }
1053
+ })();
1054
+ var EventPart = class {
1055
+ constructor(element, eventName, eventContext) {
1056
+ this.value = void 0;
1057
+ this.__pendingValue = void 0;
1058
+ this.element = element;
1059
+ this.eventName = eventName;
1060
+ this.eventContext = eventContext;
1061
+ this.__boundHandleEvent = (e) => this.handleEvent(e);
1062
+ }
1063
+ setValue(value) {
1064
+ this.__pendingValue = value;
1065
+ }
1066
+ commit() {
1067
+ while (isDirective(this.__pendingValue)) {
1068
+ const directive2 = this.__pendingValue;
1069
+ this.__pendingValue = noChange;
1070
+ directive2(this);
1071
+ }
1072
+ if (this.__pendingValue === noChange) {
1073
+ return;
1074
+ }
1075
+ const newListener = this.__pendingValue;
1076
+ const oldListener = this.value;
1077
+ const shouldRemoveListener = newListener == null || oldListener != null && (newListener.capture !== oldListener.capture || newListener.once !== oldListener.once || newListener.passive !== oldListener.passive);
1078
+ const shouldAddListener = newListener != null && (oldListener == null || shouldRemoveListener);
1079
+ if (shouldRemoveListener) {
1080
+ this.element.removeEventListener(this.eventName, this.__boundHandleEvent, this.__options);
1081
+ }
1082
+ if (shouldAddListener) {
1083
+ this.__options = getOptions(newListener);
1084
+ this.element.addEventListener(this.eventName, this.__boundHandleEvent, this.__options);
1085
+ }
1086
+ this.value = newListener;
1087
+ this.__pendingValue = noChange;
1088
+ }
1089
+ handleEvent(event) {
1090
+ if (typeof this.value === "function") {
1091
+ this.value.call(this.eventContext || this.element, event);
1092
+ } else {
1093
+ this.value.handleEvent(event);
1094
+ }
1095
+ }
1096
+ };
1097
+ var getOptions = (o) => o && (eventOptionsSupported ? {capture: o.capture, passive: o.passive, once: o.once} : o.capture);
1098
+
1099
+ // node_modules/lit-html/lib/default-template-processor.js
1100
+ /**
1101
+ * @license
1102
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
1103
+ * This code may only be used under the BSD style license found at
1104
+ * http://polymer.github.io/LICENSE.txt
1105
+ * The complete set of authors may be found at
1106
+ * http://polymer.github.io/AUTHORS.txt
1107
+ * The complete set of contributors may be found at
1108
+ * http://polymer.github.io/CONTRIBUTORS.txt
1109
+ * Code distributed by Google as part of the polymer project is also
1110
+ * subject to an additional IP rights grant found at
1111
+ * http://polymer.github.io/PATENTS.txt
1112
+ */
1113
+ var DefaultTemplateProcessor = class {
1114
+ handleAttributeExpressions(element, name, strings, options) {
1115
+ const prefix = name[0];
1116
+ if (prefix === ".") {
1117
+ const committer2 = new PropertyCommitter(element, name.slice(1), strings);
1118
+ return committer2.parts;
1119
+ }
1120
+ if (prefix === "@") {
1121
+ return [new EventPart(element, name.slice(1), options.eventContext)];
1122
+ }
1123
+ if (prefix === "?") {
1124
+ return [new BooleanAttributePart(element, name.slice(1), strings)];
1125
+ }
1126
+ const committer = new AttributeCommitter(element, name, strings);
1127
+ return committer.parts;
1128
+ }
1129
+ handleTextExpression(options) {
1130
+ return new NodePart(options);
1131
+ }
1132
+ };
1133
+ var defaultTemplateProcessor = new DefaultTemplateProcessor();
1134
+
1135
+ // node_modules/lit-html/lib/template-factory.js
1136
+ /**
1137
+ * @license
1138
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
1139
+ * This code may only be used under the BSD style license found at
1140
+ * http://polymer.github.io/LICENSE.txt
1141
+ * The complete set of authors may be found at
1142
+ * http://polymer.github.io/AUTHORS.txt
1143
+ * The complete set of contributors may be found at
1144
+ * http://polymer.github.io/CONTRIBUTORS.txt
1145
+ * Code distributed by Google as part of the polymer project is also
1146
+ * subject to an additional IP rights grant found at
1147
+ * http://polymer.github.io/PATENTS.txt
1148
+ */
1149
+ function templateFactory(result) {
1150
+ let templateCache = templateCaches.get(result.type);
1151
+ if (templateCache === void 0) {
1152
+ templateCache = {
1153
+ stringsArray: new WeakMap(),
1154
+ keyString: new Map()
1155
+ };
1156
+ templateCaches.set(result.type, templateCache);
1157
+ }
1158
+ let template = templateCache.stringsArray.get(result.strings);
1159
+ if (template !== void 0) {
1160
+ return template;
1161
+ }
1162
+ const key = result.strings.join(marker);
1163
+ template = templateCache.keyString.get(key);
1164
+ if (template === void 0) {
1165
+ template = new Template(result, result.getTemplateElement());
1166
+ templateCache.keyString.set(key, template);
1167
+ }
1168
+ templateCache.stringsArray.set(result.strings, template);
1169
+ return template;
1170
+ }
1171
+ var templateCaches = new Map();
1172
+
1173
+ // node_modules/lit-html/lib/render.js
1174
+ /**
1175
+ * @license
1176
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
1177
+ * This code may only be used under the BSD style license found at
1178
+ * http://polymer.github.io/LICENSE.txt
1179
+ * The complete set of authors may be found at
1180
+ * http://polymer.github.io/AUTHORS.txt
1181
+ * The complete set of contributors may be found at
1182
+ * http://polymer.github.io/CONTRIBUTORS.txt
1183
+ * Code distributed by Google as part of the polymer project is also
1184
+ * subject to an additional IP rights grant found at
1185
+ * http://polymer.github.io/PATENTS.txt
1186
+ */
1187
+ var parts = new WeakMap();
1188
+ var render = (result, container, options) => {
1189
+ let part = parts.get(container);
1190
+ if (part === void 0) {
1191
+ removeNodes(container, container.firstChild);
1192
+ parts.set(container, part = new NodePart(Object.assign({templateFactory}, options)));
1193
+ part.appendInto(container);
1194
+ }
1195
+ part.setValue(result);
1196
+ part.commit();
1197
+ };
1198
+
1199
+ // node_modules/lit-html/lit-html.js
1200
+ /**
1201
+ * @license
1202
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
1203
+ * This code may only be used under the BSD style license found at
1204
+ * http://polymer.github.io/LICENSE.txt
1205
+ * The complete set of authors may be found at
1206
+ * http://polymer.github.io/AUTHORS.txt
1207
+ * The complete set of contributors may be found at
1208
+ * http://polymer.github.io/CONTRIBUTORS.txt
1209
+ * Code distributed by Google as part of the polymer project is also
1210
+ * subject to an additional IP rights grant found at
1211
+ * http://polymer.github.io/PATENTS.txt
1212
+ */
1213
+ if (typeof window !== "undefined") {
1214
+ (window["litHtmlVersions"] || (window["litHtmlVersions"] = [])).push("1.2.1");
1215
+ }
1216
+ var html = (strings, ...values) => new TemplateResult(strings, values, "html", defaultTemplateProcessor);
1217
+
1218
+ // node_modules/lit-html/lib/modify-template.js
1219
+ /**
1220
+ * @license
1221
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
1222
+ * This code may only be used under the BSD style license found at
1223
+ * http://polymer.github.io/LICENSE.txt
1224
+ * The complete set of authors may be found at
1225
+ * http://polymer.github.io/AUTHORS.txt
1226
+ * The complete set of contributors may be found at
1227
+ * http://polymer.github.io/CONTRIBUTORS.txt
1228
+ * Code distributed by Google as part of the polymer project is also
1229
+ * subject to an additional IP rights grant found at
1230
+ * http://polymer.github.io/PATENTS.txt
1231
+ */
1232
+ var walkerNodeFilter = 133;
1233
+ function removeNodesFromTemplate(template, nodesToRemove) {
1234
+ const {element: {content}, parts: parts2} = template;
1235
+ const walker = document.createTreeWalker(content, walkerNodeFilter, null, false);
1236
+ let partIndex = nextActiveIndexInTemplateParts(parts2);
1237
+ let part = parts2[partIndex];
1238
+ let nodeIndex = -1;
1239
+ let removeCount = 0;
1240
+ const nodesToRemoveInTemplate = [];
1241
+ let currentRemovingNode = null;
1242
+ while (walker.nextNode()) {
1243
+ nodeIndex++;
1244
+ const node = walker.currentNode;
1245
+ if (node.previousSibling === currentRemovingNode) {
1246
+ currentRemovingNode = null;
1247
+ }
1248
+ if (nodesToRemove.has(node)) {
1249
+ nodesToRemoveInTemplate.push(node);
1250
+ if (currentRemovingNode === null) {
1251
+ currentRemovingNode = node;
1252
+ }
1253
+ }
1254
+ if (currentRemovingNode !== null) {
1255
+ removeCount++;
1256
+ }
1257
+ while (part !== void 0 && part.index === nodeIndex) {
1258
+ part.index = currentRemovingNode !== null ? -1 : part.index - removeCount;
1259
+ partIndex = nextActiveIndexInTemplateParts(parts2, partIndex);
1260
+ part = parts2[partIndex];
1261
+ }
1262
+ }
1263
+ nodesToRemoveInTemplate.forEach((n) => n.parentNode.removeChild(n));
1264
+ }
1265
+ var countNodes = (node) => {
1266
+ let count = node.nodeType === 11 ? 0 : 1;
1267
+ const walker = document.createTreeWalker(node, walkerNodeFilter, null, false);
1268
+ while (walker.nextNode()) {
1269
+ count++;
1270
+ }
1271
+ return count;
1272
+ };
1273
+ var nextActiveIndexInTemplateParts = (parts2, startIndex = -1) => {
1274
+ for (let i = startIndex + 1; i < parts2.length; i++) {
1275
+ const part = parts2[i];
1276
+ if (isTemplatePartActive(part)) {
1277
+ return i;
1278
+ }
1279
+ }
1280
+ return -1;
1281
+ };
1282
+ function insertNodeIntoTemplate(template, node, refNode = null) {
1283
+ const {element: {content}, parts: parts2} = template;
1284
+ if (refNode === null || refNode === void 0) {
1285
+ content.appendChild(node);
1286
+ return;
1287
+ }
1288
+ const walker = document.createTreeWalker(content, walkerNodeFilter, null, false);
1289
+ let partIndex = nextActiveIndexInTemplateParts(parts2);
1290
+ let insertCount = 0;
1291
+ let walkerIndex = -1;
1292
+ while (walker.nextNode()) {
1293
+ walkerIndex++;
1294
+ const walkerNode = walker.currentNode;
1295
+ if (walkerNode === refNode) {
1296
+ insertCount = countNodes(node);
1297
+ refNode.parentNode.insertBefore(node, refNode);
1298
+ }
1299
+ while (partIndex !== -1 && parts2[partIndex].index === walkerIndex) {
1300
+ if (insertCount > 0) {
1301
+ while (partIndex !== -1) {
1302
+ parts2[partIndex].index += insertCount;
1303
+ partIndex = nextActiveIndexInTemplateParts(parts2, partIndex);
1304
+ }
1305
+ return;
1306
+ }
1307
+ partIndex = nextActiveIndexInTemplateParts(parts2, partIndex);
1308
+ }
1309
+ }
1310
+ }
1311
+
1312
+ // node_modules/lit-html/lib/shady-render.js
1313
+ /**
1314
+ * @license
1315
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
1316
+ * This code may only be used under the BSD style license found at
1317
+ * http://polymer.github.io/LICENSE.txt
1318
+ * The complete set of authors may be found at
1319
+ * http://polymer.github.io/AUTHORS.txt
1320
+ * The complete set of contributors may be found at
1321
+ * http://polymer.github.io/CONTRIBUTORS.txt
1322
+ * Code distributed by Google as part of the polymer project is also
1323
+ * subject to an additional IP rights grant found at
1324
+ * http://polymer.github.io/PATENTS.txt
1325
+ */
1326
+ var getTemplateCacheKey = (type, scopeName) => `${type}--${scopeName}`;
1327
+ var compatibleShadyCSSVersion = true;
1328
+ if (typeof window.ShadyCSS === "undefined") {
1329
+ compatibleShadyCSSVersion = false;
1330
+ } else if (typeof window.ShadyCSS.prepareTemplateDom === "undefined") {
1331
+ console.warn(`Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1.`);
1332
+ compatibleShadyCSSVersion = false;
1333
+ }
1334
+ var shadyTemplateFactory = (scopeName) => (result) => {
1335
+ const cacheKey = getTemplateCacheKey(result.type, scopeName);
1336
+ let templateCache = templateCaches.get(cacheKey);
1337
+ if (templateCache === void 0) {
1338
+ templateCache = {
1339
+ stringsArray: new WeakMap(),
1340
+ keyString: new Map()
1341
+ };
1342
+ templateCaches.set(cacheKey, templateCache);
1343
+ }
1344
+ let template = templateCache.stringsArray.get(result.strings);
1345
+ if (template !== void 0) {
1346
+ return template;
1347
+ }
1348
+ const key = result.strings.join(marker);
1349
+ template = templateCache.keyString.get(key);
1350
+ if (template === void 0) {
1351
+ const element = result.getTemplateElement();
1352
+ if (compatibleShadyCSSVersion) {
1353
+ window.ShadyCSS.prepareTemplateDom(element, scopeName);
1354
+ }
1355
+ template = new Template(result, element);
1356
+ templateCache.keyString.set(key, template);
1357
+ }
1358
+ templateCache.stringsArray.set(result.strings, template);
1359
+ return template;
1360
+ };
1361
+ var TEMPLATE_TYPES = ["html", "svg"];
1362
+ var removeStylesFromLitTemplates = (scopeName) => {
1363
+ TEMPLATE_TYPES.forEach((type) => {
1364
+ const templates = templateCaches.get(getTemplateCacheKey(type, scopeName));
1365
+ if (templates !== void 0) {
1366
+ templates.keyString.forEach((template) => {
1367
+ const {element: {content}} = template;
1368
+ const styles = new Set();
1369
+ Array.from(content.querySelectorAll("style")).forEach((s) => {
1370
+ styles.add(s);
1371
+ });
1372
+ removeNodesFromTemplate(template, styles);
1373
+ });
1374
+ }
1375
+ });
1376
+ };
1377
+ var shadyRenderSet = new Set();
1378
+ var prepareTemplateStyles = (scopeName, renderedDOM, template) => {
1379
+ shadyRenderSet.add(scopeName);
1380
+ const templateElement = !!template ? template.element : document.createElement("template");
1381
+ const styles = renderedDOM.querySelectorAll("style");
1382
+ const {length} = styles;
1383
+ if (length === 0) {
1384
+ window.ShadyCSS.prepareTemplateStyles(templateElement, scopeName);
1385
+ return;
1386
+ }
1387
+ const condensedStyle = document.createElement("style");
1388
+ for (let i = 0; i < length; i++) {
1389
+ const style2 = styles[i];
1390
+ style2.parentNode.removeChild(style2);
1391
+ condensedStyle.textContent += style2.textContent;
1392
+ }
1393
+ removeStylesFromLitTemplates(scopeName);
1394
+ const content = templateElement.content;
1395
+ if (!!template) {
1396
+ insertNodeIntoTemplate(template, condensedStyle, content.firstChild);
1397
+ } else {
1398
+ content.insertBefore(condensedStyle, content.firstChild);
1399
+ }
1400
+ window.ShadyCSS.prepareTemplateStyles(templateElement, scopeName);
1401
+ const style = content.querySelector("style");
1402
+ if (window.ShadyCSS.nativeShadow && style !== null) {
1403
+ renderedDOM.insertBefore(style.cloneNode(true), renderedDOM.firstChild);
1404
+ } else if (!!template) {
1405
+ content.insertBefore(condensedStyle, content.firstChild);
1406
+ const removes = new Set();
1407
+ removes.add(condensedStyle);
1408
+ removeNodesFromTemplate(template, removes);
1409
+ }
1410
+ };
1411
+ var render2 = (result, container, options) => {
1412
+ if (!options || typeof options !== "object" || !options.scopeName) {
1413
+ throw new Error("The `scopeName` option is required.");
1414
+ }
1415
+ const scopeName = options.scopeName;
1416
+ const hasRendered = parts.has(container);
1417
+ const needsScoping = compatibleShadyCSSVersion && container.nodeType === 11 && !!container.host;
1418
+ const firstScopeRender = needsScoping && !shadyRenderSet.has(scopeName);
1419
+ const renderContainer = firstScopeRender ? document.createDocumentFragment() : container;
1420
+ render(result, renderContainer, Object.assign({templateFactory: shadyTemplateFactory(scopeName)}, options));
1421
+ if (firstScopeRender) {
1422
+ const part = parts.get(renderContainer);
1423
+ parts.delete(renderContainer);
1424
+ const template = part.value instanceof TemplateInstance ? part.value.template : void 0;
1425
+ prepareTemplateStyles(scopeName, renderContainer, template);
1426
+ removeNodes(container, container.firstChild);
1427
+ container.appendChild(renderContainer);
1428
+ parts.set(container, part);
1429
+ }
1430
+ if (!hasRendered && needsScoping) {
1431
+ window.ShadyCSS.styleElement(container.host);
1432
+ }
1433
+ };
1434
+
1435
+ // src/TemplateElement.js
1436
+ var TemplateElement = class extends StyledElement {
1437
+ constructor(options) {
1438
+ super({
1439
+ deferUpdate: false,
1440
+ shadowRender: false,
1441
+ styles: [],
1442
+ adoptGlobalStyles: true,
1443
+ mutationObserverOptions: {
1444
+ childList: false
1445
+ },
1446
+ ...options
1447
+ });
1448
+ this._template = this._options.template;
1449
+ if (this._options.shadowRender)
1450
+ this.attachShadow({mode: "open"});
1451
+ }
1452
+ template() {
1453
+ return html``;
1454
+ }
1455
+ update(options) {
1456
+ this.renderTemplate();
1457
+ super.update(options);
1458
+ }
1459
+ renderTemplate() {
1460
+ const template = this._template || this.template();
1461
+ if (typeof template === "string") {
1462
+ this.getRoot().innerHTML = `${template}`;
1463
+ } else {
1464
+ render2(html` ${template} `, this.getRoot(), {
1465
+ scopeName: this.localName,
1466
+ eventContext: this
1467
+ });
1468
+ }
1469
+ }
1470
+ getRoot() {
1471
+ return this.shadowRoot !== null ? this.shadowRoot : this;
1472
+ }
1473
+ };
1474
+ export {
1475
+ BaseElement,
1476
+ StyledElement,
1477
+ TemplateElement,
1478
+ defineElement,
1479
+ html,
1480
+ i18n,
1481
+ toString
1482
+ };
1483
+ //# sourceMappingURL=index.js.map