@luzmo/analytics-components-kit 1.0.1-alpha.31 → 1.0.1-alpha.32

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 (217) hide show
  1. package/components/{async-directive-C_bp5UcZ-B5_19oN_.js → async-directive-BfcqVjDp-BCT-lA4F.js} +8 -8
  2. package/components/{async-directive-C_bp5UcZ-mUPcBvyn.cjs → async-directive-BfcqVjDp-C8C45jl6.cjs} +3 -3
  3. package/components/{base-D76d76ww-D0dTUBua.js → base-D76d76ww-BGkuhs54.js} +59 -47
  4. package/components/{base-D76d76ww-BEIhYtgV.cjs → base-D76d76ww-tT6yr8eb.cjs} +9 -9
  5. package/components/{button-base-WsJSnMie-B1TLbPwk.cjs → button-base-DbkDzb71-CY6MJGqE.cjs} +2 -2
  6. package/components/{button-base-WsJSnMie-CyGPs7kd.js → button-base-DbkDzb71-R8oqSqlY.js} +4 -4
  7. package/components/calculate-data-item-icon-BtUWtDx3.cjs +20 -0
  8. package/components/calculate-data-item-icon-DauSiV8c.js +97 -0
  9. package/components/{checkbox-mixin-CmeCReJh-wY0R8cuc.cjs → checkbox-mixin-Do7EgtpQ-D3m-dMTI.cjs} +3 -3
  10. package/components/{checkbox-mixin-CmeCReJh-C94-rm4F.js → checkbox-mixin-Do7EgtpQ-hne79zc-.js} +2 -2
  11. package/components/{de-BaTUIQk1.js → de-CCq00pbq.js} +55 -1
  12. package/components/de-DcZysUyZ.cjs +20 -0
  13. package/components/{directive-helpers-Bx_ey3Gk-BxvL9t9F.cjs → directive-helpers-Cm6gitnu-BeggOiwf.cjs} +4 -4
  14. package/components/{directive-helpers-Bx_ey3Gk-Csi4AxXe.js → directive-helpers-Cm6gitnu-CeYtlPO9.js} +53 -19
  15. package/components/display-settings/index.cjs +1 -1
  16. package/components/display-settings/index.js +18 -17
  17. package/components/display-settings-binning/display-settings-binning.d.ts +0 -1
  18. package/components/display-settings-binning/index.cjs +3 -2
  19. package/components/display-settings-binning/index.js +21 -21
  20. package/components/display-settings-datetime/index.cjs +2 -2
  21. package/components/display-settings-datetime/index.js +37 -35
  22. package/components/display-settings-grand-totals/display-settings-grand-totals.d.ts +0 -1
  23. package/components/display-settings-grand-totals/index.cjs +4 -3
  24. package/components/display-settings-grand-totals/index.js +21 -21
  25. package/components/display-settings-numeric/index.cjs +14 -14
  26. package/components/display-settings-numeric/index.js +32 -30
  27. package/components/display-settings-period-over-period/index.cjs +6 -6
  28. package/components/display-settings-period-over-period/index.js +36 -34
  29. package/components/draggable-data-item/index.cjs +3 -3
  30. package/components/draggable-data-item/index.js +15 -13
  31. package/components/draggable-data-item-level/index.cjs +9 -9
  32. package/components/draggable-data-item-level/index.js +96 -167
  33. package/components/droppable-slot/index.cjs +2 -2
  34. package/components/droppable-slot/index.js +21 -19
  35. package/components/edit-item/index.cjs +11 -11
  36. package/components/edit-item/index.js +13 -12
  37. package/components/edit-option/index.cjs +1 -1
  38. package/components/edit-option/index.js +1 -1
  39. package/components/edit-option-action-button-group/index.cjs +2 -1
  40. package/components/edit-option-action-button-group/index.js +44 -43
  41. package/components/edit-option-base-CSJNbo2E.cjs +53 -0
  42. package/components/{edit-option-base-DOezOLDd.js → edit-option-base-DeQjGX4i.js} +5 -4
  43. package/components/edit-option-color-picker/index.cjs +23 -23
  44. package/components/edit-option-color-picker/index.js +50 -50
  45. package/components/edit-option-multi-language-field/index.cjs +1 -1
  46. package/components/edit-option-multi-language-field/index.js +3 -3
  47. package/components/edit-option-number-field/index.cjs +2 -2
  48. package/components/edit-option-number-field/index.js +3 -3
  49. package/components/edit-option-picker/index.cjs +2 -2
  50. package/components/edit-option-picker/index.js +4 -4
  51. package/components/edit-option-position-picker/index.cjs +1 -1
  52. package/components/edit-option-position-picker/index.js +3 -3
  53. package/components/edit-option-positions-number-field/index.cjs +1 -1
  54. package/components/edit-option-positions-number-field/index.js +7 -7
  55. package/components/edit-option-radio-button-group/index.cjs +4 -4
  56. package/components/edit-option-radio-button-group/index.js +4 -4
  57. package/components/edit-option-slider/index.cjs +2 -2
  58. package/components/edit-option-slider/index.js +27 -27
  59. package/components/edit-option-switch/index.cjs +3 -3
  60. package/components/edit-option-switch/index.js +5 -5
  61. package/components/edit-option-text-field/index.cjs +2 -2
  62. package/components/edit-option-text-field/index.js +3 -3
  63. package/components/es-CGiBfBKJ.cjs +20 -0
  64. package/components/{es-D37mTCZB.js → es-DBmbFw-L.js} +55 -1
  65. package/components/filter-data-item-picker/filter-data-item-picker.d.ts +88 -0
  66. package/components/filter-data-item-picker/index.cjs +47 -0
  67. package/components/filter-data-item-picker/index.d.ts +7 -0
  68. package/components/filter-data-item-picker/index.js +193 -0
  69. package/components/filter-expression-picker/filter-expression-picker.d.ts +74 -0
  70. package/components/filter-expression-picker/index.cjs +20 -0
  71. package/components/filter-expression-picker/index.d.ts +7 -0
  72. package/components/filter-expression-picker/index.js +30 -0
  73. package/components/filter-group/filter-group.d.ts +26 -0
  74. package/components/filter-group/index.d.ts +7 -0
  75. package/components/filter-item/filter-item.d.ts +76 -0
  76. package/components/filter-item/index.cjs +52 -0
  77. package/components/filter-item/index.d.ts +7 -0
  78. package/components/filter-item/index.js +271 -0
  79. package/components/filter-parameter-picker/filter-parameter-picker.d.ts +25 -0
  80. package/components/filter-parameter-picker/index.d.ts +7 -0
  81. package/components/filter-value-picker/filter-value-picker.d.ts +65 -0
  82. package/components/filter-value-picker/index.cjs +51 -0
  83. package/components/filter-value-picker/index.d.ts +7 -0
  84. package/components/filter-value-picker/index.js +149 -0
  85. package/components/filter-value-picker-datetime/filter-value-picker-datetime.d.ts +43 -0
  86. package/components/filter-value-picker-datetime/index.cjs +288 -0
  87. package/components/filter-value-picker-datetime/index.d.ts +7 -0
  88. package/components/filter-value-picker-datetime/index.js +2820 -0
  89. package/components/filter-value-picker-hierarchy/filter-value-picker-hierarchy.d.ts +82 -0
  90. package/components/filter-value-picker-hierarchy/index.cjs +46 -0
  91. package/components/filter-value-picker-hierarchy/index.d.ts +7 -0
  92. package/components/filter-value-picker-hierarchy/index.js +278 -0
  93. package/components/filter-value-picker-numeric/filter-value-picker-numeric.d.ts +83 -0
  94. package/components/filter-value-picker-numeric/index.cjs +46 -0
  95. package/components/filter-value-picker-numeric/index.d.ts +7 -0
  96. package/components/filter-value-picker-numeric/index.js +274 -0
  97. package/components/flow-D-0MTYCm-BOBCoA5Z.js +546 -0
  98. package/components/flow-D-0MTYCm-BW5krWol.cjs +48 -0
  99. package/components/{focusable-BNESohBR-DbTLvYXr.cjs → focusable-BxtpnzWp-CkK9AeMt.cjs} +2 -2
  100. package/components/{focusable-BNESohBR-DYvAZYXL.js → focusable-BxtpnzWp-DJQkL8Zv.js} +1 -1
  101. package/components/focusable-DB6Uhr-C.js +275 -0
  102. package/components/focusable-_wp5pWO-.cjs +20 -0
  103. package/components/{fr-BWJHvkss.js → fr-BOwMikLT.js} +55 -1
  104. package/components/fr-DZbYwMlh.cjs +20 -0
  105. package/components/{get-css-variable-Bhbr-Kr1.js → get-css-variable-YlLiVgo8.js} +2 -2
  106. package/components/{if-defined-DbhS35z5.js → if-defined-B4gwZxx6.js} +1 -1
  107. package/components/{if-defined-D-1p2bLN-Bn-33APC.js → if-defined-DOaE2coe-CNT45Xcl.js} +1 -1
  108. package/components/{if-defined-D-1p2bLN-0_AoRnT2.cjs → if-defined-DOaE2coe-Cvlu5s9n.cjs} +1 -1
  109. package/components/{if-defined-CF8baNdl.cjs → if-defined-DqthfJme.cjs} +2 -2
  110. package/components/{index-Dwp251OJ.js → index-5mZhN-HJ.js} +7 -6
  111. package/components/{index-B3jkBlKY.js → index-BC1LV3vH.js} +3 -3
  112. package/components/{index-BXMPi13W.js → index-BCBLJ-ei.js} +82 -82
  113. package/components/{index-B9dQtvu7.js → index-BHJH1eGn.js} +3 -3
  114. package/components/index-BHXq1-M1.cjs +195 -0
  115. package/components/{index-C2-2RrwB.cjs → index-BKwbYw6x.cjs} +3 -3
  116. package/components/index-BOqSYlku.cjs +38 -0
  117. package/components/{index-D5rT-qy9.cjs → index-Bafc5poK.cjs} +12 -28
  118. package/components/{index-CqFCIIIl.js → index-BbuNpVBr.js} +3 -3
  119. package/components/{index-CRx2nPkq.js → index-Bmpw4rGV.js} +3 -3
  120. package/components/{index-D8Na-686.cjs → index-BoXbQm2o.cjs} +1 -1
  121. package/components/{index-uRWe553S.cjs → index-BtIWR_s6.cjs} +4 -4
  122. package/components/index-BwsEWpIS.js +494 -0
  123. package/components/{index-CF84gqsb.cjs → index-C2PPSv8E.cjs} +4 -4
  124. package/components/{index-CbeVu32V.js → index-C3N6qTxJ.js} +3 -3
  125. package/components/index-C5m9vRp5.js +598 -0
  126. package/components/{index-bZQXFqxv.cjs → index-CBOAQ3-E.cjs} +10 -10
  127. package/components/{index-_McOOiwL.cjs → index-CSm0I7Gz.cjs} +4 -4
  128. package/components/index-CTHlwZ9E.cjs +274 -0
  129. package/components/{index-Brg_sVUg.js → index-CTVNGPeT.js} +1 -1
  130. package/components/{index-Rjoe8cIs.js → index-Cb5l6iK_.js} +110 -173
  131. package/components/{index-BkCJwWm3.cjs → index-CeENkpNK.cjs} +3 -3
  132. package/components/{index-BnbhRpm9.js → index-CnRQGFHT.js} +3 -3
  133. package/components/{index-BKcvEgWr.cjs → index-CnpJUw_z.cjs} +3 -3
  134. package/components/{index-DJik7S7b.js → index-CsDgk_sj.js} +2 -2
  135. package/components/{index-fl13NYnO.js → index-CskV_bXp.js} +2 -2
  136. package/components/index-CyWwLYEO.js +1789 -0
  137. package/components/index-D9yzIoGv.js +1666 -0
  138. package/components/{index-Bwxvaqxq.cjs → index-DF-s3cEL.cjs} +11 -11
  139. package/components/{index-CVuJ-LUO.cjs → index-DSQyBS9Z.cjs} +2 -2
  140. package/components/{index-Bb8vxGZY.js → index-Desl7GJ0.js} +19 -15
  141. package/components/{index-0HUnZcem.cjs → index-DtohCwyO.cjs} +2 -2
  142. package/components/index-TQG9Xdxu.cjs +20 -0
  143. package/components/index-c2uKLWDt.cjs +157 -0
  144. package/components/{index-C9-QEfA9.cjs → index-j8UKjHqY.cjs} +4 -4
  145. package/components/{index-DZZMSlYS.js → index-rQxtPaJl.js} +6 -6
  146. package/components/index.cjs +1 -1
  147. package/components/index.js +41 -27
  148. package/components/localized-decorator-ClAOFk8M.cjs +28 -0
  149. package/components/localized-decorator-DGnMToFa.js +48 -0
  150. package/components/{luzmo-icons-U09GB75o.js → luzmo-icons-CPucBq6e.js} +89 -89
  151. package/components/luzmo-icons-DbwDQtuO-DSQ-uVxy.cjs +47 -0
  152. package/components/{luzmo-icons-BLN3xVgr-Tz5XXgbL.js → luzmo-icons-DbwDQtuO-QG0fLECn.js} +67 -25
  153. package/components/luzmo-icons-Nyf1P71v.cjs +31 -0
  154. package/components/nl-0V96M02q.cjs +20 -0
  155. package/components/nl-CY0iO3Ch.js +158 -0
  156. package/components/observe-slot-presence-CmVi0zTc-B4M1Mze7.cjs +36 -0
  157. package/components/observe-slot-presence-CmVi0zTc-DCFuXW7v.js +87 -0
  158. package/components/{observe-slot-text-CVKLDesL-BB2RmFgc.cjs → observe-slot-text-BPfIQQtz-DHOh38Ve.cjs} +4 -4
  159. package/components/{observe-slot-text-CVKLDesL-CXUeCmXW.js → observe-slot-text-BPfIQQtz-v6B-1BYh.js} +5 -5
  160. package/components/pending-state-DTX7ggyF-BQGaWUEI.cjs +80 -0
  161. package/components/pending-state-DTX7ggyF-KolnwUB7.js +321 -0
  162. package/components/{periods.const-CDIkC5CK.cjs → periods.const-BbgInj9J.cjs} +1 -1
  163. package/components/{periods.const-GHh5bPfs.js → periods.const-D2cMP5hH.js} +1 -1
  164. package/components/{popover-DRyjN9y_-w1zh4tvw.js → popover-DjX0aAnY-B_ujTfos.js} +2 -2
  165. package/components/{popover-DRyjN9y_-7mF_fAOh.cjs → popover-DjX0aAnY-CSUMV_Ay.cjs} +3 -3
  166. package/components/property-CxtZroGf.js +600 -0
  167. package/components/property-Dlf9S6Jz.cjs +42 -0
  168. package/components/{query-assigned-nodes-C76XVPWY-k1jDPyUQ.cjs → query-assigned-nodes-C76XVPWY-BW2w3V7-.cjs} +1 -1
  169. package/components/{query-assigned-nodes-C76XVPWY-BWouxGZs.js → query-assigned-nodes-C76XVPWY-DxNwGHfW.js} +1 -1
  170. package/components/scatter-plot-options.config-CFfGJXsV.cjs +20 -0
  171. package/components/{scatter-plot-options.config-lrkd9qj4.js → scatter-plot-options.config-Corlzno1.js} +78 -48
  172. package/components/set-locale-5FFfQpVQ.cjs +52 -0
  173. package/components/set-locale-DAGnJZD8.js +188 -0
  174. package/components/{sized-mixin-DMuOVsw0.js → sized-mixin-C7R5uRbF.js} +1 -1
  175. package/components/sized-mixin-ZTphZKLm.cjs +20 -0
  176. package/components/slot-menu/index.cjs +1 -1
  177. package/components/slot-menu/index.js +12 -11
  178. package/components/slot-menu-list/index.cjs +3 -3
  179. package/components/slot-menu-list/index.js +15 -14
  180. package/components/{state-e2n-fyrr.js → state-BVYsk_HZ.js} +1 -1
  181. package/components/{state-QgHgNZLe.cjs → state-CrfOw8Zp.cjs} +2 -2
  182. package/components/{streaming-listener-C8Ctj0Q6-lanbGKR9.js → streaming-listener-CP-JE6Fa-9MH0gENR.js} +3 -3
  183. package/components/{streaming-listener-C8Ctj0Q6-BhMxS69F.cjs → streaming-listener-CP-JE6Fa-DMzr1X1m.cjs} +3 -3
  184. package/components/{task-fQFUVV8e.cjs → task-CdvrMX8r.cjs} +2 -2
  185. package/components/{task-gE27tBDv.js → task-DH8UFyxP.js} +1 -1
  186. package/components/{text-field-C0pFjPG1-BCVbGXp7.cjs → text-field-BIADXoLC-B8w9TVmS.cjs} +8 -8
  187. package/components/{text-field-C0pFjPG1-B4TRivuD.js → text-field-BIADXoLC-B9oE05VF.js} +11 -10
  188. package/custom-elements.json +1891 -34
  189. package/index.d.ts +7 -0
  190. package/item-definitions/scatter-plot/scatter-plot-options.config.d.ts +3 -0
  191. package/package.json +46 -1
  192. package/utils/data-broker/index.d.ts +179 -0
  193. package/utils/data-item-types/calculate-data-item-icon.d.ts +3 -0
  194. package/utils/filters/expressions.d.ts +15 -0
  195. package/utils/filters/index.d.ts +1 -0
  196. package/utils/localize/set-locale.d.ts +4 -2
  197. package/utils/types/column.types.d.ts +1 -1
  198. package/components/de-DgHoh7KS.cjs +0 -20
  199. package/components/draggable-data-item-level/helpers/calculate-type-icon.d.ts +0 -2
  200. package/components/edit-option-base-jkkFevzT.cjs +0 -53
  201. package/components/es-ByW01bzN.cjs +0 -20
  202. package/components/focusable-Cu_m_GTh.cjs +0 -42
  203. package/components/focusable-Dw_pMNQL.js +0 -852
  204. package/components/fr-DnFUAglm.cjs +0 -20
  205. package/components/index-CqynTbW1.cjs +0 -217
  206. package/components/index-DFnzlbHX.js +0 -779
  207. package/components/index-hogChFy0.cjs +0 -195
  208. package/components/luzmo-icons-BDClm1AE.cjs +0 -31
  209. package/components/luzmo-icons-BLN3xVgr-Cr3OrsqW.cjs +0 -47
  210. package/components/nl-CWxJcTNT.js +0 -104
  211. package/components/nl-CpfDNK5c.cjs +0 -20
  212. package/components/scatter-plot-options.config-DkJLutNb.cjs +0 -20
  213. package/components/set-locale-ByIApH40.cjs +0 -60
  214. package/components/set-locale-DJYT4V7U.js +0 -212
  215. package/components/sized-mixin-Cqlxwicw.cjs +0 -20
  216. /package/components/{divider.module-DwOuLGU3-B19eHVg2.js → divider.module-DoQWQEIJ-B19eHVg2.js} +0 -0
  217. /package/components/{divider.module-DwOuLGU3-Bg8RrFkc.cjs → divider.module-DoQWQEIJ-Bg8RrFkc.cjs} +0 -0
@@ -0,0 +1,1666 @@
1
+ /*! * A kit of modern Luzmo Web Components for analytics in your web application.
2
+ *
3
+ * Copyright © 2025 Luzmo
4
+ * All rights reserved.
5
+ * Luzmo web components (“Luzmo Web Components”)
6
+ * must be used according to the Luzmo Terms of Service.
7
+ * This license allows users with a current active Luzmo account
8
+ * to use the Luzmo Web Components. This license terminates
9
+ * automatically if a user no longer has an active Luzmo account.
10
+ * Please view the Luzmo Terms of Service at: https://www.luzmo.com/information-pages/terms-of-use.
11
+ *
12
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
+ * SOFTWARE.
19
+ * */
20
+ var Fe = (s) => {
21
+ throw TypeError(s);
22
+ };
23
+ var ge = (s, e, t) => e.has(s) || Fe("Cannot " + t);
24
+ var r = (s, e, t) => (ge(s, e, "read from private field"), t ? t.call(s) : e.get(s)), l = (s, e, t) => e.has(s) ? Fe("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(s) : e.set(s, t), o = (s, e, t, i) => (ge(s, e, "write to private field"), i ? i.call(s, t) : e.set(s, t), t), P = (s, e, t) => (ge(s, e, "access private method"), t);
25
+ var pe = (s, e, t, i) => ({
26
+ set _(n) {
27
+ o(s, e, n, t);
28
+ },
29
+ get _() {
30
+ return r(s, e, i);
31
+ }
32
+ });
33
+ var we = class {
34
+ constructor() {
35
+ this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
36
+ }
37
+ subscribe(s) {
38
+ return this.listeners.add(s), this.onSubscribe(), () => {
39
+ this.listeners.delete(s), this.onUnsubscribe();
40
+ };
41
+ }
42
+ hasListeners() {
43
+ return this.listeners.size > 0;
44
+ }
45
+ onSubscribe() {
46
+ }
47
+ onUnsubscribe() {
48
+ }
49
+ }, be = typeof window > "u" || "Deno" in globalThis;
50
+ function M() {
51
+ }
52
+ function Je(s, e) {
53
+ return typeof s == "function" ? s(e) : s;
54
+ }
55
+ function We(s) {
56
+ return typeof s == "number" && s >= 0 && s !== 1 / 0;
57
+ }
58
+ function _e(s, e) {
59
+ return Math.max(s + (e || 0) - Date.now(), 0);
60
+ }
61
+ function Se(s, e) {
62
+ return typeof s == "function" ? s(e) : s;
63
+ }
64
+ function Xe(s, e) {
65
+ return typeof s == "function" ? s(e) : s;
66
+ }
67
+ function Ae(s, e) {
68
+ const {
69
+ type: t = "all",
70
+ exact: i,
71
+ fetchStatus: n,
72
+ predicate: a,
73
+ queryKey: h,
74
+ stale: u
75
+ } = s;
76
+ if (h) {
77
+ if (i) {
78
+ if (e.queryHash !== Oe(h, e.options))
79
+ return !1;
80
+ } else if (!ce(e.queryKey, h))
81
+ return !1;
82
+ }
83
+ if (t !== "all") {
84
+ const d = e.isActive();
85
+ if (t === "active" && !d || t === "inactive" && d)
86
+ return !1;
87
+ }
88
+ return !(typeof u == "boolean" && e.isStale() !== u || n && n !== e.state.fetchStatus || a && !a(e));
89
+ }
90
+ function De(s, e) {
91
+ const { exact: t, status: i, predicate: n, mutationKey: a } = s;
92
+ if (a) {
93
+ if (!e.options.mutationKey)
94
+ return !1;
95
+ if (t) {
96
+ if (oe(e.options.mutationKey) !== oe(a))
97
+ return !1;
98
+ } else if (!ce(e.options.mutationKey, a))
99
+ return !1;
100
+ }
101
+ return !(i && e.state.status !== i || n && !n(e));
102
+ }
103
+ function Oe(s, e) {
104
+ return ((e == null ? void 0 : e.queryKeyHashFn) || oe)(s);
105
+ }
106
+ function oe(s) {
107
+ return JSON.stringify(
108
+ s,
109
+ (e, t) => qe(t) ? Object.keys(t).sort().reduce((i, n) => (i[n] = t[n], i), {}) : t
110
+ );
111
+ }
112
+ function ce(s, e) {
113
+ return s === e ? !0 : typeof s != typeof e ? !1 : s && e && typeof s == "object" && typeof e == "object" ? Object.keys(e).every((t) => ce(s[t], e[t])) : !1;
114
+ }
115
+ function He(s, e) {
116
+ if (s === e)
117
+ return s;
118
+ const t = Qe(s) && Qe(e);
119
+ if (t || qe(s) && qe(e)) {
120
+ const i = t ? s : Object.keys(s), n = i.length, a = t ? e : Object.keys(e), h = a.length, u = t ? [] : {};
121
+ let d = 0;
122
+ for (let g = 0; g < h; g++) {
123
+ const m = t ? g : a[g];
124
+ (!t && i.includes(m) || t) && s[m] === void 0 && e[m] === void 0 ? (u[m] = void 0, d++) : (u[m] = He(s[m], e[m]), u[m] === s[m] && s[m] !== void 0 && d++);
125
+ }
126
+ return n === h && d === n ? s : u;
127
+ }
128
+ return e;
129
+ }
130
+ function Qe(s) {
131
+ return Array.isArray(s) && s.length === Object.keys(s).length;
132
+ }
133
+ function qe(s) {
134
+ if (!Ee(s))
135
+ return !1;
136
+ const e = s.constructor;
137
+ if (e === void 0)
138
+ return !0;
139
+ const t = e.prototype;
140
+ return !(!Ee(t) || !t.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(s) !== Object.prototype);
141
+ }
142
+ function Ee(s) {
143
+ return Object.prototype.toString.call(s) === "[object Object]";
144
+ }
145
+ function Ye(s) {
146
+ return new Promise((e) => {
147
+ setTimeout(e, s);
148
+ });
149
+ }
150
+ function Ze(s, e, t) {
151
+ return typeof t.structuralSharing == "function" ? t.structuralSharing(s, e) : t.structuralSharing !== !1 ? He(s, e) : e;
152
+ }
153
+ function et(s, e, t = 0) {
154
+ const i = [...s, e];
155
+ return t && i.length > t ? i.slice(1) : i;
156
+ }
157
+ function tt(s, e, t = 0) {
158
+ const i = [e, ...s];
159
+ return t && i.length > t ? i.slice(0, -1) : i;
160
+ }
161
+ var Ce = Symbol();
162
+ function Ge(s, e) {
163
+ return !s.queryFn && (e != null && e.initialPromise) ? () => e.initialPromise : !s.queryFn || s.queryFn === Ce ? () => Promise.reject(new Error(`Missing queryFn: '${s.queryHash}'`)) : s.queryFn;
164
+ }
165
+ var J, G, Z, Re, st = (Re = class extends we {
166
+ constructor() {
167
+ super();
168
+ l(this, J);
169
+ l(this, G);
170
+ l(this, Z);
171
+ o(this, Z, (e) => {
172
+ if (!be && window.addEventListener) {
173
+ const t = () => e();
174
+ return window.addEventListener("visibilitychange", t, !1), () => {
175
+ window.removeEventListener("visibilitychange", t);
176
+ };
177
+ }
178
+ });
179
+ }
180
+ onSubscribe() {
181
+ r(this, G) || this.setEventListener(r(this, Z));
182
+ }
183
+ onUnsubscribe() {
184
+ var e;
185
+ this.hasListeners() || ((e = r(this, G)) == null || e.call(this), o(this, G, void 0));
186
+ }
187
+ setEventListener(e) {
188
+ var t;
189
+ o(this, Z, e), (t = r(this, G)) == null || t.call(this), o(this, G, e((i) => {
190
+ typeof i == "boolean" ? this.setFocused(i) : this.onFocus();
191
+ }));
192
+ }
193
+ setFocused(e) {
194
+ r(this, J) !== e && (o(this, J, e), this.onFocus());
195
+ }
196
+ onFocus() {
197
+ const e = this.isFocused();
198
+ this.listeners.forEach((t) => {
199
+ t(e);
200
+ });
201
+ }
202
+ isFocused() {
203
+ var e;
204
+ return typeof r(this, J) == "boolean" ? r(this, J) : ((e = globalThis.document) == null ? void 0 : e.visibilityState) !== "hidden";
205
+ }
206
+ }, J = new WeakMap(), G = new WeakMap(), Z = new WeakMap(), Re), Ne = new st(), ee, N, te, Ke, it = (Ke = class extends we {
207
+ constructor() {
208
+ super();
209
+ l(this, ee, !0);
210
+ l(this, N);
211
+ l(this, te);
212
+ o(this, te, (e) => {
213
+ if (!be && window.addEventListener) {
214
+ const t = () => e(!0), i = () => e(!1);
215
+ return window.addEventListener("online", t, !1), window.addEventListener("offline", i, !1), () => {
216
+ window.removeEventListener("online", t), window.removeEventListener("offline", i);
217
+ };
218
+ }
219
+ });
220
+ }
221
+ onSubscribe() {
222
+ r(this, N) || this.setEventListener(r(this, te));
223
+ }
224
+ onUnsubscribe() {
225
+ var e;
226
+ this.hasListeners() || ((e = r(this, N)) == null || e.call(this), o(this, N, void 0));
227
+ }
228
+ setEventListener(e) {
229
+ var t;
230
+ o(this, te, e), (t = r(this, N)) == null || t.call(this), o(this, N, e(this.setOnline.bind(this)));
231
+ }
232
+ setOnline(e) {
233
+ r(this, ee) !== e && (o(this, ee, e), this.listeners.forEach((i) => {
234
+ i(e);
235
+ }));
236
+ }
237
+ isOnline() {
238
+ return r(this, ee);
239
+ }
240
+ }, ee = new WeakMap(), N = new WeakMap(), te = new WeakMap(), Ke), ve = new it();
241
+ function rt() {
242
+ let s, e;
243
+ const t = new Promise((n, a) => {
244
+ s = n, e = a;
245
+ });
246
+ t.status = "pending", t.catch(() => {
247
+ });
248
+ function i(n) {
249
+ Object.assign(t, n), delete t.resolve, delete t.reject;
250
+ }
251
+ return t.resolve = (n) => {
252
+ i({
253
+ status: "fulfilled",
254
+ value: n
255
+ }), s(n);
256
+ }, t.reject = (n) => {
257
+ i({
258
+ status: "rejected",
259
+ reason: n
260
+ }), e(n);
261
+ }, t;
262
+ }
263
+ function nt(s) {
264
+ return Math.min(1e3 * 2 ** s, 3e4);
265
+ }
266
+ function Ve(s) {
267
+ return (s ?? "online") === "online" ? ve.isOnline() : !0;
268
+ }
269
+ var $e = class extends Error {
270
+ constructor(s) {
271
+ super("CancelledError"), this.revert = s == null ? void 0 : s.revert, this.silent = s == null ? void 0 : s.silent;
272
+ }
273
+ };
274
+ function Pe(s) {
275
+ return s instanceof $e;
276
+ }
277
+ function ze(s) {
278
+ let e = !1, t = 0, i = !1, n;
279
+ const a = rt(), h = (c) => {
280
+ var p;
281
+ i || (y(new $e(c)), (p = s.abort) == null || p.call(s));
282
+ }, u = () => {
283
+ e = !0;
284
+ }, d = () => {
285
+ e = !1;
286
+ }, g = () => Ne.isFocused() && (s.networkMode === "always" || ve.isOnline()) && s.canRun(), m = () => Ve(s.networkMode) && s.canRun(), f = (c) => {
287
+ var p;
288
+ i || (i = !0, (p = s.onSuccess) == null || p.call(s, c), n == null || n(), a.resolve(c));
289
+ }, y = (c) => {
290
+ var p;
291
+ i || (i = !0, (p = s.onError) == null || p.call(s, c), n == null || n(), a.reject(c));
292
+ }, S = () => new Promise((c) => {
293
+ var p;
294
+ n = (A) => {
295
+ (i || g()) && c(A);
296
+ }, (p = s.onPause) == null || p.call(s);
297
+ }).then(() => {
298
+ var c;
299
+ n = void 0, i || (c = s.onContinue) == null || c.call(s);
300
+ }), O = () => {
301
+ if (i)
302
+ return;
303
+ let c;
304
+ const p = t === 0 ? s.initialPromise : void 0;
305
+ try {
306
+ c = p ?? s.fn();
307
+ } catch (A) {
308
+ c = Promise.reject(A);
309
+ }
310
+ Promise.resolve(c).then(f).catch((A) => {
311
+ var U;
312
+ if (i)
313
+ return;
314
+ const E = s.retry ?? (be ? 0 : 3), w = s.retryDelay ?? nt, D = typeof w == "function" ? w(t, A) : w, K = E === !0 || typeof E == "number" && t < E || typeof E == "function" && E(t, A);
315
+ if (e || !K) {
316
+ y(A);
317
+ return;
318
+ }
319
+ t++, (U = s.onFail) == null || U.call(s, t, A), Ye(D).then(() => g() ? void 0 : S()).then(() => {
320
+ e ? y(A) : O();
321
+ });
322
+ });
323
+ };
324
+ return {
325
+ promise: a,
326
+ cancel: h,
327
+ continue: () => (n == null || n(), a),
328
+ cancelRetry: u,
329
+ continueRetry: d,
330
+ canStart: m,
331
+ start: () => (m() ? O() : S().then(O), a)
332
+ };
333
+ }
334
+ var at = (s) => setTimeout(s, 0);
335
+ function ut() {
336
+ let s = [], e = 0, t = (u) => {
337
+ u();
338
+ }, i = (u) => {
339
+ u();
340
+ }, n = at;
341
+ const a = (u) => {
342
+ e ? s.push(u) : n(() => {
343
+ t(u);
344
+ });
345
+ }, h = () => {
346
+ const u = s;
347
+ s = [], u.length && n(() => {
348
+ i(() => {
349
+ u.forEach((d) => {
350
+ t(d);
351
+ });
352
+ });
353
+ });
354
+ };
355
+ return {
356
+ batch: (u) => {
357
+ let d;
358
+ e++;
359
+ try {
360
+ d = u();
361
+ } finally {
362
+ e--, e || h();
363
+ }
364
+ return d;
365
+ },
366
+ /**
367
+ * All calls to the wrapped function will be batched.
368
+ */
369
+ batchCalls: (u) => (...d) => {
370
+ a(() => {
371
+ u(...d);
372
+ });
373
+ },
374
+ schedule: a,
375
+ /**
376
+ * Use this method to set a custom notify function.
377
+ * This can be used to for example wrap notifications with `React.act` while running tests.
378
+ */
379
+ setNotifyFunction: (u) => {
380
+ t = u;
381
+ },
382
+ /**
383
+ * Use this method to set a custom function to batch notifications together into a single tick.
384
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
385
+ */
386
+ setBatchNotifyFunction: (u) => {
387
+ i = u;
388
+ },
389
+ setScheduler: (u) => {
390
+ n = u;
391
+ }
392
+ };
393
+ }
394
+ var F = ut(), W, Ue, Be = (Ue = class {
395
+ constructor() {
396
+ l(this, W);
397
+ }
398
+ destroy() {
399
+ this.clearGcTimeout();
400
+ }
401
+ scheduleGc() {
402
+ this.clearGcTimeout(), We(this.gcTime) && o(this, W, setTimeout(() => {
403
+ this.optionalRemove();
404
+ }, this.gcTime));
405
+ }
406
+ updateGcTime(s) {
407
+ this.gcTime = Math.max(
408
+ this.gcTime || 0,
409
+ s ?? (be ? 1 / 0 : 5 * 60 * 1e3)
410
+ );
411
+ }
412
+ clearGcTimeout() {
413
+ r(this, W) && (clearTimeout(r(this, W)), o(this, W, void 0));
414
+ }
415
+ }, W = new WeakMap(), Ue), se, ie, Q, _, q, le, X, T, L, ke, ht = (ke = class extends Be {
416
+ constructor(e) {
417
+ super();
418
+ l(this, T);
419
+ l(this, se);
420
+ l(this, ie);
421
+ l(this, Q);
422
+ l(this, _);
423
+ l(this, q);
424
+ l(this, le);
425
+ l(this, X);
426
+ o(this, X, !1), o(this, le, e.defaultOptions), this.setOptions(e.options), this.observers = [], o(this, _, e.client), o(this, Q, r(this, _).getQueryCache()), this.queryKey = e.queryKey, this.queryHash = e.queryHash, o(this, se, ct(this.options)), this.state = e.state ?? r(this, se), this.scheduleGc();
427
+ }
428
+ get meta() {
429
+ return this.options.meta;
430
+ }
431
+ get promise() {
432
+ var e;
433
+ return (e = r(this, q)) == null ? void 0 : e.promise;
434
+ }
435
+ setOptions(e) {
436
+ this.options = { ...r(this, le), ...e }, this.updateGcTime(this.options.gcTime);
437
+ }
438
+ optionalRemove() {
439
+ !this.observers.length && this.state.fetchStatus === "idle" && r(this, Q).remove(this);
440
+ }
441
+ setData(e, t) {
442
+ const i = Ze(this.state.data, e, this.options);
443
+ return P(this, T, L).call(this, {
444
+ data: i,
445
+ type: "success",
446
+ dataUpdatedAt: t == null ? void 0 : t.updatedAt,
447
+ manual: t == null ? void 0 : t.manual
448
+ }), i;
449
+ }
450
+ setState(e, t) {
451
+ P(this, T, L).call(this, { type: "setState", state: e, setStateOptions: t });
452
+ }
453
+ cancel(e) {
454
+ var i, n;
455
+ const t = (i = r(this, q)) == null ? void 0 : i.promise;
456
+ return (n = r(this, q)) == null || n.cancel(e), t ? t.then(M).catch(M) : Promise.resolve();
457
+ }
458
+ destroy() {
459
+ super.destroy(), this.cancel({ silent: !0 });
460
+ }
461
+ reset() {
462
+ this.destroy(), this.setState(r(this, se));
463
+ }
464
+ isActive() {
465
+ return this.observers.some(
466
+ (e) => Xe(e.options.enabled, this) !== !1
467
+ );
468
+ }
469
+ isDisabled() {
470
+ return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === Ce || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
471
+ }
472
+ isStale() {
473
+ return this.state.isInvalidated ? !0 : this.getObserversCount() > 0 ? this.observers.some(
474
+ (e) => e.getCurrentResult().isStale
475
+ ) : this.state.data === void 0;
476
+ }
477
+ isStaleByTime(e = 0) {
478
+ return this.state.isInvalidated || this.state.data === void 0 || !_e(this.state.dataUpdatedAt, e);
479
+ }
480
+ onFocus() {
481
+ var t;
482
+ const e = this.observers.find((i) => i.shouldFetchOnWindowFocus());
483
+ e == null || e.refetch({ cancelRefetch: !1 }), (t = r(this, q)) == null || t.continue();
484
+ }
485
+ onOnline() {
486
+ var t;
487
+ const e = this.observers.find((i) => i.shouldFetchOnReconnect());
488
+ e == null || e.refetch({ cancelRefetch: !1 }), (t = r(this, q)) == null || t.continue();
489
+ }
490
+ addObserver(e) {
491
+ this.observers.includes(e) || (this.observers.push(e), this.clearGcTimeout(), r(this, Q).notify({ type: "observerAdded", query: this, observer: e }));
492
+ }
493
+ removeObserver(e) {
494
+ this.observers.includes(e) && (this.observers = this.observers.filter((t) => t !== e), this.observers.length || (r(this, q) && (r(this, X) ? r(this, q).cancel({ revert: !0 }) : r(this, q).cancelRetry()), this.scheduleGc()), r(this, Q).notify({ type: "observerRemoved", query: this, observer: e }));
495
+ }
496
+ getObserversCount() {
497
+ return this.observers.length;
498
+ }
499
+ invalidate() {
500
+ this.state.isInvalidated || P(this, T, L).call(this, { type: "invalidate" });
501
+ }
502
+ fetch(e, t) {
503
+ var d, g, m;
504
+ if (this.state.fetchStatus !== "idle") {
505
+ if (this.state.data !== void 0 && (t != null && t.cancelRefetch))
506
+ this.cancel({ silent: !0 });
507
+ else if (r(this, q))
508
+ return r(this, q).continueRetry(), r(this, q).promise;
509
+ }
510
+ if (e && this.setOptions(e), !this.options.queryFn) {
511
+ const f = this.observers.find((y) => y.options.queryFn);
512
+ f && this.setOptions(f.options);
513
+ }
514
+ const i = new AbortController(), n = (f) => {
515
+ Object.defineProperty(f, "signal", {
516
+ enumerable: !0,
517
+ get: () => (o(this, X, !0), i.signal)
518
+ });
519
+ }, a = () => {
520
+ const f = Ge(this.options, t), y = {
521
+ client: r(this, _),
522
+ queryKey: this.queryKey,
523
+ meta: this.meta
524
+ };
525
+ return n(y), o(this, X, !1), this.options.persister ? this.options.persister(
526
+ f,
527
+ y,
528
+ this
529
+ ) : f(y);
530
+ }, h = {
531
+ fetchOptions: t,
532
+ options: this.options,
533
+ queryKey: this.queryKey,
534
+ client: r(this, _),
535
+ state: this.state,
536
+ fetchFn: a
537
+ };
538
+ n(h), (d = this.options.behavior) == null || d.onFetch(
539
+ h,
540
+ this
541
+ ), o(this, ie, this.state), (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((g = h.fetchOptions) == null ? void 0 : g.meta)) && P(this, T, L).call(this, { type: "fetch", meta: (m = h.fetchOptions) == null ? void 0 : m.meta });
542
+ const u = (f) => {
543
+ var y, S, O, c;
544
+ Pe(f) && f.silent || P(this, T, L).call(this, {
545
+ type: "error",
546
+ error: f
547
+ }), Pe(f) || ((S = (y = r(this, Q).config).onError) == null || S.call(
548
+ y,
549
+ f,
550
+ this
551
+ ), (c = (O = r(this, Q).config).onSettled) == null || c.call(
552
+ O,
553
+ this.state.data,
554
+ f,
555
+ this
556
+ )), this.scheduleGc();
557
+ };
558
+ return o(this, q, ze({
559
+ initialPromise: t == null ? void 0 : t.initialPromise,
560
+ fn: h.fetchFn,
561
+ abort: i.abort.bind(i),
562
+ onSuccess: (f) => {
563
+ var y, S, O, c;
564
+ if (f === void 0) {
565
+ u(new Error(`${this.queryHash} data is undefined`));
566
+ return;
567
+ }
568
+ try {
569
+ this.setData(f);
570
+ } catch (p) {
571
+ u(p);
572
+ return;
573
+ }
574
+ (S = (y = r(this, Q).config).onSuccess) == null || S.call(y, f, this), (c = (O = r(this, Q).config).onSettled) == null || c.call(
575
+ O,
576
+ f,
577
+ this.state.error,
578
+ this
579
+ ), this.scheduleGc();
580
+ },
581
+ onError: u,
582
+ onFail: (f, y) => {
583
+ P(this, T, L).call(this, { type: "failed", failureCount: f, error: y });
584
+ },
585
+ onPause: () => {
586
+ P(this, T, L).call(this, { type: "pause" });
587
+ },
588
+ onContinue: () => {
589
+ P(this, T, L).call(this, { type: "continue" });
590
+ },
591
+ retry: h.options.retry,
592
+ retryDelay: h.options.retryDelay,
593
+ networkMode: h.options.networkMode,
594
+ canRun: () => !0
595
+ })), r(this, q).start();
596
+ }
597
+ }, se = new WeakMap(), ie = new WeakMap(), Q = new WeakMap(), _ = new WeakMap(), q = new WeakMap(), le = new WeakMap(), X = new WeakMap(), T = new WeakSet(), L = function(e) {
598
+ const t = (i) => {
599
+ switch (e.type) {
600
+ case "failed":
601
+ return {
602
+ ...i,
603
+ fetchFailureCount: e.failureCount,
604
+ fetchFailureReason: e.error
605
+ };
606
+ case "pause":
607
+ return {
608
+ ...i,
609
+ fetchStatus: "paused"
610
+ };
611
+ case "continue":
612
+ return {
613
+ ...i,
614
+ fetchStatus: "fetching"
615
+ };
616
+ case "fetch":
617
+ return {
618
+ ...i,
619
+ ...ot(i.data, this.options),
620
+ fetchMeta: e.meta ?? null
621
+ };
622
+ case "success":
623
+ return {
624
+ ...i,
625
+ data: e.data,
626
+ dataUpdateCount: i.dataUpdateCount + 1,
627
+ dataUpdatedAt: e.dataUpdatedAt ?? Date.now(),
628
+ error: null,
629
+ isInvalidated: !1,
630
+ status: "success",
631
+ ...!e.manual && {
632
+ fetchStatus: "idle",
633
+ fetchFailureCount: 0,
634
+ fetchFailureReason: null
635
+ }
636
+ };
637
+ case "error":
638
+ const n = e.error;
639
+ return Pe(n) && n.revert && r(this, ie) ? { ...r(this, ie), fetchStatus: "idle" } : {
640
+ ...i,
641
+ error: n,
642
+ errorUpdateCount: i.errorUpdateCount + 1,
643
+ errorUpdatedAt: Date.now(),
644
+ fetchFailureCount: i.fetchFailureCount + 1,
645
+ fetchFailureReason: n,
646
+ fetchStatus: "idle",
647
+ status: "error"
648
+ };
649
+ case "invalidate":
650
+ return {
651
+ ...i,
652
+ isInvalidated: !0
653
+ };
654
+ case "setState":
655
+ return {
656
+ ...i,
657
+ ...e.state
658
+ };
659
+ }
660
+ };
661
+ this.state = t(this.state), F.batch(() => {
662
+ this.observers.forEach((i) => {
663
+ i.onQueryUpdate();
664
+ }), r(this, Q).notify({ query: this, type: "updated", action: e });
665
+ });
666
+ }, ke);
667
+ function ot(s, e) {
668
+ return {
669
+ fetchFailureCount: 0,
670
+ fetchFailureReason: null,
671
+ fetchStatus: Ve(e.networkMode) ? "fetching" : "paused",
672
+ ...s === void 0 && {
673
+ error: null,
674
+ status: "pending"
675
+ }
676
+ };
677
+ }
678
+ function ct(s) {
679
+ const e = typeof s.initialData == "function" ? s.initialData() : s.initialData, t = e !== void 0, i = t ? typeof s.initialDataUpdatedAt == "function" ? s.initialDataUpdatedAt() : s.initialDataUpdatedAt : 0;
680
+ return {
681
+ data: e,
682
+ dataUpdateCount: 0,
683
+ dataUpdatedAt: t ? i ?? Date.now() : 0,
684
+ error: null,
685
+ errorUpdateCount: 0,
686
+ errorUpdatedAt: 0,
687
+ fetchFailureCount: 0,
688
+ fetchFailureReason: null,
689
+ fetchMeta: null,
690
+ isInvalidated: !1,
691
+ status: t ? "success" : "pending",
692
+ fetchStatus: "idle"
693
+ };
694
+ }
695
+ var k, je, lt = (je = class extends we {
696
+ constructor(e = {}) {
697
+ super();
698
+ l(this, k);
699
+ this.config = e, o(this, k, /* @__PURE__ */ new Map());
700
+ }
701
+ build(e, t, i) {
702
+ const n = t.queryKey, a = t.queryHash ?? Oe(n, t);
703
+ let h = this.get(a);
704
+ return h || (h = new ht({
705
+ client: e,
706
+ queryKey: n,
707
+ queryHash: a,
708
+ options: e.defaultQueryOptions(t),
709
+ state: i,
710
+ defaultOptions: e.getQueryDefaults(n)
711
+ }), this.add(h)), h;
712
+ }
713
+ add(e) {
714
+ r(this, k).has(e.queryHash) || (r(this, k).set(e.queryHash, e), this.notify({
715
+ type: "added",
716
+ query: e
717
+ }));
718
+ }
719
+ remove(e) {
720
+ const t = r(this, k).get(e.queryHash);
721
+ t && (e.destroy(), t === e && r(this, k).delete(e.queryHash), this.notify({ type: "removed", query: e }));
722
+ }
723
+ clear() {
724
+ F.batch(() => {
725
+ this.getAll().forEach((e) => {
726
+ this.remove(e);
727
+ });
728
+ });
729
+ }
730
+ get(e) {
731
+ return r(this, k).get(e);
732
+ }
733
+ getAll() {
734
+ return [...r(this, k).values()];
735
+ }
736
+ find(e) {
737
+ const t = { exact: !0, ...e };
738
+ return this.getAll().find(
739
+ (i) => Ae(t, i)
740
+ );
741
+ }
742
+ findAll(e = {}) {
743
+ const t = this.getAll();
744
+ return Object.keys(e).length > 0 ? t.filter((i) => Ae(e, i)) : t;
745
+ }
746
+ notify(e) {
747
+ F.batch(() => {
748
+ this.listeners.forEach((t) => {
749
+ t(e);
750
+ });
751
+ });
752
+ }
753
+ onFocus() {
754
+ F.batch(() => {
755
+ this.getAll().forEach((e) => {
756
+ e.onFocus();
757
+ });
758
+ });
759
+ }
760
+ onOnline() {
761
+ F.batch(() => {
762
+ this.getAll().forEach((e) => {
763
+ e.onOnline();
764
+ });
765
+ });
766
+ }
767
+ }, k = new WeakMap(), je), j, C, Y, I, H, Ie, dt = (Ie = class extends Be {
768
+ constructor(e) {
769
+ super();
770
+ l(this, I);
771
+ l(this, j);
772
+ l(this, C);
773
+ l(this, Y);
774
+ this.mutationId = e.mutationId, o(this, C, e.mutationCache), o(this, j, []), this.state = e.state || ft(), this.setOptions(e.options), this.scheduleGc();
775
+ }
776
+ setOptions(e) {
777
+ this.options = e, this.updateGcTime(this.options.gcTime);
778
+ }
779
+ get meta() {
780
+ return this.options.meta;
781
+ }
782
+ addObserver(e) {
783
+ r(this, j).includes(e) || (r(this, j).push(e), this.clearGcTimeout(), r(this, C).notify({
784
+ type: "observerAdded",
785
+ mutation: this,
786
+ observer: e
787
+ }));
788
+ }
789
+ removeObserver(e) {
790
+ o(this, j, r(this, j).filter((t) => t !== e)), this.scheduleGc(), r(this, C).notify({
791
+ type: "observerRemoved",
792
+ mutation: this,
793
+ observer: e
794
+ });
795
+ }
796
+ optionalRemove() {
797
+ r(this, j).length || (this.state.status === "pending" ? this.scheduleGc() : r(this, C).remove(this));
798
+ }
799
+ continue() {
800
+ var e;
801
+ return ((e = r(this, Y)) == null ? void 0 : e.continue()) ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
802
+ this.execute(this.state.variables);
803
+ }
804
+ async execute(e) {
805
+ var a, h, u, d, g, m, f, y, S, O, c, p, A, E, w, D, K, U, fe, he;
806
+ const t = () => {
807
+ P(this, I, H).call(this, { type: "continue" });
808
+ };
809
+ o(this, Y, ze({
810
+ fn: () => this.options.mutationFn ? this.options.mutationFn(e) : Promise.reject(new Error("No mutationFn found")),
811
+ onFail: (b, ye) => {
812
+ P(this, I, H).call(this, { type: "failed", failureCount: b, error: ye });
813
+ },
814
+ onPause: () => {
815
+ P(this, I, H).call(this, { type: "pause" });
816
+ },
817
+ onContinue: t,
818
+ retry: this.options.retry ?? 0,
819
+ retryDelay: this.options.retryDelay,
820
+ networkMode: this.options.networkMode,
821
+ canRun: () => r(this, C).canRun(this)
822
+ }));
823
+ const i = this.state.status === "pending", n = !r(this, Y).canStart();
824
+ try {
825
+ if (i)
826
+ t();
827
+ else {
828
+ P(this, I, H).call(this, { type: "pending", variables: e, isPaused: n }), await ((h = (a = r(this, C).config).onMutate) == null ? void 0 : h.call(
829
+ a,
830
+ e,
831
+ this
832
+ ));
833
+ const ye = await ((d = (u = this.options).onMutate) == null ? void 0 : d.call(u, e));
834
+ ye !== this.state.context && P(this, I, H).call(this, {
835
+ type: "pending",
836
+ context: ye,
837
+ variables: e,
838
+ isPaused: n
839
+ });
840
+ }
841
+ const b = await r(this, Y).start();
842
+ return await ((m = (g = r(this, C).config).onSuccess) == null ? void 0 : m.call(
843
+ g,
844
+ b,
845
+ e,
846
+ this.state.context,
847
+ this
848
+ )), await ((y = (f = this.options).onSuccess) == null ? void 0 : y.call(f, b, e, this.state.context)), await ((O = (S = r(this, C).config).onSettled) == null ? void 0 : O.call(
849
+ S,
850
+ b,
851
+ null,
852
+ this.state.variables,
853
+ this.state.context,
854
+ this
855
+ )), await ((p = (c = this.options).onSettled) == null ? void 0 : p.call(c, b, null, e, this.state.context)), P(this, I, H).call(this, { type: "success", data: b }), b;
856
+ } catch (b) {
857
+ try {
858
+ throw await ((E = (A = r(this, C).config).onError) == null ? void 0 : E.call(
859
+ A,
860
+ b,
861
+ e,
862
+ this.state.context,
863
+ this
864
+ )), await ((D = (w = this.options).onError) == null ? void 0 : D.call(
865
+ w,
866
+ b,
867
+ e,
868
+ this.state.context
869
+ )), await ((U = (K = r(this, C).config).onSettled) == null ? void 0 : U.call(
870
+ K,
871
+ void 0,
872
+ b,
873
+ this.state.variables,
874
+ this.state.context,
875
+ this
876
+ )), await ((he = (fe = this.options).onSettled) == null ? void 0 : he.call(
877
+ fe,
878
+ void 0,
879
+ b,
880
+ e,
881
+ this.state.context
882
+ )), b;
883
+ } finally {
884
+ P(this, I, H).call(this, { type: "error", error: b });
885
+ }
886
+ } finally {
887
+ r(this, C).runNext(this);
888
+ }
889
+ }
890
+ }, j = new WeakMap(), C = new WeakMap(), Y = new WeakMap(), I = new WeakSet(), H = function(e) {
891
+ const t = (i) => {
892
+ switch (e.type) {
893
+ case "failed":
894
+ return {
895
+ ...i,
896
+ failureCount: e.failureCount,
897
+ failureReason: e.error
898
+ };
899
+ case "pause":
900
+ return {
901
+ ...i,
902
+ isPaused: !0
903
+ };
904
+ case "continue":
905
+ return {
906
+ ...i,
907
+ isPaused: !1
908
+ };
909
+ case "pending":
910
+ return {
911
+ ...i,
912
+ context: e.context,
913
+ data: void 0,
914
+ failureCount: 0,
915
+ failureReason: null,
916
+ error: null,
917
+ isPaused: e.isPaused,
918
+ status: "pending",
919
+ variables: e.variables,
920
+ submittedAt: Date.now()
921
+ };
922
+ case "success":
923
+ return {
924
+ ...i,
925
+ data: e.data,
926
+ failureCount: 0,
927
+ failureReason: null,
928
+ error: null,
929
+ status: "success",
930
+ isPaused: !1
931
+ };
932
+ case "error":
933
+ return {
934
+ ...i,
935
+ data: void 0,
936
+ error: e.error,
937
+ failureCount: i.failureCount + 1,
938
+ failureReason: e.error,
939
+ isPaused: !1,
940
+ status: "error"
941
+ };
942
+ }
943
+ };
944
+ this.state = t(this.state), F.batch(() => {
945
+ r(this, j).forEach((i) => {
946
+ i.onMutationUpdate(e);
947
+ }), r(this, C).notify({
948
+ mutation: this,
949
+ type: "updated",
950
+ action: e
951
+ });
952
+ });
953
+ }, Ie);
954
+ function ft() {
955
+ return {
956
+ context: void 0,
957
+ data: void 0,
958
+ error: null,
959
+ failureCount: 0,
960
+ failureReason: null,
961
+ isPaused: !1,
962
+ status: "idle",
963
+ variables: void 0,
964
+ submittedAt: 0
965
+ };
966
+ }
967
+ var x, R, de, Le, yt = (Le = class extends we {
968
+ constructor(e = {}) {
969
+ super();
970
+ l(this, x);
971
+ l(this, R);
972
+ l(this, de);
973
+ this.config = e, o(this, x, /* @__PURE__ */ new Set()), o(this, R, /* @__PURE__ */ new Map()), o(this, de, 0);
974
+ }
975
+ build(e, t, i) {
976
+ const n = new dt({
977
+ mutationCache: this,
978
+ mutationId: ++pe(this, de)._,
979
+ options: e.defaultMutationOptions(t),
980
+ state: i
981
+ });
982
+ return this.add(n), n;
983
+ }
984
+ add(e) {
985
+ r(this, x).add(e);
986
+ const t = me(e);
987
+ if (typeof t == "string") {
988
+ const i = r(this, R).get(t);
989
+ i ? i.push(e) : r(this, R).set(t, [e]);
990
+ }
991
+ this.notify({ type: "added", mutation: e });
992
+ }
993
+ remove(e) {
994
+ if (r(this, x).delete(e)) {
995
+ const t = me(e);
996
+ if (typeof t == "string") {
997
+ const i = r(this, R).get(t);
998
+ if (i)
999
+ if (i.length > 1) {
1000
+ const n = i.indexOf(e);
1001
+ n !== -1 && i.splice(n, 1);
1002
+ } else i[0] === e && r(this, R).delete(t);
1003
+ }
1004
+ }
1005
+ this.notify({ type: "removed", mutation: e });
1006
+ }
1007
+ canRun(e) {
1008
+ const t = me(e);
1009
+ if (typeof t == "string") {
1010
+ const i = r(this, R).get(t), n = i == null ? void 0 : i.find(
1011
+ (a) => a.state.status === "pending"
1012
+ );
1013
+ return !n || n === e;
1014
+ } else
1015
+ return !0;
1016
+ }
1017
+ runNext(e) {
1018
+ var i;
1019
+ const t = me(e);
1020
+ if (typeof t == "string") {
1021
+ const n = (i = r(this, R).get(t)) == null ? void 0 : i.find((a) => a !== e && a.state.isPaused);
1022
+ return (n == null ? void 0 : n.continue()) ?? Promise.resolve();
1023
+ } else
1024
+ return Promise.resolve();
1025
+ }
1026
+ clear() {
1027
+ F.batch(() => {
1028
+ r(this, x).forEach((e) => {
1029
+ this.notify({ type: "removed", mutation: e });
1030
+ }), r(this, x).clear(), r(this, R).clear();
1031
+ });
1032
+ }
1033
+ getAll() {
1034
+ return Array.from(r(this, x));
1035
+ }
1036
+ find(e) {
1037
+ const t = { exact: !0, ...e };
1038
+ return this.getAll().find(
1039
+ (i) => De(t, i)
1040
+ );
1041
+ }
1042
+ findAll(e = {}) {
1043
+ return this.getAll().filter((t) => De(e, t));
1044
+ }
1045
+ notify(e) {
1046
+ F.batch(() => {
1047
+ this.listeners.forEach((t) => {
1048
+ t(e);
1049
+ });
1050
+ });
1051
+ }
1052
+ resumePausedMutations() {
1053
+ const e = this.getAll().filter((t) => t.state.isPaused);
1054
+ return F.batch(
1055
+ () => Promise.all(
1056
+ e.map((t) => t.continue().catch(M))
1057
+ )
1058
+ );
1059
+ }
1060
+ }, x = new WeakMap(), R = new WeakMap(), de = new WeakMap(), Le);
1061
+ function me(s) {
1062
+ var e;
1063
+ return (e = s.options.scope) == null ? void 0 : e.id;
1064
+ }
1065
+ function Me(s) {
1066
+ return {
1067
+ onFetch: (e, t) => {
1068
+ var m, f, y, S, O;
1069
+ const i = e.options, n = (y = (f = (m = e.fetchOptions) == null ? void 0 : m.meta) == null ? void 0 : f.fetchMore) == null ? void 0 : y.direction, a = ((S = e.state.data) == null ? void 0 : S.pages) || [], h = ((O = e.state.data) == null ? void 0 : O.pageParams) || [];
1070
+ let u = { pages: [], pageParams: [] }, d = 0;
1071
+ const g = async () => {
1072
+ let c = !1;
1073
+ const p = (w) => {
1074
+ Object.defineProperty(w, "signal", {
1075
+ enumerable: !0,
1076
+ get: () => (e.signal.aborted ? c = !0 : e.signal.addEventListener("abort", () => {
1077
+ c = !0;
1078
+ }), e.signal)
1079
+ });
1080
+ }, A = Ge(e.options, e.fetchOptions), E = async (w, D, K) => {
1081
+ if (c)
1082
+ return Promise.reject();
1083
+ if (D == null && w.pages.length)
1084
+ return Promise.resolve(w);
1085
+ const U = {
1086
+ client: e.client,
1087
+ queryKey: e.queryKey,
1088
+ pageParam: D,
1089
+ direction: K ? "backward" : "forward",
1090
+ meta: e.options.meta
1091
+ };
1092
+ p(U);
1093
+ const fe = await A(
1094
+ U
1095
+ ), { maxPages: he } = e.options, b = K ? tt : et;
1096
+ return {
1097
+ pages: b(w.pages, fe, he),
1098
+ pageParams: b(w.pageParams, D, he)
1099
+ };
1100
+ };
1101
+ if (n && a.length) {
1102
+ const w = n === "backward", D = w ? pt : Te, K = {
1103
+ pages: a,
1104
+ pageParams: h
1105
+ }, U = D(i, K);
1106
+ u = await E(K, U, w);
1107
+ } else {
1108
+ const w = s ?? a.length;
1109
+ do {
1110
+ const D = d === 0 ? h[0] ?? i.initialPageParam : Te(i, u);
1111
+ if (d > 0 && D == null)
1112
+ break;
1113
+ u = await E(u, D), d++;
1114
+ } while (d < w);
1115
+ }
1116
+ return u;
1117
+ };
1118
+ e.options.persister ? e.fetchFn = () => {
1119
+ var c, p;
1120
+ return (p = (c = e.options).persister) == null ? void 0 : p.call(
1121
+ c,
1122
+ g,
1123
+ {
1124
+ client: e.client,
1125
+ queryKey: e.queryKey,
1126
+ meta: e.options.meta,
1127
+ signal: e.signal
1128
+ },
1129
+ t
1130
+ );
1131
+ } : e.fetchFn = g;
1132
+ }
1133
+ };
1134
+ }
1135
+ function Te(s, { pages: e, pageParams: t }) {
1136
+ const i = e.length - 1;
1137
+ return e.length > 0 ? s.getNextPageParam(
1138
+ e[i],
1139
+ e,
1140
+ t[i],
1141
+ t
1142
+ ) : void 0;
1143
+ }
1144
+ function pt(s, { pages: e, pageParams: t }) {
1145
+ var i;
1146
+ return e.length > 0 ? (i = s.getPreviousPageParam) == null ? void 0 : i.call(s, e[0], e, t[0], t) : void 0;
1147
+ }
1148
+ var v, V, $, re, ne, z, ae, ue, xe, mt = (xe = class {
1149
+ constructor(s = {}) {
1150
+ l(this, v);
1151
+ l(this, V);
1152
+ l(this, $);
1153
+ l(this, re);
1154
+ l(this, ne);
1155
+ l(this, z);
1156
+ l(this, ae);
1157
+ l(this, ue);
1158
+ o(this, v, s.queryCache || new lt()), o(this, V, s.mutationCache || new yt()), o(this, $, s.defaultOptions || {}), o(this, re, /* @__PURE__ */ new Map()), o(this, ne, /* @__PURE__ */ new Map()), o(this, z, 0);
1159
+ }
1160
+ mount() {
1161
+ pe(this, z)._++, r(this, z) === 1 && (o(this, ae, Ne.subscribe(async (s) => {
1162
+ s && (await this.resumePausedMutations(), r(this, v).onFocus());
1163
+ })), o(this, ue, ve.subscribe(async (s) => {
1164
+ s && (await this.resumePausedMutations(), r(this, v).onOnline());
1165
+ })));
1166
+ }
1167
+ unmount() {
1168
+ var s, e;
1169
+ pe(this, z)._--, r(this, z) === 0 && ((s = r(this, ae)) == null || s.call(this), o(this, ae, void 0), (e = r(this, ue)) == null || e.call(this), o(this, ue, void 0));
1170
+ }
1171
+ isFetching(s) {
1172
+ return r(this, v).findAll({ ...s, fetchStatus: "fetching" }).length;
1173
+ }
1174
+ isMutating(s) {
1175
+ return r(this, V).findAll({ ...s, status: "pending" }).length;
1176
+ }
1177
+ /**
1178
+ * Imperative (non-reactive) way to retrieve data for a QueryKey.
1179
+ * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
1180
+ *
1181
+ * Hint: Do not use this function inside a component, because it won't receive updates.
1182
+ * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
1183
+ */
1184
+ getQueryData(s) {
1185
+ var t;
1186
+ const e = this.defaultQueryOptions({ queryKey: s });
1187
+ return (t = r(this, v).get(e.queryHash)) == null ? void 0 : t.state.data;
1188
+ }
1189
+ ensureQueryData(s) {
1190
+ const e = this.defaultQueryOptions(s), t = r(this, v).build(this, e), i = t.state.data;
1191
+ return i === void 0 ? this.fetchQuery(s) : (s.revalidateIfStale && t.isStaleByTime(Se(e.staleTime, t)) && this.prefetchQuery(e), Promise.resolve(i));
1192
+ }
1193
+ getQueriesData(s) {
1194
+ return r(this, v).findAll(s).map(({ queryKey: e, state: t }) => {
1195
+ const i = t.data;
1196
+ return [e, i];
1197
+ });
1198
+ }
1199
+ setQueryData(s, e, t) {
1200
+ const i = this.defaultQueryOptions({ queryKey: s }), n = r(this, v).get(
1201
+ i.queryHash
1202
+ ), a = n == null ? void 0 : n.state.data, h = Je(e, a);
1203
+ if (h !== void 0)
1204
+ return r(this, v).build(this, i).setData(h, { ...t, manual: !0 });
1205
+ }
1206
+ setQueriesData(s, e, t) {
1207
+ return F.batch(
1208
+ () => r(this, v).findAll(s).map(({ queryKey: i }) => [
1209
+ i,
1210
+ this.setQueryData(i, e, t)
1211
+ ])
1212
+ );
1213
+ }
1214
+ getQueryState(s) {
1215
+ var t;
1216
+ const e = this.defaultQueryOptions({ queryKey: s });
1217
+ return (t = r(this, v).get(
1218
+ e.queryHash
1219
+ )) == null ? void 0 : t.state;
1220
+ }
1221
+ removeQueries(s) {
1222
+ const e = r(this, v);
1223
+ F.batch(() => {
1224
+ e.findAll(s).forEach((t) => {
1225
+ e.remove(t);
1226
+ });
1227
+ });
1228
+ }
1229
+ resetQueries(s, e) {
1230
+ const t = r(this, v);
1231
+ return F.batch(() => (t.findAll(s).forEach((i) => {
1232
+ i.reset();
1233
+ }), this.refetchQueries(
1234
+ {
1235
+ type: "active",
1236
+ ...s
1237
+ },
1238
+ e
1239
+ )));
1240
+ }
1241
+ cancelQueries(s, e = {}) {
1242
+ const t = { revert: !0, ...e }, i = F.batch(
1243
+ () => r(this, v).findAll(s).map((n) => n.cancel(t))
1244
+ );
1245
+ return Promise.all(i).then(M).catch(M);
1246
+ }
1247
+ invalidateQueries(s, e = {}) {
1248
+ return F.batch(() => (r(this, v).findAll(s).forEach((t) => {
1249
+ t.invalidate();
1250
+ }), (s == null ? void 0 : s.refetchType) === "none" ? Promise.resolve() : this.refetchQueries(
1251
+ {
1252
+ ...s,
1253
+ type: (s == null ? void 0 : s.refetchType) ?? (s == null ? void 0 : s.type) ?? "active"
1254
+ },
1255
+ e
1256
+ )));
1257
+ }
1258
+ refetchQueries(s, e = {}) {
1259
+ const t = {
1260
+ ...e,
1261
+ cancelRefetch: e.cancelRefetch ?? !0
1262
+ }, i = F.batch(
1263
+ () => r(this, v).findAll(s).filter((n) => !n.isDisabled()).map((n) => {
1264
+ let a = n.fetch(void 0, t);
1265
+ return t.throwOnError || (a = a.catch(M)), n.state.fetchStatus === "paused" ? Promise.resolve() : a;
1266
+ })
1267
+ );
1268
+ return Promise.all(i).then(M);
1269
+ }
1270
+ fetchQuery(s) {
1271
+ const e = this.defaultQueryOptions(s);
1272
+ e.retry === void 0 && (e.retry = !1);
1273
+ const t = r(this, v).build(this, e);
1274
+ return t.isStaleByTime(
1275
+ Se(e.staleTime, t)
1276
+ ) ? t.fetch(e) : Promise.resolve(t.state.data);
1277
+ }
1278
+ prefetchQuery(s) {
1279
+ return this.fetchQuery(s).then(M).catch(M);
1280
+ }
1281
+ fetchInfiniteQuery(s) {
1282
+ return s.behavior = Me(s.pages), this.fetchQuery(s);
1283
+ }
1284
+ prefetchInfiniteQuery(s) {
1285
+ return this.fetchInfiniteQuery(s).then(M).catch(M);
1286
+ }
1287
+ ensureInfiniteQueryData(s) {
1288
+ return s.behavior = Me(s.pages), this.ensureQueryData(s);
1289
+ }
1290
+ resumePausedMutations() {
1291
+ return ve.isOnline() ? r(this, V).resumePausedMutations() : Promise.resolve();
1292
+ }
1293
+ getQueryCache() {
1294
+ return r(this, v);
1295
+ }
1296
+ getMutationCache() {
1297
+ return r(this, V);
1298
+ }
1299
+ getDefaultOptions() {
1300
+ return r(this, $);
1301
+ }
1302
+ setDefaultOptions(s) {
1303
+ o(this, $, s);
1304
+ }
1305
+ setQueryDefaults(s, e) {
1306
+ r(this, re).set(oe(s), {
1307
+ queryKey: s,
1308
+ defaultOptions: e
1309
+ });
1310
+ }
1311
+ getQueryDefaults(s) {
1312
+ const e = [...r(this, re).values()], t = {};
1313
+ return e.forEach((i) => {
1314
+ ce(s, i.queryKey) && Object.assign(t, i.defaultOptions);
1315
+ }), t;
1316
+ }
1317
+ setMutationDefaults(s, e) {
1318
+ r(this, ne).set(oe(s), {
1319
+ mutationKey: s,
1320
+ defaultOptions: e
1321
+ });
1322
+ }
1323
+ getMutationDefaults(s) {
1324
+ const e = [...r(this, ne).values()], t = {};
1325
+ return e.forEach((i) => {
1326
+ ce(s, i.mutationKey) && Object.assign(t, i.defaultOptions);
1327
+ }), t;
1328
+ }
1329
+ defaultQueryOptions(s) {
1330
+ if (s._defaulted)
1331
+ return s;
1332
+ const e = {
1333
+ ...r(this, $).queries,
1334
+ ...this.getQueryDefaults(s.queryKey),
1335
+ ...s,
1336
+ _defaulted: !0
1337
+ };
1338
+ return e.queryHash || (e.queryHash = Oe(
1339
+ e.queryKey,
1340
+ e
1341
+ )), e.refetchOnReconnect === void 0 && (e.refetchOnReconnect = e.networkMode !== "always"), e.throwOnError === void 0 && (e.throwOnError = !!e.suspense), !e.networkMode && e.persister && (e.networkMode = "offlineFirst"), e.queryFn === Ce && (e.enabled = !1), e;
1342
+ }
1343
+ defaultMutationOptions(s) {
1344
+ return s != null && s._defaulted ? s : {
1345
+ ...r(this, $).mutations,
1346
+ ...(s == null ? void 0 : s.mutationKey) && this.getMutationDefaults(s.mutationKey),
1347
+ ...s,
1348
+ _defaulted: !0
1349
+ };
1350
+ }
1351
+ clear() {
1352
+ r(this, v).clear(), r(this, V).clear();
1353
+ }
1354
+ }, v = new WeakMap(), V = new WeakMap(), $ = new WeakMap(), re = new WeakMap(), ne = new WeakMap(), z = new WeakMap(), ae = new WeakMap(), ue = new WeakMap(), xe);
1355
+ class B {
1356
+ constructor(e = {}) {
1357
+ this.apiUrl = e.apiUrl || "https://api.luzmo.com", this.apiVersion = e.apiVersion || "0.1.0", this.authKey = e.authKey || "", this.authToken = e.authToken || "", this.queryClient = new mt({
1358
+ defaultOptions: {
1359
+ queries: {
1360
+ staleTime: e.staleTime || 5 * 60 * 1e3,
1361
+ // 5 minutes
1362
+ gcTime: e.gcTime || 10 * 60 * 1e3,
1363
+ // 10 minutes
1364
+ retry: e.retry || 3,
1365
+ retryDelay: e.retryDelay || ((t) => Math.min(1e3 * 2 ** t, 3e4))
1366
+ }
1367
+ }
1368
+ }), this.initNetworkListeners();
1369
+ }
1370
+ /**
1371
+ * Set API configuration
1372
+ * @param config - API configuration
1373
+ */
1374
+ configure(e = {}) {
1375
+ if (e.apiVersion && (this.apiVersion = e.apiVersion), e.apiUrl && (this.apiUrl = e.apiUrl), e.authKey && (this.authKey = e.authKey), e.authToken && (this.authToken = e.authToken), e.staleTime || e.gcTime || e.retry) {
1376
+ const t = {};
1377
+ e.staleTime && (t.staleTime = e.staleTime), e.gcTime && (t.gcTime = e.gcTime), e.retry && (t.retry = e.retry), this.queryClient.setDefaultOptions({
1378
+ queries: {
1379
+ ...this.queryClient.getDefaultOptions().queries,
1380
+ ...t
1381
+ }
1382
+ });
1383
+ }
1384
+ }
1385
+ /**
1386
+ * Initialize network status listeners
1387
+ */
1388
+ initNetworkListeners() {
1389
+ typeof window < "u" && window.addEventListener("online", () => {
1390
+ console.warn("Network connection restored, refreshing data..."), this.refreshAll();
1391
+ });
1392
+ }
1393
+ /**
1394
+ * Get API headers
1395
+ * @param additionalHeaders - Additional headers to include
1396
+ * @returns Headers for API requests
1397
+ */
1398
+ getHeaders(e = {}) {
1399
+ return {
1400
+ "Content-Type": "application/json",
1401
+ ...e
1402
+ };
1403
+ }
1404
+ /**
1405
+ * Make API request with advanced error handling
1406
+ * Default method is POST and supports an optional JSON body
1407
+ * @param endpoint - API endpoint
1408
+ * @param jsonBody - Optional JSON body to send with request
1409
+ * @param options - Additional fetch options
1410
+ * @returns API response
1411
+ * @throws {Error} If API request fails
1412
+ */
1413
+ async fetchApi(e, t, i = {}) {
1414
+ const n = `${this.apiUrl}/${this.apiVersion}${e}`, h = {
1415
+ method: i.method || "POST",
1416
+ headers: this.getHeaders(i.headers),
1417
+ mode: "cors",
1418
+ ...i
1419
+ };
1420
+ t !== void 0 && (t.key = this.authKey, t.token = this.authToken, h.body = JSON.stringify(t));
1421
+ try {
1422
+ const u = await fetch(n, h);
1423
+ if (!u.ok) {
1424
+ const d = await u.json().catch(() => null);
1425
+ throw u.status === 401 || u.status === 403 ? new Error(
1426
+ "Authentication failed. Please check your API token."
1427
+ ) : u.status === 404 ? new Error(`Resource not found: ${e}`) : u.status === 429 ? new Error("Rate limit exceeded. Please try again later.") : new Error(
1428
+ (d == null ? void 0 : d.message) || `API request failed with status ${u.status}`
1429
+ );
1430
+ }
1431
+ return await u.json();
1432
+ } catch (u) {
1433
+ throw console.error(`API request to ${e} failed:`, u), u instanceof Error && (u.endpoint = e, u.timestamp = (/* @__PURE__ */ new Date()).toISOString()), u;
1434
+ }
1435
+ }
1436
+ /**
1437
+ * Fetch all available datasets with pagination support
1438
+ * @param options - Pagination options
1439
+ * @returns Paginated list of datasets
1440
+ */
1441
+ async fetchAllDatasets(e = {}) {
1442
+ const t = e.offset || 0, i = e.limit || 50, n = ["datasets", t, i];
1443
+ return await this.queryClient.fetchQuery({
1444
+ queryKey: n,
1445
+ queryFn: async () => {
1446
+ const a = {
1447
+ action: "get",
1448
+ version: this.apiVersion,
1449
+ find: {
1450
+ where: {
1451
+ type: "dataset"
1452
+ },
1453
+ limit: i,
1454
+ offset: t
1455
+ }
1456
+ }, h = await this.fetchApi(
1457
+ "/securable",
1458
+ a
1459
+ );
1460
+ return {
1461
+ data: (h == null ? void 0 : h.rows) || [],
1462
+ pagination: {
1463
+ offset: t,
1464
+ limit: i,
1465
+ total: (h == null ? void 0 : h.count) ?? 0,
1466
+ pages: Math.ceil(((h == null ? void 0 : h.count) ?? 0) / i)
1467
+ }
1468
+ };
1469
+ }
1470
+ });
1471
+ }
1472
+ /**
1473
+ * Search datasets by name or description
1474
+ * @param query - Search query
1475
+ * @returns List of matching datasets
1476
+ */
1477
+ async searchDatasets(e, t) {
1478
+ if (!e) return [];
1479
+ const i = ["datasets", "search", e, t];
1480
+ return await this.queryClient.fetchQuery({
1481
+ queryKey: i,
1482
+ queryFn: async () => {
1483
+ const n = {
1484
+ action: "get",
1485
+ version: this.apiVersion,
1486
+ find: {
1487
+ where: {
1488
+ type: "dataset"
1489
+ }
1490
+ }
1491
+ };
1492
+ (e == null ? void 0 : e.length) > 0 && (n.find.search = {
1493
+ match_types: ["name"],
1494
+ keyphrase: e
1495
+ }), t != null && t.offset && (n.find.offset = t == null ? void 0 : t.offset), t != null && t.limit && (n.find.limit = t == null ? void 0 : t.limit);
1496
+ const a = await this.fetchApi(
1497
+ "/securable",
1498
+ n
1499
+ ), h = {
1500
+ data: (a == null ? void 0 : a.rows) || []
1501
+ };
1502
+ return t != null && t.limit && (h.pagination = {
1503
+ offset: (t == null ? void 0 : t.offset) ?? 0,
1504
+ limit: t == null ? void 0 : t.limit,
1505
+ total: (a == null ? void 0 : a.count) ?? 0,
1506
+ pages: Math.ceil(((a == null ? void 0 : a.count) ?? 0) / (t == null ? void 0 : t.limit))
1507
+ }), h;
1508
+ }
1509
+ });
1510
+ }
1511
+ /**
1512
+ * Fetch a specific dataset by ID
1513
+ * @param datasetId - Dataset ID
1514
+ * @returns Dataset details
1515
+ */
1516
+ async fetchDatasetsWithColumnsAndFormulas(e) {
1517
+ if (!e || e.length === 0)
1518
+ throw new Error("At least one dataset ID is required");
1519
+ const t = ["datasets", e];
1520
+ return await this.queryClient.fetchQuery({
1521
+ queryKey: t,
1522
+ queryFn: async () => {
1523
+ const i = {
1524
+ action: "get",
1525
+ version: this.apiVersion,
1526
+ find: {
1527
+ where: {
1528
+ type: "dataset",
1529
+ id: {
1530
+ in: e
1531
+ }
1532
+ },
1533
+ attributes: ["name", "id"],
1534
+ include: [
1535
+ {
1536
+ model: "Column",
1537
+ attributes: [
1538
+ "id",
1539
+ "name",
1540
+ "description",
1541
+ "type",
1542
+ "subtype",
1543
+ "format",
1544
+ "hidden",
1545
+ "lowestLevel"
1546
+ ]
1547
+ },
1548
+ {
1549
+ model: "Formula",
1550
+ attributes: [
1551
+ "id",
1552
+ "name",
1553
+ "description",
1554
+ "type",
1555
+ "subtype",
1556
+ "format",
1557
+ "hidden",
1558
+ "lowestLevel"
1559
+ ]
1560
+ }
1561
+ ]
1562
+ }
1563
+ }, n = await this.fetchApi(
1564
+ "/securable",
1565
+ i
1566
+ );
1567
+ return (n == null ? void 0 : n.rows) || [];
1568
+ }
1569
+ });
1570
+ }
1571
+ /**
1572
+ * Fetch a specific dataset by ID
1573
+ * @param datasetId - Dataset ID
1574
+ * @returns Dataset details
1575
+ */
1576
+ async fetchDataset(e) {
1577
+ if (!e) throw new Error("Dataset ID is required");
1578
+ const t = ["dataset", e];
1579
+ return await this.queryClient.fetchQuery({
1580
+ queryKey: t,
1581
+ queryFn: async () => {
1582
+ var a;
1583
+ const i = {
1584
+ action: "get",
1585
+ version: this.apiVersion,
1586
+ find: {
1587
+ where: {
1588
+ type: "dataset",
1589
+ id: e
1590
+ },
1591
+ attributes: ["name", "id"],
1592
+ include: [
1593
+ {
1594
+ model: "Column"
1595
+ },
1596
+ {
1597
+ model: "Formula"
1598
+ }
1599
+ ]
1600
+ }
1601
+ }, n = await this.fetchApi(
1602
+ "/securable",
1603
+ i
1604
+ );
1605
+ return ((a = n == null ? void 0 : n.rows) == null ? void 0 : a[0]) || null;
1606
+ }
1607
+ });
1608
+ }
1609
+ /**
1610
+ * Fetch data from a dataset with filtering
1611
+ * @param datasetId - Dataset ID
1612
+ * @param queryParams - Query parameters (filters, sort, etc.)
1613
+ * @returns Dataset data
1614
+ */
1615
+ async fetchData(e) {
1616
+ if (!e) throw new Error("Query is required");
1617
+ const t = ["data", e];
1618
+ return await this.queryClient.fetchQuery({
1619
+ queryKey: t,
1620
+ queryFn: async () => {
1621
+ const i = {
1622
+ action: "get",
1623
+ version: this.apiVersion,
1624
+ find: {
1625
+ queries: [e]
1626
+ }
1627
+ }, n = await this.fetchApi("/data", i);
1628
+ return {
1629
+ data: (n == null ? void 0 : n.data) || [],
1630
+ performance: (n == null ? void 0 : n.performance) || {}
1631
+ };
1632
+ }
1633
+ });
1634
+ }
1635
+ /**
1636
+ * Refresh all queries
1637
+ */
1638
+ refreshAll() {
1639
+ this.queryClient.refetchQueries();
1640
+ }
1641
+ /**
1642
+ * Invalidate cached data for a dataset
1643
+ * @param datasetId - Dataset ID (optional)
1644
+ */
1645
+ invalidateDatasetData(e) {
1646
+ e ? (this.queryClient.invalidateQueries({ queryKey: ["dataset", e] }), this.queryClient.invalidateQueries({ queryKey: ["columns", e] })) : this.queryClient.invalidateQueries({ queryKey: ["datasets"] });
1647
+ }
1648
+ /**
1649
+ * Invalidate all cached data
1650
+ */
1651
+ invalidateAll() {
1652
+ this.queryClient.clear();
1653
+ }
1654
+ /**
1655
+ * Create a singleton instance
1656
+ * @param config - API configuration
1657
+ * @returns Singleton instance
1658
+ */
1659
+ static getInstance(e = {}) {
1660
+ return B.instance ? Object.keys(e).length > 0 && B.instance.configure(e) : B.instance = new B(e), B.instance;
1661
+ }
1662
+ }
1663
+ const wt = B.getInstance();
1664
+ export {
1665
+ wt as d
1666
+ };