@ptcwebops/ptcw-design 0.0.2 → 0.0.4

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 (93) hide show
  1. package/LICENSE +21 -21
  2. package/dist/cjs/icon-asset_4.cjs.entry.js +165 -0
  3. package/dist/cjs/index-825cf1b6.js +1454 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +21 -0
  6. package/dist/cjs/ptc-card.cjs.entry.js +19 -0
  7. package/dist/cjs/ptc-image.cjs.entry.js +62 -0
  8. package/dist/cjs/ptc-link.cjs.entry.js +43 -0
  9. package/dist/cjs/ptc-list.cjs.entry.js +19 -0
  10. package/dist/cjs/ptcw-design.cjs.js +19 -0
  11. package/dist/collection/collection-manifest.json +19 -0
  12. package/dist/collection/components/icon-asset/assets/brands.svg +1381 -0
  13. package/dist/collection/components/icon-asset/assets/regular.svg +463 -0
  14. package/dist/collection/components/icon-asset/assets/solid.svg +3013 -0
  15. package/dist/collection/components/icon-asset/assets/svg-with-js.min.css +5 -0
  16. package/dist/collection/components/icon-asset/icon-asset.css +22 -0
  17. package/dist/collection/components/icon-asset/icon-asset.js +168 -0
  18. package/dist/collection/components/my-component/my-component.css +3 -0
  19. package/dist/collection/components/my-component/my-component.js +74 -0
  20. package/dist/collection/components/ptc-button/ptc-button.css +177 -0
  21. package/dist/collection/components/ptc-button/ptc-button.js +155 -0
  22. package/dist/collection/components/ptc-card/ptc-card.css +3 -0
  23. package/dist/collection/components/ptc-card/ptc-card.js +34 -0
  24. package/dist/collection/components/ptc-image/ptc-image.css +3 -0
  25. package/dist/collection/components/ptc-image/ptc-image.js +96 -0
  26. package/dist/collection/components/ptc-link/ptc-link.css +48 -0
  27. package/dist/collection/components/ptc-link/ptc-link.js +166 -0
  28. package/dist/collection/components/ptc-list/ptc-list.css +3 -0
  29. package/dist/collection/components/ptc-list/ptc-list.js +15 -0
  30. package/dist/collection/components/ptc-title/ptc-title.css +64 -0
  31. package/dist/collection/components/ptc-title/ptc-title.js +105 -0
  32. package/dist/collection/index.js +1 -0
  33. package/dist/collection/utils/interfaces.js +1 -0
  34. package/dist/collection/utils/utils.js +3 -0
  35. package/dist/custom-elements/index.d.ts +30 -0
  36. package/dist/custom-elements/index.js +315 -0
  37. package/dist/esm/icon-asset_4.entry.js +158 -0
  38. package/dist/esm/index-4bbf8fa5.js +1426 -0
  39. package/dist/esm/index.js +1 -0
  40. package/dist/esm/loader.js +17 -0
  41. package/dist/esm/polyfills/core-js.js +11 -0
  42. package/dist/esm/polyfills/css-shim.js +1 -0
  43. package/dist/esm/polyfills/dom.js +79 -0
  44. package/dist/esm/polyfills/es5-html-element.js +1 -0
  45. package/dist/esm/polyfills/index.js +34 -0
  46. package/dist/esm/polyfills/system.js +6 -0
  47. package/dist/{ptcw-design → esm}/ptc-card.entry.js +9 -9
  48. package/dist/esm/ptc-image.entry.js +58 -0
  49. package/dist/esm/ptc-link.entry.js +39 -0
  50. package/dist/esm/ptc-list.entry.js +15 -0
  51. package/dist/esm/ptcw-design.js +17 -0
  52. package/dist/index.cjs.js +1 -0
  53. package/dist/index.js +1 -0
  54. package/dist/ptcw-design/assets/brands.svg +1381 -0
  55. package/dist/ptcw-design/assets/regular.svg +463 -0
  56. package/dist/ptcw-design/assets/solid.svg +3013 -0
  57. package/dist/ptcw-design/assets/svg-with-js.min.css +5 -0
  58. package/dist/ptcw-design/index.esm.js +0 -1
  59. package/dist/ptcw-design/p-0492a377.entry.js +1 -0
  60. package/dist/ptcw-design/p-9aef6d0e.entry.js +1 -0
  61. package/dist/ptcw-design/p-bd9fac27.entry.js +1 -0
  62. package/dist/ptcw-design/p-d855d70c.js +1 -0
  63. package/dist/ptcw-design/p-e33cba65.entry.js +1 -0
  64. package/dist/ptcw-design/p-e899eb48.entry.js +1 -0
  65. package/dist/ptcw-design/ptcw-design.css +2 -296
  66. package/dist/ptcw-design/ptcw-design.esm.js +1 -122
  67. package/dist/types/components/icon-asset/icon-asset.d.ts +31 -0
  68. package/dist/types/components/my-component/my-component.d.ts +16 -16
  69. package/dist/types/components/ptc-button/ptc-button.d.ts +28 -24
  70. package/dist/types/components/ptc-card/ptc-card.d.ts +7 -7
  71. package/dist/types/components/ptc-image/ptc-image.d.ts +18 -0
  72. package/dist/types/components/ptc-link/ptc-link.d.ts +32 -0
  73. package/dist/types/components/ptc-list/ptc-list.d.ts +3 -0
  74. package/dist/types/components/ptc-title/ptc-title.d.ts +16 -0
  75. package/dist/types/components.d.ts +217 -0
  76. package/dist/types/index.d.ts +1 -1
  77. package/dist/types/utils/interfaces.d.ts +3 -3
  78. package/dist/types/utils/utils.d.ts +1 -1
  79. package/loader/cdn.js +3 -0
  80. package/loader/index.cjs.js +3 -0
  81. package/loader/index.d.ts +13 -0
  82. package/loader/index.es2017.js +3 -0
  83. package/loader/index.js +4 -0
  84. package/loader/package.json +10 -0
  85. package/package.json +1 -1
  86. package/readme.md +11 -11
  87. package/dist/ptcw-design/app-globals-0f993ce5.js +0 -3
  88. package/dist/ptcw-design/css-shim-003e9264.js +0 -4
  89. package/dist/ptcw-design/dom-1b195079.js +0 -73
  90. package/dist/ptcw-design/index-ca91e691.js +0 -2832
  91. package/dist/ptcw-design/my-component.entry.js +0 -22
  92. package/dist/ptcw-design/ptc-button.entry.js +0 -39
  93. package/dist/ptcw-design/shadow-css-c1ad5fdc.js +0 -383
@@ -0,0 +1,1426 @@
1
+ const NAMESPACE = 'ptcw-design';
2
+
3
+ let scopeId;
4
+ let contentRef;
5
+ let hostTagName;
6
+ let useNativeShadowDom = false;
7
+ let checkSlotFallbackVisibility = false;
8
+ let checkSlotRelocate = false;
9
+ let isSvgMode = false;
10
+ let queuePending = false;
11
+ const win = typeof window !== 'undefined' ? window : {};
12
+ const doc = win.document || { head: {} };
13
+ const plt = {
14
+ $flags$: 0,
15
+ $resourcesUrl$: '',
16
+ jmp: h => h(),
17
+ raf: h => requestAnimationFrame(h),
18
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
19
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
20
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
21
+ };
22
+ const promiseResolve = (v) => Promise.resolve(v);
23
+ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
24
+ try {
25
+ new CSSStyleSheet();
26
+ return typeof (new CSSStyleSheet()).replace === 'function';
27
+ }
28
+ catch (e) { }
29
+ return false;
30
+ })()
31
+ ;
32
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
33
+ const createTime = (fnName, tagName = '') => {
34
+ {
35
+ return () => {
36
+ return;
37
+ };
38
+ }
39
+ };
40
+ const uniqueTime = (key, measureText) => {
41
+ {
42
+ return () => {
43
+ return;
44
+ };
45
+ }
46
+ };
47
+ const rootAppliedStyles = new WeakMap();
48
+ const registerStyle = (scopeId, cssText, allowCS) => {
49
+ let style = styles.get(scopeId);
50
+ if (supportsConstructibleStylesheets && allowCS) {
51
+ style = (style || new CSSStyleSheet());
52
+ style.replace(cssText);
53
+ }
54
+ else {
55
+ style = cssText;
56
+ }
57
+ styles.set(scopeId, style);
58
+ };
59
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
60
+ let scopeId = getScopeId(cmpMeta);
61
+ let style = styles.get(scopeId);
62
+ // if an element is NOT connected then getRootNode() will return the wrong root node
63
+ // so the fallback is to always use the document for the root node in those cases
64
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
65
+ if (style) {
66
+ if (typeof style === 'string') {
67
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
68
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
69
+ let styleElm;
70
+ if (!appliedStyles) {
71
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
72
+ }
73
+ if (!appliedStyles.has(scopeId)) {
74
+ {
75
+ {
76
+ styleElm = doc.createElement('style');
77
+ styleElm.innerHTML = style;
78
+ }
79
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
80
+ }
81
+ if (appliedStyles) {
82
+ appliedStyles.add(scopeId);
83
+ }
84
+ }
85
+ }
86
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
87
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
88
+ }
89
+ }
90
+ return scopeId;
91
+ };
92
+ const attachStyles = (hostRef) => {
93
+ const cmpMeta = hostRef.$cmpMeta$;
94
+ const elm = hostRef.$hostElement$;
95
+ const flags = cmpMeta.$flags$;
96
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
97
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
98
+ if (flags & 10 /* needsScopedEncapsulation */) {
99
+ // only required when we're NOT using native shadow dom (slot)
100
+ // or this browser doesn't support native shadow dom
101
+ // and this host element was NOT created with SSR
102
+ // let's pick out the inner content for slot projection
103
+ // create a node to represent where the original
104
+ // content was first placed, which is useful later on
105
+ // DOM WRITE!!
106
+ elm['s-sc'] = scopeId;
107
+ elm.classList.add(scopeId + '-h');
108
+ }
109
+ endAttachStyles();
110
+ };
111
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
112
+ /**
113
+ * Default style mode id
114
+ */
115
+ /**
116
+ * Reusable empty obj/array
117
+ * Don't add values to these!!
118
+ */
119
+ const EMPTY_OBJ = {};
120
+ /**
121
+ * Namespaces
122
+ */
123
+ const SVG_NS = 'http://www.w3.org/2000/svg';
124
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
125
+ const isDef = (v) => v != null;
126
+ const isComplexType = (o) => {
127
+ // https://jsperf.com/typeof-fn-object/5
128
+ o = typeof o;
129
+ return o === 'object' || o === 'function';
130
+ };
131
+ /**
132
+ * Production h() function based on Preact by
133
+ * Jason Miller (@developit)
134
+ * Licensed under the MIT License
135
+ * https://github.com/developit/preact/blob/master/LICENSE
136
+ *
137
+ * Modified for Stencil's compiler and vdom
138
+ */
139
+ // const stack: any[] = [];
140
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
141
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
142
+ const h = (nodeName, vnodeData, ...children) => {
143
+ let child = null;
144
+ let slotName = null;
145
+ let simple = false;
146
+ let lastSimple = false;
147
+ let vNodeChildren = [];
148
+ const walk = (c) => {
149
+ for (let i = 0; i < c.length; i++) {
150
+ child = c[i];
151
+ if (Array.isArray(child)) {
152
+ walk(child);
153
+ }
154
+ else if (child != null && typeof child !== 'boolean') {
155
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
156
+ child = String(child);
157
+ }
158
+ if (simple && lastSimple) {
159
+ // If the previous child was simple (string), we merge both
160
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
161
+ }
162
+ else {
163
+ // Append a new vNode, if it's text, we create a text vNode
164
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
165
+ }
166
+ lastSimple = simple;
167
+ }
168
+ }
169
+ };
170
+ walk(children);
171
+ if (vnodeData) {
172
+ if (vnodeData.name) {
173
+ slotName = vnodeData.name;
174
+ }
175
+ {
176
+ const classData = vnodeData.className || vnodeData.class;
177
+ if (classData) {
178
+ vnodeData.class =
179
+ typeof classData !== 'object'
180
+ ? classData
181
+ : Object.keys(classData)
182
+ .filter(k => classData[k])
183
+ .join(' ');
184
+ }
185
+ }
186
+ }
187
+ if (typeof nodeName === 'function') {
188
+ // nodeName is a functional component
189
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
190
+ }
191
+ const vnode = newVNode(nodeName, null);
192
+ vnode.$attrs$ = vnodeData;
193
+ if (vNodeChildren.length > 0) {
194
+ vnode.$children$ = vNodeChildren;
195
+ }
196
+ {
197
+ vnode.$name$ = slotName;
198
+ }
199
+ return vnode;
200
+ };
201
+ const newVNode = (tag, text) => {
202
+ const vnode = {
203
+ $flags$: 0,
204
+ $tag$: tag,
205
+ $text$: text,
206
+ $elm$: null,
207
+ $children$: null,
208
+ };
209
+ {
210
+ vnode.$attrs$ = null;
211
+ }
212
+ {
213
+ vnode.$name$ = null;
214
+ }
215
+ return vnode;
216
+ };
217
+ const Host = {};
218
+ const isHost = (node) => node && node.$tag$ === Host;
219
+ const vdomFnUtils = {
220
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
221
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
222
+ };
223
+ const convertToPublic = (node) => ({
224
+ vattrs: node.$attrs$,
225
+ vchildren: node.$children$,
226
+ vkey: node.$key$,
227
+ vname: node.$name$,
228
+ vtag: node.$tag$,
229
+ vtext: node.$text$,
230
+ });
231
+ const convertToPrivate = (node) => {
232
+ if (typeof node.vtag === 'function') {
233
+ const vnodeData = Object.assign({}, node.vattrs);
234
+ if (node.vkey) {
235
+ vnodeData.key = node.vkey;
236
+ }
237
+ if (node.vname) {
238
+ vnodeData.name = node.vname;
239
+ }
240
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
241
+ }
242
+ const vnode = newVNode(node.vtag, node.vtext);
243
+ vnode.$attrs$ = node.vattrs;
244
+ vnode.$children$ = node.vchildren;
245
+ vnode.$key$ = node.vkey;
246
+ vnode.$name$ = node.vname;
247
+ return vnode;
248
+ };
249
+ /**
250
+ * Production setAccessor() function based on Preact by
251
+ * Jason Miller (@developit)
252
+ * Licensed under the MIT License
253
+ * https://github.com/developit/preact/blob/master/LICENSE
254
+ *
255
+ * Modified for Stencil's compiler and vdom
256
+ */
257
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
258
+ if (oldValue !== newValue) {
259
+ let isProp = isMemberInElement(elm, memberName);
260
+ memberName.toLowerCase();
261
+ if (memberName === 'class') {
262
+ const classList = elm.classList;
263
+ const oldClasses = parseClassList(oldValue);
264
+ const newClasses = parseClassList(newValue);
265
+ classList.remove(...oldClasses.filter(c => c && !newClasses.includes(c)));
266
+ classList.add(...newClasses.filter(c => c && !oldClasses.includes(c)));
267
+ }
268
+ else {
269
+ // Set property if it exists and it's not a SVG
270
+ const isComplex = isComplexType(newValue);
271
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
272
+ try {
273
+ if (!elm.tagName.includes('-')) {
274
+ let n = newValue == null ? '' : newValue;
275
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
276
+ if (memberName === 'list') {
277
+ isProp = false;
278
+ // tslint:disable-next-line: triple-equals
279
+ }
280
+ else if (oldValue == null || elm[memberName] != n) {
281
+ elm[memberName] = n;
282
+ }
283
+ }
284
+ else {
285
+ elm[memberName] = newValue;
286
+ }
287
+ }
288
+ catch (e) { }
289
+ }
290
+ if (newValue == null || newValue === false) {
291
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
292
+ {
293
+ elm.removeAttribute(memberName);
294
+ }
295
+ }
296
+ }
297
+ else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
298
+ newValue = newValue === true ? '' : newValue;
299
+ {
300
+ elm.setAttribute(memberName, newValue);
301
+ }
302
+ }
303
+ }
304
+ }
305
+ };
306
+ const parseClassListRegex = /\s/;
307
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
308
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
309
+ // if the element passed in is a shadow root, which is a document fragment
310
+ // then we want to be adding attrs/props to the shadow root's "host" element
311
+ // if it's not a shadow root, then we add attrs/props to the same element
312
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
313
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
314
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
315
+ {
316
+ // remove attributes no longer present on the vnode by setting them to undefined
317
+ for (memberName in oldVnodeAttrs) {
318
+ if (!(memberName in newVnodeAttrs)) {
319
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
320
+ }
321
+ }
322
+ }
323
+ // add new & update changed attributes
324
+ for (memberName in newVnodeAttrs) {
325
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
326
+ }
327
+ };
328
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
329
+ // tslint:disable-next-line: prefer-const
330
+ let newVNode = newParentVNode.$children$[childIndex];
331
+ let i = 0;
332
+ let elm;
333
+ let childNode;
334
+ let oldVNode;
335
+ if (!useNativeShadowDom) {
336
+ // remember for later we need to check to relocate nodes
337
+ checkSlotRelocate = true;
338
+ if (newVNode.$tag$ === 'slot') {
339
+ if (scopeId) {
340
+ // scoped css needs to add its scoped id to the parent element
341
+ parentElm.classList.add(scopeId + '-s');
342
+ }
343
+ newVNode.$flags$ |= newVNode.$children$
344
+ ? // slot element has fallback content
345
+ 2 /* isSlotFallback */
346
+ : // slot element does not have fallback content
347
+ 1 /* isSlotReference */;
348
+ }
349
+ }
350
+ if (newVNode.$text$ !== null) {
351
+ // create text node
352
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
353
+ }
354
+ else if (newVNode.$flags$ & 1 /* isSlotReference */) {
355
+ // create a slot reference node
356
+ elm = newVNode.$elm$ = doc.createTextNode('');
357
+ }
358
+ else {
359
+ if (!isSvgMode) {
360
+ isSvgMode = newVNode.$tag$ === 'svg';
361
+ }
362
+ // create element
363
+ elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* isSlotFallback */ ? 'slot-fb' : newVNode.$tag$)
364
+ );
365
+ if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
366
+ isSvgMode = false;
367
+ }
368
+ // add css classes, attrs, props, listeners, etc.
369
+ {
370
+ updateElement(null, newVNode, isSvgMode);
371
+ }
372
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
373
+ // if there is a scopeId and this is the initial render
374
+ // then let's add the scopeId as a css class
375
+ elm.classList.add((elm['s-si'] = scopeId));
376
+ }
377
+ if (newVNode.$children$) {
378
+ for (i = 0; i < newVNode.$children$.length; ++i) {
379
+ // create the node
380
+ childNode = createElm(oldParentVNode, newVNode, i, elm);
381
+ // return node could have been null
382
+ if (childNode) {
383
+ // append our new node
384
+ elm.appendChild(childNode);
385
+ }
386
+ }
387
+ }
388
+ {
389
+ if (newVNode.$tag$ === 'svg') {
390
+ // Only reset the SVG context when we're exiting <svg> element
391
+ isSvgMode = false;
392
+ }
393
+ else if (elm.tagName === 'foreignObject') {
394
+ // Reenter SVG context when we're exiting <foreignObject> element
395
+ isSvgMode = true;
396
+ }
397
+ }
398
+ }
399
+ {
400
+ elm['s-hn'] = hostTagName;
401
+ if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
402
+ // remember the content reference comment
403
+ elm['s-sr'] = true;
404
+ // remember the content reference comment
405
+ elm['s-cr'] = contentRef;
406
+ // remember the slot name, or empty string for default slot
407
+ elm['s-sn'] = newVNode.$name$ || '';
408
+ // check if we've got an old vnode for this slot
409
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
410
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
411
+ // we've got an old slot vnode and the wrapper is being replaced
412
+ // so let's move the old slot content back to it's original location
413
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
414
+ }
415
+ }
416
+ }
417
+ return elm;
418
+ };
419
+ const putBackInOriginalLocation = (parentElm, recursive) => {
420
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
421
+ const oldSlotChildNodes = parentElm.childNodes;
422
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
423
+ const childNode = oldSlotChildNodes[i];
424
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
425
+ // // this child node in the old element is from another component
426
+ // // remove this node from the old slot's parent
427
+ // childNode.remove();
428
+ // and relocate it back to it's original location
429
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
430
+ // remove the old original location comment entirely
431
+ // later on the patch function will know what to do
432
+ // and move this to the correct spot in need be
433
+ childNode['s-ol'].remove();
434
+ childNode['s-ol'] = undefined;
435
+ checkSlotRelocate = true;
436
+ }
437
+ if (recursive) {
438
+ putBackInOriginalLocation(childNode, recursive);
439
+ }
440
+ }
441
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
442
+ };
443
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
444
+ let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
445
+ let childNode;
446
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
447
+ containerElm = containerElm.shadowRoot;
448
+ }
449
+ for (; startIdx <= endIdx; ++startIdx) {
450
+ if (vnodes[startIdx]) {
451
+ childNode = createElm(null, parentVNode, startIdx, parentElm);
452
+ if (childNode) {
453
+ vnodes[startIdx].$elm$ = childNode;
454
+ containerElm.insertBefore(childNode, referenceNode(before) );
455
+ }
456
+ }
457
+ }
458
+ };
459
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
460
+ for (; startIdx <= endIdx; ++startIdx) {
461
+ if ((vnode = vnodes[startIdx])) {
462
+ elm = vnode.$elm$;
463
+ {
464
+ // we're removing this element
465
+ // so it's possible we need to show slot fallback content now
466
+ checkSlotFallbackVisibility = true;
467
+ if (elm['s-ol']) {
468
+ // remove the original location comment
469
+ elm['s-ol'].remove();
470
+ }
471
+ else {
472
+ // it's possible that child nodes of the node
473
+ // that's being removed are slot nodes
474
+ putBackInOriginalLocation(elm, true);
475
+ }
476
+ }
477
+ // remove the vnode's element from the dom
478
+ elm.remove();
479
+ }
480
+ }
481
+ };
482
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
483
+ let oldStartIdx = 0;
484
+ let newStartIdx = 0;
485
+ let oldEndIdx = oldCh.length - 1;
486
+ let oldStartVnode = oldCh[0];
487
+ let oldEndVnode = oldCh[oldEndIdx];
488
+ let newEndIdx = newCh.length - 1;
489
+ let newStartVnode = newCh[0];
490
+ let newEndVnode = newCh[newEndIdx];
491
+ let node;
492
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
493
+ if (oldStartVnode == null) {
494
+ // Vnode might have been moved left
495
+ oldStartVnode = oldCh[++oldStartIdx];
496
+ }
497
+ else if (oldEndVnode == null) {
498
+ oldEndVnode = oldCh[--oldEndIdx];
499
+ }
500
+ else if (newStartVnode == null) {
501
+ newStartVnode = newCh[++newStartIdx];
502
+ }
503
+ else if (newEndVnode == null) {
504
+ newEndVnode = newCh[--newEndIdx];
505
+ }
506
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
507
+ patch(oldStartVnode, newStartVnode);
508
+ oldStartVnode = oldCh[++oldStartIdx];
509
+ newStartVnode = newCh[++newStartIdx];
510
+ }
511
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
512
+ patch(oldEndVnode, newEndVnode);
513
+ oldEndVnode = oldCh[--oldEndIdx];
514
+ newEndVnode = newCh[--newEndIdx];
515
+ }
516
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
517
+ // Vnode moved right
518
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
519
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
520
+ }
521
+ patch(oldStartVnode, newEndVnode);
522
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
523
+ oldStartVnode = oldCh[++oldStartIdx];
524
+ newEndVnode = newCh[--newEndIdx];
525
+ }
526
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
527
+ // Vnode moved left
528
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
529
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
530
+ }
531
+ patch(oldEndVnode, newStartVnode);
532
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
533
+ oldEndVnode = oldCh[--oldEndIdx];
534
+ newStartVnode = newCh[++newStartIdx];
535
+ }
536
+ else {
537
+ {
538
+ // new element
539
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
540
+ newStartVnode = newCh[++newStartIdx];
541
+ }
542
+ if (node) {
543
+ {
544
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
545
+ }
546
+ }
547
+ }
548
+ }
549
+ if (oldStartIdx > oldEndIdx) {
550
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
551
+ }
552
+ else if (newStartIdx > newEndIdx) {
553
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
554
+ }
555
+ };
556
+ const isSameVnode = (vnode1, vnode2) => {
557
+ // compare if two vnode to see if they're "technically" the same
558
+ // need to have the same element tag, and same key to be the same
559
+ if (vnode1.$tag$ === vnode2.$tag$) {
560
+ if (vnode1.$tag$ === 'slot') {
561
+ return vnode1.$name$ === vnode2.$name$;
562
+ }
563
+ return true;
564
+ }
565
+ return false;
566
+ };
567
+ const referenceNode = (node) => {
568
+ // this node was relocated to a new location in the dom
569
+ // because of some other component's slot
570
+ // but we still have an html comment in place of where
571
+ // it's original location was according to it's original vdom
572
+ return (node && node['s-ol']) || node;
573
+ };
574
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
575
+ const patch = (oldVNode, newVNode) => {
576
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
577
+ const oldChildren = oldVNode.$children$;
578
+ const newChildren = newVNode.$children$;
579
+ const tag = newVNode.$tag$;
580
+ const text = newVNode.$text$;
581
+ let defaultHolder;
582
+ if (text === null) {
583
+ {
584
+ // test if we're rendering an svg element, or still rendering nodes inside of one
585
+ // only add this to the when the compiler sees we're using an svg somewhere
586
+ isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
587
+ }
588
+ // element node
589
+ {
590
+ if (tag === 'slot')
591
+ ;
592
+ else {
593
+ // either this is the first render of an element OR it's an update
594
+ // AND we already know it's possible it could have changed
595
+ // this updates the element's css classes, attrs, props, listeners, etc.
596
+ updateElement(oldVNode, newVNode, isSvgMode);
597
+ }
598
+ }
599
+ if (oldChildren !== null && newChildren !== null) {
600
+ // looks like there's child vnodes for both the old and new vnodes
601
+ updateChildren(elm, oldChildren, newVNode, newChildren);
602
+ }
603
+ else if (newChildren !== null) {
604
+ // no old child vnodes, but there are new child vnodes to add
605
+ if (oldVNode.$text$ !== null) {
606
+ // the old vnode was text, so be sure to clear it out
607
+ elm.textContent = '';
608
+ }
609
+ // add the new vnode children
610
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
611
+ }
612
+ else if (oldChildren !== null) {
613
+ // no new child vnodes, but there are old child vnodes to remove
614
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
615
+ }
616
+ if (isSvgMode && tag === 'svg') {
617
+ isSvgMode = false;
618
+ }
619
+ }
620
+ else if ((defaultHolder = elm['s-cr'])) {
621
+ // this element has slotted content
622
+ defaultHolder.parentNode.textContent = text;
623
+ }
624
+ else if (oldVNode.$text$ !== text) {
625
+ // update the text content for the text only vnode
626
+ // and also only if the text is different than before
627
+ elm.data = text;
628
+ }
629
+ };
630
+ const updateFallbackSlotVisibility = (elm) => {
631
+ // tslint:disable-next-line: prefer-const
632
+ let childNodes = elm.childNodes;
633
+ let childNode;
634
+ let i;
635
+ let ilen;
636
+ let j;
637
+ let slotNameAttr;
638
+ let nodeType;
639
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
640
+ childNode = childNodes[i];
641
+ if (childNode.nodeType === 1 /* ElementNode */) {
642
+ if (childNode['s-sr']) {
643
+ // this is a slot fallback node
644
+ // get the slot name for this slot reference node
645
+ slotNameAttr = childNode['s-sn'];
646
+ // by default always show a fallback slot node
647
+ // then hide it if there are other slots in the light dom
648
+ childNode.hidden = false;
649
+ for (j = 0; j < ilen; j++) {
650
+ nodeType = childNodes[j].nodeType;
651
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
652
+ // this sibling node is from a different component OR is a named fallback slot node
653
+ if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
654
+ childNode.hidden = true;
655
+ break;
656
+ }
657
+ }
658
+ else {
659
+ // this is a default fallback slot node
660
+ // any element or text node (with content)
661
+ // should hide the default fallback slot node
662
+ if (nodeType === 1 /* ElementNode */ ||
663
+ (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
664
+ childNode.hidden = true;
665
+ break;
666
+ }
667
+ }
668
+ }
669
+ }
670
+ // keep drilling down
671
+ updateFallbackSlotVisibility(childNode);
672
+ }
673
+ }
674
+ };
675
+ const relocateNodes = [];
676
+ const relocateSlotContent = (elm) => {
677
+ // tslint:disable-next-line: prefer-const
678
+ let childNode;
679
+ let node;
680
+ let hostContentNodes;
681
+ let slotNameAttr;
682
+ let relocateNodeData;
683
+ let j;
684
+ let i = 0;
685
+ let childNodes = elm.childNodes;
686
+ let ilen = childNodes.length;
687
+ for (; i < ilen; i++) {
688
+ childNode = childNodes[i];
689
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
690
+ // first got the content reference comment node
691
+ // then we got it's parent, which is where all the host content is in now
692
+ hostContentNodes = node.parentNode.childNodes;
693
+ slotNameAttr = childNode['s-sn'];
694
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
695
+ node = hostContentNodes[j];
696
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
697
+ // let's do some relocating to its new home
698
+ // but never relocate a content reference node
699
+ // that is suppose to always represent the original content location
700
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
701
+ // it's possible we've already decided to relocate this node
702
+ relocateNodeData = relocateNodes.find(r => r.$nodeToRelocate$ === node);
703
+ // made some changes to slots
704
+ // let's make sure we also double check
705
+ // fallbacks are correctly hidden or shown
706
+ checkSlotFallbackVisibility = true;
707
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
708
+ if (relocateNodeData) {
709
+ // previously we never found a slot home for this node
710
+ // but turns out we did, so let's remember it now
711
+ relocateNodeData.$slotRefNode$ = childNode;
712
+ }
713
+ else {
714
+ // add to our list of nodes to relocate
715
+ relocateNodes.push({
716
+ $slotRefNode$: childNode,
717
+ $nodeToRelocate$: node,
718
+ });
719
+ }
720
+ if (node['s-sr']) {
721
+ relocateNodes.map(relocateNode => {
722
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
723
+ relocateNodeData = relocateNodes.find(r => r.$nodeToRelocate$ === node);
724
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
725
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
726
+ }
727
+ }
728
+ });
729
+ }
730
+ }
731
+ else if (!relocateNodes.some(r => r.$nodeToRelocate$ === node)) {
732
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
733
+ // if we never find a home for this element then we'll need to hide it
734
+ relocateNodes.push({
735
+ $nodeToRelocate$: node,
736
+ });
737
+ }
738
+ }
739
+ }
740
+ }
741
+ if (childNode.nodeType === 1 /* ElementNode */) {
742
+ relocateSlotContent(childNode);
743
+ }
744
+ }
745
+ };
746
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
747
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
748
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
749
+ return true;
750
+ }
751
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
752
+ return true;
753
+ }
754
+ return false;
755
+ }
756
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
757
+ return true;
758
+ }
759
+ return slotNameAttr === '';
760
+ };
761
+ const renderVdom = (hostRef, renderFnResults) => {
762
+ const hostElm = hostRef.$hostElement$;
763
+ const cmpMeta = hostRef.$cmpMeta$;
764
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
765
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
766
+ hostTagName = hostElm.tagName;
767
+ if (cmpMeta.$attrsToReflect$) {
768
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
769
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
770
+ }
771
+ rootVnode.$tag$ = null;
772
+ rootVnode.$flags$ |= 4 /* isHost */;
773
+ hostRef.$vnode$ = rootVnode;
774
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
775
+ {
776
+ scopeId = hostElm['s-sc'];
777
+ }
778
+ {
779
+ contentRef = hostElm['s-cr'];
780
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
781
+ // always reset
782
+ checkSlotFallbackVisibility = false;
783
+ }
784
+ // synchronous patch
785
+ patch(oldVNode, rootVnode);
786
+ {
787
+ // while we're moving nodes around existing nodes, temporarily disable
788
+ // the disconnectCallback from working
789
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
790
+ if (checkSlotRelocate) {
791
+ relocateSlotContent(rootVnode.$elm$);
792
+ let relocateData;
793
+ let nodeToRelocate;
794
+ let orgLocationNode;
795
+ let parentNodeRef;
796
+ let insertBeforeNode;
797
+ let refNode;
798
+ let i = 0;
799
+ for (; i < relocateNodes.length; i++) {
800
+ relocateData = relocateNodes[i];
801
+ nodeToRelocate = relocateData.$nodeToRelocate$;
802
+ if (!nodeToRelocate['s-ol']) {
803
+ // add a reference node marking this node's original location
804
+ // keep a reference to this node for later lookups
805
+ orgLocationNode = doc.createTextNode('');
806
+ orgLocationNode['s-nr'] = nodeToRelocate;
807
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
808
+ }
809
+ }
810
+ for (i = 0; i < relocateNodes.length; i++) {
811
+ relocateData = relocateNodes[i];
812
+ nodeToRelocate = relocateData.$nodeToRelocate$;
813
+ if (relocateData.$slotRefNode$) {
814
+ // by default we're just going to insert it directly
815
+ // after the slot reference node
816
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
817
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
818
+ orgLocationNode = nodeToRelocate['s-ol'];
819
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
820
+ refNode = orgLocationNode['s-nr'];
821
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
822
+ refNode = refNode.nextSibling;
823
+ if (!refNode || !refNode['s-nr']) {
824
+ insertBeforeNode = refNode;
825
+ break;
826
+ }
827
+ }
828
+ }
829
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) || nodeToRelocate.nextSibling !== insertBeforeNode) {
830
+ // we've checked that it's worth while to relocate
831
+ // since that the node to relocate
832
+ // has a different next sibling or parent relocated
833
+ if (nodeToRelocate !== insertBeforeNode) {
834
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
835
+ // probably a component in the index.html that doesn't have it's hostname set
836
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
837
+ }
838
+ // add it back to the dom but in its new home
839
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
840
+ }
841
+ }
842
+ }
843
+ else {
844
+ // this node doesn't have a slot home to go to, so let's hide it
845
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
846
+ nodeToRelocate.hidden = true;
847
+ }
848
+ }
849
+ }
850
+ }
851
+ if (checkSlotFallbackVisibility) {
852
+ updateFallbackSlotVisibility(rootVnode.$elm$);
853
+ }
854
+ // done moving nodes around
855
+ // allow the disconnect callback to work again
856
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
857
+ // always reset
858
+ relocateNodes.length = 0;
859
+ }
860
+ };
861
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
862
+ const emitEvent = (elm, name, opts) => {
863
+ const ev = plt.ce(name, opts);
864
+ elm.dispatchEvent(ev);
865
+ return ev;
866
+ };
867
+ const attachToAncestor = (hostRef, ancestorComponent) => {
868
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
869
+ ancestorComponent['s-p'].push(new Promise(r => (hostRef.$onRenderResolve$ = r)));
870
+ }
871
+ };
872
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
873
+ {
874
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
875
+ }
876
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
877
+ hostRef.$flags$ |= 512 /* needsRerender */;
878
+ return;
879
+ }
880
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
881
+ // there is no ancestor component or the ancestor component
882
+ // has already fired off its lifecycle update then
883
+ // fire off the initial update
884
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
885
+ return writeTask(dispatch) ;
886
+ };
887
+ const dispatchHooks = (hostRef, isInitialLoad) => {
888
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
889
+ const instance = hostRef.$lazyInstance$ ;
890
+ let promise;
891
+ if (isInitialLoad) ;
892
+ else {
893
+ {
894
+ promise = safeCall(instance, 'componentWillUpdate');
895
+ }
896
+ }
897
+ endSchedule();
898
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
899
+ };
900
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
901
+ // updateComponent
902
+ const elm = hostRef.$hostElement$;
903
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
904
+ const rc = elm['s-rc'];
905
+ if (isInitialLoad) {
906
+ // DOM WRITE!
907
+ attachStyles(hostRef);
908
+ }
909
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
910
+ {
911
+ callRender(hostRef, instance);
912
+ }
913
+ if (rc) {
914
+ // ok, so turns out there are some child host elements
915
+ // waiting on this parent element to load
916
+ // let's fire off all update callbacks waiting
917
+ rc.map(cb => cb());
918
+ elm['s-rc'] = undefined;
919
+ }
920
+ endRender();
921
+ endUpdate();
922
+ {
923
+ const childrenPromises = elm['s-p'];
924
+ const postUpdate = () => postUpdateComponent(hostRef);
925
+ if (childrenPromises.length === 0) {
926
+ postUpdate();
927
+ }
928
+ else {
929
+ Promise.all(childrenPromises).then(postUpdate);
930
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
931
+ childrenPromises.length = 0;
932
+ }
933
+ }
934
+ };
935
+ const callRender = (hostRef, instance, elm) => {
936
+ try {
937
+ instance = instance.render() ;
938
+ {
939
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
940
+ }
941
+ {
942
+ hostRef.$flags$ |= 2 /* hasRendered */;
943
+ }
944
+ {
945
+ {
946
+ // looks like we've got child nodes to render into this host element
947
+ // or we need to update the css class/attrs on the host element
948
+ // DOM WRITE!
949
+ {
950
+ renderVdom(hostRef, instance);
951
+ }
952
+ }
953
+ }
954
+ }
955
+ catch (e) {
956
+ consoleError(e, hostRef.$hostElement$);
957
+ }
958
+ return null;
959
+ };
960
+ const postUpdateComponent = (hostRef) => {
961
+ const tagName = hostRef.$cmpMeta$.$tagName$;
962
+ const elm = hostRef.$hostElement$;
963
+ const endPostUpdate = createTime('postUpdate', tagName);
964
+ const instance = hostRef.$lazyInstance$ ;
965
+ const ancestorComponent = hostRef.$ancestorComponent$;
966
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
967
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
968
+ {
969
+ // DOM WRITE!
970
+ addHydratedFlag(elm);
971
+ }
972
+ {
973
+ safeCall(instance, 'componentDidLoad');
974
+ }
975
+ endPostUpdate();
976
+ {
977
+ hostRef.$onReadyResolve$(elm);
978
+ if (!ancestorComponent) {
979
+ appDidLoad();
980
+ }
981
+ }
982
+ }
983
+ else {
984
+ endPostUpdate();
985
+ }
986
+ // load events fire from bottom to top
987
+ // the deepest elements load first then bubbles up
988
+ {
989
+ if (hostRef.$onRenderResolve$) {
990
+ hostRef.$onRenderResolve$();
991
+ hostRef.$onRenderResolve$ = undefined;
992
+ }
993
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
994
+ nextTick(() => scheduleUpdate(hostRef, false));
995
+ }
996
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
997
+ }
998
+ // ( •_•)
999
+ // ( •_•)>⌐■-■
1000
+ // (⌐■_■)
1001
+ };
1002
+ const appDidLoad = (who) => {
1003
+ // on appload
1004
+ // we have finish the first big initial render
1005
+ {
1006
+ addHydratedFlag(doc.documentElement);
1007
+ }
1008
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1009
+ };
1010
+ const safeCall = (instance, method, arg) => {
1011
+ if (instance && instance[method]) {
1012
+ try {
1013
+ return instance[method](arg);
1014
+ }
1015
+ catch (e) {
1016
+ consoleError(e);
1017
+ }
1018
+ }
1019
+ return undefined;
1020
+ };
1021
+ const then = (promise, thenFn) => {
1022
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
1023
+ };
1024
+ const addHydratedFlag = (elm) => (elm.classList.add('hydrated') );
1025
+ const parsePropertyValue = (propValue, propType) => {
1026
+ // ensure this value is of the correct prop type
1027
+ if (propValue != null && !isComplexType(propValue)) {
1028
+ if (propType & 4 /* Boolean */) {
1029
+ // per the HTML spec, any string value means it is a boolean true value
1030
+ // but we'll cheat here and say that the string "false" is the boolean false
1031
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
1032
+ }
1033
+ if (propType & 1 /* String */) {
1034
+ // could have been passed as a number or boolean
1035
+ // but we still want it as a string
1036
+ return String(propValue);
1037
+ }
1038
+ // redundant return here for better minification
1039
+ return propValue;
1040
+ }
1041
+ // not sure exactly what type we want
1042
+ // so no need to change to a different type
1043
+ return propValue;
1044
+ };
1045
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1046
+ const setValue = (ref, propName, newVal, cmpMeta) => {
1047
+ // check our new property value against our internal value
1048
+ const hostRef = getHostRef(ref);
1049
+ const oldVal = hostRef.$instanceValues$.get(propName);
1050
+ const flags = hostRef.$flags$;
1051
+ const instance = hostRef.$lazyInstance$ ;
1052
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1053
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && newVal !== oldVal) {
1054
+ // gadzooks! the property's value has changed!!
1055
+ // set our new value!
1056
+ hostRef.$instanceValues$.set(propName, newVal);
1057
+ if (instance) {
1058
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1059
+ // looks like this value actually changed, so we've got work to do!
1060
+ // but only if we've already rendered, otherwise just chill out
1061
+ // queue that we need to do an update, but don't worry about queuing
1062
+ // up millions cuz this function ensures it only runs once
1063
+ scheduleUpdate(hostRef, false);
1064
+ }
1065
+ }
1066
+ }
1067
+ };
1068
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
1069
+ if (cmpMeta.$members$) {
1070
+ // It's better to have a const than two Object.entries()
1071
+ const members = Object.entries(cmpMeta.$members$);
1072
+ const prototype = Cstr.prototype;
1073
+ members.map(([memberName, [memberFlags]]) => {
1074
+ if ((memberFlags & 31 /* Prop */ || ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1075
+ // proxyComponent - prop
1076
+ Object.defineProperty(prototype, memberName, {
1077
+ get() {
1078
+ // proxyComponent, get value
1079
+ return getValue(this, memberName);
1080
+ },
1081
+ set(newValue) {
1082
+ // proxyComponent, set value
1083
+ setValue(this, memberName, newValue, cmpMeta);
1084
+ },
1085
+ configurable: true,
1086
+ enumerable: true,
1087
+ });
1088
+ }
1089
+ });
1090
+ if ((flags & 1 /* isElementConstructor */)) {
1091
+ const attrNameToPropName = new Map();
1092
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1093
+ plt.jmp(() => {
1094
+ const propName = attrNameToPropName.get(attrName);
1095
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1096
+ });
1097
+ };
1098
+ // create an array of attributes to observe
1099
+ // and also create a map of html attribute name to js property name
1100
+ Cstr.observedAttributes = members
1101
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1102
+ .map(([propName, m]) => {
1103
+ const attrName = m[1] || propName;
1104
+ attrNameToPropName.set(attrName, propName);
1105
+ if (m[0] & 512 /* ReflectAttr */) {
1106
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
1107
+ }
1108
+ return attrName;
1109
+ });
1110
+ }
1111
+ }
1112
+ return Cstr;
1113
+ };
1114
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1115
+ // initializeComponent
1116
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1117
+ {
1118
+ // we haven't initialized this element yet
1119
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1120
+ // lazy loaded components
1121
+ // request the component's implementation to be
1122
+ // wired up with the host element
1123
+ Cstr = loadModule(cmpMeta);
1124
+ if (Cstr.then) {
1125
+ // Await creates a micro-task avoid if possible
1126
+ const endLoad = uniqueTime();
1127
+ Cstr = await Cstr;
1128
+ endLoad();
1129
+ }
1130
+ if (!Cstr.isProxied) {
1131
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1132
+ Cstr.isProxied = true;
1133
+ }
1134
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1135
+ // ok, time to construct the instance
1136
+ // but let's keep track of when we start and stop
1137
+ // so that the getters/setters don't incorrectly step on data
1138
+ {
1139
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
1140
+ }
1141
+ // construct the lazy-loaded component implementation
1142
+ // passing the hostRef is very important during
1143
+ // construction in order to directly wire together the
1144
+ // host element and the lazy-loaded instance
1145
+ try {
1146
+ new Cstr(hostRef);
1147
+ }
1148
+ catch (e) {
1149
+ consoleError(e);
1150
+ }
1151
+ {
1152
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1153
+ }
1154
+ endNewInstance();
1155
+ }
1156
+ if (Cstr.style) {
1157
+ // this component has styles but we haven't registered them yet
1158
+ let style = Cstr.style;
1159
+ const scopeId = getScopeId(cmpMeta);
1160
+ if (!styles.has(scopeId)) {
1161
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1162
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1163
+ endRegisterStyles();
1164
+ }
1165
+ }
1166
+ }
1167
+ // we've successfully created a lazy instance
1168
+ const ancestorComponent = hostRef.$ancestorComponent$;
1169
+ const schedule = () => scheduleUpdate(hostRef, true);
1170
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1171
+ // this is the intial load and this component it has an ancestor component
1172
+ // but the ancestor component has NOT fired its will update lifecycle yet
1173
+ // so let's just cool our jets and wait for the ancestor to continue first
1174
+ // this will get fired off when the ancestor component
1175
+ // finally gets around to rendering its lazy self
1176
+ // fire off the initial update
1177
+ ancestorComponent['s-rc'].push(schedule);
1178
+ }
1179
+ else {
1180
+ schedule();
1181
+ }
1182
+ };
1183
+ const connectedCallback = (elm) => {
1184
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1185
+ const hostRef = getHostRef(elm);
1186
+ const cmpMeta = hostRef.$cmpMeta$;
1187
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1188
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1189
+ // first time this component has connected
1190
+ hostRef.$flags$ |= 1 /* hasConnected */;
1191
+ {
1192
+ // initUpdate
1193
+ // if the slot polyfill is required we'll need to put some nodes
1194
+ // in here to act as original content anchors as we move nodes around
1195
+ // host element has been connected to the DOM
1196
+ if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
1197
+ setContentReference(elm);
1198
+ }
1199
+ }
1200
+ {
1201
+ // find the first ancestor component (if there is one) and register
1202
+ // this component as one of the actively loading child components for its ancestor
1203
+ let ancestorComponent = elm;
1204
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1205
+ // climb up the ancestors looking for the first
1206
+ // component that hasn't finished its lifecycle update yet
1207
+ if (ancestorComponent['s-p']) {
1208
+ // we found this components first ancestor component
1209
+ // keep a reference to this component's ancestor component
1210
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1211
+ break;
1212
+ }
1213
+ }
1214
+ }
1215
+ // Lazy properties
1216
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1217
+ if (cmpMeta.$members$) {
1218
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1219
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1220
+ const value = elm[memberName];
1221
+ delete elm[memberName];
1222
+ elm[memberName] = value;
1223
+ }
1224
+ });
1225
+ }
1226
+ {
1227
+ initializeComponent(elm, hostRef, cmpMeta);
1228
+ }
1229
+ }
1230
+ endConnected();
1231
+ }
1232
+ };
1233
+ const setContentReference = (elm) => {
1234
+ // only required when we're NOT using native shadow dom (slot)
1235
+ // or this browser doesn't support native shadow dom
1236
+ // and this host element was NOT created with SSR
1237
+ // let's pick out the inner content for slot projection
1238
+ // create a node to represent where the original
1239
+ // content was first placed, which is useful later on
1240
+ const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1241
+ contentRefElm['s-cn'] = true;
1242
+ elm.insertBefore(contentRefElm, elm.firstChild);
1243
+ };
1244
+ const disconnectedCallback = (elm) => {
1245
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1246
+ getHostRef(elm);
1247
+ }
1248
+ };
1249
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1250
+ const endBootstrap = createTime();
1251
+ const cmpTags = [];
1252
+ const exclude = options.exclude || [];
1253
+ const customElements = win.customElements;
1254
+ const head = doc.head;
1255
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1256
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1257
+ const deferredConnectedCallbacks = [];
1258
+ let appLoadFallback;
1259
+ let isBootstrapping = true;
1260
+ Object.assign(plt, options);
1261
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1262
+ lazyBundles.map(lazyBundle => lazyBundle[1].map(compactMeta => {
1263
+ const cmpMeta = {
1264
+ $flags$: compactMeta[0],
1265
+ $tagName$: compactMeta[1],
1266
+ $members$: compactMeta[2],
1267
+ $listeners$: compactMeta[3],
1268
+ };
1269
+ {
1270
+ cmpMeta.$members$ = compactMeta[2];
1271
+ }
1272
+ {
1273
+ cmpMeta.$attrsToReflect$ = [];
1274
+ }
1275
+ const tagName = cmpMeta.$tagName$;
1276
+ const HostElement = class extends HTMLElement {
1277
+ // StencilLazyHost
1278
+ constructor(self) {
1279
+ // @ts-ignore
1280
+ super(self);
1281
+ self = this;
1282
+ registerHost(self, cmpMeta);
1283
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1284
+ // this component is using shadow dom
1285
+ // and this browser supports shadow dom
1286
+ // add the read-only property "shadowRoot" to the host element
1287
+ // adding the shadow root build conditionals to minimize runtime
1288
+ {
1289
+ {
1290
+ self.attachShadow({ mode: 'open' });
1291
+ }
1292
+ }
1293
+ }
1294
+ }
1295
+ connectedCallback() {
1296
+ if (appLoadFallback) {
1297
+ clearTimeout(appLoadFallback);
1298
+ appLoadFallback = null;
1299
+ }
1300
+ if (isBootstrapping) {
1301
+ // connectedCallback will be processed once all components have been registered
1302
+ deferredConnectedCallbacks.push(this);
1303
+ }
1304
+ else {
1305
+ plt.jmp(() => connectedCallback(this));
1306
+ }
1307
+ }
1308
+ disconnectedCallback() {
1309
+ plt.jmp(() => disconnectedCallback(this));
1310
+ }
1311
+ componentOnReady() {
1312
+ return getHostRef(this).$onReadyPromise$;
1313
+ }
1314
+ };
1315
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1316
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1317
+ cmpTags.push(tagName);
1318
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1319
+ }
1320
+ }));
1321
+ {
1322
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1323
+ visibilityStyle.setAttribute('data-styles', '');
1324
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1325
+ }
1326
+ // Process deferred connectedCallbacks now all components have been registered
1327
+ isBootstrapping = false;
1328
+ if (deferredConnectedCallbacks.length) {
1329
+ deferredConnectedCallbacks.map(host => host.connectedCallback());
1330
+ }
1331
+ else {
1332
+ {
1333
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1334
+ }
1335
+ }
1336
+ // Fallback appLoad event
1337
+ endBootstrap();
1338
+ };
1339
+ const getAssetPath = (path) => {
1340
+ const assetUrl = new URL(path, plt.$resourcesUrl$);
1341
+ return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
1342
+ };
1343
+ const hostRefs = new WeakMap();
1344
+ const getHostRef = (ref) => hostRefs.get(ref);
1345
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1346
+ const registerHost = (elm, cmpMeta) => {
1347
+ const hostRef = {
1348
+ $flags$: 0,
1349
+ $hostElement$: elm,
1350
+ $cmpMeta$: cmpMeta,
1351
+ $instanceValues$: new Map(),
1352
+ };
1353
+ {
1354
+ hostRef.$onReadyPromise$ = new Promise(r => (hostRef.$onReadyResolve$ = r));
1355
+ elm['s-p'] = [];
1356
+ elm['s-rc'] = [];
1357
+ }
1358
+ return hostRefs.set(elm, hostRef);
1359
+ };
1360
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1361
+ const consoleError = (e, el) => (0, console.error)(e, el);
1362
+ const cmpModules = /*@__PURE__*/ new Map();
1363
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1364
+ // loadModuleImport
1365
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1366
+ const bundleId = cmpMeta.$lazyBundleId$;
1367
+ const module = cmpModules.get(bundleId) ;
1368
+ if (module) {
1369
+ return module[exportName];
1370
+ }
1371
+ return import(
1372
+ /* webpackInclude: /\.entry\.js$/ */
1373
+ /* webpackExclude: /\.system\.entry\.js$/ */
1374
+ /* webpackMode: "lazy" */
1375
+ `./${bundleId}.entry.js${''}`).then(importedModule => {
1376
+ {
1377
+ cmpModules.set(bundleId, importedModule);
1378
+ }
1379
+ return importedModule[exportName];
1380
+ }, consoleError);
1381
+ };
1382
+ const styles = new Map();
1383
+ const queueDomReads = [];
1384
+ const queueDomWrites = [];
1385
+ const queueTask = (queue, write) => (cb) => {
1386
+ queue.push(cb);
1387
+ if (!queuePending) {
1388
+ queuePending = true;
1389
+ if (write && plt.$flags$ & 4 /* queueSync */) {
1390
+ nextTick(flush);
1391
+ }
1392
+ else {
1393
+ plt.raf(flush);
1394
+ }
1395
+ }
1396
+ };
1397
+ const consume = (queue) => {
1398
+ for (let i = 0; i < queue.length; i++) {
1399
+ try {
1400
+ queue[i](performance.now());
1401
+ }
1402
+ catch (e) {
1403
+ consoleError(e);
1404
+ }
1405
+ }
1406
+ queue.length = 0;
1407
+ };
1408
+ const flush = () => {
1409
+ // always force a bunch of medium callbacks to run, but still have
1410
+ // a throttle on how many can run in a certain time
1411
+ // DOM READS!!!
1412
+ consume(queueDomReads);
1413
+ // DOM WRITES!!!
1414
+ {
1415
+ consume(queueDomWrites);
1416
+ if ((queuePending = queueDomReads.length > 0)) {
1417
+ // still more to do yet, but we've run out of time
1418
+ // let's let this thing cool off and try again in the next tick
1419
+ plt.raf(flush);
1420
+ }
1421
+ }
1422
+ };
1423
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1424
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1425
+
1426
+ export { Host as H, getElement as a, bootstrapLazy as b, getAssetPath as g, h, promiseResolve as p, registerInstance as r };