@jaak.ai/stamps 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +385 -0
  2. package/dist/cjs/document-detector_19.cjs.entry.js +8540 -0
  3. package/dist/cjs/index-5e4e5e7d.js +1685 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +22 -0
  6. package/dist/cjs/mb-tooltip.cjs.entry.js +26 -0
  7. package/dist/cjs/stamps.cjs.js +23 -0
  8. package/dist/collection/collection-manifest.json +31 -0
  9. package/dist/collection/components/document-detector/document-detector.css +154 -0
  10. package/dist/collection/components/document-detector/document-detector.js +416 -0
  11. package/dist/collection/components/shared/mb-api-process-status/mb-api-process-status.css +360 -0
  12. package/dist/collection/components/shared/mb-api-process-status/mb-api-process-status.js +124 -0
  13. package/dist/collection/components/shared/mb-button/mb-button.css +95 -0
  14. package/dist/collection/components/shared/mb-button/mb-button.js +201 -0
  15. package/dist/collection/components/shared/mb-button-classic/mb-button-classic.css +100 -0
  16. package/dist/collection/components/shared/mb-button-classic/mb-button-classic.js +130 -0
  17. package/dist/collection/components/shared/mb-camera-experience/mb-camera-experience.css +740 -0
  18. package/dist/collection/components/shared/mb-camera-experience/mb-camera-experience.js +827 -0
  19. package/dist/collection/components/shared/mb-camera-experience/mb-camera-experience.utils.js +55 -0
  20. package/dist/collection/components/shared/mb-camera-selection/mb-camera-selection.css +124 -0
  21. package/dist/collection/components/shared/mb-camera-selection/mb-camera-selection.js +194 -0
  22. package/dist/collection/components/shared/mb-camera-toolbar/mb-camera-toolbar.css +80 -0
  23. package/dist/collection/components/shared/mb-camera-toolbar/mb-camera-toolbar.js +275 -0
  24. package/dist/collection/components/shared/mb-completed/mb-completed.css +17 -0
  25. package/dist/collection/components/shared/mb-completed/mb-completed.js +48 -0
  26. package/dist/collection/components/shared/mb-component/mb-component.css +321 -0
  27. package/dist/collection/components/shared/mb-component/mb-component.js +2269 -0
  28. package/dist/collection/components/shared/mb-component/mb-component.utils.js +14 -0
  29. package/dist/collection/components/shared/mb-container/mb-container.css +7 -0
  30. package/dist/collection/components/shared/mb-container/mb-container.js +23 -0
  31. package/dist/collection/components/shared/mb-feedback/mb-feedback.css +36 -0
  32. package/dist/collection/components/shared/mb-feedback/mb-feedback.js +91 -0
  33. package/dist/collection/components/shared/mb-feedback/mb-feedback.utils.js +11 -0
  34. package/dist/collection/components/shared/mb-help/mb-help.css +191 -0
  35. package/dist/collection/components/shared/mb-help/mb-help.js +409 -0
  36. package/dist/collection/components/shared/mb-help/mb-help.model.js +5 -0
  37. package/dist/collection/components/shared/mb-image-box/mb-image-box.css +78 -0
  38. package/dist/collection/components/shared/mb-image-box/mb-image-box.js +150 -0
  39. package/dist/collection/components/shared/mb-modal/mb-modal.css +106 -0
  40. package/dist/collection/components/shared/mb-modal/mb-modal.js +239 -0
  41. package/dist/collection/components/shared/mb-overlay/mb-overlay.css +46 -0
  42. package/dist/collection/components/shared/mb-overlay/mb-overlay.js +76 -0
  43. package/dist/collection/components/shared/mb-progress-tracker/mb-progress-tracker.css +24 -0
  44. package/dist/collection/components/shared/mb-progress-tracker/mb-progress-tracker.js +80 -0
  45. package/dist/collection/components/shared/mb-screen/mb-screen.css +19 -0
  46. package/dist/collection/components/shared/mb-screen/mb-screen.js +48 -0
  47. package/dist/collection/components/shared/mb-spinner/mb-spinner.css +30 -0
  48. package/dist/collection/components/shared/mb-spinner/mb-spinner.js +67 -0
  49. package/dist/collection/components/shared/mb-tooltip/mb-tooltip.css +62 -0
  50. package/dist/collection/components/shared/mb-tooltip/mb-tooltip.js +150 -0
  51. package/dist/collection/components/shared/mb-tooltip-advanced/mb-tooltip-advanced.css +91 -0
  52. package/dist/collection/components/shared/mb-tooltip-advanced/mb-tooltip-advanced.js +96 -0
  53. package/dist/collection/index.js +1 -0
  54. package/dist/collection/utils/data-structures.js +189 -0
  55. package/dist/collection/utils/device.helpers.js +37 -0
  56. package/dist/collection/utils/error-structures.js +47 -0
  57. package/dist/collection/utils/generic.helpers.js +82 -0
  58. package/dist/collection/utils/sdk.service.js +943 -0
  59. package/dist/collection/utils/state-lifter.js +3 -0
  60. package/dist/collection/utils/status.document-detector.js +15 -0
  61. package/dist/collection/utils/translation.service.js +97 -0
  62. package/dist/esm/document-detector_19.entry.js +8518 -0
  63. package/dist/esm/index-dc740acb.js +1656 -0
  64. package/dist/esm/index.js +1 -0
  65. package/dist/esm/loader.js +18 -0
  66. package/dist/esm/mb-tooltip.entry.js +22 -0
  67. package/dist/esm/polyfills/core-js.js +11 -0
  68. package/dist/esm/polyfills/css-shim.js +1 -0
  69. package/dist/esm/polyfills/dom.js +79 -0
  70. package/dist/esm/polyfills/es5-html-element.js +1 -0
  71. package/dist/esm/polyfills/index.js +34 -0
  72. package/dist/esm/polyfills/system.js +6 -0
  73. package/dist/esm/stamps.js +18 -0
  74. package/dist/index.cjs.js +1 -0
  75. package/dist/index.js +1 -0
  76. package/dist/stamps/index.esm.js +0 -0
  77. package/dist/stamps/p-66d9fb33.entry.js +9 -0
  78. package/dist/stamps/p-7f07a434.js +2 -0
  79. package/dist/stamps/p-ec3f5972.entry.js +1 -0
  80. package/dist/stamps/stamps.esm.js +1 -0
  81. package/dist/types/components/document-detector/document-detector.d.ts +86 -0
  82. package/dist/types/components/shared/mb-api-process-status/mb-api-process-status.d.ts +30 -0
  83. package/dist/types/components/shared/mb-button/mb-button.d.ts +41 -0
  84. package/dist/types/components/shared/mb-button-classic/mb-button-classic.d.ts +27 -0
  85. package/dist/types/components/shared/mb-camera-experience/mb-camera-experience.d.ts +141 -0
  86. package/dist/types/components/shared/mb-camera-experience/mb-camera-experience.utils.d.ts +3 -0
  87. package/dist/types/components/shared/mb-camera-selection/mb-camera-selection.d.ts +33 -0
  88. package/dist/types/components/shared/mb-camera-toolbar/mb-camera-toolbar.d.ts +54 -0
  89. package/dist/types/components/shared/mb-completed/mb-completed.d.ts +12 -0
  90. package/dist/types/components/shared/mb-component/mb-component.d.ts +308 -0
  91. package/dist/types/components/shared/mb-component/mb-component.utils.d.ts +3 -0
  92. package/dist/types/components/shared/mb-container/mb-container.d.ts +8 -0
  93. package/dist/types/components/shared/mb-feedback/mb-feedback.d.ts +19 -0
  94. package/dist/types/components/shared/mb-feedback/mb-feedback.utils.d.ts +2 -0
  95. package/dist/types/components/shared/mb-help/mb-help.d.ts +66 -0
  96. package/dist/types/components/shared/mb-help/mb-help.model.d.ts +9 -0
  97. package/dist/types/components/shared/mb-image-box/mb-image-box.d.ts +35 -0
  98. package/dist/types/components/shared/mb-modal/mb-modal.d.ts +53 -0
  99. package/dist/types/components/shared/mb-overlay/mb-overlay.d.ts +17 -0
  100. package/dist/types/components/shared/mb-progress-tracker/mb-progress-tracker.d.ts +19 -0
  101. package/dist/types/components/shared/mb-screen/mb-screen.d.ts +12 -0
  102. package/dist/types/components/shared/mb-spinner/mb-spinner.d.ts +16 -0
  103. package/dist/types/components/shared/mb-tooltip/mb-tooltip.d.ts +10 -0
  104. package/dist/types/components/shared/mb-tooltip-advanced/mb-tooltip-advanced.d.ts +7 -0
  105. package/dist/types/components.d.ts +1382 -0
  106. package/dist/types/index.d.ts +1 -0
  107. package/dist/types/stencil-public-runtime.d.ts +1637 -0
  108. package/dist/types/utils/data-structures.d.ts +264 -0
  109. package/dist/types/utils/device.helpers.d.ts +7 -0
  110. package/dist/types/utils/error-structures.d.ts +44 -0
  111. package/dist/types/utils/generic.helpers.d.ts +21 -0
  112. package/dist/types/utils/sdk.service.d.ts +52 -0
  113. package/dist/types/utils/state-lifter.d.ts +3 -0
  114. package/dist/types/utils/status.document-detector.d.ts +14 -0
  115. package/dist/types/utils/translation.service.d.ts +77 -0
  116. package/loader/cdn.js +3 -0
  117. package/loader/index.cjs.js +3 -0
  118. package/loader/index.d.ts +21 -0
  119. package/loader/index.es2017.js +3 -0
  120. package/loader/index.js +4 -0
  121. package/loader/package.json +11 -0
  122. package/package.json +63 -0
@@ -0,0 +1,1685 @@
1
+ 'use strict';
2
+
3
+ function _interopNamespace(e) {
4
+ if (e && e.__esModule) return e;
5
+ var n = Object.create(null);
6
+ if (e) {
7
+ Object.keys(e).forEach(function (k) {
8
+ if (k !== 'default') {
9
+ var d = Object.getOwnPropertyDescriptor(e, k);
10
+ Object.defineProperty(n, k, d.get ? d : {
11
+ enumerable: true,
12
+ get: function () {
13
+ return e[k];
14
+ }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n['default'] = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ const NAMESPACE = 'stamps';
24
+
25
+ /**
26
+ * Virtual DOM patching algorithm based on Snabbdom by
27
+ * Simon Friis Vindum (@paldepind)
28
+ * Licensed under the MIT License
29
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
30
+ *
31
+ * Modified for Stencil's renderer and slot projection
32
+ */
33
+ let scopeId;
34
+ let hostTagName;
35
+ let isSvgMode = false;
36
+ let queuePending = false;
37
+ const createTime = (fnName, tagName = '') => {
38
+ {
39
+ return () => {
40
+ return;
41
+ };
42
+ }
43
+ };
44
+ const uniqueTime = (key, measureText) => {
45
+ {
46
+ return () => {
47
+ return;
48
+ };
49
+ }
50
+ };
51
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
52
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
53
+ /**
54
+ * Default style mode id
55
+ */
56
+ /**
57
+ * Reusable empty obj/array
58
+ * Don't add values to these!!
59
+ */
60
+ const EMPTY_OBJ = {};
61
+ /**
62
+ * Namespaces
63
+ */
64
+ const SVG_NS = 'http://www.w3.org/2000/svg';
65
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
66
+ const isDef = (v) => v != null;
67
+ const isComplexType = (o) => {
68
+ // https://jsperf.com/typeof-fn-object/5
69
+ o = typeof o;
70
+ return o === 'object' || o === 'function';
71
+ };
72
+ /**
73
+ * Helper method for querying a `meta` tag that contains a nonce value
74
+ * out of a DOM's head.
75
+ *
76
+ * @param doc The DOM containing the `head` to query against
77
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
78
+ * exists or the tag has no content.
79
+ */
80
+ function queryNonceMetaTagContent(doc) {
81
+ var _a, _b, _c;
82
+ return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
83
+ }
84
+ /**
85
+ * Production h() function based on Preact by
86
+ * Jason Miller (@developit)
87
+ * Licensed under the MIT License
88
+ * https://github.com/developit/preact/blob/master/LICENSE
89
+ *
90
+ * Modified for Stencil's compiler and vdom
91
+ */
92
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
93
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
94
+ const h = (nodeName, vnodeData, ...children) => {
95
+ let child = null;
96
+ let simple = false;
97
+ let lastSimple = false;
98
+ const vNodeChildren = [];
99
+ const walk = (c) => {
100
+ for (let i = 0; i < c.length; i++) {
101
+ child = c[i];
102
+ if (Array.isArray(child)) {
103
+ walk(child);
104
+ }
105
+ else if (child != null && typeof child !== 'boolean') {
106
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
107
+ child = String(child);
108
+ }
109
+ if (simple && lastSimple) {
110
+ // If the previous child was simple (string), we merge both
111
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
112
+ }
113
+ else {
114
+ // Append a new vNode, if it's text, we create a text vNode
115
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
116
+ }
117
+ lastSimple = simple;
118
+ }
119
+ }
120
+ };
121
+ walk(children);
122
+ if (vnodeData) {
123
+ {
124
+ const classData = vnodeData.className || vnodeData.class;
125
+ if (classData) {
126
+ vnodeData.class =
127
+ typeof classData !== 'object'
128
+ ? classData
129
+ : Object.keys(classData)
130
+ .filter((k) => classData[k])
131
+ .join(' ');
132
+ }
133
+ }
134
+ }
135
+ if (typeof nodeName === 'function') {
136
+ // nodeName is a functional component
137
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
138
+ }
139
+ const vnode = newVNode(nodeName, null);
140
+ vnode.$attrs$ = vnodeData;
141
+ if (vNodeChildren.length > 0) {
142
+ vnode.$children$ = vNodeChildren;
143
+ }
144
+ return vnode;
145
+ };
146
+ /**
147
+ * A utility function for creating a virtual DOM node from a tag and some
148
+ * possible text content.
149
+ *
150
+ * @param tag the tag for this element
151
+ * @param text possible text content for the node
152
+ * @returns a newly-minted virtual DOM node
153
+ */
154
+ const newVNode = (tag, text) => {
155
+ const vnode = {
156
+ $flags$: 0,
157
+ $tag$: tag,
158
+ $text$: text,
159
+ $elm$: null,
160
+ $children$: null,
161
+ };
162
+ {
163
+ vnode.$attrs$ = null;
164
+ }
165
+ return vnode;
166
+ };
167
+ const Host = {};
168
+ /**
169
+ * Check whether a given node is a Host node or not
170
+ *
171
+ * @param node the virtual DOM node to check
172
+ * @returns whether it's a Host node or not
173
+ */
174
+ const isHost = (node) => node && node.$tag$ === Host;
175
+ /**
176
+ * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
177
+ *
178
+ * Note that these functions convert from {@link d.VNode} to
179
+ * {@link d.ChildNode} to give functional component developers a friendly
180
+ * interface.
181
+ */
182
+ const vdomFnUtils = {
183
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
184
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
185
+ };
186
+ /**
187
+ * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
188
+ * friendlier public interface (hence, 'convertToPublic').
189
+ *
190
+ * @param node the virtual DOM node to convert
191
+ * @returns a converted child node
192
+ */
193
+ const convertToPublic = (node) => ({
194
+ vattrs: node.$attrs$,
195
+ vchildren: node.$children$,
196
+ vkey: node.$key$,
197
+ vname: node.$name$,
198
+ vtag: node.$tag$,
199
+ vtext: node.$text$,
200
+ });
201
+ /**
202
+ * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
203
+ * order to use the resulting object in the virtual DOM. The initial object was
204
+ * likely created as part of presenting a public API, so converting it back
205
+ * involved making it 'private' again (hence, `convertToPrivate`).
206
+ *
207
+ * @param node the child node to convert
208
+ * @returns a converted virtual DOM node
209
+ */
210
+ const convertToPrivate = (node) => {
211
+ if (typeof node.vtag === 'function') {
212
+ const vnodeData = Object.assign({}, node.vattrs);
213
+ if (node.vkey) {
214
+ vnodeData.key = node.vkey;
215
+ }
216
+ if (node.vname) {
217
+ vnodeData.name = node.vname;
218
+ }
219
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
220
+ }
221
+ const vnode = newVNode(node.vtag, node.vtext);
222
+ vnode.$attrs$ = node.vattrs;
223
+ vnode.$children$ = node.vchildren;
224
+ vnode.$key$ = node.vkey;
225
+ vnode.$name$ = node.vname;
226
+ return vnode;
227
+ };
228
+ /**
229
+ * Parse a new property value for a given property type.
230
+ *
231
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
232
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
233
+ * 1. `any`, the type given to `propValue` in the function signature
234
+ * 2. the type stored from `propType`.
235
+ *
236
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
237
+ *
238
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
239
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
240
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
241
+ * ```tsx
242
+ * <my-cmp prop-val={0}></my-cmp>
243
+ * ```
244
+ *
245
+ * HTML prop values on the other hand, will always a string
246
+ *
247
+ * @param propValue the new value to coerce to some type
248
+ * @param propType the type of the prop, expressed as a binary number
249
+ * @returns the parsed/coerced value
250
+ */
251
+ const parsePropertyValue = (propValue, propType) => {
252
+ // ensure this value is of the correct prop type
253
+ if (propValue != null && !isComplexType(propValue)) {
254
+ if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
255
+ // per the HTML spec, any string value means it is a boolean true value
256
+ // but we'll cheat here and say that the string "false" is the boolean false
257
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
258
+ }
259
+ if (propType & 2 /* MEMBER_FLAGS.Number */) {
260
+ // force it to be a number
261
+ return parseFloat(propValue);
262
+ }
263
+ if (propType & 1 /* MEMBER_FLAGS.String */) {
264
+ // could have been passed as a number or boolean
265
+ // but we still want it as a string
266
+ return String(propValue);
267
+ }
268
+ // redundant return here for better minification
269
+ return propValue;
270
+ }
271
+ // not sure exactly what type we want
272
+ // so no need to change to a different type
273
+ return propValue;
274
+ };
275
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
276
+ const createEvent = (ref, name, flags) => {
277
+ const elm = getElement(ref);
278
+ return {
279
+ emit: (detail) => {
280
+ return emitEvent(elm, name, {
281
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
282
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
283
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
284
+ detail,
285
+ });
286
+ },
287
+ };
288
+ };
289
+ /**
290
+ * Helper function to create & dispatch a custom Event on a provided target
291
+ * @param elm the target of the Event
292
+ * @param name the name to give the custom Event
293
+ * @param opts options for configuring a custom Event
294
+ * @returns the custom Event
295
+ */
296
+ const emitEvent = (elm, name, opts) => {
297
+ const ev = plt.ce(name, opts);
298
+ elm.dispatchEvent(ev);
299
+ return ev;
300
+ };
301
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
302
+ const registerStyle = (scopeId, cssText, allowCS) => {
303
+ let style = styles.get(scopeId);
304
+ if (supportsConstructableStylesheets && allowCS) {
305
+ style = (style || new CSSStyleSheet());
306
+ if (typeof style === 'string') {
307
+ style = cssText;
308
+ }
309
+ else {
310
+ style.replaceSync(cssText);
311
+ }
312
+ }
313
+ else {
314
+ style = cssText;
315
+ }
316
+ styles.set(scopeId, style);
317
+ };
318
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
319
+ var _a;
320
+ let scopeId = getScopeId(cmpMeta);
321
+ const style = styles.get(scopeId);
322
+ // if an element is NOT connected then getRootNode() will return the wrong root node
323
+ // so the fallback is to always use the document for the root node in those cases
324
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
325
+ if (style) {
326
+ if (typeof style === 'string') {
327
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
328
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
329
+ let styleElm;
330
+ if (!appliedStyles) {
331
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
332
+ }
333
+ if (!appliedStyles.has(scopeId)) {
334
+ {
335
+ {
336
+ styleElm = doc.createElement('style');
337
+ styleElm.innerHTML = style;
338
+ }
339
+ // Apply CSP nonce to the style tag if it exists
340
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
341
+ if (nonce != null) {
342
+ styleElm.setAttribute('nonce', nonce);
343
+ }
344
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
345
+ }
346
+ if (appliedStyles) {
347
+ appliedStyles.add(scopeId);
348
+ }
349
+ }
350
+ }
351
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
352
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
353
+ }
354
+ }
355
+ return scopeId;
356
+ };
357
+ const attachStyles = (hostRef) => {
358
+ const cmpMeta = hostRef.$cmpMeta$;
359
+ const elm = hostRef.$hostElement$;
360
+ const flags = cmpMeta.$flags$;
361
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
362
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
363
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
364
+ // only required when we're NOT using native shadow dom (slot)
365
+ // or this browser doesn't support native shadow dom
366
+ // and this host element was NOT created with SSR
367
+ // let's pick out the inner content for slot projection
368
+ // create a node to represent where the original
369
+ // content was first placed, which is useful later on
370
+ // DOM WRITE!!
371
+ elm['s-sc'] = scopeId;
372
+ elm.classList.add(scopeId + '-h');
373
+ }
374
+ endAttachStyles();
375
+ };
376
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
377
+ /**
378
+ * Production setAccessor() function based on Preact by
379
+ * Jason Miller (@developit)
380
+ * Licensed under the MIT License
381
+ * https://github.com/developit/preact/blob/master/LICENSE
382
+ *
383
+ * Modified for Stencil's compiler and vdom
384
+ */
385
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
386
+ if (oldValue !== newValue) {
387
+ let isProp = isMemberInElement(elm, memberName);
388
+ let ln = memberName.toLowerCase();
389
+ if (memberName === 'class') {
390
+ const classList = elm.classList;
391
+ const oldClasses = parseClassList(oldValue);
392
+ const newClasses = parseClassList(newValue);
393
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
394
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
395
+ }
396
+ else if (memberName === 'ref') {
397
+ // minifier will clean this up
398
+ if (newValue) {
399
+ newValue(elm);
400
+ }
401
+ }
402
+ else if ((!isProp ) &&
403
+ memberName[0] === 'o' &&
404
+ memberName[1] === 'n') {
405
+ // Event Handlers
406
+ // so if the member name starts with "on" and the 3rd characters is
407
+ // a capital letter, and it's not already a member on the element,
408
+ // then we're assuming it's an event listener
409
+ if (memberName[2] === '-') {
410
+ // on- prefixed events
411
+ // allows to be explicit about the dom event to listen without any magic
412
+ // under the hood:
413
+ // <my-cmp on-click> // listens for "click"
414
+ // <my-cmp on-Click> // listens for "Click"
415
+ // <my-cmp on-ionChange> // listens for "ionChange"
416
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
417
+ memberName = memberName.slice(3);
418
+ }
419
+ else if (isMemberInElement(win, ln)) {
420
+ // standard event
421
+ // the JSX attribute could have been "onMouseOver" and the
422
+ // member name "onmouseover" is on the window's prototype
423
+ // so let's add the listener "mouseover", which is all lowercased
424
+ memberName = ln.slice(2);
425
+ }
426
+ else {
427
+ // custom event
428
+ // the JSX attribute could have been "onMyCustomEvent"
429
+ // so let's trim off the "on" prefix and lowercase the first character
430
+ // and add the listener "myCustomEvent"
431
+ // except for the first character, we keep the event name case
432
+ memberName = ln[2] + memberName.slice(3);
433
+ }
434
+ if (oldValue) {
435
+ plt.rel(elm, memberName, oldValue, false);
436
+ }
437
+ if (newValue) {
438
+ plt.ael(elm, memberName, newValue, false);
439
+ }
440
+ }
441
+ else {
442
+ // Set property if it exists and it's not a SVG
443
+ const isComplex = isComplexType(newValue);
444
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
445
+ try {
446
+ if (!elm.tagName.includes('-')) {
447
+ const n = newValue == null ? '' : newValue;
448
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
449
+ if (memberName === 'list') {
450
+ isProp = false;
451
+ }
452
+ else if (oldValue == null || elm[memberName] != n) {
453
+ elm[memberName] = n;
454
+ }
455
+ }
456
+ else {
457
+ elm[memberName] = newValue;
458
+ }
459
+ }
460
+ catch (e) { }
461
+ }
462
+ /**
463
+ * Need to manually update attribute if:
464
+ * - memberName is not an attribute
465
+ * - if we are rendering the host element in order to reflect attribute
466
+ * - if it's a SVG, since properties might not work in <svg>
467
+ * - if the newValue is null/undefined or 'false'.
468
+ */
469
+ let xlink = false;
470
+ {
471
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
472
+ memberName = ln;
473
+ xlink = true;
474
+ }
475
+ }
476
+ if (newValue == null || newValue === false) {
477
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
478
+ if (xlink) {
479
+ elm.removeAttributeNS(XLINK_NS, memberName);
480
+ }
481
+ else {
482
+ elm.removeAttribute(memberName);
483
+ }
484
+ }
485
+ }
486
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
487
+ newValue = newValue === true ? '' : newValue;
488
+ if (xlink) {
489
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
490
+ }
491
+ else {
492
+ elm.setAttribute(memberName, newValue);
493
+ }
494
+ }
495
+ }
496
+ }
497
+ };
498
+ const parseClassListRegex = /\s/;
499
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
500
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
501
+ // if the element passed in is a shadow root, which is a document fragment
502
+ // then we want to be adding attrs/props to the shadow root's "host" element
503
+ // if it's not a shadow root, then we add attrs/props to the same element
504
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
505
+ ? newVnode.$elm$.host
506
+ : newVnode.$elm$;
507
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
508
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
509
+ {
510
+ // remove attributes no longer present on the vnode by setting them to undefined
511
+ for (memberName in oldVnodeAttrs) {
512
+ if (!(memberName in newVnodeAttrs)) {
513
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
514
+ }
515
+ }
516
+ }
517
+ // add new & update changed attributes
518
+ for (memberName in newVnodeAttrs) {
519
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
520
+ }
521
+ };
522
+ /**
523
+ * Create a DOM Node corresponding to one of the children of a given VNode.
524
+ *
525
+ * @param oldParentVNode the parent VNode from the previous render
526
+ * @param newParentVNode the parent VNode from the current render
527
+ * @param childIndex the index of the VNode, in the _new_ parent node's
528
+ * children, for which we will create a new DOM node
529
+ * @param parentElm the parent DOM node which our new node will be a child of
530
+ * @returns the newly created node
531
+ */
532
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
533
+ // tslint:disable-next-line: prefer-const
534
+ const newVNode = newParentVNode.$children$[childIndex];
535
+ let i = 0;
536
+ let elm;
537
+ let childNode;
538
+ if (newVNode.$text$ !== null) {
539
+ // create text node
540
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
541
+ }
542
+ else {
543
+ if (!isSvgMode) {
544
+ isSvgMode = newVNode.$tag$ === 'svg';
545
+ }
546
+ // create element
547
+ elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$tag$)
548
+ );
549
+ if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
550
+ isSvgMode = false;
551
+ }
552
+ // add css classes, attrs, props, listeners, etc.
553
+ {
554
+ updateElement(null, newVNode, isSvgMode);
555
+ }
556
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
557
+ // if there is a scopeId and this is the initial render
558
+ // then let's add the scopeId as a css class
559
+ elm.classList.add((elm['s-si'] = scopeId));
560
+ }
561
+ if (newVNode.$children$) {
562
+ for (i = 0; i < newVNode.$children$.length; ++i) {
563
+ // create the node
564
+ childNode = createElm(oldParentVNode, newVNode, i);
565
+ // return node could have been null
566
+ if (childNode) {
567
+ // append our new node
568
+ elm.appendChild(childNode);
569
+ }
570
+ }
571
+ }
572
+ {
573
+ if (newVNode.$tag$ === 'svg') {
574
+ // Only reset the SVG context when we're exiting <svg> element
575
+ isSvgMode = false;
576
+ }
577
+ else if (elm.tagName === 'foreignObject') {
578
+ // Reenter SVG context when we're exiting <foreignObject> element
579
+ isSvgMode = true;
580
+ }
581
+ }
582
+ }
583
+ return elm;
584
+ };
585
+ /**
586
+ * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
587
+ * add them to the DOM in the appropriate place.
588
+ *
589
+ * @param parentElm the DOM node which should be used as a parent for the new
590
+ * DOM nodes
591
+ * @param before a child of the `parentElm` which the new children should be
592
+ * inserted before (optional)
593
+ * @param parentVNode the parent virtual DOM node
594
+ * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
595
+ * @param startIdx the index in the child virtual DOM nodes at which to start
596
+ * creating DOM nodes (inclusive)
597
+ * @param endIdx the index in the child virtual DOM nodes at which to stop
598
+ * creating DOM nodes (inclusive)
599
+ */
600
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
601
+ let containerElm = (parentElm);
602
+ let childNode;
603
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
604
+ containerElm = containerElm.shadowRoot;
605
+ }
606
+ for (; startIdx <= endIdx; ++startIdx) {
607
+ if (vnodes[startIdx]) {
608
+ childNode = createElm(null, parentVNode, startIdx);
609
+ if (childNode) {
610
+ vnodes[startIdx].$elm$ = childNode;
611
+ containerElm.insertBefore(childNode, before);
612
+ }
613
+ }
614
+ }
615
+ };
616
+ /**
617
+ * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
618
+ * This can be used to, for instance, clean up after a list of children which
619
+ * should no longer be shown.
620
+ *
621
+ * This function also handles some of Stencil's slot relocation logic.
622
+ *
623
+ * @param vnodes a list of virtual DOM nodes to remove
624
+ * @param startIdx the index at which to start removing nodes (inclusive)
625
+ * @param endIdx the index at which to stop removing nodes (inclusive)
626
+ * @param vnode a VNode
627
+ * @param elm an element
628
+ */
629
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
630
+ for (; startIdx <= endIdx; ++startIdx) {
631
+ if ((vnode = vnodes[startIdx])) {
632
+ elm = vnode.$elm$;
633
+ callNodeRefs(vnode);
634
+ // remove the vnode's element from the dom
635
+ elm.remove();
636
+ }
637
+ }
638
+ };
639
+ /**
640
+ * Reconcile the children of a new VNode with the children of an old VNode by
641
+ * traversing the two collections of children, identifying nodes that are
642
+ * conserved or changed, calling out to `patch` to make any necessary
643
+ * updates to the DOM, and rearranging DOM nodes as needed.
644
+ *
645
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
646
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
647
+ * 'windows' by storing start and end indices and references to the
648
+ * corresponding array entries. Initially the two 'windows' are basically equal
649
+ * to the entire array, but we progressively narrow the windows until there are
650
+ * no children left to update by doing the following:
651
+ *
652
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
653
+ * that if we have an initial array like the following we'll end up dealing
654
+ * only with a window bounded by the highlighted elements:
655
+ *
656
+ * [null, null, VNode1 , ... , VNode2, null, null]
657
+ * ^^^^^^ ^^^^^^
658
+ *
659
+ * 2. Check to see if the elements at the head and tail positions are equal
660
+ * across the windows. This will basically detect elements which haven't
661
+ * been added, removed, or changed position, i.e. if you had the following
662
+ * VNode elements (represented as HTML):
663
+ *
664
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
665
+ * newVNode: `<div><p><span>THERE</span></p></div>`
666
+ *
667
+ * Then when comparing the children of the `<div>` tag we check the equality
668
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
669
+ * same tag in the same position, we'd be able to avoid completely
670
+ * re-rendering the subtree under them with a new DOM element and would just
671
+ * call out to `patch` to handle reconciling their children and so on.
672
+ *
673
+ * 3. Check, for both windows, to see if the element at the beginning of the
674
+ * window corresponds to the element at the end of the other window. This is
675
+ * a heuristic which will let us identify _some_ situations in which
676
+ * elements have changed position, for instance it _should_ detect that the
677
+ * children nodes themselves have not changed but merely moved in the
678
+ * following example:
679
+ *
680
+ * oldVNode: `<div><element-one /><element-two /></div>`
681
+ * newVNode: `<div><element-two /><element-one /></div>`
682
+ *
683
+ * If we find cases like this then we also need to move the concrete DOM
684
+ * elements corresponding to the moved children to write the re-order to the
685
+ * DOM.
686
+ *
687
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
688
+ * nodes in the old children which have the same key as the first element in
689
+ * our window on the new children. If we find such a node we handle calling
690
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
691
+ * what we find.
692
+ *
693
+ * Finally, once we've narrowed our 'windows' to the point that either of them
694
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
695
+ * insertion or deletion that needs to happen to get a DOM state that correctly
696
+ * reflects the new child VNodes. If, for instance, after our window on the old
697
+ * children has collapsed we still have more nodes on the new children that
698
+ * we haven't dealt with yet then we need to add them, or if the new children
699
+ * collapse but we still have unhandled _old_ children then we need to make
700
+ * sure the corresponding DOM nodes are removed.
701
+ *
702
+ * @param parentElm the node into which the parent VNode is rendered
703
+ * @param oldCh the old children of the parent node
704
+ * @param newVNode the new VNode which will replace the parent
705
+ * @param newCh the new children of the parent node
706
+ */
707
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
708
+ let oldStartIdx = 0;
709
+ let newStartIdx = 0;
710
+ let oldEndIdx = oldCh.length - 1;
711
+ let oldStartVnode = oldCh[0];
712
+ let oldEndVnode = oldCh[oldEndIdx];
713
+ let newEndIdx = newCh.length - 1;
714
+ let newStartVnode = newCh[0];
715
+ let newEndVnode = newCh[newEndIdx];
716
+ let node;
717
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
718
+ if (oldStartVnode == null) {
719
+ // VNode might have been moved left
720
+ oldStartVnode = oldCh[++oldStartIdx];
721
+ }
722
+ else if (oldEndVnode == null) {
723
+ oldEndVnode = oldCh[--oldEndIdx];
724
+ }
725
+ else if (newStartVnode == null) {
726
+ newStartVnode = newCh[++newStartIdx];
727
+ }
728
+ else if (newEndVnode == null) {
729
+ newEndVnode = newCh[--newEndIdx];
730
+ }
731
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
732
+ // if the start nodes are the same then we should patch the new VNode
733
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
734
+ // indices to reflect that. We don't need to move any DOM Nodes around
735
+ // since things are matched up in order.
736
+ patch(oldStartVnode, newStartVnode);
737
+ oldStartVnode = oldCh[++oldStartIdx];
738
+ newStartVnode = newCh[++newStartIdx];
739
+ }
740
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
741
+ // likewise, if the end nodes are the same we patch new onto old and
742
+ // decrement our end indices, and also likewise in this case we don't
743
+ // need to move any DOM Nodes.
744
+ patch(oldEndVnode, newEndVnode);
745
+ oldEndVnode = oldCh[--oldEndIdx];
746
+ newEndVnode = newCh[--newEndIdx];
747
+ }
748
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
749
+ patch(oldStartVnode, newEndVnode);
750
+ // We need to move the element for `oldStartVnode` into a position which
751
+ // will be appropriate for `newEndVnode`. For this we can use
752
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
753
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
754
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
755
+ //
756
+ // <old-start-node />
757
+ // <some-intervening-node />
758
+ // <old-end-node />
759
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
760
+ // <next-sibling />
761
+ //
762
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
763
+ // the node for `oldStartVnode` at the end of the children of
764
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
765
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
766
+ // append it to the children of the parent element.
767
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
768
+ oldStartVnode = oldCh[++oldStartIdx];
769
+ newEndVnode = newCh[--newEndIdx];
770
+ }
771
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
772
+ patch(oldEndVnode, newStartVnode);
773
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
774
+ // the same node, so since we're here we know that they are not. Thus we
775
+ // can move the element for `oldEndVnode` _before_ the element for
776
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
777
+ // future.
778
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
779
+ oldEndVnode = oldCh[--oldEndIdx];
780
+ newStartVnode = newCh[++newStartIdx];
781
+ }
782
+ else {
783
+ {
784
+ // We either didn't find an element in the old children that matches
785
+ // the key of the first new child OR the build is not using `key`
786
+ // attributes at all. In either case we need to create a new element
787
+ // for the new node.
788
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
789
+ newStartVnode = newCh[++newStartIdx];
790
+ }
791
+ if (node) {
792
+ // if we created a new node then handle inserting it to the DOM
793
+ {
794
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
795
+ }
796
+ }
797
+ }
798
+ }
799
+ if (oldStartIdx > oldEndIdx) {
800
+ // we have some more new nodes to add which don't match up with old nodes
801
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
802
+ }
803
+ else if (newStartIdx > newEndIdx) {
804
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
805
+ // in the new array, so lets remove them (which entails cleaning up the
806
+ // relevant DOM nodes)
807
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
808
+ }
809
+ };
810
+ /**
811
+ * Compare two VNodes to determine if they are the same
812
+ *
813
+ * **NB**: This function is an equality _heuristic_ based on the available
814
+ * information set on the two VNodes and can be misleading under certain
815
+ * circumstances. In particular, if the two nodes do not have `key` attrs
816
+ * (available under `$key$` on VNodes) then the function falls back on merely
817
+ * checking that they have the same tag.
818
+ *
819
+ * So, in other words, if `key` attrs are not set on VNodes which may be
820
+ * changing order within a `children` array or something along those lines then
821
+ * we could obtain a false negative and then have to do needless re-rendering
822
+ * (i.e. we'd say two VNodes aren't equal when in fact they should be).
823
+ *
824
+ * @param leftVNode the first VNode to check
825
+ * @param rightVNode the second VNode to check
826
+ * @returns whether they're equal or not
827
+ */
828
+ const isSameVnode = (leftVNode, rightVNode) => {
829
+ // compare if two vnode to see if they're "technically" the same
830
+ // need to have the same element tag, and same key to be the same
831
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
832
+ return true;
833
+ }
834
+ return false;
835
+ };
836
+ /**
837
+ * Handle reconciling an outdated VNode with a new one which corresponds to
838
+ * it. This function handles flushing updates to the DOM and reconciling the
839
+ * children of the two nodes (if any).
840
+ *
841
+ * @param oldVNode an old VNode whose DOM element and children we want to update
842
+ * @param newVNode a new VNode representing an updated version of the old one
843
+ */
844
+ const patch = (oldVNode, newVNode) => {
845
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
846
+ const oldChildren = oldVNode.$children$;
847
+ const newChildren = newVNode.$children$;
848
+ const tag = newVNode.$tag$;
849
+ const text = newVNode.$text$;
850
+ if (text === null) {
851
+ {
852
+ // test if we're rendering an svg element, or still rendering nodes inside of one
853
+ // only add this to the when the compiler sees we're using an svg somewhere
854
+ isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
855
+ }
856
+ {
857
+ if (tag === 'slot')
858
+ ;
859
+ else {
860
+ // either this is the first render of an element OR it's an update
861
+ // AND we already know it's possible it could have changed
862
+ // this updates the element's css classes, attrs, props, listeners, etc.
863
+ updateElement(oldVNode, newVNode, isSvgMode);
864
+ }
865
+ }
866
+ if (oldChildren !== null && newChildren !== null) {
867
+ // looks like there's child vnodes for both the old and new vnodes
868
+ // so we need to call `updateChildren` to reconcile them
869
+ updateChildren(elm, oldChildren, newVNode, newChildren);
870
+ }
871
+ else if (newChildren !== null) {
872
+ // no old child vnodes, but there are new child vnodes to add
873
+ if (oldVNode.$text$ !== null) {
874
+ // the old vnode was text, so be sure to clear it out
875
+ elm.textContent = '';
876
+ }
877
+ // add the new vnode children
878
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
879
+ }
880
+ else if (oldChildren !== null) {
881
+ // no new child vnodes, but there are old child vnodes to remove
882
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
883
+ }
884
+ if (isSvgMode && tag === 'svg') {
885
+ isSvgMode = false;
886
+ }
887
+ }
888
+ else if (oldVNode.$text$ !== text) {
889
+ // update the text content for the text only vnode
890
+ // and also only if the text is different than before
891
+ elm.data = text;
892
+ }
893
+ };
894
+ const callNodeRefs = (vNode) => {
895
+ {
896
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
897
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
898
+ }
899
+ };
900
+ /**
901
+ * The main entry point for Stencil's virtual DOM-based rendering engine
902
+ *
903
+ * Given a {@link d.HostRef} container and some virtual DOM nodes, this
904
+ * function will handle creating a virtual DOM tree with a single root, patching
905
+ * the current virtual DOM tree onto an old one (if any), dealing with slot
906
+ * relocation, and reflecting attributes.
907
+ *
908
+ * @param hostRef data needed to root and render the virtual DOM tree, such as
909
+ * the DOM node into which it should be rendered.
910
+ * @param renderFnResults the virtual DOM nodes to be rendered
911
+ */
912
+ const renderVdom = (hostRef, renderFnResults) => {
913
+ const hostElm = hostRef.$hostElement$;
914
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
915
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
916
+ hostTagName = hostElm.tagName;
917
+ rootVnode.$tag$ = null;
918
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
919
+ hostRef.$vnode$ = rootVnode;
920
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
921
+ {
922
+ scopeId = hostElm['s-sc'];
923
+ }
924
+ // synchronous patch
925
+ patch(oldVNode, rootVnode);
926
+ };
927
+ const attachToAncestor = (hostRef, ancestorComponent) => {
928
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
929
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
930
+ }
931
+ };
932
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
933
+ {
934
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
935
+ }
936
+ if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
937
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
938
+ return;
939
+ }
940
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
941
+ // there is no ancestor component or the ancestor component
942
+ // has already fired off its lifecycle update then
943
+ // fire off the initial update
944
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
945
+ return writeTask(dispatch) ;
946
+ };
947
+ const dispatchHooks = (hostRef, isInitialLoad) => {
948
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
949
+ const instance = hostRef.$lazyInstance$ ;
950
+ let promise;
951
+ if (isInitialLoad) {
952
+ {
953
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
954
+ if (hostRef.$queuedListeners$) {
955
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
956
+ hostRef.$queuedListeners$ = null;
957
+ }
958
+ }
959
+ {
960
+ promise = safeCall(instance, 'componentWillLoad');
961
+ }
962
+ }
963
+ else {
964
+ {
965
+ promise = safeCall(instance, 'componentWillUpdate');
966
+ }
967
+ }
968
+ endSchedule();
969
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
970
+ };
971
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
972
+ // updateComponent
973
+ const elm = hostRef.$hostElement$;
974
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
975
+ const rc = elm['s-rc'];
976
+ if (isInitialLoad) {
977
+ // DOM WRITE!
978
+ attachStyles(hostRef);
979
+ }
980
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
981
+ {
982
+ callRender(hostRef, instance);
983
+ }
984
+ if (rc) {
985
+ // ok, so turns out there are some child host elements
986
+ // waiting on this parent element to load
987
+ // let's fire off all update callbacks waiting
988
+ rc.map((cb) => cb());
989
+ elm['s-rc'] = undefined;
990
+ }
991
+ endRender();
992
+ endUpdate();
993
+ {
994
+ const childrenPromises = elm['s-p'];
995
+ const postUpdate = () => postUpdateComponent(hostRef);
996
+ if (childrenPromises.length === 0) {
997
+ postUpdate();
998
+ }
999
+ else {
1000
+ Promise.all(childrenPromises).then(postUpdate);
1001
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1002
+ childrenPromises.length = 0;
1003
+ }
1004
+ }
1005
+ };
1006
+ const callRender = (hostRef, instance, elm) => {
1007
+ try {
1008
+ instance = instance.render() ;
1009
+ {
1010
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1011
+ }
1012
+ {
1013
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1014
+ }
1015
+ {
1016
+ {
1017
+ // looks like we've got child nodes to render into this host element
1018
+ // or we need to update the css class/attrs on the host element
1019
+ // DOM WRITE!
1020
+ {
1021
+ renderVdom(hostRef, instance);
1022
+ }
1023
+ }
1024
+ }
1025
+ }
1026
+ catch (e) {
1027
+ consoleError(e, hostRef.$hostElement$);
1028
+ }
1029
+ return null;
1030
+ };
1031
+ const postUpdateComponent = (hostRef) => {
1032
+ const tagName = hostRef.$cmpMeta$.$tagName$;
1033
+ const elm = hostRef.$hostElement$;
1034
+ const endPostUpdate = createTime('postUpdate', tagName);
1035
+ const instance = hostRef.$lazyInstance$ ;
1036
+ const ancestorComponent = hostRef.$ancestorComponent$;
1037
+ {
1038
+ safeCall(instance, 'componentDidRender');
1039
+ }
1040
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1041
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1042
+ {
1043
+ // DOM WRITE!
1044
+ addHydratedFlag(elm);
1045
+ }
1046
+ {
1047
+ safeCall(instance, 'componentDidLoad');
1048
+ }
1049
+ endPostUpdate();
1050
+ {
1051
+ hostRef.$onReadyResolve$(elm);
1052
+ if (!ancestorComponent) {
1053
+ appDidLoad();
1054
+ }
1055
+ }
1056
+ }
1057
+ else {
1058
+ {
1059
+ safeCall(instance, 'componentDidUpdate');
1060
+ }
1061
+ endPostUpdate();
1062
+ }
1063
+ {
1064
+ hostRef.$onInstanceResolve$(elm);
1065
+ }
1066
+ // load events fire from bottom to top
1067
+ // the deepest elements load first then bubbles up
1068
+ {
1069
+ if (hostRef.$onRenderResolve$) {
1070
+ hostRef.$onRenderResolve$();
1071
+ hostRef.$onRenderResolve$ = undefined;
1072
+ }
1073
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1074
+ nextTick(() => scheduleUpdate(hostRef, false));
1075
+ }
1076
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1077
+ }
1078
+ // ( •_•)
1079
+ // ( •_•)>⌐■-■
1080
+ // (⌐■_■)
1081
+ };
1082
+ const appDidLoad = (who) => {
1083
+ // on appload
1084
+ // we have finish the first big initial render
1085
+ {
1086
+ addHydratedFlag(doc.documentElement);
1087
+ }
1088
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1089
+ };
1090
+ const safeCall = (instance, method, arg) => {
1091
+ if (instance && instance[method]) {
1092
+ try {
1093
+ return instance[method](arg);
1094
+ }
1095
+ catch (e) {
1096
+ consoleError(e);
1097
+ }
1098
+ }
1099
+ return undefined;
1100
+ };
1101
+ const then = (promise, thenFn) => {
1102
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
1103
+ };
1104
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1105
+ ;
1106
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1107
+ const setValue = (ref, propName, newVal, cmpMeta) => {
1108
+ // check our new property value against our internal value
1109
+ const hostRef = getHostRef(ref);
1110
+ const elm = hostRef.$hostElement$ ;
1111
+ const oldVal = hostRef.$instanceValues$.get(propName);
1112
+ const flags = hostRef.$flags$;
1113
+ const instance = hostRef.$lazyInstance$ ;
1114
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1115
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1116
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1117
+ const didValueChange = newVal !== oldVal && !areBothNaN;
1118
+ if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1119
+ // gadzooks! the property's value has changed!!
1120
+ // set our new value!
1121
+ hostRef.$instanceValues$.set(propName, newVal);
1122
+ if (instance) {
1123
+ // get an array of method names of watch functions to call
1124
+ if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1125
+ const watchMethods = cmpMeta.$watchers$[propName];
1126
+ if (watchMethods) {
1127
+ // this instance is watching for when this property changed
1128
+ watchMethods.map((watchMethodName) => {
1129
+ try {
1130
+ // fire off each of the watch methods that are watching this property
1131
+ instance[watchMethodName](newVal, oldVal, propName);
1132
+ }
1133
+ catch (e) {
1134
+ consoleError(e, elm);
1135
+ }
1136
+ });
1137
+ }
1138
+ }
1139
+ if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1140
+ // looks like this value actually changed, so we've got work to do!
1141
+ // but only if we've already rendered, otherwise just chill out
1142
+ // queue that we need to do an update, but don't worry about queuing
1143
+ // up millions cuz this function ensures it only runs once
1144
+ scheduleUpdate(hostRef, false);
1145
+ }
1146
+ }
1147
+ }
1148
+ };
1149
+ /**
1150
+ * Attach a series of runtime constructs to a compiled Stencil component
1151
+ * constructor, including getters and setters for the `@Prop` and `@State`
1152
+ * decorators, callbacks for when attributes change, and so on.
1153
+ *
1154
+ * @param Cstr the constructor for a component that we need to process
1155
+ * @param cmpMeta metadata collected previously about the component
1156
+ * @param flags a number used to store a series of bit flags
1157
+ * @returns a reference to the same constructor passed in (but now mutated)
1158
+ */
1159
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
1160
+ if (cmpMeta.$members$) {
1161
+ if (Cstr.watchers) {
1162
+ cmpMeta.$watchers$ = Cstr.watchers;
1163
+ }
1164
+ // It's better to have a const than two Object.entries()
1165
+ const members = Object.entries(cmpMeta.$members$);
1166
+ const prototype = Cstr.prototype;
1167
+ members.map(([memberName, [memberFlags]]) => {
1168
+ if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1169
+ ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1170
+ // proxyComponent - prop
1171
+ Object.defineProperty(prototype, memberName, {
1172
+ get() {
1173
+ // proxyComponent, get value
1174
+ return getValue(this, memberName);
1175
+ },
1176
+ set(newValue) {
1177
+ // proxyComponent, set value
1178
+ setValue(this, memberName, newValue, cmpMeta);
1179
+ },
1180
+ configurable: true,
1181
+ enumerable: true,
1182
+ });
1183
+ }
1184
+ else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1185
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1186
+ // proxyComponent - method
1187
+ Object.defineProperty(prototype, memberName, {
1188
+ value(...args) {
1189
+ const ref = getHostRef(this);
1190
+ return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
1191
+ },
1192
+ });
1193
+ }
1194
+ });
1195
+ if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1196
+ const attrNameToPropName = new Map();
1197
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1198
+ plt.jmp(() => {
1199
+ const propName = attrNameToPropName.get(attrName);
1200
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1201
+ // in the case where an attribute was set inline.
1202
+ // ```html
1203
+ // <my-component some-attribute="some-value"></my-component>
1204
+ // ```
1205
+ //
1206
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
1207
+ // programmatically changes it before it has been upgraded as shown below:
1208
+ //
1209
+ // ```html
1210
+ // <!-- this component has _not_ been upgraded yet -->
1211
+ // <my-component id="test" some-attribute="some-value"></my-component>
1212
+ // <script>
1213
+ // // grab non-upgraded component
1214
+ // el = document.querySelector("#test");
1215
+ // el.someAttribute = "another-value";
1216
+ // // upgrade component
1217
+ // customElements.define('my-component', MyComponent);
1218
+ // </script>
1219
+ // ```
1220
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1221
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1222
+ // to the value that was set inline i.e. "some-value" from above example. When
1223
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1224
+ //
1225
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1226
+ // by connectedCallback as this attributeChangedCallback will not fire.
1227
+ //
1228
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1229
+ //
1230
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1231
+ // properties here given that this goes against best practices outlined here
1232
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1233
+ if (this.hasOwnProperty(propName)) {
1234
+ newValue = this[propName];
1235
+ delete this[propName];
1236
+ }
1237
+ else if (prototype.hasOwnProperty(propName) &&
1238
+ typeof this[propName] === 'number' &&
1239
+ this[propName] == newValue) {
1240
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1241
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1242
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1243
+ return;
1244
+ }
1245
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1246
+ });
1247
+ };
1248
+ // create an array of attributes to observe
1249
+ // and also create a map of html attribute name to js property name
1250
+ Cstr.observedAttributes = members
1251
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
1252
+ .map(([propName, m]) => {
1253
+ const attrName = m[1] || propName;
1254
+ attrNameToPropName.set(attrName, propName);
1255
+ return attrName;
1256
+ });
1257
+ }
1258
+ }
1259
+ return Cstr;
1260
+ };
1261
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1262
+ // initializeComponent
1263
+ if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
1264
+ {
1265
+ // we haven't initialized this element yet
1266
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
1267
+ // lazy loaded components
1268
+ // request the component's implementation to be
1269
+ // wired up with the host element
1270
+ Cstr = loadModule(cmpMeta);
1271
+ if (Cstr.then) {
1272
+ // Await creates a micro-task avoid if possible
1273
+ const endLoad = uniqueTime();
1274
+ Cstr = await Cstr;
1275
+ endLoad();
1276
+ }
1277
+ if (!Cstr.isProxied) {
1278
+ // we've never proxied this Constructor before
1279
+ // let's add the getters/setters to its prototype before
1280
+ // the first time we create an instance of the implementation
1281
+ {
1282
+ cmpMeta.$watchers$ = Cstr.watchers;
1283
+ }
1284
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
1285
+ Cstr.isProxied = true;
1286
+ }
1287
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1288
+ // ok, time to construct the instance
1289
+ // but let's keep track of when we start and stop
1290
+ // so that the getters/setters don't incorrectly step on data
1291
+ {
1292
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
1293
+ }
1294
+ // construct the lazy-loaded component implementation
1295
+ // passing the hostRef is very important during
1296
+ // construction in order to directly wire together the
1297
+ // host element and the lazy-loaded instance
1298
+ try {
1299
+ new Cstr(hostRef);
1300
+ }
1301
+ catch (e) {
1302
+ consoleError(e);
1303
+ }
1304
+ {
1305
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
1306
+ }
1307
+ {
1308
+ hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
1309
+ }
1310
+ endNewInstance();
1311
+ fireConnectedCallback(hostRef.$lazyInstance$);
1312
+ }
1313
+ if (Cstr.style) {
1314
+ // this component has styles but we haven't registered them yet
1315
+ let style = Cstr.style;
1316
+ const scopeId = getScopeId(cmpMeta);
1317
+ if (!styles.has(scopeId)) {
1318
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1319
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
1320
+ endRegisterStyles();
1321
+ }
1322
+ }
1323
+ }
1324
+ // we've successfully created a lazy instance
1325
+ const ancestorComponent = hostRef.$ancestorComponent$;
1326
+ const schedule = () => scheduleUpdate(hostRef, true);
1327
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1328
+ // this is the initial load and this component it has an ancestor component
1329
+ // but the ancestor component has NOT fired its will update lifecycle yet
1330
+ // so let's just cool our jets and wait for the ancestor to continue first
1331
+ // this will get fired off when the ancestor component
1332
+ // finally gets around to rendering its lazy self
1333
+ // fire off the initial update
1334
+ ancestorComponent['s-rc'].push(schedule);
1335
+ }
1336
+ else {
1337
+ schedule();
1338
+ }
1339
+ };
1340
+ const fireConnectedCallback = (instance) => {
1341
+ {
1342
+ safeCall(instance, 'connectedCallback');
1343
+ }
1344
+ };
1345
+ const connectedCallback = (elm) => {
1346
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1347
+ const hostRef = getHostRef(elm);
1348
+ const cmpMeta = hostRef.$cmpMeta$;
1349
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1350
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1351
+ // first time this component has connected
1352
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1353
+ {
1354
+ // find the first ancestor component (if there is one) and register
1355
+ // this component as one of the actively loading child components for its ancestor
1356
+ let ancestorComponent = elm;
1357
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1358
+ // climb up the ancestors looking for the first
1359
+ // component that hasn't finished its lifecycle update yet
1360
+ if (ancestorComponent['s-p']) {
1361
+ // we found this components first ancestor component
1362
+ // keep a reference to this component's ancestor component
1363
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1364
+ break;
1365
+ }
1366
+ }
1367
+ }
1368
+ // Lazy properties
1369
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1370
+ if (cmpMeta.$members$) {
1371
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1372
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
1373
+ const value = elm[memberName];
1374
+ delete elm[memberName];
1375
+ elm[memberName] = value;
1376
+ }
1377
+ });
1378
+ }
1379
+ {
1380
+ initializeComponent(elm, hostRef, cmpMeta);
1381
+ }
1382
+ }
1383
+ else {
1384
+ // not the first time this has connected
1385
+ // reattach any event listeners to the host
1386
+ // since they would have been removed when disconnected
1387
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1388
+ // fire off connectedCallback() on component instance
1389
+ fireConnectedCallback(hostRef.$lazyInstance$);
1390
+ }
1391
+ endConnected();
1392
+ }
1393
+ };
1394
+ const disconnectedCallback = (elm) => {
1395
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1396
+ const hostRef = getHostRef(elm);
1397
+ const instance = hostRef.$lazyInstance$ ;
1398
+ {
1399
+ if (hostRef.$rmListeners$) {
1400
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
1401
+ hostRef.$rmListeners$ = undefined;
1402
+ }
1403
+ }
1404
+ {
1405
+ safeCall(instance, 'disconnectedCallback');
1406
+ }
1407
+ }
1408
+ };
1409
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1410
+ var _a;
1411
+ const endBootstrap = createTime();
1412
+ const cmpTags = [];
1413
+ const exclude = options.exclude || [];
1414
+ const customElements = win.customElements;
1415
+ const head = doc.head;
1416
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1417
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1418
+ const deferredConnectedCallbacks = [];
1419
+ let appLoadFallback;
1420
+ let isBootstrapping = true;
1421
+ Object.assign(plt, options);
1422
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1423
+ lazyBundles.map((lazyBundle) => {
1424
+ lazyBundle[1].map((compactMeta) => {
1425
+ const cmpMeta = {
1426
+ $flags$: compactMeta[0],
1427
+ $tagName$: compactMeta[1],
1428
+ $members$: compactMeta[2],
1429
+ $listeners$: compactMeta[3],
1430
+ };
1431
+ {
1432
+ cmpMeta.$members$ = compactMeta[2];
1433
+ }
1434
+ {
1435
+ cmpMeta.$listeners$ = compactMeta[3];
1436
+ }
1437
+ {
1438
+ cmpMeta.$watchers$ = {};
1439
+ }
1440
+ const tagName = cmpMeta.$tagName$;
1441
+ const HostElement = class extends HTMLElement {
1442
+ // StencilLazyHost
1443
+ constructor(self) {
1444
+ // @ts-ignore
1445
+ super(self);
1446
+ self = this;
1447
+ registerHost(self, cmpMeta);
1448
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1449
+ // this component is using shadow dom
1450
+ // and this browser supports shadow dom
1451
+ // add the read-only property "shadowRoot" to the host element
1452
+ // adding the shadow root build conditionals to minimize runtime
1453
+ {
1454
+ {
1455
+ self.attachShadow({ mode: 'open' });
1456
+ }
1457
+ }
1458
+ }
1459
+ }
1460
+ connectedCallback() {
1461
+ if (appLoadFallback) {
1462
+ clearTimeout(appLoadFallback);
1463
+ appLoadFallback = null;
1464
+ }
1465
+ if (isBootstrapping) {
1466
+ // connectedCallback will be processed once all components have been registered
1467
+ deferredConnectedCallbacks.push(this);
1468
+ }
1469
+ else {
1470
+ plt.jmp(() => connectedCallback(this));
1471
+ }
1472
+ }
1473
+ disconnectedCallback() {
1474
+ plt.jmp(() => disconnectedCallback(this));
1475
+ }
1476
+ componentOnReady() {
1477
+ return getHostRef(this).$onReadyPromise$;
1478
+ }
1479
+ };
1480
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1481
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1482
+ cmpTags.push(tagName);
1483
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
1484
+ }
1485
+ });
1486
+ });
1487
+ {
1488
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1489
+ visibilityStyle.setAttribute('data-styles', '');
1490
+ // Apply CSP nonce to the style tag if it exists
1491
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1492
+ if (nonce != null) {
1493
+ visibilityStyle.setAttribute('nonce', nonce);
1494
+ }
1495
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1496
+ }
1497
+ // Process deferred connectedCallbacks now all components have been registered
1498
+ isBootstrapping = false;
1499
+ if (deferredConnectedCallbacks.length) {
1500
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1501
+ }
1502
+ else {
1503
+ {
1504
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1505
+ }
1506
+ }
1507
+ // Fallback appLoad event
1508
+ endBootstrap();
1509
+ };
1510
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
1511
+ if (listeners) {
1512
+ listeners.map(([flags, name, method]) => {
1513
+ const target = getHostListenerTarget(elm, flags) ;
1514
+ const handler = hostListenerProxy(hostRef, method);
1515
+ const opts = hostListenerOpts(flags);
1516
+ plt.ael(target, name, handler, opts);
1517
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
1518
+ });
1519
+ }
1520
+ };
1521
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1522
+ try {
1523
+ {
1524
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
1525
+ // instance is ready, let's call it's member method for this event
1526
+ hostRef.$lazyInstance$[methodName](ev);
1527
+ }
1528
+ else {
1529
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
1530
+ }
1531
+ }
1532
+ }
1533
+ catch (e) {
1534
+ consoleError(e);
1535
+ }
1536
+ };
1537
+ const getHostListenerTarget = (elm, flags) => {
1538
+ if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
1539
+ return win;
1540
+ return elm;
1541
+ };
1542
+ // prettier-ignore
1543
+ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1544
+ /**
1545
+ * Assigns the given value to the nonce property on the runtime platform object.
1546
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1547
+ * @param nonce The value to be assigned to the platform nonce property.
1548
+ * @returns void
1549
+ */
1550
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
1551
+ const hostRefs = /*@__PURE__*/ new WeakMap();
1552
+ const getHostRef = (ref) => hostRefs.get(ref);
1553
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1554
+ const registerHost = (elm, cmpMeta) => {
1555
+ const hostRef = {
1556
+ $flags$: 0,
1557
+ $hostElement$: elm,
1558
+ $cmpMeta$: cmpMeta,
1559
+ $instanceValues$: new Map(),
1560
+ };
1561
+ {
1562
+ hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
1563
+ }
1564
+ {
1565
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1566
+ elm['s-p'] = [];
1567
+ elm['s-rc'] = [];
1568
+ }
1569
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1570
+ return hostRefs.set(elm, hostRef);
1571
+ };
1572
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1573
+ const consoleError = (e, el) => (0, console.error)(e, el);
1574
+ const cmpModules = /*@__PURE__*/ new Map();
1575
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1576
+ // loadModuleImport
1577
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1578
+ const bundleId = cmpMeta.$lazyBundleId$;
1579
+ const module = cmpModules.get(bundleId) ;
1580
+ if (module) {
1581
+ return module[exportName];
1582
+ }
1583
+
1584
+ if (!hmrVersionId || !BUILD.hotModuleReplacement) {
1585
+ const processMod = importedModule => {
1586
+ cmpModules.set(bundleId, importedModule);
1587
+ return importedModule[exportName];
1588
+ }
1589
+ switch(bundleId) {
1590
+
1591
+ case 'document-detector_19.cjs':
1592
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1593
+ /* webpackMode: "lazy" */
1594
+ './document-detector_19.cjs.entry.js')); }).then(processMod, consoleError);
1595
+ case 'mb-tooltip.cjs':
1596
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1597
+ /* webpackMode: "lazy" */
1598
+ './mb-tooltip.cjs.entry.js')); }).then(processMod, consoleError);
1599
+ }
1600
+ }
1601
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
1602
+ /* @vite-ignore */
1603
+ /* webpackInclude: /\.entry\.js$/ */
1604
+ /* webpackExclude: /\.system\.entry\.js$/ */
1605
+ /* webpackMode: "lazy" */
1606
+ `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1607
+ {
1608
+ cmpModules.set(bundleId, importedModule);
1609
+ }
1610
+ return importedModule[exportName];
1611
+ }, consoleError);
1612
+ };
1613
+ const styles = /*@__PURE__*/ new Map();
1614
+ const win = typeof window !== 'undefined' ? window : {};
1615
+ const doc = win.document || { head: {} };
1616
+ const plt = {
1617
+ $flags$: 0,
1618
+ $resourcesUrl$: '',
1619
+ jmp: (h) => h(),
1620
+ raf: (h) => requestAnimationFrame(h),
1621
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
1622
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
1623
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
1624
+ };
1625
+ const promiseResolve = (v) => Promise.resolve(v);
1626
+ const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
1627
+ try {
1628
+ new CSSStyleSheet();
1629
+ return typeof new CSSStyleSheet().replaceSync === 'function';
1630
+ }
1631
+ catch (e) { }
1632
+ return false;
1633
+ })()
1634
+ ;
1635
+ const queueDomReads = [];
1636
+ const queueDomWrites = [];
1637
+ const queueTask = (queue, write) => (cb) => {
1638
+ queue.push(cb);
1639
+ if (!queuePending) {
1640
+ queuePending = true;
1641
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
1642
+ nextTick(flush);
1643
+ }
1644
+ else {
1645
+ plt.raf(flush);
1646
+ }
1647
+ }
1648
+ };
1649
+ const consume = (queue) => {
1650
+ for (let i = 0; i < queue.length; i++) {
1651
+ try {
1652
+ queue[i](performance.now());
1653
+ }
1654
+ catch (e) {
1655
+ consoleError(e);
1656
+ }
1657
+ }
1658
+ queue.length = 0;
1659
+ };
1660
+ const flush = () => {
1661
+ // always force a bunch of medium callbacks to run, but still have
1662
+ // a throttle on how many can run in a certain time
1663
+ // DOM READS!!!
1664
+ consume(queueDomReads);
1665
+ // DOM WRITES!!!
1666
+ {
1667
+ consume(queueDomWrites);
1668
+ if ((queuePending = queueDomReads.length > 0)) {
1669
+ // still more to do yet, but we've run out of time
1670
+ // let's let this thing cool off and try again in the next tick
1671
+ plt.raf(flush);
1672
+ }
1673
+ }
1674
+ };
1675
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1676
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1677
+
1678
+ exports.Host = Host;
1679
+ exports.bootstrapLazy = bootstrapLazy;
1680
+ exports.createEvent = createEvent;
1681
+ exports.getElement = getElement;
1682
+ exports.h = h;
1683
+ exports.promiseResolve = promiseResolve;
1684
+ exports.registerInstance = registerInstance;
1685
+ exports.setNonce = setNonce;