@saasquatch/vanilla-components 1.2.4-2 → 1.2.4-22

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