@revolist/revogrid 3.2.0 → 3.2.4

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