react-semaphor 0.1.282 → 0.1.283

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 (28) hide show
  1. package/dist/chunks/{dashboard-controls-B_F5f_BF.js → dashboard-controls-DN8jYCON.js} +102 -102
  2. package/dist/chunks/{dashboard-controls-XX9__V-e.js → dashboard-controls-wfMo3T6T.js} +1 -1
  3. package/dist/chunks/{dashboard-filter-controls-button-DZpvfXwU.js → dashboard-filter-controls-button-DKc_6T_O.js} +2 -2
  4. package/dist/chunks/{dashboard-filter-controls-button-DVLBLHga.js → dashboard-filter-controls-button-zeiatmo1.js} +108 -96
  5. package/dist/chunks/{dashboard-json-Dd9Q2bZm.js → dashboard-json-DK_hQ4vs.js} +1 -1
  6. package/dist/chunks/{dashboard-json-CexNQg-E.js → dashboard-json-DyJBSpIU.js} +1 -1
  7. package/dist/chunks/{dashboard-summary-settings-dialog-BjdrHb1l.js → dashboard-summary-settings-dialog-BPyawgMV.js} +1 -1
  8. package/dist/chunks/{dashboard-summary-settings-dialog-zdacBYZZ.js → dashboard-summary-settings-dialog-CWtlFDFP.js} +1 -1
  9. package/dist/chunks/{edit-dashboard-visual-Bi9pQx6G.js → edit-dashboard-visual-0lBlwTCM.js} +1 -1
  10. package/dist/chunks/{edit-dashboard-visual-DQts3aun.js → edit-dashboard-visual-4nQV1U_c.js} +319 -319
  11. package/dist/chunks/{index-Bgn4zTsp.js → index-B7kUtCgG.js} +12111 -12123
  12. package/dist/chunks/{index-BY0YEY92.js → index-BHWWNpG6.js} +119 -119
  13. package/dist/chunks/{resource-management-panel-w7afzaPB.js → resource-management-panel-D8xvqypt.js} +1 -1
  14. package/dist/chunks/{resource-management-panel--xIMLPdz.js → resource-management-panel-Dpin6Ffw.js} +2 -2
  15. package/dist/chunks/use-create-flow-overlay-state-VwKDgVAy.js +1597 -0
  16. package/dist/chunks/use-create-flow-overlay-state-XkHgf9f3.js +21 -0
  17. package/dist/chunks/{use-visual-utils-CI-7TNJI.js → use-visual-utils-C8YSTPfX.js} +1 -1
  18. package/dist/chunks/{use-visual-utils-BCWNcaWk.js → use-visual-utils-CBocWNV1.js} +1 -1
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +5 -5
  23. package/dist/style.css +1 -1
  24. package/dist/surfboard/index.cjs +1 -1
  25. package/dist/surfboard/index.js +2 -2
  26. package/package.json +1 -1
  27. package/dist/chunks/use-create-flow-overlay-state-AsQy4tbh.js +0 -21
  28. package/dist/chunks/use-create-flow-overlay-state-COsIHnQp.js +0 -1523
@@ -0,0 +1,21 @@
1
+ "use strict";const e=require("./index-BHWWNpG6.js"),t=require("react/jsx-runtime"),C=require("react"),se=require("./use-visual-utils-C8YSTPfX.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 je=e.createLucideIcon("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
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 fe=e.createLucideIcon("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/**
12
+ * @license lucide-react v0.453.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const he=e.createLucideIcon("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
17
+ * @license lucide-react v0.453.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const re=e.createLucideIcon("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);function le(){var f,j;const a=e.useEditorStore(y=>y.card),l=e.useEditorStore(y=>y.frame),i=C.useMemo(()=>e.findCustomVisualConfigCard(l,a),[l,a]),{manifest:d}=e.useCustomVisual(((f=i==null?void 0:i.customCardPreferences)==null?void 0:f.url)||""),x=C.useMemo(()=>{var y;return(y=d==null?void 0:d.visuals)==null?void 0:y.find(p=>{var g;return p.name===((g=i==null?void 0:i.customCardPreferences)==null?void 0:g.componentName)})},[d,(j=i==null?void 0:i.customCardPreferences)==null?void 0:j.componentName]),u=e.resolveMultiInputType(i,x),h=C.useMemo(()=>e.getCustomVisualInputCards({frame:l,configCard:i,isMultiInputVisual:u==="multiple"}),[l,i,u]),v=C.useMemo(()=>{const y=h.findIndex(p=>(p==null?void 0:p.id)===a.id);return y<0?-1:e.getSlotIndexForCard(a,y)},[h,a]);return C.useMemo(()=>!i||u!=="multiple"||v<0?a.type:e.getEffectiveCardTypeForSlot(a,v,x==null?void 0:x.slots)??a.type,[i,u,v,a,x==null?void 0:x.slots])}function ke({type:a,isLinked:l,className:i,showLabel:d=!1,showLocal:x=!1}){const u=e.useDashboardStore(T=>T.selectedFrameId),h=e.useManagementStore(T=>T.selectedVisual),v=e.useEditorStore(T=>T.frame);let f;if(a)f=a;else if(l!==void 0)f=l?"linked":"library";else if(!!!(v!=null&&v.visualId||h!=null&&h.id)&&u)f="local";else if(h&&!u)f="library";else if(v!=null&&v.visualId&&u)f="linked";else if(h!=null&&h.id&&u)f="library";else return null;if(f==="local"&&!x)return null;const j={local:"border-slate-200/70 bg-slate-50/80 text-slate-700 shadow-sm hover:bg-slate-100/80 dark:border-slate-700 dark:bg-slate-900/70 dark:text-slate-200 dark:hover:bg-slate-800/80",linked:"border-purple-200/70 bg-gradient-to-r from-purple-50/50 to-purple-100/30 text-purple-900 shadow-sm hover:from-purple-100/60 hover:to-purple-100/50 hover:shadow-md dark:border-purple-800/50 dark:from-purple-950/40 dark:to-purple-900/30 dark:text-purple-100 dark:hover:from-purple-950/60 dark:hover:to-purple-900/50",library:"border-blue-200/70 bg-gradient-to-r from-blue-50/50 to-blue-100/30 text-blue-900 shadow-sm hover:from-blue-100/60 hover:to-blue-100/50 hover:shadow-md dark:border-blue-800/50 dark:from-blue-950/40 dark:to-blue-900/30 dark:text-blue-100 dark:hover:from-blue-950/60 dark:hover:to-blue-900/50"},y={local:"Local to this dashboard: Changes made here only affect this dashboard copy.",linked:"Linked to library: Changes made here update the library visual and all linked instances.",library:"Library visual: Share and reuse this visual across multiple dashboards."},p={local:"border-slate-200 bg-slate-50 text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100",linked:"border-purple-200 bg-purple-50 text-purple-900 dark:border-purple-800 dark:bg-purple-950 dark:text-purple-100",library:"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-100"},g={local:"fill-slate-50 dark:fill-slate-900",linked:"fill-purple-50 dark:fill-purple-950",library:"fill-blue-50 dark:fill-blue-950"},S={local:t.jsx("span",{className:"h-2 w-2 rounded-full bg-current/70"}),linked:t.jsx(he,{className:"h-3.5 w-3.5"}),library:t.jsx(fe,{className:"h-3.5 w-3.5"})},V={local:"Local",linked:"Linked",library:"Library"};return t.jsx(e.TooltipProvider,{children:t.jsxs(e.Tooltip,{delayDuration:300,children:[t.jsx(e.TooltipTrigger,{asChild:!0,children:t.jsxs(e.Badge,{variant:"outline",className:e.cn("cursor-help select-none transition-all",j[f],i),children:[S[f],d&&t.jsx("span",{className:"ml-1 text-xs font-medium leading-none",children:V[f]})]})}),t.jsxs(e.TooltipContent,{side:"bottom",className:e.cn("max-w-xs",p[f]),children:[t.jsx(e.TooltipArrow,{className:g[f]}),t.jsx("p",{children:y[f]})]})]})})}function Se(a,l){return{...a,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,dynamicCardPreferences:void 0,customCardPreferences:l?a.customCardPreferences:void 0,visualizationMode:"builtin",type:l?a.type:"bar"}}function ae(a){const l=e.getDynamicFrameSaveIssue(a);return l?(e.ue.error(l),!1):!0}function Ne({className:a,variant:l="outline"}){const i=e.useEditorStore(u=>u.onSave),{getUpdatedFrame:d}=se.useVisualUtils();function x(){const u=d();ae(u)&&(i==null||i(u))}return t.jsxs(e.Button,{onClick:x,className:e.cn("h-8",a),size:"sm",variant:l,children:[t.jsx(e.Check,{className:"mr-2 size-4 font-bold"}),"Accept"]})}function De({className:a,variant:l="default"}){const i=e.useQueryClient(),[d,x]=C.useState(!1),u=e.useDashboardStore(g=>g.actions.setIsDashboardPanelOpen),{setIsVisualEditing:h}=e.useDashboardActions(),{getUpdatedFrame:v}=se.useVisualUtils(),f=e.useSelectedVisual(),j=e.useEditorStore(g=>g.frame),y=e.useUpdateVisualMutation(),p=()=>{const g=v();if(!ae(g))return;const S=(j==null?void 0:j.visualId)||(f==null?void 0:f.id);if(!S){e.ue.error("No visual to save");return}x(!0),y.mutate({visualId:S,data:{frameObject:g}},{onSuccess:()=>{x(!1),u(!0),e.ue.success("Visual updated successfully"),i.invalidateQueries({queryKey:["resource-by-id","visual",S],exact:!0})},onError:()=>{x(!1),e.ue.error("Failed to update visual")}})};return t.jsxs(e.Button,{onClick:p,className:e.cn("h-8",a),size:"sm",variant:l,children:[d&&t.jsxs(t.Fragment,{children:[t.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Saving"]}),!d&&t.jsxs(t.Fragment,{children:[t.jsx(re,{className:"mr-2 size-4 font-bold"}),"Save to Library"]})]})}function we({className:a}){const l=e.useQueryClient(),[i,d]=C.useState(!1),x=e.useSelectedVisual(),u=e.useEditorStore(g=>g.frame),h=e.useDashboardStore(g=>g.selectedSheetId),{updateFrame:v,setIsVisualEditing:f}=e.useDashboardActions(),{getUpdatedFrame:j}=se.useVisualUtils(),y=e.useUpdateVisualMutation(),p=async()=>{if(!h){e.ue.error("No sheet selected");return}const g=(u==null?void 0:u.visualId)||(x==null?void 0:x.id);if(!g){e.ue.error("No visual to update");return}d(!0);try{const S=j();if(!ae(S)){d(!1);return}await y.mutateAsync({visualId:g,data:{frameObject:S}});const V={...S,visualId:g};v(h,V),l.invalidateQueries({queryKey:["visuals"]}),l.invalidateQueries({queryKey:["visual",g]}),e.ue.success("Saved to library and applied locally"),setTimeout(()=>{f(!1)},300)}catch(S){console.error("Failed to save and apply:",S),e.ue.error("Failed to save and apply changes")}finally{d(!1)}};return t.jsx(e.Button,{onClick:p,className:e.cn("h-8",a),size:"sm",variant:"default",disabled:i,children:i?t.jsxs(t.Fragment,{children:[t.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Saving..."]}):t.jsxs(t.Fragment,{children:[t.jsx(re,{className:"mr-2 size-4 font-bold"}),"Save & Apply"]})})}function Ee({className:a}){const{setTempQueryData:l,setSqlGen:i}=e.useEditorActions(),d=e.useQueryClient(),x=e.useEditorStore(p=>p.tempQueryData),u=e.useEditorStore(p=>p.onClose),h=e.useEditorStore(p=>p.card),v=le(),f=C.useMemo(()=>v!==h.type?{...h,type:v}:h,[h,v]),{queryKey:j}=e.useDashboardCardQuery(f);function y(){if(x){const{queryKey:p,queryData:g}=x;p&&g&&d.setQueryData(p,g)}i({}),u==null||u()}return t.jsxs(e.Button,{onClick:y,className:e.cn("h-8",a),size:"sm",variant:"outline",children:[t.jsx(e.X,{className:"mr-2 size-4"}),"Close"]})}function Ve({label:a="Clear",variant:l="secondary",className:i}={}){const{setTempQueryData:d}=e.useEditorActions(),x=e.useQueryClient(),u=e.useEditorStore(r=>r.tempQueryData),h=e.useEditorStore(r=>r.card),v=le(),f=C.useMemo(()=>v!==h.type?{...h,type:v}:h,[h,v]),{queryKey:j}=e.useDashboardCardQuery(f),{setCardSql:y,setSqlGen:p,setCardPython:g,setCardCustomCfg:S,setCardPreferences:V,clearQueryConfig:T,setCardConfig:H,setCardType:G,setFrame:K,setCard:O,setActiveTabCardId:J}=e.useEditorActions();function M(){var I,R,q,X;const r=x.getQueryData(j);u!=null&&u.queryData||d({queryKey:j,queryData:r}),x.setQueryData(j,null),x.removeQueries({queryKey:j,exact:!0}),y(""),p({}),T(),H(void 0),g(""),S(""),V({});const N=e.useEditorStore.getState().frame,B=e.useEditorStore.getState().card,E=e.findCustomVisualConfigCard(N,B),Q=((I=E==null?void 0:E.customCardPreferences)==null?void 0:I.visualType)==="multiple"||!!((R=E==null?void 0:E.customCardPreferences)!=null&&R.dataInputCardIds)||(((q=E==null?void 0:E.customCardPreferences)==null?void 0:q.minInputs)||0)>1||(((X=E==null?void 0:E.customCardPreferences)==null?void 0:X.maxInputs)||0)>1,_=Se(B,Q);K({...N,cards:N.cards.map(U=>U.id===_.id?_:U)}),J(_.id),O(_),Q||G("bar")}return t.jsxs(e.Button,{onClick:M,className:e.cn("h-8",i),size:"sm",variant:l,children:[t.jsx(e.X,{className:"mr-2 size-3.5"}),a]})}function ge(a){const{control:l,onChange:i}=a;return t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(e.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),t.jsx(e.Input,{size:"xs",value:l.label,placeholder:"Control label",onChange:d=>i(d.target.value)})]})}function Te(a){const{currentStep:l,labels:i}=a;return t.jsx("div",{className:"sticky top-0 z-10 -mx-1 border-b border-border/60 bg-background/95 px-1 pb-2.5 pt-1 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:t.jsx("div",{className:"flex flex-wrap items-center gap-2 sm:gap-2.5",children:i.map((d,x)=>{const u=x+1,h=u===l,v=u<l;return t.jsxs(C.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:e.cn("flex h-5 w-5 items-center justify-center rounded-full border text-[10px] font-medium tabular-nums",h?"border-foreground bg-foreground text-background":v?"border-foreground/30 bg-foreground/10 text-foreground":"border-border/60 bg-background text-muted-foreground"),children:u}),t.jsx("span",{className:e.cn("text-[12px]",h?"font-medium text-foreground":"text-muted-foreground"),children:d})]}),x<i.length-1?t.jsx("span",{className:"h-px w-4 bg-border/60 sm:w-6","aria-hidden":"true"}):null]},d)})})})}function $(a){const{secondary:l,tertiary:i,primary:d}=a;return t.jsxs("div",{className:"sticky bottom-0 z-10 -mx-1 flex justify-end gap-2 border-t bg-background/95 px-1 pb-1 pt-3 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:[l,i,d]})}function Ie(a){const{control:l,scope:i,detail:d}=a;return t.jsxs("div",{className:"flex items-start gap-2.5 rounded-[6px] border border-border/60 bg-muted/30 px-3 py-2.5",children:[t.jsx(e.CircleCheck,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground"}),t.jsxs("div",{className:"min-w-0 space-y-0.5",children:[t.jsx("div",{className:"text-[13px] font-medium text-foreground",children:l.label}),t.jsxs("div",{className:"text-[12px] text-muted-foreground",children:[e.getFriendlyTypeOption(l.type).label," ·"," ",e.getControlOptionPreview(l)," ·"," ",e.getPlacementLabel(i,l.placement)]}),d?t.jsx("div",{className:"text-[12px] text-muted-foreground",children:d}):null]})]})}function pe(a){const{control:l,defaultValue:i,availableFieldChoices:d,availableMetricChoices:x,previewControlDefinitions:u,previewControlValues:h,onControlChange:v,onLabelChange:f,onDefaultValueChange:j,onBack:y,onNext:p,nextDisabled:g}=a;return t.jsxs("div",{className:"space-y-3",children:[t.jsx(ge,{control:l,onChange:f}),t.jsx(e.ControlDefinitionOptionsEditor,{control:l,availableFieldChoices:d,availableMetricChoices:x,previewControlDefinitions:u,previewControlValues:h,controlLifecycle:"create",onChange:v}),t.jsx(e.ControlDefaultValueEditor,{control:l,value:i,onChange:j,allowNoDefault:!0,allowCardDefault:!0,hint:"This is the value viewers will see first.",previewControlDefinitions:u,previewControlValues:h}),t.jsx($,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",size:"xs",onClick:y,children:"Back"}),primary:t.jsx(e.Button,{type:"button",size:"xs",onClick:p,disabled:g,children:"Next"})})]})}const Le=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]);function me(a){const{text:l,ariaLabel:i}=a,[d,x]=C.useState(!1);return t.jsxs("button",{type:"button","aria-label":i,onClick:async()=>{try{await navigator.clipboard.writeText(l),x(!0),setTimeout(()=>x(!1),1200)}catch(u){console.error("Failed to copy",u)}},className:"group flex w-full items-center justify-between gap-2 rounded-[4px] bg-muted/40 px-2 py-1 text-left transition-colors hover:bg-muted/60 focus-visible:bg-muted/60 focus-visible:outline-none",children:[t.jsx("code",{className:"min-w-0 truncate font-mono text-[12px] text-foreground",children:l}),t.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100",children:d?"Copied":"Click to copy"})]})}function xe(a){const{control:l,scope:i,createdReference:d,explorerContent:x,sqlDescription:u,summaryDetail:h,onBack:v,onCancel:f,onDone:j}=a,y=Le.has(l.type),p=d.match(/\[\[param\.(.+?)\]\]/),g=p?`{{ param('${p[1]}') }}`:"";return t.jsxs("div",{className:"space-y-4",children:[t.jsx(Ie,{control:l,scope:i,detail:h}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-[13px] font-medium text-foreground",children:"How cards use this control"}),t.jsxs("div",{className:"divide-y divide-border/60 overflow-hidden rounded-[6px] border border-border/60",children:[y?t.jsxs("div",{className:"space-y-1 px-3 py-2.5",children:[t.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Explorer cards"}),t.jsx("div",{className:"text-[12px] text-muted-foreground",children:x})]}):null,t.jsxs("div",{className:"space-y-1.5 px-3 py-2.5",children:[t.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"SQL cards"}),t.jsx(me,{text:d,ariaLabel:"Copy SQL control reference"}),g?t.jsx(me,{text:g,ariaLabel:"Copy Jinja control reference"}):null,t.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[u," ",t.jsx("a",{href:"https://docs.semaphor.cloud/docs/concepts/template-expressions",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Template expressions docs"}),"."]})]})]})]}),t.jsx($,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",size:"xs",onClick:v,children:"Back"}),tertiary:t.jsx(e.Button,{type:"button",variant:"outline",size:"xs",onClick:f,children:"Cancel"}),primary:t.jsx(e.Button,{type:"button",size:"xs",onClick:j,children:"Done"})})]})}function Fe(a){const l=e.createBlankControl(a.scope,a.existingControls,a.reservedIds),i=a.type===l.type?{...l,label:e.DEFAULT_LABEL_BY_TYPE[a.type]}:{...e.applyControlTypeChange({controls:[{...l,label:e.DEFAULT_LABEL_BY_TYPE[a.type]}],controlId:l.id,nextType:a.type}).controls[0],label:e.DEFAULT_LABEL_BY_TYPE[a.type]};return{step:2,control:i,defaultValue:e.getDefaultValueForType(i,void 0)}}function Be({scope:a,controls:l,reservedControlIds:i,defaultValues:d,onChange:x,emptyMessage:u,initialCreateFlow:h=!1,usageByControlId:v,availableFieldChoices:f,availableMetricChoices:j,structuralParticipants:y,structuralParticipantIdsByControlId:p,card:g,onCreateFlowActiveChange:S,onCreateFlowComplete:V}){const T=C.useMemo(()=>new Set(i||[]),[i]),H=e.getPlacementOptionsForScope(a),G=e.getDefaultPlacement(a),[K,O]=C.useState(null),[J,M]=C.useState(null),[r,N]=C.useState(()=>h?{step:1,control:e.createBlankControl(a,l,Array.from(T))}:null),B=C.useRef({}),E=C.useRef(void 0),Q=C.useRef(h),_=C.useMemo(()=>e.getFriendlyControlTypeOptions({scope:a,card:g}),[g,a]),I=C.useCallback(s=>a==="dashboard"&&(s==="field_selector"||s==="metric_selector"),[a]),R=C.useMemo(()=>r?e.getEligibleParticipantsForStructuralControl(y||[],r.control.type):[],[r,y]),q=C.useMemo(()=>{if(!r)return{fields:f||[],metrics:j||[]};if(!I(r.control.type))return{fields:f||[],metrics:j||[]};const s=r.selectedCardIds||[],o=e.getCompatibleStructuralChoiceCatalog({controlType:r.control.type,participants:y||[],selectedCardIds:s});return{fields:r.control.type==="field_selector"?o.choices.map(n=>({option:n,target:o.fieldTargetMap[n.value]})):[],metrics:r.control.type==="metric_selector"?o.choices.map(n=>({option:n,target:o.metricTargetMap[n.value]})):[]}},[f,j,r,I,y]);C.useEffect(()=>{S==null||S(!!r)},[r,S]),C.useEffect(()=>{const s=h&&!Q.current;Q.current=h,s&&(N({step:1,control:e.createBlankControl(a,l,Array.from(T))}),M(null),O(null))},[l,h,T,a]);const X=s=>{if(!I(s.type))return{fields:f||[],metrics:j||[]};const o=(p==null?void 0:p[s.id])||[];if(o.length===0)return{fields:f||[],metrics:j||[]};const n=e.getCompatibleStructuralChoiceCatalog({controlType:s.type,participants:y||[],selectedCardIds:o});return{fields:s.type==="field_selector"?n.choices.map(c=>({option:c,target:n.fieldTargetMap[c.value]})):[],metrics:s.type==="metric_selector"?n.choices.map(c=>({option:c,target:n.metricTargetMap[c.value]})):[]}},U=s=>{if(!I(s.control.type))return{nextControl:s.control,cardBindingsById:void 0};const o=(p==null?void 0:p[s.control.id])||[],n=e.getCompatibleStructuralChoiceCatalog({controlType:s.control.type,participants:y||[],selectedCardIds:s.nextSelectedCardIds}),c=e.reconcileStructuralControlChoices({control:s.control,choices:n.choices}),b=Object.fromEntries(o.filter(D=>!s.nextSelectedCardIds.includes(D)).map(D=>[D,void 0]));return s.nextSelectedCardIds.length>0&&c.source.kind==="manual"&&c.source.options.length>0&&Object.assign(b,e.buildStructuralControlBindingsForParticipants({control:c,participants:y||[],selectedCardIds:s.nextSelectedCardIds})),{nextControl:c,cardBindingsById:b}},F=C.useCallback((s,o=d,n={type:"update"})=>{const c=s.map(b=>(e.resolveAuthoringControlDefaultValue({control:b,defaultValues:o}),e.syncSqlQueryControlExecutionRequirement(b)));x(c,o,n)},[d,x]),P=(s,o)=>{const n=l.find(w=>w.id===s);let c=l.map(w=>w.id!==s?w:o(w));const b=c.find(w=>w.id===s);let D,m;if(b&&a==="dashboard"&&(b.type==="field_selector"||b.type==="metric_selector")){const w=(p==null?void 0:p[b.id])||[],z=U({control:b,nextSelectedCardIds:w});c=c.map(A=>A.id===s?z.nextControl:A),D=z.cardBindingsById,m=[b.id]}else if(n&&a==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")){const w=(p==null?void 0:p[n.id])||[];D=Object.fromEntries(w.map(z=>[z,void 0])),m=[n.id]}const k=c.find(w=>w.id===s);let L=d;if(n&&k){const w=e.resolveAuthoringControlDefaultValue({control:n,defaultValues:d});n.source.kind==="manual"&&k.source.kind==="sql_query"&&(B.current[s]=w);const z=w===void 0&&n.source.kind==="sql_query"&&k.source.kind==="manual"?B.current[s]:w,A=e.getNextEditedControlDefaultValue({previousControl:n,nextControl:k,currentDefaultValue:z});k.source.kind==="manual"&&(B.current[s]=A),d&&(L={...d},A===void 0?delete L[s]:L[s]=A),c=c.map(ue=>ue.id===s?{...k,defaultValue:A}:ue)}F(c,L,{type:"update",cardBindingsById:D,affectedBindingControlIds:m})},be=(s,o)=>{const n=o.trim();if(n.length===0||n===s||T.has(n)||l.some(D=>D.id===n&&D.id!==s))return;const c=l.map(D=>D.id===s?{...D,id:n}:D);if(!d){F(c,void 0,{type:"rename",oldId:s,newId:n});return}const b={...d};Object.prototype.hasOwnProperty.call(b,s)&&(b[n]=b[s],delete b[s]),F(c,b,{type:"rename",oldId:s,newId:n})},ye=s=>{const o=l.filter(c=>c.id!==s);if(!d){F(o,void 0,{type:"remove",controlId:s});return}const n={...d};delete n[s],F(o,n,{type:"remove",controlId:s})},ve=C.useCallback(()=>{E.current=void 0,N({step:1,control:e.createBlankControl(a,l,Array.from(T))}),M(null),O(null)},[l,T,a]),Y=s=>{N(o=>o&&(()=>{const n=s(o.control);o.control.source.kind==="manual"&&n.source.kind==="sql_query"&&(E.current=o.defaultValue);const c=o.defaultValue===void 0&&o.control.source.kind==="sql_query"&&n.source.kind==="manual"?E.current:o.defaultValue,b=e.getNextEditedControlDefaultValue({previousControl:o.control,nextControl:n,currentDefaultValue:c});return n.source.kind==="manual"&&(E.current=b),{...o,control:n,defaultValue:b}})())},ne=s=>{N(o=>o&&(o.control.source.kind==="manual"&&(E.current=s),{...o,defaultValue:s}))},W=(()=>{if(!r)return!1;if(r.step===2&&I(r.control.type))return(r.selectedCardIds||[]).length>0;if(r.step!==2&&r.step!==3||!r.control.label.trim())return!1;const o=r.control.source.kind==="sql_query"?r.control:e.ensureManualSource(r.control);if(o.source.kind==="manual"&&(e.needsManualOptions(o)&&o.source.options.length===0||o.source.options.some(c=>c.label.trim().length===0||c.value.trim().length===0)))return!1;if(o.source.kind==="sql_query"){const{connectionId:n,sql:c,valueColumn:b}=o.source;return n.trim().length>0&&c.trim().length>0&&b.trim().length>0}return e.hasConcreteDefaultValue(e.getDefaultValueForType(o,r.defaultValue))})(),oe=()=>{var D;if(!r)return;const s=e.ensureManualSource(r.control),o=e.deriveUniqueControlId({label:s.label,fallbackId:s.id,existingControls:l,reservedIds:Array.from(T)}),n={...s,id:o},c=a==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")&&((D=r.selectedCardIds)!=null&&D.length)?e.buildStructuralControlBindingsForParticipants({control:n,participants:y||[],selectedCardIds:r.selectedCardIds}):void 0,b=e.getDefaultValueForType(n,r.defaultValue);N({step:a==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")?4:3,control:n,defaultValue:b,createdControlId:o,selectedCardIds:r.selectedCardIds,cardBindingsById:c})},Z=C.useCallback(()=>{N(null)},[]),ie=C.useCallback(()=>{if(!(r!=null&&r.createdControlId)){N(null);return}const s=r.control,o=r.createdControlId,n=e.getDefaultValueForType(s,r.defaultValue);if(d){const c={...d};n===void 0?delete c[o]:c[o]=n,F([...l,{...s,defaultValue:n}],c,{type:"add",cardBindingsById:r.cardBindingsById})}else F([...l,{...s,defaultValue:n}],void 0,{type:"add",cardBindingsById:r.cardBindingsById});M(o),N(null),V==null||V()},[l,r,d,F,V]),Ce=r?I(r.control.type)?["Choose type","Select cards","Configure","Finish"]:["Choose type","Configure","Finish"]:[],de=r!=null&&r.createdControlId?`[[param.${r.createdControlId}]]`:r?`[[param.${e.slugifyControlValue(r.control.label)||r.control.id}]]`:"",ee=e.buildAuthoringPreviewControlValues({controls:l,defaultValues:d}),te=r?[...l,r.control]:l,ce=r?e.buildAuthoringPreviewControlValues({controls:te,defaultValues:d,overrides:[{controlId:r.control.id,value:r.defaultValue}]}):ee;return t.jsxs("div",{className:"space-y-4",children:[r?t.jsxs("div",{className:"space-y-4 pb-1",children:[t.jsx(Te,{currentStep:r.step,labels:Ce}),r.step===1&&(()=>{const s=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]),o=_.filter(b=>!s.has(b.value)),n=_.filter(b=>s.has(b.value)),c=b=>t.jsxs("button",{type:"button",className:"rounded-[6px] border border-border/60 bg-background px-3 py-2.5 text-left transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:outline-none",onClick:()=>N(Fe({scope:a,existingControls:l,reservedIds:Array.from(T),type:b.value})),children:[t.jsx("div",{className:"text-[13px] font-medium text-foreground",children:b.label}),t.jsx("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:b.description})]},b.value);return t.jsxs("div",{className:"space-y-4",children:[a==="card"&&(g==null?void 0:g.sql)==null?t.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Explorer cards support displayed metric, group by field, aggregation, and time grain controls here."}):null,o.length>0&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Input controls"}),t.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:o.map(c)})]}),n.length>0&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data-driven controls"}),t.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:n.map(c)})]}),t.jsx($,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",size:"xs",onClick:Z,children:"Back to controls"})})]})})(),r.step===2&&I(r.control.type)&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(ge,{control:r.control,onChange:s=>Y(o=>({...o,label:s}))}),t.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Choose which cards should respond to this shared control."})]}),R.length===0?t.jsx("div",{className:"rounded-[6px] border border-border/60 bg-muted/30 px-3 py-2.5 text-[12px] text-muted-foreground",children:"No eligible cards are available yet. Add compatible metrics or group-by fields to cards first."}):t.jsx("div",{className:"space-y-1 rounded-[6px] border border-border/60 bg-background p-2",children:R.map(s=>{const o=(r.selectedCardIds||[]).includes(s.cardId);return t.jsxs("label",{className:"flex items-start gap-2 rounded-[4px] px-1.5 py-1 text-[13px] hover:bg-muted/40",children:[t.jsx(e.Checkbox,{checked:o,onCheckedChange:n=>N(c=>c&&{...c,selectedCardIds:n===!0?[...c.selectedCardIds||[],s.cardId]:(c.selectedCardIds||[]).filter(b=>b!==s.cardId)})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"font-medium text-foreground",children:s.title}),t.jsx("div",{className:"text-[12px] text-muted-foreground",children:r.control.type==="field_selector"?`${s.fieldChoices.length} compatible group-by fields`:`${s.metricChoices.length} compatible metrics`})]})]},s.cardId)})}),t.jsx($,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>N(s=>s&&{...s,step:1,selectedCardIds:[]}),children:"Back"}),primary:t.jsx(e.Button,{type:"button",size:"xs",onClick:()=>N(s=>s&&{...s,step:3}),disabled:!W,children:"Next"})})]}),r.step===2&&!I(r.control.type)&&t.jsx(pe,{control:r.control,defaultValue:r.defaultValue,availableFieldChoices:q.fields,availableMetricChoices:q.metrics,previewControlDefinitions:te,previewControlValues:ce,onControlChange:s=>Y(()=>s),onLabelChange:s=>Y(o=>({...o,label:s})),onDefaultValueChange:ne,onBack:()=>N(s=>s&&{...s,step:1}),onNext:oe,nextDisabled:!W}),r.step===3&&I(r.control.type)&&t.jsx(pe,{control:r.control,defaultValue:r.defaultValue,availableFieldChoices:q.fields,availableMetricChoices:q.metrics,previewControlDefinitions:te,previewControlValues:ce,onControlChange:s=>Y(()=>s),onLabelChange:s=>Y(o=>({...o,label:s})),onDefaultValueChange:ne,onBack:()=>N(s=>s&&{...s,step:2}),onNext:oe,nextDisabled:!W}),r.step===3&&!I(r.control.type)&&t.jsx(xe,{control:r.control,scope:a,createdReference:de,explorerContent:t.jsxs(t.Fragment,{children:["Open the card and use"," ",t.jsx("span",{className:"font-medium text-foreground",children:"Settings → Controls"})," ","to choose what this control changes."]}),sqlDescription:"Reference this control directly in the SQL editor.",onBack:()=>N(s=>s&&{...s,step:2}),onCancel:Z,onDone:ie}),r.step===4&&I(r.control.type)&&t.jsx(xe,{control:r.control,scope:a,createdReference:de,summaryDetail:t.jsxs(t.Fragment,{children:["Used by ",(r.selectedCardIds||[]).length," ","selected card",(r.selectedCardIds||[]).length===1?"":"s"]}),explorerContent:t.jsx(t.Fragment,{children:"Selected cards have been set up to respond to this control automatically."}),sqlDescription:"SQL cards can still reference this control directly in the SQL editor.",onBack:()=>N(s=>s&&{...s,step:3}),onCancel:Z,onDone:ie})]}):null,!r&&l.length===0?t.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:u}):null,!r&&l.map(s=>{const o=X(s),n=v==null?void 0:v[s.id],c=e.resolveAuthoringControlDefaultValue({control:s,defaultValues:d}),b=J===s.id,D="inline-flex shrink-0 items-center rounded-[4px] border border-border/60 bg-muted/40 px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground";return t.jsxs("div",{className:"rounded-[6px] border border-border/60",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[t.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-start gap-2 rounded-[4px] text-left focus:outline-none focus-visible:bg-muted/40",onClick:()=>M(m=>m===s.id?null:s.id),children:[b?t.jsx(e.ChevronDown,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}):t.jsx(e.ChevronRight,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:s.label||"Untitled control"}),t.jsx("span",{className:D,children:e.getFriendlyTypeOption(s.type).label}),t.jsx("span",{className:D,children:e.getPlacementLabel(a,s.placement)})]}),t.jsxs("div",{className:"mt-0.5 text-[12px] text-muted-foreground",children:[e.getControlOptionPreview(s),n!=null&&n.status?` · ${n.status}`:""]})]})]}),t.jsx(e.Button,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 shrink-0 p-0 text-muted-foreground",onClick:()=>ye(s.id),"aria-label":`Remove ${s.label}`,children:t.jsx(e.Trash2,{className:"h-3.5 w-3.5"})})]}),b&&t.jsxs("div",{className:"space-y-4 border-t border-border/60 px-3 py-3",children:[t.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(e.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),t.jsx(e.Input,{size:"xs",value:s.label,placeholder:"Control label",onChange:m=>P(s.id,k=>({...k,label:m.target.value}))})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(e.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Type"}),t.jsxs(e.Select,{value:s.type,onValueChange:m=>{const k=e.applyControlTypeChange({controls:l,controlId:s.id,nextType:m,defaultValues:d});F(k.controls,k.defaultValues)},children:[t.jsx(e.SelectTrigger,{size:"xs",children:t.jsx(e.SelectValue,{})}),t.jsx(e.SelectContent,{children:e.getFriendlyControlTypeOptions({scope:a,card:g,includeType:s.type}).map(m=>t.jsx(e.SelectItem,{value:m.value,children:m.label},m.value))})]})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(e.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Show in"}),t.jsxs(e.Select,{value:s.placement||G,onValueChange:m=>P(s.id,k=>({...k,placement:m})),children:[t.jsx(e.SelectTrigger,{size:"xs",children:t.jsx(e.SelectValue,{})}),t.jsx(e.SelectContent,{children:H.map(m=>t.jsx(e.SelectItem,{value:m.value,children:m.label},m.value))})]})]})]}),I(s.type)?t.jsx(e.StructuralParticipantSelector,{type:s.type,participants:e.getEligibleParticipantsForStructuralControl(y||[],s.type).map(m=>({cardId:m.cardId,title:m.title,choiceCount:s.type==="field_selector"?m.fieldChoices.length:m.metricChoices.length})),selectedCardIds:(p==null?void 0:p[s.id])||[],onChange:m=>{const k=U({control:s,nextSelectedCardIds:m}),L=l.map(w=>w.id===s.id?k.nextControl:w);F(L,d,{type:"update",cardBindingsById:k.cardBindingsById})}}):null,t.jsx(e.ControlDefinitionOptionsEditor,{control:s,availableFieldChoices:o.fields,availableMetricChoices:o.metrics,previewControlDefinitions:l,previewControlValues:ee,controlLifecycle:"edit",onChange:m=>P(s.id,()=>m)}),s.initialValueStrategy==="saved_default"&&t.jsx(e.ControlDefaultValueEditor,{control:s,value:c,allowNoDefault:!0,allowCardDefault:!0,previewControlDefinitions:l,previewControlValues:ee,onChange:m=>{const k=l.map(L=>L.id===s.id?{...L,defaultValue:m}:L);if(s.source.kind==="manual"&&(B.current[s.id]=m),d){const L={...d};m===void 0?delete L[s.id]:L[s.id]=m,F(k,L);return}F(k,void 0)}}),t.jsxs(e.Collapsible,{open:K===s.id,onOpenChange:m=>O(m?s.id:null),children:[t.jsx(e.CollapsibleTrigger,{asChild:!0,children:t.jsxs(e.Button,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 gap-1 text-muted-foreground hover:text-foreground",children:[K===s.id?t.jsx(e.ChevronDown,{className:"h-3.5 w-3.5"}):t.jsx(e.ChevronRight,{className:"h-3.5 w-3.5"}),"Advanced"]})}),t.jsxs(e.CollapsibleContent,{className:"space-y-3 pt-2",children:[t.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(e.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Control ID"}),t.jsx(e.ControlIdInput,{controlId:s.id,onCommit:m=>be(s.id,m)},s.id)]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(e.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Initial value"}),t.jsxs(e.Select,{value:s.initialValueStrategy,onValueChange:m=>P(s.id,k=>({...k,initialValueStrategy:m})),children:[t.jsx(e.SelectTrigger,{size:"xs",children:t.jsx(e.SelectValue,{})}),t.jsx(e.SelectContent,{children:e.INITIAL_VALUE_STRATEGY_OPTIONS.map(m=>t.jsx(e.SelectItem,{value:m.value,children:m.label},m.value))})]})]})]}),t.jsx(e.ControlVisibilitySettings,{control:s,onChange:m=>P(s.id,()=>m)})]})]})]})]},s.id)}),!r&&t.jsxs(e.Button,{type:"button",variant:"outline",size:"xs",onClick:ve,children:[t.jsx(e.Plus,{className:"h-3.5 w-3.5"}),"Add control"]})]})}function _e(a){const{open:l,onOpenChange:i,initialCreateFlowActive:d=!1,dismissMode:x="passive"}=a,u=l!==void 0,[h,v]=C.useState(!1),[f,j]=C.useState(d),y=u?l:h,p=C.useCallback(V=>{!V&&f&&x==="passive"||(u||v(V),V||j(!1),i==null||i(V))},[u,f,x,i]),g=C.useCallback(()=>{u||v(!1),j(!1),i==null||i(!1)},[u,i]);C.useEffect(()=>{y||j(!1)},[y]);const S=C.useCallback(V=>{f&&V.preventDefault()},[f]);return{forceClose:g,handleOpenChange:p,isCreateFlowActive:f,preventPassiveDismissDuringCreate:S,resolvedOpen:y,setIsCreateFlowActive:j}}exports.CircleX=je;exports.ControlDefinitionListEditor=Be;exports.EditorAcceptButton=Ne;exports.EditorCancelButton=Ee;exports.EditorClearButton=Ve;exports.Library=fe;exports.Link2=he;exports.Save=re;exports.VisualBadge=ke;exports.VisualSaveAndApplyButton=we;exports.VisualSaveButton=De;exports.useCreateFlowOverlayState=_e;exports.useEffectiveEditorCardType=le;
@@ -1 +1 @@
1
- "use strict";const o=require("./index-BY0YEY92.js"),S=require("react");function Q(e){const n=e.toUpperCase().indexOf("WHERE"),t=e.toUpperCase().indexOf("GROUP BY"),r=e.toUpperCase().indexOf("LIMIT"),s=e.toUpperCase().indexOf("ORDER BY");let i=e.length;if(s!==-1&&(i=s),r!==-1&&r<i&&(i=r),n!==-1){const d=e.substring(0,n),a=e.substring(n);return`${d} {{ filters | where }} AND ${a.substring(6)}`}else if(t!==-1){const d=e.substring(0,t),a=e.substring(t);return`${d} {{ filters | where }} ${a}`}else{const d=e.substring(0,i),a=e.substring(i);return console.log("beforeClause",d),console.log("afterClause",a),a?`${d} {{ filters | where }} ${a}`:`${d.replace(/;$/,"")} {{ filters | where }}`}}function z(e){const[n,t]=S.useState(null),[r,s]=S.useState(null),i=o.useEnsureReactGlobals();return S.useEffect(()=>{if(!e||e.trim()===""){t(null),s(null);return}if(!i)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const h=await import(l);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");t(()=>h.useChartStore),s(null)}catch(a){const l=a instanceof Error?a.message:"Unknown error";console.error("Failed to load remote chart store:",l),s(l),t(null)}})()},[e,i]),n}function G(e,n){if(e.length===0)return"";const t=e.find(r=>{var s,i;return((s=r.customCardPreferences)==null?void 0:s.visualType)==="multiple"||!!((i=r.customCardPreferences)!=null&&i.dataInputCardIds)});if(t)return t.id;if(n){const r=e.find(s=>s.id===n);if(r){const s=r.tabTitle;if(s=="All__Header")return e[0].id;if(s&&s.endsWith("__Header")){const d=s.split("__")[0],a=e.find(l=>l.tabTitle===d);return a?a.id:e[0].id}return n}}return e[0].id}const Y=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:n,...t}=e;return t};async function P(e,n,t,r){if(!n||!t)throw new Error("Missing auth token or visual ID");const s=["resource-by-id","visual",t],i=r.getQueryData(s);if(i)return console.log("Using cached visual data for:",t),{data:i,fromCache:!0};console.log("Fetching visual data from network for:",t);const d=o.ue.loading("Loading visual...",{position:"top-center"});try{const a=await fetch(`${e}/management/v1/visuals/${t}`,{headers:{Authorization:`Bearer ${n}`}});if(!a.ok)throw new Error("Failed to load visual");const l=await a.json();return r.setQueryData(s,l),o.ue.dismiss(d),{data:l,fromCache:!1}}catch(a){throw o.ue.dismiss(d),a}}function j(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function J(e,n){var i,d;const t=(e==null?void 0:e.frameObject)??((i=e==null?void 0:e.visual)==null?void 0:i.frameObject);if(!t)return!1;const r=j(t);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const s=(d=r.cards)==null?void 0:d.find(a=>a.id===r.activeCardId);return s?(o.setupEditorWithCard({...n,frame:r,card:s,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function K(){var g;const{setCardSql:e}=o.useEditorActions(),n=o.useEditorStore(c=>c.frame),t=o.useEditorStore(c=>c.card),r=o.useEditorStore(c=>c.isDevMode),s=z(((g=t.customCardPreferences)==null?void 0:g.url)||""),i=o.useEditorStore(c=>c.selectedSchemaName),d=o.useEditorStore(c=>c.selectedDatamodelId),a=o.useEditorStore(c=>c.selectedDatabaseName),l=o.useEditorStore(c=>c.selectedTableName),h=o.useEditorStore(c=>c.selectedConnectionId),m=o.useEditorStore(c=>c.isShowingVisual),p=t.sql;return{getUpdatedFrame:S.useCallback(()=>{var E;let c=p;p&&!p.includes("{{")&&(c=Q(p),e(c));const U=(E=s==null?void 0:s.getState())==null?void 0:E.settings,v=o.buildSavedEditorCard(t,{isDevMode:r,cardSql:c,isShowingVisual:m,selectedSchemaName:i,selectedDatamodelId:d,selectedDatabaseName:a,selectedTableName:l,selectedConnectionId:h,remoteChartSettings:U,stripConfig:Y}),C=n.cards.map(w=>w.id===t.id?v:w);return{...n,cards:C,activeCardId:G(C,n.activeCardId)}},[t,n,r,m,i,d,a,l,h,e,s,p])}}function X(){const{authToken:e,tokenProps:n}=o.useSemaphorContext(),t=o.useQueryClient(),r=o.useSelectedVisual(),{selectVisual:s}=o.useManagementActions(),{setFrame:i,setCard:d,setIsDevMode:a,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:$,setSelectedDatabaseName:g,setSelectedSchemaName:c,setSelectedTableName:U,setSelectedDatamodelId:v,setFilterValues:C,setInlineFilterValuesMap:E,setApplyFilters:w}=o.useEditorActions(),{setIsDashboardEditing:V,setIsVisualEditing:D,setSelectedFrameId:M,clearSelectedFrameId:A,addFrame:N,setIsDashboardPanelOpen:O}=o.useDashboardActions(),I=o.useDashboardStore(u=>u.selectedSheetId),R=o.useDashboardStore(u=>u.selectedFrameId),x=o.useDashboardStore(u=>u.dashboard),B=o.useDashboardStore(u=>u.filterValues),T=o.useDashboardStore(u=>u.inlineFilterValuesMap),y=o.useVisualById((r==null?void 0:r.id)||"",{enabled:!!(r!=null&&r.id)&&!!(e!=null&&e.accessToken)}),_=S.useCallback(async u=>{try{s(u),A();const{data:b,fromCache:f}=await P(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t);if(!J(b,{setFrame:i,setCard:d,setIsDevMode:a,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:$,setSelectedDatabaseName:g,setSelectedSchemaName:c,setSelectedTableName:U,setSelectedDatamodelId:v,setFilterValues:C,setInlineFilterValuesMap:E,setApplyFilters:w,setIsDashboardEditing:V,setIsVisualEditing:D,dashboard:x,selectedSheetId:I,selectedFrameId:R,filterValues:B,inlineFilterValuesMap:T}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:f}}catch(b){return console.error("Error editing visual:",b),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,i,d,V,D,a,l,h,m,p,$,g,c,U,v,C,E,w,A,x,I,R,B,T]),H=S.useCallback(async u=>{var b;try{if(s(u),!I)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:f,fromCache:W}=await P(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t),k=(f==null?void 0:f.frameObject)??((b=f==null?void 0:f.visual)==null?void 0:b.frameObject);if(!k)return{success:!1,error:"Visual has no frame data"};const F=j(k);if(!(F!=null&&F.cards)||F.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const L={...o.cloneLinkedFrameWithSourceMapping(F),visualId:u.id};return N(I,L,"end"),V(!0),M(L.id),O(!1),{success:!0,fromCache:W}}catch(f){return console.error("Error adding visual:",f),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,I,N,V,M,O]);return{visual:y.data,isLoading:y.isLoading,isError:y.isError,error:y.error,handleEditLibraryVisual:_,handleAddLibraryVisual:H,getUpdatedFrame:K().getUpdatedFrame,refetch:y.refetch}}exports.useVisualUtils=X;
1
+ "use strict";const o=require("./index-BHWWNpG6.js"),S=require("react");function Q(e){const n=e.toUpperCase().indexOf("WHERE"),t=e.toUpperCase().indexOf("GROUP BY"),r=e.toUpperCase().indexOf("LIMIT"),s=e.toUpperCase().indexOf("ORDER BY");let i=e.length;if(s!==-1&&(i=s),r!==-1&&r<i&&(i=r),n!==-1){const d=e.substring(0,n),a=e.substring(n);return`${d} {{ filters | where }} AND ${a.substring(6)}`}else if(t!==-1){const d=e.substring(0,t),a=e.substring(t);return`${d} {{ filters | where }} ${a}`}else{const d=e.substring(0,i),a=e.substring(i);return console.log("beforeClause",d),console.log("afterClause",a),a?`${d} {{ filters | where }} ${a}`:`${d.replace(/;$/,"")} {{ filters | where }}`}}function z(e){const[n,t]=S.useState(null),[r,s]=S.useState(null),i=o.useEnsureReactGlobals();return S.useEffect(()=>{if(!e||e.trim()===""){t(null),s(null);return}if(!i)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const h=await import(l);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");t(()=>h.useChartStore),s(null)}catch(a){const l=a instanceof Error?a.message:"Unknown error";console.error("Failed to load remote chart store:",l),s(l),t(null)}})()},[e,i]),n}function G(e,n){if(e.length===0)return"";const t=e.find(r=>{var s,i;return((s=r.customCardPreferences)==null?void 0:s.visualType)==="multiple"||!!((i=r.customCardPreferences)!=null&&i.dataInputCardIds)});if(t)return t.id;if(n){const r=e.find(s=>s.id===n);if(r){const s=r.tabTitle;if(s=="All__Header")return e[0].id;if(s&&s.endsWith("__Header")){const d=s.split("__")[0],a=e.find(l=>l.tabTitle===d);return a?a.id:e[0].id}return n}}return e[0].id}const Y=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:n,...t}=e;return t};async function P(e,n,t,r){if(!n||!t)throw new Error("Missing auth token or visual ID");const s=["resource-by-id","visual",t],i=r.getQueryData(s);if(i)return console.log("Using cached visual data for:",t),{data:i,fromCache:!0};console.log("Fetching visual data from network for:",t);const d=o.ue.loading("Loading visual...",{position:"top-center"});try{const a=await fetch(`${e}/management/v1/visuals/${t}`,{headers:{Authorization:`Bearer ${n}`}});if(!a.ok)throw new Error("Failed to load visual");const l=await a.json();return r.setQueryData(s,l),o.ue.dismiss(d),{data:l,fromCache:!1}}catch(a){throw o.ue.dismiss(d),a}}function j(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function J(e,n){var i,d;const t=(e==null?void 0:e.frameObject)??((i=e==null?void 0:e.visual)==null?void 0:i.frameObject);if(!t)return!1;const r=j(t);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const s=(d=r.cards)==null?void 0:d.find(a=>a.id===r.activeCardId);return s?(o.setupEditorWithCard({...n,frame:r,card:s,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function K(){var g;const{setCardSql:e}=o.useEditorActions(),n=o.useEditorStore(c=>c.frame),t=o.useEditorStore(c=>c.card),r=o.useEditorStore(c=>c.isDevMode),s=z(((g=t.customCardPreferences)==null?void 0:g.url)||""),i=o.useEditorStore(c=>c.selectedSchemaName),d=o.useEditorStore(c=>c.selectedDatamodelId),a=o.useEditorStore(c=>c.selectedDatabaseName),l=o.useEditorStore(c=>c.selectedTableName),h=o.useEditorStore(c=>c.selectedConnectionId),m=o.useEditorStore(c=>c.isShowingVisual),p=t.sql;return{getUpdatedFrame:S.useCallback(()=>{var E;let c=p;p&&!p.includes("{{")&&(c=Q(p),e(c));const U=(E=s==null?void 0:s.getState())==null?void 0:E.settings,v=o.buildSavedEditorCard(t,{isDevMode:r,cardSql:c,isShowingVisual:m,selectedSchemaName:i,selectedDatamodelId:d,selectedDatabaseName:a,selectedTableName:l,selectedConnectionId:h,remoteChartSettings:U,stripConfig:Y}),C=n.cards.map(w=>w.id===t.id?v:w);return{...n,cards:C,activeCardId:G(C,n.activeCardId)}},[t,n,r,m,i,d,a,l,h,e,s,p])}}function X(){const{authToken:e,tokenProps:n}=o.useSemaphorContext(),t=o.useQueryClient(),r=o.useSelectedVisual(),{selectVisual:s}=o.useManagementActions(),{setFrame:i,setCard:d,setIsDevMode:a,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:$,setSelectedDatabaseName:g,setSelectedSchemaName:c,setSelectedTableName:U,setSelectedDatamodelId:v,setFilterValues:C,setInlineFilterValuesMap:E,setApplyFilters:w}=o.useEditorActions(),{setIsDashboardEditing:V,setIsVisualEditing:D,setSelectedFrameId:M,clearSelectedFrameId:A,addFrame:N,setIsDashboardPanelOpen:O}=o.useDashboardActions(),I=o.useDashboardStore(u=>u.selectedSheetId),R=o.useDashboardStore(u=>u.selectedFrameId),x=o.useDashboardStore(u=>u.dashboard),B=o.useDashboardStore(u=>u.filterValues),T=o.useDashboardStore(u=>u.inlineFilterValuesMap),y=o.useVisualById((r==null?void 0:r.id)||"",{enabled:!!(r!=null&&r.id)&&!!(e!=null&&e.accessToken)}),_=S.useCallback(async u=>{try{s(u),A();const{data:b,fromCache:f}=await P(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t);if(!J(b,{setFrame:i,setCard:d,setIsDevMode:a,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:$,setSelectedDatabaseName:g,setSelectedSchemaName:c,setSelectedTableName:U,setSelectedDatamodelId:v,setFilterValues:C,setInlineFilterValuesMap:E,setApplyFilters:w,setIsDashboardEditing:V,setIsVisualEditing:D,dashboard:x,selectedSheetId:I,selectedFrameId:R,filterValues:B,inlineFilterValuesMap:T}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:f}}catch(b){return console.error("Error editing visual:",b),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,i,d,V,D,a,l,h,m,p,$,g,c,U,v,C,E,w,A,x,I,R,B,T]),H=S.useCallback(async u=>{var b;try{if(s(u),!I)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:f,fromCache:W}=await P(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t),k=(f==null?void 0:f.frameObject)??((b=f==null?void 0:f.visual)==null?void 0:b.frameObject);if(!k)return{success:!1,error:"Visual has no frame data"};const F=j(k);if(!(F!=null&&F.cards)||F.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const L={...o.cloneLinkedFrameWithSourceMapping(F),visualId:u.id};return N(I,L,"end"),V(!0),M(L.id),O(!1),{success:!0,fromCache:W}}catch(f){return console.error("Error adding visual:",f),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,I,N,V,M,O]);return{visual:y.data,isLoading:y.isLoading,isError:y.isError,error:y.error,handleEditLibraryVisual:_,handleAddLibraryVisual:H,getUpdatedFrame:K().getUpdatedFrame,refetch:y.refetch}}exports.useVisualUtils=X;
@@ -1,4 +1,4 @@
1
- import { G as K, b as Y, H as X, J as Z, K as q, M as _, N as ee, u as F, O as te, Q as re, x as M, T as se, U as f, V as oe } from "./index-Bgn4zTsp.js";
1
+ import { G as K, b as Y, H as X, J as Z, K as q, M as _, N as ee, u as F, O as te, Q as re, x as M, T as se, U as f, V as oe } from "./index-B7kUtCgG.js";
2
2
  import { useState as H, useEffect as ae, useCallback as N } from "react";
3
3
  function ne(e) {
4
4
  const a = e.toUpperCase().indexOf("WHERE"), t = e.toUpperCase().indexOf("GROUP BY"), r = e.toUpperCase().indexOf("LIMIT"), s = e.toUpperCase().indexOf("ORDER BY");
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/index-BY0YEY92.js"),e=require("../types/index.cjs");exports.Dashboard=r.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/index-BHWWNpG6.js"),e=require("../types/index.cjs");exports.Dashboard=r.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { D as E } from "../chunks/index-Bgn4zTsp.js";
1
+ import { D as E } from "../chunks/index-B7kUtCgG.js";
2
2
  import { CONTROL_CARD_DEFAULT_VALUE as L, EMPTY_SELECTION as T } from "../types/index.js";
3
3
  export {
4
4
  L as CONTROL_CARD_DEFAULT_VALUE,
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-BY0YEY92.js"),_=require("./types/index.cjs"),M=require("./chunks/dashboard-summary-settings-dialog-BjdrHb1l.js"),t=require("react/jsx-runtime"),x=require("react"),O=require("./chunks/resource-management-panel-w7afzaPB.js"),U=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");const A=require("./chunks/dashboard-filter-controls-button-DZpvfXwU.js"),L=require("./chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js");function z(s){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>s[n]})}}return r.default=s,Object.freeze(r)}const R=z(x);function Q(s){const{authToken:r,tokenProps:n}=e.useSemaphorContext();return e.useMutation({mutationFn:async o=>e.backtestAlert(n.apiServiceUrl,r.accessToken,s,o)})}function q(s){const{displayPreferences:r,cardId:n,...o}=s,l={...o,id:s.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:l,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:s.cardId}),t.jsx(e.UXProvider,{children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:r,children:t.jsx(e.Container,{type:"visual",cardId:n,...l,children:t.jsx(V,{cardId:n})})})})]})})}function V({cardId:s}){const r=e.useDashboardStore(l=>{var c;return(c=l.dashboard)==null?void 0:c.sheets}),{card:n,frame:o}=x.useMemo(()=>{const l=r==null?void 0:r.flatMap(i=>i.frames),c=l==null?void 0:l.flatMap(i=>i==null?void 0:i.cards),u=c==null?void 0:c.find(i=>(i==null?void 0:i.id)===s),a=l==null?void 0:l.find(i=>{var m;return(m=i==null?void 0:i.cards)==null?void 0:m.find(f=>(f==null?void 0:f.id)===s)});return{card:u,frame:a}},[r,s]);return!n||!o?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${s}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:l,resetErrorBoundary:c})=>t.jsx(e.FallbackVisual,{error:l,resetErrorBoundary:c,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:n,frame:o})})})}function W({name:s,items:r,value:n,onChange:o,isLoading:l,isError:c,refetch:u,className:a,icon:i,showNone:m=!1}){const f=R.useRef(null),[D,C]=R.useState(!1),[b,j]=R.useState("100%"),y=m?[...r||[],{id:"none",name:"None"}]:r;R.useLayoutEffect(()=>{f.current&&j(f.current.offsetWidth)},[]);function I(){var h;return l?"Loading...":c?"Error":n?(h=r==null?void 0:r.find(S=>S.id===n))==null?void 0:h.name:`Select ${s}`}function T(h,S){o(S),C(!1)}return t.jsxs(e.Popover,{open:D,onOpenChange:C,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{ref:f,variant:"outline",role:"combobox","aria-expanded":D,className:e.cn("flex h-9 w-full justify-between",a),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.jsx("div",{className:"mr-2",children:i}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:I()})]}),t.jsx(e.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(e.PopoverContent,{className:"w-full p-0",style:{minWidth:b},children:t.jsxs(e.Command,{children:[t.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[t.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),t.jsx(e.IconButton,{className:"h-7",onClick:u,children:t.jsx(e.RefreshCw,{className:e.cn("size-3.5 opacity-50",l&&"animate-spin")})})]}),t.jsxs(e.CommandList,{children:[t.jsxs(e.CommandEmpty,{children:["No ",s==null?void 0:s.toLowerCase()," found."]}),t.jsx(e.CommandGroup,{children:y==null?void 0:y.map(h=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:h.name,onSelect:S=>T(S,h.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(e.Check,{className:e.cn("size-4",n===h.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:h.name,children:h.name})]})},h.id))})]})]})})]})}function H({triggerButtonClassName:s,variant:r="ghost"}){const[n,o]=x.useState(!1),l=e.useDashboardStore(u=>{var a;return(a=u.dashboard)==null?void 0:a.id}),c=e.useDashboardStore(u=>{var a;return(a=u.dashboard)==null?void 0:a.title});return l?t.jsxs(t.Fragment,{children:[t.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:e.cn("h-7 p-2",s),buttonProps:{variant:r},onClick:()=>o(!0),children:t.jsx(e.Clock,{className:"size-4"})}),t.jsx(e.EmailScheduleDialog,{open:n,onOpenChange:o,dashboardId:l,dashboardName:c})]}):null}function $(s,r){x.useEffect(()=>(s&&r&&(window.__SEMAPHOR_PRINT_STATE__={...r}),()=>{s&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[s,r])}function P(s){if(!s)return"--";const r=new Date(s);return Number.isNaN(r.getTime())?"--":r.toLocaleString()}function G(s){var r;return((r=s.alertState)==null?void 0:r.currentState)==="FIRING"?"Signal surfaced":s.status==="ACTIVE"?"Watching":s.status==="PAUSED"?"Paused":s.status}function K({alertId:s,onBack:r}){var h,S,F,w;const{authToken:n,tokenProps:o}=e.useSemaphorContext(),{data:l,isLoading:c,refetch:u}=e.useAlertDetail(s),a=(l==null?void 0:l.alert)??null,[i,m]=x.useState([]),[f,D]=x.useState([]),[C,b]=x.useState(null),j=x.useCallback(async()=>{var g;const d=o==null?void 0:o.apiServiceUrl,p=n==null?void 0:n.accessToken;if(!d||!p||!s)return null;try{const v=await fetch(`${d}/v1/alerts/${s}/runs?limit=20`,{headers:{Authorization:`Bearer ${p}`}});if(v.ok){const E=await v.json(),N=Array.isArray(E.runs)?E.runs:[],k=C&&N.some(B=>B.id===C)?C:((g=N[0])==null?void 0:g.id)??null;return D(N),b(k),k}D([]),b(null)}catch{return D([]),b(null),null}return null},[s,n,C,o]),y=x.useCallback(async d=>{const p=o==null?void 0:o.apiServiceUrl,g=n==null?void 0:n.accessToken,v=d??C;if(!p||!g||!s||!v){m([]);return}try{const E=await fetch(`${p}/v1/alerts/${s}/runs/${v}/deliveries`,{headers:{Authorization:`Bearer ${g}`}});if(E.ok){const N=await E.json();m(Array.isArray(N.attempts)?N.attempts:[])}else m([])}catch{m([])}},[s,n,C,o]),I=x.useCallback(async()=>{await u();const d=await j();await y(d)},[y,j,u]);x.useEffect(()=>{j().catch(()=>{})},[j]),x.useEffect(()=>{y().catch(()=>{})},[y]);const T=x.useMemo(()=>{const d={};for(const p of i)d[p.channel]||(d[p.channel]=[]),d[p.channel].push(p);return d},[i]);return c?t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading signal detail..."}):a?t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[r&&t.jsx(e.Button,{variant:"outline",size:"sm",onClick:r,children:"Back"}),t.jsx("h2",{className:"text-lg font-semibold",children:a.name}),t.jsx(e.Badge,{variant:a.status==="ACTIVE"?"default":"secondary",children:G(a)}),((h=a.alertState)==null?void 0:h.currentState)&&t.jsx(e.Badge,{variant:a.alertState.currentState==="FIRING"?"destructive":"outline",children:a.alertState.currentState==="FIRING"?"Signal surfaced":"Stable"})]}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>void I(),children:"Refresh"})]}),a.description&&t.jsx("p",{className:"text-sm text-muted-foreground",children:a.description}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-4 text-sm",children:[t.jsx("p",{className:"font-medium",children:"What changed"}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:"Review the latest signal activity, then investigate the underlying dashboard context if you need more detail."})]}),t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Signal Watch"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Watching for:"})," ",e.formatSignalCondition(a.jobConfig.operator,a.jobConfig.threshold)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Severity:"})," ",a.jobConfig.severity]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Evaluated:"})," ",P((S=a.alertState)==null?void 0:S.lastEvaluatedAt)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Surfaced:"})," ",P((F=a.alertState)==null?void 0:F.lastTriggeredAt)]})]})]}),((w=a.deliveryConfig)==null?void 0:w.channels)&&a.deliveryConfig.channels.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Where It Surfaces"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:a.deliveryConfig.channels.map(d=>t.jsx(e.Badge,{variant:"outline",children:d},d))})]}),f.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Recent Delivery Activity"}),f.length>1&&t.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(d=>t.jsx(e.Button,{variant:d.id===C?"default":"outline",size:"sm",onClick:()=>b(d.id),children:P(d.scheduledFor)},d.id))}),Object.keys(T).length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No delivery attempts were recorded for this run."}):Object.entries(T).map(([d,p])=>t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(e.Badge,{variant:"secondary",className:"text-xs",children:d})}),t.jsx("div",{className:"overflow-hidden rounded border",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Recipient"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Status"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Time"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Error"})]})}),t.jsx("tbody",{children:p.map(g=>t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-2 py-1",children:g.recipient}),t.jsx("td",{className:"px-2 py-1",children:t.jsx(e.Badge,{variant:g.status==="SENT"?"default":"destructive",className:"text-[10px]",children:g.status})}),t.jsx("td",{className:"px-2 py-1",children:P(g.createdAt)}),t.jsx("td",{className:"px-2 py-1 text-muted-foreground",children:g.error||"--"})]},g.id))})]})})]},d))]})]}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Signal not found."})}function Y(){var c,u;const{quotasQuery:s,usageQuery:r}=e.useAlertQuotas(),n=((c=s.data)==null?void 0:c.quotas)||[],o=((u=r.data)==null?void 0:u.usage)||[],l=new Map(o.map(a=>[a.tenantId||"org",a]));return t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Alert Quotas"}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>{s.refetch(),r.refetch()},children:"Refresh"})]}),s.isLoading||r.isLoading?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading quota usage..."}):null,t.jsx("div",{className:"overflow-hidden rounded-lg border",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Tenant"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Active Alerts"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Active"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Min Cadence"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Context Sources"})]})}),t.jsx("tbody",{children:n.map(a=>{const i=a.tenantId||"org",m=l.get(i);return t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-3 py-2",children:i}),t.jsx("td",{className:"px-3 py-2",children:(m==null?void 0:m.activeAlerts)??0}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxActiveAlerts}),t.jsxs("td",{className:"px-3 py-2",children:[a.policy.minCadenceMinutes," min"]}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxContextSources})]},i)})})]})})]})}exports.AlertManagementPage=e.AlertManagementPage;exports.AlertWizardDialog=e.AlertWizardDialog;exports.AlertsApiError=e.AlertsApiError;exports.CALCULATED_FIELD_ENTITY_MARKER=e.CALCULATED_FIELD_ENTITY_MARKER;exports.CardAlertIndicator=e.CardAlertIndicator;exports.CardSummary=e.CardSummary;exports.DATE_FORMAT_VALUES=e.DATE_FORMAT_VALUES;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.EmailScheduleDialog=e.EmailScheduleDialog;exports.ExportError=e.ExportError;exports.PivotMarkerEnum=e.PivotMarkerEnum;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.SummaryCard=e.SummaryCard;exports.Surfboard=e.DashboardPlus;exports.backtestAlert=e.backtestAlert;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createAlert=e.createAlert;exports.createEmptyKpiConfig=e.createEmptyKpiConfig;exports.createExport=e.createExport;exports.createSqlGenConfig=e.createSqlGenConfig;exports.deleteAlert=e.deleteAlert;exports.downloadPdf=e.downloadPdf;exports.emitDashboardLoad=e.emitDashboardLoad;exports.emitDashboardUnload=e.emitDashboardUnload;exports.fmt=e.fmt;exports.formatFileSize=e.formatFileSize;exports.getAlert=e.getAlert;exports.getAlertContextSources=e.getAlertContextSources;exports.getAlertHistory=e.getAlertHistory;exports.getAlertQuotaUsage=e.getAlertQuotaUsage;exports.getAlertRunDeliveries=e.getAlertRunDeliveries;exports.getAlertRunSteps=e.getAlertRunSteps;exports.getAlertRuns=e.getAlertRuns;exports.getAlertState=e.getAlertState;exports.getColumnDataType=e.getColumnDataType;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isCalculatedDimension=e.isCalculatedDimension;exports.isCalculatedField=e.isCalculatedField;exports.isCalculatedMetric=e.isCalculatedMetric;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.listAlertQuotas=e.listAlertQuotas;exports.listAlerts=e.listAlerts;exports.previewAlertDeliverable=e.previewAlertDeliverable;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;exports.triggerAlertNow=e.triggerAlertNow;exports.updateAlert=e.updateAlert;exports.updateAlertContextSources=e.updateAlertContextSources;exports.updateAlertQuota=e.updateAlertQuota;exports.useActiveExports=e.useActiveExports;exports.useAddNewFrame=e.useAddNewFrame;exports.useAlertActions=e.useAlertActions;exports.useAlertDeliveries=e.useAlertDeliveries;exports.useAlertDetail=e.useAlertDetail;exports.useAlertDraft=e.useAlertDraft;exports.useAlertFilters=e.useAlertFilters;exports.useAlertHistory=e.useAlertHistory;exports.useAlertQuotas=e.useAlertQuotas;exports.useAlertRuns=e.useAlertRuns;exports.useAlertState=e.useAlertState;exports.useAlertStore=e.useAlertStore;exports.useAlertWizard=e.useAlertWizard;exports.useAlerts=e.useAlerts;exports.useAlertsBootstrap=e.useAlertsBootstrap;exports.useAlertsById=e.useAlertsById;exports.useAlertsForCard=e.useAlertsForCard;exports.useCard=e.useCard;exports.useCardAlertMap=e.useCardAlertMap;exports.useCardSummary=e.useCardSummary;exports.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardStore=e.useDashboardStore;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useSelectedAlertId=e.useSelectedAlertId;exports.useTextFilterHook=e.useTextFilterHook;exports.CONTROL_CARD_DEFAULT_VALUE=_.CONTROL_CARD_DEFAULT_VALUE;exports.DEFAULT_CALENDAR_CONTEXT=_.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=_.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.EMPTY_SELECTION=_.EMPTY_SELECTION;exports.CalendarPreferencesDialog=M.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=M.DashboardSummarySettingsDialog;exports.ResourceManagementPanel=O.ResourceManagementPanel;exports.useDebouncedDirtyCheck=U.useDebouncedDirtyCheck;exports.AdvancedModeToggle=A.AdvancedModeToggle;exports.DashboardControlsSettings=A.DashboardControlsSettings;exports.DashboardFilterControlsButton=A.DashboardFilterControlsButton;exports.ExportNotificationItem=A.ExportNotificationItem;exports.ExportNotificationList=A.ExportNotificationList;exports.NotificationBell=A.NotificationBell;exports.UnsavedChangesAlert=A.UnsavedChangesAlert;exports.VisualEditingControls=A.VisualEditingControls;exports.useExportPolling=A.useExportPolling;exports.useExportRecovery=A.useExportRecovery;exports.usePristineSnapshotInitializer=A.usePristineSnapshotInitializer;exports.normalizeDashboardForDirtyCheck=L.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=L.serializeDashboardForDirtyCheck;exports.AlertDetailPageEmbedded=K;exports.Combobox=W;exports.ScheduleDashboard=H;exports.TenantQuotaPage=Y;exports.Visual=q;exports.useAlertBacktest=Q;exports.useExposePrintState=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-BHWWNpG6.js"),_=require("./types/index.cjs"),M=require("./chunks/dashboard-summary-settings-dialog-BPyawgMV.js"),t=require("react/jsx-runtime"),x=require("react"),O=require("./chunks/resource-management-panel-D8xvqypt.js"),U=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");const A=require("./chunks/dashboard-filter-controls-button-DKc_6T_O.js"),L=require("./chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js");function z(s){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>s[n]})}}return r.default=s,Object.freeze(r)}const R=z(x);function Q(s){const{authToken:r,tokenProps:n}=e.useSemaphorContext();return e.useMutation({mutationFn:async o=>e.backtestAlert(n.apiServiceUrl,r.accessToken,s,o)})}function q(s){const{displayPreferences:r,cardId:n,...o}=s,l={...o,id:s.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:l,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:s.cardId}),t.jsx(e.UXProvider,{children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:r,children:t.jsx(e.Container,{type:"visual",cardId:n,...l,children:t.jsx(V,{cardId:n})})})})]})})}function V({cardId:s}){const r=e.useDashboardStore(l=>{var c;return(c=l.dashboard)==null?void 0:c.sheets}),{card:n,frame:o}=x.useMemo(()=>{const l=r==null?void 0:r.flatMap(i=>i.frames),c=l==null?void 0:l.flatMap(i=>i==null?void 0:i.cards),u=c==null?void 0:c.find(i=>(i==null?void 0:i.id)===s),a=l==null?void 0:l.find(i=>{var m;return(m=i==null?void 0:i.cards)==null?void 0:m.find(f=>(f==null?void 0:f.id)===s)});return{card:u,frame:a}},[r,s]);return!n||!o?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${s}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:l,resetErrorBoundary:c})=>t.jsx(e.FallbackVisual,{error:l,resetErrorBoundary:c,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:n,frame:o})})})}function W({name:s,items:r,value:n,onChange:o,isLoading:l,isError:c,refetch:u,className:a,icon:i,showNone:m=!1}){const f=R.useRef(null),[D,C]=R.useState(!1),[b,j]=R.useState("100%"),y=m?[...r||[],{id:"none",name:"None"}]:r;R.useLayoutEffect(()=>{f.current&&j(f.current.offsetWidth)},[]);function I(){var h;return l?"Loading...":c?"Error":n?(h=r==null?void 0:r.find(S=>S.id===n))==null?void 0:h.name:`Select ${s}`}function T(h,S){o(S),C(!1)}return t.jsxs(e.Popover,{open:D,onOpenChange:C,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{ref:f,variant:"outline",role:"combobox","aria-expanded":D,className:e.cn("flex h-9 w-full justify-between",a),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.jsx("div",{className:"mr-2",children:i}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:I()})]}),t.jsx(e.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(e.PopoverContent,{className:"w-full p-0",style:{minWidth:b},children:t.jsxs(e.Command,{children:[t.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[t.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),t.jsx(e.IconButton,{className:"h-7",onClick:u,children:t.jsx(e.RefreshCw,{className:e.cn("size-3.5 opacity-50",l&&"animate-spin")})})]}),t.jsxs(e.CommandList,{children:[t.jsxs(e.CommandEmpty,{children:["No ",s==null?void 0:s.toLowerCase()," found."]}),t.jsx(e.CommandGroup,{children:y==null?void 0:y.map(h=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:h.name,onSelect:S=>T(S,h.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(e.Check,{className:e.cn("size-4",n===h.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:h.name,children:h.name})]})},h.id))})]})]})})]})}function H({triggerButtonClassName:s,variant:r="ghost"}){const[n,o]=x.useState(!1),l=e.useDashboardStore(u=>{var a;return(a=u.dashboard)==null?void 0:a.id}),c=e.useDashboardStore(u=>{var a;return(a=u.dashboard)==null?void 0:a.title});return l?t.jsxs(t.Fragment,{children:[t.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:e.cn("h-7 p-2",s),buttonProps:{variant:r},onClick:()=>o(!0),children:t.jsx(e.Clock,{className:"size-4"})}),t.jsx(e.EmailScheduleDialog,{open:n,onOpenChange:o,dashboardId:l,dashboardName:c})]}):null}function $(s,r){x.useEffect(()=>(s&&r&&(window.__SEMAPHOR_PRINT_STATE__={...r}),()=>{s&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[s,r])}function P(s){if(!s)return"--";const r=new Date(s);return Number.isNaN(r.getTime())?"--":r.toLocaleString()}function G(s){var r;return((r=s.alertState)==null?void 0:r.currentState)==="FIRING"?"Signal surfaced":s.status==="ACTIVE"?"Watching":s.status==="PAUSED"?"Paused":s.status}function K({alertId:s,onBack:r}){var h,S,F,w;const{authToken:n,tokenProps:o}=e.useSemaphorContext(),{data:l,isLoading:c,refetch:u}=e.useAlertDetail(s),a=(l==null?void 0:l.alert)??null,[i,m]=x.useState([]),[f,D]=x.useState([]),[C,b]=x.useState(null),j=x.useCallback(async()=>{var g;const d=o==null?void 0:o.apiServiceUrl,p=n==null?void 0:n.accessToken;if(!d||!p||!s)return null;try{const v=await fetch(`${d}/v1/alerts/${s}/runs?limit=20`,{headers:{Authorization:`Bearer ${p}`}});if(v.ok){const E=await v.json(),N=Array.isArray(E.runs)?E.runs:[],k=C&&N.some(B=>B.id===C)?C:((g=N[0])==null?void 0:g.id)??null;return D(N),b(k),k}D([]),b(null)}catch{return D([]),b(null),null}return null},[s,n,C,o]),y=x.useCallback(async d=>{const p=o==null?void 0:o.apiServiceUrl,g=n==null?void 0:n.accessToken,v=d??C;if(!p||!g||!s||!v){m([]);return}try{const E=await fetch(`${p}/v1/alerts/${s}/runs/${v}/deliveries`,{headers:{Authorization:`Bearer ${g}`}});if(E.ok){const N=await E.json();m(Array.isArray(N.attempts)?N.attempts:[])}else m([])}catch{m([])}},[s,n,C,o]),I=x.useCallback(async()=>{await u();const d=await j();await y(d)},[y,j,u]);x.useEffect(()=>{j().catch(()=>{})},[j]),x.useEffect(()=>{y().catch(()=>{})},[y]);const T=x.useMemo(()=>{const d={};for(const p of i)d[p.channel]||(d[p.channel]=[]),d[p.channel].push(p);return d},[i]);return c?t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading signal detail..."}):a?t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[r&&t.jsx(e.Button,{variant:"outline",size:"sm",onClick:r,children:"Back"}),t.jsx("h2",{className:"text-lg font-semibold",children:a.name}),t.jsx(e.Badge,{variant:a.status==="ACTIVE"?"default":"secondary",children:G(a)}),((h=a.alertState)==null?void 0:h.currentState)&&t.jsx(e.Badge,{variant:a.alertState.currentState==="FIRING"?"destructive":"outline",children:a.alertState.currentState==="FIRING"?"Signal surfaced":"Stable"})]}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>void I(),children:"Refresh"})]}),a.description&&t.jsx("p",{className:"text-sm text-muted-foreground",children:a.description}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-4 text-sm",children:[t.jsx("p",{className:"font-medium",children:"What changed"}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:"Review the latest signal activity, then investigate the underlying dashboard context if you need more detail."})]}),t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Signal Watch"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Watching for:"})," ",e.formatSignalCondition(a.jobConfig.operator,a.jobConfig.threshold)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Severity:"})," ",a.jobConfig.severity]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Evaluated:"})," ",P((S=a.alertState)==null?void 0:S.lastEvaluatedAt)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Surfaced:"})," ",P((F=a.alertState)==null?void 0:F.lastTriggeredAt)]})]})]}),((w=a.deliveryConfig)==null?void 0:w.channels)&&a.deliveryConfig.channels.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Where It Surfaces"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:a.deliveryConfig.channels.map(d=>t.jsx(e.Badge,{variant:"outline",children:d},d))})]}),f.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Recent Delivery Activity"}),f.length>1&&t.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(d=>t.jsx(e.Button,{variant:d.id===C?"default":"outline",size:"sm",onClick:()=>b(d.id),children:P(d.scheduledFor)},d.id))}),Object.keys(T).length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No delivery attempts were recorded for this run."}):Object.entries(T).map(([d,p])=>t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(e.Badge,{variant:"secondary",className:"text-xs",children:d})}),t.jsx("div",{className:"overflow-hidden rounded border",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Recipient"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Status"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Time"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Error"})]})}),t.jsx("tbody",{children:p.map(g=>t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-2 py-1",children:g.recipient}),t.jsx("td",{className:"px-2 py-1",children:t.jsx(e.Badge,{variant:g.status==="SENT"?"default":"destructive",className:"text-[10px]",children:g.status})}),t.jsx("td",{className:"px-2 py-1",children:P(g.createdAt)}),t.jsx("td",{className:"px-2 py-1 text-muted-foreground",children:g.error||"--"})]},g.id))})]})})]},d))]})]}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Signal not found."})}function Y(){var c,u;const{quotasQuery:s,usageQuery:r}=e.useAlertQuotas(),n=((c=s.data)==null?void 0:c.quotas)||[],o=((u=r.data)==null?void 0:u.usage)||[],l=new Map(o.map(a=>[a.tenantId||"org",a]));return t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Alert Quotas"}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>{s.refetch(),r.refetch()},children:"Refresh"})]}),s.isLoading||r.isLoading?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading quota usage..."}):null,t.jsx("div",{className:"overflow-hidden rounded-lg border",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Tenant"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Active Alerts"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Active"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Min Cadence"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Context Sources"})]})}),t.jsx("tbody",{children:n.map(a=>{const i=a.tenantId||"org",m=l.get(i);return t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-3 py-2",children:i}),t.jsx("td",{className:"px-3 py-2",children:(m==null?void 0:m.activeAlerts)??0}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxActiveAlerts}),t.jsxs("td",{className:"px-3 py-2",children:[a.policy.minCadenceMinutes," min"]}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxContextSources})]},i)})})]})})]})}exports.AlertManagementPage=e.AlertManagementPage;exports.AlertWizardDialog=e.AlertWizardDialog;exports.AlertsApiError=e.AlertsApiError;exports.CALCULATED_FIELD_ENTITY_MARKER=e.CALCULATED_FIELD_ENTITY_MARKER;exports.CardAlertIndicator=e.CardAlertIndicator;exports.CardSummary=e.CardSummary;exports.DATE_FORMAT_VALUES=e.DATE_FORMAT_VALUES;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.EmailScheduleDialog=e.EmailScheduleDialog;exports.ExportError=e.ExportError;exports.PivotMarkerEnum=e.PivotMarkerEnum;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.SummaryCard=e.SummaryCard;exports.Surfboard=e.DashboardPlus;exports.backtestAlert=e.backtestAlert;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createAlert=e.createAlert;exports.createEmptyKpiConfig=e.createEmptyKpiConfig;exports.createExport=e.createExport;exports.createSqlGenConfig=e.createSqlGenConfig;exports.deleteAlert=e.deleteAlert;exports.downloadPdf=e.downloadPdf;exports.emitDashboardLoad=e.emitDashboardLoad;exports.emitDashboardUnload=e.emitDashboardUnload;exports.fmt=e.fmt;exports.formatFileSize=e.formatFileSize;exports.getAlert=e.getAlert;exports.getAlertContextSources=e.getAlertContextSources;exports.getAlertHistory=e.getAlertHistory;exports.getAlertQuotaUsage=e.getAlertQuotaUsage;exports.getAlertRunDeliveries=e.getAlertRunDeliveries;exports.getAlertRunSteps=e.getAlertRunSteps;exports.getAlertRuns=e.getAlertRuns;exports.getAlertState=e.getAlertState;exports.getColumnDataType=e.getColumnDataType;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isCalculatedDimension=e.isCalculatedDimension;exports.isCalculatedField=e.isCalculatedField;exports.isCalculatedMetric=e.isCalculatedMetric;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.listAlertQuotas=e.listAlertQuotas;exports.listAlerts=e.listAlerts;exports.previewAlertDeliverable=e.previewAlertDeliverable;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;exports.triggerAlertNow=e.triggerAlertNow;exports.updateAlert=e.updateAlert;exports.updateAlertContextSources=e.updateAlertContextSources;exports.updateAlertQuota=e.updateAlertQuota;exports.useActiveExports=e.useActiveExports;exports.useAddNewFrame=e.useAddNewFrame;exports.useAlertActions=e.useAlertActions;exports.useAlertDeliveries=e.useAlertDeliveries;exports.useAlertDetail=e.useAlertDetail;exports.useAlertDraft=e.useAlertDraft;exports.useAlertFilters=e.useAlertFilters;exports.useAlertHistory=e.useAlertHistory;exports.useAlertQuotas=e.useAlertQuotas;exports.useAlertRuns=e.useAlertRuns;exports.useAlertState=e.useAlertState;exports.useAlertStore=e.useAlertStore;exports.useAlertWizard=e.useAlertWizard;exports.useAlerts=e.useAlerts;exports.useAlertsBootstrap=e.useAlertsBootstrap;exports.useAlertsById=e.useAlertsById;exports.useAlertsForCard=e.useAlertsForCard;exports.useCard=e.useCard;exports.useCardAlertMap=e.useCardAlertMap;exports.useCardSummary=e.useCardSummary;exports.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardStore=e.useDashboardStore;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useSelectedAlertId=e.useSelectedAlertId;exports.useTextFilterHook=e.useTextFilterHook;exports.CONTROL_CARD_DEFAULT_VALUE=_.CONTROL_CARD_DEFAULT_VALUE;exports.DEFAULT_CALENDAR_CONTEXT=_.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=_.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.EMPTY_SELECTION=_.EMPTY_SELECTION;exports.CalendarPreferencesDialog=M.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=M.DashboardSummarySettingsDialog;exports.ResourceManagementPanel=O.ResourceManagementPanel;exports.useDebouncedDirtyCheck=U.useDebouncedDirtyCheck;exports.AdvancedModeToggle=A.AdvancedModeToggle;exports.DashboardControlsSettings=A.DashboardControlsSettings;exports.DashboardFilterControlsButton=A.DashboardFilterControlsButton;exports.ExportNotificationItem=A.ExportNotificationItem;exports.ExportNotificationList=A.ExportNotificationList;exports.NotificationBell=A.NotificationBell;exports.UnsavedChangesAlert=A.UnsavedChangesAlert;exports.VisualEditingControls=A.VisualEditingControls;exports.useExportPolling=A.useExportPolling;exports.useExportRecovery=A.useExportRecovery;exports.usePristineSnapshotInitializer=A.usePristineSnapshotInitializer;exports.normalizeDashboardForDirtyCheck=L.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=L.serializeDashboardForDirtyCheck;exports.AlertDetailPageEmbedded=K;exports.Combobox=W;exports.ScheduleDashboard=H;exports.TenantQuotaPage=Y;exports.Visual=q;exports.useAlertBacktest=Q;exports.useExposePrintState=$;
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
- import { b as j, W as q, Y as H, Z as W, _ as G, $ as K, a0 as Y, a1 as X, a2 as J, a3 as Z, u as F, a4 as O, a5 as ee, P as ae, k as te, B as T, c as _, a6 as se, l as re, m as ne, n as ie, a7 as Q, a8 as oe, o as le, p as de, q as ce, r as ue, s as me, a9 as he, aa as pe, ab as fe, ac as E, ad as be, ae as ge } from "./chunks/index-Bgn4zTsp.js";
2
- import { aU as Me, aW as Fe, bC as Le, aY as Ue, aV as ze, ax as Be, aZ as Oe, D as je, av as We, ap as Qe, bI as Ve, b1 as $e, ah as qe, ak as He, ak as Ge, al as Ke, aw as Ye, a as Xe, bH as Je, as as Ze, bn as ea, bk as aa, bD as ta, b8 as sa, bp as ra, au as na, aq as ia, ar as oa, b2 as la, bL as da, bm as ca, bw as ua, bt as ma, bA as ha, bu as pa, bv as fa, bs as ba, br as ga, ba as xa, bG as Na, bF as va, bE as ya, b9 as Aa, bd as Ca, be as Sa, b7 as Da, at as Ea, b6 as Ta, a$ as wa, b0 as Ra, a_ as Ia, bb as _a, b5 as Pa, bK as ka, bJ as Ma, b4 as Fa, b3 as La, bz as Ua, bl as za, by as Ba, bf as Oa, bc as ja, bq as Wa, bo as Qa, bx as Va, bB as $a, aE as qa, aB as Ha, aN as Ga, aL as Ka, aT as Ya, aS as Xa, aK as Ja, aJ as Za, aI as et, aM as at, aX as tt, aG as st, aH as rt, aO as nt, aQ as it, ao as ot, aP as lt, az as dt, bh as ct, bj as ut, bi as mt, N as ht, an as pt, ag as ft, ay as bt, aA as gt, ai as xt, M as Nt, bg as vt, U as yt, aD as At, aC as Ct, aF as St, af as Dt, am as Et, aR as Tt, aj as wt } from "./chunks/index-Bgn4zTsp.js";
1
+ import { b as j, W as q, Y as H, Z as W, _ as G, $ as K, a0 as Y, a1 as X, a2 as J, a3 as Z, u as F, a4 as O, a5 as ee, P as ae, k as te, B as T, c as _, a6 as se, l as re, m as ne, n as ie, a7 as Q, a8 as oe, o as le, p as de, q as ce, r as ue, s as me, a9 as he, aa as pe, ab as fe, ac as E, ad as be, ae as ge } from "./chunks/index-B7kUtCgG.js";
2
+ import { aU as Me, aW as Fe, bC as Le, aY as Ue, aV as ze, ax as Be, aZ as Oe, D as je, av as We, ap as Qe, bI as Ve, b1 as $e, ah as qe, ak as He, ak as Ge, al as Ke, aw as Ye, a as Xe, bH as Je, as as Ze, bn as ea, bk as aa, bD as ta, b8 as sa, bp as ra, au as na, aq as ia, ar as oa, b2 as la, bL as da, bm as ca, bw as ua, bt as ma, bA as ha, bu as pa, bv as fa, bs as ba, br as ga, ba as xa, bG as Na, bF as va, bE as ya, b9 as Aa, bd as Ca, be as Sa, b7 as Da, at as Ea, b6 as Ta, a$ as wa, b0 as Ra, a_ as Ia, bb as _a, b5 as Pa, bK as ka, bJ as Ma, b4 as Fa, b3 as La, bz as Ua, bl as za, by as Ba, bf as Oa, bc as ja, bq as Wa, bo as Qa, bx as Va, bB as $a, aE as qa, aB as Ha, aN as Ga, aL as Ka, aT as Ya, aS as Xa, aK as Ja, aJ as Za, aI as et, aM as at, aX as tt, aG as st, aH as rt, aO as nt, aQ as it, ao as ot, aP as lt, az as dt, bh as ct, bj as ut, bi as mt, N as ht, an as pt, ag as ft, ay as bt, aA as gt, ai as xt, M as Nt, bg as vt, U as yt, aD as At, aC as Ct, aF as St, af as Dt, am as Et, aR as Tt, aj as wt } from "./chunks/index-B7kUtCgG.js";
3
3
  import { CONTROL_CARD_DEFAULT_VALUE as It, DEFAULT_CALENDAR_CONTEXT as _t, DEFAULT_SEMANTIC_DOMAIN_ACCESS as Pt, EMPTY_SELECTION as kt } from "./types/index.js";
4
- import { C as Ft, D as Lt } from "./chunks/dashboard-summary-settings-dialog-zdacBYZZ.js";
4
+ import { C as Ft, D as Lt } from "./chunks/dashboard-summary-settings-dialog-CWtlFDFP.js";
5
5
  import { jsx as e, jsxs as r, Fragment as xe } from "react/jsx-runtime";
6
6
  import * as R from "react";
7
7
  import { useMemo as V, useState as P, useEffect as L, useCallback as M } from "react";
8
- import { ResourceManagementPanel as zt } from "./chunks/resource-management-panel--xIMLPdz.js";
8
+ import { ResourceManagementPanel as zt } from "./chunks/resource-management-panel-Dpin6Ffw.js";
9
9
  import { u as Ot } from "./chunks/use-debounced-dirty-check-BwAbnX_5.js";
10
10
  import "react-dom";
11
- import { A as Wt, D as Qt, c as Vt, a as $t, E as qt, N as Ht, U as Gt, V as Kt, u as Yt, b as Xt, d as Jt } from "./chunks/dashboard-filter-controls-button-DVLBLHga.js";
11
+ import { A as Wt, D as Qt, c as Vt, a as $t, E as qt, N as Ht, U as Gt, V as Kt, u as Yt, b as Xt, d as Jt } from "./chunks/dashboard-filter-controls-button-zeiatmo1.js";
12
12
  import { n as es, s as as } from "./chunks/normalize-dashboard-for-dirty-check-5KpZN8xr.js";
13
13
  function De(a) {
14
14
  const { authToken: s, tokenProps: i } = j();