@saasquatch/vanilla-components 1.2.3-1 → 1.2.4-1

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.
Files changed (92) hide show
  1. package/LICENSE +21 -21
  2. package/dist/cjs/{WidgetHost-d7b870ce.js → WidgetHost-71b013eb.js} +615 -615
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/sqh-close-button.cjs.entry.js +27 -22
  5. package/dist/cjs/sqh-copy-button_12.cjs.entry.js +1054 -980
  6. package/dist/cjs/sqh-referral-code.cjs.entry.js +22 -22
  7. package/dist/cjs/sqh-rewards-actions.cjs.entry.js +26 -11
  8. package/dist/cjs/widget-components.cjs.js +1 -1
  9. package/dist/collection/components/close-button/close-button.js +67 -56
  10. package/dist/collection/components/copy-button/copy-button.js +386 -293
  11. package/dist/collection/components/copy-link-button/copy-link-button.js +230 -182
  12. package/dist/collection/components/global-container/global-container.js +169 -126
  13. package/dist/collection/components/image-component/image-component.js +174 -132
  14. package/dist/collection/components/partner-stat-component/partner-stat-component.js +185 -155
  15. package/dist/collection/components/referral-code/referral-code.js +33 -30
  16. package/dist/collection/components/referral-component/referral-component.js +254 -236
  17. package/dist/collection/components/referral-list/referral-list.js +929 -671
  18. package/dist/collection/components/rewards-actions/rewards-actions.js +104 -77
  19. package/dist/collection/components/share-button/share-button.js +309 -255
  20. package/dist/collection/components/share-button-container/share-button-container.js +2467 -1534
  21. package/dist/collection/components/stat-component/stat-component.js +185 -155
  22. package/dist/collection/components/stats-container/stats-container.js +204 -180
  23. package/dist/collection/components/text-component/text-component.js +276 -249
  24. package/dist/collection/entrypoint.js +32 -32
  25. package/dist/collection/global/global.js +4 -4
  26. package/dist/collection/services/FormatJs.js +15 -15
  27. package/dist/collection/services/WidgetHost.js +621 -621
  28. package/dist/collection/utilities.js +81 -81
  29. package/dist/esm/{WidgetHost-a27e693d.js → WidgetHost-9c337319.js} +615 -615
  30. package/dist/esm/loader.mjs +1 -1
  31. package/dist/esm/polyfills/core-js.js +0 -0
  32. package/dist/esm/polyfills/dom.js +0 -0
  33. package/dist/esm/polyfills/es5-html-element.js +0 -0
  34. package/dist/esm/polyfills/index.js +0 -0
  35. package/dist/esm/polyfills/system.js +0 -0
  36. package/dist/esm/sqh-close-button.entry.js +27 -22
  37. package/dist/esm/sqh-copy-button_12.entry.js +1053 -979
  38. package/dist/esm/sqh-referral-code.entry.js +22 -22
  39. package/dist/esm/sqh-rewards-actions.entry.js +26 -11
  40. package/dist/esm/widget-components.mjs +1 -1
  41. package/dist/esm-es5/{WidgetHost-a27e693d.js → WidgetHost-9c337319.js} +9432 -9432
  42. package/dist/esm-es5/_commonjsHelpers-1d681858.js +17 -17
  43. package/dist/esm-es5/css-shim-a659079f.js +122 -122
  44. package/dist/esm-es5/dom-4061ceba.js +468 -468
  45. package/dist/esm-es5/en-be593af0.js +1471 -1471
  46. package/dist/esm-es5/index-8ea8b6d8.js +1758 -1758
  47. package/dist/esm-es5/loader.mjs +11 -11
  48. package/dist/esm-es5/sqh-close-button.entry.js +35 -30
  49. package/dist/esm-es5/sqh-copy-button_12.entry.js +9571 -9485
  50. package/dist/esm-es5/sqh-referral-code.entry.js +29 -29
  51. package/dist/esm-es5/sqh-rewards-actions.entry.js +31 -16
  52. package/dist/esm-es5/widget-components.mjs +6 -6
  53. package/dist/types/components/close-button/close-button.d.ts +15 -7
  54. package/dist/types/components/copy-button/copy-button.d.ts +104 -23
  55. package/dist/types/components/copy-link-button/copy-link-button.d.ts +59 -17
  56. package/dist/types/components/global-container/global-container.d.ts +46 -9
  57. package/dist/types/components/image-component/image-component.d.ts +50 -9
  58. package/dist/types/components/partner-stat-component/partner-stat-component.d.ts +48 -16
  59. package/dist/types/components/referral-code/referral-code.d.ts +9 -6
  60. package/dist/types/components/referral-component/referral-component.d.ts +45 -17
  61. package/dist/types/components/referral-list/referral-list.d.ts +248 -44
  62. package/dist/types/components/rewards-actions/rewards-actions.d.ts +24 -6
  63. package/dist/types/components/share-button/share-button.d.ts +81 -17
  64. package/dist/types/components/share-button-container/share-button-container.d.ts +681 -97
  65. package/dist/types/components/stat-component/stat-component.d.ts +47 -16
  66. package/dist/types/components/stats-container/stats-container.d.ts +44 -23
  67. package/dist/types/components/text-component/text-component.d.ts +77 -16
  68. package/dist/types/components.d.ts +2050 -2
  69. package/dist/types/global/global.d.ts +4 -4
  70. package/dist/types/saasquatch.d.ts +103 -103
  71. package/dist/types/services/FormatJs.d.ts +7 -7
  72. package/dist/types/services/WidgetHost.d.ts +45 -45
  73. package/dist/types/utilities.d.ts +7 -7
  74. package/dist/widget-components/entrypoint.js +32 -32
  75. package/dist/widget-components/p-24fc4ba9.js +1 -1
  76. package/dist/widget-components/{p-d4b27c72.entry.js → p-366f1663.entry.js} +1 -1
  77. package/dist/widget-components/p-46109683.js +3 -3
  78. package/dist/widget-components/{p-650d012d.entry.js → p-54ea7a00.entry.js} +1 -1
  79. package/dist/widget-components/p-58be1132.system.js +1 -1
  80. package/dist/widget-components/{p-9adc7c50.system.js → p-8e232564.system.js} +0 -0
  81. package/dist/widget-components/{p-c0cdba77.system.entry.js → p-b17efca4.system.entry.js} +1 -1
  82. package/dist/widget-components/p-c8bc8c77.system.entry.js +1 -0
  83. package/dist/widget-components/{p-93574d86.entry.js → p-d416634a.entry.js} +16 -16
  84. package/dist/widget-components/p-d97c955d.system.entry.js +8 -0
  85. package/dist/widget-components/{p-9525bf4a.js → p-edd43dbc.js} +0 -0
  86. package/dist/widget-components/widget-components.esm.js +1 -1
  87. package/dist/widget-components/widget-components.js +1 -1
  88. package/docs/raisins.json +1 -0
  89. package/package.json +96 -89
  90. package/readme.md +52 -52
  91. package/dist/widget-components/p-45e253f6.system.entry.js +0 -8
  92. package/dist/widget-components/p-908068c2.system.entry.js +0 -1
@@ -1,1758 +1,1758 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- extendStatics(d, b);
10
- function __() { this.constructor = d; }
11
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
- };
13
- })();
14
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
- return new (P || (P = Promise))(function (resolve, reject) {
17
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
- step((generator = generator.apply(thisArg, _arguments || [])).next());
21
- });
22
- };
23
- var __generator = (this && this.__generator) || function (thisArg, body) {
24
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
25
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
- function verb(n) { return function (v) { return step([n, v]); }; }
27
- function step(op) {
28
- if (f) throw new TypeError("Generator is already executing.");
29
- while (_) try {
30
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
31
- if (y = 0, t) op = [op[0] & 2, t.value];
32
- switch (op[0]) {
33
- case 0: case 1: t = op; break;
34
- case 4: _.label++; return { value: op[1], done: false };
35
- case 5: _.label++; y = op[1]; op = [0]; continue;
36
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
37
- default:
38
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42
- if (t[2]) _.ops.pop();
43
- _.trys.pop(); continue;
44
- }
45
- op = body.call(thisArg, _);
46
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
- }
49
- };
50
- var __spreadArrays = (this && this.__spreadArrays) || function () {
51
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
52
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
53
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
54
- r[k] = a[j];
55
- return r;
56
- };
57
- var NAMESPACE = 'widget-components';
58
- var contentRef;
59
- var hostTagName;
60
- var useNativeShadowDom = false;
61
- var checkSlotFallbackVisibility = false;
62
- var checkSlotRelocate = false;
63
- var isSvgMode = false;
64
- var queueCongestion = 0;
65
- var queuePending = false;
66
- var win = typeof window !== 'undefined' ? window : {};
67
- var CSS = win.CSS;
68
- var doc = win.document || { head: {} };
69
- var H = (win.HTMLElement || /** @class */ (function () {
70
- function HTMLElement() {
71
- }
72
- return HTMLElement;
73
- }()));
74
- var plt = {
75
- $flags$: 0,
76
- $resourcesUrl$: '',
77
- jmp: function (h) { return h(); },
78
- raf: function (h) { return requestAnimationFrame(h); },
79
- ael: function (el, eventName, listener, opts) { return el.addEventListener(eventName, listener, opts); },
80
- rel: function (el, eventName, listener, opts) { return el.removeEventListener(eventName, listener, opts); },
81
- ce: function (eventName, opts) { return new CustomEvent(eventName, opts); },
82
- };
83
- var promiseResolve = function (v) { return Promise.resolve(v); };
84
- var supportsConstructibleStylesheets = /*@__PURE__*/ (function () {
85
- try {
86
- new CSSStyleSheet();
87
- return true;
88
- }
89
- catch (e) { }
90
- return false;
91
- })();
92
- var addHostEventListeners = function (elm, hostRef, listeners, attachParentListeners) {
93
- if (listeners) {
94
- listeners.map(function (_a) {
95
- var flags = _a[0], name = _a[1], method = _a[2];
96
- var target = elm;
97
- var handler = hostListenerProxy(hostRef, method);
98
- var opts = hostListenerOpts(flags);
99
- plt.ael(target, name, handler, opts);
100
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(function () { return plt.rel(target, name, handler, opts); });
101
- });
102
- }
103
- };
104
- var hostListenerProxy = function (hostRef, methodName) { return function (ev) {
105
- {
106
- if (hostRef.$flags$ & 256 /* isListenReady */) {
107
- // instance is ready, let's call it's member method for this event
108
- hostRef.$lazyInstance$[methodName](ev);
109
- }
110
- else {
111
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
112
- }
113
- }
114
- }; };
115
- // prettier-ignore
116
- var hostListenerOpts = function (flags) { return (flags & 2 /* Capture */) !== 0; };
117
- var HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
118
- var createTime = function (fnName, tagName) {
119
- if (tagName === void 0) { tagName = ''; }
120
- {
121
- return function () {
122
- return;
123
- };
124
- }
125
- };
126
- var uniqueTime = function (key, measureText) {
127
- {
128
- return function () {
129
- return;
130
- };
131
- }
132
- };
133
- var rootAppliedStyles = new WeakMap();
134
- var registerStyle = function (scopeId, cssText, allowCS) {
135
- var style = styles.get(scopeId);
136
- if (supportsConstructibleStylesheets && allowCS) {
137
- style = (style || new CSSStyleSheet());
138
- style.replace(cssText);
139
- }
140
- else {
141
- style = cssText;
142
- }
143
- styles.set(scopeId, style);
144
- };
145
- var addStyle = function (styleContainerNode, cmpMeta, mode, hostElm) {
146
- var scopeId = getScopeId(cmpMeta);
147
- var style = styles.get(scopeId);
148
- // if an element is NOT connected then getRootNode() will return the wrong root node
149
- // so the fallback is to always use the document for the root node in those cases
150
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
151
- if (style) {
152
- if (typeof style === 'string') {
153
- styleContainerNode = styleContainerNode.head || styleContainerNode;
154
- var appliedStyles = rootAppliedStyles.get(styleContainerNode);
155
- var styleElm = void 0;
156
- if (!appliedStyles) {
157
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
158
- }
159
- if (!appliedStyles.has(scopeId)) {
160
- {
161
- if (plt.$cssShim$) {
162
- styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */));
163
- var newScopeId = styleElm['s-sc'];
164
- if (newScopeId) {
165
- scopeId = newScopeId;
166
- // we don't want to add this styleID to the appliedStyles Set
167
- // since the cssVarShim might need to apply several different
168
- // stylesheets for the same component
169
- appliedStyles = null;
170
- }
171
- }
172
- else {
173
- styleElm = doc.createElement('style');
174
- styleElm.innerHTML = style;
175
- }
176
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
177
- }
178
- if (appliedStyles) {
179
- appliedStyles.add(scopeId);
180
- }
181
- }
182
- }
183
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
184
- styleContainerNode.adoptedStyleSheets = __spreadArrays(styleContainerNode.adoptedStyleSheets, [style]);
185
- }
186
- }
187
- return scopeId;
188
- };
189
- var attachStyles = function (hostRef) {
190
- var cmpMeta = hostRef.$cmpMeta$;
191
- var elm = hostRef.$hostElement$;
192
- var endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
193
- var scopeId = addStyle(elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
194
- endAttachStyles();
195
- };
196
- var getScopeId = function (cmp, mode) { return 'sc-' + (cmp.$tagName$); };
197
- /**
198
- * Default style mode id
199
- */
200
- /**
201
- * Reusable empty obj/array
202
- * Don't add values to these!!
203
- */
204
- var EMPTY_OBJ = {};
205
- var noop = function () {
206
- /* noop*/
207
- };
208
- var isComplexType = function (o) {
209
- // https://jsperf.com/typeof-fn-object/5
210
- o = typeof o;
211
- return o === 'object' || o === 'function';
212
- };
213
- var IS_DENO_ENV = typeof Deno !== 'undefined';
214
- var IS_NODE_ENV = !IS_DENO_ENV &&
215
- typeof global !== 'undefined' &&
216
- typeof require === 'function' &&
217
- !!global.process &&
218
- typeof __filename === 'string' &&
219
- (!global.origin || typeof global.origin !== 'string');
220
- var IS_DENO_WINDOWS_ENV = IS_DENO_ENV && Deno.build.os === 'windows';
221
- var getCurrentDirectory = IS_NODE_ENV ? process.cwd : IS_DENO_ENV ? Deno.cwd : function () { return '/'; };
222
- var exit = IS_NODE_ENV ? process.exit : IS_DENO_ENV ? Deno.exit : noop;
223
- /**
224
- * Production h() function based on Preact by
225
- * Jason Miller (@developit)
226
- * Licensed under the MIT License
227
- * https://github.com/developit/preact/blob/master/LICENSE
228
- *
229
- * Modified for Stencil's compiler and vdom
230
- */
231
- // const stack: any[] = [];
232
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
233
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
234
- var h = function (nodeName, vnodeData) {
235
- var children = [];
236
- for (var _i = 2; _i < arguments.length; _i++) {
237
- children[_i - 2] = arguments[_i];
238
- }
239
- var child = null;
240
- var slotName = null;
241
- var simple = false;
242
- var lastSimple = false;
243
- var vNodeChildren = [];
244
- var walk = function (c) {
245
- for (var i = 0; i < c.length; i++) {
246
- child = c[i];
247
- if (Array.isArray(child)) {
248
- walk(child);
249
- }
250
- else if (child != null && typeof child !== 'boolean') {
251
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
252
- child = String(child);
253
- }
254
- if (simple && lastSimple) {
255
- // If the previous child was simple (string), we merge both
256
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
257
- }
258
- else {
259
- // Append a new vNode, if it's text, we create a text vNode
260
- vNodeChildren.push(simple ? newVNode(null, child) : child);
261
- }
262
- lastSimple = simple;
263
- }
264
- }
265
- };
266
- walk(children);
267
- if (vnodeData) {
268
- if (vnodeData.name) {
269
- slotName = vnodeData.name;
270
- }
271
- {
272
- var classData_1 = vnodeData.className || vnodeData.class;
273
- if (classData_1) {
274
- vnodeData.class =
275
- typeof classData_1 !== 'object'
276
- ? classData_1
277
- : Object.keys(classData_1)
278
- .filter(function (k) { return classData_1[k]; })
279
- .join(' ');
280
- }
281
- }
282
- }
283
- if (typeof nodeName === 'function') {
284
- // nodeName is a functional component
285
- return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
286
- }
287
- var vnode = newVNode(nodeName, null);
288
- vnode.$attrs$ = vnodeData;
289
- if (vNodeChildren.length > 0) {
290
- vnode.$children$ = vNodeChildren;
291
- }
292
- {
293
- vnode.$name$ = slotName;
294
- }
295
- return vnode;
296
- };
297
- var newVNode = function (tag, text) {
298
- var vnode = {
299
- $flags$: 0,
300
- $tag$: tag,
301
- $text$: text,
302
- $elm$: null,
303
- $children$: null,
304
- };
305
- {
306
- vnode.$attrs$ = null;
307
- }
308
- {
309
- vnode.$name$ = null;
310
- }
311
- return vnode;
312
- };
313
- var Host = {};
314
- var isHost = function (node) { return node && node.$tag$ === Host; };
315
- var vdomFnUtils = {
316
- forEach: function (children, cb) { return children.map(convertToPublic).forEach(cb); },
317
- map: function (children, cb) { return children
318
- .map(convertToPublic)
319
- .map(cb)
320
- .map(convertToPrivate); },
321
- };
322
- var convertToPublic = function (node) { return ({
323
- vattrs: node.$attrs$,
324
- vchildren: node.$children$,
325
- vkey: node.$key$,
326
- vname: node.$name$,
327
- vtag: node.$tag$,
328
- vtext: node.$text$,
329
- }); };
330
- var convertToPrivate = function (node) {
331
- if (typeof node.vtag === 'function') {
332
- var vnodeData = Object.assign({}, node.vattrs);
333
- if (node.vkey) {
334
- vnodeData.key = node.vkey;
335
- }
336
- if (node.vname) {
337
- vnodeData.name = node.vname;
338
- }
339
- return h.apply(void 0, __spreadArrays([node.vtag, vnodeData], node.vchildren || []));
340
- }
341
- var vnode = newVNode(node.vtag, node.vtext);
342
- vnode.$attrs$ = node.vattrs;
343
- vnode.$children$ = node.vchildren;
344
- vnode.$key$ = node.vkey;
345
- vnode.$name$ = node.vname;
346
- return vnode;
347
- };
348
- /**
349
- * Production setAccessor() function based on Preact by
350
- * Jason Miller (@developit)
351
- * Licensed under the MIT License
352
- * https://github.com/developit/preact/blob/master/LICENSE
353
- *
354
- * Modified for Stencil's compiler and vdom
355
- */
356
- var setAccessor = function (elm, memberName, oldValue, newValue, isSvg, flags) {
357
- if (oldValue !== newValue) {
358
- var isProp = isMemberInElement(elm, memberName);
359
- var ln = memberName.toLowerCase();
360
- if (memberName === 'class') {
361
- var classList = elm.classList;
362
- var oldClasses_1 = parseClassList(oldValue);
363
- var newClasses_1 = parseClassList(newValue);
364
- classList.remove.apply(classList, oldClasses_1.filter(function (c) { return c && !newClasses_1.includes(c); }));
365
- classList.add.apply(classList, newClasses_1.filter(function (c) { return c && !oldClasses_1.includes(c); }));
366
- }
367
- else if ((!isProp) && memberName[0] === 'o' && memberName[1] === 'n') {
368
- // Event Handlers
369
- // so if the member name starts with "on" and the 3rd characters is
370
- // a capital letter, and it's not already a member on the element,
371
- // then we're assuming it's an event listener
372
- if (memberName[2] === '-') {
373
- // on- prefixed events
374
- // allows to be explicit about the dom event to listen without any magic
375
- // under the hood:
376
- // <my-cmp on-click> // listens for "click"
377
- // <my-cmp on-Click> // listens for "Click"
378
- // <my-cmp on-ionChange> // listens for "ionChange"
379
- // <my-cmp on-EVENTS> // listens for "EVENTS"
380
- memberName = memberName.slice(3);
381
- }
382
- else if (isMemberInElement(win, ln)) {
383
- // standard event
384
- // the JSX attribute could have been "onMouseOver" and the
385
- // member name "onmouseover" is on the window's prototype
386
- // so let's add the listener "mouseover", which is all lowercased
387
- memberName = ln.slice(2);
388
- }
389
- else {
390
- // custom event
391
- // the JSX attribute could have been "onMyCustomEvent"
392
- // so let's trim off the "on" prefix and lowercase the first character
393
- // and add the listener "myCustomEvent"
394
- // except for the first character, we keep the event name case
395
- memberName = ln[2] + memberName.slice(3);
396
- }
397
- if (oldValue) {
398
- plt.rel(elm, memberName, oldValue, false);
399
- }
400
- if (newValue) {
401
- plt.ael(elm, memberName, newValue, false);
402
- }
403
- }
404
- else {
405
- // Set property if it exists and it's not a SVG
406
- var isComplex = isComplexType(newValue);
407
- if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
408
- try {
409
- if (!elm.tagName.includes('-')) {
410
- var n = newValue == null ? '' : newValue;
411
- // Workaround for Safari, moving the <input> caret when re-assigning the same valued
412
- if (memberName === 'list') {
413
- isProp = false;
414
- // tslint:disable-next-line: triple-equals
415
- }
416
- else if (oldValue == null || elm[memberName] != n) {
417
- elm[memberName] = n;
418
- }
419
- }
420
- else {
421
- elm[memberName] = newValue;
422
- }
423
- }
424
- catch (e) { }
425
- }
426
- if (newValue == null || newValue === false) {
427
- if (newValue !== false || elm.getAttribute(memberName) === '') {
428
- {
429
- elm.removeAttribute(memberName);
430
- }
431
- }
432
- }
433
- else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
434
- newValue = newValue === true ? '' : newValue;
435
- {
436
- elm.setAttribute(memberName, newValue);
437
- }
438
- }
439
- }
440
- }
441
- };
442
- var parseClassListRegex = /\s/;
443
- var parseClassList = function (value) { return (!value ? [] : value.split(parseClassListRegex)); };
444
- var updateElement = function (oldVnode, newVnode, isSvgMode, memberName) {
445
- // if the element passed in is a shadow root, which is a document fragment
446
- // then we want to be adding attrs/props to the shadow root's "host" element
447
- // if it's not a shadow root, then we add attrs/props to the same element
448
- var elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
449
- var oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
450
- var newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
451
- {
452
- // remove attributes no longer present on the vnode by setting them to undefined
453
- for (memberName in oldVnodeAttrs) {
454
- if (!(memberName in newVnodeAttrs)) {
455
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
456
- }
457
- }
458
- }
459
- // add new & update changed attributes
460
- for (memberName in newVnodeAttrs) {
461
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
462
- }
463
- };
464
- var createElm = function (oldParentVNode, newParentVNode, childIndex, parentElm) {
465
- // tslint:disable-next-line: prefer-const
466
- var newVNode = newParentVNode.$children$[childIndex];
467
- var i = 0;
468
- var elm;
469
- var childNode;
470
- var oldVNode;
471
- if (!useNativeShadowDom) {
472
- // remember for later we need to check to relocate nodes
473
- checkSlotRelocate = true;
474
- if (newVNode.$tag$ === 'slot') {
475
- newVNode.$flags$ |= newVNode.$children$
476
- ? // slot element has fallback content
477
- 2 /* isSlotFallback */
478
- : // slot element does not have fallback content
479
- 1 /* isSlotReference */;
480
- }
481
- }
482
- if (newVNode.$text$ !== null) {
483
- // create text node
484
- elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
485
- }
486
- else if (newVNode.$flags$ & 1 /* isSlotReference */) {
487
- // create a slot reference node
488
- elm = newVNode.$elm$ = doc.createTextNode('');
489
- }
490
- else {
491
- // create element
492
- elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* isSlotFallback */ ? 'slot-fb' : newVNode.$tag$));
493
- // add css classes, attrs, props, listeners, etc.
494
- {
495
- updateElement(null, newVNode, isSvgMode);
496
- }
497
- if (newVNode.$children$) {
498
- for (i = 0; i < newVNode.$children$.length; ++i) {
499
- // create the node
500
- childNode = createElm(oldParentVNode, newVNode, i);
501
- // return node could have been null
502
- if (childNode) {
503
- // append our new node
504
- elm.appendChild(childNode);
505
- }
506
- }
507
- }
508
- }
509
- {
510
- elm['s-hn'] = hostTagName;
511
- if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
512
- // remember the content reference comment
513
- elm['s-sr'] = true;
514
- // remember the content reference comment
515
- elm['s-cr'] = contentRef;
516
- // remember the slot name, or empty string for default slot
517
- elm['s-sn'] = newVNode.$name$ || '';
518
- // check if we've got an old vnode for this slot
519
- oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
520
- if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
521
- // we've got an old slot vnode and the wrapper is being replaced
522
- // so let's move the old slot content back to it's original location
523
- putBackInOriginalLocation(oldParentVNode.$elm$, false);
524
- }
525
- }
526
- }
527
- return elm;
528
- };
529
- var putBackInOriginalLocation = function (parentElm, recursive) {
530
- plt.$flags$ |= 1 /* isTmpDisconnected */;
531
- var oldSlotChildNodes = parentElm.childNodes;
532
- for (var i = oldSlotChildNodes.length - 1; i >= 0; i--) {
533
- var childNode = oldSlotChildNodes[i];
534
- if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
535
- // // this child node in the old element is from another component
536
- // // remove this node from the old slot's parent
537
- // childNode.remove();
538
- // and relocate it back to it's original location
539
- parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
540
- // remove the old original location comment entirely
541
- // later on the patch function will know what to do
542
- // and move this to the correct spot in need be
543
- childNode['s-ol'].remove();
544
- childNode['s-ol'] = undefined;
545
- checkSlotRelocate = true;
546
- }
547
- if (recursive) {
548
- putBackInOriginalLocation(childNode, recursive);
549
- }
550
- }
551
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
552
- };
553
- var addVnodes = function (parentElm, before, parentVNode, vnodes, startIdx, endIdx) {
554
- var containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
555
- var childNode;
556
- for (; startIdx <= endIdx; ++startIdx) {
557
- if (vnodes[startIdx]) {
558
- childNode = createElm(null, parentVNode, startIdx);
559
- if (childNode) {
560
- vnodes[startIdx].$elm$ = childNode;
561
- containerElm.insertBefore(childNode, referenceNode(before));
562
- }
563
- }
564
- }
565
- };
566
- var removeVnodes = function (vnodes, startIdx, endIdx, vnode, elm) {
567
- for (; startIdx <= endIdx; ++startIdx) {
568
- if ((vnode = vnodes[startIdx])) {
569
- elm = vnode.$elm$;
570
- {
571
- // we're removing this element
572
- // so it's possible we need to show slot fallback content now
573
- checkSlotFallbackVisibility = true;
574
- if (elm['s-ol']) {
575
- // remove the original location comment
576
- elm['s-ol'].remove();
577
- }
578
- else {
579
- // it's possible that child nodes of the node
580
- // that's being removed are slot nodes
581
- putBackInOriginalLocation(elm, true);
582
- }
583
- }
584
- // remove the vnode's element from the dom
585
- elm.remove();
586
- }
587
- }
588
- };
589
- var updateChildren = function (parentElm, oldCh, newVNode, newCh) {
590
- var oldStartIdx = 0;
591
- var newStartIdx = 0;
592
- var oldEndIdx = oldCh.length - 1;
593
- var oldStartVnode = oldCh[0];
594
- var oldEndVnode = oldCh[oldEndIdx];
595
- var newEndIdx = newCh.length - 1;
596
- var newStartVnode = newCh[0];
597
- var newEndVnode = newCh[newEndIdx];
598
- var node;
599
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
600
- if (oldStartVnode == null) {
601
- // Vnode might have been moved left
602
- oldStartVnode = oldCh[++oldStartIdx];
603
- }
604
- else if (oldEndVnode == null) {
605
- oldEndVnode = oldCh[--oldEndIdx];
606
- }
607
- else if (newStartVnode == null) {
608
- newStartVnode = newCh[++newStartIdx];
609
- }
610
- else if (newEndVnode == null) {
611
- newEndVnode = newCh[--newEndIdx];
612
- }
613
- else if (isSameVnode(oldStartVnode, newStartVnode)) {
614
- patch(oldStartVnode, newStartVnode);
615
- oldStartVnode = oldCh[++oldStartIdx];
616
- newStartVnode = newCh[++newStartIdx];
617
- }
618
- else if (isSameVnode(oldEndVnode, newEndVnode)) {
619
- patch(oldEndVnode, newEndVnode);
620
- oldEndVnode = oldCh[--oldEndIdx];
621
- newEndVnode = newCh[--newEndIdx];
622
- }
623
- else if (isSameVnode(oldStartVnode, newEndVnode)) {
624
- // Vnode moved right
625
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
626
- putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
627
- }
628
- patch(oldStartVnode, newEndVnode);
629
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
630
- oldStartVnode = oldCh[++oldStartIdx];
631
- newEndVnode = newCh[--newEndIdx];
632
- }
633
- else if (isSameVnode(oldEndVnode, newStartVnode)) {
634
- // Vnode moved left
635
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
636
- putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
637
- }
638
- patch(oldEndVnode, newStartVnode);
639
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
640
- oldEndVnode = oldCh[--oldEndIdx];
641
- newStartVnode = newCh[++newStartIdx];
642
- }
643
- else {
644
- {
645
- // new element
646
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
647
- newStartVnode = newCh[++newStartIdx];
648
- }
649
- if (node) {
650
- {
651
- parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
652
- }
653
- }
654
- }
655
- }
656
- if (oldStartIdx > oldEndIdx) {
657
- addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
658
- }
659
- else if (newStartIdx > newEndIdx) {
660
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
661
- }
662
- };
663
- var isSameVnode = function (vnode1, vnode2) {
664
- // compare if two vnode to see if they're "technically" the same
665
- // need to have the same element tag, and same key to be the same
666
- if (vnode1.$tag$ === vnode2.$tag$) {
667
- if (vnode1.$tag$ === 'slot') {
668
- return vnode1.$name$ === vnode2.$name$;
669
- }
670
- return true;
671
- }
672
- return false;
673
- };
674
- var referenceNode = function (node) {
675
- // this node was relocated to a new location in the dom
676
- // because of some other component's slot
677
- // but we still have an html comment in place of where
678
- // it's original location was according to it's original vdom
679
- return (node && node['s-ol']) || node;
680
- };
681
- var parentReferenceNode = function (node) { return (node['s-ol'] ? node['s-ol'] : node).parentNode; };
682
- var patch = function (oldVNode, newVNode) {
683
- var elm = (newVNode.$elm$ = oldVNode.$elm$);
684
- var oldChildren = oldVNode.$children$;
685
- var newChildren = newVNode.$children$;
686
- var tag = newVNode.$tag$;
687
- var text = newVNode.$text$;
688
- var defaultHolder;
689
- if (text === null) {
690
- // element node
691
- {
692
- if (tag === 'slot')
693
- ;
694
- else {
695
- // either this is the first render of an element OR it's an update
696
- // AND we already know it's possible it could have changed
697
- // this updates the element's css classes, attrs, props, listeners, etc.
698
- updateElement(oldVNode, newVNode, isSvgMode);
699
- }
700
- }
701
- if (oldChildren !== null && newChildren !== null) {
702
- // looks like there's child vnodes for both the old and new vnodes
703
- updateChildren(elm, oldChildren, newVNode, newChildren);
704
- }
705
- else if (newChildren !== null) {
706
- // no old child vnodes, but there are new child vnodes to add
707
- if (oldVNode.$text$ !== null) {
708
- // the old vnode was text, so be sure to clear it out
709
- elm.textContent = '';
710
- }
711
- // add the new vnode children
712
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
713
- }
714
- else if (oldChildren !== null) {
715
- // no new child vnodes, but there are old child vnodes to remove
716
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
717
- }
718
- }
719
- else if ((defaultHolder = elm['s-cr'])) {
720
- // this element has slotted content
721
- defaultHolder.parentNode.textContent = text;
722
- }
723
- else if (oldVNode.$text$ !== text) {
724
- // update the text content for the text only vnode
725
- // and also only if the text is different than before
726
- elm.data = text;
727
- }
728
- };
729
- var updateFallbackSlotVisibility = function (elm) {
730
- // tslint:disable-next-line: prefer-const
731
- var childNodes = elm.childNodes;
732
- var childNode;
733
- var i;
734
- var ilen;
735
- var j;
736
- var slotNameAttr;
737
- var nodeType;
738
- for (i = 0, ilen = childNodes.length; i < ilen; i++) {
739
- childNode = childNodes[i];
740
- if (childNode.nodeType === 1 /* ElementNode */) {
741
- if (childNode['s-sr']) {
742
- // this is a slot fallback node
743
- // get the slot name for this slot reference node
744
- slotNameAttr = childNode['s-sn'];
745
- // by default always show a fallback slot node
746
- // then hide it if there are other slots in the light dom
747
- childNode.hidden = false;
748
- for (j = 0; j < ilen; j++) {
749
- if (childNodes[j]['s-hn'] !== childNode['s-hn']) {
750
- // this sibling node is from a different component
751
- nodeType = childNodes[j].nodeType;
752
- if (slotNameAttr !== '') {
753
- // this is a named fallback slot node
754
- if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
755
- childNode.hidden = true;
756
- break;
757
- }
758
- }
759
- else {
760
- // this is a default fallback slot node
761
- // any element or text node (with content)
762
- // should hide the default fallback slot node
763
- if (nodeType === 1 /* ElementNode */ || (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
764
- childNode.hidden = true;
765
- break;
766
- }
767
- }
768
- }
769
- }
770
- }
771
- // keep drilling down
772
- updateFallbackSlotVisibility(childNode);
773
- }
774
- }
775
- };
776
- var relocateNodes = [];
777
- var relocateSlotContent = function (elm) {
778
- // tslint:disable-next-line: prefer-const
779
- var childNode;
780
- var node;
781
- var hostContentNodes;
782
- var slotNameAttr;
783
- var relocateNodeData;
784
- var j;
785
- var i = 0;
786
- var childNodes = elm.childNodes;
787
- var ilen = childNodes.length;
788
- for (; i < ilen; i++) {
789
- childNode = childNodes[i];
790
- if (childNode['s-sr'] && (node = childNode['s-cr'])) {
791
- // first got the content reference comment node
792
- // then we got it's parent, which is where all the host content is in now
793
- hostContentNodes = node.parentNode.childNodes;
794
- slotNameAttr = childNode['s-sn'];
795
- for (j = hostContentNodes.length - 1; j >= 0; j--) {
796
- node = hostContentNodes[j];
797
- if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
798
- // let's do some relocating to its new home
799
- // but never relocate a content reference node
800
- // that is suppose to always represent the original content location
801
- if (isNodeLocatedInSlot(node, slotNameAttr)) {
802
- // it's possible we've already decided to relocate this node
803
- relocateNodeData = relocateNodes.find(function (r) { return r.$nodeToRelocate$ === node; });
804
- // made some changes to slots
805
- // let's make sure we also double check
806
- // fallbacks are correctly hidden or shown
807
- checkSlotFallbackVisibility = true;
808
- node['s-sn'] = node['s-sn'] || slotNameAttr;
809
- if (relocateNodeData) {
810
- // previously we never found a slot home for this node
811
- // but turns out we did, so let's remember it now
812
- relocateNodeData.$slotRefNode$ = childNode;
813
- }
814
- else {
815
- // add to our list of nodes to relocate
816
- relocateNodes.push({
817
- $slotRefNode$: childNode,
818
- $nodeToRelocate$: node,
819
- });
820
- }
821
- if (node['s-sr']) {
822
- relocateNodes.map(function (relocateNode) {
823
- if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
824
- relocateNodeData = relocateNodes.find(function (r) { return r.$nodeToRelocate$ === node; });
825
- if (relocateNodeData && !relocateNode.$slotRefNode$) {
826
- relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
827
- }
828
- }
829
- });
830
- }
831
- }
832
- else if (!relocateNodes.some(function (r) { return r.$nodeToRelocate$ === node; })) {
833
- // so far this element does not have a slot home, not setting slotRefNode on purpose
834
- // if we never find a home for this element then we'll need to hide it
835
- relocateNodes.push({
836
- $nodeToRelocate$: node,
837
- });
838
- }
839
- }
840
- }
841
- }
842
- if (childNode.nodeType === 1 /* ElementNode */) {
843
- relocateSlotContent(childNode);
844
- }
845
- }
846
- };
847
- var isNodeLocatedInSlot = function (nodeToRelocate, slotNameAttr) {
848
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
849
- if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
850
- return true;
851
- }
852
- if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
853
- return true;
854
- }
855
- return false;
856
- }
857
- if (nodeToRelocate['s-sn'] === slotNameAttr) {
858
- return true;
859
- }
860
- return slotNameAttr === '';
861
- };
862
- var renderVdom = function (hostRef, renderFnResults) {
863
- var hostElm = hostRef.$hostElement$;
864
- var cmpMeta = hostRef.$cmpMeta$;
865
- var oldVNode = hostRef.$vnode$ || newVNode(null, null);
866
- var rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
867
- hostTagName = hostElm.tagName;
868
- rootVnode.$tag$ = null;
869
- rootVnode.$flags$ |= 4 /* isHost */;
870
- hostRef.$vnode$ = rootVnode;
871
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
872
- {
873
- contentRef = hostElm['s-cr'];
874
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
875
- // always reset
876
- checkSlotFallbackVisibility = false;
877
- }
878
- // synchronous patch
879
- patch(oldVNode, rootVnode);
880
- {
881
- // while we're moving nodes around existing nodes, temporarily disable
882
- // the disconnectCallback from working
883
- plt.$flags$ |= 1 /* isTmpDisconnected */;
884
- if (checkSlotRelocate) {
885
- relocateSlotContent(rootVnode.$elm$);
886
- var relocateData = void 0;
887
- var nodeToRelocate = void 0;
888
- var orgLocationNode = void 0;
889
- var parentNodeRef = void 0;
890
- var insertBeforeNode = void 0;
891
- var refNode = void 0;
892
- var i = 0;
893
- for (; i < relocateNodes.length; i++) {
894
- relocateData = relocateNodes[i];
895
- nodeToRelocate = relocateData.$nodeToRelocate$;
896
- if (!nodeToRelocate['s-ol']) {
897
- // add a reference node marking this node's original location
898
- // keep a reference to this node for later lookups
899
- orgLocationNode = doc.createTextNode('');
900
- orgLocationNode['s-nr'] = nodeToRelocate;
901
- nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
902
- }
903
- }
904
- for (i = 0; i < relocateNodes.length; i++) {
905
- relocateData = relocateNodes[i];
906
- nodeToRelocate = relocateData.$nodeToRelocate$;
907
- if (relocateData.$slotRefNode$) {
908
- // by default we're just going to insert it directly
909
- // after the slot reference node
910
- parentNodeRef = relocateData.$slotRefNode$.parentNode;
911
- insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
912
- orgLocationNode = nodeToRelocate['s-ol'];
913
- while ((orgLocationNode = orgLocationNode.previousSibling)) {
914
- refNode = orgLocationNode['s-nr'];
915
- if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
916
- refNode = refNode.nextSibling;
917
- if (!refNode || !refNode['s-nr']) {
918
- insertBeforeNode = refNode;
919
- break;
920
- }
921
- }
922
- }
923
- if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) || nodeToRelocate.nextSibling !== insertBeforeNode) {
924
- // we've checked that it's worth while to relocate
925
- // since that the node to relocate
926
- // has a different next sibling or parent relocated
927
- if (nodeToRelocate !== insertBeforeNode) {
928
- if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
929
- // probably a component in the index.html that doesn't have it's hostname set
930
- nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
931
- }
932
- // add it back to the dom but in its new home
933
- parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
934
- }
935
- }
936
- }
937
- else {
938
- // this node doesn't have a slot home to go to, so let's hide it
939
- if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
940
- nodeToRelocate.hidden = true;
941
- }
942
- }
943
- }
944
- }
945
- if (checkSlotFallbackVisibility) {
946
- updateFallbackSlotVisibility(rootVnode.$elm$);
947
- }
948
- // done moving nodes around
949
- // allow the disconnect callback to work again
950
- plt.$flags$ &= ~1 /* isTmpDisconnected */;
951
- // always reset
952
- relocateNodes.length = 0;
953
- }
954
- };
955
- var getElement = function (ref) { return (getHostRef(ref).$hostElement$); };
956
- var createEvent = function (ref, name, flags) {
957
- var elm = getElement(ref);
958
- return {
959
- emit: function (detail) {
960
- return emitEvent(elm, name, {
961
- bubbles: !!(flags & 4 /* Bubbles */),
962
- composed: !!(flags & 2 /* Composed */),
963
- cancelable: !!(flags & 1 /* Cancellable */),
964
- detail: detail,
965
- });
966
- },
967
- };
968
- };
969
- var emitEvent = function (elm, name, opts) {
970
- var ev = plt.ce(name, opts);
971
- elm.dispatchEvent(ev);
972
- return ev;
973
- };
974
- var attachToAncestor = function (hostRef, ancestorComponent) {
975
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
976
- ancestorComponent['s-p'].push(new Promise(function (r) { return (hostRef.$onRenderResolve$ = r); }));
977
- }
978
- };
979
- var scheduleUpdate = function (hostRef, isInitialLoad) {
980
- {
981
- hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
982
- }
983
- if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
984
- hostRef.$flags$ |= 512 /* needsRerender */;
985
- return;
986
- }
987
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
988
- // there is no ancestorc omponent or the ancestor component
989
- // has already fired off its lifecycle update then
990
- // fire off the initial update
991
- var dispatch = function () { return dispatchHooks(hostRef, isInitialLoad); };
992
- return writeTask(dispatch);
993
- };
994
- var dispatchHooks = function (hostRef, isInitialLoad) {
995
- var endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
996
- var instance = hostRef.$lazyInstance$;
997
- var promise;
998
- if (isInitialLoad) {
999
- {
1000
- hostRef.$flags$ |= 256 /* isListenReady */;
1001
- if (hostRef.$queuedListeners$) {
1002
- hostRef.$queuedListeners$.map(function (_a) {
1003
- var methodName = _a[0], event = _a[1];
1004
- return safeCall(instance, methodName, event);
1005
- });
1006
- hostRef.$queuedListeners$ = null;
1007
- }
1008
- }
1009
- {
1010
- promise = safeCall(instance, 'componentWillLoad');
1011
- }
1012
- }
1013
- endSchedule();
1014
- return then(promise, function () { return updateComponent(hostRef, instance, isInitialLoad); });
1015
- };
1016
- var updateComponent = function (hostRef, instance, isInitialLoad) {
1017
- // updateComponent
1018
- var elm = hostRef.$hostElement$;
1019
- var endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1020
- var rc = elm['s-rc'];
1021
- if (isInitialLoad) {
1022
- // DOM WRITE!
1023
- attachStyles(hostRef);
1024
- }
1025
- var endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1026
- {
1027
- {
1028
- // looks like we've got child nodes to render into this host element
1029
- // or we need to update the css class/attrs on the host element
1030
- // DOM WRITE!
1031
- renderVdom(hostRef, callRender(hostRef, instance));
1032
- }
1033
- }
1034
- if (plt.$cssShim$) {
1035
- plt.$cssShim$.updateHost(elm);
1036
- }
1037
- if (rc) {
1038
- // ok, so turns out there are some child host elements
1039
- // waiting on this parent element to load
1040
- // let's fire off all update callbacks waiting
1041
- rc.map(function (cb) { return cb(); });
1042
- elm['s-rc'] = undefined;
1043
- }
1044
- endRender();
1045
- endUpdate();
1046
- {
1047
- var childrenPromises = elm['s-p'];
1048
- var postUpdate = function () { return postUpdateComponent(hostRef); };
1049
- if (childrenPromises.length === 0) {
1050
- postUpdate();
1051
- }
1052
- else {
1053
- Promise.all(childrenPromises).then(postUpdate);
1054
- hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1055
- childrenPromises.length = 0;
1056
- }
1057
- }
1058
- };
1059
- var callRender = function (hostRef, instance) {
1060
- try {
1061
- instance = instance.render();
1062
- {
1063
- hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1064
- }
1065
- {
1066
- hostRef.$flags$ |= 2 /* hasRendered */;
1067
- }
1068
- }
1069
- catch (e) {
1070
- consoleError(e);
1071
- }
1072
- return instance;
1073
- };
1074
- var postUpdateComponent = function (hostRef) {
1075
- var tagName = hostRef.$cmpMeta$.$tagName$;
1076
- var elm = hostRef.$hostElement$;
1077
- var endPostUpdate = createTime('postUpdate', tagName);
1078
- var instance = hostRef.$lazyInstance$;
1079
- var ancestorComponent = hostRef.$ancestorComponent$;
1080
- if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1081
- hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1082
- {
1083
- // DOM WRITE!
1084
- addHydratedFlag(elm);
1085
- }
1086
- {
1087
- safeCall(instance, 'componentDidLoad');
1088
- }
1089
- endPostUpdate();
1090
- {
1091
- hostRef.$onReadyResolve$(elm);
1092
- if (!ancestorComponent) {
1093
- appDidLoad();
1094
- }
1095
- }
1096
- }
1097
- else {
1098
- endPostUpdate();
1099
- }
1100
- // load events fire from bottom to top
1101
- // the deepest elements load first then bubbles up
1102
- {
1103
- if (hostRef.$onRenderResolve$) {
1104
- hostRef.$onRenderResolve$();
1105
- hostRef.$onRenderResolve$ = undefined;
1106
- }
1107
- if (hostRef.$flags$ & 512 /* needsRerender */) {
1108
- nextTick(function () { return scheduleUpdate(hostRef, false); });
1109
- }
1110
- hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1111
- }
1112
- // ( •_•)
1113
- // ( •_•)>⌐■-■
1114
- // (⌐■_■)
1115
- };
1116
- var forceUpdate = function (ref) {
1117
- {
1118
- var hostRef = getHostRef(ref);
1119
- var isConnected = hostRef.$hostElement$.isConnected;
1120
- if (isConnected && (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1121
- scheduleUpdate(hostRef, false);
1122
- }
1123
- // Returns "true" when the forced update was successfully scheduled
1124
- return isConnected;
1125
- }
1126
- };
1127
- var appDidLoad = function (who) {
1128
- // on appload
1129
- // we have finish the first big initial render
1130
- {
1131
- addHydratedFlag(doc.documentElement);
1132
- }
1133
- {
1134
- plt.$flags$ |= 2 /* appLoaded */;
1135
- }
1136
- nextTick(function () { return emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }); });
1137
- };
1138
- var safeCall = function (instance, method, arg) {
1139
- if (instance && instance[method]) {
1140
- try {
1141
- return instance[method](arg);
1142
- }
1143
- catch (e) {
1144
- consoleError(e);
1145
- }
1146
- }
1147
- return undefined;
1148
- };
1149
- var then = function (promise, thenFn) {
1150
- return promise && promise.then ? promise.then(thenFn) : thenFn();
1151
- };
1152
- var addHydratedFlag = function (elm) { return (elm.classList.add('hydrated')); };
1153
- var parsePropertyValue = function (propValue, propType) {
1154
- // ensure this value is of the correct prop type
1155
- if (propValue != null && !isComplexType(propValue)) {
1156
- if (propType & 4 /* Boolean */) {
1157
- // per the HTML spec, any string value means it is a boolean true value
1158
- // but we'll cheat here and say that the string "false" is the boolean false
1159
- return propValue === 'false' ? false : propValue === '' || !!propValue;
1160
- }
1161
- if (propType & 2 /* Number */) {
1162
- // force it to be a number
1163
- return parseFloat(propValue);
1164
- }
1165
- if (propType & 1 /* String */) {
1166
- // could have been passed as a number or boolean
1167
- // but we still want it as a string
1168
- return String(propValue);
1169
- }
1170
- // redundant return here for better minification
1171
- return propValue;
1172
- }
1173
- // not sure exactly what type we want
1174
- // so no need to change to a different type
1175
- return propValue;
1176
- };
1177
- var getValue = function (ref, propName) { return getHostRef(ref).$instanceValues$.get(propName); };
1178
- var setValue = function (ref, propName, newVal, cmpMeta) {
1179
- // check our new property value against our internal value
1180
- var hostRef = getHostRef(ref);
1181
- var oldVal = hostRef.$instanceValues$.get(propName);
1182
- var flags = hostRef.$flags$;
1183
- var instance = hostRef.$lazyInstance$;
1184
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1185
- if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && newVal !== oldVal) {
1186
- // gadzooks! the property's value has changed!!
1187
- // set our new value!
1188
- hostRef.$instanceValues$.set(propName, newVal);
1189
- if (instance) {
1190
- // get an array of method names of watch functions to call
1191
- if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1192
- var watchMethods = cmpMeta.$watchers$[propName];
1193
- if (watchMethods) {
1194
- // this instance is watching for when this property changed
1195
- watchMethods.map(function (watchMethodName) {
1196
- try {
1197
- // fire off each of the watch methods that are watching this property
1198
- instance[watchMethodName](newVal, oldVal, propName);
1199
- }
1200
- catch (e) {
1201
- consoleError(e);
1202
- }
1203
- });
1204
- }
1205
- }
1206
- if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1207
- // looks like this value actually changed, so we've got work to do!
1208
- // but only if we've already rendered, otherwise just chill out
1209
- // queue that we need to do an update, but don't worry about queuing
1210
- // up millions cuz this function ensures it only runs once
1211
- scheduleUpdate(hostRef, false);
1212
- }
1213
- }
1214
- }
1215
- };
1216
- var proxyComponent = function (Cstr, cmpMeta, flags) {
1217
- if (cmpMeta.$members$) {
1218
- if (Cstr.watchers) {
1219
- cmpMeta.$watchers$ = Cstr.watchers;
1220
- }
1221
- // It's better to have a const than two Object.entries()
1222
- var members = Object.entries(cmpMeta.$members$);
1223
- var prototype_1 = Cstr.prototype;
1224
- members.map(function (_a) {
1225
- var memberName = _a[0], memberFlags = _a[1][0];
1226
- if ((memberFlags & 31 /* Prop */ || ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1227
- // proxyComponent - prop
1228
- Object.defineProperty(prototype_1, memberName, {
1229
- get: function () {
1230
- // proxyComponent, get value
1231
- return getValue(this, memberName);
1232
- },
1233
- set: function (newValue) {
1234
- // proxyComponent, set value
1235
- setValue(this, memberName, newValue, cmpMeta);
1236
- },
1237
- configurable: true,
1238
- enumerable: true,
1239
- });
1240
- }
1241
- });
1242
- if ((flags & 1 /* isElementConstructor */)) {
1243
- var attrNameToPropName_1 = new Map();
1244
- prototype_1.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1245
- var _this = this;
1246
- plt.jmp(function () {
1247
- var propName = attrNameToPropName_1.get(attrName);
1248
- _this[propName] = newValue === null && typeof _this[propName] === 'boolean' ? false : newValue;
1249
- });
1250
- };
1251
- // create an array of attributes to observe
1252
- // and also create a map of html attribute name to js property name
1253
- Cstr.observedAttributes = members
1254
- .filter(function (_a) {
1255
- var _ = _a[0], m = _a[1];
1256
- return m[0] & 15;
1257
- } /* HasAttribute */) // filter to only keep props that should match attributes
1258
- .map(function (_a) {
1259
- var propName = _a[0], m = _a[1];
1260
- var attrName = m[1] || propName;
1261
- attrNameToPropName_1.set(attrName, propName);
1262
- return attrName;
1263
- });
1264
- }
1265
- }
1266
- return Cstr;
1267
- };
1268
- var initializeComponent = function (elm, hostRef, cmpMeta, hmrVersionId, Cstr) { return __awaiter(void 0, void 0, void 0, function () {
1269
- var endLoad, endNewInstance, style, scopeId, endRegisterStyles, ancestorComponent, schedule;
1270
- return __generator(this, function (_a) {
1271
- switch (_a.label) {
1272
- case 0:
1273
- if (!((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0)) return [3 /*break*/, 3];
1274
- // we haven't initialized this element yet
1275
- hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1276
- // lazy loaded components
1277
- // request the component's implementation to be
1278
- // wired up with the host element
1279
- Cstr = loadModule(cmpMeta);
1280
- if (!Cstr.then) return [3 /*break*/, 2];
1281
- endLoad = uniqueTime();
1282
- return [4 /*yield*/, Cstr];
1283
- case 1:
1284
- Cstr = _a.sent();
1285
- endLoad();
1286
- _a.label = 2;
1287
- case 2:
1288
- if (!Cstr.isProxied) {
1289
- // we'eve never proxied this Constructor before
1290
- // let's add the getters/setters to its prototype before
1291
- // the first time we create an instance of the implementation
1292
- {
1293
- cmpMeta.$watchers$ = Cstr.watchers;
1294
- }
1295
- proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1296
- Cstr.isProxied = true;
1297
- }
1298
- endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1299
- // ok, time to construct the instance
1300
- // but let's keep track of when we start and stop
1301
- // so that the getters/setters don't incorrectly step on data
1302
- {
1303
- hostRef.$flags$ |= 8 /* isConstructingInstance */;
1304
- }
1305
- // construct the lazy-loaded component implementation
1306
- // passing the hostRef is very important during
1307
- // construction in order to directly wire together the
1308
- // host element and the lazy-loaded instance
1309
- try {
1310
- new Cstr(hostRef);
1311
- }
1312
- catch (e) {
1313
- consoleError(e);
1314
- }
1315
- {
1316
- hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1317
- }
1318
- {
1319
- hostRef.$flags$ |= 128 /* isWatchReady */;
1320
- }
1321
- endNewInstance();
1322
- if (Cstr.style) {
1323
- style = Cstr.style;
1324
- scopeId = getScopeId(cmpMeta);
1325
- if (!styles.has(scopeId)) {
1326
- endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1327
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1328
- endRegisterStyles();
1329
- }
1330
- }
1331
- _a.label = 3;
1332
- case 3:
1333
- ancestorComponent = hostRef.$ancestorComponent$;
1334
- schedule = function () { return scheduleUpdate(hostRef, true); };
1335
- if (ancestorComponent && ancestorComponent['s-rc']) {
1336
- // this is the intial load and this component it has an ancestor component
1337
- // but the ancestor component has NOT fired its will update lifecycle yet
1338
- // so let's just cool our jets and wait for the ancestor to continue first
1339
- // this will get fired off when the ancestor component
1340
- // finally gets around to rendering its lazy self
1341
- // fire off the initial update
1342
- ancestorComponent['s-rc'].push(schedule);
1343
- }
1344
- else {
1345
- schedule();
1346
- }
1347
- return [2 /*return*/];
1348
- }
1349
- });
1350
- }); };
1351
- var connectedCallback = function (elm) {
1352
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1353
- var hostRef_1 = getHostRef(elm);
1354
- var cmpMeta_1 = hostRef_1.$cmpMeta$;
1355
- var endConnected = createTime('connectedCallback', cmpMeta_1.$tagName$);
1356
- if (!(hostRef_1.$flags$ & 1 /* hasConnected */)) {
1357
- // first time this component has connected
1358
- hostRef_1.$flags$ |= 1 /* hasConnected */;
1359
- {
1360
- // initUpdate
1361
- // if the slot polyfill is required we'll need to put some nodes
1362
- // in here to act as original content anchors as we move nodes around
1363
- // host element has been connected to the DOM
1364
- if ((cmpMeta_1.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
1365
- setContentReference(elm);
1366
- }
1367
- }
1368
- {
1369
- // find the first ancestor component (if there is one) and register
1370
- // this component as one of the actively loading child components for its ancestor
1371
- var ancestorComponent = elm;
1372
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1373
- // climb up the ancestors looking for the first
1374
- // component that hasn't finished its lifecycle update yet
1375
- if (ancestorComponent['s-p']) {
1376
- // we found this components first ancestor component
1377
- // keep a reference to this component's ancestor component
1378
- attachToAncestor(hostRef_1, (hostRef_1.$ancestorComponent$ = ancestorComponent));
1379
- break;
1380
- }
1381
- }
1382
- }
1383
- // Lazy properties
1384
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1385
- if (cmpMeta_1.$members$) {
1386
- Object.entries(cmpMeta_1.$members$).map(function (_a) {
1387
- var memberName = _a[0], memberFlags = _a[1][0];
1388
- if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1389
- var value = elm[memberName];
1390
- delete elm[memberName];
1391
- elm[memberName] = value;
1392
- }
1393
- });
1394
- }
1395
- {
1396
- // connectedCallback, taskQueue, initialLoad
1397
- // angular sets attribute AFTER connectCallback
1398
- // https://github.com/angular/angular/issues/18909
1399
- // https://github.com/angular/angular/issues/19940
1400
- nextTick(function () { return initializeComponent(elm, hostRef_1, cmpMeta_1); });
1401
- }
1402
- }
1403
- else {
1404
- // not the first time this has connected
1405
- // reattach any event listeners to the host
1406
- // since they would have been removed when disconnected
1407
- addHostEventListeners(elm, hostRef_1, cmpMeta_1.$listeners$);
1408
- }
1409
- endConnected();
1410
- }
1411
- };
1412
- var setContentReference = function (elm) {
1413
- // only required when we're NOT using native shadow dom (slot)
1414
- // or this browser doesn't support native shadow dom
1415
- // and this host element was NOT created with SSR
1416
- // let's pick out the inner content for slot projection
1417
- // create a node to represent where the original
1418
- // content was first placed, which is useful later on
1419
- var contentRefElm = (elm['s-cr'] = doc.createComment(''));
1420
- contentRefElm['s-cn'] = true;
1421
- elm.insertBefore(contentRefElm, elm.firstChild);
1422
- };
1423
- var disconnectedCallback = function (elm) {
1424
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1425
- var hostRef = getHostRef(elm);
1426
- {
1427
- if (hostRef.$rmListeners$) {
1428
- hostRef.$rmListeners$.map(function (rmListener) { return rmListener(); });
1429
- hostRef.$rmListeners$ = undefined;
1430
- }
1431
- }
1432
- // clear CSS var-shim tracking
1433
- if (plt.$cssShim$) {
1434
- plt.$cssShim$.removeHost(elm);
1435
- }
1436
- }
1437
- };
1438
- var patchCloneNode = function (HostElementPrototype) {
1439
- var orgCloneNode = HostElementPrototype.cloneNode;
1440
- HostElementPrototype.cloneNode = function (deep) {
1441
- var srcNode = this;
1442
- var clonedNode = orgCloneNode.call(srcNode, false);
1443
- if (deep) {
1444
- var i = 0;
1445
- var slotted = void 0;
1446
- for (; i < srcNode.childNodes.length; i++) {
1447
- slotted = srcNode.childNodes[i]['s-nr'];
1448
- if (slotted) {
1449
- if (clonedNode.__appendChild) {
1450
- clonedNode.__appendChild(slotted.cloneNode(true));
1451
- }
1452
- else {
1453
- clonedNode.appendChild(slotted.cloneNode(true));
1454
- }
1455
- }
1456
- }
1457
- }
1458
- return clonedNode;
1459
- };
1460
- };
1461
- var patchSlotAppendChild = function (HostElementPrototype) {
1462
- HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
1463
- HostElementPrototype.appendChild = function (newChild) {
1464
- var slotName = (newChild['s-sn'] = getSlotName(newChild));
1465
- var slotNode = getHostSlotNode(this.childNodes, slotName);
1466
- if (slotNode) {
1467
- var slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
1468
- var appendAfter = slotChildNodes[slotChildNodes.length - 1];
1469
- return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
1470
- }
1471
- return this.__appendChild(newChild);
1472
- };
1473
- };
1474
- var patchChildSlotNodes = function (elm, cmpMeta) {
1475
- var FakeNodeList = /** @class */ (function (_super) {
1476
- __extends(FakeNodeList, _super);
1477
- function FakeNodeList() {
1478
- return _super !== null && _super.apply(this, arguments) || this;
1479
- }
1480
- FakeNodeList.prototype.item = function (n) {
1481
- return this[n];
1482
- };
1483
- return FakeNodeList;
1484
- }(Array));
1485
- if (cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
1486
- var childNodesFn_1 = elm.__lookupGetter__('childNodes');
1487
- Object.defineProperty(elm, 'children', {
1488
- get: function () {
1489
- return this.childNodes.map(function (n) { return n.nodeType === 1; });
1490
- },
1491
- });
1492
- Object.defineProperty(elm, 'childElementCount', {
1493
- get: function () {
1494
- return elm.children.length;
1495
- },
1496
- });
1497
- Object.defineProperty(elm, 'childNodes', {
1498
- get: function () {
1499
- var childNodes = childNodesFn_1.call(this);
1500
- if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0 && getHostRef(this).$flags$ & 2 /* hasRendered */) {
1501
- var result = new FakeNodeList();
1502
- for (var i = 0; i < childNodes.length; i++) {
1503
- var slot = childNodes[i]['s-nr'];
1504
- if (slot) {
1505
- result.push(slot);
1506
- }
1507
- }
1508
- return result;
1509
- }
1510
- return FakeNodeList.from(childNodes);
1511
- },
1512
- });
1513
- }
1514
- };
1515
- var getSlotName = function (node) { return node['s-sn'] || (node.nodeType === 1 && node.getAttribute('slot')) || ''; };
1516
- var getHostSlotNode = function (childNodes, slotName) {
1517
- var i = 0;
1518
- var childNode;
1519
- for (; i < childNodes.length; i++) {
1520
- childNode = childNodes[i];
1521
- if (childNode['s-sr'] && childNode['s-sn'] === slotName) {
1522
- return childNode;
1523
- }
1524
- childNode = getHostSlotNode(childNode.childNodes, slotName);
1525
- if (childNode) {
1526
- return childNode;
1527
- }
1528
- }
1529
- return null;
1530
- };
1531
- var getHostSlotChildNodes = function (n, slotName) {
1532
- var childNodes = [n];
1533
- while ((n = n.nextSibling) && n['s-sn'] === slotName) {
1534
- childNodes.push(n);
1535
- }
1536
- return childNodes;
1537
- };
1538
- var bootstrapLazy = function (lazyBundles, options) {
1539
- if (options === void 0) { options = {}; }
1540
- var endBootstrap = createTime();
1541
- var cmpTags = [];
1542
- var exclude = options.exclude || [];
1543
- var customElements = win.customElements;
1544
- var head = doc.head;
1545
- var metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1546
- var visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1547
- var deferredConnectedCallbacks = [];
1548
- var appLoadFallback;
1549
- var isBootstrapping = true;
1550
- Object.assign(plt, options);
1551
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1552
- {
1553
- if (options.syncQueue) {
1554
- plt.$flags$ |= 4 /* queueSync */;
1555
- }
1556
- }
1557
- lazyBundles.map(function (lazyBundle) { return lazyBundle[1].map(function (compactMeta) {
1558
- var cmpMeta = {
1559
- $flags$: compactMeta[0],
1560
- $tagName$: compactMeta[1],
1561
- $members$: compactMeta[2],
1562
- $listeners$: compactMeta[3],
1563
- };
1564
- {
1565
- cmpMeta.$members$ = compactMeta[2];
1566
- }
1567
- {
1568
- cmpMeta.$listeners$ = compactMeta[3];
1569
- }
1570
- {
1571
- cmpMeta.$watchers$ = {};
1572
- }
1573
- var tagName = cmpMeta.$tagName$;
1574
- var HostElement = /** @class */ (function (_super) {
1575
- __extends(HostElement, _super);
1576
- // StencilLazyHost
1577
- function HostElement(self) {
1578
- var _this =
1579
- // @ts-ignore
1580
- _super.call(this, self) || this;
1581
- self = _this;
1582
- registerHost(self, cmpMeta);
1583
- {
1584
- patchChildSlotNodes(self, cmpMeta);
1585
- }
1586
- return _this;
1587
- }
1588
- HostElement.prototype.connectedCallback = function () {
1589
- var _this = this;
1590
- if (appLoadFallback) {
1591
- clearTimeout(appLoadFallback);
1592
- appLoadFallback = null;
1593
- }
1594
- if (isBootstrapping) {
1595
- // connectedCallback will be processed once all components have been registered
1596
- deferredConnectedCallbacks.push(this);
1597
- }
1598
- else {
1599
- plt.jmp(function () { return connectedCallback(_this); });
1600
- }
1601
- };
1602
- HostElement.prototype.disconnectedCallback = function () {
1603
- var _this = this;
1604
- plt.jmp(function () { return disconnectedCallback(_this); });
1605
- };
1606
- HostElement.prototype.forceUpdate = function () {
1607
- forceUpdate(this);
1608
- };
1609
- HostElement.prototype.componentOnReady = function () {
1610
- return getHostRef(this).$onReadyPromise$;
1611
- };
1612
- return HostElement;
1613
- }(HTMLElement));
1614
- {
1615
- patchCloneNode(HostElement.prototype);
1616
- }
1617
- {
1618
- patchSlotAppendChild(HostElement.prototype);
1619
- }
1620
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
1621
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1622
- cmpTags.push(tagName);
1623
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1624
- }
1625
- }); });
1626
- {
1627
- visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1628
- visibilityStyle.setAttribute('data-styles', '');
1629
- head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1630
- }
1631
- // Process deferred connectedCallbacks now all components have been registered
1632
- isBootstrapping = false;
1633
- if (deferredConnectedCallbacks.length) {
1634
- deferredConnectedCallbacks.map(function (host) { return host.connectedCallback(); });
1635
- }
1636
- else {
1637
- {
1638
- plt.jmp(function () { return (appLoadFallback = setTimeout(appDidLoad, 30)); });
1639
- }
1640
- }
1641
- // Fallback appLoad event
1642
- endBootstrap();
1643
- };
1644
- var hostRefs = new WeakMap();
1645
- var getHostRef = function (ref) { return hostRefs.get(ref); };
1646
- var registerInstance = function (lazyInstance, hostRef) { return hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef); };
1647
- var registerHost = function (elm, cmpMeta) {
1648
- var hostRef = {
1649
- $flags$: 0,
1650
- $hostElement$: elm,
1651
- $cmpMeta$: cmpMeta,
1652
- $instanceValues$: new Map(),
1653
- };
1654
- {
1655
- hostRef.$onReadyPromise$ = new Promise(function (r) { return (hostRef.$onReadyResolve$ = r); });
1656
- elm['s-p'] = [];
1657
- elm['s-rc'] = [];
1658
- }
1659
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1660
- return hostRefs.set(elm, hostRef);
1661
- };
1662
- var isMemberInElement = function (elm, memberName) { return memberName in elm; };
1663
- var consoleError = function (e) { return console.error(e); };
1664
- var cmpModules = /*@__PURE__*/ new Map();
1665
- var loadModule = function (cmpMeta, hostRef, hmrVersionId) {
1666
- // loadModuleImport
1667
- var exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1668
- var bundleId = cmpMeta.$lazyBundleId$;
1669
- var module = cmpModules.get(bundleId);
1670
- if (module) {
1671
- return module[exportName];
1672
- }
1673
- return import(
1674
- /* webpackInclude: /\.entry\.js$/ */
1675
- /* webpackExclude: /\.system\.entry\.js$/ */
1676
- /* webpackMode: "lazy" */
1677
- "./" + bundleId + ".entry.js" + '').then(function (importedModule) {
1678
- {
1679
- cmpModules.set(bundleId, importedModule);
1680
- }
1681
- return importedModule[exportName];
1682
- }, consoleError);
1683
- };
1684
- var styles = new Map();
1685
- var queueDomReads = [];
1686
- var queueDomWrites = [];
1687
- var queueDomWritesLow = [];
1688
- var queueTask = function (queue, write) { return function (cb) {
1689
- queue.push(cb);
1690
- if (!queuePending) {
1691
- queuePending = true;
1692
- if (write && plt.$flags$ & 4 /* queueSync */) {
1693
- nextTick(flush);
1694
- }
1695
- else {
1696
- plt.raf(flush);
1697
- }
1698
- }
1699
- }; };
1700
- var consume = function (queue) {
1701
- for (var i = 0; i < queue.length; i++) {
1702
- try {
1703
- queue[i](performance.now());
1704
- }
1705
- catch (e) {
1706
- consoleError(e);
1707
- }
1708
- }
1709
- queue.length = 0;
1710
- };
1711
- var consumeTimeout = function (queue, timeout) {
1712
- var i = 0;
1713
- var ts = 0;
1714
- while (i < queue.length && (ts = performance.now()) < timeout) {
1715
- try {
1716
- queue[i++](ts);
1717
- }
1718
- catch (e) {
1719
- consoleError(e);
1720
- }
1721
- }
1722
- if (i === queue.length) {
1723
- queue.length = 0;
1724
- }
1725
- else if (i !== 0) {
1726
- queue.splice(0, i);
1727
- }
1728
- };
1729
- var flush = function () {
1730
- {
1731
- queueCongestion++;
1732
- }
1733
- // always force a bunch of medium callbacks to run, but still have
1734
- // a throttle on how many can run in a certain time
1735
- // DOM READS!!!
1736
- consume(queueDomReads);
1737
- // DOM WRITES!!!
1738
- {
1739
- var timeout = (plt.$flags$ & 6 /* queueMask */) === 2 /* appLoaded */ ? performance.now() + 14 * Math.ceil(queueCongestion * (1.0 / 10.0)) : Infinity;
1740
- consumeTimeout(queueDomWrites, timeout);
1741
- consumeTimeout(queueDomWritesLow, timeout);
1742
- if (queueDomWrites.length > 0) {
1743
- queueDomWritesLow.push.apply(queueDomWritesLow, queueDomWrites);
1744
- queueDomWrites.length = 0;
1745
- }
1746
- if ((queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)) {
1747
- // still more to do yet, but we've run out of time
1748
- // let's let this thing cool off and try again in the next tick
1749
- plt.raf(flush);
1750
- }
1751
- else {
1752
- queueCongestion = 0;
1753
- }
1754
- }
1755
- };
1756
- var nextTick = /*@__PURE__*/ function (cb) { return promiseResolve().then(cb); };
1757
- var writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1758
- export { CSS as C, H, NAMESPACE as N, promiseResolve as a, bootstrapLazy as b, createEvent as c, doc as d, getElement as g, h, plt as p, registerInstance as r, win as w };
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ var __generator = (this && this.__generator) || function (thisArg, body) {
24
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
25
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
26
+ function verb(n) { return function (v) { return step([n, v]); }; }
27
+ function step(op) {
28
+ if (f) throw new TypeError("Generator is already executing.");
29
+ while (_) try {
30
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
31
+ if (y = 0, t) op = [op[0] & 2, t.value];
32
+ switch (op[0]) {
33
+ case 0: case 1: t = op; break;
34
+ case 4: _.label++; return { value: op[1], done: false };
35
+ case 5: _.label++; y = op[1]; op = [0]; continue;
36
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
37
+ default:
38
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
39
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
40
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
41
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
42
+ if (t[2]) _.ops.pop();
43
+ _.trys.pop(); continue;
44
+ }
45
+ op = body.call(thisArg, _);
46
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
47
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
48
+ }
49
+ };
50
+ var __spreadArrays = (this && this.__spreadArrays) || function () {
51
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
52
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
53
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
54
+ r[k] = a[j];
55
+ return r;
56
+ };
57
+ var NAMESPACE = 'widget-components';
58
+ var contentRef;
59
+ var hostTagName;
60
+ var useNativeShadowDom = false;
61
+ var checkSlotFallbackVisibility = false;
62
+ var checkSlotRelocate = false;
63
+ var isSvgMode = false;
64
+ var queueCongestion = 0;
65
+ var queuePending = false;
66
+ var win = typeof window !== 'undefined' ? window : {};
67
+ var CSS = win.CSS;
68
+ var doc = win.document || { head: {} };
69
+ var H = (win.HTMLElement || /** @class */ (function () {
70
+ function HTMLElement() {
71
+ }
72
+ return HTMLElement;
73
+ }()));
74
+ var plt = {
75
+ $flags$: 0,
76
+ $resourcesUrl$: '',
77
+ jmp: function (h) { return h(); },
78
+ raf: function (h) { return requestAnimationFrame(h); },
79
+ ael: function (el, eventName, listener, opts) { return el.addEventListener(eventName, listener, opts); },
80
+ rel: function (el, eventName, listener, opts) { return el.removeEventListener(eventName, listener, opts); },
81
+ ce: function (eventName, opts) { return new CustomEvent(eventName, opts); },
82
+ };
83
+ var promiseResolve = function (v) { return Promise.resolve(v); };
84
+ var supportsConstructibleStylesheets = /*@__PURE__*/ (function () {
85
+ try {
86
+ new CSSStyleSheet();
87
+ return true;
88
+ }
89
+ catch (e) { }
90
+ return false;
91
+ })();
92
+ var addHostEventListeners = function (elm, hostRef, listeners, attachParentListeners) {
93
+ if (listeners) {
94
+ listeners.map(function (_a) {
95
+ var flags = _a[0], name = _a[1], method = _a[2];
96
+ var target = elm;
97
+ var handler = hostListenerProxy(hostRef, method);
98
+ var opts = hostListenerOpts(flags);
99
+ plt.ael(target, name, handler, opts);
100
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(function () { return plt.rel(target, name, handler, opts); });
101
+ });
102
+ }
103
+ };
104
+ var hostListenerProxy = function (hostRef, methodName) { return function (ev) {
105
+ {
106
+ if (hostRef.$flags$ & 256 /* isListenReady */) {
107
+ // instance is ready, let's call it's member method for this event
108
+ hostRef.$lazyInstance$[methodName](ev);
109
+ }
110
+ else {
111
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
112
+ }
113
+ }
114
+ }; };
115
+ // prettier-ignore
116
+ var hostListenerOpts = function (flags) { return (flags & 2 /* Capture */) !== 0; };
117
+ var HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
118
+ var createTime = function (fnName, tagName) {
119
+ if (tagName === void 0) { tagName = ''; }
120
+ {
121
+ return function () {
122
+ return;
123
+ };
124
+ }
125
+ };
126
+ var uniqueTime = function (key, measureText) {
127
+ {
128
+ return function () {
129
+ return;
130
+ };
131
+ }
132
+ };
133
+ var rootAppliedStyles = new WeakMap();
134
+ var registerStyle = function (scopeId, cssText, allowCS) {
135
+ var style = styles.get(scopeId);
136
+ if (supportsConstructibleStylesheets && allowCS) {
137
+ style = (style || new CSSStyleSheet());
138
+ style.replace(cssText);
139
+ }
140
+ else {
141
+ style = cssText;
142
+ }
143
+ styles.set(scopeId, style);
144
+ };
145
+ var addStyle = function (styleContainerNode, cmpMeta, mode, hostElm) {
146
+ var scopeId = getScopeId(cmpMeta);
147
+ var style = styles.get(scopeId);
148
+ // if an element is NOT connected then getRootNode() will return the wrong root node
149
+ // so the fallback is to always use the document for the root node in those cases
150
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
151
+ if (style) {
152
+ if (typeof style === 'string') {
153
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
154
+ var appliedStyles = rootAppliedStyles.get(styleContainerNode);
155
+ var styleElm = void 0;
156
+ if (!appliedStyles) {
157
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
158
+ }
159
+ if (!appliedStyles.has(scopeId)) {
160
+ {
161
+ if (plt.$cssShim$) {
162
+ styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* needsScopedEncapsulation */));
163
+ var newScopeId = styleElm['s-sc'];
164
+ if (newScopeId) {
165
+ scopeId = newScopeId;
166
+ // we don't want to add this styleID to the appliedStyles Set
167
+ // since the cssVarShim might need to apply several different
168
+ // stylesheets for the same component
169
+ appliedStyles = null;
170
+ }
171
+ }
172
+ else {
173
+ styleElm = doc.createElement('style');
174
+ styleElm.innerHTML = style;
175
+ }
176
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
177
+ }
178
+ if (appliedStyles) {
179
+ appliedStyles.add(scopeId);
180
+ }
181
+ }
182
+ }
183
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
184
+ styleContainerNode.adoptedStyleSheets = __spreadArrays(styleContainerNode.adoptedStyleSheets, [style]);
185
+ }
186
+ }
187
+ return scopeId;
188
+ };
189
+ var attachStyles = function (hostRef) {
190
+ var cmpMeta = hostRef.$cmpMeta$;
191
+ var elm = hostRef.$hostElement$;
192
+ var endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
193
+ var scopeId = addStyle(elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
194
+ endAttachStyles();
195
+ };
196
+ var getScopeId = function (cmp, mode) { return 'sc-' + (cmp.$tagName$); };
197
+ /**
198
+ * Default style mode id
199
+ */
200
+ /**
201
+ * Reusable empty obj/array
202
+ * Don't add values to these!!
203
+ */
204
+ var EMPTY_OBJ = {};
205
+ var noop = function () {
206
+ /* noop*/
207
+ };
208
+ var isComplexType = function (o) {
209
+ // https://jsperf.com/typeof-fn-object/5
210
+ o = typeof o;
211
+ return o === 'object' || o === 'function';
212
+ };
213
+ var IS_DENO_ENV = typeof Deno !== 'undefined';
214
+ var IS_NODE_ENV = !IS_DENO_ENV &&
215
+ typeof global !== 'undefined' &&
216
+ typeof require === 'function' &&
217
+ !!global.process &&
218
+ typeof __filename === 'string' &&
219
+ (!global.origin || typeof global.origin !== 'string');
220
+ var IS_DENO_WINDOWS_ENV = IS_DENO_ENV && Deno.build.os === 'windows';
221
+ var getCurrentDirectory = IS_NODE_ENV ? process.cwd : IS_DENO_ENV ? Deno.cwd : function () { return '/'; };
222
+ var exit = IS_NODE_ENV ? process.exit : IS_DENO_ENV ? Deno.exit : noop;
223
+ /**
224
+ * Production h() function based on Preact by
225
+ * Jason Miller (@developit)
226
+ * Licensed under the MIT License
227
+ * https://github.com/developit/preact/blob/master/LICENSE
228
+ *
229
+ * Modified for Stencil's compiler and vdom
230
+ */
231
+ // const stack: any[] = [];
232
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
233
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
234
+ var h = function (nodeName, vnodeData) {
235
+ var children = [];
236
+ for (var _i = 2; _i < arguments.length; _i++) {
237
+ children[_i - 2] = arguments[_i];
238
+ }
239
+ var child = null;
240
+ var slotName = null;
241
+ var simple = false;
242
+ var lastSimple = false;
243
+ var vNodeChildren = [];
244
+ var walk = function (c) {
245
+ for (var i = 0; i < c.length; i++) {
246
+ child = c[i];
247
+ if (Array.isArray(child)) {
248
+ walk(child);
249
+ }
250
+ else if (child != null && typeof child !== 'boolean') {
251
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
252
+ child = String(child);
253
+ }
254
+ if (simple && lastSimple) {
255
+ // If the previous child was simple (string), we merge both
256
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
257
+ }
258
+ else {
259
+ // Append a new vNode, if it's text, we create a text vNode
260
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
261
+ }
262
+ lastSimple = simple;
263
+ }
264
+ }
265
+ };
266
+ walk(children);
267
+ if (vnodeData) {
268
+ if (vnodeData.name) {
269
+ slotName = vnodeData.name;
270
+ }
271
+ {
272
+ var classData_1 = vnodeData.className || vnodeData.class;
273
+ if (classData_1) {
274
+ vnodeData.class =
275
+ typeof classData_1 !== 'object'
276
+ ? classData_1
277
+ : Object.keys(classData_1)
278
+ .filter(function (k) { return classData_1[k]; })
279
+ .join(' ');
280
+ }
281
+ }
282
+ }
283
+ if (typeof nodeName === 'function') {
284
+ // nodeName is a functional component
285
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
286
+ }
287
+ var vnode = newVNode(nodeName, null);
288
+ vnode.$attrs$ = vnodeData;
289
+ if (vNodeChildren.length > 0) {
290
+ vnode.$children$ = vNodeChildren;
291
+ }
292
+ {
293
+ vnode.$name$ = slotName;
294
+ }
295
+ return vnode;
296
+ };
297
+ var newVNode = function (tag, text) {
298
+ var vnode = {
299
+ $flags$: 0,
300
+ $tag$: tag,
301
+ $text$: text,
302
+ $elm$: null,
303
+ $children$: null,
304
+ };
305
+ {
306
+ vnode.$attrs$ = null;
307
+ }
308
+ {
309
+ vnode.$name$ = null;
310
+ }
311
+ return vnode;
312
+ };
313
+ var Host = {};
314
+ var isHost = function (node) { return node && node.$tag$ === Host; };
315
+ var vdomFnUtils = {
316
+ forEach: function (children, cb) { return children.map(convertToPublic).forEach(cb); },
317
+ map: function (children, cb) { return children
318
+ .map(convertToPublic)
319
+ .map(cb)
320
+ .map(convertToPrivate); },
321
+ };
322
+ var convertToPublic = function (node) { return ({
323
+ vattrs: node.$attrs$,
324
+ vchildren: node.$children$,
325
+ vkey: node.$key$,
326
+ vname: node.$name$,
327
+ vtag: node.$tag$,
328
+ vtext: node.$text$,
329
+ }); };
330
+ var convertToPrivate = function (node) {
331
+ if (typeof node.vtag === 'function') {
332
+ var vnodeData = Object.assign({}, node.vattrs);
333
+ if (node.vkey) {
334
+ vnodeData.key = node.vkey;
335
+ }
336
+ if (node.vname) {
337
+ vnodeData.name = node.vname;
338
+ }
339
+ return h.apply(void 0, __spreadArrays([node.vtag, vnodeData], node.vchildren || []));
340
+ }
341
+ var vnode = newVNode(node.vtag, node.vtext);
342
+ vnode.$attrs$ = node.vattrs;
343
+ vnode.$children$ = node.vchildren;
344
+ vnode.$key$ = node.vkey;
345
+ vnode.$name$ = node.vname;
346
+ return vnode;
347
+ };
348
+ /**
349
+ * Production setAccessor() function based on Preact by
350
+ * Jason Miller (@developit)
351
+ * Licensed under the MIT License
352
+ * https://github.com/developit/preact/blob/master/LICENSE
353
+ *
354
+ * Modified for Stencil's compiler and vdom
355
+ */
356
+ var setAccessor = function (elm, memberName, oldValue, newValue, isSvg, flags) {
357
+ if (oldValue !== newValue) {
358
+ var isProp = isMemberInElement(elm, memberName);
359
+ var ln = memberName.toLowerCase();
360
+ if (memberName === 'class') {
361
+ var classList = elm.classList;
362
+ var oldClasses_1 = parseClassList(oldValue);
363
+ var newClasses_1 = parseClassList(newValue);
364
+ classList.remove.apply(classList, oldClasses_1.filter(function (c) { return c && !newClasses_1.includes(c); }));
365
+ classList.add.apply(classList, newClasses_1.filter(function (c) { return c && !oldClasses_1.includes(c); }));
366
+ }
367
+ else if ((!isProp) && memberName[0] === 'o' && memberName[1] === 'n') {
368
+ // Event Handlers
369
+ // so if the member name starts with "on" and the 3rd characters is
370
+ // a capital letter, and it's not already a member on the element,
371
+ // then we're assuming it's an event listener
372
+ if (memberName[2] === '-') {
373
+ // on- prefixed events
374
+ // allows to be explicit about the dom event to listen without any magic
375
+ // under the hood:
376
+ // <my-cmp on-click> // listens for "click"
377
+ // <my-cmp on-Click> // listens for "Click"
378
+ // <my-cmp on-ionChange> // listens for "ionChange"
379
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
380
+ memberName = memberName.slice(3);
381
+ }
382
+ else if (isMemberInElement(win, ln)) {
383
+ // standard event
384
+ // the JSX attribute could have been "onMouseOver" and the
385
+ // member name "onmouseover" is on the window's prototype
386
+ // so let's add the listener "mouseover", which is all lowercased
387
+ memberName = ln.slice(2);
388
+ }
389
+ else {
390
+ // custom event
391
+ // the JSX attribute could have been "onMyCustomEvent"
392
+ // so let's trim off the "on" prefix and lowercase the first character
393
+ // and add the listener "myCustomEvent"
394
+ // except for the first character, we keep the event name case
395
+ memberName = ln[2] + memberName.slice(3);
396
+ }
397
+ if (oldValue) {
398
+ plt.rel(elm, memberName, oldValue, false);
399
+ }
400
+ if (newValue) {
401
+ plt.ael(elm, memberName, newValue, false);
402
+ }
403
+ }
404
+ else {
405
+ // Set property if it exists and it's not a SVG
406
+ var isComplex = isComplexType(newValue);
407
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
408
+ try {
409
+ if (!elm.tagName.includes('-')) {
410
+ var n = newValue == null ? '' : newValue;
411
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
412
+ if (memberName === 'list') {
413
+ isProp = false;
414
+ // tslint:disable-next-line: triple-equals
415
+ }
416
+ else if (oldValue == null || elm[memberName] != n) {
417
+ elm[memberName] = n;
418
+ }
419
+ }
420
+ else {
421
+ elm[memberName] = newValue;
422
+ }
423
+ }
424
+ catch (e) { }
425
+ }
426
+ if (newValue == null || newValue === false) {
427
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
428
+ {
429
+ elm.removeAttribute(memberName);
430
+ }
431
+ }
432
+ }
433
+ else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
434
+ newValue = newValue === true ? '' : newValue;
435
+ {
436
+ elm.setAttribute(memberName, newValue);
437
+ }
438
+ }
439
+ }
440
+ }
441
+ };
442
+ var parseClassListRegex = /\s/;
443
+ var parseClassList = function (value) { return (!value ? [] : value.split(parseClassListRegex)); };
444
+ var updateElement = function (oldVnode, newVnode, isSvgMode, memberName) {
445
+ // if the element passed in is a shadow root, which is a document fragment
446
+ // then we want to be adding attrs/props to the shadow root's "host" element
447
+ // if it's not a shadow root, then we add attrs/props to the same element
448
+ var elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
449
+ var oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
450
+ var newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
451
+ {
452
+ // remove attributes no longer present on the vnode by setting them to undefined
453
+ for (memberName in oldVnodeAttrs) {
454
+ if (!(memberName in newVnodeAttrs)) {
455
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
456
+ }
457
+ }
458
+ }
459
+ // add new & update changed attributes
460
+ for (memberName in newVnodeAttrs) {
461
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
462
+ }
463
+ };
464
+ var createElm = function (oldParentVNode, newParentVNode, childIndex, parentElm) {
465
+ // tslint:disable-next-line: prefer-const
466
+ var newVNode = newParentVNode.$children$[childIndex];
467
+ var i = 0;
468
+ var elm;
469
+ var childNode;
470
+ var oldVNode;
471
+ if (!useNativeShadowDom) {
472
+ // remember for later we need to check to relocate nodes
473
+ checkSlotRelocate = true;
474
+ if (newVNode.$tag$ === 'slot') {
475
+ newVNode.$flags$ |= newVNode.$children$
476
+ ? // slot element has fallback content
477
+ 2 /* isSlotFallback */
478
+ : // slot element does not have fallback content
479
+ 1 /* isSlotReference */;
480
+ }
481
+ }
482
+ if (newVNode.$text$ !== null) {
483
+ // create text node
484
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
485
+ }
486
+ else if (newVNode.$flags$ & 1 /* isSlotReference */) {
487
+ // create a slot reference node
488
+ elm = newVNode.$elm$ = doc.createTextNode('');
489
+ }
490
+ else {
491
+ // create element
492
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* isSlotFallback */ ? 'slot-fb' : newVNode.$tag$));
493
+ // add css classes, attrs, props, listeners, etc.
494
+ {
495
+ updateElement(null, newVNode, isSvgMode);
496
+ }
497
+ if (newVNode.$children$) {
498
+ for (i = 0; i < newVNode.$children$.length; ++i) {
499
+ // create the node
500
+ childNode = createElm(oldParentVNode, newVNode, i);
501
+ // return node could have been null
502
+ if (childNode) {
503
+ // append our new node
504
+ elm.appendChild(childNode);
505
+ }
506
+ }
507
+ }
508
+ }
509
+ {
510
+ elm['s-hn'] = hostTagName;
511
+ if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
512
+ // remember the content reference comment
513
+ elm['s-sr'] = true;
514
+ // remember the content reference comment
515
+ elm['s-cr'] = contentRef;
516
+ // remember the slot name, or empty string for default slot
517
+ elm['s-sn'] = newVNode.$name$ || '';
518
+ // check if we've got an old vnode for this slot
519
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
520
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
521
+ // we've got an old slot vnode and the wrapper is being replaced
522
+ // so let's move the old slot content back to it's original location
523
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
524
+ }
525
+ }
526
+ }
527
+ return elm;
528
+ };
529
+ var putBackInOriginalLocation = function (parentElm, recursive) {
530
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
531
+ var oldSlotChildNodes = parentElm.childNodes;
532
+ for (var i = oldSlotChildNodes.length - 1; i >= 0; i--) {
533
+ var childNode = oldSlotChildNodes[i];
534
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
535
+ // // this child node in the old element is from another component
536
+ // // remove this node from the old slot's parent
537
+ // childNode.remove();
538
+ // and relocate it back to it's original location
539
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
540
+ // remove the old original location comment entirely
541
+ // later on the patch function will know what to do
542
+ // and move this to the correct spot in need be
543
+ childNode['s-ol'].remove();
544
+ childNode['s-ol'] = undefined;
545
+ checkSlotRelocate = true;
546
+ }
547
+ if (recursive) {
548
+ putBackInOriginalLocation(childNode, recursive);
549
+ }
550
+ }
551
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
552
+ };
553
+ var addVnodes = function (parentElm, before, parentVNode, vnodes, startIdx, endIdx) {
554
+ var containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
555
+ var childNode;
556
+ for (; startIdx <= endIdx; ++startIdx) {
557
+ if (vnodes[startIdx]) {
558
+ childNode = createElm(null, parentVNode, startIdx);
559
+ if (childNode) {
560
+ vnodes[startIdx].$elm$ = childNode;
561
+ containerElm.insertBefore(childNode, referenceNode(before));
562
+ }
563
+ }
564
+ }
565
+ };
566
+ var removeVnodes = function (vnodes, startIdx, endIdx, vnode, elm) {
567
+ for (; startIdx <= endIdx; ++startIdx) {
568
+ if ((vnode = vnodes[startIdx])) {
569
+ elm = vnode.$elm$;
570
+ {
571
+ // we're removing this element
572
+ // so it's possible we need to show slot fallback content now
573
+ checkSlotFallbackVisibility = true;
574
+ if (elm['s-ol']) {
575
+ // remove the original location comment
576
+ elm['s-ol'].remove();
577
+ }
578
+ else {
579
+ // it's possible that child nodes of the node
580
+ // that's being removed are slot nodes
581
+ putBackInOriginalLocation(elm, true);
582
+ }
583
+ }
584
+ // remove the vnode's element from the dom
585
+ elm.remove();
586
+ }
587
+ }
588
+ };
589
+ var updateChildren = function (parentElm, oldCh, newVNode, newCh) {
590
+ var oldStartIdx = 0;
591
+ var newStartIdx = 0;
592
+ var oldEndIdx = oldCh.length - 1;
593
+ var oldStartVnode = oldCh[0];
594
+ var oldEndVnode = oldCh[oldEndIdx];
595
+ var newEndIdx = newCh.length - 1;
596
+ var newStartVnode = newCh[0];
597
+ var newEndVnode = newCh[newEndIdx];
598
+ var node;
599
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
600
+ if (oldStartVnode == null) {
601
+ // Vnode might have been moved left
602
+ oldStartVnode = oldCh[++oldStartIdx];
603
+ }
604
+ else if (oldEndVnode == null) {
605
+ oldEndVnode = oldCh[--oldEndIdx];
606
+ }
607
+ else if (newStartVnode == null) {
608
+ newStartVnode = newCh[++newStartIdx];
609
+ }
610
+ else if (newEndVnode == null) {
611
+ newEndVnode = newCh[--newEndIdx];
612
+ }
613
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
614
+ patch(oldStartVnode, newStartVnode);
615
+ oldStartVnode = oldCh[++oldStartIdx];
616
+ newStartVnode = newCh[++newStartIdx];
617
+ }
618
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
619
+ patch(oldEndVnode, newEndVnode);
620
+ oldEndVnode = oldCh[--oldEndIdx];
621
+ newEndVnode = newCh[--newEndIdx];
622
+ }
623
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
624
+ // Vnode moved right
625
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
626
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
627
+ }
628
+ patch(oldStartVnode, newEndVnode);
629
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
630
+ oldStartVnode = oldCh[++oldStartIdx];
631
+ newEndVnode = newCh[--newEndIdx];
632
+ }
633
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
634
+ // Vnode moved left
635
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
636
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
637
+ }
638
+ patch(oldEndVnode, newStartVnode);
639
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
640
+ oldEndVnode = oldCh[--oldEndIdx];
641
+ newStartVnode = newCh[++newStartIdx];
642
+ }
643
+ else {
644
+ {
645
+ // new element
646
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
647
+ newStartVnode = newCh[++newStartIdx];
648
+ }
649
+ if (node) {
650
+ {
651
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
652
+ }
653
+ }
654
+ }
655
+ }
656
+ if (oldStartIdx > oldEndIdx) {
657
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
658
+ }
659
+ else if (newStartIdx > newEndIdx) {
660
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
661
+ }
662
+ };
663
+ var isSameVnode = function (vnode1, vnode2) {
664
+ // compare if two vnode to see if they're "technically" the same
665
+ // need to have the same element tag, and same key to be the same
666
+ if (vnode1.$tag$ === vnode2.$tag$) {
667
+ if (vnode1.$tag$ === 'slot') {
668
+ return vnode1.$name$ === vnode2.$name$;
669
+ }
670
+ return true;
671
+ }
672
+ return false;
673
+ };
674
+ var referenceNode = function (node) {
675
+ // this node was relocated to a new location in the dom
676
+ // because of some other component's slot
677
+ // but we still have an html comment in place of where
678
+ // it's original location was according to it's original vdom
679
+ return (node && node['s-ol']) || node;
680
+ };
681
+ var parentReferenceNode = function (node) { return (node['s-ol'] ? node['s-ol'] : node).parentNode; };
682
+ var patch = function (oldVNode, newVNode) {
683
+ var elm = (newVNode.$elm$ = oldVNode.$elm$);
684
+ var oldChildren = oldVNode.$children$;
685
+ var newChildren = newVNode.$children$;
686
+ var tag = newVNode.$tag$;
687
+ var text = newVNode.$text$;
688
+ var defaultHolder;
689
+ if (text === null) {
690
+ // element node
691
+ {
692
+ if (tag === 'slot')
693
+ ;
694
+ else {
695
+ // either this is the first render of an element OR it's an update
696
+ // AND we already know it's possible it could have changed
697
+ // this updates the element's css classes, attrs, props, listeners, etc.
698
+ updateElement(oldVNode, newVNode, isSvgMode);
699
+ }
700
+ }
701
+ if (oldChildren !== null && newChildren !== null) {
702
+ // looks like there's child vnodes for both the old and new vnodes
703
+ updateChildren(elm, oldChildren, newVNode, newChildren);
704
+ }
705
+ else if (newChildren !== null) {
706
+ // no old child vnodes, but there are new child vnodes to add
707
+ if (oldVNode.$text$ !== null) {
708
+ // the old vnode was text, so be sure to clear it out
709
+ elm.textContent = '';
710
+ }
711
+ // add the new vnode children
712
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
713
+ }
714
+ else if (oldChildren !== null) {
715
+ // no new child vnodes, but there are old child vnodes to remove
716
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
717
+ }
718
+ }
719
+ else if ((defaultHolder = elm['s-cr'])) {
720
+ // this element has slotted content
721
+ defaultHolder.parentNode.textContent = text;
722
+ }
723
+ else if (oldVNode.$text$ !== text) {
724
+ // update the text content for the text only vnode
725
+ // and also only if the text is different than before
726
+ elm.data = text;
727
+ }
728
+ };
729
+ var updateFallbackSlotVisibility = function (elm) {
730
+ // tslint:disable-next-line: prefer-const
731
+ var childNodes = elm.childNodes;
732
+ var childNode;
733
+ var i;
734
+ var ilen;
735
+ var j;
736
+ var slotNameAttr;
737
+ var nodeType;
738
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
739
+ childNode = childNodes[i];
740
+ if (childNode.nodeType === 1 /* ElementNode */) {
741
+ if (childNode['s-sr']) {
742
+ // this is a slot fallback node
743
+ // get the slot name for this slot reference node
744
+ slotNameAttr = childNode['s-sn'];
745
+ // by default always show a fallback slot node
746
+ // then hide it if there are other slots in the light dom
747
+ childNode.hidden = false;
748
+ for (j = 0; j < ilen; j++) {
749
+ if (childNodes[j]['s-hn'] !== childNode['s-hn']) {
750
+ // this sibling node is from a different component
751
+ nodeType = childNodes[j].nodeType;
752
+ if (slotNameAttr !== '') {
753
+ // this is a named fallback slot node
754
+ if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
755
+ childNode.hidden = true;
756
+ break;
757
+ }
758
+ }
759
+ else {
760
+ // this is a default fallback slot node
761
+ // any element or text node (with content)
762
+ // should hide the default fallback slot node
763
+ if (nodeType === 1 /* ElementNode */ || (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
764
+ childNode.hidden = true;
765
+ break;
766
+ }
767
+ }
768
+ }
769
+ }
770
+ }
771
+ // keep drilling down
772
+ updateFallbackSlotVisibility(childNode);
773
+ }
774
+ }
775
+ };
776
+ var relocateNodes = [];
777
+ var relocateSlotContent = function (elm) {
778
+ // tslint:disable-next-line: prefer-const
779
+ var childNode;
780
+ var node;
781
+ var hostContentNodes;
782
+ var slotNameAttr;
783
+ var relocateNodeData;
784
+ var j;
785
+ var i = 0;
786
+ var childNodes = elm.childNodes;
787
+ var ilen = childNodes.length;
788
+ for (; i < ilen; i++) {
789
+ childNode = childNodes[i];
790
+ if (childNode['s-sr'] && (node = childNode['s-cr'])) {
791
+ // first got the content reference comment node
792
+ // then we got it's parent, which is where all the host content is in now
793
+ hostContentNodes = node.parentNode.childNodes;
794
+ slotNameAttr = childNode['s-sn'];
795
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
796
+ node = hostContentNodes[j];
797
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
798
+ // let's do some relocating to its new home
799
+ // but never relocate a content reference node
800
+ // that is suppose to always represent the original content location
801
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
802
+ // it's possible we've already decided to relocate this node
803
+ relocateNodeData = relocateNodes.find(function (r) { return r.$nodeToRelocate$ === node; });
804
+ // made some changes to slots
805
+ // let's make sure we also double check
806
+ // fallbacks are correctly hidden or shown
807
+ checkSlotFallbackVisibility = true;
808
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
809
+ if (relocateNodeData) {
810
+ // previously we never found a slot home for this node
811
+ // but turns out we did, so let's remember it now
812
+ relocateNodeData.$slotRefNode$ = childNode;
813
+ }
814
+ else {
815
+ // add to our list of nodes to relocate
816
+ relocateNodes.push({
817
+ $slotRefNode$: childNode,
818
+ $nodeToRelocate$: node,
819
+ });
820
+ }
821
+ if (node['s-sr']) {
822
+ relocateNodes.map(function (relocateNode) {
823
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
824
+ relocateNodeData = relocateNodes.find(function (r) { return r.$nodeToRelocate$ === node; });
825
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
826
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
827
+ }
828
+ }
829
+ });
830
+ }
831
+ }
832
+ else if (!relocateNodes.some(function (r) { return r.$nodeToRelocate$ === node; })) {
833
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
834
+ // if we never find a home for this element then we'll need to hide it
835
+ relocateNodes.push({
836
+ $nodeToRelocate$: node,
837
+ });
838
+ }
839
+ }
840
+ }
841
+ }
842
+ if (childNode.nodeType === 1 /* ElementNode */) {
843
+ relocateSlotContent(childNode);
844
+ }
845
+ }
846
+ };
847
+ var isNodeLocatedInSlot = function (nodeToRelocate, slotNameAttr) {
848
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
849
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
850
+ return true;
851
+ }
852
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
853
+ return true;
854
+ }
855
+ return false;
856
+ }
857
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
858
+ return true;
859
+ }
860
+ return slotNameAttr === '';
861
+ };
862
+ var renderVdom = function (hostRef, renderFnResults) {
863
+ var hostElm = hostRef.$hostElement$;
864
+ var cmpMeta = hostRef.$cmpMeta$;
865
+ var oldVNode = hostRef.$vnode$ || newVNode(null, null);
866
+ var rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
867
+ hostTagName = hostElm.tagName;
868
+ rootVnode.$tag$ = null;
869
+ rootVnode.$flags$ |= 4 /* isHost */;
870
+ hostRef.$vnode$ = rootVnode;
871
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
872
+ {
873
+ contentRef = hostElm['s-cr'];
874
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
875
+ // always reset
876
+ checkSlotFallbackVisibility = false;
877
+ }
878
+ // synchronous patch
879
+ patch(oldVNode, rootVnode);
880
+ {
881
+ // while we're moving nodes around existing nodes, temporarily disable
882
+ // the disconnectCallback from working
883
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
884
+ if (checkSlotRelocate) {
885
+ relocateSlotContent(rootVnode.$elm$);
886
+ var relocateData = void 0;
887
+ var nodeToRelocate = void 0;
888
+ var orgLocationNode = void 0;
889
+ var parentNodeRef = void 0;
890
+ var insertBeforeNode = void 0;
891
+ var refNode = void 0;
892
+ var i = 0;
893
+ for (; i < relocateNodes.length; i++) {
894
+ relocateData = relocateNodes[i];
895
+ nodeToRelocate = relocateData.$nodeToRelocate$;
896
+ if (!nodeToRelocate['s-ol']) {
897
+ // add a reference node marking this node's original location
898
+ // keep a reference to this node for later lookups
899
+ orgLocationNode = doc.createTextNode('');
900
+ orgLocationNode['s-nr'] = nodeToRelocate;
901
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
902
+ }
903
+ }
904
+ for (i = 0; i < relocateNodes.length; i++) {
905
+ relocateData = relocateNodes[i];
906
+ nodeToRelocate = relocateData.$nodeToRelocate$;
907
+ if (relocateData.$slotRefNode$) {
908
+ // by default we're just going to insert it directly
909
+ // after the slot reference node
910
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
911
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
912
+ orgLocationNode = nodeToRelocate['s-ol'];
913
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
914
+ refNode = orgLocationNode['s-nr'];
915
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
916
+ refNode = refNode.nextSibling;
917
+ if (!refNode || !refNode['s-nr']) {
918
+ insertBeforeNode = refNode;
919
+ break;
920
+ }
921
+ }
922
+ }
923
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) || nodeToRelocate.nextSibling !== insertBeforeNode) {
924
+ // we've checked that it's worth while to relocate
925
+ // since that the node to relocate
926
+ // has a different next sibling or parent relocated
927
+ if (nodeToRelocate !== insertBeforeNode) {
928
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
929
+ // probably a component in the index.html that doesn't have it's hostname set
930
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
931
+ }
932
+ // add it back to the dom but in its new home
933
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
934
+ }
935
+ }
936
+ }
937
+ else {
938
+ // this node doesn't have a slot home to go to, so let's hide it
939
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
940
+ nodeToRelocate.hidden = true;
941
+ }
942
+ }
943
+ }
944
+ }
945
+ if (checkSlotFallbackVisibility) {
946
+ updateFallbackSlotVisibility(rootVnode.$elm$);
947
+ }
948
+ // done moving nodes around
949
+ // allow the disconnect callback to work again
950
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
951
+ // always reset
952
+ relocateNodes.length = 0;
953
+ }
954
+ };
955
+ var getElement = function (ref) { return (getHostRef(ref).$hostElement$); };
956
+ var createEvent = function (ref, name, flags) {
957
+ var elm = getElement(ref);
958
+ return {
959
+ emit: function (detail) {
960
+ return emitEvent(elm, name, {
961
+ bubbles: !!(flags & 4 /* Bubbles */),
962
+ composed: !!(flags & 2 /* Composed */),
963
+ cancelable: !!(flags & 1 /* Cancellable */),
964
+ detail: detail,
965
+ });
966
+ },
967
+ };
968
+ };
969
+ var emitEvent = function (elm, name, opts) {
970
+ var ev = plt.ce(name, opts);
971
+ elm.dispatchEvent(ev);
972
+ return ev;
973
+ };
974
+ var attachToAncestor = function (hostRef, ancestorComponent) {
975
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
976
+ ancestorComponent['s-p'].push(new Promise(function (r) { return (hostRef.$onRenderResolve$ = r); }));
977
+ }
978
+ };
979
+ var scheduleUpdate = function (hostRef, isInitialLoad) {
980
+ {
981
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
982
+ }
983
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
984
+ hostRef.$flags$ |= 512 /* needsRerender */;
985
+ return;
986
+ }
987
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
988
+ // there is no ancestorc omponent or the ancestor component
989
+ // has already fired off its lifecycle update then
990
+ // fire off the initial update
991
+ var dispatch = function () { return dispatchHooks(hostRef, isInitialLoad); };
992
+ return writeTask(dispatch);
993
+ };
994
+ var dispatchHooks = function (hostRef, isInitialLoad) {
995
+ var endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
996
+ var instance = hostRef.$lazyInstance$;
997
+ var promise;
998
+ if (isInitialLoad) {
999
+ {
1000
+ hostRef.$flags$ |= 256 /* isListenReady */;
1001
+ if (hostRef.$queuedListeners$) {
1002
+ hostRef.$queuedListeners$.map(function (_a) {
1003
+ var methodName = _a[0], event = _a[1];
1004
+ return safeCall(instance, methodName, event);
1005
+ });
1006
+ hostRef.$queuedListeners$ = null;
1007
+ }
1008
+ }
1009
+ {
1010
+ promise = safeCall(instance, 'componentWillLoad');
1011
+ }
1012
+ }
1013
+ endSchedule();
1014
+ return then(promise, function () { return updateComponent(hostRef, instance, isInitialLoad); });
1015
+ };
1016
+ var updateComponent = function (hostRef, instance, isInitialLoad) {
1017
+ // updateComponent
1018
+ var elm = hostRef.$hostElement$;
1019
+ var endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1020
+ var rc = elm['s-rc'];
1021
+ if (isInitialLoad) {
1022
+ // DOM WRITE!
1023
+ attachStyles(hostRef);
1024
+ }
1025
+ var endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1026
+ {
1027
+ {
1028
+ // looks like we've got child nodes to render into this host element
1029
+ // or we need to update the css class/attrs on the host element
1030
+ // DOM WRITE!
1031
+ renderVdom(hostRef, callRender(hostRef, instance));
1032
+ }
1033
+ }
1034
+ if (plt.$cssShim$) {
1035
+ plt.$cssShim$.updateHost(elm);
1036
+ }
1037
+ if (rc) {
1038
+ // ok, so turns out there are some child host elements
1039
+ // waiting on this parent element to load
1040
+ // let's fire off all update callbacks waiting
1041
+ rc.map(function (cb) { return cb(); });
1042
+ elm['s-rc'] = undefined;
1043
+ }
1044
+ endRender();
1045
+ endUpdate();
1046
+ {
1047
+ var childrenPromises = elm['s-p'];
1048
+ var postUpdate = function () { return postUpdateComponent(hostRef); };
1049
+ if (childrenPromises.length === 0) {
1050
+ postUpdate();
1051
+ }
1052
+ else {
1053
+ Promise.all(childrenPromises).then(postUpdate);
1054
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1055
+ childrenPromises.length = 0;
1056
+ }
1057
+ }
1058
+ };
1059
+ var callRender = function (hostRef, instance) {
1060
+ try {
1061
+ instance = instance.render();
1062
+ {
1063
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1064
+ }
1065
+ {
1066
+ hostRef.$flags$ |= 2 /* hasRendered */;
1067
+ }
1068
+ }
1069
+ catch (e) {
1070
+ consoleError(e);
1071
+ }
1072
+ return instance;
1073
+ };
1074
+ var postUpdateComponent = function (hostRef) {
1075
+ var tagName = hostRef.$cmpMeta$.$tagName$;
1076
+ var elm = hostRef.$hostElement$;
1077
+ var endPostUpdate = createTime('postUpdate', tagName);
1078
+ var instance = hostRef.$lazyInstance$;
1079
+ var ancestorComponent = hostRef.$ancestorComponent$;
1080
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1081
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1082
+ {
1083
+ // DOM WRITE!
1084
+ addHydratedFlag(elm);
1085
+ }
1086
+ {
1087
+ safeCall(instance, 'componentDidLoad');
1088
+ }
1089
+ endPostUpdate();
1090
+ {
1091
+ hostRef.$onReadyResolve$(elm);
1092
+ if (!ancestorComponent) {
1093
+ appDidLoad();
1094
+ }
1095
+ }
1096
+ }
1097
+ else {
1098
+ endPostUpdate();
1099
+ }
1100
+ // load events fire from bottom to top
1101
+ // the deepest elements load first then bubbles up
1102
+ {
1103
+ if (hostRef.$onRenderResolve$) {
1104
+ hostRef.$onRenderResolve$();
1105
+ hostRef.$onRenderResolve$ = undefined;
1106
+ }
1107
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
1108
+ nextTick(function () { return scheduleUpdate(hostRef, false); });
1109
+ }
1110
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1111
+ }
1112
+ // ( •_•)
1113
+ // ( •_•)>⌐■-■
1114
+ // (⌐■_■)
1115
+ };
1116
+ var forceUpdate = function (ref) {
1117
+ {
1118
+ var hostRef = getHostRef(ref);
1119
+ var isConnected = hostRef.$hostElement$.isConnected;
1120
+ if (isConnected && (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1121
+ scheduleUpdate(hostRef, false);
1122
+ }
1123
+ // Returns "true" when the forced update was successfully scheduled
1124
+ return isConnected;
1125
+ }
1126
+ };
1127
+ var appDidLoad = function (who) {
1128
+ // on appload
1129
+ // we have finish the first big initial render
1130
+ {
1131
+ addHydratedFlag(doc.documentElement);
1132
+ }
1133
+ {
1134
+ plt.$flags$ |= 2 /* appLoaded */;
1135
+ }
1136
+ nextTick(function () { return emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }); });
1137
+ };
1138
+ var safeCall = function (instance, method, arg) {
1139
+ if (instance && instance[method]) {
1140
+ try {
1141
+ return instance[method](arg);
1142
+ }
1143
+ catch (e) {
1144
+ consoleError(e);
1145
+ }
1146
+ }
1147
+ return undefined;
1148
+ };
1149
+ var then = function (promise, thenFn) {
1150
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
1151
+ };
1152
+ var addHydratedFlag = function (elm) { return (elm.classList.add('hydrated')); };
1153
+ var parsePropertyValue = function (propValue, propType) {
1154
+ // ensure this value is of the correct prop type
1155
+ if (propValue != null && !isComplexType(propValue)) {
1156
+ if (propType & 4 /* Boolean */) {
1157
+ // per the HTML spec, any string value means it is a boolean true value
1158
+ // but we'll cheat here and say that the string "false" is the boolean false
1159
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
1160
+ }
1161
+ if (propType & 2 /* Number */) {
1162
+ // force it to be a number
1163
+ return parseFloat(propValue);
1164
+ }
1165
+ if (propType & 1 /* String */) {
1166
+ // could have been passed as a number or boolean
1167
+ // but we still want it as a string
1168
+ return String(propValue);
1169
+ }
1170
+ // redundant return here for better minification
1171
+ return propValue;
1172
+ }
1173
+ // not sure exactly what type we want
1174
+ // so no need to change to a different type
1175
+ return propValue;
1176
+ };
1177
+ var getValue = function (ref, propName) { return getHostRef(ref).$instanceValues$.get(propName); };
1178
+ var setValue = function (ref, propName, newVal, cmpMeta) {
1179
+ // check our new property value against our internal value
1180
+ var hostRef = getHostRef(ref);
1181
+ var oldVal = hostRef.$instanceValues$.get(propName);
1182
+ var flags = hostRef.$flags$;
1183
+ var instance = hostRef.$lazyInstance$;
1184
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1185
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && newVal !== oldVal) {
1186
+ // gadzooks! the property's value has changed!!
1187
+ // set our new value!
1188
+ hostRef.$instanceValues$.set(propName, newVal);
1189
+ if (instance) {
1190
+ // get an array of method names of watch functions to call
1191
+ if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1192
+ var watchMethods = cmpMeta.$watchers$[propName];
1193
+ if (watchMethods) {
1194
+ // this instance is watching for when this property changed
1195
+ watchMethods.map(function (watchMethodName) {
1196
+ try {
1197
+ // fire off each of the watch methods that are watching this property
1198
+ instance[watchMethodName](newVal, oldVal, propName);
1199
+ }
1200
+ catch (e) {
1201
+ consoleError(e);
1202
+ }
1203
+ });
1204
+ }
1205
+ }
1206
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1207
+ // looks like this value actually changed, so we've got work to do!
1208
+ // but only if we've already rendered, otherwise just chill out
1209
+ // queue that we need to do an update, but don't worry about queuing
1210
+ // up millions cuz this function ensures it only runs once
1211
+ scheduleUpdate(hostRef, false);
1212
+ }
1213
+ }
1214
+ }
1215
+ };
1216
+ var proxyComponent = function (Cstr, cmpMeta, flags) {
1217
+ if (cmpMeta.$members$) {
1218
+ if (Cstr.watchers) {
1219
+ cmpMeta.$watchers$ = Cstr.watchers;
1220
+ }
1221
+ // It's better to have a const than two Object.entries()
1222
+ var members = Object.entries(cmpMeta.$members$);
1223
+ var prototype_1 = Cstr.prototype;
1224
+ members.map(function (_a) {
1225
+ var memberName = _a[0], memberFlags = _a[1][0];
1226
+ if ((memberFlags & 31 /* Prop */ || ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1227
+ // proxyComponent - prop
1228
+ Object.defineProperty(prototype_1, memberName, {
1229
+ get: function () {
1230
+ // proxyComponent, get value
1231
+ return getValue(this, memberName);
1232
+ },
1233
+ set: function (newValue) {
1234
+ // proxyComponent, set value
1235
+ setValue(this, memberName, newValue, cmpMeta);
1236
+ },
1237
+ configurable: true,
1238
+ enumerable: true,
1239
+ });
1240
+ }
1241
+ });
1242
+ if ((flags & 1 /* isElementConstructor */)) {
1243
+ var attrNameToPropName_1 = new Map();
1244
+ prototype_1.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1245
+ var _this = this;
1246
+ plt.jmp(function () {
1247
+ var propName = attrNameToPropName_1.get(attrName);
1248
+ _this[propName] = newValue === null && typeof _this[propName] === 'boolean' ? false : newValue;
1249
+ });
1250
+ };
1251
+ // create an array of attributes to observe
1252
+ // and also create a map of html attribute name to js property name
1253
+ Cstr.observedAttributes = members
1254
+ .filter(function (_a) {
1255
+ var _ = _a[0], m = _a[1];
1256
+ return m[0] & 15;
1257
+ } /* HasAttribute */) // filter to only keep props that should match attributes
1258
+ .map(function (_a) {
1259
+ var propName = _a[0], m = _a[1];
1260
+ var attrName = m[1] || propName;
1261
+ attrNameToPropName_1.set(attrName, propName);
1262
+ return attrName;
1263
+ });
1264
+ }
1265
+ }
1266
+ return Cstr;
1267
+ };
1268
+ var initializeComponent = function (elm, hostRef, cmpMeta, hmrVersionId, Cstr) { return __awaiter(void 0, void 0, void 0, function () {
1269
+ var endLoad, endNewInstance, style, scopeId, endRegisterStyles, ancestorComponent, schedule;
1270
+ return __generator(this, function (_a) {
1271
+ switch (_a.label) {
1272
+ case 0:
1273
+ if (!((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0)) return [3 /*break*/, 3];
1274
+ // we haven't initialized this element yet
1275
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1276
+ // lazy loaded components
1277
+ // request the component's implementation to be
1278
+ // wired up with the host element
1279
+ Cstr = loadModule(cmpMeta);
1280
+ if (!Cstr.then) return [3 /*break*/, 2];
1281
+ endLoad = uniqueTime();
1282
+ return [4 /*yield*/, Cstr];
1283
+ case 1:
1284
+ Cstr = _a.sent();
1285
+ endLoad();
1286
+ _a.label = 2;
1287
+ case 2:
1288
+ if (!Cstr.isProxied) {
1289
+ // we'eve never proxied this Constructor before
1290
+ // let's add the getters/setters to its prototype before
1291
+ // the first time we create an instance of the implementation
1292
+ {
1293
+ cmpMeta.$watchers$ = Cstr.watchers;
1294
+ }
1295
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1296
+ Cstr.isProxied = true;
1297
+ }
1298
+ endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1299
+ // ok, time to construct the instance
1300
+ // but let's keep track of when we start and stop
1301
+ // so that the getters/setters don't incorrectly step on data
1302
+ {
1303
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
1304
+ }
1305
+ // construct the lazy-loaded component implementation
1306
+ // passing the hostRef is very important during
1307
+ // construction in order to directly wire together the
1308
+ // host element and the lazy-loaded instance
1309
+ try {
1310
+ new Cstr(hostRef);
1311
+ }
1312
+ catch (e) {
1313
+ consoleError(e);
1314
+ }
1315
+ {
1316
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1317
+ }
1318
+ {
1319
+ hostRef.$flags$ |= 128 /* isWatchReady */;
1320
+ }
1321
+ endNewInstance();
1322
+ if (Cstr.style) {
1323
+ style = Cstr.style;
1324
+ scopeId = getScopeId(cmpMeta);
1325
+ if (!styles.has(scopeId)) {
1326
+ endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1327
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1328
+ endRegisterStyles();
1329
+ }
1330
+ }
1331
+ _a.label = 3;
1332
+ case 3:
1333
+ ancestorComponent = hostRef.$ancestorComponent$;
1334
+ schedule = function () { return scheduleUpdate(hostRef, true); };
1335
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1336
+ // this is the intial load and this component it has an ancestor component
1337
+ // but the ancestor component has NOT fired its will update lifecycle yet
1338
+ // so let's just cool our jets and wait for the ancestor to continue first
1339
+ // this will get fired off when the ancestor component
1340
+ // finally gets around to rendering its lazy self
1341
+ // fire off the initial update
1342
+ ancestorComponent['s-rc'].push(schedule);
1343
+ }
1344
+ else {
1345
+ schedule();
1346
+ }
1347
+ return [2 /*return*/];
1348
+ }
1349
+ });
1350
+ }); };
1351
+ var connectedCallback = function (elm) {
1352
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1353
+ var hostRef_1 = getHostRef(elm);
1354
+ var cmpMeta_1 = hostRef_1.$cmpMeta$;
1355
+ var endConnected = createTime('connectedCallback', cmpMeta_1.$tagName$);
1356
+ if (!(hostRef_1.$flags$ & 1 /* hasConnected */)) {
1357
+ // first time this component has connected
1358
+ hostRef_1.$flags$ |= 1 /* hasConnected */;
1359
+ {
1360
+ // initUpdate
1361
+ // if the slot polyfill is required we'll need to put some nodes
1362
+ // in here to act as original content anchors as we move nodes around
1363
+ // host element has been connected to the DOM
1364
+ if ((cmpMeta_1.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
1365
+ setContentReference(elm);
1366
+ }
1367
+ }
1368
+ {
1369
+ // find the first ancestor component (if there is one) and register
1370
+ // this component as one of the actively loading child components for its ancestor
1371
+ var ancestorComponent = elm;
1372
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1373
+ // climb up the ancestors looking for the first
1374
+ // component that hasn't finished its lifecycle update yet
1375
+ if (ancestorComponent['s-p']) {
1376
+ // we found this components first ancestor component
1377
+ // keep a reference to this component's ancestor component
1378
+ attachToAncestor(hostRef_1, (hostRef_1.$ancestorComponent$ = ancestorComponent));
1379
+ break;
1380
+ }
1381
+ }
1382
+ }
1383
+ // Lazy properties
1384
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1385
+ if (cmpMeta_1.$members$) {
1386
+ Object.entries(cmpMeta_1.$members$).map(function (_a) {
1387
+ var memberName = _a[0], memberFlags = _a[1][0];
1388
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1389
+ var value = elm[memberName];
1390
+ delete elm[memberName];
1391
+ elm[memberName] = value;
1392
+ }
1393
+ });
1394
+ }
1395
+ {
1396
+ // connectedCallback, taskQueue, initialLoad
1397
+ // angular sets attribute AFTER connectCallback
1398
+ // https://github.com/angular/angular/issues/18909
1399
+ // https://github.com/angular/angular/issues/19940
1400
+ nextTick(function () { return initializeComponent(elm, hostRef_1, cmpMeta_1); });
1401
+ }
1402
+ }
1403
+ else {
1404
+ // not the first time this has connected
1405
+ // reattach any event listeners to the host
1406
+ // since they would have been removed when disconnected
1407
+ addHostEventListeners(elm, hostRef_1, cmpMeta_1.$listeners$);
1408
+ }
1409
+ endConnected();
1410
+ }
1411
+ };
1412
+ var setContentReference = function (elm) {
1413
+ // only required when we're NOT using native shadow dom (slot)
1414
+ // or this browser doesn't support native shadow dom
1415
+ // and this host element was NOT created with SSR
1416
+ // let's pick out the inner content for slot projection
1417
+ // create a node to represent where the original
1418
+ // content was first placed, which is useful later on
1419
+ var contentRefElm = (elm['s-cr'] = doc.createComment(''));
1420
+ contentRefElm['s-cn'] = true;
1421
+ elm.insertBefore(contentRefElm, elm.firstChild);
1422
+ };
1423
+ var disconnectedCallback = function (elm) {
1424
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1425
+ var hostRef = getHostRef(elm);
1426
+ {
1427
+ if (hostRef.$rmListeners$) {
1428
+ hostRef.$rmListeners$.map(function (rmListener) { return rmListener(); });
1429
+ hostRef.$rmListeners$ = undefined;
1430
+ }
1431
+ }
1432
+ // clear CSS var-shim tracking
1433
+ if (plt.$cssShim$) {
1434
+ plt.$cssShim$.removeHost(elm);
1435
+ }
1436
+ }
1437
+ };
1438
+ var patchCloneNode = function (HostElementPrototype) {
1439
+ var orgCloneNode = HostElementPrototype.cloneNode;
1440
+ HostElementPrototype.cloneNode = function (deep) {
1441
+ var srcNode = this;
1442
+ var clonedNode = orgCloneNode.call(srcNode, false);
1443
+ if (deep) {
1444
+ var i = 0;
1445
+ var slotted = void 0;
1446
+ for (; i < srcNode.childNodes.length; i++) {
1447
+ slotted = srcNode.childNodes[i]['s-nr'];
1448
+ if (slotted) {
1449
+ if (clonedNode.__appendChild) {
1450
+ clonedNode.__appendChild(slotted.cloneNode(true));
1451
+ }
1452
+ else {
1453
+ clonedNode.appendChild(slotted.cloneNode(true));
1454
+ }
1455
+ }
1456
+ }
1457
+ }
1458
+ return clonedNode;
1459
+ };
1460
+ };
1461
+ var patchSlotAppendChild = function (HostElementPrototype) {
1462
+ HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
1463
+ HostElementPrototype.appendChild = function (newChild) {
1464
+ var slotName = (newChild['s-sn'] = getSlotName(newChild));
1465
+ var slotNode = getHostSlotNode(this.childNodes, slotName);
1466
+ if (slotNode) {
1467
+ var slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
1468
+ var appendAfter = slotChildNodes[slotChildNodes.length - 1];
1469
+ return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
1470
+ }
1471
+ return this.__appendChild(newChild);
1472
+ };
1473
+ };
1474
+ var patchChildSlotNodes = function (elm, cmpMeta) {
1475
+ var FakeNodeList = /** @class */ (function (_super) {
1476
+ __extends(FakeNodeList, _super);
1477
+ function FakeNodeList() {
1478
+ return _super !== null && _super.apply(this, arguments) || this;
1479
+ }
1480
+ FakeNodeList.prototype.item = function (n) {
1481
+ return this[n];
1482
+ };
1483
+ return FakeNodeList;
1484
+ }(Array));
1485
+ if (cmpMeta.$flags$ & 8 /* needsShadowDomShim */) {
1486
+ var childNodesFn_1 = elm.__lookupGetter__('childNodes');
1487
+ Object.defineProperty(elm, 'children', {
1488
+ get: function () {
1489
+ return this.childNodes.map(function (n) { return n.nodeType === 1; });
1490
+ },
1491
+ });
1492
+ Object.defineProperty(elm, 'childElementCount', {
1493
+ get: function () {
1494
+ return elm.children.length;
1495
+ },
1496
+ });
1497
+ Object.defineProperty(elm, 'childNodes', {
1498
+ get: function () {
1499
+ var childNodes = childNodesFn_1.call(this);
1500
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0 && getHostRef(this).$flags$ & 2 /* hasRendered */) {
1501
+ var result = new FakeNodeList();
1502
+ for (var i = 0; i < childNodes.length; i++) {
1503
+ var slot = childNodes[i]['s-nr'];
1504
+ if (slot) {
1505
+ result.push(slot);
1506
+ }
1507
+ }
1508
+ return result;
1509
+ }
1510
+ return FakeNodeList.from(childNodes);
1511
+ },
1512
+ });
1513
+ }
1514
+ };
1515
+ var getSlotName = function (node) { return node['s-sn'] || (node.nodeType === 1 && node.getAttribute('slot')) || ''; };
1516
+ var getHostSlotNode = function (childNodes, slotName) {
1517
+ var i = 0;
1518
+ var childNode;
1519
+ for (; i < childNodes.length; i++) {
1520
+ childNode = childNodes[i];
1521
+ if (childNode['s-sr'] && childNode['s-sn'] === slotName) {
1522
+ return childNode;
1523
+ }
1524
+ childNode = getHostSlotNode(childNode.childNodes, slotName);
1525
+ if (childNode) {
1526
+ return childNode;
1527
+ }
1528
+ }
1529
+ return null;
1530
+ };
1531
+ var getHostSlotChildNodes = function (n, slotName) {
1532
+ var childNodes = [n];
1533
+ while ((n = n.nextSibling) && n['s-sn'] === slotName) {
1534
+ childNodes.push(n);
1535
+ }
1536
+ return childNodes;
1537
+ };
1538
+ var bootstrapLazy = function (lazyBundles, options) {
1539
+ if (options === void 0) { options = {}; }
1540
+ var endBootstrap = createTime();
1541
+ var cmpTags = [];
1542
+ var exclude = options.exclude || [];
1543
+ var customElements = win.customElements;
1544
+ var head = doc.head;
1545
+ var metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1546
+ var visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1547
+ var deferredConnectedCallbacks = [];
1548
+ var appLoadFallback;
1549
+ var isBootstrapping = true;
1550
+ Object.assign(plt, options);
1551
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1552
+ {
1553
+ if (options.syncQueue) {
1554
+ plt.$flags$ |= 4 /* queueSync */;
1555
+ }
1556
+ }
1557
+ lazyBundles.map(function (lazyBundle) { return lazyBundle[1].map(function (compactMeta) {
1558
+ var cmpMeta = {
1559
+ $flags$: compactMeta[0],
1560
+ $tagName$: compactMeta[1],
1561
+ $members$: compactMeta[2],
1562
+ $listeners$: compactMeta[3],
1563
+ };
1564
+ {
1565
+ cmpMeta.$members$ = compactMeta[2];
1566
+ }
1567
+ {
1568
+ cmpMeta.$listeners$ = compactMeta[3];
1569
+ }
1570
+ {
1571
+ cmpMeta.$watchers$ = {};
1572
+ }
1573
+ var tagName = cmpMeta.$tagName$;
1574
+ var HostElement = /** @class */ (function (_super) {
1575
+ __extends(HostElement, _super);
1576
+ // StencilLazyHost
1577
+ function HostElement(self) {
1578
+ var _this =
1579
+ // @ts-ignore
1580
+ _super.call(this, self) || this;
1581
+ self = _this;
1582
+ registerHost(self, cmpMeta);
1583
+ {
1584
+ patchChildSlotNodes(self, cmpMeta);
1585
+ }
1586
+ return _this;
1587
+ }
1588
+ HostElement.prototype.connectedCallback = function () {
1589
+ var _this = this;
1590
+ if (appLoadFallback) {
1591
+ clearTimeout(appLoadFallback);
1592
+ appLoadFallback = null;
1593
+ }
1594
+ if (isBootstrapping) {
1595
+ // connectedCallback will be processed once all components have been registered
1596
+ deferredConnectedCallbacks.push(this);
1597
+ }
1598
+ else {
1599
+ plt.jmp(function () { return connectedCallback(_this); });
1600
+ }
1601
+ };
1602
+ HostElement.prototype.disconnectedCallback = function () {
1603
+ var _this = this;
1604
+ plt.jmp(function () { return disconnectedCallback(_this); });
1605
+ };
1606
+ HostElement.prototype.forceUpdate = function () {
1607
+ forceUpdate(this);
1608
+ };
1609
+ HostElement.prototype.componentOnReady = function () {
1610
+ return getHostRef(this).$onReadyPromise$;
1611
+ };
1612
+ return HostElement;
1613
+ }(HTMLElement));
1614
+ {
1615
+ patchCloneNode(HostElement.prototype);
1616
+ }
1617
+ {
1618
+ patchSlotAppendChild(HostElement.prototype);
1619
+ }
1620
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1621
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1622
+ cmpTags.push(tagName);
1623
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1624
+ }
1625
+ }); });
1626
+ {
1627
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1628
+ visibilityStyle.setAttribute('data-styles', '');
1629
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1630
+ }
1631
+ // Process deferred connectedCallbacks now all components have been registered
1632
+ isBootstrapping = false;
1633
+ if (deferredConnectedCallbacks.length) {
1634
+ deferredConnectedCallbacks.map(function (host) { return host.connectedCallback(); });
1635
+ }
1636
+ else {
1637
+ {
1638
+ plt.jmp(function () { return (appLoadFallback = setTimeout(appDidLoad, 30)); });
1639
+ }
1640
+ }
1641
+ // Fallback appLoad event
1642
+ endBootstrap();
1643
+ };
1644
+ var hostRefs = new WeakMap();
1645
+ var getHostRef = function (ref) { return hostRefs.get(ref); };
1646
+ var registerInstance = function (lazyInstance, hostRef) { return hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef); };
1647
+ var registerHost = function (elm, cmpMeta) {
1648
+ var hostRef = {
1649
+ $flags$: 0,
1650
+ $hostElement$: elm,
1651
+ $cmpMeta$: cmpMeta,
1652
+ $instanceValues$: new Map(),
1653
+ };
1654
+ {
1655
+ hostRef.$onReadyPromise$ = new Promise(function (r) { return (hostRef.$onReadyResolve$ = r); });
1656
+ elm['s-p'] = [];
1657
+ elm['s-rc'] = [];
1658
+ }
1659
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1660
+ return hostRefs.set(elm, hostRef);
1661
+ };
1662
+ var isMemberInElement = function (elm, memberName) { return memberName in elm; };
1663
+ var consoleError = function (e) { return console.error(e); };
1664
+ var cmpModules = /*@__PURE__*/ new Map();
1665
+ var loadModule = function (cmpMeta, hostRef, hmrVersionId) {
1666
+ // loadModuleImport
1667
+ var exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1668
+ var bundleId = cmpMeta.$lazyBundleId$;
1669
+ var module = cmpModules.get(bundleId);
1670
+ if (module) {
1671
+ return module[exportName];
1672
+ }
1673
+ return import(
1674
+ /* webpackInclude: /\.entry\.js$/ */
1675
+ /* webpackExclude: /\.system\.entry\.js$/ */
1676
+ /* webpackMode: "lazy" */
1677
+ "./" + bundleId + ".entry.js" + '').then(function (importedModule) {
1678
+ {
1679
+ cmpModules.set(bundleId, importedModule);
1680
+ }
1681
+ return importedModule[exportName];
1682
+ }, consoleError);
1683
+ };
1684
+ var styles = new Map();
1685
+ var queueDomReads = [];
1686
+ var queueDomWrites = [];
1687
+ var queueDomWritesLow = [];
1688
+ var queueTask = function (queue, write) { return function (cb) {
1689
+ queue.push(cb);
1690
+ if (!queuePending) {
1691
+ queuePending = true;
1692
+ if (write && plt.$flags$ & 4 /* queueSync */) {
1693
+ nextTick(flush);
1694
+ }
1695
+ else {
1696
+ plt.raf(flush);
1697
+ }
1698
+ }
1699
+ }; };
1700
+ var consume = function (queue) {
1701
+ for (var i = 0; i < queue.length; i++) {
1702
+ try {
1703
+ queue[i](performance.now());
1704
+ }
1705
+ catch (e) {
1706
+ consoleError(e);
1707
+ }
1708
+ }
1709
+ queue.length = 0;
1710
+ };
1711
+ var consumeTimeout = function (queue, timeout) {
1712
+ var i = 0;
1713
+ var ts = 0;
1714
+ while (i < queue.length && (ts = performance.now()) < timeout) {
1715
+ try {
1716
+ queue[i++](ts);
1717
+ }
1718
+ catch (e) {
1719
+ consoleError(e);
1720
+ }
1721
+ }
1722
+ if (i === queue.length) {
1723
+ queue.length = 0;
1724
+ }
1725
+ else if (i !== 0) {
1726
+ queue.splice(0, i);
1727
+ }
1728
+ };
1729
+ var flush = function () {
1730
+ {
1731
+ queueCongestion++;
1732
+ }
1733
+ // always force a bunch of medium callbacks to run, but still have
1734
+ // a throttle on how many can run in a certain time
1735
+ // DOM READS!!!
1736
+ consume(queueDomReads);
1737
+ // DOM WRITES!!!
1738
+ {
1739
+ var timeout = (plt.$flags$ & 6 /* queueMask */) === 2 /* appLoaded */ ? performance.now() + 14 * Math.ceil(queueCongestion * (1.0 / 10.0)) : Infinity;
1740
+ consumeTimeout(queueDomWrites, timeout);
1741
+ consumeTimeout(queueDomWritesLow, timeout);
1742
+ if (queueDomWrites.length > 0) {
1743
+ queueDomWritesLow.push.apply(queueDomWritesLow, queueDomWrites);
1744
+ queueDomWrites.length = 0;
1745
+ }
1746
+ if ((queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)) {
1747
+ // still more to do yet, but we've run out of time
1748
+ // let's let this thing cool off and try again in the next tick
1749
+ plt.raf(flush);
1750
+ }
1751
+ else {
1752
+ queueCongestion = 0;
1753
+ }
1754
+ }
1755
+ };
1756
+ var nextTick = /*@__PURE__*/ function (cb) { return promiseResolve().then(cb); };
1757
+ var writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1758
+ export { CSS as C, H, NAMESPACE as N, promiseResolve as a, bootstrapLazy as b, createEvent as c, doc as d, getElement as g, h, plt as p, registerInstance as r, win as w };