@geotrekce/geotrek-rando-widget 0.0.1

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