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