react-semaphor 0.1.477 → 0.1.479

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 (109) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +9 -9
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +4 -4
  5. package/dist/briefings/index.cjs +1 -1
  6. package/dist/briefings/index.js +4 -4
  7. package/dist/chunks/{analyze-result-contract-OgPk-zGu.cjs → analyze-result-contract-BX_nQmPN.cjs} +1 -1
  8. package/dist/chunks/{analyze-result-contract-C8s8EUL5.js → analyze-result-contract-DsiAzCYn.js} +1 -1
  9. package/dist/chunks/{saved-temporal-bucket-format-CHsXUPJI.js → card-config-utils-CyDKaPNT.js} +190 -190
  10. package/dist/chunks/card-config-utils-D3Xuu0ub.cjs +1 -0
  11. package/dist/chunks/{common-types-C1IM7gao.cjs → common-types-BCSbPclk.cjs} +1 -1
  12. package/dist/chunks/{common-types-BLPy5_E0.js → common-types-D3r4PILe.js} +1 -1
  13. package/dist/chunks/{dashboard-briefing-launcher-CXHq6ime.cjs → dashboard-briefing-launcher-DWwSdfV7.cjs} +2 -2
  14. package/dist/chunks/{dashboard-briefing-launcher-C9d8CPxv.js → dashboard-briefing-launcher-Dk4yNOLY.js} +134 -134
  15. package/dist/chunks/{dashboard-controls-d7Yd2fJb.cjs → dashboard-controls-B0Pm_y8L.cjs} +10 -10
  16. package/dist/chunks/{dashboard-controls-BqDm4ARp.js → dashboard-controls-CIC5_549.js} +13 -12
  17. package/dist/chunks/{dashboard-input-contract-JFJZgenC.cjs → dashboard-date-comparison-definition-C93wv8Ua.cjs} +1 -1
  18. package/dist/chunks/{dashboard-input-contract-BrGdGFz0.js → dashboard-date-comparison-definition-KohOqBqR.js} +19 -19
  19. package/dist/chunks/dashboard-filter-value-compatibility-ByT__CYM.cjs +1 -0
  20. package/dist/chunks/dashboard-filter-value-compatibility-DQkUs41q.js +1220 -0
  21. package/dist/chunks/dashboard-json-Bk6nEHap.cjs +1 -0
  22. package/dist/chunks/{dashboard-json-CL_vgcWq.js → dashboard-json-YDTb3r4e.js} +7 -7
  23. package/dist/chunks/{edit-dashboard-visual-Dklel3MC.cjs → edit-dashboard-visual-B3oH-O0L.cjs} +6 -6
  24. package/dist/chunks/{edit-dashboard-visual-C0Zvyo-X.js → edit-dashboard-visual-q5Yj9dMP.js} +277 -277
  25. package/dist/chunks/{editor-action-buttons-BOyUtX9j.js → editor-action-buttons-BqelO0n9.js} +39 -39
  26. package/dist/chunks/{editor-action-buttons-AcaZsiDy.cjs → editor-action-buttons-vZ63-lN-.cjs} +1 -1
  27. package/dist/chunks/{format-types-CFHQoIuk.js → index-BS0_dp0l.js} +168 -168
  28. package/dist/chunks/{index-D9S3j7_z.js → index-BvRREsU9.js} +9 -9
  29. package/dist/chunks/index-ByQgqT9d.cjs +1 -0
  30. package/dist/chunks/{index-DrdF7QR7.js → index-CUCiMVzS.js} +34219 -35005
  31. package/dist/chunks/{index-v2MZLyus.cjs → index-CXeIDdjd.cjs} +1 -1
  32. package/dist/chunks/{index-Cd8qGOXl.cjs → index-DhDfPZUu.cjs} +232 -232
  33. package/dist/chunks/matrix-result-contract-CFPnlcLm.cjs +1 -0
  34. package/dist/chunks/{matrix-result-contract-BpzhImar.js → matrix-result-contract-DFfUvb1r.js} +3 -3
  35. package/dist/chunks/{temporal-bucket-CtP7hKLa.js → metric-comparison-CTexJ8V1.js} +705 -705
  36. package/dist/chunks/metric-comparison-x0lipytf.cjs +1 -0
  37. package/dist/chunks/pivot-header-presentation-8Ra1RfHg.cjs +4 -0
  38. package/dist/chunks/{pivot-header-presentation-CaERAWpl.js → pivot-header-presentation-tpb_J900.js} +118 -118
  39. package/dist/chunks/{pivot-result-identity-CIZXsI53.js → pivot-result-identity-BIeP9v8I.js} +1 -1
  40. package/dist/chunks/{pivot-result-identity-DRUlTWUq.cjs → pivot-result-identity-BVnhG2rR.cjs} +1 -1
  41. package/dist/chunks/pivot-result-lifecycle-D_bRCqaB.cjs +1 -0
  42. package/dist/chunks/{pivot-result-lifecycle-B9FTybxN.js → pivot-result-lifecycle-mjJ1rBvV.js} +7 -7
  43. package/dist/chunks/{raw-temporal-contract-U8J9RlEH.js → raw-temporal-contract-BuQIB31z.js} +1 -1
  44. package/dist/chunks/{raw-temporal-contract-D8YuxTAg.cjs → raw-temporal-contract-vnNwLy9R.cjs} +1 -1
  45. package/dist/chunks/report-preferences-dialog--aV7ITSE.cjs +1 -0
  46. package/dist/chunks/{report-preferences-dialog-BjygtSP3.js → report-preferences-dialog-DKq0k5BH.js} +25 -25
  47. package/dist/chunks/{report-runtime-context-DNbgCsko.js → report-runtime-context-B_pAmqxl.js} +1 -1
  48. package/dist/chunks/{report-runtime-context-RFiWq4wK.cjs → report-runtime-context-BfW4qiMJ.cjs} +1 -1
  49. package/dist/chunks/{source-entity-resolution-BDC-Qngk.cjs → source-entity-resolution-DCAAS-y8.cjs} +1 -1
  50. package/dist/chunks/{source-entity-resolution-ugN3sZUk.js → source-entity-resolution-WUstJID6.js} +1 -1
  51. package/dist/chunks/switch-D12C40LN.cjs +138 -0
  52. package/dist/chunks/{switch-C8NihGV4.js → switch-LucIPRtD.js} +13142 -11648
  53. package/dist/chunks/{temporal-bucket-authoring-DJ9kK2wD.js → temporal-bucket-authoring-CyTCHy1K.js} +3 -3
  54. package/dist/chunks/temporal-bucket-authoring-DueSgLJU.cjs +1 -0
  55. package/dist/chunks/{temporal-bucket-contract-CZl5D7FZ.js → temporal-bucket-contract-BeOx0uYe.js} +1 -1
  56. package/dist/chunks/{temporal-bucket-contract-BD862TAa.cjs → temporal-bucket-contract-Cp-usD9Z.cjs} +1 -1
  57. package/dist/chunks/{token-types-CoHsSJ4E.cjs → token-types-D9eN35rf.cjs} +1 -1
  58. package/dist/chunks/{token-types-DfDtCqlw.js → token-types-Dvomvqw0.js} +1 -1
  59. package/dist/chunks/{update-policy-BGNXFgBU.cjs → update-policy-Buw2LmvX.cjs} +1 -1
  60. package/dist/chunks/{update-policy-BybMiM61.js → update-policy-MWg0aH3d.js} +1 -1
  61. package/dist/chunks/{validators-D-T-2HOR.js → validators-D3AarM2T.js} +662 -663
  62. package/dist/chunks/validators-DqIM0B3C.cjs +1 -0
  63. package/dist/dashboard/index.cjs +1 -1
  64. package/dist/dashboard/index.js +2 -2
  65. package/dist/dashboard-authoring/index.cjs +3 -3
  66. package/dist/dashboard-authoring/index.js +81 -79
  67. package/dist/data-app-builder/index.cjs +1 -1
  68. package/dist/data-app-builder/index.js +2 -2
  69. package/dist/data-app-codegen/index.cjs +1 -1
  70. package/dist/data-app-codegen/index.js +2 -2
  71. package/dist/data-app-codegen-node/index.cjs +1 -1
  72. package/dist/data-app-codegen-node/index.js +3 -3
  73. package/dist/data-app-sdk/index.cjs +1 -1
  74. package/dist/data-app-sdk/index.js +3 -3
  75. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  76. package/dist/data-app-sdk-adapters/index.js +2 -2
  77. package/dist/data-app-sdk-validation/index.cjs +1 -1
  78. package/dist/data-app-sdk-validation/index.js +3 -3
  79. package/dist/format-utils/index.cjs +3 -3
  80. package/dist/format-utils/index.js +9 -9
  81. package/dist/index.cjs +1 -1
  82. package/dist/index.js +177 -176
  83. package/dist/report-runtime-context/index.cjs +1 -1
  84. package/dist/report-runtime-context/index.js +2 -2
  85. package/dist/surfboard/index.cjs +1 -1
  86. package/dist/surfboard/index.js +3 -3
  87. package/dist/types/briefings.d.ts +19 -2
  88. package/dist/types/dashboard-authoring.d.ts +26 -3
  89. package/dist/types/dashboard.d.ts +20 -3
  90. package/dist/types/index.cjs +1 -1
  91. package/dist/types/index.js +4 -4
  92. package/dist/types/main.d.ts +39 -18
  93. package/dist/types/shared.d.ts +19 -2
  94. package/dist/types/surfboard.d.ts +20 -3
  95. package/dist/types/types.d.ts +20 -3
  96. package/package.json +1 -1
  97. package/dist/chunks/dashboard-filter-value-compatibility-BCVF9IHg.js +0 -1026
  98. package/dist/chunks/dashboard-filter-value-compatibility-DLkdeypb.cjs +0 -1
  99. package/dist/chunks/dashboard-json-BYQjTmqD.cjs +0 -1
  100. package/dist/chunks/format-types-PSZZ7hG8.cjs +0 -1
  101. package/dist/chunks/matrix-result-contract-Bhg60NtS.cjs +0 -1
  102. package/dist/chunks/pivot-header-presentation-CePk1R6g.cjs +0 -4
  103. package/dist/chunks/pivot-result-lifecycle-CcGt_29N.cjs +0 -1
  104. package/dist/chunks/report-preferences-dialog-DW40ECz1.cjs +0 -1
  105. package/dist/chunks/saved-temporal-bucket-format-DNMtD77o.cjs +0 -1
  106. package/dist/chunks/switch-B1mZx2k9.cjs +0 -138
  107. package/dist/chunks/temporal-bucket-9Wz9Ds6H.cjs +0 -1
  108. package/dist/chunks/temporal-bucket-authoring-DSpzgXHc.cjs +0 -1
  109. package/dist/chunks/validators-DcshgK7w.cjs +0 -1
@@ -1,39 +1,39 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("./switch-B1mZx2k9.cjs"),s=require("./index-Cd8qGOXl.cjs"),U=require("./x-B6ghREd2.cjs");require("./saved-temporal-bucket-format-DNMtD77o.cjs");require("./validators-DcshgK7w.cjs");require("./analyze-result-contract-OgPk-zGu.cjs");require("../value-format-preferences/index.cjs");const y=require("react");require("./appearance-context-DhyjbQk1.cjs");require("./index-ByFbacH7.cjs");require("./temporal-bucket-authoring-DSpzgXHc.cjs");require("./color-CyB5o13F.cjs");const cs=require("react-dom");require("./index-v2MZLyus.cjs");require("./appearance-runtime-provider-BgNYdUYH.cjs");const $=require("./dashboard-briefing-launcher-CXHq6ime.cjs"),wt=require("./search-BqqhaMx9.cjs"),St=require("./format-types-PSZZ7hG8.cjs"),us=require("./report-preferences-dialog-DW40ECz1.cjs"),ms=require("./use-debounced-dirty-check-XHSwAefL.cjs"),qe=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.cjs"),xt=require("./save-3dYRmehL.cjs"),hs=require("./palette-BN-jYtaK.cjs"),ps=require("./braces-v55uLCAK.cjs");function fs(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(a,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return a.default=t,Object.freeze(a)}const M=fs(y);/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("./switch-D12C40LN.cjs"),s=require("./index-DhDfPZUu.cjs"),U=require("./x-B6ghREd2.cjs");require("./card-config-utils-D3Xuu0ub.cjs");require("./validators-DqIM0B3C.cjs");require("./analyze-result-contract-BX_nQmPN.cjs");require("../value-format-preferences/index.cjs");const y=require("react");require("./appearance-context-DhyjbQk1.cjs");require("./index-ByFbacH7.cjs");require("./temporal-bucket-authoring-DueSgLJU.cjs");require("./color-CyB5o13F.cjs");const us=require("react-dom");require("./index-CXeIDdjd.cjs");require("./appearance-runtime-provider-BgNYdUYH.cjs");const $=require("./dashboard-briefing-launcher-DWwSdfV7.cjs"),St=require("./search-BqqhaMx9.cjs"),Dt=require("./index-ByQgqT9d.cjs"),Ge=require("./dashboard-filter-value-compatibility-ByT__CYM.cjs"),ms=require("./report-preferences-dialog--aV7ITSE.cjs"),hs=require("./use-debounced-dirty-check-XHSwAefL.cjs"),qe=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.cjs"),gt=require("./save-3dYRmehL.cjs"),ps=require("./palette-BN-jYtaK.cjs"),xs=require("./braces-v55uLCAK.cjs");function fs(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(a,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return a.default=t,Object.freeze(a)}const M=fs(y);/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const xs=U.createLucideIcon("Glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]);/**
6
+ */const gs=U.createLucideIcon("Glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]);/**
7
7
  * @license lucide-react v0.453.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const gs=U.createLucideIcon("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
11
+ */const bs=U.createLucideIcon("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
12
12
  * @license lucide-react v0.453.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const bs=U.createLucideIcon("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
16
+ */const vs=U.createLucideIcon("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
17
17
  * @license lucide-react v0.453.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const vs=U.createLucideIcon("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"}]]);/**
21
+ */const ys=U.createLucideIcon("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"}]]);/**
22
22
  * @license lucide-react v0.453.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const ys=U.createLucideIcon("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"}]]);/**
26
+ */const js=U.createLucideIcon("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"}]]);/**
27
27
  * @license lucide-react v0.453.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const js=U.createLucideIcon("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"}]]);/**
31
+ */const ws=U.createLucideIcon("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"}]]);/**
32
32
  * @license lucide-react v0.453.0 - ISC
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const Dt=U.createLucideIcon("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);var Ge={exports:{}},Be={};/**
36
+ */const Nt=U.createLucideIcon("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);var ze={exports:{}},Be={};/**
37
37
  * @license React
38
38
  * use-sync-external-store-shim.production.js
39
39
  *
@@ -41,7 +41,7 @@
41
41
  *
42
42
  * This source code is licensed under the MIT license found in the
43
43
  * LICENSE file in the root directory of this source tree.
44
- */var gt;function ws(){if(gt)return Be;gt=1;var t=y;function a(u,x){return u===x&&(u!==0||1/u===1/x)||u!==u&&x!==x}var n=typeof Object.is=="function"?Object.is:a,r=t.useState,o=t.useEffect,c=t.useLayoutEffect,p=t.useDebugValue;function f(u,x){var i=x(),v=r({inst:{value:i,getSnapshot:x}}),j=v[0].inst,S=v[1];return c(function(){j.value=i,j.getSnapshot=x,b(j)&&S({inst:j})},[u,i,x]),o(function(){return b(j)&&S({inst:j}),u(function(){b(j)&&S({inst:j})})},[u]),p(i),i}function b(u){var x=u.getSnapshot;u=u.value;try{var i=x();return!n(u,i)}catch{return!0}}function g(u,x){return x()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?g:f;return Be.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:m,Be}var $e={};/**
44
+ */var bt;function Ss(){if(bt)return Be;bt=1;var t=y;function a(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var n=typeof Object.is=="function"?Object.is:a,r=t.useState,o=t.useEffect,c=t.useLayoutEffect,p=t.useDebugValue;function x(u,f){var i=f(),v=r({inst:{value:i,getSnapshot:f}}),j=v[0].inst,S=v[1];return c(function(){j.value=i,j.getSnapshot=f,b(j)&&S({inst:j})},[u,i,f]),o(function(){return b(j)&&S({inst:j}),u(function(){b(j)&&S({inst:j})})},[u]),p(i),i}function b(u){var f=u.getSnapshot;u=u.value;try{var i=f();return!n(u,i)}catch{return!0}}function g(u,f){return f()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?g:x;return Be.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:m,Be}var $e={};/**
45
45
  * @license React
46
46
  * use-sync-external-store-shim.development.js
47
47
  *
@@ -49,4 +49,4 @@
49
49
  *
50
50
  * This source code is licensed under the MIT license found in the
51
51
  * LICENSE file in the root directory of this source tree.
52
- */var bt;function Ss(){return bt||(bt=1,process.env.NODE_ENV!=="production"&&function(){function t(i,v){return i===v&&(i!==0||1/i===1/v)||i!==i&&v!==v}function a(i,v){m||o.startTransition===void 0||(m=!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 j=v();if(!u){var S=v();c(j,S)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}S=p({inst:{value:j,getSnapshot:v}});var D=S[0].inst,C=S[1];return b(function(){D.value=j,D.getSnapshot=v,n(D)&&C({inst:D})},[i,j,v]),f(function(){return n(D)&&C({inst:D}),i(function(){n(D)&&C({inst:D})})},[i]),g(j),j}function n(i){var v=i.getSnapshot;i=i.value;try{var j=v();return!c(i,j)}catch{return!0}}function r(i,v){return v()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=y,c=typeof Object.is=="function"?Object.is:t,p=o.useState,f=o.useEffect,b=o.useLayoutEffect,g=o.useDebugValue,m=!1,u=!1,x=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:a;$e.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:x,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),$e}process.env.NODE_ENV==="production"?Ge.exports=ws():Ge.exports=Ss();var Ds=Ge.exports;const Me=["light","dark","system"];function Ns(){const{theme:t,setTheme:a}=s.useTheme(),n=l.useDashboardStore(p=>p.actions.setDashboardTheme);function r(){const p=Me.includes(t)?t:"system",f=Me[(Me.indexOf(p)+1)%Me.length];a(f),n(f)}const o=t==="light"?ys:t==="dark"?bs:gs,c=t==="light"?"Theme: light (click for dark)":t==="dark"?"Theme: dark (click for system)":"Theme: system (click for light)";return e.jsx(l.Button,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:r,"aria-label":c,title:c,children:e.jsx(o,{className:"h-3.5 w-3.5",strokeWidth:1.5})})}function Nt(t){const a=new Date().toISOString(),n=s.buildDashboardSheetsInputExecutionSnapshot({dashboard:t.dashboard,sheetIds:(t.dashboard.sheets||[]).filter(r=>r.kind!=="document").map(r=>r.id),sheetKind:"dashboard",mode:"dashboard",generatedAt:a,runtimeValues:{dashboardInputValues:t.dashboardInputValues,filterValues:t.filterValues,controlValues:t.controlValues,inlineFilterValuesMap:t.inlineFilterValuesMap,cardControlValuesMap:t.cardControlValuesMap}}).snapshot;return{generatedAt:a,dashboardInputValues:n.dashboardInputValues}}async function Cs(t,a,n,r,o,c){if(!c)return null;const p=JSON.stringify(n),f=`${t}/v1/lens`;return await l.postRequest(f,c,{name:a,template:p,filterValues:r,inputValues:o,operation:"create"})}async function ze(t,a,n){if(!n)return null;const{id:r,template:o,filterValues:c,inputValues:p,isDefault:f,shared:b}=a,g=`${t}/v1/lens`;return await l.postRequest(g,n,{lensId:r,template:o,filterValues:c,inputValues:p,isDefault:f,shared:b,operation:"update"})}async function ks(t,a,n){if(!n)return null;const r=`${t}/v1/lens`;return await l.postRequest(r,n,{operation:"delete",lensId:a})}const Ms="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Es({open:t,onOpenChange:a}={}){const[n,r]=y.useState(""),[o,c]=y.useState(!1),p=l.useDashboardStore(h=>h.lenses),{setLenses:f,setSelectedLensId:b}=l.useDashboardActions(),[g,m]=y.useState(!1),[u,x]=y.useState(!1),i=t!==void 0,v=i?t:u,j=h=>{i||x(h),a==null||a(h)},S=l.useDashboardStore(h=>h.dashboard),D=l.useDashboardStore(h=>h.filterValues),{authToken:C,tokenProps:_}=s.useSemaphorContext();async function k(){m(!0);const h=l.useDashboardStore.getState(),T=Nt({dashboard:S,dashboardInputValues:h.dashboardInputValues,filterValues:D,controlValues:h.controlValues,inlineFilterValuesMap:h.inlineFilterValuesMap,cardControlValuesMap:h.cardControlValuesMap}),R=await Cs(_.apiServiceUrl,n,S,D,T,C==null?void 0:C.accessToken);R&&(f([...p||[],R]),b(R.id),j(!1)),m(!1)}return e.jsxs(s.Dialog,{open:v,onOpenChange:j,children:[i?null:e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(l.Button,{variant:"secondary",size:"xs",children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Lens"]})}),e.jsxs(s.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[420px] sm:rounded-control",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:"Create lens"}),e.jsx(s.DialogDescription,{className:"text-[13px] leading-5",children:"Lenses are private by default and are only visible to you."})]}),e.jsxs("div",{className:"space-y-1.5 py-1",children:[e.jsx(l.Label,{htmlFor:"lens-name",className:Ms,children:"Name"}),e.jsx(l.Input,{id:"lens-name",size:"xs",value:n,placeholder:"Monthly review, West region, …",onChange:h=>r(h.target.value)}),o&&e.jsx("p",{className:"text-[12px] text-destructive",children:"A lens with this name already exists. Pick a different one."})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(l.Button,{variant:"outline",size:"xs",onClick:()=>j(!1),children:"Cancel"}),e.jsx(l.Button,{size:"xs",type:"submit",onClick:k,disabled:g||!n.trim(),children:g?"Creating…":"Create"})]})]})]})}function Is({includeLabel:t=!1}={}){const a=l.useDashboardStore(m=>m.lenses),n=l.useDashboardStore(m=>m.selectedLensId),{setLenses:r,setSelectedLensId:o}=l.useDashboardActions(),{authToken:c,tokenProps:p}=s.useSemaphorContext();async function f(m){o(m)}async function b(m){if(await ks(p.apiServiceUrl,m,c==null?void 0:c.accessToken)){const x=a==null?void 0:a.filter(i=>i.id!==m);r(x||[]),o("original")}}async function g(m){const u=a==null?void 0:a.map(v=>v.id===m.id?{...v,isDefault:!m.isDefault}:{...v,isDefault:!1});r(u||[]);const x={...m,isDefault:!m.isDefault};await ze(p.apiServiceUrl,x,c==null?void 0:c.accessToken);const i=a==null?void 0:a.find(v=>v.isDefault);if(i&&i.id!==m.id){const v={...i,isDefault:!1};await ze(p.apiServiceUrl,v,c==null?void 0:c.accessToken)}}return e.jsxs(e.Fragment,{children:[t?e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(s.DropdownMenuSeparator,{})]}):null,e.jsxs(s.DropdownMenuRadioGroup,{value:n,onValueChange:f,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),a==null?void 0:a.map(m=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:m.id,children:[e.jsx("p",{children:m.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:u=>{u.preventDefault(),g(m)},className:l.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!m.isDefault,"text-green-500":m.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:u=>{u.preventDefault(),b(m.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},m.id))]})]})}function Ls(){const{displayPreferences:t,shouldShowElement:a}=s.useDisplayPreferences(),{currentUser:n,userContext:r}=s.useCurrentUserInfo(),o=y.useMemo(()=>s.getRoleBasedDisplayOverrides(n),[n]),c=y.useMemo(()=>f=>o&&o[f]!==void 0&&o[f]===!1?!1:a(f),[o,a,t]),p=y.useMemo(()=>{var f,b,g,m,u;return{canEdit:((f=r==null?void 0:r.permissions)==null?void 0:f.canEdit)??s.canUserEdit(n),canUseFilters:((b=r==null?void 0:r.permissions)==null?void 0:b.canEdit)??s.canUserUseFilters(n),canManageDashboards:((g=r==null?void 0:r.permissions)==null?void 0:g.canCreateDashboard)??s.canUserManageDashboards(n),canCreateDashboards:((m=r==null?void 0:r.permissions)==null?void 0:m.canCreateDashboard)??s.canUserCreateDashboards(n),canAccessVisuals:((u=r==null?void 0:r.permissions)==null?void 0:u.canEdit)??s.canUserAccessVisuals(n)}},[n,r]);return{displayPreferences:t,shouldShowElement:c,permissions:p,currentUser:n}}function As(t,a=[]){let n=[];function r(c,p){const f=M.createContext(p);f.displayName=c+"Context";const b=n.length;n=[...n,p];const g=u=>{var D;const{scope:x,children:i,...v}=u,j=((D=x==null?void 0:x[t])==null?void 0:D[b])||f,S=M.useMemo(()=>v,Object.values(v));return e.jsx(j.Provider,{value:S,children:i})};g.displayName=c+"Provider";function m(u,x){var j;const i=((j=x==null?void 0:x[t])==null?void 0:j[b])||f,v=M.useContext(i);if(v)return v;if(p!==void 0)return p;throw new Error(`\`${u}\` must be used within \`${c}\``)}return[g,m]}const o=()=>{const c=n.map(p=>M.createContext(p));return function(f){const b=(f==null?void 0:f[t])||c;return M.useMemo(()=>({[`__scope${t}`]:{...f,[t]:b}}),[f,b])}};return o.scopeName=t,[r,Ps(o,...a)]}function Ps(...t){const a=t[0];if(t.length===1)return a;const n=()=>{const r=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(c){const p=r.reduce((f,{useScope:b,scopeName:g})=>{const u=b(c)[`__scope${g}`];return{...f,...u}},{});return M.useMemo(()=>({[`__scope${a.scopeName}`]:p}),[p])}};return n.scopeName=a.scopeName,n}var Os=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],He=Os.reduce((t,a)=>{const n=l.createSlot(`Primitive.${a}`),r=M.forwardRef((o,c)=>{const{asChild:p,...f}=o,b=p?n:a;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(b,{...f,ref:c})});return r.displayName=`Primitive.${a}`,{...t,[a]:r}},{});function Rs(){return Ds.useSyncExternalStore(_s,()=>!0,()=>!1)}function _s(){return()=>{}}var Ke="Avatar",[Us]=As(Ke),[Ts,Ct]=Us(Ke),kt=M.forwardRef((t,a)=>{const{__scopeAvatar:n,...r}=t,[o,c]=M.useState("idle");return e.jsx(Ts,{scope:n,imageLoadingStatus:o,onImageLoadingStatusChange:c,children:e.jsx(He.span,{...r,ref:a})})});kt.displayName=Ke;var Mt="AvatarImage",Et=M.forwardRef((t,a)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:o=()=>{},...c}=t,p=Ct(Mt,n),f=Fs(r,c),b=l.useCallbackRef(g=>{o(g),p.onImageLoadingStatusChange(g)});return l.useLayoutEffect2(()=>{f!=="idle"&&b(f)},[f,b]),f==="loaded"?e.jsx(He.img,{...c,ref:a,src:r}):null});Et.displayName=Mt;var It="AvatarFallback",Lt=M.forwardRef((t,a)=>{const{__scopeAvatar:n,delayMs:r,...o}=t,c=Ct(It,n),[p,f]=M.useState(r===void 0);return M.useEffect(()=>{if(r!==void 0){const b=window.setTimeout(()=>f(!0),r);return()=>window.clearTimeout(b)}},[r]),p&&c.imageLoadingStatus!=="loaded"?e.jsx(He.span,{...o,ref:a}):null});Lt.displayName=It;function vt(t,a){return t?a?(t.src!==a&&(t.src=a),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Fs(t,{referrerPolicy:a,crossOrigin:n}){const r=Rs(),o=M.useRef(null),c=r?(o.current||(o.current=new window.Image),o.current):null,[p,f]=M.useState(()=>vt(c,t));return l.useLayoutEffect2(()=>{f(vt(c,t))},[c,t]),l.useLayoutEffect2(()=>{const b=u=>()=>{f(u)};if(!c)return;const g=b("loaded"),m=b("error");return c.addEventListener("load",g),c.addEventListener("error",m),a&&(c.referrerPolicy=a),typeof n=="string"&&(c.crossOrigin=n),()=>{c.removeEventListener("load",g),c.removeEventListener("error",m)}},[c,n,a]),p}var At=kt,Pt=Et,Ot=Lt;const Rt=M.forwardRef(({className:t,...a},n)=>e.jsx(At,{ref:n,className:l.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...a}));Rt.displayName=At.displayName;const Vs=M.forwardRef(({className:t,...a},n)=>e.jsx(Pt,{ref:n,className:l.cn("aspect-square h-full w-full",t),...a}));Vs.displayName=Pt.displayName;const _t=M.forwardRef(({className:t,...a},n)=>e.jsx(Ot,{ref:n,className:l.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...a}));_t.displayName=Ot.displayName;const qs=async(t,a,n)=>{const r=`${t}/management/v1/groups`;return await l.postRequestRegular(r,a,n)},Bs=async(t,a,n,r)=>{const o=`${t}/management/v1/groups/${n}`;return l.requestJsonRegular(o,a,"PATCH",r)},$s=async(t,a,n)=>{const r=`${t}/management/v1/groups/${n}`;await l.requestJsonRegular(r,a,"DELETE")},Gs=async(t,a,n,r)=>{const o=`${t}/management/v1/groups/${n}/members`;return await l.postRequestRegular(o,a,r)},zs=async(t,a,n,r)=>{const o=`${t}/management/v1/groups/${n}/members`;await l.requestJsonRegular(o,a,"DELETE",r)};function Hs(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:r=>qs(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:()=>{n.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group created successfully")},onError:r=>{console.error("Failed to create group:",r),s.ue.error("Failed to create group",{description:l.getRequestErrorMessage(r,"Failed to create group")})}})}function Ks(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:o})=>Bs(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,o),onSuccess:(r,o)=>{n.invalidateQueries({queryKey:["group",o.groupId]}),n.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group updated successfully")},onError:r=>{console.error("Failed to update group:",r),s.ue.error("Failed to update group",{description:l.getRequestErrorMessage(r,"Failed to update group")})}})}function Qs(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:r=>$s(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:(r,o)=>{n.invalidateQueries({queryKey:["groups"]}),n.removeQueries({queryKey:["group",o]}),s.ue.success("Group deleted successfully")},onError:r=>{console.error("Failed to delete group:",r),s.ue.error("Failed to delete group",{description:l.getRequestErrorMessage(r,"Failed to delete group")})}})}function Ws(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:o})=>Gs(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,o),onSuccess:(r,o)=>{n.invalidateQueries({queryKey:["group",o.groupId]}),n.invalidateQueries({queryKey:["group-members",o.groupId]}),n.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members added successfully")},onError:r=>{console.error("Failed to add group members:",r),s.ue.error("Failed to add members",{description:l.getRequestErrorMessage(r,"Failed to add members")})}})}function Js(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:o})=>zs(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,o),onSuccess:(r,o)=>{n.invalidateQueries({queryKey:["group",o.groupId]}),n.invalidateQueries({queryKey:["group-members",o.groupId]}),n.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members removed successfully")},onError:r=>{console.error("Failed to remove group members:",r),s.ue.error("Failed to remove members",{description:l.getRequestErrorMessage(r,"Failed to remove members")})}})}const Xs=[];function Ys({open:t,onOpenChange:a}){var C,_,k;const{tokenProps:n}=s.useSemaphorContext(),{currentUser:r}=s.useCurrentUserInfo(),o=(r==null?void 0:r.type)==="tenant",c=n==null?void 0:n.tenantId,{groups:p,isLoading:f,error:b,refetch:g}=s.useGroups({type:o?"TENANT_GROUP":"all",tenantId:o?c:void 0,includeMembers:!1}),m=b?Ut(b,"Unable to load groups."):null,[u,x]=y.useState({kind:"list"}),[i,v]=y.useState(null),j=Qs();y.useEffect(()=>{t||(x({kind:"list"}),v(null))},[t]);const S=u.kind==="members"&&p.find(h=>h.id===u.groupId)||null,D=async()=>{if(i)try{await j.mutateAsync(i.id),v(null),x({kind:"list"}),g()}catch{}};return e.jsx(s.Dialog,{open:t,onOpenChange:a,children:e.jsxs(s.DialogContent,{className:"flex max-h-[640px] w-[720px] max-w-[92vw] flex-col gap-0 overflow-hidden p-0",children:[u.kind==="list"?e.jsxs("div",{className:"shrink-0 border-b border-border px-5 pt-4 pb-3.5",children:[e.jsx(s.DialogTitle,{className:"text-[15px] font-semibold tracking-tight",children:"Group management"}),e.jsx(s.DialogDescription,{className:"mt-1 text-[12px] leading-[1.5] text-muted-foreground",children:"Organize people into groups for shared access."})]}):u.kind==="create"?e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5",children:[e.jsx("button",{type:"button",onClick:()=>x({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:e.jsx(s.ArrowLeft,{className:"h-3.5 w-3.5"})}),e.jsx(s.DialogTitle,{className:"truncate text-[13px] font-medium",children:"New group"}),e.jsx(s.DialogDescription,{className:"sr-only",children:"Create a new group to organize members."})]}):null,u.kind==="list"&&e.jsx(Zs,{groups:p,isLoading:f,errorMessage:m,onRetry:()=>g(),currentUserId:r==null?void 0:r.id,onOpenGroup:h=>x({kind:"members",groupId:h}),onCreate:()=>x({kind:"create"}),onDeleteRequest:h=>v(h)}),u.kind==="members"&&S&&e.jsx(sr,{group:S,isTenantViewer:o,canEdit:((C=S.permissions)==null?void 0:C.canEdit)??S.createdBy===(r==null?void 0:r.id),canDelete:((_=S.permissions)==null?void 0:_.canDelete)??S.createdBy===(r==null?void 0:r.id),canManageMembers:((k=S.permissions)==null?void 0:k.canManageMembers)??S.createdBy===(r==null?void 0:r.id),onBack:()=>x({kind:"list"}),onMembersChanged:g,onUpdated:g,onRequestDelete:()=>v(S)},S.id),u.kind==="create"&&e.jsx(rr,{isTenantUser:o,tenantId:c,onCancel:()=>x({kind:"list"}),onCreated:h=>{g(),x({kind:"members",groupId:h})}}),i&&e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border bg-muted/40 px-5 py-2.5",children:[e.jsxs("div",{className:"min-w-0 text-[12px] text-foreground",children:["Delete ",e.jsx("span",{className:"font-medium",children:i.name}),"?",e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Members lose any access granted via this group."})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>v(null),disabled:j.isPending,className:"h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-background",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:D,disabled:j.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:[j.isPending?e.jsx(l.LoaderCircle,{className:"h-3 w-3 animate-spin"}):e.jsx(s.Trash2,{className:"h-3 w-3"}),"Delete group"]})]})]})]})})}function Zs({groups:t,isLoading:a,errorMessage:n,onRetry:r,currentUserId:o,onOpenGroup:c,onCreate:p,onDeleteRequest:f}){const[b,g]=y.useState(""),m=y.useMemo(()=>t.filter(u=>!b.trim()||u.name.toLowerCase().includes(b.toLowerCase())||(u.description||"").toLowerCase().includes(b.toLowerCase())),[t,b]);return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-5 py-2.5",children:[e.jsxs("div",{className:"flex flex-1 items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[e.jsx(wt.Search,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("input",{value:b,onChange:u=>g(u.target.value),placeholder:"Search groups…",className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"}),b&&e.jsx("button",{type:"button",onClick:()=>g(""),className:"flex h-4 w-4 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(U.X,{className:"h-2.5 w-2.5"})})]}),e.jsxs("button",{type:"button",onClick:p,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:[e.jsx(s.Plus,{className:"h-3 w-3"}),"New group"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:a?e.jsx("div",{className:"space-y-px p-3",children:[1,2,3].map(u=>e.jsx("div",{className:"h-12 animate-pulse rounded-[4px] bg-muted/60"},u))}):n?e.jsx(Tt,{title:"Can't load groups",message:n,onRetry:r}):m.length===0&&t.length===0?e.jsx(tr,{onCreate:p}):m.length===0?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1 py-10 text-center",children:[e.jsxs("div",{className:"text-[12px] text-foreground",children:['No groups match "',b,'"']}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Try a different search."})]}):m.map(u=>{var x;return e.jsx(er,{group:u,canDelete:((x=u.permissions)==null?void 0:x.canDelete)??u.createdBy===o,onClick:()=>c(u.id),onDelete:()=>f(u)},u.id)})})]})}function er({group:t,canDelete:a,onClick:n,onDelete:r}){let o="";try{o=St.format(new Date(t.createdAt),"MMM d, yyyy")}catch{o=""}return e.jsxs("button",{type:"button",onClick:n,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:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-[4px] border border-border bg-background text-muted-foreground",children:e.jsx(s.UsersRound,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13px] font-medium text-foreground",children:t.name}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Dt,{className:"h-2.5 w-2.5"}),t.memberCount," member",t.memberCount===1?"":"s"]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-border",children:"·"}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(s.Calendar,{className:"h-2.5 w-2.5"}),o]})]}),t.description&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-border",children:"·"}),e.jsx("span",{className:"truncate text-muted-foreground",children:t.description})]})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[a&&e.jsx("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:e.jsx(s.Trash2,{className:"h-3 w-3"})}),e.jsx(wt.ChevronRight,{className:"h-3.5 w-3.5 text-muted-foreground"})]})]})}function tr({onCreate:t}){return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-full border border-border bg-muted/40 text-muted-foreground",children:e.jsx(s.Users,{className:"h-4 w-4"})}),e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:"No groups yet"}),e.jsx("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."}),e.jsxs("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:[e.jsx(s.Plus,{className:"h-3 w-3"}),"New group"]})]})}function sr({group:t,isTenantViewer:a,canEdit:n,canDelete:r,canManageMembers:o,onBack:c,onMembersChanged:p,onUpdated:f,onRequestDelete:b}){const{data:g,isLoading:m,error:u,refetch:x}=s.useGroupMembers(t.id),i=(g==null?void 0:g.members)??Xs,v=u?Ut(u,"Unable to load members for this group."):null,j=t.type==="TENANT_GROUP"?"tenant":"organization",{users:S}=s.useUnifiedUsers({type:j,tenantId:t.tenantId||void 0,active:!0,limit:200}),D=y.useMemo(()=>new Set(i.map(w=>w.userId)),[i]),C=Ws(),_=Js(),k=Ks(),[h,T]=y.useState(!1),[R,F]=y.useState(t.name),[L,N]=y.useState(!1),[W,J]=y.useState(t.description||""),[G,ce]=y.useState(""),[ue,me]=y.useState(!1),he=y.useMemo(()=>{const w=G.trim().toLowerCase();return S.filter(V=>!D.has(V.id)).filter(V=>!w||(V.name||"").toLowerCase().includes(w)||(V.email||"").toLowerCase().includes(w)).slice(0,50)},[S,D,G]),pe=async()=>{const w=R.trim();if(T(!1),w.length>=3&&w!==t.name)try{await k.mutateAsync({groupId:t.id,data:{name:w}}),f()}catch{}},Z=async()=>{const w=W.trim();if(N(!1),w!==(t.description||""))try{await k.mutateAsync({groupId:t.id,data:{description:w}}),f()}catch{}},fe=async w=>{if(o){ce(""),me(!1);try{await C.mutateAsync({groupId:t.id,data:{userIds:[w.id],userType:j==="tenant"?"tenant":"org"}}),x(),p()}catch{}}},ee=async w=>{if(o)try{await _.mutateAsync({groupId:t.id,data:{userIds:[w]}}),x(),p()}catch{}};let X="";try{X=St.format(new Date(t.createdAt),"MMM d, yyyy")}catch{X=""}return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5",children:[e.jsx("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:e.jsx(s.ArrowLeft,{className:"h-3.5 w-3.5"})}),h?e.jsx("input",{autoFocus:!0,value:R,onChange:w=>F(w.target.value),onBlur:pe,onKeyDown:w=>{w.key==="Enter"&&pe(),w.key==="Escape"&&(F(t.name),T(!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"}):e.jsx("button",{type:"button",onClick:()=>{n&&(F(t.name),T(!0))},title:n?"Click to rename":t.name,disabled:!n,className:"truncate rounded-[3px] px-1 text-[13px] font-medium text-foreground enabled:hover:bg-accent disabled:cursor-default",children:t.name}),e.jsxs("span",{className:"ml-1 inline-flex shrink-0 items-center gap-1 text-[10.5px] text-muted-foreground",children:[e.jsx(Dt,{className:"h-2.5 w-2.5"}),i.length," member",i.length===1?"":"s"]})]}),e.jsx("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:L?e.jsxs("div",{children:[e.jsx("textarea",{autoFocus:!0,rows:2,value:W,onChange:w=>J(w.target.value),maxLength:200,onKeyDown:w=>{w.key==="Escape"&&(J(t.description||""),N(!1)),w.key==="Enter"&&(w.metaKey||w.ctrlKey)&&Z()},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"}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10.5px] text-muted-foreground",children:[W.length,"/200 · Esc to cancel · ⌘↩ to save"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>{J(t.description||""),N(!1)},className:"h-6 rounded-[5px] px-2 text-[11px] font-medium text-foreground/80 hover:bg-accent",children:"Cancel"}),e.jsx("button",{type:"button",onClick:Z,className:"inline-flex h-6 items-center rounded-[5px] bg-foreground px-2 text-[11px] font-medium text-background hover:opacity-90",children:"Save"})]})]})]}):e.jsxs("button",{type:"button",onClick:()=>{n&&(J(t.description||""),N(!0))},disabled:!n,title:n?"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?e.jsx("p",{className:"text-[12px] leading-[1.55] text-foreground/90",children:t.description}):e.jsx("p",{className:"text-[12px] leading-[1.55] text-muted-foreground",children:n?"Add a description…":"No description"}),e.jsxs("p",{className:"mt-1 text-[10.5px] text-muted-foreground",children:[X?`Created ${X}`:"Recently created",n?" · You can edit this group":""]})]})}),o&&e.jsx(nr,{query:G,setQuery:ce,open:ue,setOpen:me,candidates:he,showKindChip:!a,onAdd:fe,busy:C.isPending}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:m?e.jsx("div",{className:"space-y-px p-3",children:[1,2,3].map(w=>e.jsx("div",{className:"h-10 animate-pulse rounded-[4px] bg-muted/60"},w))}):v?e.jsx(Tt,{title:"Can't load members",message:v,onRetry:()=>x()}):i.length===0?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1 py-10 text-center",children:[e.jsx("div",{className:"text-[12px] text-foreground",children:"No members yet"}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:o?"Search above to add people to this group.":"This group does not have any members."})]}):i.map(w=>{var V,te,xe,z,H,K;return e.jsxs("div",{className:"group flex items-center gap-2 border-b border-border/60 px-5 py-2",children:[e.jsx(Ft,{name:((V=w.user)==null?void 0:V.name)||((te=w.user)==null?void 0:te.email)||"?"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12.5px] font-medium text-foreground",children:((xe=w.user)==null?void 0:xe.name)||((z=w.user)==null?void 0:z.email)||"Unknown"}),((H=w.user)==null?void 0:H.email)&&w.user.name&&e.jsx("div",{className:"truncate text-[10.5px] text-muted-foreground",children:w.user.email})]}),!a&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:w.userType}),e.jsx("button",{type:"button",onClick:()=>ee(w.userId),disabled:!o||_.isPending,"aria-label":`Remove ${((K=w.user)==null?void 0:K.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:e.jsx(U.X,{className:"h-3 w-3"})})]},w.id)})}),r&&e.jsx("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:e.jsxs("button",{type:"button",onClick:b,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:[e.jsx(s.Trash2,{className:"h-3 w-3"}),"Delete group"]})})]})}function rr({isTenantUser:t,tenantId:a,onCancel:n,onCreated:r}){const[o,c]=y.useState(""),[p,f]=y.useState(""),[b,g]=y.useState(null),m=Hs(),u=o.trim().length>=3&&o.trim().length<=50,x=async()=>{if(!u)return;g(null);const i={name:o.trim(),description:p.trim()||void 0,type:t?"TENANT_GROUP":"ORG_GROUP",...t&&a?{tenantId:a}:{}};try{const v=await m.mutateAsync(i),j=v==null?void 0:v.id;j?r(j):n()}catch(v){g(v instanceof Error?v.message:"Failed to create group")}};return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[e.jsx(yt,{children:"Name"}),e.jsx("input",{autoFocus:!0,value:o,onChange:i=>c(i.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"}),e.jsx("div",{className:"mt-1 text-[10.5px] text-muted-foreground",children:"3–50 characters."}),e.jsxs("div",{className:"mt-4",children:[e.jsx(yt,{children:"Description (optional)"}),e.jsx("textarea",{rows:2,value:p,onChange:i=>f(i.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"}),e.jsxs("div",{className:"mt-1 flex justify-end text-[10.5px] text-muted-foreground",children:[p.length,"/200"]})]}),b&&e.jsx("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:b})]}),e.jsxs("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:[e.jsx("button",{type:"button",onClick:n,disabled:m.isPending,className:"h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-accent",children:"Cancel"}),e.jsx("button",{type:"button",onClick:x,disabled:!u||m.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:m.isPending?e.jsxs(e.Fragment,{children:[e.jsx(l.LoaderCircle,{className:"h-3 w-3 animate-spin"}),"Creating…"]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Plus,{className:"h-3 w-3"}),"Create group"]})})]})]})}function nr({query:t,setQuery:a,open:n,setOpen:r,candidates:o,showKindChip:c,onAdd:p,busy:f}){const b=y.useRef(null),g=y.useRef(null),[m,u]=y.useState(null);y.useLayoutEffect(()=>{if(!n){u(null);return}const i=()=>{const v=b.current;if(!v)return;const j=v.getBoundingClientRect(),S=240,C=window.innerHeight-j.bottom<S+16&&j.top>S;u({left:j.left,top:C?j.top-6:j.bottom+6,width:j.width,above:C})};return i(),window.addEventListener("resize",i),window.addEventListener("scroll",i,!0),()=>{window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0)}},[n,o.length]),y.useEffect(()=>{if(!n)return;const i=v=>{var S,D;const j=v.target;(S=b.current)!=null&&S.contains(j)||(D=g.current)!=null&&D.contains(j)||r(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[n,r]);const x=n&&o.length>0&&m;return e.jsxs("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:[e.jsxs("div",{ref:b,className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[e.jsx(js,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("input",{value:t,onChange:i=>{a(i.target.value),r(!0)},onFocus:()=>r(!0),placeholder:"Add a member by name or email…",disabled:f,className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed"})]}),x&&typeof document<"u"&&cs.createPortal(e.jsx("div",{ref:g,style:{position:"fixed",left:m.left,top:m.top,width:m.width,transform:m.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:o.map(i=>e.jsxs("button",{type:"button",onClick:()=>p(i),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:[e.jsx(Ft,{name:i.name||i.email||"?"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12px] font-medium text-foreground",children:i.name||i.email||"Unknown"}),i.email&&i.name&&e.jsx("div",{className:"truncate text-[10.5px] text-muted-foreground",children:i.email})]}),c&&i.type&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:i.type==="tenant"?"tenant":"org"})]},i.id))}),document.body)]})}function Ut(t,a){if(!t)return a;if(t instanceof Error){const n=t.message||"",r=n.match(/\{[\s\S]*"error"\s*:\s*"([^"]+)"[\s\S]*\}/);return r?r[1]:n||a}return typeof t=="string"?t:a}function Tt({title:t,message:a,onRetry:n}){return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 py-10 text-center",children:[e.jsx("div",{className:"text-[12.5px] font-medium text-foreground",children:t}),e.jsx("div",{className:"max-w-[360px] text-[11.5px] leading-[1.55] text-muted-foreground",children:a}),n&&e.jsx("button",{type:"button",onClick:n,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 yt({children:t}){return e.jsx("label",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:t})}function Ft({name:t}){const a=t.split(" ").map(n=>n[0]).filter(Boolean).slice(0,2).join("").toUpperCase();return e.jsx(Rt,{className:"h-6 w-6 shrink-0",children:e.jsx(_t,{className:"text-[9px] font-semibold",children:a||"?"})})}function de(t,a,n){var c,p;const r=(t.controls||[]).find(f=>f.id===n);if(r)return r.label;const o=(p=(c=l.findCardById(t,a))==null?void 0:c.controls)==null?void 0:p.find(f=>f.id===n);return(o==null?void 0:o.label)||n}function le(t,a){var n;return((n=l.findCardById(t,a))==null?void 0:n.title)||a}function ar(t){const{errors:a,dashboard:n}=t;if(!n)return a;const r=new Map;for(const o of a){const c=o.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(c){const[,m,u]=c,x=`${m}:${u}:missing-metric`;r.has(x)||r.set(x,`"${le(n,m)}" has an outdated "${de(n,m,u)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue}const p=o.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(p){const[,m,u]=p,x=`${m}:${u}:missing-group-by`;r.has(x)||r.set(x,`"${le(n,m)}" has an outdated "${de(n,m,u)}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`);continue}const f=o.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/);if(f){const[,m,u]=f,x=`${m}:${u}:invalid-metric`;r.has(x)||r.set(x,`"${le(n,m)}" has an invalid "${de(n,m,u)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue}const b=o.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(b){const[,m,u]=b,x=`${m}:${u}:invalid-group-by`;r.has(x)||r.set(x,`"${le(n,m)}" has an invalid "${de(n,m,u)}" field mapping. Open the card controls and choose a valid field for each option.`);continue}const g=o.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(g){const[,m,u]=g,x=`${m}:${u}:missing-temporal-group-by`;r.has(x)||r.set(x,`"${le(n,m)}" can no longer use "${de(n,m,u)}" for time grain because the card does not currently group by a date field.`);continue}r.set(o,o)}return Array.from(r.values())}function or({visible:t,onSelect:a}){return t?e.jsxs(s.DropdownMenuItem,{onSelect:a,children:[e.jsx(s.CalendarClock,{className:"h-3.5 w-3.5"}),"Schedule email report"]}):null}function ir({scheduleReportVisible:t,analyticalBriefingVisible:a,onScheduleReport:n,onCreateAnalyticalBriefing:r}){return e.jsxs(e.Fragment,{children:[e.jsx(or,{visible:t,onSelect:n}),a?e.jsxs(s.DropdownMenuItem,{onSelect:r,children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Create analytical briefing"]}):null]})}function jt(t,a){return{dashboard:s.cloneDeep(t),semanticExecutionPayload:s.cloneDeep(a)}}function dr(){var ct,ut,mt,ht,pt;$.useExportRecovery(),$.useExportPolling();const{authToken:t,tokenProps:a,id:n,showBriefings:r}=s.useSemaphorContext(),o=s.useBriefingUiCapabilities(),{isLocalDev:c}=s.useDashboardPreferences(),{canEditDashboard:p,hasInspectionUser:f,inspectionMessage:b,isInspectionMode:g,isInspectionSurface:m}=s.useDashboardInteractionMode(),{openBrandStudioPreview:u}=s.useBrandStudioPreview(),{permissions:x}=Ls(),i=s.useHasDashboardId(),{isLoading:v}=s.useDashboardQuery(),j=l.useDashboardStore(d=>d.theme),S=l.useDashboardStore(d=>d.isDownloadingPdf),D=l.useDashboardStore(d=>d.dashboardAssistantDraftScopeKey),C=l.useDashboardStore(d=>d.lenses),_=l.useDashboardStore(d=>d.selectedLensId),k=C==null?void 0:C.find(d=>d.id===_),h=l.useDashboardStore(d=>d.dashboard),T=l.useDashboardStore(d=>d.selectedSheetId),R=(ct=h==null?void 0:h.sheets)==null?void 0:ct.find(d=>d.id===T),F=l.isDocumentSheet(R),L=F?(ut=R==null?void 0:R.document)==null?void 0:ut.page:void 0,N=l.useDashboardStore(d=>d.isDashboardEditing),{setDashboardTitle:W}=l.useDashboardStore(d=>d.actions),[J,G]=y.useState(!1),[ce,ue]=y.useState(!1),[me,he]=y.useState(!1),[pe,Z]=y.useState(!1),[fe,ee]=y.useState(null),[X,w]=y.useState(!1),[V,te]=y.useState(!1),[xe,z]=y.useState(!1),[H,K]=y.useState(null),[Qe,ge]=y.useState([]),[We,be]=y.useState(!1),[Vt,Je]=y.useState(!1),Xe=l.useDashboardStore(d=>d.filterValues),A=l.useDashboardStore(d=>d.isVisualEditing);l.useEditorStore(d=>d.card);const qt=s.useManagementStore(d=>d.selectedDashboard),Bt=s.useManagementStore(d=>d.initialDashboard);s.useManagementStore(d=>d.selectedVisual),l.useDashboardStore(d=>d.selectedFrameId),l.useEditorStore(d=>d.frame);const Ye=l.useDashboardStore(d=>d.showDashboardJSON),Ee=l.useDashboardStore(d=>d.onSaveFunction),{setIsDashboardEditing:Ze,setShowDashboardJSON:et}=l.useDashboardStore(d=>d.actions),{setInitialDashboard:tt,clearSelectedDashboard:Ie}=s.useManagementStore(d=>d.actions),se=!!a.orgUserId||!!(a.tenantId&&a.endUserId&&a.endUserEmail),{resources:ve}=s.useResourceManagement(s.ResourceType.DASHBOARD),{data:Le}=s.useUserPreferences(),$t=((mt=Le==null?void 0:Le.preference)==null?void 0:mt.defaultDashboardId)||null,{mutate:Gt,isPending:zt}=s.useDefaultDashboardMutation(),{currentUser:Ht}=s.useCurrentUserInfo(),Kt=s.canUserManageGroups(Ht),q=qt||Bt,Y=s.resolveDashboardControlsVisibility({config:a.config,canNavigateDashboardHub:se,canShareDashboard:((ht=q==null?void 0:q.permissions)==null?void 0:ht.canShare)===!0,canManageGroups:Kt}),st=q?{id:q.id,title:(h==null?void 0:h.title)||q.title||"Dashboard"}:null,{handleAddNewFrame:Qt}=s.useAddNewFrame(),[Ae,Pe]=y.useState(!1),[Wt,re]=y.useState(!1),[Oe,ye]=y.useState("close"),ne=s.useUpdateResource(s.ResourceType.DASHBOARD),[I,je]=y.useState(null),Jt=async(d,E)=>{if(!g){if(!(h!=null&&h.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:h.id,newTitle:d,previousTitle:E}),ne.mutate({resourceId:h.id,data:{title:d}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:O=>{console.error("Failed to update dashboard title:",O),s.ue.error("Failed to update dashboard title"),W(E)}})}};y.useEffect(()=>{if(ve&&ve.length>0){const d=h==null?void 0:h.id;if(d){const E=ve.find(O=>O.id===d);E&&tt(E)}}},[ve,h==null?void 0:h.id,tt]);const ae=a.orgUserId||a.tenantId,Re=y.useMemo(()=>lr({accessToken:t==null?void 0:t.accessToken,dashboardId:(h==null?void 0:h.id)||n||a.dashboard_id,selectedSheetId:F?T:void 0,pageSize:L==null?void 0:L.size,orientation:L==null?void 0:L.orientation,theme:j}),[t==null?void 0:t.accessToken,n,h==null?void 0:h.id,F,L==null?void 0:L.orientation,L==null?void 0:L.size,T,j,a.dashboard_id]),rt=N&&!A&&!g&&ae&&p,{setDashboard:_e}=l.useDashboardStore(d=>d.actions),nt=l.useDashboardStore(d=>d.semanticExecutionPayload),Xt=()=>{Ze(!0)},we=()=>{Ze(!1),et(!1),je(null)};y.useEffect(()=>{if(!N){I&&je(null);return}I||!h||v||je(jt(h,nt))},[h,I,N,v,nt]);const Se=(I==null?void 0:I.dashboard)??null,{isDirty:at,isDirtyPending:Yt,resetDirty:oe}=ms.useDebouncedDirtyCheck(h,Se,300,1e3,qe.serializeDashboardForDirtyCheck),ot=y.useCallback(()=>Se?qe.serializeDashboardForDirtyCheck(h)!==qe.serializeDashboardForDirtyCheck(Se):!1,[h,Se]),it=at||Yt,De=Ae||ne.isPending,Zt=()=>{if(g){I&&_e(I.dashboard,{semanticExecutionPayload:I.semanticExecutionPayload}),we(),oe();return}ot()?(ye("close"),re(!0)):(we(),oe())},es=async()=>{await Ue({closeAfterSave:!0,navigateHomeAfterSave:Oe==="home"})},ts=()=>{const d=Oe==="home"&&!!se;I&&_e(I.dashboard,{semanticExecutionPayload:I.semanticExecutionPayload}),we(),d&&Ie(),ye("close"),re(!1),oe()},ss=()=>{I&&(_e(I.dashboard,{semanticExecutionPayload:I.semanticExecutionPayload}),oe())},rs=()=>{if(se){if(N&&ot()){ye("home"),re(!0);return}Ie()}};async function Ue(d){if(g)return;const E=l.useDashboardStore.getState().dashboard;if(!E)return;const O=(d==null?void 0:d.closeAfterSave)??We,Te=(d==null?void 0:d.navigateHomeAfterSave)??!1;be(O),O&&re(!1);const Fe=s.cloneDeep(E);z(!0),K(null),ge([]),Pe(!0);const ls={template:E};ne.mutate({resourceId:E.id,data:ls},{onSuccess:P=>{var Ne,Ce,ft;const Q=(P==null?void 0:P.id)||((Ne=P==null?void 0:P.dashboard)==null?void 0:Ne.id)||((Ce=P==null?void 0:P.resource)==null?void 0:Ce.id)||((ft=P==null?void 0:P.template)==null?void 0:ft.id)||null;if(!E.id&&Q){const Ve=l.useAIInteractionStore.getState(),ke=Ve.pendingDashboardDraftMigration;(ke==null?void 0:ke.scopeKey)===D?Ve.actions.setPendingDashboardDraftMigrationExpectedDashboardId(Q):ke&&Ve.actions.clearPendingDashboardDraftMigration()}Pe(!1),s.ue.success("Dashboard saved!"),je(jt(Fe,l.useDashboardStore.getState().semanticExecutionPayload)),z(!1),be(!1),O&&(we(),oe(),Te&&se&&Ie()),ye("close")},onError:P=>{Pe(!1),K("Failed to save dashboard. Please try again.");const Q=P.details,Ne=Array.isArray(Q==null?void 0:Q.errors)?(Q.errors||[]).filter(Ce=>typeof Ce=="string"):[];ge(ar({errors:Ne,dashboard:E||void 0})),s.ue.error("Failed to save dashboard")}})}async function ns(){if(g||(G(!0),!_||!k))return;const d=l.useDashboardStore.getState().dashboard;if(!d){G(!1);return}const E=JSON.stringify(d),O=l.useDashboardStore.getState(),Te=Nt({dashboard:d,dashboardInputValues:O.dashboardInputValues,filterValues:Xe,controlValues:O.controlValues,inlineFilterValuesMap:O.inlineFilterValuesMap,cardControlValuesMap:O.cardControlValuesMap}),Fe={...k,template:E,filterValues:Xe,inputValues:Te};await ze(a.apiServiceUrl,Fe,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),Ee==null||Ee(d),G(!1)}const dt=(k==null?void 0:k.name)||h.title;ne.isPending&&console.log("Title during update:",{title:dt,dashboardStateTitle:h.title,dashboardId:h==null?void 0:h.id,currentLensName:k==null?void 0:k.name});const as=se&&!!(t!=null&&t.accessToken)&&!!(a!=null&&a.apiServiceUrl),os=!g&&Y.showDashboardHub&&as,is=!g&&i&&Y.showDashboardHub,B=(h==null?void 0:h.id)||null,lt=s.resolveDashboardBriefingsVisibility((pt=a.config)==null?void 0:pt.showBriefings,r),ie=!!B&&$t===B,ds=()=>{!B||g||Gt({dashboardId:ie?null:B})};return!i&&!A?null:e.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between gap-2 overflow-x-auto border-b px-4 py-2",role:"dashboard-controls",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[is&&!A&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:rs,className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(s.House,{className:"h-3.5 w-3.5"})}),!A&&i&&(v?e.jsx("div",{className:"h-4 w-28 animate-pulse rounded-md bg-muted/70","aria-label":"Loading dashboard title",role:"status",children:e.jsx("span",{className:"sr-only",children:"Loading dashboard title"})}):e.jsxs(e.Fragment,{children:[e.jsx(s.EditableText,{value:dt||"Untitled Dashboard",onSave:d=>{console.log("EditableText onSave called:",{newTitle:d,canEditDashboard:p,dashboardId:h==null?void 0:h.id});const E=(h==null?void 0:h.title)||"";W(d),Jt(d,E)},isEditable:s.resolveDashboardTitleEditability({isDashboardEditing:N,canEditDashboard:p===!0&&!g,hasCurrentLens:!!k}),displayClassName:"text-[13px] font-medium",inputClassName:"text-[13px] font-medium",placeholder:"Dashboard Title",isPending:ne.isPending}),Y.showDashboardHub&&ie&&e.jsx("span",{className:"shrink-0 rounded-[4px] border border-border/60 px-1.5 py-px text-[10px] font-medium uppercase tracking-[0.06em] text-muted-foreground",title:"Default dashboard",children:"Default"}),os&&B&&e.jsx(l.TooltipProvider,{children:e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx(l.Button,{variant:"ghost",size:"xs",onClick:ds,disabled:zt||!(t!=null&&t.accessToken)||!(a!=null&&a.apiServiceUrl),className:"w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":ie?"Clear default dashboard":"Set as default dashboard",children:ie?e.jsx(s.PinOff,{className:"h-3.5 w-3.5"}):e.jsx(s.Pin,{className:"h-3.5 w-3.5"})})}),e.jsx(l.TooltipContent,{children:e.jsx("p",{children:ie?"Clear default":"Set as default"})})]})})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[A&&e.jsxs(e.Fragment,{children:[e.jsx($.AdvancedModeToggle,{}),e.jsx($.VisualEditingControls,{})]}),!A&&i&&!g&&Y.showDashboardSharing&&e.jsxs(l.Button,{variant:"outline",size:"xs",onClick:()=>ue(!0),children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),!A&&N&&!g&&x.canUseFilters&&i&&e.jsx($.DashboardFilterControlsLauncher,{}),N&&!A&&!g&&ae&&k&&c&&i&&e.jsxs(l.Button,{variant:"secondary",size:"xs",disabled:J,onClick:ns,children:[e.jsx(xt.Save,{className:"h-3.5 w-3.5"}),"Save Lens"]}),N&&!A&&!g&&i&&!F&&e.jsxs("div",{className:"inline-flex h-7 items-stretch overflow-hidden rounded-control border border-input bg-background",children:[e.jsxs(l.Button,{variant:"ghost",size:"xs",disabled:!N,onClick:()=>void Qt(),className:"h-full rounded-none border-0 shadow-none hover:bg-accent",children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Visual"]}),e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(l.Button,{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:!N,children:e.jsx(U.ChevronDown,{className:"h-3.5 w-3.5"})})}),e.jsx(s.DropdownMenuContent,{align:"end",className:"z-[60] w-48 rounded-[6px] border-border/60 p-1 shadow-sm",children:e.jsxs(s.DropdownMenuItem,{onClick:()=>Je(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"From library..."]})})]}),e.jsx($.VisualsLibraryDialog,{open:Vt,onOpenChange:Je})]}),!A&&!N&&(p||g)&&(!m||!f||p!==void 0)&&i&&e.jsxs("div",{className:"inline-flex items-center gap-1",children:[e.jsxs(l.Button,{size:"xs",onClick:Xt,children:[e.jsx(s.Pencil,{className:"h-3.5 w-3.5"}),g?"Inspect":"Edit"]}),b?e.jsx(l.TooltipProvider,{children:e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx("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:e.jsx(l.Info,{"aria-hidden":"true",className:"size-3.5"})})}),e.jsx(l.TooltipContent,{children:e.jsx("p",{children:b})})]})}):null]}),rt&&i&&at&&e.jsxs(l.Button,{variant:"outline",size:"xs",onClick:ss,disabled:De,children:[e.jsx(s.Undo2,{className:"h-3.5 w-3.5"}),"Undo"]}),rt&&i&&e.jsxs(l.Button,{size:"xs",className:l.cn(!it&&"opacity-60"),disabled:De||!it,onClick:()=>Ue(),children:[De?e.jsx(l.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(xt.Save,{className:"h-3.5 w-3.5"}),De?"Saving...":"Save"]}),N&&!A&&i&&e.jsxs(l.Button,{variant:"outline",size:"xs",onClick:Zt,children:[e.jsx(s.Cross2Icon,{className:"h-3.5 w-3.5"}),"Close"]}),!A&&i&&e.jsx("div",{className:"ml-2",children:e.jsx($.NotificationBell,{})}),!A&&c&&e.jsx(Ns,{}),!A&&i&&!g&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"More Options",className:"w-7 px-0 text-muted-foreground hover:text-foreground",buttonProps:{size:"xs",variant:"ghost","aria-label":"More dashboard options"},children:e.jsx(s.EllipsisVertical,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-56 rounded-control border border-border/60 p-1 shadow-sm",children:[e.jsx(s.DropdownMenuLabel,{children:"Reports & briefings"}),e.jsxs(s.DropdownMenuItem,{disabled:S,onSelect:()=>te(!0),children:[e.jsx(s.Download,{className:"h-3.5 w-3.5"}),"Export"]}),e.jsx(ir,{scheduleReportVisible:!!(lt&&o.surfaceVisible&&B&&!N),analyticalBriefingVisible:!!(lt&&o.surfaceVisible&&B&&!N),onScheduleReport:()=>ee("scheduled_report"),onCreateAnalyticalBriefing:()=>ee("analytical_briefing")}),e.jsx(s.DropdownMenuSeparator,{}),Y.showGroupManagement&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{children:"Access"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>he(!0),children:[e.jsx(s.Users,{className:"h-3.5 w-3.5"}),"Manage Groups"]}),e.jsx(s.DropdownMenuSeparator,{})]}),e.jsx(s.DropdownMenuLabel,{children:"Preferences"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>Z(!0),children:[e.jsx(s.Calendar,{className:"h-3.5 w-3.5"}),"Report preferences"]}),c&&i&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuSeparator,{}),e.jsx(s.DropdownMenuLabel,{children:"Developer"}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>{var d;t!=null&&t.accessToken&&((d=navigator==null?void 0:navigator.clipboard)!=null&&d.writeText?navigator.clipboard.writeText(t.accessToken).then(()=>s.ue.success("Token copied to clipboard")).catch(()=>s.ue.error("Unable to copy token")):s.ue.error("Clipboard not available"))},children:[e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),"Copy token"]}),F&&e.jsxs(s.DropdownMenuItem,{disabled:!Re,onSelect:()=>{var d;if(!Re){s.ue.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(Re).then(()=>s.ue.success("Local document PDF URL copied to clipboard")).catch(()=>s.ue.error("Unable to copy local document PDF URL")):s.ue.error("Clipboard not available")},children:[e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),"Copy local document PDF URL"]}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>l.invalidateToken(a.apiServiceUrl),children:[e.jsx(vs,{className:"h-3.5 w-3.5"}),"Invalidate token"]}),e.jsxs(s.DropdownMenuItem,{onSelect:u,children:[e.jsx(hs.Palette,{className:"h-3.5 w-3.5"}),"Brand Studio"]}),N&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>et(!Ye),children:[e.jsx(ps.Braces,{className:"h-3.5 w-3.5"}),Ye?"Hide dashboard JSON":"Show dashboard JSON"]}),ae&&N&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>w(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add lens"]}),ae&&e.jsxs(s.DropdownMenuSub,{children:[e.jsxs(s.DropdownMenuSubTrigger,{children:[e.jsx(xs,{className:"h-3.5 w-3.5"}),"Lenses"]}),e.jsx(s.DropdownMenuSubContent,{className:"w-60",children:e.jsx(Is,{})})]})]})]})]}),ce&&st&&e.jsx(s.ShareDialog,{resource:st,resourceType:s.ResourceType.DASHBOARD,onClose:()=>ue(!1)}),Y.showGroupManagement&&e.jsx(Ys,{open:me,onOpenChange:he}),e.jsx(us.ReportPreferencesDialog,{open:pe,onOpenChange:Z}),B&&fe?e.jsx($.DashboardBriefingLauncher,{dashboardId:B,dashboardTitle:(h==null?void 0:h.title)||(q==null?void 0:q.title),open:!0,onOpenChange:d=>{d||ee(null)},hideTrigger:!0,workflowIntent:fe}):null,c&&ae&&i&&e.jsx(Es,{open:X,onOpenChange:w}),i&&e.jsx(s.DownloadPdf,{open:V,onOpenChange:te}),e.jsx(s.AlertDialog,{open:xe,onOpenChange:d=>{!d&&Ae&&!H||(z(d),d||(K(null),ge([]),be(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:H?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:H?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),Qe.length>0&&e.jsxs("div",{className:"space-y-1 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-left",children:[e.jsx("div",{className:"text-sm font-medium text-destructive",children:"What needs attention"}),e.jsx("ul",{className:"list-disc space-y-1 pl-4 text-xs text-muted-foreground",children:Qe.slice(0,5).map(d=>e.jsx("li",{children:d},d))})]})]}),e.jsx(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:H?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{z(!1),K(null),ge([]),be(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>Ue({closeAfterSave:We,navigateHomeAfterSave:Oe==="home"}),className:"m-0",children:"Retry"})]}):e.jsxs(s.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(l.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx($.UnsavedChangesAlert,{open:Wt,onOpenChange:d=>{re(d)},onSave:es,onDiscard:ts,isSaving:Ae,saveLabel:"Save",discardLabel:"Discard"})]})]})}function lr({accessToken:t,dashboardId:a,selectedSheetId:n,pageSize:r,orientation:o,theme:c}){if(!t||!n)return null;const p=new URL("http://localhost:5173/print-document");p.searchParams.set("token",t),a&&p.searchParams.set("dashboardId",a),p.searchParams.set("selectedSheetId",n),c&&p.searchParams.set("theme",c);const f=new URL("http://127.0.0.1:3002/");return f.searchParams.set("pdfMode","document"),f.searchParams.set("pageSize",r||"letter"),f.searchParams.set("orientation",o||"portrait"),f.searchParams.set("url",p.toString()),f.toString()}exports.default=dr;
52
+ */var vt;function Ds(){return vt||(vt=1,process.env.NODE_ENV!=="production"&&function(){function t(i,v){return i===v&&(i!==0||1/i===1/v)||i!==i&&v!==v}function a(i,v){m||o.startTransition===void 0||(m=!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 j=v();if(!u){var S=v();c(j,S)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}S=p({inst:{value:j,getSnapshot:v}});var D=S[0].inst,C=S[1];return b(function(){D.value=j,D.getSnapshot=v,n(D)&&C({inst:D})},[i,j,v]),x(function(){return n(D)&&C({inst:D}),i(function(){n(D)&&C({inst:D})})},[i]),g(j),j}function n(i){var v=i.getSnapshot;i=i.value;try{var j=v();return!c(i,j)}catch{return!0}}function r(i,v){return v()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=y,c=typeof Object.is=="function"?Object.is:t,p=o.useState,x=o.useEffect,b=o.useLayoutEffect,g=o.useDebugValue,m=!1,u=!1,f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:a;$e.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:f,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),$e}process.env.NODE_ENV==="production"?ze.exports=Ss():ze.exports=Ds();var Ns=ze.exports;const Me=["light","dark","system"];function Cs(){const{theme:t,setTheme:a}=s.useTheme(),n=l.useDashboardStore(p=>p.actions.setDashboardTheme);function r(){const p=Me.includes(t)?t:"system",x=Me[(Me.indexOf(p)+1)%Me.length];a(x),n(x)}const o=t==="light"?js:t==="dark"?vs:bs,c=t==="light"?"Theme: light (click for dark)":t==="dark"?"Theme: dark (click for system)":"Theme: system (click for light)";return e.jsx(l.Button,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:r,"aria-label":c,title:c,children:e.jsx(o,{className:"h-3.5 w-3.5",strokeWidth:1.5})})}function Ct(t){const a=new Date().toISOString(),n=s.buildDashboardSheetsInputExecutionSnapshot({dashboard:t.dashboard,sheetIds:(t.dashboard.sheets||[]).filter(r=>r.kind!=="document").map(r=>r.id),sheetKind:"dashboard",mode:"dashboard",generatedAt:a,runtimeValues:{dashboardInputValues:t.dashboardInputValues,filterValues:t.filterValues,controlValues:t.controlValues,inlineFilterValuesMap:t.inlineFilterValuesMap,cardControlValuesMap:t.cardControlValuesMap}}).snapshot;return{generatedAt:a,dashboardInputValues:n.dashboardInputValues}}async function ks(t,a,n,r,o,c){if(!c)return null;const p=JSON.stringify(n),x=`${t}/v1/lens`;return await l.postRequest(x,c,{name:a,template:p,filterValues:r,inputValues:o,operation:"create"})}async function He(t,a,n){if(!n)return null;const{id:r,template:o,filterValues:c,inputValues:p,isDefault:x,shared:b}=a,g=`${t}/v1/lens`;return await l.postRequest(g,n,{lensId:r,template:o,filterValues:c,inputValues:p,isDefault:x,shared:b,operation:"update"})}async function Ms(t,a,n){if(!n)return null;const r=`${t}/v1/lens`;return await l.postRequest(r,n,{operation:"delete",lensId:a})}const Es="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Is({open:t,onOpenChange:a}={}){const[n,r]=y.useState(""),[o,c]=y.useState(!1),p=l.useDashboardStore(h=>h.lenses),{setLenses:x,setSelectedLensId:b}=l.useDashboardActions(),[g,m]=y.useState(!1),[u,f]=y.useState(!1),i=t!==void 0,v=i?t:u,j=h=>{i||f(h),a==null||a(h)},S=l.useDashboardStore(h=>h.dashboard),D=l.useDashboardStore(h=>h.filterValues),{authToken:C,tokenProps:_}=s.useSemaphorContext();async function k(){m(!0);const h=l.useDashboardStore.getState(),T=Ct({dashboard:S,dashboardInputValues:h.dashboardInputValues,filterValues:D,controlValues:h.controlValues,inlineFilterValuesMap:h.inlineFilterValuesMap,cardControlValuesMap:h.cardControlValuesMap}),R=await ks(_.apiServiceUrl,n,S,D,T,C==null?void 0:C.accessToken);R&&(x([...p||[],R]),b(R.id),j(!1)),m(!1)}return e.jsxs(s.Dialog,{open:v,onOpenChange:j,children:[i?null:e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(l.Button,{variant:"secondary",size:"xs",children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Lens"]})}),e.jsxs(s.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[420px] sm:rounded-control",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:"Create lens"}),e.jsx(s.DialogDescription,{className:"text-[13px] leading-5",children:"Lenses are private by default and are only visible to you."})]}),e.jsxs("div",{className:"space-y-1.5 py-1",children:[e.jsx(l.Label,{htmlFor:"lens-name",className:Es,children:"Name"}),e.jsx(l.Input,{id:"lens-name",size:"xs",value:n,placeholder:"Monthly review, West region, …",onChange:h=>r(h.target.value)}),o&&e.jsx("p",{className:"text-[12px] text-destructive",children:"A lens with this name already exists. Pick a different one."})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(l.Button,{variant:"outline",size:"xs",onClick:()=>j(!1),children:"Cancel"}),e.jsx(l.Button,{size:"xs",type:"submit",onClick:k,disabled:g||!n.trim(),children:g?"Creating…":"Create"})]})]})]})}function Ls({includeLabel:t=!1}={}){const a=l.useDashboardStore(m=>m.lenses),n=l.useDashboardStore(m=>m.selectedLensId),{setLenses:r,setSelectedLensId:o}=l.useDashboardActions(),{authToken:c,tokenProps:p}=s.useSemaphorContext();async function x(m){o(m)}async function b(m){if(await Ms(p.apiServiceUrl,m,c==null?void 0:c.accessToken)){const f=a==null?void 0:a.filter(i=>i.id!==m);r(f||[]),o("original")}}async function g(m){const u=a==null?void 0:a.map(v=>v.id===m.id?{...v,isDefault:!m.isDefault}:{...v,isDefault:!1});r(u||[]);const f={...m,isDefault:!m.isDefault};await He(p.apiServiceUrl,f,c==null?void 0:c.accessToken);const i=a==null?void 0:a.find(v=>v.isDefault);if(i&&i.id!==m.id){const v={...i,isDefault:!1};await He(p.apiServiceUrl,v,c==null?void 0:c.accessToken)}}return e.jsxs(e.Fragment,{children:[t?e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(s.DropdownMenuSeparator,{})]}):null,e.jsxs(s.DropdownMenuRadioGroup,{value:n,onValueChange:x,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),a==null?void 0:a.map(m=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:m.id,children:[e.jsx("p",{children:m.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:u=>{u.preventDefault(),g(m)},className:l.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!m.isDefault,"text-green-500":m.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:u=>{u.preventDefault(),b(m.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},m.id))]})]})}function As(){const{displayPreferences:t,shouldShowElement:a}=s.useDisplayPreferences(),{currentUser:n,userContext:r}=s.useCurrentUserInfo(),o=y.useMemo(()=>s.getRoleBasedDisplayOverrides(n),[n]),c=y.useMemo(()=>x=>o&&o[x]!==void 0&&o[x]===!1?!1:a(x),[o,a,t]),p=y.useMemo(()=>{var x,b,g,m,u;return{canEdit:((x=r==null?void 0:r.permissions)==null?void 0:x.canEdit)??s.canUserEdit(n),canUseFilters:((b=r==null?void 0:r.permissions)==null?void 0:b.canEdit)??s.canUserUseFilters(n),canManageDashboards:((g=r==null?void 0:r.permissions)==null?void 0:g.canCreateDashboard)??s.canUserManageDashboards(n),canCreateDashboards:((m=r==null?void 0:r.permissions)==null?void 0:m.canCreateDashboard)??s.canUserCreateDashboards(n),canAccessVisuals:((u=r==null?void 0:r.permissions)==null?void 0:u.canEdit)??s.canUserAccessVisuals(n)}},[n,r]);return{displayPreferences:t,shouldShowElement:c,permissions:p,currentUser:n}}function Ps(t,a=[]){let n=[];function r(c,p){const x=M.createContext(p);x.displayName=c+"Context";const b=n.length;n=[...n,p];const g=u=>{var D;const{scope:f,children:i,...v}=u,j=((D=f==null?void 0:f[t])==null?void 0:D[b])||x,S=M.useMemo(()=>v,Object.values(v));return e.jsx(j.Provider,{value:S,children:i})};g.displayName=c+"Provider";function m(u,f){var j;const i=((j=f==null?void 0:f[t])==null?void 0:j[b])||x,v=M.useContext(i);if(v)return v;if(p!==void 0)return p;throw new Error(`\`${u}\` must be used within \`${c}\``)}return[g,m]}const o=()=>{const c=n.map(p=>M.createContext(p));return function(x){const b=(x==null?void 0:x[t])||c;return M.useMemo(()=>({[`__scope${t}`]:{...x,[t]:b}}),[x,b])}};return o.scopeName=t,[r,Os(o,...a)]}function Os(...t){const a=t[0];if(t.length===1)return a;const n=()=>{const r=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(c){const p=r.reduce((x,{useScope:b,scopeName:g})=>{const u=b(c)[`__scope${g}`];return{...x,...u}},{});return M.useMemo(()=>({[`__scope${a.scopeName}`]:p}),[p])}};return n.scopeName=a.scopeName,n}var Rs=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ke=Rs.reduce((t,a)=>{const n=l.createSlot(`Primitive.${a}`),r=M.forwardRef((o,c)=>{const{asChild:p,...x}=o,b=p?n:a;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(b,{...x,ref:c})});return r.displayName=`Primitive.${a}`,{...t,[a]:r}},{});function _s(){return Ns.useSyncExternalStore(Us,()=>!0,()=>!1)}function Us(){return()=>{}}var Qe="Avatar",[Ts]=Ps(Qe),[Fs,kt]=Ts(Qe),Mt=M.forwardRef((t,a)=>{const{__scopeAvatar:n,...r}=t,[o,c]=M.useState("idle");return e.jsx(Fs,{scope:n,imageLoadingStatus:o,onImageLoadingStatusChange:c,children:e.jsx(Ke.span,{...r,ref:a})})});Mt.displayName=Qe;var Et="AvatarImage",It=M.forwardRef((t,a)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:o=()=>{},...c}=t,p=kt(Et,n),x=Vs(r,c),b=l.useCallbackRef(g=>{o(g),p.onImageLoadingStatusChange(g)});return l.useLayoutEffect2(()=>{x!=="idle"&&b(x)},[x,b]),x==="loaded"?e.jsx(Ke.img,{...c,ref:a,src:r}):null});It.displayName=Et;var Lt="AvatarFallback",At=M.forwardRef((t,a)=>{const{__scopeAvatar:n,delayMs:r,...o}=t,c=kt(Lt,n),[p,x]=M.useState(r===void 0);return M.useEffect(()=>{if(r!==void 0){const b=window.setTimeout(()=>x(!0),r);return()=>window.clearTimeout(b)}},[r]),p&&c.imageLoadingStatus!=="loaded"?e.jsx(Ke.span,{...o,ref:a}):null});At.displayName=Lt;function yt(t,a){return t?a?(t.src!==a&&(t.src=a),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Vs(t,{referrerPolicy:a,crossOrigin:n}){const r=_s(),o=M.useRef(null),c=r?(o.current||(o.current=new window.Image),o.current):null,[p,x]=M.useState(()=>yt(c,t));return l.useLayoutEffect2(()=>{x(yt(c,t))},[c,t]),l.useLayoutEffect2(()=>{const b=u=>()=>{x(u)};if(!c)return;const g=b("loaded"),m=b("error");return c.addEventListener("load",g),c.addEventListener("error",m),a&&(c.referrerPolicy=a),typeof n=="string"&&(c.crossOrigin=n),()=>{c.removeEventListener("load",g),c.removeEventListener("error",m)}},[c,n,a]),p}var Pt=Mt,Ot=It,Rt=At;const _t=M.forwardRef(({className:t,...a},n)=>e.jsx(Pt,{ref:n,className:l.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...a}));_t.displayName=Pt.displayName;const qs=M.forwardRef(({className:t,...a},n)=>e.jsx(Ot,{ref:n,className:l.cn("aspect-square h-full w-full",t),...a}));qs.displayName=Ot.displayName;const Ut=M.forwardRef(({className:t,...a},n)=>e.jsx(Rt,{ref:n,className:l.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...a}));Ut.displayName=Rt.displayName;const Bs=async(t,a,n)=>{const r=`${t}/management/v1/groups`;return await l.postRequestRegular(r,a,n)},$s=async(t,a,n,r)=>{const o=`${t}/management/v1/groups/${n}`;return l.requestJsonRegular(o,a,"PATCH",r)},Gs=async(t,a,n)=>{const r=`${t}/management/v1/groups/${n}`;await l.requestJsonRegular(r,a,"DELETE")},zs=async(t,a,n,r)=>{const o=`${t}/management/v1/groups/${n}/members`;return await l.postRequestRegular(o,a,r)},Hs=async(t,a,n,r)=>{const o=`${t}/management/v1/groups/${n}/members`;await l.requestJsonRegular(o,a,"DELETE",r)};function Ks(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:r=>Bs(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:()=>{n.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group created successfully")},onError:r=>{console.error("Failed to create group:",r),s.ue.error("Failed to create group",{description:l.getRequestErrorMessage(r,"Failed to create group")})}})}function Qs(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:o})=>$s(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,o),onSuccess:(r,o)=>{n.invalidateQueries({queryKey:["group",o.groupId]}),n.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group updated successfully")},onError:r=>{console.error("Failed to update group:",r),s.ue.error("Failed to update group",{description:l.getRequestErrorMessage(r,"Failed to update group")})}})}function Ws(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:r=>Gs(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:(r,o)=>{n.invalidateQueries({queryKey:["groups"]}),n.removeQueries({queryKey:["group",o]}),s.ue.success("Group deleted successfully")},onError:r=>{console.error("Failed to delete group:",r),s.ue.error("Failed to delete group",{description:l.getRequestErrorMessage(r,"Failed to delete group")})}})}function Js(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:o})=>zs(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,o),onSuccess:(r,o)=>{n.invalidateQueries({queryKey:["group",o.groupId]}),n.invalidateQueries({queryKey:["group-members",o.groupId]}),n.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members added successfully")},onError:r=>{console.error("Failed to add group members:",r),s.ue.error("Failed to add members",{description:l.getRequestErrorMessage(r,"Failed to add members")})}})}function Xs(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),n=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:o})=>Hs(a.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,o),onSuccess:(r,o)=>{n.invalidateQueries({queryKey:["group",o.groupId]}),n.invalidateQueries({queryKey:["group-members",o.groupId]}),n.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members removed successfully")},onError:r=>{console.error("Failed to remove group members:",r),s.ue.error("Failed to remove members",{description:l.getRequestErrorMessage(r,"Failed to remove members")})}})}const Ys=[];function Zs({open:t,onOpenChange:a}){var C,_,k;const{tokenProps:n}=s.useSemaphorContext(),{currentUser:r}=s.useCurrentUserInfo(),o=(r==null?void 0:r.type)==="tenant",c=n==null?void 0:n.tenantId,{groups:p,isLoading:x,error:b,refetch:g}=s.useGroups({type:o?"TENANT_GROUP":"all",tenantId:o?c:void 0,includeMembers:!1}),m=b?Tt(b,"Unable to load groups."):null,[u,f]=y.useState({kind:"list"}),[i,v]=y.useState(null),j=Ws();y.useEffect(()=>{t||(f({kind:"list"}),v(null))},[t]);const S=u.kind==="members"&&p.find(h=>h.id===u.groupId)||null,D=async()=>{if(i)try{await j.mutateAsync(i.id),v(null),f({kind:"list"}),g()}catch{}};return e.jsx(s.Dialog,{open:t,onOpenChange:a,children:e.jsxs(s.DialogContent,{className:"flex max-h-[640px] w-[720px] max-w-[92vw] flex-col gap-0 overflow-hidden p-0",children:[u.kind==="list"?e.jsxs("div",{className:"shrink-0 border-b border-border px-5 pt-4 pb-3.5",children:[e.jsx(s.DialogTitle,{className:"text-[15px] font-semibold tracking-tight",children:"Group management"}),e.jsx(s.DialogDescription,{className:"mt-1 text-[12px] leading-[1.5] text-muted-foreground",children:"Organize people into groups for shared access."})]}):u.kind==="create"?e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5",children:[e.jsx("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:e.jsx(s.ArrowLeft,{className:"h-3.5 w-3.5"})}),e.jsx(s.DialogTitle,{className:"truncate text-[13px] font-medium",children:"New group"}),e.jsx(s.DialogDescription,{className:"sr-only",children:"Create a new group to organize members."})]}):null,u.kind==="list"&&e.jsx(er,{groups:p,isLoading:x,errorMessage:m,onRetry:()=>g(),currentUserId:r==null?void 0:r.id,onOpenGroup:h=>f({kind:"members",groupId:h}),onCreate:()=>f({kind:"create"}),onDeleteRequest:h=>v(h)}),u.kind==="members"&&S&&e.jsx(rr,{group:S,isTenantViewer:o,canEdit:((C=S.permissions)==null?void 0:C.canEdit)??S.createdBy===(r==null?void 0:r.id),canDelete:((_=S.permissions)==null?void 0:_.canDelete)??S.createdBy===(r==null?void 0:r.id),canManageMembers:((k=S.permissions)==null?void 0:k.canManageMembers)??S.createdBy===(r==null?void 0:r.id),onBack:()=>f({kind:"list"}),onMembersChanged:g,onUpdated:g,onRequestDelete:()=>v(S)},S.id),u.kind==="create"&&e.jsx(nr,{isTenantUser:o,tenantId:c,onCancel:()=>f({kind:"list"}),onCreated:h=>{g(),f({kind:"members",groupId:h})}}),i&&e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border bg-muted/40 px-5 py-2.5",children:[e.jsxs("div",{className:"min-w-0 text-[12px] text-foreground",children:["Delete ",e.jsx("span",{className:"font-medium",children:i.name}),"?",e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Members lose any access granted via this group."})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>v(null),disabled:j.isPending,className:"h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-background",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:D,disabled:j.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:[j.isPending?e.jsx(l.LoaderCircle,{className:"h-3 w-3 animate-spin"}):e.jsx(s.Trash2,{className:"h-3 w-3"}),"Delete group"]})]})]})]})})}function er({groups:t,isLoading:a,errorMessage:n,onRetry:r,currentUserId:o,onOpenGroup:c,onCreate:p,onDeleteRequest:x}){const[b,g]=y.useState(""),m=y.useMemo(()=>t.filter(u=>!b.trim()||u.name.toLowerCase().includes(b.toLowerCase())||(u.description||"").toLowerCase().includes(b.toLowerCase())),[t,b]);return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-5 py-2.5",children:[e.jsxs("div",{className:"flex flex-1 items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[e.jsx(St.Search,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("input",{value:b,onChange:u=>g(u.target.value),placeholder:"Search groups…",className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"}),b&&e.jsx("button",{type:"button",onClick:()=>g(""),className:"flex h-4 w-4 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(U.X,{className:"h-2.5 w-2.5"})})]}),e.jsxs("button",{type:"button",onClick:p,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:[e.jsx(s.Plus,{className:"h-3 w-3"}),"New group"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:a?e.jsx("div",{className:"space-y-px p-3",children:[1,2,3].map(u=>e.jsx("div",{className:"h-12 animate-pulse rounded-[4px] bg-muted/60"},u))}):n?e.jsx(Ft,{title:"Can't load groups",message:n,onRetry:r}):m.length===0&&t.length===0?e.jsx(sr,{onCreate:p}):m.length===0?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1 py-10 text-center",children:[e.jsxs("div",{className:"text-[12px] text-foreground",children:['No groups match "',b,'"']}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Try a different search."})]}):m.map(u=>{var f;return e.jsx(tr,{group:u,canDelete:((f=u.permissions)==null?void 0:f.canDelete)??u.createdBy===o,onClick:()=>c(u.id),onDelete:()=>x(u)},u.id)})})]})}function tr({group:t,canDelete:a,onClick:n,onDelete:r}){let o="";try{o=Dt.format(new Date(t.createdAt),"MMM d, yyyy")}catch{o=""}return e.jsxs("button",{type:"button",onClick:n,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:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-[4px] border border-border bg-background text-muted-foreground",children:e.jsx(s.UsersRound,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13px] font-medium text-foreground",children:t.name}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Nt,{className:"h-2.5 w-2.5"}),t.memberCount," member",t.memberCount===1?"":"s"]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-border",children:"·"}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(s.Calendar,{className:"h-2.5 w-2.5"}),o]})]}),t.description&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-border",children:"·"}),e.jsx("span",{className:"truncate text-muted-foreground",children:t.description})]})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[a&&e.jsx("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:e.jsx(s.Trash2,{className:"h-3 w-3"})}),e.jsx(St.ChevronRight,{className:"h-3.5 w-3.5 text-muted-foreground"})]})]})}function sr({onCreate:t}){return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-full border border-border bg-muted/40 text-muted-foreground",children:e.jsx(s.Users,{className:"h-4 w-4"})}),e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:"No groups yet"}),e.jsx("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."}),e.jsxs("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:[e.jsx(s.Plus,{className:"h-3 w-3"}),"New group"]})]})}function rr({group:t,isTenantViewer:a,canEdit:n,canDelete:r,canManageMembers:o,onBack:c,onMembersChanged:p,onUpdated:x,onRequestDelete:b}){const{data:g,isLoading:m,error:u,refetch:f}=s.useGroupMembers(t.id),i=(g==null?void 0:g.members)??Ys,v=u?Tt(u,"Unable to load members for this group."):null,j=t.type==="TENANT_GROUP"?"tenant":"organization",{users:S}=s.useUnifiedUsers({type:j,tenantId:t.tenantId||void 0,active:!0,limit:200}),D=y.useMemo(()=>new Set(i.map(w=>w.userId)),[i]),C=Js(),_=Xs(),k=Qs(),[h,T]=y.useState(!1),[R,F]=y.useState(t.name),[L,N]=y.useState(!1),[W,J]=y.useState(t.description||""),[G,ce]=y.useState(""),[ue,me]=y.useState(!1),he=y.useMemo(()=>{const w=G.trim().toLowerCase();return S.filter(V=>!D.has(V.id)).filter(V=>!w||(V.name||"").toLowerCase().includes(w)||(V.email||"").toLowerCase().includes(w)).slice(0,50)},[S,D,G]),pe=async()=>{const w=R.trim();if(T(!1),w.length>=3&&w!==t.name)try{await k.mutateAsync({groupId:t.id,data:{name:w}}),x()}catch{}},Z=async()=>{const w=W.trim();if(N(!1),w!==(t.description||""))try{await k.mutateAsync({groupId:t.id,data:{description:w}}),x()}catch{}},xe=async w=>{if(o){ce(""),me(!1);try{await C.mutateAsync({groupId:t.id,data:{userIds:[w.id],userType:j==="tenant"?"tenant":"org"}}),f(),p()}catch{}}},ee=async w=>{if(o)try{await _.mutateAsync({groupId:t.id,data:{userIds:[w]}}),f(),p()}catch{}};let X="";try{X=Dt.format(new Date(t.createdAt),"MMM d, yyyy")}catch{X=""}return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5",children:[e.jsx("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:e.jsx(s.ArrowLeft,{className:"h-3.5 w-3.5"})}),h?e.jsx("input",{autoFocus:!0,value:R,onChange:w=>F(w.target.value),onBlur:pe,onKeyDown:w=>{w.key==="Enter"&&pe(),w.key==="Escape"&&(F(t.name),T(!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"}):e.jsx("button",{type:"button",onClick:()=>{n&&(F(t.name),T(!0))},title:n?"Click to rename":t.name,disabled:!n,className:"truncate rounded-[3px] px-1 text-[13px] font-medium text-foreground enabled:hover:bg-accent disabled:cursor-default",children:t.name}),e.jsxs("span",{className:"ml-1 inline-flex shrink-0 items-center gap-1 text-[10.5px] text-muted-foreground",children:[e.jsx(Nt,{className:"h-2.5 w-2.5"}),i.length," member",i.length===1?"":"s"]})]}),e.jsx("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:L?e.jsxs("div",{children:[e.jsx("textarea",{autoFocus:!0,rows:2,value:W,onChange:w=>J(w.target.value),maxLength:200,onKeyDown:w=>{w.key==="Escape"&&(J(t.description||""),N(!1)),w.key==="Enter"&&(w.metaKey||w.ctrlKey)&&Z()},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"}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10.5px] text-muted-foreground",children:[W.length,"/200 · Esc to cancel · ⌘↩ to save"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>{J(t.description||""),N(!1)},className:"h-6 rounded-[5px] px-2 text-[11px] font-medium text-foreground/80 hover:bg-accent",children:"Cancel"}),e.jsx("button",{type:"button",onClick:Z,className:"inline-flex h-6 items-center rounded-[5px] bg-foreground px-2 text-[11px] font-medium text-background hover:opacity-90",children:"Save"})]})]})]}):e.jsxs("button",{type:"button",onClick:()=>{n&&(J(t.description||""),N(!0))},disabled:!n,title:n?"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?e.jsx("p",{className:"text-[12px] leading-[1.55] text-foreground/90",children:t.description}):e.jsx("p",{className:"text-[12px] leading-[1.55] text-muted-foreground",children:n?"Add a description…":"No description"}),e.jsxs("p",{className:"mt-1 text-[10.5px] text-muted-foreground",children:[X?`Created ${X}`:"Recently created",n?" · You can edit this group":""]})]})}),o&&e.jsx(ar,{query:G,setQuery:ce,open:ue,setOpen:me,candidates:he,showKindChip:!a,onAdd:xe,busy:C.isPending}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:m?e.jsx("div",{className:"space-y-px p-3",children:[1,2,3].map(w=>e.jsx("div",{className:"h-10 animate-pulse rounded-[4px] bg-muted/60"},w))}):v?e.jsx(Ft,{title:"Can't load members",message:v,onRetry:()=>f()}):i.length===0?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1 py-10 text-center",children:[e.jsx("div",{className:"text-[12px] text-foreground",children:"No members yet"}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:o?"Search above to add people to this group.":"This group does not have any members."})]}):i.map(w=>{var V,te,fe,z,H,K;return e.jsxs("div",{className:"group flex items-center gap-2 border-b border-border/60 px-5 py-2",children:[e.jsx(Vt,{name:((V=w.user)==null?void 0:V.name)||((te=w.user)==null?void 0:te.email)||"?"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12.5px] font-medium text-foreground",children:((fe=w.user)==null?void 0:fe.name)||((z=w.user)==null?void 0:z.email)||"Unknown"}),((H=w.user)==null?void 0:H.email)&&w.user.name&&e.jsx("div",{className:"truncate text-[10.5px] text-muted-foreground",children:w.user.email})]}),!a&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:w.userType}),e.jsx("button",{type:"button",onClick:()=>ee(w.userId),disabled:!o||_.isPending,"aria-label":`Remove ${((K=w.user)==null?void 0:K.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:e.jsx(U.X,{className:"h-3 w-3"})})]},w.id)})}),r&&e.jsx("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:e.jsxs("button",{type:"button",onClick:b,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:[e.jsx(s.Trash2,{className:"h-3 w-3"}),"Delete group"]})})]})}function nr({isTenantUser:t,tenantId:a,onCancel:n,onCreated:r}){const[o,c]=y.useState(""),[p,x]=y.useState(""),[b,g]=y.useState(null),m=Ks(),u=o.trim().length>=3&&o.trim().length<=50,f=async()=>{if(!u)return;g(null);const i={name:o.trim(),description:p.trim()||void 0,type:t?"TENANT_GROUP":"ORG_GROUP",...t&&a?{tenantId:a}:{}};try{const v=await m.mutateAsync(i),j=v==null?void 0:v.id;j?r(j):n()}catch(v){g(v instanceof Error?v.message:"Failed to create group")}};return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[e.jsx(jt,{children:"Name"}),e.jsx("input",{autoFocus:!0,value:o,onChange:i=>c(i.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"}),e.jsx("div",{className:"mt-1 text-[10.5px] text-muted-foreground",children:"3–50 characters."}),e.jsxs("div",{className:"mt-4",children:[e.jsx(jt,{children:"Description (optional)"}),e.jsx("textarea",{rows:2,value:p,onChange:i=>x(i.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"}),e.jsxs("div",{className:"mt-1 flex justify-end text-[10.5px] text-muted-foreground",children:[p.length,"/200"]})]}),b&&e.jsx("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:b})]}),e.jsxs("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:[e.jsx("button",{type:"button",onClick:n,disabled:m.isPending,className:"h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-accent",children:"Cancel"}),e.jsx("button",{type:"button",onClick:f,disabled:!u||m.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:m.isPending?e.jsxs(e.Fragment,{children:[e.jsx(l.LoaderCircle,{className:"h-3 w-3 animate-spin"}),"Creating…"]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Plus,{className:"h-3 w-3"}),"Create group"]})})]})]})}function ar({query:t,setQuery:a,open:n,setOpen:r,candidates:o,showKindChip:c,onAdd:p,busy:x}){const b=y.useRef(null),g=y.useRef(null),[m,u]=y.useState(null);y.useLayoutEffect(()=>{if(!n){u(null);return}const i=()=>{const v=b.current;if(!v)return;const j=v.getBoundingClientRect(),S=240,C=window.innerHeight-j.bottom<S+16&&j.top>S;u({left:j.left,top:C?j.top-6:j.bottom+6,width:j.width,above:C})};return i(),window.addEventListener("resize",i),window.addEventListener("scroll",i,!0),()=>{window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0)}},[n,o.length]),y.useEffect(()=>{if(!n)return;const i=v=>{var S,D;const j=v.target;(S=b.current)!=null&&S.contains(j)||(D=g.current)!=null&&D.contains(j)||r(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[n,r]);const f=n&&o.length>0&&m;return e.jsxs("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:[e.jsxs("div",{ref:b,className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[e.jsx(ws,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("input",{value:t,onChange:i=>{a(i.target.value),r(!0)},onFocus:()=>r(!0),placeholder:"Add a member by name or email…",disabled:x,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"&&us.createPortal(e.jsx("div",{ref:g,style:{position:"fixed",left:m.left,top:m.top,width:m.width,transform:m.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:o.map(i=>e.jsxs("button",{type:"button",onClick:()=>p(i),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:[e.jsx(Vt,{name:i.name||i.email||"?"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12px] font-medium text-foreground",children:i.name||i.email||"Unknown"}),i.email&&i.name&&e.jsx("div",{className:"truncate text-[10.5px] text-muted-foreground",children:i.email})]}),c&&i.type&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:i.type==="tenant"?"tenant":"org"})]},i.id))}),document.body)]})}function Tt(t,a){if(!t)return a;if(t instanceof Error){const n=t.message||"",r=n.match(/\{[\s\S]*"error"\s*:\s*"([^"]+)"[\s\S]*\}/);return r?r[1]:n||a}return typeof t=="string"?t:a}function Ft({title:t,message:a,onRetry:n}){return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 py-10 text-center",children:[e.jsx("div",{className:"text-[12.5px] font-medium text-foreground",children:t}),e.jsx("div",{className:"max-w-[360px] text-[11.5px] leading-[1.55] text-muted-foreground",children:a}),n&&e.jsx("button",{type:"button",onClick:n,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 jt({children:t}){return e.jsx("label",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:t})}function Vt({name:t}){const a=t.split(" ").map(n=>n[0]).filter(Boolean).slice(0,2).join("").toUpperCase();return e.jsx(_t,{className:"h-6 w-6 shrink-0",children:e.jsx(Ut,{className:"text-[9px] font-semibold",children:a||"?"})})}function de(t,a,n){var c,p;const r=(t.controls||[]).find(x=>x.id===n);if(r)return r.label;const o=(p=(c=l.findCardById(t,a))==null?void 0:c.controls)==null?void 0:p.find(x=>x.id===n);return(o==null?void 0:o.label)||n}function le(t,a){var n;return((n=l.findCardById(t,a))==null?void 0:n.title)||a}function or(t){const{errors:a,dashboard:n}=t;if(!n)return a;const r=new Map;for(const o of a){const c=o.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(c){const[,m,u]=c,f=`${m}:${u}:missing-metric`;r.has(f)||r.set(f,`"${le(n,m)}" has an outdated "${de(n,m,u)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue}const p=o.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(p){const[,m,u]=p,f=`${m}:${u}:missing-group-by`;r.has(f)||r.set(f,`"${le(n,m)}" has an outdated "${de(n,m,u)}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`);continue}const x=o.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/);if(x){const[,m,u]=x,f=`${m}:${u}:invalid-metric`;r.has(f)||r.set(f,`"${le(n,m)}" has an invalid "${de(n,m,u)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue}const b=o.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(b){const[,m,u]=b,f=`${m}:${u}:invalid-group-by`;r.has(f)||r.set(f,`"${le(n,m)}" has an invalid "${de(n,m,u)}" field mapping. Open the card controls and choose a valid field for each option.`);continue}const g=o.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(g){const[,m,u]=g,f=`${m}:${u}:missing-temporal-group-by`;r.has(f)||r.set(f,`"${le(n,m)}" can no longer use "${de(n,m,u)}" for time grain because the card does not currently group by a date field.`);continue}r.set(o,o)}return Array.from(r.values())}function ir({visible:t,onSelect:a}){return t?e.jsxs(s.DropdownMenuItem,{onSelect:a,children:[e.jsx(s.CalendarClock,{className:"h-3.5 w-3.5"}),"Schedule email report"]}):null}function dr({scheduleReportVisible:t,analyticalBriefingVisible:a,onScheduleReport:n,onCreateAnalyticalBriefing:r}){return e.jsxs(e.Fragment,{children:[e.jsx(ir,{visible:t,onSelect:n}),a?e.jsxs(s.DropdownMenuItem,{onSelect:r,children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Create analytical briefing"]}):null]})}function wt(t,a){return{dashboard:Ge.cloneDeep(t),semanticExecutionPayload:Ge.cloneDeep(a)}}function lr(){var ut,mt,ht,pt,xt;$.useExportRecovery(),$.useExportPolling();const{authToken:t,tokenProps:a,id:n,showBriefings:r}=s.useSemaphorContext(),o=s.useBriefingUiCapabilities(),{isLocalDev:c}=s.useDashboardPreferences(),{canEditDashboard:p,hasInspectionUser:x,inspectionMessage:b,isInspectionMode:g,isInspectionSurface:m}=s.useDashboardInteractionMode(),{openBrandStudioPreview:u}=s.useBrandStudioPreview(),{permissions:f}=As(),i=s.useHasDashboardId(),{isLoading:v}=s.useDashboardQuery(),j=l.useDashboardStore(d=>d.theme),S=l.useDashboardStore(d=>d.isDownloadingPdf),D=l.useDashboardStore(d=>d.dashboardAssistantDraftScopeKey),C=l.useDashboardStore(d=>d.lenses),_=l.useDashboardStore(d=>d.selectedLensId),k=C==null?void 0:C.find(d=>d.id===_),h=l.useDashboardStore(d=>d.dashboard),T=l.useDashboardStore(d=>d.selectedSheetId),R=(ut=h==null?void 0:h.sheets)==null?void 0:ut.find(d=>d.id===T),F=l.isDocumentSheet(R),L=F?(mt=R==null?void 0:R.document)==null?void 0:mt.page:void 0,N=l.useDashboardStore(d=>d.isDashboardEditing),{setDashboardTitle:W}=l.useDashboardStore(d=>d.actions),[J,G]=y.useState(!1),[ce,ue]=y.useState(!1),[me,he]=y.useState(!1),[pe,Z]=y.useState(!1),[xe,ee]=y.useState(null),[X,w]=y.useState(!1),[V,te]=y.useState(!1),[fe,z]=y.useState(!1),[H,K]=y.useState(null),[We,ge]=y.useState([]),[Je,be]=y.useState(!1),[qt,Xe]=y.useState(!1),Ye=l.useDashboardStore(d=>d.filterValues),A=l.useDashboardStore(d=>d.isVisualEditing);l.useEditorStore(d=>d.card);const Bt=s.useManagementStore(d=>d.selectedDashboard),$t=s.useManagementStore(d=>d.initialDashboard);s.useManagementStore(d=>d.selectedVisual),l.useDashboardStore(d=>d.selectedFrameId),l.useEditorStore(d=>d.frame);const Ze=l.useDashboardStore(d=>d.showDashboardJSON),Ee=l.useDashboardStore(d=>d.onSaveFunction),{setIsDashboardEditing:et,setShowDashboardJSON:tt}=l.useDashboardStore(d=>d.actions),{setInitialDashboard:st,clearSelectedDashboard:Ie}=s.useManagementStore(d=>d.actions),se=!!a.orgUserId||!!(a.tenantId&&a.endUserId&&a.endUserEmail),{resources:ve}=s.useResourceManagement(s.ResourceType.DASHBOARD),{data:Le}=s.useUserPreferences(),Gt=((ht=Le==null?void 0:Le.preference)==null?void 0:ht.defaultDashboardId)||null,{mutate:zt,isPending:Ht}=s.useDefaultDashboardMutation(),{currentUser:Kt}=s.useCurrentUserInfo(),Qt=s.canUserManageGroups(Kt),q=Bt||$t,Y=s.resolveDashboardControlsVisibility({config:a.config,canNavigateDashboardHub:se,canShareDashboard:((pt=q==null?void 0:q.permissions)==null?void 0:pt.canShare)===!0,canManageGroups:Qt}),rt=q?{id:q.id,title:(h==null?void 0:h.title)||q.title||"Dashboard"}:null,{handleAddNewFrame:Wt}=s.useAddNewFrame(),[Ae,Pe]=y.useState(!1),[Jt,re]=y.useState(!1),[Oe,ye]=y.useState("close"),ne=s.useUpdateResource(s.ResourceType.DASHBOARD),[I,je]=y.useState(null),Xt=async(d,E)=>{if(!g){if(!(h!=null&&h.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:h.id,newTitle:d,previousTitle:E}),ne.mutate({resourceId:h.id,data:{title:d}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:O=>{console.error("Failed to update dashboard title:",O),s.ue.error("Failed to update dashboard title"),W(E)}})}};y.useEffect(()=>{if(ve&&ve.length>0){const d=h==null?void 0:h.id;if(d){const E=ve.find(O=>O.id===d);E&&st(E)}}},[ve,h==null?void 0:h.id,st]);const ae=a.orgUserId||a.tenantId,Re=y.useMemo(()=>cr({accessToken:t==null?void 0:t.accessToken,dashboardId:(h==null?void 0:h.id)||n||a.dashboard_id,selectedSheetId:F?T:void 0,pageSize:L==null?void 0:L.size,orientation:L==null?void 0:L.orientation,theme:j}),[t==null?void 0:t.accessToken,n,h==null?void 0:h.id,F,L==null?void 0:L.orientation,L==null?void 0:L.size,T,j,a.dashboard_id]),nt=N&&!A&&!g&&ae&&p,{setDashboard:_e}=l.useDashboardStore(d=>d.actions),at=l.useDashboardStore(d=>d.semanticExecutionPayload),Yt=()=>{et(!0)},we=()=>{et(!1),tt(!1),je(null)};y.useEffect(()=>{if(!N){I&&je(null);return}I||!h||v||je(wt(h,at))},[h,I,N,v,at]);const Se=(I==null?void 0:I.dashboard)??null,{isDirty:ot,isDirtyPending:Zt,resetDirty:oe}=hs.useDebouncedDirtyCheck(h,Se,300,1e3,qe.serializeDashboardForDirtyCheck),it=y.useCallback(()=>Se?qe.serializeDashboardForDirtyCheck(h)!==qe.serializeDashboardForDirtyCheck(Se):!1,[h,Se]),dt=ot||Zt,De=Ae||ne.isPending,es=()=>{if(g){I&&_e(I.dashboard,{semanticExecutionPayload:I.semanticExecutionPayload}),we(),oe();return}it()?(ye("close"),re(!0)):(we(),oe())},ts=async()=>{await Ue({closeAfterSave:!0,navigateHomeAfterSave:Oe==="home"})},ss=()=>{const d=Oe==="home"&&!!se;I&&_e(I.dashboard,{semanticExecutionPayload:I.semanticExecutionPayload}),we(),d&&Ie(),ye("close"),re(!1),oe()},rs=()=>{I&&(_e(I.dashboard,{semanticExecutionPayload:I.semanticExecutionPayload}),oe())},ns=()=>{if(se){if(N&&it()){ye("home"),re(!0);return}Ie()}};async function Ue(d){if(g)return;const E=l.useDashboardStore.getState().dashboard;if(!E)return;const O=(d==null?void 0:d.closeAfterSave)??Je,Te=(d==null?void 0:d.navigateHomeAfterSave)??!1;be(O),O&&re(!1);const Fe=Ge.cloneDeep(E);z(!0),K(null),ge([]),Pe(!0);const cs={template:E};ne.mutate({resourceId:E.id,data:cs},{onSuccess:P=>{var Ne,Ce,ft;const Q=(P==null?void 0:P.id)||((Ne=P==null?void 0:P.dashboard)==null?void 0:Ne.id)||((Ce=P==null?void 0:P.resource)==null?void 0:Ce.id)||((ft=P==null?void 0:P.template)==null?void 0:ft.id)||null;if(!E.id&&Q){const Ve=l.useAIInteractionStore.getState(),ke=Ve.pendingDashboardDraftMigration;(ke==null?void 0:ke.scopeKey)===D?Ve.actions.setPendingDashboardDraftMigrationExpectedDashboardId(Q):ke&&Ve.actions.clearPendingDashboardDraftMigration()}Pe(!1),s.ue.success("Dashboard saved!"),je(wt(Fe,l.useDashboardStore.getState().semanticExecutionPayload)),z(!1),be(!1),O&&(we(),oe(),Te&&se&&Ie()),ye("close")},onError:P=>{Pe(!1),K("Failed to save dashboard. Please try again.");const Q=P.details,Ne=Array.isArray(Q==null?void 0:Q.errors)?(Q.errors||[]).filter(Ce=>typeof Ce=="string"):[];ge(or({errors:Ne,dashboard:E||void 0})),s.ue.error("Failed to save dashboard")}})}async function as(){if(g||(G(!0),!_||!k))return;const d=l.useDashboardStore.getState().dashboard;if(!d){G(!1);return}const E=JSON.stringify(d),O=l.useDashboardStore.getState(),Te=Ct({dashboard:d,dashboardInputValues:O.dashboardInputValues,filterValues:Ye,controlValues:O.controlValues,inlineFilterValuesMap:O.inlineFilterValuesMap,cardControlValuesMap:O.cardControlValuesMap}),Fe={...k,template:E,filterValues:Ye,inputValues:Te};await He(a.apiServiceUrl,Fe,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),Ee==null||Ee(d),G(!1)}const lt=(k==null?void 0:k.name)||h.title;ne.isPending&&console.log("Title during update:",{title:lt,dashboardStateTitle:h.title,dashboardId:h==null?void 0:h.id,currentLensName:k==null?void 0:k.name});const os=se&&!!(t!=null&&t.accessToken)&&!!(a!=null&&a.apiServiceUrl),is=!g&&Y.showDashboardHub&&os,ds=!g&&i&&Y.showDashboardHub,B=(h==null?void 0:h.id)||null,ct=s.resolveDashboardBriefingsVisibility((xt=a.config)==null?void 0:xt.showBriefings,r),ie=!!B&&Gt===B,ls=()=>{!B||g||zt({dashboardId:ie?null:B})};return!i&&!A?null:e.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between gap-2 overflow-x-auto border-b px-4 py-2",role:"dashboard-controls",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[ds&&!A&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:ns,className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(s.House,{className:"h-3.5 w-3.5"})}),!A&&i&&(v?e.jsx("div",{className:"h-4 w-28 animate-pulse rounded-md bg-muted/70","aria-label":"Loading dashboard title",role:"status",children:e.jsx("span",{className:"sr-only",children:"Loading dashboard title"})}):e.jsxs(e.Fragment,{children:[e.jsx(s.EditableText,{value:lt||"Untitled Dashboard",onSave:d=>{console.log("EditableText onSave called:",{newTitle:d,canEditDashboard:p,dashboardId:h==null?void 0:h.id});const E=(h==null?void 0:h.title)||"";W(d),Xt(d,E)},isEditable:s.resolveDashboardTitleEditability({isDashboardEditing:N,canEditDashboard:p===!0&&!g,hasCurrentLens:!!k}),displayClassName:"text-[13px] font-medium",inputClassName:"text-[13px] font-medium",placeholder:"Dashboard Title",isPending:ne.isPending}),Y.showDashboardHub&&ie&&e.jsx("span",{className:"shrink-0 rounded-[4px] border border-border/60 px-1.5 py-px text-[10px] font-medium uppercase tracking-[0.06em] text-muted-foreground",title:"Default dashboard",children:"Default"}),is&&B&&e.jsx(l.TooltipProvider,{children:e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx(l.Button,{variant:"ghost",size:"xs",onClick:ls,disabled:Ht||!(t!=null&&t.accessToken)||!(a!=null&&a.apiServiceUrl),className:"w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":ie?"Clear default dashboard":"Set as default dashboard",children:ie?e.jsx(s.PinOff,{className:"h-3.5 w-3.5"}):e.jsx(s.Pin,{className:"h-3.5 w-3.5"})})}),e.jsx(l.TooltipContent,{children:e.jsx("p",{children:ie?"Clear default":"Set as default"})})]})})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[A&&e.jsxs(e.Fragment,{children:[e.jsx($.AdvancedModeToggle,{}),e.jsx($.VisualEditingControls,{})]}),!A&&i&&!g&&Y.showDashboardSharing&&e.jsxs(l.Button,{variant:"outline",size:"xs",onClick:()=>ue(!0),children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),!A&&N&&!g&&f.canUseFilters&&i&&e.jsx($.DashboardFilterControlsLauncher,{}),N&&!A&&!g&&ae&&k&&c&&i&&e.jsxs(l.Button,{variant:"secondary",size:"xs",disabled:J,onClick:as,children:[e.jsx(gt.Save,{className:"h-3.5 w-3.5"}),"Save Lens"]}),N&&!A&&!g&&i&&!F&&e.jsxs("div",{className:"inline-flex h-7 items-stretch overflow-hidden rounded-control border border-input bg-background",children:[e.jsxs(l.Button,{variant:"ghost",size:"xs",disabled:!N,onClick:()=>void Wt(),className:"h-full rounded-none border-0 shadow-none hover:bg-accent",children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Visual"]}),e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(l.Button,{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:!N,children:e.jsx(U.ChevronDown,{className:"h-3.5 w-3.5"})})}),e.jsx(s.DropdownMenuContent,{align:"end",className:"z-[60] w-48 rounded-[6px] border-border/60 p-1 shadow-sm",children:e.jsxs(s.DropdownMenuItem,{onClick:()=>Xe(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"From library..."]})})]}),e.jsx($.VisualsLibraryDialog,{open:qt,onOpenChange:Xe})]}),!A&&!N&&(p||g)&&(!m||!x||p!==void 0)&&i&&e.jsxs("div",{className:"inline-flex items-center gap-1",children:[e.jsxs(l.Button,{size:"xs",onClick:Yt,children:[e.jsx(s.Pencil,{className:"h-3.5 w-3.5"}),g?"Inspect":"Edit"]}),b?e.jsx(l.TooltipProvider,{children:e.jsxs(l.Tooltip,{children:[e.jsx(l.TooltipTrigger,{asChild:!0,children:e.jsx("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:e.jsx(l.Info,{"aria-hidden":"true",className:"size-3.5"})})}),e.jsx(l.TooltipContent,{children:e.jsx("p",{children:b})})]})}):null]}),nt&&i&&ot&&e.jsxs(l.Button,{variant:"outline",size:"xs",onClick:rs,disabled:De,children:[e.jsx(s.Undo2,{className:"h-3.5 w-3.5"}),"Undo"]}),nt&&i&&e.jsxs(l.Button,{size:"xs",className:l.cn(!dt&&"opacity-60"),disabled:De||!dt,onClick:()=>Ue(),children:[De?e.jsx(l.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(gt.Save,{className:"h-3.5 w-3.5"}),De?"Saving...":"Save"]}),N&&!A&&i&&e.jsxs(l.Button,{variant:"outline",size:"xs",onClick:es,children:[e.jsx(s.Cross2Icon,{className:"h-3.5 w-3.5"}),"Close"]}),!A&&i&&e.jsx("div",{className:"ml-2",children:e.jsx($.NotificationBell,{})}),!A&&c&&e.jsx(Cs,{}),!A&&i&&!g&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"More Options",className:"w-7 px-0 text-muted-foreground hover:text-foreground",buttonProps:{size:"xs",variant:"ghost","aria-label":"More dashboard options"},children:e.jsx(s.EllipsisVertical,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-56 rounded-control border border-border/60 p-1 shadow-sm",children:[e.jsx(s.DropdownMenuLabel,{children:"Reports & briefings"}),e.jsxs(s.DropdownMenuItem,{disabled:S,onSelect:()=>te(!0),children:[e.jsx(s.Download,{className:"h-3.5 w-3.5"}),"Export"]}),e.jsx(dr,{scheduleReportVisible:!!(ct&&o.surfaceVisible&&B&&!N),analyticalBriefingVisible:!!(ct&&o.surfaceVisible&&B&&!N),onScheduleReport:()=>ee("scheduled_report"),onCreateAnalyticalBriefing:()=>ee("analytical_briefing")}),e.jsx(s.DropdownMenuSeparator,{}),Y.showGroupManagement&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{children:"Access"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>he(!0),children:[e.jsx(s.Users,{className:"h-3.5 w-3.5"}),"Manage Groups"]}),e.jsx(s.DropdownMenuSeparator,{})]}),e.jsx(s.DropdownMenuLabel,{children:"Preferences"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>Z(!0),children:[e.jsx(s.Calendar,{className:"h-3.5 w-3.5"}),"Report preferences"]}),c&&i&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuSeparator,{}),e.jsx(s.DropdownMenuLabel,{children:"Developer"}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>{var d;t!=null&&t.accessToken&&((d=navigator==null?void 0:navigator.clipboard)!=null&&d.writeText?navigator.clipboard.writeText(t.accessToken).then(()=>s.ue.success("Token copied to clipboard")).catch(()=>s.ue.error("Unable to copy token")):s.ue.error("Clipboard not available"))},children:[e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),"Copy token"]}),F&&e.jsxs(s.DropdownMenuItem,{disabled:!Re,onSelect:()=>{var d;if(!Re){s.ue.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(Re).then(()=>s.ue.success("Local document PDF URL copied to clipboard")).catch(()=>s.ue.error("Unable to copy local document PDF URL")):s.ue.error("Clipboard not available")},children:[e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),"Copy local document PDF URL"]}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>l.invalidateToken(a.apiServiceUrl),children:[e.jsx(ys,{className:"h-3.5 w-3.5"}),"Invalidate token"]}),e.jsxs(s.DropdownMenuItem,{onSelect:u,children:[e.jsx(ps.Palette,{className:"h-3.5 w-3.5"}),"Brand Studio"]}),N&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>tt(!Ze),children:[e.jsx(xs.Braces,{className:"h-3.5 w-3.5"}),Ze?"Hide dashboard JSON":"Show dashboard JSON"]}),ae&&N&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>w(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add lens"]}),ae&&e.jsxs(s.DropdownMenuSub,{children:[e.jsxs(s.DropdownMenuSubTrigger,{children:[e.jsx(gs,{className:"h-3.5 w-3.5"}),"Lenses"]}),e.jsx(s.DropdownMenuSubContent,{className:"w-60",children:e.jsx(Ls,{})})]})]})]})]}),ce&&rt&&e.jsx(s.ShareDialog,{resource:rt,resourceType:s.ResourceType.DASHBOARD,onClose:()=>ue(!1)}),Y.showGroupManagement&&e.jsx(Zs,{open:me,onOpenChange:he}),e.jsx(ms.ReportPreferencesDialog,{open:pe,onOpenChange:Z}),B&&xe?e.jsx($.DashboardBriefingLauncher,{dashboardId:B,dashboardTitle:(h==null?void 0:h.title)||(q==null?void 0:q.title),open:!0,onOpenChange:d=>{d||ee(null)},hideTrigger:!0,workflowIntent:xe}):null,c&&ae&&i&&e.jsx(Is,{open:X,onOpenChange:w}),i&&e.jsx(s.DownloadPdf,{open:V,onOpenChange:te}),e.jsx(s.AlertDialog,{open:fe,onOpenChange:d=>{!d&&Ae&&!H||(z(d),d||(K(null),ge([]),be(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:H?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:H?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),We.length>0&&e.jsxs("div",{className:"space-y-1 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-left",children:[e.jsx("div",{className:"text-sm font-medium text-destructive",children:"What needs attention"}),e.jsx("ul",{className:"list-disc space-y-1 pl-4 text-xs text-muted-foreground",children:We.slice(0,5).map(d=>e.jsx("li",{children:d},d))})]})]}),e.jsx(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:H?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{z(!1),K(null),ge([]),be(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>Ue({closeAfterSave:Je,navigateHomeAfterSave:Oe==="home"}),className:"m-0",children:"Retry"})]}):e.jsxs(s.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(l.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx($.UnsavedChangesAlert,{open:Jt,onOpenChange:d=>{re(d)},onSave:ts,onDiscard:ss,isSaving:Ae,saveLabel:"Save",discardLabel:"Discard"})]})]})}function cr({accessToken:t,dashboardId:a,selectedSheetId:n,pageSize:r,orientation:o,theme:c}){if(!t||!n)return null;const p=new URL("http://localhost:5173/print-document");p.searchParams.set("token",t),a&&p.searchParams.set("dashboardId",a),p.searchParams.set("selectedSheetId",n),c&&p.searchParams.set("theme",c);const x=new URL("http://127.0.0.1:3002/");return x.searchParams.set("pdfMode","document"),x.searchParams.set("pageSize",r||"letter"),x.searchParams.set("orientation",o||"portrait"),x.searchParams.set("url",p.toString()),x.toString()}exports.default=lr;
@@ -1,24 +1,25 @@
1
1
  import { jsx as e, jsxs as o, Fragment as T } from "react/jsx-runtime";
2
- import { u as S, B as R, ax as mt, z as sr, O as na, Z as sa, c as be, ay as oa, az as ia, aA as ot, aB as xe, aC as pt, aD as or, L as Be, aE as ir, aF as da, D as $t, Q as Gt, V as Bt, W as zt, Y as Ht, X as la, i as ca, aG as ua } from "./switch-C8NihGV4.js";
3
- import { bx as ma, by as pa, az as q, aH as dr, bz as ha, aZ as K, aI as lr, aJ as fa, aK as it, aL as dt, aF as ga, bA as ge, bB as Ge, bC as ba, bD as jt, bE as cr, bF as ur, bG as xa, bH as ht, bI as va, bJ as ya, bK as wa, bL as Na, bM as Sa, bN as Da, b8 as ve, bO as ye, aG as C, bP as Ca, bQ as mr, bl as ft, bR as ka, bS as Ea, bT as pr, bU as La, bV as hr, bW as V, bX as Ia, ap as Ma, bY as Aa, bZ as Pa, b_ as Oa, b$ as _a, n as Ra, u as Fe, t as Ua, o as rt, c0 as Va, c1 as Ta, c2 as Fa, c3 as $a, N as Ga, c4 as Ba, c5 as za, I as qt, c6 as Ha, c7 as ja, c8 as qa, c9 as Ka, ca as Wa, cb as Kt, cc as Wt, cd as Qt, ce as Qa, cf as Ja, cg as Ya, ch as Xa, b1 as Jt, ci as Za, cj as en, ck as tn, s as rn, cl as an, aP as nn, aS as sn, aT as on, aU as dn, aV as ln, aW as cn, aX as un, aY as Yt, g as lt } from "./index-DrdF7QR7.js";
2
+ import { u as S, B as R, ax as mt, z as sr, O as na, Z as sa, c as be, ay as oa, az as ia, aA as ot, aB as xe, aC as pt, aD as or, L as Be, aE as ir, aF as da, D as $t, Q as Gt, V as Bt, W as zt, Y as Ht, X as la, i as ca, aG as ua } from "./switch-LucIPRtD.js";
3
+ import { bw as ma, bx as pa, ay as q, aG as dr, by as ha, aY as K, aH as lr, aI as fa, aJ as it, aK as dt, aE as ga, bz as ge, bA as Ge, bB as ba, bC as jt, bD as cr, bE as ur, bF as xa, bG as ht, bH as va, bI as ya, bJ as wa, bK as Na, bL as Sa, bM as Da, b7 as ve, bN as ye, aF as C, bO as Ca, bP as mr, bk as ft, bQ as ka, bR as Ea, bS as pr, bT as La, bU as hr, bV as V, bW as Ia, ao as Ma, bX as Aa, bY as Pa, bZ as Oa, b_ as _a, m as Ra, u as Fe, s as Ua, n as rt, b$ as Va, c0 as Ta, c1 as Fa, c2 as $a, L as Ga, c3 as Ba, c4 as za, I as qt, c5 as Ha, c6 as ja, c7 as qa, c8 as Ka, c9 as Wa, ca as Kt, cb as Wt, cc as Qt, cd as Qa, ce as Ja, cf as Ya, cg as Xa, b0 as Jt, ch as Za, ci as en, cj as tn, r as rn, ck as an, aO as nn, aR as sn, aS as on, aT as dn, aU as ln, aV as cn, aW as un, aX as Yt } from "./index-CUCiMVzS.js";
4
4
  import { c as ee, X as fr, C as mn } from "./x-CXDkqdur.js";
5
- import "./saved-temporal-bucket-format-CHsXUPJI.js";
6
- import "./validators-D-T-2HOR.js";
7
- import "./analyze-result-contract-C8s8EUL5.js";
5
+ import "./card-config-utils-CyDKaPNT.js";
6
+ import "./validators-D3AarM2T.js";
7
+ import "./analyze-result-contract-DsiAzCYn.js";
8
8
  import "../value-format-preferences/index.js";
9
9
  import * as I from "react";
10
10
  import gr, { useState as N, useMemo as Z, useEffect as ze, useRef as Xt, useLayoutEffect as pn, useCallback as hn } from "react";
11
11
  import "./appearance-context-DVXt8qjW.js";
12
12
  import "./index-DSKR3nKn.js";
13
- import "./temporal-bucket-authoring-DJ9kK2wD.js";
13
+ import "./temporal-bucket-authoring-CyTCHy1K.js";
14
14
  import "./color-CJvdlFM_.js";
15
15
  import { createPortal as fn } from "react-dom";
16
- import "./index-D9S3j7_z.js";
16
+ import "./index-BvRREsU9.js";
17
17
  import "./appearance-runtime-provider-CjmE4gBY.js";
18
- import { c as gn, u as bn, A as xn, a as vn, f as yn, V as wn, N as Nn, g as Sn, U as Dn } from "./dashboard-briefing-launcher-C9d8CPxv.js";
18
+ import { c as gn, u as bn, A as xn, a as vn, f as yn, V as wn, N as Nn, g as Sn, U as Dn } from "./dashboard-briefing-launcher-Dk4yNOLY.js";
19
19
  import { S as Cn, C as kn } from "./search-BHsQIWBV.js";
20
- import { d as br } from "./format-types-CFHQoIuk.js";
21
- import { R as En } from "./report-preferences-dialog-BjygtSP3.js";
20
+ import { d as br } from "./index-BS0_dp0l.js";
21
+ import { c as lt } from "./dashboard-filter-value-compatibility-DQkUs41q.js";
22
+ import { R as En } from "./report-preferences-dialog-DKq0k5BH.js";
22
23
  import { u as Ln } from "./use-debounced-dirty-check-BwAbnX_5.js";
23
24
  import { s as at } from "./normalize-dashboard-for-dirty-check-5KpZN8xr.js";
24
25
  import { S as Zt } from "./save-DgMfP0j8.js";
@@ -1680,7 +1681,7 @@ function nr(t, n) {
1680
1681
  semanticExecutionPayload: lt(n)
1681
1682
  };
1682
1683
  }
1683
- function Qs() {
1684
+ function Js() {
1684
1685
  var _t, Rt, Ut, Vt, Tt;
1685
1686
  gn(), bn();
1686
1687
  const {
@@ -2408,5 +2409,5 @@ function Ss({
2408
2409
  return h.searchParams.set("pdfMode", "document"), h.searchParams.set("pageSize", r || "letter"), h.searchParams.set("orientation", s || "portrait"), h.searchParams.set("url", p.toString()), h.toString();
2409
2410
  }
2410
2411
  export {
2411
- Qs as default
2412
+ Js as default
2412
2413
  };
@@ -1 +1 @@
1
- "use strict";const h=require("./validators-DcshgK7w.cjs");function v(e,n){const t=e.split(".").map(r=>r.trim()),i=n.split(".").map(r=>r.trim());if(t.length===0||i.length===0||t.some(r=>!r)||i.some(r=>!r))return!1;const[o,s]=t.length<=i.length?[t,i]:[i,t],a=s.length-o.length;return o.every((r,c)=>r===s[c+a])}function D(e,n){const t=e.split("."),i=n.split("."),o=t.pop(),s=i.pop();return!!(o&&o===s&&t.length>0&&i.length>0&&v(t.join("."),i.join(".")))}function F(e){const n=e.map(i=>i.trim()).filter(Boolean);if(n.every((i,o)=>n.slice(o+1).every(s=>v(i,s))))return[...n].sort((i,o)=>o.split(".").length-i.split(".").length)[0]}function u(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _(e){if(typeof e!="string")return"";const n=e.split(".").map(t=>t.trim());return n.length>1&&n.every(Boolean)?n.join("."):""}function I(e){if(typeof e!="string")return"";const n=e.split(".").map(t=>t.trim());return n.length>0&&n.every(Boolean)?n.join("."):""}function d(e){return typeof e=="string"?e.trim():""}function S(e,n){return e.every((t,i)=>e.slice(i+1).every(o=>n(t,o)))}function N(e,n){const t=d(e.id),i=d(e.name),o=d(n.entityId),s=d(n.entityName);return!i||!o&&!s?!1:(!o||o===t||o===i)&&(!s||s===i)}function E(e){const n=u(e.semanticContext)?e.semanticContext:void 0,t=u(e.fieldMeta)?e.fieldMeta:void 0,i=d(n==null?void 0:n.semanticDomainId),o=Array.isArray(n==null?void 0:n.selectedEntities)?n.selectedEntities.filter(g=>u(g)&&g.type==="dataset"):[];if(!!!(i||o.length>0||(t==null?void 0:t.entityType)==="dataset"))return;if(!i)return{status:"unresolved",reason:"incomplete_source_identity"};const a=d(t==null?void 0:t.entityId),r=d(t==null?void 0:t.entityName),c=!!(a||r),f=c?o.filter(g=>N(g,{entityId:a,entityName:r})):o;if(f.length>1)return{status:"unresolved",reason:"incomplete_source_identity"};if(c&&o.length>0&&f.length===0)return{status:"unresolved",reason:"divergent_source_identity"};const l=f[0],m=d(l==null?void 0:l.domainId),y=d(l==null?void 0:l.id),p=d(l==null?void 0:l.name);if(m&&m!==i)return{status:"unresolved",reason:"divergent_source_identity"};const b=y,C=p||r;return C?{status:"resolved",source:{kind:"semantic",domainId:i,datasetName:C,...b?{datasetId:b}:{}}}:{status:"unresolved",reason:"incomplete_source_identity"}}function A(e,n){const t=d(e.connectionId),i=u(e.semanticContext)?e.semanticContext:void 0,o=d(i==null?void 0:i.connectionId);if(t&&o&&t!==o)return{status:"unresolved",reason:"divergent_source_identity"};const s=t||o,a=u(e.fieldMeta)?e.fieldMeta:void 0,r=n.split(".").slice(0,-1).join("."),c=I(e.qualifiedTableName),f=I(a==null?void 0:a.qualifiedEntityName),l=[c,f,r].filter(Boolean),m=F(l);return!m&&l.length>0?{status:"unresolved",reason:"divergent_source_identity"}:!s||!m?{status:"unresolved",reason:"incomplete_source_identity"}:{status:"resolved",source:{kind:"physical",connectionId:s,tableName:m}}}function B(e,n){const t=u(e.fieldMeta)?e.fieldMeta:void 0,i=typeof(t==null?void 0:t.qualifiedFieldName)=="string"?t.qualifiedFieldName.trim():"",o=_(t==null?void 0:t.qualifiedFieldName),s=typeof e.column=="string"?e.column.trim():"",a=_(s),r=typeof e.qualifiedTableName=="string"?e.qualifiedTableName.trim():"",c=I(e.qualifiedTableName);if(i&&!o||n&&r&&!c||s.includes(".")&&!a)return{status:"unresolved",reason:"incomplete_field_identity"};const f=a.split("."),l=a?f[f.length-1]:s,m=n&&c&&l?`${c}.${l}`:"",y=[o,a,m].filter(Boolean);if(!S(y,D))return{status:"unresolved",reason:"divergent_field_identity"};const p=a||o||m;return p?{status:"resolved",qualifiedFieldName:p}:{status:"unresolved",reason:"incomplete_field_identity"}}function q(e){if(!u(e))return{status:"ineligible",reason:"invalid_input"};if(e.kind==="global-date")return{status:"eligible",kind:"global_date"};const n=h.normalizeAnalyticsCatalogDataType(e.dataType);if(n!=="date"&&n!=="datetime")return{status:"ineligible",reason:"non_date_filter"};const t=u(e.fieldMeta)?e.fieldMeta:void 0,i=h.normalizeAnalyticsCatalogDataType(t==null?void 0:t.dataType);if((t==null?void 0:t.dataType)!==void 0&&i!=="date"&&i!=="datetime")return{status:"ineligible",reason:"non_date_filter"};if(e.customFilterPreferences)return{status:"ineligible",reason:"custom_filter"};if(e.targetColumns!==void 0&&(!Array.isArray(e.targetColumns)||e.targetColumns.length>0))return{status:"ineligible",reason:"multi_target_filter"};const o=E(e),s=B(e,o===void 0);if(s.status==="unresolved")return{status:"ineligible",reason:s.reason};const a=o||A(e,s.qualifiedFieldName);return a.status==="resolved"?{status:"eligible",kind:"field_date",qualifiedFieldName:s.qualifiedFieldName,source:a.source}:{status:"ineligible",reason:a.reason}}function T(e){if(!u(e)||e.kind!=="filter"||!u(e.filter))return{status:"ineligible",reason:"invalid_input"};const n=q(e.filter);return n.status==="ineligible"?n:n.kind==="field_date"&&u(e.compatibility)&&e.compatibility.source==="cardInlineFilter"?{status:"ineligible",reason:"card_inline_filter"}:n}function $(e){return T(e).status==="eligible"}function k(e){return`compat-filter:${e}`}function j(e){return`compat-control:${e}`}function z(e,n){return`compat-inline-filter:${e}:${n}`}function M(e,n){return`compat-card-control:${e}:${n}`}exports.getCardControlCompatInputId=M;exports.getCardInlineFilterCompatInputId=z;exports.getDashboardControlCompatInputId=j;exports.getDashboardFilterCompatInputId=k;exports.isComparisonCapableDashboardDateInputDefinition=$;exports.qualifiedEntityIdentitiesReferToSameEntity=v;exports.qualifiedFieldIdentitiesReferToSameField=D;exports.resolveDashboardDateComparisonFilterDefinition=q;exports.resolveDashboardDateComparisonInputDefinition=T;exports.selectMostQualifiedCompatibleEntityIdentity=F;exports.semanticDatasetMatchesFieldCoordinates=N;
1
+ "use strict";const h=require("./validators-DqIM0B3C.cjs");function S(e){return`compat-filter:${e}`}function E(e){return`compat-control:${e}`}function A(e,n){return`compat-inline-filter:${e}:${n}`}function B(e,n){return`compat-card-control:${e}:${n}`}function v(e,n){const t=e.split(".").map(r=>r.trim()),i=n.split(".").map(r=>r.trim());if(t.length===0||i.length===0||t.some(r=>!r)||i.some(r=>!r))return!1;const[o,s]=t.length<=i.length?[t,i]:[i,t],a=s.length-o.length;return o.every((r,c)=>r===s[c+a])}function D(e,n){const t=e.split("."),i=n.split("."),o=t.pop(),s=i.pop();return!!(o&&o===s&&t.length>0&&i.length>0&&v(t.join("."),i.join(".")))}function F(e){const n=e.map(i=>i.trim()).filter(Boolean);if(n.every((i,o)=>n.slice(o+1).every(s=>v(i,s))))return[...n].sort((i,o)=>o.split(".").length-i.split(".").length)[0]}function u(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _(e){if(typeof e!="string")return"";const n=e.split(".").map(t=>t.trim());return n.length>1&&n.every(Boolean)?n.join("."):""}function I(e){if(typeof e!="string")return"";const n=e.split(".").map(t=>t.trim());return n.length>0&&n.every(Boolean)?n.join("."):""}function d(e){return typeof e=="string"?e.trim():""}function $(e,n){return e.every((t,i)=>e.slice(i+1).every(o=>n(t,o)))}function N(e,n){const t=d(e.id),i=d(e.name),o=d(n.entityId),s=d(n.entityName);return!i||!o&&!s?!1:(!o||o===t||o===i)&&(!s||s===i)}function k(e){const n=u(e.semanticContext)?e.semanticContext:void 0,t=u(e.fieldMeta)?e.fieldMeta:void 0,i=d(n==null?void 0:n.semanticDomainId),o=Array.isArray(n==null?void 0:n.selectedEntities)?n.selectedEntities.filter(g=>u(g)&&g.type==="dataset"):[];if(!!!(i||o.length>0||(t==null?void 0:t.entityType)==="dataset"))return;if(!i)return{status:"unresolved",reason:"incomplete_source_identity"};const a=d(t==null?void 0:t.entityId),r=d(t==null?void 0:t.entityName),c=!!(a||r),f=c?o.filter(g=>N(g,{entityId:a,entityName:r})):o;if(f.length>1)return{status:"unresolved",reason:"incomplete_source_identity"};if(c&&o.length>0&&f.length===0)return{status:"unresolved",reason:"divergent_source_identity"};const l=f[0],m=d(l==null?void 0:l.domainId),y=d(l==null?void 0:l.id),p=d(l==null?void 0:l.name);if(m&&m!==i)return{status:"unresolved",reason:"divergent_source_identity"};const b=y,C=p||r;return C?{status:"resolved",source:{kind:"semantic",domainId:i,datasetName:C,...b?{datasetId:b}:{}}}:{status:"unresolved",reason:"incomplete_source_identity"}}function j(e,n){const t=d(e.connectionId),i=u(e.semanticContext)?e.semanticContext:void 0,o=d(i==null?void 0:i.connectionId);if(t&&o&&t!==o)return{status:"unresolved",reason:"divergent_source_identity"};const s=t||o,a=u(e.fieldMeta)?e.fieldMeta:void 0,r=n.split(".").slice(0,-1).join("."),c=I(e.qualifiedTableName),f=I(a==null?void 0:a.qualifiedEntityName),l=[c,f,r].filter(Boolean),m=F(l);return!m&&l.length>0?{status:"unresolved",reason:"divergent_source_identity"}:!s||!m?{status:"unresolved",reason:"incomplete_source_identity"}:{status:"resolved",source:{kind:"physical",connectionId:s,tableName:m}}}function z(e,n){const t=u(e.fieldMeta)?e.fieldMeta:void 0,i=typeof(t==null?void 0:t.qualifiedFieldName)=="string"?t.qualifiedFieldName.trim():"",o=_(t==null?void 0:t.qualifiedFieldName),s=typeof e.column=="string"?e.column.trim():"",a=_(s),r=typeof e.qualifiedTableName=="string"?e.qualifiedTableName.trim():"",c=I(e.qualifiedTableName);if(i&&!o||n&&r&&!c||s.includes(".")&&!a)return{status:"unresolved",reason:"incomplete_field_identity"};const f=a.split("."),l=a?f[f.length-1]:s,m=n&&c&&l?`${c}.${l}`:"",y=[o,a,m].filter(Boolean);if(!$(y,D))return{status:"unresolved",reason:"divergent_field_identity"};const p=a||o||m;return p?{status:"resolved",qualifiedFieldName:p}:{status:"unresolved",reason:"incomplete_field_identity"}}function q(e){if(!u(e))return{status:"ineligible",reason:"invalid_input"};if(e.kind==="global-date")return{status:"eligible",kind:"global_date"};const n=h.normalizeAnalyticsCatalogDataType(e.dataType);if(n!=="date"&&n!=="datetime")return{status:"ineligible",reason:"non_date_filter"};const t=u(e.fieldMeta)?e.fieldMeta:void 0,i=h.normalizeAnalyticsCatalogDataType(t==null?void 0:t.dataType);if((t==null?void 0:t.dataType)!==void 0&&i!=="date"&&i!=="datetime")return{status:"ineligible",reason:"non_date_filter"};if(e.customFilterPreferences)return{status:"ineligible",reason:"custom_filter"};if(e.targetColumns!==void 0&&(!Array.isArray(e.targetColumns)||e.targetColumns.length>0))return{status:"ineligible",reason:"multi_target_filter"};const o=k(e),s=z(e,o===void 0);if(s.status==="unresolved")return{status:"ineligible",reason:s.reason};const a=o||j(e,s.qualifiedFieldName);return a.status==="resolved"?{status:"eligible",kind:"field_date",qualifiedFieldName:s.qualifiedFieldName,source:a.source}:{status:"ineligible",reason:a.reason}}function T(e){if(!u(e)||e.kind!=="filter"||!u(e.filter))return{status:"ineligible",reason:"invalid_input"};const n=q(e.filter);return n.status==="ineligible"?n:n.kind==="field_date"&&u(e.compatibility)&&e.compatibility.source==="cardInlineFilter"?{status:"ineligible",reason:"card_inline_filter"}:n}function M(e){return T(e).status==="eligible"}exports.getCardControlCompatInputId=B;exports.getCardInlineFilterCompatInputId=A;exports.getDashboardControlCompatInputId=E;exports.getDashboardFilterCompatInputId=S;exports.isComparisonCapableDashboardDateInputDefinition=M;exports.qualifiedEntityIdentitiesReferToSameEntity=v;exports.qualifiedFieldIdentitiesReferToSameField=D;exports.resolveDashboardDateComparisonFilterDefinition=q;exports.resolveDashboardDateComparisonInputDefinition=T;exports.selectMostQualifiedCompatibleEntityIdentity=F;exports.semanticDatasetMatchesFieldCoordinates=N;
@@ -1,4 +1,16 @@
1
- import { F as _ } from "./validators-D-T-2HOR.js";
1
+ import { F as _ } from "./validators-D3AarM2T.js";
2
+ function k(e) {
3
+ return `compat-filter:${e}`;
4
+ }
5
+ function j(e) {
6
+ return `compat-control:${e}`;
7
+ }
8
+ function z(e, n) {
9
+ return `compat-inline-filter:${e}:${n}`;
10
+ }
11
+ function M(e, n) {
12
+ return `compat-card-control:${e}:${n}`;
13
+ }
2
14
  function C(e, n) {
3
15
  const t = e.split(".").map((r) => r.trim()), i = n.split(".").map((r) => r.trim());
4
16
  if (t.length === 0 || i.length === 0 || t.some((r) => !r) || i.some((r) => !r))
@@ -153,30 +165,18 @@ function B(e) {
153
165
  );
154
166
  return n.status === "ineligible" ? n : n.kind === "field_date" && u(e.compatibility) && e.compatibility.source === "cardInlineFilter" ? { status: "ineligible", reason: "card_inline_filter" } : n;
155
167
  }
156
- function k(e) {
168
+ function Q(e) {
157
169
  return B(e).status === "eligible";
158
170
  }
159
- function j(e) {
160
- return `compat-filter:${e}`;
161
- }
162
- function z(e) {
163
- return `compat-control:${e}`;
164
- }
165
- function M(e, n) {
166
- return `compat-inline-filter:${e}:${n}`;
167
- }
168
- function Q(e, n) {
169
- return `compat-card-control:${e}:${n}`;
170
- }
171
171
  export {
172
172
  B as a,
173
- z as b,
174
- M as c,
175
- Q as d,
173
+ j as b,
174
+ z as c,
175
+ M as d,
176
176
  q as e,
177
177
  C as f,
178
- j as g,
179
- k as i,
178
+ k as g,
179
+ Q as i,
180
180
  N as q,
181
181
  E as r,
182
182
  F as s