@sisense/sdk-ui 2.22.0 → 2.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/dist/ai.cjs +17 -17
  2. package/dist/ai.js +57 -57
  3. package/dist/analytics-composer/node.cjs +1 -1
  4. package/dist/analytics-composer/node.js +2177 -1176
  5. package/dist/analytics-composer.cjs +47 -47
  6. package/dist/analytics-composer.js +135 -131
  7. package/dist/dimensions-2t18RSZC.cjs +1 -0
  8. package/dist/dimensions-C0BmtTH2.js +204 -0
  9. package/dist/execute-query-CHYTupEo.js +5866 -0
  10. package/dist/execute-query-DmAyVFF5.cjs +1 -0
  11. package/dist/{index-kxX21arA.js → index-DCAC0mJe.js} +18 -1
  12. package/dist/{index-NyouhE_A.cjs → index-Dx6wvLd3.cjs} +1 -1
  13. package/dist/index.cjs +335 -322
  14. package/dist/index.js +15230 -15097
  15. package/dist/index.umd.js +687 -634
  16. package/dist/packages/sdk-ui/src/domains/dashboarding/components/editable-layout/const.d.ts +1 -0
  17. package/dist/packages/sdk-ui/src/domains/dashboarding/components/editable-layout/smart-pointer-sensor.d.ts +17 -0
  18. package/dist/packages/sdk-ui/src/domains/dashboarding/dashboard-model/get-dashboard-model.d.ts +2 -1
  19. package/dist/packages/sdk-ui/src/domains/dashboarding/dashboard-model/use-dashboard-model/dashboard-model-reducer/types.d.ts +24 -2
  20. package/dist/packages/sdk-ui/src/domains/dashboarding/dashboard-model/use-dashboard-model/dashboard-model-reducer/utils.d.ts +2 -1
  21. package/dist/packages/sdk-ui/src/domains/dashboarding/dashboard-model/use-dashboard-model/use-dashboard-persistence.d.ts +2 -1
  22. package/dist/packages/sdk-ui/src/domains/dashboarding/hooks/jtd/jtd-types.d.ts +1 -1
  23. package/dist/packages/sdk-ui/src/domains/dashboarding/hooks/rename-widget/use-widget-renaming.d.ts +34 -0
  24. package/dist/packages/sdk-ui/src/domains/dashboarding/types.d.ts +23 -1
  25. package/dist/packages/sdk-ui/src/domains/dashboarding/use-dashboard-theme.d.ts +1 -1
  26. package/dist/packages/sdk-ui/src/domains/data-browser/add-filter-popover/add-filter-data-browser.d.ts +2 -1
  27. package/dist/packages/sdk-ui/src/domains/data-browser/data-schema-browser/data-schema-browser.d.ts +2 -1
  28. package/dist/packages/sdk-ui/src/domains/data-browser/dimensions-browser/types.d.ts +9 -1
  29. package/dist/packages/sdk-ui/src/domains/formulas/fetch-formula.d.ts +1 -1
  30. package/dist/packages/sdk-ui/src/domains/query-execution/core/execute-query.d.ts +1 -1
  31. package/dist/packages/sdk-ui/src/domains/query-execution/hooks/use-execute-query-by-widget-id/use-execute-query-by-widget-id.d.ts +1 -1
  32. package/dist/packages/sdk-ui/src/domains/query-execution/hooks/use-query-cache/use-query-cache.d.ts +2 -1
  33. package/dist/packages/sdk-ui/src/domains/visualizations/components/boxplot-chart/boxplot-utils.d.ts +1 -1
  34. package/dist/packages/sdk-ui/src/domains/visualizations/components/chart/helpers/get-load-data-function.d.ts +1 -1
  35. package/dist/packages/sdk-ui/src/domains/visualizations/components/chart/restructured-charts/helpers/data-loading.d.ts +1 -1
  36. package/dist/packages/sdk-ui/src/domains/visualizations/components/chart/restructured-charts/types.d.ts +1 -1
  37. package/dist/packages/sdk-ui/src/domains/widgets/change-events.d.ts +73 -0
  38. package/dist/packages/sdk-ui/src/domains/widgets/components/chart-widget/types.d.ts +12 -2
  39. package/dist/packages/sdk-ui/src/domains/widgets/components/pivot-table-widget/types.d.ts +12 -2
  40. package/dist/packages/sdk-ui/src/domains/widgets/components/widget-by-id/translate-dashboard-filters.d.ts +3 -1
  41. package/dist/packages/sdk-ui/src/domains/widgets/components/widget-by-id/translate-widget-data-options.d.ts +1 -1
  42. package/dist/packages/sdk-ui/src/domains/widgets/components/widget-by-id/types.d.ts +1 -1
  43. package/dist/packages/sdk-ui/src/domains/widgets/components/widget-by-id/utils.d.ts +3 -2
  44. package/dist/packages/sdk-ui/src/domains/widgets/event-to-delta.d.ts +17 -0
  45. package/dist/packages/sdk-ui/src/domains/widgets/helpers/header-menu-utils.d.ts +14 -4
  46. package/dist/packages/sdk-ui/src/domains/widgets/helpers/index.d.ts +1 -0
  47. package/dist/packages/sdk-ui/src/domains/widgets/hooks/use-title-renaming.d.ts +27 -0
  48. package/dist/packages/sdk-ui/src/domains/widgets/hooks/use-widget-header-management.d.ts +28 -0
  49. package/dist/packages/sdk-ui/src/domains/widgets/shared/widget-container/widget-container.d.ts +3 -1
  50. package/dist/packages/sdk-ui/src/domains/widgets/shared/widget-header/types.d.ts +31 -0
  51. package/dist/packages/sdk-ui/src/domains/widgets/shared/widget-header/widget-header.d.ts +3 -1
  52. package/dist/packages/sdk-ui/src/infra/api/rest-api.d.ts +4 -0
  53. package/dist/packages/sdk-ui/src/infra/api/types/dashboard-dto.d.ts +1 -1
  54. package/dist/packages/sdk-ui/src/infra/app/client-application.d.ts +5 -231
  55. package/dist/packages/sdk-ui/src/infra/app/helpers.d.ts +16 -0
  56. package/dist/packages/sdk-ui/src/infra/app/settings/settings.d.ts +1 -1
  57. package/dist/packages/sdk-ui/src/infra/app/settings/types/deployment-props.d.ts +3 -0
  58. package/dist/packages/sdk-ui/src/infra/app/settings/types/features.d.ts +2 -1
  59. package/dist/packages/sdk-ui/src/infra/app/types.d.ts +236 -0
  60. package/dist/packages/sdk-ui/src/infra/contexts/sisense-context/sisense-context.d.ts +1 -1
  61. package/dist/packages/sdk-ui/src/infra/contexts/theme-provider/theme-context.d.ts +2 -1
  62. package/dist/packages/sdk-ui/src/infra/decorators/component-decorators/with-tracking/with-tracking.d.ts +1 -1
  63. package/dist/packages/sdk-ui/src/infra/decorators/hook-decorators/with-tracking.d.ts +1 -1
  64. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/de-de.d.ts +17 -0
  65. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/en-us.d.ts +17 -0
  66. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/es-ar.d.ts +17 -0
  67. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/es-es.d.ts +17 -0
  68. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/fr-fr.d.ts +17 -0
  69. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/it-it.d.ts +17 -0
  70. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/ja-jp.d.ts +17 -0
  71. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/ko-kr.d.ts +17 -0
  72. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/nl-nl.d.ts +17 -0
  73. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/pt-br.d.ts +17 -0
  74. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/ru-ru.d.ts +17 -0
  75. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/tr-tr.d.ts +17 -0
  76. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/zh-cn.d.ts +17 -0
  77. package/dist/packages/sdk-ui/src/infra/translation/resources/en.d.ts +17 -0
  78. package/dist/packages/sdk-ui/src/infra/translation/resources/index.d.ts +34 -0
  79. package/dist/packages/sdk-ui/src/modules/ai/use-get-nlq-result.d.ts +1 -0
  80. package/dist/packages/sdk-ui/src/modules/ai/use-get-query-recommendations.d.ts +1 -0
  81. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/chart/helpers/axis-type-detection.d.ts +17 -0
  82. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/chart/helpers/chart-type-schemas.d.ts +37 -0
  83. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/chart/helpers/index.d.ts +9 -0
  84. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/chart/helpers/translate-data-options.d.ts +9 -0
  85. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/chart/helpers/validate-chart-json.d.ts +19 -0
  86. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/chart/translate-chart-from-json.d.ts +42 -0
  87. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/chart/translate-chart-to-json.d.ts +41 -0
  88. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/constructs/dimensions/translate-dimensions-from-json.d.ts +11 -0
  89. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/constructs/dimensions/translate-dimensions-to-json.d.ts +22 -0
  90. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{translate-filters-from-json.d.ts → constructs/filters/translate-filters-from-json.d.ts} +2 -2
  91. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{translate-filters-to-json.d.ts → constructs/filters/translate-filters-to-json.d.ts} +1 -1
  92. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{translate-measures-from-json.d.ts → constructs/measures/translate-measures-from-json.d.ts} +4 -4
  93. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/constructs/measures/translate-measures-to-json.d.ts +22 -0
  94. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/index.d.ts +8 -3
  95. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/pivot-table/helpers/index.d.ts +7 -0
  96. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/pivot-table/helpers/translate-data-options.d.ts +14 -0
  97. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/pivot-table/helpers/validate-pivot-table-json.d.ts +19 -0
  98. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/pivot-table/translate-pivot-table-from-json.d.ts +12 -0
  99. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/pivot-table/translate-pivot-table-to-json.d.ts +12 -0
  100. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/query/constants.d.ts +8 -0
  101. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{translate-query-from-json.d.ts → query/translate-query-from-json.d.ts} +3 -3
  102. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{translate-query-to-jaql.d.ts → query/translate-query-to-jaql.d.ts} +1 -1
  103. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{translate-query-to-json.d.ts → query/translate-query-to-json.d.ts} +2 -2
  104. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/data-options/adapters.d.ts +19 -0
  105. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/data-options/index.d.ts +9 -0
  106. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/data-options/translate-axis-from-json.d.ts +24 -0
  107. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/data-options/translate-axis-to-json.d.ts +18 -0
  108. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{process-function → shared/expression}/custom-formula/process-custom-formula.d.ts +1 -1
  109. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{process-function → shared/expression}/custom-formula/validate-custom-formula.d.ts +13 -0
  110. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{process-function → shared/expression}/execute-function.d.ts +1 -1
  111. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{process-function → shared/expression}/factory-function-processors.d.ts +1 -1
  112. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{process-function → shared/expression}/factory-function-schemas.d.ts +1 -1
  113. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{process-function → shared/expression}/filter-processors.d.ts +1 -1
  114. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/expression/formula-function-schemas.d.ts +25 -0
  115. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{process-function → shared/expression}/process-arg.d.ts +1 -1
  116. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{process-function → shared/expression}/process-node.d.ts +1 -1
  117. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/utils/attribute-helpers.d.ts +50 -0
  118. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/utils/fuzzy-match.d.ts +16 -0
  119. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{parse-compose-code.d.ts → shared/utils/parse-compose-code.d.ts} +1 -1
  120. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/utils/schema-index.d.ts +49 -0
  121. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/utils/translation-helpers.d.ts +31 -0
  122. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/types.d.ts +115 -4
  123. package/dist/packages/sdk-ui/src/modules/analytics-composer/types.d.ts +6 -6
  124. package/dist/packages/sdk-ui/src/props.d.ts +1 -1
  125. package/dist/packages/sdk-ui/src/public-api/alpha.d.ts +1 -1
  126. package/dist/packages/sdk-ui/src/public-api/beta.d.ts +1 -1
  127. package/dist/packages/sdk-ui/src/public-api/internal.d.ts +8 -6
  128. package/dist/packages/sdk-ui/src/public-api/public.d.ts +1 -1
  129. package/dist/packages/sdk-ui/src/public-api/sisense-internal.d.ts +12 -5
  130. package/dist/packages/sdk-ui/src/shared/components/grouped-items-browser/types.d.ts +7 -1
  131. package/dist/packages/sdk-ui/src/shared/components/inline-text-editor/inline-text-editor.d.ts +26 -0
  132. package/dist/packages/sdk-ui/src/shared/components/inline-text-editor/use-blur-on-pointer-down-outside.d.ts +11 -0
  133. package/dist/packages/sdk-ui/src/shared/components/loading-indicator.d.ts +2 -1
  134. package/dist/packages/sdk-ui/src/shared/components/quota-notification/quota-notification.d.ts +2 -2
  135. package/dist/packages/sdk-ui/src/shared/hooks/use-app-settings.d.ts +2 -1
  136. package/dist/packages/sdk-ui/src/shared/hooks/use-quota-notification.d.ts +4 -4
  137. package/dist/packages/sdk-ui/src/shared/hooks/use-should-load.d.ts +1 -1
  138. package/dist/packages/sdk-ui/src/shared/hooks/use-with-change-detection.d.ts +5 -5
  139. package/dist/packages/sdk-ui/src/types.d.ts +3 -3
  140. package/dist/{quota-notification-D6oMJal8.js → quota-notification-CVl0isIV.js} +17901 -16770
  141. package/dist/quota-notification-RAaHp-eO.cjs +713 -0
  142. package/dist/translations/de-de.cjs +1 -1
  143. package/dist/translations/de-de.js +19 -2
  144. package/dist/translations/en-us.cjs +1 -1
  145. package/dist/translations/en-us.js +1 -1
  146. package/dist/translations/es-ar.cjs +1 -1
  147. package/dist/translations/es-ar.js +19 -2
  148. package/dist/translations/es-es.cjs +1 -1
  149. package/dist/translations/es-es.js +19 -2
  150. package/dist/translations/fr-fr.cjs +1 -1
  151. package/dist/translations/fr-fr.js +19 -2
  152. package/dist/translations/it-it.cjs +1 -1
  153. package/dist/translations/it-it.js +19 -2
  154. package/dist/translations/ja-jp.cjs +1 -1
  155. package/dist/translations/ja-jp.js +19 -2
  156. package/dist/translations/ko-kr.cjs +1 -1
  157. package/dist/translations/ko-kr.js +19 -2
  158. package/dist/translations/nl-nl.cjs +1 -1
  159. package/dist/translations/nl-nl.js +19 -2
  160. package/dist/translations/pt-br.cjs +1 -1
  161. package/dist/translations/pt-br.js +19 -2
  162. package/dist/translations/ru-ru.cjs +1 -1
  163. package/dist/translations/ru-ru.js +19 -2
  164. package/dist/translations/tr-tr.cjs +1 -1
  165. package/dist/translations/tr-tr.js +19 -2
  166. package/dist/translations/zh-cn.cjs +1 -1
  167. package/dist/translations/zh-cn.js +19 -2
  168. package/dist/{types-ixSwJkxM.js → types-B96nVbgX.js} +1 -1
  169. package/dist/{types-CoY6F8Ma.cjs → types-DZ4vWh8j.cjs} +1 -1
  170. package/dist/{utils-C8YMrOdw.cjs → utils-CgV-jWWQ.cjs} +33 -33
  171. package/dist/{utils-BP-BglHE.js → utils-ChqSLRbz.js} +3742 -3774
  172. package/dist/{widget-composer-DI4sHaNe.cjs → widget-composer-Blul90Zb.cjs} +1 -1
  173. package/dist/{widget-composer-CUUFoCb9.js → widget-composer-Cf_CN3Ux.js} +8 -8
  174. package/package.json +10 -8
  175. package/dist/dimensions-BiLyFpCg.js +0 -202
  176. package/dist/dimensions-X4_igtmO.cjs +0 -1
  177. package/dist/execute-query-BEeqqDl6.js +0 -5795
  178. package/dist/execute-query-DJDE0zRU.cjs +0 -1
  179. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/common.d.ts +0 -84
  180. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/translate-dimensions-from-json.d.ts +0 -12
  181. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/translate-dimensions-to-json.d.ts +0 -13
  182. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/translate-measures-to-json.d.ts +0 -13
  183. package/dist/quota-notification-z3dv2KoH.cjs +0 -672
@@ -1,186 +1,193 @@
1
- var er = Object.defineProperty, rr = Object.defineProperties;
2
- var tr = Object.getOwnPropertyDescriptors;
3
- var ye = Object.getOwnPropertySymbols;
4
- var sr = Object.prototype.hasOwnProperty, nr = Object.prototype.propertyIsEnumerable;
5
- var ge = (e, r, t) => r in e ? er(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, g = (e, r) => {
6
- for (var t in r || (r = {}))
7
- sr.call(r, t) && ge(e, t, r[t]);
8
- if (ye)
9
- for (var t of ye(r))
10
- nr.call(r, t) && ge(e, t, r[t]);
1
+ var zt = Object.defineProperty, Pt = Object.defineProperties;
2
+ var Lt = Object.getOwnPropertyDescriptors;
3
+ var ze = Object.getOwnPropertySymbols;
4
+ var _t = Object.prototype.hasOwnProperty, Ut = Object.prototype.propertyIsEnumerable;
5
+ var Pe = (e, t, r) => t in e ? zt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, g = (e, t) => {
6
+ for (var r in t || (t = {}))
7
+ _t.call(t, r) && Pe(e, r, t[r]);
8
+ if (ze)
9
+ for (var r of ze(t))
10
+ Ut.call(t, r) && Pe(e, r, t[r]);
11
11
  return e;
12
- }, h = (e, r) => rr(e, tr(r));
13
- import { f as ir, J as or } from "../types-ixSwJkxM.js";
14
- import { b as Ws, E as js, a as Js, i as Ks, e as Gs, d as Qs } from "../types-ixSwJkxM.js";
15
- import { bW as ar, bA as ur, bX as cr, bY as lr, bZ as fr, aw as ne, b_ as dr, av as mr, b$ as pr, b8 as yr, ax as gr, c0 as hr, bb as br, b9 as Fr, aL as wr, b7 as qr, ba as Er, d as Cr, c as $r, k as Ar, c1 as xr, c2 as Dr, c3 as Mr, c4 as Sr, c5 as Tr, c6 as Nr, c7 as Rr, c8 as Or, c9 as Ir, ca as zr, cb as Br, au as Pr, cc as kr, cd as Lr, S as ie, h as Vr, s as oe, b as W, M as I, aj as $e, bG as Ae, ce as _r, cf as Ur, cg as Wr, ch as jr, ci as Jr, aH as Kr, an as he, am as Gr, cj as xe, a6 as Qr, ck as Yr, x as Hr, v as Zr } from "../execute-query-BEeqqDl6.js";
16
- import { i as Xr, b as vr, D as et, d as rt, a as tt } from "../dimensions-BiLyFpCg.js";
17
- class st {
12
+ }, F = (e, t) => Pt(e, Lt(t));
13
+ import { f as jt, J as Vt } from "../types-B96nVbgX.js";
14
+ import { b as ri, E as si, a as ni, i as ii, e as oi, d as ai } from "../types-B96nVbgX.js";
15
+ import { cb as Wt, bK as Kt, cc as Jt, cd as Yt, ce as Gt, aG as be, cf as Qt, aF as Ht, cg as Xt, bi as Zt, aH as er, ch as tr, bl as rr, bj as sr, aV as nr, bh as ir, bk as or, d as ar, c as ur, k as cr, ci as lr, cj as fr, ck as dr, cl as mr, cm as pr, cn as yr, co as gr, cp as hr, cq as br, cr as Fr, cs as wr, aE as qr, ct as Ar, cu as Cr, S as B, t as H, h as Er, b as $, av as _, at as te, cv as xr, cw as $r, cx as Tr, M as L, cy as Dr, cz as Sr, aR as Or, ax as Le, aw as Fe, bQ as re, U as Mr, V as vr, cA as tt, ag as Nr, A as Rr, cB as Ir, y as kr, x as Br } from "../execute-query-CHYTupEo.js";
16
+ import { i as zr, b as Pr, D as Lr, d as _r, a as Ur } from "../dimensions-C0BmtTH2.js";
17
+ function jr(e, t) {
18
+ const r = e.length, s = t.length, n = Array.from({ length: r + 1 }, (i, o) => Array.from({ length: s + 1 }, (a, u) => o === 0 ? u : u === 0 ? o : 0));
19
+ for (let i = 1; i <= r; i++)
20
+ for (let o = 1; o <= s; o++)
21
+ n[i][o] = Math.min(n[i - 1][o] + 1, n[i][o - 1] + 1, n[i - 1][o - 1] + (e[i - 1] === t[o - 1] ? 0 : 1));
22
+ return n[r][s];
23
+ }
24
+ class Vr {
18
25
  constructor() {
19
26
  this.keyToValue = /* @__PURE__ */ new Map(), this.valueToKey = /* @__PURE__ */ new Map();
20
27
  }
21
- set(r, t) {
22
- this.keyToValue.set(r, t), this.valueToKey.set(t, r);
28
+ set(t, r) {
29
+ this.keyToValue.set(t, r), this.valueToKey.set(r, t);
23
30
  }
24
- getByKey(r) {
25
- return this.keyToValue.get(r);
31
+ getByKey(t) {
32
+ return this.keyToValue.get(t);
26
33
  }
27
- getByValue(r) {
28
- return this.valueToKey.get(r);
34
+ getByValue(t) {
35
+ return this.valueToKey.get(t);
29
36
  }
30
37
  clear() {
31
38
  this.keyToValue.clear(), this.valueToKey.clear();
32
39
  }
33
40
  }
34
- class De {
35
- constructor(r) {
36
- this.generateIdentifier = r, this.kv = new st();
41
+ class rt {
42
+ constructor(t) {
43
+ this.generateIdentifier = t, this.kv = new Vr();
37
44
  }
38
- register(r, t) {
39
- this.kv.getByValue(r) || (t || (t = this.generateIdentifier(r)), this.kv.set(t, r));
45
+ register(t, r) {
46
+ this.kv.getByValue(t) || (r || (r = this.generateIdentifier(t)), this.kv.set(r, t));
40
47
  }
41
48
  clear() {
42
49
  this.kv.clear();
43
50
  }
44
- getIdentifier(r) {
45
- return this.kv.getByValue(r);
51
+ getIdentifier(t) {
52
+ return this.kv.getByValue(t);
46
53
  }
47
- getValue(r) {
48
- return this.kv.getByKey(r);
54
+ getValue(t) {
55
+ return this.kv.getByKey(t);
49
56
  }
50
57
  }
51
- class nt extends De {
58
+ class Wr extends rt {
52
59
  constructor() {
53
- super((r) => r.name), this.classToAllowedProps = /* @__PURE__ */ new Map();
60
+ super((t) => t.name), this.classToAllowedProps = /* @__PURE__ */ new Map();
54
61
  }
55
- register(r, t) {
56
- typeof t == "object" ? (t.allowProps && this.classToAllowedProps.set(r, t.allowProps), super.register(r, t.identifier)) : super.register(r, t);
62
+ register(t, r) {
63
+ typeof r == "object" ? (r.allowProps && this.classToAllowedProps.set(t, r.allowProps), super.register(t, r.identifier)) : super.register(t, r);
57
64
  }
58
- getAllowedProps(r) {
59
- return this.classToAllowedProps.get(r);
65
+ getAllowedProps(t) {
66
+ return this.classToAllowedProps.get(t);
60
67
  }
61
68
  }
62
- function it(e) {
69
+ function Kr(e) {
63
70
  if ("values" in Object)
64
71
  return Object.values(e);
65
- const r = [];
66
- for (const t in e)
67
- e.hasOwnProperty(t) && r.push(e[t]);
68
- return r;
72
+ const t = [];
73
+ for (const r in e)
74
+ e.hasOwnProperty(r) && t.push(e[r]);
75
+ return t;
69
76
  }
70
- function ot(e, r) {
71
- const t = it(e);
72
- if ("find" in t)
73
- return t.find(r);
74
- const s = t;
77
+ function Jr(e, t) {
78
+ const r = Kr(e);
79
+ if ("find" in r)
80
+ return r.find(t);
81
+ const s = r;
75
82
  for (let n = 0; n < s.length; n++) {
76
- const o = s[n];
77
- if (r(o))
78
- return o;
83
+ const i = s[n];
84
+ if (t(i))
85
+ return i;
79
86
  }
80
87
  }
81
- function z(e, r) {
82
- Object.entries(e).forEach(([t, s]) => r(s, t));
88
+ function U(e, t) {
89
+ Object.entries(e).forEach(([r, s]) => t(s, r));
83
90
  }
84
- function j(e, r) {
85
- return e.indexOf(r) !== -1;
91
+ function Z(e, t) {
92
+ return e.indexOf(t) !== -1;
86
93
  }
87
- function be(e, r) {
88
- for (let t = 0; t < e.length; t++) {
89
- const s = e[t];
90
- if (r(s))
94
+ function _e(e, t) {
95
+ for (let r = 0; r < e.length; r++) {
96
+ const s = e[r];
97
+ if (t(s))
91
98
  return s;
92
99
  }
93
100
  }
94
- class at {
101
+ class Yr {
95
102
  constructor() {
96
103
  this.transfomers = {};
97
104
  }
98
- register(r) {
99
- this.transfomers[r.name] = r;
105
+ register(t) {
106
+ this.transfomers[t.name] = t;
100
107
  }
101
- findApplicable(r) {
102
- return ot(this.transfomers, (t) => t.isApplicable(r));
108
+ findApplicable(t) {
109
+ return Jr(this.transfomers, (r) => r.isApplicable(t));
103
110
  }
104
- findByName(r) {
105
- return this.transfomers[r];
111
+ findByName(t) {
112
+ return this.transfomers[t];
106
113
  }
107
114
  }
108
- const ut = (e) => Object.prototype.toString.call(e).slice(8, -1), Me = (e) => typeof e == "undefined", ct = (e) => e === null, k = (e) => typeof e != "object" || e === null || e === Object.prototype ? !1 : Object.getPrototypeOf(e) === null ? !0 : Object.getPrototypeOf(e) === Object.prototype, X = (e) => k(e) && Object.keys(e).length === 0, S = (e) => Array.isArray(e), lt = (e) => typeof e == "string", ft = (e) => typeof e == "number" && !isNaN(e), dt = (e) => typeof e == "boolean", mt = (e) => e instanceof RegExp, L = (e) => e instanceof Map, V = (e) => e instanceof Set, Se = (e) => ut(e) === "Symbol", pt = (e) => e instanceof Date && !isNaN(e.valueOf()), yt = (e) => e instanceof Error, Fe = (e) => typeof e == "number" && isNaN(e), gt = (e) => dt(e) || ct(e) || Me(e) || ft(e) || lt(e) || Se(e), ht = (e) => typeof e == "bigint", bt = (e) => e === 1 / 0 || e === -1 / 0, Ft = (e) => ArrayBuffer.isView(e) && !(e instanceof DataView), wt = (e) => e instanceof URL, Te = (e) => e.replace(/\./g, "\\."), Y = (e) => e.map(String).map(Te).join("."), P = (e) => {
109
- const r = [];
110
- let t = "";
115
+ const Gr = (e) => Object.prototype.toString.call(e).slice(8, -1), st = (e) => typeof e == "undefined", Qr = (e) => e === null, K = (e) => typeof e != "object" || e === null || e === Object.prototype ? !1 : Object.getPrototypeOf(e) === null ? !0 : Object.getPrototypeOf(e) === Object.prototype, fe = (e) => K(e) && Object.keys(e).length === 0, R = (e) => Array.isArray(e), Hr = (e) => typeof e == "string", Xr = (e) => typeof e == "number" && !isNaN(e), Zr = (e) => typeof e == "boolean", es = (e) => e instanceof RegExp, J = (e) => e instanceof Map, Y = (e) => e instanceof Set, nt = (e) => Gr(e) === "Symbol", ts = (e) => e instanceof Date && !isNaN(e.valueOf()), rs = (e) => e instanceof Error, Ue = (e) => typeof e == "number" && isNaN(e), ss = (e) => Zr(e) || Qr(e) || st(e) || Xr(e) || Hr(e) || nt(e), ns = (e) => typeof e == "bigint", is = (e) => e === 1 / 0 || e === -1 / 0, os = (e) => ArrayBuffer.isView(e) && !(e instanceof DataView), as = (e) => e instanceof URL, it = (e) => e.replace(/\./g, "\\."), ae = (e) => e.map(String).map(it).join("."), W = (e) => {
116
+ const t = [];
117
+ let r = "";
111
118
  for (let n = 0; n < e.length; n++) {
112
- let o = e.charAt(n);
113
- if (o === "\\" && e.charAt(n + 1) === ".") {
114
- t += ".", n++;
119
+ let i = e.charAt(n);
120
+ if (i === "\\" && e.charAt(n + 1) === ".") {
121
+ r += ".", n++;
115
122
  continue;
116
123
  }
117
- if (o === ".") {
118
- r.push(t), t = "";
124
+ if (i === ".") {
125
+ t.push(r), r = "";
119
126
  continue;
120
127
  }
121
- t += o;
128
+ r += i;
122
129
  }
123
- const s = t;
124
- return r.push(s), r;
130
+ const s = r;
131
+ return t.push(s), t;
125
132
  };
126
- function A(e, r, t, s) {
133
+ function v(e, t, r, s) {
127
134
  return {
128
135
  isApplicable: e,
129
- annotation: r,
130
- transform: t,
136
+ annotation: t,
137
+ transform: r,
131
138
  untransform: s
132
139
  };
133
140
  }
134
- const Ne = [
135
- A(Me, "undefined", () => null, () => {
141
+ const ot = [
142
+ v(st, "undefined", () => null, () => {
136
143
  }),
137
- A(ht, "bigint", (e) => e.toString(), (e) => typeof BigInt != "undefined" ? BigInt(e) : (console.error("Please add a BigInt polyfill."), e)),
138
- A(pt, "Date", (e) => e.toISOString(), (e) => new Date(e)),
139
- A(yt, "Error", (e, r) => {
140
- const t = {
144
+ v(ns, "bigint", (e) => e.toString(), (e) => typeof BigInt != "undefined" ? BigInt(e) : (console.error("Please add a BigInt polyfill."), e)),
145
+ v(ts, "Date", (e) => e.toISOString(), (e) => new Date(e)),
146
+ v(rs, "Error", (e, t) => {
147
+ const r = {
141
148
  name: e.name,
142
149
  message: e.message
143
150
  };
144
- return r.allowedErrorProps.forEach((s) => {
145
- t[s] = e[s];
146
- }), t;
147
- }, (e, r) => {
148
- const t = new Error(e.message);
149
- return t.name = e.name, t.stack = e.stack, r.allowedErrorProps.forEach((s) => {
150
- t[s] = e[s];
151
- }), t;
151
+ return t.allowedErrorProps.forEach((s) => {
152
+ r[s] = e[s];
153
+ }), r;
154
+ }, (e, t) => {
155
+ const r = new Error(e.message);
156
+ return r.name = e.name, r.stack = e.stack, t.allowedErrorProps.forEach((s) => {
157
+ r[s] = e[s];
158
+ }), r;
152
159
  }),
153
- A(mt, "regexp", (e) => "" + e, (e) => {
154
- const r = e.slice(1, e.lastIndexOf("/")), t = e.slice(e.lastIndexOf("/") + 1);
155
- return new RegExp(r, t);
160
+ v(es, "regexp", (e) => "" + e, (e) => {
161
+ const t = e.slice(1, e.lastIndexOf("/")), r = e.slice(e.lastIndexOf("/") + 1);
162
+ return new RegExp(t, r);
156
163
  }),
157
- A(
158
- V,
164
+ v(
165
+ Y,
159
166
  "set",
160
167
  // (sets only exist in es6+)
161
168
  // eslint-disable-next-line es5/no-es6-methods
162
169
  (e) => [...e.values()],
163
170
  (e) => new Set(e)
164
171
  ),
165
- A(L, "map", (e) => [...e.entries()], (e) => new Map(e)),
166
- A((e) => Fe(e) || bt(e), "number", (e) => Fe(e) ? "NaN" : e > 0 ? "Infinity" : "-Infinity", Number),
167
- A((e) => e === 0 && 1 / e === -1 / 0, "number", () => "-0", Number),
168
- A(wt, "URL", (e) => e.toString(), (e) => new URL(e))
172
+ v(J, "map", (e) => [...e.entries()], (e) => new Map(e)),
173
+ v((e) => Ue(e) || is(e), "number", (e) => Ue(e) ? "NaN" : e > 0 ? "Infinity" : "-Infinity", Number),
174
+ v((e) => e === 0 && 1 / e === -1 / 0, "number", () => "-0", Number),
175
+ v(as, "URL", (e) => e.toString(), (e) => new URL(e))
169
176
  ];
170
- function J(e, r, t, s) {
177
+ function se(e, t, r, s) {
171
178
  return {
172
179
  isApplicable: e,
173
- annotation: r,
174
- transform: t,
180
+ annotation: t,
181
+ transform: r,
175
182
  untransform: s
176
183
  };
177
184
  }
178
- const Re = J((e, r) => Se(e) ? !!r.symbolRegistry.getIdentifier(e) : !1, (e, r) => ["symbol", r.symbolRegistry.getIdentifier(e)], (e) => e.description, (e, r, t) => {
179
- const s = t.symbolRegistry.getValue(r[1]);
185
+ const at = se((e, t) => nt(e) ? !!t.symbolRegistry.getIdentifier(e) : !1, (e, t) => ["symbol", t.symbolRegistry.getIdentifier(e)], (e) => e.description, (e, t, r) => {
186
+ const s = r.symbolRegistry.getValue(t[1]);
180
187
  if (!s)
181
188
  throw new Error("Trying to deserialize unknown symbol");
182
189
  return s;
183
- }), qt = [
190
+ }), us = [
184
191
  Int8Array,
185
192
  Uint8Array,
186
193
  Int16Array,
@@ -190,480 +197,482 @@ const Re = J((e, r) => Se(e) ? !!r.symbolRegistry.getIdentifier(e) : !1, (e, r)
190
197
  Float32Array,
191
198
  Float64Array,
192
199
  Uint8ClampedArray
193
- ].reduce((e, r) => (e[r.name] = r, e), {}), Oe = J(Ft, (e) => ["typed-array", e.constructor.name], (e) => [...e], (e, r) => {
194
- const t = qt[r[1]];
195
- if (!t)
200
+ ].reduce((e, t) => (e[t.name] = t, e), {}), ut = se(os, (e) => ["typed-array", e.constructor.name], (e) => [...e], (e, t) => {
201
+ const r = us[t[1]];
202
+ if (!r)
196
203
  throw new Error("Trying to deserialize unknown typed array");
197
- return new t(e);
204
+ return new r(e);
198
205
  });
199
- function Ie(e, r) {
200
- return e != null && e.constructor ? !!r.classRegistry.getIdentifier(e.constructor) : !1;
206
+ function ct(e, t) {
207
+ return e != null && e.constructor ? !!t.classRegistry.getIdentifier(e.constructor) : !1;
201
208
  }
202
- const ze = J(Ie, (e, r) => ["class", r.classRegistry.getIdentifier(e.constructor)], (e, r) => {
203
- const t = r.classRegistry.getAllowedProps(e.constructor);
204
- if (!t)
209
+ const lt = se(ct, (e, t) => ["class", t.classRegistry.getIdentifier(e.constructor)], (e, t) => {
210
+ const r = t.classRegistry.getAllowedProps(e.constructor);
211
+ if (!r)
205
212
  return g({}, e);
206
213
  const s = {};
207
- return t.forEach((n) => {
214
+ return r.forEach((n) => {
208
215
  s[n] = e[n];
209
216
  }), s;
210
- }, (e, r, t) => {
211
- const s = t.classRegistry.getValue(r[1]);
217
+ }, (e, t, r) => {
218
+ const s = r.classRegistry.getValue(t[1]);
212
219
  if (!s)
213
- throw new Error(`Trying to deserialize unknown class '${r[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
220
+ throw new Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
214
221
  return Object.assign(Object.create(s.prototype), e);
215
- }), Be = J((e, r) => !!r.customTransformerRegistry.findApplicable(e), (e, r) => ["custom", r.customTransformerRegistry.findApplicable(e).name], (e, r) => r.customTransformerRegistry.findApplicable(e).serialize(e), (e, r, t) => {
216
- const s = t.customTransformerRegistry.findByName(r[1]);
222
+ }), ft = se((e, t) => !!t.customTransformerRegistry.findApplicable(e), (e, t) => ["custom", t.customTransformerRegistry.findApplicable(e).name], (e, t) => t.customTransformerRegistry.findApplicable(e).serialize(e), (e, t, r) => {
223
+ const s = r.customTransformerRegistry.findByName(t[1]);
217
224
  if (!s)
218
225
  throw new Error("Trying to deserialize unknown custom value");
219
226
  return s.deserialize(e);
220
- }), Et = [ze, Re, Be, Oe], we = (e, r) => {
221
- const t = be(Et, (n) => n.isApplicable(e, r));
222
- if (t)
227
+ }), cs = [lt, at, ft, ut], je = (e, t) => {
228
+ const r = _e(cs, (n) => n.isApplicable(e, t));
229
+ if (r)
223
230
  return {
224
- value: t.transform(e, r),
225
- type: t.annotation(e, r)
231
+ value: r.transform(e, t),
232
+ type: r.annotation(e, t)
226
233
  };
227
- const s = be(Ne, (n) => n.isApplicable(e, r));
234
+ const s = _e(ot, (n) => n.isApplicable(e, t));
228
235
  if (s)
229
236
  return {
230
- value: s.transform(e, r),
237
+ value: s.transform(e, t),
231
238
  type: s.annotation
232
239
  };
233
- }, Pe = {};
234
- Ne.forEach((e) => {
235
- Pe[e.annotation] = e;
240
+ }, dt = {};
241
+ ot.forEach((e) => {
242
+ dt[e.annotation] = e;
236
243
  });
237
- const Ct = (e, r, t) => {
238
- if (S(r))
239
- switch (r[0]) {
244
+ const ls = (e, t, r) => {
245
+ if (R(t))
246
+ switch (t[0]) {
240
247
  case "symbol":
241
- return Re.untransform(e, r, t);
248
+ return at.untransform(e, t, r);
242
249
  case "class":
243
- return ze.untransform(e, r, t);
250
+ return lt.untransform(e, t, r);
244
251
  case "custom":
245
- return Be.untransform(e, r, t);
252
+ return ft.untransform(e, t, r);
246
253
  case "typed-array":
247
- return Oe.untransform(e, r, t);
254
+ return ut.untransform(e, t, r);
248
255
  default:
249
- throw new Error("Unknown transformation: " + r);
256
+ throw new Error("Unknown transformation: " + t);
250
257
  }
251
258
  else {
252
- const s = Pe[r];
259
+ const s = dt[t];
253
260
  if (!s)
254
- throw new Error("Unknown transformation: " + r);
255
- return s.untransform(e, t);
261
+ throw new Error("Unknown transformation: " + t);
262
+ return s.untransform(e, r);
256
263
  }
257
- }, O = (e, r) => {
258
- if (r > e.size)
264
+ }, P = (e, t) => {
265
+ if (t > e.size)
259
266
  throw new Error("index out of bounds");
260
- const t = e.keys();
261
- for (; r > 0; )
262
- t.next(), r--;
263
- return t.next().value;
267
+ const r = e.keys();
268
+ for (; t > 0; )
269
+ r.next(), t--;
270
+ return r.next().value;
264
271
  };
265
- function ke(e) {
266
- if (j(e, "__proto__"))
272
+ function mt(e) {
273
+ if (Z(e, "__proto__"))
267
274
  throw new Error("__proto__ is not allowed as a property");
268
- if (j(e, "prototype"))
275
+ if (Z(e, "prototype"))
269
276
  throw new Error("prototype is not allowed as a property");
270
- if (j(e, "constructor"))
277
+ if (Z(e, "constructor"))
271
278
  throw new Error("constructor is not allowed as a property");
272
279
  }
273
- const $t = (e, r) => {
274
- ke(r);
275
- for (let t = 0; t < r.length; t++) {
276
- const s = r[t];
277
- if (V(e))
278
- e = O(e, +s);
279
- else if (L(e)) {
280
- const n = +s, o = +r[++t] == 0 ? "key" : "value", i = O(e, n);
281
- switch (o) {
280
+ const fs = (e, t) => {
281
+ mt(t);
282
+ for (let r = 0; r < t.length; r++) {
283
+ const s = t[r];
284
+ if (Y(e))
285
+ e = P(e, +s);
286
+ else if (J(e)) {
287
+ const n = +s, i = +t[++r] == 0 ? "key" : "value", o = P(e, n);
288
+ switch (i) {
282
289
  case "key":
283
- e = i;
290
+ e = o;
284
291
  break;
285
292
  case "value":
286
- e = e.get(i);
293
+ e = e.get(o);
287
294
  break;
288
295
  }
289
296
  } else
290
297
  e = e[s];
291
298
  }
292
299
  return e;
293
- }, v = (e, r, t) => {
294
- if (ke(r), r.length === 0)
295
- return t(e);
300
+ }, de = (e, t, r) => {
301
+ if (mt(t), t.length === 0)
302
+ return r(e);
296
303
  let s = e;
297
- for (let o = 0; o < r.length - 1; o++) {
298
- const i = r[o];
299
- if (S(s)) {
300
- const a = +i;
304
+ for (let i = 0; i < t.length - 1; i++) {
305
+ const o = t[i];
306
+ if (R(s)) {
307
+ const a = +o;
301
308
  s = s[a];
302
- } else if (k(s))
303
- s = s[i];
304
- else if (V(s)) {
305
- const a = +i;
306
- s = O(s, a);
307
- } else if (L(s)) {
308
- if (o === r.length - 2)
309
+ } else if (K(s))
310
+ s = s[o];
311
+ else if (Y(s)) {
312
+ const a = +o;
313
+ s = P(s, a);
314
+ } else if (J(s)) {
315
+ if (i === t.length - 2)
309
316
  break;
310
- const u = +i, c = +r[++o] == 0 ? "key" : "value", p = O(s, u);
317
+ const u = +o, c = +t[++i] == 0 ? "key" : "value", m = P(s, u);
311
318
  switch (c) {
312
319
  case "key":
313
- s = p;
320
+ s = m;
314
321
  break;
315
322
  case "value":
316
- s = s.get(p);
323
+ s = s.get(m);
317
324
  break;
318
325
  }
319
326
  }
320
327
  }
321
- const n = r[r.length - 1];
322
- if (S(s) ? s[+n] = t(s[+n]) : k(s) && (s[n] = t(s[n])), V(s)) {
323
- const o = O(s, +n), i = t(o);
324
- o !== i && (s.delete(o), s.add(i));
328
+ const n = t[t.length - 1];
329
+ if (R(s) ? s[+n] = r(s[+n]) : K(s) && (s[n] = r(s[n])), Y(s)) {
330
+ const i = P(s, +n), o = r(i);
331
+ i !== o && (s.delete(i), s.add(o));
325
332
  }
326
- if (L(s)) {
327
- const o = +r[r.length - 2], i = O(s, o);
333
+ if (J(s)) {
334
+ const i = +t[t.length - 2], o = P(s, i);
328
335
  switch (+n == 0 ? "key" : "value") {
329
336
  case "key": {
330
- const u = t(i);
331
- s.set(u, s.get(i)), u !== i && s.delete(i);
337
+ const u = r(o);
338
+ s.set(u, s.get(o)), u !== o && s.delete(o);
332
339
  break;
333
340
  }
334
341
  case "value": {
335
- s.set(i, t(s.get(i)));
342
+ s.set(o, r(s.get(o)));
336
343
  break;
337
344
  }
338
345
  }
339
346
  }
340
347
  return e;
341
348
  };
342
- function ee(e, r, t = []) {
349
+ function me(e, t, r = []) {
343
350
  if (!e)
344
351
  return;
345
- if (!S(e)) {
346
- z(e, (o, i) => ee(o, r, [...t, ...P(i)]));
352
+ if (!R(e)) {
353
+ U(e, (i, o) => me(i, t, [...r, ...W(o)]));
347
354
  return;
348
355
  }
349
356
  const [s, n] = e;
350
- n && z(n, (o, i) => {
351
- ee(o, r, [...t, ...P(i)]);
352
- }), r(s, t);
357
+ n && U(n, (i, o) => {
358
+ me(i, t, [...r, ...W(o)]);
359
+ }), t(s, r);
353
360
  }
354
- function At(e, r, t) {
355
- return ee(r, (s, n) => {
356
- e = v(e, n, (o) => Ct(o, s, t));
361
+ function ds(e, t, r) {
362
+ return me(t, (s, n) => {
363
+ e = de(e, n, (i) => ls(i, s, r));
357
364
  }), e;
358
365
  }
359
- function xt(e, r) {
360
- function t(s, n) {
361
- const o = $t(e, P(n));
362
- s.map(P).forEach((i) => {
363
- e = v(e, i, () => o);
366
+ function ms(e, t) {
367
+ function r(s, n) {
368
+ const i = fs(e, W(n));
369
+ s.map(W).forEach((o) => {
370
+ e = de(e, o, () => i);
364
371
  });
365
372
  }
366
- if (S(r)) {
367
- const [s, n] = r;
368
- s.forEach((o) => {
369
- e = v(e, P(o), () => e);
370
- }), n && z(n, t);
373
+ if (R(t)) {
374
+ const [s, n] = t;
375
+ s.forEach((i) => {
376
+ e = de(e, W(i), () => e);
377
+ }), n && U(n, r);
371
378
  } else
372
- z(r, t);
379
+ U(t, r);
373
380
  return e;
374
381
  }
375
- const Dt = (e, r) => k(e) || S(e) || L(e) || V(e) || Ie(e, r);
376
- function Mt(e, r, t) {
377
- const s = t.get(e);
378
- s ? s.push(r) : t.set(e, [r]);
382
+ const ps = (e, t) => K(e) || R(e) || J(e) || Y(e) || ct(e, t);
383
+ function ys(e, t, r) {
384
+ const s = r.get(e);
385
+ s ? s.push(t) : r.set(e, [t]);
379
386
  }
380
- function St(e, r) {
381
- const t = {};
387
+ function gs(e, t) {
388
+ const r = {};
382
389
  let s;
383
390
  return e.forEach((n) => {
384
391
  if (n.length <= 1)
385
392
  return;
386
- r || (n = n.map((a) => a.map(String)).sort((a, u) => a.length - u.length));
387
- const [o, ...i] = n;
388
- o.length === 0 ? s = i.map(Y) : t[Y(o)] = i.map(Y);
389
- }), s ? X(t) ? [s] : [s, t] : X(t) ? void 0 : t;
390
- }
391
- const Le = (e, r, t, s, n = [], o = [], i = /* @__PURE__ */ new Map()) => {
392
- var x;
393
- const a = gt(e);
393
+ t || (n = n.map((a) => a.map(String)).sort((a, u) => a.length - u.length));
394
+ const [i, ...o] = n;
395
+ i.length === 0 ? s = o.map(ae) : r[ae(i)] = o.map(ae);
396
+ }), s ? fe(r) ? [s] : [s, r] : fe(r) ? void 0 : r;
397
+ }
398
+ const pt = (e, t, r, s, n = [], i = [], o = /* @__PURE__ */ new Map()) => {
399
+ var h;
400
+ const a = ss(e);
394
401
  if (!a) {
395
- Mt(e, n, r);
396
- const f = i.get(e);
397
- if (f)
402
+ ys(e, n, t);
403
+ const p = o.get(e);
404
+ if (p)
398
405
  return s ? {
399
406
  transformedValue: null
400
- } : f;
407
+ } : p;
401
408
  }
402
- if (!Dt(e, t)) {
403
- const f = we(e, t), d = f ? {
404
- transformedValue: f.value,
405
- annotations: [f.type]
409
+ if (!ps(e, r)) {
410
+ const p = je(e, r), d = p ? {
411
+ transformedValue: p.value,
412
+ annotations: [p.type]
406
413
  } : {
407
414
  transformedValue: e
408
415
  };
409
- return a || i.set(e, d), d;
416
+ return a || o.set(e, d), d;
410
417
  }
411
- if (j(o, e))
418
+ if (Z(i, e))
412
419
  return {
413
420
  transformedValue: null
414
421
  };
415
- const u = we(e, t), c = (x = u == null ? void 0 : u.value) != null ? x : e, p = S(c) ? [] : {}, m = {};
416
- z(c, (f, d) => {
422
+ const u = je(e, r), c = (h = u == null ? void 0 : u.value) != null ? h : e, m = R(c) ? [] : {}, l = {};
423
+ U(c, (p, d) => {
417
424
  if (d === "__proto__" || d === "constructor" || d === "prototype")
418
425
  throw new Error(`Detected property ${d}. This is a prototype pollution risk, please remove it from your object.`);
419
- const w = Le(f, r, t, s, [...n, d], [...o, e], i);
420
- p[d] = w.transformedValue, S(w.annotations) ? m[d] = w.annotations : k(w.annotations) && z(w.annotations, ($, D) => {
421
- m[Te(d) + "." + D] = $;
426
+ const b = pt(p, t, r, s, [...n, d], [...i, e], o);
427
+ m[d] = b.transformedValue, R(b.annotations) ? l[d] = b.annotations : K(b.annotations) && U(b.annotations, (A, O) => {
428
+ l[it(d) + "." + O] = A;
422
429
  });
423
430
  });
424
- const y = X(m) ? {
425
- transformedValue: p,
431
+ const f = fe(l) ? {
432
+ transformedValue: m,
426
433
  annotations: u ? [u.type] : void 0
427
434
  } : {
428
- transformedValue: p,
429
- annotations: u ? [u.type, m] : m
435
+ transformedValue: m,
436
+ annotations: u ? [u.type, l] : l
430
437
  };
431
- return a || i.set(e, y), y;
438
+ return a || o.set(e, f), f;
432
439
  };
433
- function Ve(e) {
440
+ function yt(e) {
434
441
  return Object.prototype.toString.call(e).slice(8, -1);
435
442
  }
436
- function qe(e) {
437
- return Ve(e) === "Array";
443
+ function Ve(e) {
444
+ return yt(e) === "Array";
438
445
  }
439
- function Tt(e) {
440
- if (Ve(e) !== "Object")
446
+ function hs(e) {
447
+ if (yt(e) !== "Object")
441
448
  return !1;
442
- const r = Object.getPrototypeOf(e);
443
- return !!r && r.constructor === Object && r === Object.prototype;
449
+ const t = Object.getPrototypeOf(e);
450
+ return !!t && t.constructor === Object && t === Object.prototype;
444
451
  }
445
- function Nt(e, r, t, s, n) {
446
- const o = {}.propertyIsEnumerable.call(s, r) ? "enumerable" : "nonenumerable";
447
- o === "enumerable" && (e[r] = t), n && o === "nonenumerable" && Object.defineProperty(e, r, {
448
- value: t,
452
+ function bs(e, t, r, s, n) {
453
+ const i = {}.propertyIsEnumerable.call(s, t) ? "enumerable" : "nonenumerable";
454
+ i === "enumerable" && (e[t] = r), n && i === "nonenumerable" && Object.defineProperty(e, t, {
455
+ value: r,
449
456
  enumerable: !1,
450
457
  writable: !0,
451
458
  configurable: !0
452
459
  });
453
460
  }
454
- function re(e, r = {}) {
455
- if (qe(e))
456
- return e.map((n) => re(n, r));
457
- if (!Tt(e))
461
+ function pe(e, t = {}) {
462
+ if (Ve(e))
463
+ return e.map((n) => pe(n, t));
464
+ if (!hs(e))
458
465
  return e;
459
- const t = Object.getOwnPropertyNames(e), s = Object.getOwnPropertySymbols(e);
460
- return [...t, ...s].reduce((n, o) => {
461
- if (qe(r.props) && !r.props.includes(o))
466
+ const r = Object.getOwnPropertyNames(e), s = Object.getOwnPropertySymbols(e);
467
+ return [...r, ...s].reduce((n, i) => {
468
+ if (Ve(t.props) && !t.props.includes(i))
462
469
  return n;
463
- const i = e[o], a = re(i, r);
464
- return Nt(n, o, a, e, r.nonenumerable), n;
470
+ const o = e[i], a = pe(o, t);
471
+ return bs(n, i, a, e, t.nonenumerable), n;
465
472
  }, {});
466
473
  }
467
- class l {
474
+ class y {
468
475
  /**
469
476
  * @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
470
477
  */
471
- constructor({ dedupe: r = !1 } = {}) {
472
- this.classRegistry = new nt(), this.symbolRegistry = new De((t) => {
478
+ constructor({ dedupe: t = !1 } = {}) {
479
+ this.classRegistry = new Wr(), this.symbolRegistry = new rt((r) => {
473
480
  var s;
474
- return (s = t.description) != null ? s : "";
475
- }), this.customTransformerRegistry = new at(), this.allowedErrorProps = [], this.dedupe = r;
481
+ return (s = r.description) != null ? s : "";
482
+ }), this.customTransformerRegistry = new Yr(), this.allowedErrorProps = [], this.dedupe = t;
476
483
  }
477
- serialize(r) {
478
- const t = /* @__PURE__ */ new Map(), s = Le(r, t, this, this.dedupe), n = {
484
+ serialize(t) {
485
+ const r = /* @__PURE__ */ new Map(), s = pt(t, r, this, this.dedupe), n = {
479
486
  json: s.transformedValue
480
487
  };
481
- s.annotations && (n.meta = h(g({}, n.meta), {
488
+ s.annotations && (n.meta = F(g({}, n.meta), {
482
489
  values: s.annotations
483
490
  }));
484
- const o = St(t, this.dedupe);
485
- return o && (n.meta = h(g({}, n.meta), {
486
- referentialEqualities: o
491
+ const i = gs(r, this.dedupe);
492
+ return i && (n.meta = F(g({}, n.meta), {
493
+ referentialEqualities: i
487
494
  })), n;
488
495
  }
489
- deserialize(r) {
490
- const { json: t, meta: s } = r;
491
- let n = re(t);
492
- return s != null && s.values && (n = At(n, s.values, this)), s != null && s.referentialEqualities && (n = xt(n, s.referentialEqualities)), n;
496
+ deserialize(t) {
497
+ const { json: r, meta: s } = t;
498
+ let n = pe(r);
499
+ return s != null && s.values && (n = ds(n, s.values, this)), s != null && s.referentialEqualities && (n = ms(n, s.referentialEqualities)), n;
493
500
  }
494
- stringify(r) {
495
- return JSON.stringify(this.serialize(r));
501
+ stringify(t) {
502
+ return JSON.stringify(this.serialize(t));
496
503
  }
497
- parse(r) {
498
- return this.deserialize(JSON.parse(r));
504
+ parse(t) {
505
+ return this.deserialize(JSON.parse(t));
499
506
  }
500
- registerClass(r, t) {
501
- this.classRegistry.register(r, t);
507
+ registerClass(t, r) {
508
+ this.classRegistry.register(t, r);
502
509
  }
503
- registerSymbol(r, t) {
504
- this.symbolRegistry.register(r, t);
510
+ registerSymbol(t, r) {
511
+ this.symbolRegistry.register(t, r);
505
512
  }
506
- registerCustom(r, t) {
513
+ registerCustom(t, r) {
507
514
  this.customTransformerRegistry.register(g({
508
- name: t
509
- }, r));
510
- }
511
- allowErrorProps(...r) {
512
- this.allowedErrorProps.push(...r);
513
- }
514
- }
515
- l.defaultInstance = new l();
516
- l.serialize = l.defaultInstance.serialize.bind(l.defaultInstance);
517
- l.deserialize = l.defaultInstance.deserialize.bind(l.defaultInstance);
518
- l.stringify = l.defaultInstance.stringify.bind(l.defaultInstance);
519
- l.parse = l.defaultInstance.parse.bind(l.defaultInstance);
520
- l.registerClass = l.defaultInstance.registerClass.bind(l.defaultInstance);
521
- l.registerSymbol = l.defaultInstance.registerSymbol.bind(l.defaultInstance);
522
- l.registerCustom = l.defaultInstance.registerCustom.bind(l.defaultInstance);
523
- l.allowErrorProps = l.defaultInstance.allowErrorProps.bind(l.defaultInstance);
524
- const R = (e) => e === void 0 ? ie.None : e, Rt = (e) => new or(e.metadataItem, e.type), ae = (e) => new Cr(
515
+ name: r
516
+ }, t));
517
+ }
518
+ allowErrorProps(...t) {
519
+ this.allowedErrorProps.push(...t);
520
+ }
521
+ }
522
+ y.defaultInstance = new y();
523
+ y.serialize = y.defaultInstance.serialize.bind(y.defaultInstance);
524
+ y.deserialize = y.defaultInstance.deserialize.bind(y.defaultInstance);
525
+ y.stringify = y.defaultInstance.stringify.bind(y.defaultInstance);
526
+ y.parse = y.defaultInstance.parse.bind(y.defaultInstance);
527
+ y.registerClass = y.defaultInstance.registerClass.bind(y.defaultInstance);
528
+ y.registerSymbol = y.defaultInstance.registerSymbol.bind(y.defaultInstance);
529
+ y.registerCustom = y.defaultInstance.registerCustom.bind(y.defaultInstance);
530
+ y.allowErrorProps = y.defaultInstance.allowErrorProps.bind(y.defaultInstance);
531
+ const z = (e) => e === void 0 ? B.None : e, Fs = (e) => new Vt(e.metadataItem, e.type), we = (e) => new ar(
525
532
  e.name,
526
533
  e.expression,
527
534
  e.type,
528
535
  e.description,
529
- R(e.sort),
536
+ z(e.sort),
530
537
  e.dataSource,
531
538
  e.composeCode
532
- ), ue = (e) => new $r(
539
+ ), qe = (e) => new ur(
533
540
  e.name,
534
541
  e.expression,
535
542
  e.granularity,
536
543
  e.format,
537
544
  e.description,
538
- R(e.sort),
545
+ z(e.sort),
539
546
  e.dataSource,
540
547
  e.composeCode
541
- ), q = (e) => {
548
+ ), D = (e) => {
542
549
  switch (e.__serializable) {
543
550
  case "DimensionalAttribute":
544
- return ae(e);
551
+ return we(e);
545
552
  case "DimensionalLevelAttribute":
546
- return ue(e);
553
+ return qe(e);
547
554
  default:
548
555
  return e;
549
556
  }
550
- }, _e = (e) => new et(
557
+ }, gt = (e) => new Lr(
551
558
  e.name,
552
559
  e.expression,
553
- e.attributes.map(q),
554
- e.dimensions.map(Ot),
560
+ e.attributes.map(D),
561
+ e.dimensions.map(ws),
555
562
  e.type,
556
563
  e.description,
557
- R(e.sort),
564
+ z(e.sort),
558
565
  e.dataSource,
559
566
  e.composeCode,
560
- e.defaultAttribute ? q(e.defaultAttribute) : void 0
561
- ), Ue = (e) => new rt(
567
+ e.defaultAttribute ? D(e.defaultAttribute) : void 0
568
+ ), ht = (e) => new _r(
562
569
  e.name,
563
570
  e.expression,
564
571
  e.description,
565
- R(e.sort),
572
+ z(e.sort),
566
573
  e.dataSource,
567
- e.composeCode
568
- ), Ot = (e) => {
574
+ e.composeCode,
575
+ e.indexed,
576
+ e.merged
577
+ ), ws = (e) => {
569
578
  switch (e.__serializable) {
570
579
  case "DimensionalDimension":
571
- return _e(e);
580
+ return gt(e);
572
581
  case "DimensionalDateDimension":
573
- return Ue(e);
582
+ return ht(e);
574
583
  default:
575
584
  return e;
576
585
  }
577
- }, ce = (e) => new Ar(
586
+ }, Ae = (e) => new cr(
578
587
  e.name,
579
- q(e.attribute),
588
+ D(e.attribute),
580
589
  e.aggregation,
581
590
  e.format,
582
591
  e.description,
583
- R(e.sort),
592
+ z(e.sort),
584
593
  e.dataSource,
585
594
  e.composeCode
586
- ), le = (e) => {
587
- const r = Object.fromEntries(
588
- Object.entries(e.context).map(([t, s]) => {
595
+ ), Ce = (e) => {
596
+ const t = Object.fromEntries(
597
+ Object.entries(e.context).map(([r, s]) => {
589
598
  if (s && typeof s == "object" && "__serializable" in s)
590
599
  switch (s.__serializable) {
591
600
  case "DimensionalAttribute":
592
- return [t, ae(s)];
601
+ return [r, we(s)];
593
602
  case "DimensionalLevelAttribute":
594
- return [t, ue(s)];
603
+ return [r, qe(s)];
595
604
  case "DimensionalBaseMeasure":
596
- return [t, ce(s)];
605
+ return [r, Ae(s)];
597
606
  case "DimensionalCalculatedMeasure":
598
- return [t, le(s)];
607
+ return [r, Ce(s)];
599
608
  default:
600
- return [t, s];
609
+ return [r, s];
601
610
  }
602
- return [t, s];
611
+ return [r, s];
603
612
  })
604
613
  );
605
- return new xr(
614
+ return new lr(
606
615
  e.name,
607
616
  e.expression,
608
- r,
617
+ t,
609
618
  e.format,
610
619
  e.description,
611
- R(e.sort),
620
+ z(e.sort),
612
621
  e.dataSource,
613
622
  e.composeCode
614
623
  );
615
- }, We = (e) => new Dr(
624
+ }, bt = (e) => new fr(
616
625
  e.name,
617
- q(e.attribute),
626
+ D(e.attribute),
618
627
  e.format,
619
628
  e.description,
620
- R(e.sort),
629
+ z(e.sort),
621
630
  e.dataSource,
622
631
  e.composeCode
623
- ), H = (e) => {
632
+ ), ue = (e) => {
624
633
  switch (e.__serializable) {
625
634
  case "DimensionalBaseMeasure":
626
- return ce(e);
635
+ return Ae(e);
627
636
  case "DimensionalCalculatedMeasure":
628
- return le(e);
637
+ return Ce(e);
629
638
  case "DimensionalMeasureTemplate":
630
- return We(e);
639
+ return bt(e);
631
640
  default:
632
641
  return e;
633
642
  }
634
- }, b = (e) => {
643
+ }, C = (e) => {
635
644
  switch (e.__serializable) {
636
645
  case "MembersFilter":
637
- return new Lr(
638
- q(e.attribute),
646
+ return new Cr(
647
+ D(e.attribute),
639
648
  e.members,
640
- e.config.backgroundFilter ? h(g({}, e.config), { backgroundFilter: b(e.config.backgroundFilter) }) : e.config,
649
+ e.config.backgroundFilter ? F(g({}, e.config), { backgroundFilter: C(e.config.backgroundFilter) }) : e.config,
641
650
  e.composeCode
642
651
  );
643
652
  case "LogicalAttributeFilter":
644
- return new kr(
645
- e.filters.map((t) => b(t)),
653
+ return new Ar(
654
+ e.filters.map((r) => C(r)),
646
655
  e.operator,
647
656
  e.config,
648
657
  e.composeCode
649
658
  );
650
659
  case "CascadingFilter":
651
- return new Pr(
652
- e._filters.map((t) => b(t)),
660
+ return new qr(
661
+ e._filters.map((r) => C(r)),
653
662
  e.config,
654
663
  e.composeCode
655
664
  );
656
665
  case "ExcludeFilter":
657
- return new Br(
658
- b(e.filter),
659
- e.input ? b(e.input) : void 0,
666
+ return new wr(
667
+ C(e.filter),
668
+ e.input ? C(e.input) : void 0,
660
669
  e.config,
661
670
  e.composeCode
662
671
  );
663
672
  case "MeasureFilter":
664
- return new zr(
665
- q(e.attribute),
666
- H(e.measure),
673
+ return new Fr(
674
+ D(e.attribute),
675
+ ue(e.measure),
667
676
  e.operatorA,
668
677
  e.valueA,
669
678
  e.operatorB,
@@ -672,25 +681,25 @@ const R = (e) => e === void 0 ? ie.None : e, Rt = (e) => new or(e.metadataItem,
672
681
  e.composeCode
673
682
  );
674
683
  case "RankingFilter":
675
- return new Ir(
676
- q(e.attribute),
677
- H(e.measure),
684
+ return new br(
685
+ D(e.attribute),
686
+ ue(e.measure),
678
687
  e.operator,
679
688
  e.count,
680
689
  e.config,
681
690
  e.composeCode
682
691
  );
683
692
  case "MeasureRankingFilter":
684
- return new Or(
685
- H(e.measure),
693
+ return new hr(
694
+ ue(e.measure),
686
695
  e.operator,
687
696
  e.count,
688
697
  e.config,
689
698
  e.composeCode
690
699
  );
691
700
  case "NumericFilter":
692
- return new Rr(
693
- q(e.attribute),
701
+ return new gr(
702
+ D(e.attribute),
694
703
  e.operatorA,
695
704
  e.valueA,
696
705
  e.operatorB,
@@ -699,26 +708,26 @@ const R = (e) => e === void 0 ? ie.None : e, Rt = (e) => new or(e.metadataItem,
699
708
  e.composeCode
700
709
  );
701
710
  case "TextFilter":
702
- return new Nr(
703
- q(e.attribute),
711
+ return new yr(
712
+ D(e.attribute),
704
713
  e.operatorA,
705
714
  e.valueA,
706
715
  e.config,
707
716
  e.composeCode
708
717
  );
709
718
  case "DateRangeFilter": {
710
- const { valueA: t, valueB: s } = e;
711
- return new Tr(
712
- q(e.attribute),
713
- t,
719
+ const { valueA: r, valueB: s } = e;
720
+ return new pr(
721
+ D(e.attribute),
722
+ r,
714
723
  s,
715
724
  e.config,
716
725
  e.composeCode
717
726
  );
718
727
  }
719
728
  case "RelativeDateFilter":
720
- return new Sr(
721
- q(e.attribute),
729
+ return new mr(
730
+ D(e.attribute),
722
731
  e.offset,
723
732
  e.count,
724
733
  e.operator,
@@ -727,8 +736,8 @@ const R = (e) => e === void 0 ? ie.None : e, Rt = (e) => new or(e.metadataItem,
727
736
  e.composeCode
728
737
  );
729
738
  case "CustomFilter":
730
- return new Mr(
731
- q(e.attribute),
739
+ return new dr(
740
+ D(e.attribute),
732
741
  e.jaqlExpression,
733
742
  e.config,
734
743
  e.composeCode
@@ -737,433 +746,510 @@ const R = (e) => e === void 0 ? ie.None : e, Rt = (e) => new or(e.metadataItem,
737
746
  return e;
738
747
  }
739
748
  };
740
- l.registerCustom(
749
+ y.registerCustom(
741
750
  {
742
- isApplicable: ir,
751
+ isApplicable: jt,
743
752
  serialize: (e) => e.serialize(),
744
- deserialize: (e) => Rt(e)
753
+ deserialize: (e) => Fs(e)
745
754
  },
746
755
  "JaqlElement"
747
756
  );
748
- l.registerCustom(
757
+ y.registerCustom(
749
758
  {
750
- isApplicable: ar,
759
+ isApplicable: Wt,
751
760
  serialize: (e) => e.serialize(),
752
- deserialize: (e) => ae(e)
761
+ deserialize: (e) => we(e)
753
762
  },
754
763
  "DimensionalAttribute"
755
764
  );
756
- l.registerCustom(
765
+ y.registerCustom(
757
766
  {
758
- isApplicable: ur,
767
+ isApplicable: Kt,
759
768
  serialize: (e) => e.serialize(),
760
- deserialize: (e) => ue(e)
769
+ deserialize: (e) => qe(e)
761
770
  },
762
771
  "DimensionalLevelAttribute"
763
772
  );
764
- l.registerCustom(
773
+ y.registerCustom(
765
774
  {
766
- isApplicable: Xr,
775
+ isApplicable: zr,
767
776
  serialize: (e) => e.serialize(),
768
- deserialize: (e) => _e(e)
777
+ deserialize: (e) => gt(e)
769
778
  },
770
779
  "DimensionalDimension"
771
780
  );
772
- l.registerCustom(
781
+ y.registerCustom(
773
782
  {
774
- isApplicable: vr,
783
+ isApplicable: Pr,
775
784
  serialize: (e) => e.serialize(),
776
- deserialize: (e) => Ue(e)
785
+ deserialize: (e) => ht(e)
777
786
  },
778
787
  "DimensionalDateDimension"
779
788
  );
780
- l.registerCustom(
789
+ y.registerCustom(
781
790
  {
782
- isApplicable: cr,
791
+ isApplicable: Jt,
783
792
  serialize: (e) => e.serialize(),
784
- deserialize: (e) => ce(e)
793
+ deserialize: (e) => Ae(e)
785
794
  },
786
795
  "DimensionalBaseMeasure"
787
796
  );
788
- l.registerCustom(
797
+ y.registerCustom(
789
798
  {
790
- isApplicable: lr,
799
+ isApplicable: Yt,
791
800
  serialize: (e) => e.serialize(),
792
- deserialize: (e) => le(e)
801
+ deserialize: (e) => Ce(e)
793
802
  },
794
803
  "DimensionalCalculatedMeasure"
795
804
  );
796
- l.registerCustom(
805
+ y.registerCustom(
797
806
  {
798
- isApplicable: fr,
807
+ isApplicable: Gt,
799
808
  serialize: (e) => e.serialize(),
800
- deserialize: (e) => We(e)
809
+ deserialize: (e) => bt(e)
801
810
  },
802
811
  "DimensionalMeasureTemplate"
803
812
  );
804
- l.registerCustom(
813
+ y.registerCustom(
805
814
  {
806
- isApplicable: ne,
815
+ isApplicable: be,
807
816
  serialize: (e) => e.serialize(),
808
- deserialize: (e) => b(e)
817
+ deserialize: (e) => C(e)
809
818
  },
810
819
  "MembersFilter"
811
820
  );
812
- l.registerCustom(
821
+ y.registerCustom(
813
822
  {
814
- isApplicable: dr,
823
+ isApplicable: Qt,
815
824
  serialize: (e) => e.serialize(),
816
- deserialize: (e) => b(e)
825
+ deserialize: (e) => C(e)
817
826
  },
818
827
  "LogicalAttributeFilter"
819
828
  );
820
- l.registerCustom(
829
+ y.registerCustom(
821
830
  {
822
- isApplicable: mr,
831
+ isApplicable: Ht,
823
832
  serialize: (e) => e.serialize(),
824
- deserialize: (e) => b(e)
833
+ deserialize: (e) => C(e)
825
834
  },
826
835
  "CascadingFilter"
827
836
  );
828
- l.registerCustom(
837
+ y.registerCustom(
829
838
  {
830
- isApplicable: pr,
839
+ isApplicable: Xt,
831
840
  serialize: (e) => e.serialize(),
832
- deserialize: (e) => b(e)
841
+ deserialize: (e) => C(e)
833
842
  },
834
843
  "ExcludeFilter"
835
844
  );
836
- l.registerCustom(
845
+ y.registerCustom(
837
846
  {
838
- isApplicable: yr,
847
+ isApplicable: Zt,
839
848
  serialize: (e) => e.serialize(),
840
- deserialize: (e) => b(e)
849
+ deserialize: (e) => C(e)
841
850
  },
842
851
  "MeasureFilter"
843
852
  );
844
- l.registerCustom(
853
+ y.registerCustom(
845
854
  {
846
- isApplicable: gr,
855
+ isApplicable: er,
847
856
  serialize: (e) => e.serialize(),
848
- deserialize: (e) => b(e)
857
+ deserialize: (e) => C(e)
849
858
  },
850
859
  "RankingFilter"
851
860
  );
852
- l.registerCustom(
861
+ y.registerCustom(
853
862
  {
854
- isApplicable: hr,
863
+ isApplicable: tr,
855
864
  serialize: (e) => e.serialize(),
856
- deserialize: (e) => b(e)
865
+ deserialize: (e) => C(e)
857
866
  },
858
867
  "MeasureRankingFilter"
859
868
  );
860
- l.registerCustom(
869
+ y.registerCustom(
861
870
  {
862
- isApplicable: br,
871
+ isApplicable: rr,
863
872
  serialize: (e) => e.serialize(),
864
- deserialize: (e) => b(e)
873
+ deserialize: (e) => C(e)
865
874
  },
866
875
  "NumericFilter"
867
876
  );
868
- l.registerCustom(
877
+ y.registerCustom(
869
878
  {
870
- isApplicable: Fr,
879
+ isApplicable: sr,
871
880
  serialize: (e) => e.serialize(),
872
- deserialize: (e) => b(e)
881
+ deserialize: (e) => C(e)
873
882
  },
874
883
  "TextFilter"
875
884
  );
876
- l.registerCustom(
885
+ y.registerCustom(
877
886
  {
878
- isApplicable: wr,
887
+ isApplicable: nr,
879
888
  serialize: (e) => e.serialize(),
880
- deserialize: (e) => b(e)
889
+ deserialize: (e) => C(e)
881
890
  },
882
891
  "DateRangeFilter"
883
892
  );
884
- l.registerCustom(
893
+ y.registerCustom(
885
894
  {
886
- isApplicable: qr,
895
+ isApplicable: ir,
887
896
  serialize: (e) => e.serialize(),
888
- deserialize: (e) => b(e)
897
+ deserialize: (e) => C(e)
889
898
  },
890
899
  "RelativeDateFilter"
891
900
  );
892
- l.registerCustom(
901
+ y.registerCustom(
893
902
  {
894
- isApplicable: Er,
903
+ isApplicable: or,
895
904
  serialize: (e) => e.serialize(),
896
- deserialize: (e) => b(e)
905
+ deserialize: (e) => C(e)
897
906
  },
898
907
  "CustomFilter"
899
908
  );
900
- const Ps = l, F = "DM.";
909
+ const Kn = y, q = "DM.";
910
+ function T(e) {
911
+ return typeof e == "object" && e !== null;
912
+ }
901
913
  function E(e) {
902
914
  return typeof e == "object" && e !== null && "function" in e && "args" in e;
903
915
  }
904
- function je(e) {
916
+ function Ft(e) {
905
917
  return e.every(E);
906
918
  }
907
- function K(e) {
919
+ function ne(e) {
908
920
  return "attribute" in e && "config" in e;
909
921
  }
910
- function U(e) {
922
+ function X(e) {
911
923
  return "left" in e && "right" in e && "operator" in e;
912
924
  }
913
- function fe(e) {
914
- return !K(e) && !U(e);
925
+ function Ee(e) {
926
+ return !ne(e) && !X(e);
915
927
  }
916
- function It(e) {
917
- return typeof e == "object" && e !== null && "column" in e && typeof e.column == "string" && !("function" in e && "args" in e);
928
+ function qs(e) {
929
+ return T(e) && "column" in e && typeof e.column == "string" && !("function" in e && "args" in e);
918
930
  }
919
- function zt(e) {
920
- const r = e;
921
- return typeof e != "object" || e === null || r === null || !("column" in r) ? !1 : E(r.column);
931
+ function As(e) {
932
+ return !T(e) || !("column" in e) ? !1 : E(e.column);
922
933
  }
923
- function Bt(e) {
924
- const r = [...e].sort((o, i) => i.name.length - o.name.length), t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
925
- for (const o of e) {
926
- t.set(o.name, o);
927
- const i = [...o.columns].sort((u, c) => c.name.length - u.name.length);
928
- n.set(o.name, i);
934
+ const x = 3;
935
+ function M(e, t, r) {
936
+ if (t.length === 0) return;
937
+ let s = Number.MAX_SAFE_INTEGER, n;
938
+ for (const i of t) {
939
+ const o = r(i), a = jr(e, o);
940
+ a < s && (s = a, n = i);
941
+ }
942
+ return n !== void 0 ? { best: n, distance: s } : void 0;
943
+ }
944
+ function xe(e) {
945
+ const t = [...e].sort((i, o) => o.name.length - i.name.length), r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
946
+ for (const i of e) {
947
+ r.set(i.name, i);
948
+ const o = [...i.columns].sort((u, c) => c.name.length - u.name.length);
949
+ n.set(i.name, o);
929
950
  const a = /* @__PURE__ */ new Map();
930
- for (const u of o.columns)
951
+ for (const u of i.columns)
931
952
  a.set(u.name, u);
932
- s.set(o.name, a);
953
+ s.set(i.name, a);
933
954
  }
934
955
  return {
935
- sortedTables: r,
956
+ sortedTables: t,
936
957
  tableColumnMap: n,
937
- tableMap: t,
958
+ tableMap: r,
938
959
  columnMap: s
939
960
  };
940
961
  }
941
- function Je(e, r) {
942
- if (!e.startsWith(F))
962
+ function $e(e, t) {
963
+ if (!e.startsWith(q))
943
964
  throw new Error(
944
- `Invalid dimensional element name format: "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`
965
+ `Invalid dimensional element name format: '${e}'. Expected format: '${q}TableName.ColumnName[.Level]'`
945
966
  );
946
- const t = e.slice(F.length);
947
- if (!t)
967
+ const r = e.slice(q.length);
968
+ if (!r)
948
969
  throw new Error(
949
- `Invalid dimensional element name format: "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`
970
+ `Invalid dimensional element name format: '${e}'. Expected format: '${q}TableName.ColumnName[.Level]'`
950
971
  );
951
972
  let s, n;
952
- for (const m of r.sortedTables)
953
- if (t.startsWith(m.name + ".")) {
954
- const y = t.slice(m.name.length + 1);
955
- if (!y)
973
+ for (const d of t.sortedTables)
974
+ if (r.startsWith(d.name + ".")) {
975
+ const b = r.slice(d.name.length + 1);
976
+ if (!b)
956
977
  throw new Error(
957
- `Invalid dimensional element name format: "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`
978
+ `Invalid dimensional element name format: '${e}'. Expected format: '${q}TableName.ColumnName[.Level]'`
958
979
  );
959
- s = m, n = y;
980
+ s = d, n = b;
960
981
  break;
961
982
  }
962
983
  if (!s) {
963
- const m = t.indexOf(".");
964
- if (m === -1)
984
+ const d = r.indexOf(".");
985
+ if (d === -1)
965
986
  throw new Error(
966
- `Invalid dimensional element name format: "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`
987
+ `Invalid dimensional element name format: '${e}'. Expected format: '${q}TableName.ColumnName[.Level]'`
967
988
  );
968
- const y = t.slice(0, m);
969
- throw new Error(`Table "${y}" not found in the data model`);
970
- }
971
- const o = r.tableColumnMap.get(s.name);
972
- if (!o)
973
- throw new Error(`Table "${s.name}" found but has no columns`);
974
- let i, a;
975
- const u = W.all;
976
- for (const m of o) {
977
- if (n === m.name)
978
- return { table: s, column: m };
979
- if (!n.startsWith(m.name + "."))
989
+ const b = r.slice(0, d), A = M(b, t.sortedTables, (oe) => oe.name), O = A && A.distance <= x ? ` Did you mean '${A.best.name}'?` : "";
990
+ throw new Error(`Table '${b}' not found in the data model.${O}`);
991
+ }
992
+ const i = t.tableColumnMap.get(s.name);
993
+ if (!i)
994
+ throw new Error(`Table '${s.name}' found but has no columns`);
995
+ let o, a;
996
+ const u = $.all;
997
+ for (const d of i) {
998
+ if (n === d.name)
999
+ return { table: s, column: d };
1000
+ if (!n.startsWith(d.name + "."))
980
1001
  continue;
981
- const y = n.slice(m.name.length + 1);
982
- if (!y)
1002
+ const b = n.slice(d.name.length + 1);
1003
+ if (!b)
983
1004
  continue;
984
- const x = u.includes(y), f = oe(m.dataType);
985
- if (x) {
986
- if (f)
987
- return { table: s, column: m, level: y };
988
- i || (i = m, a = y);
1005
+ const A = u.includes(b), O = H(d.dataType);
1006
+ if (A) {
1007
+ if (O)
1008
+ return { table: s, column: d, level: b };
1009
+ o || (o = d, a = b);
989
1010
  continue;
990
1011
  }
991
- f && !i && (i = m, a = y);
1012
+ O && !o && (o = d, a = b);
992
1013
  }
993
- if (i && a)
994
- throw u.includes(a) ? new Error(
995
- `Invalid date level "${a}" in dimensional element "${e}". Column "${s.name}.${i.name}" is not a datetime column`
996
- ) : new Error(
997
- `Invalid date level "${a}" in dimensional element "${e}". Valid levels are: ${u.join(
1014
+ if (o && a) {
1015
+ if (u.includes(a))
1016
+ throw new Error(
1017
+ `Invalid date level '${a}' in dimensional element '${e}'. Column '${s.name}.${o.name}' is not a datetime column`
1018
+ );
1019
+ const d = M(a, u, (A) => A), b = d && d.distance <= x ? ` Did you mean '${d.best}'?` : "";
1020
+ throw new Error(
1021
+ `Invalid date level '${a}' in dimensional element '${e}'. Valid levels are: ${u.join(
998
1022
  ", "
999
- )}`
1023
+ )}.${b}`
1000
1024
  );
1001
- const c = n.indexOf("."), p = c === -1 ? n : n.slice(0, c);
1002
- throw new Error(`Column "${p}" not found in table "${s.name}"`);
1025
+ }
1026
+ const c = n.indexOf("."), m = c === -1 ? n : n.slice(0, c), l = M(n, i, (d) => d.name), f = l && l.distance <= x && l.best.name !== m, h = f ? ` Did you mean '${l.best.name}'?` : "", p = !f && n.endsWith(".") && (l == null ? void 0 : l.best.name) === m ? ` Use '${m}' without a trailing dot.` : "";
1027
+ throw new Error(
1028
+ `Column '${m}' not found in table '${s.name}'.${h}${p}`
1029
+ );
1003
1030
  }
1004
- function Pt(e, r) {
1005
- const { table: t, column: s, level: n } = Je(e, r);
1031
+ function Cs(e, t) {
1032
+ const { table: r, column: s, level: n } = $e(e, t);
1006
1033
  if (n) {
1007
- if (!oe(s.dataType))
1034
+ if (!H(s.dataType))
1008
1035
  throw new Error(
1009
- `Invalid date level "${n}" in dimensional element "${e}". Column "${t.name}.${s.name}" is not a datetime column`
1036
+ `Invalid date level '${n}' in dimensional element '${e}'. Column '${r.name}.${s.name}' is not a datetime column`
1010
1037
  );
1011
- const o = W.all;
1012
- if (!o.includes(n))
1038
+ const i = $.all;
1039
+ if (!i.includes(n))
1013
1040
  throw new Error(
1014
- `Invalid date level "${n}" in dimensional element "${e}". Valid levels are: ${o.join(
1041
+ `Invalid date level '${n}' in dimensional element '${e}'. Valid levels are: ${i.join(
1015
1042
  ", "
1016
1043
  )}`
1017
1044
  );
1018
- const i = W.dateOnly;
1019
- if (s.dataType === "date" && !i.includes(n))
1045
+ const o = $.dateOnly;
1046
+ if (s.dataType === "date" && !o.includes(n))
1020
1047
  throw new Error(
1021
- `Invalid level "${n}" in dimensional element "${e}". Column "${t.name}.${s.name}" is only a date column, not a datetime column`
1048
+ `Invalid level '${n}' in dimensional element '${e}'. Column '${r.name}.${s.name}' is only a date column, not a datetime column`
1022
1049
  );
1023
- const a = W.timeOnly;
1050
+ const a = $.timeOnly;
1024
1051
  if (s.dataType === "time" && !a.includes(n))
1025
1052
  throw new Error(
1026
- `Invalid level "${n}" in dimensional element "${e}". Column "${t.name}.${s.name}" is only a time column, not a date column`
1053
+ `Invalid level '${n}' in dimensional element '${e}'. Column '${r.name}.${s.name}' is only a time column, not a date column`
1027
1054
  );
1028
1055
  }
1029
- return { column: s, level: n };
1030
- }
1031
- function Ke(e) {
1032
- return e.type === I.TextAttribute;
1033
- }
1034
- function Ge(e) {
1035
- return e.type === I.NumericAttribute;
1036
- }
1037
- function kt(e) {
1038
- return e.type === I.DateLevel;
1039
- }
1040
- function Lt(e) {
1041
- return Ke(e) || Ge(e);
1042
- }
1043
- function G(e) {
1044
- return e.type === I.TextAttribute ? "text" : e.type === I.NumericAttribute ? "numeric" : e.type === I.DateLevel ? "date/datetime" : "unknown";
1056
+ return { table: r, column: s, level: n };
1045
1057
  }
1046
- function Q(e, r, t) {
1047
- const { column: s, level: n } = Pt(e, t);
1048
- return Vr({
1049
- expression: s.expression,
1050
- dataType: s.dataType,
1051
- granularity: n,
1058
+ function G(e, t, r, s) {
1059
+ const { table: n, column: i, level: o } = Cs(e, r);
1060
+ let a = o;
1061
+ if (H(i.dataType) && a === void 0 && (s != null && s.inferredDateLevel)) {
1062
+ const u = s.inferredDateLevel, c = $.all;
1063
+ if (!c.includes(u))
1064
+ throw new Error(
1065
+ `Invalid inferred date level '${u}'. Valid levels are: ${c.join(", ")}`
1066
+ );
1067
+ const m = `${e}.${u}`, l = $.dateOnly;
1068
+ if (i.dataType === "date" && !l.includes(u))
1069
+ throw new Error(
1070
+ `Invalid level '${u}' in dimensional element '${m}'. Column '${n.name}.${i.name}' is only a date column, not a datetime column`
1071
+ );
1072
+ const f = $.timeOnly;
1073
+ if (i.dataType === "time" && !f.includes(u))
1074
+ throw new Error(
1075
+ `Invalid level '${u}' in dimensional element '${m}'. Column '${n.name}.${i.name}' is only a time column, not a date column`
1076
+ );
1077
+ a = u;
1078
+ }
1079
+ return Er({
1080
+ expression: i.expression,
1081
+ dataType: i.dataType,
1082
+ granularity: a,
1052
1083
  format: void 0,
1053
1084
  sort: void 0,
1054
- dataSource: r
1085
+ dataSource: t
1055
1086
  });
1056
1087
  }
1057
- function Vt(e, r, t) {
1058
- const { column: s, level: n } = Je(e, t);
1088
+ function Es(e, t, r) {
1089
+ const { column: s, level: n } = $e(e, r);
1059
1090
  if (n)
1060
1091
  throw new Error(
1061
- `Invalid DateDimension name format: "${e}". Expected format: "${F}TableName.ColumnName"`
1092
+ `Invalid DateDimension name format: '${e}'. Expected format: '${q}TableName.ColumnName'`
1062
1093
  );
1063
- if (!oe(s.dataType))
1094
+ if (!H(s.dataType))
1064
1095
  throw new Error(
1065
- `Invalid DateDimension name "${e}". Column "${s.name}" is not a datetime column (got ${s.dataType}).`
1096
+ `Invalid DateDimension name '${e}'. Column '${s.name}' is not a datetime column (got ${s.dataType}).`
1066
1097
  );
1067
- return tt({
1098
+ return Ur({
1068
1099
  name: s.name,
1069
1100
  expression: s.expression,
1070
- dataSource: r
1101
+ dataSource: t
1071
1102
  });
1072
1103
  }
1073
- function M(e, r) {
1074
- const t = e();
1075
- return t.success ? t.data : (r.push(...t.errors), null);
1076
- }
1077
- const _t = (e, r, t) => {
1078
- if (!r)
1079
- return { attribute: e };
1080
- const s = typeof r == "object" ? r.direction : r;
1081
- return $e(s) ? { attribute: e.sort(Ae(s)) } : {
1082
- attribute: e,
1083
- error: h(g({}, t), {
1084
- message: `Invalid sort type. Expected "sortAsc", "sortDesc", or "sortNone". Got: "${s}".`
1085
- })
1086
- };
1087
- }, Ut = (e, r, t, s) => {
1088
- const n = Q(e.column, r, t);
1089
- return _t(n, e.sortType, s);
1090
- }, Wt = (e, r, t, s) => typeof e == "string" ? { attribute: Q(e, r, t) } : It(e) ? Ut(e, r, t, s) : {
1091
- error: h(g({}, s), {
1092
- message: 'Invalid dimension item. Expected a string (composeCode) or object with "column" and optional "sortType".'
1104
+ const xs = (e, t) => {
1105
+ if (!e) return;
1106
+ const r = typeof e == "object" ? e.direction : e;
1107
+ if (!te(r))
1108
+ return F(g({}, t), {
1109
+ message: `Invalid sort type. Expected 'sortAsc', 'sortDesc', or 'sortNone'. Got: '${r}'.`
1110
+ });
1111
+ }, $s = (e, t, r, s) => {
1112
+ const n = xs(e.sortType, s);
1113
+ if (n)
1114
+ return {
1115
+ attribute: G(e.column, t, r),
1116
+ style: {},
1117
+ error: n
1118
+ };
1119
+ const i = G(e.column, t, r), o = _(e, "column");
1120
+ return { attribute: i, style: o };
1121
+ }, Ts = (e, t, r, s) => typeof e == "string" ? { attribute: G(e, t, r) } : qs(e) ? $s(e, t, r, s) : {
1122
+ error: F(g({}, s), {
1123
+ message: "Invalid dimension item. Expected a string (composeCode) or object with 'column' and optional 'sortType'."
1093
1124
  })
1094
- }, jt = (e) => {
1095
- const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context;
1096
- if (!r)
1125
+ }, wt = (e) => {
1126
+ const { data: t } = e, { dataSource: r, schemaIndex: s } = e.context;
1127
+ if (!t)
1097
1128
  return { success: !0, data: [] };
1098
- if (!Array.isArray(r))
1129
+ if (!Array.isArray(t))
1099
1130
  return {
1100
1131
  success: !1,
1101
1132
  errors: [
1102
1133
  {
1103
1134
  category: "dimensions",
1104
1135
  index: -1,
1105
- input: r,
1136
+ input: t,
1106
1137
  message: "Invalid dimensions JSON. Expected an array."
1107
1138
  }
1108
1139
  ]
1109
1140
  };
1110
- const n = [], o = [];
1111
- return r.forEach((i, a) => {
1141
+ const n = [], i = [];
1142
+ return t.forEach((o, a) => {
1112
1143
  const u = {
1113
1144
  category: "dimensions",
1114
1145
  index: a,
1115
- input: i
1146
+ input: o
1116
1147
  };
1117
1148
  try {
1118
- const c = Wt(i, t, s, u);
1149
+ const c = Ts(o, r, s, u);
1119
1150
  if (c.error) {
1120
- o.push(c.error);
1151
+ i.push(c.error);
1121
1152
  return;
1122
1153
  }
1123
- c.attribute && n.push(c.attribute);
1154
+ c.attribute && n.push(
1155
+ c.style !== void 0 ? { attribute: c.attribute, style: c.style } : { attribute: c.attribute }
1156
+ );
1124
1157
  } catch (c) {
1125
- const p = c instanceof Error ? c.message : "Unknown error";
1126
- o.push(h(g({}, u), { message: p }));
1158
+ const m = c instanceof Error ? c.message : "Unknown error";
1159
+ i.push(F(g({}, u), { message: m }));
1127
1160
  }
1128
- }), o.length > 0 ? { success: !1, errors: o } : { success: !0, data: n };
1161
+ }), i.length > 0 ? { success: !1, errors: i } : { success: !0, data: n };
1129
1162
  };
1130
- function de(e, r) {
1131
- const t = Reflect.get(e, r);
1132
- if (typeof t != "function")
1133
- throw new Error(`Function "${r}" not found or is not a function`);
1134
- return t;
1163
+ function Te(e, t) {
1164
+ const r = Reflect.get(e, t);
1165
+ if (typeof r != "function")
1166
+ throw new Error(`Function '${t}' not found or is not a function`);
1167
+ return r;
1135
1168
  }
1136
- function Jt(e, r) {
1137
- const t = e.replace("measureFactory.", ""), n = de(_r, t)(...r);
1138
- if (!fe(n))
1139
- throw new Error(`Function "${e}" did not return a valid Measure`);
1169
+ function Ds(e, t) {
1170
+ const r = e.replace("measureFactory.", ""), n = Te(xr, r)(...t);
1171
+ if (!Ee(n))
1172
+ throw new Error(`Function '${e}' did not return a valid Measure`);
1140
1173
  return n;
1141
1174
  }
1142
- function Kt(e, r) {
1143
- const t = e.replace("filterFactory.logic.", ""), n = de(Ur, t)(...r);
1144
- if (!U(n))
1145
- throw new Error(`Function "${e}" did not return a valid FilterRelations`);
1175
+ function Ss(e, t) {
1176
+ const r = e.replace("filterFactory.logic.", ""), n = Te($r, r)(...t);
1177
+ if (!X(n))
1178
+ throw new Error(`Function '${e}' did not return a valid FilterRelations`);
1146
1179
  return n;
1147
1180
  }
1148
- function Gt(e, r) {
1181
+ function Os(e, t) {
1149
1182
  if (e.startsWith("filterFactory.logic."))
1150
- return Kt(e, r);
1151
- const t = e.replace("filterFactory.", ""), n = de(Wr, t)(...r);
1152
- if (!K(n) && !U(n))
1153
- throw new Error(`Function "${e}" did not return a valid Filter or FilterRelations`);
1183
+ return Ss(e, t);
1184
+ const r = e.replace("filterFactory.", ""), n = Te(Tr, r)(...t);
1185
+ if (!ne(n) && !X(n))
1186
+ throw new Error(`Function '${e}' did not return a valid Filter or FilterRelations`);
1154
1187
  return n;
1155
1188
  }
1156
- function Qt(e, r) {
1189
+ function Ms(e, t) {
1157
1190
  const s = e.split(".")[0];
1158
1191
  if (s === "measureFactory")
1159
- return Jt(e, r);
1192
+ return Ds(e, t);
1160
1193
  if (s === "filterFactory")
1161
- return Gt(e, r);
1194
+ return Os(e, t);
1162
1195
  throw new Error(
1163
- `Unsupported factory: "${s}". Supported factories: measureFactory, filterFactory`
1196
+ `Unsupported factory: '${s}'. Supported factories: measureFactory, filterFactory`
1164
1197
  );
1165
1198
  }
1166
- const Yt = /\[(\w[\w.-]*)\]/g, Qe = /* @__PURE__ */ new Set([
1199
+ const ye = {
1200
+ SDIFF: {
1201
+ category: "time-diff",
1202
+ argCount: 2,
1203
+ requiredDateLevel: $.Seconds,
1204
+ argType: "datetime"
1205
+ },
1206
+ MNDIFF: {
1207
+ category: "time-diff",
1208
+ argCount: 2,
1209
+ requiredDateLevel: $.Minutes,
1210
+ argType: "datetime"
1211
+ },
1212
+ HDIFF: {
1213
+ category: "time-diff",
1214
+ argCount: 2,
1215
+ requiredDateLevel: $.Hours,
1216
+ argType: "datetime"
1217
+ },
1218
+ DDIFF: {
1219
+ category: "time-diff",
1220
+ argCount: 2,
1221
+ requiredDateLevel: $.Days,
1222
+ argType: "datetime"
1223
+ },
1224
+ MDIFF: {
1225
+ category: "time-diff",
1226
+ argCount: 2,
1227
+ requiredDateLevel: $.Months,
1228
+ argType: "datetime"
1229
+ },
1230
+ QDIFF: {
1231
+ category: "time-diff",
1232
+ argCount: 2,
1233
+ requiredDateLevel: $.Quarters,
1234
+ argType: "datetime"
1235
+ },
1236
+ YDIFF: {
1237
+ category: "time-diff",
1238
+ argCount: 2,
1239
+ requiredDateLevel: $.Years,
1240
+ argType: "datetime"
1241
+ }
1242
+ }, vs = Object.keys(ye).filter(
1243
+ (e) => ye[e].category === "time-diff"
1244
+ );
1245
+ function qt() {
1246
+ return vs;
1247
+ }
1248
+ function At(e) {
1249
+ const t = ye[e.toUpperCase()];
1250
+ return t == null ? void 0 : t.requiredDateLevel;
1251
+ }
1252
+ const Ns = /\[(\w[\w.-]*)\]/g, Ct = /* @__PURE__ */ new Set([
1167
1253
  // Universal – Aggregative (per Sisense doc: (A) only; Statistical CONTRIBUTION, PERCENTILE, etc. are non-aggregative)
1168
1254
  "AVG",
1169
1255
  "COUNT",
@@ -1191,227 +1277,322 @@ const Yt = /\[(\w[\w.-]*)\]/g, Qe = /* @__PURE__ */ new Set([
1191
1277
  "SKEWP",
1192
1278
  "SKEW",
1193
1279
  "SLOPE"
1194
- ]), Ht = new RegExp(
1195
- `\\b(${Array.from(Qe).join("|")})\\s*\\(`,
1280
+ ]), Rs = new RegExp(
1281
+ `\\b(${Array.from(Ct).join("|")})\\s*\\(`,
1196
1282
  "i"
1197
1283
  );
1198
- function Zt(e) {
1199
- return E(e) ? !0 : typeof e == "string" && e.startsWith(F) ? !1 : e && typeof e == "object" && "kind" in e ? e.kind === "measure" : !0;
1284
+ function Et(e) {
1285
+ return E(e) ? !0 : typeof e == "string" && e.startsWith(q) ? !1 : T(e) && "kind" in e ? e.kind === "measure" : !0;
1200
1286
  }
1201
- function Xt(e) {
1202
- const r = /\b(\w+)\s*\(/g, t = /* @__PURE__ */ new Set();
1287
+ function Is(e) {
1288
+ const t = /\b(\w+)\s*\(/g, r = /* @__PURE__ */ new Set();
1203
1289
  let s;
1204
- for (; (s = r.exec(e)) !== null; ) {
1290
+ for (; (s = t.exec(e)) !== null; ) {
1205
1291
  const n = s[1];
1206
- Qe.has(n.toUpperCase()) || t.add(n);
1292
+ Ct.has(n.toUpperCase()) || r.add(n);
1207
1293
  }
1208
- return Array.from(t);
1294
+ return Array.from(r);
1209
1295
  }
1210
- function vt(e) {
1211
- return e.length === 1 ? `[${e[0]}]` : e.map((r) => `[${r}]`).join(", ");
1296
+ function ks(e) {
1297
+ return e.length === 1 ? `[${e[0]}]` : e.map((t) => `[${t}]`).join(", ");
1212
1298
  }
1213
- function es(e) {
1299
+ function Bs(e) {
1214
1300
  return e.length === 0 ? "" : e.length === 1 ? `${e[0]} is not an aggregative function. ` : `${e.join(", ")} are not aggregative functions. `;
1215
1301
  }
1216
- const B = (e) => e.startsWith("[") ? e : `[${e}]`, Ee = (e) => e.startsWith("[") && e.endsWith("]") ? e.slice(1, -1) : e;
1217
- function rs(e, r, t = {}) {
1218
- const {
1219
- warnUnusedContext: s = !0,
1220
- errorOnUnusedContext: n = !0,
1221
- allowEmptyFormula: o = !1,
1222
- errorPrefix: i = "customFormula validation"
1223
- } = t, a = {
1224
- isValid: !0,
1225
- errors: [],
1226
- warnings: [],
1227
- references: [],
1228
- unusedContextKeys: []
1302
+ const j = (e) => e.startsWith("[") ? e : `[${e}]`, xt = (e) => e.startsWith("[") && e.endsWith("]") ? e.slice(1, -1) : e;
1303
+ function $t(e, t) {
1304
+ if (t.length === 0) return [];
1305
+ const r = t.map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), s = new RegExp(
1306
+ `\\b(${r})\\s*\\(\\s*\\[([^\\]]+)\\]\\s*,\\s*\\[([^\\]]+)\\]\\s*\\)`,
1307
+ "gi"
1308
+ );
1309
+ return [...e.matchAll(s)].map((n) => ({
1310
+ functionName: n[1].toUpperCase(),
1311
+ ref1: n[2].trim(),
1312
+ ref2: n[3].trim()
1313
+ }));
1314
+ }
1315
+ function zs(e, t, r) {
1316
+ var o, a, u;
1317
+ const s = Object.keys(t), n = ((o = r.errorPrefix) != null ? o : "customFormula validation").trim(), i = n === "" ? "" : n.endsWith(" ") ? n : `${n} `;
1318
+ return {
1319
+ formula: e,
1320
+ context: t,
1321
+ contextKeys: s,
1322
+ canonicalContextKeys: new Set(s.map(j)),
1323
+ errorPrefix: i,
1324
+ warnUnusedContext: (a = r.warnUnusedContext) != null ? a : !0,
1325
+ errorOnUnusedContext: (u = r.errorOnUnusedContext) != null ? u : !0,
1326
+ schemaIndex: r.schemaIndex,
1327
+ result: { isValid: !0, errors: [], warnings: [], references: [], unusedContextKeys: [] }
1229
1328
  };
1230
- if (!e || e.trim().length === 0)
1231
- return o || (a.errors.push(`${i}args[1]: Formula cannot be empty`), a.isValid = !1), a;
1232
- const u = /\b\w+\s*\[/gi, c = e.match(u);
1233
- if (c) {
1234
- const f = c[0].replace(/\s*\[.*$/, "");
1235
- a.errors.push(
1236
- `${i}args[1]: Invalid syntax: '${f}' - operator cannot be used before bracket reference without parentheses`
1237
- ), a.isValid = !1;
1238
- }
1239
- a.references = [
1329
+ }
1330
+ function N(e, t) {
1331
+ e.result.errors.push(t), e.result.isValid = !1;
1332
+ }
1333
+ const Ps = /* @__PURE__ */ new Set(["CASE", "WHEN", "THEN", "ELSE", "END", "AND", "OR"]);
1334
+ function Ls(e) {
1335
+ const t = /\b(\w+)\s*\[/gi, r = [...e.formula.matchAll(t)].find(
1336
+ (s) => !Ps.has(s[1].toUpperCase())
1337
+ );
1338
+ r && N(
1339
+ e,
1340
+ `${e.errorPrefix}args[1]: Invalid syntax: '${r[1]}' - operator cannot be used before bracket reference without parentheses`
1341
+ );
1342
+ }
1343
+ function _s(e) {
1344
+ return [
1240
1345
  ...new Set(
1241
- [...e.matchAll(new RegExp(Yt.source, "g"))].map((f) => f[1])
1346
+ [...e.matchAll(new RegExp(Ns.source, "g"))].map((t) => t[1])
1242
1347
  )
1243
1348
  ];
1244
- const p = Object.keys(r);
1245
- if (a.references.length === 0)
1246
- return a.warnings.push(
1247
- `${i}args[1]: No bracket references found in formula - ensure this is intentional`
1248
- ), a;
1249
- if (p.length === 0)
1250
- return a.errors.push(
1251
- `${i}args[2]: Context cannot be empty - custom formulas require context definitions`
1252
- ), a.isValid = !1, a;
1253
- const m = new Set(p.map(B)), y = a.references.filter(
1254
- (f) => !m.has(B(f))
1349
+ }
1350
+ function Us(e) {
1351
+ const t = e.result.references.filter(
1352
+ (n) => !e.canonicalContextKeys.has(j(n))
1353
+ );
1354
+ if (t.length === 0) return;
1355
+ const r = e.contextKeys.map((n) => `[${xt(n)}]`).join(", "), s = t.length === 1 ? `Reference [${t[0]}]` : `References [${t.join("], [")}]`;
1356
+ N(
1357
+ e,
1358
+ `${e.errorPrefix}args[1]: ${s} not found in context. Available keys: ${r}`
1359
+ );
1360
+ }
1361
+ function js(e) {
1362
+ if (Rs.test(e.formula)) return;
1363
+ const t = e.result.references.filter((r) => {
1364
+ var n;
1365
+ const s = (n = e.context[j(r)]) != null ? n : e.context[r];
1366
+ return s !== void 0 && !Et(s);
1367
+ });
1368
+ t.length !== 0 && N(
1369
+ e,
1370
+ `${e.errorPrefix}args[1]: ${Bs(
1371
+ Is(e.formula)
1372
+ )}Bracket reference(s) ${ks(
1373
+ t
1374
+ )} point to raw attributes and must be wrapped in an aggregative function (e.g. SUM, AVG)`
1255
1375
  );
1256
- if (y.length > 0) {
1257
- a.isValid = !1;
1258
- const f = p.map((d) => `[${Ee(d)}]`).join(", ");
1259
- y.length === 1 ? a.errors.push(
1260
- `${i}args[1]: Reference [${y[0]}] not found in context. Available keys: ${f}`
1261
- ) : a.errors.push(
1262
- `${i}args[1]: References [${y.join(
1263
- "], ["
1264
- )}] not found in context. Available keys: ${f}`
1376
+ }
1377
+ function Vs(e) {
1378
+ if (!e.warnUnusedContext && !e.errorOnUnusedContext || e.contextKeys.length === 0) return;
1379
+ const t = new Set(e.result.references.map(j)), r = e.contextKeys.filter((i) => !t.has(j(i)));
1380
+ if (e.result.unusedContextKeys = r, r.length === 0) return;
1381
+ const s = r.map((i) => `[${xt(i)}]`).join(", "), n = `${e.errorPrefix}args[2]: Context keys ${s} are defined but not used in formula`;
1382
+ e.errorOnUnusedContext ? N(e, n) : e.warnUnusedContext && e.result.warnings.push(n);
1383
+ }
1384
+ function We(e, t, r, s) {
1385
+ var o;
1386
+ const n = (o = s.context[j(e)]) != null ? o : s.context[e];
1387
+ if (n === void 0) return;
1388
+ if (!(typeof n == "string" && n.startsWith(q))) {
1389
+ Et(n) && N(
1390
+ s,
1391
+ `${s.errorPrefix}args[1]: ${t.functionName} requires datetime dimension attributes. Reference [${e}] points to a measure; use an attribute (e.g. ${q}Table.Column.Level).`
1265
1392
  );
1393
+ return;
1266
1394
  }
1267
- if (!Ht.test(e)) {
1268
- const f = a.references.filter((d) => {
1269
- var $;
1270
- const w = ($ = r[B(d)]) != null ? $ : r[d];
1271
- return w !== void 0 && !Zt(w);
1272
- });
1273
- f.length > 0 && (a.errors.push(
1274
- `${i}args[1]: ${es(
1275
- Xt(e)
1276
- )}Bracket reference(s) ${vt(
1277
- f
1278
- )} point to raw attributes and must be wrapped in an aggregative function (e.g. SUM, AVG)`
1279
- ), a.isValid = !1);
1280
- }
1281
- if ((s || n) && p.length > 0) {
1282
- const f = new Set(a.references.map(B)), d = p.filter((w) => !f.has(B(w)));
1283
- if (a.unusedContextKeys = d, d.length > 0) {
1284
- const w = d.map((D) => `[${Ee(D)}]`).join(", "), $ = `${i}args[2]: Context keys ${w} are defined but not used in formula`;
1285
- n ? (a.errors.push($), a.isValid = !1) : s && a.warnings.push($);
1395
+ if (s.schemaIndex)
1396
+ try {
1397
+ const a = $e(n, s.schemaIndex);
1398
+ H(a.column.dataType) ? r && a.level && a.level !== r && N(
1399
+ s,
1400
+ `${s.errorPrefix}args[1]: ${t.functionName} expects date level '${r}'. Reference [${e}] has level '${a.level}'.`
1401
+ ) : N(
1402
+ s,
1403
+ `${s.errorPrefix}args[1]: ${t.functionName} requires datetime dimensions. Reference [${e}] resolves to non-datetime column '${a.column.name}'.`
1404
+ );
1405
+ } catch (a) {
1406
+ const u = a instanceof Error ? a.message : "Unknown error";
1407
+ N(s, `${s.errorPrefix}args[1]: ${t.functionName} reference [${e}]: ${u}`);
1286
1408
  }
1287
- }
1288
- return a;
1289
1409
  }
1290
- function ts(e, r, t = {}) {
1291
- const s = rs(e, r, t);
1410
+ function Ws(e) {
1411
+ const t = qt(), r = $t(e.formula, t);
1412
+ for (const s of r) {
1413
+ const n = At(s.functionName);
1414
+ We(s.ref1, s, n, e), We(s.ref2, s, n, e);
1415
+ }
1416
+ }
1417
+ function Ks(e, t, r = {}) {
1418
+ var n;
1419
+ const s = zs(e, t, r);
1420
+ return !e || e.trim().length === 0 ? ((n = r.allowEmptyFormula) != null && n || N(s, `${s.errorPrefix}args[1]: Formula cannot be empty`), s.result) : (Ls(s), s.result.references = _s(e), s.result.references.length === 0 ? (s.result.warnings.push(
1421
+ `${s.errorPrefix}args[1]: No bracket references found in formula - ensure this is intentional`
1422
+ ), s.result) : s.contextKeys.length === 0 ? (N(
1423
+ s,
1424
+ `${s.errorPrefix}args[2]: Context cannot be empty - custom formulas require context definitions`
1425
+ ), s.result) : (Us(s), js(s), Vs(s), Ws(s), s.result));
1426
+ }
1427
+ function Js(e, t, r = {}) {
1428
+ const s = Ks(e, t, r);
1292
1429
  if (!s.isValid)
1293
1430
  throw new Error(s.errors.join("; "));
1294
1431
  s.warnings.length > 0 && console.warn("Formula validation warnings:", s.warnings.join("; "));
1295
1432
  }
1296
- function ss(e, r) {
1433
+ function Ys(e, t) {
1297
1434
  if (e.length < 3 || e.length > 5)
1298
1435
  throw new Error(
1299
- `${r.pathPrefix}Expected 3, 4, or 5 arguments for customFormula (title, formula, context, format?, description?)`
1436
+ `${t.pathPrefix}Expected 3, 4, or 5 arguments for customFormula (title, formula, context, format?, description?)`
1437
+ );
1438
+ const r = e[1];
1439
+ if (typeof r != "string")
1440
+ throw new Error(
1441
+ `${t.pathPrefix}args[1]: Expected formula string, got ${typeof r}`
1442
+ );
1443
+ const s = r, n = e[2];
1444
+ if (!T(n))
1445
+ throw new Error(
1446
+ `${t.pathPrefix}args[2]: Expected context object, got ${n === null ? "null" : typeof n}`
1300
1447
  );
1301
- const t = e[1], s = e[2];
1302
- ts(t, s, {
1303
- errorPrefix: `${r.pathPrefix}`,
1448
+ const i = n;
1449
+ Js(s, i, {
1450
+ errorPrefix: `${t.pathPrefix}`,
1304
1451
  errorOnUnusedContext: !0,
1305
1452
  // Strict validation: all context keys must be used
1306
- allowEmptyFormula: !1
1453
+ allowEmptyFormula: !1,
1307
1454
  // Custom formulas must have content
1455
+ schemaIndex: t.schemaIndex
1308
1456
  });
1309
- const n = {};
1310
- for (const [o, i] of Object.entries(s)) {
1311
- const a = `args[2].${o}`;
1312
- if (E(i))
1313
- n[`${o}`] = C({
1314
- data: i,
1457
+ const o = Gs(s), a = {};
1458
+ for (const [u, c] of Object.entries(i)) {
1459
+ const m = `args[2].${u}`;
1460
+ if (E(c))
1461
+ a[`${u}`] = S({
1462
+ data: c,
1315
1463
  context: {
1316
- dataSource: r.dataSource,
1317
- schemaIndex: r.schemaIndex,
1318
- pathPrefix: a
1464
+ dataSource: t.dataSource,
1465
+ schemaIndex: t.schemaIndex,
1466
+ pathPrefix: m
1319
1467
  }
1320
1468
  });
1321
- else if (typeof i == "string" && i.startsWith(F))
1469
+ else if (typeof c == "string" && c.startsWith(q)) {
1470
+ const l = u.startsWith("[") && u.endsWith("]") ? u.slice(1, -1) : u, f = o[l];
1322
1471
  try {
1323
- n[`${o}`] = Q(
1324
- i,
1325
- r.dataSource,
1326
- r.schemaIndex
1472
+ a[`${u}`] = G(
1473
+ c,
1474
+ t.dataSource,
1475
+ t.schemaIndex,
1476
+ f !== void 0 ? { inferredDateLevel: f } : void 0
1327
1477
  );
1328
- } catch (u) {
1329
- const c = u instanceof Error ? u.message : "Unknown error";
1330
- throw new Error(`${a}: ${c}`);
1478
+ } catch (h) {
1479
+ const p = h instanceof Error ? h.message : "Unknown error";
1480
+ throw new Error(`${m}: ${p}`);
1331
1481
  }
1332
- else if (i && typeof i == "object" && "kind" in i)
1333
- n[`${o}`] = i;
1482
+ } else if (c && typeof c == "object" && "kind" in c)
1483
+ a[`${u}`] = c;
1334
1484
  else
1335
1485
  throw new Error(
1336
- `${a}: Invalid context value for key '${o}'. Expected a function call or attribute reference (${F}...), but got: ${typeof i}`
1486
+ `${m}: Invalid context value for key '${u}'. Expected a function call or attribute reference (${q}...), but got: ${typeof c}`
1337
1487
  );
1338
1488
  }
1339
- e[2] = n;
1489
+ e[2] = a;
1340
1490
  }
1341
- function me(e, r) {
1342
- const t = e[0];
1343
- if (!t || typeof t != "object" || !("type" in t))
1344
- throw new Error(`${r.pathPrefix}args[0]: Expected attribute as first argument`);
1345
- return t;
1491
+ function Gs(e) {
1492
+ const t = qt(), r = $t(e, t), s = {};
1493
+ for (const n of r) {
1494
+ const i = At(n.functionName);
1495
+ if (i !== void 0)
1496
+ for (const o of [n.ref1, n.ref2]) {
1497
+ const a = s[o];
1498
+ if (a !== void 0 && a !== i)
1499
+ throw new Error(
1500
+ `Reference [${o}] is used in time-diff functions with conflicting date levels ('${a}' and '${i}'). Specify the date level in the context (e.g. DM.Table.Column.${i}).`
1501
+ );
1502
+ s[o] = i;
1503
+ }
1504
+ }
1505
+ return s;
1506
+ }
1507
+ function Tt(e) {
1508
+ return e.type === L.TextAttribute;
1509
+ }
1510
+ function Dt(e) {
1511
+ return e.type === L.NumericAttribute;
1512
+ }
1513
+ function Qs(e) {
1514
+ return e.type === L.DateLevel;
1346
1515
  }
1347
- function Ce(e, r) {
1348
- const t = me(e, r);
1349
- if (!Lt(t))
1516
+ function Hs(e) {
1517
+ return Tt(e) || Dt(e);
1518
+ }
1519
+ function ie(e) {
1520
+ return e.type === L.TextAttribute ? "text" : e.type === L.NumericAttribute ? "numeric" : e.type === L.DateLevel ? "date/datetime" : "unknown";
1521
+ }
1522
+ function De(e, t) {
1523
+ const r = e[0];
1524
+ if (!r || typeof r != "object" || !("type" in r))
1525
+ throw new Error(`${t.pathPrefix}args[0]: Expected attribute as first argument`);
1526
+ return r;
1527
+ }
1528
+ function Ke(e, t) {
1529
+ const r = De(e, t);
1530
+ if (!Hs(r))
1350
1531
  throw new Error(
1351
- `${r.pathPrefix}args[0]: Attribute must be string or numeric type, got ${G(
1352
- t
1532
+ `${t.pathPrefix}args[0]: Attribute must be string or numeric type, got ${ie(
1533
+ r
1353
1534
  )} attribute`
1354
1535
  );
1355
1536
  }
1356
- function T(e, r) {
1357
- const t = me(e, r);
1358
- if (!Ge(t))
1537
+ function I(e, t) {
1538
+ const r = De(e, t);
1539
+ if (!Dt(r))
1359
1540
  throw new Error(
1360
- `${r.pathPrefix}args[0]: Attribute must be numeric type, got ${G(
1361
- t
1541
+ `${t.pathPrefix}args[0]: Attribute must be numeric type, got ${ie(
1542
+ r
1362
1543
  )} attribute`
1363
1544
  );
1364
1545
  }
1365
- function N(e, r) {
1366
- const t = me(e, r);
1367
- if (!Ke(t))
1546
+ function k(e, t) {
1547
+ const r = De(e, t);
1548
+ if (!Tt(r))
1368
1549
  throw new Error(
1369
- `${r.pathPrefix}args[0]: Attribute must be string type, got ${G(
1370
- t
1550
+ `${t.pathPrefix}args[0]: Attribute must be string type, got ${ie(
1551
+ r
1371
1552
  )} attribute`
1372
1553
  );
1373
1554
  }
1374
- function ns(e, r) {
1375
- const t = e[0];
1376
- if (!t || typeof t != "object" || !("attribute" in t))
1377
- throw new Error(`${r.pathPrefix}args[0]: Expected filter as first argument`);
1378
- return t;
1555
+ function Xs(e, t) {
1556
+ const r = e[0];
1557
+ if (!r || typeof r != "object" || !("attribute" in r))
1558
+ throw new Error(`${t.pathPrefix}args[0]: Expected filter as first argument`);
1559
+ return r;
1379
1560
  }
1380
- function is(e, r) {
1381
- const t = ns(e, r);
1382
- if (!ne(t))
1561
+ function Zs(e, t) {
1562
+ const r = Xs(e, t);
1563
+ if (!be(r))
1383
1564
  throw new Error(
1384
- `${r.pathPrefix}args[0]: exclude filter only accepts members filter, got ${t.__serializable || "unknown"} filter`
1565
+ `${t.pathPrefix}args[0]: exclude filter only accepts members filter, got ${r.__serializable || "unknown"} filter`
1385
1566
  );
1386
1567
  }
1387
- const os = {
1388
- "measureFactory.customFormula": ss,
1568
+ const en = {
1569
+ "measureFactory.customFormula": Ys,
1389
1570
  // String | Number filters
1390
- "filterFactory.equals": Ce,
1391
- "filterFactory.doesntEqual": Ce,
1571
+ "filterFactory.equals": Ke,
1572
+ "filterFactory.doesntEqual": Ke,
1392
1573
  // Numeric filters
1393
- "filterFactory.greaterThan": T,
1394
- "filterFactory.greaterThanOrEqual": T,
1395
- "filterFactory.lessThan": T,
1396
- "filterFactory.lessThanOrEqual": T,
1397
- "filterFactory.between": T,
1398
- "filterFactory.betweenNotEqual": T,
1399
- "filterFactory.numeric": T,
1574
+ "filterFactory.greaterThan": I,
1575
+ "filterFactory.greaterThanOrEqual": I,
1576
+ "filterFactory.lessThan": I,
1577
+ "filterFactory.lessThanOrEqual": I,
1578
+ "filterFactory.between": I,
1579
+ "filterFactory.betweenNotEqual": I,
1580
+ "filterFactory.numeric": I,
1400
1581
  // String filters
1401
- "filterFactory.contains": N,
1402
- "filterFactory.doesntContain": N,
1403
- "filterFactory.startsWith": N,
1404
- "filterFactory.doesntStartWith": N,
1405
- "filterFactory.endsWith": N,
1406
- "filterFactory.doesntEndWith": N,
1407
- "filterFactory.like": N,
1582
+ "filterFactory.contains": k,
1583
+ "filterFactory.doesntContain": k,
1584
+ "filterFactory.startsWith": k,
1585
+ "filterFactory.doesntStartWith": k,
1586
+ "filterFactory.endsWith": k,
1587
+ "filterFactory.doesntEndWith": k,
1588
+ "filterFactory.like": k,
1408
1589
  // Exclude filter
1409
- "filterFactory.exclude": is
1590
+ "filterFactory.exclude": Zs
1410
1591
  };
1411
- function as(e) {
1412
- return os[`${e}`];
1592
+ function tn(e) {
1593
+ return en[`${e}`];
1413
1594
  }
1414
- const us = {
1595
+ const St = {
1415
1596
  // ==================== MEASURE FACTORY FUNCTIONS ====================
1416
1597
  // Basic aggregations
1417
1598
  "measureFactory.sum": [
@@ -1938,609 +2119,677 @@ const us = {
1938
2119
  { type: "FilterRelationsNode", required: !0 }
1939
2120
  ]
1940
2121
  };
1941
- function pe(e) {
1942
- return us[`${e}`];
2122
+ function Se(e) {
2123
+ return St[`${e}`];
1943
2124
  }
1944
- function cs(e) {
1945
- const r = pe(e);
1946
- return r ? r.filter((t) => t.required).length : 0;
2125
+ function rn(e) {
2126
+ const t = Se(e);
2127
+ return t ? t.filter((r) => r.required).length : 0;
1947
2128
  }
1948
- function ls(e) {
1949
- const r = pe(e);
1950
- return r ? r.length : 0;
2129
+ function sn(e) {
2130
+ const t = Se(e);
2131
+ return t ? t.length : 0;
1951
2132
  }
1952
- function fs(e) {
2133
+ function nn(e) {
1953
2134
  if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}/.test(e))
1954
2135
  return !1;
1955
- const t = Date.parse(e);
1956
- if (isNaN(t) || e.length < 10)
2136
+ const r = Date.parse(e);
2137
+ if (isNaN(r) || e.length < 10)
1957
2138
  return !1;
1958
2139
  const s = new Date(e);
1959
2140
  return !isNaN(s.getTime());
1960
2141
  }
1961
- function Z(e, r, t, s) {
1962
- if (e.startsWith(F))
2142
+ function ce(e, t, r, s) {
2143
+ if (e.startsWith(q))
1963
2144
  try {
1964
- return Q(e, r, t);
2145
+ return G(e, t, r);
1965
2146
  } catch (n) {
1966
- const o = n instanceof Error ? n.message : "Unknown error";
1967
- throw new Error(`${s}: ${o}`);
2147
+ const i = n instanceof Error ? n.message : "Unknown error";
2148
+ throw new Error(`${s}: ${i}`);
1968
2149
  }
1969
2150
  throw new Error(
1970
- `${s}: Invalid attribute "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`
2151
+ `${s}: Invalid attribute '${e}'. Expected format: '${q}TableName.ColumnName[.Level]'`
1971
2152
  );
1972
2153
  }
1973
- function ds(e, r, t, s) {
1974
- if (e.startsWith(F))
2154
+ function on(e, t, r, s) {
2155
+ if (e.startsWith(q))
1975
2156
  try {
1976
- return Vt(e, r, t);
2157
+ return Es(e, t, r);
1977
2158
  } catch (n) {
1978
- const o = n instanceof Error ? n.message : "Unknown error";
1979
- throw new Error(`${s}: ${o}`);
2159
+ const i = n instanceof Error ? n.message : "Unknown error";
2160
+ throw new Error(`${s}: ${i}`);
1980
2161
  }
1981
2162
  throw new Error(
1982
- `${s}: Invalid date dimension string "${e}". Expected format: "${F}TableName.ColumnName"`
2163
+ `${s}: Invalid date dimension string '${e}'. Expected format: '${q}TableName.ColumnName'`
1983
2164
  );
1984
2165
  }
1985
- function ms(e) {
1986
- const r = e.data, { argSchema: t, dataSource: s, schemaIndex: n, pathPrefix: o } = e.context, i = o;
1987
- if (r === void 0) {
1988
- if (t.required)
1989
- throw new Error(`${i}: Required argument is missing (expected ${t.type})`);
2166
+ function an(e) {
2167
+ const t = e.data, { argSchema: r, dataSource: s, schemaIndex: n, pathPrefix: i } = e.context, o = i;
2168
+ if (t === void 0) {
2169
+ if (r.required)
2170
+ throw new Error(`${o}: Required argument is missing (expected ${r.type})`);
1990
2171
  return;
1991
2172
  }
1992
- if (!(r === null && !t.required))
1993
- switch (t.type) {
2173
+ if (!(t === null && !r.required))
2174
+ switch (r.type) {
1994
2175
  case "string":
1995
- if (typeof r != "string")
1996
- throw new Error(`${i}: Expected string, got ${typeof r}`);
1997
- return r;
2176
+ if (typeof t != "string")
2177
+ throw new Error(`${o}: Expected string, got ${typeof t}`);
2178
+ return t;
1998
2179
  case "number":
1999
- if (typeof r != "number")
2000
- throw new Error(`${i}: Expected number, got ${typeof r}`);
2001
- return r;
2180
+ if (typeof t != "number")
2181
+ throw new Error(`${o}: Expected number, got ${typeof t}`);
2182
+ return t;
2002
2183
  case "boolean":
2003
- if (typeof r != "boolean")
2004
- throw new Error(`${i}: Expected boolean, got ${typeof r}`);
2005
- return r;
2184
+ if (typeof t != "boolean")
2185
+ throw new Error(`${o}: Expected boolean, got ${typeof t}`);
2186
+ return t;
2006
2187
  case "string[]":
2007
- if (!Array.isArray(r))
2188
+ if (!Array.isArray(t))
2008
2189
  throw new Error(
2009
- `${i}: Expected array of strings, got ${typeof r}. Example: ["value1", "value2"]`
2190
+ `${o}: Expected array of strings, got ${typeof t}. Example: ['value1', 'value2']`
2010
2191
  );
2011
- if (!r.every((a) => typeof a == "string"))
2192
+ if (!t.every((a) => typeof a == "string"))
2012
2193
  throw new Error(
2013
- `${i}: Expected array of strings, but contains non-string values`
2194
+ `${o}: Expected array of strings, but contains non-string values`
2014
2195
  );
2015
- return r;
2196
+ return t;
2016
2197
  case "number[]":
2017
- if (!Array.isArray(r))
2198
+ if (!Array.isArray(t))
2018
2199
  throw new Error(
2019
- `${i}: Expected array of numbers, got ${typeof r}. Example: [10, 20]`
2200
+ `${o}: Expected array of numbers, got ${typeof t}. Example: [10, 20]`
2020
2201
  );
2021
- if (!r.every((a) => typeof a == "number"))
2202
+ if (!t.every((a) => typeof a == "number"))
2022
2203
  throw new Error(
2023
- `${i}: Expected array of numbers, but contains non-number values`
2204
+ `${o}: Expected array of numbers, but contains non-number values`
2024
2205
  );
2025
- return r;
2206
+ return t;
2026
2207
  case "Attribute":
2027
- if (typeof r != "string")
2208
+ if (typeof t != "string")
2028
2209
  throw new Error(
2029
- `${i}: Expected attribute string, got ${typeof r}. Example: "DM.Commerce.Revenue"`
2210
+ `${o}: Expected attribute string, got ${typeof t}. Example: 'DM.Commerce.Revenue'`
2030
2211
  );
2031
- return Z(r, s, n, i);
2212
+ return ce(t, s, n, o);
2032
2213
  case "Attribute[]":
2033
- if (!Array.isArray(r))
2214
+ if (!Array.isArray(t))
2034
2215
  throw new Error(
2035
- `${i}: Expected array of attributes, got ${typeof r}. Example: ["DM.Commerce.AgeRange"]`
2216
+ `${o}: Expected array of attributes, got ${typeof t}. Example: ['DM.Commerce.AgeRange']`
2036
2217
  );
2037
- return r.map((a, u) => {
2218
+ return t.map((a, u) => {
2038
2219
  if (typeof a != "string")
2039
- throw new Error(`${i}[${u}]: Expected attribute string, got ${typeof a}`);
2040
- return Z(a, s, n, `${i}[${u}]`);
2220
+ throw new Error(`${o}[${u}]: Expected attribute string, got ${typeof a}`);
2221
+ return ce(a, s, n, `${o}[${u}]`);
2041
2222
  });
2042
2223
  case "Measure":
2043
2224
  case "BaseMeasure":
2044
- if (!E(r))
2225
+ if (!E(t))
2045
2226
  throw new Error(
2046
- `${i}: Expected measure function call, got ${typeof r}. Example: {"function": "measureFactory.sum", "args": ["DM.Commerce.Revenue"]}`
2227
+ `${o}: Expected measure function call, got ${typeof t}. Example: {'function': 'measureFactory.sum', 'args': ['DM.Commerce.Revenue']}`
2047
2228
  );
2048
- return C({
2049
- data: r,
2050
- context: { dataSource: s, schemaIndex: n, pathPrefix: i }
2229
+ return S({
2230
+ data: t,
2231
+ context: { dataSource: s, schemaIndex: n, pathPrefix: o }
2051
2232
  });
2052
2233
  case "Measure[]":
2053
- if (!Array.isArray(r))
2234
+ if (!Array.isArray(t))
2054
2235
  throw new Error(
2055
- `${i}: Expected array of measure function calls, got ${typeof r}`
2236
+ `${o}: Expected array of measure function calls, got ${typeof t}`
2056
2237
  );
2057
- return r.map((a, u) => {
2238
+ return t.map((a, u) => {
2058
2239
  if (!E(a))
2059
2240
  throw new Error(
2060
- `${i}[${u}]: Expected measure function call, got ${typeof a}`
2241
+ `${o}[${u}]: Expected measure function call, got ${typeof a}`
2061
2242
  );
2062
- return C({
2243
+ return S({
2063
2244
  data: a,
2064
- context: { dataSource: s, schemaIndex: n, pathPrefix: `${i}[${u}]` }
2245
+ context: { dataSource: s, schemaIndex: n, pathPrefix: `${o}[${u}]` }
2065
2246
  });
2066
2247
  });
2067
2248
  case "Filter":
2068
- if (!E(r))
2249
+ if (!E(t))
2069
2250
  throw new Error(
2070
- `${i}: Expected filter function call, got ${typeof r}. Example: {"function": "filterFactory.contains", "args": ["DM.Brand.Brand", "Apple"]}`
2251
+ `${o}: Expected filter function call, got ${typeof t}. Example: {'function': 'filterFactory.contains', 'args': ['DM.Brand.Brand', 'Apple']}`
2071
2252
  );
2072
- return C({
2073
- data: r,
2074
- context: { dataSource: s, schemaIndex: n, pathPrefix: i }
2253
+ return S({
2254
+ data: t,
2255
+ context: { dataSource: s, schemaIndex: n, pathPrefix: o }
2075
2256
  });
2076
2257
  case "Filter[]":
2077
- if (!Array.isArray(r))
2258
+ if (!Array.isArray(t))
2078
2259
  throw new Error(
2079
- `${i}: Expected array of filter function calls, got ${typeof r}`
2260
+ `${o}: Expected array of filter function calls, got ${typeof t}`
2080
2261
  );
2081
- return r.map((a, u) => {
2262
+ return t.map((a, u) => {
2082
2263
  if (!E(a))
2083
2264
  throw new Error(
2084
- `${i}[${u}]: Expected filter function call, got ${typeof a}`
2265
+ `${o}[${u}]: Expected filter function call, got ${typeof a}`
2085
2266
  );
2086
- return C({
2267
+ return S({
2087
2268
  data: a,
2088
- context: { dataSource: s, schemaIndex: n, pathPrefix: `${i}[${u}]` }
2269
+ context: { dataSource: s, schemaIndex: n, pathPrefix: `${o}[${u}]` }
2089
2270
  });
2090
2271
  });
2091
2272
  case "FilterRelationsNode":
2092
- if (Array.isArray(r))
2093
- return r.map((a, u) => {
2273
+ if (Array.isArray(t))
2274
+ return t.map((a, u) => {
2094
2275
  if (!E(a))
2095
2276
  throw new Error(
2096
- `${i}[${u}]: Expected filter function call, got ${typeof a}`
2277
+ `${o}[${u}]: Expected filter function call, got ${typeof a}`
2097
2278
  );
2098
- return C({
2279
+ return S({
2099
2280
  data: a,
2100
- context: { dataSource: s, schemaIndex: n, pathPrefix: `${i}[${u}]` }
2281
+ context: { dataSource: s, schemaIndex: n, pathPrefix: `${o}[${u}]` }
2101
2282
  });
2102
2283
  });
2103
- if (E(r))
2104
- return C({
2105
- data: r,
2106
- context: { dataSource: s, schemaIndex: n, pathPrefix: i }
2284
+ if (E(t))
2285
+ return S({
2286
+ data: t,
2287
+ context: { dataSource: s, schemaIndex: n, pathPrefix: o }
2107
2288
  });
2108
2289
  throw new Error(
2109
- `${i}: Expected filter function call or array of filters, got ${typeof r}`
2290
+ `${o}: Expected filter function call or array of filters, got ${typeof t}`
2110
2291
  );
2111
2292
  case "DateDimension":
2112
- if (typeof r != "string")
2293
+ if (typeof t != "string")
2113
2294
  throw new Error(
2114
- `${i}: Expected date dimension string, got ${typeof r}. Example: "DM.Commerce.Date"`
2295
+ `${o}: Expected date dimension string, got ${typeof t}. Example: 'DM.Commerce.Date'`
2115
2296
  );
2116
- return ds(r, s, n, i);
2297
+ return on(t, s, n, o);
2117
2298
  case "LevelAttribute": {
2118
- if (typeof r != "string")
2299
+ if (typeof t != "string")
2119
2300
  throw new Error(
2120
- `${i}: Expected date attribute string, got ${typeof r}. Example: "DM.Commerce.Date.Years"`
2301
+ `${o}: Expected date attribute string, got ${typeof t}. Example: 'DM.Commerce.Date.Years'`
2121
2302
  );
2122
- const a = Z(
2123
- r,
2303
+ const a = ce(
2304
+ t,
2124
2305
  s,
2125
2306
  n,
2126
- i
2307
+ o
2127
2308
  );
2128
- if (!kt(a))
2309
+ if (!Qs(a))
2129
2310
  throw new Error(
2130
- `${i}: Attribute must be date/datetime type, got ${G(
2311
+ `${o}: Attribute must be date/datetime type, got ${ie(
2131
2312
  a
2132
2313
  )} attribute`
2133
2314
  );
2134
2315
  return a;
2135
2316
  }
2136
2317
  case "Measure | number":
2137
- if (typeof r == "number")
2138
- return r;
2139
- if (E(r))
2140
- return C({
2141
- data: r,
2142
- context: { dataSource: s, schemaIndex: n, pathPrefix: i }
2318
+ if (typeof t == "number")
2319
+ return t;
2320
+ if (E(t))
2321
+ return S({
2322
+ data: t,
2323
+ context: { dataSource: s, schemaIndex: n, pathPrefix: o }
2143
2324
  });
2144
2325
  throw new Error(
2145
- `${i}: Expected measure function call or number, got ${typeof r}`
2326
+ `${o}: Expected measure function call or number, got ${typeof t}`
2146
2327
  );
2147
2328
  case "Date | string":
2148
- if (typeof r == "string") {
2149
- if (fs(r))
2150
- return r;
2329
+ if (typeof t == "string") {
2330
+ if (nn(t))
2331
+ return t;
2151
2332
  throw new Error(
2152
- `${i}: Expected valid ISO date string or Date object, got invalid date string "${r}"`
2333
+ `${o}: Expected valid ISO date string or Date object, got invalid date string '${t}'`
2153
2334
  );
2154
2335
  } else {
2155
- if (r instanceof Date)
2156
- return r;
2336
+ if (t instanceof Date)
2337
+ return t;
2157
2338
  throw new Error(
2158
- `${i}: Expected date string or Date object, got ${typeof r}`
2339
+ `${o}: Expected date string or Date object, got ${typeof t}`
2159
2340
  );
2160
2341
  }
2161
2342
  case "string | number":
2162
- if (typeof r == "string" || typeof r == "number")
2163
- return r;
2164
- throw new Error(`${i}: Expected string or number, got ${typeof r}`);
2343
+ if (typeof t == "string" || typeof t == "number")
2344
+ return t;
2345
+ throw new Error(`${o}: Expected string or number, got ${typeof t}`);
2165
2346
  case "BaseFilterConfig":
2166
2347
  case "MembersFilterConfig":
2167
2348
  case "CustomFormulaContext":
2168
2349
  case "any":
2169
- if (r == null && t.required)
2170
- throw new Error(`${i}: Required argument is null/undefined`);
2171
- return r;
2350
+ if (t == null && r.required)
2351
+ throw new Error(`${o}: Required argument is null/undefined`);
2352
+ return t;
2172
2353
  default:
2173
- return r;
2354
+ return t;
2174
2355
  }
2175
2356
  }
2176
- function C(e) {
2177
- const { data: r } = e, { dataSource: t, schemaIndex: s, pathPrefix: n } = e.context, { function: o, args: i } = r, a = n ? `${n}.` : "", u = pe(o);
2178
- if (!u)
2179
- throw new Error(`${a}function: Unknown function "${o}"`);
2180
- const c = cs(o), p = ls(o);
2181
- if (i.length < c)
2357
+ function S(e) {
2358
+ const { data: t } = e, { dataSource: r, schemaIndex: s, pathPrefix: n } = e.context, { function: i, args: o } = t, a = n ? `${n}.` : "", u = Se(i);
2359
+ if (!u) {
2360
+ const p = Object.keys(St), d = M(i, p, (A) => A), b = d && d.distance <= x ? ` Did you mean '${d.best}'?` : "";
2182
2361
  throw new Error(
2183
- `${a}function: Expected at least ${c} arguments, got ${i.length}`
2362
+ `${a}function: Unknown function '${i}'.${b}`
2184
2363
  );
2185
- if (i.length > p)
2364
+ }
2365
+ const c = rn(i), m = sn(i);
2366
+ if (o.length < c)
2367
+ throw new Error(
2368
+ `${a}function: Expected at least ${c} arguments, got ${o.length}`
2369
+ );
2370
+ if (o.length > m)
2186
2371
  throw new Error(
2187
- `${a}function: Expected at most ${p} arguments, got ${i.length}`
2372
+ `${a}function: Expected at most ${m} arguments, got ${o.length}`
2188
2373
  );
2189
- const m = [], y = [];
2190
- for (let f = 0; f < Math.max(i.length, u.length); f++) {
2191
- const d = u[`${f}`], w = i[`${f}`], $ = a ? `${a}args[${f}]` : `args[${f}]`;
2192
- if (w === void 0) {
2193
- d != null && d.required && y.push(`${$}: Missing required argument (expected ${d.type})`);
2374
+ const l = [], f = [];
2375
+ for (let p = 0; p < Math.max(o.length, u.length); p++) {
2376
+ const d = u[`${p}`], b = o[`${p}`], A = a ? `${a}args[${p}]` : `args[${p}]`;
2377
+ if (b === void 0) {
2378
+ d != null && d.required && f.push(`${A}: Missing required argument (expected ${d.type})`);
2194
2379
  continue;
2195
2380
  }
2196
2381
  if (!d) {
2197
- y.push(`${$}: Unexpected argument`);
2382
+ f.push(`${A}: Unexpected argument`);
2198
2383
  continue;
2199
2384
  }
2200
2385
  try {
2201
- const D = ms({
2202
- data: w,
2386
+ const O = an({
2387
+ data: b,
2203
2388
  context: {
2204
- dataSource: t,
2389
+ dataSource: r,
2205
2390
  schemaIndex: s,
2206
- pathPrefix: $,
2391
+ pathPrefix: A,
2207
2392
  argSchema: d
2208
2393
  }
2209
2394
  });
2210
- m.push(D);
2211
- } catch (D) {
2212
- const ve = D instanceof Error ? D.message : "Unknown error";
2213
- y.push(ve);
2395
+ l.push(O);
2396
+ } catch (O) {
2397
+ const oe = O instanceof Error ? O.message : "Unknown error";
2398
+ f.push(oe);
2214
2399
  }
2215
2400
  }
2216
- if (y.length > 0) {
2217
- const f = y.join("; ");
2218
- throw new Error(f);
2401
+ if (f.length > 0) {
2402
+ const p = f.join("; ");
2403
+ throw new Error(p);
2219
2404
  }
2220
- const x = as(o);
2221
- if (x)
2405
+ const h = tn(i);
2406
+ if (h)
2222
2407
  try {
2223
- x(m, {
2224
- dataSource: t,
2408
+ h(l, {
2409
+ dataSource: r,
2225
2410
  schemaIndex: s,
2226
2411
  pathPrefix: a
2227
2412
  });
2228
- } catch (f) {
2229
- const d = f instanceof Error ? f.message : "Unknown validation error";
2413
+ } catch (p) {
2414
+ const d = p instanceof Error ? p.message : "Unknown validation error";
2230
2415
  throw new Error(d);
2231
2416
  }
2232
- return Qt(o, m);
2417
+ return Ms(i, l);
2233
2418
  }
2234
- function Ye(e) {
2235
- const { attribute: r, config: t } = e;
2236
- if (ne(e) && jr(r)) {
2237
- const { granularity: s } = r, n = e.members.map((a) => s === "Years" && !isNaN(Number(a)) ? `${a}-01-01T00:00:00` : a), o = Jr(t), i = Object.keys(o).length === 0 ? void 0 : o;
2238
- return Kr(r, n, i);
2419
+ function Ot(e) {
2420
+ const { attribute: t, config: r } = e;
2421
+ if (be(e) && Dr(t)) {
2422
+ const { granularity: s } = t, n = e.members.map((a) => s === "Years" && !isNaN(Number(a)) ? `${a}-01-01T00:00:00` : a), i = Sr(r), o = Object.keys(i).length === 0 ? void 0 : i;
2423
+ return Or(t, n, o);
2239
2424
  }
2240
2425
  return e;
2241
2426
  }
2242
- function ps(e) {
2243
- let r = [];
2244
- for (const t of e)
2245
- U(t) ? r = he(t, r) : r = he([Ye(t)], r);
2246
- return r != null ? r : [];
2427
+ function un(e) {
2428
+ let t = [];
2429
+ for (const r of e)
2430
+ X(r) ? t = Le(r, t) : t = Le([Ot(r)], t);
2431
+ return t != null ? t : [];
2247
2432
  }
2248
- const ys = (e) => {
2249
- const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context, n = [], o = [];
2250
- return r.forEach((i, a) => {
2433
+ const cn = (e) => {
2434
+ const { data: t } = e, { dataSource: r, schemaIndex: s } = e.context, n = [], i = [];
2435
+ return t.forEach((o, a) => {
2251
2436
  const u = {
2252
2437
  category: "filters",
2253
2438
  index: a,
2254
- input: i
2439
+ input: o
2255
2440
  };
2256
2441
  try {
2257
- const c = C({
2258
- data: i,
2259
- context: { dataSource: t, schemaIndex: s, pathPrefix: "" }
2442
+ const c = S({
2443
+ data: o,
2444
+ context: { dataSource: r, schemaIndex: s, pathPrefix: "" }
2260
2445
  });
2261
- !U(c) && !K(c) ? o.push(h(g({}, u), { message: "Invalid filter JSON" })) : n.push(c);
2446
+ !X(c) && !ne(c) ? i.push(F(g({}, u), { message: "Invalid filter JSON" })) : n.push(c);
2262
2447
  } catch (c) {
2263
- const p = c instanceof Error ? c.message : "Unknown error";
2264
- o.push(h(g({}, u), { message: p }));
2448
+ const m = c instanceof Error ? c.message : "Unknown error";
2449
+ i.push(F(g({}, u), { message: m }));
2265
2450
  }
2266
- }), o.length > 0 ? { success: !1, errors: o } : { success: !0, data: ps(n) };
2267
- }, gs = (e) => {
2268
- const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context;
2269
- return r ? je(r) ? ys({
2270
- data: r,
2271
- context: { dataSource: t, schemaIndex: s }
2451
+ }), i.length > 0 ? { success: !1, errors: i } : { success: !0, data: un(n) };
2452
+ }, Oe = (e) => {
2453
+ const { data: t } = e, { dataSource: r, schemaIndex: s } = e.context;
2454
+ return t ? Ft(t) ? cn({
2455
+ data: t,
2456
+ context: { dataSource: r, schemaIndex: s }
2272
2457
  }) : {
2273
2458
  success: !1,
2274
2459
  errors: [
2275
2460
  {
2276
2461
  category: "filters",
2277
2462
  index: -1,
2278
- input: r,
2279
- message: 'Invalid filters JSON. Expected an array of function calls with "function" and "args" properties.'
2463
+ input: t,
2464
+ message: "Invalid filters JSON. Expected an array of function calls with 'function' and 'args' properties."
2280
2465
  }
2281
2466
  ]
2282
2467
  } : { success: !0, data: [] };
2283
- }, hs = (e) => {
2284
- const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context, n = [], o = [];
2285
- return r.forEach((i, a) => {
2468
+ }, ln = (e) => {
2469
+ const { data: t } = e, { dataSource: r, schemaIndex: s } = e.context, n = [], i = [];
2470
+ return t.forEach((o, a) => {
2286
2471
  const u = {
2287
2472
  category: "highlights",
2288
2473
  index: a,
2289
- input: i
2474
+ input: o
2290
2475
  };
2291
2476
  try {
2292
- const c = C({
2293
- data: i,
2294
- context: { dataSource: t, schemaIndex: s, pathPrefix: "" }
2477
+ const c = S({
2478
+ data: o,
2479
+ context: { dataSource: r, schemaIndex: s, pathPrefix: "" }
2295
2480
  });
2296
- K(c) ? n.push(Ye(c)) : o.push(h(g({}, u), { message: "Invalid filter JSON" }));
2481
+ ne(c) ? n.push(Ot(c)) : i.push(F(g({}, u), { message: "Invalid filter JSON" }));
2297
2482
  } catch (c) {
2298
- const p = c instanceof Error ? c.message : "Unknown error";
2299
- o.push(h(g({}, u), { message: p }));
2483
+ const m = c instanceof Error ? c.message : "Unknown error";
2484
+ i.push(F(g({}, u), { message: m }));
2300
2485
  }
2301
- }), o.length > 0 ? { success: !1, errors: o } : { success: !0, data: n };
2302
- }, bs = (e) => {
2303
- const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context;
2304
- return r ? je(r) ? hs({
2305
- data: r,
2306
- context: { dataSource: t, schemaIndex: s }
2486
+ }), i.length > 0 ? { success: !1, errors: i } : { success: !0, data: n };
2487
+ }, Me = (e) => {
2488
+ const { data: t } = e, { dataSource: r, schemaIndex: s } = e.context;
2489
+ return t ? Ft(t) ? ln({
2490
+ data: t,
2491
+ context: { dataSource: r, schemaIndex: s }
2307
2492
  }) : {
2308
2493
  success: !1,
2309
2494
  errors: [
2310
2495
  {
2311
2496
  category: "highlights",
2312
2497
  index: -1,
2313
- input: r,
2314
- message: 'Invalid highlights JSON. Expected an array of function calls with "function" and "args" properties.'
2498
+ input: t,
2499
+ message: "Invalid highlights JSON. Expected an array of function calls with 'function' and 'args' properties."
2315
2500
  }
2316
2501
  ]
2317
2502
  } : { success: !0, data: [] };
2318
- }, Fs = (e, r, t) => {
2319
- const { dataSource: s, schemaIndex: n } = r;
2503
+ }, fn = (e, t) => {
2504
+ if (e && !te(e))
2505
+ return F(g({}, t), {
2506
+ message: `Invalid sort type. Expected 'sortAsc', 'sortDesc', or 'sortNone'. Got: '${e}'.`
2507
+ });
2508
+ }, dn = (e, t, r) => {
2509
+ const { dataSource: s, schemaIndex: n } = t;
2320
2510
  try {
2321
- const o = C({
2511
+ const i = S({
2322
2512
  data: e,
2323
2513
  context: { dataSource: s, schemaIndex: n, pathPrefix: "" }
2324
2514
  });
2325
- return fe(o) ? { success: !0, data: o } : {
2515
+ return Ee(i) ? { success: !0, data: i } : {
2326
2516
  success: !1,
2327
- errors: [h(g({}, t), { message: "Invalid measure JSON" })]
2517
+ errors: [F(g({}, r), { message: "Invalid measure JSON" })]
2328
2518
  };
2329
- } catch (o) {
2330
- const i = o instanceof Error ? o.message : "Unknown error";
2519
+ } catch (i) {
2520
+ const o = i instanceof Error ? i.message : "Unknown error";
2331
2521
  return {
2332
2522
  success: !1,
2333
- errors: [h(g({}, t), { message: i })]
2523
+ errors: [F(g({}, r), { message: o })]
2334
2524
  };
2335
2525
  }
2336
- }, ws = (e, r, t) => r ? $e(r) ? { measure: e.sort(Ae(r)) } : {
2337
- measure: e,
2338
- error: h(g({}, t), {
2339
- message: `Invalid sort type. Expected "sortAsc", "sortDesc", or "sortNone". Got: "${r}".`
2340
- })
2341
- } : { measure: e }, qs = (e, r, t, s) => {
2342
- const n = C({
2526
+ }, mn = (e, t, r, s) => {
2527
+ const n = S({
2343
2528
  data: e.column,
2344
- context: { dataSource: r, schemaIndex: t, pathPrefix: "" }
2529
+ context: { dataSource: t, schemaIndex: r, pathPrefix: "" }
2345
2530
  });
2346
- return fe(n) ? ws(n, e.sortType, s) : { error: h(g({}, s), { message: "Invalid measure JSON" }) };
2347
- }, Es = (e, r, t, s) => {
2348
- if (zt(e))
2349
- return qs(e, r, t, s);
2531
+ if (!Ee(n))
2532
+ return {
2533
+ style: {},
2534
+ error: F(g({}, s), { message: "Invalid measure JSON" })
2535
+ };
2536
+ const i = fn(e.sortType, s);
2537
+ if (i) {
2538
+ const a = _(e, "column");
2539
+ return { measure: n, style: a, error: i };
2540
+ }
2541
+ const o = _(e, "column");
2542
+ return { measure: n, style: o };
2543
+ }, pn = (e, t, r, s) => {
2544
+ if (As(e))
2545
+ return mn(e, t, r, s);
2350
2546
  if (E(e)) {
2351
- const n = Fs(
2547
+ const n = dn(
2352
2548
  e,
2353
- { dataSource: r, schemaIndex: t },
2549
+ { dataSource: t, schemaIndex: r },
2354
2550
  s
2355
2551
  );
2356
2552
  return n.success ? { measure: n.data } : { error: n.errors[0] };
2357
2553
  }
2358
2554
  return {
2359
- error: h(g({}, s), {
2360
- message: 'Invalid measure item. Expected a function call (function/args) or object with "column" and optional "sortType".'
2555
+ error: F(g({}, s), {
2556
+ message: "Invalid measure item. Expected a function call (function/args) or object with 'column' and optional 'sortType'."
2361
2557
  })
2362
2558
  };
2363
- }, Cs = (e) => {
2364
- const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context;
2365
- if (!r)
2559
+ }, Mt = (e) => {
2560
+ const { data: t } = e, { dataSource: r, schemaIndex: s } = e.context;
2561
+ if (!t)
2366
2562
  return { success: !0, data: [] };
2367
- if (!Array.isArray(r))
2563
+ if (!Array.isArray(t))
2368
2564
  return {
2369
2565
  success: !1,
2370
2566
  errors: [
2371
2567
  {
2372
2568
  category: "measures",
2373
2569
  index: -1,
2374
- input: r,
2570
+ input: t,
2375
2571
  message: "Invalid measures JSON. Expected an array."
2376
2572
  }
2377
2573
  ]
2378
2574
  };
2379
- const n = [], o = [];
2380
- return r.forEach((i, a) => {
2575
+ const n = [], i = [];
2576
+ return t.forEach((o, a) => {
2381
2577
  const u = {
2382
2578
  category: "measures",
2383
2579
  index: a,
2384
- input: i
2580
+ input: o
2385
2581
  };
2386
2582
  try {
2387
- const c = Es(i, t, s, u);
2583
+ const c = pn(o, r, s, u);
2388
2584
  if (c.error) {
2389
- o.push(c.error);
2585
+ i.push(c.error);
2390
2586
  return;
2391
2587
  }
2392
- c.measure && n.push(c.measure);
2588
+ c.measure && n.push(
2589
+ c.style !== void 0 ? { measure: c.measure, style: c.style } : { measure: c.measure }
2590
+ );
2393
2591
  } catch (c) {
2394
- const p = c instanceof Error ? c.message : "Unknown error";
2395
- o.push(h(g({}, u), { message: p }));
2592
+ const m = c instanceof Error ? c.message : "Unknown error";
2593
+ i.push(F(g({}, u), { message: m }));
2396
2594
  }
2397
- }), o.length > 0 ? { success: !1, errors: o } : { success: !0, data: n };
2398
- }, ks = (e) => {
2399
- const { data: r } = e, { dataSource: t, tables: s } = e.context, n = Bt(s), o = [], i = M(
2400
- () => jt({
2401
- data: r.dimensions || [],
2402
- context: { dataSource: t, schemaIndex: n }
2595
+ }), i.length > 0 ? { success: !1, errors: i } : { success: !0, data: n };
2596
+ };
2597
+ function Q(e) {
2598
+ return typeof e == "string" ? e.replace(/\[\[([^\]]+)\]\]/g, "$1") : Array.isArray(e) ? e.map(Q) : e !== null && typeof e == "object" ? Object.fromEntries(
2599
+ Object.entries(e).map(([t, r]) => [t, Q(r)])
2600
+ ) : e;
2601
+ }
2602
+ function w(e, t, r) {
2603
+ const s = e();
2604
+ if (!s.success) {
2605
+ const n = r ? s.errors.map(r) : s.errors;
2606
+ return t.push(...n), null;
2607
+ }
2608
+ return s.data;
2609
+ }
2610
+ const ve = "$trend", Ne = "$forecast";
2611
+ function yn(e) {
2612
+ return e.map(({ attribute: t, style: r }) => {
2613
+ const s = r == null ? void 0 : r.sortType;
2614
+ if (!s) return t;
2615
+ const n = typeof s == "object" ? s.direction : s;
2616
+ return te(n) ? t.sort(re(n)) : t;
2617
+ });
2618
+ }
2619
+ function gn(e) {
2620
+ var t, r;
2621
+ return (r = (t = e.composeCode) == null ? void 0 : t.includes("measureFactory.trend")) != null ? r : !1;
2622
+ }
2623
+ function hn(e) {
2624
+ var t, r;
2625
+ return (r = (t = e.composeCode) == null ? void 0 : t.includes("measureFactory.forecast")) != null ? r : !1;
2626
+ }
2627
+ function bn(e) {
2628
+ var r, s;
2629
+ const t = [];
2630
+ for (const { measure: n, style: i } of e) {
2631
+ const o = i == null ? void 0 : i.sortType, a = o && te(o) ? n.sort(re(o)) : n;
2632
+ t.push(a), i != null && i.trend && !gn(n) && t.push(
2633
+ Mr(n, `${ve}_${(r = n.name) != null ? r : "Measure"}`, i.trend)
2634
+ ), i != null && i.forecast && !hn(n) && t.push(
2635
+ vr(
2636
+ n,
2637
+ `${Ne}_${(s = n.name) != null ? s : "Measure"}`,
2638
+ i.forecast
2639
+ )
2640
+ );
2641
+ }
2642
+ return t;
2643
+ }
2644
+ const Jn = (e) => {
2645
+ const { data: t } = e, { dataSource: r, tables: s } = e.context, n = xe(s), i = [], o = w(
2646
+ () => wt({
2647
+ data: t.dimensions || [],
2648
+ context: { dataSource: r, schemaIndex: n }
2403
2649
  }),
2404
- o
2405
- ), a = M(
2406
- () => Cs({
2407
- data: r.measures || [],
2408
- context: { dataSource: t, schemaIndex: n }
2650
+ i
2651
+ ), a = w(
2652
+ () => Mt({
2653
+ data: t.measures || [],
2654
+ context: { dataSource: r, schemaIndex: n }
2409
2655
  }),
2410
- o
2411
- ), u = M(
2412
- () => gs({
2413
- data: r.filters || [],
2414
- context: { dataSource: t, schemaIndex: n }
2656
+ i
2657
+ ), u = w(
2658
+ () => Oe({
2659
+ data: t.filters || [],
2660
+ context: { dataSource: r, schemaIndex: n }
2415
2661
  }),
2416
- o
2662
+ i
2417
2663
  );
2418
2664
  let c = null;
2419
- return r.highlights && (c = M(
2420
- () => bs({
2421
- data: r.highlights || [],
2422
- context: { dataSource: t, schemaIndex: n }
2665
+ return t.highlights && (c = w(
2666
+ () => Me({
2667
+ data: t.highlights || [],
2668
+ context: { dataSource: r, schemaIndex: n }
2423
2669
  }),
2424
- o
2425
- )), o.length > 0 ? {
2670
+ i
2671
+ )), i.length > 0 ? {
2426
2672
  success: !1,
2427
- errors: o
2673
+ errors: i
2428
2674
  } : {
2429
2675
  success: !0,
2430
2676
  data: g({
2431
- dataSource: Gr(t),
2432
- dimensions: i || [],
2433
- measures: a || [],
2677
+ dataSource: Fe(r),
2678
+ dimensions: o ? yn(o) : [],
2679
+ measures: a ? bn(a) : [],
2434
2680
  filters: u || []
2435
2681
  }, c && { highlights: c })
2436
2682
  };
2437
2683
  };
2438
- function $s(e) {
2439
- const r = [], t = [];
2684
+ function Je(e) {
2685
+ return typeof e == "object" && e !== null && "column" in e && e.column !== void 0;
2686
+ }
2687
+ function Re(e) {
2688
+ const t = [], r = [];
2440
2689
  return e.forEach((s, n) => {
2441
- const o = () => typeof s.toJSON == "function" ? s.toJSON() : s;
2442
- if (!s.composeCode) {
2443
- t.push({
2690
+ var l, f, h;
2691
+ const i = Je(s) ? s.column : s, o = Je(s) ? s : void 0, a = () => typeof i.toJSON == "function" ? i.toJSON() : i;
2692
+ if (!i.composeCode) {
2693
+ r.push({
2444
2694
  category: "dimensions",
2445
2695
  index: n,
2446
- input: o(),
2447
- message: `Dimension at index ${n} (${s.name || "unnamed"}) is missing composeCode`
2696
+ input: a(),
2697
+ message: `Dimension at index ${n} (${i.name || "unnamed"}) is missing composeCode`
2448
2698
  });
2449
2699
  return;
2450
2700
  }
2451
- if (!s.composeCode.startsWith(F)) {
2452
- t.push({
2701
+ if (!i.composeCode.startsWith(q)) {
2702
+ r.push({
2453
2703
  category: "dimensions",
2454
2704
  index: n,
2455
- input: o(),
2456
- message: `Expected composeCode to start with "${F}" for dimension at index ${n} (${s.name || "unnamed"}). Got: "${s.composeCode}"`
2705
+ input: a(),
2706
+ message: `Expected composeCode to start with '${q}' for dimension at index ${n} (${i.name || "unnamed"}). Got: '${i.composeCode}'`
2457
2707
  });
2458
2708
  return;
2459
2709
  }
2460
- const i = s.getSort();
2461
- if (i !== void 0 && i !== ie.None) {
2462
- const a = {
2463
- column: s.composeCode,
2464
- sortType: xe(i)
2465
- };
2466
- r.push(a);
2710
+ const u = (h = o != null && o.sortType ? re(o.sortType) : void 0) != null ? h : ((l = i.getSort) == null ? void 0 : l.call(i)) !== void 0 && ((f = i.getSort) == null ? void 0 : f.call(i)) !== B.None ? i.getSort() : void 0, c = o ? _(o, "column") : {};
2711
+ if (u !== void 0 && u !== B.None || o && Object.keys(c).length > 0) {
2712
+ const p = g(g({
2713
+ column: i.composeCode
2714
+ }, u !== void 0 && u !== B.None && { sortType: tt(u) }), c);
2715
+ t.push(p);
2467
2716
  } else
2468
- r.push(s.composeCode);
2469
- }), t.length > 0 ? { success: !1, errors: t } : { success: !0, data: r };
2717
+ t.push(i.composeCode);
2718
+ }), r.length > 0 ? { success: !1, errors: r } : { success: !0, data: t };
2470
2719
  }
2471
- function He(e, r) {
2472
- const t = [];
2473
- let s = "", n = 0, o = !1, i = null;
2720
+ function vt(e, t) {
2721
+ const r = [];
2722
+ let s = "", n = 0, i = !1, o = null;
2474
2723
  for (let a = 0; a < e.length; a++) {
2475
2724
  const u = e[a], c = e[a + 1];
2476
- if (o) {
2477
- if (u !== i) {
2725
+ if (i) {
2726
+ if (u !== o) {
2478
2727
  s += u;
2479
2728
  continue;
2480
2729
  }
2481
- if (c === i) {
2730
+ if (c === o) {
2482
2731
  s += u + c, a++;
2483
2732
  continue;
2484
2733
  }
2485
- o = !1, i = null, s += u;
2734
+ i = !1, o = null, s += u;
2486
2735
  continue;
2487
2736
  } else {
2488
2737
  if (u === "'" || u === '"') {
2489
- o = !0, i = u, s += u;
2738
+ i = !0, o = u, s += u;
2490
2739
  continue;
2491
2740
  }
2492
- if ("([{".includes(u) && n++, ")]}".includes(u) && n--, u === r && n === 0) {
2493
- t.push(s.trim()), s = "";
2741
+ if ("([{".includes(u) && n++, ")]}".includes(u) && n--, u === t && n === 0) {
2742
+ r.push(s.trim()), s = "";
2494
2743
  continue;
2495
2744
  }
2496
2745
  }
2497
2746
  s += u;
2498
2747
  }
2499
- return s.trim() && t.push(s.trim()), t;
2748
+ return s.trim() && r.push(s.trim()), r;
2500
2749
  }
2501
- function As(e, r) {
2502
- let t = 0, s = !1, n = null;
2503
- for (let o = 0; o < e.length; o++) {
2504
- const i = e[o], a = e[o + 1];
2750
+ function Fn(e, t) {
2751
+ let r = 0, s = !1, n = null;
2752
+ for (let i = 0; i < e.length; i++) {
2753
+ const o = e[i], a = e[i + 1];
2505
2754
  if (s) {
2506
- if (i !== n) continue;
2755
+ if (o !== n) continue;
2507
2756
  if (a === n) {
2508
- o++;
2757
+ i++;
2509
2758
  continue;
2510
2759
  }
2511
2760
  s = !1, n = null;
2512
2761
  } else {
2513
- if (i === "'" || i === '"') {
2514
- s = !0, n = i;
2762
+ if (o === "'" || o === '"') {
2763
+ s = !0, n = o;
2515
2764
  continue;
2516
2765
  }
2517
- if ("([{".includes(i) && t++, ")]}".includes(i) && t--, i === r && t === 0) return o;
2766
+ if ("([{".includes(o) && r++, ")]}".includes(o) && r--, o === t && r === 0) return i;
2518
2767
  }
2519
2768
  }
2520
2769
  return -1;
2521
2770
  }
2522
- function xs(e) {
2771
+ function wn(e) {
2523
2772
  return e.startsWith("'") && e.endsWith("'") || e.startsWith('"') && e.endsWith('"') ? e.slice(1, -1) : e;
2524
2773
  }
2525
- function _(e) {
2774
+ function V(e) {
2526
2775
  if (!e || typeof e != "string")
2527
2776
  throw new Error(`Invalid composeCode: expected non-empty string, got ${typeof e}`);
2528
- const r = e.trim();
2529
- if (!r)
2530
- throw new Error("Invalid composeCode: empty string");
2531
- const t = r.match(/^([a-zA-Z_$][a-zA-Z0-9_.$]*)\s*\((.*)\)$/);
2777
+ const t = e.trim();
2532
2778
  if (!t)
2533
- throw new Error(`Invalid composeCode format: expected function call, got "${r}"`);
2534
- const s = t[1], n = t[2], o = Ze(n);
2779
+ throw new Error("Invalid composeCode: empty string");
2780
+ const r = t.match(/^([a-zA-Z_$][a-zA-Z0-9_.$]*)\s*\((.*)\)$/);
2781
+ if (!r)
2782
+ throw new Error(`Invalid composeCode format: expected function call, got '${t}'`);
2783
+ const s = r[1], n = r[2], i = Nt(n);
2535
2784
  return {
2536
2785
  function: s,
2537
- args: o
2786
+ args: i
2538
2787
  };
2539
2788
  }
2540
- function Ze(e) {
2541
- return e.trim() ? He(e, ",").map(Xe) : [];
2789
+ function Nt(e) {
2790
+ return e.trim() ? vt(e, ",").map(Rt) : [];
2542
2791
  }
2543
- function Xe(e) {
2792
+ function Rt(e) {
2544
2793
  if (!e)
2545
2794
  throw new Error("Cannot parse empty argument value");
2546
2795
  if (e === "null")
@@ -2554,40 +2803,40 @@ function Xe(e) {
2554
2803
  if (e.match(/^-?\d+(\.\d+)?$/))
2555
2804
  return parseFloat(e);
2556
2805
  if (e.startsWith("'") && e.endsWith("'") || e.startsWith('"') && e.endsWith('"')) {
2557
- const t = e[0];
2558
- return e.slice(1, -1).replace(new RegExp(`${t}${t}`, "g"), t);
2806
+ const r = e[0];
2807
+ return e.slice(1, -1).replace(new RegExp(`${r}${r}`, "g"), r);
2559
2808
  }
2560
2809
  if (e.startsWith("[") && e.endsWith("]")) {
2561
- const t = e.slice(1, -1).trim();
2562
- if (!t)
2810
+ const r = e.slice(1, -1).trim();
2811
+ if (!r)
2563
2812
  return [];
2564
- const s = Ze(t);
2813
+ const s = Nt(r);
2565
2814
  return s.every((n) => typeof n == "string"), s;
2566
2815
  }
2567
2816
  if (e.startsWith("{") && e.endsWith("}")) {
2568
- const t = e.slice(1, -1).trim();
2569
- return t ? Ms(t) : {};
2817
+ const r = e.slice(1, -1).trim();
2818
+ return r ? An(r) : {};
2570
2819
  }
2571
- return e.includes("(") && e.includes(")") ? _(e) : (e.startsWith("DM."), e);
2820
+ return e.includes("(") && e.includes(")") ? V(e) : (e.startsWith("DM."), e);
2572
2821
  }
2573
- function Ds(e) {
2574
- const r = As(e, ":");
2575
- if (r === -1)
2576
- throw new Error(`Invalid object property: expected "key: value", got "${e}"`);
2577
- const t = xs(e.slice(0, r).trim()), s = Xe(e.slice(r + 1).trim());
2578
- return [t, s];
2822
+ function qn(e) {
2823
+ const t = Fn(e, ":");
2824
+ if (t === -1)
2825
+ throw new Error(`Invalid object property: expected 'key: value', got '${e}'`);
2826
+ const r = wn(e.slice(0, t).trim()), s = Rt(e.slice(t + 1).trim());
2827
+ return [r, s];
2579
2828
  }
2580
- function Ms(e) {
2829
+ function An(e) {
2581
2830
  if (!e.trim()) return {};
2582
- const r = He(e, ",").map(Ds).filter(([, t]) => t !== null);
2583
- return Object.fromEntries(r);
2831
+ const t = vt(e, ",").map(qn).filter(([, r]) => r !== null);
2832
+ return Object.fromEntries(t);
2584
2833
  }
2585
- const te = "Unknown error";
2586
- function Ss(e) {
2834
+ const ge = "Unknown error";
2835
+ function Ie(e) {
2587
2836
  if (!e)
2588
2837
  return { success: !0, data: [] };
2589
- const r = [];
2590
- if (Qr(e)) {
2838
+ const t = [];
2839
+ if (Nr(e)) {
2591
2840
  if (!e.composeCode)
2592
2841
  return {
2593
2842
  success: !1,
@@ -2601,9 +2850,9 @@ function Ss(e) {
2601
2850
  ]
2602
2851
  };
2603
2852
  try {
2604
- return { success: !0, data: [_(e.composeCode)] };
2853
+ return { success: !0, data: [V(e.composeCode)] };
2605
2854
  } catch (s) {
2606
- const n = s instanceof Error ? s.message : te;
2855
+ const n = s instanceof Error ? s.message : ge;
2607
2856
  return {
2608
2857
  success: !1,
2609
2858
  errors: [
@@ -2611,162 +2860,914 @@ function Ss(e) {
2611
2860
  category: "filters",
2612
2861
  index: -1,
2613
2862
  input: e,
2614
- message: `Failed to parse composeCode for FilterRelations: ${n}. ComposeCode: "${e.composeCode}"`
2863
+ message: `Failed to parse composeCode for FilterRelations: ${n}. ComposeCode: '${e.composeCode}'`
2615
2864
  }
2616
2865
  ]
2617
2866
  };
2618
2867
  }
2619
2868
  }
2620
- const t = [];
2869
+ const r = [];
2621
2870
  return e.forEach((s, n) => {
2871
+ var i;
2622
2872
  if (!s.composeCode) {
2623
- r.push({
2873
+ t.push({
2624
2874
  category: "filters",
2625
2875
  index: n,
2626
2876
  input: s,
2627
- message: `Filter at index ${n} (${s.name || "unnamed"}) is missing composeCode`
2877
+ message: `Filter at index ${n} (${(i = s.name) != null ? i : "unnamed"}) is missing composeCode`
2628
2878
  });
2629
2879
  return;
2630
2880
  }
2631
2881
  try {
2632
- const o = _(s.composeCode);
2633
- t.push(o);
2882
+ const o = V(s.composeCode);
2883
+ r.push(o);
2634
2884
  } catch (o) {
2635
- const i = o instanceof Error ? o.message : te;
2636
- r.push({
2885
+ const a = o instanceof Error ? o.message : ge;
2886
+ t.push({
2637
2887
  category: "filters",
2638
2888
  index: n,
2639
2889
  input: s,
2640
- message: `Failed to parse composeCode for filter at index ${n}: ${i}. ComposeCode: "${s.composeCode}"`
2890
+ message: `Failed to parse composeCode for filter at index ${n}: ${a}. ComposeCode: '${s.composeCode}'`
2641
2891
  });
2642
2892
  }
2643
- }), r.length > 0 ? { success: !1, errors: r } : { success: !0, data: t };
2893
+ }), t.length > 0 ? { success: !1, errors: t } : { success: !0, data: r };
2644
2894
  }
2645
- function Ts(e) {
2895
+ function ke(e) {
2646
2896
  if (!e)
2647
2897
  return { success: !0, data: [] };
2648
- const r = [], t = [];
2898
+ const t = [], r = [];
2649
2899
  return e.forEach((s, n) => {
2900
+ var i;
2650
2901
  if (!s.composeCode) {
2651
- t.push({
2902
+ r.push({
2652
2903
  category: "highlights",
2653
2904
  index: n,
2654
2905
  input: s,
2655
- message: `Highlight filter at index ${n} (${s.name || "unnamed"}) is missing composeCode`
2906
+ message: `Highlight filter at index ${n} (${(i = s.name) != null ? i : "unnamed"}) is missing composeCode`
2656
2907
  });
2657
2908
  return;
2658
2909
  }
2659
2910
  try {
2660
- const o = _(s.composeCode);
2661
- r.push(o);
2911
+ const o = V(s.composeCode);
2912
+ t.push(o);
2662
2913
  } catch (o) {
2663
- const i = o instanceof Error ? o.message : te;
2664
- t.push({
2914
+ const a = o instanceof Error ? o.message : ge;
2915
+ r.push({
2665
2916
  category: "highlights",
2666
2917
  index: n,
2667
2918
  input: s,
2668
- message: `Failed to parse composeCode for highlight filter at index ${n}: ${i}. ComposeCode: "${s.composeCode}"`
2919
+ message: `Failed to parse composeCode for highlight filter at index ${n}: ${a}. ComposeCode: '${s.composeCode}'`
2669
2920
  });
2670
2921
  }
2671
- }), t.length > 0 ? { success: !1, errors: t } : { success: !0, data: r };
2922
+ }), r.length > 0 ? { success: !1, errors: r } : { success: !0, data: t };
2672
2923
  }
2673
- function Ns(e) {
2674
- const r = [], t = [];
2924
+ function Ye(e) {
2925
+ return typeof e == "object" && e !== null && "column" in e && e.column !== void 0;
2926
+ }
2927
+ function Be(e) {
2928
+ const t = [], r = [];
2675
2929
  return e.forEach((s, n) => {
2676
- const o = () => typeof s.toJSON == "function" ? s.toJSON() : s;
2677
- if (!s.composeCode) {
2678
- t.push({
2930
+ var u, c, m;
2931
+ const i = Ye(s) ? s.column : s, o = Ye(s) ? s : void 0, a = () => typeof i.toJSON == "function" ? i.toJSON() : i;
2932
+ if (!i.composeCode) {
2933
+ r.push({
2679
2934
  category: "measures",
2680
2935
  index: n,
2681
- input: o(),
2682
- message: `Measure at index ${n} (${s.name || "unnamed"}) is missing composeCode`
2936
+ input: a(),
2937
+ message: `Measure at index ${n} (${i.name || "unnamed"}) is missing composeCode`
2683
2938
  });
2684
2939
  return;
2685
2940
  }
2686
2941
  try {
2687
- const i = _(s.composeCode), a = s.getSort();
2688
- if (a !== void 0 && a !== ie.None) {
2689
- const u = {
2690
- column: i,
2691
- sortType: xe(a)
2692
- };
2693
- r.push(u);
2942
+ const l = V(i.composeCode), f = (m = o != null && o.sortType ? re(o.sortType) : void 0) != null ? m : ((u = i.getSort) == null ? void 0 : u.call(i)) !== void 0 && ((c = i.getSort) == null ? void 0 : c.call(i)) !== B.None ? i.getSort() : void 0;
2943
+ if (f !== void 0 && f !== B.None || o && Object.keys(_(o, "column")).length > 0) {
2944
+ const p = o ? _(o, "column") : {}, d = g(g({
2945
+ column: l
2946
+ }, f !== void 0 && f !== B.None && { sortType: tt(f) }), p);
2947
+ t.push(d);
2694
2948
  } else
2695
- r.push(i);
2696
- } catch (i) {
2697
- const a = i instanceof Error ? i.message : "Unknown error";
2698
- t.push({
2949
+ t.push(l);
2950
+ } catch (l) {
2951
+ const f = l instanceof Error ? l.message : "Unknown error";
2952
+ r.push({
2699
2953
  category: "measures",
2700
2954
  index: n,
2701
- input: o(),
2702
- message: `Failed to parse composeCode for measure at index ${n} (${s.name || "unnamed"}): ${a}. ComposeCode: "${s.composeCode}"`
2955
+ input: a(),
2956
+ message: `Failed to parse composeCode for measure at index ${n} (${i.name || "unnamed"}): ${f}. ComposeCode: '${i.composeCode}'`
2703
2957
  });
2704
2958
  }
2705
- }), t.length > 0 ? { success: !1, errors: t } : { success: !0, data: r };
2959
+ }), r.length > 0 ? { success: !1, errors: r } : { success: !0, data: t };
2706
2960
  }
2707
- function se(e) {
2708
- return typeof e == "string" ? e.replace(/\[\[([^\]]+)\]\]/g, "$1") : Array.isArray(e) ? e.map(se) : e !== null && typeof e == "object" ? Object.fromEntries(
2709
- Object.entries(e).map(([r, t]) => [r, se(t)])
2710
- ) : e;
2961
+ function Ge(e) {
2962
+ var t, r, s, n;
2963
+ return ((r = (t = e.composeCode) == null ? void 0 : t.includes("measureFactory.trend")) != null ? r : !1) || ((n = (s = e.name) == null ? void 0 : s.startsWith(ve)) != null ? n : !1);
2711
2964
  }
2712
- function Ls(e) {
2713
- const r = [], t = M(
2714
- () => $s(e.dimensions || []),
2715
- r
2716
- ), s = M(
2717
- () => Ns(e.measures || []),
2718
- r
2719
- ), n = M(
2720
- () => Ss(e.filters),
2721
- r
2965
+ function Qe(e) {
2966
+ var t, r, s, n;
2967
+ return ((r = (t = e.composeCode) == null ? void 0 : t.includes("measureFactory.forecast")) != null ? r : !1) || ((n = (s = e.name) == null ? void 0 : s.startsWith(Ne)) != null ? n : !1);
2968
+ }
2969
+ function He(e) {
2970
+ try {
2971
+ const t = V(e.trim());
2972
+ return t.args[2] != null && typeof t.args[2] == "object" ? t.args[2] : void 0;
2973
+ } catch (t) {
2974
+ return;
2975
+ }
2976
+ }
2977
+ function Cn(e) {
2978
+ var s, n, i;
2979
+ if (!(e != null && e.length)) return [];
2980
+ const t = /* @__PURE__ */ new Set(), r = [];
2981
+ for (let o = 0; o < e.length; o++) {
2982
+ if (t.has(o)) continue;
2983
+ const a = e[o];
2984
+ if (Ge(a) || Qe(a)) {
2985
+ r.push(a);
2986
+ continue;
2987
+ }
2988
+ const u = (s = a.name) != null ? s : "Measure", c = `${ve}_${u}`, m = `${Ne}_${u}`;
2989
+ let l, f, h = o + 1;
2990
+ if (h < e.length && !t.has(h) && Ge(e[h]) && e[h].name === c) {
2991
+ const p = (n = e[h].composeCode) == null ? void 0 : n.trim();
2992
+ p && (l = He(p), t.add(h), h++);
2993
+ }
2994
+ if (h < e.length && !t.has(h) && Qe(e[h]) && e[h].name === m) {
2995
+ const p = (i = e[h].composeCode) == null ? void 0 : i.trim();
2996
+ p && (f = He(p), t.add(h));
2997
+ }
2998
+ l !== void 0 || f !== void 0 ? r.push(g(g({
2999
+ column: a
3000
+ }, l && Object.keys(l).length > 0 && { trend: l }), f && Object.keys(f).length > 0 && { forecast: f })) : r.push(a);
3001
+ }
3002
+ return r;
3003
+ }
3004
+ function Yn(e) {
3005
+ const t = [], r = w(
3006
+ () => Re(e.dimensions || []),
3007
+ t
3008
+ ), s = Cn(e.measures || []), n = w(
3009
+ () => Be(s),
3010
+ t
3011
+ ), i = w(
3012
+ () => Ie(e.filters),
3013
+ t
2722
3014
  );
2723
3015
  let o = null;
2724
- if (e.highlights && e.highlights.length > 0 && (o = M(
2725
- () => Ts(e.highlights),
2726
- r
2727
- )), r.length > 0)
3016
+ if (e.highlights && e.highlights.length > 0 && (o = w(
3017
+ () => ke(e.highlights),
3018
+ t
3019
+ )), t.length > 0)
2728
3020
  return {
2729
3021
  success: !1,
2730
- errors: r
3022
+ errors: t
2731
3023
  };
2732
- const i = g({
2733
- dimensions: t || [],
2734
- measures: s || [],
2735
- filters: n || []
3024
+ const a = g({
3025
+ dimensions: r || [],
3026
+ measures: n || [],
3027
+ filters: i || []
2736
3028
  }, o && { highlights: o });
2737
3029
  return {
2738
3030
  success: !0,
2739
3031
  // Strip [[delimiters]] from all strings to preserve original names with spaces
2740
- data: se(i)
3032
+ data: Q(a)
3033
+ };
3034
+ }
3035
+ const It = new Set(
3036
+ Rr.filter((e) => e !== "image")
3037
+ ), Xe = Object.freeze([...It]), le = /* @__PURE__ */ new Set([
3038
+ "category",
3039
+ "value",
3040
+ "breakBy",
3041
+ "breakByPoint",
3042
+ "x",
3043
+ "y",
3044
+ "breakByColor",
3045
+ "size",
3046
+ "boxType",
3047
+ "outliers",
3048
+ "geo",
3049
+ "colorBy",
3050
+ "details",
3051
+ "color",
3052
+ "date",
3053
+ "columns",
3054
+ "rows",
3055
+ "values",
3056
+ "secondary",
3057
+ "min",
3058
+ "max",
3059
+ "seriesToColorMap"
3060
+ ]), En = {
3061
+ line: {
3062
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "breakBy", "seriesToColorMap"]),
3063
+ requiredAxes: ["category", "value"]
3064
+ },
3065
+ area: {
3066
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "breakBy", "seriesToColorMap"]),
3067
+ requiredAxes: ["category", "value"]
3068
+ },
3069
+ bar: {
3070
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "breakBy", "seriesToColorMap"]),
3071
+ requiredAxes: ["category", "value"]
3072
+ },
3073
+ column: {
3074
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "breakBy", "seriesToColorMap"]),
3075
+ requiredAxes: ["category", "value"]
3076
+ },
3077
+ streamgraph: {
3078
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "breakBy", "seriesToColorMap"]),
3079
+ requiredAxes: ["category", "value"]
3080
+ },
3081
+ polar: {
3082
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "breakBy", "seriesToColorMap"]),
3083
+ requiredAxes: ["category", "value"]
3084
+ },
3085
+ pie: {
3086
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "seriesToColorMap"]),
3087
+ requiredAxes: ["category", "value"]
3088
+ },
3089
+ funnel: {
3090
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "seriesToColorMap"]),
3091
+ requiredAxes: ["category", "value"]
3092
+ },
3093
+ treemap: {
3094
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "seriesToColorMap"]),
3095
+ requiredAxes: ["category", "value"]
3096
+ },
3097
+ sunburst: {
3098
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "seriesToColorMap"]),
3099
+ requiredAxes: ["category", "value"]
3100
+ },
3101
+ scatter: {
3102
+ validAxes: /* @__PURE__ */ new Set(["x", "y", "breakByPoint", "breakByColor", "size", "seriesToColorMap"]),
3103
+ requiredAxes: []
3104
+ },
3105
+ table: {
3106
+ validAxes: /* @__PURE__ */ new Set(["columns"]),
3107
+ requiredAxes: ["columns"]
3108
+ },
3109
+ indicator: {
3110
+ validAxes: /* @__PURE__ */ new Set(["value", "secondary", "min", "max"]),
3111
+ requiredAxes: []
3112
+ },
3113
+ boxplot: {
3114
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "boxType", "outliers"]),
3115
+ requiredAxes: ["value"]
3116
+ },
3117
+ areamap: {
3118
+ validAxes: /* @__PURE__ */ new Set(["geo", "color"]),
3119
+ requiredAxes: ["geo"]
3120
+ },
3121
+ scattermap: {
3122
+ validAxes: /* @__PURE__ */ new Set(["geo", "size", "colorBy", "details"]),
3123
+ requiredAxes: ["geo"]
3124
+ },
3125
+ "calendar-heatmap": {
3126
+ validAxes: /* @__PURE__ */ new Set(["date", "value"]),
3127
+ requiredAxes: ["date", "value"]
3128
+ },
3129
+ arearange: {
3130
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "breakBy", "seriesToColorMap"]),
3131
+ requiredAxes: ["category", "value"]
3132
+ }
3133
+ }, xn = /* @__PURE__ */ new Set([
3134
+ "category",
3135
+ "breakBy",
3136
+ "breakByPoint",
3137
+ "rows",
3138
+ "geo",
3139
+ "details",
3140
+ "date"
3141
+ ]), $n = /* @__PURE__ */ new Set([
3142
+ "value",
3143
+ "size",
3144
+ "colorBy",
3145
+ "boxType",
3146
+ "outliers",
3147
+ "values",
3148
+ "secondary",
3149
+ "min",
3150
+ "max",
3151
+ "color"
3152
+ ]);
3153
+ function Tn(e) {
3154
+ const t = En[e];
3155
+ if (t)
3156
+ return {
3157
+ validAxes: new Set(t.validAxes),
3158
+ requiredAxes: Object.freeze([...t.requiredAxes])
3159
+ };
3160
+ }
3161
+ function kt(e) {
3162
+ return typeof e == "string" && It.has(e);
3163
+ }
3164
+ function Dn(e, t, r) {
3165
+ if (r === "boxplot" && e === "value" || r === "calendar-heatmap" && e === "date" || xn.has(e))
3166
+ return !0;
3167
+ if ($n.has(e))
3168
+ return !1;
3169
+ const s = Array.isArray(t) ? t[0] : t;
3170
+ if (!s)
3171
+ return !0;
3172
+ let n;
3173
+ return T(s) && "column" in s && (n = s.column), !(E(s) || n !== void 0 && E(n));
3174
+ }
3175
+ function Sn(e) {
3176
+ const t = [], r = {
3177
+ chartType: "",
3178
+ dataOptions: {}
3179
+ };
3180
+ if (!T(e))
3181
+ return t.push({
3182
+ category: "chartType",
3183
+ index: -1,
3184
+ input: e,
3185
+ message: "Expected an object"
3186
+ }), { normalized: r, errors: t };
3187
+ const s = e.chartType;
3188
+ if (s === void 0) {
3189
+ const i = Object.keys(e), o = M("chartType", i, (c) => c), a = o && o.distance <= x ? ` Did you mean 'chartType'? (You may have typed '${o.best}')` : "", u = o && o.distance <= x ? { [o.best]: e[o.best] } : e;
3190
+ t.push({
3191
+ category: "chartType",
3192
+ index: -1,
3193
+ input: u,
3194
+ message: `chartType is required.${a}`
3195
+ });
3196
+ } else if (kt(s))
3197
+ r.chartType = s;
3198
+ else {
3199
+ const i = M(String(s), Xe, (u) => u), o = i && i.distance <= x ? ` Did you mean '${i.best}'?` : "", a = Xe.slice(0, 8).join(", ");
3200
+ t.push({
3201
+ category: "chartType",
3202
+ index: -1,
3203
+ input: s,
3204
+ message: `Invalid chartType '${s}'. Valid types: ${a}, ...${o}`
3205
+ });
3206
+ }
3207
+ const n = e.dataOptions;
3208
+ if (n === void 0) {
3209
+ const i = Object.keys(e), o = M("dataOptions", i, (c) => c), a = o && o.distance <= x ? ` Did you mean 'dataOptions'? (You may have typed '${o.best}')` : "", u = o && o.distance <= x ? { [o.best]: e[o.best] } : e;
3210
+ t.push({
3211
+ category: "dataOptions",
3212
+ index: -1,
3213
+ input: u,
3214
+ message: `dataOptions is required.${a}`
3215
+ });
3216
+ } else n !== null && typeof n == "object" && (r.dataOptions = n);
3217
+ return e.styleOptions !== void 0 && (r.styleOptions = e.styleOptions), e.filters !== void 0 && Array.isArray(e.filters) && (r.filters = e.filters), e.highlights !== void 0 && Array.isArray(e.highlights) && (r.highlights = e.highlights), { normalized: r, errors: t };
3218
+ }
3219
+ function On(e) {
3220
+ return e.map(
3221
+ ({ attribute: t, style: r }) => r ? g({ column: t }, r) : t
3222
+ );
3223
+ }
3224
+ function Mn(e) {
3225
+ return e.map(
3226
+ ({ measure: t, style: r }) => r ? g({ column: t }, r) : t
3227
+ );
3228
+ }
3229
+ function Bt(e) {
3230
+ return Array.isArray(e) ? e : [e];
3231
+ }
3232
+ function he(e) {
3233
+ return (t) => F(g({}, t), {
3234
+ category: "dataOptions",
3235
+ index: e
3236
+ });
3237
+ }
3238
+ function ee(e, t, r, s, n) {
3239
+ const i = t ? Bt(
3240
+ t
3241
+ ) : [];
3242
+ if (i.length === 0)
3243
+ return [];
3244
+ if (r === "dimension") {
3245
+ const a = w(
3246
+ () => wt({
3247
+ data: i,
3248
+ context: s
3249
+ }),
3250
+ n,
3251
+ he(e)
3252
+ );
3253
+ return a !== null ? On(a) : null;
3254
+ }
3255
+ const o = w(
3256
+ () => Mt({
3257
+ data: i,
3258
+ context: s
3259
+ }),
3260
+ n,
3261
+ he(e)
3262
+ );
3263
+ return o !== null ? Mn(o) : null;
3264
+ }
3265
+ function Ze(e, t, r) {
3266
+ const s = Array.isArray(t) ? t : t != null ? [t] : [];
3267
+ if (r === "dimension") {
3268
+ const i = Re(
3269
+ s
3270
+ );
3271
+ return i.success ? { success: !0, data: i.data } : {
3272
+ success: !1,
3273
+ errors: i.errors.map((o) => F(g({}, o), {
3274
+ category: "dataOptions",
3275
+ index: e
3276
+ }))
3277
+ };
3278
+ }
3279
+ const n = Be(s);
3280
+ return n.success ? { success: !0, data: n.data } : {
3281
+ success: !1,
3282
+ errors: n.errors.map((i) => F(g({}, i), {
3283
+ category: "dataOptions",
3284
+ index: e
3285
+ }))
3286
+ };
3287
+ }
3288
+ function vn(e, t) {
3289
+ let r;
3290
+ T(e) && "column" in e && (r = e.column);
3291
+ const n = !(E(e) || r !== void 0 && E(r)) ? "dimension" : "measure", i = [], o = ee("columns", [e], n, t, i);
3292
+ return o !== null ? { success: !0, data: o } : { success: !1, errors: i };
3293
+ }
3294
+ function Nn(e, t, r, s) {
3295
+ const n = [];
3296
+ for (const i of e) {
3297
+ const o = w(
3298
+ () => vn(i, t),
3299
+ r,
3300
+ s
3301
+ );
3302
+ o && n.push(...o);
3303
+ }
3304
+ return n;
3305
+ }
3306
+ function Rn(e, t, r) {
3307
+ if (!e || !T(e))
3308
+ return r.push({
3309
+ category: "dataOptions",
3310
+ index: -1,
3311
+ input: e,
3312
+ message: "dataOptions is required"
3313
+ }), null;
3314
+ const s = {}, { chartType: n } = t, i = r.length, o = e, a = Object.keys(e), u = /* @__PURE__ */ new Map();
3315
+ for (const l of a)
3316
+ if (!le.has(l)) {
3317
+ const f = M(l, [...le], (p) => p), h = f && f.distance <= x ? ` Did you mean '${f.best}'?` : "";
3318
+ f && f.distance <= x && u.set(l, f.best), r.push({
3319
+ category: "dataOptions",
3320
+ index: l,
3321
+ input: o[l],
3322
+ message: `Unknown dataOptions key '${l}'.${h}`
3323
+ });
3324
+ }
3325
+ const c = n ? Tn(n) : void 0;
3326
+ if (c) {
3327
+ for (const l of a)
3328
+ if (l !== "seriesToColorMap" && !c.validAxes.has(l) && le.has(l)) {
3329
+ const f = M(l, [...c.validAxes], (d) => d), h = f && f.distance <= x ? ` Did you mean '${f.best}'?` : "", p = [...c.validAxes].join(", ");
3330
+ r.push({
3331
+ category: "dataOptions",
3332
+ index: l,
3333
+ input: o[l],
3334
+ message: `Axis '${l}' is not valid for chart type '${n}'. Valid axes: ${p}.${h}`
3335
+ });
3336
+ }
3337
+ for (const l of c.requiredAxes)
3338
+ [...u.values()].includes(l) || (!(l in o) || o[l] == null) && r.push({
3339
+ category: "dataOptions",
3340
+ index: l,
3341
+ input: null,
3342
+ message: `Chart type '${n}' requires '${c.requiredAxes.join(
3343
+ "' and '"
3344
+ )}'. Missing: ${l}.`
3345
+ });
3346
+ n === "indicator" && (["value", "secondary", "min", "max"].some(
3347
+ (h) => h in o && o[h] != null
3348
+ ) || r.push({
3349
+ category: "dataOptions",
3350
+ index: -1,
3351
+ input: e,
3352
+ message: "Indicator chart requires at least one of: value, secondary, min, max."
3353
+ })), n === "scatter" && ("x" in e && e.x != null || "y" in e && e.y != null || r.push({
3354
+ category: "dataOptions",
3355
+ index: -1,
3356
+ input: e,
3357
+ message: "Scatter chart requires at least one of: x, y."
3358
+ }));
3359
+ }
3360
+ if (r.length > i)
3361
+ return null;
3362
+ const m = Object.entries(e);
3363
+ for (const [l, f] of m) {
3364
+ if (!f) continue;
3365
+ if (l === "seriesToColorMap") {
3366
+ s[l] = f;
3367
+ continue;
3368
+ }
3369
+ if (l === "columns") {
3370
+ s[l] = Nn(
3371
+ Bt(f),
3372
+ t,
3373
+ r,
3374
+ he("columns")
3375
+ );
3376
+ continue;
3377
+ }
3378
+ const h = Dn(l, f, n) ? "dimension" : "measure", p = ee(
3379
+ l,
3380
+ f,
3381
+ h,
3382
+ t,
3383
+ r
3384
+ );
3385
+ if (p !== null) {
3386
+ const d = n === "calendar-heatmap" && l === "value";
3387
+ s[l] = d || !Array.isArray(f) ? p[0] : p;
3388
+ }
3389
+ }
3390
+ return r.length > i ? null : s;
3391
+ }
3392
+ function In(e) {
3393
+ if (typeof e != "string") return "iqr";
3394
+ const t = e.split("/")[1];
3395
+ return t === "iqr" || t === "extremums" || t === "standardDeviation" ? t : "iqr";
3396
+ }
3397
+ const Gn = (e) => {
3398
+ var d;
3399
+ const { data: t, context: r } = e, { dataSource: s, tables: n } = r, { normalized: i, errors: o } = Sn(t);
3400
+ if (o.length > 0)
3401
+ return { success: !1, errors: o };
3402
+ const a = i.chartType, u = xe(n), c = [];
3403
+ let m = Rn(
3404
+ i.dataOptions,
3405
+ { dataSource: s, schemaIndex: u, chartType: a },
3406
+ c
3407
+ );
3408
+ if (a === "boxplot" && m) {
3409
+ const b = In((d = i.styleOptions) == null ? void 0 : d.subtype), A = b === "iqr" || b === "standardDeviation";
3410
+ m = F(g({}, m), { boxType: b, outliersEnabled: A });
3411
+ }
3412
+ let l = null;
3413
+ i.filters && i.filters.length > 0 && (l = w(
3414
+ () => Oe({
3415
+ data: i.filters || [],
3416
+ context: { dataSource: s, schemaIndex: u }
3417
+ }),
3418
+ c
3419
+ ));
3420
+ let f = null;
3421
+ if (i.highlights && i.highlights.length > 0 && (f = w(
3422
+ () => Me({
3423
+ data: i.highlights || [],
3424
+ context: { dataSource: s, schemaIndex: u }
3425
+ }),
3426
+ c
3427
+ )), c.length > 0 || m === null)
3428
+ return {
3429
+ success: !1,
3430
+ errors: c
3431
+ };
3432
+ if (!kt(i.chartType))
3433
+ return {
3434
+ success: !1,
3435
+ errors: [
3436
+ {
3437
+ category: "chartType",
3438
+ index: -1,
3439
+ input: i.chartType,
3440
+ message: "Invalid chartType"
3441
+ }
3442
+ ]
3443
+ };
3444
+ const h = i.chartType;
3445
+ return {
3446
+ success: !0,
3447
+ data: g(g(g({
3448
+ dataSet: Fe(s),
3449
+ chartType: h,
3450
+ dataOptions: m
3451
+ }, i.styleOptions && {
3452
+ // Pass-through NLQ JSON; shape matches ChartStyleOptions.
3453
+ styleOptions: i.styleOptions
3454
+ }), l && { filters: l }), f && { highlights: f })
3455
+ };
3456
+ }, Qn = (e) => {
3457
+ const t = [];
3458
+ if (!e.chartType)
3459
+ return {
3460
+ success: !1,
3461
+ errors: [
3462
+ {
3463
+ category: "dimensions",
3464
+ index: -1,
3465
+ input: e,
3466
+ message: "chartType is required"
3467
+ }
3468
+ ]
3469
+ };
3470
+ if (!e.dataOptions)
3471
+ return {
3472
+ success: !1,
3473
+ errors: [
3474
+ {
3475
+ category: "dimensions",
3476
+ index: -1,
3477
+ input: e,
3478
+ message: "dataOptions is required"
3479
+ }
3480
+ ]
3481
+ };
3482
+ let r = null;
3483
+ const s = kn(e.dataOptions);
3484
+ s.success ? r = s.data : t.push(...s.errors);
3485
+ let n;
3486
+ if (e.filters) {
3487
+ const u = w(
3488
+ () => Ie(e.filters),
3489
+ t
3490
+ );
3491
+ n = u != null ? u : void 0;
3492
+ }
3493
+ let i;
3494
+ if (e.highlights && e.highlights.length > 0) {
3495
+ const u = w(
3496
+ () => ke(e.highlights),
3497
+ t
3498
+ );
3499
+ i = u != null ? u : void 0;
3500
+ }
3501
+ if (t.length > 0 || r === null)
3502
+ return { success: !1, errors: t };
3503
+ const o = g(g(g({
3504
+ chartType: e.chartType,
3505
+ dataOptions: r
3506
+ }, e.styleOptions && {
3507
+ styleOptions: e.styleOptions
3508
+ }), n && n.length > 0 && { filters: n }), i && i.length > 0 && { highlights: i });
3509
+ return {
3510
+ success: !0,
3511
+ data: Q(
3512
+ o
3513
+ )
2741
3514
  };
3515
+ };
3516
+ function kn(e) {
3517
+ const t = {}, r = [], s = /* @__PURE__ */ new Set(["seriesToColorMap", "boxType", "outliersEnabled", "valueTitle"]);
3518
+ for (const [n, i] of Object.entries(e)) {
3519
+ if (n === "seriesToColorMap" && i) {
3520
+ t[n] = i;
3521
+ continue;
3522
+ }
3523
+ if (s.has(n) || i == null) {
3524
+ i != null && (t[n] = i);
3525
+ continue;
3526
+ }
3527
+ const o = Array.isArray(i) ? i : [i], a = Array.isArray(i), u = [], c = [];
3528
+ for (let m = 0; m < o.length; m++) {
3529
+ const l = o[m], h = Bn(l) ? Re([
3530
+ l
3531
+ ]) : Be([l]);
3532
+ h.success ? u.push(...h.data) : h.errors.forEach((p) => {
3533
+ var d;
3534
+ c.push(F(g({}, p), { index: m, input: (d = p.input) != null ? d : l }));
3535
+ });
3536
+ }
3537
+ if (c.length > 0) {
3538
+ r.push(...c);
3539
+ continue;
3540
+ }
3541
+ t[n] = a ? u : u[0];
3542
+ }
3543
+ return r.length > 0 ? { success: !1, errors: r } : { success: !0, data: t };
2742
3544
  }
2743
- function Rs(e) {
2744
- const { filters: r, relations: t } = Zr(
3545
+ function Bn(e) {
3546
+ const t = Array.isArray(e) ? e[0] : e;
3547
+ if (!t || !T(t))
3548
+ return !0;
3549
+ const r = "column" in t && t.column != null && T(t.column) ? t.column : t;
3550
+ if ("composeCode" in r) {
3551
+ const s = r.composeCode;
3552
+ if (typeof s == "string" && s.startsWith("DM."))
3553
+ return !0;
3554
+ if (typeof s == "string" && (s.includes("measureFactory") || s.includes("Formula")))
3555
+ return !1;
3556
+ }
3557
+ if ("type" in r) {
3558
+ const s = r.type;
3559
+ if (s === "basemeasure" || s === "calculatedmeasure")
3560
+ return !1;
3561
+ }
3562
+ return !("aggregation" in r || "attribute" in r && "aggregation" in r);
3563
+ }
3564
+ const et = ["rows", "columns", "values", "grandTotals"];
3565
+ function zn(e) {
3566
+ if (!T(e)) return !1;
3567
+ const t = Object.keys(e);
3568
+ return t.every((r) => r === "rows" || r === "columns") && t.every((r) => typeof e[r] == "boolean");
3569
+ }
3570
+ function Pn(e) {
3571
+ const t = [], r = {
3572
+ dataOptions: {}
3573
+ };
3574
+ if (!T(e))
3575
+ return t.push({
3576
+ category: "dataOptions",
3577
+ index: -1,
3578
+ input: e,
3579
+ message: "Expected an object"
3580
+ }), { normalized: r, errors: t };
3581
+ const s = e.dataOptions;
3582
+ if (s === void 0) {
3583
+ const n = Object.keys(e), i = M("dataOptions", n, (u) => u), o = i && i.distance <= x ? ` Did you mean 'dataOptions'? (You may have typed '${i.best}')` : "", a = i && i.distance <= x ? { [i.best]: e[i.best] } : e;
3584
+ t.push({
3585
+ category: "dataOptions",
3586
+ index: -1,
3587
+ input: a,
3588
+ message: `dataOptions is required.${o}`
3589
+ });
3590
+ } else if (T(s)) {
3591
+ const n = s;
3592
+ r.dataOptions = n;
3593
+ for (const o of Object.keys(n))
3594
+ if (!et.includes(o)) {
3595
+ const a = M(o, [...et], (c) => c), u = a && a.distance <= x ? ` Did you mean '${a.best}'?` : "";
3596
+ t.push({
3597
+ category: "dataOptions",
3598
+ index: o,
3599
+ input: n[o],
3600
+ message: `Unknown dataOptions key '${o}'. Valid keys: rows, columns, values, grandTotals.${u}`
3601
+ });
3602
+ }
3603
+ for (const o of ["rows", "columns", "values"]) {
3604
+ const a = n[o];
3605
+ a != null && !Array.isArray(a) && t.push({
3606
+ category: "dataOptions",
3607
+ index: o,
3608
+ input: a,
3609
+ message: `dataOptions.${o} must be an array`
3610
+ });
3611
+ }
3612
+ const i = n.grandTotals;
3613
+ i != null && !zn(i) && t.push({
3614
+ category: "dataOptions",
3615
+ index: "grandTotals",
3616
+ input: i,
3617
+ message: "grandTotals must be an object with optional rows?: boolean, columns?: boolean"
3618
+ });
3619
+ }
3620
+ return e.styleOptions !== void 0 && (r.styleOptions = e.styleOptions), e.filters !== void 0 && Array.isArray(e.filters) && (r.filters = e.filters), e.highlights !== void 0 && Array.isArray(e.highlights) && (r.highlights = e.highlights), { normalized: r, errors: t };
3621
+ }
3622
+ function Ln(e, t, r) {
3623
+ if (!e || typeof e != "object")
3624
+ return r.push({
3625
+ category: "dataOptions",
3626
+ index: -1,
3627
+ input: e,
3628
+ message: "dataOptions is required"
3629
+ }), null;
3630
+ const s = {}, n = r.length;
3631
+ for (const o of ["rows", "columns"]) {
3632
+ const a = ee(
3633
+ o,
3634
+ e[o],
3635
+ "dimension",
3636
+ t,
3637
+ r
3638
+ );
3639
+ a && (s[o] = a);
3640
+ }
3641
+ const i = ee(
3642
+ "values",
3643
+ e.values,
3644
+ "measure",
3645
+ t,
3646
+ r
3647
+ );
3648
+ return i && (s.values = i), e.grandTotals !== void 0 && (s.grandTotals = e.grandTotals), r.length > n ? null : s;
3649
+ }
3650
+ const Hn = (e) => {
3651
+ const { data: t, context: r } = e, { dataSource: s, tables: n } = r, { normalized: i, errors: o } = Pn(t);
3652
+ if (o.length > 0)
3653
+ return { success: !1, errors: o };
3654
+ const a = xe(n), u = [], c = Ln(
3655
+ i.dataOptions,
3656
+ { dataSource: s, schemaIndex: a },
3657
+ u
3658
+ );
3659
+ let m = null;
3660
+ i.filters && i.filters.length > 0 && (m = w(
3661
+ () => Oe({
3662
+ data: i.filters || [],
3663
+ context: { dataSource: s, schemaIndex: a }
3664
+ }),
3665
+ u
3666
+ ));
3667
+ let l = null;
3668
+ return i.highlights && i.highlights.length > 0 && (l = w(
3669
+ () => Me({
3670
+ data: i.highlights || [],
3671
+ context: { dataSource: s, schemaIndex: a }
3672
+ }),
3673
+ u
3674
+ )), u.length > 0 || c === null ? {
3675
+ success: !1,
3676
+ errors: u
3677
+ } : {
3678
+ success: !0,
3679
+ data: g(g(g({
3680
+ dataSet: Fe(s),
3681
+ dataOptions: c
3682
+ }, i.styleOptions && { styleOptions: i.styleOptions }), m && { filters: m }), l && { highlights: l })
3683
+ };
3684
+ }, Xn = (e) => {
3685
+ const t = [];
3686
+ if (!e.dataOptions)
3687
+ return {
3688
+ success: !1,
3689
+ errors: [
3690
+ {
3691
+ category: "dataOptions",
3692
+ index: -1,
3693
+ input: e,
3694
+ message: "dataOptions is required"
3695
+ }
3696
+ ]
3697
+ };
3698
+ const r = e.dataOptions, s = {};
3699
+ for (const c of ["rows", "columns"]) {
3700
+ const m = r[c];
3701
+ if (m && m.length > 0) {
3702
+ const l = Ze(c, m, "dimension");
3703
+ l.success ? s[c] = l.data : t.push(...l.errors);
3704
+ }
3705
+ }
3706
+ const n = r.values;
3707
+ if (n && n.length > 0) {
3708
+ const c = Ze("values", n, "measure");
3709
+ c.success ? s.values = c.data : t.push(...c.errors);
3710
+ }
3711
+ r.grandTotals !== void 0 && (s.grandTotals = r.grandTotals);
3712
+ let i;
3713
+ if (e.filters) {
3714
+ const c = w(
3715
+ () => Ie(e.filters),
3716
+ t
3717
+ );
3718
+ i = c != null ? c : void 0;
3719
+ }
3720
+ let o;
3721
+ if (e.highlights && e.highlights.length > 0) {
3722
+ const c = w(
3723
+ () => ke(e.highlights),
3724
+ t
3725
+ );
3726
+ o = c != null ? c : void 0;
3727
+ }
3728
+ if (t.length > 0)
3729
+ return { success: !1, errors: t };
3730
+ const a = g(g(g({
3731
+ dataOptions: s
3732
+ }, e.styleOptions && { styleOptions: e.styleOptions }), i && i.length > 0 && { filters: i }), o && o.length > 0 && { highlights: o });
3733
+ return {
3734
+ success: !0,
3735
+ data: Q(
3736
+ a
3737
+ )
3738
+ };
3739
+ };
3740
+ function _n(e) {
3741
+ const { filters: t, relations: r } = Br(
2745
3742
  e.filters || []
2746
3743
  );
2747
3744
  return {
2748
3745
  dataSource: e.dataSource,
2749
3746
  dimensions: e.dimensions,
2750
3747
  measures: e.measures,
2751
- filters: r,
2752
- filterRelations: t,
3748
+ filters: t,
3749
+ filterRelations: r,
2753
3750
  highlights: e.highlights
2754
3751
  // No count/offset/ungroup - these are execution concerns, not translation concerns
2755
3752
  };
2756
3753
  }
2757
- function Vs(e, r, t = !1) {
2758
- const s = Rs(e), n = Yr(s, r);
2759
- return Hr(n, t);
3754
+ function Zn(e, t, r = !1) {
3755
+ const s = _n(e), n = Ir(s, t);
3756
+ return kr(n, r);
2760
3757
  }
2761
3758
  export {
2762
- Ps as CustomSuperJSON,
2763
- Ws as EMPTY_EXPANDED_QUERY_MODEL,
2764
- js as EMPTY_SIMPLE_QUERY_MODEL,
2765
- Js as isByIdDashboardCodeParams,
2766
- Ks as isByIdWidgetCodeParams,
2767
- Gs as isClientSideDashboardCodeParams,
2768
- Qs as isClientSideWidgetCodeParams,
2769
- ks as translateQueryFromJSON,
2770
- Ls as translateQueryToJSON,
2771
- Vs as translateQueryToJaql
3759
+ Kn as CustomSuperJSON,
3760
+ ri as EMPTY_EXPANDED_QUERY_MODEL,
3761
+ si as EMPTY_SIMPLE_QUERY_MODEL,
3762
+ ni as isByIdDashboardCodeParams,
3763
+ ii as isByIdWidgetCodeParams,
3764
+ oi as isClientSideDashboardCodeParams,
3765
+ ai as isClientSideWidgetCodeParams,
3766
+ Gn as translateChartFromJSON,
3767
+ Qn as translateChartToJSON,
3768
+ Hn as translatePivotTableFromJSON,
3769
+ Xn as translatePivotTableToJSON,
3770
+ Jn as translateQueryFromJSON,
3771
+ Yn as translateQueryToJSON,
3772
+ Zn as translateQueryToJaql
2772
3773
  };