@paperless/core 0.0.0

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