@maggioli-design-system/mds-paginator 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 (133) hide show
  1. package/dist/cjs/index-970ace02.js +1203 -0
  2. package/dist/cjs/index.cjs.js +2 -0
  3. package/dist/cjs/loader.cjs.js +21 -0
  4. package/dist/cjs/mds-paginator.cjs.entry.js +59 -0
  5. package/dist/cjs/mds-paginator.cjs.js +19 -0
  6. package/dist/collection/collection-manifest.json +12 -0
  7. package/dist/collection/components/mds-paginator/mds-paginator.css +73 -0
  8. package/dist/collection/components/mds-paginator/mds-paginator.js +114 -0
  9. package/dist/collection/components/mds-paginator/test/mds-paginator.stories.js +26 -0
  10. package/dist/collection/dictionary/autocomplete.js +59 -0
  11. package/dist/collection/dictionary/button.js +26 -0
  12. package/dist/collection/dictionary/color.js +19 -0
  13. package/dist/collection/dictionary/floating-ui.js +19 -0
  14. package/dist/collection/dictionary/icon.js +3 -0
  15. package/dist/collection/dictionary/input-text-type.js +13 -0
  16. package/dist/collection/dictionary/loading.js +5 -0
  17. package/dist/collection/dictionary/typography.js +59 -0
  18. package/dist/collection/dictionary/variant.js +65 -0
  19. package/dist/collection/fixtures/cities.js +110 -0
  20. package/dist/collection/interface/input-value.js +1 -0
  21. package/dist/collection/types/autocomplete.js +1 -0
  22. package/dist/collection/types/button.js +1 -0
  23. package/dist/collection/types/floating-ui.js +1 -0
  24. package/dist/collection/types/form-rel.js +1 -0
  25. package/dist/collection/types/input-text-type.js +1 -0
  26. package/dist/collection/types/input-value-type.js +1 -0
  27. package/dist/collection/types/loading.js +1 -0
  28. package/dist/collection/types/typography.js +1 -0
  29. package/dist/collection/types/variant.js +1 -0
  30. package/dist/components/index.d.ts +22 -0
  31. package/dist/components/index.js +2 -0
  32. package/dist/components/mds-paginator.d.ts +11 -0
  33. package/dist/components/mds-paginator.js +76 -0
  34. package/dist/esm/index-2c9f4cc7.js +1175 -0
  35. package/dist/esm/index.js +1 -0
  36. package/dist/esm/loader.js +17 -0
  37. package/dist/esm/mds-paginator.entry.js +55 -0
  38. package/dist/esm/mds-paginator.js +17 -0
  39. package/dist/esm/polyfills/core-js.js +11 -0
  40. package/dist/esm/polyfills/css-shim.js +1 -0
  41. package/dist/esm/polyfills/dom.js +79 -0
  42. package/dist/esm/polyfills/es5-html-element.js +1 -0
  43. package/dist/esm/polyfills/index.js +34 -0
  44. package/dist/esm/polyfills/system.js +6 -0
  45. package/dist/esm-es5/index-2c9f4cc7.js +2 -0
  46. package/dist/esm-es5/index.js +0 -0
  47. package/dist/esm-es5/loader.js +1 -0
  48. package/dist/esm-es5/mds-paginator.entry.js +1 -0
  49. package/dist/esm-es5/mds-paginator.js +1 -0
  50. package/dist/index.cjs.js +1 -0
  51. package/dist/index.js +1 -0
  52. package/dist/mds-paginator/index.esm.js +0 -0
  53. package/dist/mds-paginator/mds-paginator.esm.js +1 -0
  54. package/dist/mds-paginator/mds-paginator.js +130 -0
  55. package/dist/mds-paginator/p-1af6182a.entry.js +1 -0
  56. package/dist/mds-paginator/p-4e602610.js +2 -0
  57. package/dist/mds-paginator/p-50ea2036.system.js +1 -0
  58. package/dist/mds-paginator/p-580a8708.system.js +2 -0
  59. package/dist/mds-paginator/p-628f5264.system.js +1 -0
  60. package/dist/mds-paginator/p-d71311fc.system.entry.js +1 -0
  61. package/dist/stats.json +487 -0
  62. package/dist/types/components/mds-paginator/mds-paginator.d.ts +20 -0
  63. package/dist/types/components/mds-paginator/test/mds-paginator.stories.d.ts +22 -0
  64. package/dist/types/components.d.ts +61 -0
  65. package/dist/types/dictionary/autocomplete.d.ts +2 -0
  66. package/dist/types/dictionary/button.d.ts +5 -0
  67. package/dist/types/dictionary/color.d.ts +3 -0
  68. package/dist/types/dictionary/floating-ui.d.ts +3 -0
  69. package/dist/types/dictionary/icon.d.ts +2 -0
  70. package/dist/types/dictionary/input-text-type.d.ts +2 -0
  71. package/dist/types/dictionary/loading.d.ts +2 -0
  72. package/dist/types/dictionary/typography.d.ts +9 -0
  73. package/dist/types/dictionary/variant.d.ts +9 -0
  74. package/dist/types/fixtures/cities.d.ts +2 -0
  75. package/dist/types/interface/input-value.d.ts +4 -0
  76. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  77. package/dist/types/types/autocomplete.d.ts +2 -0
  78. package/dist/types/types/button.d.ts +4 -0
  79. package/dist/types/types/floating-ui.d.ts +2 -0
  80. package/dist/types/types/form-rel.d.ts +1 -0
  81. package/dist/types/types/input-text-type.d.ts +1 -0
  82. package/dist/types/types/input-value-type.d.ts +1 -0
  83. package/dist/types/types/loading.d.ts +1 -0
  84. package/dist/types/types/typography.d.ts +8 -0
  85. package/dist/types/types/variant.d.ts +10 -0
  86. package/loader/cdn.js +3 -0
  87. package/loader/index.cjs.js +3 -0
  88. package/loader/index.d.ts +12 -0
  89. package/loader/index.es2017.js +3 -0
  90. package/loader/index.js +4 -0
  91. package/loader/package.json +10 -0
  92. package/package.json +47 -0
  93. package/readme.md +40 -0
  94. package/src/components/mds-paginator/.gitlab-ci.yml +25 -0
  95. package/src/components/mds-paginator/mds-paginator.css +41 -0
  96. package/src/components/mds-paginator/mds-paginator.tsx +78 -0
  97. package/src/components/mds-paginator/readme.md +25 -0
  98. package/src/components/mds-paginator/test/mds-paginator.e2e.ts +12 -0
  99. package/src/components/mds-paginator/test/mds-paginator.spec.tsx +19 -0
  100. package/src/components/mds-paginator/test/mds-paginator.stories.tsx +31 -0
  101. package/src/components.d.ts +61 -0
  102. package/src/dictionary/autocomplete.ts +62 -0
  103. package/src/dictionary/button.ts +35 -0
  104. package/src/dictionary/color.ts +24 -0
  105. package/src/dictionary/floating-ui.ts +25 -0
  106. package/src/dictionary/icon.ts +5 -0
  107. package/src/dictionary/input-text-type.ts +17 -0
  108. package/src/dictionary/loading.ts +9 -0
  109. package/src/dictionary/typography.ts +76 -0
  110. package/src/dictionary/variant.ts +82 -0
  111. package/src/fixtures/cities.ts +116 -0
  112. package/src/fixtures/icons.json +65 -0
  113. package/src/interface/input-value.ts +5 -0
  114. package/src/tailwind/components.css +14 -0
  115. package/src/types/autocomplete.ts +69 -0
  116. package/src/types/button.ts +24 -0
  117. package/src/types/floating-ui.ts +17 -0
  118. package/src/types/form-rel.ts +11 -0
  119. package/src/types/input-text-type.ts +11 -0
  120. package/src/types/input-value-type.ts +5 -0
  121. package/src/types/loading.ts +3 -0
  122. package/src/types/typography.ts +57 -0
  123. package/src/types/variant.ts +73 -0
  124. package/www/build/index.esm.js +0 -0
  125. package/www/build/mds-paginator.esm.js +1 -0
  126. package/www/build/mds-paginator.js +130 -0
  127. package/www/build/p-1af6182a.entry.js +1 -0
  128. package/www/build/p-4e602610.js +2 -0
  129. package/www/build/p-50ea2036.system.js +1 -0
  130. package/www/build/p-580a8708.system.js +2 -0
  131. package/www/build/p-628f5264.system.js +1 -0
  132. package/www/build/p-d71311fc.system.entry.js +1 -0
  133. package/www/host.config.json +15 -0
@@ -0,0 +1,1175 @@
1
+ const NAMESPACE = 'mds-paginator';
2
+
3
+ let scopeId;
4
+ let hostTagName;
5
+ let isSvgMode = false;
6
+ let queuePending = false;
7
+ const win = typeof window !== 'undefined' ? window : {};
8
+ const doc = win.document || { head: {} };
9
+ const plt = {
10
+ $flags$: 0,
11
+ $resourcesUrl$: '',
12
+ jmp: (h) => h(),
13
+ raf: (h) => requestAnimationFrame(h),
14
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
15
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
16
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
17
+ };
18
+ const promiseResolve = (v) => Promise.resolve(v);
19
+ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
20
+ try {
21
+ new CSSStyleSheet();
22
+ return typeof new CSSStyleSheet().replace === 'function';
23
+ }
24
+ catch (e) { }
25
+ return false;
26
+ })()
27
+ ;
28
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
29
+ const createTime = (fnName, tagName = '') => {
30
+ {
31
+ return () => {
32
+ return;
33
+ };
34
+ }
35
+ };
36
+ const uniqueTime = (key, measureText) => {
37
+ {
38
+ return () => {
39
+ return;
40
+ };
41
+ }
42
+ };
43
+ const rootAppliedStyles = new WeakMap();
44
+ const registerStyle = (scopeId, cssText, allowCS) => {
45
+ let style = styles.get(scopeId);
46
+ if (supportsConstructibleStylesheets && allowCS) {
47
+ style = (style || new CSSStyleSheet());
48
+ style.replace(cssText);
49
+ }
50
+ else {
51
+ style = cssText;
52
+ }
53
+ styles.set(scopeId, style);
54
+ };
55
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
56
+ let scopeId = getScopeId(cmpMeta);
57
+ const style = styles.get(scopeId);
58
+ // if an element is NOT connected then getRootNode() will return the wrong root node
59
+ // so the fallback is to always use the document for the root node in those cases
60
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
61
+ if (style) {
62
+ if (typeof style === 'string') {
63
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
64
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
65
+ let styleElm;
66
+ if (!appliedStyles) {
67
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
68
+ }
69
+ if (!appliedStyles.has(scopeId)) {
70
+ {
71
+ {
72
+ styleElm = doc.createElement('style');
73
+ styleElm.innerHTML = style;
74
+ }
75
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
76
+ }
77
+ if (appliedStyles) {
78
+ appliedStyles.add(scopeId);
79
+ }
80
+ }
81
+ }
82
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
83
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
84
+ }
85
+ }
86
+ return scopeId;
87
+ };
88
+ const attachStyles = (hostRef) => {
89
+ const cmpMeta = hostRef.$cmpMeta$;
90
+ const elm = hostRef.$hostElement$;
91
+ const flags = cmpMeta.$flags$;
92
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
93
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
94
+ if (flags & 10 /* needsScopedEncapsulation */) {
95
+ // only required when we're NOT using native shadow dom (slot)
96
+ // or this browser doesn't support native shadow dom
97
+ // and this host element was NOT created with SSR
98
+ // let's pick out the inner content for slot projection
99
+ // create a node to represent where the original
100
+ // content was first placed, which is useful later on
101
+ // DOM WRITE!!
102
+ elm['s-sc'] = scopeId;
103
+ elm.classList.add(scopeId + '-h');
104
+ }
105
+ endAttachStyles();
106
+ };
107
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
108
+ /**
109
+ * Default style mode id
110
+ */
111
+ /**
112
+ * Reusable empty obj/array
113
+ * Don't add values to these!!
114
+ */
115
+ const EMPTY_OBJ = {};
116
+ const isDef = (v) => v != null;
117
+ const isComplexType = (o) => {
118
+ // https://jsperf.com/typeof-fn-object/5
119
+ o = typeof o;
120
+ return o === 'object' || o === 'function';
121
+ };
122
+ /**
123
+ * Production h() function based on Preact by
124
+ * Jason Miller (@developit)
125
+ * Licensed under the MIT License
126
+ * https://github.com/developit/preact/blob/master/LICENSE
127
+ *
128
+ * Modified for Stencil's compiler and vdom
129
+ */
130
+ // const stack: any[] = [];
131
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
132
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
133
+ const h = (nodeName, vnodeData, ...children) => {
134
+ let child = null;
135
+ let key = null;
136
+ let simple = false;
137
+ let lastSimple = false;
138
+ const vNodeChildren = [];
139
+ const walk = (c) => {
140
+ for (let i = 0; i < c.length; i++) {
141
+ child = c[i];
142
+ if (Array.isArray(child)) {
143
+ walk(child);
144
+ }
145
+ else if (child != null && typeof child !== 'boolean') {
146
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
147
+ child = String(child);
148
+ }
149
+ if (simple && lastSimple) {
150
+ // If the previous child was simple (string), we merge both
151
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
152
+ }
153
+ else {
154
+ // Append a new vNode, if it's text, we create a text vNode
155
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
156
+ }
157
+ lastSimple = simple;
158
+ }
159
+ }
160
+ };
161
+ walk(children);
162
+ if (vnodeData) {
163
+ // normalize class / classname attributes
164
+ if (vnodeData.key) {
165
+ key = vnodeData.key;
166
+ }
167
+ {
168
+ const classData = vnodeData.className || vnodeData.class;
169
+ if (classData) {
170
+ vnodeData.class =
171
+ typeof classData !== 'object'
172
+ ? classData
173
+ : Object.keys(classData)
174
+ .filter((k) => classData[k])
175
+ .join(' ');
176
+ }
177
+ }
178
+ }
179
+ const vnode = newVNode(nodeName, null);
180
+ vnode.$attrs$ = vnodeData;
181
+ if (vNodeChildren.length > 0) {
182
+ vnode.$children$ = vNodeChildren;
183
+ }
184
+ {
185
+ vnode.$key$ = key;
186
+ }
187
+ return vnode;
188
+ };
189
+ const newVNode = (tag, text) => {
190
+ const vnode = {
191
+ $flags$: 0,
192
+ $tag$: tag,
193
+ $text$: text,
194
+ $elm$: null,
195
+ $children$: null,
196
+ };
197
+ {
198
+ vnode.$attrs$ = null;
199
+ }
200
+ {
201
+ vnode.$key$ = null;
202
+ }
203
+ return vnode;
204
+ };
205
+ const Host = {};
206
+ const isHost = (node) => node && node.$tag$ === Host;
207
+ /**
208
+ * Production setAccessor() function based on Preact by
209
+ * Jason Miller (@developit)
210
+ * Licensed under the MIT License
211
+ * https://github.com/developit/preact/blob/master/LICENSE
212
+ *
213
+ * Modified for Stencil's compiler and vdom
214
+ */
215
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
216
+ if (oldValue !== newValue) {
217
+ let isProp = isMemberInElement(elm, memberName);
218
+ let ln = memberName.toLowerCase();
219
+ if (memberName === 'class') {
220
+ const classList = elm.classList;
221
+ const oldClasses = parseClassList(oldValue);
222
+ const newClasses = parseClassList(newValue);
223
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
224
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
225
+ }
226
+ else if (memberName === 'key')
227
+ ;
228
+ else if ((!isProp ) &&
229
+ memberName[0] === 'o' &&
230
+ memberName[1] === 'n') {
231
+ // Event Handlers
232
+ // so if the member name starts with "on" and the 3rd characters is
233
+ // a capital letter, and it's not already a member on the element,
234
+ // then we're assuming it's an event listener
235
+ if (memberName[2] === '-') {
236
+ // on- prefixed events
237
+ // allows to be explicit about the dom event to listen without any magic
238
+ // under the hood:
239
+ // <my-cmp on-click> // listens for "click"
240
+ // <my-cmp on-Click> // listens for "Click"
241
+ // <my-cmp on-ionChange> // listens for "ionChange"
242
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
243
+ memberName = memberName.slice(3);
244
+ }
245
+ else if (isMemberInElement(win, ln)) {
246
+ // standard event
247
+ // the JSX attribute could have been "onMouseOver" and the
248
+ // member name "onmouseover" is on the window's prototype
249
+ // so let's add the listener "mouseover", which is all lowercased
250
+ memberName = ln.slice(2);
251
+ }
252
+ else {
253
+ // custom event
254
+ // the JSX attribute could have been "onMyCustomEvent"
255
+ // so let's trim off the "on" prefix and lowercase the first character
256
+ // and add the listener "myCustomEvent"
257
+ // except for the first character, we keep the event name case
258
+ memberName = ln[2] + memberName.slice(3);
259
+ }
260
+ if (oldValue) {
261
+ plt.rel(elm, memberName, oldValue, false);
262
+ }
263
+ if (newValue) {
264
+ plt.ael(elm, memberName, newValue, false);
265
+ }
266
+ }
267
+ else {
268
+ // Set property if it exists and it's not a SVG
269
+ const isComplex = isComplexType(newValue);
270
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
271
+ try {
272
+ if (!elm.tagName.includes('-')) {
273
+ const n = newValue == null ? '' : newValue;
274
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
275
+ if (memberName === 'list') {
276
+ isProp = false;
277
+ }
278
+ else if (oldValue == null || elm[memberName] != n) {
279
+ elm[memberName] = n;
280
+ }
281
+ }
282
+ else {
283
+ elm[memberName] = newValue;
284
+ }
285
+ }
286
+ catch (e) { }
287
+ }
288
+ if (newValue == null || newValue === false) {
289
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
290
+ {
291
+ elm.removeAttribute(memberName);
292
+ }
293
+ }
294
+ }
295
+ else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
296
+ newValue = newValue === true ? '' : newValue;
297
+ {
298
+ elm.setAttribute(memberName, newValue);
299
+ }
300
+ }
301
+ }
302
+ }
303
+ };
304
+ const parseClassListRegex = /\s/;
305
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
306
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
307
+ // if the element passed in is a shadow root, which is a document fragment
308
+ // then we want to be adding attrs/props to the shadow root's "host" element
309
+ // if it's not a shadow root, then we add attrs/props to the same element
310
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
311
+ ? newVnode.$elm$.host
312
+ : newVnode.$elm$;
313
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
314
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
315
+ {
316
+ // remove attributes no longer present on the vnode by setting them to undefined
317
+ for (memberName in oldVnodeAttrs) {
318
+ if (!(memberName in newVnodeAttrs)) {
319
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
320
+ }
321
+ }
322
+ }
323
+ // add new & update changed attributes
324
+ for (memberName in newVnodeAttrs) {
325
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
326
+ }
327
+ };
328
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
329
+ // tslint:disable-next-line: prefer-const
330
+ const newVNode = newParentVNode.$children$[childIndex];
331
+ let i = 0;
332
+ let elm;
333
+ let childNode;
334
+ if (newVNode.$text$ !== null) {
335
+ // create text node
336
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
337
+ }
338
+ else {
339
+ // create element
340
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
341
+ // add css classes, attrs, props, listeners, etc.
342
+ {
343
+ updateElement(null, newVNode, isSvgMode);
344
+ }
345
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
346
+ // if there is a scopeId and this is the initial render
347
+ // then let's add the scopeId as a css class
348
+ elm.classList.add((elm['s-si'] = scopeId));
349
+ }
350
+ if (newVNode.$children$) {
351
+ for (i = 0; i < newVNode.$children$.length; ++i) {
352
+ // create the node
353
+ childNode = createElm(oldParentVNode, newVNode, i);
354
+ // return node could have been null
355
+ if (childNode) {
356
+ // append our new node
357
+ elm.appendChild(childNode);
358
+ }
359
+ }
360
+ }
361
+ }
362
+ return elm;
363
+ };
364
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
365
+ let containerElm = (parentElm);
366
+ let childNode;
367
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
368
+ containerElm = containerElm.shadowRoot;
369
+ }
370
+ for (; startIdx <= endIdx; ++startIdx) {
371
+ if (vnodes[startIdx]) {
372
+ childNode = createElm(null, parentVNode, startIdx);
373
+ if (childNode) {
374
+ vnodes[startIdx].$elm$ = childNode;
375
+ containerElm.insertBefore(childNode, before);
376
+ }
377
+ }
378
+ }
379
+ };
380
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
381
+ for (; startIdx <= endIdx; ++startIdx) {
382
+ if ((vnode = vnodes[startIdx])) {
383
+ elm = vnode.$elm$;
384
+ // remove the vnode's element from the dom
385
+ elm.remove();
386
+ }
387
+ }
388
+ };
389
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
390
+ let oldStartIdx = 0;
391
+ let newStartIdx = 0;
392
+ let idxInOld = 0;
393
+ let i = 0;
394
+ let oldEndIdx = oldCh.length - 1;
395
+ let oldStartVnode = oldCh[0];
396
+ let oldEndVnode = oldCh[oldEndIdx];
397
+ let newEndIdx = newCh.length - 1;
398
+ let newStartVnode = newCh[0];
399
+ let newEndVnode = newCh[newEndIdx];
400
+ let node;
401
+ let elmToMove;
402
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
403
+ if (oldStartVnode == null) {
404
+ // Vnode might have been moved left
405
+ oldStartVnode = oldCh[++oldStartIdx];
406
+ }
407
+ else if (oldEndVnode == null) {
408
+ oldEndVnode = oldCh[--oldEndIdx];
409
+ }
410
+ else if (newStartVnode == null) {
411
+ newStartVnode = newCh[++newStartIdx];
412
+ }
413
+ else if (newEndVnode == null) {
414
+ newEndVnode = newCh[--newEndIdx];
415
+ }
416
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
417
+ patch(oldStartVnode, newStartVnode);
418
+ oldStartVnode = oldCh[++oldStartIdx];
419
+ newStartVnode = newCh[++newStartIdx];
420
+ }
421
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
422
+ patch(oldEndVnode, newEndVnode);
423
+ oldEndVnode = oldCh[--oldEndIdx];
424
+ newEndVnode = newCh[--newEndIdx];
425
+ }
426
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
427
+ patch(oldStartVnode, newEndVnode);
428
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
429
+ oldStartVnode = oldCh[++oldStartIdx];
430
+ newEndVnode = newCh[--newEndIdx];
431
+ }
432
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
433
+ patch(oldEndVnode, newStartVnode);
434
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
435
+ oldEndVnode = oldCh[--oldEndIdx];
436
+ newStartVnode = newCh[++newStartIdx];
437
+ }
438
+ else {
439
+ // createKeyToOldIdx
440
+ idxInOld = -1;
441
+ {
442
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
443
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
444
+ idxInOld = i;
445
+ break;
446
+ }
447
+ }
448
+ }
449
+ if (idxInOld >= 0) {
450
+ elmToMove = oldCh[idxInOld];
451
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
452
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
453
+ }
454
+ else {
455
+ patch(elmToMove, newStartVnode);
456
+ oldCh[idxInOld] = undefined;
457
+ node = elmToMove.$elm$;
458
+ }
459
+ newStartVnode = newCh[++newStartIdx];
460
+ }
461
+ else {
462
+ // new element
463
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
464
+ newStartVnode = newCh[++newStartIdx];
465
+ }
466
+ if (node) {
467
+ {
468
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
469
+ }
470
+ }
471
+ }
472
+ }
473
+ if (oldStartIdx > oldEndIdx) {
474
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
475
+ }
476
+ else if (newStartIdx > newEndIdx) {
477
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
478
+ }
479
+ };
480
+ const isSameVnode = (vnode1, vnode2) => {
481
+ // compare if two vnode to see if they're "technically" the same
482
+ // need to have the same element tag, and same key to be the same
483
+ if (vnode1.$tag$ === vnode2.$tag$) {
484
+ {
485
+ return vnode1.$key$ === vnode2.$key$;
486
+ }
487
+ }
488
+ return false;
489
+ };
490
+ const patch = (oldVNode, newVNode) => {
491
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
492
+ const oldChildren = oldVNode.$children$;
493
+ const newChildren = newVNode.$children$;
494
+ const text = newVNode.$text$;
495
+ if (text === null) {
496
+ // element node
497
+ {
498
+ {
499
+ // either this is the first render of an element OR it's an update
500
+ // AND we already know it's possible it could have changed
501
+ // this updates the element's css classes, attrs, props, listeners, etc.
502
+ updateElement(oldVNode, newVNode, isSvgMode);
503
+ }
504
+ }
505
+ if (oldChildren !== null && newChildren !== null) {
506
+ // looks like there's child vnodes for both the old and new vnodes
507
+ updateChildren(elm, oldChildren, newVNode, newChildren);
508
+ }
509
+ else if (newChildren !== null) {
510
+ // no old child vnodes, but there are new child vnodes to add
511
+ if (oldVNode.$text$ !== null) {
512
+ // the old vnode was text, so be sure to clear it out
513
+ elm.textContent = '';
514
+ }
515
+ // add the new vnode children
516
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
517
+ }
518
+ else if (oldChildren !== null) {
519
+ // no new child vnodes, but there are old child vnodes to remove
520
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
521
+ }
522
+ }
523
+ else if (oldVNode.$text$ !== text) {
524
+ // update the text content for the text only vnode
525
+ // and also only if the text is different than before
526
+ elm.data = text;
527
+ }
528
+ };
529
+ const renderVdom = (hostRef, renderFnResults) => {
530
+ const hostElm = hostRef.$hostElement$;
531
+ const cmpMeta = hostRef.$cmpMeta$;
532
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
533
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
534
+ hostTagName = hostElm.tagName;
535
+ if (cmpMeta.$attrsToReflect$) {
536
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
537
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
538
+ }
539
+ rootVnode.$tag$ = null;
540
+ rootVnode.$flags$ |= 4 /* isHost */;
541
+ hostRef.$vnode$ = rootVnode;
542
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
543
+ {
544
+ scopeId = hostElm['s-sc'];
545
+ }
546
+ // synchronous patch
547
+ patch(oldVNode, rootVnode);
548
+ };
549
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
550
+ const createEvent = (ref, name, flags) => {
551
+ const elm = getElement(ref);
552
+ return {
553
+ emit: (detail) => {
554
+ return emitEvent(elm, name, {
555
+ bubbles: !!(flags & 4 /* Bubbles */),
556
+ composed: !!(flags & 2 /* Composed */),
557
+ cancelable: !!(flags & 1 /* Cancellable */),
558
+ detail,
559
+ });
560
+ },
561
+ };
562
+ };
563
+ /**
564
+ * Helper function to create & dispatch a custom Event on a provided target
565
+ * @param elm the target of the Event
566
+ * @param name the name to give the custom Event
567
+ * @param opts options for configuring a custom Event
568
+ * @returns the custom Event
569
+ */
570
+ const emitEvent = (elm, name, opts) => {
571
+ const ev = plt.ce(name, opts);
572
+ elm.dispatchEvent(ev);
573
+ return ev;
574
+ };
575
+ const attachToAncestor = (hostRef, ancestorComponent) => {
576
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
577
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
578
+ }
579
+ };
580
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
581
+ {
582
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
583
+ }
584
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
585
+ hostRef.$flags$ |= 512 /* needsRerender */;
586
+ return;
587
+ }
588
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
589
+ // there is no ancestor component or the ancestor component
590
+ // has already fired off its lifecycle update then
591
+ // fire off the initial update
592
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
593
+ return writeTask(dispatch) ;
594
+ };
595
+ const dispatchHooks = (hostRef, isInitialLoad) => {
596
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
597
+ const instance = hostRef.$lazyInstance$ ;
598
+ let promise;
599
+ endSchedule();
600
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
601
+ };
602
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
603
+ // updateComponent
604
+ const elm = hostRef.$hostElement$;
605
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
606
+ const rc = elm['s-rc'];
607
+ if (isInitialLoad) {
608
+ // DOM WRITE!
609
+ attachStyles(hostRef);
610
+ }
611
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
612
+ {
613
+ callRender(hostRef, instance);
614
+ }
615
+ if (rc) {
616
+ // ok, so turns out there are some child host elements
617
+ // waiting on this parent element to load
618
+ // let's fire off all update callbacks waiting
619
+ rc.map((cb) => cb());
620
+ elm['s-rc'] = undefined;
621
+ }
622
+ endRender();
623
+ endUpdate();
624
+ {
625
+ const childrenPromises = elm['s-p'];
626
+ const postUpdate = () => postUpdateComponent(hostRef);
627
+ if (childrenPromises.length === 0) {
628
+ postUpdate();
629
+ }
630
+ else {
631
+ Promise.all(childrenPromises).then(postUpdate);
632
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
633
+ childrenPromises.length = 0;
634
+ }
635
+ }
636
+ };
637
+ const callRender = (hostRef, instance, elm) => {
638
+ try {
639
+ instance = instance.render() ;
640
+ {
641
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
642
+ }
643
+ {
644
+ hostRef.$flags$ |= 2 /* hasRendered */;
645
+ }
646
+ {
647
+ {
648
+ // looks like we've got child nodes to render into this host element
649
+ // or we need to update the css class/attrs on the host element
650
+ // DOM WRITE!
651
+ {
652
+ renderVdom(hostRef, instance);
653
+ }
654
+ }
655
+ }
656
+ }
657
+ catch (e) {
658
+ consoleError(e, hostRef.$hostElement$);
659
+ }
660
+ return null;
661
+ };
662
+ const postUpdateComponent = (hostRef) => {
663
+ const tagName = hostRef.$cmpMeta$.$tagName$;
664
+ const elm = hostRef.$hostElement$;
665
+ const endPostUpdate = createTime('postUpdate', tagName);
666
+ const instance = hostRef.$lazyInstance$ ;
667
+ const ancestorComponent = hostRef.$ancestorComponent$;
668
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
669
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
670
+ {
671
+ // DOM WRITE!
672
+ addHydratedFlag(elm);
673
+ }
674
+ {
675
+ safeCall(instance, 'componentDidLoad');
676
+ }
677
+ endPostUpdate();
678
+ {
679
+ hostRef.$onReadyResolve$(elm);
680
+ if (!ancestorComponent) {
681
+ appDidLoad();
682
+ }
683
+ }
684
+ }
685
+ else {
686
+ endPostUpdate();
687
+ }
688
+ // load events fire from bottom to top
689
+ // the deepest elements load first then bubbles up
690
+ {
691
+ if (hostRef.$onRenderResolve$) {
692
+ hostRef.$onRenderResolve$();
693
+ hostRef.$onRenderResolve$ = undefined;
694
+ }
695
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
696
+ nextTick(() => scheduleUpdate(hostRef, false));
697
+ }
698
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
699
+ }
700
+ // ( •_•)
701
+ // ( •_•)>⌐■-■
702
+ // (⌐■_■)
703
+ };
704
+ const appDidLoad = (who) => {
705
+ // on appload
706
+ // we have finish the first big initial render
707
+ {
708
+ addHydratedFlag(doc.documentElement);
709
+ }
710
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
711
+ };
712
+ const safeCall = (instance, method, arg) => {
713
+ if (instance && instance[method]) {
714
+ try {
715
+ return instance[method](arg);
716
+ }
717
+ catch (e) {
718
+ consoleError(e);
719
+ }
720
+ }
721
+ return undefined;
722
+ };
723
+ const then = (promise, thenFn) => {
724
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
725
+ };
726
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
727
+ ;
728
+ /**
729
+ * Parse a new property value for a given property type.
730
+ *
731
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
732
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
733
+ * 1. `any`, the type given to `propValue` in the function signature
734
+ * 2. the type stored from `propType`.
735
+ *
736
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
737
+ *
738
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
739
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
740
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
741
+ * ```tsx
742
+ * <my-cmp prop-val={0}></my-cmp>
743
+ * ```
744
+ *
745
+ * HTML prop values on the other hand, will always a string
746
+ *
747
+ * @param propValue the new value to coerce to some type
748
+ * @param propType the type of the prop, expressed as a binary number
749
+ * @returns the parsed/coerced value
750
+ */
751
+ const parsePropertyValue = (propValue, propType) => {
752
+ // ensure this value is of the correct prop type
753
+ if (propValue != null && !isComplexType(propValue)) {
754
+ if (propType & 2 /* Number */) {
755
+ // force it to be a number
756
+ return parseFloat(propValue);
757
+ }
758
+ // redundant return here for better minification
759
+ return propValue;
760
+ }
761
+ // not sure exactly what type we want
762
+ // so no need to change to a different type
763
+ return propValue;
764
+ };
765
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
766
+ const setValue = (ref, propName, newVal, cmpMeta) => {
767
+ // check our new property value against our internal value
768
+ const hostRef = getHostRef(ref);
769
+ const oldVal = hostRef.$instanceValues$.get(propName);
770
+ const flags = hostRef.$flags$;
771
+ const instance = hostRef.$lazyInstance$ ;
772
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
773
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
774
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
775
+ const didValueChange = newVal !== oldVal && !areBothNaN;
776
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
777
+ // gadzooks! the property's value has changed!!
778
+ // set our new value!
779
+ hostRef.$instanceValues$.set(propName, newVal);
780
+ if (instance) {
781
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
782
+ // looks like this value actually changed, so we've got work to do!
783
+ // but only if we've already rendered, otherwise just chill out
784
+ // queue that we need to do an update, but don't worry about queuing
785
+ // up millions cuz this function ensures it only runs once
786
+ scheduleUpdate(hostRef, false);
787
+ }
788
+ }
789
+ }
790
+ };
791
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
792
+ if (cmpMeta.$members$) {
793
+ // It's better to have a const than two Object.entries()
794
+ const members = Object.entries(cmpMeta.$members$);
795
+ const prototype = Cstr.prototype;
796
+ members.map(([memberName, [memberFlags]]) => {
797
+ if ((memberFlags & 31 /* Prop */ ||
798
+ ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
799
+ // proxyComponent - prop
800
+ Object.defineProperty(prototype, memberName, {
801
+ get() {
802
+ // proxyComponent, get value
803
+ return getValue(this, memberName);
804
+ },
805
+ set(newValue) {
806
+ // proxyComponent, set value
807
+ setValue(this, memberName, newValue, cmpMeta);
808
+ },
809
+ configurable: true,
810
+ enumerable: true,
811
+ });
812
+ }
813
+ });
814
+ if ((flags & 1 /* isElementConstructor */)) {
815
+ const attrNameToPropName = new Map();
816
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
817
+ plt.jmp(() => {
818
+ const propName = attrNameToPropName.get(attrName);
819
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
820
+ // in the case where an attribute was set inline.
821
+ // ```html
822
+ // <my-component some-attribute="some-value"></my-component>
823
+ // ```
824
+ //
825
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
826
+ // programmatically changes it before it has been upgraded as shown below:
827
+ //
828
+ // ```html
829
+ // <!-- this component has _not_ been upgraded yet -->
830
+ // <my-component id="test" some-attribute="some-value"></my-component>
831
+ // <script>
832
+ // // grab non-upgraded component
833
+ // el = document.querySelector("#test");
834
+ // el.someAttribute = "another-value";
835
+ // // upgrade component
836
+ // customElements.define('my-component', MyComponent);
837
+ // </script>
838
+ // ```
839
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
840
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
841
+ // to the value that was set inline i.e. "some-value" from above example. When
842
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
843
+ //
844
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
845
+ // by connectedCallback as this attributeChangedCallback will not fire.
846
+ //
847
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
848
+ //
849
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
850
+ // properties here given that this goes against best practices outlined here
851
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
852
+ if (this.hasOwnProperty(propName)) {
853
+ newValue = this[propName];
854
+ delete this[propName];
855
+ }
856
+ else if (prototype.hasOwnProperty(propName) &&
857
+ typeof this[propName] === 'number' &&
858
+ this[propName] == newValue) {
859
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
860
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
861
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
862
+ return;
863
+ }
864
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
865
+ });
866
+ };
867
+ // create an array of attributes to observe
868
+ // and also create a map of html attribute name to js property name
869
+ Cstr.observedAttributes = members
870
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
871
+ .map(([propName, m]) => {
872
+ const attrName = m[1] || propName;
873
+ attrNameToPropName.set(attrName, propName);
874
+ if (m[0] & 512 /* ReflectAttr */) {
875
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
876
+ }
877
+ return attrName;
878
+ });
879
+ }
880
+ }
881
+ return Cstr;
882
+ };
883
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
884
+ // initializeComponent
885
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
886
+ {
887
+ // we haven't initialized this element yet
888
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
889
+ // lazy loaded components
890
+ // request the component's implementation to be
891
+ // wired up with the host element
892
+ Cstr = loadModule(cmpMeta);
893
+ if (Cstr.then) {
894
+ // Await creates a micro-task avoid if possible
895
+ const endLoad = uniqueTime();
896
+ Cstr = await Cstr;
897
+ endLoad();
898
+ }
899
+ if (!Cstr.isProxied) {
900
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
901
+ Cstr.isProxied = true;
902
+ }
903
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
904
+ // ok, time to construct the instance
905
+ // but let's keep track of when we start and stop
906
+ // so that the getters/setters don't incorrectly step on data
907
+ {
908
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
909
+ }
910
+ // construct the lazy-loaded component implementation
911
+ // passing the hostRef is very important during
912
+ // construction in order to directly wire together the
913
+ // host element and the lazy-loaded instance
914
+ try {
915
+ new Cstr(hostRef);
916
+ }
917
+ catch (e) {
918
+ consoleError(e);
919
+ }
920
+ {
921
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
922
+ }
923
+ endNewInstance();
924
+ }
925
+ if (Cstr.style) {
926
+ // this component has styles but we haven't registered them yet
927
+ let style = Cstr.style;
928
+ const scopeId = getScopeId(cmpMeta);
929
+ if (!styles.has(scopeId)) {
930
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
931
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
932
+ endRegisterStyles();
933
+ }
934
+ }
935
+ }
936
+ // we've successfully created a lazy instance
937
+ const ancestorComponent = hostRef.$ancestorComponent$;
938
+ const schedule = () => scheduleUpdate(hostRef, true);
939
+ if (ancestorComponent && ancestorComponent['s-rc']) {
940
+ // this is the initial load and this component it has an ancestor component
941
+ // but the ancestor component has NOT fired its will update lifecycle yet
942
+ // so let's just cool our jets and wait for the ancestor to continue first
943
+ // this will get fired off when the ancestor component
944
+ // finally gets around to rendering its lazy self
945
+ // fire off the initial update
946
+ ancestorComponent['s-rc'].push(schedule);
947
+ }
948
+ else {
949
+ schedule();
950
+ }
951
+ };
952
+ const connectedCallback = (elm) => {
953
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
954
+ const hostRef = getHostRef(elm);
955
+ const cmpMeta = hostRef.$cmpMeta$;
956
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
957
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
958
+ // first time this component has connected
959
+ hostRef.$flags$ |= 1 /* hasConnected */;
960
+ {
961
+ // find the first ancestor component (if there is one) and register
962
+ // this component as one of the actively loading child components for its ancestor
963
+ let ancestorComponent = elm;
964
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
965
+ // climb up the ancestors looking for the first
966
+ // component that hasn't finished its lifecycle update yet
967
+ if (ancestorComponent['s-p']) {
968
+ // we found this components first ancestor component
969
+ // keep a reference to this component's ancestor component
970
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
971
+ break;
972
+ }
973
+ }
974
+ }
975
+ // Lazy properties
976
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
977
+ if (cmpMeta.$members$) {
978
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
979
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
980
+ const value = elm[memberName];
981
+ delete elm[memberName];
982
+ elm[memberName] = value;
983
+ }
984
+ });
985
+ }
986
+ {
987
+ initializeComponent(elm, hostRef, cmpMeta);
988
+ }
989
+ }
990
+ endConnected();
991
+ }
992
+ };
993
+ const disconnectedCallback = (elm) => {
994
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
995
+ getHostRef(elm);
996
+ }
997
+ };
998
+ const bootstrapLazy = (lazyBundles, options = {}) => {
999
+ const endBootstrap = createTime();
1000
+ const cmpTags = [];
1001
+ const exclude = options.exclude || [];
1002
+ const customElements = win.customElements;
1003
+ const head = doc.head;
1004
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1005
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1006
+ const deferredConnectedCallbacks = [];
1007
+ let appLoadFallback;
1008
+ let isBootstrapping = true;
1009
+ Object.assign(plt, options);
1010
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1011
+ lazyBundles.map((lazyBundle) => {
1012
+ lazyBundle[1].map((compactMeta) => {
1013
+ const cmpMeta = {
1014
+ $flags$: compactMeta[0],
1015
+ $tagName$: compactMeta[1],
1016
+ $members$: compactMeta[2],
1017
+ $listeners$: compactMeta[3],
1018
+ };
1019
+ {
1020
+ cmpMeta.$members$ = compactMeta[2];
1021
+ }
1022
+ {
1023
+ cmpMeta.$attrsToReflect$ = [];
1024
+ }
1025
+ const tagName = cmpMeta.$tagName$;
1026
+ const HostElement = class extends HTMLElement {
1027
+ // StencilLazyHost
1028
+ constructor(self) {
1029
+ // @ts-ignore
1030
+ super(self);
1031
+ self = this;
1032
+ registerHost(self, cmpMeta);
1033
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1034
+ // this component is using shadow dom
1035
+ // and this browser supports shadow dom
1036
+ // add the read-only property "shadowRoot" to the host element
1037
+ // adding the shadow root build conditionals to minimize runtime
1038
+ {
1039
+ {
1040
+ self.attachShadow({ mode: 'open' });
1041
+ }
1042
+ }
1043
+ }
1044
+ }
1045
+ connectedCallback() {
1046
+ if (appLoadFallback) {
1047
+ clearTimeout(appLoadFallback);
1048
+ appLoadFallback = null;
1049
+ }
1050
+ if (isBootstrapping) {
1051
+ // connectedCallback will be processed once all components have been registered
1052
+ deferredConnectedCallbacks.push(this);
1053
+ }
1054
+ else {
1055
+ plt.jmp(() => connectedCallback(this));
1056
+ }
1057
+ }
1058
+ disconnectedCallback() {
1059
+ plt.jmp(() => disconnectedCallback(this));
1060
+ }
1061
+ componentOnReady() {
1062
+ return getHostRef(this).$onReadyPromise$;
1063
+ }
1064
+ };
1065
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1066
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1067
+ cmpTags.push(tagName);
1068
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1069
+ }
1070
+ });
1071
+ });
1072
+ {
1073
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1074
+ visibilityStyle.setAttribute('data-styles', '');
1075
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1076
+ }
1077
+ // Process deferred connectedCallbacks now all components have been registered
1078
+ isBootstrapping = false;
1079
+ if (deferredConnectedCallbacks.length) {
1080
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1081
+ }
1082
+ else {
1083
+ {
1084
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1085
+ }
1086
+ }
1087
+ // Fallback appLoad event
1088
+ endBootstrap();
1089
+ };
1090
+ const hostRefs = new WeakMap();
1091
+ const getHostRef = (ref) => hostRefs.get(ref);
1092
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1093
+ const registerHost = (elm, cmpMeta) => {
1094
+ const hostRef = {
1095
+ $flags$: 0,
1096
+ $hostElement$: elm,
1097
+ $cmpMeta$: cmpMeta,
1098
+ $instanceValues$: new Map(),
1099
+ };
1100
+ {
1101
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1102
+ elm['s-p'] = [];
1103
+ elm['s-rc'] = [];
1104
+ }
1105
+ return hostRefs.set(elm, hostRef);
1106
+ };
1107
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1108
+ const consoleError = (e, el) => (0, console.error)(e, el);
1109
+ const cmpModules = /*@__PURE__*/ new Map();
1110
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1111
+ // loadModuleImport
1112
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1113
+ const bundleId = cmpMeta.$lazyBundleId$;
1114
+ const module = cmpModules.get(bundleId) ;
1115
+ if (module) {
1116
+ return module[exportName];
1117
+ }
1118
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1119
+ return import(
1120
+ /* @vite-ignore */
1121
+ /* webpackInclude: /\.entry\.js$/ */
1122
+ /* webpackExclude: /\.system\.entry\.js$/ */
1123
+ /* webpackMode: "lazy" */
1124
+ `./${bundleId}.entry.js${''}`).then((importedModule) => {
1125
+ {
1126
+ cmpModules.set(bundleId, importedModule);
1127
+ }
1128
+ return importedModule[exportName];
1129
+ }, consoleError);
1130
+ };
1131
+ const styles = new Map();
1132
+ const queueDomReads = [];
1133
+ const queueDomWrites = [];
1134
+ const queueTask = (queue, write) => (cb) => {
1135
+ queue.push(cb);
1136
+ if (!queuePending) {
1137
+ queuePending = true;
1138
+ if (write && plt.$flags$ & 4 /* queueSync */) {
1139
+ nextTick(flush);
1140
+ }
1141
+ else {
1142
+ plt.raf(flush);
1143
+ }
1144
+ }
1145
+ };
1146
+ const consume = (queue) => {
1147
+ for (let i = 0; i < queue.length; i++) {
1148
+ try {
1149
+ queue[i](performance.now());
1150
+ }
1151
+ catch (e) {
1152
+ consoleError(e);
1153
+ }
1154
+ }
1155
+ queue.length = 0;
1156
+ };
1157
+ const flush = () => {
1158
+ // always force a bunch of medium callbacks to run, but still have
1159
+ // a throttle on how many can run in a certain time
1160
+ // DOM READS!!!
1161
+ consume(queueDomReads);
1162
+ // DOM WRITES!!!
1163
+ {
1164
+ consume(queueDomWrites);
1165
+ if ((queuePending = queueDomReads.length > 0)) {
1166
+ // still more to do yet, but we've run out of time
1167
+ // let's let this thing cool off and try again in the next tick
1168
+ plt.raf(flush);
1169
+ }
1170
+ }
1171
+ };
1172
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1173
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1174
+
1175
+ export { Host as H, bootstrapLazy as b, createEvent as c, getElement as g, h, promiseResolve as p, registerInstance as r };