react-semaphor 0.1.307 → 0.1.308

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 (43) hide show
  1. package/dist/brand-studio/index.cjs +1 -1
  2. package/dist/brand-studio/index.js +4 -4
  3. package/dist/chunks/{braces-CkL8POe0.js → braces-BHDm9arh.js} +1 -1
  4. package/dist/chunks/{braces-e5qkN-I_.js → braces-DEq8EJtw.js} +1 -1
  5. package/dist/chunks/chevrons-up-down-Cbtggnqv.js +14 -0
  6. package/dist/chunks/chevrons-up-down-DDEY9beZ.js +6 -0
  7. package/dist/chunks/{dashboard-controls-5bibC_5a.js → dashboard-controls-DTxSUWvy.js} +233 -223
  8. package/dist/chunks/{dashboard-controls-Dwet_9h0.js → dashboard-controls-DviftQE7.js} +8 -3
  9. package/dist/chunks/dashboard-filter-controls-button-D0nrJ7wl.js +11 -0
  10. package/dist/chunks/{dashboard-filter-controls-button-D0k9NDci.js → dashboard-filter-controls-button-DHKfgPah.js} +304 -303
  11. package/dist/chunks/{dashboard-json-Bi5XdgG5.js → dashboard-json-DYzZ0G6T.js} +1 -1
  12. package/dist/chunks/{dashboard-json-CfRKLL7C.js → dashboard-json-DZmsUV5n.js} +2 -2
  13. package/dist/chunks/dashboard-summary-settings-dialog-Cc3yKCu4.js +1 -0
  14. package/dist/chunks/{dashboard-summary-settings-dialog-Bj4_wBW9.js → dashboard-summary-settings-dialog-QbUTp92u.js} +33 -32
  15. package/dist/chunks/{edit-dashboard-visual-Wfs53Kbn.js → edit-dashboard-visual-BS3LKMJe.js} +32 -32
  16. package/dist/chunks/{edit-dashboard-visual-DIuzuJfj.js → edit-dashboard-visual-CmgculGv.js} +130 -129
  17. package/dist/chunks/{index-DMFCfjgD.js → index-BxYIELMe.js} +60366 -62293
  18. package/dist/chunks/index-C0zD3JgK.js +1330 -0
  19. package/dist/chunks/{palette-Oa4O9jWG.js → palette-CNKSAIrt.js} +1 -1
  20. package/dist/chunks/{palette-D5Lorzf2.js → palette-CteErylX.js} +1 -1
  21. package/dist/chunks/{resource-management-panel-Dqc3gfYn.js → resource-management-panel-8cHoj8SV.js} +52 -52
  22. package/dist/chunks/resource-management-panel-B4QM3fZ_.js +6 -0
  23. package/dist/chunks/{save-CDX2p4v1.js → save-B1-nDZwS.js} +1 -1
  24. package/dist/chunks/{save-zEdICevW.js → save-BVVnWGeb.js} +1 -1
  25. package/dist/chunks/{switch-BPFzGTzF.js → switch-BG4RWnrq.js} +25 -25
  26. package/dist/chunks/{switch-CKiXRRoh.js → switch-BZn7R_Cp.js} +696 -697
  27. package/dist/chunks/{use-create-flow-overlay-state-CSMe5Ls6.js → use-create-flow-overlay-state-Bmb471Fp.js} +1 -1
  28. package/dist/chunks/{use-create-flow-overlay-state-CLyv5c2m.js → use-create-flow-overlay-state-CeWstFjy.js} +49 -49
  29. package/dist/chunks/{use-visual-utils-Det6M3Wd.js → use-visual-utils-CmfDomt0.js} +2 -2
  30. package/dist/chunks/{use-visual-utils-DDAs4dCz.js → use-visual-utils-DflfgX9g.js} +1 -1
  31. package/dist/dashboard/index.cjs +1 -1
  32. package/dist/dashboard/index.js +1 -1
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.js +76 -76
  35. package/dist/style.css +1 -1
  36. package/dist/surfboard/index.cjs +1 -1
  37. package/dist/surfboard/index.js +2 -2
  38. package/dist/types/main.d.ts +10 -2
  39. package/package.json +1 -1
  40. package/dist/chunks/dashboard-filter-controls-button-ZeYO5jux.js +0 -11
  41. package/dist/chunks/dashboard-summary-settings-dialog-DD9Aj2XH.js +0 -1
  42. package/dist/chunks/index-DQCMUspd.js +0 -1350
  43. package/dist/chunks/resource-management-panel-CNr6uMMf.js +0 -6
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/index-DQCMUspd.js"),e=require("../chunks/common-types-nBuCd3u2.js"),r=require("../chunks/dashboard-summary-settings-dialog-DD9Aj2XH.js");exports.Surfboard=a.DashboardPlus;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;exports.CalendarPreferencesDialog=r.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=r.DashboardSummarySettingsDialog;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/index-C0zD3JgK.js"),e=require("../chunks/common-types-nBuCd3u2.js"),r=require("../chunks/dashboard-summary-settings-dialog-Cc3yKCu4.js");exports.Surfboard=a.DashboardPlus;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;exports.CalendarPreferencesDialog=r.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=r.DashboardSummarySettingsDialog;
@@ -1,6 +1,6 @@
1
- import { a as o } from "../chunks/index-DMFCfjgD.js";
1
+ import { a as o } from "../chunks/index-BxYIELMe.js";
2
2
  import { C as s, E as C } from "../chunks/common-types-C6cAQgyh.js";
3
- import { C as E, D as f } from "../chunks/dashboard-summary-settings-dialog-Bj4_wBW9.js";
3
+ import { C as E, D as f } from "../chunks/dashboard-summary-settings-dialog-QbUTp92u.js";
4
4
  export {
5
5
  s as CONTROL_CARD_DEFAULT_VALUE,
6
6
  E as CalendarPreferencesDialog,
@@ -3979,7 +3979,7 @@ declare type SensitivityPreset_2 = 'low_noise' | 'standard' | 'early_warning';
3979
3979
  */
3980
3980
  export declare function serializeDashboardForDirtyCheck(dashboard: TDashboard | null): string;
3981
3981
 
3982
- export declare function ShareDialog({ resource, resourceType, onClose, onShareSuccess, onRemoveSuccess, }: ShareDialogProps): JSX.Element;
3982
+ export declare function ShareDialog({ resource, resourceType, onClose, }: ShareDialogProps): JSX.Element;
3983
3983
 
3984
3984
  declare interface ShareDialogProps {
3985
3985
  resource: MinimalResourceForSharing;
@@ -3991,9 +3991,17 @@ declare interface ShareDialogProps {
3991
3991
 
3992
3992
  declare interface ShareResourceRequest {
3993
3993
  shares: Array<{
3994
- scope: ShareScope;
3994
+ /** API actually accepts a wider set than the typed `ShareScope` —
3995
+ * e.g. `'group'`, `'all_org_groups'`, `'all_tenant_groups'`. The
3996
+ * unified share dialog needs those, so we accept either the typed
3997
+ * union or any other API-recognized scope string. */
3998
+ scope: ShareScope | string;
3995
3999
  tenantId?: string;
3996
4000
  tenantUserId?: string;
4001
+ /** Present for `specific_org_user` shares. */
4002
+ orgUserId?: string;
4003
+ /** Present for group shares (`group`, `all_org_groups`, etc.). */
4004
+ groupId?: string;
3997
4005
  role: ShareRole;
3998
4006
  }>;
3999
4007
  message?: string;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.1.307",
8
+ "version": "0.1.308",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",
@@ -1,11 +0,0 @@
1
- "use strict";const g=require("react"),t=require("./index-DQCMUspd.js"),e=require("react/jsx-runtime"),r=require("./switch-BPFzGTzF.js"),F=require("./use-create-flow-overlay-state-CSMe5Ls6.js"),R=require("./use-visual-utils-DDAs4dCz.js"),U=require("./date-formatter-D9Bvw5Qk.js");/**
2
- * @license lucide-react v0.453.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const V=r.createLucideIcon("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/**
7
- * @license lucide-react v0.453.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const $=r.createLucideIcon("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]),_=1e4,q=15e3,X=3e4,G=3e4,Q=12e4,O=2*60*60*1e3;function K(s){const a=Date.now()-s.getTime();return a<G?_:a<Q?q:X}function W(){const{authToken:s,tokenProps:a}=t.useSemaphorContext(),v=t.useExportStore(x=>x.activeExports),[d,i]=g.useState(typeof document<"u"?!document.hidden:!0),c=g.useRef(null),u=g.useRef(!1),m=g.useRef(void 0),l=a==null?void 0:a.apiServiceUrl,o=s==null?void 0:s.accessToken,p=g.useCallback(()=>{const x=t.useExportStore.getState().activeExports;return Array.from(x.values()).filter(y=>t.isExportInProgress(y.status))},[]);g.useEffect(()=>{if(typeof document>"u")return;const x=()=>{i(!document.hidden)};return document.addEventListener("visibilitychange",x),()=>{document.removeEventListener("visibilitychange",x)}},[]);const C=g.useCallback(async()=>{if(!l||!o){u.current=!1;return}const x=p();if(x.length===0){u.current=!1;return}const y=Date.now(),N=x.filter(n=>y-n.startedAt.getTime()>O);if(N.length>0){const{updateExport:n}=t.useExportStore.getState().actions;for(const w of N)n(w.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const f=x.filter(n=>y-n.startedAt.getTime()<=O);if(f.length===0){u.current=!1;return}const j=await Promise.allSettled(f.map(async n=>{try{const w=await t.getExportStatus(l,o,n.id);let E;if(w.status==="completed")try{E=await t.getDownloadUrl(l,o,n.id)}catch(L){console.error(`[useExportPolling] Failed to get download URL for ${n.id}:`,L)}return{id:n.id,status:w.status,progress:w.progress,completedChunks:w.completedChunks,completedAt:w.completedAt?new Date(w.completedAt):void 0,lastUpdatedAt:new Date,fileSize:w.fileSize,error:w.error,downloadUrl:E}}catch(w){return console.error(`[useExportPolling] Failed to poll export ${n.id}:`,w),null}})),{updateExport:A}=t.useExportStore.getState().actions;for(const n of j)n.status==="fulfilled"&&n.value&&A(n.value.id,n.value);const D=p();if(D.length>0&&!document.hidden){const n=D.reduce((E,L)=>L.startedAt<E?L.startedAt:E,D[0].startedAt),w=K(n);c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{var E;(E=m.current)==null||E.call(m)},w)}else u.current=!1},[l,o,p]);return g.useEffect(()=>{m.current=C},[C]),g.useEffect(()=>{var y;p().length>0&&d&&!u.current&&(u.current=!0,(y=m.current)==null||y.call(m))},[v,d,p]),g.useEffect(()=>{var y;const x=p();d&&x.length>0&&!u.current&&(u.current=!0,(y=m.current)==null||y.call(m))},[d,p]),g.useEffect(()=>{!d&&c.current&&(clearTimeout(c.current),c.current=null,u.current=!1)},[d]),g.useEffect(()=>()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]),{isPolling:u.current,isTabVisible:d,inProgressCount:p().length}}function Y(){const{authToken:s,tokenProps:a}=t.useSemaphorContext(),v=t.useExportStore(m=>m.activeExports),{addExport:d}=t.useExportActions(),i=g.useRef(!1),c=a==null?void 0:a.apiServiceUrl,u=s==null?void 0:s.accessToken;g.useEffect(()=>{if(i.current||!c||!u)return;(async()=>{try{const{exports:l}=await t.getExports(c,u,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const o of l){if(v.has(o.id))continue;const p=o.totalChunks?Math.round(o.completedChunks/o.totalChunks*100):0;let C;if(o.status==="completed")try{C=await t.getDownloadUrl(c,u,o.id)}catch(y){console.error(`[useExportRecovery] Failed to get download URL for ${o.id}:`,y)}const x={id:o.id,status:o.status,progress:p,title:Z(o),totalRows:o.totalRows,totalChunks:o.totalChunks,completedChunks:o.completedChunks,startedAt:new Date(o.createdAt),lastUpdatedAt:new Date,completedAt:o.completedAt?new Date(o.completedAt):void 0,fileSize:o.fileSize,error:o.error,expiresAt:new Date(o.expiresAt),downloadUrl:C};d(x)}i.current=!0}catch(l){console.error("[useExportRecovery] Failed to recover exports:",l),i.current=!0}})()},[c,u,d,v])}function Z(s){return s.title?s.title:t.isExportInProgress(s.status)?"Export in progress...":s.status==="completed"?"Export completed":s.status==="failed"?"Export failed":"Export"}function J({open:s,onOpenChange:a,isLibraryVisual:v,currentVisualName:d,isSaving:i=!1,destinationMode:c="both",onConfirm:u}){const[m,l]=g.useState(v&&d?`Copy of ${d}`:d||""),[o,p]=g.useState("");g.useEffect(()=>{s&&(l(v&&d?`Copy of ${d}`:d||""),p(""))},[s,v,d]);const C=!!m.trim(),x=c==="local"?{saveToLibrary:!1,saveToCurrentDashboard:!0,badgeType:"local",description:"Creates a local copy on the current dashboard.",actionLabel:"Add to Dashboard (Local)"}:c==="library"?{saveToLibrary:!0,saveToCurrentDashboard:!1,badgeType:"library",description:"Creates a reusable visual in Visual Library.",actionLabel:"Save as Library Visual"}:{saveToLibrary:!0,saveToCurrentDashboard:!0,badgeType:"linked",description:"Creates a new library visual and adds a linked copy to this dashboard.",actionLabel:"Save Copy as Linked Visual"},y=()=>{!C||i||u({name:m.trim(),description:o.trim()||void 0,saveToLibrary:x.saveToLibrary,saveToCurrentDashboard:x.saveToCurrentDashboard})};return e.jsx(t.Dialog,{open:s,onOpenChange:a,children:e.jsxs(t.DialogContent,{className:"sm:max-w-[500px]",children:[e.jsxs(t.DialogHeader,{children:[e.jsxs(t.DialogTitle,{className:"flex items-center gap-2",children:[e.jsx("span",{children:"Save Visual As"}),x.badgeType!=="local"&&e.jsx(F.VisualBadge,{type:x.badgeType,showLabel:!0,className:"px-2 py-0.5"})]}),e.jsx(t.DialogDescription,{children:x.description})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(r.Label,{htmlFor:"name",children:"Name"}),e.jsx(r.Input,{id:"name",value:m,onChange:N=>l(N.target.value),placeholder:"Enter visual name",disabled:i})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(r.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(t.Textarea,{id:"description",value:o,onChange:N=>p(N.target.value),placeholder:"Enter visual description",rows:3,disabled:i})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(r.Button,{variant:"outline",onClick:()=>a(!1),disabled:i,children:"Cancel"}),e.jsxs(r.Button,{onClick:y,disabled:!C||i,children:[i&&e.jsx(r.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),x.actionLabel]})]})]})})}function ee(){const[s,a]=g.useState(!1),[v,d]=g.useState(!1),[i,c]=g.useState(null),[u,m]=g.useState(null),l=r.useEditorStore(h=>h.frame),o=r.useEditorStore(h=>h.card),p=t.useSelectedVisual(),C=r.useDashboardStore(h=>h.selectedSheetId),x=r.useDashboardStore(h=>h.dashboard),y=r.useDashboardStore(h=>h.actions.setIsDashboardPanelOpen),{getUpdatedFrame:N}=R.useVisualUtils(),{selectVisual:f}=t.useManagementActions(),{addFrame:j,setSelectedFrameId:A,setIsVisualEditing:D}=r.useDashboardActions(),n=t.useResolveExistingFrameSemanticExecutionPayload(),w=!!(l!=null&&l.visualId),E=(()=>{var h,b;return((h=l==null?void 0:l.cards)==null?void 0:h.length)===1&&((b=l.cards[0])!=null&&b.title)?l.cards[0].title:p!=null&&p.title?p.title:(o==null?void 0:o.title)||"Untitled Visual"})(),L=t.useCreateVisualWithFrame(h=>{h!=null&&h.id&&(f(h),v&&i&&u&&C&&(async()=>{try{const b={...i,id:r.v4(),visualId:h.id};j(C,b,{position:"end",semanticExecutionPayload:u}),A(b.id),d(!1),c(null),m(null),D(!1)}catch(b){console.error("Failed to promote semantic metadata for saved visual:",b),t.ue.error(b instanceof Error?b.message:"Failed to prepare semantic metadata for the saved visual")}})(),y(!0),a(!1))});return{saveAsDialogOpen:s,setSaveAsDialogOpen:a,handleSaveAs:async h=>{if(!C){t.ue.error("No sheet selected");return}const b=N(),I=r.getDynamicFrameSaveIssue(b);if(I){t.ue.error(I);return}const P=b.cards.length===1?{...b,cards:b.cards.map(T=>({...T,title:h.name}))}:b;if(h.saveToLibrary){let T=null;if(h.saveToCurrentDashboard)try{T=await n(P,{previousFrame:t.findDashboardFrameById(x,P.id)})}catch(M){console.error("Failed to prepare semantic metadata before saving visual:",M),t.ue.error(M instanceof Error?M.message:"Failed to prepare semantic metadata for the saved visual");return}d(h.saveToCurrentDashboard),c(P),m(T);const B={title:h.name,description:h.description,frameObject:P,isPrivate:!1};L.mutate(B)}else if(h.saveToCurrentDashboard){const T={...P,id:r.v4(),visualId:void 0};try{const B=await n(P,{previousFrame:t.findDashboardFrameById(x,P.id)});j(C,T,{position:"end",semanticExecutionPayload:B}),A(T.id),t.ue.success("Visual saved to dashboard"),a(!1),D(!1)}catch(B){console.error("Failed to save visual to dashboard:",B),t.ue.error(B instanceof Error?B.message:"Failed to prepare semantic metadata for the visual")}}},isLibraryVisual:w,currentVisualName:E,isSaving:L.isPending}}function te(s={}){const a=r.useEditorStore(S=>S.frame),v=r.useEditorStore(S=>S.editorContext),d=t.useManagementStore(S=>S.selectedVisual),i=r.useDashboardStore(S=>S.selectedFrameId),c=r.useDashboardStore(S=>S.selectedSheetId),u=r.useDashboardStore(S=>S.dashboard),{setIsVisualEditing:m,updateFrame:l}=r.useDashboardActions(),[o,p]=g.useState(!1),[C,x]=g.useState("both"),y=t.useResolveExistingFrameSemanticExecutionPayload(),N=(v==null?void 0:v.type)==="documentSection",f=!!(a!=null&&a.visualId||d!=null&&d.id),j=!!(a!=null&&a.visualId&&i),A=f&&!j,{saveAsDialogOpen:D,setSaveAsDialogOpen:n,handleSaveAs:w,isLibraryVisual:E,currentVisualName:L,isSaving:k}=ee(),{getUpdatedFrame:h}=R.useVisualUtils();if(N)return e.jsxs(e.Fragment,{children:[e.jsx(F.EditorAcceptButton,{className:"rounded-control",variant:"default"}),e.jsx(F.EditorCancelButton,{})]});const b=async()=>{if(!c){t.ue.error("No sheet selected");return}if(o)return;p(!0);const S=h(),P=r.getDynamicFrameSaveIssue(S);if(P){p(!1),t.ue.error(P);return}const T={...S,visualId:void 0},B=t.findDashboardFrameById(u,T.id);try{const M=await y(T,{previousFrame:B});l(c,T,{semanticExecutionPayload:M})}catch(M){console.error("Failed to apply local semantic metadata:",M),p(!1),t.ue.error(M instanceof Error?M.message:"Failed to prepare semantic metadata for this visual");return}setTimeout(()=>{p(!1),t.ue.success("Changes applied. Visual is now local to this dashboard"),m(!1)},300)},I=S=>{x(S),n(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"inline-flex items-center overflow-hidden rounded-control",children:[!f&&e.jsx(F.EditorAcceptButton,{className:"!rounded-none",variant:"default"}),f&&A&&e.jsx(F.VisualSaveButton,{className:"!rounded-none",variant:"default"}),f&&j&&e.jsx(F.VisualSaveAndApplyButton,{className:"!rounded-none"}),e.jsxs(t.DropdownMenu,{modal:!1,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(r.Button,{variant:"default",size:"xs",className:"w-7 !rounded-none border-l border-primary-foreground/20 px-0","aria-label":"Open visual save options",disabled:k||o,children:e.jsx(r.ChevronDown,{className:"h-3.5 w-3.5"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",className:"min-w-[220px] rounded-control border border-border/60 p-1 shadow-sm",children:[j&&e.jsxs(e.Fragment,{children:[e.jsxs(t.DropdownMenuItem,{onClick:b,disabled:o,children:[e.jsx(r.Check,{className:"h-3.5 w-3.5"}),o?"Applying...":"Apply Locally"]}),e.jsx(t.DropdownMenuSeparator,{})]}),e.jsxs(t.DropdownMenuItem,{onClick:()=>I("local"),disabled:k,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"Add to Dashboard (Local)"]}),e.jsxs(t.DropdownMenuItem,{onClick:()=>I("library"),disabled:k,children:[e.jsx(F.Library,{className:"h-3.5 w-3.5"}),"Save as Library Visual"]}),e.jsxs(t.DropdownMenuItem,{onClick:()=>I("both"),disabled:k,children:[e.jsx(F.Link2,{className:"h-3.5 w-3.5"}),"Save Copy as Linked Visual"]})]})]})]}),e.jsx(F.EditorCancelButton,{}),e.jsx(J,{open:D,onOpenChange:S=>{k||n(S)},isLibraryVisual:E,currentVisualName:L,isSaving:k,destinationMode:C,onConfirm:w})]})}function se({className:s}){const a=r.useEditorStore(o=>o.isDevMode),v=r.useDashboardStore(o=>o.isVisualEditing),{setIsDevMode:d}=r.useEditorActions(),{config:i}=g.useContext(t.SemaphorContext).tokenProps,c=(i==null?void 0:i.showAdvancedMode)!==!1;if(!v||!c)return null;const u=a?r.SlidersHorizontal:t.CodeXml,m=a?"Drag & drop":"SQL",l=a?"Switch to drag-and-drop mode":"Switch to SQL mode";return e.jsxs("button",{type:"button","aria-label":l,title:l,onClick:()=>d(!a),className:r.cn("inline-flex h-7 items-center gap-1.5 rounded-control border border-input bg-background px-2 text-[12px] font-medium text-foreground transition-colors hover:bg-muted/40 focus-visible:border-ring focus-visible:outline-none",s),children:[e.jsx(u,{className:"h-3 w-3 text-muted-foreground"}),m]})}function re({open:s,onOpenChange:a,onSave:v,onDiscard:d,isSaving:i,title:c="Unsaved changes",description:u="You have unsaved changes to this dashboard. What would you like to do?",cancelLabel:m="Cancel",discardLabel:l="Discard",saveLabel:o="Save"}){const p=C=>{!C&&i||a(C)};return e.jsx(t.AlertDialog,{open:s,onOpenChange:p,children:e.jsxs(t.AlertDialogContent,{children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsx(t.AlertDialogTitle,{children:c}),e.jsx(t.AlertDialogDescription,{children:u})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(r.Button,{type:"button",size:"xs",onClick:d,disabled:i,variant:"ghost",className:"mr-auto text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive",children:l}),e.jsx(t.AlertDialogCancel,{disabled:i,children:m}),e.jsx(r.Button,{type:"button",size:"xs",onClick:v,disabled:i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(r.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Saving..."]}):o})]})]})})}function z({export:s,onRemove:a}){const v=()=>{s.downloadUrl&&window.open(s.downloadUrl,"_blank")},d=m=>{m.stopPropagation(),a==null||a(s.id)},i=()=>{switch(s.status){case"completed":return e.jsx(t.CircleCheck,{className:"mt-0.5 h-5 w-5 shrink-0 text-green-600"});case"failed":return e.jsx(F.CircleX,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"});default:return e.jsx(r.LoaderCircle,{className:"text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin"})}},c=t.isExportInProgress(s.status),u=(()=>{switch(s.status){case"pending":return"Queued...";case"processing":return"Processing...";case"chunking":return"Processing...";case"compacting":return"Finalizing...";default:return"Processing..."}})();return e.jsxs("div",{className:"group p-4 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"mb-2 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[i(),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"mb-1 truncate text-sm font-medium",children:s.title}),s.status==="completed"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[s.totalRows.toLocaleString()," rows"]}),s.fileSize&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t.formatFileSize(s.fileSize)})]})]}),c&&e.jsx("div",{className:"text-xs text-muted-foreground",children:u}),s.status==="failed"&&e.jsx("div",{className:"line-clamp-2 text-xs text-destructive",children:s.error||"Export failed"})]})]}),e.jsx(r.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:d,"aria-label":"Remove notification",children:e.jsx(r.X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"ml-8",children:[s.status==="completed"&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:U.formatDistanceToNow(s.startedAt,{addSuffix:!0})}),s.downloadUrl&&e.jsxs(r.Button,{size:"sm",variant:"outline",className:"h-8 bg-transparent",onClick:v,children:[e.jsx(t.Download,{className:"mr-1.5 h-3.5 w-3.5"}),"Download"]})]}),c&&e.jsxs("div",{children:[e.jsx(t.Progress,{value:s.progress,className:"h-1.5"}),e.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[s.progress,"% complete"]})]}),s.status==="failed"&&e.jsx("span",{className:"text-xs text-muted-foreground",children:U.formatDistanceToNow(s.startedAt,{addSuffix:!0})})]})]})}function H(){const{authToken:s,tokenProps:a}=t.useSemaphorContext(),v=t.useExportStore(f=>f.activeExports),{clearCompleted:d,removeExport:i,updateExport:c}=t.useExportActions(),[u,m]=g.useState(!1),[l,o]=g.useState(!1),p=Array.from(v.values()).sort((f,j)=>j.startedAt.getTime()-f.startedAt.getTime()),C=p.some(f=>f.status==="completed"||f.status==="failed"),x=g.useCallback(async()=>{const f=a==null?void 0:a.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!(!f||!j)){m(!0);try{const A=Array.from(v.values());await Promise.all(A.map(async D=>{try{const n=await t.getExportStatus(f,j,D.id);let w;if(n.status==="completed")try{w=await t.getDownloadUrl(f,j,D.id)}catch(E){console.error(`Failed to get download URL for ${D.id}:`,E)}c(D.id,{status:n.status,progress:n.progress,completedChunks:n.completedChunks,completedAt:n.completedAt?new Date(n.completedAt):void 0,lastUpdatedAt:new Date,fileSize:n.fileSize,error:n.error,downloadUrl:w})}catch(n){console.error(`Failed to refresh export ${D.id}:`,n)}}))}finally{m(!1)}}},[v,s==null?void 0:s.accessToken,a==null?void 0:a.apiServiceUrl,c]),y=g.useCallback(async()=>{const f=a==null?void 0:a.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!f||!j){d();return}o(!0);try{const A=p.filter(n=>n.status==="completed"||n.status==="failed"),D=await Promise.allSettled(A.map(async n=>(await t.cancelExport(f,j,n.id),n.id)));for(const n of D)n.status==="fulfilled"?i(n.value):console.error("Failed to delete export:",n.reason)}finally{o(!1)}},[p,a==null?void 0:a.apiServiceUrl,s==null?void 0:s.accessToken,d,i]),N=g.useCallback(async f=>{const j=a==null?void 0:a.apiServiceUrl,A=s==null?void 0:s.accessToken;if(j&&A)try{await t.cancelExport(j,A,f),i(f);return}catch(D){console.error(`Failed to cancel export ${f}:`,D)}i(f)},[a==null?void 0:a.apiServiceUrl,s==null?void 0:s.accessToken,i]);return p.length===0?e.jsxs("div",{className:"p-6 text-center",children:[e.jsx(V,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No active exports"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Large exports will appear here"})]}):e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h4",{className:"font-semibold",children:"Exports"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(r.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:x,disabled:u,title:"Refresh status",children:e.jsx(t.RefreshCw,{className:`h-4 w-4 ${u?"animate-spin":""}`})}),C&&e.jsx(r.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-sm",onClick:y,disabled:l,children:l?"Clearing...":"Clear all"})]})]}),e.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:e.jsx("div",{className:"divide-y",children:p.map(f=>e.jsx(z,{export:f,onRemove:N},f.id))})})]})}function ae({variant:s}){const a=t.useExportStore(l=>l.activeExports),v=t.useInProgressExportsCount(),d=a.size>0,i=Array.from(a.values()).some(l=>l.status==="completed"||l.status==="failed"),u=v>0?v>9?"9+":String(v):null,m=d;return e.jsxs(r.Popover,{children:[e.jsx(r.PopoverTrigger,{asChild:!0,children:e.jsxs(r.Button,{variant:s??"ghost",size:"xs",className:"relative w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":"Export notifications",children:[e.jsx(t.Bell,{className:"h-3.5 w-3.5"}),m&&e.jsx("span",{className:`absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${u?"-right-0.5 -top-0.5 h-3.5 min-w-3.5 px-0.5 text-[9px] font-semibold":"right-1 top-1 h-1.5 w-1.5"}`,children:u})]})}),e.jsx(r.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:e.jsx(H,{})})]})}function oe(s){if(s)return{renamed:s.type==="rename"?{oldId:s.oldId,newId:s.newId}:void 0,removedControlId:s.type==="remove"?s.controlId:void 0,cardBindingsById:s.type==="add"||s.type==="update"?s.cardBindingsById:void 0,affectedBindingControlIds:s.type==="add"||s.type==="update"?s.affectedBindingControlIds:void 0}}function ne({open:s,onOpenChange:a,trigger:v,showTrigger:d=!0,initialMode:i="manage"}){const c=i==="create",{forceClose:u,handleOpenChange:m,isCreateFlowActive:l,preventPassiveDismissDuringCreate:o,resolvedOpen:p,setIsCreateFlowActive:C}=F.useCreateFlowOverlayState({open:s,onOpenChange:a,initialCreateFlowActive:i==="create",dismissMode:d?"passive":"explicit-only"}),x=r.useDashboardStore(h=>h.dashboard),{setDashboardControlsModel:y}=r.useDashboardActions(),{participants:N}=t.useDashboardStructuralParticipants(r.getDashboardCards(x)),f=Array.from(new Map(N.flatMap(h=>h.fieldChoices.map(b=>{var I;return[b.value,{option:b,target:(I=h.fieldTargetMap)==null?void 0:I[b.value]}]}))).values()),j=Array.from(new Map(N.flatMap(h=>h.metricChoices.map(b=>{var I;return[b.value,{option:b,target:(I=h.metricTargetMap)==null?void 0:I[b.value]}]}))).values()),A=r.collectDashboardControlIds({...x||{},controls:[]}),D=t.buildDashboardStructuralParticipantIdsByControlId(x),n=(h,b,I)=>{y(h,b,oe(I))},w=g.useCallback(()=>{if(c){u();return}C(!1)},[c,u,C]),E=e.jsx(F.ControlDefinitionListEditor,{scope:"dashboard",controls:x.controls||[],reservedControlIds:A,defaultValues:x.defaultControlValues||{},usageByControlId:t.buildDashboardControlUsageById(x),availableFieldChoices:f,availableMetricChoices:j,structuralParticipants:N,structuralParticipantIdsByControlId:D,initialCreateFlow:i==="create",onCreateFlowActiveChange:C,onCreateFlowComplete:w,onChange:n,emptyMessage:"No dashboard controls yet."}),L=l?"Add dashboard control":"Dashboard Controls",k=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Dashboard Controls"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),E]});return d?e.jsxs(r.Popover,{open:p,onOpenChange:m,children:[e.jsx(r.PopoverTrigger,{asChild:!0,children:v||e.jsxs(r.Button,{variant:"outline",className:"h-7 px-2",size:"sm",children:[e.jsx(r.SlidersHorizontal,{className:"mr-2 h-4 w-4"}),"Controls"]})}),e.jsx(r.PopoverContent,{className:"w-[620px] max-w-[95vw] space-y-4",align:"end",onEscapeKeyDown:o,onPointerDownOutside:o,children:k})]}):e.jsx(t.Dialog,{open:p,onOpenChange:m,children:e.jsxs(t.DialogContent,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:o,onPointerDownOutside:o,children:[e.jsxs(t.DialogHeader,{className:l?"space-y-0":void 0,children:[e.jsx(t.DialogTitle,{className:"text-[15px]",children:L}),e.jsx(t.DialogDescription,{className:l?"sr-only":"text-[13px]",children:l?"Configure and add a shared dashboard control.":"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),e.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:E})]})})}function ie({showFilters:s,onToggleFilters:a,onAddFilter:v,onAddControl:d,onManageControls:i,size:c="default",className:u,primaryButtonClassName:m,secondaryButtonClassName:l,dropdownContentClassName:o}){const p=c==="toolbar";return e.jsxs("div",{className:r.cn("relative inline-flex items-stretch overflow-hidden rounded-control border border-input bg-background",p?"h-8":"h-7",u),children:[e.jsxs(r.Button,{variant:"ghost",size:"xs",className:r.cn("h-full rounded-none border-0 bg-transparent pl-2.5 pr-2 shadow-none hover:bg-accent/50",m),onClick:a,children:[s?e.jsx($,{className:"h-3.5 w-3.5"}):e.jsx(t.Filter,{className:"h-3.5 w-3.5"}),"Filter"]}),e.jsxs(t.DropdownMenu,{children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(r.Button,{variant:"ghost",size:"xs",className:r.cn("h-full w-7 rounded-none border-0 border-l border-border/60 bg-transparent px-0 shadow-none hover:bg-accent/50",l),"aria-label":"Filter and control actions",children:e.jsx(r.ChevronDown,{className:"h-3.5 w-3.5"})})}),e.jsxs(t.DropdownMenuContent,{align:"start",className:r.cn("min-w-[180px] rounded-control border border-border/60 p-1 shadow-sm",o),children:[e.jsxs(t.DropdownMenuItem,{onSelect:v,children:[e.jsx(t.Filter,{className:"h-3.5 w-3.5"}),"Add filter"]}),e.jsxs(t.DropdownMenuItem,{onSelect:d,children:[e.jsx(r.SlidersHorizontal,{className:"h-3.5 w-3.5"}),"Add control"]}),e.jsxs(t.DropdownMenuItem,{onSelect:i,children:[e.jsx(t.Pencil,{className:"h-3.5 w-3.5"}),"Manage controls"]})]})]})]})}exports.AdvancedModeToggle=se;exports.DashboardControlsSettings=ne;exports.DashboardFilterControlsButton=ie;exports.ExportNotificationItem=z;exports.ExportNotificationList=H;exports.NotificationBell=ae;exports.UnsavedChangesAlert=re;exports.VisualEditingControls=te;exports.useExportPolling=W;exports.useExportRecovery=Y;
@@ -1 +0,0 @@
1
- "use strict";const e=require("react/jsx-runtime"),o=require("react"),a=require("./index-DQCMUspd.js"),s=require("./switch-BPFzGTzF.js");function q(n={}){var k,P,A,E;const{authToken:c,tokenProps:t}=a.useSemaphorContext(),S=n.enabled??!0,u=(c==null?void 0:c.accessToken)??null,f=(t==null?void 0:t.apiServiceUrl)??null,[N,j]=o.useState(!1),[v,b]=o.useState(!1),[h,l]=o.useState(!1),[y,d]=o.useState(null),[p,w]=o.useState(null),T=p||{tz:((P=(k=t==null?void 0:t.params)==null?void 0:k.calendarContext)==null?void 0:P.tz)||null,weekStart:((E=(A=t==null?void 0:t.params)==null?void 0:A.calendarContext)==null?void 0:E.weekStart)??null},g=o.useCallback(async()=>{if(!(!S||!u||!f)){j(!0),d(null);try{const m=await fetch(`${f}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${u}`}});if(!m.ok){const x=await m.json().catch(()=>({}));throw new Error(x.error||"Failed to fetch preferences")}const i=await m.json();w({tz:i.tz,weekStart:i.weekStart,source:i.source,isInherited:i.isInherited,userHasPrefs:i.userHasPrefs,inherited:i.inherited})}catch(m){const i=m instanceof Error?m.message:"Unknown error";d(i)}finally{j(!1)}}},[u,f,S]);o.useEffect(()=>{S&&g()},[S,g]);const I=o.useCallback(async m=>{if(!u||!f)return d("Not authenticated"),!1;b(!0),d(null);try{const i=await fetch(`${f}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify(m)});if(!i.ok){const x=await i.json().catch(()=>({}));throw new Error(x.error||"Failed to update preferences")}return await g(),!0}catch(i){const x=i instanceof Error?i.message:"Unknown error";return d(x),!1}finally{b(!1)}},[u,f,g]),C=o.useCallback(async()=>{if(!u||!f)return d("Not authenticated"),!1;l(!0),d(null);try{const m=await fetch(`${f}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${u}`}});if(!m.ok){const x=await m.json().catch(()=>({}));throw new Error(x.error||"Failed to clear preferences")}const i=await m.text();if(i)try{const x=JSON.parse(i);return w({tz:x.tz,weekStart:x.weekStart,source:x.source,isInherited:x.isInherited??!0,userHasPrefs:!1,inherited:x.inherited}),!0}catch{}return await g(),!0}catch(m){const i=m instanceof Error?m.message:"Unknown error";return d(i),!1}finally{l(!1)}},[u,f,g]);return{preferences:T,isLoading:N,isSaving:v,isClearing:h,error:y,updatePreferences:I,clearPreferences:C,refetch:g}}const D=[{value:"America/New_York",label:"Eastern Time (US & Canada)"},{value:"America/Chicago",label:"Central Time (US & Canada)"},{value:"America/Denver",label:"Mountain Time (US & Canada)"},{value:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{value:"America/Phoenix",label:"Arizona"},{value:"America/Anchorage",label:"Alaska"},{value:"Pacific/Honolulu",label:"Hawaii"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris, Berlin, Rome"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Shanghai",label:"Beijing, Shanghai"},{value:"Asia/Kolkata",label:"Mumbai, New Delhi"},{value:"Australia/Sydney",label:"Sydney"},{value:"UTC",label:"UTC"}],$=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}],B="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function X(){try{const n=Intl;if(n.supportedValuesOf)return n.supportedValuesOf("timeZone")}catch{}return D.map(n=>n.value)}function Z(n){switch(n){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function _(n){const c=D.find(t=>t.value===n);return c?c.label:n}function J(n){const c=$.find(t=>t.value===n);return c?c.label:String(n)}function K({open:n,onOpenChange:c}){var M,F,U;const{preferences:t,isLoading:S,isSaving:u,isClearing:f,updatePreferences:N,clearPreferences:j}=q({enabled:n}),v=t.tz||((M=t.inherited)==null?void 0:M.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,b=t.weekStart??((F=t.inherited)==null?void 0:F.weekStart)??1,[h,l]=o.useState(!t.userHasPrefs),[y,d]=o.useState(!1),[p,w]=o.useState(v),[T,g]=o.useState(b),[I,C]=o.useState(!1),k=o.useMemo(()=>X(),[]),P=o.useMemo(()=>k.filter(r=>!D.some(V=>V.value===r)),[k]),A=o.useMemo(()=>_(p),[p]),E=t.inherited?_(t.inherited.tz):"UTC",m=t.inherited?J(t.inherited.weekStart):"Monday",i=Z((U=t.inherited)==null?void 0:U.source);o.useEffect(()=>{if(!n){d(!1);return}y||(t.userHasPrefs!==void 0&&l(!t.userHasPrefs),w(v),g(b))},[n,y,t.userHasPrefs,v,b]);const x=async()=>{if(S){a.ue.error("Preferences are still loading. Please try again.");return}h?await j()?(a.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),c(!1)):a.ue.error("Failed to save preferences. Please try again."):await N({tz:p,weekStart:T})?(a.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),c(!1)):a.ue.error("Failed to save preferences. Please try again.")},G=()=>{c(!1)},L=u||f,W=L||S;return e.jsx(a.Dialog,{open:n,onOpenChange:c,children:e.jsxs(a.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{className:"text-[15px]",children:"Calendar preferences"}),e.jsx(a.DialogDescription,{className:"text-[13px] leading-5",children:"Set your timezone and week-start for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs(a.RadioGroup,{value:h?"defaults":"custom",onValueChange:r=>{d(!0),l(r==="defaults")},className:"space-y-0.5",children:[e.jsxs("label",{htmlFor:"mode-defaults",className:s.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",h&&"bg-muted/50"),onClick:()=>{d(!0),l(!0)},children:[e.jsx(a.RadioGroupItem,{value:"defaults",id:"mode-defaults",className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-[13px] font-medium text-foreground",children:["Use ",i," defaults"]}),e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[E,", week starts ",m]})]})]}),e.jsxs("label",{htmlFor:"mode-custom",className:s.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",!h&&"bg-muted/50"),onClick:()=>{d(!0),l(!1)},children:[e.jsx(a.RadioGroupItem,{value:"custom",id:"mode-custom",className:"mt-0.5"}),e.jsx("p",{className:"flex-1 text-[13px] font-medium text-foreground",children:"Use custom settings"})]})]}),e.jsxs("div",{className:s.cn("space-y-4 border-t border-border/60 pt-4 transition-opacity",h&&"pointer-events-none opacity-50"),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{className:B,children:"Timezone"}),e.jsxs(s.Popover,{open:I,onOpenChange:C,modal:!0,children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsxs(s.Button,{variant:"outline",size:"xs",role:"combobox","aria-expanded":I,className:"w-full justify-between text-[12px] font-normal",disabled:h,children:[e.jsx("span",{className:"truncate",children:A}),e.jsx(a.ChevronsUpDown,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(s.PopoverContent,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(a.Command,{className:"overflow-visible",children:[e.jsx(a.CommandInput,{placeholder:"Search timezones…"}),e.jsxs(a.CommandList,{children:[e.jsx(a.CommandEmpty,{children:"No timezone found."}),e.jsx(a.CommandGroup,{heading:"Common",children:D.map(r=>e.jsxs(a.CommandItem,{value:`${r.value} ${r.label}`,onSelect:()=>{d(!0),w(r.value),C(!1)},children:[e.jsx(s.Check,{className:s.cn("h-3.5 w-3.5",p===r.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:r.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:r.value})]},r.value))}),e.jsx(a.CommandSeparator,{}),e.jsx(a.CommandGroup,{heading:"All timezones",children:P.map(r=>e.jsxs(a.CommandItem,{value:r,onSelect:()=>{d(!0),w(r),C(!1)},children:[e.jsx(s.Check,{className:s.cn("h-3.5 w-3.5",p===r?"opacity-100":"opacity-0")}),r]},r))})]})]})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{className:B,children:"Week starts on"}),e.jsx(a.RadioGroup,{value:String(T),onValueChange:r=>{d(!0),g(Number(r))},className:"flex gap-4",disabled:h,children:$.map(r=>e.jsxs("label",{htmlFor:`week-start-${r.value}`,className:s.cn("flex cursor-pointer items-center gap-2 text-[13px]",h&&"cursor-not-allowed"),children:[e.jsx(a.RadioGroupItem,{value:String(r.value),id:`week-start-${r.value}`,disabled:h}),r.label]},r.value))})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",size:"xs",onClick:G,disabled:L,children:"Cancel"}),e.jsx(s.Button,{size:"xs",onClick:x,disabled:W,children:L?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})})}const z=6,O=1,R=20,H="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Y(n){return Number.isNaN(n)?z:Math.min(R,Math.max(O,n))}function Q({open:n,onOpenChange:c,dashboard:t,onApply:S,disabled:u=!1}){const[f,N]=o.useState(!1),[j,v]=o.useState("top"),[b,h]=o.useState(String(z)),l=t.summary;o.useEffect(()=>{n&&(N((l==null?void 0:l.enabled)===!0),v((l==null?void 0:l.position)==="bottom"?"bottom":"top"),h(String((l==null?void 0:l.maxItems)??z)))},[n,l==null?void 0:l.enabled,l==null?void 0:l.position,l==null?void 0:l.maxItems]);const y=o.useMemo(()=>Y(Number.parseInt(b||`${z}`,10)),[b]),d=()=>{S({enabled:f,position:j,maxItems:y}),c(!1)};return e.jsx(a.Dialog,{open:n,onOpenChange:c,children:e.jsxs(a.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[420px] sm:rounded-control",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{className:"text-[15px]",children:"Summary Settings"}),e.jsx(a.DialogDescription,{className:"text-[13px] leading-5",children:"Configure dashboard-level summary display. Card-level summary settings still control which cards contribute."})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(s.Label,{htmlFor:"dashboard-summary-enabled",className:"text-[13px]",children:"Enable dashboard summary"}),e.jsx(s.Switch,{size:"xs",id:"dashboard-summary-enabled",checked:f,disabled:u,onCheckedChange:N})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{htmlFor:"dashboard-summary-position",className:H,children:"Position"}),e.jsxs(s.Select,{value:j,disabled:u,onValueChange:p=>v(p),children:[e.jsx(s.SelectTrigger,{id:"dashboard-summary-position",size:"xs",children:e.jsx(s.SelectValue,{placeholder:"Select position"})}),e.jsxs(s.SelectContent,{children:[e.jsx(s.SelectItem,{value:"top",children:"Top"}),e.jsx(s.SelectItem,{value:"bottom",children:"Bottom"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{htmlFor:"dashboard-summary-max-items",className:H,children:"Max items"}),e.jsx(s.Input,{size:"xs",id:"dashboard-summary-max-items",type:"number",min:O,max:R,disabled:u,value:b,onChange:p=>h(p.target.value),onBlur:()=>h(String(y))}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Display limit only. Computation is unchanged."})]}),u&&e.jsx("p",{className:"text-[12px] text-amber-700",children:"Enter dashboard edit mode to modify summary settings."})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",size:"xs",onClick:()=>c(!1),children:"Cancel"}),e.jsx(s.Button,{size:"xs",onClick:d,disabled:u,children:"Apply"})]})]})})}exports.CalendarPreferencesDialog=K;exports.DashboardSummarySettingsDialog=Q;