@arcgis/coding-components 4.31.0-next.2 → 4.31.0-next.21

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 (205) hide show
  1. package/README.md +22 -3
  2. package/dist/arcgis-coding-components/arcgis-coding-components.esm.js +2 -2
  3. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ar.json +1 -1
  4. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.bg.json +1 -1
  5. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.bs.json +1 -1
  6. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ca.json +6 -6
  7. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.cs.json +1 -1
  8. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.da.json +1 -1
  9. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.de.json +1 -1
  10. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.el.json +1 -1
  11. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.es.json +1 -1
  12. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.et.json +1 -1
  13. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.fi.json +1 -1
  14. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.fr.json +1 -1
  15. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.he.json +1 -1
  16. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.hr.json +1 -1
  17. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.id.json +1 -1
  18. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.it.json +1 -1
  19. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ko.json +1 -1
  20. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.nb.json +1 -1
  21. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.nl.json +1 -1
  22. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.pl.json +1 -1
  23. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.pt-BR.json +1 -1
  24. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.pt-PT.json +1 -1
  25. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ru.json +1 -1
  26. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sk.json +1 -1
  27. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sl.json +1 -1
  28. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sr.json +1 -1
  29. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sv.json +1 -1
  30. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.th.json +1 -1
  31. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.tr.json +1 -1
  32. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.uk.json +5 -5
  33. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.vi.json +1 -1
  34. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.zh-CN.json +1 -1
  35. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.zh-HK.json +1 -1
  36. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.zh-TW.json +1 -1
  37. package/dist/arcgis-coding-components/assets/arcade-results/t9n/arcade-results.t9n.ca.json +2 -2
  38. package/dist/arcgis-coding-components/assets/arcade-results/t9n/arcade-results.t9n.de.json +1 -1
  39. package/dist/arcgis-coding-components/assets/arcade-results/t9n/arcade-results.t9n.he.json +1 -1
  40. package/dist/arcgis-coding-components/assets/arcade-variables/t9n/arcade-variables.t9n.ca.json +1 -1
  41. package/dist/arcgis-coding-components/assets/arcade-variables/t9n/arcade-variables.t9n.it.json +1 -1
  42. package/dist/arcgis-coding-components/assets/code-editor/css.worker.js +1 -1
  43. package/dist/arcgis-coding-components/assets/code-editor/html.worker.js +1 -1
  44. package/dist/arcgis-coding-components/assets/code-editor/json.worker.js +1 -1
  45. package/dist/arcgis-coding-components/assets/code-editor/sql-expr.worker.js +33 -0
  46. package/dist/arcgis-coding-components/assets/code-editor/ts.worker.js +1 -1
  47. package/dist/arcgis-coding-components/assets/language-api-panel/t9n/language-api-panel.t9n.ca.json +1 -1
  48. package/dist/arcgis-coding-components/assets/sql-expression-editor/api/sql-expression-api.t9n.en.json +735 -0
  49. package/dist/arcgis-coding-components/index.esm.js +2 -2
  50. package/dist/arcgis-coding-components/{p-7984ea8e.js → p-1b799777.js} +2 -2
  51. package/dist/arcgis-coding-components/p-4d5cf512.entry.js +6 -0
  52. package/dist/arcgis-coding-components/{p-60c2a820.js → p-56266a64.js} +2 -2
  53. package/dist/arcgis-coding-components/{p-e8211ffe.js → p-57b8bcd7.js} +1 -1
  54. package/dist/arcgis-coding-components/{p-9eced6fc.js → p-5b67b62b.js} +2 -2
  55. package/dist/arcgis-coding-components/{p-93a97573.js → p-64137fec.js} +3 -3
  56. package/dist/arcgis-coding-components/{p-e7ee4d64.js → p-6621a80f.js} +3 -3
  57. package/dist/arcgis-coding-components/p-77dd5521.js +6 -0
  58. package/dist/arcgis-coding-components/p-8eb7e694.js +6 -0
  59. package/dist/arcgis-coding-components/p-a2341e0c.js +6 -0
  60. package/dist/arcgis-coding-components/{p-bb7e832e.js → p-b715834b.js} +3 -3
  61. package/dist/arcgis-coding-components/p-cbee273f.js +6 -0
  62. package/dist/arcgis-coding-components/{p-5ef7cce5.js → p-cdc52d2f.js} +1 -1
  63. package/dist/arcgis-coding-components/{p-36fedc23.js → p-d7d1f130.js} +12 -12
  64. package/dist/arcgis-coding-components/p-e1f9b463.entry.js +6 -0
  65. package/dist/arcgis-coding-components/{p-62ee6251.js → p-e5a924a1.js} +1 -1
  66. package/dist/arcgis-coding-components/p-f2d64a9d.js +6 -0
  67. package/dist/arcgis-coding-components/{p-03ea6cd7.js → p-ff62d134.js} +3 -3
  68. package/dist/arcgis-coding-components/p-ffce0588.entry.js +6 -0
  69. package/dist/cjs/{app-globals-aee5f4b5.js → app-globals-a9ef3ca8.js} +1 -1
  70. package/dist/cjs/arcade-defaults-f5241680.js +349 -0
  71. package/dist/cjs/arcade-language-features-0b9f3947.js +274 -0
  72. package/dist/cjs/arcade-mode-cc08d9cd.js +335 -0
  73. package/dist/cjs/arcgis-arcade-editor_6.cjs.entry.js +181 -1501
  74. package/dist/cjs/arcgis-coding-components.cjs.js +4 -4
  75. package/dist/cjs/arcgis-sql-expression-editor.cjs.entry.js +81 -0
  76. package/dist/cjs/arcgis-sql-expression-fields.cjs.entry.js +80 -0
  77. package/dist/cjs/{css-7cc05f76.js → css-bb6a49ec.js} +1 -1
  78. package/dist/cjs/{cssMode-2b0daeae.js → cssMode-e7fac7d7.js} +3 -4
  79. package/dist/cjs/{html-f56911e1.js → html-7ff4071d.js} +3 -4
  80. package/dist/cjs/{htmlMode-43eed674.js → htmlMode-c89193ec.js} +3 -4
  81. package/dist/cjs/{index-b34238a6.js → index-4b7880ab.js} +9 -1
  82. package/dist/cjs/index.cjs.js +4 -3
  83. package/dist/cjs/{javascript-5115cb76.js → javascript-864c0220.js} +3 -4
  84. package/dist/cjs/{jsonMode-550dda36.js → jsonMode-ac4a7be7.js} +3 -4
  85. package/dist/cjs/{arcade-defaults-a8d8f8e2.js → language-defaults-base-57b37f9f.js} +842 -1183
  86. package/dist/cjs/loader.cjs.js +4 -4
  87. package/dist/cjs/sql-expr-defaults-245b036d.js +1347 -0
  88. package/dist/cjs/sql-expr-mode-304f5ce2.js +20844 -0
  89. package/dist/cjs/{tsMode-336306a9.js → tsMode-d30d4ab1.js} +4 -5
  90. package/dist/cjs/{typescript-b395242f.js → typescript-6c87ddb3.js} +3 -4
  91. package/dist/components/arcade-defaults.js +54 -1369
  92. package/dist/components/arcade-language-features.js +271 -0
  93. package/dist/components/arcade-mode.js +4 -264
  94. package/dist/components/arcade-results.js +7 -5
  95. package/dist/components/arcade-suggestions.js +7 -5
  96. package/dist/components/arcade-variables.js +8 -6
  97. package/dist/components/arcgis-arcade-editor.js +37 -35
  98. package/dist/components/arcgis-arcade-results.js +1 -1
  99. package/dist/components/arcgis-arcade-suggestions.js +1 -1
  100. package/dist/components/arcgis-arcade-variables.js +1 -1
  101. package/dist/components/arcgis-assets.d.ts +1 -1
  102. package/dist/components/arcgis-assets.js +1 -1
  103. package/dist/components/arcgis-code-editor.js +1 -1
  104. package/dist/components/arcgis-language-api-panel.js +1 -1
  105. package/dist/components/arcgis-sql-expression-editor.d.ts +11 -0
  106. package/dist/components/arcgis-sql-expression-editor.js +120 -0
  107. package/dist/components/arcgis-sql-expression-fields.d.ts +11 -0
  108. package/dist/components/arcgis-sql-expression-fields.js +11 -0
  109. package/dist/components/chunk-2JTWBRMN.js +1154 -0
  110. package/dist/components/code-editor.js +40 -13
  111. package/dist/components/fields.js +5 -5
  112. package/dist/components/index.js +1 -1
  113. package/dist/components/index2.js +30 -22
  114. package/dist/components/language-api-panel.js +13 -40
  115. package/dist/components/language-defaults-base.js +1309 -0
  116. package/dist/components/markdown.js +1 -1
  117. package/dist/components/sql-expr-defaults.js +196 -0
  118. package/dist/components/sql-expr-mode.js +20842 -0
  119. package/dist/components/sql-expression-fields.js +102 -0
  120. package/dist/components/useT9n.js +45 -8
  121. package/dist/components/utilities.js +1 -1
  122. package/dist/esm/{app-globals-59faaf33.js → app-globals-6d0ca11d.js} +1 -1
  123. package/dist/esm/arcade-defaults-066445c4.js +344 -0
  124. package/dist/esm/arcade-language-features-0e00c199.js +269 -0
  125. package/dist/esm/{arcade-mode-5d46035e.js → arcade-mode-abf1e1cf.js} +3 -263
  126. package/dist/esm/arcgis-arcade-editor_6.entry.js +127 -1447
  127. package/dist/esm/arcgis-coding-components.js +5 -5
  128. package/dist/esm/arcgis-sql-expression-editor.entry.js +77 -0
  129. package/dist/esm/arcgis-sql-expression-fields.entry.js +76 -0
  130. package/dist/esm/{css-e257dc49.js → css-c6dae12d.js} +1 -1
  131. package/dist/esm/{cssMode-c11f7f40.js → cssMode-052bb603.js} +2 -3
  132. package/dist/esm/{html-a6c37a99.js → html-572696a1.js} +2 -3
  133. package/dist/esm/{htmlMode-1270bc7d.js → htmlMode-fc184f2d.js} +2 -3
  134. package/dist/esm/{index-a970952c.js → index-0edd9846.js} +9 -1
  135. package/dist/esm/index.js +4 -3
  136. package/dist/esm/{javascript-ee179624.js → javascript-8bfc0096.js} +3 -4
  137. package/dist/esm/{jsonMode-07502ccb.js → jsonMode-7adf94ff.js} +2 -3
  138. package/dist/esm/{arcade-defaults-9eb28407.js → language-defaults-base-85a7f476.js} +833 -1179
  139. package/dist/esm/loader.js +5 -5
  140. package/dist/esm/sql-expr-defaults-be84ec7f.js +1339 -0
  141. package/dist/esm/sql-expr-mode-a4413e5c.js +20840 -0
  142. package/dist/esm/{tsMode-96749a12.js → tsMode-d10773c8.js} +2 -3
  143. package/dist/esm/{typescript-a3cf9881.js → typescript-9491f23e.js} +2 -3
  144. package/dist/loader/cdn.js +1 -1
  145. package/dist/loader/index.cjs.js +1 -1
  146. package/dist/loader/index.es2017.js +1 -1
  147. package/dist/loader/index.js +1 -1
  148. package/dist/types/components/arcade-editor/arcade-editor.d.ts +45 -10
  149. package/dist/types/components/arcade-results/arcade-results.d.ts +43 -1
  150. package/dist/types/components/arcade-suggestions/arcade-suggestions.d.ts +22 -1
  151. package/dist/types/components/arcade-variables/arcade-variables.d.ts +28 -1
  152. package/dist/types/components/code-editor/code-editor.d.ts +16 -5
  153. package/dist/types/components/language-api-panel/language-api-panel.d.ts +34 -8
  154. package/dist/types/components/sql-expression-editor/sql-expression-editor.d.ts +24 -0
  155. package/dist/types/components/sql-expression-fields/sql-expression-fields.d.ts +32 -0
  156. package/dist/types/components.d.ts +98 -24
  157. package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stories/internal/arcade-editor/arcade-editor.stories.d.ts +8 -1
  158. package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stories/internal/arcade-editor/editorContext.d.ts +5 -1
  159. package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stories/internal/sql-expression-editor/sql-expression-editor.stories.d.ts +13 -0
  160. package/dist/types/dependencies.d.ts +6 -10
  161. package/dist/types/utils/arcade-monaco/arcade-language-features.d.ts +1 -0
  162. package/dist/types/utils/arcade-monaco/arcade-profile-strategy.d.ts +9 -0
  163. package/dist/types/utils/fields.d.ts +2 -2
  164. package/dist/types/utils/language-defaults-base.d.ts +2 -9
  165. package/dist/types/utils/profile/editor-profile.d.ts +7 -6
  166. package/dist/types/utils/profile/types.d.ts +53 -65
  167. package/dist/types/utils/profile/utils.d.ts +9 -8
  168. package/dist/types/utils/sql-expr-monaco/DependentFiles/DateOnly.d.ts +41 -0
  169. package/dist/types/utils/sql-expr-monaco/DependentFiles/SqlInterval.d.ts +16 -0
  170. package/dist/types/utils/sql-expr-monaco/DependentFiles/SqlTimestampOffset.d.ts +26 -0
  171. package/dist/types/utils/sql-expr-monaco/DependentFiles/TimeOnly.d.ts +37 -0
  172. package/dist/types/utils/sql-expr-monaco/DependentFiles/UnknownTimeZone.d.ts +11 -0
  173. package/dist/types/utils/sql-expr-monaco/DependentFiles/WhereGrammar.d.ts +122 -0
  174. package/dist/types/utils/sql-expr-monaco/DependentFiles/sqlCompareUtils.d.ts +5 -0
  175. package/dist/types/utils/sql-expr-monaco/DependentFiles/sqlDateParsingUtils.d.ts +18 -0
  176. package/dist/types/utils/sql-expr-monaco/DependentFiles/sqlUtils.d.ts +6 -0
  177. package/dist/types/utils/sql-expr-monaco/DependentFiles/standardizedFunctions.d.ts +156 -0
  178. package/dist/types/utils/sql-expr-monaco/DependentFiles/support.d.ts +150 -0
  179. package/dist/types/utils/sql-expr-monaco/PeggyGrammar/sql92grammar.d.ts +1397 -0
  180. package/dist/types/utils/sql-expr-monaco/sql-expr-completion.d.ts +6 -0
  181. package/dist/types/utils/sql-expr-monaco/sql-expr-constants.d.ts +45 -0
  182. package/dist/types/utils/sql-expr-monaco/sql-expr-contribution.d.ts +1 -0
  183. package/dist/types/utils/sql-expr-monaco/sql-expr-defaults.d.ts +21 -0
  184. package/dist/types/utils/sql-expr-monaco/sql-expr-language-features.d.ts +39 -0
  185. package/dist/types/utils/sql-expr-monaco/sql-expr-language-syntax.d.ts +8 -0
  186. package/dist/types/utils/sql-expr-monaco/sql-expr-mode.d.ts +43 -0
  187. package/dist/types/utils/sql-expr-monaco/sql-expr-service-accessors.d.ts +19 -0
  188. package/dist/types/utils/sql-expr-monaco/sql-expr-validation-diagnostic-adapter.d.ts +34 -0
  189. package/dist/types/utils/sql-expr-monaco/sql-expr-validation-utils.d.ts +100 -0
  190. package/dist/types/utils/sql-expr-monaco/sql-expr-validation.d.ts +41 -0
  191. package/dist/types/utils/sql-expr-monaco/sql-expr-worker-manager.d.ts +17 -0
  192. package/dist/types/utils/sql-expr-monaco/sql-expr.worker.d.ts +24 -0
  193. package/dist/types/utils/sql-expr-monaco/sql-expression-profile-strategy.d.ts +13 -0
  194. package/dist/types/utils/sql-expr-monaco/types.d.ts +89 -0
  195. package/package.json +27 -21
  196. package/dist/arcgis-coding-components/p-0c6de9b3.js +0 -6
  197. package/dist/arcgis-coding-components/p-81c37dab.entry.js +0 -6
  198. package/dist/cjs/arcade-mode-b85ae7d4.js +0 -595
  199. package/dist/components/chunk-IHYYRFLQ.js +0 -1363
  200. package/dist/types/components/arcade-editor/t9n-types.d.ts +0 -8
  201. package/dist/types/components/arcade-results/t9n-types.d.ts +0 -13
  202. package/dist/types/components/arcade-suggestions/t9n-types.d.ts +0 -6
  203. package/dist/types/components/arcade-variables/t9n-types.d.ts +0 -8
  204. package/dist/types/components/language-api-panel/t9n-types.d.ts +0 -8
  205. package/dist/types/utils/profile/predefined-profile.d.ts +0 -2
@@ -0,0 +1,1154 @@
1
+ /*!
2
+ * All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
+ * See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
+ * v4.31.0-next.21
5
+ */
6
+ import { a as isNotUndefined, D as Deferred, k as safeAsyncCall, l as devToolsAwareTimeout, m as safeCall } from './index2.js';
7
+
8
+ // src/framework.ts
9
+ function retrieveComponentMembers(component, isLit) {
10
+ if (isLit) {
11
+ const elementProperties = component.constructor.elementProperties;
12
+ component.manager.internals.members = Object.fromEntries(
13
+ Array.from(
14
+ elementProperties,
15
+ ([name, descriptor]) => descriptor.noAccessor ? void 0 : [
16
+ name,
17
+ [
18
+ (descriptor.readOnly ? 2048 /* ReadOnly */ : 0) | (descriptor.state ? 32 /* State */ : descriptor.type === Number ? 2 /* Number */ : descriptor.type === Boolean ? 4 /* Boolean */ : 1 /* String */)
19
+ ]
20
+ ]
21
+ ).filter(isNotUndefined)
22
+ );
23
+ } else {
24
+ const constructor = component.constructor;
25
+ const members = constructor.__registerControllers?.(component) ?? void 0;
26
+ constructor.__registerControllers = void 0;
27
+ if (typeof members !== "object") {
28
+ throw new Error(
29
+ "Failed to retrieve component meta"
30
+ );
31
+ }
32
+ component.manager.internals.members = Object.fromEntries(
33
+ Object.entries(members).filter(([_name, [propType]]) => (propType & 63 /* PropLike */) !== 0)
34
+ );
35
+ }
36
+ }
37
+ function parsePropertyValue(value, type = 8 /* Any */) {
38
+ const isComplex = value == null || typeof value === "object" || typeof value === "function";
39
+ if (isComplex) {
40
+ return value;
41
+ }
42
+ if ((type & 4 /* Boolean */) !== 0) {
43
+ return value === "false" ? false : value === "" || !!value;
44
+ } else if ((type & 2 /* Number */) !== 0) {
45
+ return Number.parseFloat(value);
46
+ } else if ((type & 1 /* String */) !== 0) {
47
+ return String(value);
48
+ } else {
49
+ return value;
50
+ }
51
+ }
52
+ var getMemberType = (component, name) => component.manager.internals.members?.[name]?.[0];
53
+
54
+ // src/types.ts
55
+ var controllerSymbol = Symbol.for("controller");
56
+
57
+ // src/utils.ts
58
+ var isController = (value) => typeof value === "object" && value !== null && (controllerSymbol in value || "hostConnected" in value || "hostDisconnected" in value || "hostUpdate" in value || "hostUpdated" in value);
59
+
60
+ // src/ControllerInternals.ts
61
+ var ambientComponent;
62
+ function setAmbientComponent(component) {
63
+ if (ambientComponent === component) {
64
+ return;
65
+ }
66
+ ambientComponent = component;
67
+ queueMicrotask(() => {
68
+ if (ambientComponent === component) {
69
+ ambientComponent = void 0;
70
+ }
71
+ });
72
+ }
73
+ function retrieveComponent(name2) {
74
+ return ambientComponent;
75
+ }
76
+ var ambientControllers = [];
77
+ function setParentController(controller) {
78
+ if (controller === void 0) {
79
+ ambientControllers = [];
80
+ return;
81
+ }
82
+ const index = ambientControllers.indexOf(controller);
83
+ ambientControllers = index === -1 ? [...ambientControllers, controller] : ambientControllers.slice(0, index + 1);
84
+ queueMicrotask(() => {
85
+ ambientControllers = [];
86
+ });
87
+ }
88
+ function retrieveParentControllers() {
89
+ return ambientControllers;
90
+ }
91
+ var ambientChildController;
92
+ function setAmbientChildController(controller) {
93
+ if (ambientChildController === controller) {
94
+ return;
95
+ }
96
+ ambientChildController = controller;
97
+ queueMicrotask(() => {
98
+ if (ambientChildController === controller) {
99
+ ambientChildController = void 0;
100
+ }
101
+ });
102
+ }
103
+ function retrieveAmbientChildController() {
104
+ const controller = ambientChildController;
105
+ ambientChildController = void 0;
106
+ return controller;
107
+ }
108
+ var use = async (value, watchExports) => {
109
+ const controller = useRefSync(value);
110
+ if (controller === void 0) {
111
+ return value;
112
+ }
113
+ await controller.ready;
114
+ if (typeof watchExports === "function") {
115
+ const unsubscribe = controller.watchExports(
116
+ (exports) => watchExports(exports, unsubscribe)
117
+ );
118
+ }
119
+ return controller.exports;
120
+ };
121
+ var useRef = async (value) => {
122
+ const controller = useRefSync(value);
123
+ await controller.ready;
124
+ return controller;
125
+ };
126
+ var useRefSync = (value) => {
127
+ const ambientChildController2 = retrieveAmbientChildController();
128
+ if (ambientChildController2 !== void 0) {
129
+ return ambientChildController2;
130
+ }
131
+ const component = retrieveComponent();
132
+ const controller = component.manager.internals.resolveExports(value);
133
+ if (controller !== void 0) {
134
+ return controller;
135
+ }
136
+ if (isController(value)) {
137
+ return value;
138
+ }
139
+ return void 0;
140
+ };
141
+ var shouldBypass = {
142
+ setter: false,
143
+ getter: false,
144
+ readOnly: false
145
+ };
146
+ var elementToInstance = /* @__PURE__ */ new WeakMap();
147
+ var _a;
148
+ _a = controllerSymbol;
149
+ var Controller = class {
150
+ constructor(component) {
151
+ this._callbacks = {
152
+ hostConnected: [],
153
+ hostDisconnected: [],
154
+ hostLoad: [],
155
+ hostLoaded: [],
156
+ hostUpdate: [],
157
+ hostUpdated: [],
158
+ hostDestroy: [],
159
+ hostLifecycle: []
160
+ };
161
+ this._ready = new Deferred();
162
+ this._lifecycleCleanups = [];
163
+ this.connectedCalled = false;
164
+ this.willLoadCalled = false;
165
+ this.didLoadCalled = false;
166
+ this[_a] = true;
167
+ this.ready = this._ready.promise;
168
+ /*
169
+ * Setting default exports to "this" so that controllers that don't use
170
+ * exports/proxyExports(), could still be used as if they did
171
+ * (i.e with controller.use)
172
+ */
173
+ this._exports = makeProvisionalValue(this);
174
+ this._exportWatchers = /* @__PURE__ */ new Set();
175
+ const resolvedComponent = toControllerHost(component ?? retrieveComponent());
176
+ {
177
+ this.component = resolvedComponent;
178
+ }
179
+ this.component.addController(this);
180
+ setParentController(this);
181
+ const manager = this.component.manager;
182
+ const isInControllerManager = manager === void 0;
183
+ if (!isInControllerManager) {
184
+ queueMicrotask(() => this.catchUpLifecycle());
185
+ }
186
+ }
187
+ /**
188
+ * If controller is being added dynamically, after the component
189
+ * construction, then trigger connected and load right away
190
+ */
191
+ catchUpLifecycle() {
192
+ const { manager } = this.component;
193
+ const connectedWillStillHappen = !manager.connectedCalled;
194
+ if (!connectedWillStillHappen && !this.connectedCalled) {
195
+ this.triggerConnected();
196
+ }
197
+ const loadWillStillHappen = !manager.willLoadCalled;
198
+ if (loadWillStillHappen) {
199
+ return;
200
+ }
201
+ this.triggerLoad().then(() => {
202
+ const loadedWillStillHappen = !manager.didLoadCalled;
203
+ if (loadedWillStillHappen) {
204
+ return;
205
+ }
206
+ this.triggerLoaded();
207
+ }).catch(console.error);
208
+ }
209
+ get exports() {
210
+ return this._exports;
211
+ }
212
+ /**
213
+ * Set controller's exports property (for usage with proxyExports()) and mark
214
+ * controller as ready (for usage in other controllers). Also, triggers
215
+ * re-render of the component
216
+ */
217
+ set exports(exports) {
218
+ const oldExports = this._exports;
219
+ if (oldExports !== exports) {
220
+ this._exports = exports;
221
+ this._exportWatchers.forEach(safeCall);
222
+ if (this.connectedCalled && this.assignedProperty !== false) {
223
+ this.component.requestUpdate(this.assignedProperty, oldExports);
224
+ }
225
+ }
226
+ this._ready.resolve(exports);
227
+ }
228
+ setProvisionalExports(exports) {
229
+ this._exports = makeProvisionalValue(exports);
230
+ this._exportWatchers.forEach(safeCall);
231
+ }
232
+ watchExports(callback) {
233
+ const safeCallback = () => callback(this._exports);
234
+ this._exportWatchers.add(safeCallback);
235
+ return () => void this._exportWatchers.delete(safeCallback);
236
+ }
237
+ /**
238
+ * A flexible utility for making sure a controller is loaded before it's used,
239
+ * regardless of how or where a controller was defined:
240
+ *
241
+ * @example
242
+ * makeGenericController(async (component, controller) => {
243
+ * // Await some controller from the component:
244
+ * await controller.use(component.someController);
245
+ * // Initialize new controllers
246
+ * await controller.use(load(importCoreReactiveUtils));
247
+ * await controller.use(new ViewModelController(component,newWidgetsHomeHomeViewModel));
248
+ * await controller.use(someController(component));
249
+ * });
250
+ *
251
+ * @remarks
252
+ * If your controller is not async, and you are not creating it async, then
253
+ * you are not required to use controller.use - you can use it directly.
254
+ * Similarly, accessing controllers after componentWillLoad callback does not
255
+ * require awaiting them as they are guaranteed to be loaded by then.
256
+ */
257
+ get use() {
258
+ setAmbientComponent(this.component);
259
+ return use;
260
+ }
261
+ /**
262
+ * Just like controller.use, but returns the controller itself, rather than it's
263
+ * exports
264
+ *
265
+ * Use cases:
266
+ * - You have a controller and you want to make sure it's loaded before you
267
+ * try to use it
268
+ * - Your controller is not using exports, so you wish to access some props on
269
+ * it directly
270
+ * - You have a controller exports only, and you want to retrieve the
271
+ * controller itself. This is useful if you wish to call .watchExports() or
272
+ * some other method on the controller
273
+ */
274
+ get useRef() {
275
+ setAmbientComponent(this.component);
276
+ return useRef;
277
+ }
278
+ /**
279
+ * Like useRef, but doesn't wait for the controller to get ready
280
+ *
281
+ * @internal
282
+ */
283
+ get useRefSync() {
284
+ setAmbientComponent(this.component);
285
+ return useRefSync;
286
+ }
287
+ controllerRemoved() {
288
+ if (this.component.el.isConnected) {
289
+ this.triggerDisconnected();
290
+ }
291
+ this.triggerDestroy();
292
+ }
293
+ // Register a lifecycle callback
294
+ onConnected(callback) {
295
+ this._callbacks.hostConnected.push(callback);
296
+ }
297
+ onDisconnected(callback) {
298
+ this._callbacks.hostDisconnected.push(callback);
299
+ }
300
+ onLoad(callback) {
301
+ this._callbacks.hostLoad.push(callback);
302
+ }
303
+ onLoaded(callback) {
304
+ this._callbacks.hostLoaded.push(callback);
305
+ }
306
+ onUpdate(callback) {
307
+ this._callbacks.hostUpdate.push(callback);
308
+ }
309
+ onUpdated(callback) {
310
+ this._callbacks.hostUpdated.push(callback);
311
+ }
312
+ onDestroy(callback) {
313
+ this._callbacks.hostDestroy.push(callback);
314
+ }
315
+ onLifecycle(callback) {
316
+ this._callbacks.hostLifecycle.push(callback);
317
+ if (this.connectedCalled && this.component.el.isConnected) {
318
+ this._callLifecycle(callback);
319
+ }
320
+ }
321
+ // Call each lifecycle hook
322
+ /** @internal */
323
+ triggerConnected() {
324
+ const genericController = this;
325
+ if (genericController.hostConnected) {
326
+ safeCall(genericController.hostConnected, genericController);
327
+ }
328
+ this._callbacks.hostConnected.forEach(safeCall);
329
+ this.triggerLifecycle();
330
+ this.connectedCalled = true;
331
+ }
332
+ /** @internal */
333
+ triggerDisconnected() {
334
+ const genericController = this;
335
+ if (genericController.hostDisconnected) {
336
+ safeCall(genericController.hostDisconnected, genericController);
337
+ }
338
+ this._callbacks.hostDisconnected.forEach(safeCall);
339
+ this._lifecycleCleanups.forEach(safeCall);
340
+ this._lifecycleCleanups = [];
341
+ }
342
+ /** @internal */
343
+ async triggerLoad() {
344
+ if (this.willLoadCalled) {
345
+ return;
346
+ }
347
+ this.willLoadCalled = true;
348
+ const genericController = this;
349
+ if (genericController.hostLoad) {
350
+ await safeAsyncCall(genericController.hostLoad, genericController);
351
+ }
352
+ if (this._callbacks.hostLoad.length > 0) {
353
+ await Promise.allSettled(this._callbacks.hostLoad.map(safeAsyncCall));
354
+ }
355
+ this._ready.resolve(this._exports);
356
+ }
357
+ /** @internal */
358
+ triggerLoaded() {
359
+ if (this.didLoadCalled) {
360
+ return;
361
+ }
362
+ const genericController = this;
363
+ if (genericController.hostLoaded) {
364
+ safeCall(genericController.hostLoaded, genericController);
365
+ }
366
+ this._callbacks.hostLoaded.forEach(safeCall);
367
+ this.didLoadCalled = true;
368
+ }
369
+ /** @internal */
370
+ triggerUpdate(changedProperties) {
371
+ const genericController = this;
372
+ if (genericController.hostUpdate) {
373
+ safeCall(genericController.hostUpdate, genericController, changedProperties);
374
+ }
375
+ this._callbacks.hostUpdate.forEach(callUpdate, changedProperties);
376
+ }
377
+ /** @internal */
378
+ triggerUpdated(changedProperties) {
379
+ const genericController = this;
380
+ if (genericController.hostUpdated) {
381
+ safeCall(genericController.hostUpdated, genericController, changedProperties);
382
+ }
383
+ this._callbacks.hostUpdated.forEach(callUpdate, changedProperties);
384
+ }
385
+ /** @internal */
386
+ triggerDestroy() {
387
+ const genericController = this;
388
+ if (genericController.hostDestroy) {
389
+ safeCall(genericController.hostDestroy, genericController);
390
+ }
391
+ this._callbacks.hostDestroy.forEach(safeCall);
392
+ }
393
+ /** @internal */
394
+ triggerLifecycle() {
395
+ const genericController = this;
396
+ if (genericController.hostLifecycle) {
397
+ this._callLifecycle(() => genericController.hostLifecycle());
398
+ }
399
+ this._callbacks.hostLifecycle.forEach(this._callLifecycle, this);
400
+ }
401
+ _callLifecycle(callback) {
402
+ setAmbientComponent(this.component);
403
+ const cleanupRaw = safeCall(callback);
404
+ const cleanup = Array.isArray(cleanupRaw) ? cleanupRaw : [cleanupRaw];
405
+ cleanup.forEach((cleanup2) => {
406
+ if (typeof cleanup2 === "function") {
407
+ this._lifecycleCleanups.push(cleanup2);
408
+ } else if (typeof cleanup2 === "object" && typeof cleanup2.remove === "function") {
409
+ this._lifecycleCleanups.push(cleanup2.remove);
410
+ }
411
+ });
412
+ }
413
+ };
414
+ function callUpdate(callback) {
415
+ safeCall(callback, void 0, this);
416
+ }
417
+ var GenericController = Controller;
418
+ function makeProvisionalValue(base) {
419
+ if (typeof base !== "object" && typeof base !== "function" || base === null) {
420
+ return base;
421
+ }
422
+ const proxy2 = new Proxy(base, {
423
+ get(target, prop, receiver) {
424
+ if (cyclical.has(prop) && prop in target && target[prop] === proxy2) {
425
+ return void 0;
426
+ }
427
+ if (prop in target || prop in Promise.prototype || typeof prop === "symbol") {
428
+ return typeof target === "function" ? target[prop] : Reflect.get(target, prop, receiver);
429
+ }
430
+ return void 0;
431
+ },
432
+ set: (target, prop, newValue, receiver) => {
433
+ return Reflect.set(target, prop, newValue, receiver);
434
+ }
435
+ });
436
+ return proxy2;
437
+ }
438
+ var cyclical = /* @__PURE__ */ new Set(["exports", "_exports"]);
439
+ function toControllerHost(component) {
440
+ {
441
+ return component;
442
+ }
443
+ }
444
+ function trackPropertyKey(object, onResolved, defaultValue) {
445
+ const keys = Object.keys(object);
446
+ const keyCount = keys.length;
447
+ if (keyTrackMap === void 0) {
448
+ queueMicrotask(keyTrackResolve);
449
+ }
450
+ keyTrackMap ?? (keyTrackMap = /* @__PURE__ */ new Map());
451
+ let pendingTrackers = keyTrackMap.get(object);
452
+ if (pendingTrackers === void 0) {
453
+ pendingTrackers = { callbacks: [], keyCount };
454
+ keyTrackMap.set(object, pendingTrackers);
455
+ }
456
+ if (pendingTrackers.keyCount !== keyCount) {
457
+ pendingTrackers.callbacks.forEach((resolve) => resolve(keys));
458
+ pendingTrackers.callbacks = [];
459
+ pendingTrackers.keyCount = keyCount;
460
+ }
461
+ pendingTrackers.callbacks.push((keys2) => {
462
+ const callback = (key2) => safeCall(onResolved, null, key2);
463
+ const key = keys2[keyCount];
464
+ if (key === void 0) {
465
+ callback(void 0);
466
+ } else if (object[key] === defaultValue) {
467
+ callback(key);
468
+ } else {
469
+ callback(void 0);
470
+ }
471
+ });
472
+ return defaultValue;
473
+ }
474
+ var keyTrackMap = void 0;
475
+ function keyTrackResolve() {
476
+ Array.from(keyTrackMap?.entries() ?? []).forEach(([object, { callbacks }]) => {
477
+ const keys = Object.keys(object);
478
+ callbacks.forEach((commit) => commit(keys));
479
+ });
480
+ keyTrackMap = void 0;
481
+ }
482
+ function watch(component, property, callback) {
483
+ var _a2;
484
+ const genericProperty = property;
485
+ const internals = component.manager.internals;
486
+ (_a2 = internals.allWatchers)[genericProperty] ?? (_a2[genericProperty] = []);
487
+ const watchers = internals.allWatchers[genericProperty];
488
+ const genericCallback = callback;
489
+ const safeCallback = (newValue, oldValue, propertyName) => safeCall(genericCallback, null, newValue, oldValue, propertyName);
490
+ watchers.push(safeCallback);
491
+ return () => {
492
+ const index = watchers.indexOf(safeCallback);
493
+ if (index !== -1) {
494
+ watchers.splice(index, 1);
495
+ }
496
+ };
497
+ }
498
+
499
+ // src/ComponentInternals.ts
500
+ var ComponentInternals = class {
501
+ constructor(component) {
502
+ /**
503
+ * When watchers are set, set then into `allWatchers`. When watchers are read
504
+ * in the setter, read from `enabledWatchers`.
505
+ * On connectedCallback(), controller manager does `enabledWatchers=allWatchers`.
506
+ * Reasoning:
507
+ * - This disables watchers until connected callback (matches behavior of
508
+ * Stencil's watchers)
509
+ * - This removes in the setter to check if watchers were enabled already or
510
+ * not (as getters/setters are hot path, and should be streamlined)
511
+ */
512
+ this.enabledWatchers = {};
513
+ this.allWatchers = {};
514
+ /**
515
+ * "readOnly" is not enabled initially since we need to allow to set property
516
+ * default values in the constructor.
517
+ * For Stencil, readonly is enabled by the `readonly()` controller.
518
+ * For Lit, we have the following logic:
519
+ */
520
+ this.enableReadonly = () => {
521
+ this.enableReadonly = void 0;
522
+ if (!this.component.manager.isLit) {
523
+ return;
524
+ }
525
+ const internals = this.component.manager.internals;
526
+ Object.entries(internals.members).forEach(([name2, [type]]) => {
527
+ var _a2;
528
+ const isReadOnly = type & 2048 /* ReadOnly */;
529
+ if (isReadOnly) {
530
+ (_a2 = internals.setters)[name2] ?? (_a2[name2] = []);
531
+ internals.setters[name2].push(internals.readonlySetter);
532
+ }
533
+ });
534
+ };
535
+ this.trackedValue = nothing;
536
+ this.keyTrackers = [];
537
+ this.getters = {};
538
+ this.setters = {};
539
+ this.accessorGetter = {};
540
+ this.accessorSetter = {};
541
+ this.reactiveUtilsIntegrations = /* @__PURE__ */ new Set();
542
+ this._exports = /* @__PURE__ */ new WeakMap();
543
+ this.readonlySetter = (newValue, _oldValue, property) => {
544
+ if (shouldBypass.readOnly) {
545
+ return newValue;
546
+ }
547
+ throw new Error(
548
+ `Cannot assign to read-only property "${property}" of ${this.component.el.tagName.toLowerCase()}. Trying to assign "${String(
549
+ newValue
550
+ )}"`
551
+ );
552
+ };
553
+ {
554
+ this.component = component;
555
+ }
556
+ }
557
+ firePropTrackers(key, value) {
558
+ const trackers = this.keyTrackers;
559
+ this.trackedValue = nothing;
560
+ this.keyTrackers = [];
561
+ trackers.forEach((tracker) => tracker(key, value));
562
+ }
563
+ // REFACTOR: once Stencil is no longer supported, simplify this with Lit's getPropertyDescriptor(), or https://github.com/shoelace-style/shoelace/issues/1990
564
+ /**
565
+ * Configure a getter or setter for a given \@Prop/\@State
566
+ *
567
+ * Note, since props are defined on the prototype, they are shared between all
568
+ * instances of a component. Thus, instead of passing a reference to the
569
+ * getter/setter function, you should update the
570
+ * ComponentInternals.getters/setters properties, and then call getSetProxy
571
+ * to apply the changes to the prototype
572
+ */
573
+ getSetProxy(property) {
574
+ const component = this.component;
575
+ const classPrototype = component.constructor.prototype;
576
+ this._getSetProxy(classPrototype, property, "class");
577
+ if (component.manager.isLit) {
578
+ return;
579
+ }
580
+ const htmlPrototype = component.el.constructor.prototype;
581
+ if (classPrototype !== htmlPrototype) {
582
+ this._getSetProxy(htmlPrototype, property, "html");
583
+ }
584
+ }
585
+ _getSetProxy(prototype, name2, type) {
586
+ const component = this.component;
587
+ const propType = getMemberType(component, name2);
588
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, name2);
589
+ if (!descriptor) {
590
+ return void 0;
591
+ }
592
+ const originalGet = descriptor.get;
593
+ const originalSet = descriptor.set;
594
+ const isGetterAlreadyOverwritten = customAccessor in originalGet;
595
+ const isSetterAlreadyOverwritten = customAccessor in originalSet;
596
+ const shouldOverwriteGet = !isGetterAlreadyOverwritten;
597
+ const shouldOverwriteSet = !isSetterAlreadyOverwritten;
598
+ if (!shouldOverwriteGet && !shouldOverwriteSet) {
599
+ return;
600
+ }
601
+ const finalGetter = shouldOverwriteGet ? function getter() {
602
+ let value = originalGet.call(this);
603
+ const component2 = elementToInstance.get(this);
604
+ if (component2 === void 0) {
605
+ return value;
606
+ }
607
+ const internals = component2.manager.internals;
608
+ value = internals.accessorGetter[name2](value, name2);
609
+ const getters = internals.getters[name2] ?? emptyArray;
610
+ for (let i = 0; i < getters.length; i++) {
611
+ value = getters[i](value, name2);
612
+ }
613
+ return value;
614
+ } : originalGet;
615
+ const finalSetter = shouldOverwriteSet ? function setter(rawNewValue) {
616
+ const oldValue = originalGet.call(this);
617
+ const component2 = elementToInstance.get(this);
618
+ if (component2 === void 0) {
619
+ originalSet.call(this, rawNewValue);
620
+ return;
621
+ }
622
+ let newValue = component2.manager.isLit ? rawNewValue : parsePropertyValue(rawNewValue, propType);
623
+ const internals = component2.manager.internals;
624
+ if (newValue === oldValue) {
625
+ originalSet.call(this, rawNewValue);
626
+ } else {
627
+ const setters = shouldBypass.setter ? emptyArray : internals.setters[name2] ?? emptyArray;
628
+ for (let i = 0; i < setters.length; i++) {
629
+ newValue = setters[i](newValue, oldValue, name2);
630
+ if (newValue === oldValue) {
631
+ break;
632
+ }
633
+ }
634
+ newValue = internals.accessorSetter[name2](newValue, oldValue, name2);
635
+ originalSet.call(this, newValue);
636
+ if (newValue !== oldValue) {
637
+ internals.enabledWatchers[name2]?.forEach((watcher) => watcher(newValue, oldValue, name2));
638
+ }
639
+ }
640
+ if (internals.keyTrackers.length > 0) {
641
+ internals?.firePropTrackers(name2, rawNewValue);
642
+ }
643
+ } : originalSet;
644
+ if (shouldOverwriteGet) {
645
+ finalGetter[customAccessor] = true;
646
+ }
647
+ if (shouldOverwriteSet) {
648
+ finalSetter[customAccessor] = true;
649
+ }
650
+ Object.defineProperty(prototype, name2, {
651
+ ...descriptor,
652
+ get: finalGetter,
653
+ set: finalSetter
654
+ });
655
+ }
656
+ /**
657
+ * Associate an exports object with a controller for reverse lookup in
658
+ * controller.use
659
+ */
660
+ markExports(controller, exports) {
661
+ if (typeof exports === "object" && exports !== null || typeof exports === "function") {
662
+ this._exports.set(exports, controller);
663
+ }
664
+ }
665
+ resolveExports(exports) {
666
+ if (typeof exports === "object" && exports !== null || typeof exports === "function") {
667
+ return this._exports.get(exports);
668
+ } else {
669
+ return void 0;
670
+ }
671
+ }
672
+ };
673
+ var emptyArray = [];
674
+ var customAccessor = Symbol();
675
+ var nothing = (
676
+ // eslint-disable-next-line symbol-description
677
+ Symbol()
678
+ ) ;
679
+ var useControllerManager = (component, forceUpdate) => new ControllerManager(component, forceUpdate);
680
+ var ControllerManager = class extends GenericController {
681
+ constructor(component, forceUpdate) {
682
+ const isLit = "addController" in component;
683
+ const controllers = /* @__PURE__ */ new Set();
684
+ function addController(controller) {
685
+ controllers.add(controller);
686
+ if (isLit && !(controllerSymbol in controller) && component.el.isConnected) {
687
+ controller.hostConnected?.();
688
+ }
689
+ }
690
+ function removeController(controller) {
691
+ void controllers.delete(controller);
692
+ controller.controllerRemoved?.();
693
+ }
694
+ const controllerHost = component;
695
+ controllerHost.addController = addController;
696
+ controllerHost.removeController = removeController;
697
+ if (!isLit) {
698
+ const update = forceUpdate ?? component.constructor.__forceUpdate;
699
+ controllerHost.requestUpdate = () => update(component);
700
+ }
701
+ super(component);
702
+ /** @internal */
703
+ this.internals = new ComponentInternals(this.component);
704
+ this.destroyed = false;
705
+ this._updatePromise = new Deferred();
706
+ this._originalLifecycles = {};
707
+ this.isLit = isLit;
708
+ this.component.manager = this;
709
+ retrieveComponentMembers(component, isLit);
710
+ this._controllers = controllers;
711
+ this.exports = void 0;
712
+ this.hasDestroy = autoDestroyDisabledPropName in this.component && typeof this.component.destroy === "function";
713
+ if (this.hasDestroy) {
714
+ watch(component, autoDestroyDisabledPropName, () => this._setAutoDestroyTimeout());
715
+ }
716
+ this._bindLifecycleMethods();
717
+ const internals = this.internals;
718
+ Object.keys(internals.members).forEach((name2) => {
719
+ internals.accessorGetter[name2] = defaultGetterSetter;
720
+ internals.accessorSetter[name2] = defaultGetterSetter;
721
+ internals.getSetProxy(name2);
722
+ });
723
+ if (!isLit) {
724
+ Object.defineProperty(component, "updateComplete", {
725
+ get: async () => await this._updatePromise.promise
726
+ });
727
+ }
728
+ queueMicrotask(internals.enableReadonly);
729
+ setParentController(void 0);
730
+ setAmbientComponent(component);
731
+ elementToInstance.set(component.el, component);
732
+ elementToInstance.set(component, component);
733
+ }
734
+ _bindLifecycleMethods() {
735
+ const component = this.component;
736
+ const isLit = this.isLit;
737
+ const isStencilDistBuild = component.el === component;
738
+ this._originalLifecycles = {
739
+ // These component's callbacks will be called by Lit, so we don't have to
740
+ connectedCallback: isLit || isStencilDistBuild ? void 0 : component.connectedCallback,
741
+ disconnectedCallback: isLit || isStencilDistBuild ? void 0 : component.disconnectedCallback,
742
+ componentWillLoad: isLit ? void 0 : component.componentWillLoad,
743
+ componentDidLoad: isLit ? void 0 : component.componentDidLoad,
744
+ componentWillUpdate: isLit ? void 0 : component.componentWillUpdate,
745
+ componentDidUpdate: isLit ? void 0 : component.componentDidUpdate,
746
+ destroy: component.destroy
747
+ };
748
+ const hostConnected = this._connectedCallback.bind(this);
749
+ const hostDisconnected = this._disconnectedCallback.bind(this);
750
+ const hostUpdate = this._update.bind(this);
751
+ const hostUpdated = this._updated.bind(this);
752
+ if (isLit) {
753
+ component.constructor.prototype.addController.call(component, {
754
+ // Lit will call these callbacks
755
+ hostConnected,
756
+ hostDisconnected,
757
+ hostUpdate,
758
+ hostUpdated
759
+ });
760
+ } else {
761
+ component.connectedCallback = hostConnected;
762
+ component.disconnectedCallback = hostDisconnected;
763
+ component.componentWillLoad = this._load.bind(this);
764
+ component.componentDidLoad = this._loaded.bind(this);
765
+ component.componentWillUpdate = hostUpdate;
766
+ component.componentDidUpdate = hostUpdated;
767
+ }
768
+ if (this.hasDestroy) {
769
+ component.destroy = this.destroy.bind(this);
770
+ }
771
+ }
772
+ /**
773
+ * Private because this is not supposed to be called by Component directly.
774
+ * Instead, _bindLifecycleMethods will take care of that. Otherwise, you risk
775
+ * calling lifecycle methods twice.
776
+ *
777
+ * @internal
778
+ */
779
+ _connectedCallback() {
780
+ if (this.destroyed) {
781
+ const tagName = this.component.el.tagName.toLowerCase();
782
+ this.component.el.remove();
783
+ throw new Error(
784
+ `The ${tagName} component has already been destroyed. It can not be used again. If you meant to disconnect and reconnect a component without automatic destroy, set the ${autoDestroyDisabledPropName} prop.`
785
+ );
786
+ }
787
+ if (this._autoDestroyTimeout !== void 0) {
788
+ clearTimeout(this._autoDestroyTimeout);
789
+ }
790
+ const internals = this.internals;
791
+ internals.enabledWatchers = internals.allWatchers;
792
+ keyTrackResolve();
793
+ internals.enableReadonly?.();
794
+ this._controllers.forEach(callConnected);
795
+ this._originalLifecycles.connectedCallback?.call(this.component);
796
+ }
797
+ /** @internal */
798
+ _disconnectedCallback() {
799
+ if (this.destroyed) {
800
+ return;
801
+ }
802
+ this._controllers.forEach(callDisconnected);
803
+ this._originalLifecycles.disconnectedCallback?.call(this.component);
804
+ if (this.hasDestroy) {
805
+ this._setAutoDestroyTimeout();
806
+ }
807
+ }
808
+ /** @internal */
809
+ async _load() {
810
+ const integrations = this.internals.reactiveUtilsIntegrations;
811
+ if (integrations.size > 0) {
812
+ for (const controller of integrations) {
813
+ if ("triggerLoad" in controller) {
814
+ await controller.triggerLoad();
815
+ } else {
816
+ await safeAsyncCall(controller.hostLoad, controller);
817
+ }
818
+ }
819
+ }
820
+ await Promise.allSettled(Array.from(this._controllers, callLoad, integrations));
821
+ await this._originalLifecycles.componentWillLoad?.call(this.component);
822
+ }
823
+ /** @internal */
824
+ _loaded() {
825
+ this._controllers.forEach(callLoaded);
826
+ this._originalLifecycles.componentDidLoad?.call(this.component);
827
+ }
828
+ _update() {
829
+ const changedProperties = this.component.changedProperties;
830
+ this._controllers.forEach(callUpdate2, changedProperties);
831
+ void this._originalLifecycles.componentWillUpdate?.call(this.component);
832
+ }
833
+ _updated() {
834
+ const maybeLitComponent = this.component;
835
+ this._controllers.forEach(callUpdated, maybeLitComponent.changedProperties);
836
+ this._originalLifecycles.componentDidUpdate?.call(this.component);
837
+ if (this.isLit) {
838
+ maybeLitComponent.changedProperties = /* @__PURE__ */ new Map();
839
+ } else {
840
+ const updatePromise = this._updatePromise;
841
+ this._updatePromise = new Deferred();
842
+ updatePromise.resolve(true);
843
+ }
844
+ }
845
+ async destroy() {
846
+ if (this.destroyed) {
847
+ return;
848
+ }
849
+ if (this.component.el.isConnected) {
850
+ this.hasDestroy = false;
851
+ try {
852
+ this.component.el.remove();
853
+ } finally {
854
+ this.hasDestroy = true;
855
+ }
856
+ }
857
+ this._autoDestroyTimeout = void 0;
858
+ this.destroyed = true;
859
+ this._controllers.forEach(callDestroy);
860
+ this._controllers.clear();
861
+ await this._originalLifecycles.destroy?.call(this.component);
862
+ }
863
+ _setAutoDestroyTimeout() {
864
+ if (!this.component.el.isConnected && !this.component.autoDestroyDisabled) {
865
+ if (this._autoDestroyTimeout !== void 0) {
866
+ clearTimeout(this._autoDestroyTimeout);
867
+ }
868
+ const destroy = () => void this.destroy().catch(console.error);
869
+ {
870
+ this._autoDestroyTimeout = devToolsAwareTimeout(destroy, autoDestroyOnDisconnectTimeout);
871
+ }
872
+ }
873
+ }
874
+ };
875
+ var autoDestroyDisabledPropName = "autoDestroyDisabled";
876
+ var autoDestroyOnDisconnectTimeout = 1e3;
877
+ var defaultGetterSetter = (value) => value;
878
+ function callConnected(controller) {
879
+ if ("triggerConnected" in controller) {
880
+ controller.triggerConnected();
881
+ } else {
882
+ safeCall(controller.hostConnected, controller);
883
+ }
884
+ }
885
+ function callDisconnected(controller) {
886
+ if ("triggerDisconnected" in controller) {
887
+ controller.triggerDisconnected();
888
+ } else {
889
+ safeCall(controller.hostDisconnected, controller);
890
+ }
891
+ }
892
+ async function callLoad(controller) {
893
+ if (!this.has(controller)) {
894
+ if ("triggerLoad" in controller) {
895
+ await controller.triggerLoad();
896
+ } else {
897
+ await safeAsyncCall(controller.hostLoad, controller);
898
+ }
899
+ }
900
+ }
901
+ function callLoaded(controller) {
902
+ if ("triggerLoaded" in controller) {
903
+ controller.triggerLoaded();
904
+ } else {
905
+ safeCall(controller.hostLoaded, controller);
906
+ }
907
+ }
908
+ function callUpdate2(controller) {
909
+ if ("triggerUpdate" in controller) {
910
+ controller.triggerUpdate(this);
911
+ } else {
912
+ safeCall(controller.hostUpdate, controller, this);
913
+ }
914
+ }
915
+ function callUpdated(controller) {
916
+ if ("triggerUpdated" in controller) {
917
+ controller.triggerUpdated(this);
918
+ } else {
919
+ safeCall(controller.hostUpdated, controller, this);
920
+ }
921
+ }
922
+ function callDestroy(controller) {
923
+ if ("triggerDestroy" in controller) {
924
+ controller.triggerDestroy();
925
+ } else {
926
+ safeCall(controller.hostDestroy, controller);
927
+ }
928
+ }
929
+ function trackPropKey(component, onResolved, defaultValue) {
930
+ const internals = component.manager.internals;
931
+ if (internals.trackedValue !== nothing && internals.trackedValue !== defaultValue) {
932
+ internals.firePropTrackers(void 0, void 0);
933
+ }
934
+ if (internals.keyTrackers.length === 0) {
935
+ queueMicrotask(() => internals.firePropTrackers(void 0, void 0));
936
+ }
937
+ internals.trackedValue = defaultValue;
938
+ internals.keyTrackers.push((key, value) => safeCall(onResolved, void 0, defaultValue === value ? key : void 0));
939
+ return defaultValue;
940
+ }
941
+
942
+ // src/trackKey.ts
943
+ function trackKey(hostsCandidates, onResolved, defaultValue) {
944
+ const candidateHosts = Array.isArray(hostsCandidates) ? hostsCandidates : [hostsCandidates];
945
+ let leftToResolve = candidateHosts.length + 1;
946
+ const resolved = (resolution) => {
947
+ leftToResolve -= 1;
948
+ if (resolution !== void 0) {
949
+ leftToResolve = 0;
950
+ }
951
+ if (leftToResolve === 0) {
952
+ onResolved(resolution);
953
+ }
954
+ };
955
+ candidateHosts.forEach(
956
+ (host) => trackPropertyKey(
957
+ host,
958
+ (key) => resolved(
959
+ key === void 0 ? void 0 : {
960
+ key,
961
+ host,
962
+ isReactive: false
963
+ }
964
+ ),
965
+ defaultValue
966
+ )
967
+ );
968
+ const component = candidateHosts.find(
969
+ (host) => "manager" in host && typeof host.manager === "object" && host.manager.component === host
970
+ );
971
+ if (component) {
972
+ trackPropKey(
973
+ component,
974
+ (key) => resolved(
975
+ key === void 0 ? void 0 : {
976
+ key,
977
+ host: component,
978
+ isReactive: getMemberType(component, key) !== void 0
979
+ }
980
+ ),
981
+ defaultValue
982
+ );
983
+ }
984
+ return defaultValue;
985
+ }
986
+
987
+ // src/getSet.ts
988
+ function getSet(defaultValue, getSet2) {
989
+ const component = retrieveComponent();
990
+ return trackPropKey(
991
+ component,
992
+ (rawName) => {
993
+ const name2 = rawName;
994
+ const manager = component.manager;
995
+ const genericComponent = component;
996
+ const value = genericComponent[name2];
997
+ const isStencilHotReload = "production" !== "production" ;
998
+ const initialSet = getSet2.initialSet ?? true;
999
+ if (value != null && value !== defaultValue && typeof getSet2.set === "function" && initialSet && !isStencilHotReload) {
1000
+ const newValue = getSet2.set(value, defaultValue, name2);
1001
+ if (newValue !== value) {
1002
+ if (manager.isLit) {
1003
+ genericComponent[name2] = newValue;
1004
+ } else {
1005
+ let firstConnected = true;
1006
+ manager.onConnected(() => {
1007
+ if (!firstConnected) {
1008
+ return;
1009
+ }
1010
+ firstConnected = true;
1011
+ bypassSetter(() => {
1012
+ genericComponent[name2] = newValue;
1013
+ });
1014
+ });
1015
+ }
1016
+ }
1017
+ }
1018
+ genericGetSet(component, name2, getSet2);
1019
+ },
1020
+ defaultValue
1021
+ );
1022
+ }
1023
+ function bypassSetter(callback) {
1024
+ shouldBypass.setter = true;
1025
+ try {
1026
+ return callback();
1027
+ } finally {
1028
+ shouldBypass.setter = false;
1029
+ }
1030
+ }
1031
+ function genericGetSet(component, property, getSet2) {
1032
+ var _a2, _b;
1033
+ const genericGetSet2 = getSet2;
1034
+ const internals = component.manager.internals;
1035
+ const get = typeof genericGetSet2.get === "function" ? genericGetSet2.get : void 0;
1036
+ if (get) {
1037
+ (_a2 = internals.getters)[property] ?? (_a2[property] = []);
1038
+ internals.getters[property].unshift(get);
1039
+ }
1040
+ const set = genericGetSet2.set === "ignore" ? ignoreSet : genericGetSet2.set;
1041
+ if (set) {
1042
+ (_b = internals.setters)[property] ?? (_b[property] = []);
1043
+ internals.setters[property].unshift(
1044
+ set
1045
+ );
1046
+ }
1047
+ }
1048
+ var ignoreSet = (_, value) => value;
1049
+ function bypassReadOnly(callback) {
1050
+ shouldBypass.readOnly = true;
1051
+ try {
1052
+ return callback();
1053
+ } finally {
1054
+ shouldBypass.readOnly = false;
1055
+ }
1056
+ }
1057
+
1058
+ // src/proxyExports.ts
1059
+ var proxyExports = (Class) => (...args) => {
1060
+ const ambientControllers2 = retrieveParentControllers();
1061
+ const instance = new Class(...args);
1062
+ const initialExports = instance.exports;
1063
+ setParentController(ambientControllers2.at(-1));
1064
+ const internals = instance.component.manager.internals;
1065
+ internals.markExports(instance, initialExports);
1066
+ instance.watchExports((exports) => internals.markExports(instance, exports));
1067
+ setAmbientChildController(instance);
1068
+ const hostCandidates = [instance.component, ...ambientControllers2].reverse();
1069
+ return trackKey(
1070
+ hostCandidates,
1071
+ (resolution) => resolution === void 0 ? void 0 : setProxy(instance, resolution, initialExports),
1072
+ initialExports
1073
+ );
1074
+ };
1075
+ function setProxy(controller, { host, key, isReactive: assignedToProp }, initialExports) {
1076
+ const genericHost = host;
1077
+ const controllerValueChanged = genericHost[key] !== controller.exports;
1078
+ const hostValueChanged = genericHost[key] !== initialExports;
1079
+ const controllerUpdatedExports = initialExports !== controller.exports;
1080
+ if (controllerValueChanged && !hostValueChanged && controllerUpdatedExports) {
1081
+ genericHost[key] = controller.exports;
1082
+ }
1083
+ const isProxyExportsOnComponent = host === controller.component;
1084
+ if (isProxyExportsOnComponent) {
1085
+ if (assignedToProp) {
1086
+ const internals = controller.component.manager.internals;
1087
+ if (hostValueChanged) {
1088
+ internals.markExports(controller, genericHost[key]);
1089
+ }
1090
+ watch(controller.component, key, (value) => {
1091
+ if (value !== controller.exports) {
1092
+ internals.markExports(controller, value);
1093
+ }
1094
+ });
1095
+ }
1096
+ controller.assignedProperty = assignedToProp ? void 0 : key;
1097
+ }
1098
+ controller.watchExports(() => {
1099
+ if (genericHost[key] === controller.exports) {
1100
+ return;
1101
+ }
1102
+ const manager = controller.component.manager;
1103
+ const isReadOnly = manager.internals.setters[key]?.includes(manager.internals.readonlySetter);
1104
+ if (isReadOnly) {
1105
+ bypassReadOnly(() => {
1106
+ genericHost[key] = controller.exports;
1107
+ });
1108
+ } else {
1109
+ genericHost[key] = controller.exports;
1110
+ }
1111
+ });
1112
+ }
1113
+
1114
+ // src/functional.ts
1115
+ var makeController = (constructor) => proxy(void 0, constructor);
1116
+ var FunctionalController = class extends Controller {
1117
+ constructor(component, constructor) {
1118
+ super(component);
1119
+ const originalExports = this.exports;
1120
+ try {
1121
+ setAmbientComponent(this.component);
1122
+ const value = constructor(this.component, this);
1123
+ const constructorChangedExports = this.exports !== originalExports;
1124
+ if (value instanceof Promise) {
1125
+ if (!constructorChangedExports) {
1126
+ this.setProvisionalExports(value);
1127
+ }
1128
+ const resolved = value.then((result) => {
1129
+ this.exports = result;
1130
+ super.catchUpLifecycle();
1131
+ }).catch((error) => {
1132
+ this._ready.reject(error);
1133
+ console.error(error);
1134
+ });
1135
+ this.onLoad(async () => await resolved);
1136
+ } else {
1137
+ if (!constructorChangedExports || value !== void 0) {
1138
+ this.exports = value;
1139
+ }
1140
+ queueMicrotask(() => super.catchUpLifecycle());
1141
+ }
1142
+ } catch (error) {
1143
+ this._ready.reject(error);
1144
+ console.error(error);
1145
+ }
1146
+ }
1147
+ /** Noop - will be called in the constructor instead */
1148
+ catchUpLifecycle() {
1149
+ return;
1150
+ }
1151
+ };
1152
+ var proxy = proxyExports(FunctionalController);
1153
+
1154
+ export { getSet as g, makeController as m, useControllerManager as u, watch as w };