@luzmo/analytics-components-kit 1.0.1-alpha.90 → 1.0.1-alpha.94

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 (253) hide show
  1. package/README.md +195 -0
  2. package/angular/README.md +1 -0
  3. package/angular/components/widget-menu.component.ts +25 -0
  4. package/angular/esm/components/widget-menu.component.d.ts +13 -0
  5. package/angular/esm/components/widget-menu.component.js +49 -0
  6. package/angular/esm/index.d.ts +3 -1
  7. package/angular/esm/index.js +4 -1
  8. package/angular/esm/types.d.ts +4 -0
  9. package/angular/index.ts +4 -1
  10. package/angular/types.ts +6 -0
  11. package/components/ai-chat-message-assistant/index.cjs +1 -1
  12. package/components/ai-chat-message-assistant/index.js +1 -0
  13. package/components/ai-chat-messages-container/index.cjs +1 -1
  14. package/components/ai-chat-messages-container/index.js +2 -2
  15. package/components/ai-interaction-textarea/index.cjs +1 -1
  16. package/components/ai-interaction-textarea/index.js +2 -1
  17. package/components/area-chart-options.config-C7sMAHco.cjs +20 -0
  18. package/components/{area-chart-options.config-u8itidsi.js → area-chart-options.config-_J0sG4NF.js} +26 -14
  19. package/components/{bar-chart-options.config-DIirbAJ0.js → bar-chart-options.config-D1mb5TDl.js} +35 -21
  20. package/components/bar-chart-options.config-DcxEkOT5.cjs +20 -0
  21. package/components/box-plot-options.config-SrrbDEYW.cjs +20 -0
  22. package/components/{box-plot-options.config-BWROiguA.js → box-plot-options.config-xu_i6ms7.js} +88 -52
  23. package/components/{bubble-chart-options.config-4QD8VPhU.js → bubble-chart-options.config-BacgXkJ_.js} +18 -9
  24. package/components/bubble-chart-options.config-Ihn6eVQI.cjs +20 -0
  25. package/components/{bullet-chart-options.config-3bH7uekx.js → bullet-chart-options.config-CDPpX1yc.js} +1 -1
  26. package/components/{bullet-chart-options.config-tWb6Fio-.cjs → bullet-chart-options.config-DfS4Bwds.cjs} +1 -1
  27. package/components/calculate-data-item-icon-CEa82-5u.cjs +20 -0
  28. package/components/calculate-data-item-icon-DjlZwMdO.js +147 -0
  29. package/components/{choropleth-map-options.config-CMxx3ORp.js → choropleth-map-options.config-B_W9-rhe.js} +84 -63
  30. package/components/choropleth-map-options.config-ZW8yoZH2.cjs +20 -0
  31. package/components/{circular-gauge-options.config-DhIKn44k.js → circular-gauge-options.config-DAIjz4Rl.js} +36 -23
  32. package/components/circular-gauge-options.config-msZ4mfpN.cjs +20 -0
  33. package/components/color-B6LaL8qz.cjs +20 -0
  34. package/components/{color-B7m0j8lX.js → color-DuJ4-73S.js} +950 -941
  35. package/components/{color-range-utils-BSfqtB3A.js → color-range-utils-Bvo9sm5A.js} +32 -31
  36. package/components/color-range-utils-C5yXW7ZC.cjs +20 -0
  37. package/components/{column-chart-options.config-D5-yR7iq.js → column-chart-options.config-B5SjBVdy.js} +37 -27
  38. package/components/column-chart-options.config-BjDvA7i9.cjs +20 -0
  39. package/components/{conditional-number-options.config-DPYsdML5.js → conditional-number-options.config-BCEpSK9J.js} +40 -24
  40. package/components/conditional-number-options.config-DgzUo0xi.cjs +20 -0
  41. package/components/dataset-icon/index.cjs +1 -1
  42. package/components/dataset-icon/index.js +2 -1
  43. package/components/dataset-selector-list/index.cjs +1 -1
  44. package/components/dataset-selector-list/index.js +35 -32
  45. package/components/dataset-selector-row/index.cjs +9 -9
  46. package/components/dataset-selector-row/index.js +53 -51
  47. package/components/{date-comparison-filter-options.config-QaoWaFUn.cjs → date-comparison-filter-options.config-DAVncmi0.cjs} +1 -1
  48. package/components/{date-comparison-filter-options.config-CSwGyuBg.js → date-comparison-filter-options.config-JA_yYpJa.js} +6 -3
  49. package/components/{date-filter-options.config-n-zhWaYa.cjs → date-filter-options.config-CWPMtA18.cjs} +1 -1
  50. package/components/{date-filter-options.config-BTVyHRkp.js → date-filter-options.config-DBRxlTWy.js} +6 -3
  51. package/components/display-settings/index.cjs +1 -1
  52. package/components/display-settings/index.js +1 -1
  53. package/components/display-settings-binning/index.cjs +5 -5
  54. package/components/display-settings-binning/index.js +30 -29
  55. package/components/display-settings-datetime/index.cjs +29 -29
  56. package/components/display-settings-datetime/index.js +120 -112
  57. package/components/display-settings-grand-totals/index.cjs +4 -4
  58. package/components/display-settings-grand-totals/index.js +24 -23
  59. package/components/display-settings-numeric/index.cjs +48 -48
  60. package/components/display-settings-numeric/index.js +211 -194
  61. package/components/display-settings-period-over-period/index.cjs +16 -16
  62. package/components/display-settings-period-over-period/index.js +97 -91
  63. package/components/{donut-chart-options.config-3ZqX8Cbb.js → donut-chart-options.config-BulUEiaH.js} +37 -21
  64. package/components/donut-chart-options.config-tNpqBZfR.cjs +20 -0
  65. package/components/draggable-data-item/index.cjs +5 -5
  66. package/components/draggable-data-item/index.js +46 -45
  67. package/components/draggable-data-item-level/index.cjs +11 -11
  68. package/components/draggable-data-item-level/index.js +73 -70
  69. package/components/{dropdown-filter-options.config-CGJTtgAX.js → dropdown-filter-options.config-D9dvPypF.js} +10 -7
  70. package/components/{dropdown-filter-options.config-DJvfCTk7.cjs → dropdown-filter-options.config-DS-MORmq.cjs} +1 -1
  71. package/components/droppable-slot/index.cjs +16 -16
  72. package/components/droppable-slot/index.js +223 -208
  73. package/components/edit-item/index.cjs +9 -9
  74. package/components/edit-item/index.js +119 -116
  75. package/components/edit-option/index.cjs +1 -1
  76. package/components/edit-option/index.js +1 -1
  77. package/components/edit-option-action-button-group/index.cjs +8 -8
  78. package/components/edit-option-action-button-group/index.js +53 -52
  79. package/components/{edit-option-base-Bh29-Cak.js → edit-option-base-DIc7iC-b.js} +1 -1
  80. package/components/{edit-option-base-tFr8Qg2B.cjs → edit-option-base-VhTih9T1.cjs} +1 -1
  81. package/components/edit-option-color-palette-picker/index.cjs +1 -1
  82. package/components/edit-option-color-palette-picker/index.js +1 -1
  83. package/components/edit-option-color-picker/index.cjs +1 -1
  84. package/components/edit-option-color-picker/index.js +1 -1
  85. package/components/edit-option-color-range/index.cjs +19 -19
  86. package/components/edit-option-color-range/index.js +117 -106
  87. package/components/edit-option-multi-language-field/index.cjs +3 -3
  88. package/components/edit-option-multi-language-field/index.js +27 -26
  89. package/components/edit-option-number-field/index.cjs +1 -1
  90. package/components/edit-option-number-field/index.js +1 -1
  91. package/components/edit-option-picker/index.cjs +5 -5
  92. package/components/edit-option-picker/index.js +7 -7
  93. package/components/edit-option-position-picker/index.cjs +4 -4
  94. package/components/edit-option-position-picker/index.js +25 -21
  95. package/components/edit-option-positions-number-field/index.cjs +9 -9
  96. package/components/edit-option-positions-number-field/index.js +81 -76
  97. package/components/edit-option-radio-button-group/index.cjs +6 -6
  98. package/components/edit-option-radio-button-group/index.js +22 -21
  99. package/components/edit-option-slider/index.cjs +1 -1
  100. package/components/edit-option-slider/index.js +1 -1
  101. package/components/edit-option-switch/index.cjs +1 -1
  102. package/components/edit-option-switch/index.js +1 -1
  103. package/components/edit-option-text-field/index.cjs +2 -2
  104. package/components/edit-option-text-field/index.js +23 -22
  105. package/components/en-BKBhKBXY.cjs +20 -0
  106. package/components/en-BOTjhwEc.js +1488 -0
  107. package/components/{en-GB-ialeqj_z.js → en-GB-CEHEs8F2.js} +1 -1
  108. package/components/{en-GB-TqvgIw9B.cjs → en-GB-DG6uS3sM.cjs} +1 -1
  109. package/components/{evolution-number-options.config-Bc9eKYnn.cjs → evolution-number-options.config-BgIZY4gQ.cjs} +1 -1
  110. package/components/{evolution-number-options.config-BIPO_4n3.js → evolution-number-options.config-DzkfeoIN.js} +14 -11
  111. package/components/{extrapolate-color-C0n1UDs-.cjs → extrapolate-color-0j_AeYkz.cjs} +1 -1
  112. package/components/{extrapolate-color-v1PimdQr.js → extrapolate-color-CC9CURf6.js} +1 -1
  113. package/components/filter-data-item-picker/index.cjs +7 -7
  114. package/components/filter-data-item-picker/index.js +86 -85
  115. package/components/filter-expression-picker/index.cjs +1 -1
  116. package/components/filter-expression-picker/index.js +1 -1
  117. package/components/filter-item/index.cjs +6 -6
  118. package/components/filter-item/index.js +119 -109
  119. package/components/filter-value-picker/index.cjs +2 -2
  120. package/components/filter-value-picker/index.js +36 -34
  121. package/components/filter-value-picker-datetime/index.cjs +8 -8
  122. package/components/filter-value-picker-datetime/index.js +71 -56
  123. package/components/filter-value-picker-hierarchy/index.cjs +12 -12
  124. package/components/filter-value-picker-hierarchy/index.js +124 -113
  125. package/components/filter-value-picker-numeric/index.cjs +8 -8
  126. package/components/filter-value-picker-numeric/index.js +110 -101
  127. package/components/focusable-B3E_hQmm.cjs +20 -0
  128. package/components/{focusable-BS2pbY7w.js → focusable-DCIFkpiW.js} +26 -24
  129. package/components/{funnel-chart-options.config-CrJy2U7_.js → funnel-chart-options.config-C_VjTOvD.js} +20 -5
  130. package/components/funnel-chart-options.config-D7H7gFcx.cjs +20 -0
  131. package/components/get-css-variable-BEYG097C.js +1446 -0
  132. package/components/get-css-variable-BZxY4IOa.cjs +35 -0
  133. package/components/get-css-variable-DLiZYZEi.cjs +24 -0
  134. package/components/{get-css-variable-CdwF98oh.js → get-css-variable-YlLiVgo8.js} +35 -35
  135. package/components/grid/index.cjs +49 -43
  136. package/components/grid/index.js +1878 -2610
  137. package/components/{heat-map-options.config-CmL87j1j.js → heat-map-options.config-BnLWe8jS.js} +41 -35
  138. package/components/heat-map-options.config-DVH-Bb5-.cjs +20 -0
  139. package/components/heat-table-options.config-B12JEYnp.cjs +20 -0
  140. package/components/{heat-table-options.config-BrCYAgYD.js → heat-table-options.config-CUsDdgUr.js} +88 -60
  141. package/components/helpers-DXQwEH1P.cjs +20 -0
  142. package/components/helpers-v1bPALRP.js +91 -0
  143. package/components/hexbin-map-options.config-DZERRhM8.cjs +20 -0
  144. package/components/{hexbin-map-options.config-BguV1w8q.js → hexbin-map-options.config-F-7uCqxb.js} +38 -20
  145. package/components/{index-BNAmjOkm.cjs → index-BPNsFiyq.cjs} +4 -4
  146. package/components/index-CDi4fe3N.js +1716 -0
  147. package/components/index-CQ9ck-BO.cjs +249 -0
  148. package/components/index-CXn67vdn.cjs +121 -0
  149. package/components/{index-haa7WNrl.js → index-CdIUfo-L.js} +481 -453
  150. package/components/index-Cz9vSXy6.cjs +20 -0
  151. package/components/{index-DdyZ2g5L.js → index-D0GBF6tg.js} +104 -94
  152. package/components/index-Dn0j_pcR.cjs +20 -0
  153. package/components/{index-CqKpf0B8.js → index-Do7O9azB.js} +123 -112
  154. package/components/index-E239Dotg.js +1735 -0
  155. package/components/index.cjs +1 -1
  156. package/components/index.js +20 -18
  157. package/components/item-options-configs.cjs +1 -1
  158. package/components/item-options-configs.js +37 -37
  159. package/components/{line-chart-options.config-BhirTGqD.js → line-chart-options.config-DB3IsXXr.js} +28 -13
  160. package/components/line-chart-options.config-DSugoe0t.cjs +20 -0
  161. package/components/{localize-CcDpq940.js → localize-BX7q0S0M.js} +10 -10
  162. package/components/{localize-C4zNlrwK.cjs → localize-r7ALOUy_.cjs} +1 -1
  163. package/components/{marker-map-options.config-Bx17jmiq.js → marker-map-options.config-DPJ955tt.js} +1 -1
  164. package/components/{marker-map-options.config-CvhCylSC.cjs → marker-map-options.config-_FYZzRwA.cjs} +1 -1
  165. package/components/pivot-table-options.config-BiJXKSFR.cjs +20 -0
  166. package/components/{pivot-table-options.config-CFc7y0IT.js → pivot-table-options.config-DNK_AIG7.js} +24 -15
  167. package/components/pyramid-chart-options.config-C4zbFS26.cjs +20 -0
  168. package/components/{pyramid-chart-options.config-2Waxb11l.js → pyramid-chart-options.config-CcVMatYx.js} +43 -29
  169. package/components/{radar-chart-options.config-CPN5fOl8.js → radar-chart-options.config-CUZn_3Fd.js} +23 -11
  170. package/components/radar-chart-options.config-EqQu6PTh.cjs +20 -0
  171. package/components/{regular-table-options.config-CFKCJQK1.js → regular-table-options.config-BoLZsBry.js} +23 -17
  172. package/components/{regular-table-options.config-YRuoijIk.cjs → regular-table-options.config-DTx3RTnS.cjs} +1 -1
  173. package/components/{route-map-options.config-CyolTJfK.js → route-map-options.config-CN86T7c0.js} +109 -87
  174. package/components/route-map-options.config-D7NJePTu.cjs +20 -0
  175. package/components/{sankey-diagram-options.config-D7OSvSqm.cjs → sankey-diagram-options.config-RFB83YLZ.cjs} +1 -1
  176. package/components/{sankey-diagram-options.config-Ldjk84ro.js → sankey-diagram-options.config-tVLKy_Zn.js} +10 -7
  177. package/components/scatter-plot-options.config-CFfGJXsV.cjs +20 -0
  178. package/components/{scatter-plot-options.config-CfxEfkQ1.js → scatter-plot-options.config-Corlzno1.js} +86 -56
  179. package/components/{search-filter-options.config-Oqco9BKj.cjs → search-filter-options.config-BCaDlYqZ.cjs} +1 -1
  180. package/components/{search-filter-options.config-C0syQmP4.js → search-filter-options.config-BE3JhR-F.js} +6 -3
  181. package/components/{set-locale-hKTMz37h.js → set-locale-Dp3N_gXN.js} +8 -1
  182. package/components/{slicer-filter-options.config-DmOe3440.js → slicer-filter-options.config-3JZZcw5C.js} +18 -9
  183. package/components/slicer-filter-options.config-DNI-XevE.cjs +20 -0
  184. package/components/{slider-filter-options.config-B1M8RcDs.js → slider-filter-options.config-DH4SS8wH.js} +1 -1
  185. package/components/{slider-filter-options.config-k45I-t6G.cjs → slider-filter-options.config-_8Z2zKmU.cjs} +1 -1
  186. package/components/slot-contents-picker/index.cjs +33 -33
  187. package/components/slot-contents-picker/index.js +205 -194
  188. package/components/slot-menu/index.cjs +12 -12
  189. package/components/slot-menu/index.js +184 -171
  190. package/components/slot-menu-list/index.cjs +3 -3
  191. package/components/slot-menu-list/index.js +103 -97
  192. package/components/speedometer-chart-options.config-BX9LTQBH.cjs +20 -0
  193. package/components/{speedometer-chart-options.config-CzOmuEF8.js → speedometer-chart-options.config-SL581yOa.js} +53 -31
  194. package/components/{spike-map-options.config-Cbt1YUw6.js → spike-map-options.config-C5KewecZ.js} +122 -91
  195. package/components/spike-map-options.config-DoBFXPmN.cjs +20 -0
  196. package/components/{sunburst-chart-options.config-Yrxc2i57.cjs → sunburst-chart-options.config-AbNjWS6t.cjs} +1 -1
  197. package/components/{sunburst-chart-options.config-_dyLQxPJ.js → sunburst-chart-options.config-CNauGQJv.js} +20 -9
  198. package/components/{symbol-map-options.config-BORL1NSU.js → symbol-map-options.config-DdDA4aa7.js} +20 -11
  199. package/components/symbol-map-options.config-m-lwLTtu.cjs +20 -0
  200. package/components/treemap-chart-options.config-C0Q9aQ1Z.cjs +20 -0
  201. package/components/{treemap-chart-options.config-B9i9qIm_.js → treemap-chart-options.config-D5AJaF_u.js} +37 -20
  202. package/components/utils.cjs +1 -1
  203. package/components/utils.js +97 -94
  204. package/components/{video-options.config-B0asgYt8.cjs → video-options.config-CGsDTwHc.cjs} +1 -1
  205. package/components/{video-options.config-UX-9MDfS.js → video-options.config-Dk36zJ1B.js} +10 -7
  206. package/components/widget-menu/index.cjs +51 -0
  207. package/components/widget-menu/index.d.ts +8 -0
  208. package/components/widget-menu/index.js +211 -0
  209. package/components/widget-menu/widget-menu.d.ts +77 -0
  210. package/components/{wordcloud-chart-options.config-BKtJT8Va.cjs → wordcloud-chart-options.config-vGfCW8kE.cjs} +1 -1
  211. package/components/{wordcloud-chart-options.config-BoB_KuhA.js → wordcloud-chart-options.config-w2NUIWVA.js} +7 -4
  212. package/custom-elements.json +133 -20
  213. package/index.d.ts +1 -0
  214. package/package.json +6 -1
  215. package/types.d.ts +4 -0
  216. package/components/area-chart-options.config-Bl8bhhOo.cjs +0 -20
  217. package/components/bar-chart-options.config-CePAqM83.cjs +0 -20
  218. package/components/box-plot-options.config-BVNrV2eD.cjs +0 -20
  219. package/components/bubble-chart-options.config-BDgOe3GQ.cjs +0 -20
  220. package/components/calculate-data-item-icon-DMDhKq_m.js +0 -147
  221. package/components/calculate-data-item-icon-DtVGbet3.cjs +0 -20
  222. package/components/choropleth-map-options.config-CWJACFd0.cjs +0 -20
  223. package/components/circular-gauge-options.config-BMxgq3zH.cjs +0 -20
  224. package/components/color-Czp4Im5q.cjs +0 -20
  225. package/components/color-range-utils-DYYR-iwx.cjs +0 -20
  226. package/components/column-chart-options.config-BV9R3ssH.cjs +0 -20
  227. package/components/conditional-number-options.config-Co099Qfm.cjs +0 -20
  228. package/components/donut-chart-options.config-BQyPgnC9.cjs +0 -20
  229. package/components/en-D3ihEGXg.js +0 -1483
  230. package/components/en-DZcn_iz_.cjs +0 -20
  231. package/components/focusable-QLh-LlNt.cjs +0 -20
  232. package/components/funnel-chart-options.config-DrP4AFgk.cjs +0 -20
  233. package/components/get-css-variable-COd1d84B.cjs +0 -24
  234. package/components/heat-map-options.config-CIHnPdYE.cjs +0 -20
  235. package/components/heat-table-options.config-DTlZRc_i.cjs +0 -20
  236. package/components/helpers-9I0oLoUB.cjs +0 -20
  237. package/components/helpers-bR8Ibjqh.js +0 -79
  238. package/components/hexbin-map-options.config-CKnn3VAB.cjs +0 -20
  239. package/components/index-BekTY3Em.cjs +0 -121
  240. package/components/index-CFL6gmIu.cjs +0 -20
  241. package/components/index-DNPULp4A.js +0 -1755
  242. package/components/index-DvkzMbLt.cjs +0 -249
  243. package/components/line-chart-options.config-Cqwou5u6.cjs +0 -20
  244. package/components/pivot-table-options.config-uZDAertf.cjs +0 -20
  245. package/components/pyramid-chart-options.config-DoGfEvzU.cjs +0 -20
  246. package/components/radar-chart-options.config-CtNUMN1l.cjs +0 -20
  247. package/components/route-map-options.config-CVTk5RVL.cjs +0 -20
  248. package/components/scatter-plot-options.config-5gN7pMTm.cjs +0 -20
  249. package/components/slicer-filter-options.config-CrusP6a0.cjs +0 -20
  250. package/components/speedometer-chart-options.config-B4ceg_qI.cjs +0 -20
  251. package/components/spike-map-options.config-BkkDqb4g.cjs +0 -20
  252. package/components/symbol-map-options.config-NpBKm64d.cjs +0 -20
  253. package/components/treemap-chart-options.config-x4J54WSw.cjs +0 -20
@@ -0,0 +1,1716 @@
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 we = (s, e, t) => e.has(s) || Fe("Cannot " + t);
24
+ var r = (s, e, t) => (we(s, e, "read from private field"), t ? t.call(s) : e.get(s)), f = (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), h = (s, e, t, i) => (we(s, e, "write to private field"), i ? i.call(s, t) : e.set(s, t), t), P = (s, e, t) => (we(s, e, "access private method"), t);
25
+ var me = (s, e, t, i) => ({
26
+ set _(n) {
27
+ h(s, e, n, t);
28
+ },
29
+ get _() {
30
+ return r(s, e, i);
31
+ }
32
+ });
33
+ var be = 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
+ }, ge = typeof window > "u" || "Deno" in globalThis;
50
+ function Q() {
51
+ }
52
+ function ze(s, e) {
53
+ return typeof s == "function" ? s(e) : s;
54
+ }
55
+ function Be(s) {
56
+ return typeof s == "number" && s >= 0 && s !== 1 / 0;
57
+ }
58
+ function We(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: u,
73
+ queryKey: o,
74
+ stale: a
75
+ } = s;
76
+ if (o) {
77
+ if (i) {
78
+ if (e.queryHash !== qe(o, e.options))
79
+ return !1;
80
+ } else if (!ce(e.queryKey, o))
81
+ return !1;
82
+ }
83
+ if (t !== "all") {
84
+ const l = e.isActive();
85
+ if (t === "active" && !l || t === "inactive" && l)
86
+ return !1;
87
+ }
88
+ return !(typeof a == "boolean" && e.isStale() !== a || n && n !== e.state.fetchStatus || u && !u(e));
89
+ }
90
+ function De(s, e) {
91
+ const { exact: t, status: i, predicate: n, mutationKey: u } = s;
92
+ if (u) {
93
+ if (!e.options.mutationKey)
94
+ return !1;
95
+ if (t) {
96
+ if (he(e.options.mutationKey) !== he(u))
97
+ return !1;
98
+ } else if (!ce(e.options.mutationKey, u))
99
+ return !1;
100
+ }
101
+ return !(i && e.state.status !== i || n && !n(e));
102
+ }
103
+ function qe(s, e) {
104
+ return ((e == null ? void 0 : e.queryKeyHashFn) || he)(s);
105
+ }
106
+ function he(s) {
107
+ return JSON.stringify(
108
+ s,
109
+ (e, t) => Ce(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 = Ee(s) && Ee(e);
119
+ if (t || Ce(s) && Ce(e)) {
120
+ const i = t ? s : Object.keys(s), n = i.length, u = t ? e : Object.keys(e), o = u.length, a = t ? [] : {};
121
+ let l = 0;
122
+ for (let y = 0; y < o; y++) {
123
+ const m = t ? y : u[y];
124
+ (!t && i.includes(m) || t) && s[m] === void 0 && e[m] === void 0 ? (a[m] = void 0, l++) : (a[m] = He(s[m], e[m]), a[m] === s[m] && s[m] !== void 0 && l++);
125
+ }
126
+ return n === o && l === n ? s : a;
127
+ }
128
+ return e;
129
+ }
130
+ function Ee(s) {
131
+ return Array.isArray(s) && s.length === Object.keys(s).length;
132
+ }
133
+ function Ce(s) {
134
+ if (!Me(s))
135
+ return !1;
136
+ const e = s.constructor;
137
+ if (e === void 0)
138
+ return !0;
139
+ const t = e.prototype;
140
+ return !(!Me(t) || !t.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(s) !== Object.prototype);
141
+ }
142
+ function Me(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 Oe = Symbol();
162
+ function Ge(s, e) {
163
+ return !s.queryFn && (e != null && e.initialPromise) ? () => e.initialPromise : !s.queryFn || s.queryFn === Oe ? () => Promise.reject(new Error(`Missing queryFn: '${s.queryHash}'`)) : s.queryFn;
164
+ }
165
+ var z, G, Z, Re, st = (Re = class extends be {
166
+ constructor() {
167
+ super();
168
+ f(this, z);
169
+ f(this, G);
170
+ f(this, Z);
171
+ h(this, Z, (e) => {
172
+ if (!ge && 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), h(this, G, void 0));
186
+ }
187
+ setEventListener(e) {
188
+ var t;
189
+ h(this, Z, e), (t = r(this, G)) == null || t.call(this), h(this, G, e((i) => {
190
+ typeof i == "boolean" ? this.setFocused(i) : this.onFocus();
191
+ }));
192
+ }
193
+ setFocused(e) {
194
+ r(this, z) !== e && (h(this, z, 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, z) == "boolean" ? r(this, z) : ((e = globalThis.document) == null ? void 0 : e.visibilityState) !== "hidden";
205
+ }
206
+ }, z = new WeakMap(), G = new WeakMap(), Z = new WeakMap(), Re), Ne = new st(), ee, N, te, Ke, it = (Ke = class extends be {
207
+ constructor() {
208
+ super();
209
+ f(this, ee, !0);
210
+ f(this, N);
211
+ f(this, te);
212
+ h(this, te, (e) => {
213
+ if (!ge && 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), h(this, N, void 0));
227
+ }
228
+ setEventListener(e) {
229
+ var t;
230
+ h(this, te, e), (t = r(this, N)) == null || t.call(this), h(this, N, e(this.setOnline.bind(this)));
231
+ }
232
+ setOnline(e) {
233
+ r(this, ee) !== e && (h(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, u) => {
244
+ s = n, e = u;
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 $e(s) {
278
+ let e = !1, t = 0, i = !1, n;
279
+ const u = rt(), o = (d) => {
280
+ var v;
281
+ i || (p(new _e(d)), (v = s.abort) == null || v.call(s));
282
+ }, a = () => {
283
+ e = !0;
284
+ }, l = () => {
285
+ e = !1;
286
+ }, y = () => Ne.isFocused() && (s.networkMode === "always" || ve.isOnline()) && s.canRun(), m = () => Ve(s.networkMode) && s.canRun(), c = (d) => {
287
+ var v;
288
+ i || (i = !0, (v = s.onSuccess) == null || v.call(s, d), n == null || n(), u.resolve(d));
289
+ }, p = (d) => {
290
+ var v;
291
+ i || (i = !0, (v = s.onError) == null || v.call(s, d), n == null || n(), u.reject(d));
292
+ }, S = () => new Promise((d) => {
293
+ var v;
294
+ n = (A) => {
295
+ (i || y()) && d(A);
296
+ }, (v = s.onPause) == null || v.call(s);
297
+ }).then(() => {
298
+ var d;
299
+ n = void 0, i || (d = s.onContinue) == null || d.call(s);
300
+ }), q = () => {
301
+ if (i)
302
+ return;
303
+ let d;
304
+ const v = t === 0 ? s.initialPromise : void 0;
305
+ try {
306
+ d = v ?? s.fn();
307
+ } catch (A) {
308
+ d = Promise.reject(A);
309
+ }
310
+ Promise.resolve(d).then(c).catch((A) => {
311
+ var j;
312
+ if (i)
313
+ return;
314
+ const M = s.retry ?? (ge ? 0 : 3), g = s.retryDelay ?? nt, D = typeof g == "function" ? g(t, A) : g, K = M === !0 || typeof M == "number" && t < M || typeof M == "function" && M(t, A);
315
+ if (e || !K) {
316
+ p(A);
317
+ return;
318
+ }
319
+ t++, (j = s.onFail) == null || j.call(s, t, A), Ye(D).then(() => y() ? void 0 : S()).then(() => {
320
+ e ? p(A) : q();
321
+ });
322
+ });
323
+ };
324
+ return {
325
+ promise: u,
326
+ cancel: o,
327
+ continue: () => (n == null || n(), u),
328
+ cancelRetry: a,
329
+ continueRetry: l,
330
+ canStart: m,
331
+ start: () => (m() ? q() : S().then(q), u)
332
+ };
333
+ }
334
+ var at = (s) => setTimeout(s, 0);
335
+ function ut() {
336
+ let s = [], e = 0, t = (a) => {
337
+ a();
338
+ }, i = (a) => {
339
+ a();
340
+ }, n = at;
341
+ const u = (a) => {
342
+ e ? s.push(a) : n(() => {
343
+ t(a);
344
+ });
345
+ }, o = () => {
346
+ const a = s;
347
+ s = [], a.length && n(() => {
348
+ i(() => {
349
+ a.forEach((l) => {
350
+ t(l);
351
+ });
352
+ });
353
+ });
354
+ };
355
+ return {
356
+ batch: (a) => {
357
+ let l;
358
+ e++;
359
+ try {
360
+ l = a();
361
+ } finally {
362
+ e--, e || o();
363
+ }
364
+ return l;
365
+ },
366
+ /**
367
+ * All calls to the wrapped function will be batched.
368
+ */
369
+ batchCalls: (a) => (...l) => {
370
+ u(() => {
371
+ a(...l);
372
+ });
373
+ },
374
+ schedule: u,
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: (a) => {
380
+ t = a;
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: (a) => {
387
+ i = a;
388
+ },
389
+ setScheduler: (a) => {
390
+ n = a;
391
+ }
392
+ };
393
+ }
394
+ var F = ut(), B, je, Je = (je = class {
395
+ constructor() {
396
+ f(this, B);
397
+ }
398
+ destroy() {
399
+ this.clearGcTimeout();
400
+ }
401
+ scheduleGc() {
402
+ this.clearGcTimeout(), Be(this.gcTime) && h(this, B, setTimeout(() => {
403
+ this.optionalRemove();
404
+ }, this.gcTime));
405
+ }
406
+ updateGcTime(s) {
407
+ this.gcTime = Math.max(
408
+ this.gcTime || 0,
409
+ s ?? (ge ? 1 / 0 : 5 * 60 * 1e3)
410
+ );
411
+ }
412
+ clearGcTimeout() {
413
+ r(this, B) && (clearTimeout(r(this, B)), h(this, B, void 0));
414
+ }
415
+ }, B = new WeakMap(), je), se, ie, E, W, C, le, X, T, L, ke, ot = (ke = class extends Je {
416
+ constructor(e) {
417
+ super();
418
+ f(this, T);
419
+ f(this, se);
420
+ f(this, ie);
421
+ f(this, E);
422
+ f(this, W);
423
+ f(this, C);
424
+ f(this, le);
425
+ f(this, X);
426
+ h(this, X, !1), h(this, le, e.defaultOptions), this.setOptions(e.options), this.observers = [], h(this, W, e.client), h(this, E, r(this, W).getQueryCache()), this.queryKey = e.queryKey, this.queryHash = e.queryHash, h(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, C)) == 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, E).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, C)) == null ? void 0 : i.promise;
456
+ return (n = r(this, C)) == null || n.cancel(e), t ? t.then(Q).catch(Q) : 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 === Oe || 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 || !We(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, C)) == 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, C)) == null || t.continue();
489
+ }
490
+ addObserver(e) {
491
+ this.observers.includes(e) || (this.observers.push(e), this.clearGcTimeout(), r(this, E).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, C) && (r(this, X) ? r(this, C).cancel({ revert: !0 }) : r(this, C).cancelRetry()), this.scheduleGc()), r(this, E).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 l, y, 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, C))
508
+ return r(this, C).continueRetry(), r(this, C).promise;
509
+ }
510
+ if (e && this.setOptions(e), !this.options.queryFn) {
511
+ const c = this.observers.find((p) => p.options.queryFn);
512
+ c && this.setOptions(c.options);
513
+ }
514
+ const i = new AbortController(), n = (c) => {
515
+ Object.defineProperty(c, "signal", {
516
+ enumerable: !0,
517
+ get: () => (h(this, X, !0), i.signal)
518
+ });
519
+ }, u = () => {
520
+ const c = Ge(this.options, t), p = {
521
+ client: r(this, W),
522
+ queryKey: this.queryKey,
523
+ meta: this.meta
524
+ };
525
+ return n(p), h(this, X, !1), this.options.persister ? this.options.persister(
526
+ c,
527
+ p,
528
+ this
529
+ ) : c(p);
530
+ }, o = {
531
+ fetchOptions: t,
532
+ options: this.options,
533
+ queryKey: this.queryKey,
534
+ client: r(this, W),
535
+ state: this.state,
536
+ fetchFn: u
537
+ };
538
+ n(o), (l = this.options.behavior) == null || l.onFetch(
539
+ o,
540
+ this
541
+ ), h(this, ie, this.state), (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((y = o.fetchOptions) == null ? void 0 : y.meta)) && P(this, T, L).call(this, { type: "fetch", meta: (m = o.fetchOptions) == null ? void 0 : m.meta });
542
+ const a = (c) => {
543
+ var p, S, q, d;
544
+ Pe(c) && c.silent || P(this, T, L).call(this, {
545
+ type: "error",
546
+ error: c
547
+ }), Pe(c) || ((S = (p = r(this, E).config).onError) == null || S.call(
548
+ p,
549
+ c,
550
+ this
551
+ ), (d = (q = r(this, E).config).onSettled) == null || d.call(
552
+ q,
553
+ this.state.data,
554
+ c,
555
+ this
556
+ )), this.scheduleGc();
557
+ };
558
+ return h(this, C, $e({
559
+ initialPromise: t == null ? void 0 : t.initialPromise,
560
+ fn: o.fetchFn,
561
+ abort: i.abort.bind(i),
562
+ onSuccess: (c) => {
563
+ var p, S, q, d;
564
+ if (c === void 0) {
565
+ a(new Error(`${this.queryHash} data is undefined`));
566
+ return;
567
+ }
568
+ try {
569
+ this.setData(c);
570
+ } catch (v) {
571
+ a(v);
572
+ return;
573
+ }
574
+ (S = (p = r(this, E).config).onSuccess) == null || S.call(p, c, this), (d = (q = r(this, E).config).onSettled) == null || d.call(
575
+ q,
576
+ c,
577
+ this.state.error,
578
+ this
579
+ ), this.scheduleGc();
580
+ },
581
+ onError: a,
582
+ onFail: (c, p) => {
583
+ P(this, T, L).call(this, { type: "failed", failureCount: c, error: p });
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: o.options.retry,
592
+ retryDelay: o.options.retryDelay,
593
+ networkMode: o.options.networkMode,
594
+ canRun: () => !0
595
+ })), r(this, C).start();
596
+ }
597
+ }, se = new WeakMap(), ie = new WeakMap(), E = new WeakMap(), W = new WeakMap(), C = 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
+ ...ht(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, E).notify({ query: this, type: "updated", action: e });
665
+ });
666
+ }, ke);
667
+ function ht(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, Ue, lt = (Ue = class extends be {
696
+ constructor(e = {}) {
697
+ super();
698
+ f(this, k);
699
+ this.config = e, h(this, k, /* @__PURE__ */ new Map());
700
+ }
701
+ build(e, t, i) {
702
+ const n = t.queryKey, u = t.queryHash ?? qe(n, t);
703
+ let o = this.get(u);
704
+ return o || (o = new ot({
705
+ client: e,
706
+ queryKey: n,
707
+ queryHash: u,
708
+ options: e.defaultQueryOptions(t),
709
+ state: i,
710
+ defaultOptions: e.getQueryDefaults(n)
711
+ }), this.add(o)), o;
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(), Ue), U, O, Y, I, H, Ie, dt = (Ie = class extends Je {
768
+ constructor(e) {
769
+ super();
770
+ f(this, I);
771
+ f(this, U);
772
+ f(this, O);
773
+ f(this, Y);
774
+ this.mutationId = e.mutationId, h(this, O, e.mutationCache), h(this, U, []), 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, U).includes(e) || (r(this, U).push(e), this.clearGcTimeout(), r(this, O).notify({
784
+ type: "observerAdded",
785
+ mutation: this,
786
+ observer: e
787
+ }));
788
+ }
789
+ removeObserver(e) {
790
+ h(this, U, r(this, U).filter((t) => t !== e)), this.scheduleGc(), r(this, O).notify({
791
+ type: "observerRemoved",
792
+ mutation: this,
793
+ observer: e
794
+ });
795
+ }
796
+ optionalRemove() {
797
+ r(this, U).length || (this.state.status === "pending" ? this.scheduleGc() : r(this, O).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 u, o, a, l, y, m, c, p, S, q, d, v, A, M, g, D, K, j, fe, oe;
806
+ const t = () => {
807
+ P(this, I, H).call(this, { type: "continue" });
808
+ };
809
+ h(this, Y, $e({
810
+ fn: () => this.options.mutationFn ? this.options.mutationFn(e) : Promise.reject(new Error("No mutationFn found")),
811
+ onFail: (w, ye) => {
812
+ P(this, I, H).call(this, { type: "failed", failureCount: w, 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, O).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 ((o = (u = r(this, O).config).onMutate) == null ? void 0 : o.call(
829
+ u,
830
+ e,
831
+ this
832
+ ));
833
+ const ye = await ((l = (a = this.options).onMutate) == null ? void 0 : l.call(a, 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 w = await r(this, Y).start();
842
+ return await ((m = (y = r(this, O).config).onSuccess) == null ? void 0 : m.call(
843
+ y,
844
+ w,
845
+ e,
846
+ this.state.context,
847
+ this
848
+ )), await ((p = (c = this.options).onSuccess) == null ? void 0 : p.call(c, w, e, this.state.context)), await ((q = (S = r(this, O).config).onSettled) == null ? void 0 : q.call(
849
+ S,
850
+ w,
851
+ null,
852
+ this.state.variables,
853
+ this.state.context,
854
+ this
855
+ )), await ((v = (d = this.options).onSettled) == null ? void 0 : v.call(d, w, null, e, this.state.context)), P(this, I, H).call(this, { type: "success", data: w }), w;
856
+ } catch (w) {
857
+ try {
858
+ throw await ((M = (A = r(this, O).config).onError) == null ? void 0 : M.call(
859
+ A,
860
+ w,
861
+ e,
862
+ this.state.context,
863
+ this
864
+ )), await ((D = (g = this.options).onError) == null ? void 0 : D.call(
865
+ g,
866
+ w,
867
+ e,
868
+ this.state.context
869
+ )), await ((j = (K = r(this, O).config).onSettled) == null ? void 0 : j.call(
870
+ K,
871
+ void 0,
872
+ w,
873
+ this.state.variables,
874
+ this.state.context,
875
+ this
876
+ )), await ((oe = (fe = this.options).onSettled) == null ? void 0 : oe.call(
877
+ fe,
878
+ void 0,
879
+ w,
880
+ e,
881
+ this.state.context
882
+ )), w;
883
+ } finally {
884
+ P(this, I, H).call(this, { type: "error", error: w });
885
+ }
886
+ } finally {
887
+ r(this, O).runNext(this);
888
+ }
889
+ }
890
+ }, U = new WeakMap(), O = 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, U).forEach((i) => {
946
+ i.onMutationUpdate(e);
947
+ }), r(this, O).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 be {
968
+ constructor(e = {}) {
969
+ super();
970
+ f(this, x);
971
+ f(this, R);
972
+ f(this, de);
973
+ this.config = e, h(this, x, /* @__PURE__ */ new Set()), h(this, R, /* @__PURE__ */ new Map()), h(this, de, 0);
974
+ }
975
+ build(e, t, i) {
976
+ const n = new dt({
977
+ mutationCache: this,
978
+ mutationId: ++me(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 = pe(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 = pe(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 = pe(e);
1009
+ if (typeof t == "string") {
1010
+ const i = r(this, R).get(t), n = i == null ? void 0 : i.find(
1011
+ (u) => u.state.status === "pending"
1012
+ );
1013
+ return !n || n === e;
1014
+ } else
1015
+ return !0;
1016
+ }
1017
+ runNext(e) {
1018
+ var i;
1019
+ const t = pe(e);
1020
+ if (typeof t == "string") {
1021
+ const n = (i = r(this, R).get(t)) == null ? void 0 : i.find((u) => u !== e && u.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(Q))
1057
+ )
1058
+ );
1059
+ }
1060
+ }, x = new WeakMap(), R = new WeakMap(), de = new WeakMap(), Le);
1061
+ function pe(s) {
1062
+ var e;
1063
+ return (e = s.options.scope) == null ? void 0 : e.id;
1064
+ }
1065
+ function Qe(s) {
1066
+ return {
1067
+ onFetch: (e, t) => {
1068
+ var m, c, p, S, q;
1069
+ const i = e.options, n = (p = (c = (m = e.fetchOptions) == null ? void 0 : m.meta) == null ? void 0 : c.fetchMore) == null ? void 0 : p.direction, u = ((S = e.state.data) == null ? void 0 : S.pages) || [], o = ((q = e.state.data) == null ? void 0 : q.pageParams) || [];
1070
+ let a = { pages: [], pageParams: [] }, l = 0;
1071
+ const y = async () => {
1072
+ let d = !1;
1073
+ const v = (g) => {
1074
+ Object.defineProperty(g, "signal", {
1075
+ enumerable: !0,
1076
+ get: () => (e.signal.aborted ? d = !0 : e.signal.addEventListener("abort", () => {
1077
+ d = !0;
1078
+ }), e.signal)
1079
+ });
1080
+ }, A = Ge(e.options, e.fetchOptions), M = async (g, D, K) => {
1081
+ if (d)
1082
+ return Promise.reject();
1083
+ if (D == null && g.pages.length)
1084
+ return Promise.resolve(g);
1085
+ const j = {
1086
+ client: e.client,
1087
+ queryKey: e.queryKey,
1088
+ pageParam: D,
1089
+ direction: K ? "backward" : "forward",
1090
+ meta: e.options.meta
1091
+ };
1092
+ v(j);
1093
+ const fe = await A(
1094
+ j
1095
+ ), { maxPages: oe } = e.options, w = K ? tt : et;
1096
+ return {
1097
+ pages: w(g.pages, fe, oe),
1098
+ pageParams: w(g.pageParams, D, oe)
1099
+ };
1100
+ };
1101
+ if (n && u.length) {
1102
+ const g = n === "backward", D = g ? mt : Te, K = {
1103
+ pages: u,
1104
+ pageParams: o
1105
+ }, j = D(i, K);
1106
+ a = await M(K, j, g);
1107
+ } else {
1108
+ const g = s ?? u.length;
1109
+ do {
1110
+ const D = l === 0 ? o[0] ?? i.initialPageParam : Te(i, a);
1111
+ if (l > 0 && D == null)
1112
+ break;
1113
+ a = await M(a, D), l++;
1114
+ } while (l < g);
1115
+ }
1116
+ return a;
1117
+ };
1118
+ e.options.persister ? e.fetchFn = () => {
1119
+ var d, v;
1120
+ return (v = (d = e.options).persister) == null ? void 0 : v.call(
1121
+ d,
1122
+ y,
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 = y;
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 mt(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 b, V, _, re, ne, $, ae, ue, xe, pt = (xe = class {
1149
+ constructor(s = {}) {
1150
+ f(this, b);
1151
+ f(this, V);
1152
+ f(this, _);
1153
+ f(this, re);
1154
+ f(this, ne);
1155
+ f(this, $);
1156
+ f(this, ae);
1157
+ f(this, ue);
1158
+ h(this, b, s.queryCache || new lt()), h(this, V, s.mutationCache || new yt()), h(this, _, s.defaultOptions || {}), h(this, re, /* @__PURE__ */ new Map()), h(this, ne, /* @__PURE__ */ new Map()), h(this, $, 0);
1159
+ }
1160
+ mount() {
1161
+ me(this, $)._++, r(this, $) === 1 && (h(this, ae, Ne.subscribe(async (s) => {
1162
+ s && (await this.resumePausedMutations(), r(this, b).onFocus());
1163
+ })), h(this, ue, ve.subscribe(async (s) => {
1164
+ s && (await this.resumePausedMutations(), r(this, b).onOnline());
1165
+ })));
1166
+ }
1167
+ unmount() {
1168
+ var s, e;
1169
+ me(this, $)._--, r(this, $) === 0 && ((s = r(this, ae)) == null || s.call(this), h(this, ae, void 0), (e = r(this, ue)) == null || e.call(this), h(this, ue, void 0));
1170
+ }
1171
+ isFetching(s) {
1172
+ return r(this, b).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, b).get(e.queryHash)) == null ? void 0 : t.state.data;
1188
+ }
1189
+ ensureQueryData(s) {
1190
+ const e = this.defaultQueryOptions(s), t = r(this, b).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, b).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, b).get(
1201
+ i.queryHash
1202
+ ), u = n == null ? void 0 : n.state.data, o = ze(e, u);
1203
+ if (o !== void 0)
1204
+ return r(this, b).build(this, i).setData(o, { ...t, manual: !0 });
1205
+ }
1206
+ setQueriesData(s, e, t) {
1207
+ return F.batch(
1208
+ () => r(this, b).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, b).get(
1218
+ e.queryHash
1219
+ )) == null ? void 0 : t.state;
1220
+ }
1221
+ removeQueries(s) {
1222
+ const e = r(this, b);
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, b);
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, b).findAll(s).map((n) => n.cancel(t))
1244
+ );
1245
+ return Promise.all(i).then(Q).catch(Q);
1246
+ }
1247
+ invalidateQueries(s, e = {}) {
1248
+ return F.batch(() => (r(this, b).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, b).findAll(s).filter((n) => !n.isDisabled()).map((n) => {
1264
+ let u = n.fetch(void 0, t);
1265
+ return t.throwOnError || (u = u.catch(Q)), n.state.fetchStatus === "paused" ? Promise.resolve() : u;
1266
+ })
1267
+ );
1268
+ return Promise.all(i).then(Q);
1269
+ }
1270
+ fetchQuery(s) {
1271
+ const e = this.defaultQueryOptions(s);
1272
+ e.retry === void 0 && (e.retry = !1);
1273
+ const t = r(this, b).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(Q).catch(Q);
1280
+ }
1281
+ fetchInfiniteQuery(s) {
1282
+ return s.behavior = Qe(s.pages), this.fetchQuery(s);
1283
+ }
1284
+ prefetchInfiniteQuery(s) {
1285
+ return this.fetchInfiniteQuery(s).then(Q).catch(Q);
1286
+ }
1287
+ ensureInfiniteQueryData(s) {
1288
+ return s.behavior = Qe(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, b);
1295
+ }
1296
+ getMutationCache() {
1297
+ return r(this, V);
1298
+ }
1299
+ getDefaultOptions() {
1300
+ return r(this, _);
1301
+ }
1302
+ setDefaultOptions(s) {
1303
+ h(this, _, s);
1304
+ }
1305
+ setQueryDefaults(s, e) {
1306
+ r(this, re).set(he(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(he(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 = qe(
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 === Oe && (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, b).clear(), r(this, V).clear();
1353
+ }
1354
+ }, b = new WeakMap(), V = new WeakMap(), _ = new WeakMap(), re = new WeakMap(), ne = new WeakMap(), $ = new WeakMap(), ae = new WeakMap(), ue = new WeakMap(), xe);
1355
+ class J {
1356
+ constructor(e = {}) {
1357
+ this.availableDatasets = [], 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 pt({
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}`, o = {
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, o.body = JSON.stringify(t));
1421
+ try {
1422
+ const a = await fetch(n, o);
1423
+ if (!a.ok) {
1424
+ const l = await a.json().catch(() => null);
1425
+ throw a.status === 401 || a.status === 403 ? new Error(
1426
+ "Authentication failed. Please check your API token."
1427
+ ) : a.status === 404 ? new Error(`Resource not found: ${e}`) : a.status === 429 ? new Error("Rate limit exceeded. Please try again later.") : new Error(
1428
+ (l == null ? void 0 : l.message) || `API request failed with status ${a.status}`
1429
+ );
1430
+ }
1431
+ return await a.json();
1432
+ } catch (a) {
1433
+ throw console.error(`API request to ${e} failed:`, a), a instanceof Error && (a.endpoint = e, a.timestamp = (/* @__PURE__ */ new Date()).toISOString()), a;
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 u = {
1447
+ action: "get",
1448
+ version: this.apiVersion,
1449
+ find: {
1450
+ where: {
1451
+ type: "dataset"
1452
+ },
1453
+ limit: i,
1454
+ offset: t
1455
+ }
1456
+ }, o = await this.fetchApi("/securable", u);
1457
+ return {
1458
+ data: (o == null ? void 0 : o.rows) ?? [],
1459
+ pagination: {
1460
+ offset: t,
1461
+ limit: i,
1462
+ total: (o == null ? void 0 : o.count) ?? 0,
1463
+ pages: Math.ceil(((o == null ? void 0 : o.count) ?? 0) / i)
1464
+ }
1465
+ };
1466
+ }
1467
+ });
1468
+ }
1469
+ /**
1470
+ * Search datasets by name or description
1471
+ * @param query - Search query
1472
+ * @returns List of matching datasets
1473
+ */
1474
+ async searchDatasets(e, t) {
1475
+ if (!e)
1476
+ return { data: [] };
1477
+ const i = ["datasets", "search", e, t];
1478
+ return await this.queryClient.fetchQuery({
1479
+ queryKey: i,
1480
+ queryFn: async () => {
1481
+ const n = {
1482
+ action: "get",
1483
+ version: this.apiVersion,
1484
+ find: {
1485
+ where: {
1486
+ type: "dataset"
1487
+ }
1488
+ }
1489
+ };
1490
+ (e == null ? void 0 : e.length) > 0 && (n.find.search = {
1491
+ match_types: ["name"],
1492
+ keyphrase: e
1493
+ }), 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);
1494
+ const u = await this.fetchApi("/securable", n), o = {
1495
+ data: (u == null ? void 0 : u.rows) ?? []
1496
+ };
1497
+ return t != null && t.limit && (o.pagination = {
1498
+ offset: (t == null ? void 0 : t.offset) ?? 0,
1499
+ limit: t == null ? void 0 : t.limit,
1500
+ total: (u == null ? void 0 : u.count) ?? 0,
1501
+ pages: Math.ceil(((u == null ? void 0 : u.count) ?? 0) / (t == null ? void 0 : t.limit))
1502
+ }), o;
1503
+ }
1504
+ });
1505
+ }
1506
+ /**
1507
+ * Fetches multiple datasets with their associated columns and formulas metadata
1508
+ * @param datasetIds - Array of dataset IDs to fetch
1509
+ * @returns Promise that resolves to an array of DatasetMetadata objects containing:
1510
+ * - Basic dataset info (id, name, description)
1511
+ * - Columns with metadata including joins, hierarchy levels, and currency info
1512
+ * - Formulas with their expressions and currency associations
1513
+ * @throws Error if datasetIds is empty or null
1514
+ */
1515
+ async fetchDatasetsWithColumnsAndFormulas(e) {
1516
+ if (!e || e.length === 0)
1517
+ throw new Error("At least one dataset ID is required");
1518
+ const t = ["datasets", e, this.authKey, this.authToken];
1519
+ return await this.queryClient.fetchQuery({
1520
+ queryKey: t,
1521
+ queryFn: async () => {
1522
+ const i = {
1523
+ action: "get",
1524
+ version: this.apiVersion,
1525
+ find: {
1526
+ where: {
1527
+ type: "dataset",
1528
+ id: {
1529
+ in: e
1530
+ }
1531
+ },
1532
+ attributes: ["name", "id", "description"],
1533
+ include: [
1534
+ {
1535
+ model: "Column",
1536
+ attributes: [
1537
+ "id",
1538
+ "name",
1539
+ "description",
1540
+ "type",
1541
+ "subtype",
1542
+ "format",
1543
+ "hidden",
1544
+ "lowestLevel",
1545
+ "expression",
1546
+ "duration_levels",
1547
+ "duration_format"
1548
+ ],
1549
+ separate: !0,
1550
+ order: [["order", "asc"]],
1551
+ include: [
1552
+ {
1553
+ model: "Column",
1554
+ attributes: [
1555
+ "id",
1556
+ "securable_id",
1557
+ "hierarchy_enabled",
1558
+ "currency_id"
1559
+ ],
1560
+ as: "Joins"
1561
+ },
1562
+ {
1563
+ model: "HierarchyLevel",
1564
+ attributes: ["id", "level", "name"],
1565
+ as: "HierarchyLevels"
1566
+ },
1567
+ {
1568
+ model: "Currency",
1569
+ attributes: ["id", "name", "symbol"],
1570
+ as: "Currency"
1571
+ }
1572
+ ]
1573
+ },
1574
+ {
1575
+ model: "Formula",
1576
+ attributes: [
1577
+ "id",
1578
+ "name",
1579
+ "description",
1580
+ "type",
1581
+ "subtype",
1582
+ "format",
1583
+ "hidden",
1584
+ "lowestLevel",
1585
+ "expression",
1586
+ "duration_levels",
1587
+ "duration_format"
1588
+ ],
1589
+ include: [
1590
+ {
1591
+ model: "Currency",
1592
+ attributes: ["id", "name", "symbol"],
1593
+ as: "Currency"
1594
+ }
1595
+ ]
1596
+ }
1597
+ ]
1598
+ }
1599
+ }, n = await this.fetchApi("/securable", i);
1600
+ return (n == null ? void 0 : n.rows) ?? [];
1601
+ }
1602
+ });
1603
+ }
1604
+ /**
1605
+ * Fetch data from a dataset with filtering
1606
+ * @param datasetId - Dataset ID
1607
+ * @param queryParams - Query parameters (filters, sort, etc.)
1608
+ * @returns Dataset data
1609
+ */
1610
+ async fetchData(e) {
1611
+ if (!e) throw new Error("Query is required");
1612
+ const t = ["data", e];
1613
+ return await this.queryClient.fetchQuery({
1614
+ queryKey: t,
1615
+ queryFn: async () => {
1616
+ const i = {
1617
+ action: "get",
1618
+ version: this.apiVersion,
1619
+ find: {
1620
+ queries: [e]
1621
+ }
1622
+ }, n = await this.fetchApi("/data", i);
1623
+ return {
1624
+ data: (n == null ? void 0 : n.data) || [],
1625
+ performance: (n == null ? void 0 : n.performance) || {}
1626
+ };
1627
+ }
1628
+ });
1629
+ }
1630
+ /**
1631
+ * Refresh all queries
1632
+ */
1633
+ refreshAll() {
1634
+ this.queryClient.refetchQueries();
1635
+ }
1636
+ /**
1637
+ * Invalidate cached data for a dataset
1638
+ * @param datasetId - Dataset ID (optional)
1639
+ */
1640
+ invalidateDatasetData(e) {
1641
+ e ? (this.queryClient.invalidateQueries({ queryKey: ["dataset", e] }), this.queryClient.invalidateQueries({ queryKey: ["columns", e] })) : this.queryClient.invalidateQueries({ queryKey: ["datasets"] });
1642
+ }
1643
+ /**
1644
+ * Invalidate all cached data
1645
+ */
1646
+ invalidateAll() {
1647
+ this.queryClient.clear();
1648
+ }
1649
+ /**
1650
+ * Create a singleton instance
1651
+ * @param config - API configuration
1652
+ * @returns Singleton instance
1653
+ */
1654
+ static getInstance(e = {}) {
1655
+ return J.instance ? Object.keys(e).length > 0 && J.instance.configure(e) : J.instance = new J(e), J.instance;
1656
+ }
1657
+ async fetchDatasetsRecursive(e) {
1658
+ if (!e || e.length === 0)
1659
+ throw new Error("At least one dataset ID is required");
1660
+ const t = [...new Set(e)], i = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map(), u = (o) => {
1661
+ o && !i.has(o) && !t.includes(o) && t.push(o);
1662
+ };
1663
+ for (; t.length > 0; ) {
1664
+ const o = [];
1665
+ for (; t.length > 0 && o.length < 50; ) {
1666
+ const a = t.shift();
1667
+ i.has(a) || o.push(a);
1668
+ }
1669
+ if (o.length !== 0)
1670
+ try {
1671
+ (await this.fetchDatasetsWithColumnsAndFormulas(o)).forEach((l) => {
1672
+ const y = this.postProcessDatasetMetadata(l);
1673
+ i.add(y.id), this.queryClient.setQueryData(["dataset", y.id], y), (y.outgoingJoins ?? []).map((c) => c.securable_id).filter((c) => !!c && c !== y.id).forEach((c) => {
1674
+ u(c);
1675
+ }), n.set(y.id, y), this.availableDatasets.some((c) => c.id === y.id) || this.availableDatasets.push({
1676
+ id: y.id,
1677
+ name: y.name,
1678
+ columns: y.columns
1679
+ });
1680
+ });
1681
+ } catch (a) {
1682
+ console.error("Error fetching datasets recursively:", a);
1683
+ }
1684
+ }
1685
+ return [...n.values()];
1686
+ }
1687
+ postProcessDatasetMetadata(e) {
1688
+ const t = [], i = (e.columns ?? []).map((n) => {
1689
+ const u = n.joins ?? (Array.isArray(n.joins) ? n.joins : []);
1690
+ Array.isArray(u) && u.length > 0 && t.push(...u);
1691
+ const { joins: o, ...a } = n;
1692
+ return {
1693
+ ...a,
1694
+ joins: u
1695
+ };
1696
+ });
1697
+ return {
1698
+ ...e,
1699
+ columns: i,
1700
+ formulas: e.formulas ?? [],
1701
+ outgoingJoins: t,
1702
+ dateLoaded: /* @__PURE__ */ new Date()
1703
+ };
1704
+ }
1705
+ getAvailableDatasets() {
1706
+ return this.availableDatasets;
1707
+ }
1708
+ getLinkedDatasetsIds(e) {
1709
+ const t = this.queryClient.getQueryData(["dataset", e]);
1710
+ return t ? (t.outgoingJoins ?? []).map((i) => i.securable_id).filter((i) => !!i && i !== e) : [];
1711
+ }
1712
+ }
1713
+ const bt = J.getInstance();
1714
+ export {
1715
+ bt as d
1716
+ };