react-semaphor 0.1.604 → 0.1.606

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 (151) hide show
  1. package/dist/analytics-protocol/index.js +1 -1
  2. package/dist/appearance/index.js +1 -1
  3. package/dist/appearance-runtime/index.js +1 -1
  4. package/dist/assistant-context/index.js +1 -1
  5. package/dist/assistant-protocol/index.js +1 -1
  6. package/dist/brand-studio/index.js +3 -8
  7. package/dist/briefings/index.js +1 -1
  8. package/dist/chunks/{add-to-dashboard-DeHEBEqG.js → add-to-dashboard-CEmZUf9o.js} +1 -1
  9. package/dist/chunks/{analytics-base-schemas-BREc5WGv.js → analytics-base-schemas-DMFrDqn_.js} +1 -1
  10. package/dist/chunks/appearance-provider-fIhJSX6y.js +613 -0
  11. package/dist/chunks/appearance-runtime-provider-Bx8H-moR.js +1 -0
  12. package/dist/chunks/{assistant-chat-CjYrwVDa.js → assistant-chat-SBKSrrEA.js} +19 -24
  13. package/dist/chunks/attachment-filter-line-C_zHMhGh.js +1 -0
  14. package/dist/chunks/{bookmark-impact-C89zBLq3.js → bookmark-impact-BW30cm5E.js} +1 -1
  15. package/dist/chunks/bookmark-state-DScd31KT.js +1 -0
  16. package/dist/chunks/brand-CL5xDiFH.js +1 -0
  17. package/dist/chunks/card-filter-builder-CzScSOQY.js +11 -0
  18. package/dist/chunks/comparison-window-caption-tguyN24S.js +1 -0
  19. package/dist/chunks/{context-ALdccLHw.js → context-CntvtZwC.js} +1 -1
  20. package/dist/chunks/dashboard-Cyhj9EOl.js +1 -0
  21. package/dist/chunks/dashboard-briefing-launcher-CyOFddmD.js +42 -0
  22. package/dist/chunks/dashboard-controls-DpADfhr0.js +42 -0
  23. package/dist/chunks/dashboard-json-4xMChR2q.js +1 -0
  24. package/dist/chunks/dashboard-temporal-snapshot-w3SMiPKj.js +1 -0
  25. package/dist/chunks/edit-dashboard-visual-DlvY7au4.js +73 -0
  26. package/dist/chunks/filter-line-WwUV5JzN.js +1 -0
  27. package/dist/chunks/filter-reach-preview-DAEIyrEG.js +1 -0
  28. package/dist/chunks/filter-value-text-DqTHe_vu.js +1 -0
  29. package/dist/chunks/{index-BE1DfxNs.js → index-bkP6SnYu.js} +1 -1
  30. package/dist/chunks/kpi-trend-rule-N1Xkwe_u.js +1 -0
  31. package/dist/chunks/{layout-grid-BWtlgw0T.js → layout-grid-Dtsioq4h.js} +1 -1
  32. package/dist/chunks/matrix-analytical-definition-5T-2euHZ.js +1 -0
  33. package/dist/chunks/matrix-member-presentation-vVAv-aqg.js +1 -0
  34. package/dist/chunks/matrix-operation-contract-CWvcEsQ0.js +1 -0
  35. package/dist/chunks/numeric-range-options-C8tr-Bls.js +1 -0
  36. package/dist/chunks/{palette-BzC-CGOc.js → palette-565cA0nh.js} +1 -1
  37. package/dist/chunks/pivot-result-contract-expectations-BNWhS8mv.js +1 -0
  38. package/dist/chunks/pivot-result-identity-B0eWVMXg.js +1 -0
  39. package/dist/chunks/{raw-temporal-value-DeyEhL0S.js → raw-temporal-value-BHQ-ldpW.js} +1 -1
  40. package/dist/chunks/report-preferences-dialog-B2ZGPS9t.js +1 -0
  41. package/dist/chunks/{report-runtime-context-BWzIHCKK.js → report-runtime-context-Cd1b5pku.js} +1 -1
  42. package/dist/chunks/resolve-dashboard-input-context-SlAAe4GF.js +8 -0
  43. package/dist/chunks/resolver-CjsW8Rz0.js +1 -0
  44. package/dist/chunks/saved-dashboard-context-Bc2SVDr-.js +1 -0
  45. package/dist/chunks/schema-O1Y3WTGF.js +4 -0
  46. package/dist/chunks/{selection-filter-compiler-CCoCD25M.js → selection-filter-compiler-kYsRugss.js} +1 -1
  47. package/dist/chunks/semaphor-ready-indicator-Bj-cjkz-.js +612 -0
  48. package/dist/chunks/set-CACXVM2A.js +1 -0
  49. package/dist/chunks/slider-CWze9OEM.js +4 -0
  50. package/dist/chunks/stored-dashboard-CcNdU-mG.js +1 -0
  51. package/dist/chunks/{table-export-sheet-rC5pKmXg.js → table-export-sheet-xaczzWZF.js} +1 -1
  52. package/dist/chunks/{token-types-Bj9iMy0w.js → token-types-1vzMWjI-.js} +1 -1
  53. package/dist/chunks/{validators-CqV3Yka1.js → validators-Dg2kyF4_.js} +1 -1
  54. package/dist/chunks/{variable-draft-DJrfUyhv.js → variable-draft-CRbSYdB6.js} +1 -1
  55. package/dist/dashboard/index.js +1 -1
  56. package/dist/dashboard-authoring/index.js +1 -1
  57. package/dist/format-utils/index.js +1 -1
  58. package/dist/index.js +1 -1
  59. package/dist/report-runtime-context/index.js +1 -1
  60. package/dist/style.css +1 -1
  61. package/dist/surfboard/index.js +1 -1
  62. package/dist/types/brand-studio/brand-studio-draft.d.ts +45 -13
  63. package/dist/types/brand-studio/brand-studio-editor.d.ts +13 -2
  64. package/dist/types/components/index.d.ts +1 -0
  65. package/dist/types/components/visual/data-table/hooks/use-data-table-logic.d.ts +17 -6
  66. package/dist/types/components/visual/data-table/types/data-table.d.ts +52 -42
  67. package/dist/types/index.js +1 -1
  68. package/dist/types/lib/appearance/aliases.d.ts +3 -0
  69. package/dist/types/lib/appearance/index.d.ts +1 -0
  70. package/dist/types/lib/appearance/table-density.d.ts +18 -0
  71. package/dist/types/lib/appearance/types.d.ts +39 -1
  72. package/dist/types/lib/dashboard-viewer/column-header-actions.d.ts +100 -0
  73. package/dist/types/lib/dashboard-viewer/table-view-edit.d.ts +0 -27
  74. package/dist/types/lib/dashboard-viewer/table-view.d.ts +26 -2
  75. package/dist/types/lib/dashboard-viewer/use-table-view.d.ts +2 -0
  76. package/dist/types/lib/hooks/use-add-new-frame.d.ts +7 -0
  77. package/dist/types/lib/hooks/use-dashboard-card.d.ts +4 -0
  78. package/dist/types/lib/interactions/get-click-context-from-chartjs.d.ts +8 -0
  79. package/dist/types/lib/stores/dashboard-store.d.ts +14 -2
  80. package/dist/types/lib/stores/explorer-actions.d.ts +0 -4
  81. package/dist/types/lib/types/common-types.d.ts +1 -2
  82. package/dist/types/lib/utils/card-config-utils.d.ts +13 -0
  83. package/dist/types/lib/utils/field-placement.d.ts +17 -0
  84. package/dist/types/shared/analytics-protocol/analytics-refusal.d.ts +21 -1
  85. package/dist/types/shared/analytics-protocol/field-provenance.d.ts +7 -4
  86. package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-folders.d.ts +48 -0
  87. package/dist/types/shared/dashboard-authoring/card-settings/card-display-write.d.ts +2 -8
  88. package/dist/types/shared/dashboard-authoring/card-settings/card-kinds.d.ts +1 -1
  89. package/dist/types/shared/dashboard-authoring/card-settings/column-display-values.d.ts +5 -0
  90. package/dist/types/shared/dashboard-authoring/card-settings/column-display.d.ts +52 -0
  91. package/dist/types/shared/dashboard-authoring/card-settings/index.d.ts +1 -0
  92. package/dist/types/shared/dashboard-authoring/card-settings/inputs.d.ts +9 -0
  93. package/dist/types/shared/dashboard-authoring/card-settings/resolved.d.ts +4 -0
  94. package/dist/types/shared/dashboard-authoring/card-settings/table-viewer-switches.d.ts +15 -0
  95. package/dist/types/shared/dashboard-authoring/card-settings/views.d.ts +5 -0
  96. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +6 -0
  97. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +132 -3
  98. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +3 -1
  99. package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +10 -10
  100. package/dist/types/shared/dashboard-authoring/conditional-formatting/store.d.ts +10 -1
  101. package/dist/types/shared/dashboard-authoring/field-aggregations.d.ts +9 -2
  102. package/dist/types/shared/dashboard-authoring/field-folders/field-folders.d.ts +8 -7
  103. package/dist/types/shared/dashboard-authoring/index.d.ts +1 -0
  104. package/dist/types/shared/dashboard-authoring/measure-calculations/index.d.ts +1 -1
  105. package/dist/types/shared/dashboard-authoring/measure-calculations/window-transforms.d.ts +2 -0
  106. package/dist/types/shared/dashboard-authoring/operations/card-operations.d.ts +2 -0
  107. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +7 -2
  108. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +6 -2
  109. package/dist/types/shared/dashboard-authoring/sheet-kinds.d.ts +36 -0
  110. package/dist/types/shared/dashboard-authoring/table-sheet-shape.d.ts +140 -0
  111. package/dist/types/shared/dashboard-viewer/table-column-move.d.ts +15 -0
  112. package/dist/types/shared/dashboard-viewer/table-settings.d.ts +8 -2
  113. package/dist/types/shared/format-utils/types/format-types.d.ts +1 -1
  114. package/dist/usage-events/index.js +1 -1
  115. package/package.json +2 -2
  116. package/dist/chunks/appearance-context-BqBZrijL.js +0 -1
  117. package/dist/chunks/appearance-runtime-provider-DmbCrOOG.js +0 -1
  118. package/dist/chunks/bookmark-state-69YYnRql.js +0 -1
  119. package/dist/chunks/brand-DCaZyRt6.js +0 -1
  120. package/dist/chunks/card-filter-builder-CTp6RAz1.js +0 -17
  121. package/dist/chunks/comparison-window-caption-C312mn3s.js +0 -1
  122. package/dist/chunks/dashboard-BX28ld6s.js +0 -1
  123. package/dist/chunks/dashboard-briefing-launcher-qo7GH4EO.js +0 -37
  124. package/dist/chunks/dashboard-controls-DhRjB7MA.js +0 -42
  125. package/dist/chunks/dashboard-json-9cHzhSjC.js +0 -1
  126. package/dist/chunks/dates-D-KP8G-z.js +0 -1
  127. package/dist/chunks/edit-DEAK0UZo.js +0 -1
  128. package/dist/chunks/edit-dashboard-visual-Duq_QkB_.js +0 -93
  129. package/dist/chunks/filter-line-CwQrqORc.js +0 -1
  130. package/dist/chunks/filter-reach-preview-gixPFlZj.js +0 -1
  131. package/dist/chunks/filter-value-text-B3tXakhd.js +0 -1
  132. package/dist/chunks/index-B-VF1ogs.js +0 -1
  133. package/dist/chunks/matrix-analytical-definition-CtFqWyCK.js +0 -1
  134. package/dist/chunks/matrix-member-presentation-Q0MCJ-YK.js +0 -1
  135. package/dist/chunks/matrix-operation-contract-D1RC1bfi.js +0 -1
  136. package/dist/chunks/metric-comparison-DEZYXROZ.js +0 -1
  137. package/dist/chunks/paintbrush-BjS3SbrH.js +0 -6
  138. package/dist/chunks/pickers-DuBrUht0.js +0 -1
  139. package/dist/chunks/pivot-result-contract-expectations-DTQAgr4n.js +0 -1
  140. package/dist/chunks/pivot-result-identity-DTNCB--h.js +0 -1
  141. package/dist/chunks/report-preferences-dialog-B_gUmCzG.js +0 -1
  142. package/dist/chunks/resolve-dashboard-input-context-B-TtRqxu.js +0 -8
  143. package/dist/chunks/resolver-AN9ChBfZ.js +0 -1
  144. package/dist/chunks/save-DdFUZcbi.js +0 -6
  145. package/dist/chunks/saved-dashboard-context-BAJ5tWiq.js +0 -1
  146. package/dist/chunks/schema-MC0cQSAb.js +0 -4
  147. package/dist/chunks/semaphor-ready-indicator-DzjorP3t.js +0 -999
  148. package/dist/chunks/set-DuJfGkbY.js +0 -1
  149. package/dist/chunks/shelf-drop-preview-context-BlLJ5RsT.js +0 -6
  150. package/dist/chunks/stored-dashboard-Ctcpkllg.js +0 -1
  151. package/dist/chunks/style-sheet-parts-BRGt9O05.js +0 -178
@@ -1,37 +0,0 @@
1
- import{jsx as t,jsxs as r,Fragment as $}from"react/jsx-runtime";import la,{useState as E,useEffect as Me,useCallback as ie,useMemo as Y,useLayoutEffect as $t,useRef as et,useContext as Va}from"react";import{ek as it,bp as Te,bq as Le,bs as Ve,el as Ba,b1 as $e,bE as ot,em as Pa,en as lt,eo as Ct,an as wt,ak as Ce,u as w,ep as _a,eq as Oa,bo as z,er as za,am as le,dJ as Ma,bW as Ra,es as Ua,et as $a,bJ as da,bK as be,ce as ca,bI as tt,w as ja,q as qa,eu as Wa,ch as St,ci as kt,cj as Dt,ck as At,cl as Ft,cm as Et,cn as It,co as ua,cG as Tt,ev as Qa,e1 as Ka,c6 as mt,c3 as je,c4 as qe,dl as ha,c5 as We,bS as re,cf as Ha,ca as at,ew as Ga,bP as Ya,ex as ma,bc as dt,br as Lt,bt as ct,cv as pa,bn as Xa,ey as Ja,bd as Za,o as en,cF as tn,ez as an,W as nn,P as fa,b7 as rn,X as sn,G as on,eA as ln,eB as dn,eC as cn,eD as ga,eE as un,eF as hn,eG as Ne,eH as mn,R as ba,eI as pn,eJ as fn,b0 as gn,eK as bn,eL as ge,eM as xn,aa as Vt,eN as vn,eO as pt,eP as yn,eQ as jt,eR as Nn,eS as Cn,eT as wn,eU as xa,eV as Sn,dD as kn,eW as Dn,e8 as Bt,dp as va,eX as An,eY as qt,eZ as Fn,e_ as En,e$ as In,f0 as Tn,dL as Ln,bi as Vn,bV as ya,f1 as Bn,f2 as Pn,f3 as Xe,f4 as _n,f5 as On,f6 as zn,A as Mn,aR as Rn,aS as Un,ax as $n,aw as jn,av as qn,au as Wn,ar as Qn,ap as Kn,f7 as Hn,f8 as Gn,f9 as Yn,fa as Xn,fb as Jn,aP as Zn}from"./semaphor-ready-indicator-DzjorP3t.js";import{c as Ae,B as L,X as Qe,s as Re,x as xe,L as de,q as Pt,j as _t,p as er,F as Ot,e as Ee,$ as Na,h as Ie,f as nt,i as Ca,g as Nt,y as we,z as Se,A as ke,D as De,E as fe,ae as tr}from"./style-sheet-parts-BRGt9O05.js";import{L as Ue}from"./layout-grid-BWtlgw0T.js";import{c as J}from"./pickers-DuBrUht0.js";import{T as ar}from"./validators-CqV3Yka1.js";import"./matrix-operation-contract-D1RC1bfi.js";import"./analytics-base-schemas-BREc5WGv.js";import"../value-format-preferences/index.js";import{s as Je}from"./normalize-dashboard-for-dirty-check-ILKfqgL3.js";import{cn as Wt,bU as Qt,g4 as Kt,jb as nr,jc as rt,iX as ft,jd as rr,B as Ke,je as sr,M as ir,jf as or,jg as lr,jh as dr,ds as cr,ji as ur,J as hr,iO as mr,jj as pr,jk as fr,e as zt,bh as gr,ae as br,d5 as xr,jl as vr,jm as yr,dg as Nr,jn as Cr,jo as Ht,jp as wr}from"./resolve-dashboard-input-context-B-TtRqxu.js";import{S as wa}from"./save-DdFUZcbi.js";import{V as Sr,L as kr,u as Sa,a as ka,F as Dr,C as Ar,b as Fr}from"./card-filter-builder-CTp6RAz1.js";import{createPortal as Er}from"react-dom";import{b7 as Gt,aD as Ir}from"./pivot-result-contract-expectations-DTQAgr4n.js";import{aD as Tr,as as Lr,H as Vr,ad as st,U as Br}from"./bookmark-state-69YYnRql.js";import{g as Pr,a as pe,d as _r,b as Or}from"./index-B-VF1ogs.js";import{a2 as zr,v as Mr,K as Rr}from"./filter-reach-preview-gixPFlZj.js";import"zod";import"./schema-MC0cQSAb.js";import"./index-DViPGDFj.js";import"./context-ALdccLHw.js";import{a as Yt,d as Xt,c as Ur,i as $r,b as jr,e as qr,v as Jt,f as Zt,g as Wr}from"./variable-draft-DJrfUyhv.js";/**
2
- * @license lucide-react v0.453.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Qr=Ae("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/**
7
- * @license lucide-react v0.453.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const ea=Ae("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/**
12
- * @license lucide-react v0.453.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const Kr=Ae("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/**
17
- * @license lucide-react v0.453.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const ta=Ae("MonitorSmartphone",[["path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8",key:"10dyio"}],["path",{d:"M10 19v-3.96 3.15",key:"1irgej"}],["path",{d:"M7 19h5",key:"qswx4l"}],["rect",{width:"6",height:"10",x:"16",y:"12",rx:"2",key:"1egngj"}]]);/**
22
- * @license lucide-react v0.453.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Hr=Ae("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/**
27
- * @license lucide-react v0.453.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const Gr=Ae("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);/**
32
- * @license lucide-react v0.453.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const Yr=Ae("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);function Xr(){return/* @__PURE__ */t("div",{className:"space-y-1.5 py-1",children:[...Array(5)].map((e,a)=>/* @__PURE__ */r("div",{className:"flex animate-pulse items-start gap-3 rounded-xl border border-transparent px-2.5 py-2.5",children:[/* @__PURE__ */t("div",{className:"mt-0.5 h-4 w-4 flex-shrink-0 rounded bg-muted/60"}),/* @__PURE__ */r("div",{className:"flex-1 space-y-1.5",children:[/* @__PURE__ */t("div",{className:"h-4 w-3/5 rounded bg-muted/60"}),/* @__PURE__ */t("div",{className:"h-3 w-4/5 rounded bg-muted/40"})]})]},a))});}function Jr({open:e,onOpenChange:a,onSubmit:s,isCreating:n}){const i=it("interactive"),[o,l]=E(""),[h,c]=E("");Me(()=>{e||(l(""),c(""));},[e]);const d=()=>{o.trim()&&s({title:o,description:h});},u=p=>{a(p);};return/* @__PURE__ */t(Te,{open:e,onOpenChange:u,children:/* @__PURE__ */r(Le,{showCloseButton:!1,className:"flex max-w-lg grid-cols-none flex-col gap-0 overflow-hidden rounded-card border-border/60 p-0 shadow-lg sm:rounded-card",style:i.dialogStyle,children:[/* @__PURE__ */r("div",{className:"flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3",children:[/* @__PURE__ */r("div",{className:"flex min-w-0 items-center gap-2",children:[/* @__PURE__ */t(Ue,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),/* @__PURE__ */r("div",{className:"flex min-w-0 items-baseline gap-2",children:[/* @__PURE__ */t(Ve,{className:"truncate text-[13px] font-medium leading-none tracking-normal",children:"New library visual"}),/* @__PURE__ */t("span",{className:"shrink-0 text-[10px] font-medium uppercase leading-none tracking-[0.08em] text-muted-foreground",children:"Visual"})]})]}),/* @__PURE__ */t(L,{size:"xs",variant:"ghost",className:"w-7 px-0 text-muted-foreground hover:text-foreground",onClick:()=>u(!1),"aria-label":"Close",disabled:n,children:/* @__PURE__ */t(Qe,{className:"h-3.5 w-3.5"})})]}),/* @__PURE__ */r("div",{className:"space-y-3 px-4 py-3",children:[/* @__PURE__ */t("p",{className:"text-[12px] text-muted-foreground",children:"Create a saved visual that can be reused across dashboards."}),/* @__PURE__ */r("div",{className:"space-y-1.5",children:[/* @__PURE__ */t(Re,{htmlFor:"visual-title",className:"text-[12px]",children:"Name"}),/* @__PURE__ */t(xe,{id:"visual-title",size:"sm",placeholder:"Untitled visual",value:o,onChange:p=>l(p.target.value),disabled:n,onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),d());}})]}),/* @__PURE__ */r("div",{className:"space-y-1.5",children:[/* @__PURE__ */t(Re,{htmlFor:"visual-description",className:"text-[12px]",children:"Description"}),/* @__PURE__ */t(xe,{id:"visual-description",size:"sm",placeholder:"Optional",value:h,onChange:p=>c(p.target.value),disabled:n})]})]}),/* @__PURE__ */r("div",{className:"flex shrink-0 justify-end gap-2 border-t border-border/60 px-4 py-2.5",children:[/* @__PURE__ */t(L,{size:"xs",variant:"outline",onClick:()=>u(!1),disabled:n,children:"Cancel"}),/* @__PURE__ */t(L,{size:"xs",onClick:d,disabled:!o.trim()||n,children:n?/* @__PURE__ */r($,{children:[/* @__PURE__ */t(de,{className:"h-3.5 w-3.5 animate-spin"}),"Creating..."]}):"Create library visual"})]})]})});}function Zr(e){const[a,s]=E(null),[n,i]=E(null),o=Ba();return Me(()=>{if(!e||e.trim()===""){s(null),i(null);return;}if(!o)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e);}catch{throw new Error(`Invalid URL: ${e}`);}const c=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(c,{method:"HEAD"})).ok)throw new Error(`Module not found at ${c}`);}catch{}const d=await import(c);if(typeof d.useChartStore!="function")throw new Error("useChartStore is not a function");s(()=>d.useChartStore),i(null);}catch(h){const c=h instanceof Error?h.message:"Unknown error";console.error("Failed to load remote chart store:",c),i(c),s(null);}})();},[e,o]),a;}function es(e,a){if(e.length===0)return"";const s=e.find(n=>{var i,o;return((i=n.customCardPreferences)==null?void 0:i.visualType)==="multiple"||!!((o=n.customCardPreferences)!=null&&o.dataInputCardIds);});if(s)return s.id;if(a){const n=e.find(i=>i.id===a);if(n){const i=n.tabTitle;if(i=="All__Header")return e[0].id;if(i&&i.endsWith("__Header")){const l=i.split("__")[0],h=e.find(c=>c.tabTitle===l);return h?h.id:e[0].id;}return a;}}return e[0].id;}async function aa(e,a,s,n,i="Opening library visual..."){if(!a||!s)throw new Error("Missing auth token or visual ID");const o=["resource-by-id","visual",s],l=n.getQueryData(o);if(l)return console.log("Using cached visual data for:",s),{data:l,fromCache:!0};console.log("Fetching visual data from network for:",s);const h=z.loading(i,{position:"top-center"});try{const c=await fetch(`${e}/management/v1/visuals/${s}`,{headers:{Authorization:`Bearer ${a}`}});if(!c.ok)throw new Error("Failed to load visual");const d=await c.json();return n.setQueryData(o,d),z.dismiss(h),{data:d,fromCache:!1};}catch(c){throw z.dismiss(h),c;}}function Da(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format");}function ts(e,a){var o,l;const s=(e==null?void 0:e.frameObject)??((o=e==null?void 0:e.visual)==null?void 0:o.frameObject);if(!s)return!1;const n=Da(s);if(!(n!=null&&n.cards)||n.cards.length===0)return!1;const i=(l=n.cards)==null?void 0:l.find(h=>h.id===n.activeCardId);return i?(za({...a,frame:n,card:i,visualId:(e==null?void 0:e.id)||n.visualId}),!0):!1;}function as(){const e=le(n=>{var i;return((i=n.card.customCardPreferences)==null?void 0:i.url)||"";}),a=Zr(e);return{getUpdatedFrame:ie(()=>{var C;Ma();const{frame:n,card:i,isDevMode:o,selectedSchemaName:l,selectedDatabaseName:h,selectedTableName:c,selectedConnectionId:d}=le.getState(),u=i.sql,p=(C=a==null?void 0:a.getState())==null?void 0:C.settings,m=Wt(i,{isDevMode:o,cardSql:u,selectedSchemaName:l,selectedDatabaseName:h,selectedTableName:c,selectedConnectionId:d,remoteChartSettings:p,stripConfig:Qt}),g=n.cards.map(S=>{if(S.id===i.id)return Kt({before:i,after:m});const V=nr(S)?Wt(S,{isDevMode:!0,cardSql:S.sql,stripConfig:Qt}):S;return Kt({before:S,after:V});}),f=g.flatMap(S=>S.dropped);f.length&&z.info("Some conditional formatting rules were removed",{description:`Their column isn't in the saved visual: ${f.map(S=>S.name||"an unnamed rule").join(", ")}.`});const y=g.map(S=>S.card);return{...n,cards:y,activeCardId:es(y,n.activeCardId)};},[a])};}function Be(){const{authToken:e,tokenProps:a}=$e(),s=ot(),n=Pa(),i=lt(),{selectVisual:o}=Ct(),{setFrame:l,loadCard:h,setIsDevMode:c,initializeModeDrafts:d,setActiveTabCardId:u,updateDataSource:p,setQueryResultColumns:m,setSelectedConnectionId:g,setSelectedDatabaseName:f,setSelectedSchemaName:y,setSelectedTableName:C,setSelectedDatamodelId:S,setInlineFilterValuesMap:V,setApplyFilters:P,clearEditorContext:D}=wt(),{setIsDashboardEditing:B,setIsVisualEditing:k,clearSelectedFrameId:v}=Ce(),b=w(O=>O.selectedSheetId),_=w(O=>O.selectedFrameId),A=w(O=>O.dashboard),G=w(O=>O.inlineFilterValuesMap),T=_a((i==null?void 0:i.id)||"",{enabled:!!(i!=null&&i.id)&&!!(e!=null&&e.accessToken)}),R=ie(async O=>{try{o(O),v(),D();const{data:te,fromCache:Z}=await aa(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",O.id,s,"Opening library visual...");if(!ts(te,{setFrame:l,loadCard:h,setIsDevMode:c,initializeModeDrafts:d,setActiveTabCardId:u,updateDataSource:p,setQueryResultColumns:m,setSelectedConnectionId:g,setSelectedDatabaseName:f,setSelectedSchemaName:y,setSelectedTableName:C,setSelectedDatamodelId:S,setInlineFilterValuesMap:V,setApplyFilters:P,setIsDashboardEditing:B,setIsVisualEditing:k,dashboard:A,selectedSheetId:b,selectedFrameId:_,inlineFilterValuesMap:G}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:Z};}catch(te){return console.error("Error editing visual:",te),{success:!1,error:"Failed to load visual for editing"};}},[e==null?void 0:e.accessToken,a.apiServiceUrl,s,o,l,h,B,k,c,d,u,p,m,g,f,y,C,S,V,P,D,v,A,b,_,G]),X=ie(async O=>{var Z;const te=H=>(z.error(H),{success:!1,error:H});try{if(o(O),!b)return te("No sheet selected. Please select a sheet first.");const{data:H,fromCache:I}=await aa(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",O.id,s,"Adding visual to dashboard..."),ae=(H==null?void 0:H.frameObject)??((Z=H==null?void 0:H.visual)==null?void 0:Z.frameObject);if(!ae)return te("Visual has no frame data");const q=Da(ae);if(!(q!=null&&q.cards)||q.cards.length===0)return te("Visual frame is malformed");const M={...Oa(q),visualId:O.id};return await n(b,M),B(!0),{success:!0,fromCache:I};}catch(H){return console.error("Error adding visual:",H),te(H instanceof Error?H.message:"Failed to add visual to dashboard");}},[e==null?void 0:e.accessToken,a.apiServiceUrl,s,o,b,B,n]);return{visual:T.data,isLoading:T.isLoading,isError:T.isError,error:T.error,handleEditLibraryVisual:R,handleAddLibraryVisual:X,getUpdatedFrame:as().getUpdatedFrame,refetch:T.refetch};}function Aa(e){return e?new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"Unknown";}function Fa(e,a){var n;const s=(n=e.ownership.createdBy)==null?void 0:n.type;return s==="tenant"||s==="organization"&&a;}function Mt(e,a){var s,n;return Fa(e,a)?((s=e.ownership.createdBy)==null?void 0:s.name)||((n=e.createdByTenantUserRel)==null?void 0:n.name)||e.lastModifiedBy||"Unknown":"Organization";}function ns(e,a){return Mt(e,a).split(/\s+/).filter(Boolean).slice(0,2).map(n=>n.charAt(0).toUpperCase()).join("")||"?";}function rs(e){const a=(e||"").toLowerCase();return a.includes("table")?Pt:a.includes("pie")||a.includes("donut")?Qa:a.includes("line")?Ka:a.includes("bar")?er:Ue;}function ss({visual:e}){const a=e.ownership.status==="public"?"Public":e.ownership.status==="shared"||e.ownership.sharedCount>0?"Shared":"Private";return/* @__PURE__ */t("span",{className:"inline-flex items-center rounded-[4px] border border-border/60 px-1.5 py-px text-[11px] text-muted-foreground",children:a});}function ji({open:e,onOpenChange:a}){const s=it("interactive"),[n,i]=E(""),[o,l]=E(/* @__PURE__ */new Set()),[h,c]=E(!1),[d,u]=E(null),[p,m]=E(null),[g,f]=E(!1),[y,C]=E(null),[S,V]=E(null),P=()=>{l(/* @__PURE__ */new Set()),u(null),m(null),f(!1),C(null);},D=()=>{a(!1),P();},{selectVisual:B}=Ct(),{handleAddLibraryVisual:k,handleEditLibraryVisual:v}=Be(),{isConsoleMode:b}=Ra(),{resources:_,isLoading:A,isError:G,createResource:T,updateResource:R,deleteResourceAsync:X,duplicateResource:O,isCreating:te,isDeleting:Z}=Ua(void 0,N=>{c(!1),N&&(B(N),v(N),D());}),{startUpdating:H,stopUpdating:I,isUpdating:ae}=$a(),q=_,M=Y(()=>{const N=n.trim().toLowerCase();return N?q.filter(W=>{var ee,me,ye;return((ee=W.title)==null?void 0:ee.toLowerCase().includes(N))||((me=W.description)==null?void 0:me.toLowerCase().includes(N))||((ye=W.kind)==null?void 0:ye.toLowerCase().includes(N));}):q;},[n,q]),ne=Y(()=>q.filter(N=>o.has(N.id)),[o,q]),ue=ne.filter(N=>N.permissions.canDelete),he=ne.filter(N=>N.permissions.canShare),ve=M.length>0&&M.every(N=>o.has(N.id)),x=M.some(N=>o.has(N.id)),U=N=>{const W=new Set(o);N(W),l(W);},j=N=>{U(W=>{W.has(N)?W.delete(N):W.add(N);});},K=()=>{l(N=>{const W=new Set(N);return ve?M.forEach(ee=>W.delete(ee.id)):M.forEach(ee=>W.add(ee.id)),W;});},oe=async N=>{(await k(N)).success&&D();},Pe=async()=>{const N=ne;if(N.length===0)return;let W=!1;for(const ee of N)if(!(await k(ee)).success){W=!0;break;}W||D();},ut=N=>{v(N),D();},Fe=N=>{V(N),O(N,{onSettled:()=>V(null)});},He=()=>{if(ue.length===0){z.error("Select a visual you can delete");return;}C(null),f(!0);},ht=async()=>{const N=y?[y]:ue;try{for(const W of N)await X(W.id);l(W=>{const ee=new Set(W);return N.forEach(me=>ee.delete(me.id)),ee;}),f(!1),C(null);}catch{}},_e=()=>{if(ne.length!==1){z.error("Select one visual to share");return;}const[N]=ne;if(!N.permissions.canShare){z.error("You do not have permission to share this visual");return;}u(N);},Oe=({title:N,description:W})=>{if(!p)return;const ee={};if(N!==p.title&&(ee.title=N),(p.description||"")!==W&&(ee.description=W),Object.keys(ee).length===0){m(null);return;}const me=Object.keys(ee),ye=me.length===1?me[0]:void 0;H(p.id,ye),R({resourceId:p.id,data:ee},{onSuccess:()=>{I(p.id,ye),m(null);},onError:()=>{I(p.id,ye);}});},ce=N=>{a(N),N||P();},ze=y?1:ue.length;return/* @__PURE__ */r($,{children:[/* @__PURE__ */t(Te,{open:e,onOpenChange:ce,children:/* @__PURE__ */r(Le,{showCloseButton:!1,className:"flex max-h-[80vh] w-[min(72rem,calc(100vw-2rem))] max-w-none grid-cols-none flex-col gap-0 overflow-hidden rounded-card border-border/60 p-0 shadow-lg sm:rounded-card",style:s.dialogStyle,children:[/* @__PURE__ */r("div",{className:"flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3",children:[/* @__PURE__ */r("div",{className:"flex min-w-0 items-center gap-2",children:[/* @__PURE__ */t(Pt,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),/* @__PURE__ */r("div",{className:"flex min-w-0 items-baseline gap-2",children:[/* @__PURE__ */t(Ve,{className:"truncate text-[13px] font-medium leading-none tracking-normal",children:"Visuals library"}),/* @__PURE__ */t("span",{className:"shrink-0 text-[10px] font-medium uppercase leading-none tracking-[0.08em] text-muted-foreground",children:"Add to dashboard"})]})]}),/* @__PURE__ */t(L,{size:"xs",variant:"ghost",className:"w-7 px-0 text-muted-foreground hover:text-foreground",onClick:()=>ce(!1),"aria-label":"Close visuals library",children:"×"})]}),/* @__PURE__ */r("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/60 px-3 py-2",children:[/* @__PURE__ */r("div",{className:"relative min-w-[12rem] flex-1 md:max-w-md",children:[/* @__PURE__ */t(da,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),/* @__PURE__ */t("input",{autoFocus:!0,value:n,onChange:N=>i(N.target.value),placeholder:"Search visuals...",className:"h-7 w-full rounded-control border border-input bg-background pl-7 pr-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-ring focus:outline-none","aria-label":"Search visuals"})]}),/* @__PURE__ */r(L,{size:"xs",variant:"outline",className:"ml-auto",onClick:()=>c(!0),children:[/* @__PURE__ */t(be,{className:"h-3.5 w-3.5"}),"New library visual"]})]}),/* @__PURE__ */t("div",{className:"min-h-0 flex-1 overflow-auto",children:A?/* @__PURE__ */t("div",{className:"p-3",children:/* @__PURE__ */t(Xr,{})}):G?/* @__PURE__ */t("div",{className:"flex flex-col items-center gap-2 px-4 py-12 text-center",children:/* @__PURE__ */t("p",{className:"text-[13px] text-destructive",children:"Failed to load visuals"})}):M.length===0?/* @__PURE__ */r("div",{className:"flex flex-col items-center gap-2 px-4 py-12 text-center",children:[/* @__PURE__ */t(Ue,{className:"h-5 w-5 text-muted-foreground/60"}),/* @__PURE__ */t("p",{className:"text-[13px] font-medium",children:n?"No visuals found":"No visuals yet"}),/* @__PURE__ */t("p",{className:"text-[12px] text-muted-foreground",children:n?"Try a different search.":"Create a saved visual to add it here."})]}):/* @__PURE__ */t(is,{visuals:M,selectedIds:o,allFilteredSelected:ve,someFilteredSelected:x,onSelectAll:K,onToggleSelection:j,onAddVisual:oe,onOpenVisual:ut,onEditDetails:m,onShareVisual:u,onDeleteVisual:N=>{C(N),f(!0);},onDuplicateVisual:Fe,duplicatingId:S,isDeleting:Z,isConsoleMode:b})}),/* @__PURE__ */r("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border/60 px-3 py-2",children:[/* @__PURE__ */t("div",{className:"flex min-w-0 items-center gap-1.5",children:o.size>0&&/* @__PURE__ */r($,{children:[/* @__PURE__ */r("span",{className:"text-[12px] text-muted-foreground",children:[/* @__PURE__ */t("span",{className:"font-medium tabular-nums text-foreground",children:o.size})," ","selected"]}),/* @__PURE__ */t(L,{size:"xs",variant:"ghost",onClick:()=>l(/* @__PURE__ */new Set()),children:"Clear"}),/* @__PURE__ */r(L,{size:"xs",variant:"outline",onClick:_e,disabled:ne.length!==1||he.length!==1,children:[/* @__PURE__ */t(ca,{className:"h-3.5 w-3.5"}),"Share"]}),/* @__PURE__ */r(L,{size:"xs",variant:"outline",className:"text-destructive hover:text-destructive",onClick:He,disabled:ue.length===0,children:[/* @__PURE__ */t(tt,{className:"h-3.5 w-3.5"}),"Delete ",ue.length||o.size]})]})}),/* @__PURE__ */r("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */t(L,{size:"xs",variant:"outline",onClick:()=>ce(!1),children:"Close"}),/* @__PURE__ */r(L,{size:"xs",onClick:Pe,disabled:o.size===0,children:[/* @__PURE__ */t(_t,{className:"h-3.5 w-3.5"}),o.size===0?"Add to dashboard":`Add ${o.size} visual${o.size===1?"":"s"}`]})]})]})]})}),/* @__PURE__ */t(Jr,{open:h,onOpenChange:c,onSubmit:T,isCreating:te}),d&&/* @__PURE__ */t(ja,{resource:d,resourceType:qa.VISUAL,onClose:()=>u(null)}),p&&/* @__PURE__ */t(Wa,{open:!!p,resourceLabel:"Visual",initialTitle:p.title||"",initialDescription:p.description||"",onClose:()=>m(null),onSave:Oe,isSaving:ae(p.id)}),/* @__PURE__ */t(St,{open:g,onOpenChange:N=>{!N&&Z||(f(N),N||C(null));},children:/* @__PURE__ */r(kt,{children:[/* @__PURE__ */r(Dt,{children:[/* @__PURE__ */r(At,{children:["Delete ",ze," visual",ze===1?"":"s","?"]}),/* @__PURE__ */t(Ft,{children:"This cannot be undone. Visuals already added to dashboards may need to be removed from those dashboards separately."})]}),/* @__PURE__ */r(Et,{children:[/* @__PURE__ */t(It,{disabled:Z,children:"Cancel"}),/* @__PURE__ */r(ua,{onClick:N=>{N.preventDefault(),ht();},disabled:Z||ze===0,children:[Z?/* @__PURE__ */t(de,{className:"h-3.5 w-3.5 animate-spin"}):/* @__PURE__ */t(tt,{className:"h-3.5 w-3.5"}),Z?"Deleting...":"Delete"]})]})]})})]});}function is({visuals:e,selectedIds:a,allFilteredSelected:s,someFilteredSelected:n,onSelectAll:i,onToggleSelection:o,onAddVisual:l,onOpenVisual:h,onEditDetails:c,onShareVisual:d,onDeleteVisual:u,onDuplicateVisual:p,duplicatingId:m,isDeleting:g,isConsoleMode:f}){return/* @__PURE__ */r("div",{className:"min-w-[48rem]",children:[/* @__PURE__ */r("div",{className:"grid h-9 grid-cols-[2.5rem_minmax(14rem,1.8fr)_minmax(10rem,1fr)_8rem_7rem_5rem_5.5rem] items-center border-b border-border/60 px-3 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:[/* @__PURE__ */t(Tt,{checked:s?!0:n?"indeterminate":!1,onCheckedChange:i,"aria-label":"Select all visuals"}),/* @__PURE__ */t("span",{children:"Name"}),/* @__PURE__ */t("span",{children:"Created by"}),/* @__PURE__ */t("span",{children:"Updated"}),/* @__PURE__ */t("span",{children:"Visibility"}),/* @__PURE__ */t("span",{className:"text-right",children:"Shared"}),/* @__PURE__ */t("span",{className:"text-right",children:"Actions"})]}),e.map(y=>/* @__PURE__ */t(os,{visual:y,selected:a.has(y.id),onToggleSelection:o,onAddVisual:l,onOpenVisual:h,onEditDetails:c,onShareVisual:d,onDeleteVisual:u,onDuplicateVisual:p,duplicatingId:m,isDeleting:g,isConsoleMode:f},y.id))]});}function os({visual:e,selected:a,onToggleSelection:s,onAddVisual:n,onOpenVisual:i,onEditDetails:o,onShareVisual:l,onDeleteVisual:h,onDuplicateVisual:c,duplicatingId:d,isDeleting:u,isConsoleMode:p}){var f;const m=rs(e.kind),g=()=>{n(e);};return/* @__PURE__ */r("div",{className:J("group grid min-h-12 grid-cols-[2.5rem_minmax(14rem,1.8fr)_minmax(10rem,1fr)_8rem_7rem_5rem_5.5rem] items-center border-b border-border/50 px-3 text-[13px] hover:bg-muted/50",a&&"bg-muted/70"),children:[/* @__PURE__ */t("div",{children:/* @__PURE__ */t(Tt,{checked:a,onCheckedChange:()=>s(e.id),"aria-label":`Select ${e.title||"visual"}`})}),/* @__PURE__ */r("button",{type:"button",className:"flex min-w-0 items-center gap-2 rounded-[4px] text-left outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:g,"aria-label":`Add ${e.title||"visual"} to dashboard`,children:[/* @__PURE__ */t(m,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),/* @__PURE__ */r("div",{className:"min-w-0",children:[/* @__PURE__ */t("div",{className:"truncate font-medium text-foreground",title:e.title||"Untitled Visual",children:e.title||"Untitled Visual"}),((f=e.description)==null?void 0:f.trim())&&/* @__PURE__ */t("div",{className:"truncate text-[11px] text-muted-foreground",title:e.description,children:e.description})]})]}),/* @__PURE__ */r("div",{className:"flex min-w-0 items-center gap-2",children:[/* @__PURE__ */t("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-[9px] font-medium text-muted-foreground",children:ns(e,p)}),/* @__PURE__ */t("span",{className:"truncate text-muted-foreground",children:Mt(e,p)})]}),/* @__PURE__ */t("span",{className:"text-muted-foreground",children:Aa(e.updatedAt)}),/* @__PURE__ */t(ss,{visual:e}),/* @__PURE__ */t("span",{className:"text-right tabular-nums text-muted-foreground",children:e.ownership.sharedCount>0?e.ownership.sharedCount:"—"}),/* @__PURE__ */t(ls,{visual:e,onOpenVisual:i,onEditDetails:o,onShareVisual:l,onDeleteVisual:h,onDuplicateVisual:c,duplicatingId:d,isDeleting:u,isConsoleMode:p})]});}function ls({visual:e,onOpenVisual:a,onEditDetails:s,onShareVisual:n,onDeleteVisual:i,onDuplicateVisual:o,duplicatingId:l,isDeleting:h,isConsoleMode:c}){return/* @__PURE__ */r("div",{className:"flex items-center justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",onClick:d=>d.stopPropagation(),children:[/* @__PURE__ */t(L,{size:"xs",variant:"ghost",className:"w-7 px-0",onClick:()=>a(e),"aria-label":"Edit visual",children:/* @__PURE__ */t(mt,{className:"h-3.5 w-3.5"})}),/* @__PURE__ */r(je,{modal:!1,children:[/* @__PURE__ */t(qe,{asChild:!0,children:/* @__PURE__ */t(L,{size:"xs",variant:"ghost",className:"w-7 px-0","aria-label":"More actions",children:/* @__PURE__ */t(ha,{className:"h-3.5 w-3.5"})})}),/* @__PURE__ */r(We,{align:"end",className:"z-[60] w-44 rounded-[6px] border-border/60 p-1 shadow-sm",children:[/* @__PURE__ */r(re,{onClick:()=>a(e),children:[/* @__PURE__ */t(mt,{className:"h-3.5 w-3.5"}),"Edit visual"]}),/* @__PURE__ */r(re,{onClick:()=>o(e.id),disabled:l===e.id,children:[l===e.id?/* @__PURE__ */t(de,{className:"h-3.5 w-3.5 animate-spin"}):/* @__PURE__ */t(Ha,{className:"h-3.5 w-3.5"}),l===e.id?"Duplicating...":"Duplicate"]}),e.permissions.canEdit&&/* @__PURE__ */r(re,{onClick:()=>s(e),children:[/* @__PURE__ */t(mt,{className:"h-3.5 w-3.5"}),"Edit details"]}),e.permissions.canShare&&/* @__PURE__ */r(re,{onClick:()=>n(e),children:[/* @__PURE__ */t(ca,{className:"h-3.5 w-3.5"}),"Share"]}),e.permissions.canDelete&&/* @__PURE__ */r($,{children:[/* @__PURE__ */t(at,{}),/* @__PURE__ */r(re,{className:"text-destructive focus:bg-destructive/10 focus:text-destructive",onClick:()=>i(e),disabled:h,children:[/* @__PURE__ */t(tt,{className:"h-3.5 w-3.5"}),h?"Deleting...":"Delete"]})]}),/* @__PURE__ */t(at,{}),/* @__PURE__ */r("div",{className:"space-y-1 px-2 py-1.5 text-[11px] text-muted-foreground",children:[Fa(e,c)&&/* @__PURE__ */r("div",{className:"flex items-center gap-1.5",children:[/* @__PURE__ */t(Ga,{className:"h-3 w-3"}),/* @__PURE__ */t("span",{className:"truncate",children:Mt(e,c)})]}),/* @__PURE__ */r("div",{className:"flex items-center gap-1.5",children:[/* @__PURE__ */t(Ya,{className:"h-3 w-3"}),/* @__PURE__ */t("span",{children:Aa(e.updatedAt)})]})]})]})]})]});}function qi(e,a,s=!1){const n=w(u=>u.dashboard),i=w(u=>u.isDashboardEditing),o=w(u=>u.isVisualEditing),l=w(u=>u.onDashboardLifecycleEvent),h=ie(()=>{const{dashboard:u,isVisualEditing:p}=w.getState();return a||!e||!u||u.id!==e.id?!1:p?!0:Je(u)!==Je(e);},[e,a]);$t(()=>(w.setState({checkUnsavedDashboardChanges:h}),()=>{w.getState().checkUnsavedDashboardChanges===h&&w.setState({checkUnsavedDashboardChanges:null});}),[h]);const c=Y(()=>!s||a||!n||i&&(!e||n.id!==e.id)?null:{dashboardId:n.id,dirty:i&&e?o||Je(n)!==Je(e):!1},[i,o,a,s,e,n]),d=et(null);return $t(()=>{if(!l||!c){d.current=null;return;}const u=d.current;(u==null?void 0:u.callback)===l&&u.dashboardId===c.dashboardId&&u.dirty===c.dirty||(d.current={callback:l,dashboardId:c.dashboardId,dirty:c.dirty},l({type:"dashboard:dirty-state",dashboardId:c.dashboardId,payload:{dirty:c.dirty}}));},[c,l]),h;}function Rt(e){var a;for(const s of e.cards)if(s.type==="matrixTable"&&!ar.safeParse((a=s.config)==null?void 0:a.matrix).success)return z.error("Matrix requires at least one row field, one metric, and valid settings."),!1;return!0;}function gt({className:e,variant:a="outline"}){const s=le(o=>o.onSave),{getUpdatedFrame:n}=Be();function i(){const o=n();Rt(o)&&(s==null||s(o));}return/* @__PURE__ */r(L,{onClick:i,className:e,size:"xs",variant:a,children:[/* @__PURE__ */t(_t,{className:"h-3.5 w-3.5"}),"Done"]});}function ds({className:e,variant:a="default"}){const s=ot(),[n,i]=E(!1),{setIsVisualEditing:o}=Ce(),{getUpdatedFrame:l}=Be(),h=lt(),c=le(p=>p.frame),d=ma();return/* @__PURE__ */t(L,{onClick:()=>{const p=l();if(!Rt(p))return;const m=(c==null?void 0:c.visualId)||(h==null?void 0:h.id);if(!m){z.error("No visual to save");return;}i(!0),d.mutate({visualId:m,data:{frameObject:p}},{onSuccess:()=>{i(!1),z.success("Visual updated successfully"),s.invalidateQueries({queryKey:["resource-by-id","visual",m],exact:!0});},onError:()=>{i(!1),z.error("Failed to update visual");}});},className:e,size:"xs",variant:a,children:n?/* @__PURE__ */r($,{children:[/* @__PURE__ */t(de,{className:"h-3.5 w-3.5 animate-spin"}),"Saving"]}):/* @__PURE__ */r($,{children:[/* @__PURE__ */t(wa,{className:"h-3.5 w-3.5"}),"Save to Library"]})});}function cs({className:e}){const a=ot(),[s,n]=E(!1),i=lt(),o=le(f=>f.frame),l=w(f=>f.selectedSheetId),h=w(f=>f.dashboard),{updateFrame:c,setIsVisualEditing:d}=Ce(),{getUpdatedFrame:u}=Be(),p=ma(),m=dt();return/* @__PURE__ */t(L,{onClick:async()=>{if(!l){z.error("No sheet selected");return;}const f=(o==null?void 0:o.visualId)||(i==null?void 0:i.id);if(!f){z.error("No visual to update");return;}n(!0);try{const y=u();if(!Rt(y)){n(!1);return;}const C={...y,visualId:f},S=rt(h,C.id),V=await m(C,{previousFrame:S});await p.mutateAsync({visualId:f,data:{frameObject:y}}),c(l,C,{semanticExecutionPayload:V}),a.invalidateQueries({queryKey:["visuals"]}),a.invalidateQueries({queryKey:["visual",f]}),z.success("Saved to library and applied locally"),setTimeout(()=>{d(!1);},300);}catch(y){console.error("Failed to save and apply:",y),z.error(y instanceof Error?y.message:"Failed to save and apply changes");}finally{n(!1);}},className:e,size:"xs",variant:"default",disabled:s,children:s?/* @__PURE__ */r($,{children:[/* @__PURE__ */t(de,{className:"h-3.5 w-3.5 animate-spin"}),"Saving..."]}):/* @__PURE__ */r($,{children:[/* @__PURE__ */t(wa,{className:"h-3.5 w-3.5"}),"Save & Apply"]})});}function bt({className:e}){const{setTempQueryData:a,setSqlGen:s}=wt(),n=ot(),i=le(h=>h.tempQueryData),o=le(h=>h.onClose);function l(){if(i){const{queryKey:h,queryData:c}=i;h&&c&&n.setQueryData(h,c);}s({}),o==null||o();}return/* @__PURE__ */r(L,{onClick:l,className:e,size:"xs",variant:"outline",children:[/* @__PURE__ */t(Qe,{className:"h-3.5 w-3.5"}),"Close"]});}function us({open:e,onOpenChange:a,isLibraryVisual:s,currentVisualName:n,isSaving:i=!1,destinationMode:o="both",onConfirm:l}){const[h,c]=E(s&&n?`Copy of ${n}`:n||""),[d,u]=E("");la.useEffect(()=>{e&&(c(s&&n?`Copy of ${n}`:n||""),u(""));},[e,s,n]);const p=!!h.trim(),m=o==="local"?{saveToLibrary:!1,saveToCurrentDashboard:!0,badgeType:"local",description:"Creates a local copy on the current dashboard.",actionLabel:"Add to Dashboard (Local)"}:o==="library"?{saveToLibrary:!0,saveToCurrentDashboard:!1,badgeType:"library",description:"Creates a reusable visual in Visual Library.",actionLabel:"Save as Library Visual"}:{saveToLibrary:!0,saveToCurrentDashboard:!0,badgeType:"linked",description:"Creates a new library visual and adds a linked copy to this dashboard.",actionLabel:"Save Copy as Linked Visual"},g=()=>{!p||i||l({name:h.trim(),description:d.trim()||void 0,saveToLibrary:m.saveToLibrary,saveToCurrentDashboard:m.saveToCurrentDashboard});};return/* @__PURE__ */t(Te,{open:e,onOpenChange:a,children:/* @__PURE__ */r(Le,{className:"sm:max-w-[500px]",children:[/* @__PURE__ */r(Lt,{children:[/* @__PURE__ */r(Ve,{className:"flex items-center gap-2",children:[/* @__PURE__ */t("span",{children:"Save Visual As"}),m.badgeType!=="local"&&/* @__PURE__ */t(Sr,{type:m.badgeType,showLabel:!0,className:"px-2 py-0.5"})]}),/* @__PURE__ */t(ct,{children:m.description})]}),/* @__PURE__ */r("div",{className:"grid gap-4 py-4",children:[/* @__PURE__ */r("div",{className:"grid gap-2",children:[/* @__PURE__ */t(Re,{htmlFor:"name",children:"Name"}),/* @__PURE__ */t(xe,{id:"name",value:h,onChange:f=>c(f.target.value),placeholder:"Enter visual name",disabled:i})]}),/* @__PURE__ */r("div",{className:"grid gap-2",children:[/* @__PURE__ */t(Re,{htmlFor:"description",children:"Description (optional)"}),/* @__PURE__ */t(pa,{id:"description",value:d,onChange:f=>u(f.target.value),placeholder:"Enter visual description",rows:3,disabled:i})]})]}),/* @__PURE__ */r(Xa,{children:[/* @__PURE__ */t(L,{variant:"outline",onClick:()=>a(!1),disabled:i,children:"Cancel"}),/* @__PURE__ */r(L,{onClick:g,disabled:!p||i,children:[i&&/* @__PURE__ */t(de,{className:"mr-2 h-4 w-4 animate-spin"}),m.actionLabel]})]})]})});}function hs(){const[e,a]=E(!1),[s,n]=E(!1),[i,o]=E(null),[l,h]=E(null),c=le(v=>v.frame),d=le(v=>v.card),u=lt(),p=w(v=>v.selectedSheetId),m=w(v=>v.dashboard),{getUpdatedFrame:g}=Be(),{selectVisual:f}=Ct(),{addFrame:y,checkAddFrame:C,setIsVisualEditing:S}=Ce(),V=dt(),P=!!(c!=null&&c.visualId),D=(()=>{var v,b;return((v=c==null?void 0:c.cards)==null?void 0:v.length)===1&&(b=c.cards[0])!=null&&b.title?c.cards[0].title:u!=null&&u.title?u.title:(d==null?void 0:d.title)||"Untitled Visual";})(),B=Ja(v=>{v!=null&&v.id&&(f(v),s&&i&&l&&p&&(async()=>{try{const b={...i,id:ft(),visualId:v.id};y(p,b,{semanticExecutionPayload:l,withEditorFieldChanges:!0}),n(!1),o(null),h(null),S(!1);}catch(b){console.error("Failed to promote semantic metadata for saved visual:",b),z.error(b instanceof Error?b.message:"Failed to prepare semantic metadata for the saved visual");}})(),a(!1));});return{saveAsDialogOpen:e,setSaveAsDialogOpen:a,handleSaveAs:async v=>{if(!p){z.error("No sheet selected");return;}const b=g(),A=b.cards.length===1?{...b,cards:b.cards.map(G=>({...G,title:v.name}))}:b;if(v.saveToLibrary){let G=null;if(v.saveToCurrentDashboard)try{G=await V(A,{previousFrame:rt(m,A.id)});}catch(R){console.error("Failed to prepare semantic metadata before saving visual:",R),z.error(R instanceof Error?R.message:"Failed to prepare semantic metadata for the saved visual");return;}if(v.saveToCurrentDashboard){const R=C(p,{...A,id:ft()},{withEditorFieldChanges:!0});if(!R.ok){z.error(R.reason);return;}}n(v.saveToCurrentDashboard),o(A),h(G);const T={title:v.name,description:v.description,frameObject:A,isPrivate:!1};B.mutate(T);}else if(v.saveToCurrentDashboard){const G={...A,id:ft(),visualId:void 0};try{const T=await V(A,{previousFrame:rt(m,A.id)});y(p,G,{semanticExecutionPayload:T,withEditorFieldChanges:!0}),z.success("Visual saved to dashboard"),a(!1),S(!1);}catch(T){console.error("Failed to save visual to dashboard:",T),z.error(T instanceof Error?T.message:"Failed to prepare semantic metadata for the visual");}}},isLibraryVisual:P,currentVisualName:D,isSaving:B.isPending};}function Wi(e={}){const{isInspectionMode:a}=Za(),s=le(T=>T.frame),n=le(T=>T.editorContext),i=en(T=>T.selectedVisual),o=w(T=>T.selectedFrameId),l=w(T=>T.selectedSheetId),h=w(T=>T.dashboard),{setIsVisualEditing:c,updateFrame:d}=Ce(),[u,p]=E(!1),[m,g]=E("both"),f=dt(),y=(n==null?void 0:n.type)==="documentSection",C=!!(s!=null&&s.visualId||i!=null&&i.id),S=!!(s!=null&&s.visualId&&o),V=C&&!S,{saveAsDialogOpen:P,setSaveAsDialogOpen:D,handleSaveAs:B,isLibraryVisual:k,currentVisualName:v,isSaving:b}=hs(),{getUpdatedFrame:_}=Be();if(a)return/* @__PURE__ */r($,{children:[/* @__PURE__ */t(gt,{className:"rounded-control",variant:"default"}),/* @__PURE__ */t(bt,{})]});if(y)return/* @__PURE__ */r($,{children:[/* @__PURE__ */t(gt,{className:"rounded-control",variant:"default"}),/* @__PURE__ */t(bt,{})]});const A=async()=>{if(!l){z.error("No sheet selected");return;}if(u)return;p(!0);const R={..._(),visualId:void 0},X=rt(h,R.id);try{const O=await f(R,{previousFrame:X});d(l,R,{semanticExecutionPayload:O});}catch(O){console.error("Failed to apply local semantic metadata:",O),p(!1),z.error(O instanceof Error?O.message:"Failed to prepare semantic metadata for this visual");return;}setTimeout(()=>{p(!1),z.success("Changes applied. Visual is now local to this dashboard"),c(!1);},300);},G=T=>{g(T),D(!0);};return/* @__PURE__ */r($,{children:[/* @__PURE__ */r("div",{className:"inline-flex items-center overflow-hidden rounded-control",children:[!C&&/* @__PURE__ */t(gt,{className:"!rounded-none",variant:"default"}),C&&V&&/* @__PURE__ */t(ds,{className:"!rounded-none",variant:"default"}),C&&S&&/* @__PURE__ */t(cs,{className:"!rounded-none"}),/* @__PURE__ */r(je,{modal:!1,children:[/* @__PURE__ */t(qe,{asChild:!0,children:/* @__PURE__ */t(L,{variant:"default",size:"xs",className:"w-7 !rounded-none border-l border-primary-foreground/20 px-0","aria-label":"Open visual save options",disabled:b||u,children:/* @__PURE__ */t(Ot,{className:"h-3.5 w-3.5"})})}),/* @__PURE__ */r(We,{align:"end",className:"min-w-[220px] rounded-control border border-border/60 p-1 shadow-sm",children:[S&&/* @__PURE__ */r($,{children:[/* @__PURE__ */r(re,{onClick:A,disabled:u,children:[/* @__PURE__ */t(_t,{className:"h-3.5 w-3.5"}),u?"Applying...":"Apply Locally"]}),/* @__PURE__ */t(at,{})]}),/* @__PURE__ */r(re,{onClick:()=>G("local"),disabled:b,children:[/* @__PURE__ */t(be,{className:"h-3.5 w-3.5"}),"Add to Dashboard (Local)"]}),/* @__PURE__ */r(re,{onClick:()=>G("library"),disabled:b,children:[/* @__PURE__ */t(kr,{className:"h-3.5 w-3.5"}),"Save as Library Visual"]}),/* @__PURE__ */r(re,{onClick:()=>G("both"),disabled:b,children:[/* @__PURE__ */t(tn,{className:"h-3.5 w-3.5"}),"Save Copy as Linked Visual"]})]})]})]}),/* @__PURE__ */t(bt,{}),/* @__PURE__ */t(us,{open:P,onOpenChange:T=>{b||D(T);},isLibraryVisual:k,currentVisualName:v,isSaving:b,destinationMode:m,onConfirm:B})]});}function Qi({className:e}){const a=le(u=>u.isDevMode),s=le(u=>u.card.type),n=w(u=>u.isVisualEditing),{setIsDevMode:i}=wt(),{config:o}=Va(an).tokenProps,l=(o==null?void 0:o.showAdvancedMode)!==!1;if(!n||!l||!rr(s))return null;const h=a?Hr:Kr,c=a?"Visual editor":"SQL editor",d=a?"Switch to visual editor":"Switch to SQL editor";return/* @__PURE__ */r("button",{type:"button","aria-label":d,title:d,onClick:()=>i(!a),className:J("inline-flex h-7 items-center gap-1.5 rounded-control border border-input bg-background px-2 text-[12px] font-medium text-foreground transition-colors hover:bg-muted/40 focus-visible:border-ring focus-visible:outline-none",e),children:[/* @__PURE__ */t(h,{className:"h-3 w-3 text-muted-foreground"}),c]});}function Ki(){const e=nn()==="sm",a=w(c=>c.isDashboardEditing),s=w(c=>c.isVisualEditing),n=w(c=>{var u;const d=((u=c.dashboard)==null?void 0:u.sheets)??[];return d.find(p=>p.id===c.selectedSheetId)??d[0];}),i=w(c=>c.actions.arrangeSheet),o=w(c=>c.actions.undoArrange);if(!a||s||!n||Ke(n))return null;const l=!(n.frames??[]).length,h=c=>{const d=i(n.id,{keepOrder:c});if(!d.ok){z.error(d.reason==="not_a_grid"?"This sheet has no grid to arrange.":"The dashboard can't be arranged right now.");return;}z("Arranged",{duration:1e4,description:c?"Sizes and gaps fixed on every screen size, in your order.":"KPIs on top, charts in pairs, tables full width, on every screen size.",action:{label:"Undo",onClick:()=>{const u=o();!u.ok&&u.reason==="changed_since"&&z.info("The dashboard changed after Arrange, so it can't be undone from here.");}}});};return/* @__PURE__ */r("div",{className:"inline-flex h-7 items-stretch overflow-hidden rounded-control border border-input bg-background",children:[/* @__PURE__ */r(L,{variant:"ghost",size:"xs",disabled:l,title:l?"This sheet has no cards to arrange":"Lay out the cards by kind on every screen size",onClick:()=>h(!1),"aria-label":e?"Arrange":void 0,className:`h-full rounded-none border-0 shadow-none hover:bg-accent${e?" w-7 px-0":""}`,children:[/* @__PURE__ */t(Ue,{className:"h-3.5 w-3.5"}),!e&&"Arrange"]}),/* @__PURE__ */r(je,{modal:!1,children:[/* @__PURE__ */t(qe,{asChild:!0,children:/* @__PURE__ */t(L,{variant:"ghost",size:"xs",disabled:l,className:"h-full w-7 rounded-none border-0 border-l border-border/60 px-0 shadow-none hover:bg-accent","aria-label":"Open arrange options",children:/* @__PURE__ */t(Ot,{className:"h-3.5 w-3.5"})})}),/* @__PURE__ */t(We,{align:"end",className:"z-[60] w-48 rounded-[6px] border-border/60 p-1 shadow-sm",children:/* @__PURE__ */r(re,{onClick:()=>h(!0),children:[/* @__PURE__ */t(Ue,{className:"h-3.5 w-3.5"}),"Keep my order"]})})]})]});}function Hi(){const e=w(i=>i.screenSizesOpen),a=w(i=>{var h,c;const o=((h=i.dashboard)==null?void 0:h.sheets)??[],l=o.find(d=>d.id===i.selectedSheetId)??o[0];return!!l&&!Ke(l)&&!!((c=l.frames)!=null&&c.length);}),s=w(i=>i.actions.setScreenSizesOpen),n=fa("screen-sizes","lg",a?{label:"Screen sizes",icon:/* @__PURE__ */t(ta,{className:"h-3.5 w-3.5","aria-hidden":!0}),checked:e,order:40,onSelect:()=>s(!e)}:void 0);return!a||n.collapsed?null:/* @__PURE__ */t(L,{type:"button",size:"xs",variant:e?"secondary":"ghost","aria-pressed":e,"aria-label":"Screen sizes",title:"Screen sizes",onClick:()=>s(!e),className:"w-7 px-0",children:/* @__PURE__ */t(ta,{className:"h-3.5 w-3.5","aria-hidden":!0})});}function Gi({dashboardId:e}){const{openDashboardId:a,access:s,printMode:n,serverIsFavorite:i,fetchedAt:o}=w(rn(c=>{var d;return{openDashboardId:(d=c.dashboard)==null?void 0:d.id,access:c.viewer.access,printMode:c.viewer.printMode,serverIsFavorite:c.viewer.isFavorite,fetchedAt:c.viewer.fetchedAt};})),l=sn(),h=l.isFavorite(e,i,o);return a!==e||n||s==="session-only"?null:/* @__PURE__ */t(on,{variant:"toolbar",isFavorite:h,readOnly:s==="read-only",pending:l.isPending(e),onToggle:()=>void l.setFavorite({dashboardId:e,isFavorite:!h})});}function Yi(e){var c;const{authToken:a,tokenProps:s}=$e(),{data:n}=ln(),{mutate:i,isPending:o}=dn(),l=!!e&&((c=n==null?void 0:n.preference)==null?void 0:c.defaultDashboardId)===e,h=!n||o;return{available:!!e&&!!(a!=null&&a.accessToken)&&!!(s!=null&&s.apiServiceUrl),isDefault:l,disabled:h,toggle:()=>{!e||h||i({dashboardId:l?null:e});}};}function Xi({open:e,onOpenChange:a,onSave:s,onDiscard:n,isSaving:i,title:o="Unsaved changes",description:l="You have unsaved changes to this dashboard. What would you like to do?",cancelLabel:h="Cancel",discardLabel:c="Discard changes",saveLabel:d="Save"}){return/* @__PURE__ */t(St,{open:e,onOpenChange:p=>{!p&&i||a(p);},children:/* @__PURE__ */r(kt,{children:[/* @__PURE__ */r(Dt,{children:[/* @__PURE__ */t(At,{children:o}),/* @__PURE__ */t(Ft,{children:l})]}),/* @__PURE__ */r(Et,{children:[/* @__PURE__ */t(L,{type:"button",size:"xs",onClick:n,disabled:i,variant:"outline",className:"mr-auto text-destructive hover:border-destructive/40 hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive",children:c}),s?/* @__PURE__ */t(It,{disabled:i,children:h}):/* @__PURE__ */t(cn,{asChild:!0,children:/* @__PURE__ */t(L,{type:"button",size:"xs",children:h})}),s&&/* @__PURE__ */t(L,{type:"button",size:"xs",onClick:s,disabled:i,children:i?/* @__PURE__ */r($,{children:[/* @__PURE__ */t(de,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Saving..."]}):d})]})]})});}async function Ji(e){var o,l;const a=(l=(o=w.getState())==null?void 0:o.authToken)==null?void 0:l.accessToken;if(!a)return;const s=`${e}/v1/invalidate-token`,n=await fetch(s,{method:"POST",headers:{Authorization:`Bearer ${a}`}});if(!n.ok)throw new Error("Failed to invalidate token");const i=await n.json();return console.log("invalidateToken",i),i;}function ms(e){var s;const a=e.item;return a.kind==="export"?{title:a.title,status:a.status,startedAt:a.startedAt,finishedAt:a.finishedAt,running:bn(a.stage),finishedDetail:[a.totalRows!==null?`${a.totalRows.toLocaleString("en-US")} rows`:null,a.fileSize?gn(a.fileSize):null].filter(n=>!!n),failure:((s=a.failure)==null?void 0:s.kind)==="export"?a.failure.message:a.status==="failed"?Ne.failedFallback:null,note:null}:{title:a.title,status:a.status,startedAt:a.startedAt,finishedAt:a.finishedAt,running:{text:a.stageLabel??Ne.inProgress},finishedDetail:[],failure:null,note:a.omittedAttachmentCount>0?ge.attachmentsLeftOut(a.omittedAttachmentCount):null};}function na({row:e,now:a,api:s}){const[n,i]=E("idle"),o=hn(e,s),l=async()=>{if(!o)return;i("working");const h=await xn(s,e,o);i(h==="done"?"idle":h);};return/* @__PURE__ */t(Ea,{shown:ms(e),now:a,longRunningHint:e.item.kind==="export",action:o?{label:ga[o],run:()=>void l()}:null,working:n==="working",problem:n==="denied"||n==="blocked"?n:null});}function ps({work:e,now:a}){const s=e.stage==="preparing"?e.cancel:null;return/* @__PURE__ */t(Ea,{shown:{title:e.title,status:"running",startedAt:e.startedAt,finishedAt:null,running:un(e),finishedDetail:[],failure:null,note:null},now:a,longRunningHint:!1,action:s?{label:ga.cancel,run:s}:null,working:!1,problem:null});}function Ea({shown:e,now:a,longRunningHint:s,action:n,working:i,problem:o}){const l=e.status==="ready"?"bg-emerald-500":e.status==="failed"?"bg-destructive":e.status==="cancelled"?"bg-muted-foreground/40":"animate-pulse bg-muted-foreground/60",h=e.status==="ready"?Ne.ready:e.status==="failed"?Ne.failed:e.status==="cancelled"?Ne.cancelled:Ne.inProgress,c=Date.parse(e.startedAt),d=Gt(Date.parse(e.finishedAt??e.startedAt),a,{addSuffix:!0}),u=e.status==="running"&&s&&a-c>=mn,p=/* @__PURE__ */t("span",{className:"text-muted-foreground/50",children:"·"});return/* @__PURE__ */r("div",{className:"group flex items-start gap-2.5 px-3 py-2 transition-colors hover:bg-muted/40 focus-within:bg-muted/40",children:[/* @__PURE__ */t("span",{className:"flex h-5 shrink-0 items-center","aria-hidden":"true",children:/* @__PURE__ */t("span",{className:`h-1.5 w-1.5 rounded-full ${l}`})}),/* @__PURE__ */t("span",{className:"sr-only",children:h}),/* @__PURE__ */r("div",{className:"min-w-0 flex-1",children:[/* @__PURE__ */r("div",{className:"flex h-5 items-center gap-2",children:[/* @__PURE__ */t("span",{className:"min-w-0 flex-1 truncate text-[13px] font-medium leading-5",children:e.title}),n&&i&&/* @__PURE__ */t("span",{role:"status",className:"inline-flex shrink-0 items-center gap-1.5 text-[12px] text-muted-foreground",children:/* @__PURE__ */t(ba,{className:"h-3 w-3 animate-spin",strokeWidth:1.75})}),n&&!i&&/* @__PURE__ */t("button",{type:"button",onClick:n.run,className:"shrink-0 text-[12px] font-medium text-foreground/80 underline-offset-2 hover:text-foreground hover:underline focus-visible:underline focus-visible:outline-none",children:n.label})]}),e.status==="running"&&e.running&&/* @__PURE__ */r("div",{className:"text-[12px] leading-4 text-muted-foreground",children:[/* @__PURE__ */t("span",{className:"tabular-nums",children:e.running.text}),e.running.detail&&/* @__PURE__ */r($,{children:[" ",p," ",/* @__PURE__ */t("span",{className:"tabular-nums",children:e.running.detail})]})," ",p," ",/* @__PURE__ */t("span",{children:Ne.started(Gt(c,a))}),e.running.percent!==void 0&&/* @__PURE__ */t(pn,{value:e.running.percent,className:"mt-1.5 h-1"}),u&&/* @__PURE__ */t("div",{className:"mt-1",children:Ne.longRunning})]}),e.status!=="running"&&/* @__PURE__ */r("div",{className:"flex items-center gap-1.5 text-[12px] leading-4 text-muted-foreground",children:[e.status==="ready"&&e.finishedDetail.length>0?/* @__PURE__ */r("span",{className:"hidden group-hover:contents group-focus-within:contents",children:[e.finishedDetail.map((m,g)=>/* @__PURE__ */r(la.Fragment,{children:[g>0&&p,/* @__PURE__ */t("span",{children:m})]},g)),p]}):e.status!=="ready"?/* @__PURE__ */r($,{children:[/* @__PURE__ */t("span",{children:h}),p]}):null,/* @__PURE__ */t("span",{children:d})]}),e.note&&/* @__PURE__ */t("div",{className:"text-[12px] leading-4 text-muted-foreground",children:e.note}),e.status==="failed"&&e.failure&&/* @__PURE__ */t("div",{className:"mt-1 whitespace-pre-wrap break-words text-[12px] leading-4 text-destructive",children:e.failure}),o&&/* @__PURE__ */t(fn,{problem:o,className:"mt-1"})]})]});}function Zi({variant:e}){const{snapshot:a,markSeen:s}=Vt(),n=a.runningCount>0?a.runningCount>9?"9+":String(a.runningCount):a.hasUnseenFinished?"":null,i=fa("activity","md",{label:ge.title,icon:/* @__PURE__ */t(ea,{className:"h-3.5 w-3.5"}),hint:n||(n===""?"New":void 0),order:30,onOpen:s});return i.collapsed?/* @__PURE__ */r(Ee,{open:i.popoverOpen,onOpenChange:o=>{i.setPopoverOpen(o),o&&s();},children:[i.anchorSlot&&Er(/* @__PURE__ */t(Na,{asChild:!0,children:/* @__PURE__ */t("span",{className:"absolute right-0 top-0 h-7 w-px"})}),i.anchorSlot),/* @__PURE__ */t(Ie,{className:"w-80 p-0",align:"end",sideOffset:8,onFocusOutside:o=>o.preventDefault(),children:/* @__PURE__ */t(ra,{})})]}):/* @__PURE__ */r(Ee,{onOpenChange:o=>{o&&s();},children:[/* @__PURE__ */t(nt,{asChild:!0,children:/* @__PURE__ */r(L,{variant:e??"ghost",size:"xs",className:"relative w-7 px-0","aria-label":ge.title,title:ge.title,children:[/* @__PURE__ */t(ea,{className:"h-3.5 w-3.5"}),n!==null&&/* @__PURE__ */t("span",{className:`absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${n?"-right-0.5 -top-0.5 h-3.5 min-w-3.5 px-0.5 text-[9px] font-semibold":"right-1 top-1 h-1.5 w-1.5"}`,children:n})]})}),/* @__PURE__ */t(Ie,{className:"w-80 p-0",align:"end",sideOffset:8,children:/* @__PURE__ */t(ra,{})})]});}function ra(){const e=Vt(),a=vn(),{rows:s,browserRows:n,activeTruncated:i}=e.snapshot,o=s.some(d=>pt(d.item.status)),l=[...s.filter(d=>!pt(d.item.status)).map(d=>({startedAt:d.item.startedAt,row:d})),...n.map(d=>({startedAt:d.startedAt,work:d}))].sort((d,u)=>u.startedAt.localeCompare(d.startedAt)),h=s.filter(d=>pt(d.item.status)),c=s.length+n.length;return c===0?/* @__PURE__ */r("div",{className:"flex flex-col items-center gap-1.5 px-6 py-8 text-center",children:[/* @__PURE__ */t("span",{className:"flex h-8 w-8 items-center justify-center rounded-[6px] border border-border text-muted-foreground",children:/* @__PURE__ */t(yn,{className:"h-3.5 w-3.5",strokeWidth:1.75})}),/* @__PURE__ */t("p",{className:"text-[13px] font-medium",children:ge.title}),/* @__PURE__ */t("p",{className:"text-[12px] text-muted-foreground",children:ge.empty})]}):/* @__PURE__ */r("div",{className:"flex flex-col",children:[/* @__PURE__ */r("div",{className:"flex h-8 items-center gap-2 border-b border-border px-3",children:[/* @__PURE__ */t("span",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:ge.title}),/* @__PURE__ */t("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:c}),/* @__PURE__ */r("div",{className:"ml-auto flex items-center gap-0.5",children:[o&&/* @__PURE__ */t(L,{variant:"ghost",size:"xs",className:"h-6 px-1.5 text-[12px] text-muted-foreground hover:text-foreground",onClick:e.clearFinished,children:ge.clear}),/* @__PURE__ */t(L,{variant:"ghost",size:"xs",className:"h-6 w-6 px-0 text-muted-foreground hover:text-foreground",onClick:e.refresh,title:"Refresh status","aria-label":"Refresh status",children:/* @__PURE__ */t(ba,{strokeWidth:1.75,className:"h-3.5 w-3.5"})})]})]}),i&&/* @__PURE__ */t("p",{className:"border-b border-border px-3 py-2 text-[12px] leading-4 text-muted-foreground",children:ge.truncated}),/* @__PURE__ */t("div",{className:"max-h-[320px] overflow-y-auto",children:/* @__PURE__ */r("div",{className:"divide-y divide-border/70",children:[l.map(d=>"work"in d?/* @__PURE__ */t(ps,{work:d.work,now:a},d.work.id):/* @__PURE__ */t(na,{row:d.row,now:a,api:e},jt(d.row))),h.map(d=>/* @__PURE__ */t(na,{row:d,now:a,api:e},jt(d)))]})})]});}function fs(e){if(e)return{renamed:e.type==="rename"?{oldId:e.oldId,newId:e.newId}:void 0,removedControlId:e.type==="remove"?e.controlId:void 0,cardBindingsById:e.type==="add"||e.type==="update"?e.cardBindingsById:void 0,affectedBindingControlIds:e.type==="add"||e.type==="update"?e.affectedBindingControlIds:void 0};}function gs({open:e,onOpenChange:a,trigger:s,showTrigger:n=!0,initialMode:i="manage"}){const o=i==="create",{forceClose:l,handleOpenChange:h,isCreateFlowActive:c,preventPassiveDismissDuringCreate:d,resolvedOpen:u,setIsCreateFlowActive:p}=Sa({open:e,onOpenChange:a,initialCreateFlowActive:i==="create",dismissMode:n?"passive":"explicit-only"}),m=w(b=>b.dashboard),{setDashboardControlsModel:g}=Ce(),{participants:f}=Nn(Tr(m)),y=Array.from(new Map(f.flatMap(b=>b.fieldChoices.map(_=>{var A;return[_.value,{option:_,target:(A=b.fieldTargetMap)==null?void 0:A[_.value]}];}))).values()),C=Array.from(new Map(f.flatMap(b=>b.metricChoices.map(_=>{var A;return[_.value,{option:_,target:(A=b.metricTargetMap)==null?void 0:A[_.value]}];}))).values()),S=sr({...(m||{}),controls:[]}),V=Cn(m),P=(b,_,A)=>{g(b,_,fs(A));},D=ie(()=>{if(o){l();return;}p(!1);},[o,l,p]),B=/* @__PURE__ */t(ka,{scope:"dashboard",controls:m.controls||[],reservedControlIds:S,defaultValues:m.defaultControlValues||{},usageByControlId:wn(m),availableFieldChoices:y,availableMetricChoices:C,structuralParticipants:f,structuralParticipantIdsByControlId:V,initialCreateFlow:i==="create",onCreateFlowActiveChange:p,onCreateFlowComplete:D,onChange:P,emptyMessage:"No dashboard controls yet."}),k=c?"Add dashboard control":"Dashboard Controls",v=/* @__PURE__ */r($,{children:[/* @__PURE__ */r("div",{className:"space-y-1",children:[/* @__PURE__ */t("h4",{className:"text-sm font-medium",children:"Dashboard Controls"}),/* @__PURE__ */t("p",{className:"text-xs text-muted-foreground",children:"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),B]});return n?/* @__PURE__ */r(Ee,{open:u,onOpenChange:h,children:[/* @__PURE__ */t(nt,{asChild:!0,children:s||/* @__PURE__ */r(L,{variant:"outline",className:"h-7 px-2",size:"sm",children:[/* @__PURE__ */t(Ca,{className:"mr-2 h-4 w-4"}),"Controls"]})}),/* @__PURE__ */t(Ie,{className:"w-[620px] max-w-[95vw] space-y-4",align:"end",onEscapeKeyDown:d,onPointerDownOutside:d,children:v})]}):/* @__PURE__ */t(Te,{open:u,onOpenChange:h,children:/* @__PURE__ */r(Le,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:d,onPointerDownOutside:d,children:[/* @__PURE__ */r(Lt,{className:c?"space-y-0":void 0,children:[/* @__PURE__ */t(Ve,{className:"text-[15px]",children:k}),/* @__PURE__ */t(ct,{className:c?"sr-only":"text-[13px]",children:c?"Configure and add a shared dashboard control.":"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),/* @__PURE__ */t("div",{className:"min-h-0 overflow-y-auto pr-1",children:B})]})});}const bs=["enum","multi_enum","text","number","boolean","date"];function xs({open:e,onOpenChange:a,initialMode:s="manage"}){var v;const n=s==="create",{forceClose:i,handleOpenChange:o,isCreateFlowActive:l,preventPassiveDismissDuringCreate:h,resolvedOpen:c,setIsCreateFlowActive:d}=Sa({open:e,onOpenChange:a,initialCreateFlowActive:s==="create",dismissMode:"explicit-only"}),u=w(b=>b.dashboard),p=w(b=>b.selectedSheetId),{setDashboardInputs:m}=Ce(),g=(v=u.sheets)==null?void 0:v.find(b=>b.id===p),f=(g==null?void 0:g.kind)==="document"&&!!g.document,y=Y(()=>f&&g!=null&&g.document?ir(u,g.id):[],[u,f,g==null?void 0:g.document,g==null?void 0:g.id]),C=Y(()=>y.filter(b=>b.kind==="control"),[y]),S=Y(()=>C.map(b=>b.control),[C]),V=Y(()=>ys(S),[S]),P=Y(()=>[...vs(u),...(u.variables??[]).map(b=>b.name)],[u]),D=ie(()=>{if(n){i();return;}d(!1);},[n,i,d]),B=ie((b,_,A)=>{!f||!(g!=null&&g.document)||m(Cs({dashboard:u,documentSheetId:g.id,currentDocumentInputs:y,nextControls:b,nextDefaultValues:_,change:A}));},[u,y,f,g,m]);return!f||!(g!=null&&g.document)?null:/* @__PURE__ */t(Te,{open:c,onOpenChange:o,children:/* @__PURE__ */r(Le,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:h,onPointerDownOutside:h,children:[/* @__PURE__ */r(Lt,{className:l?"space-y-0":void 0,children:[/* @__PURE__ */t(Ve,{className:"text-[15px]",children:l?"Add document control":"Document Controls"}),/* @__PURE__ */t(ct,{className:l?"sr-only":"text-[13px]",children:l?"Configure and add a document-local control input.":"Add document-local control inputs. They are stored on this document sheet and are not dashboard controls."})]}),/* @__PURE__ */t("div",{className:"min-h-0 overflow-y-auto pr-1",children:/* @__PURE__ */t(ka,{scope:"dashboard",controls:S,reservedControlIds:P,defaultValues:V,usageByControlId:{},availableFieldChoices:[],availableMetricChoices:[],structuralParticipants:[],structuralParticipantIdsByControlId:{},allowedControlTypes:bs,initialCreateFlow:s==="create",onCreateFlowActiveChange:d,onCreateFlowComplete:D,onChange:B,emptyMessage:"No document controls yet."})})]})});}function vs(e){return(e.controls||[]).map(a=>a.id);}function ys(e){const a={};for(const s of e)s.defaultValue!==void 0&&(a[s.id]=s.defaultValue);return a;}function Ns(e,a){return a?Object.prototype.hasOwnProperty.call(a,e.id)?{...e,defaultValue:a[e.id]}:e.defaultValue===void 0?e:{...e,defaultValue:void 0}:e.defaultValue===void 0?e:{...e,defaultValue:void 0};}function Cs({dashboard:e,documentSheetId:a,currentDocumentInputs:s,nextControls:n,nextDefaultValues:i,change:o}){const l=new Map(n.map(g=>[g.id,Ns(g,i)])),h=(o==null?void 0:o.type)==="rename"?{oldId:o.oldId,newId:o.newId}:null,c=/* @__PURE__ */new Set(),d=[];for(const g of s){if(g.kind!=="control"){d.push(g);continue;}const f=l.get(g.control.id)||((h==null?void 0:h.oldId)===g.control.id?l.get(h.newId):void 0);if(!f)continue;c.add(f.id);const y=or(e,{name:f.id},{exclude:{source:"input",inputId:g.id},alsoTaken:d}),C=f.id===y?f:{...f,id:y};d.push({...g,label:C.label,variableName:y,requiredAtExecution:C.requiredAtExecution,control:C});}for(const g of l.values())c.has(g.id)||d.push(lr({control:g,dashboard:e,alsoTaken:d,sheetId:a}));const u=new Set(s.map(g=>g.id));return[...(Array.isArray(e.inputs)?e.inputs:[]).filter(g=>!u.has(g.id)),...d];}function ws({showFilters:e,onShowFiltersChange:a,pickerContent:s,settingsContent:n,size:i="default",className:o,primaryButtonClassName:l,secondaryButtonClassName:h,pickerContentClassName:c,settingsContentClassName:d}){const u=i==="toolbar",[p,m]=E(!1),g=it("interactive");return/* @__PURE__ */r("div",{className:J("relative inline-flex items-stretch overflow-hidden rounded-control border border-input bg-background",u?"h-8":"h-7",o),children:[/* @__PURE__ */r(Ee,{open:e,onOpenChange:a,children:[/* @__PURE__ */t(nt,{asChild:!0,children:/* @__PURE__ */r(L,{variant:"ghost",size:"xs",className:J("h-full rounded-none border-0 bg-transparent pl-2.5 pr-2 shadow-none hover:bg-accent/50 data-[state=open]:bg-accent/60",l),children:[e?/* @__PURE__ */t(Dr,{className:"h-3.5 w-3.5"}):/* @__PURE__ */t(xa,{className:"h-3.5 w-3.5"}),"Filter"]})}),/* @__PURE__ */t(Ie,{align:"end",sideOffset:6,className:J("w-auto rounded-card border border-border/60 p-0 shadow-[0_10px_28px_rgba(0,0,0,0.14)] dark:shadow-[0_10px_28px_rgba(0,0,0,0.5)]",c),style:g.contentStyle,children:s})]}),/* @__PURE__ */r(Ee,{open:p,onOpenChange:m,children:[/* @__PURE__ */t(nt,{asChild:!0,children:/* @__PURE__ */t(L,{variant:"ghost",size:"xs",className:J("h-full w-7 rounded-none border-0 border-l border-border/60 bg-transparent px-0 shadow-none hover:bg-accent/50 data-[state=open]:bg-accent/60",h),"aria-label":"Filter and control actions",children:/* @__PURE__ */t(Ot,{className:"h-3.5 w-3.5"})})}),/* @__PURE__ */t(Ie,{align:"end",sideOffset:6,className:J("w-auto rounded-card border border-border/60 p-0 shadow-[0_10px_28px_rgba(0,0,0,0.14)] dark:shadow-[0_10px_28px_rgba(0,0,0,0.5)]",d),style:g.contentStyle,children:n(()=>m(!1))})]})]});}function Ss(){const e=w(d=>d.dashboard),a=w(d=>d.semanticExecutionPayload),s=w(d=>d.actions.addFilterInput),n=w(d=>d.selectedSheetId),i=Y(()=>{var u,p;const d=((u=e==null?void 0:e.sheets)==null?void 0:u.find(m=>m.id===n))??((p=e==null?void 0:e.sheets)==null?void 0:p[0]);return((d==null?void 0:d.frames)??[]).map(m=>Pr(m)).filter(m=>!!m);},[e,n]),o=zr(i).length>0,l=Y(()=>dr(e,a),[e,a]),c=!cr(e)&&l.hasEligibleCards;return/* @__PURE__ */r("div",{className:"flex h-[520px] w-[400px] flex-col",children:[c&&/* @__PURE__ */t("div",{className:"border-b border-border/60 p-2",children:/* @__PURE__ */r("button",{type:"button",onClick:()=>s(ur(),{kind:"allSheets",sheetKinds:["dashboard"]}),title:`Applies to ${l.eligibleCardCount} of ${l.totalCardCount} date-aware cards`,className:"flex w-full items-start gap-2 rounded-control px-2 py-1.5 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-border",children:[/* @__PURE__ */t(Sn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),/* @__PURE__ */r("span",{className:"flex min-w-0 flex-col",children:[/* @__PURE__ */t("span",{className:"text-[12px] font-medium text-foreground",children:"Add global date filter"}),/* @__PURE__ */t("span",{className:"text-[11px] leading-[1.4] text-muted-foreground",children:"One date range across all date-aware cards."})]})]})}),!o&&/* @__PURE__ */r("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-8 text-center",children:[/* @__PURE__ */t(kn,{className:"mb-3 h-10 w-10 text-muted-foreground/50"}),/* @__PURE__ */t("h3",{className:"mb-1 text-[13px] font-medium text-foreground",children:"No fields configured"}),/* @__PURE__ */t("p",{className:"text-[11px] text-muted-foreground",children:"Add a card with data to this sheet to filter it."})]}),o&&/* @__PURE__ */t("div",{className:"flex flex-1 overflow-hidden",children:/* @__PURE__ */t(Dn,{cards:i,context:"filter"})})]});}function ks({onAddFilter:e,onAddControl:a,onManageControls:s,onDismiss:n}){const i=w(h=>h.dashboard.filterLayout),{setFilterLayout:o}=Ce(),l=(i==null?void 0:i.toolbarWrap)??!1;return/* @__PURE__ */r("div",{className:"w-[300px]",children:[/* @__PURE__ */r("div",{className:"p-1",children:[/* @__PURE__ */t(xt,{icon:xa,label:"Add filter",onClick:()=>{e(),n();}}),/* @__PURE__ */t(xt,{icon:Ca,label:"Add control",onClick:()=>{a(),n();}}),/* @__PURE__ */t(xt,{icon:Bt,label:"Manage controls",onClick:()=>{s(),n();}})]}),/* @__PURE__ */t("div",{className:"border-t border-border/60"}),/* @__PURE__ */r("div",{className:"space-y-1 p-2",children:[/* @__PURE__ */t("p",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Display"}),/* @__PURE__ */t(Ds,{id:"filter-display-wrap",label:"Wrap to multiple lines",checked:l,onCheckedChange:h=>o({toolbarWrap:h===!0})})]})]});}function xt({icon:e,label:a,onClick:s}){return/* @__PURE__ */r("button",{type:"button",onClick:s,className:"flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-[13px] text-foreground outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40",children:[/* @__PURE__ */t(e,{className:"h-3.5 w-3.5 text-muted-foreground"}),a]});}function Ds({id:e,label:a,checked:s,onCheckedChange:n}){return/* @__PURE__ */r("div",{className:"flex items-center gap-2 rounded-control px-1 py-1 transition-colors hover:bg-muted/40 focus-within:bg-muted/40",children:[/* @__PURE__ */t(Tt,{id:e,checked:s,onCheckedChange:n}),/* @__PURE__ */t(Re,{htmlFor:e,className:"cursor-pointer text-[12px] font-normal leading-[1.3]",children:a})]});}function eo({size:e,className:a,primaryButtonClassName:s,secondaryButtonClassName:n,pickerContentClassName:i,settingsContentClassName:o}){var B;const[l,h]=E(null),c=w(k=>k.dashboard),d=w(k=>k.selectedSheetId),u=w(k=>k.showFilters),p=w(k=>k.actions),{setDocumentPanelTarget:m,setShowFilters:g}=p,f=(B=c.sheets)==null?void 0:B.find(k=>k.id===d),y=Ke(f),C=ie(k=>{window.setTimeout(()=>{h(k);},0);},[]),S=ie(k=>{if(y&&d){k&&m(d,{kind:"document",group:"inputs"});return;}g(k);},[y,d,m,g]),V=ie(()=>{S(!0);},[S]),P=ie(()=>{C("create");},[C]),D=ie(()=>{C("manage");},[C]);return/* @__PURE__ */r($,{children:[/* @__PURE__ */t(ws,{showFilters:y?!1:u,onShowFiltersChange:S,pickerContent:/* @__PURE__ */t(Ss,{}),settingsContent:k=>/* @__PURE__ */t(ks,{onAddFilter:V,onAddControl:P,onManageControls:D,onDismiss:k}),size:e,className:a,primaryButtonClassName:s,secondaryButtonClassName:n,pickerContentClassName:i,settingsContentClassName:o}),l?y?/* @__PURE__ */t(xs,{open:!0,onOpenChange:k=>{k||h(null);},initialMode:l}):/* @__PURE__ */t(gs,{open:!0,onOpenChange:k=>{k||h(null);},showTrigger:!1,initialMode:l}):null]});}function As(e,a){return(e.variables??[]).map(s=>{const n=Lr(e,s.id);return{variable:s,question:Mr(s),places:n,usedHere:!!a&&n.some(i=>i.sheetId===a)};});}function Fs(e,a){const s=a?e.places.filter(i=>i.sheetId===a).length:0,n=e.places.length-s;return e.places.length?s&&n?`Used here · ${n} elsewhere`:s?"Used here":`Used in ${n} ${n===1?"place":"places"}`:"Not used yet";}function Es({dashboard:e,sheetId:a,sheetTitle:s,onOpen:n,onNew:i}){const[o,l]=E(""),h=Y(()=>As(e,a),[e,a]),c=o.trim().toLowerCase(),d=h.filter(m=>!c||m.variable.name.toLowerCase().includes(c)||(m.variable.label??"").toLowerCase().includes(c)||m.question.toLowerCase().includes(c)),u=d.filter(m=>m.usedHere),p=d.filter(m=>!m.usedHere);return/* @__PURE__ */r("div",{className:"w-[380px] max-w-[calc(100vw-24px)] overflow-hidden","data-testid":"variables-list",children:[/* @__PURE__ */r("div",{className:"flex h-11 items-center justify-between gap-2 border-b border-border/60 px-3",children:[/* @__PURE__ */r("span",{className:"flex items-center gap-2",children:[/* @__PURE__ */t(Nt,{className:"h-3.5 w-3.5 text-muted-foreground","aria-hidden":!0}),/* @__PURE__ */t("span",{className:"text-[13px] font-medium",children:"Data variables"}),h.length?/* @__PURE__ */t("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium tabular-nums text-muted-foreground",children:h.length}):null]}),h.length?/* @__PURE__ */r(L,{size:"xs",className:"gap-1",onClick:i,children:[/* @__PURE__ */t(be,{className:"h-3.5 w-3.5","aria-hidden":!0})," New variable"]}):null]}),h.length?/* @__PURE__ */r($,{children:[/* @__PURE__ */t("div",{className:"px-3 py-2",children:/* @__PURE__ */r("div",{className:"flex h-7 items-center gap-1.5 rounded-control border border-border px-2 text-[12px] text-muted-foreground",children:[/* @__PURE__ */t(da,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}),/* @__PURE__ */t("input",{value:o,onChange:m=>l(m.target.value),placeholder:"Search variables","aria-label":"Search variables",className:"w-full bg-transparent text-foreground outline-none placeholder:text-muted-foreground"})]})}),/* @__PURE__ */r("div",{className:"max-h-[360px] overflow-y-auto",children:[u.length?/* @__PURE__ */t(sa,{children:s?`On ${s}`:"On this tab"}):null,u.map(m=>/* @__PURE__ */t(ia,{row:m,sheetId:a,onOpen:n},m.variable.id)),p.length?/* @__PURE__ */t(sa,{children:u.length?"Elsewhere on this dashboard":"On this dashboard"}):null,p.map(m=>/* @__PURE__ */t(ia,{row:m,sheetId:a,onOpen:n,muted:!!u.length},m.variable.id)),d.length?null:/* @__PURE__ */t("p",{className:"px-4 py-6 text-center text-[12px] text-muted-foreground",children:"No variable matches."})]})]}):/* @__PURE__ */r("div",{className:"px-6 py-8 text-center",children:[/* @__PURE__ */t("span",{className:"mx-auto flex h-8 w-8 items-center justify-center rounded-full bg-muted",children:/* @__PURE__ */t(Nt,{className:"h-4 w-4 text-muted-foreground","aria-hidden":!0})}),/* @__PURE__ */t("p",{className:"mt-3 text-[13px] font-medium",children:"No variables yet"}),/* @__PURE__ */t("p",{className:"mx-auto mt-1 max-w-[280px] text-[12px] leading-[1.5] text-muted-foreground",children:"A variable shows a value from your data in any text: a name or address in a header, the latest date in a footer."}),/* @__PURE__ */r(L,{size:"xs",className:"mt-4 gap-1",onClick:i,children:[/* @__PURE__ */t(be,{className:"h-3.5 w-3.5","aria-hidden":!0})," New variable"]})]})]});}function sa({children:e}){return/* @__PURE__ */t("p",{className:"border-y border-border/60 bg-muted/40 px-4 py-1 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground first:border-t-0",children:e});}function ia({row:e,sheetId:a,onOpen:s,muted:n}){return/* @__PURE__ */r("button",{type:"button",onClick:()=>s(e.variable.id),className:"grid w-full grid-cols-[minmax(0,1fr)_132px] items-center gap-3 border-t border-border/60 px-4 py-2 text-left first:border-t-0 hover:bg-muted/50",children:[/* @__PURE__ */r("span",{className:"min-w-0",children:[/* @__PURE__ */t("span",{className:J("block truncate text-[12px] font-medium text-foreground",!e.variable.label&&"font-mono"),children:e.variable.label||e.variable.name}),/* @__PURE__ */t("span",{className:"mt-0.5 block truncate text-[11px] text-muted-foreground",children:e.question})]}),/* @__PURE__ */t("span",{className:J("truncate text-right text-[11px]",n?"text-muted-foreground/70":"text-muted-foreground"),children:Fs(e,a)})]});}function to(){const e=w(s=>{var n;return((n=s.dashboard.variables)==null?void 0:n.length)??0;}),a=w(s=>s.actions.setVariablesListOpen);return{label:"Data variables",count:e,open:()=>a(!0)};}function ao(){var c;const e=w(d=>d.variablesListOpen),a=w(d=>d.actions.setVariablesListOpen),s=w(d=>d.dashboard),n=w(d=>d.selectedSheetId),i=w(d=>d.actions.openVariableEditor),o=it("interactive"),l=(c=s.sheets)==null?void 0:c.find(d=>d.id===n),h=d=>{a(!1),i(d);};return/* @__PURE__ */r(Ee,{open:e,onOpenChange:a,children:[/* @__PURE__ */t(Na,{asChild:!0,children:/* @__PURE__ */t("span",{"aria-hidden":!0,className:"pointer-events-none inline-block h-7 w-0 self-center"})}),/* @__PURE__ */t(Ie,{align:"end",sideOffset:6,collisionPadding:12,onFocusOutside:d=>d.preventDefault(),className:"z-50 w-auto rounded-card border border-border/60 p-0 shadow-[0_10px_28px_rgba(0,0,0,0.14)] dark:shadow-[0_10px_28px_rgba(0,0,0,0.5)]",style:o.contentStyle,children:/* @__PURE__ */t(Es,{dashboard:s,sheetId:n??void 0,sheetTitle:l==null?void 0:l.title,onOpen:d=>h({kind:"edit",variableId:d}),onNew:()=>h({kind:"new"})})})]});}function Is(e,a){const s=hr(e);return new Set((e.sheets??[]).map(i=>{const o={sheetId:i.id,cardId:a,sheetKind:Ke(i)?"document":"dashboard"};return s.filter(l=>Vr(l,o)).map(l=>l.runtimeScope==="shared"?l.id:`${l.id}@${i.id}`).join(`
37
- `);})).size>1;}const Ts=[];function vt(e){return Object.fromEntries(Object.entries(e).filter(([,a])=>a!=null));}function Ls(e){const a=e==null?void 0:e.type;return a==="dataset"||a==="model"||pr.includes(a);}function Vs(e,a){return Rr(e.map((s,n)=>{var i,o;return{target:s,columns:(i=a[n])==null?void 0:i.columns,calculatedFields:(o=a[n])==null?void 0:o.calculatedFields};})).columns;}function Bs(e){const{tokenProps:a}=$e(),s=w(m=>m.authToken),{connections:n}=va(),i=e==null?void 0:e.connectionId,o=n.find(m=>m.id===i),l=Y(()=>((e==null?void 0:e.selectedEntities)??[]).filter(Ls),[e==null?void 0:e.selectedEntities]),h=m=>{var f;if(!(s!=null&&s.accessToken))return!1;if(m.type==="dataset"){const y=m;return!!(y.domainId&&y.name);}if(m.type==="model")return!!(i&&m.id);const g=((f=o==null?void 0:o.capabilities)==null?void 0:f.path)||[];return!(!i||!m.name||g.includes("database")&&!m.database||g.includes("schema")&&!m.schema);},c=ie(m=>{var f,y;const g=Vs(l,m.map(C=>C.data));return{fields:g.length?g:Ts,isLoading:m.some(C=>C.isLoading),error:(y=(f=m.find(C=>C.error))==null?void 0:f.error)==null?void 0:y.message};},[l]),{fields:d,isLoading:u,error:p}=An({queries:l.map(m=>({queryKey:["columns",i,m,(e==null?void 0:e.semanticDomainId)??null],queryFn:()=>mr(`${a.apiServiceUrl}/v1/columns`,(s==null?void 0:s.accessToken)||"",m.type==="model"?vt({connection_id:i,datamodel_id:m.id,database_name:"",schema_name:"",table_name:""}):m.type==="dataset"?vt({connection_id:m.connectionId??i,domain_id:m.domainId,dataset_name:m.name,database_name:m.database,schema_name:m.schema,table_name:m.table}):vt({connection_id:i,datamodel_id:"",database_name:m.database,schema_name:m.schema,table_name:m.name})),enabled:h(m),staleTime:6e4})),combine:c});return{fields:d,isLoading:u,error:p};}function Ps(e){var s;const a=((s=e.comparison)==null?void 0:s.mode)==="explicit"?e.comparison.spec:void 0;return a&&a.kind!=="target"?{mode:"period",spec:a}:{mode:"off"};}function _s(e){return e.mode==="period"?gr(e.spec):void 0;}const Ut="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",Os={connectionId:"",connectionType:"",mode:"semanticDomain",selectedEntities:[]};function se({label:e,hint:a,aside:s,children:n,className:i}){return/* @__PURE__ */r("div",{className:i,children:[/* @__PURE__ */r("div",{className:"mb-1 flex min-h-5 items-center justify-between gap-2",children:[/* @__PURE__ */t("p",{className:Ut,children:e}),s]}),n,a?/* @__PURE__ */t("p",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:a}):null]});}function yt({muted:e,onClick:a,children:s,ariaLabel:n}){return/* @__PURE__ */t("button",{type:"button",onClick:a,"aria-label":n,className:J("flex h-7 w-full items-center gap-1.5 rounded-control border border-input bg-background px-2 text-left text-[12px] hover:bg-muted/50",e?"text-muted-foreground":"text-foreground"),children:s});}function zs(e){var s;const a=(s=e==null?void 0:e.selectedEntities)==null?void 0:s[0];if(a)return a.label||a.name;}function Ms(e){const a=zt(e);return a==="date"?"date":a==="string"?"text":a==="number"?"number":a==="boolean"?"yes/no":a;}const oa="__new_calculated_field__";function Rs({draft:e,onChange:a,handle:s,onCalculatedFieldOpenChange:n}){var O,te,Z,H,I,ae,q,M,ne,ue,he,ve;const{tokenProps:i}=$e(),o=((O=i.config)==null?void 0:O.showAdvancedMode)!==!1,l=((te=i.config)==null?void 0:te.showDirectSource)!==!1,{connections:h}=va(),[c,d]=E(!1),[u,p]=E(!1),[m,g]=E(!1),f=x=>{p(x),n==null||n(x);},{fields:y,isLoading:C,error:S}=Bs(e.mode==="data"?e.dataSource:void 0),V=[...(e.calculatedFields??[]),...y],P=x=>x&&(V.find(U=>U.id===x.id)??V.find(U=>Us(U,x))),D=[...V,...[e.field,e.sortField].filter(x=>!!x&&!P(x)&&!V.some(U=>U.id===x.id))],B=((Z=P(e.field))==null?void 0:Z.id)??((H=e.field)==null?void 0:H.id)??"",k=((I=P(e.sortField??e.field))==null?void 0:I.id)??((ae=e.sortField??e.field)==null?void 0:ae.id)??"",v=x=>a({...e,...x}),b=zs(e.dataSource),_=((q=e.dataSource)==null?void 0:q.mode)==="database"?Pt:qt,A="mt-1 inline-flex items-center gap-1 text-[11px] font-medium text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",G={connectionId:((M=e.dataSource)==null?void 0:M.connectionId)||e.connectionId,dataSource:e.dataSource,config:e.conditions?{filters:e.conditions}:{},cardType:"text"},T=Yt(e.field),R=(ne=T.find(x=>x.value===e.get))==null?void 0:ne.hint,X=x=>{if(x===oa){f(!0);return;}const U=D.find(K=>K.id===x);if(!U)return;const j=Yt(U).some(K=>K.value===e.get)&&e.field!==void 0;v({field:U,get:j?e.get:Xt(U)});};return u?/* @__PURE__ */t(Ar,{inline:!0,open:!0,onOpenChange:f,availableFields:D,cardId:e.id,source:G,onSave:x=>{const U={...x,fieldScope:x.fieldScope??"card"};v({calculatedFields:[...(e.calculatedFields??[]).filter(j=>j.id!==U.id),U],field:U,get:Xt(U)}),f(!1);}}):/* @__PURE__ */r($,{children:[/* @__PURE__ */t(se,{label:"Name",aside:/* @__PURE__ */t(js,{value:e.name,placeholder:s,editing:m,onEditing:g,onChange:x=>v({name:x})}),hint:m?"The key: what you type after {{, and what links and agents use. Letters, digits and underscores.":void 0,children:/* @__PURE__ */t(xe,{size:"xs",value:e.label??"",onChange:x=>v({label:x.target.value}),placeholder:((ue=e.field)==null?void 0:ue.label)||"Latest order date","aria-label":"Variable name"})}),e.mode==="sql"?/* @__PURE__ */r($,{children:[/* @__PURE__ */r(se,{label:"Connection",children:[/* @__PURE__ */r(we,{value:e.connectionId??"",onValueChange:x=>v({connectionId:x}),children:[/* @__PURE__ */t(Se,{size:"xs","aria-label":"Connection",children:/* @__PURE__ */t(ke,{placeholder:"Choose a connection"})}),/* @__PURE__ */t(De,{children:h.map(x=>/* @__PURE__ */t(fe,{value:x.id,children:x.name},x.id))})]}),/* @__PURE__ */r("button",{type:"button",onClick:()=>v({mode:"data"}),className:A,children:[/* @__PURE__ */t(qt,{className:"h-3 w-3","aria-hidden":!0})," Use a dataset or table instead"]})]}),/* @__PURE__ */t(se,{label:"SQL",hint:/* @__PURE__ */t($,{children:"One row. Each column is a part; the first shows by default. Filters reach it where the SQL names them, as a SQL card's do."}),children:/* @__PURE__ */t(pa,{size:"xs",value:e.sql,onChange:x=>v({sql:x.target.value}),placeholder:"select max(order_date) as latest_order_date from orders",className:"min-h-[96px] font-mono","aria-label":"SQL"})}),/* @__PURE__ */t(se,{label:"Get",children:/* @__PURE__ */r(we,{value:e.get==="first"?"first":"only",onValueChange:x=>v({get:x}),children:[/* @__PURE__ */t(Se,{size:"xs","aria-label":"Get",children:/* @__PURE__ */t(ke,{})}),/* @__PURE__ */r(De,{children:[/* @__PURE__ */t(fe,{value:"only",children:"The only row"}),/* @__PURE__ */t(fe,{value:"first",children:"The first row"})]})]})})]}):/* @__PURE__ */r($,{children:[/* @__PURE__ */r(se,{label:"Source",children:[/* @__PURE__ */t(yt,{muted:!b,onClick:()=>d(!0),ariaLabel:"Source",children:b?/* @__PURE__ */r($,{children:[/* @__PURE__ */t(_,{className:"h-3.5 w-3.5 text-muted-foreground","aria-hidden":!0})," ",b]}):l?"Choose a dataset or table":"Choose a dataset"}),o?/* @__PURE__ */r("button",{type:"button",onClick:()=>{var x;return v({mode:"sql",connectionId:((x=e.dataSource)==null?void 0:x.connectionId)||e.connectionId});},className:A,children:[/* @__PURE__ */t(Yr,{className:"h-3 w-3","aria-hidden":!0})," Write SQL instead"]}):null]}),/* @__PURE__ */t(Fn,{open:c,onOpenChange:d,dataSource:e.dataSource??Os,incomingSelectedEntities:((he=e.dataSource)==null?void 0:he.selectedEntities)??[],onDataSourceChange:x=>{var j;const U=JSON.stringify(x.selectedEntities)===JSON.stringify((j=e.dataSource)==null?void 0:j.selectedEntities);v(U?{dataSource:x}:{dataSource:x,field:void 0,sortField:void 0,conditions:null,calculatedFields:void 0});}}),/* @__PURE__ */r("div",{className:"grid grid-cols-2 gap-3",children:[/* @__PURE__ */t(se,{label:"Field",children:b?/* @__PURE__ */r(we,{value:B,onValueChange:X,disabled:C&&!D.length,children:[/* @__PURE__ */t(Se,{size:"xs","aria-label":"Field",children:/* @__PURE__ */t(ke,{placeholder:C?"Loading fields…":S?"Fields unavailable":"Choose a field"})}),/* @__PURE__ */r(De,{children:[D.map(x=>/* @__PURE__ */t(fe,{value:x.id,children:/* @__PURE__ */r("span",{className:"flex items-center gap-2",children:[/* @__PURE__ */t("span",{children:x.label||x.name}),/* @__PURE__ */t("span",{className:"text-muted-foreground",children:Ms(x.dataType)})]})},x.id)),/* @__PURE__ */t(tr,{}),/* @__PURE__ */t(fe,{value:oa,children:/* @__PURE__ */r("span",{className:"flex items-center gap-1.5",children:[/* @__PURE__ */t(be,{className:"h-3 w-3","aria-hidden":!0})," New calculated field…"]})})]})]}):/* @__PURE__ */t(yt,{muted:!0,children:"Choose a source first"})}),/* @__PURE__ */t(se,{label:"Get",children:/* @__PURE__ */r(we,{value:e.get,onValueChange:x=>v({get:x}),disabled:!e.field,children:[/* @__PURE__ */t(Se,{size:"xs","aria-label":"Get",children:/* @__PURE__ */t(ke,{})}),/* @__PURE__ */t(De,{children:T.map(x=>/* @__PURE__ */t(fe,{value:x.value,children:x.label},x.value))})]})}),e.field&&R?/* @__PURE__ */t("p",{className:"col-span-2 -mt-1.5 text-[11px] leading-4 text-muted-foreground",children:R}):null,S?/* @__PURE__ */t("p",{className:"col-span-2 -mt-1.5 text-[11px] leading-4 text-destructive",children:S}):null,Ur(e)?/* @__PURE__ */t(se,{label:"Compare with",className:"col-span-2",children:/* @__PURE__ */t(En,{controlLabel:"Variable",selection:Ps(e),onChange:x=>v({comparison:_s(x)})})}):null,e.field&&!$r(e.get)&&e.get!=="only"?/* @__PURE__ */r("div",{className:J("col-span-2 grid gap-3",e.get==="list"?"grid-cols-3":"grid-cols-2"),children:[/* @__PURE__ */t(se,{label:"Order by",children:/* @__PURE__ */r(we,{value:`${k}|${e.sortDirection}`,onValueChange:x=>{const U=x.lastIndexOf("|"),j=x.slice(0,U),K=x.slice(U+1);v({sortField:D.find(oe=>oe.id===j),sortDirection:K});},children:[/* @__PURE__ */t(Se,{size:"xs","aria-label":"Order by",children:/* @__PURE__ */t(ke,{})}),/* @__PURE__ */t(De,{children:D.flatMap(x=>["asc","desc"].map(U=>/* @__PURE__ */r(fe,{value:`${x.id}|${U}`,children:[x.label||x.name,", ",$s(x,U)]},`${x.id}|${U}`)))})]})}),e.get==="list"?/* @__PURE__ */r($,{children:[/* @__PURE__ */t(se,{label:"Show up to",children:/* @__PURE__ */t(xe,{size:"xs",type:"number",min:1,max:st,value:e.listLimit??"",placeholder:"10",onChange:x=>{const U=Number.parseInt(x.target.value,10);v({listLimit:Number.isFinite(U)&&U>0?Math.min(U,st):void 0});},"aria-label":"Show up to"})}),/* @__PURE__ */t(se,{label:"Separator",children:/* @__PURE__ */t(xe,{size:"xs",value:e.listSeparator??", ",maxLength:fr,onChange:x=>v({listSeparator:x.target.value}),className:"font-mono","aria-label":"Separator"})})]}):null]}):null]}),/* @__PURE__ */t(se,{label:"Filters",children:b?/* @__PURE__ */t(Fr,{filters:e.conditions??null,availableFields:D,source:G,onChange:x=>v({conditions:x})},JSON.stringify(((ve=e.dataSource)==null?void 0:ve.selectedEntities)??null)):/* @__PURE__ */t(yt,{muted:!0,children:"Choose a source first"})})]})]});}function Us(e,a){return e.name===a.name&&(e.qualifiedEntityName??e.entityName??"")===(a.qualifiedEntityName??a.entityName??"");}function $s(e,a){const s=zt(e.dataType);return s==="date"?a==="asc"?"earliest first":"latest first":s==="number"?a==="asc"?"lowest first":"highest first":a==="asc"?"A to Z":"Z to A";}function js({value:e,placeholder:a,editing:s,onEditing:n,onChange:i}){return s?/* @__PURE__ */t(xe,{size:"xs",autoFocus:!0,value:e,placeholder:a,onChange:o=>i(o.target.value),onBlur:()=>n(!1),onKeyDown:o=>{(o.key==="Enter"||o.key==="Escape")&&(o.preventDefault(),o.stopPropagation(),n(!1));},className:"h-6 w-44 font-mono text-[11px]","aria-label":"Key"}):/* @__PURE__ */r("button",{type:"button",onClick:()=>n(!0),"aria-label":"Edit key",title:"The key: what you type after {{, and what links and agents use",className:"inline-flex h-5 items-center gap-1 rounded-[4px] px-1 font-mono text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[`{{${e.trim()||a}}}`,/* @__PURE__ */t(Bt,{className:"h-3 w-3","aria-hidden":!0})]});}const qs=[{id:"data",label:"Data"},{id:"filters",label:"Dashboard filters"},{id:"display",label:"Display"}];function Ws(e){const{name:a,label:s,presentation:n,emptyText:i,...o}=e;return JSON.stringify(o);}function Qs({variable:e,onClose:a,onHoldEscape:s}){var Z,H;const n=w(I=>I.dashboard),i=w(I=>I.selectedSheetId),o=w(I=>I.actions.saveVariableChange),[l,h]=E(()=>e?jr(e):qr()),[c,d]=E("data"),[u,p]=E(!1),m=I=>{p(I),s==null||s(I);},[g,f]=E([]),[y,C]=E(null),S=!e,V=Ws(l),P=Y(()=>Jt({...JSON.parse(V),name:""},n),[V,n]),{name:D,label:B,presentation:k,emptyText:v}=l,b=Y(()=>({...P,name:Zt(n,{id:P.id,name:D,field:l.field,mode:l.mode,label:B}),...(B!=null&&B.trim()?{label:B.trim()}:{}),...(k?{presentation:k}:{}),...(v!=null&&v.trim()?{emptyText:v}:{})}),[P,n,D,B,k,v,l.field,l.mode]),_=Y(()=>({...n,variables:[...(n.variables??[]).filter(I=>I.id!==b.id),b]}),[n,b]),A=Wr(l),G=dt(),T=w(I=>I.actions.mergeSemanticExecutionPayload),[R,X]=E(!1),O=async()=>{const I=Jt(l,n);X(!0);let ae;try{const M=Nr(n,e?{kind:"update",id:e.id,patch:I}:{kind:"add",variable:I});if(!M.ok){X(!1),f(M.issues);return;}const[ne]=M.queryFrames;ae=ne?await G(ne,e?{previousFrame:Cr(n,e)}:void 0):{domainsById:{}};}catch(M){X(!1),f([{code:"queryMissing",message:M instanceof Error&&M.message?M.message:"The data source's details could not be loaded.",fix:"Try again, or choose the source again."}]);return;}const q=o(S?{kind:"add",variable:I}:{kind:"update",id:I.id,patch:Ks(I)});if(X(!1),!q.ok){f(q.issues);return;}T(ae),a();},te=I=>{if(!e)return;const ae=o({kind:"remove",id:e.id,confirmed:I});if(!ae.ok){const q=ae.issues.find(M=>M.code==="inUse");if(q&&!I){C(q);return;}f(ae.issues);return;}a();};return/* @__PURE__ */r("div",{className:"flex h-[600px] max-h-[85vh] w-[600px] max-w-[calc(100vw-24px)] flex-col overflow-hidden","data-testid":"variable-editor",children:[/* @__PURE__ */r("div",{className:"flex min-h-12 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-1.5",children:[/* @__PURE__ */r("div",{className:"flex min-w-0 items-start gap-2",children:[/* @__PURE__ */t(Nt,{className:"mt-1 h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),/* @__PURE__ */r("div",{className:"min-w-0",children:[/* @__PURE__ */r("p",{className:"flex items-center gap-2",children:[/* @__PURE__ */t("span",{className:"truncate text-[13px] font-medium text-foreground",children:S?"New variable":e.label||e.name}),/* @__PURE__ */t("span",{className:Ut,children:"Variable from data"})]}),/* @__PURE__ */t("p",{className:"mt-0.5 truncate text-[10px] leading-3 text-muted-foreground/70",children:"Available on every tab and Document of this dashboard"})]})]}),/* @__PURE__ */t("button",{type:"button",onClick:a,"aria-label":"Close",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",children:/* @__PURE__ */t(Qe,{className:"h-3.5 w-3.5","aria-hidden":!0})})]}),u?null:/* @__PURE__ */t("nav",{role:"tablist","aria-label":"Variable settings sections",className:"flex h-9 shrink-0 items-stretch gap-4 border-b border-border/60 px-4",children:qs.map(I=>/* @__PURE__ */r("button",{role:"tab","aria-selected":c===I.id,onClick:()=>d(I.id),className:J("relative -mb-px inline-flex items-center text-[13px] transition-colors focus-visible:outline-none",c===I.id?"font-medium text-foreground":"text-muted-foreground hover:text-foreground"),children:[I.label,c===I.id?/* @__PURE__ */t("span",{className:"absolute inset-x-0 -bottom-px h-[2px] bg-foreground"}):null]},I.id))}),/* @__PURE__ */r("div",{className:J("min-h-0 flex-1 overflow-y-auto",c==="filters"||u?"":"space-y-4 px-4 py-4"),children:[c==="data"?/* @__PURE__ */t(Rs,{draft:l,onChange:h,handle:Zt(n,l),onCalculatedFieldOpenChange:m}):null,c==="filters"?/* @__PURE__ */t(Hs,{draft:l,draftDashboard:_}):null,c==="display"?/* @__PURE__ */t(Xs,{draft:l,onChange:h}):null]}),u?null:/* @__PURE__ */r($,{children:[/* @__PURE__ */t(Js,{draft:l,draftVariable:b,draftDashboard:_,blocker:A,selectedSheetId:i??void 0}),g.length?/* @__PURE__ */t("div",{className:"shrink-0 border-t border-border/60 bg-destructive/5 px-4 py-2 text-[11px] leading-4 text-destructive",role:"alert",children:g.map(I=>/* @__PURE__ */r("p",{children:[I.message," ",I.fix]},`${I.code}:${I.path??""}`))}):null,y?/* @__PURE__ */r("div",{className:"shrink-0 border-t border-border/60 bg-amber-500/10 px-4 py-2 text-[11px] leading-4 text-amber-800 dark:text-amber-300",role:"alertdialog",children:[/* @__PURE__ */r("p",{children:[y.message," Used in ",((Z=y.places)==null?void 0:Z.length)??0," ",((H=y.places)==null?void 0:H.length)===1?"place":"places",". Its chips then read as missing."]}),/* @__PURE__ */r("div",{className:"mt-1.5 flex gap-1.5",children:[/* @__PURE__ */t(L,{variant:"outline",size:"xs",className:"h-6 px-2 text-[11px]",onClick:()=>C(null),children:"Keep it"}),/* @__PURE__ */t(L,{size:"xs",className:"h-6 px-2 text-[11px]",onClick:()=>te(!0),children:"Remove anyway"})]})]}):null,/* @__PURE__ */r("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border/60 px-4 py-2.5",children:[S?/* @__PURE__ */t("span",{}):/* @__PURE__ */t(L,{variant:"outline",size:"xs",className:"text-destructive hover:border-destructive/40 hover:bg-destructive/10 hover:text-destructive",onClick:()=>te(!1),children:"Delete"}),/* @__PURE__ */r("span",{className:"flex items-center gap-1.5",children:[/* @__PURE__ */t(L,{variant:"outline",size:"xs",onClick:a,children:"Cancel"}),/* @__PURE__ */t(L,{size:"xs",disabled:!!A||R,title:A,onClick:()=>void O(),children:S?"Create":"Done"})]})]})]})]});}function Ks(e){const{id:a,...s}=e;return{...s,label:s.label,presentation:s.presentation,emptyText:s.emptyText};}function Hs({draft:e,draftDashboard:a}){const s=Y(()=>br(a),[a]),n=s.inputs.filter(o=>s.reachedVariables({inputId:o.input.id}).some(l=>l.variableId===e.id)),i=e.mode==="sql"&&xr(e.sql);return n.length?/* @__PURE__ */r("div",{className:"divide-y divide-border/60",children:[/* @__PURE__ */t("p",{className:"px-4 py-2 text-[11px] leading-4 text-muted-foreground",children:"How each filter applies here. Change a mapping on the filter's Cards tab, under Variables."}),n.map(o=>{var c;const l=(c=o.input.application)==null?void 0:c.cards.find(d=>d.cardId===e.id),h=i?"Subscribes in SQL":e.mode==="sql"?"Not named in the SQL":(l==null?void 0:l.kind)==="excluded"?"Don't apply":(l==null?void 0:l.kind)==="bound"?`${l.target.kind==="field"?"Field":"Path"} · ${l.target.field.name}`:"Auto";return/* @__PURE__ */r("div",{className:"flex items-center justify-between gap-3 px-4 py-2 text-[12px]",children:[/* @__PURE__ */r("span",{className:"min-w-0",children:[/* @__PURE__ */t("span",{className:"block truncate font-medium text-foreground",children:o.input.label||o.input.filter.title}),/* @__PURE__ */t("span",{className:"block truncate text-[11px] text-muted-foreground",children:Gs(o.input.scope)})]}),/* @__PURE__ */t("span",{className:J("shrink-0 text-[11px]",h==="Don't apply"||h==="Not named in the SQL"?"text-muted-foreground":"text-foreground"),children:h})]},o.input.id);})]}):/* @__PURE__ */t("p",{className:"px-4 py-6 text-center text-[12px] text-muted-foreground",children:"No filter reaches this variable. A filter on the tabs or Documents where it is used reaches it; a variable used nowhere yet follows every tab's filters."});}function Gs(e){switch(e.kind){case"allSheets":return"On every tab";case"sheets":return"On chosen tabs";case"cards":return"On chosen cards and variables";default:return e.kind;}}const Ys=[{value:"auto",label:"Automatic"},{value:"short",label:"Short"},{value:"medium",label:"Medium"},{value:"long",label:"Long"},{value:"pattern",label:"Custom pattern…"}];function Xs({draft:e,onChange:a}){var h,c;const s=e.mode==="sql"?"unknown":zt((h=e.field)==null?void 0:h.dataType),n=(c=e.presentation)==null?void 0:c.temporal,i=n?n.mode==="style"?n.dateStyle:n.mode==="pattern"?"pattern":"auto":"auto",o=(n==null?void 0:n.mode)==="pattern"?Ir(n.pattern):null,l=d=>a({...e,presentation:d&&Object.keys(d).length?d:void 0});return/* @__PURE__ */r($,{children:[s==="date"||s==="unknown"?/* @__PURE__ */r(se,{label:"Dates read as",hint:"A chip can change this for itself.",children:[/* @__PURE__ */r("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */r(we,{value:i,onValueChange:d=>l({...e.presentation,temporal:d==="auto"?void 0:d==="pattern"?{mode:"pattern",dialect:"semaphor_tokens",pattern:(n==null?void 0:n.mode)==="pattern"?n.pattern:"MMM D, YYYY"}:{mode:"style",dateStyle:d}}),children:[/* @__PURE__ */t(Se,{size:"xs",className:"w-44","aria-label":"Date style",children:/* @__PURE__ */t(ke,{})}),/* @__PURE__ */t(De,{children:Ys.map(d=>/* @__PURE__ */t(fe,{value:d.value,children:d.label},d.value))})]}),(n==null?void 0:n.mode)==="pattern"?/* @__PURE__ */t(xe,{size:"xs",value:n.pattern,onChange:d=>l({...e.presentation,temporal:{mode:"pattern",dialect:"semaphor_tokens",pattern:d.target.value}}),className:"w-40 font-mono","aria-label":"Date pattern"}):null]}),o?/* @__PURE__ */t("p",{className:"mt-1 text-[11px] text-destructive",children:o}):null]}):null,s==="number"||s==="unknown"?/* @__PURE__ */t(se,{label:"Numbers read as",hint:"A chip can change any of these for itself.",children:/* @__PURE__ */t(In,{value:e.presentation,onChange:l})}):null,/* @__PURE__ */t(se,{label:"When there’s no value",hint:"Readers see this when nothing matches or more than one does. Leave it empty to show nothing.",children:/* @__PURE__ */t(xe,{size:"xs",value:e.emptyText??"",maxLength:vr,onChange:d=>a({...e,emptyText:d.target.value||void 0}),placeholder:"Show nothing",className:"w-72","aria-label":"Empty text"})})]});}function Js({draft:e,draftVariable:a,draftDashboard:s,blocker:n,selectedSheetId:i}){var v;const o=s.sheets??[],l=Y(()=>Is(s,a.id),[s,a.id]),[h,c]=E(void 0),d=(l?h:void 0)??i??((v=o[0])==null?void 0:v.id),u=o.find(b=>b.id===d),p=w(b=>d?b.documentSectionRuntimeBySheetId[d]:void 0),m=!!(u&&Ke(u)),g=Y(()=>d?m?p?{kind:"document",sheetId:d,runtime:p}:void 0:{kind:"sheet",sheetId:d}:void 0,[m,p,d]),f=Y(()=>n||!g?[]:[a],[n,a,g]),C=Tn({dashboard:s,place:g??{kind:"sheet",sheetId:d??""},purpose:"preview",variables:f}).byId.get(a.id),S=Ln(),V=Vn(),P=Y(()=>yr({preferences:S,calendar:V}),[V,S]);let D,B="",k=null;if(n)D=/* @__PURE__ */t("span",{className:"text-muted-foreground",children:e.mode==="sql"?"Write the SQL to see a value.":"Choose a source and a field to see a value."});else if(!g)D=/* @__PURE__ */t("span",{className:"text-muted-foreground",children:"Open this Document to preview here."});else if(!C||C.status==="loading")D=/* @__PURE__ */t("span",{className:"text-muted-foreground",children:"Loading…"});else{const b=Zs(a,C,P);if(D=b.body,B=b.meta,b.unavailable){const _=(u==null?void 0:u.title)||"this tab";k=/* @__PURE__ */r("p",{className:"mt-1.5 flex gap-1.5 text-[11px] leading-4 text-amber-700 dark:text-amber-400",children:[/* @__PURE__ */t(ya,{className:"mt-px h-3 w-3 shrink-0","aria-hidden":!0}),/* @__PURE__ */r("span",{children:["No change on ",_,". ",Bn(b.unavailable,"variable")]})]});}}return/* @__PURE__ */r("div",{className:"shrink-0 border-t border-border/60 bg-muted/30 px-4 py-2.5","data-testid":"variable-preview",children:[/* @__PURE__ */r("div",{className:"flex items-center gap-3",children:[/* @__PURE__ */t("span",{className:Ut,children:l?"Preview on":"Preview"}),l?/* @__PURE__ */r(we,{value:d??"",onValueChange:c,disabled:!!n,children:[/* @__PURE__ */t(Se,{size:"xs",className:"h-6 w-auto gap-1.5 px-2 text-[12px]","aria-label":"Preview place",children:/* @__PURE__ */t(ke,{})}),/* @__PURE__ */t(De,{children:o.map(b=>/* @__PURE__ */t(fe,{value:b.id,children:b.title||b.id},b.id))})]}):null,/* @__PURE__ */t("div",{className:"min-w-0 flex-1 truncate text-right text-[13px]",children:D})]}),B?/* @__PURE__ */t("p",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:B}):null,k]});}function Zs(e,a,s){const n=u=>/* @__PURE__ */t("span",{className:"font-medium text-foreground",children:u}),i=u=>/* @__PURE__ */r("span",{className:"inline-flex items-center gap-1.5 text-[12px] text-amber-700 dark:text-amber-400",children:[/* @__PURE__ */t(ya,{className:"h-3.5 w-3.5","aria-hidden":!0})," ",u]}),o=u=>u===void 0?"":u==="beyondCap"?`more than ${st} match`:`${u} ${u===1?"match":"matches"}`,l="filterReach"in a?a.filterReach:[],h=l.filter(u=>u.status==="applied").length,c=l.length-h,d=l.length?` · ${h} ${h===1?"filter":"filters"} applied${c?`, ${c} skipped`:""}`:"";switch(a.status){case"answered":{const u=Br(e,Object.keys(a.parts))[0],p=u?a.parts[u]:void 0,m=p&&Ht(p,e.presentation,s)||"(empty)",g=`${o(a.matched)}${d}`.replace(/^ · /,""),f=wr(e,a,s);return f&&typeof f=="object"&&"unavailable"in f?{body:n(m),meta:g,unavailable:f.unavailable}:f==="noPrevious"?{body:n(m),meta:`${g} · Nothing in the period before to compare with.`.replace(/^ · /,"")}:f?{body:/* @__PURE__ */r($,{children:[n(f.value),/* @__PURE__ */r("span",{className:"text-muted-foreground",children:[" · was ",f.previous," · "]}),n(f.change)]}),meta:g}:{body:n(m),meta:g};}case"listed":{const u=a.items.map(m=>Ht(m,e.presentation,s)),p=a.more==="beyondCap"?" and more":a.more?` and ${a.more} more`:"";return{body:n(`${u.join(e.get.kind==="list"?e.get.separator??", ":", ")}${p}`),meta:`${o(a.matched)}${d}`};}case"none":return a.why==="moreThanOne"?{body:i(`More than one matches${a.matched!==void 0?` (${a.matched==="beyondCap"?`${st}+`:a.matched})`:""}. Readers see nothing.`),meta:"Keep a selection on a filter, add a condition, or choose First or List."}:{body:/* @__PURE__ */t("span",{className:"text-muted-foreground",children:"No rows match."}),meta:d.slice(3)};case"held":return{body:/* @__PURE__ */r("span",{className:"text-muted-foreground",children:["Waiting for ",a.missingRequired.join(", "),"."]}),meta:"A required filter has no value here."};case"broken":return{body:i("The query no longer compiles against its mapping."),meta:""};case"failed":return{body:i("The query failed."),meta:a.message};default:return{body:null,meta:""};}}function no(){const e=w(l=>l.variableEditor),a=w(l=>l.dashboard.variables),s=w(l=>l.actions.closeVariableEditor),n=et(!1),i=(e==null?void 0:e.kind)==="edit"?a==null?void 0:a.find(l=>l.id===e.variableId):void 0;return!(e&&(e.kind==="new"||i))?null:/* @__PURE__ */r(Te,{modal:!1,open:!0,onOpenChange:l=>!l&&s(),children:[/* @__PURE__ */t("div",{className:"pointer-events-none fixed inset-0 z-40 bg-zinc-950/40 backdrop-blur-sm"}),/* @__PURE__ */r(Le,{className:"w-auto max-w-none gap-0 overflow-hidden p-0 [&>button:last-child]:hidden",onInteractOutside:l=>l.preventDefault(),onEscapeKeyDown:l=>{n.current?l.preventDefault():s();},children:[/* @__PURE__ */t(Ve,{className:"sr-only",children:"Variable from data"}),/* @__PURE__ */t(ct,{className:"sr-only",children:"Define a value from your data to show in text."}),/* @__PURE__ */t(Qs,{variable:i,onClose:s,onHoldEscape:l=>{n.current=l;}},(e==null?void 0:e.kind)==="edit"?e.variableId:"new")]})]});}function ei({disabled:e,briefingCount:a,className:s,onClick:n}){const i=typeof a=="number"&&a>0;return/* @__PURE__ */r(L,{type:"button",size:"xs",variant:"outline",disabled:e,className:J("gap-1.5",s),onClick:n,"aria-label":"Reports & briefings",children:[/* @__PURE__ */t(Gr,{className:"h-3.5 w-3.5"}),"Reports & briefings",i?/* @__PURE__ */t("span",{className:"ml-0.5 rounded-control bg-muted px-1 text-[10px] tabular-nums text-foreground/70",children:a}):null]});}const ti="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",Ia="inline-flex h-7 items-center gap-1.5 rounded-control px-2 text-[12px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50",Ze="inline-flex h-7 items-center gap-1.5 rounded-control bg-primary px-3 text-[12px] font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50";function ai(e){return e==="dashboard"?"This dashboard":"Project";}function ni(e){if(!e)return"Never";const a=new Date(e);if(Number.isNaN(a.getTime()))return"Unknown";const s=Date.now()-a.getTime(),n=Math.round(s/6e4);if(n<1)return"now";if(n<60)return`${n}m ago`;const i=Math.round(n/60);if(i<24)return`${i}h ago`;const o=Math.round(i/24);if(o<7)return`${o}d ago`;const l=Math.round(o/7);return l<5?`${l}w ago`:`${Math.round(o/30)}mo ago`;}function ri(e){return e.scheduleExpr?_r(e.scheduleExpr,e.timezone||"UTC")??"Invalid schedule":"On demand";}function si(e){if(e.lastRunStatus){const a=e.lastRunStatus.toString().toUpperCase();return a==="SUCCESS"?"Last run completed.":a==="FAILED"?"Last run failed.":`Last run ${e.lastRunStatus.toString().toLowerCase()}`;}return null;}function Ta(e){return e.hasActiveRun?"Running":e.lastRunStatus?`Last run ${e.lastRunStatus.toString().toLowerCase()}`:"Idle";}function ii(e){return e.source.type==="dashboard"?"This dashboard":"Project";}function oi({activeView:e,onChange:a}){return/* @__PURE__ */t("div",{className:"flex shrink-0 items-center gap-1 rounded-control bg-muted p-0.5",role:"tablist","aria-label":"Briefing source view",children:["dashboard","project"].map(s=>{const n=e===s;return/* @__PURE__ */t("button",{type:"button",role:"tab","aria-selected":n,onClick:()=>a(s),className:J("h-6 rounded-[3px] px-2 text-[11px] transition-colors",n?"bg-background font-medium text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:ai(s)},s);})});}function li({briefings:e,dashboardLabel:a,sourceView:s,error:n,loading:i,onSourceViewChange:o,onClose:l,onEdit:h,onNew:c,canCreate:d,canCreateScheduledReport:u,analyticalBriefingsEnabled:p,onRunNow:m,onTogglePause:g,onDelete:f,selectingId:y,busyId:C,manageBriefingsHref:S,contentKind:V,hideHeader:P=!1}){const D=e.length,B=e.filter(A=>A.status==="ACTIVE").length,k=V==="reports"?D===1?"report":"reports":V==="briefings"?D===1?"briefing":"briefings":D===1?"item":"items",v=e.find(A=>A.hasActiveRun)??null,b=V??"reports & briefings",_=s==="dashboard"?a:`Project ${b}`;return/* @__PURE__ */r("section",{"aria-label":`Dashboard ${b.replace("&","and")}`,className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:[P?null:/* @__PURE__ */r("header",{className:"flex items-start justify-between gap-3 border-b border-border px-4 py-3",children:[/* @__PURE__ */r("div",{className:"min-w-0",children:[/* @__PURE__ */t("div",{className:ti,children:b}),/* @__PURE__ */t("h2",{className:"mt-0.5 truncate text-[14px] font-semibold leading-5",children:_})]}),/* @__PURE__ */t("button",{type:"button",onClick:l,className:"rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":`Close ${b.replace("&","and")} panel`,children:/* @__PURE__ */t(Qe,{className:"h-3.5 w-3.5"})})]}),/* @__PURE__ */r("div",{className:"flex items-center justify-between gap-3 border-b border-border px-4 py-2",children:[/* @__PURE__ */r("div",{className:"flex min-w-0 items-center gap-3",children:[/* @__PURE__ */t(oi,{activeView:s,onChange:o}),/* @__PURE__ */t("div",{className:"flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:i&&D===0?/* @__PURE__ */r("span",{children:["Loading ",b,"…"]}):D===0?/* @__PURE__ */r("span",{children:["No ",b," yet"]}):/* @__PURE__ */r($,{children:[/* @__PURE__ */r("span",{className:"font-medium text-foreground/80",children:[D," ",k]}),/* @__PURE__ */t("span",{className:"text-border",children:"·"}),/* @__PURE__ */r("span",{children:[B," active"]})]})})]}),/* @__PURE__ */r("div",{className:"flex items-center gap-1.5",children:[i?/* @__PURE__ */t(de,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}):null,D>0&&d?p&&u?/* @__PURE__ */r(je,{children:[/* @__PURE__ */t(qe,{asChild:!0,children:/* @__PURE__ */r("button",{className:Ze,children:[/* @__PURE__ */t(be,{className:"h-3 w-3"})," New"]})}),/* @__PURE__ */r(We,{align:"end",children:[/* @__PURE__ */t(re,{onClick:()=>c("scheduled_report"),children:"Schedule a report"}),/* @__PURE__ */t(re,{onClick:()=>c("analytical_briefing"),children:"Create analytical briefing"})]})]}):u?/* @__PURE__ */r("button",{onClick:()=>c("scheduled_report"),className:Ze,children:[/* @__PURE__ */t(be,{className:"h-3 w-3"})," Schedule report"]}):p?/* @__PURE__ */r("button",{onClick:()=>c("analytical_briefing"),className:Ze,children:[/* @__PURE__ */t(be,{className:"h-3 w-3"})," New briefing"]}):null:null]})]}),v?/* @__PURE__ */r("div",{className:"flex items-center gap-2 border-b border-border bg-muted/60 px-4 py-2 text-[12px]",children:[/* @__PURE__ */t(de,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}),/* @__PURE__ */t("span",{className:"font-medium text-foreground",children:v.name}),/* @__PURE__ */t("span",{className:"text-border",children:"·"}),/* @__PURE__ */t("span",{className:"truncate text-muted-foreground",children:Ta(v)})]}):null,/* @__PURE__ */r("div",{className:"flex-1 overflow-y-auto",children:[n?/* @__PURE__ */t("div",{className:"m-4 rounded-card border border-destructive/30 bg-destructive/10 px-3 py-2 text-[12px] text-destructive",children:n}):null,!i&&e.length===0&&!n?/* @__PURE__ */t(di,{onNew:c,canCreate:d,canCreateScheduledReport:u,analyticalBriefingsEnabled:p,contentKind:V}):null,e.map(A=>/* @__PURE__ */t(ui,{briefing:A,isOpening:y===A.id,isBusy:C===A.id,onOpen:()=>h(A.id),onRunNow:()=>m(A),onTogglePause:()=>g(A),onDelete:()=>f(A)},A.id))]}),S?/* @__PURE__ */t("div",{className:"border-t border-border px-4 py-2.5",children:/* @__PURE__ */r("a",{href:S,className:J(Ia,"h-6 px-1 text-[11px]"),children:["Manage all reports & briefings",/* @__PURE__ */t(Qr,{className:"h-3 w-3"})]})}):null]});}function di({onNew:e,canCreate:a,canCreateScheduledReport:s,analyticalBriefingsEnabled:n,contentKind:i}){const o=i==="reports"?{title:"No reports yet",description:"Schedule an emailed dashboard or visual report to see it here."}:i==="briefings"?{title:"No briefings yet",description:"Create an analytical briefing to monitor this dashboard and brief your team."}:null;return/* @__PURE__ */r("div",{className:"flex h-full flex-col items-center justify-center px-8 py-12 text-center",children:[/* @__PURE__ */t(ci,{className:"mb-5 h-[88px] w-[112px] text-border"}),/* @__PURE__ */t("div",{className:"text-[13px] font-medium text-foreground",children:(o==null?void 0:o.title)??"Have an analyst brief your team"}),/* @__PURE__ */t("p",{className:"mt-1.5 max-w-[320px] text-[12px] leading-5 text-muted-foreground",children:(o==null?void 0:o.description)??"Describe what to watch. An analyst digs into this dashboard and the data behind it, then briefs your team on the cadence you choose."}),a?/* @__PURE__ */r("div",{className:"mt-4 flex flex-wrap justify-center gap-2",children:[s?/* @__PURE__ */r("button",{onClick:()=>e("scheduled_report"),className:Ze,children:[/* @__PURE__ */t(be,{className:"h-3 w-3"})," Schedule a report"]}):null,n?/* @__PURE__ */t("button",{onClick:()=>e("analytical_briefing"),className:Ia,children:"Create analytical briefing"}):null]}):null]});}function ci({className:e}){return/* @__PURE__ */r("svg",{viewBox:"0 0 112 88",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"presentation","aria-hidden":"true",className:e,children:[/* @__PURE__ */t("rect",{x:"22",y:"6",width:"60",height:"72",rx:"3",stroke:"currentColor",strokeWidth:"1.25"}),/* @__PURE__ */t("line",{x1:"30",y1:"16",x2:"64",y2:"16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),/* @__PURE__ */t("line",{x1:"30",y1:"21",x2:"52",y2:"21",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",opacity:"0.5"}),/* @__PURE__ */t("circle",{cx:"31",cy:"32",r:"1",fill:"currentColor",opacity:"0.6"}),/* @__PURE__ */t("line",{x1:"35",y1:"32",x2:"72",y2:"32",stroke:"currentColor",strokeWidth:"1",opacity:"0.4",strokeLinecap:"round"}),/* @__PURE__ */t("circle",{cx:"31",cy:"38",r:"1",fill:"currentColor",opacity:"0.6"}),/* @__PURE__ */t("line",{x1:"35",y1:"38",x2:"68",y2:"38",stroke:"currentColor",strokeWidth:"1",opacity:"0.4",strokeLinecap:"round"}),/* @__PURE__ */t("circle",{cx:"31",cy:"44",r:"1",fill:"currentColor",opacity:"0.6"}),/* @__PURE__ */t("line",{x1:"35",y1:"44",x2:"74",y2:"44",stroke:"currentColor",strokeWidth:"1",opacity:"0.4",strokeLinecap:"round"}),/* @__PURE__ */t("rect",{x:"30",y:"64",width:"5",height:"8",rx:"0.5",fill:"currentColor",opacity:"0.55"}),/* @__PURE__ */t("rect",{x:"38",y:"60",width:"5",height:"12",rx:"0.5",fill:"currentColor",opacity:"0.7"}),/* @__PURE__ */t("rect",{x:"46",y:"56",width:"5",height:"16",rx:"0.5",fill:"currentColor",opacity:"0.85"}),/* @__PURE__ */t("rect",{x:"54",y:"62",width:"5",height:"10",rx:"0.5",fill:"currentColor",opacity:"0.6"}),/* @__PURE__ */t("rect",{x:"62",y:"58",width:"5",height:"14",rx:"0.5",fill:"currentColor",opacity:"0.75"}),/* @__PURE__ */t("circle",{cx:"86",cy:"62",r:"10",className:"fill-background",stroke:"currentColor",strokeWidth:"1.25"}),/* @__PURE__ */t("line",{x1:"93.5",y1:"69.5",x2:"100",y2:"76",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]});}function ui({briefing:e,isOpening:a,isBusy:s,onOpen:n,onRunNow:i,onTogglePause:o,onDelete:l}){const h=e.status==="PAUSED",c=e.hasActiveRun,d=si(e),u=ni(e.lastRunAt),p=e.lastRunStatus,m=pe(e),g=p==="SUCCESS"?Xe.success.dot:p==="FAILED"?Xe.danger.dot:p?Xe.warning.dot:Xe.neutral.dot;return/* @__PURE__ */r("div",{className:J("group relative border-b border-border/60 px-4 py-3 transition-colors hover:bg-muted/60",h&&"opacity-70"),children:[/* @__PURE__ */r("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),n());},className:"cursor-pointer pr-8",children:[/* @__PURE__ */r("div",{className:"flex min-w-0 items-center gap-2",children:[/* @__PURE__ */t("span",{className:"truncate text-[13px] font-medium text-foreground",children:e.name}),h?/* @__PURE__ */t("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:"· Paused"}):null]}),/* @__PURE__ */r("div",{className:"mt-1 flex flex-wrap items-center gap-x-1.5 text-[11px] text-muted-foreground",children:[/* @__PURE__ */t("span",{children:m.typeLabel}),/* @__PURE__ */t("span",{className:"text-border",children:"·"}),/* @__PURE__ */t("span",{children:ii(e)}),/* @__PURE__ */t("span",{className:"text-border",children:"·"}),/* @__PURE__ */t(Pn,{className:"h-3 w-3"}),/* @__PURE__ */t("span",{className:"truncate",children:ri(e)}),e.lastRunAt?/* @__PURE__ */r($,{children:[/* @__PURE__ */t("span",{className:"text-border",children:"·"}),/* @__PURE__ */r("span",{children:["Last run ",u]})]}):null]}),d||c?/* @__PURE__ */r("div",{className:"mt-1.5 flex items-center gap-1.5 text-[12px] leading-[1.5] text-foreground/80",children:[c?/* @__PURE__ */t(de,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground/70"}):/* @__PURE__ */t("span",{className:J("inline-block h-1.5 w-1.5 shrink-0 rounded-full",g)}),/* @__PURE__ */t("span",{className:"truncate",children:c?Ta(e):d})]}):null]}),/* @__PURE__ */t("div",{className:"absolute right-3 top-3",children:s?/* @__PURE__ */t(de,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground/70"}):a?/* @__PURE__ */t(de,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground/70"}):/* @__PURE__ */r(je,{children:[/* @__PURE__ */t(qe,{asChild:!0,children:/* @__PURE__ */t("button",{type:"button",onClick:f=>f.stopPropagation(),className:"inline-flex h-6 w-6 items-center justify-center rounded-control text-muted-foreground/70 opacity-60 hover:bg-muted hover:text-foreground/80 focus-visible:opacity-100 group-hover:opacity-100","aria-label":`${m.noun==="report"?"Report":"Briefing"} actions`,children:/* @__PURE__ */t(ha,{className:"h-3.5 w-3.5"})})}),/* @__PURE__ */r(We,{align:"end",className:"w-44",children:[/* @__PURE__ */r(re,{onClick:n,children:[/* @__PURE__ */t(Bt,{className:"h-3.5 w-3.5"}),"Edit ",m.noun]}),/* @__PURE__ */r(re,{onClick:f=>{f.preventDefault(),i();},children:[/* @__PURE__ */t(_n,{className:"h-3.5 w-3.5"}),"Run now"]}),e.scheduleExpr?/* @__PURE__ */t(re,{onClick:f=>{f.preventDefault(),o();},children:h?/* @__PURE__ */r($,{children:[/* @__PURE__ */t(On,{className:"h-3.5 w-3.5"}),"Resume"]}):/* @__PURE__ */r($,{children:[/* @__PURE__ */t(zn,{className:"h-3.5 w-3.5"}),"Pause"]})}):null,/* @__PURE__ */t(at,{}),/* @__PURE__ */r(re,{onClick:f=>{f.preventDefault(),l();},className:"text-destructive focus:bg-destructive/10 focus:text-destructive",children:[/* @__PURE__ */t(tt,{className:"h-3.5 w-3.5"}),"Delete ",m.noun]})]})]})})]});}function hi(e){return(e==null?void 0:e.trim())||"This dashboard";}function mi(e){return e==="This dashboard"?"Watch this dashboard":`Watch ${e}`;}function pi(e,a,s){return a!=="dashboard"?e:e.filter(n=>n.source.type==="dashboard"&&n.source.dashboardId===s);}async function fi(e){const s=[];let n=1,i=0,o=Number.POSITIVE_INFINITY;for(;i<o;){const l=await e.apiClient.listBriefings(e.apiServiceUrl,e.token,{scope:"organization",page:n,pageSize:100});if(s.push(...l.briefings),i+=l.briefings.length,o=l.total,l.briefings.length===0||i>=o)break;n+=1;}return s;}const gi={listBriefings:Kn,getBriefing:Qn,pauseBriefing:Wn,resumeBriefing:qn,deleteBriefing:jn,runBriefingNow:$n};function ro(e){return/* @__PURE__ */t(Mn,{authToken:e.token?{accessToken:e.token}:void 0,children:/* @__PURE__ */t(Rn,{children:/* @__PURE__ */t(bi,{...e})})});}function bi({dashboardId:e,dashboardTitle:a,apiServiceUrl:s,token:n,disabled:i,className:o,manageBriefingsHref:l,open:h,onOpenChange:c,hideTrigger:d=!1,workflowIntent:u,openRun:p,client:m}){const{authToken:g,tokenProps:f}=$e(),y=Un(),C=!u||y.canCreate&&(u==="scheduled_report"||y.analyticalBriefingsEnabled),[S,V]=E(!1),P=h??S,D=F=>{h===void 0&&V(F),c==null||c(F);},[B,k]=E(u?"author":"list"),[v,b]=E(u??"analytical_briefing"),[_,A]=E("dashboard"),[G,T]=E([]),[R,X]=E(null),O=u&&!C&&!R?"list":B,[te,Z]=E(!1),[H,I]=E(null),[ae,q]=E(null),[M,ne]=E(null),[ue,he]=E(null),ve=et(null),x=et(P);Me(()=>{const F=P&&!x.current;x.current=P,!(!F||!u)&&(X(null),A("dashboard"),b(u),k("author"),he(null));},[P,u]);const U=Vt(),j=s??(f==null?void 0:f.apiServiceUrl),K=n??(g==null?void 0:g.accessToken),oe=Y(()=>({...gi,...m}),[m]),[Pe,ut]=E(null);Me(()=>{if(!p||!j||!K)return;let F=!0;return oe.getBriefing(j,K,p.briefingId).then(({briefing:Q})=>{F&&(X(Q),ut(p),k("author"));},Q=>{F&&z.error(Q instanceof Error?Q.message:"Could not open the run.");}),()=>{F=!1;};},[p,j,K,oe]);const Fe=hi(a),He=Y(()=>{const F=pi(G,_,e);if(!u)return F;const Q=u==="scheduled_report"?"report":"briefing";return F.filter(Ge=>pe(Ge).noun===Q);},[e,G,_,u]),ht=Y(()=>_==="dashboard"?{source:{type:"dashboard",dashboardId:e},label:Fe,detail:mi(Fe)}:{source:{type:"project"},label:"This project",detail:"Use any data in this project."},[e,Fe,_]),_e=!!(j&&K),Oe=Or({canCreate:y.canCreate,analyticalBriefingsEnabled:y.analyticalBriefingsEnabled,scheduledReportAvailable:_==="dashboard"}),ce=ie(async()=>{if(!(!j||!K)){Z(!0),he(null);try{T(await fi({apiClient:oe,apiServiceUrl:j,token:K}));}catch(F){he(F instanceof Error?F.message:"Could not load briefings.");}finally{Z(!1);}}},[oe,j,K]);Me(()=>{!P||O!=="list"||!_e||ce();},[_e,O,ce,P]);const ze=()=>{X(null),A("dashboard"),k("list"),D(!0);},N=F=>{X(null),b(F),k("author");},W=async F=>{if(!(!j||!K)){I(F),he(null);try{const Q=await oe.getBriefing(j,K,F);X(Q.briefing),k("author");}catch(Q){he(Q instanceof Error?Q.message:"Could not open briefing.");}finally{I(null);}}},ee=async F=>{if(!(!j||!K)){q(F.id);try{const Q=await oe.runBriefingNow(j,K,F.id,{requestId:xi()});U.track({kind:"briefing",id:Q.run.id,title:F.name,briefingId:F.id}),ce();}catch(Q){z.error(Q instanceof Error?Q.message:"Could not start the run.");}finally{q(null);}}},me=async F=>{if(!j||!K)return;const{noun:Q}=pe(F),Ge=Q==="report"?"Report":"Briefing";q(F.id);try{const Ye=F.status==="PAUSED"?await oe.resumeBriefing(j,K,F.id):await oe.pauseBriefing(j,K,F.id);z.success(Ye.briefing.status==="PAUSED"?`${Ge} paused`:`${Ge} resumed`),ce();}catch(Ye){z.error(Ye instanceof Error?Ye.message:`Could not update the ${Q} status.`);}finally{q(null);}},ye=async()=>{if(!M||!j||!K)return;const F=M;q(F.id);try{await oe.deleteBriefing(j,K,F.id);const{noun:Q}=pe(F);z.success(`${Q==="report"?"Report":"Briefing"} deleted`),ne(null),ce();}catch(Q){z.error(Q instanceof Error?Q.message:"Could not delete the briefing.");}finally{q(null);}},La=He.length;return y.surfaceVisible?/* @__PURE__ */r(Hn,{open:P,onOpenChange:D,children:[d?null:/* @__PURE__ */t(ei,{disabled:i||!_e,briefingCount:La,className:o,onClick:ze}),/* @__PURE__ */r(Gn,{ref:ve,side:"right",hideClose:!0,className:"flex h-full w-full flex-col overflow-hidden p-0 outline-none sm:max-w-[560px]",onOpenAutoFocus:F=>{var Q;F.preventDefault(),(Q=ve.current)==null||Q.focus({preventScroll:!0});},children:[/* @__PURE__ */r(Yn,{className:"sr-only",children:[/* @__PURE__ */t(Xn,{children:"Reports & briefings"}),/* @__PURE__ */t(Jn,{children:"Manage reports and briefings for this dashboard."})]}),u?/* @__PURE__ */r("div",{className:"flex shrink-0 items-start justify-between gap-3 border-b border-border pl-4 pr-3 pt-2",children:[/* @__PURE__ */r("div",{className:"flex items-center gap-5",role:"tablist","aria-label":u==="scheduled_report"?"Email report workflow":"Analytical briefing workflow",children:[/* @__PURE__ */t("button",{type:"button",role:"tab","aria-selected":O==="author",disabled:!C,className:J("-mb-px border-b-2 px-0.5 pb-2 text-[12px] transition-colors",O==="author"?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground",!C&&"cursor-not-allowed opacity-50"),onClick:()=>{C&&(X(null),b(u),A("dashboard"),k("author"));},children:R?`Edit ${pe(R).noun}`:u==="scheduled_report"?"Schedule report":"Create briefing"}),/* @__PURE__ */t("button",{type:"button",role:"tab","aria-selected":O==="list",className:J("-mb-px border-b-2 px-0.5 pb-2 text-[12px] transition-colors",O==="list"?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),onClick:()=>k("list"),children:u==="scheduled_report"?"Manage reports":"Manage briefings"})]}),/* @__PURE__ */t("button",{type:"button",onClick:()=>D(!1),className:"rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":u==="scheduled_report"?"Close email report workflow":"Close analytical briefing workflow",children:/* @__PURE__ */t(Qe,{className:"h-3.5 w-3.5"})})]}):null,O==="list"?/* @__PURE__ */t(li,{briefings:He,dashboardLabel:Fe,sourceView:_,error:ue,loading:te,onSourceViewChange:A,onClose:()=>D(!1),onEdit:F=>{W(F);},onNew:N,canCreate:!u&&Oe.length>0,canCreateScheduledReport:Oe.includes("scheduled_report"),analyticalBriefingsEnabled:Oe.includes("analytical_briefing"),onRunNow:F=>{ee(F);},onTogglePause:F=>{me(F);},onDelete:F=>ne(F),selectingId:H,busyId:ae,manageBriefingsHref:l,contentKind:u==="scheduled_report"?"reports":u==="analytical_briefing"?"briefings":void 0,hideHeader:!!u}):/* @__PURE__ */t(Zn,{apiServiceUrl:j,token:K,briefing:R,initialRunId:Pe&&(R==null?void 0:R.id)===Pe.briefingId?Pe.runId:void 0,intent:v,sourceContext:R?void 0:ht,title:R?`Edit ${pe(R).noun}`:v==="scheduled_report"?"Schedule report":"Create analytical briefing",hideHeader:!!u,className:"h-full min-h-0 max-w-none border-0 shadow-none",onBack:u?void 0:()=>k("list"),onCancel:()=>D(!1),onDeleted:()=>{const F=R?pe(R).noun:"briefing";z.success(`${F==="report"?"Report":"Briefing"} deleted`),X(null),k("list"),ce();},onRunStarted:()=>{},onSaved:F=>{X(F),ce();},onMinimizeRun:()=>{D(!1);}})]}),/* @__PURE__ */t(St,{open:!!M,onOpenChange:F=>{F||ne(null);},children:/* @__PURE__ */r(kt,{children:[/* @__PURE__ */r(Dt,{children:[/* @__PURE__ */r(At,{children:["Delete"," ",M?pe(M).noun:"briefing","?"]}),/* @__PURE__ */r(Ft,{children:["This permanently deletes ",/* @__PURE__ */t("strong",{children:M==null?void 0:M.name}),". Recipients will stop receiving it."]})]}),/* @__PURE__ */r(Et,{children:[/* @__PURE__ */t(It,{children:"Cancel"}),/* @__PURE__ */r(ua,{className:"bg-destructive/90 hover:bg-destructive",onClick:ye,children:["Delete"," ",M?pe(M).noun:"briefing"]})]})]})})]}):null;}function xi(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`briefing-run-now-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;}export{Qi as A,Gi as D,Hi as S,Xi as U,ji as V,ei as W,Wi as a,Ki as b,Yi as c,Zi as d,gs as e,xs as f,ws as g,eo as h,Ji as i,ao as j,to as k,no as l,ro as m,qi as u};
@@ -1,42 +0,0 @@
1
- import{jsx as e,jsxs as o,Fragment as R}from"react/jsx-runtime";import{bu as Fr,u as k,bv as $r,bw as Gr,bx as ot,by as Vr,bz as Hr,bA as jr,bB as qr,bC as zr,bD as Kr,b1 as Y,bE as xe,bF as ve,bo as C,bG as Qr,bp as $t,bq as Gt,bs as tt,bt as rt,bH as Vt,bI as it,bJ as Wr,bK as ne,bL as Yr,bM as Jr,bN as Ht,bO as Xr,bP as jt,bQ as Zr,br as ea,bR as ta,bS as A,bT as ra,bU as aa,bV as na,aS as sa,bW as oa,bd as ia,bX as da,be as ca,p as la,aa as ua,am as Et,o as Be,x as ma,q as Xe,O as ha,bY as pa,bZ as fa,a8 as ba,b_ as ga,s as xa,b$ as va,I as ya,c0 as wa,c1 as Na,c2 as Sa,c3 as At,c4 as It,c5 as Mt,c6 as Da,bf as ka,c7 as Ca,T as Ea,c8 as Aa,c9 as Ia,ca as ae,cb as he,cc as Ma,cd as La,ce as Oa,cf as Lt,w as Pa,cg as _a,ch as Ta,ci as Ra,cj as Ua,ck as Ba,cl as Fa,cm as $a,cn as Ga,co as Ot,Q as Va}from"./semaphor-ready-indicator-DzjorP3t.js";import{c as ye,B as V,Q as Ha,V as ja,W as at,L as $e,X as qt,s as qa,y as za,z as Ka,A as Qa,D as Wa,E as Ya,e as Ja,f as Xa,h as Za,F as en,t as tn,u as rn,v as an,I as nn,w as sn,j as zt,g as Pt}from"./style-sheet-parts-BRGt9O05.js";import*as E from"react";import Kt,{useMemo as H,useState as N,useEffect as be,useRef as _t,useLayoutEffect as on}from"react";import{c as ge}from"./pickers-DuBrUht0.js";import"./validators-CqV3Yka1.js";import"./matrix-operation-contract-D1RC1bfi.js";import"./analytics-base-schemas-BREc5WGv.js";import"../value-format-preferences/index.js";import{u as dn,c as cn,k as ln,D as un,A as mn,a as hn,h as pn,l as fn,V as bn,b as gn,d as xn,S as vn,j as yn,i as wn,m as Nn,U as Sn}from"./dashboard-briefing-launcher-qo7GH4EO.js";import{I as Dn}from"./card-filter-builder-CTp6RAz1.js";import{c as kn,R as Cn}from"./report-preferences-dialog-B_gUmCzG.js";import{createPortal as En}from"react-dom";import{h_ as we,h$ as dt,i0 as Qt,B as An}from"./resolve-dashboard-input-context-B-TtRqxu.js";import{aX as Wt}from"./pivot-result-contract-expectations-DTQAgr4n.js";import{g as nt}from"./stored-dashboard-Ctcpkllg.js";import{r as In}from"./export-file-format-B-wQNHIn.js";import{u as Mn,s as Ln}from"./normalize-dashboard-for-dirty-check-ILKfqgL3.js";import{A as Yt}from"./bookmark-state-69YYnRql.js";import{d as On,a as Pn}from"./bookmark-impact-C89zBLq3.js";import{S as _n}from"./save-DdFUZcbi.js";import{P as Tn}from"./paintbrush-BjS3SbrH.js";import{P as Rn}from"./palette-BzC-CGOc.js";/**
2
- * @license lucide-react v0.453.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Un=ye("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
7
- * @license lucide-react v0.453.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const Bn=ye("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/**
12
- * @license lucide-react v0.453.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const Fn=ye("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
17
- * @license lucide-react v0.453.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const $n=ye("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/**
22
- * @license lucide-react v0.453.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Jt=ye("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);var st={exports:{}},Ze={};/**
27
- * @license React
28
- * use-sync-external-store-shim.production.js
29
- *
30
- * Copyright (c) Meta Platforms, Inc. and affiliates.
31
- *
32
- * This source code is licensed under the MIT license found in the
33
- * LICENSE file in the root directory of this source tree.
34
- */var Tt;function Gn(){if(Tt)return Ze;Tt=1;var t=Kt;function n(i,f){return i===f&&(i!==0||1/i===1/f)||i!==i&&f!==f;}var a=typeof Object.is=="function"?Object.is:n,r=t.useState,s=t.useEffect,c=t.useLayoutEffect,u=t.useDebugValue;function m(i,f){var l=f(),x=r({inst:{value:l,getSnapshot:f}}),h=x[0].inst,w=x[1];return c(function(){h.value=l,h.getSnapshot=f,p(h)&&w({inst:h});},[i,l,f]),s(function(){return p(h)&&w({inst:h}),i(function(){p(h)&&w({inst:h});});},[i]),u(l),l;}function p(i){var f=i.getSnapshot;i=i.value;try{var l=f();return!a(i,l);}catch{return!0;}}function y(i,f){return f();}var b=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?y:m;return Ze.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:b,Ze;}var et={};/**
35
- * @license React
36
- * use-sync-external-store-shim.development.js
37
- *
38
- * Copyright (c) Meta Platforms, Inc. and affiliates.
39
- *
40
- * This source code is licensed under the MIT license found in the
41
- * LICENSE file in the root directory of this source tree.
42
- */var Rt;function Vn(){return Rt||(Rt=1,process.env.NODE_ENV!=="production"&&function(){function t(l,x){return l===x&&(l!==0||1/l===1/x)||l!==l&&x!==x;}function n(l,x){b||s.startTransition===void 0||(b=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var h=x();if(!i){var w=x();c(h,w)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),i=!0);}w=u({inst:{value:h,getSnapshot:x}});var S=w[0].inst,O=w[1];return p(function(){S.value=h,S.getSnapshot=x,a(S)&&O({inst:S});},[l,h,x]),m(function(){return a(S)&&O({inst:S}),l(function(){a(S)&&O({inst:S});});},[l]),y(h),h;}function a(l){var x=l.getSnapshot;l=l.value;try{var h=x();return!c(l,h);}catch{return!0;}}function r(l,x){return x();}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=Kt,c=typeof Object.is=="function"?Object.is:t,u=s.useState,m=s.useEffect,p=s.useLayoutEffect,y=s.useDebugValue,b=!1,i=!1,f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:n;et.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:f,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());}()),et;}process.env.NODE_ENV==="production"?st.exports=Gn():st.exports=Vn();var Hn=st.exports;const Fe=["light","dark","system"];function jn(){const{theme:t,setTheme:n}=Fr(),a=k(u=>u.actions.setDashboardTheme);function r(){const u=Fe.includes(t)?t:"system",m=Fe[(Fe.indexOf(u)+1)%Fe.length];n(m),a(m);}const s=t==="light"?Fn:t==="dark"?Un:$r,c=t==="light"?"Theme: light (click for dark)":t==="dark"?"Theme: dark (click for system)":"Theme: system (click for light)";return/* @__PURE__ */e(V,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-7 p-0",onClick:r,"aria-label":c,title:c,children:/* @__PURE__ */e(s,{className:"h-3.5 w-3.5",strokeWidth:1.5})});}function qn(){const{displayPreferences:t,shouldShowElement:n}=Gr(),{currentUser:a,userContext:r}=ot(),s=H(()=>Vr(a),[a]),c=H(()=>m=>s&&s[m]!==void 0&&s[m]===!1?!1:n(m),[s,n,t]),u=H(()=>{var m,p,y,b,i;return{canEdit:((m=r==null?void 0:r.permissions)==null?void 0:m.canEdit)??Kr(a),canUseFilters:((p=r==null?void 0:r.permissions)==null?void 0:p.canEdit)??zr(a),canManageDashboards:((y=r==null?void 0:r.permissions)==null?void 0:y.canCreateDashboard)??qr(a),canCreateDashboards:((b=r==null?void 0:r.permissions)==null?void 0:b.canCreateDashboard)??jr(a),canAccessVisuals:((i=r==null?void 0:r.permissions)==null?void 0:i.canEdit)??Hr(a)};},[a,r]);return{displayPreferences:t,shouldShowElement:c,permissions:u,currentUser:a};}function zn(t,n=[]){let a=[];function r(c,u){const m=E.createContext(u);m.displayName=c+"Context";const p=a.length;a=[...a,u];const y=i=>{var S;const{scope:f,children:l,...x}=i,h=((S=f==null?void 0:f[t])==null?void 0:S[p])||m,w=E.useMemo(()=>x,Object.values(x));return/* @__PURE__ */e(h.Provider,{value:w,children:l});};y.displayName=c+"Provider";function b(i,f){var h;const l=((h=f==null?void 0:f[t])==null?void 0:h[p])||m,x=E.useContext(l);if(x)return x;if(u!==void 0)return u;throw new Error(`\`${i}\` must be used within \`${c}\``);}return[y,b];}const s=()=>{const c=a.map(u=>E.createContext(u));return function(m){const p=(m==null?void 0:m[t])||c;return E.useMemo(()=>({[`__scope${t}`]:{...m,[t]:p}}),[m,p]);};};return s.scopeName=t,[r,Kn(s,...n)];}function Kn(...t){const n=t[0];if(t.length===1)return n;const a=()=>{const r=t.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(c){const u=r.reduce((m,{useScope:p,scopeName:y})=>{const i=p(c)[`__scope${y}`];return{...m,...i};},{});return E.useMemo(()=>({[`__scope${n.scopeName}`]:u}),[u]);};};return a.scopeName=n.scopeName,a;}var Qn=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ct=Qn.reduce((t,n)=>{const a=Ha(`Primitive.${n}`),r=E.forwardRef((s,c)=>{const{asChild:u,...m}=s,p=u?a:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),/* @__PURE__ */e(p,{...m,ref:c});});return r.displayName=`Primitive.${n}`,{...t,[n]:r};},{});function Wn(){return Hn.useSyncExternalStore(Yn,()=>!0,()=>!1);}function Yn(){return()=>{};}var lt="Avatar",[Jn]=zn(lt),[Xn,Xt]=Jn(lt),Zt=E.forwardRef((t,n)=>{const{__scopeAvatar:a,...r}=t,[s,c]=E.useState("idle");return/* @__PURE__ */e(Xn,{scope:a,imageLoadingStatus:s,onImageLoadingStatusChange:c,children:/* @__PURE__ */e(ct.span,{...r,ref:n})});});Zt.displayName=lt;var er="AvatarImage",tr=E.forwardRef((t,n)=>{const{__scopeAvatar:a,src:r,onLoadingStatusChange:s=()=>{},...c}=t,u=Xt(er,a),m=Zn(r,c),p=ja(y=>{s(y),u.onImageLoadingStatusChange(y);});return at(()=>{m!=="idle"&&p(m);},[m,p]),m==="loaded"?/* @__PURE__ */e(ct.img,{...c,ref:n,src:r}):null;});tr.displayName=er;var rr="AvatarFallback",ar=E.forwardRef((t,n)=>{const{__scopeAvatar:a,delayMs:r,...s}=t,c=Xt(rr,a),[u,m]=E.useState(r===void 0);return E.useEffect(()=>{if(r!==void 0){const p=window.setTimeout(()=>m(!0),r);return()=>window.clearTimeout(p);}},[r]),u&&c.imageLoadingStatus!=="loaded"?/* @__PURE__ */e(ct.span,{...s,ref:n}):null;});ar.displayName=rr;function Ut(t,n){return t?n?(t.src!==n&&(t.src=n),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle";}function Zn(t,{referrerPolicy:n,crossOrigin:a}){const r=Wn(),s=E.useRef(null),c=r?(s.current||(s.current=new window.Image()),s.current):null,[u,m]=E.useState(()=>Ut(c,t));return at(()=>{m(Ut(c,t));},[c,t]),at(()=>{const p=i=>()=>{m(i);};if(!c)return;const y=p("loaded"),b=p("error");return c.addEventListener("load",y),c.addEventListener("error",b),n&&(c.referrerPolicy=n),typeof a=="string"&&(c.crossOrigin=a),()=>{c.removeEventListener("load",y),c.removeEventListener("error",b);};},[c,a,n]),u;}var nr=Zt,sr=tr,or=ar;const ir=E.forwardRef(({className:t,...n},a)=>/* @__PURE__ */e(nr,{ref:a,className:ge("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...n}));ir.displayName=nr.displayName;const es=E.forwardRef(({className:t,...n},a)=>/* @__PURE__ */e(sr,{ref:a,className:ge("aspect-square h-full w-full",t),...n}));es.displayName=sr.displayName;const dr=E.forwardRef(({className:t,...n},a)=>/* @__PURE__ */e(or,{ref:a,className:ge("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...n}));dr.displayName=or.displayName;const ts=async(t,n,a)=>{const r=`${t}/management/v1/groups`;return await Qt(r,n,a);},rs=async(t,n,a,r)=>{const s=`${t}/management/v1/groups/${a}`;return dt(s,n,"PATCH",r);},as=async(t,n,a)=>{const r=`${t}/management/v1/groups/${a}`;await dt(r,n,"DELETE");},ns=async(t,n,a,r)=>{const s=`${t}/management/v1/groups/${a}/members`;return await Qt(s,n,r);},ss=async(t,n,a,r)=>{const s=`${t}/management/v1/groups/${a}/members`;await dt(s,n,"DELETE",r);};function os(){const{authToken:t,tokenProps:n}=Y(),a=xe();return ve({mutationFn:r=>ts(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:()=>{a.invalidateQueries({queryKey:["groups"]}),C.success("Group created successfully");},onError:r=>{console.error("Failed to create group:",r),C.error("Failed to create group",{description:we(r,"Failed to create group")});}});}function is(){const{authToken:t,tokenProps:n}=Y(),a=xe();return ve({mutationFn:({groupId:r,data:s})=>rs(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,s),onSuccess:(r,s)=>{a.invalidateQueries({queryKey:["group",s.groupId]}),a.invalidateQueries({queryKey:["groups"]}),C.success("Group updated successfully");},onError:r=>{console.error("Failed to update group:",r),C.error("Failed to update group",{description:we(r,"Failed to update group")});}});}function ds(){const{authToken:t,tokenProps:n}=Y(),a=xe();return ve({mutationFn:r=>as(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:(r,s)=>{a.invalidateQueries({queryKey:["groups"]}),a.removeQueries({queryKey:["group",s]}),C.success("Group deleted successfully");},onError:r=>{console.error("Failed to delete group:",r),C.error("Failed to delete group",{description:we(r,"Failed to delete group")});}});}function cs(){const{authToken:t,tokenProps:n}=Y(),a=xe();return ve({mutationFn:({groupId:r,data:s})=>ns(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,s),onSuccess:(r,s)=>{a.invalidateQueries({queryKey:["group",s.groupId]}),a.invalidateQueries({queryKey:["group-members",s.groupId]}),a.invalidateQueries({queryKey:["groups"]}),C.success("Members added successfully");},onError:r=>{console.error("Failed to add group members:",r),C.error("Failed to add members",{description:we(r,"Failed to add members")});}});}function ls(){const{authToken:t,tokenProps:n}=Y(),a=xe();return ve({mutationFn:({groupId:r,data:s})=>ss(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,s),onSuccess:(r,s)=>{a.invalidateQueries({queryKey:["group",s.groupId]}),a.invalidateQueries({queryKey:["group-members",s.groupId]}),a.invalidateQueries({queryKey:["groups"]}),C.success("Members removed successfully");},onError:r=>{console.error("Failed to remove group members:",r),C.error("Failed to remove members",{description:we(r,"Failed to remove members")});}});}const us=[];function ms({open:t,onOpenChange:n}){var O,g,F;const{tokenProps:a}=Y(),{currentUser:r}=ot(),s=(r==null?void 0:r.type)==="tenant",c=a==null?void 0:a.tenantId,{groups:u,isLoading:m,error:p,refetch:y}=Qr({type:s?"TENANT_GROUP":"all",tenantId:s?c:void 0,includeMembers:!1}),b=p?cr(p,"Unable to load groups."):null,[i,f]=N({kind:"list"}),[l,x]=N(null),h=ds();be(()=>{t||(f({kind:"list"}),x(null));},[t]);const w=i.kind==="members"&&u.find(P=>P.id===i.groupId)||null,S=async()=>{if(l)try{await h.mutateAsync(l.id),x(null),f({kind:"list"}),y();}catch{}};return/* @__PURE__ */e($t,{open:t,onOpenChange:n,children:/* @__PURE__ */o(Gt,{className:"flex max-h-[640px] w-[720px] max-w-[92vw] flex-col gap-0 overflow-hidden p-0",children:[i.kind==="list"?/* @__PURE__ */o("div",{className:"shrink-0 border-b border-border px-5 pt-4 pb-3.5",children:[/* @__PURE__ */e(tt,{className:"text-[15px] font-semibold tracking-tight",children:"Group management"}),/* @__PURE__ */e(rt,{className:"mt-1 text-[12px] leading-[1.5] text-muted-foreground",children:"Organize people into groups for shared access."})]}):i.kind==="create"?/* @__PURE__ */o("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5",children:[/* @__PURE__ */e("button",{type:"button",onClick:()=>f({kind:"list"}),"aria-label":"Back",className:"-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:/* @__PURE__ */e(Vt,{className:"h-3.5 w-3.5"})}),/* @__PURE__ */e(tt,{className:"truncate text-[13px] font-medium",children:"New group"}),/* @__PURE__ */e(rt,{className:"sr-only",children:"Create a new group to organize members."})]}):null,i.kind==="list"&&/* @__PURE__ */e(hs,{groups:u,isLoading:m,errorMessage:b,onRetry:()=>y(),currentUserId:r==null?void 0:r.id,onOpenGroup:P=>f({kind:"members",groupId:P}),onCreate:()=>f({kind:"create"}),onDeleteRequest:P=>x(P)}),i.kind==="members"&&w&&/* @__PURE__ */e(bs,{group:w,isTenantViewer:s,canEdit:((O=w.permissions)==null?void 0:O.canEdit)??w.createdBy===(r==null?void 0:r.id),canDelete:((g=w.permissions)==null?void 0:g.canDelete)??w.createdBy===(r==null?void 0:r.id),canManageMembers:((F=w.permissions)==null?void 0:F.canManageMembers)??w.createdBy===(r==null?void 0:r.id),onBack:()=>f({kind:"list"}),onMembersChanged:y,onUpdated:y,onRequestDelete:()=>x(w)},w.id),i.kind==="create"&&/* @__PURE__ */e(gs,{isTenantUser:s,tenantId:c,onCancel:()=>f({kind:"list"}),onCreated:P=>{y(),f({kind:"members",groupId:P});}}),l&&/* @__PURE__ */o("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border bg-muted/40 px-5 py-2.5",children:[/* @__PURE__ */o("div",{className:"min-w-0 text-[12px] text-foreground",children:["Delete ",/* @__PURE__ */e("span",{className:"font-medium",children:l.name}),"?",/* @__PURE__ */e("span",{className:"ml-2 text-muted-foreground",children:"Members lose any access granted via this group."})]}),/* @__PURE__ */o("div",{className:"flex shrink-0 items-center gap-1.5",children:[/* @__PURE__ */e("button",{type:"button",onClick:()=>x(null),disabled:h.isPending,className:"h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-background",children:"Cancel"}),/* @__PURE__ */o("button",{type:"button",onClick:S,disabled:h.isPending,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-rose-600 px-2.5 text-[12px] font-medium text-white hover:bg-rose-700 disabled:opacity-60",children:[h.isPending?/* @__PURE__ */e($e,{className:"h-3 w-3 animate-spin"}):/* @__PURE__ */e(it,{className:"h-3 w-3"}),"Delete group"]})]})]})]})});}function hs({groups:t,isLoading:n,errorMessage:a,onRetry:r,currentUserId:s,onOpenGroup:c,onCreate:u,onDeleteRequest:m}){const[p,y]=N(""),b=H(()=>t.filter(i=>!p.trim()||i.name.toLowerCase().includes(p.toLowerCase())||(i.description||"").toLowerCase().includes(p.toLowerCase())),[t,p]);return/* @__PURE__ */o("div",{className:"flex flex-1 flex-col overflow-hidden",children:[/* @__PURE__ */o("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-5 py-2.5",children:[/* @__PURE__ */o("div",{className:"flex flex-1 items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[/* @__PURE__ */e(Wr,{className:"h-3 w-3 text-muted-foreground"}),/* @__PURE__ */e("input",{value:p,onChange:i=>y(i.target.value),placeholder:"Search groups…",className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"}),p&&/* @__PURE__ */e("button",{type:"button",onClick:()=>y(""),className:"flex h-4 w-4 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:/* @__PURE__ */e(qt,{className:"h-2.5 w-2.5"})})]}),/* @__PURE__ */o("button",{type:"button",onClick:u,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",children:[/* @__PURE__ */e(ne,{className:"h-3 w-3"}),"New group"]})]}),/* @__PURE__ */e("div",{className:"flex-1 overflow-y-auto",children:n?/* @__PURE__ */e("div",{className:"space-y-px p-3",children:[1,2,3].map(i=>/* @__PURE__ */e("div",{className:"h-12 animate-pulse rounded-[4px] bg-muted/60"},i))}):a?/* @__PURE__ */e(lr,{title:"Can't load groups",message:a,onRetry:r}):b.length===0&&t.length===0?/* @__PURE__ */e(fs,{onCreate:u}):b.length===0?/* @__PURE__ */o("div",{className:"flex h-full flex-col items-center justify-center gap-1 py-10 text-center",children:[/* @__PURE__ */o("div",{className:"text-[12px] text-foreground",children:['No groups match "',p,'"']}),/* @__PURE__ */e("div",{className:"text-[11px] text-muted-foreground",children:"Try a different search."})]}):b.map(i=>{var f;return/* @__PURE__ */e(ps,{group:i,canDelete:((f=i.permissions)==null?void 0:f.canDelete)??i.createdBy===s,onClick:()=>c(i.id),onDelete:()=>m(i)},i.id);})})]});}function ps({group:t,canDelete:n,onClick:a,onDelete:r}){let s="";try{s=Wt(new Date(t.createdAt),"MMM d, yyyy");}catch{s="";}return/* @__PURE__ */o("button",{type:"button",onClick:a,className:"group flex w-full items-center gap-3 border-b border-border/60 px-5 py-2.5 text-left hover:bg-accent/40",children:[/* @__PURE__ */e("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-[4px] border border-border bg-background text-muted-foreground",children:/* @__PURE__ */e(Xr,{className:"h-3.5 w-3.5"})}),/* @__PURE__ */o("div",{className:"min-w-0 flex-1",children:[/* @__PURE__ */e("div",{className:"truncate text-[13px] font-medium text-foreground",children:t.name}),/* @__PURE__ */o("div",{className:"mt-0.5 flex items-center gap-2 text-[11px] text-muted-foreground",children:[/* @__PURE__ */o("span",{className:"inline-flex items-center gap-1",children:[/* @__PURE__ */e(Jt,{className:"h-2.5 w-2.5"}),t.memberCount," member",t.memberCount===1?"":"s"]}),s&&/* @__PURE__ */o(R,{children:[/* @__PURE__ */e("span",{className:"text-border",children:"·"}),/* @__PURE__ */o("span",{className:"inline-flex items-center gap-1",children:[/* @__PURE__ */e(jt,{className:"h-2.5 w-2.5"}),s]})]}),t.description&&/* @__PURE__ */o(R,{children:[/* @__PURE__ */e("span",{className:"text-border",children:"·"}),/* @__PURE__ */e("span",{className:"truncate text-muted-foreground",children:t.description})]})]})]}),/* @__PURE__ */o("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[n&&/* @__PURE__ */e("span",{role:"button",tabIndex:0,onClick:c=>{c.stopPropagation(),r();},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),c.stopPropagation(),r());},"aria-label":`Delete ${t.name}`,className:"flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:/* @__PURE__ */e(it,{className:"h-3 w-3"})}),/* @__PURE__ */e(Zr,{className:"h-3.5 w-3.5 text-muted-foreground"})]})]});}function fs({onCreate:t}){return/* @__PURE__ */o("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center",children:[/* @__PURE__ */e("div",{className:"flex h-9 w-9 items-center justify-center rounded-full border border-border bg-muted/40 text-muted-foreground",children:/* @__PURE__ */e(Ht,{className:"h-4 w-4"})}),/* @__PURE__ */e("div",{className:"text-[13px] font-medium text-foreground",children:"No groups yet"}),/* @__PURE__ */e("div",{className:"max-w-[320px] text-[11.5px] leading-[1.55] text-muted-foreground",children:"Groups let you grant shared access to dashboards. Create one and add members."}),/* @__PURE__ */o("button",{type:"button",onClick:t,className:"mt-1 inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",children:[/* @__PURE__ */e(ne,{className:"h-3 w-3"}),"New group"]})]});}function bs({group:t,isTenantViewer:n,canEdit:a,canDelete:r,canManageMembers:s,onBack:c,onMembersChanged:u,onUpdated:m,onRequestDelete:p}){const{data:y,isLoading:b,error:i,refetch:f}=Yr(t.id),l=(y==null?void 0:y.members)??us,x=i?cr(i,"Unable to load members for this group."):null,h=t.type==="TENANT_GROUP"?"tenant":"organization",{users:w}=Jr({type:h,tenantId:t.tenantId||void 0,active:!0,limit:200}),S=H(()=>new Set(l.map(v=>v.userId)),[l]),O=cs(),g=ls(),F=is(),[P,$]=N(!1),[M,D]=N(t.name),[Ne,J]=N(!1),[X,Z]=N(t.description||""),[ee,Se]=N(""),[De,ke]=N(!1),Ce=H(()=>{const v=ee.trim().toLowerCase();return w.filter(B=>!S.has(B.id)).filter(B=>!v||(B.name||"").toLowerCase().includes(v)||(B.email||"").toLowerCase().includes(v)).slice(0,50);},[w,S,ee]),se=async()=>{const v=M.trim();if($(!1),v.length>=3&&v!==t.name)try{await F.mutateAsync({groupId:t.id,data:{name:v}}),m();}catch{}},te=async()=>{const v=X.trim();if(J(!1),v!==(t.description||""))try{await F.mutateAsync({groupId:t.id,data:{description:v}}),m();}catch{}},Ee=async v=>{if(s){Se(""),ke(!1);try{await O.mutateAsync({groupId:t.id,data:{userIds:[v.id],userType:h==="tenant"?"tenant":"org"}}),f(),u();}catch{}}},Ae=async v=>{if(s)try{await g.mutateAsync({groupId:t.id,data:{userIds:[v]}}),f(),u();}catch{}};let j="";try{j=Wt(new Date(t.createdAt),"MMM d, yyyy");}catch{j="";}return/* @__PURE__ */o("div",{className:"flex flex-1 flex-col overflow-hidden",children:[/* @__PURE__ */o("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5",children:[/* @__PURE__ */e("button",{type:"button",onClick:c,"aria-label":"Back",className:"-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:/* @__PURE__ */e(Vt,{className:"h-3.5 w-3.5"})}),P?/* @__PURE__ */e("input",{autoFocus:!0,value:M,onChange:v=>D(v.target.value),onBlur:se,onKeyDown:v=>{v.key==="Enter"&&se(),v.key==="Escape"&&(D(t.name),$(!1));},className:"h-6 min-w-0 flex-1 rounded-[3px] border border-border bg-background px-1.5 text-[13px] font-medium text-foreground focus:border-foreground/40 focus:outline-none"}):/* @__PURE__ */e("button",{type:"button",onClick:()=>{a&&(D(t.name),$(!0));},title:a?"Click to rename":t.name,disabled:!a,className:"truncate rounded-[3px] px-1 text-[13px] font-medium text-foreground enabled:hover:bg-accent disabled:cursor-default",children:t.name}),/* @__PURE__ */o("span",{className:"ml-1 inline-flex shrink-0 items-center gap-1 text-[10.5px] text-muted-foreground",children:[/* @__PURE__ */e(Jt,{className:"h-2.5 w-2.5"}),l.length," member",l.length===1?"":"s"]})]}),/* @__PURE__ */e("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:Ne?/* @__PURE__ */o("div",{children:[/* @__PURE__ */e("textarea",{autoFocus:!0,rows:2,value:X,onChange:v=>Z(v.target.value),maxLength:200,onKeyDown:v=>{v.key==="Escape"&&(Z(t.description||""),J(!1)),v.key==="Enter"&&(v.metaKey||v.ctrlKey)&&te();},placeholder:"What is this group for?",className:"block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),/* @__PURE__ */o("div",{className:"mt-1.5 flex items-center justify-between",children:[/* @__PURE__ */o("span",{className:"text-[10.5px] text-muted-foreground",children:[X.length,"/200 · Esc to cancel · ⌘↩ to save"]}),/* @__PURE__ */o("div",{className:"flex items-center gap-1.5",children:[/* @__PURE__ */e("button",{type:"button",onClick:()=>{Z(t.description||""),J(!1);},className:"h-6 rounded-[5px] px-2 text-[11px] font-medium text-foreground/80 hover:bg-accent",children:"Cancel"}),/* @__PURE__ */e("button",{type:"button",onClick:te,className:"inline-flex h-6 items-center rounded-[5px] bg-foreground px-2 text-[11px] font-medium text-background hover:opacity-90",children:"Save"})]})]})]}):/* @__PURE__ */o("button",{type:"button",onClick:()=>{a&&(Z(t.description||""),J(!0));},disabled:!a,title:a?"Click to edit description":void 0,className:"block w-full rounded-[3px] px-1 py-0.5 text-left enabled:hover:bg-accent/40 disabled:cursor-default",children:[t.description?/* @__PURE__ */e("p",{className:"text-[12px] leading-[1.55] text-foreground/90",children:t.description}):/* @__PURE__ */e("p",{className:"text-[12px] leading-[1.55] text-muted-foreground",children:a?"Add a description…":"No description"}),/* @__PURE__ */o("p",{className:"mt-1 text-[10.5px] text-muted-foreground",children:[j?`Created ${j}`:"Recently created",a?" · You can edit this group":""]})]})}),s&&/* @__PURE__ */e(xs,{query:ee,setQuery:Se,open:De,setOpen:ke,candidates:Ce,showKindChip:!n,onAdd:Ee,busy:O.isPending}),/* @__PURE__ */e("div",{className:"flex-1 overflow-y-auto",children:b?/* @__PURE__ */e("div",{className:"space-y-px p-3",children:[1,2,3].map(v=>/* @__PURE__ */e("div",{className:"h-10 animate-pulse rounded-[4px] bg-muted/60"},v))}):x?/* @__PURE__ */e(lr,{title:"Can't load members",message:x,onRetry:()=>f()}):l.length===0?/* @__PURE__ */o("div",{className:"flex h-full flex-col items-center justify-center gap-1 py-10 text-center",children:[/* @__PURE__ */e("div",{className:"text-[12px] text-foreground",children:"No members yet"}),/* @__PURE__ */e("div",{className:"text-[11px] text-muted-foreground",children:s?"Search above to add people to this group.":"This group does not have any members."})]}):l.map(v=>{var B,Ie,q,z,K,oe;return/* @__PURE__ */o("div",{className:"group flex items-center gap-2 border-b border-border/60 px-5 py-2",children:[/* @__PURE__ */e(ur,{name:((B=v.user)==null?void 0:B.name)||((Ie=v.user)==null?void 0:Ie.email)||"?"}),/* @__PURE__ */o("div",{className:"min-w-0 flex-1",children:[/* @__PURE__ */e("div",{className:"truncate text-[12.5px] font-medium text-foreground",children:((q=v.user)==null?void 0:q.name)||((z=v.user)==null?void 0:z.email)||"Unknown"}),((K=v.user)==null?void 0:K.email)&&v.user.name&&/* @__PURE__ */e("div",{className:"truncate text-[10.5px] text-muted-foreground",children:v.user.email})]}),!n&&/* @__PURE__ */e("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:v.userType}),/* @__PURE__ */e("button",{type:"button",onClick:()=>Ae(v.userId),disabled:!s||g.isPending,"aria-label":`Remove ${((oe=v.user)==null?void 0:oe.name)||"member"}`,className:"flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover:opacity-100 disabled:opacity-30",children:/* @__PURE__ */e(qt,{className:"h-3 w-3"})})]},v.id);})}),r&&/* @__PURE__ */e("div",{className:"flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5",children:/* @__PURE__ */o("button",{type:"button",onClick:p,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] border border-rose-200 bg-background px-2.5 text-[12px] font-medium text-rose-600 hover:bg-rose-50 dark:border-rose-900/60 dark:text-rose-400 dark:hover:bg-rose-950/30",children:[/* @__PURE__ */e(it,{className:"h-3 w-3"}),"Delete group"]})})]});}function gs({isTenantUser:t,tenantId:n,onCancel:a,onCreated:r}){const[s,c]=N(""),[u,m]=N(""),[p,y]=N(null),b=os(),i=s.trim().length>=3&&s.trim().length<=50,f=async()=>{if(!i)return;y(null);const l={name:s.trim(),description:u.trim()||void 0,type:t?"TENANT_GROUP":"ORG_GROUP",...(t&&n?{tenantId:n}:{})};try{const x=await b.mutateAsync(l),h=x==null?void 0:x.id;h?r(h):a();}catch(x){y(x instanceof Error?x.message:"Failed to create group");}};return/* @__PURE__ */o("div",{className:"flex flex-1 flex-col overflow-hidden",children:[/* @__PURE__ */o("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[/* @__PURE__ */e(Bt,{children:"Name"}),/* @__PURE__ */e("input",{autoFocus:!0,value:s,onChange:l=>c(l.target.value),placeholder:"Marketing leads, North America sales, …",maxLength:50,className:"mt-1 block h-7 w-full rounded-[5px] border border-border bg-background px-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),/* @__PURE__ */e("div",{className:"mt-1 text-[10.5px] text-muted-foreground",children:"3–50 characters."}),/* @__PURE__ */o("div",{className:"mt-4",children:[/* @__PURE__ */e(Bt,{children:"Description (optional)"}),/* @__PURE__ */e("textarea",{rows:2,value:u,onChange:l=>m(l.target.value),maxLength:200,placeholder:"What is this group for?",className:"mt-1 block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),/* @__PURE__ */o("div",{className:"mt-1 flex justify-end text-[10.5px] text-muted-foreground",children:[u.length,"/200"]})]}),p&&/* @__PURE__ */e("div",{className:"mt-3 rounded-[5px] border border-rose-200 bg-rose-50 px-2 py-1.5 text-[11.5px] text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/30 dark:text-rose-300",children:p})]}),/* @__PURE__ */o("div",{className:"flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5",children:[/* @__PURE__ */e("button",{type:"button",onClick:a,disabled:b.isPending,className:"h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-accent",children:"Cancel"}),/* @__PURE__ */e("button",{type:"button",onClick:f,disabled:!i||b.isPending,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60",children:b.isPending?/* @__PURE__ */o(R,{children:[/* @__PURE__ */e($e,{className:"h-3 w-3 animate-spin"}),"Creating…"]}):/* @__PURE__ */o(R,{children:[/* @__PURE__ */e(ne,{className:"h-3 w-3"}),"Create group"]})})]})]});}function xs({query:t,setQuery:n,open:a,setOpen:r,candidates:s,showKindChip:c,onAdd:u,busy:m}){const p=_t(null),y=_t(null),[b,i]=N(null);on(()=>{if(!a){i(null);return;}const l=()=>{const x=p.current;if(!x)return;const h=x.getBoundingClientRect(),w=240,O=window.innerHeight-h.bottom<w+16&&h.top>w;i({left:h.left,top:O?h.top-6:h.bottom+6,width:h.width,above:O});};return l(),window.addEventListener("resize",l),window.addEventListener("scroll",l,!0),()=>{window.removeEventListener("resize",l),window.removeEventListener("scroll",l,!0);};},[a,s.length]),be(()=>{if(!a)return;const l=x=>{var w,S;const h=x.target;(w=p.current)!=null&&w.contains(h)||(S=y.current)!=null&&S.contains(h)||r(!1);};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l);},[a,r]);const f=a&&s.length>0&&b;return/* @__PURE__ */o("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:[/* @__PURE__ */o("div",{ref:p,className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[/* @__PURE__ */e($n,{className:"h-3 w-3 text-muted-foreground"}),/* @__PURE__ */e("input",{value:t,onChange:l=>{n(l.target.value),r(!0);},onFocus:()=>r(!0),placeholder:"Add a member by name or email…",disabled:m,className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed"})]}),f&&typeof document<"u"&&En(/* @__PURE__ */e("div",{ref:y,style:{position:"fixed",left:b.left,top:b.top,width:b.width,transform:b.above?"translateY(-100%)":void 0},className:"z-[60] max-h-[240px] overflow-y-auto rounded-[5px] border border-border bg-background shadow-[0_8px_24px_-12px_rgba(0,0,0,0.18)]",children:s.map(l=>/* @__PURE__ */o("button",{type:"button",onClick:()=>u(l),className:"flex w-full items-center gap-2 border-b border-border/60 px-2.5 py-2 text-left last:border-b-0 hover:bg-accent",children:[/* @__PURE__ */e(ur,{name:l.name||l.email||"?"}),/* @__PURE__ */o("div",{className:"min-w-0 flex-1",children:[/* @__PURE__ */e("div",{className:"truncate text-[12px] font-medium text-foreground",children:l.name||l.email||"Unknown"}),l.email&&l.name&&/* @__PURE__ */e("div",{className:"truncate text-[10.5px] text-muted-foreground",children:l.email})]}),c&&l.type&&/* @__PURE__ */e("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:l.type==="tenant"?"tenant":"org"})]},l.id))}),document.body)]});}function cr(t,n){if(!t)return n;if(t instanceof Error){const a=t.message||"",r=a.match(/\{[\s\S]*"error"\s*:\s*"([^"]+)"[\s\S]*\}/);return r?r[1]:a||n;}return typeof t=="string"?t:n;}function lr({title:t,message:n,onRetry:a}){return/* @__PURE__ */o("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 py-10 text-center",children:[/* @__PURE__ */e("div",{className:"text-[12.5px] font-medium text-foreground",children:t}),/* @__PURE__ */e("div",{className:"max-w-[360px] text-[11.5px] leading-[1.55] text-muted-foreground",children:n}),a&&/* @__PURE__ */e("button",{type:"button",onClick:a,className:"mt-1 inline-flex h-7 items-center rounded-[5px] border border-border bg-background px-2.5 text-[11.5px] font-medium text-foreground hover:bg-accent",children:"Try again"})]});}function Bt({children:t}){return/* @__PURE__ */e("label",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:t});}function ur({name:t}){const n=t.split(" ").map(a=>a[0]).filter(Boolean).slice(0,2).join("").toUpperCase();return/* @__PURE__ */e(ir,{className:"h-6 w-6 shrink-0",children:/* @__PURE__ */e(dr,{className:"text-[9px] font-semibold",children:n||"?"})});}const vs="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function ys({open:t,onOpenChange:n}){const a=k(s=>{var c,u;return In({dashboardDefault:(u=(c=s.dashboard)==null?void 0:c.exportDefaults)==null?void 0:u.csvEncoding});}),{setDashboardExportDefaults:r}=k(s=>s.actions);return/* @__PURE__ */e($t,{open:t,onOpenChange:n,children:/* @__PURE__ */o(Gt,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[/* @__PURE__ */o(ea,{children:[/* @__PURE__ */e(tt,{className:"text-[15px]",children:"Download settings"}),/* @__PURE__ */e(rt,{className:"text-[13px] leading-5",children:"Applies to every CSV downloaded or delivered from this dashboard. People can still change it for a single download."})]}),/* @__PURE__ */o("div",{className:"space-y-2",children:[/* @__PURE__ */e(qa,{htmlFor:"dashboard-csv-encoding",className:vs,children:"CSV encoding"}),/* @__PURE__ */o(za,{value:a,onValueChange:s=>r({csvEncoding:s}),children:[/* @__PURE__ */e(Ka,{id:"dashboard-csv-encoding",size:"sm",children:/* @__PURE__ */e(Qa,{})}),/* @__PURE__ */e(Wa,{children:ta.map(s=>/* @__PURE__ */e(Ya,{value:s.value,children:s.label},s.value))})]})]})]})});}function pe(t,n,a){var c,u;const r=(t.controls||[]).find(m=>m.id===a);if(r)return r.label;const s=(u=(c=Yt(t,n))==null?void 0:c.controls)==null?void 0:u.find(m=>m.id===a);return(s==null?void 0:s.label)||a;}function fe(t,n){var a;return((a=Yt(t,n))==null?void 0:a.title)||n;}function ws(t){const{errors:n,dashboard:a}=t;if(!a)return n;const r=/* @__PURE__ */new Map();for(const s of n){const c=s.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(c){const[,b,i]=c,f=`${b}:${i}:missing-metric`;r.has(f)||r.set(f,`"${fe(a,b)}" has an outdated "${pe(a,b,i)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue;}const u=s.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(u){const[,b,i]=u,f=`${b}:${i}:missing-group-by`;r.has(f)||r.set(f,`"${fe(a,b)}" has an outdated "${pe(a,b,i)}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`);continue;}const m=s.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/);if(m){const[,b,i]=m,f=`${b}:${i}:invalid-metric`;r.has(f)||r.set(f,`"${fe(a,b)}" has an invalid "${pe(a,b,i)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue;}const p=s.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(p){const[,b,i]=p,f=`${b}:${i}:invalid-group-by`;r.has(f)||r.set(f,`"${fe(a,b)}" has an invalid "${pe(a,b,i)}" field mapping. Open the card controls and choose a valid field for each option.`);continue;}const y=s.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(y){const[,b,i]=y,f=`${b}:${i}:missing-temporal-group-by`;r.has(f)||r.set(f,`"${fe(a,b)}" can no longer use "${pe(a,b,i)}" for time grain because the card does not currently group by a date field.`);continue;}r.set(s,s);}return Array.from(r.values());}function Ns({visible:t,onSelect:n}){return t?/* @__PURE__ */o(A,{onSelect:n,children:[/* @__PURE__ */e(ra,{className:"h-3.5 w-3.5"}),"Schedule email report"]}):null;}function Ss({scheduleReportVisible:t,analyticalBriefingVisible:n,onScheduleReport:a,onCreateAnalyticalBriefing:r}){return/* @__PURE__ */o(R,{children:[/* @__PURE__ */e(Ns,{visible:t,onSelect:a}),n?/* @__PURE__ */o(A,{onSelect:r,children:[/* @__PURE__ */e(ne,{className:"h-3.5 w-3.5"}),"Create analytical briefing"]}):null]});}const Ds="dashboard-bookmark-usage";function ks(t){var p;const n=k(y=>y.viewerStateClient),a=(p=t.saved)==null?void 0:p.id,s=aa({queryKey:[Ds,(n==null?void 0:n.viewerKey)??null],queryFn:()=>n.bookmarks.usage(),enabled:t.enabled&&!!n&&!!a,staleTime:5*6e4,retry:!1}).data,{saved:c,draft:u,enabled:m}=t;return H(()=>!m||!c||!s?[]:!s.bookmarks&&!Object.keys(s.tables).length?[]:On({saved:c,draft:u,usage:s}),[u,m,c,s]);}function Cs({saved:t,draft:n,enabled:a}){const r=ks({saved:t,draft:n,enabled:a});return r.length?/* @__PURE__ */o(Ja,{children:[/* @__PURE__ */e(Xa,{asChild:!0,children:/* @__PURE__ */o(V,{variant:"ghost",size:"xs",className:"gap-1 text-muted-foreground hover:text-foreground",children:[/* @__PURE__ */e(na,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Affects saved views"]})}),/* @__PURE__ */o(Za,{align:"end",className:"w-[320px] p-3 text-[12px]",children:[/* @__PURE__ */e("p",{className:"text-foreground",children:"This edit removes parts of the dashboard that viewers saved. Their views still open, with a note about what no longer applies."}),/* @__PURE__ */e("ul",{"aria-label":"Affected saved views",className:"mt-2 grid gap-1 border-t border-border/60 pt-2",children:r.map(s=>{const{name:c,uses:u}=Pn(s);return/* @__PURE__ */o("li",{className:"flex items-baseline justify-between gap-3",children:[/* @__PURE__ */e("span",{className:"min-w-0 truncate text-foreground",children:c}),/* @__PURE__ */e("span",{className:"shrink-0 text-[11.5px] text-muted-foreground",children:u})]},`${s.target}:${s.cardId??""}:${s.id}`);})})]})]}):null;}function Ft(t,n){return{dashboard:nt(t),semanticExecutionPayload:nt(n)};}function Xs(){var St,Dt,kt,Ct;const{authToken:t,tokenProps:n,id:a,showBriefings:r,toolbarStatus:s}=Y(),c=sa(),{isLocalDev:u,isConsoleMode:m}=oa(),{canEditDashboard:p,hasInspectionUser:y,inspectionMessage:b,isInspectionMode:i,isInspectionSurface:f}=ia(),{openBrandStudioPreview:l}=da(),{permissions:x}=qn(),h=ca(),{isLoading:w}=la(),S=k(d=>d.theme),O=k(d=>d.isDownloadingPdf),g=k(d=>d.dashboard),F=k(d=>d.selectedSheetId),P=(St=g==null?void 0:g.sheets)==null?void 0:St.find(d=>d.id===F),$=An(P),M=$?(Dt=P==null?void 0:P.document)==null?void 0:Dt.page:void 0,D=k(d=>d.isDashboardEditing),{setDashboardTitle:Ne}=k(d=>d.actions),[J,X]=N(!1),[Z,ee]=N(!1),[Se,De]=N(!1),[ke,Ce]=N(!1),[se,te]=N(null),[Ee,Ae]=N(null),{registerBriefingViewer:j}=ua();be(()=>j(d=>Ae(d)),[j]);const[v,B]=N(!1),[Ie,q]=N(!1),[z,K]=N(null),[oe,Me]=N([]),[ut,Le]=N(!1),[mr,mt]=N(!1),U=k(d=>d.isVisualEditing);Et(d=>d.card);const hr=Be(d=>d.selectedDashboard),pr=Be(d=>d.initialDashboard);Be(d=>d.selectedVisual),k(d=>d.selectedFrameId),Et(d=>d.frame);const ht=k(d=>d.showDashboardJSON);k(d=>d.onSaveFunction);const{setIsDashboardEditing:pt,setShowDashboardJSON:ft,markDashboardSaved:fr,openStyleSheet:br}=k(d=>d.actions),{setInitialDashboard:bt,clearSelectedDashboard:Ge}=Be(d=>d.actions),ie=!!n.orgUserId||!!(n.tenantId&&n.endUserId&&n.endUserEmail),{resources:Oe}=ma(Xe.DASHBOARD),I=ha(),{currentUser:gr}=ot(),xr=pa(gr),G=hr||pr,Q=fa({config:n.config,canNavigateDashboardHub:ie,canShareDashboard:((kt=G==null?void 0:G.permissions)==null?void 0:kt.canShare)===!0,canManageGroups:xr}),gt=G?{id:G.id,title:(g==null?void 0:g.title)||G.title||"Dashboard"}:null,{handleAddNewFrame:vr}=ba(),[Ve,He]=N(!1),[yr,de]=N(!1),[je,Pe]=N("close"),ce=ga(Xe.DASHBOARD),[L,le]=N(null),wr=async(d,T)=>{if(!i){if(!(g!=null&&g.id)){console.log("No dashboard ID found");return;}console.log("Updating dashboard title:",{dashboardId:g.id,newTitle:d,previousTitle:T}),ce.mutate({resourceId:g.id,data:{title:d}},{onSuccess:()=>{le(_=>(_==null?void 0:_.dashboard.id)===g.id?{..._,dashboard:{..._.dashboard,title:d}}:_),C.success("Dashboard title updated");},onError:_=>{console.error("Failed to update dashboard title:",_),C.error("Failed to update dashboard title");const re=k.getState().dashboard;(re==null?void 0:re.id)===g.id&&re.title===d&&Ne(T);}});}};be(()=>{if(Oe&&Oe.length>0){const d=g==null?void 0:g.id;if(d){const T=Oe.find(_=>_.id===d);T&&bt(T);}}},[Oe,g==null?void 0:g.id,bt]);const Nr=n.orgUserId||n.tenantId,qe=H(()=>As({accessToken:t==null?void 0:t.accessToken,dashboardId:(g==null?void 0:g.id)||a||n.dashboard_id,selectedSheetId:$?F:void 0,pageSize:M==null?void 0:M.size,orientation:M==null?void 0:M.orientation,theme:S}),[t==null?void 0:t.accessToken,a,g==null?void 0:g.id,$,M==null?void 0:M.orientation,M==null?void 0:M.size,F,S,n.dashboard_id]),ze=D&&!U&&!i&&Nr&&p,{setDashboard:Ke}=k(d=>d.actions),Sr=k(d=>d.semanticExecutionPayload),Dr=()=>{pt(!0);},_e=()=>{pt(!1),ft(!1),le(null);};be(()=>{if(!D){L&&le(null);return;}if(L||!g||w)return;const d=xa(k.getState());le(Ft(d.dashboard,d.semanticExecutionPayload));},[g,L,D,w,Sr]);const Qe=(L==null?void 0:L.dashboard)??null,{isDirty:We,isDirtyPending:kr,resetDirty:ue}=Mn(g,Qe,300,1e3,Ln),xt=dn(Qe,i,p),vt=We||kr,Te=Ve||ce.isPending,Cr=()=>{if(i){L&&Ke(L.dashboard,{semanticExecutionPayload:L.semanticExecutionPayload}),_e(),ue();return;}xt()?(Pe("close"),de(!0)):(_e(),ue());},Er=async()=>{await Ye({closeAfterSave:!0,navigateHomeAfterSave:je==="home"});},Ar=()=>{const d=je==="home"&&!!ie;L&&Ke(L.dashboard,{semanticExecutionPayload:L.semanticExecutionPayload}),_e(),d&&Ge(),Pe("close"),de(!1),ue();},Ir=()=>{L&&(Ke(L.dashboard,{semanticExecutionPayload:L.semanticExecutionPayload}),ue());},Mr=()=>{if(ie){if(D&&xt()){Pe("home"),de(!0);return;}Ge();}};async function Ye(d){if(i)return;const T=k.getState().dashboard;if(!T)return;const _=(d==null?void 0:d.closeAfterSave)??ut,re=(d==null?void 0:d.navigateHomeAfterSave)??!1;Le(_),_&&de(!1);const _r=nt(T);q(!0),K(null),Me([]),He(!0);const Tr={template:T};ce.mutate({resourceId:T.id,data:Tr},{onSuccess:()=>{He(!1),fr(),C.success("Dashboard saved!"),le(Ft(_r,k.getState().semanticExecutionPayload)),q(!1),Le(!1),_&&(_e(),ue(),re&&ie&&Ge()),Pe("close");},onError:Rr=>{He(!1),K("Failed to save dashboard. Please try again.");const Ue=Rr.details,Ur=Array.isArray(Ue==null?void 0:Ue.errors)?(Ue.errors||[]).filter(Br=>typeof Br=="string"):[];Me(ws({errors:Ur,dashboard:T||void 0})),C.error("Failed to save dashboard");}});}const yt=g.title;ce.isPending&&console.log("Title during update:",{title:yt,dashboardStateTitle:g.title,dashboardId:g==null?void 0:g.id});const Lr=ie&&!!(t!=null&&t.accessToken)&&!!(n!=null&&n.apiServiceUrl),Or=!i&&Q.showDashboardHub&&Lr,Pr=!i&&h&&Q.showDashboardHub,W=(g==null?void 0:g.id)||null,wt=va((Ct=n.config)==null?void 0:Ct.showBriefings,r),Re=cn(W),Je=ln();if(!h&&!U)return null;const me=!U&&h&&!i,Nt=D&&me;return/* @__PURE__ */e(ya,{width:I.width,hasOverflowMenu:me,children:/* @__PURE__ */o("div",{ref:I.measure,className:"flex min-h-11 shrink-0 items-center gap-2 border-b px-3 py-1.5",role:"dashboard-controls",children:[/* @__PURE__ */o("div",{className:"flex min-w-[80px] flex-1 items-center gap-2",children:[Pr&&!U&&/* @__PURE__ */e(Dn,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:Mr,className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:/* @__PURE__ */e(wa,{className:"h-3.5 w-3.5"})}),!U&&h&&(w?/* @__PURE__ */e("div",{className:"h-4 w-28 animate-pulse rounded-md bg-muted/70","aria-label":"Loading dashboard title",role:"status",children:/* @__PURE__ */e("span",{className:"sr-only",children:"Loading dashboard title"})}):/* @__PURE__ */o("div",{className:"flex min-w-0 items-center gap-1",children:[/* @__PURE__ */e(Na,{value:yt||"Untitled Dashboard",onSave:d=>{console.log("EditableText onSave called:",{newTitle:d,canEditDashboard:p,dashboardId:g==null?void 0:g.id});const T=(g==null?void 0:g.title)||"";Ne(d),wr(d,T);},isEditable:Sa({isDashboardEditing:D,canEditDashboard:p===!0&&!i}),displayClassName:"text-[13px] font-medium",inputClassName:"text-[13px] font-medium",placeholder:"Dashboard Title",isPending:ce.isPending}),!i&&W&&/* @__PURE__ */e(un,{dashboardId:W}),s?/* @__PURE__ */e("div",{className:"flex min-w-[1.25rem] shrink-[2]",children:s}):null]}))]}),/* @__PURE__ */o("div",{className:"flex min-w-0 items-center gap-1.5",children:[/* @__PURE__ */o("div",{className:"-m-1 flex min-w-0 items-center gap-1.5 overflow-x-auto p-1 [scrollbar-width:thin] [&>*]:shrink-0",children:[U&&/* @__PURE__ */o(R,{children:[/* @__PURE__ */e(mn,{}),/* @__PURE__ */e(hn,{})]}),h&&!i&&/* @__PURE__ */e(kn,{}),!U&&D&&!i&&x.canUseFilters&&h&&/* @__PURE__ */e(pn,{}),D&&!i&&h&&/* @__PURE__ */e(fn,{}),D&&!U&&!i&&h&&!$&&/* @__PURE__ */o("div",{className:"inline-flex h-7 items-stretch overflow-hidden rounded-control border border-input bg-background",children:[/* @__PURE__ */o(V,{variant:"ghost",size:"xs",disabled:!D,onClick:()=>void vr(),"aria-label":I.width==="sm"?"Add visual":void 0,title:I.width==="sm"?"Add visual":void 0,className:ge("h-full rounded-none border-0 shadow-none hover:bg-accent",I.width==="sm"&&"w-7 px-0"),children:[/* @__PURE__ */e(ne,{className:"h-3.5 w-3.5"}),I.width!=="sm"&&"Visual"]}),/* @__PURE__ */o(At,{modal:!1,children:[/* @__PURE__ */e(It,{asChild:!0,children:/* @__PURE__ */e(V,{variant:"ghost",size:"xs",className:"h-full w-7 rounded-none border-0 border-l border-border/60 px-0 shadow-none hover:bg-accent","aria-label":"Open visual options",disabled:!D,children:/* @__PURE__ */e(en,{className:"h-3.5 w-3.5"})})}),/* @__PURE__ */e(Mt,{align:"end",className:"z-[60] w-48 rounded-control border-border/60 p-1 shadow-sm",children:/* @__PURE__ */o(A,{onClick:()=>mt(!0),children:[/* @__PURE__ */e(ne,{className:"h-3.5 w-3.5"}),"From library..."]})})]}),/* @__PURE__ */e(bn,{open:mr,onOpenChange:mt})]}),!i&&h&&/* @__PURE__ */e(gn,{}),!U&&!D&&(p||i)&&(!f||!y||p!==void 0)&&h&&/* @__PURE__ */o("div",{className:"inline-flex items-center gap-1",children:[/* @__PURE__ */o(V,{size:"xs",onClick:Dr,"aria-label":i?"Inspect":"Edit",title:I.width==="sm"?i?"Inspect":"Edit":void 0,className:I.width==="sm"?"w-7 px-0":void 0,children:[/* @__PURE__ */e(Da,{className:"h-3.5 w-3.5"}),I.width!=="sm"&&(i?"Inspect":"Edit")]}),b?/* @__PURE__ */e(tn,{children:/* @__PURE__ */o(rn,{children:[/* @__PURE__ */e(an,{asChild:!0,children:/* @__PURE__ */e("button",{type:"button","aria-label":b,className:"inline-flex size-6 items-center justify-center rounded-control text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:/* @__PURE__ */e(nn,{"aria-hidden":"true",className:"size-3.5"})})}),/* @__PURE__ */e(sn,{children:/* @__PURE__ */e("p",{children:b})})]})}):null]}),ze&&h&&We&&/* @__PURE__ */e(Cs,{saved:Qe,draft:g,enabled:D&&!i}),ze&&h&&We&&/* @__PURE__ */o(V,{variant:"outline",size:"xs",onClick:Ir,disabled:Te,"aria-label":"Undo",title:I.width==="sm"?"Undo":void 0,className:I.width==="sm"?"w-7 px-0":void 0,children:[/* @__PURE__ */e(ka,{className:"h-3.5 w-3.5"}),I.width!=="sm"&&"Undo"]}),ze&&h&&/* @__PURE__ */o(V,{size:"xs",className:ge(!vt&&"opacity-60"),disabled:Te||!vt,onClick:()=>Ye(),children:[Te?/* @__PURE__ */e($e,{className:"h-3.5 w-3.5 animate-spin"}):/* @__PURE__ */e(_n,{className:"h-3.5 w-3.5"}),Te?"Saving...":"Save"]}),D&&!U&&h&&/* @__PURE__ */o(V,{variant:"outline",size:"xs",onClick:Cr,"aria-label":"Close",title:I.width==="sm"?"Close":void 0,className:I.width==="sm"?"w-7 px-0":void 0,children:[/* @__PURE__ */e(Ca,{className:"h-3.5 w-3.5"}),I.width!=="sm"&&"Close"]})]}),!U&&h&&/* @__PURE__ */o(R,{children:[/* @__PURE__ */e(xn,{}),m&&p===!0&&!i&&/* @__PURE__ */e(vn,{})]}),!U&&u&&I.width==="lg"&&/* @__PURE__ */e(jn,{}),me&&/* @__PURE__ */e(Ea,{}),me&&Nt&&/* @__PURE__ */e(yn,{}),me&&/* @__PURE__ */o(At,{children:[/* @__PURE__ */e(It,{asChild:!0,children:/* @__PURE__ */e(V,{variant:"ghost",size:"xs",className:"w-7 px-0","aria-label":"More dashboard options",children:/* @__PURE__ */e(Aa,{className:"h-3.5 w-3.5"})})}),/* @__PURE__ */o(Mt,{align:"end",className:"w-56 rounded-control border border-border/60 p-1 shadow-sm",children:[/* @__PURE__ */e(Es,{}),Re.available&&Or&&/* @__PURE__ */o(R,{children:[/* @__PURE__ */o(A,{disabled:Re.disabled,onSelect:Re.toggle,children:[/* @__PURE__ */e(Ia,{className:"h-3.5 w-3.5"}),/* @__PURE__ */e("span",{className:"flex-1",children:"Default dashboard"}),Re.isDefault&&/* @__PURE__ */e(zt,{className:"h-3.5 w-3.5"})]}),/* @__PURE__ */e(ae,{})]}),/* @__PURE__ */e(he,{children:"Reports & briefings"}),/* @__PURE__ */o(A,{disabled:O,onSelect:()=>B(!0),children:[/* @__PURE__ */e(Ma,{className:"h-3.5 w-3.5"}),"Export"]}),/* @__PURE__ */e(Ss,{scheduleReportVisible:!!(wt&&c.surfaceVisible&&W&&!D),analyticalBriefingVisible:!!(wt&&c.surfaceVisible&&W&&!D),onScheduleReport:()=>te("scheduled_report"),onCreateAnalyticalBriefing:()=>te("analytical_briefing")}),D&&/* @__PURE__ */o(A,{onSelect:()=>Ce(!0),children:[/* @__PURE__ */e(La,{className:"h-3.5 w-3.5"}),"Download settings"]}),/* @__PURE__ */e(ae,{}),(Q.showDashboardSharing||Q.showGroupManagement)&&/* @__PURE__ */o(R,{children:[/* @__PURE__ */e(he,{children:"Access"}),Q.showDashboardSharing&&/* @__PURE__ */o(A,{onSelect:()=>X(!0),children:[/* @__PURE__ */e(Oa,{className:"h-3.5 w-3.5"}),"Share"]}),Q.showGroupManagement&&/* @__PURE__ */o(A,{onClick:()=>ee(!0),children:[/* @__PURE__ */e(Ht,{className:"h-3.5 w-3.5"}),"Manage Groups"]}),/* @__PURE__ */e(ae,{})]}),Nt&&/* @__PURE__ */o(R,{children:[/* @__PURE__ */e(he,{children:"Dashboard"}),/* @__PURE__ */o(A,{onSelect:Je.open,children:[/* @__PURE__ */e(Pt,{className:"h-3.5 w-3.5"}),/* @__PURE__ */e("span",{className:"flex-1",children:Je.label}),/* @__PURE__ */e("span",{className:"pl-4 text-[11px] tabular-nums text-muted-foreground",children:Je.count})]}),/* @__PURE__ */o(A,{onSelect:br,children:[/* @__PURE__ */e(Tn,{className:"h-3.5 w-3.5"}),"Style"]}),/* @__PURE__ */e(ae,{})]}),/* @__PURE__ */e(he,{children:"Preferences"}),/* @__PURE__ */o(A,{onClick:()=>De(!0),children:[/* @__PURE__ */e(jt,{className:"h-3.5 w-3.5"}),"Report preferences"]}),u&&h&&/* @__PURE__ */o(R,{children:[/* @__PURE__ */e(ae,{}),/* @__PURE__ */e(he,{children:"Developer"}),/* @__PURE__ */o(A,{onSelect:()=>{var d;t!=null&&t.accessToken&&((d=navigator==null?void 0:navigator.clipboard)!=null&&d.writeText?navigator.clipboard.writeText(t.accessToken).then(()=>C.success("Token copied to clipboard")).catch(()=>C.error("Unable to copy token")):C.error("Clipboard not available"));},children:[/* @__PURE__ */e(Lt,{className:"h-3.5 w-3.5"}),"Copy token"]}),$&&/* @__PURE__ */o(A,{disabled:!qe,onSelect:()=>{var d;if(!qe){C.error("Open a document sheet with a token to copy the local PDF URL");return;}(d=navigator==null?void 0:navigator.clipboard)!=null&&d.writeText?navigator.clipboard.writeText(qe).then(()=>C.success("Local document PDF URL copied to clipboard")).catch(()=>C.error("Unable to copy local document PDF URL")):C.error("Clipboard not available");},children:[/* @__PURE__ */e(Lt,{className:"h-3.5 w-3.5"}),"Copy local document PDF URL"]}),/* @__PURE__ */o(A,{onSelect:()=>wn(n.apiServiceUrl),children:[/* @__PURE__ */e(Bn,{className:"h-3.5 w-3.5"}),"Invalidate token"]}),/* @__PURE__ */o(A,{onSelect:l,children:[/* @__PURE__ */e(Rn,{className:"h-3.5 w-3.5"}),"Brand Studio"]}),D&&/* @__PURE__ */o(A,{onSelect:()=>ft(!ht),children:[/* @__PURE__ */e(Pt,{className:"h-3.5 w-3.5"}),ht?"Hide dashboard JSON":"Show dashboard JSON"]})]})]})]}),J&&gt&&/* @__PURE__ */e(Pa,{resource:gt,resourceType:Xe.DASHBOARD,onClose:()=>X(!1)}),Q.showGroupManagement&&/* @__PURE__ */e(ms,{open:Z,onOpenChange:ee}),/* @__PURE__ */e(Cn,{open:Se,onOpenChange:De}),/* @__PURE__ */e(ys,{open:ke,onOpenChange:Ce}),W&&(se||Ee)?/* @__PURE__ */e(Nn,{dashboardId:W,dashboardTitle:(g==null?void 0:g.title)||(G==null?void 0:G.title),open:!0,onOpenChange:d=>{d||(te(null),Ae(null));},hideTrigger:!0,workflowIntent:se??void 0,openRun:Ee??void 0}):null,h&&/* @__PURE__ */e(_a,{open:v,onOpenChange:B}),/* @__PURE__ */e(Ta,{open:Ie,onOpenChange:d=>{!d&&Ve&&!z||(q(d),d||(K(null),Me([]),Le(!1)));},children:/* @__PURE__ */o(Ra,{className:"max-w-sm",children:[/* @__PURE__ */o(Ua,{children:[/* @__PURE__ */e(Ba,{children:z?"Save failed":"Saving dashboard"}),/* @__PURE__ */e(Fa,{className:"pt-2",children:z?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),oe.length>0&&/* @__PURE__ */o("div",{className:"space-y-1 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-left",children:[/* @__PURE__ */e("div",{className:"text-sm font-medium text-destructive",children:"What needs attention"}),/* @__PURE__ */e("ul",{className:"list-disc space-y-1 pl-4 text-xs text-muted-foreground",children:oe.slice(0,5).map(d=>/* @__PURE__ */e("li",{children:d},d))})]})]}),/* @__PURE__ */e($a,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:z?/* @__PURE__ */o(R,{children:[/* @__PURE__ */e(Ga,{onClick:()=>{q(!1),K(null),Me([]),Le(!1);},className:"m-0",children:"Close"}),/* @__PURE__ */e(Ot,{onClick:()=>Ye({closeAfterSave:ut,navigateHomeAfterSave:je==="home"}),className:"m-0",children:"Retry"})]}):/* @__PURE__ */o(Ot,{disabled:!0,className:"m-0 cursor-default",children:[/* @__PURE__ */e($e,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),/* @__PURE__ */e(Sn,{open:yr,onOpenChange:d=>{de(d);},onSave:Er,onDiscard:Ar,isSaving:Ve,saveLabel:"Save",discardLabel:"Discard changes"})]})]})});}function Es(){const t=Va();return t.length===0?null:/* @__PURE__ */o(R,{children:[t.map(n=>/* @__PURE__ */o(A,{onSelect:n.onSelect,children:[n.icon,/* @__PURE__ */e("span",{className:"flex-1",children:n.label}),n.hint&&/* @__PURE__ */e("span",{className:"text-[11px] text-muted-foreground",children:n.hint}),n.checked&&/* @__PURE__ */e(zt,{className:"h-3.5 w-3.5"})]},n.id)),/* @__PURE__ */e(ae,{})]});}function As({accessToken:t,dashboardId:n,selectedSheetId:a,pageSize:r,orientation:s,theme:c}){if(!t||!a)return null;const u=new URL("http://localhost:5173/print-document");u.searchParams.set("token",t),n&&u.searchParams.set("dashboardId",n),u.searchParams.set("selectedSheetId",a),c&&u.searchParams.set("theme",c);const m=new URL("http://127.0.0.1:3002/");return m.searchParams.set("pdfMode","document"),m.searchParams.set("pageSize",r||"letter"),m.searchParams.set("orientation",s||"portrait"),m.searchParams.set("url",u.toString()),m.toString();}export{Xs as default};
@@ -1 +0,0 @@
1
- import{jsxs as d,jsx as t}from"react/jsx-runtime";import{useMemo as u,useState as f,useRef as b,useEffect as p}from"react";import{u as o}from"./semaphor-ready-indicator-DzjorP3t.js";import{B as S,X as N,C as D}from"./style-sheet-parts-BRGt9O05.js";import{c as J}from"./pickers-DuBrUht0.js";import"./validators-CqV3Yka1.js";import"./matrix-operation-contract-D1RC1bfi.js";import"./analytics-base-schemas-BREc5WGv.js";import"../value-format-preferences/index.js";function z(){const r=o(s=>s.dashboard),c=o(s=>s.actions.setDashboard),h=o(s=>s.showDashboardJSON),l=o(s=>s.actions.setShowDashboardJSON),a=u(()=>r?JSON.stringify(r,null,2):"",[r]),[m,n]=f(a),e=b(a);return p(()=>{a!==e.current&&(n(a),e.current=a);},[a]),/* @__PURE__ */d("div",{className:J("relative p-2",{hidden:!h}),children:[/* @__PURE__ */d(S,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>l(!1),children:[/* @__PURE__ */t(N,{className:"mr-2 h-4 w-4"}),"Close"]}),/* @__PURE__ */t("div",{className:"h-[550px] overflow-hidden",children:/* @__PURE__ */t(D,{value:m,onValueChange:s=>{n(s);try{const i=JSON.parse(s);e.current=JSON.stringify(i,null,2),c(i);}catch{}},language:"json"})})]});}export{z as default};