@sankhyalabs/sankhyablocks 1.3.34 → 1.4.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/dist/cjs/SnkMessageBuilder-7717f1e4.js +326 -0
  2. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  3. package/dist/cjs/css-shim-b8158822.js +6 -0
  4. package/dist/cjs/dom-36862b77.js +75 -0
  5. package/dist/cjs/filter-item-type.enum-e2e1bc5b.js +14 -0
  6. package/dist/cjs/index-02201bc9.js +2397 -0
  7. package/dist/cjs/index-b0b676c5.js +3298 -0
  8. package/dist/cjs/loader.cjs.js +19 -3
  9. package/dist/cjs/sankhyablocks.cjs.js +117 -5
  10. package/dist/cjs/shadow-css-346c0795.js +389 -0
  11. package/dist/cjs/snk-application.cjs.entry.js +720 -168
  12. package/dist/cjs/snk-crud.cjs.entry.js +70 -0
  13. package/dist/cjs/snk-data-unit.cjs.entry.js +280 -0
  14. package/dist/cjs/snk-filter-bar.cjs.entry.js +278 -0
  15. package/dist/cjs/snk-filter-binary-select.cjs.entry.js +47 -0
  16. package/dist/cjs/snk-filter-detail.cjs.entry.js +49 -0
  17. package/dist/cjs/snk-filter-item.cjs.entry.js +154 -0
  18. package/dist/cjs/snk-filter-list.cjs.entry.js +91 -0
  19. package/dist/cjs/snk-filter-multi-select.cjs.entry.js +23 -0
  20. package/dist/cjs/snk-filter-number.cjs.entry.js +24 -0
  21. package/dist/cjs/snk-filter-period.cjs.entry.js +37 -0
  22. package/dist/cjs/snk-filter-search.cjs.entry.js +44 -0
  23. package/dist/cjs/snk-filter-text.cjs.entry.js +22 -0
  24. package/dist/cjs/snk-form.cjs.entry.js +133 -0
  25. package/dist/cjs/snk-grid.cjs.entry.js +79 -0
  26. package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -5
  27. package/dist/cjs/snk-taskbar.cjs.entry.js +160 -0
  28. package/dist/cjs/taskbar-elements-283c737e.js +93 -0
  29. package/dist/cjs/taskbar-processor-6bd0d35c.js +47 -0
  30. package/dist/cjs/teste-pesquisa.cjs.entry.js +5 -5
  31. package/dist/collection/collection-manifest.json +17 -2
  32. package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +9 -2
  33. package/dist/collection/components/snk-application/snk-application.js +1126 -621
  34. package/dist/collection/components/snk-crud/snk-crud.css +6 -0
  35. package/dist/collection/components/snk-crud/snk-crud.js +203 -0
  36. package/dist/collection/components/snk-data-unit/snk-data-unit.css +6 -0
  37. package/dist/collection/components/snk-data-unit/snk-data-unit.js +544 -0
  38. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +88 -0
  39. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +64 -0
  40. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +65 -0
  41. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +78 -0
  42. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +118 -0
  43. package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +63 -0
  44. package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +10 -0
  45. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +118 -0
  46. package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +255 -0
  47. package/dist/collection/components/snk-filter-bar/filter-list/snk-filter-list.js +233 -0
  48. package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +114 -0
  49. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +353 -0
  50. package/dist/collection/components/snk-form/snk-form.css +34 -0
  51. package/dist/collection/components/snk-form/snk-form.js +258 -0
  52. package/dist/collection/components/snk-grid/snk-grid.css +18 -0
  53. package/dist/collection/components/snk-grid/snk-grid.js +205 -0
  54. package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +80 -79
  55. package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +86 -0
  56. package/dist/collection/components/snk-taskbar/processor/taskbar-processor.js +43 -0
  57. package/dist/collection/components/snk-taskbar/snk-taskbar.css +3 -0
  58. package/dist/collection/components/snk-taskbar/snk-taskbar.js +307 -0
  59. package/dist/collection/components/teste-pesquisa/teste-pesquisa.js +12 -9
  60. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +37 -12
  61. package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +52 -21
  62. package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +54 -0
  63. package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +4 -3
  64. package/dist/collection/lib/http/data-fetcher/fetchers/totals-fetcher.js +47 -0
  65. package/dist/collection/lib/index.js +1 -0
  66. package/dist/collection/lib/message/SnkMessageBuilder.js +121 -0
  67. package/dist/collection/lib/message/resources/snk-data-unit.msg.js +23 -0
  68. package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +18 -0
  69. package/dist/collection/lib/message/resources/snk-form.msg.js +10 -0
  70. package/dist/collection/lib/message/resources/snk-taskbar.msg.js +17 -0
  71. package/dist/components/SnkMessageBuilder.js +303 -0
  72. package/dist/components/filter-item-type.enum.js +12 -0
  73. package/dist/components/index.d.ts +18 -5
  74. package/dist/components/index.js +22 -0
  75. package/dist/components/index2.js +2384 -0
  76. package/dist/components/snk-application2.js +700 -139
  77. package/dist/components/snk-crud.d.ts +11 -0
  78. package/dist/components/snk-crud.js +133 -0
  79. package/dist/components/snk-data-unit.d.ts +11 -0
  80. package/dist/components/snk-data-unit.js +303 -0
  81. package/dist/components/snk-filter-bar.d.ts +11 -0
  82. package/dist/components/snk-filter-bar.js +6 -0
  83. package/dist/components/snk-filter-bar2.js +310 -0
  84. package/dist/components/snk-filter-binary-select.d.ts +11 -0
  85. package/dist/components/snk-filter-binary-select.js +63 -0
  86. package/dist/components/snk-filter-detail.d.ts +11 -0
  87. package/dist/components/snk-filter-detail.js +6 -0
  88. package/dist/components/snk-filter-detail2.js +63 -0
  89. package/dist/components/snk-filter-item.d.ts +11 -0
  90. package/dist/components/snk-filter-item.js +6 -0
  91. package/dist/components/snk-filter-item2.js +175 -0
  92. package/dist/components/snk-filter-list.d.ts +11 -0
  93. package/dist/components/snk-filter-list.js +6 -0
  94. package/dist/components/snk-filter-list2.js +111 -0
  95. package/dist/components/snk-filter-multi-select.d.ts +11 -0
  96. package/dist/components/snk-filter-multi-select.js +39 -0
  97. package/dist/components/snk-filter-number.d.ts +11 -0
  98. package/dist/components/snk-filter-number.js +40 -0
  99. package/dist/components/snk-filter-period.d.ts +11 -0
  100. package/dist/components/snk-filter-period.js +53 -0
  101. package/dist/components/snk-filter-search.d.ts +11 -0
  102. package/dist/components/snk-filter-search.js +62 -0
  103. package/dist/components/snk-filter-text.d.ts +11 -0
  104. package/dist/components/snk-filter-text.js +38 -0
  105. package/dist/components/snk-form.d.ts +11 -0
  106. package/dist/components/snk-form.js +6 -0
  107. package/dist/components/snk-form2.js +159 -0
  108. package/dist/components/snk-grid.d.ts +11 -0
  109. package/dist/components/snk-grid.js +6 -0
  110. package/dist/components/snk-grid2.js +127 -0
  111. package/dist/components/snk-pesquisa2.js +1 -1
  112. package/dist/components/snk-taskbar.d.ts +11 -0
  113. package/dist/components/snk-taskbar.js +6 -0
  114. package/dist/components/snk-taskbar2.js +264 -0
  115. package/dist/components/taskbar-processor.js +45 -0
  116. package/dist/components/teste-pesquisa.js +1 -1
  117. package/dist/esm/SnkMessageBuilder-a7da466b.js +303 -0
  118. package/dist/esm/app-globals-0f993ce5.js +3 -0
  119. package/dist/esm/css-shim-b3f2ee8d.js +4 -0
  120. package/dist/esm/dom-665d6011.js +73 -0
  121. package/dist/esm/filter-item-type.enum-61fbf80a.js +12 -0
  122. package/dist/esm/index-2b4d2d14.js +3262 -0
  123. package/dist/esm/index-f1d3e4da.js +2384 -0
  124. package/dist/esm/loader.js +19 -3
  125. package/dist/esm/polyfills/css-shim.js +1 -1
  126. package/dist/esm/sankhyablocks.js +117 -5
  127. package/dist/esm/shadow-css-b18e99d7.js +387 -0
  128. package/dist/esm/snk-application.entry.js +692 -140
  129. package/dist/esm/snk-crud.entry.js +66 -0
  130. package/dist/esm/snk-data-unit.entry.js +276 -0
  131. package/dist/esm/snk-filter-bar.entry.js +274 -0
  132. package/dist/esm/snk-filter-binary-select.entry.js +43 -0
  133. package/dist/esm/snk-filter-detail.entry.js +45 -0
  134. package/dist/esm/snk-filter-item.entry.js +150 -0
  135. package/dist/esm/snk-filter-list.entry.js +87 -0
  136. package/dist/esm/snk-filter-multi-select.entry.js +19 -0
  137. package/dist/esm/snk-filter-number.entry.js +20 -0
  138. package/dist/esm/snk-filter-period.entry.js +33 -0
  139. package/dist/esm/snk-filter-search.entry.js +40 -0
  140. package/dist/esm/snk-filter-text.entry.js +18 -0
  141. package/dist/esm/snk-form.entry.js +129 -0
  142. package/dist/esm/snk-grid.entry.js +75 -0
  143. package/dist/esm/snk-pesquisa.entry.js +2 -2
  144. package/dist/esm/snk-taskbar.entry.js +156 -0
  145. package/dist/esm/taskbar-elements-35d64ff9.js +90 -0
  146. package/dist/esm/taskbar-processor-aa6772c9.js +45 -0
  147. package/dist/esm/teste-pesquisa.entry.js +2 -2
  148. package/dist/sankhyablocks/SnkMessageBuilder-a7da466b.js +303 -0
  149. package/dist/sankhyablocks/app-globals-0f993ce5.js +3 -0
  150. package/dist/sankhyablocks/css-shim-b3f2ee8d.js +4 -0
  151. package/dist/sankhyablocks/dom-665d6011.js +73 -0
  152. package/dist/sankhyablocks/filter-item-type.enum-61fbf80a.js +12 -0
  153. package/dist/sankhyablocks/index-2b4d2d14.js +3262 -0
  154. package/dist/sankhyablocks/index-f1d3e4da.js +2384 -0
  155. package/dist/sankhyablocks/index.esm.js +1 -0
  156. package/dist/sankhyablocks/sankhyablocks.esm.js +129 -1
  157. package/dist/sankhyablocks/shadow-css-b18e99d7.js +387 -0
  158. package/dist/sankhyablocks/snk-application.entry.js +8148 -0
  159. package/dist/sankhyablocks/snk-crud.entry.js +66 -0
  160. package/dist/sankhyablocks/snk-data-unit.entry.js +276 -0
  161. package/dist/sankhyablocks/snk-filter-bar.entry.js +274 -0
  162. package/dist/sankhyablocks/snk-filter-binary-select.entry.js +43 -0
  163. package/dist/sankhyablocks/snk-filter-detail.entry.js +45 -0
  164. package/dist/sankhyablocks/snk-filter-item.entry.js +150 -0
  165. package/dist/sankhyablocks/snk-filter-list.entry.js +87 -0
  166. package/dist/sankhyablocks/snk-filter-multi-select.entry.js +19 -0
  167. package/dist/sankhyablocks/snk-filter-number.entry.js +20 -0
  168. package/dist/sankhyablocks/snk-filter-period.entry.js +33 -0
  169. package/dist/sankhyablocks/snk-filter-search.entry.js +40 -0
  170. package/dist/sankhyablocks/snk-filter-text.entry.js +18 -0
  171. package/dist/sankhyablocks/snk-form.entry.js +129 -0
  172. package/dist/sankhyablocks/snk-grid.entry.js +75 -0
  173. package/dist/sankhyablocks/snk-pesquisa.entry.js +311 -0
  174. package/dist/sankhyablocks/snk-taskbar.entry.js +156 -0
  175. package/dist/sankhyablocks/taskbar-elements-35d64ff9.js +90 -0
  176. package/dist/sankhyablocks/taskbar-processor-aa6772c9.js +45 -0
  177. package/dist/sankhyablocks/teste-pesquisa.entry.js +33 -0
  178. package/dist/types/components/snk-application/errorhandler/snk-error-handler.d.ts +1 -0
  179. package/dist/types/components/snk-application/snk-application.d.ts +145 -15
  180. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.d.ts +12 -0
  181. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.d.ts +7 -0
  182. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +7 -0
  183. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +14 -0
  184. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +12 -0
  185. package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-text.d.ts +7 -0
  186. package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +9 -0
  187. package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +14 -0
  188. package/dist/types/components/snk-filter-bar/filter-list/snk-filter-list.d.ts +40 -0
  189. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +51 -0
  190. package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +29 -0
  191. package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +12 -0
  192. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +84 -0
  193. package/dist/types/components.d.ts +696 -8
  194. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +7 -6
  195. package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +2 -0
  196. package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +6 -0
  197. package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +1 -1
  198. package/dist/types/lib/http/data-fetcher/fetchers/totals-fetcher.d.ts +8 -0
  199. package/dist/types/lib/index.d.ts +1 -0
  200. package/dist/types/lib/message/SnkMessageBuilder.d.ts +42 -0
  201. package/dist/types/lib/message/resources/snk-data-unit.msg.d.ts +2 -0
  202. package/dist/types/lib/message/resources/snk-filter-bar.msg.d.ts +2 -0
  203. package/dist/types/lib/message/resources/snk-form.msg.d.ts +2 -0
  204. package/dist/types/lib/message/resources/snk-taskbar.msg.d.ts +2 -0
  205. package/dist/types/stencil-public-runtime.d.ts +15 -4
  206. package/loader/package.json +1 -0
  207. package/package.json +5 -5
  208. package/react/components.d.ts +0 -2
  209. package/react/components.js +0 -2
  210. package/react/components.js.map +1 -1
  211. package/dist/cjs/index-1133bc2a.js +0 -1235
  212. package/dist/esm/index-ffda6382.js +0 -1208
  213. package/dist/sankhyablocks/p-2a7b4cb3.entry.js +0 -1
  214. package/dist/sankhyablocks/p-9520d78a.entry.js +0 -1
  215. package/dist/sankhyablocks/p-98e8490d.entry.js +0 -69
  216. package/dist/sankhyablocks/p-edcb9d8e.js +0 -2
@@ -0,0 +1,3298 @@
1
+ 'use strict';
2
+
3
+ function _interopNamespace(e) {
4
+ if (e && e.__esModule) return e;
5
+ var n = Object.create(null);
6
+ if (e) {
7
+ Object.keys(e).forEach(function (k) {
8
+ if (k !== 'default') {
9
+ var d = Object.getOwnPropertyDescriptor(e, k);
10
+ Object.defineProperty(n, k, d.get ? d : {
11
+ enumerable: true,
12
+ get: function () {
13
+ return e[k];
14
+ }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n['default'] = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ const NAMESPACE = 'sankhyablocks';
24
+ const BUILD = /* sankhyablocks */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: true, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: true, cmpWillUpdate: false, connectedCallback: true, constructableCSS: true, cssAnnotations: true, cssVarShim: false, devTools: false, disconnectedCallback: true, dynamicImportShim: false, element: false, event: true, hasRenderFn: true, hostListener: true, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: true, isTesting: true, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: true, member: true, method: true, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, safari10: false, scoped: true, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, shadowDomShim: false, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: false, vdomText: true, vdomXlink: false, watchCallback: true };
25
+ const Env = /* sankhyablocks */ {};
26
+
27
+ /**
28
+ * Virtual DOM patching algorithm based on Snabbdom by
29
+ * Simon Friis Vindum (@paldepind)
30
+ * Licensed under the MIT License
31
+ * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
32
+ *
33
+ * Modified for Stencil's renderer and slot projection
34
+ */
35
+ let scopeId;
36
+ let contentRef;
37
+ let hostTagName;
38
+ let customError;
39
+ let i = 0;
40
+ let useNativeShadowDom = false;
41
+ let checkSlotFallbackVisibility = false;
42
+ let checkSlotRelocate = false;
43
+ let isSvgMode = false;
44
+ let renderingRef = null;
45
+ let queueCongestion = 0;
46
+ let queuePending = false;
47
+ const Build = {
48
+ isDev: BUILD.isDev ? true : false,
49
+ isBrowser: true,
50
+ isServer: false,
51
+ isTesting: BUILD.isTesting ? true : false,
52
+ };
53
+ const Context = {};
54
+ const getAssetPath = (path) => {
55
+ const assetUrl = new URL(path, plt.$resourcesUrl$);
56
+ return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
57
+ };
58
+ const setAssetPath = (path) => (plt.$resourcesUrl$ = path);
59
+ const createTime = (fnName, tagName = '') => {
60
+ if (BUILD.profile && performance.mark) {
61
+ const key = `st:${fnName}:${tagName}:${i++}`;
62
+ // Start
63
+ performance.mark(key);
64
+ // End
65
+ return () => performance.measure(`[Stencil] ${fnName}() <${tagName}>`, key);
66
+ }
67
+ else {
68
+ return () => {
69
+ return;
70
+ };
71
+ }
72
+ };
73
+ const uniqueTime = (key, measureText) => {
74
+ if (BUILD.profile && performance.mark) {
75
+ if (performance.getEntriesByName(key).length === 0) {
76
+ performance.mark(key);
77
+ }
78
+ return () => {
79
+ if (performance.getEntriesByName(measureText).length === 0) {
80
+ performance.measure(measureText, key);
81
+ }
82
+ };
83
+ }
84
+ else {
85
+ return () => {
86
+ return;
87
+ };
88
+ }
89
+ };
90
+ const inspect = (ref) => {
91
+ const hostRef = getHostRef(ref);
92
+ if (!hostRef) {
93
+ return undefined;
94
+ }
95
+ const flags = hostRef.$flags$;
96
+ const hostElement = hostRef.$hostElement$;
97
+ return {
98
+ renderCount: hostRef.$renderCount$,
99
+ flags: {
100
+ hasRendered: !!(flags & 2 /* HOST_FLAGS.hasRendered */),
101
+ hasConnected: !!(flags & 1 /* HOST_FLAGS.hasConnected */),
102
+ isWaitingForChildren: !!(flags & 4 /* HOST_FLAGS.isWaitingForChildren */),
103
+ isConstructingInstance: !!(flags & 8 /* HOST_FLAGS.isConstructingInstance */),
104
+ isQueuedForUpdate: !!(flags & 16 /* HOST_FLAGS.isQueuedForUpdate */),
105
+ hasInitializedComponent: !!(flags & 32 /* HOST_FLAGS.hasInitializedComponent */),
106
+ hasLoadedComponent: !!(flags & 64 /* HOST_FLAGS.hasLoadedComponent */),
107
+ isWatchReady: !!(flags & 128 /* HOST_FLAGS.isWatchReady */),
108
+ isListenReady: !!(flags & 256 /* HOST_FLAGS.isListenReady */),
109
+ needsRerender: !!(flags & 512 /* HOST_FLAGS.needsRerender */),
110
+ },
111
+ instanceValues: hostRef.$instanceValues$,
112
+ ancestorComponent: hostRef.$ancestorComponent$,
113
+ hostElement,
114
+ lazyInstance: hostRef.$lazyInstance$,
115
+ vnode: hostRef.$vnode$,
116
+ modeName: hostRef.$modeName$,
117
+ onReadyPromise: hostRef.$onReadyPromise$,
118
+ onReadyResolve: hostRef.$onReadyResolve$,
119
+ onInstancePromise: hostRef.$onInstancePromise$,
120
+ onInstanceResolve: hostRef.$onInstanceResolve$,
121
+ onRenderResolve: hostRef.$onRenderResolve$,
122
+ queuedListeners: hostRef.$queuedListeners$,
123
+ rmListeners: hostRef.$rmListeners$,
124
+ ['s-id']: hostElement['s-id'],
125
+ ['s-cr']: hostElement['s-cr'],
126
+ ['s-lr']: hostElement['s-lr'],
127
+ ['s-p']: hostElement['s-p'],
128
+ ['s-rc']: hostElement['s-rc'],
129
+ ['s-sc']: hostElement['s-sc'],
130
+ };
131
+ };
132
+ const installDevTools = () => {
133
+ if (BUILD.devTools) {
134
+ const stencil = (win.stencil = win.stencil || {});
135
+ const originalInspect = stencil.inspect;
136
+ stencil.inspect = (ref) => {
137
+ let result = inspect(ref);
138
+ if (!result && typeof originalInspect === 'function') {
139
+ result = originalInspect(ref);
140
+ }
141
+ return result;
142
+ };
143
+ }
144
+ };
145
+ const CONTENT_REF_ID = 'r';
146
+ const ORG_LOCATION_ID = 'o';
147
+ const SLOT_NODE_ID = 's';
148
+ const TEXT_NODE_ID = 't';
149
+ const HYDRATE_ID = 's-id';
150
+ const HYDRATED_STYLE_ID = 'sty-id';
151
+ const HYDRATE_CHILD_ID = 'c-id';
152
+ const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
153
+ const XLINK_NS = 'http://www.w3.org/1999/xlink';
154
+ /**
155
+ * Default style mode id
156
+ */
157
+ /**
158
+ * Reusable empty obj/array
159
+ * Don't add values to these!!
160
+ */
161
+ const EMPTY_OBJ = {};
162
+ /**
163
+ * Namespaces
164
+ */
165
+ const SVG_NS = 'http://www.w3.org/2000/svg';
166
+ const HTML_NS = 'http://www.w3.org/1999/xhtml';
167
+ const isDef = (v) => v != null;
168
+ const isComplexType = (o) => {
169
+ // https://jsperf.com/typeof-fn-object/5
170
+ o = typeof o;
171
+ return o === 'object' || o === 'function';
172
+ };
173
+ /**
174
+ * Production h() function based on Preact by
175
+ * Jason Miller (@developit)
176
+ * Licensed under the MIT License
177
+ * https://github.com/developit/preact/blob/master/LICENSE
178
+ *
179
+ * Modified for Stencil's compiler and vdom
180
+ */
181
+ // const stack: any[] = [];
182
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
183
+ // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
184
+ const h = (nodeName, vnodeData, ...children) => {
185
+ let child = null;
186
+ let key = null;
187
+ let slotName = null;
188
+ let simple = false;
189
+ let lastSimple = false;
190
+ const vNodeChildren = [];
191
+ const walk = (c) => {
192
+ for (let i = 0; i < c.length; i++) {
193
+ child = c[i];
194
+ if (Array.isArray(child)) {
195
+ walk(child);
196
+ }
197
+ else if (child != null && typeof child !== 'boolean') {
198
+ if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
199
+ child = String(child);
200
+ }
201
+ else if (BUILD.isDev && typeof nodeName !== 'function' && child.$flags$ === undefined) {
202
+ consoleDevError(`vNode passed as children has unexpected type.
203
+ Make sure it's using the correct h() function.
204
+ Empty objects can also be the cause, look for JSX comments that became objects.`);
205
+ }
206
+ if (simple && lastSimple) {
207
+ // If the previous child was simple (string), we merge both
208
+ vNodeChildren[vNodeChildren.length - 1].$text$ += child;
209
+ }
210
+ else {
211
+ // Append a new vNode, if it's text, we create a text vNode
212
+ vNodeChildren.push(simple ? newVNode(null, child) : child);
213
+ }
214
+ lastSimple = simple;
215
+ }
216
+ }
217
+ };
218
+ walk(children);
219
+ if (vnodeData) {
220
+ if (BUILD.isDev && nodeName === 'input') {
221
+ validateInputProperties(vnodeData);
222
+ }
223
+ // normalize class / classname attributes
224
+ if (BUILD.vdomKey && vnodeData.key) {
225
+ key = vnodeData.key;
226
+ }
227
+ if (BUILD.slotRelocation && vnodeData.name) {
228
+ slotName = vnodeData.name;
229
+ }
230
+ if (BUILD.vdomClass) {
231
+ const classData = vnodeData.className || vnodeData.class;
232
+ if (classData) {
233
+ vnodeData.class =
234
+ typeof classData !== 'object'
235
+ ? classData
236
+ : Object.keys(classData)
237
+ .filter((k) => classData[k])
238
+ .join(' ');
239
+ }
240
+ }
241
+ }
242
+ if (BUILD.isDev && vNodeChildren.some(isHost)) {
243
+ consoleDevError(`The <Host> must be the single root component. Make sure:
244
+ - You are NOT using hostData() and <Host> in the same component.
245
+ - <Host> is used once, and it's the single root component of the render() function.`);
246
+ }
247
+ if (BUILD.vdomFunctional && typeof nodeName === 'function') {
248
+ // nodeName is a functional component
249
+ return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
250
+ }
251
+ const vnode = newVNode(nodeName, null);
252
+ vnode.$attrs$ = vnodeData;
253
+ if (vNodeChildren.length > 0) {
254
+ vnode.$children$ = vNodeChildren;
255
+ }
256
+ if (BUILD.vdomKey) {
257
+ vnode.$key$ = key;
258
+ }
259
+ if (BUILD.slotRelocation) {
260
+ vnode.$name$ = slotName;
261
+ }
262
+ return vnode;
263
+ };
264
+ const newVNode = (tag, text) => {
265
+ const vnode = {
266
+ $flags$: 0,
267
+ $tag$: tag,
268
+ $text$: text,
269
+ $elm$: null,
270
+ $children$: null,
271
+ };
272
+ if (BUILD.vdomAttribute) {
273
+ vnode.$attrs$ = null;
274
+ }
275
+ if (BUILD.vdomKey) {
276
+ vnode.$key$ = null;
277
+ }
278
+ if (BUILD.slotRelocation) {
279
+ vnode.$name$ = null;
280
+ }
281
+ return vnode;
282
+ };
283
+ const Host = {};
284
+ const isHost = (node) => node && node.$tag$ === Host;
285
+ const vdomFnUtils = {
286
+ forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
287
+ map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
288
+ };
289
+ const convertToPublic = (node) => ({
290
+ vattrs: node.$attrs$,
291
+ vchildren: node.$children$,
292
+ vkey: node.$key$,
293
+ vname: node.$name$,
294
+ vtag: node.$tag$,
295
+ vtext: node.$text$,
296
+ });
297
+ const convertToPrivate = (node) => {
298
+ if (typeof node.vtag === 'function') {
299
+ const vnodeData = Object.assign({}, node.vattrs);
300
+ if (node.vkey) {
301
+ vnodeData.key = node.vkey;
302
+ }
303
+ if (node.vname) {
304
+ vnodeData.name = node.vname;
305
+ }
306
+ return h(node.vtag, vnodeData, ...(node.vchildren || []));
307
+ }
308
+ const vnode = newVNode(node.vtag, node.vtext);
309
+ vnode.$attrs$ = node.vattrs;
310
+ vnode.$children$ = node.vchildren;
311
+ vnode.$key$ = node.vkey;
312
+ vnode.$name$ = node.vname;
313
+ return vnode;
314
+ };
315
+ /**
316
+ * Validates the ordering of attributes on an input element
317
+ * @param inputElm the element to validate
318
+ */
319
+ const validateInputProperties = (inputElm) => {
320
+ const props = Object.keys(inputElm);
321
+ const value = props.indexOf('value');
322
+ if (value === -1) {
323
+ return;
324
+ }
325
+ const typeIndex = props.indexOf('type');
326
+ const minIndex = props.indexOf('min');
327
+ const maxIndex = props.indexOf('max');
328
+ const stepIndex = props.indexOf('step');
329
+ if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
330
+ consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
331
+ }
332
+ };
333
+ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
334
+ const endHydrate = createTime('hydrateClient', tagName);
335
+ const shadowRoot = hostElm.shadowRoot;
336
+ const childRenderNodes = [];
337
+ const slotNodes = [];
338
+ const shadowRootNodes = BUILD.shadowDom && shadowRoot ? [] : null;
339
+ const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
340
+ if (!plt.$orgLocNodes$) {
341
+ initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
342
+ }
343
+ hostElm[HYDRATE_ID] = hostId;
344
+ hostElm.removeAttribute(HYDRATE_ID);
345
+ clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
346
+ childRenderNodes.map((c) => {
347
+ const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
348
+ const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
349
+ const node = c.$elm$;
350
+ if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
351
+ orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
352
+ }
353
+ if (!shadowRoot) {
354
+ node['s-hn'] = tagName;
355
+ if (orgLocationNode) {
356
+ node['s-ol'] = orgLocationNode;
357
+ node['s-ol']['s-nr'] = node;
358
+ }
359
+ }
360
+ plt.$orgLocNodes$.delete(orgLocationId);
361
+ });
362
+ if (BUILD.shadowDom && shadowRoot) {
363
+ shadowRootNodes.map((shadowRootNode) => {
364
+ if (shadowRootNode) {
365
+ shadowRoot.appendChild(shadowRootNode);
366
+ }
367
+ });
368
+ }
369
+ endHydrate();
370
+ };
371
+ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
372
+ let childNodeType;
373
+ let childIdSplt;
374
+ let childVNode;
375
+ let i;
376
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
377
+ childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
378
+ if (childNodeType) {
379
+ // got the node data from the element's attribute
380
+ // `${hostId}.${nodeId}.${depth}.${index}`
381
+ childIdSplt = childNodeType.split('.');
382
+ if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
383
+ childVNode = {
384
+ $flags$: 0,
385
+ $hostId$: childIdSplt[0],
386
+ $nodeId$: childIdSplt[1],
387
+ $depth$: childIdSplt[2],
388
+ $index$: childIdSplt[3],
389
+ $tag$: node.tagName.toLowerCase(),
390
+ $elm$: node,
391
+ $attrs$: null,
392
+ $children$: null,
393
+ $key$: null,
394
+ $name$: null,
395
+ $text$: null,
396
+ };
397
+ childRenderNodes.push(childVNode);
398
+ node.removeAttribute(HYDRATE_CHILD_ID);
399
+ // this is a new child vnode
400
+ // so ensure its parent vnode has the vchildren array
401
+ if (!parentVNode.$children$) {
402
+ parentVNode.$children$ = [];
403
+ }
404
+ // add our child vnode to a specific index of the vnode's children
405
+ parentVNode.$children$[childVNode.$index$] = childVNode;
406
+ // this is now the new parent vnode for all the next child checks
407
+ parentVNode = childVNode;
408
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
409
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
410
+ }
411
+ }
412
+ }
413
+ // recursively drill down, end to start so we can remove nodes
414
+ for (i = node.childNodes.length - 1; i >= 0; i--) {
415
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
416
+ }
417
+ if (node.shadowRoot) {
418
+ // keep drilling down through the shadow root nodes
419
+ for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
420
+ clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
421
+ }
422
+ }
423
+ }
424
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
425
+ // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
426
+ childIdSplt = node.nodeValue.split('.');
427
+ if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
428
+ // comment node for either the host id or a 0 host id
429
+ childNodeType = childIdSplt[0];
430
+ childVNode = {
431
+ $flags$: 0,
432
+ $hostId$: childIdSplt[1],
433
+ $nodeId$: childIdSplt[2],
434
+ $depth$: childIdSplt[3],
435
+ $index$: childIdSplt[4],
436
+ $elm$: node,
437
+ $attrs$: null,
438
+ $children$: null,
439
+ $key$: null,
440
+ $name$: null,
441
+ $tag$: null,
442
+ $text$: null,
443
+ };
444
+ if (childNodeType === TEXT_NODE_ID) {
445
+ childVNode.$elm$ = node.nextSibling;
446
+ if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
447
+ childVNode.$text$ = childVNode.$elm$.textContent;
448
+ childRenderNodes.push(childVNode);
449
+ // remove the text comment since it's no longer needed
450
+ node.remove();
451
+ if (!parentVNode.$children$) {
452
+ parentVNode.$children$ = [];
453
+ }
454
+ parentVNode.$children$[childVNode.$index$] = childVNode;
455
+ if (shadowRootNodes && childVNode.$depth$ === '0') {
456
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
457
+ }
458
+ }
459
+ }
460
+ else if (childVNode.$hostId$ === hostId) {
461
+ // this comment node is specifcally for this host id
462
+ if (childNodeType === SLOT_NODE_ID) {
463
+ // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
464
+ childVNode.$tag$ = 'slot';
465
+ if (childIdSplt[5]) {
466
+ node['s-sn'] = childVNode.$name$ = childIdSplt[5];
467
+ }
468
+ else {
469
+ node['s-sn'] = '';
470
+ }
471
+ node['s-sr'] = true;
472
+ if (BUILD.shadowDom && shadowRootNodes) {
473
+ // browser support shadowRoot and this is a shadow dom component
474
+ // create an actual slot element
475
+ childVNode.$elm$ = doc.createElement(childVNode.$tag$);
476
+ if (childVNode.$name$) {
477
+ // add the slot name attribute
478
+ childVNode.$elm$.setAttribute('name', childVNode.$name$);
479
+ }
480
+ // insert the new slot element before the slot comment
481
+ node.parentNode.insertBefore(childVNode.$elm$, node);
482
+ // remove the slot comment since it's not needed for shadow
483
+ node.remove();
484
+ if (childVNode.$depth$ === '0') {
485
+ shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
486
+ }
487
+ }
488
+ slotNodes.push(childVNode);
489
+ if (!parentVNode.$children$) {
490
+ parentVNode.$children$ = [];
491
+ }
492
+ parentVNode.$children$[childVNode.$index$] = childVNode;
493
+ }
494
+ else if (childNodeType === CONTENT_REF_ID) {
495
+ // `${CONTENT_REF_ID}.${hostId}`;
496
+ if (BUILD.shadowDom && shadowRootNodes) {
497
+ // remove the content ref comment since it's not needed for shadow
498
+ node.remove();
499
+ }
500
+ else if (BUILD.slotRelocation) {
501
+ hostElm['s-cr'] = node;
502
+ node['s-cn'] = true;
503
+ }
504
+ }
505
+ }
506
+ }
507
+ }
508
+ else if (parentVNode && parentVNode.$tag$ === 'style') {
509
+ const vnode = newVNode(null, node.textContent);
510
+ vnode.$elm$ = node;
511
+ vnode.$index$ = '0';
512
+ parentVNode.$children$ = [vnode];
513
+ }
514
+ };
515
+ const initializeDocumentHydrate = (node, orgLocNodes) => {
516
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
517
+ let i = 0;
518
+ for (; i < node.childNodes.length; i++) {
519
+ initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
520
+ }
521
+ if (node.shadowRoot) {
522
+ for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
523
+ initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
524
+ }
525
+ }
526
+ }
527
+ else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
528
+ const childIdSplt = node.nodeValue.split('.');
529
+ if (childIdSplt[0] === ORG_LOCATION_ID) {
530
+ orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
531
+ node.nodeValue = '';
532
+ // useful to know if the original location is
533
+ // the root light-dom of a shadow dom component
534
+ node['s-en'] = childIdSplt[3];
535
+ }
536
+ }
537
+ };
538
+ // Private
539
+ const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
540
+ // Public
541
+ const setMode = (handler) => modeResolutionChain.push(handler);
542
+ const getMode = (ref) => getHostRef(ref).$modeName$;
543
+ /**
544
+ * Parse a new property value for a given property type.
545
+ *
546
+ * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
547
+ * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
548
+ * 1. `any`, the type given to `propValue` in the function signature
549
+ * 2. the type stored from `propType`.
550
+ *
551
+ * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
552
+ *
553
+ * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
554
+ * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
555
+ * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
556
+ * ```tsx
557
+ * <my-cmp prop-val={0}></my-cmp>
558
+ * ```
559
+ *
560
+ * HTML prop values on the other hand, will always a string
561
+ *
562
+ * @param propValue the new value to coerce to some type
563
+ * @param propType the type of the prop, expressed as a binary number
564
+ * @returns the parsed/coerced value
565
+ */
566
+ const parsePropertyValue = (propValue, propType) => {
567
+ // ensure this value is of the correct prop type
568
+ if (propValue != null && !isComplexType(propValue)) {
569
+ if (BUILD.propBoolean && propType & 4 /* MEMBER_FLAGS.Boolean */) {
570
+ // per the HTML spec, any string value means it is a boolean true value
571
+ // but we'll cheat here and say that the string "false" is the boolean false
572
+ return propValue === 'false' ? false : propValue === '' || !!propValue;
573
+ }
574
+ if (BUILD.propNumber && propType & 2 /* MEMBER_FLAGS.Number */) {
575
+ // force it to be a number
576
+ return parseFloat(propValue);
577
+ }
578
+ if (BUILD.propString && propType & 1 /* MEMBER_FLAGS.String */) {
579
+ // could have been passed as a number or boolean
580
+ // but we still want it as a string
581
+ return String(propValue);
582
+ }
583
+ // redundant return here for better minification
584
+ return propValue;
585
+ }
586
+ // not sure exactly what type we want
587
+ // so no need to change to a different type
588
+ return propValue;
589
+ };
590
+ const getElement = (ref) => (BUILD.lazyLoad ? getHostRef(ref).$hostElement$ : ref);
591
+ const createEvent = (ref, name, flags) => {
592
+ const elm = getElement(ref);
593
+ return {
594
+ emit: (detail) => {
595
+ if (BUILD.isDev && !elm.isConnected) {
596
+ consoleDevWarn(`The "${name}" event was emitted, but the dispatcher node is no longer connected to the dom.`);
597
+ }
598
+ return emitEvent(elm, name, {
599
+ bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
600
+ composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
601
+ cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
602
+ detail,
603
+ });
604
+ },
605
+ };
606
+ };
607
+ /**
608
+ * Helper function to create & dispatch a custom Event on a provided target
609
+ * @param elm the target of the Event
610
+ * @param name the name to give the custom Event
611
+ * @param opts options for configuring a custom Event
612
+ * @returns the custom Event
613
+ */
614
+ const emitEvent = (elm, name, opts) => {
615
+ const ev = plt.ce(name, opts);
616
+ elm.dispatchEvent(ev);
617
+ return ev;
618
+ };
619
+ const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
620
+ const registerStyle = (scopeId, cssText, allowCS) => {
621
+ let style = styles.get(scopeId);
622
+ if (supportsConstructableStylesheets && allowCS) {
623
+ style = (style || new CSSStyleSheet());
624
+ if (typeof style === 'string') {
625
+ style = cssText;
626
+ }
627
+ else {
628
+ style.replaceSync(cssText);
629
+ }
630
+ }
631
+ else {
632
+ style = cssText;
633
+ }
634
+ styles.set(scopeId, style);
635
+ };
636
+ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
637
+ let scopeId = getScopeId(cmpMeta, mode);
638
+ const style = styles.get(scopeId);
639
+ if (!BUILD.attachStyles) {
640
+ return scopeId;
641
+ }
642
+ // if an element is NOT connected then getRootNode() will return the wrong root node
643
+ // so the fallback is to always use the document for the root node in those cases
644
+ styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
645
+ if (style) {
646
+ if (typeof style === 'string') {
647
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
648
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
649
+ let styleElm;
650
+ if (!appliedStyles) {
651
+ rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
652
+ }
653
+ if (!appliedStyles.has(scopeId)) {
654
+ if (BUILD.hydrateClientSide &&
655
+ styleContainerNode.host &&
656
+ (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
657
+ // This is only happening on native shadow-dom, do not needs CSS var shim
658
+ styleElm.innerHTML = style;
659
+ }
660
+ else {
661
+ if (BUILD.cssVarShim && plt.$cssShim$) {
662
+ styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style, !!(cmpMeta.$flags$ & 10 /* CMP_FLAGS.needsScopedEncapsulation */));
663
+ const newScopeId = styleElm['s-sc'];
664
+ if (newScopeId) {
665
+ scopeId = newScopeId;
666
+ // we don't want to add this styleID to the appliedStyles Set
667
+ // since the cssVarShim might need to apply several different
668
+ // stylesheets for the same component
669
+ appliedStyles = null;
670
+ }
671
+ }
672
+ else {
673
+ styleElm = doc.createElement('style');
674
+ styleElm.innerHTML = style;
675
+ }
676
+ if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) {
677
+ styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
678
+ }
679
+ styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
680
+ }
681
+ if (appliedStyles) {
682
+ appliedStyles.add(scopeId);
683
+ }
684
+ }
685
+ }
686
+ else if (BUILD.constructableCSS && !styleContainerNode.adoptedStyleSheets.includes(style)) {
687
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
688
+ }
689
+ }
690
+ return scopeId;
691
+ };
692
+ const attachStyles = (hostRef) => {
693
+ const cmpMeta = hostRef.$cmpMeta$;
694
+ const elm = hostRef.$hostElement$;
695
+ const flags = cmpMeta.$flags$;
696
+ const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
697
+ const scopeId = addStyle(BUILD.shadowDom && supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
698
+ if ((BUILD.shadowDom || BUILD.scoped) && BUILD.cssAnnotations && flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
699
+ // only required when we're NOT using native shadow dom (slot)
700
+ // or this browser doesn't support native shadow dom
701
+ // and this host element was NOT created with SSR
702
+ // let's pick out the inner content for slot projection
703
+ // create a node to represent where the original
704
+ // content was first placed, which is useful later on
705
+ // DOM WRITE!!
706
+ elm['s-sc'] = scopeId;
707
+ elm.classList.add(scopeId + '-h');
708
+ if (BUILD.scoped && flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
709
+ elm.classList.add(scopeId + '-s');
710
+ }
711
+ }
712
+ endAttachStyles();
713
+ };
714
+ const getScopeId = (cmp, mode) => 'sc-' + (BUILD.mode && mode && cmp.$flags$ & 32 /* CMP_FLAGS.hasMode */ ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
715
+ const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
716
+ /**
717
+ * Production setAccessor() function based on Preact by
718
+ * Jason Miller (@developit)
719
+ * Licensed under the MIT License
720
+ * https://github.com/developit/preact/blob/master/LICENSE
721
+ *
722
+ * Modified for Stencil's compiler and vdom
723
+ */
724
+ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
725
+ if (oldValue !== newValue) {
726
+ let isProp = isMemberInElement(elm, memberName);
727
+ let ln = memberName.toLowerCase();
728
+ if (BUILD.vdomClass && memberName === 'class') {
729
+ const classList = elm.classList;
730
+ const oldClasses = parseClassList(oldValue);
731
+ const newClasses = parseClassList(newValue);
732
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
733
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
734
+ }
735
+ else if (BUILD.vdomStyle && memberName === 'style') {
736
+ // update style attribute, css properties and values
737
+ if (BUILD.updatable) {
738
+ for (const prop in oldValue) {
739
+ if (!newValue || newValue[prop] == null) {
740
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
741
+ elm.style.removeProperty(prop);
742
+ }
743
+ else {
744
+ elm.style[prop] = '';
745
+ }
746
+ }
747
+ }
748
+ }
749
+ for (const prop in newValue) {
750
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
751
+ if (!BUILD.hydrateServerSide && prop.includes('-')) {
752
+ elm.style.setProperty(prop, newValue[prop]);
753
+ }
754
+ else {
755
+ elm.style[prop] = newValue[prop];
756
+ }
757
+ }
758
+ }
759
+ }
760
+ else if (BUILD.vdomKey && memberName === 'key')
761
+ ;
762
+ else if (BUILD.vdomRef && memberName === 'ref') {
763
+ // minifier will clean this up
764
+ if (newValue) {
765
+ newValue(elm);
766
+ }
767
+ }
768
+ else if (BUILD.vdomListener &&
769
+ (BUILD.lazyLoad ? !isProp : !elm.__lookupSetter__(memberName)) &&
770
+ memberName[0] === 'o' &&
771
+ memberName[1] === 'n') {
772
+ // Event Handlers
773
+ // so if the member name starts with "on" and the 3rd characters is
774
+ // a capital letter, and it's not already a member on the element,
775
+ // then we're assuming it's an event listener
776
+ if (memberName[2] === '-') {
777
+ // on- prefixed events
778
+ // allows to be explicit about the dom event to listen without any magic
779
+ // under the hood:
780
+ // <my-cmp on-click> // listens for "click"
781
+ // <my-cmp on-Click> // listens for "Click"
782
+ // <my-cmp on-ionChange> // listens for "ionChange"
783
+ // <my-cmp on-EVENTS> // listens for "EVENTS"
784
+ memberName = memberName.slice(3);
785
+ }
786
+ else if (isMemberInElement(win, ln)) {
787
+ // standard event
788
+ // the JSX attribute could have been "onMouseOver" and the
789
+ // member name "onmouseover" is on the window's prototype
790
+ // so let's add the listener "mouseover", which is all lowercased
791
+ memberName = ln.slice(2);
792
+ }
793
+ else {
794
+ // custom event
795
+ // the JSX attribute could have been "onMyCustomEvent"
796
+ // so let's trim off the "on" prefix and lowercase the first character
797
+ // and add the listener "myCustomEvent"
798
+ // except for the first character, we keep the event name case
799
+ memberName = ln[2] + memberName.slice(3);
800
+ }
801
+ if (oldValue) {
802
+ plt.rel(elm, memberName, oldValue, false);
803
+ }
804
+ if (newValue) {
805
+ plt.ael(elm, memberName, newValue, false);
806
+ }
807
+ }
808
+ else if (BUILD.vdomPropOrAttr) {
809
+ // Set property if it exists and it's not a SVG
810
+ const isComplex = isComplexType(newValue);
811
+ if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
812
+ try {
813
+ if (!elm.tagName.includes('-')) {
814
+ const n = newValue == null ? '' : newValue;
815
+ // Workaround for Safari, moving the <input> caret when re-assigning the same valued
816
+ if (memberName === 'list') {
817
+ isProp = false;
818
+ }
819
+ else if (oldValue == null || elm[memberName] != n) {
820
+ elm[memberName] = n;
821
+ }
822
+ }
823
+ else {
824
+ elm[memberName] = newValue;
825
+ }
826
+ }
827
+ catch (e) { }
828
+ }
829
+ /**
830
+ * Need to manually update attribute if:
831
+ * - memberName is not an attribute
832
+ * - if we are rendering the host element in order to reflect attribute
833
+ * - if it's a SVG, since properties might not work in <svg>
834
+ * - if the newValue is null/undefined or 'false'.
835
+ */
836
+ let xlink = false;
837
+ if (BUILD.vdomXlink) {
838
+ if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
839
+ memberName = ln;
840
+ xlink = true;
841
+ }
842
+ }
843
+ if (newValue == null || newValue === false) {
844
+ if (newValue !== false || elm.getAttribute(memberName) === '') {
845
+ if (BUILD.vdomXlink && xlink) {
846
+ elm.removeAttributeNS(XLINK_NS, memberName);
847
+ }
848
+ else {
849
+ elm.removeAttribute(memberName);
850
+ }
851
+ }
852
+ }
853
+ else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
854
+ newValue = newValue === true ? '' : newValue;
855
+ if (BUILD.vdomXlink && xlink) {
856
+ elm.setAttributeNS(XLINK_NS, memberName, newValue);
857
+ }
858
+ else {
859
+ elm.setAttribute(memberName, newValue);
860
+ }
861
+ }
862
+ }
863
+ }
864
+ };
865
+ const parseClassListRegex = /\s/;
866
+ const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
867
+ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
868
+ // if the element passed in is a shadow root, which is a document fragment
869
+ // then we want to be adding attrs/props to the shadow root's "host" element
870
+ // if it's not a shadow root, then we add attrs/props to the same element
871
+ const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
872
+ ? newVnode.$elm$.host
873
+ : newVnode.$elm$;
874
+ const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
875
+ const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
876
+ if (BUILD.updatable) {
877
+ // remove attributes no longer present on the vnode by setting them to undefined
878
+ for (memberName in oldVnodeAttrs) {
879
+ if (!(memberName in newVnodeAttrs)) {
880
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
881
+ }
882
+ }
883
+ }
884
+ // add new & update changed attributes
885
+ for (memberName in newVnodeAttrs) {
886
+ setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
887
+ }
888
+ };
889
+ /**
890
+ * Create a DOM Node corresponding to one of the children of a given VNode.
891
+ *
892
+ * @param oldParentVNode the parent VNode from the previous render
893
+ * @param newParentVNode the parent VNode from the current render
894
+ * @param childIndex the index of the VNode, in the _new_ parent node's
895
+ * children, for which we will create a new DOM node
896
+ * @param parentElm the parent DOM node which our new node will be a child of
897
+ * @returns the newly created node
898
+ */
899
+ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
900
+ // tslint:disable-next-line: prefer-const
901
+ const newVNode = newParentVNode.$children$[childIndex];
902
+ let i = 0;
903
+ let elm;
904
+ let childNode;
905
+ let oldVNode;
906
+ if (BUILD.slotRelocation && !useNativeShadowDom) {
907
+ // remember for later we need to check to relocate nodes
908
+ checkSlotRelocate = true;
909
+ if (newVNode.$tag$ === 'slot') {
910
+ if (scopeId) {
911
+ // scoped css needs to add its scoped id to the parent element
912
+ parentElm.classList.add(scopeId + '-s');
913
+ }
914
+ newVNode.$flags$ |= newVNode.$children$
915
+ ? // slot element has fallback content
916
+ 2 /* VNODE_FLAGS.isSlotFallback */
917
+ : // slot element does not have fallback content
918
+ 1 /* VNODE_FLAGS.isSlotReference */;
919
+ }
920
+ }
921
+ if (BUILD.isDev && newVNode.$elm$) {
922
+ consoleDevError(`The JSX ${newVNode.$text$ !== null ? `"${newVNode.$text$}" text` : `"${newVNode.$tag$}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`);
923
+ }
924
+ if (BUILD.vdomText && newVNode.$text$ !== null) {
925
+ // create text node
926
+ elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
927
+ }
928
+ else if (BUILD.slotRelocation && newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
929
+ // create a slot reference node
930
+ elm = newVNode.$elm$ =
931
+ BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : doc.createTextNode('');
932
+ }
933
+ else {
934
+ if (BUILD.svg && !isSvgMode) {
935
+ isSvgMode = newVNode.$tag$ === 'svg';
936
+ }
937
+ // create element
938
+ elm = newVNode.$elm$ = (BUILD.svg
939
+ ? doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
940
+ ? 'slot-fb'
941
+ : newVNode.$tag$)
942
+ : doc.createElement(BUILD.slotRelocation && newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
943
+ ? 'slot-fb'
944
+ : newVNode.$tag$));
945
+ if (BUILD.svg && isSvgMode && newVNode.$tag$ === 'foreignObject') {
946
+ isSvgMode = false;
947
+ }
948
+ // add css classes, attrs, props, listeners, etc.
949
+ if (BUILD.vdomAttribute) {
950
+ updateElement(null, newVNode, isSvgMode);
951
+ }
952
+ if ((BUILD.shadowDom || BUILD.scoped) && isDef(scopeId) && elm['s-si'] !== scopeId) {
953
+ // if there is a scopeId and this is the initial render
954
+ // then let's add the scopeId as a css class
955
+ elm.classList.add((elm['s-si'] = scopeId));
956
+ }
957
+ if (newVNode.$children$) {
958
+ for (i = 0; i < newVNode.$children$.length; ++i) {
959
+ // create the node
960
+ childNode = createElm(oldParentVNode, newVNode, i, elm);
961
+ // return node could have been null
962
+ if (childNode) {
963
+ // append our new node
964
+ elm.appendChild(childNode);
965
+ }
966
+ }
967
+ }
968
+ if (BUILD.svg) {
969
+ if (newVNode.$tag$ === 'svg') {
970
+ // Only reset the SVG context when we're exiting <svg> element
971
+ isSvgMode = false;
972
+ }
973
+ else if (elm.tagName === 'foreignObject') {
974
+ // Reenter SVG context when we're exiting <foreignObject> element
975
+ isSvgMode = true;
976
+ }
977
+ }
978
+ }
979
+ if (BUILD.slotRelocation) {
980
+ elm['s-hn'] = hostTagName;
981
+ if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
982
+ // remember the content reference comment
983
+ elm['s-sr'] = true;
984
+ // remember the content reference comment
985
+ elm['s-cr'] = contentRef;
986
+ // remember the slot name, or empty string for default slot
987
+ elm['s-sn'] = newVNode.$name$ || '';
988
+ // check if we've got an old vnode for this slot
989
+ oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
990
+ if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
991
+ // we've got an old slot vnode and the wrapper is being replaced
992
+ // so let's move the old slot content back to it's original location
993
+ putBackInOriginalLocation(oldParentVNode.$elm$, false);
994
+ }
995
+ }
996
+ }
997
+ return elm;
998
+ };
999
+ const putBackInOriginalLocation = (parentElm, recursive) => {
1000
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1001
+ const oldSlotChildNodes = parentElm.childNodes;
1002
+ for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
1003
+ const childNode = oldSlotChildNodes[i];
1004
+ if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
1005
+ // // this child node in the old element is from another component
1006
+ // // remove this node from the old slot's parent
1007
+ // childNode.remove();
1008
+ // and relocate it back to it's original location
1009
+ parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
1010
+ // remove the old original location comment entirely
1011
+ // later on the patch function will know what to do
1012
+ // and move this to the correct spot in need be
1013
+ childNode['s-ol'].remove();
1014
+ childNode['s-ol'] = undefined;
1015
+ checkSlotRelocate = true;
1016
+ }
1017
+ if (recursive) {
1018
+ putBackInOriginalLocation(childNode, recursive);
1019
+ }
1020
+ }
1021
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1022
+ };
1023
+ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
1024
+ let containerElm = ((BUILD.slotRelocation && parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
1025
+ let childNode;
1026
+ if (BUILD.shadowDom && containerElm.shadowRoot && containerElm.tagName === hostTagName) {
1027
+ containerElm = containerElm.shadowRoot;
1028
+ }
1029
+ for (; startIdx <= endIdx; ++startIdx) {
1030
+ if (vnodes[startIdx]) {
1031
+ childNode = createElm(null, parentVNode, startIdx, parentElm);
1032
+ if (childNode) {
1033
+ vnodes[startIdx].$elm$ = childNode;
1034
+ containerElm.insertBefore(childNode, BUILD.slotRelocation ? referenceNode(before) : before);
1035
+ }
1036
+ }
1037
+ }
1038
+ };
1039
+ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
1040
+ for (; startIdx <= endIdx; ++startIdx) {
1041
+ if ((vnode = vnodes[startIdx])) {
1042
+ elm = vnode.$elm$;
1043
+ callNodeRefs(vnode);
1044
+ if (BUILD.slotRelocation) {
1045
+ // we're removing this element
1046
+ // so it's possible we need to show slot fallback content now
1047
+ checkSlotFallbackVisibility = true;
1048
+ if (elm['s-ol']) {
1049
+ // remove the original location comment
1050
+ elm['s-ol'].remove();
1051
+ }
1052
+ else {
1053
+ // it's possible that child nodes of the node
1054
+ // that's being removed are slot nodes
1055
+ putBackInOriginalLocation(elm, true);
1056
+ }
1057
+ }
1058
+ // remove the vnode's element from the dom
1059
+ elm.remove();
1060
+ }
1061
+ }
1062
+ };
1063
+ /**
1064
+ * Reconcile the children of a new VNode with the children of an old VNode by
1065
+ * traversing the two collections of children, identifying nodes that are
1066
+ * conserved or changed, calling out to `patch` to make any necessary
1067
+ * updates to the DOM, and rearranging DOM nodes as needed.
1068
+ *
1069
+ * The algorithm for reconciling children works by analyzing two 'windows' onto
1070
+ * the two arrays of children (`oldCh` and `newCh`). We keep track of the
1071
+ * 'windows' by storing start and end indices and references to the
1072
+ * corresponding array entries. Initially the two 'windows' are basically equal
1073
+ * to the entire array, but we progressively narrow the windows until there are
1074
+ * no children left to update by doing the following:
1075
+ *
1076
+ * 1. Skip any `null` entries at the beginning or end of the two arrays, so
1077
+ * that if we have an initial array like the following we'll end up dealing
1078
+ * only with a window bounded by the highlighted elements:
1079
+ *
1080
+ * [null, null, VNode1 , ... , VNode2, null, null]
1081
+ * ^^^^^^ ^^^^^^
1082
+ *
1083
+ * 2. Check to see if the elements at the head and tail positions are equal
1084
+ * across the windows. This will basically detect elements which haven't
1085
+ * been added, removed, or changed position, i.e. if you had the following
1086
+ * VNode elements (represented as HTML):
1087
+ *
1088
+ * oldVNode: `<div><p><span>HEY</span></p></div>`
1089
+ * newVNode: `<div><p><span>THERE</span></p></div>`
1090
+ *
1091
+ * Then when comparing the children of the `<div>` tag we check the equality
1092
+ * of the VNodes corresponding to the `<p>` tags and, since they are the
1093
+ * same tag in the same position, we'd be able to avoid completely
1094
+ * re-rendering the subtree under them with a new DOM element and would just
1095
+ * call out to `patch` to handle reconciling their children and so on.
1096
+ *
1097
+ * 3. Check, for both windows, to see if the element at the beginning of the
1098
+ * window corresponds to the element at the end of the other window. This is
1099
+ * a heuristic which will let us identify _some_ situations in which
1100
+ * elements have changed position, for instance it _should_ detect that the
1101
+ * children nodes themselves have not changed but merely moved in the
1102
+ * following example:
1103
+ *
1104
+ * oldVNode: `<div><element-one /><element-two /></div>`
1105
+ * newVNode: `<div><element-two /><element-one /></div>`
1106
+ *
1107
+ * If we find cases like this then we also need to move the concrete DOM
1108
+ * elements corresponding to the moved children to write the re-order to the
1109
+ * DOM.
1110
+ *
1111
+ * 4. Finally, if VNodes have the `key` attribute set on them we check for any
1112
+ * nodes in the old children which have the same key as the first element in
1113
+ * our window on the new children. If we find such a node we handle calling
1114
+ * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
1115
+ * what we find.
1116
+ *
1117
+ * Finally, once we've narrowed our 'windows' to the point that either of them
1118
+ * collapse (i.e. they have length 0) we then handle any remaining VNode
1119
+ * insertion or deletion that needs to happen to get a DOM state that correctly
1120
+ * reflects the new child VNodes. If, for instance, after our window on the old
1121
+ * children has collapsed we still have more nodes on the new children that
1122
+ * we haven't dealt with yet then we need to add them, or if the new children
1123
+ * collapse but we still have unhandled _old_ children then we need to make
1124
+ * sure the corresponding DOM nodes are removed.
1125
+ *
1126
+ * @param parentElm the node into which the parent VNode is rendered
1127
+ * @param oldCh the old children of the parent node
1128
+ * @param newVNode the new VNode which will replace the parent
1129
+ * @param newCh the new children of the parent node
1130
+ */
1131
+ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
1132
+ let oldStartIdx = 0;
1133
+ let newStartIdx = 0;
1134
+ let idxInOld = 0;
1135
+ let i = 0;
1136
+ let oldEndIdx = oldCh.length - 1;
1137
+ let oldStartVnode = oldCh[0];
1138
+ let oldEndVnode = oldCh[oldEndIdx];
1139
+ let newEndIdx = newCh.length - 1;
1140
+ let newStartVnode = newCh[0];
1141
+ let newEndVnode = newCh[newEndIdx];
1142
+ let node;
1143
+ let elmToMove;
1144
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1145
+ if (oldStartVnode == null) {
1146
+ // VNode might have been moved left
1147
+ oldStartVnode = oldCh[++oldStartIdx];
1148
+ }
1149
+ else if (oldEndVnode == null) {
1150
+ oldEndVnode = oldCh[--oldEndIdx];
1151
+ }
1152
+ else if (newStartVnode == null) {
1153
+ newStartVnode = newCh[++newStartIdx];
1154
+ }
1155
+ else if (newEndVnode == null) {
1156
+ newEndVnode = newCh[--newEndIdx];
1157
+ }
1158
+ else if (isSameVnode(oldStartVnode, newStartVnode)) {
1159
+ // if the start nodes are the same then we should patch the new VNode
1160
+ // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
1161
+ // indices to reflect that. We don't need to move any DOM Nodes around
1162
+ // since things are matched up in order.
1163
+ patch(oldStartVnode, newStartVnode);
1164
+ oldStartVnode = oldCh[++oldStartIdx];
1165
+ newStartVnode = newCh[++newStartIdx];
1166
+ }
1167
+ else if (isSameVnode(oldEndVnode, newEndVnode)) {
1168
+ // likewise, if the end nodes are the same we patch new onto old and
1169
+ // decrement our end indices, and also likewise in this case we don't
1170
+ // need to move any DOM Nodes.
1171
+ patch(oldEndVnode, newEndVnode);
1172
+ oldEndVnode = oldCh[--oldEndIdx];
1173
+ newEndVnode = newCh[--newEndIdx];
1174
+ }
1175
+ else if (isSameVnode(oldStartVnode, newEndVnode)) {
1176
+ // case: "Vnode moved right"
1177
+ //
1178
+ // We've found that the last node in our window on the new children is
1179
+ // the same VNode as the _first_ node in our window on the old children
1180
+ // we're dealing with now. Visually, this is the layout of these two
1181
+ // nodes:
1182
+ //
1183
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1184
+ // ^^^^^^^^^^^
1185
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1186
+ // ^^^^^^^^^^^^^
1187
+ //
1188
+ // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
1189
+ // and move the DOM element for `oldStartVnode`.
1190
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1191
+ putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1192
+ }
1193
+ patch(oldStartVnode, newEndVnode);
1194
+ // We need to move the element for `oldStartVnode` into a position which
1195
+ // will be appropriate for `newEndVnode`. For this we can use
1196
+ // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
1197
+ // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
1198
+ // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
1199
+ //
1200
+ // <old-start-node />
1201
+ // <some-intervening-node />
1202
+ // <old-end-node />
1203
+ // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
1204
+ // <next-sibling />
1205
+ //
1206
+ // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
1207
+ // the node for `oldStartVnode` at the end of the children of
1208
+ // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
1209
+ // aren't any siblings, and passing `null` to `Node.insertBefore` will
1210
+ // append it to the children of the parent element.
1211
+ parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1212
+ oldStartVnode = oldCh[++oldStartIdx];
1213
+ newEndVnode = newCh[--newEndIdx];
1214
+ }
1215
+ else if (isSameVnode(oldEndVnode, newStartVnode)) {
1216
+ // case: "Vnode moved left"
1217
+ //
1218
+ // We've found that the first node in our window on the new children is
1219
+ // the same VNode as the _last_ node in our window on the old children.
1220
+ // Visually, this is the layout of these two nodes:
1221
+ //
1222
+ // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1223
+ // ^^^^^^^^^^^^^
1224
+ // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1225
+ // ^^^^^^^^^^^
1226
+ //
1227
+ // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
1228
+ // (which will handle updating any changed attributes, reconciling their
1229
+ // children etc) but we also need to move the DOM node to which
1230
+ // `oldEndVnode` corresponds.
1231
+ if (BUILD.slotRelocation && (oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1232
+ putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1233
+ }
1234
+ patch(oldEndVnode, newStartVnode);
1235
+ // We've already checked above if `oldStartVnode` and `newStartVnode` are
1236
+ // the same node, so since we're here we know that they are not. Thus we
1237
+ // can move the element for `oldEndVnode` _before_ the element for
1238
+ // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
1239
+ // future.
1240
+ parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
1241
+ oldEndVnode = oldCh[--oldEndIdx];
1242
+ newStartVnode = newCh[++newStartIdx];
1243
+ }
1244
+ else {
1245
+ // Here we do some checks to match up old and new nodes based on the
1246
+ // `$key$` attribute, which is set by putting a `key="my-key"` attribute
1247
+ // in the JSX for a DOM element in the implementation of a Stencil
1248
+ // component.
1249
+ //
1250
+ // First we check to see if there are any nodes in the array of old
1251
+ // children which have the same key as the first node in the new
1252
+ // children.
1253
+ idxInOld = -1;
1254
+ if (BUILD.vdomKey) {
1255
+ for (i = oldStartIdx; i <= oldEndIdx; ++i) {
1256
+ if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
1257
+ idxInOld = i;
1258
+ break;
1259
+ }
1260
+ }
1261
+ }
1262
+ if (BUILD.vdomKey && idxInOld >= 0) {
1263
+ // We found a node in the old children which matches up with the first
1264
+ // node in the new children! So let's deal with that
1265
+ elmToMove = oldCh[idxInOld];
1266
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1267
+ // the tag doesn't match so we'll need a new DOM element
1268
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
1269
+ }
1270
+ else {
1271
+ patch(elmToMove, newStartVnode);
1272
+ // invalidate the matching old node so that we won't try to update it
1273
+ // again later on
1274
+ oldCh[idxInOld] = undefined;
1275
+ node = elmToMove.$elm$;
1276
+ }
1277
+ newStartVnode = newCh[++newStartIdx];
1278
+ }
1279
+ else {
1280
+ // We either didn't find an element in the old children that matches
1281
+ // the key of the first new child OR the build is not using `key`
1282
+ // attributes at all. In either case we need to create a new element
1283
+ // for the new node.
1284
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
1285
+ newStartVnode = newCh[++newStartIdx];
1286
+ }
1287
+ if (node) {
1288
+ // if we created a new node then handle inserting it to the DOM
1289
+ if (BUILD.slotRelocation) {
1290
+ parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
1291
+ }
1292
+ else {
1293
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
1294
+ }
1295
+ }
1296
+ }
1297
+ }
1298
+ if (oldStartIdx > oldEndIdx) {
1299
+ // we have some more new nodes to add which don't match up with old nodes
1300
+ addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
1301
+ }
1302
+ else if (BUILD.updatable && newStartIdx > newEndIdx) {
1303
+ // there are nodes in the `oldCh` array which no longer correspond to nodes
1304
+ // in the new array, so lets remove them (which entails cleaning up the
1305
+ // relevant DOM nodes)
1306
+ removeVnodes(oldCh, oldStartIdx, oldEndIdx);
1307
+ }
1308
+ };
1309
+ /**
1310
+ * Compare two VNodes to determine if they are the same
1311
+ *
1312
+ * **NB**: This function is an equality _heuristic_ based on the available
1313
+ * information set on the two VNodes and can be misleading under certain
1314
+ * circumstances. In particular, if the two nodes do not have `key` attrs
1315
+ * (available under `$key$` on VNodes) then the function falls back on merely
1316
+ * checking that they have the same tag.
1317
+ *
1318
+ * So, in other words, if `key` attrs are not set on VNodes which may be
1319
+ * changing order within a `children` array or something along those lines then
1320
+ * we could obtain a false positive and then have to do needless re-rendering.
1321
+ *
1322
+ * @param leftVNode the first VNode to check
1323
+ * @param rightVNode the second VNode to check
1324
+ * @returns whether they're equal or not
1325
+ */
1326
+ const isSameVnode = (leftVNode, rightVNode) => {
1327
+ // compare if two vnode to see if they're "technically" the same
1328
+ // need to have the same element tag, and same key to be the same
1329
+ if (leftVNode.$tag$ === rightVNode.$tag$) {
1330
+ if (BUILD.slotRelocation && leftVNode.$tag$ === 'slot') {
1331
+ return leftVNode.$name$ === rightVNode.$name$;
1332
+ }
1333
+ // this will be set if components in the build have `key` attrs set on them
1334
+ if (BUILD.vdomKey) {
1335
+ return leftVNode.$key$ === rightVNode.$key$;
1336
+ }
1337
+ return true;
1338
+ }
1339
+ return false;
1340
+ };
1341
+ const referenceNode = (node) => {
1342
+ // this node was relocated to a new location in the dom
1343
+ // because of some other component's slot
1344
+ // but we still have an html comment in place of where
1345
+ // it's original location was according to it's original vdom
1346
+ return (node && node['s-ol']) || node;
1347
+ };
1348
+ const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
1349
+ /**
1350
+ * Handle reconciling an outdated VNode with a new one which corresponds to
1351
+ * it. This function handles flushing updates to the DOM and reconciling the
1352
+ * children of the two nodes (if any).
1353
+ *
1354
+ * @param oldVNode an old VNode whose DOM element and children we want to update
1355
+ * @param newVNode a new VNode representing an updated version of the old one
1356
+ */
1357
+ const patch = (oldVNode, newVNode) => {
1358
+ const elm = (newVNode.$elm$ = oldVNode.$elm$);
1359
+ const oldChildren = oldVNode.$children$;
1360
+ const newChildren = newVNode.$children$;
1361
+ const tag = newVNode.$tag$;
1362
+ const text = newVNode.$text$;
1363
+ let defaultHolder;
1364
+ if (!BUILD.vdomText || text === null) {
1365
+ if (BUILD.svg) {
1366
+ // test if we're rendering an svg element, or still rendering nodes inside of one
1367
+ // only add this to the when the compiler sees we're using an svg somewhere
1368
+ isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
1369
+ }
1370
+ if (BUILD.vdomAttribute || BUILD.reflect) {
1371
+ if (BUILD.slot && tag === 'slot')
1372
+ ;
1373
+ else {
1374
+ // either this is the first render of an element OR it's an update
1375
+ // AND we already know it's possible it could have changed
1376
+ // this updates the element's css classes, attrs, props, listeners, etc.
1377
+ updateElement(oldVNode, newVNode, isSvgMode);
1378
+ }
1379
+ }
1380
+ if (BUILD.updatable && oldChildren !== null && newChildren !== null) {
1381
+ // looks like there's child vnodes for both the old and new vnodes
1382
+ // so we need to call `updateChildren` to reconcile them
1383
+ updateChildren(elm, oldChildren, newVNode, newChildren);
1384
+ }
1385
+ else if (newChildren !== null) {
1386
+ // no old child vnodes, but there are new child vnodes to add
1387
+ if (BUILD.updatable && BUILD.vdomText && oldVNode.$text$ !== null) {
1388
+ // the old vnode was text, so be sure to clear it out
1389
+ elm.textContent = '';
1390
+ }
1391
+ // add the new vnode children
1392
+ addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1393
+ }
1394
+ else if (BUILD.updatable && oldChildren !== null) {
1395
+ // no new child vnodes, but there are old child vnodes to remove
1396
+ removeVnodes(oldChildren, 0, oldChildren.length - 1);
1397
+ }
1398
+ if (BUILD.svg && isSvgMode && tag === 'svg') {
1399
+ isSvgMode = false;
1400
+ }
1401
+ }
1402
+ else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm['s-cr'])) {
1403
+ // this element has slotted content
1404
+ defaultHolder.parentNode.textContent = text;
1405
+ }
1406
+ else if (BUILD.vdomText && oldVNode.$text$ !== text) {
1407
+ // update the text content for the text only vnode
1408
+ // and also only if the text is different than before
1409
+ elm.data = text;
1410
+ }
1411
+ };
1412
+ const updateFallbackSlotVisibility = (elm) => {
1413
+ // tslint:disable-next-line: prefer-const
1414
+ const childNodes = elm.childNodes;
1415
+ let childNode;
1416
+ let i;
1417
+ let ilen;
1418
+ let j;
1419
+ let slotNameAttr;
1420
+ let nodeType;
1421
+ for (i = 0, ilen = childNodes.length; i < ilen; i++) {
1422
+ childNode = childNodes[i];
1423
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1424
+ if (childNode['s-sr']) {
1425
+ // this is a slot fallback node
1426
+ // get the slot name for this slot reference node
1427
+ slotNameAttr = childNode['s-sn'];
1428
+ // by default always show a fallback slot node
1429
+ // then hide it if there are other slots in the light dom
1430
+ childNode.hidden = false;
1431
+ for (j = 0; j < ilen; j++) {
1432
+ nodeType = childNodes[j].nodeType;
1433
+ if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
1434
+ // this sibling node is from a different component OR is a named fallback slot node
1435
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
1436
+ childNode.hidden = true;
1437
+ break;
1438
+ }
1439
+ }
1440
+ else {
1441
+ // this is a default fallback slot node
1442
+ // any element or text node (with content)
1443
+ // should hide the default fallback slot node
1444
+ if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
1445
+ (nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
1446
+ childNode.hidden = true;
1447
+ break;
1448
+ }
1449
+ }
1450
+ }
1451
+ }
1452
+ // keep drilling down
1453
+ updateFallbackSlotVisibility(childNode);
1454
+ }
1455
+ }
1456
+ };
1457
+ const relocateNodes = [];
1458
+ const relocateSlotContent = (elm) => {
1459
+ // tslint:disable-next-line: prefer-const
1460
+ let childNode;
1461
+ let node;
1462
+ let hostContentNodes;
1463
+ let slotNameAttr;
1464
+ let relocateNodeData;
1465
+ let j;
1466
+ let i = 0;
1467
+ const childNodes = elm.childNodes;
1468
+ const ilen = childNodes.length;
1469
+ for (; i < ilen; i++) {
1470
+ childNode = childNodes[i];
1471
+ if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
1472
+ // first got the content reference comment node
1473
+ // then we got it's parent, which is where all the host content is in now
1474
+ hostContentNodes = node.parentNode.childNodes;
1475
+ slotNameAttr = childNode['s-sn'];
1476
+ for (j = hostContentNodes.length - 1; j >= 0; j--) {
1477
+ node = hostContentNodes[j];
1478
+ if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
1479
+ // let's do some relocating to its new home
1480
+ // but never relocate a content reference node
1481
+ // that is suppose to always represent the original content location
1482
+ if (isNodeLocatedInSlot(node, slotNameAttr)) {
1483
+ // it's possible we've already decided to relocate this node
1484
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1485
+ // made some changes to slots
1486
+ // let's make sure we also double check
1487
+ // fallbacks are correctly hidden or shown
1488
+ checkSlotFallbackVisibility = true;
1489
+ node['s-sn'] = node['s-sn'] || slotNameAttr;
1490
+ if (relocateNodeData) {
1491
+ // previously we never found a slot home for this node
1492
+ // but turns out we did, so let's remember it now
1493
+ relocateNodeData.$slotRefNode$ = childNode;
1494
+ }
1495
+ else {
1496
+ // add to our list of nodes to relocate
1497
+ relocateNodes.push({
1498
+ $slotRefNode$: childNode,
1499
+ $nodeToRelocate$: node,
1500
+ });
1501
+ }
1502
+ if (node['s-sr']) {
1503
+ relocateNodes.map((relocateNode) => {
1504
+ if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
1505
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1506
+ if (relocateNodeData && !relocateNode.$slotRefNode$) {
1507
+ relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1508
+ }
1509
+ }
1510
+ });
1511
+ }
1512
+ }
1513
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1514
+ // so far this element does not have a slot home, not setting slotRefNode on purpose
1515
+ // if we never find a home for this element then we'll need to hide it
1516
+ relocateNodes.push({
1517
+ $nodeToRelocate$: node,
1518
+ });
1519
+ }
1520
+ }
1521
+ }
1522
+ }
1523
+ if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1524
+ relocateSlotContent(childNode);
1525
+ }
1526
+ }
1527
+ };
1528
+ const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
1529
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1530
+ if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
1531
+ return true;
1532
+ }
1533
+ if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
1534
+ return true;
1535
+ }
1536
+ return false;
1537
+ }
1538
+ if (nodeToRelocate['s-sn'] === slotNameAttr) {
1539
+ return true;
1540
+ }
1541
+ return slotNameAttr === '';
1542
+ };
1543
+ const callNodeRefs = (vNode) => {
1544
+ if (BUILD.vdomRef) {
1545
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1546
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
1547
+ }
1548
+ };
1549
+ const renderVdom = (hostRef, renderFnResults) => {
1550
+ const hostElm = hostRef.$hostElement$;
1551
+ const cmpMeta = hostRef.$cmpMeta$;
1552
+ const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1553
+ const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1554
+ hostTagName = hostElm.tagName;
1555
+ // <Host> runtime check
1556
+ if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) {
1557
+ throw new Error(`The <Host> must be the single root component.
1558
+ Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
1559
+
1560
+ The render() function should look like this instead:
1561
+
1562
+ render() {
1563
+ // Do not return an array
1564
+ return (
1565
+ <Host>{content}</Host>
1566
+ );
1567
+ }
1568
+ `);
1569
+ }
1570
+ if (BUILD.reflect && cmpMeta.$attrsToReflect$) {
1571
+ rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1572
+ cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1573
+ }
1574
+ rootVnode.$tag$ = null;
1575
+ rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1576
+ hostRef.$vnode$ = rootVnode;
1577
+ rootVnode.$elm$ = oldVNode.$elm$ = (BUILD.shadowDom ? hostElm.shadowRoot || hostElm : hostElm);
1578
+ if (BUILD.scoped || BUILD.shadowDom) {
1579
+ scopeId = hostElm['s-sc'];
1580
+ }
1581
+ if (BUILD.slotRelocation) {
1582
+ contentRef = hostElm['s-cr'];
1583
+ useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1584
+ // always reset
1585
+ checkSlotFallbackVisibility = false;
1586
+ }
1587
+ // synchronous patch
1588
+ patch(oldVNode, rootVnode);
1589
+ if (BUILD.slotRelocation) {
1590
+ // while we're moving nodes around existing nodes, temporarily disable
1591
+ // the disconnectCallback from working
1592
+ plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1593
+ if (checkSlotRelocate) {
1594
+ relocateSlotContent(rootVnode.$elm$);
1595
+ let relocateData;
1596
+ let nodeToRelocate;
1597
+ let orgLocationNode;
1598
+ let parentNodeRef;
1599
+ let insertBeforeNode;
1600
+ let refNode;
1601
+ let i = 0;
1602
+ for (; i < relocateNodes.length; i++) {
1603
+ relocateData = relocateNodes[i];
1604
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1605
+ if (!nodeToRelocate['s-ol']) {
1606
+ // add a reference node marking this node's original location
1607
+ // keep a reference to this node for later lookups
1608
+ orgLocationNode =
1609
+ BUILD.isDebug || BUILD.hydrateServerSide
1610
+ ? originalLocationDebugNode(nodeToRelocate)
1611
+ : doc.createTextNode('');
1612
+ orgLocationNode['s-nr'] = nodeToRelocate;
1613
+ nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1614
+ }
1615
+ }
1616
+ for (i = 0; i < relocateNodes.length; i++) {
1617
+ relocateData = relocateNodes[i];
1618
+ nodeToRelocate = relocateData.$nodeToRelocate$;
1619
+ if (relocateData.$slotRefNode$) {
1620
+ // by default we're just going to insert it directly
1621
+ // after the slot reference node
1622
+ parentNodeRef = relocateData.$slotRefNode$.parentNode;
1623
+ insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
1624
+ orgLocationNode = nodeToRelocate['s-ol'];
1625
+ while ((orgLocationNode = orgLocationNode.previousSibling)) {
1626
+ refNode = orgLocationNode['s-nr'];
1627
+ if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1628
+ refNode = refNode.nextSibling;
1629
+ if (!refNode || !refNode['s-nr']) {
1630
+ insertBeforeNode = refNode;
1631
+ break;
1632
+ }
1633
+ }
1634
+ }
1635
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1636
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
1637
+ // we've checked that it's worth while to relocate
1638
+ // since that the node to relocate
1639
+ // has a different next sibling or parent relocated
1640
+ if (nodeToRelocate !== insertBeforeNode) {
1641
+ if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1642
+ // probably a component in the index.html that doesn't have it's hostname set
1643
+ nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1644
+ }
1645
+ // add it back to the dom but in its new home
1646
+ parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1647
+ }
1648
+ }
1649
+ }
1650
+ else {
1651
+ // this node doesn't have a slot home to go to, so let's hide it
1652
+ if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1653
+ nodeToRelocate.hidden = true;
1654
+ }
1655
+ }
1656
+ }
1657
+ }
1658
+ if (checkSlotFallbackVisibility) {
1659
+ updateFallbackSlotVisibility(rootVnode.$elm$);
1660
+ }
1661
+ // done moving nodes around
1662
+ // allow the disconnect callback to work again
1663
+ plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1664
+ // always reset
1665
+ relocateNodes.length = 0;
1666
+ }
1667
+ };
1668
+ // slot comment debug nodes only created with the `--debug` flag
1669
+ // otherwise these nodes are text nodes w/out content
1670
+ const slotReferenceDebugNode = (slotVNode) => doc.createComment(`<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ''}> (host=${hostTagName.toLowerCase()})`);
1671
+ const originalLocationDebugNode = (nodeToRelocate) => doc.createComment(`org-location for ` +
1672
+ (nodeToRelocate.localName
1673
+ ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate['s-hn']})`
1674
+ : `[${nodeToRelocate.textContent}]`));
1675
+ const attachToAncestor = (hostRef, ancestorComponent) => {
1676
+ if (BUILD.asyncLoading && ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1677
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1678
+ }
1679
+ };
1680
+ const scheduleUpdate = (hostRef, isInitialLoad) => {
1681
+ if (BUILD.taskQueue && BUILD.updatable) {
1682
+ hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1683
+ }
1684
+ if (BUILD.asyncLoading && hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1685
+ hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1686
+ return;
1687
+ }
1688
+ attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1689
+ // there is no ancestor component or the ancestor component
1690
+ // has already fired off its lifecycle update then
1691
+ // fire off the initial update
1692
+ const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1693
+ return BUILD.taskQueue ? writeTask(dispatch) : dispatch();
1694
+ };
1695
+ const dispatchHooks = (hostRef, isInitialLoad) => {
1696
+ const elm = hostRef.$hostElement$;
1697
+ const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1698
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1699
+ let promise;
1700
+ if (isInitialLoad) {
1701
+ if (BUILD.lazyLoad && BUILD.hostListener) {
1702
+ hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1703
+ if (hostRef.$queuedListeners$) {
1704
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1705
+ hostRef.$queuedListeners$ = null;
1706
+ }
1707
+ }
1708
+ emitLifecycleEvent(elm, 'componentWillLoad');
1709
+ if (BUILD.cmpWillLoad) {
1710
+ promise = safeCall(instance, 'componentWillLoad');
1711
+ }
1712
+ }
1713
+ else {
1714
+ emitLifecycleEvent(elm, 'componentWillUpdate');
1715
+ if (BUILD.cmpWillUpdate) {
1716
+ promise = safeCall(instance, 'componentWillUpdate');
1717
+ }
1718
+ }
1719
+ emitLifecycleEvent(elm, 'componentWillRender');
1720
+ if (BUILD.cmpWillRender) {
1721
+ promise = then(promise, () => safeCall(instance, 'componentWillRender'));
1722
+ }
1723
+ endSchedule();
1724
+ return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
1725
+ };
1726
+ const updateComponent = async (hostRef, instance, isInitialLoad) => {
1727
+ // updateComponent
1728
+ const elm = hostRef.$hostElement$;
1729
+ const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1730
+ const rc = elm['s-rc'];
1731
+ if (BUILD.style && isInitialLoad) {
1732
+ // DOM WRITE!
1733
+ attachStyles(hostRef);
1734
+ }
1735
+ const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1736
+ if (BUILD.isDev) {
1737
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1738
+ }
1739
+ if (BUILD.hydrateServerSide) {
1740
+ await callRender(hostRef, instance, elm);
1741
+ }
1742
+ else {
1743
+ callRender(hostRef, instance, elm);
1744
+ }
1745
+ if (BUILD.cssVarShim && plt.$cssShim$) {
1746
+ plt.$cssShim$.updateHost(elm);
1747
+ }
1748
+ if (BUILD.isDev) {
1749
+ hostRef.$renderCount$++;
1750
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1751
+ }
1752
+ if (BUILD.hydrateServerSide) {
1753
+ try {
1754
+ // manually connected child components during server-side hydrate
1755
+ serverSideConnected(elm);
1756
+ if (isInitialLoad) {
1757
+ // using only during server-side hydrate
1758
+ if (hostRef.$cmpMeta$.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1759
+ elm['s-en'] = '';
1760
+ }
1761
+ else if (hostRef.$cmpMeta$.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
1762
+ elm['s-en'] = 'c';
1763
+ }
1764
+ }
1765
+ }
1766
+ catch (e) {
1767
+ consoleError(e, elm);
1768
+ }
1769
+ }
1770
+ if (BUILD.asyncLoading && rc) {
1771
+ // ok, so turns out there are some child host elements
1772
+ // waiting on this parent element to load
1773
+ // let's fire off all update callbacks waiting
1774
+ rc.map((cb) => cb());
1775
+ elm['s-rc'] = undefined;
1776
+ }
1777
+ endRender();
1778
+ endUpdate();
1779
+ if (BUILD.asyncLoading) {
1780
+ const childrenPromises = elm['s-p'];
1781
+ const postUpdate = () => postUpdateComponent(hostRef);
1782
+ if (childrenPromises.length === 0) {
1783
+ postUpdate();
1784
+ }
1785
+ else {
1786
+ Promise.all(childrenPromises).then(postUpdate);
1787
+ hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1788
+ childrenPromises.length = 0;
1789
+ }
1790
+ }
1791
+ else {
1792
+ postUpdateComponent(hostRef);
1793
+ }
1794
+ };
1795
+ const callRender = (hostRef, instance, elm) => {
1796
+ // in order for bundlers to correctly treeshake the BUILD object
1797
+ // we need to ensure BUILD is not deoptimized within a try/catch
1798
+ // https://rollupjs.org/guide/en/#treeshake tryCatchDeoptimization
1799
+ const allRenderFn = BUILD.allRenderFn ? true : false;
1800
+ const lazyLoad = BUILD.lazyLoad ? true : false;
1801
+ const taskQueue = BUILD.taskQueue ? true : false;
1802
+ const updatable = BUILD.updatable ? true : false;
1803
+ try {
1804
+ renderingRef = instance;
1805
+ instance = allRenderFn ? instance.render() : instance.render && instance.render();
1806
+ if (updatable && taskQueue) {
1807
+ hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1808
+ }
1809
+ if (updatable || lazyLoad) {
1810
+ hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1811
+ }
1812
+ if (BUILD.hasRenderFn || BUILD.reflect) {
1813
+ if (BUILD.vdomRender || BUILD.reflect) {
1814
+ // looks like we've got child nodes to render into this host element
1815
+ // or we need to update the css class/attrs on the host element
1816
+ // DOM WRITE!
1817
+ if (BUILD.hydrateServerSide) {
1818
+ return Promise.resolve(instance).then((value) => renderVdom(hostRef, value));
1819
+ }
1820
+ else {
1821
+ renderVdom(hostRef, instance);
1822
+ }
1823
+ }
1824
+ else {
1825
+ elm.textContent = instance;
1826
+ }
1827
+ }
1828
+ }
1829
+ catch (e) {
1830
+ consoleError(e, hostRef.$hostElement$);
1831
+ }
1832
+ renderingRef = null;
1833
+ return null;
1834
+ };
1835
+ const getRenderingRef = () => renderingRef;
1836
+ const postUpdateComponent = (hostRef) => {
1837
+ const tagName = hostRef.$cmpMeta$.$tagName$;
1838
+ const elm = hostRef.$hostElement$;
1839
+ const endPostUpdate = createTime('postUpdate', tagName);
1840
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1841
+ const ancestorComponent = hostRef.$ancestorComponent$;
1842
+ if (BUILD.cmpDidRender) {
1843
+ if (BUILD.isDev) {
1844
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1845
+ }
1846
+ safeCall(instance, 'componentDidRender');
1847
+ if (BUILD.isDev) {
1848
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1849
+ }
1850
+ }
1851
+ emitLifecycleEvent(elm, 'componentDidRender');
1852
+ if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1853
+ hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1854
+ if (BUILD.asyncLoading && BUILD.cssAnnotations) {
1855
+ // DOM WRITE!
1856
+ addHydratedFlag(elm);
1857
+ }
1858
+ if (BUILD.cmpDidLoad) {
1859
+ if (BUILD.isDev) {
1860
+ hostRef.$flags$ |= 2048 /* HOST_FLAGS.devOnDidLoad */;
1861
+ }
1862
+ safeCall(instance, 'componentDidLoad');
1863
+ if (BUILD.isDev) {
1864
+ hostRef.$flags$ &= ~2048 /* HOST_FLAGS.devOnDidLoad */;
1865
+ }
1866
+ }
1867
+ emitLifecycleEvent(elm, 'componentDidLoad');
1868
+ endPostUpdate();
1869
+ if (BUILD.asyncLoading) {
1870
+ hostRef.$onReadyResolve$(elm);
1871
+ if (!ancestorComponent) {
1872
+ appDidLoad(tagName);
1873
+ }
1874
+ }
1875
+ }
1876
+ else {
1877
+ if (BUILD.cmpDidUpdate) {
1878
+ // we've already loaded this component
1879
+ // fire off the user's componentDidUpdate method (if one was provided)
1880
+ // componentDidUpdate runs AFTER render() has been called
1881
+ // and all child components have finished updating
1882
+ if (BUILD.isDev) {
1883
+ hostRef.$flags$ |= 1024 /* HOST_FLAGS.devOnRender */;
1884
+ }
1885
+ safeCall(instance, 'componentDidUpdate');
1886
+ if (BUILD.isDev) {
1887
+ hostRef.$flags$ &= ~1024 /* HOST_FLAGS.devOnRender */;
1888
+ }
1889
+ }
1890
+ emitLifecycleEvent(elm, 'componentDidUpdate');
1891
+ endPostUpdate();
1892
+ }
1893
+ if (BUILD.hotModuleReplacement) {
1894
+ elm['s-hmr-load'] && elm['s-hmr-load']();
1895
+ }
1896
+ if (BUILD.method && BUILD.lazyLoad) {
1897
+ hostRef.$onInstanceResolve$(elm);
1898
+ }
1899
+ // load events fire from bottom to top
1900
+ // the deepest elements load first then bubbles up
1901
+ if (BUILD.asyncLoading) {
1902
+ if (hostRef.$onRenderResolve$) {
1903
+ hostRef.$onRenderResolve$();
1904
+ hostRef.$onRenderResolve$ = undefined;
1905
+ }
1906
+ if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1907
+ nextTick(() => scheduleUpdate(hostRef, false));
1908
+ }
1909
+ hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1910
+ }
1911
+ // ( •_•)
1912
+ // ( •_•)>⌐■-■
1913
+ // (⌐■_■)
1914
+ };
1915
+ const forceUpdate = (ref) => {
1916
+ if (BUILD.updatable) {
1917
+ const hostRef = getHostRef(ref);
1918
+ const isConnected = hostRef.$hostElement$.isConnected;
1919
+ if (isConnected &&
1920
+ (hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1921
+ scheduleUpdate(hostRef, false);
1922
+ }
1923
+ // Returns "true" when the forced update was successfully scheduled
1924
+ return isConnected;
1925
+ }
1926
+ return false;
1927
+ };
1928
+ const appDidLoad = (who) => {
1929
+ // on appload
1930
+ // we have finish the first big initial render
1931
+ if (BUILD.cssAnnotations) {
1932
+ addHydratedFlag(doc.documentElement);
1933
+ }
1934
+ if (BUILD.asyncQueue) {
1935
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
1936
+ }
1937
+ nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1938
+ if (BUILD.profile && performance.measure) {
1939
+ performance.measure(`[Stencil] ${NAMESPACE} initial load (by ${who})`, 'st:app:start');
1940
+ }
1941
+ };
1942
+ const safeCall = (instance, method, arg) => {
1943
+ if (instance && instance[method]) {
1944
+ try {
1945
+ return instance[method](arg);
1946
+ }
1947
+ catch (e) {
1948
+ consoleError(e);
1949
+ }
1950
+ }
1951
+ return undefined;
1952
+ };
1953
+ const then = (promise, thenFn) => {
1954
+ return promise && promise.then ? promise.then(thenFn) : thenFn();
1955
+ };
1956
+ const emitLifecycleEvent = (elm, lifecycleName) => {
1957
+ if (BUILD.lifecycleDOMEvents) {
1958
+ emitEvent(elm, 'stencil_' + lifecycleName, {
1959
+ bubbles: true,
1960
+ composed: true,
1961
+ detail: {
1962
+ namespace: NAMESPACE,
1963
+ },
1964
+ });
1965
+ }
1966
+ };
1967
+ const addHydratedFlag = (elm) => BUILD.hydratedClass
1968
+ ? elm.classList.add('hydrated')
1969
+ : BUILD.hydratedAttribute
1970
+ ? elm.setAttribute('hydrated', '')
1971
+ : undefined;
1972
+ const serverSideConnected = (elm) => {
1973
+ const children = elm.children;
1974
+ if (children != null) {
1975
+ for (let i = 0, ii = children.length; i < ii; i++) {
1976
+ const childElm = children[i];
1977
+ if (typeof childElm.connectedCallback === 'function') {
1978
+ childElm.connectedCallback();
1979
+ }
1980
+ serverSideConnected(childElm);
1981
+ }
1982
+ }
1983
+ };
1984
+ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1985
+ const setValue = (ref, propName, newVal, cmpMeta) => {
1986
+ // check our new property value against our internal value
1987
+ const hostRef = getHostRef(ref);
1988
+ const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
1989
+ const oldVal = hostRef.$instanceValues$.get(propName);
1990
+ const flags = hostRef.$flags$;
1991
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
1992
+ newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1993
+ // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1994
+ const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1995
+ const didValueChange = newVal !== oldVal && !areBothNaN;
1996
+ if ((!BUILD.lazyLoad || !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1997
+ // gadzooks! the property's value has changed!!
1998
+ // set our new value!
1999
+ hostRef.$instanceValues$.set(propName, newVal);
2000
+ if (BUILD.isDev) {
2001
+ if (hostRef.$flags$ & 1024 /* HOST_FLAGS.devOnRender */) {
2002
+ consoleDevWarn(`The state/prop "${propName}" changed during rendering. This can potentially lead to infinite-loops and other bugs.`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
2003
+ }
2004
+ else if (hostRef.$flags$ & 2048 /* HOST_FLAGS.devOnDidLoad */) {
2005
+ consoleDevWarn(`The state/prop "${propName}" changed during "componentDidLoad()", this triggers extra re-renders, try to setup on "componentWillLoad()"`, '\nElement', elm, '\nNew value', newVal, '\nOld value', oldVal);
2006
+ }
2007
+ }
2008
+ if (!BUILD.lazyLoad || instance) {
2009
+ // get an array of method names of watch functions to call
2010
+ if (BUILD.watchCallback && cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
2011
+ const watchMethods = cmpMeta.$watchers$[propName];
2012
+ if (watchMethods) {
2013
+ // this instance is watching for when this property changed
2014
+ watchMethods.map((watchMethodName) => {
2015
+ try {
2016
+ // fire off each of the watch methods that are watching this property
2017
+ instance[watchMethodName](newVal, oldVal, propName);
2018
+ }
2019
+ catch (e) {
2020
+ consoleError(e, elm);
2021
+ }
2022
+ });
2023
+ }
2024
+ }
2025
+ if (BUILD.updatable &&
2026
+ (flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
2027
+ if (BUILD.cmpShouldUpdate && instance.componentShouldUpdate) {
2028
+ if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
2029
+ return;
2030
+ }
2031
+ }
2032
+ // looks like this value actually changed, so we've got work to do!
2033
+ // but only if we've already rendered, otherwise just chill out
2034
+ // queue that we need to do an update, but don't worry about queuing
2035
+ // up millions cuz this function ensures it only runs once
2036
+ scheduleUpdate(hostRef, false);
2037
+ }
2038
+ }
2039
+ }
2040
+ };
2041
+ /**
2042
+ * Attach a series of runtime constructs to a compiled Stencil component
2043
+ * constructor, including getters and setters for the `@Prop` and `@State`
2044
+ * decorators, callbacks for when attributes change, and so on.
2045
+ *
2046
+ * @param Cstr the constructor for a component that we need to process
2047
+ * @param cmpMeta metadata collected previously about the component
2048
+ * @param flags a number used to store a series of bit flags
2049
+ * @returns a reference to the same constructor passed in (but now mutated)
2050
+ */
2051
+ const proxyComponent = (Cstr, cmpMeta, flags) => {
2052
+ if (BUILD.member && cmpMeta.$members$) {
2053
+ if (BUILD.watchCallback && Cstr.watchers) {
2054
+ cmpMeta.$watchers$ = Cstr.watchers;
2055
+ }
2056
+ // It's better to have a const than two Object.entries()
2057
+ const members = Object.entries(cmpMeta.$members$);
2058
+ const prototype = Cstr.prototype;
2059
+ members.map(([memberName, [memberFlags]]) => {
2060
+ if ((BUILD.prop || BUILD.state) &&
2061
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
2062
+ ((!BUILD.lazyLoad || flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
2063
+ // proxyComponent - prop
2064
+ Object.defineProperty(prototype, memberName, {
2065
+ get() {
2066
+ // proxyComponent, get value
2067
+ return getValue(this, memberName);
2068
+ },
2069
+ set(newValue) {
2070
+ // only during dev time
2071
+ if (BUILD.isDev) {
2072
+ const ref = getHostRef(this);
2073
+ if (
2074
+ // we are proxying the instance (not element)
2075
+ (flags & 1 /* PROXY_FLAGS.isElementConstructor */) === 0 &&
2076
+ // the element is not constructing
2077
+ (ref.$flags$ & 8 /* HOST_FLAGS.isConstructingInstance */) === 0 &&
2078
+ // the member is a prop
2079
+ (memberFlags & 31 /* MEMBER_FLAGS.Prop */) !== 0 &&
2080
+ // the member is not mutable
2081
+ (memberFlags & 1024 /* MEMBER_FLAGS.Mutable */) === 0) {
2082
+ consoleDevWarn(`@Prop() "${memberName}" on <${cmpMeta.$tagName$}> is immutable but was modified from within the component.\nMore information: https://stenciljs.com/docs/properties#prop-mutability`);
2083
+ }
2084
+ }
2085
+ // proxyComponent, set value
2086
+ setValue(this, memberName, newValue, cmpMeta);
2087
+ },
2088
+ configurable: true,
2089
+ enumerable: true,
2090
+ });
2091
+ }
2092
+ else if (BUILD.lazyLoad &&
2093
+ BUILD.method &&
2094
+ flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
2095
+ memberFlags & 64 /* MEMBER_FLAGS.Method */) {
2096
+ // proxyComponent - method
2097
+ Object.defineProperty(prototype, memberName, {
2098
+ value(...args) {
2099
+ const ref = getHostRef(this);
2100
+ return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
2101
+ },
2102
+ });
2103
+ }
2104
+ });
2105
+ if (BUILD.observeAttribute && (!BUILD.lazyLoad || flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
2106
+ const attrNameToPropName = new Map();
2107
+ prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
2108
+ plt.jmp(() => {
2109
+ const propName = attrNameToPropName.get(attrName);
2110
+ // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
2111
+ // in the case where an attribute was set inline.
2112
+ // ```html
2113
+ // <my-component some-attribute="some-value"></my-component>
2114
+ // ```
2115
+ //
2116
+ // There is an edge case where a developer sets the attribute inline on a custom element and then
2117
+ // programmatically changes it before it has been upgraded as shown below:
2118
+ //
2119
+ // ```html
2120
+ // <!-- this component has _not_ been upgraded yet -->
2121
+ // <my-component id="test" some-attribute="some-value"></my-component>
2122
+ // <script>
2123
+ // // grab non-upgraded component
2124
+ // el = document.querySelector("#test");
2125
+ // el.someAttribute = "another-value";
2126
+ // // upgrade component
2127
+ // customElements.define('my-component', MyComponent);
2128
+ // </script>
2129
+ // ```
2130
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
2131
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
2132
+ // to the value that was set inline i.e. "some-value" from above example. When
2133
+ // the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
2134
+ //
2135
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
2136
+ // by connectedCallback as this attributeChangedCallback will not fire.
2137
+ //
2138
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2139
+ //
2140
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
2141
+ // properties here given that this goes against best practices outlined here
2142
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
2143
+ if (this.hasOwnProperty(propName)) {
2144
+ newValue = this[propName];
2145
+ delete this[propName];
2146
+ }
2147
+ else if (prototype.hasOwnProperty(propName) &&
2148
+ typeof this[propName] === 'number' &&
2149
+ this[propName] == newValue) {
2150
+ // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
2151
+ // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
2152
+ // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
2153
+ return;
2154
+ }
2155
+ this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
2156
+ });
2157
+ };
2158
+ // create an array of attributes to observe
2159
+ // and also create a map of html attribute name to js property name
2160
+ Cstr.observedAttributes = members
2161
+ .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
2162
+ .map(([propName, m]) => {
2163
+ const attrName = m[1] || propName;
2164
+ attrNameToPropName.set(attrName, propName);
2165
+ if (BUILD.reflect && m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
2166
+ cmpMeta.$attrsToReflect$.push([propName, attrName]);
2167
+ }
2168
+ return attrName;
2169
+ });
2170
+ }
2171
+ }
2172
+ return Cstr;
2173
+ };
2174
+ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
2175
+ // initializeComponent
2176
+ if ((BUILD.lazyLoad || BUILD.hydrateServerSide || BUILD.style) &&
2177
+ (hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
2178
+ if (BUILD.lazyLoad || BUILD.hydrateClientSide) {
2179
+ // we haven't initialized this element yet
2180
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
2181
+ // lazy loaded components
2182
+ // request the component's implementation to be
2183
+ // wired up with the host element
2184
+ Cstr = loadModule(cmpMeta, hostRef, hmrVersionId);
2185
+ if (Cstr.then) {
2186
+ // Await creates a micro-task avoid if possible
2187
+ const endLoad = uniqueTime(`st:load:${cmpMeta.$tagName$}:${hostRef.$modeName$}`, `[Stencil] Load module for <${cmpMeta.$tagName$}>`);
2188
+ Cstr = await Cstr;
2189
+ endLoad();
2190
+ }
2191
+ if ((BUILD.isDev || BUILD.isDebug) && !Cstr) {
2192
+ throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
2193
+ }
2194
+ if (BUILD.member && !Cstr.isProxied) {
2195
+ // we've never proxied this Constructor before
2196
+ // let's add the getters/setters to its prototype before
2197
+ // the first time we create an instance of the implementation
2198
+ if (BUILD.watchCallback) {
2199
+ cmpMeta.$watchers$ = Cstr.watchers;
2200
+ }
2201
+ proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
2202
+ Cstr.isProxied = true;
2203
+ }
2204
+ const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
2205
+ // ok, time to construct the instance
2206
+ // but let's keep track of when we start and stop
2207
+ // so that the getters/setters don't incorrectly step on data
2208
+ if (BUILD.member) {
2209
+ hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
2210
+ }
2211
+ // construct the lazy-loaded component implementation
2212
+ // passing the hostRef is very important during
2213
+ // construction in order to directly wire together the
2214
+ // host element and the lazy-loaded instance
2215
+ try {
2216
+ new Cstr(hostRef);
2217
+ }
2218
+ catch (e) {
2219
+ consoleError(e);
2220
+ }
2221
+ if (BUILD.member) {
2222
+ hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
2223
+ }
2224
+ if (BUILD.watchCallback) {
2225
+ hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
2226
+ }
2227
+ endNewInstance();
2228
+ fireConnectedCallback(hostRef.$lazyInstance$);
2229
+ }
2230
+ else {
2231
+ // sync constructor component
2232
+ Cstr = elm.constructor;
2233
+ hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
2234
+ // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
2235
+ // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
2236
+ // Stencil has completed instantiating the component.
2237
+ customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
2238
+ }
2239
+ if (BUILD.style && Cstr.style) {
2240
+ // this component has styles but we haven't registered them yet
2241
+ let style = Cstr.style;
2242
+ if (BUILD.mode && typeof style !== 'string') {
2243
+ style = style[(hostRef.$modeName$ = computeMode(elm))];
2244
+ if (BUILD.hydrateServerSide && hostRef.$modeName$) {
2245
+ elm.setAttribute('s-mode', hostRef.$modeName$);
2246
+ }
2247
+ }
2248
+ const scopeId = getScopeId(cmpMeta, hostRef.$modeName$);
2249
+ if (!styles.has(scopeId)) {
2250
+ const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
2251
+ if (!BUILD.hydrateServerSide &&
2252
+ BUILD.shadowDom &&
2253
+ BUILD.shadowDomShim &&
2254
+ cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2255
+ style = await Promise.resolve().then(function () { return require('./shadow-css-346c0795.js'); }).then((m) => m.scopeCss(style, scopeId, false));
2256
+ }
2257
+ registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2258
+ endRegisterStyles();
2259
+ }
2260
+ }
2261
+ }
2262
+ // we've successfully created a lazy instance
2263
+ const ancestorComponent = hostRef.$ancestorComponent$;
2264
+ const schedule = () => scheduleUpdate(hostRef, true);
2265
+ if (BUILD.asyncLoading && ancestorComponent && ancestorComponent['s-rc']) {
2266
+ // this is the initial load and this component it has an ancestor component
2267
+ // but the ancestor component has NOT fired its will update lifecycle yet
2268
+ // so let's just cool our jets and wait for the ancestor to continue first
2269
+ // this will get fired off when the ancestor component
2270
+ // finally gets around to rendering its lazy self
2271
+ // fire off the initial update
2272
+ ancestorComponent['s-rc'].push(schedule);
2273
+ }
2274
+ else {
2275
+ schedule();
2276
+ }
2277
+ };
2278
+ const fireConnectedCallback = (instance) => {
2279
+ if (BUILD.lazyLoad && BUILD.connectedCallback) {
2280
+ safeCall(instance, 'connectedCallback');
2281
+ }
2282
+ };
2283
+ const connectedCallback = (elm) => {
2284
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2285
+ const hostRef = getHostRef(elm);
2286
+ const cmpMeta = hostRef.$cmpMeta$;
2287
+ const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
2288
+ if (BUILD.hostListenerTargetParent) {
2289
+ // only run if we have listeners being attached to a parent
2290
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, true);
2291
+ }
2292
+ if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
2293
+ // first time this component has connected
2294
+ hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
2295
+ let hostId;
2296
+ if (BUILD.hydrateClientSide) {
2297
+ hostId = elm.getAttribute(HYDRATE_ID);
2298
+ if (hostId) {
2299
+ if (BUILD.shadowDom && supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2300
+ const scopeId = BUILD.mode
2301
+ ? addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode'))
2302
+ : addStyle(elm.shadowRoot, cmpMeta);
2303
+ elm.classList.remove(scopeId + '-h', scopeId + '-s');
2304
+ }
2305
+ initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2306
+ }
2307
+ }
2308
+ if (BUILD.slotRelocation && !hostId) {
2309
+ // initUpdate
2310
+ // if the slot polyfill is required we'll need to put some nodes
2311
+ // in here to act as original content anchors as we move nodes around
2312
+ // host element has been connected to the DOM
2313
+ if (BUILD.hydrateServerSide ||
2314
+ ((BUILD.slot || BUILD.shadowDom) &&
2315
+ cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
2316
+ setContentReference(elm);
2317
+ }
2318
+ }
2319
+ if (BUILD.asyncLoading) {
2320
+ // find the first ancestor component (if there is one) and register
2321
+ // this component as one of the actively loading child components for its ancestor
2322
+ let ancestorComponent = elm;
2323
+ while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
2324
+ // climb up the ancestors looking for the first
2325
+ // component that hasn't finished its lifecycle update yet
2326
+ if ((BUILD.hydrateClientSide &&
2327
+ ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
2328
+ ancestorComponent.hasAttribute('s-id') &&
2329
+ ancestorComponent['s-p']) ||
2330
+ ancestorComponent['s-p']) {
2331
+ // we found this components first ancestor component
2332
+ // keep a reference to this component's ancestor component
2333
+ attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
2334
+ break;
2335
+ }
2336
+ }
2337
+ }
2338
+ // Lazy properties
2339
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2340
+ if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) {
2341
+ Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2342
+ if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
2343
+ const value = elm[memberName];
2344
+ delete elm[memberName];
2345
+ elm[memberName] = value;
2346
+ }
2347
+ });
2348
+ }
2349
+ if (BUILD.initializeNextTick) {
2350
+ // connectedCallback, taskQueue, initialLoad
2351
+ // angular sets attribute AFTER connectCallback
2352
+ // https://github.com/angular/angular/issues/18909
2353
+ // https://github.com/angular/angular/issues/19940
2354
+ nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
2355
+ }
2356
+ else {
2357
+ initializeComponent(elm, hostRef, cmpMeta);
2358
+ }
2359
+ }
2360
+ else {
2361
+ // not the first time this has connected
2362
+ // reattach any event listeners to the host
2363
+ // since they would have been removed when disconnected
2364
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
2365
+ // fire off connectedCallback() on component instance
2366
+ fireConnectedCallback(hostRef.$lazyInstance$);
2367
+ }
2368
+ endConnected();
2369
+ }
2370
+ };
2371
+ const setContentReference = (elm) => {
2372
+ // only required when we're NOT using native shadow dom (slot)
2373
+ // or this browser doesn't support native shadow dom
2374
+ // and this host element was NOT created with SSR
2375
+ // let's pick out the inner content for slot projection
2376
+ // create a node to represent where the original
2377
+ // content was first placed, which is useful later on
2378
+ const contentRefElm = (elm['s-cr'] = doc.createComment(BUILD.isDebug ? `content-ref (host=${elm.localName})` : ''));
2379
+ contentRefElm['s-cn'] = true;
2380
+ elm.insertBefore(contentRefElm, elm.firstChild);
2381
+ };
2382
+ const disconnectedCallback = (elm) => {
2383
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2384
+ const hostRef = getHostRef(elm);
2385
+ const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
2386
+ if (BUILD.hostListener) {
2387
+ if (hostRef.$rmListeners$) {
2388
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
2389
+ hostRef.$rmListeners$ = undefined;
2390
+ }
2391
+ }
2392
+ // clear CSS var-shim tracking
2393
+ if (BUILD.cssVarShim && plt.$cssShim$) {
2394
+ plt.$cssShim$.removeHost(elm);
2395
+ }
2396
+ if (BUILD.lazyLoad && BUILD.disconnectedCallback) {
2397
+ safeCall(instance, 'disconnectedCallback');
2398
+ }
2399
+ if (BUILD.cmpDidUnload) {
2400
+ safeCall(instance, 'componentDidUnload');
2401
+ }
2402
+ }
2403
+ };
2404
+ const defineCustomElement = (Cstr, compactMeta) => {
2405
+ customElements.define(compactMeta[1], proxyCustomElement(Cstr, compactMeta));
2406
+ };
2407
+ const proxyCustomElement = (Cstr, compactMeta) => {
2408
+ const cmpMeta = {
2409
+ $flags$: compactMeta[0],
2410
+ $tagName$: compactMeta[1],
2411
+ };
2412
+ if (BUILD.member) {
2413
+ cmpMeta.$members$ = compactMeta[2];
2414
+ }
2415
+ if (BUILD.hostListener) {
2416
+ cmpMeta.$listeners$ = compactMeta[3];
2417
+ }
2418
+ if (BUILD.watchCallback) {
2419
+ cmpMeta.$watchers$ = Cstr.$watchers$;
2420
+ }
2421
+ if (BUILD.reflect) {
2422
+ cmpMeta.$attrsToReflect$ = [];
2423
+ }
2424
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2425
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2426
+ }
2427
+ const originalConnectedCallback = Cstr.prototype.connectedCallback;
2428
+ const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
2429
+ Object.assign(Cstr.prototype, {
2430
+ __registerHost() {
2431
+ registerHost(this, cmpMeta);
2432
+ },
2433
+ connectedCallback() {
2434
+ connectedCallback(this);
2435
+ if (BUILD.connectedCallback && originalConnectedCallback) {
2436
+ originalConnectedCallback.call(this);
2437
+ }
2438
+ },
2439
+ disconnectedCallback() {
2440
+ disconnectedCallback(this);
2441
+ if (BUILD.disconnectedCallback && originalDisconnectedCallback) {
2442
+ originalDisconnectedCallback.call(this);
2443
+ }
2444
+ },
2445
+ __attachShadow() {
2446
+ if (supportsShadow) {
2447
+ if (BUILD.shadowDelegatesFocus) {
2448
+ this.attachShadow({
2449
+ mode: 'open',
2450
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2451
+ });
2452
+ }
2453
+ else {
2454
+ this.attachShadow({ mode: 'open' });
2455
+ }
2456
+ }
2457
+ else {
2458
+ this.shadowRoot = this;
2459
+ }
2460
+ },
2461
+ });
2462
+ Cstr.is = cmpMeta.$tagName$;
2463
+ return proxyComponent(Cstr, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */ | 2 /* PROXY_FLAGS.proxyState */);
2464
+ };
2465
+ const forceModeUpdate = (elm) => {
2466
+ if (BUILD.style && BUILD.mode && !BUILD.lazyLoad) {
2467
+ const mode = computeMode(elm);
2468
+ const hostRef = getHostRef(elm);
2469
+ if (hostRef.$modeName$ !== mode) {
2470
+ const cmpMeta = hostRef.$cmpMeta$;
2471
+ const oldScopeId = elm['s-sc'];
2472
+ const scopeId = getScopeId(cmpMeta, mode);
2473
+ const style = elm.constructor.style[mode];
2474
+ const flags = cmpMeta.$flags$;
2475
+ if (style) {
2476
+ if (!styles.has(scopeId)) {
2477
+ registerStyle(scopeId, style, !!(flags & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2478
+ }
2479
+ hostRef.$modeName$ = mode;
2480
+ elm.classList.remove(oldScopeId + '-h', oldScopeId + '-s');
2481
+ attachStyles(hostRef);
2482
+ forceUpdate(elm);
2483
+ }
2484
+ }
2485
+ }
2486
+ };
2487
+ const patchCloneNode = (HostElementPrototype) => {
2488
+ const orgCloneNode = HostElementPrototype.cloneNode;
2489
+ HostElementPrototype.cloneNode = function (deep) {
2490
+ const srcNode = this;
2491
+ const isShadowDom = BUILD.shadowDom ? srcNode.shadowRoot && supportsShadow : false;
2492
+ const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
2493
+ if (BUILD.slot && !isShadowDom && deep) {
2494
+ let i = 0;
2495
+ let slotted, nonStencilNode;
2496
+ const stencilPrivates = [
2497
+ 's-id',
2498
+ 's-cr',
2499
+ 's-lr',
2500
+ 's-rc',
2501
+ 's-sc',
2502
+ 's-p',
2503
+ 's-cn',
2504
+ 's-sr',
2505
+ 's-sn',
2506
+ 's-hn',
2507
+ 's-ol',
2508
+ 's-nr',
2509
+ 's-si',
2510
+ ];
2511
+ for (; i < srcNode.childNodes.length; i++) {
2512
+ slotted = srcNode.childNodes[i]['s-nr'];
2513
+ nonStencilNode = stencilPrivates.every((privateField) => !srcNode.childNodes[i][privateField]);
2514
+ if (slotted) {
2515
+ if (BUILD.appendChildSlotFix && clonedNode.__appendChild) {
2516
+ clonedNode.__appendChild(slotted.cloneNode(true));
2517
+ }
2518
+ else {
2519
+ clonedNode.appendChild(slotted.cloneNode(true));
2520
+ }
2521
+ }
2522
+ if (nonStencilNode) {
2523
+ clonedNode.appendChild(srcNode.childNodes[i].cloneNode(true));
2524
+ }
2525
+ }
2526
+ }
2527
+ return clonedNode;
2528
+ };
2529
+ };
2530
+ const patchSlotAppendChild = (HostElementPrototype) => {
2531
+ HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
2532
+ HostElementPrototype.appendChild = function (newChild) {
2533
+ const slotName = (newChild['s-sn'] = getSlotName(newChild));
2534
+ const slotNode = getHostSlotNode(this.childNodes, slotName);
2535
+ if (slotNode) {
2536
+ const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2537
+ const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2538
+ return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2539
+ }
2540
+ return this.__appendChild(newChild);
2541
+ };
2542
+ };
2543
+ /**
2544
+ * Patches the text content of an unnamed slotted node inside a scoped component
2545
+ * @param hostElementPrototype the `Element` to be patched
2546
+ * @param cmpMeta component runtime metadata used to determine if the component should be patched or not
2547
+ */
2548
+ const patchTextContent = (hostElementPrototype, cmpMeta) => {
2549
+ if (BUILD.scoped && cmpMeta.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
2550
+ const descriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'textContent');
2551
+ Object.defineProperty(hostElementPrototype, '__textContent', descriptor);
2552
+ Object.defineProperty(hostElementPrototype, 'textContent', {
2553
+ get() {
2554
+ var _a;
2555
+ // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2556
+ // the empty string
2557
+ const slotNode = getHostSlotNode(this.childNodes, '');
2558
+ // when a slot node is found, the textContent _may_ be found in the next sibling (text) node, depending on how
2559
+ // nodes were reordered during the vdom render. first try to get the text content from the sibling.
2560
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2561
+ return slotNode.nextSibling.textContent;
2562
+ }
2563
+ else if (slotNode) {
2564
+ return slotNode.textContent;
2565
+ }
2566
+ else {
2567
+ // fallback to the original implementation
2568
+ return this.__textContent;
2569
+ }
2570
+ },
2571
+ set(value) {
2572
+ var _a;
2573
+ // get the 'default slot', which would be the first slot in a shadow tree (if we were using one), whose name is
2574
+ // the empty string
2575
+ const slotNode = getHostSlotNode(this.childNodes, '');
2576
+ // when a slot node is found, the textContent _may_ need to be placed in the next sibling (text) node,
2577
+ // depending on how nodes were reordered during the vdom render. first try to set the text content on the
2578
+ // sibling.
2579
+ if (((_a = slotNode === null || slotNode === void 0 ? void 0 : slotNode.nextSibling) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* NODE_TYPES.TEXT_NODE */) {
2580
+ slotNode.nextSibling.textContent = value;
2581
+ }
2582
+ else if (slotNode) {
2583
+ slotNode.textContent = value;
2584
+ }
2585
+ else {
2586
+ // we couldn't find a slot, but that doesn't mean that there isn't one. if this check ran before the DOM
2587
+ // loaded, we could have missed it. check for a content reference element on the scoped component and insert
2588
+ // it there
2589
+ this.__textContent = value;
2590
+ const contentRefElm = this['s-cr'];
2591
+ if (contentRefElm) {
2592
+ this.insertBefore(contentRefElm, this.firstChild);
2593
+ }
2594
+ }
2595
+ },
2596
+ });
2597
+ }
2598
+ };
2599
+ const patchChildSlotNodes = (elm, cmpMeta) => {
2600
+ class FakeNodeList extends Array {
2601
+ item(n) {
2602
+ return this[n];
2603
+ }
2604
+ }
2605
+ if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2606
+ const childNodesFn = elm.__lookupGetter__('childNodes');
2607
+ Object.defineProperty(elm, 'children', {
2608
+ get() {
2609
+ return this.childNodes.map((n) => n.nodeType === 1);
2610
+ },
2611
+ });
2612
+ Object.defineProperty(elm, 'childElementCount', {
2613
+ get() {
2614
+ return elm.children.length;
2615
+ },
2616
+ });
2617
+ Object.defineProperty(elm, 'childNodes', {
2618
+ get() {
2619
+ const childNodes = childNodesFn.call(this);
2620
+ if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0 &&
2621
+ getHostRef(this).$flags$ & 2 /* HOST_FLAGS.hasRendered */) {
2622
+ const result = new FakeNodeList();
2623
+ for (let i = 0; i < childNodes.length; i++) {
2624
+ const slot = childNodes[i]['s-nr'];
2625
+ if (slot) {
2626
+ result.push(slot);
2627
+ }
2628
+ }
2629
+ return result;
2630
+ }
2631
+ return FakeNodeList.from(childNodes);
2632
+ },
2633
+ });
2634
+ }
2635
+ };
2636
+ const getSlotName = (node) => node['s-sn'] || (node.nodeType === 1 && node.getAttribute('slot')) || '';
2637
+ /**
2638
+ * Recursively searches a series of child nodes for a slot with the provided name.
2639
+ * @param childNodes the nodes to search for a slot with a specific name.
2640
+ * @param slotName the name of the slot to match on.
2641
+ * @returns a reference to the slot node that matches the provided name, `null` otherwise
2642
+ */
2643
+ const getHostSlotNode = (childNodes, slotName) => {
2644
+ let i = 0;
2645
+ let childNode;
2646
+ for (; i < childNodes.length; i++) {
2647
+ childNode = childNodes[i];
2648
+ if (childNode['s-sr'] && childNode['s-sn'] === slotName) {
2649
+ return childNode;
2650
+ }
2651
+ childNode = getHostSlotNode(childNode.childNodes, slotName);
2652
+ if (childNode) {
2653
+ return childNode;
2654
+ }
2655
+ }
2656
+ return null;
2657
+ };
2658
+ const getHostSlotChildNodes = (n, slotName) => {
2659
+ const childNodes = [n];
2660
+ while ((n = n.nextSibling) && n['s-sn'] === slotName) {
2661
+ childNodes.push(n);
2662
+ }
2663
+ return childNodes;
2664
+ };
2665
+ const hmrStart = (elm, cmpMeta, hmrVersionId) => {
2666
+ // ¯\_(ツ)_/¯
2667
+ const hostRef = getHostRef(elm);
2668
+ // reset state flags to only have been connected
2669
+ hostRef.$flags$ = 1 /* HOST_FLAGS.hasConnected */;
2670
+ // TODO
2671
+ // detatch any event listeners that may have been added
2672
+ // because we're not passing an exact event name it'll
2673
+ // remove all of this element's event, which is good
2674
+ // create a callback for when this component finishes hmr
2675
+ elm['s-hmr-load'] = () => {
2676
+ // finished hmr for this element
2677
+ delete elm['s-hmr-load'];
2678
+ };
2679
+ // re-initialize the component
2680
+ initializeComponent(elm, hostRef, cmpMeta, hmrVersionId);
2681
+ };
2682
+ const bootstrapLazy = (lazyBundles, options = {}) => {
2683
+ if (BUILD.profile && performance.mark) {
2684
+ performance.mark('st:app:start');
2685
+ }
2686
+ installDevTools();
2687
+ const endBootstrap = createTime('bootstrapLazy');
2688
+ const cmpTags = [];
2689
+ const exclude = options.exclude || [];
2690
+ const customElements = win.customElements;
2691
+ const head = doc.head;
2692
+ const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
2693
+ const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
2694
+ const deferredConnectedCallbacks = [];
2695
+ const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
2696
+ let appLoadFallback;
2697
+ let isBootstrapping = true;
2698
+ let i = 0;
2699
+ Object.assign(plt, options);
2700
+ plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2701
+ if (BUILD.asyncQueue) {
2702
+ if (options.syncQueue) {
2703
+ plt.$flags$ |= 4 /* PLATFORM_FLAGS.queueSync */;
2704
+ }
2705
+ }
2706
+ if (BUILD.hydrateClientSide) {
2707
+ // If the app is already hydrated there is not point to disable the
2708
+ // async queue. This will improve the first input delay
2709
+ plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2710
+ }
2711
+ if (BUILD.hydrateClientSide && BUILD.shadowDom) {
2712
+ for (; i < styles.length; i++) {
2713
+ registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2714
+ }
2715
+ }
2716
+ lazyBundles.map((lazyBundle) => {
2717
+ lazyBundle[1].map((compactMeta) => {
2718
+ const cmpMeta = {
2719
+ $flags$: compactMeta[0],
2720
+ $tagName$: compactMeta[1],
2721
+ $members$: compactMeta[2],
2722
+ $listeners$: compactMeta[3],
2723
+ };
2724
+ if (BUILD.member) {
2725
+ cmpMeta.$members$ = compactMeta[2];
2726
+ }
2727
+ if (BUILD.hostListener) {
2728
+ cmpMeta.$listeners$ = compactMeta[3];
2729
+ }
2730
+ if (BUILD.reflect) {
2731
+ cmpMeta.$attrsToReflect$ = [];
2732
+ }
2733
+ if (BUILD.watchCallback) {
2734
+ cmpMeta.$watchers$ = {};
2735
+ }
2736
+ if (BUILD.shadowDom && !supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2737
+ cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
2738
+ }
2739
+ const tagName = BUILD.transformTagName && options.transformTagName
2740
+ ? options.transformTagName(cmpMeta.$tagName$)
2741
+ : cmpMeta.$tagName$;
2742
+ const HostElement = class extends HTMLElement {
2743
+ // StencilLazyHost
2744
+ constructor(self) {
2745
+ // @ts-ignore
2746
+ super(self);
2747
+ self = this;
2748
+ registerHost(self, cmpMeta);
2749
+ if (BUILD.shadowDom && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2750
+ // this component is using shadow dom
2751
+ // and this browser supports shadow dom
2752
+ // add the read-only property "shadowRoot" to the host element
2753
+ // adding the shadow root build conditionals to minimize runtime
2754
+ if (supportsShadow) {
2755
+ if (BUILD.shadowDelegatesFocus) {
2756
+ self.attachShadow({
2757
+ mode: 'open',
2758
+ delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
2759
+ });
2760
+ }
2761
+ else {
2762
+ self.attachShadow({ mode: 'open' });
2763
+ }
2764
+ }
2765
+ else if (!BUILD.hydrateServerSide && !('shadowRoot' in self)) {
2766
+ self.shadowRoot = self;
2767
+ }
2768
+ }
2769
+ if (BUILD.slotChildNodesFix) {
2770
+ patchChildSlotNodes(self, cmpMeta);
2771
+ }
2772
+ }
2773
+ connectedCallback() {
2774
+ if (appLoadFallback) {
2775
+ clearTimeout(appLoadFallback);
2776
+ appLoadFallback = null;
2777
+ }
2778
+ if (isBootstrapping) {
2779
+ // connectedCallback will be processed once all components have been registered
2780
+ deferredConnectedCallbacks.push(this);
2781
+ }
2782
+ else {
2783
+ plt.jmp(() => connectedCallback(this));
2784
+ }
2785
+ }
2786
+ disconnectedCallback() {
2787
+ plt.jmp(() => disconnectedCallback(this));
2788
+ }
2789
+ componentOnReady() {
2790
+ return getHostRef(this).$onReadyPromise$;
2791
+ }
2792
+ };
2793
+ if (BUILD.cloneNodeFix) {
2794
+ patchCloneNode(HostElement.prototype);
2795
+ }
2796
+ if (BUILD.appendChildSlotFix) {
2797
+ patchSlotAppendChild(HostElement.prototype);
2798
+ }
2799
+ if (BUILD.hotModuleReplacement) {
2800
+ HostElement.prototype['s-hmr'] = function (hmrVersionId) {
2801
+ hmrStart(this, cmpMeta, hmrVersionId);
2802
+ };
2803
+ }
2804
+ if (BUILD.scopedSlotTextContentFix) {
2805
+ patchTextContent(HostElement.prototype, cmpMeta);
2806
+ }
2807
+ cmpMeta.$lazyBundleId$ = lazyBundle[0];
2808
+ if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2809
+ cmpTags.push(tagName);
2810
+ customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
2811
+ }
2812
+ });
2813
+ });
2814
+ if (BUILD.invisiblePrehydration && (BUILD.hydratedClass || BUILD.hydratedAttribute)) {
2815
+ visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
2816
+ visibilityStyle.setAttribute('data-styles', '');
2817
+ head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
2818
+ }
2819
+ // Process deferred connectedCallbacks now all components have been registered
2820
+ isBootstrapping = false;
2821
+ if (deferredConnectedCallbacks.length) {
2822
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
2823
+ }
2824
+ else {
2825
+ if (BUILD.profile) {
2826
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30, 'timeout')));
2827
+ }
2828
+ else {
2829
+ plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
2830
+ }
2831
+ }
2832
+ // Fallback appLoad event
2833
+ endBootstrap();
2834
+ };
2835
+ const getConnect = (_ref, tagName) => {
2836
+ const componentOnReady = () => {
2837
+ let elm = doc.querySelector(tagName);
2838
+ if (!elm) {
2839
+ elm = doc.createElement(tagName);
2840
+ doc.body.appendChild(elm);
2841
+ }
2842
+ return typeof elm.componentOnReady === 'function' ? elm.componentOnReady() : Promise.resolve(elm);
2843
+ };
2844
+ const create = (...args) => {
2845
+ return componentOnReady().then((el) => el.create(...args));
2846
+ };
2847
+ return {
2848
+ create,
2849
+ componentOnReady,
2850
+ };
2851
+ };
2852
+ const getContext = (_elm, context) => {
2853
+ if (context in Context) {
2854
+ return Context[context];
2855
+ }
2856
+ else if (context === 'window') {
2857
+ return win;
2858
+ }
2859
+ else if (context === 'document') {
2860
+ return doc;
2861
+ }
2862
+ else if (context === 'isServer' || context === 'isPrerender') {
2863
+ return BUILD.hydrateServerSide ? true : false;
2864
+ }
2865
+ else if (context === 'isClient') {
2866
+ return BUILD.hydrateServerSide ? false : true;
2867
+ }
2868
+ else if (context === 'resourcesUrl' || context === 'publicPath') {
2869
+ return getAssetPath('.');
2870
+ }
2871
+ else if (context === 'queue') {
2872
+ return {
2873
+ write: writeTask,
2874
+ read: readTask,
2875
+ tick: {
2876
+ then(cb) {
2877
+ return nextTick(cb);
2878
+ },
2879
+ },
2880
+ };
2881
+ }
2882
+ return undefined;
2883
+ };
2884
+ const Fragment = (_, children) => children;
2885
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
2886
+ if (BUILD.hostListener && listeners) {
2887
+ // this is called immediately within the element's constructor
2888
+ // initialize our event listeners on the host element
2889
+ // we do this now so that we can listen to events that may
2890
+ // have fired even before the instance is ready
2891
+ if (BUILD.hostListenerTargetParent) {
2892
+ // this component may have event listeners that should be attached to the parent
2893
+ if (attachParentListeners) {
2894
+ // this is being ran from within the connectedCallback
2895
+ // which is important so that we know the host element actually has a parent element
2896
+ // filter out the listeners to only have the ones that ARE being attached to the parent
2897
+ listeners = listeners.filter(([flags]) => flags & 32 /* LISTENER_FLAGS.TargetParent */);
2898
+ }
2899
+ else {
2900
+ // this is being ran from within the component constructor
2901
+ // everything BUT the parent element listeners should be attached at this time
2902
+ // filter out the listeners that are NOT being attached to the parent
2903
+ listeners = listeners.filter(([flags]) => !(flags & 32 /* LISTENER_FLAGS.TargetParent */));
2904
+ }
2905
+ }
2906
+ listeners.map(([flags, name, method]) => {
2907
+ const target = BUILD.hostListenerTarget ? getHostListenerTarget(elm, flags) : elm;
2908
+ const handler = hostListenerProxy(hostRef, method);
2909
+ const opts = hostListenerOpts(flags);
2910
+ plt.ael(target, name, handler, opts);
2911
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
2912
+ });
2913
+ }
2914
+ };
2915
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
2916
+ try {
2917
+ if (BUILD.lazyLoad) {
2918
+ if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
2919
+ // instance is ready, let's call it's member method for this event
2920
+ hostRef.$lazyInstance$[methodName](ev);
2921
+ }
2922
+ else {
2923
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
2924
+ }
2925
+ }
2926
+ else {
2927
+ hostRef.$hostElement$[methodName](ev);
2928
+ }
2929
+ }
2930
+ catch (e) {
2931
+ consoleError(e);
2932
+ }
2933
+ };
2934
+ const getHostListenerTarget = (elm, flags) => {
2935
+ if (BUILD.hostListenerTargetDocument && flags & 4 /* LISTENER_FLAGS.TargetDocument */)
2936
+ return doc;
2937
+ if (BUILD.hostListenerTargetWindow && flags & 8 /* LISTENER_FLAGS.TargetWindow */)
2938
+ return win;
2939
+ if (BUILD.hostListenerTargetBody && flags & 16 /* LISTENER_FLAGS.TargetBody */)
2940
+ return doc.body;
2941
+ if (BUILD.hostListenerTargetParent && flags & 32 /* LISTENER_FLAGS.TargetParent */)
2942
+ return elm.parentElement;
2943
+ return elm;
2944
+ };
2945
+ // prettier-ignore
2946
+ const hostListenerOpts = (flags) => supportsListenerOptions
2947
+ ? ({
2948
+ passive: (flags & 1 /* LISTENER_FLAGS.Passive */) !== 0,
2949
+ capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
2950
+ })
2951
+ : (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
2952
+ const setPlatformOptions = (opts) => Object.assign(plt, opts);
2953
+ const insertVdomAnnotations = (doc, staticComponents) => {
2954
+ if (doc != null) {
2955
+ const docData = {
2956
+ hostIds: 0,
2957
+ rootLevelIds: 0,
2958
+ staticComponents: new Set(staticComponents),
2959
+ };
2960
+ const orgLocationNodes = [];
2961
+ parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
2962
+ orgLocationNodes.forEach((orgLocationNode) => {
2963
+ if (orgLocationNode != null) {
2964
+ const nodeRef = orgLocationNode['s-nr'];
2965
+ let hostId = nodeRef['s-host-id'];
2966
+ let nodeId = nodeRef['s-node-id'];
2967
+ let childId = `${hostId}.${nodeId}`;
2968
+ if (hostId == null) {
2969
+ hostId = 0;
2970
+ docData.rootLevelIds++;
2971
+ nodeId = docData.rootLevelIds;
2972
+ childId = `${hostId}.${nodeId}`;
2973
+ if (nodeRef.nodeType === 1 /* NODE_TYPE.ElementNode */) {
2974
+ nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
2975
+ }
2976
+ else if (nodeRef.nodeType === 3 /* NODE_TYPE.TextNode */) {
2977
+ if (hostId === 0) {
2978
+ const textContent = nodeRef.nodeValue.trim();
2979
+ if (textContent === '') {
2980
+ // useless whitespace node at the document root
2981
+ orgLocationNode.remove();
2982
+ return;
2983
+ }
2984
+ }
2985
+ const commentBeforeTextNode = doc.createComment(childId);
2986
+ commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
2987
+ nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
2988
+ }
2989
+ }
2990
+ let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
2991
+ const orgLocationParentNode = orgLocationNode.parentElement;
2992
+ if (orgLocationParentNode) {
2993
+ if (orgLocationParentNode['s-en'] === '') {
2994
+ // ending with a "." means that the parent element
2995
+ // of this node's original location is a SHADOW dom element
2996
+ // and this node is apart of the root level light dom
2997
+ orgLocationNodeId += `.`;
2998
+ }
2999
+ else if (orgLocationParentNode['s-en'] === 'c') {
3000
+ // ending with a ".c" means that the parent element
3001
+ // of this node's original location is a SCOPED element
3002
+ // and this node is apart of the root level light dom
3003
+ orgLocationNodeId += `.c`;
3004
+ }
3005
+ }
3006
+ orgLocationNode.nodeValue = orgLocationNodeId;
3007
+ }
3008
+ });
3009
+ }
3010
+ };
3011
+ const parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
3012
+ if (node == null) {
3013
+ return;
3014
+ }
3015
+ if (node['s-nr'] != null) {
3016
+ orgLocationNodes.push(node);
3017
+ }
3018
+ if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3019
+ node.childNodes.forEach((childNode) => {
3020
+ const hostRef = getHostRef(childNode);
3021
+ if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
3022
+ const cmpData = {
3023
+ nodeIds: 0,
3024
+ };
3025
+ insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, cmpData);
3026
+ }
3027
+ parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
3028
+ });
3029
+ }
3030
+ };
3031
+ const insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
3032
+ if (vnode != null) {
3033
+ const hostId = ++docData.hostIds;
3034
+ hostElm.setAttribute(HYDRATE_ID, hostId);
3035
+ if (hostElm['s-cr'] != null) {
3036
+ hostElm['s-cr'].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
3037
+ }
3038
+ if (vnode.$children$ != null) {
3039
+ const depth = 0;
3040
+ vnode.$children$.forEach((vnodeChild, index) => {
3041
+ insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
3042
+ });
3043
+ }
3044
+ if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute('c-id')) {
3045
+ const parent = hostElm.parentElement;
3046
+ if (parent && parent.childNodes) {
3047
+ const parentChildNodes = Array.from(parent.childNodes);
3048
+ const comment = parentChildNodes.find((node) => node.nodeType === 8 /* NODE_TYPE.CommentNode */ && node['s-sr']);
3049
+ if (comment) {
3050
+ const index = parentChildNodes.indexOf(hostElm) - 1;
3051
+ vnode.$elm$.setAttribute(HYDRATE_CHILD_ID, `${comment['s-host-id']}.${comment['s-node-id']}.0.${index}`);
3052
+ }
3053
+ }
3054
+ }
3055
+ }
3056
+ };
3057
+ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
3058
+ const childElm = vnodeChild.$elm$;
3059
+ if (childElm == null) {
3060
+ return;
3061
+ }
3062
+ const nodeId = cmpData.nodeIds++;
3063
+ const childId = `${hostId}.${nodeId}.${depth}.${index}`;
3064
+ childElm['s-host-id'] = hostId;
3065
+ childElm['s-node-id'] = nodeId;
3066
+ if (childElm.nodeType === 1 /* NODE_TYPE.ElementNode */) {
3067
+ childElm.setAttribute(HYDRATE_CHILD_ID, childId);
3068
+ }
3069
+ else if (childElm.nodeType === 3 /* NODE_TYPE.TextNode */) {
3070
+ const parentNode = childElm.parentNode;
3071
+ const nodeName = parentNode.nodeName;
3072
+ if (nodeName !== 'STYLE' && nodeName !== 'SCRIPT') {
3073
+ const textNodeId = `${TEXT_NODE_ID}.${childId}`;
3074
+ const commentBeforeTextNode = doc.createComment(textNodeId);
3075
+ parentNode.insertBefore(commentBeforeTextNode, childElm);
3076
+ }
3077
+ }
3078
+ else if (childElm.nodeType === 8 /* NODE_TYPE.CommentNode */) {
3079
+ if (childElm['s-sr']) {
3080
+ const slotName = childElm['s-sn'] || '';
3081
+ const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
3082
+ childElm.nodeValue = slotNodeId;
3083
+ }
3084
+ }
3085
+ if (vnodeChild.$children$ != null) {
3086
+ const childDepth = depth + 1;
3087
+ vnodeChild.$children$.forEach((vnode, index) => {
3088
+ insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, index);
3089
+ });
3090
+ }
3091
+ };
3092
+ const hostRefs = /*@__PURE__*/ new WeakMap();
3093
+ const getHostRef = (ref) => hostRefs.get(ref);
3094
+ const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
3095
+ const registerHost = (elm, cmpMeta) => {
3096
+ const hostRef = {
3097
+ $flags$: 0,
3098
+ $hostElement$: elm,
3099
+ $cmpMeta$: cmpMeta,
3100
+ $instanceValues$: new Map(),
3101
+ };
3102
+ if (BUILD.isDev) {
3103
+ hostRef.$renderCount$ = 0;
3104
+ }
3105
+ if (BUILD.method && BUILD.lazyLoad) {
3106
+ hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
3107
+ }
3108
+ if (BUILD.asyncLoading) {
3109
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
3110
+ elm['s-p'] = [];
3111
+ elm['s-rc'] = [];
3112
+ }
3113
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$, false);
3114
+ return hostRefs.set(elm, hostRef);
3115
+ };
3116
+ const isMemberInElement = (elm, memberName) => memberName in elm;
3117
+ const consoleError = (e, el) => (customError || console.error)(e, el);
3118
+ const STENCIL_DEV_MODE = BUILD.isTesting
3119
+ ? ['STENCIL:'] // E2E testing
3120
+ : [
3121
+ '%cstencil',
3122
+ 'color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px',
3123
+ ];
3124
+ const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
3125
+ const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
3126
+ const consoleDevInfo = (...m) => console.info(...STENCIL_DEV_MODE, ...m);
3127
+ const setErrorHandler = (handler) => (customError = handler);
3128
+ const cmpModules = /*@__PURE__*/ new Map();
3129
+ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
3130
+ // loadModuleImport
3131
+ const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
3132
+ const bundleId = cmpMeta.$lazyBundleId$;
3133
+ if (BUILD.isDev && typeof bundleId !== 'string') {
3134
+ consoleDevError(`Trying to lazily load component <${cmpMeta.$tagName$}> with style mode "${hostRef.$modeName$}", but it does not exist.`);
3135
+ return undefined;
3136
+ }
3137
+ const module = !BUILD.hotModuleReplacement ? cmpModules.get(bundleId) : false;
3138
+ if (module) {
3139
+ return module[exportName];
3140
+ }
3141
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
3142
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
3143
+ /* @vite-ignore */
3144
+ /* webpackInclude: /\.entry\.js$/ */
3145
+ /* webpackExclude: /\.system\.entry\.js$/ */
3146
+ /* webpackMode: "lazy" */
3147
+ `./${bundleId}.entry.js${BUILD.hotModuleReplacement && hmrVersionId ? '?s-hmr=' + hmrVersionId : ''}`)); }).then((importedModule) => {
3148
+ if (!BUILD.hotModuleReplacement) {
3149
+ cmpModules.set(bundleId, importedModule);
3150
+ }
3151
+ return importedModule[exportName];
3152
+ }, consoleError);
3153
+ };
3154
+ const styles = /*@__PURE__*/ new Map();
3155
+ const modeResolutionChain = [];
3156
+ const win = typeof window !== 'undefined' ? window : {};
3157
+ const CSS = BUILD.cssVarShim ? win.CSS : null;
3158
+ const doc = win.document || { head: {} };
3159
+ const H = (win.HTMLElement || class {
3160
+ });
3161
+ const plt = {
3162
+ $flags$: 0,
3163
+ $resourcesUrl$: '',
3164
+ jmp: (h) => h(),
3165
+ raf: (h) => requestAnimationFrame(h),
3166
+ ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
3167
+ rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
3168
+ ce: (eventName, opts) => new CustomEvent(eventName, opts),
3169
+ };
3170
+ const setPlatformHelpers = (helpers) => {
3171
+ Object.assign(plt, helpers);
3172
+ };
3173
+ const supportsShadow = BUILD.shadowDomShim && BUILD.shadowDom
3174
+ ? /*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
3175
+ : true;
3176
+ const supportsListenerOptions = /*@__PURE__*/ (() => {
3177
+ let supportsListenerOptions = false;
3178
+ try {
3179
+ doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
3180
+ get() {
3181
+ supportsListenerOptions = true;
3182
+ },
3183
+ }));
3184
+ }
3185
+ catch (e) { }
3186
+ return supportsListenerOptions;
3187
+ })();
3188
+ const promiseResolve = (v) => Promise.resolve(v);
3189
+ const supportsConstructableStylesheets = BUILD.constructableCSS
3190
+ ? /*@__PURE__*/ (() => {
3191
+ try {
3192
+ new CSSStyleSheet();
3193
+ return typeof new CSSStyleSheet().replaceSync === 'function';
3194
+ }
3195
+ catch (e) { }
3196
+ return false;
3197
+ })()
3198
+ : false;
3199
+ const queueDomReads = [];
3200
+ const queueDomWrites = [];
3201
+ const queueDomWritesLow = [];
3202
+ const queueTask = (queue, write) => (cb) => {
3203
+ queue.push(cb);
3204
+ if (!queuePending) {
3205
+ queuePending = true;
3206
+ if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
3207
+ nextTick(flush);
3208
+ }
3209
+ else {
3210
+ plt.raf(flush);
3211
+ }
3212
+ }
3213
+ };
3214
+ const consume = (queue) => {
3215
+ for (let i = 0; i < queue.length; i++) {
3216
+ try {
3217
+ queue[i](performance.now());
3218
+ }
3219
+ catch (e) {
3220
+ consoleError(e);
3221
+ }
3222
+ }
3223
+ queue.length = 0;
3224
+ };
3225
+ const consumeTimeout = (queue, timeout) => {
3226
+ let i = 0;
3227
+ let ts = 0;
3228
+ while (i < queue.length && (ts = performance.now()) < timeout) {
3229
+ try {
3230
+ queue[i++](ts);
3231
+ }
3232
+ catch (e) {
3233
+ consoleError(e);
3234
+ }
3235
+ }
3236
+ if (i === queue.length) {
3237
+ queue.length = 0;
3238
+ }
3239
+ else if (i !== 0) {
3240
+ queue.splice(0, i);
3241
+ }
3242
+ };
3243
+ const flush = () => {
3244
+ if (BUILD.asyncQueue) {
3245
+ queueCongestion++;
3246
+ }
3247
+ // always force a bunch of medium callbacks to run, but still have
3248
+ // a throttle on how many can run in a certain time
3249
+ // DOM READS!!!
3250
+ consume(queueDomReads);
3251
+ // DOM WRITES!!!
3252
+ if (BUILD.asyncQueue) {
3253
+ const timeout = (plt.$flags$ & 6 /* PLATFORM_FLAGS.queueMask */) === 2 /* PLATFORM_FLAGS.appLoaded */
3254
+ ? performance.now() + 14 * Math.ceil(queueCongestion * (1.0 / 10.0))
3255
+ : Infinity;
3256
+ consumeTimeout(queueDomWrites, timeout);
3257
+ consumeTimeout(queueDomWritesLow, timeout);
3258
+ if (queueDomWrites.length > 0) {
3259
+ queueDomWritesLow.push(...queueDomWrites);
3260
+ queueDomWrites.length = 0;
3261
+ }
3262
+ if ((queuePending = queueDomReads.length + queueDomWrites.length + queueDomWritesLow.length > 0)) {
3263
+ // still more to do yet, but we've run out of time
3264
+ // let's let this thing cool off and try again in the next tick
3265
+ plt.raf(flush);
3266
+ }
3267
+ else {
3268
+ queueCongestion = 0;
3269
+ }
3270
+ }
3271
+ else {
3272
+ consume(queueDomWrites);
3273
+ if ((queuePending = queueDomReads.length > 0)) {
3274
+ // still more to do yet, but we've run out of time
3275
+ // let's let this thing cool off and try again in the next tick
3276
+ plt.raf(flush);
3277
+ }
3278
+ }
3279
+ };
3280
+ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
3281
+ const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
3282
+ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
3283
+
3284
+ exports.BUILD = BUILD;
3285
+ exports.CSS = CSS;
3286
+ exports.H = H;
3287
+ exports.Host = Host;
3288
+ exports.NAMESPACE = NAMESPACE;
3289
+ exports.bootstrapLazy = bootstrapLazy;
3290
+ exports.consoleDevInfo = consoleDevInfo;
3291
+ exports.createEvent = createEvent;
3292
+ exports.doc = doc;
3293
+ exports.getElement = getElement;
3294
+ exports.h = h;
3295
+ exports.plt = plt;
3296
+ exports.promiseResolve = promiseResolve;
3297
+ exports.registerInstance = registerInstance;
3298
+ exports.win = win;