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