@maggioli-design-system/mds-input-select 1.0.0

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