@sankhyalabs/sankhyablocks 1.1.24 → 1.1.25

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 (180) hide show
  1. package/dist/cjs/ApplicationUtils-05b74ee9.js +39 -0
  2. package/dist/cjs/AssetsUtils-7e3c38f9.js +24 -0
  3. package/dist/cjs/CSSVarsUtils-75ca9c64.js +19 -0
  4. package/dist/cjs/ez-action-chip.cjs.entry.js +27 -0
  5. package/dist/cjs/ez-application.cjs.entry.js +26 -0
  6. package/dist/cjs/ez-button_4.cjs.entry.js +660 -0
  7. package/dist/cjs/ez-calendar.cjs.entry.js +223 -0
  8. package/dist/cjs/ez-collapsible-box.cjs.entry.js +47 -0
  9. package/dist/cjs/ez-combo-box.cjs.entry.js +278 -0
  10. package/dist/cjs/ez-date-input.cjs.entry.js +102 -0
  11. package/dist/cjs/ez-date-time-input.cjs.entry.js +145 -0
  12. package/dist/cjs/ez-dialog.cjs.entry.js +89 -0
  13. package/dist/cjs/ez-form.cjs.entry.js +463 -0
  14. package/dist/cjs/ez-grid.cjs.entry.js +647 -0
  15. package/dist/cjs/ez-icon.cjs.entry.js +41 -0
  16. package/dist/cjs/ez-label-chip.cjs.entry.js +104 -0
  17. package/dist/cjs/ez-modal_2.cjs.entry.js +316 -0
  18. package/dist/cjs/ez-number-input.cjs.entry.js +86 -0
  19. package/dist/cjs/ez-popover.cjs.entry.js +120 -0
  20. package/dist/cjs/ez-popup.cjs.entry.js +48 -0
  21. package/dist/cjs/ez-search.cjs.entry.js +64 -0
  22. package/dist/cjs/ez-tabselector.cjs.entry.js +198 -0
  23. package/dist/cjs/ez-text-area.cjs.entry.js +114 -0
  24. package/dist/cjs/ez-text-input.cjs.entry.js +201 -0
  25. package/dist/cjs/ez-time-input.cjs.entry.js +118 -0
  26. package/dist/cjs/ez-toast.cjs.entry.js +44 -0
  27. package/dist/cjs/ez-upload.cjs.entry.js +356 -0
  28. package/dist/cjs/index-682c98b2.js +1771 -0
  29. package/dist/cjs/loader.cjs.js +2 -2
  30. package/dist/cjs/sankhyablocks.cjs.js +2 -2
  31. package/dist/cjs/snk-application.cjs.entry.js +6 -41
  32. package/dist/cjs/test-du.cjs.entry.js +76 -0
  33. package/dist/collection/collection-manifest.json +36 -1
  34. package/dist/collection/components/snk-application/snk-application.js +2 -1
  35. package/dist/{collection/temp → components}/ApplicationUtils.js +37 -36
  36. package/dist/components/AssetsUtils.js +22 -0
  37. package/dist/components/CSSVarsUtils.js +17 -0
  38. package/dist/components/ez-action-chip.js +44 -0
  39. package/dist/components/ez-application.js +39 -0
  40. package/dist/components/ez-button.js +6 -0
  41. package/dist/components/ez-button2.js +105 -0
  42. package/dist/components/ez-calendar.js +6 -0
  43. package/dist/components/ez-calendar2.js +242 -0
  44. package/dist/components/ez-check.js +6 -0
  45. package/dist/components/ez-check2.js +94 -0
  46. package/dist/components/ez-collapsible-box.js +67 -0
  47. package/dist/components/ez-combo-box.js +6 -0
  48. package/dist/components/ez-combo-box2.js +311 -0
  49. package/dist/components/ez-date-input.js +135 -0
  50. package/dist/components/ez-date-time-input.js +179 -0
  51. package/dist/components/ez-dialog.js +124 -0
  52. package/dist/components/ez-form.js +6 -0
  53. package/dist/components/ez-form2.js +485 -0
  54. package/dist/components/ez-grid.js +738 -0
  55. package/dist/components/ez-icon.js +6 -0
  56. package/dist/components/ez-icon2.js +56 -0
  57. package/dist/components/ez-label-chip.js +125 -0
  58. package/dist/components/ez-list.js +6 -0
  59. package/dist/components/ez-list2.js +523 -0
  60. package/dist/components/ez-modal.js +6 -0
  61. package/dist/components/ez-modal2.js +82 -0
  62. package/dist/components/ez-number-input.js +115 -0
  63. package/dist/components/ez-popover.js +145 -0
  64. package/dist/components/ez-popup.js +67 -0
  65. package/dist/components/ez-search.js +100 -0
  66. package/dist/components/ez-tabselector.js +6 -0
  67. package/dist/components/ez-tabselector2.js +213 -0
  68. package/dist/components/ez-text-area.js +137 -0
  69. package/dist/components/ez-text-input.js +6 -0
  70. package/dist/components/ez-text-input2.js +223 -0
  71. package/dist/components/ez-time-input.js +153 -0
  72. package/dist/components/ez-toast.js +64 -0
  73. package/dist/components/ez-upload.js +382 -0
  74. package/dist/components/grid-config.js +6 -0
  75. package/dist/components/grid-config2.js +318 -0
  76. package/dist/components/select-box.js +6 -0
  77. package/dist/components/select-box2.js +47 -0
  78. package/dist/components/snk-application.js +1 -36
  79. package/dist/components/test-du.js +101 -0
  80. package/dist/esm/ApplicationUtils-e0b6d857.js +37 -0
  81. package/dist/esm/AssetsUtils-6e6624dc.js +22 -0
  82. package/dist/esm/CSSVarsUtils-0787c3f3.js +17 -0
  83. package/dist/esm/ez-action-chip.entry.js +23 -0
  84. package/dist/esm/ez-application.entry.js +22 -0
  85. package/dist/esm/ez-button_4.entry.js +653 -0
  86. package/dist/esm/ez-calendar.entry.js +219 -0
  87. package/dist/esm/ez-collapsible-box.entry.js +43 -0
  88. package/dist/esm/ez-combo-box.entry.js +274 -0
  89. package/dist/esm/ez-date-input.entry.js +98 -0
  90. package/dist/esm/ez-date-time-input.entry.js +141 -0
  91. package/dist/esm/ez-dialog.entry.js +85 -0
  92. package/dist/esm/ez-form.entry.js +459 -0
  93. package/dist/esm/ez-grid.entry.js +643 -0
  94. package/dist/esm/ez-icon.entry.js +37 -0
  95. package/dist/esm/ez-label-chip.entry.js +100 -0
  96. package/dist/esm/ez-modal_2.entry.js +311 -0
  97. package/dist/esm/ez-number-input.entry.js +82 -0
  98. package/dist/esm/ez-popover.entry.js +116 -0
  99. package/dist/esm/ez-popup.entry.js +44 -0
  100. package/dist/esm/ez-search.entry.js +60 -0
  101. package/dist/esm/ez-tabselector.entry.js +194 -0
  102. package/dist/esm/ez-text-area.entry.js +110 -0
  103. package/dist/esm/ez-text-input.entry.js +197 -0
  104. package/dist/esm/ez-time-input.entry.js +114 -0
  105. package/dist/esm/ez-toast.entry.js +40 -0
  106. package/dist/esm/ez-upload.entry.js +352 -0
  107. package/dist/esm/index-35088a3f.js +1740 -0
  108. package/dist/esm/loader.js +2 -2
  109. package/dist/esm/sankhyablocks.js +2 -2
  110. package/dist/esm/snk-application.entry.js +2 -37
  111. package/dist/esm/test-du.entry.js +72 -0
  112. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-action-chip/ez-action-chip.css +67 -0
  113. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-application/ez-application.css +3 -0
  114. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-button/ez-button.css +180 -0
  115. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-calendar/ez-calendar.css +319 -0
  116. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-check/ez-check.css +327 -0
  117. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-collapsible-box/ez-collapsible-box.css +162 -0
  118. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-combo-box/ez-combo-box.css +217 -0
  119. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-date-input/ez-date-input.css +49 -0
  120. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-date-time-input/ez-date-time-input.css +44 -0
  121. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-dialog/ez-dialog.css +527 -0
  122. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-form/ez-form.css +5 -0
  123. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/ez-grid.css +31 -0
  124. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/subcomponents/gridconfig/grid-config.css +129 -0
  125. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-grid/subcomponents/select-box/select-box.css +10 -0
  126. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-icon/ez-icon.css +176 -0
  127. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-label-chip/ez-label-chip.css +139 -0
  128. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-list/ez-list.css +335 -0
  129. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-modal/ez-modal.css +358 -0
  130. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-number-input/ez-number-input.css +4 -0
  131. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-popover/ez-popover.css +44 -0
  132. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-popup/ez-popup.css +405 -0
  133. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-search/ez-search.css +3 -0
  134. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-tabselector/ez-tabselector.css +138 -0
  135. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-text-area/ez-text-area.css +165 -0
  136. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-text-input/ez-text-input.css +196 -0
  137. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-time-input/ez-time-input.css +10 -0
  138. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-toast/ez-toast.css +127 -0
  139. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/ez-upload/ez-upload.css +568 -0
  140. package/dist/node_modules/@sankhyalabs/ezui/dist/collection/components/test-du/test-du.css +3 -0
  141. package/dist/sankhyablocks/p-0183d259.entry.js +1 -0
  142. package/dist/sankhyablocks/p-01f23a70.entry.js +1 -0
  143. package/dist/sankhyablocks/p-07c32f68.entry.js +1 -0
  144. package/dist/sankhyablocks/p-0f90499d.entry.js +1 -0
  145. package/dist/sankhyablocks/p-105724a3.entry.js +1 -0
  146. package/dist/sankhyablocks/p-2ac02d48.entry.js +1 -0
  147. package/dist/sankhyablocks/p-35364a97.entry.js +1 -0
  148. package/dist/sankhyablocks/p-3f6aa9a7.entry.js +1 -0
  149. package/dist/sankhyablocks/p-5f9af495.entry.js +1 -0
  150. package/dist/sankhyablocks/p-60967cf0.js +1 -0
  151. package/dist/sankhyablocks/p-6ce33b60.entry.js +57 -0
  152. package/dist/sankhyablocks/p-70ad6c16.entry.js +1 -0
  153. package/dist/sankhyablocks/p-710bfffe.entry.js +1 -0
  154. package/dist/sankhyablocks/p-735440c1.entry.js +1 -0
  155. package/dist/sankhyablocks/p-811b4b9d.js +1 -0
  156. package/dist/sankhyablocks/p-813fe4f7.js +1 -0
  157. package/dist/sankhyablocks/p-85a9446b.js +2 -0
  158. package/dist/sankhyablocks/p-89a1100f.entry.js +1 -0
  159. package/dist/sankhyablocks/p-8b543003.entry.js +1 -0
  160. package/dist/sankhyablocks/p-9750632b.entry.js +1 -0
  161. package/dist/sankhyablocks/p-a96272f7.entry.js +1 -0
  162. package/dist/sankhyablocks/p-ac8842e5.entry.js +1 -0
  163. package/dist/sankhyablocks/p-ba64cc41.entry.js +1 -0
  164. package/dist/sankhyablocks/p-c1ede043.entry.js +1 -0
  165. package/dist/sankhyablocks/p-d90ebb85.entry.js +1 -0
  166. package/dist/sankhyablocks/p-e17dfaae.entry.js +1 -0
  167. package/dist/sankhyablocks/p-e5355a29.entry.js +1 -0
  168. package/dist/sankhyablocks/p-ef04b633.entry.js +1 -0
  169. package/dist/sankhyablocks/p-f6db07fb.entry.js +1 -0
  170. package/dist/sankhyablocks/p-fcd9bd92.entry.js +1 -0
  171. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  172. package/package.json +1 -1
  173. package/react/components.d.ts +29 -0
  174. package/react/components.js +29 -0
  175. package/react/components.js.map +1 -1
  176. package/dist/cjs/index-4720dab8.js +0 -735
  177. package/dist/esm/index-72d4e2e0.js +0 -709
  178. package/dist/sankhyablocks/p-45635e4f.entry.js +0 -57
  179. package/dist/sankhyablocks/p-a33afc3b.js +0 -2
  180. package/dist/types/temp/ApplicationUtils.d.ts +0 -11
@@ -0,0 +1,1740 @@
1
+ const NAMESPACE = 'sankhyablocks';
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 XLINK_NS = 'http://www.w3.org/1999/xlink';
34
+ const createTime = (fnName, tagName = '') => {
35
+ {
36
+ return () => {
37
+ return;
38
+ };
39
+ }
40
+ };
41
+ const uniqueTime = (key, measureText) => {
42
+ {
43
+ return () => {
44
+ return;
45
+ };
46
+ }
47
+ };
48
+ const rootAppliedStyles = new WeakMap();
49
+ const registerStyle = (scopeId, cssText, allowCS) => {
50
+ let style = styles.get(scopeId);
51
+ if (supportsConstructibleStylesheets && allowCS) {
52
+ style = (style || new CSSStyleSheet());
53
+ style.replace(cssText);
54
+ }
55
+ else {
56
+ style = cssText;
57
+ }
58
+ styles.set(scopeId, style);
59
+ };
60
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
61
+ let scopeId = getScopeId(cmpMeta);
62
+ const style = styles.get(scopeId);
63
+ // if an element is NOT connected then getRootNode() will return the wrong root node
64
+ // so the fallback is to always use the document for the root node in those cases
65
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
66
+ if (style) {
67
+ if (typeof style === 'string') {
68
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
69
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
70
+ let styleElm;
71
+ if (!appliedStyles) {
72
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
73
+ }
74
+ if (!appliedStyles.has(scopeId)) {
75
+ {
76
+ {
77
+ styleElm = doc.createElement('style');
78
+ styleElm.innerHTML = style;
79
+ }
80
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
81
+ }
82
+ if (appliedStyles) {
83
+ appliedStyles.add(scopeId);
84
+ }
85
+ }
86
+ }
87
+ else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
88
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
89
+ }
90
+ }
91
+ return scopeId;
92
+ };
93
+ const attachStyles = (hostRef) => {
94
+ const cmpMeta = hostRef.$cmpMeta$;
95
+ const elm = hostRef.$hostElement$;
96
+ const flags = cmpMeta.$flags$;
97
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
98
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
99
+ if (flags & 10 /* needsScopedEncapsulation */) {
100
+ // only required when we're NOT using native shadow dom (slot)
101
+ // or this browser doesn't support native shadow dom
102
+ // and this host element was NOT created with SSR
103
+ // let's pick out the inner content for slot projection
104
+ // create a node to represent where the original
105
+ // content was first placed, which is useful later on
106
+ // DOM WRITE!!
107
+ elm['s-sc'] = scopeId;
108
+ elm.classList.add(scopeId + '-h');
109
+ if (flags & 2 /* scopedCssEncapsulation */) {
110
+ elm.classList.add(scopeId + '-s');
111
+ }
112
+ }
113
+ endAttachStyles();
114
+ };
115
+ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
116
+ /**
117
+ * Default style mode id
118
+ */
119
+ /**
120
+ * Reusable empty obj/array
121
+ * Don't add values to these!!
122
+ */
123
+ const EMPTY_OBJ = {};
124
+ /**
125
+ * Namespaces
126
+ */
127
+ const SVG_NS = 'http://www.w3.org/2000/svg';
128
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
129
+ const isDef = (v) => v != null;
130
+ const isComplexType = (o) => {
131
+ // https://jsperf.com/typeof-fn-object/5
132
+ o = typeof o;
133
+ return o === 'object' || o === 'function';
134
+ };
135
+ /**
136
+ * Production h() function based on Preact by
137
+ * Jason Miller (@developit)
138
+ * Licensed under the MIT License
139
+ * https://github.com/developit/preact/blob/master/LICENSE
140
+ *
141
+ * Modified for Stencil's compiler and vdom
142
+ */
143
+ // const stack: any[] = [];
144
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
145
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
146
+ const h = (nodeName, vnodeData, ...children) => {
147
+ let child = null;
148
+ let key = null;
149
+ let slotName = null;
150
+ let simple = false;
151
+ let lastSimple = false;
152
+ const vNodeChildren = [];
153
+ const walk = (c) => {
154
+ for (let i = 0; i < c.length; i++) {
155
+ child = c[i];
156
+ if (Array.isArray(child)) {
157
+ walk(child);
158
+ }
159
+ else if (child != null && typeof child !== 'boolean') {
160
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
161
+ child = String(child);
162
+ }
163
+ if (simple && lastSimple) {
164
+ // If the previous child was simple (string), we merge both
165
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
166
+ }
167
+ else {
168
+ // Append a new vNode, if it's text, we create a text vNode
169
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
170
+ }
171
+ lastSimple = simple;
172
+ }
173
+ }
174
+ };
175
+ walk(children);
176
+ if (vnodeData) {
177
+ // normalize class / classname attributes
178
+ if (vnodeData.key) {
179
+ key = vnodeData.key;
180
+ }
181
+ if (vnodeData.name) {
182
+ slotName = vnodeData.name;
183
+ }
184
+ {
185
+ const classData = vnodeData.className || vnodeData.class;
186
+ if (classData) {
187
+ vnodeData.class =
188
+ typeof classData !== 'object'
189
+ ? classData
190
+ : Object.keys(classData)
191
+ .filter((k) => classData[k])
192
+ .join(' ');
193
+ }
194
+ }
195
+ }
196
+ if (typeof nodeName === 'function') {
197
+ // nodeName is a functional component
198
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
199
+ }
200
+ const vnode = newVNode(nodeName, null);
201
+ vnode.$attrs$ = vnodeData;
202
+ if (vNodeChildren.length > 0) {
203
+ vnode.$children$ = vNodeChildren;
204
+ }
205
+ {
206
+ vnode.$key$ = key;
207
+ }
208
+ {
209
+ vnode.$name$ = slotName;
210
+ }
211
+ return vnode;
212
+ };
213
+ const newVNode = (tag, text) => {
214
+ const vnode = {
215
+ $flags$: 0,
216
+ $tag$: tag,
217
+ $text$: text,
218
+ $elm$: null,
219
+ $children$: null,
220
+ };
221
+ {
222
+ vnode.$attrs$ = null;
223
+ }
224
+ {
225
+ vnode.$key$ = null;
226
+ }
227
+ {
228
+ vnode.$name$ = null;
229
+ }
230
+ return vnode;
231
+ };
232
+ const Host = {};
233
+ const isHost = (node) => node && node.$tag$ === Host;
234
+ const vdomFnUtils = {
235
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
236
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
237
+ };
238
+ const convertToPublic = (node) => ({
239
+ vattrs: node.$attrs$,
240
+ vchildren: node.$children$,
241
+ vkey: node.$key$,
242
+ vname: node.$name$,
243
+ vtag: node.$tag$,
244
+ vtext: node.$text$,
245
+ });
246
+ const convertToPrivate = (node) => {
247
+ if (typeof node.vtag === 'function') {
248
+ const vnodeData = Object.assign({}, node.vattrs);
249
+ if (node.vkey) {
250
+ vnodeData.key = node.vkey;
251
+ }
252
+ if (node.vname) {
253
+ vnodeData.name = node.vname;
254
+ }
255
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
256
+ }
257
+ const vnode = newVNode(node.vtag, node.vtext);
258
+ vnode.$attrs$ = node.vattrs;
259
+ vnode.$children$ = node.vchildren;
260
+ vnode.$key$ = node.vkey;
261
+ vnode.$name$ = node.vname;
262
+ return vnode;
263
+ };
264
+ /**
265
+ * Production setAccessor() function based on Preact by
266
+ * Jason Miller (@developit)
267
+ * Licensed under the MIT License
268
+ * https://github.com/developit/preact/blob/master/LICENSE
269
+ *
270
+ * Modified for Stencil's compiler and vdom
271
+ */
272
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
273
+ if (oldValue !== newValue) {
274
+ let isProp = isMemberInElement(elm, memberName);
275
+ let ln = memberName.toLowerCase();
276
+ if (memberName === 'class') {
277
+ const classList = elm.classList;
278
+ const oldClasses = parseClassList(oldValue);
279
+ const newClasses = parseClassList(newValue);
280
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
281
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
282
+ }
283
+ else if (memberName === 'style') {
284
+ // update style attribute, css properties and values
285
+ {
286
+ for (const prop in oldValue) {
287
+ if (!newValue || newValue[prop] == null) {
288
+ if (prop.includes('-')) {
289
+ elm.style.removeProperty(prop);
290
+ }
291
+ else {
292
+ elm.style[prop] = '';
293
+ }
294
+ }
295
+ }
296
+ }
297
+ for (const prop in newValue) {
298
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
299
+ if (prop.includes('-')) {
300
+ elm.style.setProperty(prop, newValue[prop]);
301
+ }
302
+ else {
303
+ elm.style[prop] = newValue[prop];
304
+ }
305
+ }
306
+ }
307
+ }
308
+ else if (memberName === 'key')
309
+ ;
310
+ else if (memberName === 'ref') {
311
+ // minifier will clean this up
312
+ if (newValue) {
313
+ newValue(elm);
314
+ }
315
+ }
316
+ else if ((!isProp ) &&
317
+ memberName[0] === 'o' &&
318
+ memberName[1] === 'n') {
319
+ // Event Handlers
320
+ // so if the member name starts with "on" and the 3rd characters is
321
+ // a capital letter, and it's not already a member on the element,
322
+ // then we're assuming it's an event listener
323
+ if (memberName[2] === '-') {
324
+ // on- prefixed events
325
+ // allows to be explicit about the dom event to listen without any magic
326
+ // under the hood:
327
+ // <my-cmp on-click> // listens for "click"
328
+ // <my-cmp on-Click> // listens for "Click"
329
+ // <my-cmp on-ionChange> // listens for "ionChange"
330
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
331
+ memberName = memberName.slice(3);
332
+ }
333
+ else if (isMemberInElement(win, ln)) {
334
+ // standard event
335
+ // the JSX attribute could have been "onMouseOver" and the
336
+ // member name "onmouseover" is on the window's prototype
337
+ // so let's add the listener "mouseover", which is all lowercased
338
+ memberName = ln.slice(2);
339
+ }
340
+ else {
341
+ // custom event
342
+ // the JSX attribute could have been "onMyCustomEvent"
343
+ // so let's trim off the "on" prefix and lowercase the first character
344
+ // and add the listener "myCustomEvent"
345
+ // except for the first character, we keep the event name case
346
+ memberName = ln[2] + memberName.slice(3);
347
+ }
348
+ if (oldValue) {
349
+ plt.rel(elm, memberName, oldValue, false);
350
+ }
351
+ if (newValue) {
352
+ plt.ael(elm, memberName, newValue, false);
353
+ }
354
+ }
355
+ else {
356
+ // Set property if it exists and it's not a SVG
357
+ const isComplex = isComplexType(newValue);
358
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
359
+ try {
360
+ if (!elm.tagName.includes('-')) {
361
+ const n = newValue == null ? '' : newValue;
362
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
363
+ if (memberName === 'list') {
364
+ isProp = false;
365
+ }
366
+ else if (oldValue == null || elm[memberName] != n) {
367
+ elm[memberName] = n;
368
+ }
369
+ }
370
+ else {
371
+ elm[memberName] = newValue;
372
+ }
373
+ }
374
+ catch (e) { }
375
+ }
376
+ /**
377
+ * Need to manually update attribute if:
378
+ * - memberName is not an attribute
379
+ * - if we are rendering the host element in order to reflect attribute
380
+ * - if it's a SVG, since properties might not work in <svg>
381
+ * - if the newValue is null/undefined or 'false'.
382
+ */
383
+ let xlink = false;
384
+ {
385
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
386
+ memberName = ln;
387
+ xlink = true;
388
+ }
389
+ }
390
+ if (newValue == null || newValue === false) {
391
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
392
+ if (xlink) {
393
+ elm.removeAttributeNS(XLINK_NS, memberName);
394
+ }
395
+ else {
396
+ elm.removeAttribute(memberName);
397
+ }
398
+ }
399
+ }
400
+ else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
401
+ newValue = newValue === true ? '' : newValue;
402
+ if (xlink) {
403
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
404
+ }
405
+ else {
406
+ elm.setAttribute(memberName, newValue);
407
+ }
408
+ }
409
+ }
410
+ }
411
+ };
412
+ const parseClassListRegex = /\s/;
413
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
414
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
415
+ // if the element passed in is a shadow root, which is a document fragment
416
+ // then we want to be adding attrs/props to the shadow root's "host" element
417
+ // if it's not a shadow root, then we add attrs/props to the same element
418
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
419
+ ? newVnode.$elm$.host
420
+ : newVnode.$elm$;
421
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
422
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
423
+ {
424
+ // remove attributes no longer present on the vnode by setting them to undefined
425
+ for (memberName in oldVnodeAttrs) {
426
+ if (!(memberName in newVnodeAttrs)) {
427
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
428
+ }
429
+ }
430
+ }
431
+ // add new & update changed attributes
432
+ for (memberName in newVnodeAttrs) {
433
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
434
+ }
435
+ };
436
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
437
+ // tslint:disable-next-line: prefer-const
438
+ const newVNode = newParentVNode.$children$[childIndex];
439
+ let i = 0;
440
+ let elm;
441
+ let childNode;
442
+ let oldVNode;
443
+ if (!useNativeShadowDom) {
444
+ // remember for later we need to check to relocate nodes
445
+ checkSlotRelocate = true;
446
+ if (newVNode.$tag$ === 'slot') {
447
+ if (scopeId) {
448
+ // scoped css needs to add its scoped id to the parent element
449
+ parentElm.classList.add(scopeId + '-s');
450
+ }
451
+ newVNode.$flags$ |= newVNode.$children$
452
+ ? // slot element has fallback content
453
+ 2 /* isSlotFallback */
454
+ : // slot element does not have fallback content
455
+ 1 /* isSlotReference */;
456
+ }
457
+ }
458
+ if (newVNode.$text$ !== null) {
459
+ // create text node
460
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
461
+ }
462
+ else if (newVNode.$flags$ & 1 /* isSlotReference */) {
463
+ // create a slot reference node
464
+ elm = newVNode.$elm$ =
465
+ doc.createTextNode('');
466
+ }
467
+ else {
468
+ if (!isSvgMode) {
469
+ isSvgMode = newVNode.$tag$ === 'svg';
470
+ }
471
+ // create element
472
+ elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* isSlotFallback */
473
+ ? 'slot-fb'
474
+ : newVNode.$tag$)
475
+ );
476
+ if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
477
+ isSvgMode = false;
478
+ }
479
+ // add css classes, attrs, props, listeners, etc.
480
+ {
481
+ updateElement(null, newVNode, isSvgMode);
482
+ }
483
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
484
+ // if there is a scopeId and this is the initial render
485
+ // then let's add the scopeId as a css class
486
+ elm.classList.add((elm['s-si'] = scopeId));
487
+ }
488
+ if (newVNode.$children$) {
489
+ for (i = 0; i < newVNode.$children$.length; ++i) {
490
+ // create the node
491
+ childNode = createElm(oldParentVNode, newVNode, i, elm);
492
+ // return node could have been null
493
+ if (childNode) {
494
+ // append our new node
495
+ elm.appendChild(childNode);
496
+ }
497
+ }
498
+ }
499
+ {
500
+ if (newVNode.$tag$ === 'svg') {
501
+ // Only reset the SVG context when we're exiting <svg> element
502
+ isSvgMode = false;
503
+ }
504
+ else if (elm.tagName === 'foreignObject') {
505
+ // Reenter SVG context when we're exiting <foreignObject> element
506
+ isSvgMode = true;
507
+ }
508
+ }
509
+ }
510
+ {
511
+ elm['s-hn'] = hostTagName;
512
+ if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
513
+ // remember the content reference comment
514
+ elm['s-sr'] = true;
515
+ // remember the content reference comment
516
+ elm['s-cr'] = contentRef;
517
+ // remember the slot name, or empty string for default slot
518
+ elm['s-sn'] = newVNode.$name$ || '';
519
+ // check if we've got an old vnode for this slot
520
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
521
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
522
+ // we've got an old slot vnode and the wrapper is being replaced
523
+ // so let's move the old slot content back to it's original location
524
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
525
+ }
526
+ }
527
+ }
528
+ return elm;
529
+ };
530
+ const putBackInOriginalLocation = (parentElm, recursive) => {
531
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
532
+ const oldSlotChildNodes = parentElm.childNodes;
533
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
534
+ const childNode = oldSlotChildNodes[i];
535
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
536
+ // // this child node in the old element is from another component
537
+ // // remove this node from the old slot's parent
538
+ // childNode.remove();
539
+ // and relocate it back to it's original location
540
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
541
+ // remove the old original location comment entirely
542
+ // later on the patch function will know what to do
543
+ // and move this to the correct spot in need be
544
+ childNode['s-ol'].remove();
545
+ childNode['s-ol'] = undefined;
546
+ checkSlotRelocate = true;
547
+ }
548
+ if (recursive) {
549
+ putBackInOriginalLocation(childNode, recursive);
550
+ }
551
+ }
552
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
553
+ };
554
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
555
+ let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
556
+ let childNode;
557
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
558
+ containerElm = containerElm.shadowRoot;
559
+ }
560
+ for (; startIdx <= endIdx; ++startIdx) {
561
+ if (vnodes[startIdx]) {
562
+ childNode = createElm(null, parentVNode, startIdx, parentElm);
563
+ if (childNode) {
564
+ vnodes[startIdx].$elm$ = childNode;
565
+ containerElm.insertBefore(childNode, referenceNode(before) );
566
+ }
567
+ }
568
+ }
569
+ };
570
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
571
+ for (; startIdx <= endIdx; ++startIdx) {
572
+ if ((vnode = vnodes[startIdx])) {
573
+ elm = vnode.$elm$;
574
+ callNodeRefs(vnode);
575
+ {
576
+ // we're removing this element
577
+ // so it's possible we need to show slot fallback content now
578
+ checkSlotFallbackVisibility = true;
579
+ if (elm['s-ol']) {
580
+ // remove the original location comment
581
+ elm['s-ol'].remove();
582
+ }
583
+ else {
584
+ // it's possible that child nodes of the node
585
+ // that's being removed are slot nodes
586
+ putBackInOriginalLocation(elm, true);
587
+ }
588
+ }
589
+ // remove the vnode's element from the dom
590
+ elm.remove();
591
+ }
592
+ }
593
+ };
594
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
595
+ let oldStartIdx = 0;
596
+ let newStartIdx = 0;
597
+ let idxInOld = 0;
598
+ let i = 0;
599
+ let oldEndIdx = oldCh.length - 1;
600
+ let oldStartVnode = oldCh[0];
601
+ let oldEndVnode = oldCh[oldEndIdx];
602
+ let newEndIdx = newCh.length - 1;
603
+ let newStartVnode = newCh[0];
604
+ let newEndVnode = newCh[newEndIdx];
605
+ let node;
606
+ let elmToMove;
607
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
608
+ if (oldStartVnode == null) {
609
+ // Vnode might have been moved left
610
+ oldStartVnode = oldCh[++oldStartIdx];
611
+ }
612
+ else if (oldEndVnode == null) {
613
+ oldEndVnode = oldCh[--oldEndIdx];
614
+ }
615
+ else if (newStartVnode == null) {
616
+ newStartVnode = newCh[++newStartIdx];
617
+ }
618
+ else if (newEndVnode == null) {
619
+ newEndVnode = newCh[--newEndIdx];
620
+ }
621
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
622
+ patch(oldStartVnode, newStartVnode);
623
+ oldStartVnode = oldCh[++oldStartIdx];
624
+ newStartVnode = newCh[++newStartIdx];
625
+ }
626
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
627
+ patch(oldEndVnode, newEndVnode);
628
+ oldEndVnode = oldCh[--oldEndIdx];
629
+ newEndVnode = newCh[--newEndIdx];
630
+ }
631
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
632
+ // Vnode moved right
633
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
634
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
635
+ }
636
+ patch(oldStartVnode, newEndVnode);
637
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
638
+ oldStartVnode = oldCh[++oldStartIdx];
639
+ newEndVnode = newCh[--newEndIdx];
640
+ }
641
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
642
+ // Vnode moved left
643
+ if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
644
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
645
+ }
646
+ patch(oldEndVnode, newStartVnode);
647
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
648
+ oldEndVnode = oldCh[--oldEndIdx];
649
+ newStartVnode = newCh[++newStartIdx];
650
+ }
651
+ else {
652
+ // createKeyToOldIdx
653
+ idxInOld = -1;
654
+ {
655
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
656
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
657
+ idxInOld = i;
658
+ break;
659
+ }
660
+ }
661
+ }
662
+ if (idxInOld >= 0) {
663
+ elmToMove = oldCh[idxInOld];
664
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
665
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
666
+ }
667
+ else {
668
+ patch(elmToMove, newStartVnode);
669
+ oldCh[idxInOld] = undefined;
670
+ node = elmToMove.$elm$;
671
+ }
672
+ newStartVnode = newCh[++newStartIdx];
673
+ }
674
+ else {
675
+ // new element
676
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
677
+ newStartVnode = newCh[++newStartIdx];
678
+ }
679
+ if (node) {
680
+ {
681
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
682
+ }
683
+ }
684
+ }
685
+ }
686
+ if (oldStartIdx > oldEndIdx) {
687
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
688
+ }
689
+ else if (newStartIdx > newEndIdx) {
690
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
691
+ }
692
+ };
693
+ const isSameVnode = (vnode1, vnode2) => {
694
+ // compare if two vnode to see if they're "technically" the same
695
+ // need to have the same element tag, and same key to be the same
696
+ if (vnode1.$tag$ === vnode2.$tag$) {
697
+ if (vnode1.$tag$ === 'slot') {
698
+ return vnode1.$name$ === vnode2.$name$;
699
+ }
700
+ {
701
+ return vnode1.$key$ === vnode2.$key$;
702
+ }
703
+ }
704
+ return false;
705
+ };
706
+ const referenceNode = (node) => {
707
+ // this node was relocated to a new location in the dom
708
+ // because of some other component's slot
709
+ // but we still have an html comment in place of where
710
+ // it's original location was according to it's original vdom
711
+ return (node && node['s-ol']) || node;
712
+ };
713
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
714
+ const patch = (oldVNode, newVNode) => {
715
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
716
+ const oldChildren = oldVNode.$children$;
717
+ const newChildren = newVNode.$children$;
718
+ const tag = newVNode.$tag$;
719
+ const text = newVNode.$text$;
720
+ let defaultHolder;
721
+ if (text === null) {
722
+ {
723
+ // test if we're rendering an svg element, or still rendering nodes inside of one
724
+ // only add this to the when the compiler sees we're using an svg somewhere
725
+ isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
726
+ }
727
+ // element node
728
+ {
729
+ if (tag === 'slot')
730
+ ;
731
+ else {
732
+ // either this is the first render of an element OR it's an update
733
+ // AND we already know it's possible it could have changed
734
+ // this updates the element's css classes, attrs, props, listeners, etc.
735
+ updateElement(oldVNode, newVNode, isSvgMode);
736
+ }
737
+ }
738
+ if (oldChildren !== null && newChildren !== null) {
739
+ // looks like there's child vnodes for both the old and new vnodes
740
+ updateChildren(elm, oldChildren, newVNode, newChildren);
741
+ }
742
+ else if (newChildren !== null) {
743
+ // no old child vnodes, but there are new child vnodes to add
744
+ if (oldVNode.$text$ !== null) {
745
+ // the old vnode was text, so be sure to clear it out
746
+ elm.textContent = '';
747
+ }
748
+ // add the new vnode children
749
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
750
+ }
751
+ else if (oldChildren !== null) {
752
+ // no new child vnodes, but there are old child vnodes to remove
753
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
754
+ }
755
+ if (isSvgMode && tag === 'svg') {
756
+ isSvgMode = false;
757
+ }
758
+ }
759
+ else if ((defaultHolder = elm['s-cr'])) {
760
+ // this element has slotted content
761
+ defaultHolder.parentNode.textContent = text;
762
+ }
763
+ else if (oldVNode.$text$ !== text) {
764
+ // update the text content for the text only vnode
765
+ // and also only if the text is different than before
766
+ elm.data = text;
767
+ }
768
+ };
769
+ const updateFallbackSlotVisibility = (elm) => {
770
+ // tslint:disable-next-line: prefer-const
771
+ const childNodes = elm.childNodes;
772
+ let childNode;
773
+ let i;
774
+ let ilen;
775
+ let j;
776
+ let slotNameAttr;
777
+ let nodeType;
778
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
779
+ childNode = childNodes[i];
780
+ if (childNode.nodeType === 1 /* ElementNode */) {
781
+ if (childNode['s-sr']) {
782
+ // this is a slot fallback node
783
+ // get the slot name for this slot reference node
784
+ slotNameAttr = childNode['s-sn'];
785
+ // by default always show a fallback slot node
786
+ // then hide it if there are other slots in the light dom
787
+ childNode.hidden = false;
788
+ for (j = 0; j < ilen; j++) {
789
+ nodeType = childNodes[j].nodeType;
790
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
791
+ // this sibling node is from a different component OR is a named fallback slot node
792
+ if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
793
+ childNode.hidden = true;
794
+ break;
795
+ }
796
+ }
797
+ else {
798
+ // this is a default fallback slot node
799
+ // any element or text node (with content)
800
+ // should hide the default fallback slot node
801
+ if (nodeType === 1 /* ElementNode */ ||
802
+ (nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
803
+ childNode.hidden = true;
804
+ break;
805
+ }
806
+ }
807
+ }
808
+ }
809
+ // keep drilling down
810
+ updateFallbackSlotVisibility(childNode);
811
+ }
812
+ }
813
+ };
814
+ const relocateNodes = [];
815
+ const relocateSlotContent = (elm) => {
816
+ // tslint:disable-next-line: prefer-const
817
+ let childNode;
818
+ let node;
819
+ let hostContentNodes;
820
+ let slotNameAttr;
821
+ let relocateNodeData;
822
+ let j;
823
+ let i = 0;
824
+ const childNodes = elm.childNodes;
825
+ const ilen = childNodes.length;
826
+ for (; i < ilen; i++) {
827
+ childNode = childNodes[i];
828
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
829
+ // first got the content reference comment node
830
+ // then we got it's parent, which is where all the host content is in now
831
+ hostContentNodes = node.parentNode.childNodes;
832
+ slotNameAttr = childNode['s-sn'];
833
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
834
+ node = hostContentNodes[j];
835
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
836
+ // let's do some relocating to its new home
837
+ // but never relocate a content reference node
838
+ // that is suppose to always represent the original content location
839
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
840
+ // it's possible we've already decided to relocate this node
841
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
842
+ // made some changes to slots
843
+ // let's make sure we also double check
844
+ // fallbacks are correctly hidden or shown
845
+ checkSlotFallbackVisibility = true;
846
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
847
+ if (relocateNodeData) {
848
+ // previously we never found a slot home for this node
849
+ // but turns out we did, so let's remember it now
850
+ relocateNodeData.$slotRefNode$ = childNode;
851
+ }
852
+ else {
853
+ // add to our list of nodes to relocate
854
+ relocateNodes.push({
855
+ $slotRefNode$: childNode,
856
+ $nodeToRelocate$: node,
857
+ });
858
+ }
859
+ if (node['s-sr']) {
860
+ relocateNodes.map((relocateNode) => {
861
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
862
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
863
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
864
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
865
+ }
866
+ }
867
+ });
868
+ }
869
+ }
870
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
871
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
872
+ // if we never find a home for this element then we'll need to hide it
873
+ relocateNodes.push({
874
+ $nodeToRelocate$: node,
875
+ });
876
+ }
877
+ }
878
+ }
879
+ }
880
+ if (childNode.nodeType === 1 /* ElementNode */) {
881
+ relocateSlotContent(childNode);
882
+ }
883
+ }
884
+ };
885
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
886
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
887
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
888
+ return true;
889
+ }
890
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
891
+ return true;
892
+ }
893
+ return false;
894
+ }
895
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
896
+ return true;
897
+ }
898
+ return slotNameAttr === '';
899
+ };
900
+ const callNodeRefs = (vNode) => {
901
+ {
902
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
903
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
904
+ }
905
+ };
906
+ const renderVdom = (hostRef, renderFnResults) => {
907
+ const hostElm = hostRef.$hostElement$;
908
+ const cmpMeta = hostRef.$cmpMeta$;
909
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
910
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
911
+ hostTagName = hostElm.tagName;
912
+ if (cmpMeta.$attrsToReflect$) {
913
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
914
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
915
+ }
916
+ rootVnode.$tag$ = null;
917
+ rootVnode.$flags$ |= 4 /* isHost */;
918
+ hostRef.$vnode$ = rootVnode;
919
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
920
+ {
921
+ scopeId = hostElm['s-sc'];
922
+ }
923
+ {
924
+ contentRef = hostElm['s-cr'];
925
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
926
+ // always reset
927
+ checkSlotFallbackVisibility = false;
928
+ }
929
+ // synchronous patch
930
+ patch(oldVNode, rootVnode);
931
+ {
932
+ // while we're moving nodes around existing nodes, temporarily disable
933
+ // the disconnectCallback from working
934
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
935
+ if (checkSlotRelocate) {
936
+ relocateSlotContent(rootVnode.$elm$);
937
+ let relocateData;
938
+ let nodeToRelocate;
939
+ let orgLocationNode;
940
+ let parentNodeRef;
941
+ let insertBeforeNode;
942
+ let refNode;
943
+ let i = 0;
944
+ for (; i < relocateNodes.length; i++) {
945
+ relocateData = relocateNodes[i];
946
+ nodeToRelocate = relocateData.$nodeToRelocate$;
947
+ if (!nodeToRelocate['s-ol']) {
948
+ // add a reference node marking this node's original location
949
+ // keep a reference to this node for later lookups
950
+ orgLocationNode =
951
+ doc.createTextNode('');
952
+ orgLocationNode['s-nr'] = nodeToRelocate;
953
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
954
+ }
955
+ }
956
+ for (i = 0; i < relocateNodes.length; i++) {
957
+ relocateData = relocateNodes[i];
958
+ nodeToRelocate = relocateData.$nodeToRelocate$;
959
+ if (relocateData.$slotRefNode$) {
960
+ // by default we're just going to insert it directly
961
+ // after the slot reference node
962
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
963
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
964
+ orgLocationNode = nodeToRelocate['s-ol'];
965
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
966
+ refNode = orgLocationNode['s-nr'];
967
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
968
+ refNode = refNode.nextSibling;
969
+ if (!refNode || !refNode['s-nr']) {
970
+ insertBeforeNode = refNode;
971
+ break;
972
+ }
973
+ }
974
+ }
975
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
976
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
977
+ // we've checked that it's worth while to relocate
978
+ // since that the node to relocate
979
+ // has a different next sibling or parent relocated
980
+ if (nodeToRelocate !== insertBeforeNode) {
981
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
982
+ // probably a component in the index.html that doesn't have it's hostname set
983
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
984
+ }
985
+ // add it back to the dom but in its new home
986
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
987
+ }
988
+ }
989
+ }
990
+ else {
991
+ // this node doesn't have a slot home to go to, so let's hide it
992
+ if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
993
+ nodeToRelocate.hidden = true;
994
+ }
995
+ }
996
+ }
997
+ }
998
+ if (checkSlotFallbackVisibility) {
999
+ updateFallbackSlotVisibility(rootVnode.$elm$);
1000
+ }
1001
+ // done moving nodes around
1002
+ // allow the disconnect callback to work again
1003
+ plt.$flags$ &= ~1 /* isTmpDisconnected */;
1004
+ // always reset
1005
+ relocateNodes.length = 0;
1006
+ }
1007
+ };
1008
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
1009
+ const createEvent = (ref, name, flags) => {
1010
+ const elm = getElement(ref);
1011
+ return {
1012
+ emit: (detail) => {
1013
+ return emitEvent(elm, name, {
1014
+ bubbles: !!(flags & 4 /* Bubbles */),
1015
+ composed: !!(flags & 2 /* Composed */),
1016
+ cancelable: !!(flags & 1 /* Cancellable */),
1017
+ detail,
1018
+ });
1019
+ },
1020
+ };
1021
+ };
1022
+ /**
1023
+ * Helper function to create & dispatch a custom Event on a provided target
1024
+ * @param elm the target of the Event
1025
+ * @param name the name to give the custom Event
1026
+ * @param opts options for configuring a custom Event
1027
+ * @returns the custom Event
1028
+ */
1029
+ const emitEvent = (elm, name, opts) => {
1030
+ const ev = plt.ce(name, opts);
1031
+ elm.dispatchEvent(ev);
1032
+ return ev;
1033
+ };
1034
+ const attachToAncestor = (hostRef, ancestorComponent) => {
1035
+ if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1036
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1037
+ }
1038
+ };
1039
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
1040
+ {
1041
+ hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
1042
+ }
1043
+ if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
1044
+ hostRef.$flags$ |= 512 /* needsRerender */;
1045
+ return;
1046
+ }
1047
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1048
+ // there is no ancestor component or the ancestor component
1049
+ // has already fired off its lifecycle update then
1050
+ // fire off the initial update
1051
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1052
+ return writeTask(dispatch) ;
1053
+ };
1054
+ const dispatchHooks = (hostRef, isInitialLoad) => {
1055
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1056
+ const instance = hostRef.$lazyInstance$ ;
1057
+ let promise;
1058
+ if (isInitialLoad) {
1059
+ {
1060
+ promise = safeCall(instance, 'componentWillLoad');
1061
+ }
1062
+ }
1063
+ {
1064
+ promise = then(promise, () => safeCall(instance, 'componentWillRender'));
1065
+ }
1066
+ endSchedule();
1067
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1068
+ };
1069
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1070
+ // updateComponent
1071
+ const elm = hostRef.$hostElement$;
1072
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1073
+ const rc = elm['s-rc'];
1074
+ if (isInitialLoad) {
1075
+ // DOM WRITE!
1076
+ attachStyles(hostRef);
1077
+ }
1078
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1079
+ {
1080
+ callRender(hostRef, instance);
1081
+ }
1082
+ if (rc) {
1083
+ // ok, so turns out there are some child host elements
1084
+ // waiting on this parent element to load
1085
+ // let's fire off all update callbacks waiting
1086
+ rc.map((cb) => cb());
1087
+ elm['s-rc'] = undefined;
1088
+ }
1089
+ endRender();
1090
+ endUpdate();
1091
+ {
1092
+ const childrenPromises = elm['s-p'];
1093
+ const postUpdate = () => postUpdateComponent(hostRef);
1094
+ if (childrenPromises.length === 0) {
1095
+ postUpdate();
1096
+ }
1097
+ else {
1098
+ Promise.all(childrenPromises).then(postUpdate);
1099
+ hostRef.$flags$ |= 4 /* isWaitingForChildren */;
1100
+ childrenPromises.length = 0;
1101
+ }
1102
+ }
1103
+ };
1104
+ const callRender = (hostRef, instance, elm) => {
1105
+ try {
1106
+ instance = instance.render() ;
1107
+ {
1108
+ hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
1109
+ }
1110
+ {
1111
+ hostRef.$flags$ |= 2 /* hasRendered */;
1112
+ }
1113
+ {
1114
+ {
1115
+ // looks like we've got child nodes to render into this host element
1116
+ // or we need to update the css class/attrs on the host element
1117
+ // DOM WRITE!
1118
+ {
1119
+ renderVdom(hostRef, instance);
1120
+ }
1121
+ }
1122
+ }
1123
+ }
1124
+ catch (e) {
1125
+ consoleError(e, hostRef.$hostElement$);
1126
+ }
1127
+ return null;
1128
+ };
1129
+ const postUpdateComponent = (hostRef) => {
1130
+ const tagName = hostRef.$cmpMeta$.$tagName$;
1131
+ const elm = hostRef.$hostElement$;
1132
+ const endPostUpdate = createTime('postUpdate', tagName);
1133
+ const instance = hostRef.$lazyInstance$ ;
1134
+ const ancestorComponent = hostRef.$ancestorComponent$;
1135
+ {
1136
+ safeCall(instance, 'componentDidRender');
1137
+ }
1138
+ if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
1139
+ hostRef.$flags$ |= 64 /* hasLoadedComponent */;
1140
+ {
1141
+ // DOM WRITE!
1142
+ addHydratedFlag(elm);
1143
+ }
1144
+ {
1145
+ safeCall(instance, 'componentDidLoad');
1146
+ }
1147
+ endPostUpdate();
1148
+ {
1149
+ hostRef.$onReadyResolve$(elm);
1150
+ if (!ancestorComponent) {
1151
+ appDidLoad();
1152
+ }
1153
+ }
1154
+ }
1155
+ else {
1156
+ endPostUpdate();
1157
+ }
1158
+ {
1159
+ hostRef.$onInstanceResolve$(elm);
1160
+ }
1161
+ // load events fire from bottom to top
1162
+ // the deepest elements load first then bubbles up
1163
+ {
1164
+ if (hostRef.$onRenderResolve$) {
1165
+ hostRef.$onRenderResolve$();
1166
+ hostRef.$onRenderResolve$ = undefined;
1167
+ }
1168
+ if (hostRef.$flags$ & 512 /* needsRerender */) {
1169
+ nextTick(() => scheduleUpdate(hostRef, false));
1170
+ }
1171
+ hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
1172
+ }
1173
+ // ( •_•)
1174
+ // ( •_•)>⌐■-■
1175
+ // (⌐■_■)
1176
+ };
1177
+ const forceUpdate = (ref) => {
1178
+ {
1179
+ const hostRef = getHostRef(ref);
1180
+ const isConnected = hostRef.$hostElement$.isConnected;
1181
+ if (isConnected &&
1182
+ (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1183
+ scheduleUpdate(hostRef, false);
1184
+ }
1185
+ // Returns "true" when the forced update was successfully scheduled
1186
+ return isConnected;
1187
+ }
1188
+ };
1189
+ const appDidLoad = (who) => {
1190
+ // on appload
1191
+ // we have finish the first big initial render
1192
+ {
1193
+ addHydratedFlag(doc.documentElement);
1194
+ }
1195
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1196
+ };
1197
+ const safeCall = (instance, method, arg) => {
1198
+ if (instance && instance[method]) {
1199
+ try {
1200
+ return instance[method](arg);
1201
+ }
1202
+ catch (e) {
1203
+ consoleError(e);
1204
+ }
1205
+ }
1206
+ return undefined;
1207
+ };
1208
+ const then = (promise, thenFn) => {
1209
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
1210
+ };
1211
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1212
+ ;
1213
+ /**
1214
+ * Parse a new property value for a given property type.
1215
+ *
1216
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
1217
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
1218
+ * 1. `any`, the type given to `propValue` in the function signature
1219
+ * 2. the type stored from `propType`.
1220
+ *
1221
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
1222
+ *
1223
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
1224
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
1225
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
1226
+ * ```tsx
1227
+ * <my-cmp prop-val={0}></my-cmp>
1228
+ * ```
1229
+ *
1230
+ * HTML prop values on the other hand, will always a string
1231
+ *
1232
+ * @param propValue the new value to coerce to some type
1233
+ * @param propType the type of the prop, expressed as a binary number
1234
+ * @returns the parsed/coerced value
1235
+ */
1236
+ const parsePropertyValue = (propValue, propType) => {
1237
+ // ensure this value is of the correct prop type
1238
+ if (propValue != null && !isComplexType(propValue)) {
1239
+ if (propType & 4 /* Boolean */) {
1240
+ // per the HTML spec, any string value means it is a boolean true value
1241
+ // but we'll cheat here and say that the string "false" is the boolean false
1242
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
1243
+ }
1244
+ if (propType & 2 /* Number */) {
1245
+ // force it to be a number
1246
+ return parseFloat(propValue);
1247
+ }
1248
+ if (propType & 1 /* String */) {
1249
+ // could have been passed as a number or boolean
1250
+ // but we still want it as a string
1251
+ return String(propValue);
1252
+ }
1253
+ // redundant return here for better minification
1254
+ return propValue;
1255
+ }
1256
+ // not sure exactly what type we want
1257
+ // so no need to change to a different type
1258
+ return propValue;
1259
+ };
1260
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1261
+ const setValue = (ref, propName, newVal, cmpMeta) => {
1262
+ // check our new property value against our internal value
1263
+ const hostRef = getHostRef(ref);
1264
+ const elm = hostRef.$hostElement$ ;
1265
+ const oldVal = hostRef.$instanceValues$.get(propName);
1266
+ const flags = hostRef.$flags$;
1267
+ const instance = hostRef.$lazyInstance$ ;
1268
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1269
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1270
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1271
+ const didValueChange = newVal !== oldVal && !areBothNaN;
1272
+ if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1273
+ // gadzooks! the property's value has changed!!
1274
+ // set our new value!
1275
+ hostRef.$instanceValues$.set(propName, newVal);
1276
+ if (instance) {
1277
+ // get an array of method names of watch functions to call
1278
+ if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
1279
+ const watchMethods = cmpMeta.$watchers$[propName];
1280
+ if (watchMethods) {
1281
+ // this instance is watching for when this property changed
1282
+ watchMethods.map((watchMethodName) => {
1283
+ try {
1284
+ // fire off each of the watch methods that are watching this property
1285
+ instance[watchMethodName](newVal, oldVal, propName);
1286
+ }
1287
+ catch (e) {
1288
+ consoleError(e, elm);
1289
+ }
1290
+ });
1291
+ }
1292
+ }
1293
+ if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
1294
+ // looks like this value actually changed, so we've got work to do!
1295
+ // but only if we've already rendered, otherwise just chill out
1296
+ // queue that we need to do an update, but don't worry about queuing
1297
+ // up millions cuz this function ensures it only runs once
1298
+ scheduleUpdate(hostRef, false);
1299
+ }
1300
+ }
1301
+ }
1302
+ };
1303
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
1304
+ if (cmpMeta.$members$) {
1305
+ if (Cstr.watchers) {
1306
+ cmpMeta.$watchers$ = Cstr.watchers;
1307
+ }
1308
+ // It's better to have a const than two Object.entries()
1309
+ const members = Object.entries(cmpMeta.$members$);
1310
+ const prototype = Cstr.prototype;
1311
+ members.map(([memberName, [memberFlags]]) => {
1312
+ if ((memberFlags & 31 /* Prop */ ||
1313
+ ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1314
+ // proxyComponent - prop
1315
+ Object.defineProperty(prototype, memberName, {
1316
+ get() {
1317
+ // proxyComponent, get value
1318
+ return getValue(this, memberName);
1319
+ },
1320
+ set(newValue) {
1321
+ // proxyComponent, set value
1322
+ setValue(this, memberName, newValue, cmpMeta);
1323
+ },
1324
+ configurable: true,
1325
+ enumerable: true,
1326
+ });
1327
+ }
1328
+ else if (flags & 1 /* isElementConstructor */ &&
1329
+ memberFlags & 64 /* Method */) {
1330
+ // proxyComponent - method
1331
+ Object.defineProperty(prototype, memberName, {
1332
+ value(...args) {
1333
+ const ref = getHostRef(this);
1334
+ return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
1335
+ },
1336
+ });
1337
+ }
1338
+ });
1339
+ if ((flags & 1 /* isElementConstructor */)) {
1340
+ const attrNameToPropName = new Map();
1341
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1342
+ plt.jmp(() => {
1343
+ const propName = attrNameToPropName.get(attrName);
1344
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1345
+ // in the case where an attribute was set inline.
1346
+ // ```html
1347
+ // <my-component some-attribute="some-value"></my-component>
1348
+ // ```
1349
+ //
1350
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
1351
+ // programmatically changes it before it has been upgraded as shown below:
1352
+ //
1353
+ // ```html
1354
+ // <!-- this component has _not_ been upgraded yet -->
1355
+ // <my-component id="test" some-attribute="some-value"></my-component>
1356
+ // <script>
1357
+ // // grab non-upgraded component
1358
+ // el = document.querySelector("#test");
1359
+ // el.someAttribute = "another-value";
1360
+ // // upgrade component
1361
+ // customElements.define('my-component', MyComponent);
1362
+ // </script>
1363
+ // ```
1364
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1365
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1366
+ // to the value that was set inline i.e. "some-value" from above example. When
1367
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
1368
+ //
1369
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1370
+ // by connectedCallback as this attributeChangedCallback will not fire.
1371
+ //
1372
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1373
+ //
1374
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1375
+ // properties here given that this goes against best practices outlined here
1376
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1377
+ if (this.hasOwnProperty(propName)) {
1378
+ newValue = this[propName];
1379
+ delete this[propName];
1380
+ }
1381
+ else if (prototype.hasOwnProperty(propName) &&
1382
+ typeof this[propName] === 'number' &&
1383
+ this[propName] == newValue) {
1384
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1385
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1386
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1387
+ return;
1388
+ }
1389
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1390
+ });
1391
+ };
1392
+ // create an array of attributes to observe
1393
+ // and also create a map of html attribute name to js property name
1394
+ Cstr.observedAttributes = members
1395
+ .filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
1396
+ .map(([propName, m]) => {
1397
+ const attrName = m[1] || propName;
1398
+ attrNameToPropName.set(attrName, propName);
1399
+ if (m[0] & 512 /* ReflectAttr */) {
1400
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
1401
+ }
1402
+ return attrName;
1403
+ });
1404
+ }
1405
+ }
1406
+ return Cstr;
1407
+ };
1408
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
1409
+ // initializeComponent
1410
+ if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
1411
+ {
1412
+ // we haven't initialized this element yet
1413
+ hostRef.$flags$ |= 32 /* hasInitializedComponent */;
1414
+ // lazy loaded components
1415
+ // request the component's implementation to be
1416
+ // wired up with the host element
1417
+ Cstr = loadModule(cmpMeta);
1418
+ if (Cstr.then) {
1419
+ // Await creates a micro-task avoid if possible
1420
+ const endLoad = uniqueTime();
1421
+ Cstr = await Cstr;
1422
+ endLoad();
1423
+ }
1424
+ if (!Cstr.isProxied) {
1425
+ // we've never proxied this Constructor before
1426
+ // let's add the getters/setters to its prototype before
1427
+ // the first time we create an instance of the implementation
1428
+ {
1429
+ cmpMeta.$watchers$ = Cstr.watchers;
1430
+ }
1431
+ proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
1432
+ Cstr.isProxied = true;
1433
+ }
1434
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
1435
+ // ok, time to construct the instance
1436
+ // but let's keep track of when we start and stop
1437
+ // so that the getters/setters don't incorrectly step on data
1438
+ {
1439
+ hostRef.$flags$ |= 8 /* isConstructingInstance */;
1440
+ }
1441
+ // construct the lazy-loaded component implementation
1442
+ // passing the hostRef is very important during
1443
+ // construction in order to directly wire together the
1444
+ // host element and the lazy-loaded instance
1445
+ try {
1446
+ new Cstr(hostRef);
1447
+ }
1448
+ catch (e) {
1449
+ consoleError(e);
1450
+ }
1451
+ {
1452
+ hostRef.$flags$ &= ~8 /* isConstructingInstance */;
1453
+ }
1454
+ {
1455
+ hostRef.$flags$ |= 128 /* isWatchReady */;
1456
+ }
1457
+ endNewInstance();
1458
+ }
1459
+ if (Cstr.style) {
1460
+ // this component has styles but we haven't registered them yet
1461
+ let style = Cstr.style;
1462
+ const scopeId = getScopeId(cmpMeta);
1463
+ if (!styles.has(scopeId)) {
1464
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
1465
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
1466
+ endRegisterStyles();
1467
+ }
1468
+ }
1469
+ }
1470
+ // we've successfully created a lazy instance
1471
+ const ancestorComponent = hostRef.$ancestorComponent$;
1472
+ const schedule = () => scheduleUpdate(hostRef, true);
1473
+ if (ancestorComponent && ancestorComponent['s-rc']) {
1474
+ // this is the initial load and this component it has an ancestor component
1475
+ // but the ancestor component has NOT fired its will update lifecycle yet
1476
+ // so let's just cool our jets and wait for the ancestor to continue first
1477
+ // this will get fired off when the ancestor component
1478
+ // finally gets around to rendering its lazy self
1479
+ // fire off the initial update
1480
+ ancestorComponent['s-rc'].push(schedule);
1481
+ }
1482
+ else {
1483
+ schedule();
1484
+ }
1485
+ };
1486
+ const connectedCallback = (elm) => {
1487
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1488
+ const hostRef = getHostRef(elm);
1489
+ const cmpMeta = hostRef.$cmpMeta$;
1490
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
1491
+ if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
1492
+ // first time this component has connected
1493
+ hostRef.$flags$ |= 1 /* hasConnected */;
1494
+ {
1495
+ // initUpdate
1496
+ // if the slot polyfill is required we'll need to put some nodes
1497
+ // in here to act as original content anchors as we move nodes around
1498
+ // host element has been connected to the DOM
1499
+ if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
1500
+ setContentReference(elm);
1501
+ }
1502
+ }
1503
+ {
1504
+ // find the first ancestor component (if there is one) and register
1505
+ // this component as one of the actively loading child components for its ancestor
1506
+ let ancestorComponent = elm;
1507
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
1508
+ // climb up the ancestors looking for the first
1509
+ // component that hasn't finished its lifecycle update yet
1510
+ if (ancestorComponent['s-p']) {
1511
+ // we found this components first ancestor component
1512
+ // keep a reference to this component's ancestor component
1513
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
1514
+ break;
1515
+ }
1516
+ }
1517
+ }
1518
+ // Lazy properties
1519
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1520
+ if (cmpMeta.$members$) {
1521
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
1522
+ if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
1523
+ const value = elm[memberName];
1524
+ delete elm[memberName];
1525
+ elm[memberName] = value;
1526
+ }
1527
+ });
1528
+ }
1529
+ {
1530
+ initializeComponent(elm, hostRef, cmpMeta);
1531
+ }
1532
+ }
1533
+ endConnected();
1534
+ }
1535
+ };
1536
+ const setContentReference = (elm) => {
1537
+ // only required when we're NOT using native shadow dom (slot)
1538
+ // or this browser doesn't support native shadow dom
1539
+ // and this host element was NOT created with SSR
1540
+ // let's pick out the inner content for slot projection
1541
+ // create a node to represent where the original
1542
+ // content was first placed, which is useful later on
1543
+ const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1544
+ contentRefElm['s-cn'] = true;
1545
+ elm.insertBefore(contentRefElm, elm.firstChild);
1546
+ };
1547
+ const disconnectedCallback = (elm) => {
1548
+ if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1549
+ getHostRef(elm);
1550
+ }
1551
+ };
1552
+ const bootstrapLazy = (lazyBundles, options = {}) => {
1553
+ const endBootstrap = createTime();
1554
+ const cmpTags = [];
1555
+ const exclude = options.exclude || [];
1556
+ const customElements = win.customElements;
1557
+ const head = doc.head;
1558
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
1559
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
1560
+ const deferredConnectedCallbacks = [];
1561
+ let appLoadFallback;
1562
+ let isBootstrapping = true;
1563
+ Object.assign(plt, options);
1564
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1565
+ lazyBundles.map((lazyBundle) => {
1566
+ lazyBundle[1].map((compactMeta) => {
1567
+ const cmpMeta = {
1568
+ $flags$: compactMeta[0],
1569
+ $tagName$: compactMeta[1],
1570
+ $members$: compactMeta[2],
1571
+ $listeners$: compactMeta[3],
1572
+ };
1573
+ {
1574
+ cmpMeta.$members$ = compactMeta[2];
1575
+ }
1576
+ {
1577
+ cmpMeta.$attrsToReflect$ = [];
1578
+ }
1579
+ {
1580
+ cmpMeta.$watchers$ = {};
1581
+ }
1582
+ const tagName = cmpMeta.$tagName$;
1583
+ const HostElement = class extends HTMLElement {
1584
+ // StencilLazyHost
1585
+ constructor(self) {
1586
+ // @ts-ignore
1587
+ super(self);
1588
+ self = this;
1589
+ registerHost(self, cmpMeta);
1590
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1591
+ // this component is using shadow dom
1592
+ // and this browser supports shadow dom
1593
+ // add the read-only property "shadowRoot" to the host element
1594
+ // adding the shadow root build conditionals to minimize runtime
1595
+ {
1596
+ {
1597
+ self.attachShadow({ mode: 'open' });
1598
+ }
1599
+ }
1600
+ }
1601
+ }
1602
+ connectedCallback() {
1603
+ if (appLoadFallback) {
1604
+ clearTimeout(appLoadFallback);
1605
+ appLoadFallback = null;
1606
+ }
1607
+ if (isBootstrapping) {
1608
+ // connectedCallback will be processed once all components have been registered
1609
+ deferredConnectedCallbacks.push(this);
1610
+ }
1611
+ else {
1612
+ plt.jmp(() => connectedCallback(this));
1613
+ }
1614
+ }
1615
+ disconnectedCallback() {
1616
+ plt.jmp(() => disconnectedCallback(this));
1617
+ }
1618
+ componentOnReady() {
1619
+ return getHostRef(this).$onReadyPromise$;
1620
+ }
1621
+ };
1622
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
1623
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
1624
+ cmpTags.push(tagName);
1625
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
1626
+ }
1627
+ });
1628
+ });
1629
+ {
1630
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1631
+ visibilityStyle.setAttribute('data-styles', '');
1632
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1633
+ }
1634
+ // Process deferred connectedCallbacks now all components have been registered
1635
+ isBootstrapping = false;
1636
+ if (deferredConnectedCallbacks.length) {
1637
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1638
+ }
1639
+ else {
1640
+ {
1641
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
1642
+ }
1643
+ }
1644
+ // Fallback appLoad event
1645
+ endBootstrap();
1646
+ };
1647
+ const getAssetPath = (path) => {
1648
+ const assetUrl = new URL(path, plt.$resourcesUrl$);
1649
+ return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
1650
+ };
1651
+ const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
1652
+ const hostRefs = new WeakMap();
1653
+ const getHostRef = (ref) => hostRefs.get(ref);
1654
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
1655
+ const registerHost = (elm, cmpMeta) => {
1656
+ const hostRef = {
1657
+ $flags$: 0,
1658
+ $hostElement$: elm,
1659
+ $cmpMeta$: cmpMeta,
1660
+ $instanceValues$: new Map(),
1661
+ };
1662
+ {
1663
+ hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
1664
+ }
1665
+ {
1666
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1667
+ elm['s-p'] = [];
1668
+ elm['s-rc'] = [];
1669
+ }
1670
+ return hostRefs.set(elm, hostRef);
1671
+ };
1672
+ const isMemberInElement = (elm, memberName) => memberName in elm;
1673
+ const consoleError = (e, el) => (0, console.error)(e, el);
1674
+ const cmpModules = /*@__PURE__*/ new Map();
1675
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1676
+ // loadModuleImport
1677
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
1678
+ const bundleId = cmpMeta.$lazyBundleId$;
1679
+ const module = cmpModules.get(bundleId) ;
1680
+ if (module) {
1681
+ return module[exportName];
1682
+ }
1683
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
1684
+ return import(
1685
+ /* @vite-ignore */
1686
+ /* webpackInclude: /\.entry\.js$/ */
1687
+ /* webpackExclude: /\.system\.entry\.js$/ */
1688
+ /* webpackMode: "lazy" */
1689
+ `./${bundleId}.entry.js${''}`).then((importedModule) => {
1690
+ {
1691
+ cmpModules.set(bundleId, importedModule);
1692
+ }
1693
+ return importedModule[exportName];
1694
+ }, consoleError);
1695
+ };
1696
+ const styles = new Map();
1697
+ const queueDomReads = [];
1698
+ const queueDomWrites = [];
1699
+ const queueTask = (queue, write) => (cb) => {
1700
+ queue.push(cb);
1701
+ if (!queuePending) {
1702
+ queuePending = true;
1703
+ if (write && plt.$flags$ & 4 /* queueSync */) {
1704
+ nextTick(flush);
1705
+ }
1706
+ else {
1707
+ plt.raf(flush);
1708
+ }
1709
+ }
1710
+ };
1711
+ const consume = (queue) => {
1712
+ for (let i = 0; i < queue.length; i++) {
1713
+ try {
1714
+ queue[i](performance.now());
1715
+ }
1716
+ catch (e) {
1717
+ consoleError(e);
1718
+ }
1719
+ }
1720
+ queue.length = 0;
1721
+ };
1722
+ const flush = () => {
1723
+ // always force a bunch of medium callbacks to run, but still have
1724
+ // a throttle on how many can run in a certain time
1725
+ // DOM READS!!!
1726
+ consume(queueDomReads);
1727
+ // DOM WRITES!!!
1728
+ {
1729
+ consume(queueDomWrites);
1730
+ if ((queuePending = queueDomReads.length > 0)) {
1731
+ // still more to do yet, but we've run out of time
1732
+ // let's let this thing cool off and try again in the next tick
1733
+ plt.raf(flush);
1734
+ }
1735
+ }
1736
+ };
1737
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1738
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1739
+
1740
+ export { Host as H, getAssetPath as a, bootstrapLazy as b, createEvent as c, forceUpdate as f, getElement as g, h, promiseResolve as p, registerInstance as r, setAssetPath as s };