@mgdis/mg-components 3.1.0

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