react-semaphor 0.1.382 → 0.1.384
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.
- package/dist/brand-studio/index.cjs +4 -4
- package/dist/brand-studio/index.js +27 -27
- package/dist/chunks/{braces-CP8BEzl3.js → braces--20GzUQh.js} +1 -1
- package/dist/chunks/{braces-CGi-YFZp.js → braces-C0Vh_Mft.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-CV4xF2Tp.js → calendar-preferences-dialog-B-VsxhsA.js} +3 -3
- package/dist/chunks/calendar-preferences-dialog-DE67Z3oQ.js +1 -0
- package/dist/chunks/{dashboard-briefing-launcher-BT00MvGB.js → dashboard-briefing-launcher-BIj3X7b3.js} +107 -106
- package/dist/chunks/dashboard-briefing-launcher-Czx6BcXW.js +80 -0
- package/dist/chunks/dashboard-controls-BP-DcPFs.js +52 -0
- package/dist/chunks/{dashboard-controls-B6y7jkKO.js → dashboard-controls-BXxucM4f.js} +114 -113
- package/dist/chunks/dashboard-json-BNwshkK2.js +1 -0
- package/dist/chunks/{dashboard-json-CfIUG8k1.js → dashboard-json-C6oZuipD.js} +8 -8
- package/dist/chunks/edit-dashboard-visual-BAprin3J.js +178 -0
- package/dist/chunks/{edit-dashboard-visual-DMbf89xa.js → edit-dashboard-visual-CmfrI_L3.js} +1277 -1276
- package/dist/chunks/{index-CrKxP9uF.js → index-4W_ElSBJ.js} +219 -239
- package/dist/chunks/{index-BAsWLkZ8.js → index-icb12JV1.js} +879 -932
- package/dist/chunks/{layout-grid-jJQUqDN9.js → layout-grid-B7-klXiK.js} +1 -1
- package/dist/chunks/{layout-grid-BsKH3TgY.js → layout-grid-DV89AC9_.js} +1 -1
- package/dist/chunks/{palette-xU9Qt6bE.js → palette-5IwhMbSF.js} +1 -1
- package/dist/chunks/{palette-9zLPGlj2.js → palette-Dj-dgPYh.js} +1 -1
- package/dist/chunks/{save-DzciESDh.js → save-16C6YSW2.js} +1 -1
- package/dist/chunks/{save-8A_q6K4E.js → save-C5fwVdTF.js} +1 -1
- package/dist/chunks/search-0LmWwZzW.js +57 -0
- package/dist/chunks/search-Dq1Mbb03.js +21 -0
- package/dist/chunks/{switch-DArtNJZh.js → switch-DUdaHFZQ.js} +2332 -2419
- package/dist/chunks/{switch-k7kj6NRg.js → switch-bdJp0Bkw.js} +29 -54
- package/dist/chunks/use-create-flow-overlay-state-BIHKf_XK.js +21 -0
- package/dist/chunks/{use-create-flow-overlay-state-BdG1DiSx.js → use-create-flow-overlay-state-YvqCp6Zo.js} +74 -74
- package/dist/chunks/x-B_cx7LwM.js +26 -0
- package/dist/chunks/x-IdR_js6f.js +139 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/data-app-builder/index.cjs +23 -23
- package/dist/data-app-builder/index.js +17 -15
- package/dist/data-app-sdk/index.cjs +68 -1
- package/dist/data-app-sdk/index.js +2876 -495
- package/dist/index.cjs +1 -1
- package/dist/index.js +14 -14
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/data-app-sdk.d.ts +148 -1
- package/package.json +1 -1
- package/dist/chunks/calendar-preferences-dialog-rDDobeLo.js +0 -1
- package/dist/chunks/dashboard-briefing-launcher-Dcbh-mjY.js +0 -80
- package/dist/chunks/dashboard-controls-CRqnPibB.js +0 -52
- package/dist/chunks/dashboard-json-DEQqRR1x.js +0 -1
- package/dist/chunks/edit-dashboard-visual-wDOcHak3.js +0 -178
- package/dist/chunks/index-BxM99sFL.js +0 -1
- package/dist/chunks/index-CuHybtft.js +0 -51
- package/dist/chunks/use-create-flow-overlay-state-ipeaE65_.js +0 -21
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";const ee=require("./x-B_cx7LwM.js"),C=require("react"),s=require("./switch-bdJp0Bkw.js"),m=require("./index-4W_ElSBJ.js"),e=require("react/jsx-runtime");require("./analyze-result-contract-CtXfp3nv.js");const je=require("./save-C5fwVdTF.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 ke=ee.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"}]]);/**
|
|
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 Ne=ee.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"}]]);/**
|
|
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 Ie=ee.createLucideIcon("Rows3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/**
|
|
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 Ve=ee.createLucideIcon("SendHorizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]);function Te(r){const[a,o]=C.useState(null),[n,i]=C.useState(null),c=m.useEnsureReactGlobals();return C.useEffect(()=>{if(!r||r.trim()===""){o(null),i(null);return}if(!c)return;(async()=>{try{if(!r.startsWith("http://")&&!r.startsWith("https://"))throw new Error(`Invalid URL format: ${r}`);try{new URL(r)}catch{throw new Error(`Invalid URL: ${r}`)}const p=`${r.endsWith("/")?r:`${r}/`}index.js`;try{if(!(await fetch(p,{method:"HEAD"})).ok)throw new Error(`Module not found at ${p}`)}catch{}const v=await import(p);if(typeof v.useChartStore!="function")throw new Error("useChartStore is not a function");o(()=>v.useChartStore),i(null)}catch(h){const p=h instanceof Error?h.message:"Unknown error";console.error("Failed to load remote chart store:",p),i(p),o(null)}})()},[r,c]),a}function Le(r,a){if(r.length===0)return"";const o=r.find(n=>{var i,c;return((i=n.customCardPreferences)==null?void 0:i.visualType)==="multiple"||!!((c=n.customCardPreferences)!=null&&c.dataInputCardIds)});if(o)return o.id;if(a){const n=r.find(i=>i.id===a);if(n){const i=n.tabTitle;if(i=="All__Header")return r[0].id;if(i&&i.endsWith("__Header")){const f=i.split("__")[0],h=r.find(p=>p.tabTitle===f);return h?h.id:r[0].id}return a}}return r[0].id}const ue=new Set;function Ae(r){return ue.add(r),()=>{ue.delete(r)}}function Ee(){ue.forEach(r=>{r()})}const _e=r=>{if(!r||!("detailTableBackup"in r))return r;const{detailTableBackup:a,...o}=r;return o};async function ye(r,a,o,n,i="Opening library visual..."){if(!a||!o)throw new Error("Missing auth token or visual ID");const c=["resource-by-id","visual",o],f=n.getQueryData(c);if(f)return console.log("Using cached visual data for:",o),{data:f,fromCache:!0};console.log("Fetching visual data from network for:",o);const h=m.ue.loading(i,{position:"top-center"});try{const p=await fetch(`${r}/management/v1/visuals/${o}`,{headers:{Authorization:`Bearer ${a}`}});if(!p.ok)throw new Error("Failed to load visual");const v=await p.json();return n.setQueryData(c,v),m.ue.dismiss(h),{data:v,fromCache:!1}}catch(p){throw m.ue.dismiss(h),p}}function we(r){if(typeof r=="string")return JSON.parse(r);if(typeof r=="object")return r;throw new Error("Invalid frame object format")}function Be(r,a){var c,f;const o=(r==null?void 0:r.frameObject)??((c=r==null?void 0:r.visual)==null?void 0:c.frameObject);if(!o)return!1;const n=we(o);if(!(n!=null&&n.cards)||n.cards.length===0)return!1;const i=(f=n.cards)==null?void 0:f.find(h=>h.id===n.activeCardId);return i?(m.setupEditorWithCard({...a,frame:n,card:i,visualId:(r==null?void 0:r.id)||n.visualId}),!0):!1}function Me(){const r=s.useEditorStore(n=>{var i;return((i=n.card.customCardPreferences)==null?void 0:i.url)||""}),a=Te(r);return{getUpdatedFrame:C.useCallback(()=>{var V;Ee();const{frame:n,card:i,isDevMode:c,isShowingVisual:f,selectedSchemaName:h,selectedDatamodelId:p,selectedDatabaseName:v,selectedTableName:g,selectedConnectionId:x}=s.useEditorStore.getState(),S=i.sql,w=(V=a==null?void 0:a.getState())==null?void 0:V.settings,k=s.buildSavedEditorCard(i,{isDevMode:c,cardSql:S,isShowingVisual:f,selectedSchemaName:h,selectedDatamodelId:p,selectedDatabaseName:v,selectedTableName:g,selectedConnectionId:x,remoteChartSettings:w,stripConfig:_e}),E=n.cards.map(U=>U.id===i.id?k:U);return{...n,cards:E,activeCardId:Le(E,n.activeCardId)}},[a])}}function ae(){const{authToken:r,tokenProps:a}=m.useSemaphorContext(),o=m.useQueryClient(),n=m.useAddFrameWithFreshSemanticExecutionPayload(),i=m.useSelectedVisual(),{selectVisual:c}=m.useManagementActions(),{setFrame:f,setCard:h,setIsDevMode:p,initializeModeDrafts:v,setActiveTabCardId:g,updateDataSource:x,setQueryResultColumns:S,setSelectedConnectionId:w,setSelectedDatabaseName:k,setSelectedSchemaName:E,setSelectedTableName:V,setSelectedDatamodelId:U,setFilterValues:H,setInlineFilterValuesMap:W,setApplyFilters:Y,clearEditorContext:J}=s.useEditorActions(),{setIsDashboardEditing:M,setIsVisualEditing:l,setSelectedFrameId:D,clearSelectedFrameId:T}=s.useDashboardActions(),q=s.useDashboardStore(A=>A.selectedSheetId),Q=s.useDashboardStore(A=>A.selectedFrameId),K=s.useDashboardStore(A=>A.dashboard),G=s.useDashboardStore(A=>A.filterValues),_=s.useDashboardStore(A=>A.inlineFilterValuesMap),z=m.useVisualById((i==null?void 0:i.id)||"",{enabled:!!(i!=null&&i.id)&&!!(r!=null&&r.accessToken)}),$=C.useCallback(async A=>{try{c(A),T(),J();const{data:F,fromCache:P}=await ye(a.apiServiceUrl,(r==null?void 0:r.accessToken)||"",A.id,o,"Opening library visual...");if(!Be(F,{setFrame:f,setCard:h,setIsDevMode:p,initializeModeDrafts:v,setActiveTabCardId:g,updateDataSource:x,setQueryResultColumns:S,setSelectedConnectionId:w,setSelectedDatabaseName:k,setSelectedSchemaName:E,setSelectedTableName:V,setSelectedDatamodelId:U,setFilterValues:H,setInlineFilterValuesMap:W,setApplyFilters:Y,setIsDashboardEditing:M,setIsVisualEditing:l,dashboard:K,selectedSheetId:q,selectedFrameId:Q,filterValues:G,inlineFilterValuesMap:_}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:P}}catch(F){return console.error("Error editing visual:",F),{success:!1,error:"Failed to load visual for editing"}}},[r==null?void 0:r.accessToken,a.apiServiceUrl,o,c,f,h,M,l,p,v,g,x,S,w,k,E,V,U,H,W,Y,J,T,K,q,Q,G,_]),ne=C.useCallback(async A=>{var P;const F=B=>(m.ue.error(B),{success:!1,error:B});try{if(c(A),!q)return F("No sheet selected. Please select a sheet first.");const{data:B,fromCache:oe}=await ye(a.apiServiceUrl,(r==null?void 0:r.accessToken)||"",A.id,o,"Adding visual to dashboard..."),re=(B==null?void 0:B.frameObject)??((P=B==null?void 0:B.visual)==null?void 0:P.frameObject);if(!re)return F("Visual has no frame data");const R=we(re);if(!(R!=null&&R.cards)||R.cards.length===0)return F("Visual frame is malformed");const te={...m.cloneLinkedFrameWithSourceMapping(R),visualId:A.id};return await n(q,te,"end"),M(!0),D(te.id),{success:!0,fromCache:oe}}catch(B){return console.error("Error adding visual:",B),F(B instanceof Error?B.message:"Failed to add visual to dashboard")}},[r==null?void 0:r.accessToken,a.apiServiceUrl,o,c,q,M,D,n]);return{visual:z.data,isLoading:z.isLoading,isError:z.isError,error:z.error,handleEditLibraryVisual:$,handleAddLibraryVisual:ne,getUpdatedFrame:Me().getUpdatedFrame,refetch:z.refetch}}function qe(){const r=s.useEditorStore(f=>f.card.dataSource),{setSelectedConnectionId:a,setSelectedDatabaseName:o,setSelectedSchemaName:n,setSelectedTableName:i,setSelectedDatamodelId:c}=s.useEditorActions();C.useEffect(()=>{var w;if(!r)return;const{tableName:f,schemaName:h,databaseName:p,connectionId:v}=m.extractTableMetadata(r),g=(w=r.selectedEntities)==null?void 0:w[0],S=(g==null?void 0:g.type)==="model"&&"id"in g?g.id:"";a(v||""),o(p||""),n(h||""),i(f||""),c(S)},[r,a,o,n,i,c])}function pe(){var p,v;const r=s.useEditorStore(g=>g.card),a=s.useEditorStore(g=>g.frame),o=C.useMemo(()=>m.findCustomVisualConfigCard(a,r),[a,r]),{manifest:n}=m.useCustomVisual(((p=o==null?void 0:o.customCardPreferences)==null?void 0:p.url)||""),i=C.useMemo(()=>{var g;return(g=n==null?void 0:n.visuals)==null?void 0:g.find(x=>{var S;return x.name===((S=o==null?void 0:o.customCardPreferences)==null?void 0:S.componentName)})},[n,(v=o==null?void 0:o.customCardPreferences)==null?void 0:v.componentName]),c=m.resolveMultiInputType(o,i),f=C.useMemo(()=>m.getCustomVisualInputCards({frame:a,configCard:o,isMultiInputVisual:c==="multiple"}),[a,o,c]),h=C.useMemo(()=>{const g=f.findIndex(x=>(x==null?void 0:x.id)===r.id);return g<0?-1:m.getSlotIndexForCard(r,g)},[f,r]);return C.useMemo(()=>!o||c!=="multiple"||h<0?r.type:m.getEffectiveCardTypeForSlot(r,h,i==null?void 0:i.slots)??r.type,[o,c,h,r,i==null?void 0:i.slots])}function Oe({type:r,isLinked:a,className:o,showLabel:n=!1,showLocal:i=!1}){const c=s.useDashboardStore(E=>E.selectedFrameId),f=m.useManagementStore(E=>E.selectedVisual),h=s.useEditorStore(E=>E.frame);let p;if(r)p=r;else if(a!==void 0)p=a?"linked":"library";else if(!!!(h!=null&&h.visualId||f!=null&&f.id)&&c)p="local";else if(f&&!c)p="library";else if(h!=null&&h.visualId&&c)p="linked";else if(f!=null&&f.id&&c)p="library";else return null;if(p==="local"&&!i)return null;const v={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"},g={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."},x={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"},S={local:"fill-slate-50 dark:fill-slate-900",linked:"fill-purple-50 dark:fill-purple-950",library:"fill-blue-50 dark:fill-blue-950"},w={local:e.jsx("span",{className:"h-2 w-2 rounded-full bg-current/70"}),linked:e.jsx(Ne,{className:"h-3.5 w-3.5"}),library:e.jsx(ke,{className:"h-3.5 w-3.5"})},k={local:"Local",linked:"Linked",library:"Library"};return e.jsx(s.TooltipProvider,{children:e.jsxs(s.Tooltip,{delayDuration:300,children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsxs(m.Badge,{variant:"outline",className:s.cn("cursor-help select-none transition-all",v[p],o),children:[w[p],n&&e.jsx("span",{className:"ml-1 text-xs font-medium leading-none",children:k[p]})]})}),e.jsxs(s.TooltipContent,{side:"bottom",className:s.cn("max-w-xs",x[p]),children:[e.jsx(s.TooltipArrow,{className:S[p]}),e.jsx("p",{children:g[p]})]})]})})}function Ue(r,a){return{...r,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,dynamicCardPreferences:void 0,customCardPreferences:a?r.customCardPreferences:void 0,visualizationMode:"builtin",type:a?r.type:"bar"}}function me(r){const a=s.getDynamicFrameSaveIssue(r);return a?(m.ue.error(a),!1):!0}function ze({className:r,variant:a="outline"}){const o=s.useEditorStore(c=>c.onSave),{getUpdatedFrame:n}=ae();function i(){const c=n();me(c)&&(o==null||o(c))}return e.jsxs(s.Button,{onClick:i,className:r,size:"xs",variant:a,children:[e.jsx(s.Check,{className:"h-3.5 w-3.5"}),"Accept"]})}function Re({className:r,variant:a="default"}){const o=m.useQueryClient(),[n,i]=C.useState(!1),{setIsVisualEditing:c}=s.useDashboardActions(),{getUpdatedFrame:f}=ae(),h=m.useSelectedVisual(),p=s.useEditorStore(x=>x.frame),v=m.useUpdateVisualMutation(),g=()=>{const x=f();if(!me(x))return;const S=(p==null?void 0:p.visualId)||(h==null?void 0:h.id);if(!S){m.ue.error("No visual to save");return}i(!0),v.mutate({visualId:S,data:{frameObject:x}},{onSuccess:()=>{i(!1),m.ue.success("Visual updated successfully"),o.invalidateQueries({queryKey:["resource-by-id","visual",S],exact:!0})},onError:()=>{i(!1),m.ue.error("Failed to update visual")}})};return e.jsx(s.Button,{onClick:g,className:r,size:"xs",variant:a,children:n?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving"]}):e.jsxs(e.Fragment,{children:[e.jsx(je.Save,{className:"h-3.5 w-3.5"}),"Save to Library"]})})}function Qe({className:r}){const a=m.useQueryClient(),[o,n]=C.useState(!1),i=m.useSelectedVisual(),c=s.useEditorStore(k=>k.frame),f=s.useDashboardStore(k=>k.selectedSheetId),h=s.useDashboardStore(k=>k.dashboard),{updateFrame:p,setIsVisualEditing:v}=s.useDashboardActions(),{getUpdatedFrame:g}=ae(),x=m.useUpdateVisualMutation(),S=m.useResolveExistingFrameSemanticExecutionPayload(),w=async()=>{if(!f){m.ue.error("No sheet selected");return}const k=(c==null?void 0:c.visualId)||(i==null?void 0:i.id);if(!k){m.ue.error("No visual to update");return}n(!0);try{const E=g();if(!me(E)){n(!1);return}const V={...E,visualId:k},U=m.findDashboardFrameById(h,V.id),H=await S(V,{previousFrame:U});await x.mutateAsync({visualId:k,data:{frameObject:E}}),p(f,V,{semanticExecutionPayload:H}),a.invalidateQueries({queryKey:["visuals"]}),a.invalidateQueries({queryKey:["visual",k]}),m.ue.success("Saved to library and applied locally"),setTimeout(()=>{v(!1)},300)}catch(E){console.error("Failed to save and apply:",E),m.ue.error(E instanceof Error?E.message:"Failed to save and apply changes")}finally{n(!1)}};return e.jsx(s.Button,{onClick:w,className:r,size:"xs",variant:"default",disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(je.Save,{className:"h-3.5 w-3.5"}),"Save & Apply"]})})}function Pe({className:r}){const{setTempQueryData:a,setSqlGen:o}=s.useEditorActions(),n=m.useQueryClient(),i=s.useEditorStore(x=>x.tempQueryData),c=s.useEditorStore(x=>x.onClose),f=s.useEditorStore(x=>x.card),h=pe(),p=C.useMemo(()=>h!==f.type?{...f,type:h}:f,[f,h]),{queryKey:v}=m.useEditorCardQuery(p);function g(){if(i){const{queryKey:x,queryData:S}=i;x&&S&&n.setQueryData(x,S)}o({}),c==null||c()}return e.jsxs(s.Button,{onClick:g,className:r,size:"xs",variant:"outline",children:[e.jsx(ee.X,{className:"h-3.5 w-3.5"}),"Close"]})}function $e({label:r="Clear",variant:a="secondary",className:o}={}){const{setTempQueryData:n}=s.useEditorActions(),i=m.useQueryClient(),c=s.useEditorStore(M=>M.tempQueryData),f=s.useEditorStore(M=>M.card),h=pe(),p=C.useMemo(()=>h!==f.type?{...f,type:h}:f,[f,h]),{queryKey:v}=m.useEditorCardQuery(p),{setCardSql:g,setSqlGen:x,setCardPython:S,setCardCustomCfg:w,setCardPreferences:k,clearQueryConfig:E,setCardConfig:V,setCardType:U,setFrame:H,setCard:W,setActiveTabCardId:Y}=s.useEditorActions();function J(){var K,G,_,z;const M=i.getQueryData(v);c!=null&&c.queryData||n({queryKey:v,queryData:M}),i.setQueryData(v,null),i.removeQueries({queryKey:v,exact:!0}),g(""),x({}),E(),V(void 0),S(""),w(""),k({});const l=s.useEditorStore.getState().frame,D=s.useEditorStore.getState().card,T=m.findCustomVisualConfigCard(l,D),q=((K=T==null?void 0:T.customCardPreferences)==null?void 0:K.visualType)==="multiple"||!!((G=T==null?void 0:T.customCardPreferences)!=null&&G.dataInputCardIds)||(((_=T==null?void 0:T.customCardPreferences)==null?void 0:_.minInputs)||0)>1||(((z=T==null?void 0:T.customCardPreferences)==null?void 0:z.maxInputs)||0)>1,Q=Ue(D,q);H({...l,cards:l.cards.map($=>$.id===Q.id?Q:$)}),Y(Q.id),W(Q),q||U("bar")}return e.jsxs(s.Button,{onClick:J,className:o,size:"xs",variant:a,children:[e.jsx(ee.X,{className:"h-3.5 w-3.5"}),r]})}function De(r){const{control:a,onChange:o}=r;return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(s.Input,{size:"xs",value:a.label,placeholder:"Control label",onChange:n=>o(n.target.value)})]})}function He(r){const{currentStep:a,labels:o}=r;return e.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:e.jsx("div",{className:"flex flex-wrap items-center gap-2 sm:gap-2.5",children:o.map((n,i)=>{const c=i+1,f=c===a,h=c<a;return e.jsxs(C.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:s.cn("flex h-5 w-5 items-center justify-center rounded-full border text-[10px] font-medium tabular-nums",f?"border-foreground bg-foreground text-background":h?"border-foreground/30 bg-foreground/10 text-foreground":"border-border/60 bg-background text-muted-foreground"),children:c}),e.jsx("span",{className:s.cn("text-[12px]",f?"font-medium text-foreground":"text-muted-foreground"),children:n})]}),i<o.length-1?e.jsx("span",{className:"h-px w-4 bg-border/60 sm:w-6","aria-hidden":"true"}):null]},n)})})})}function se(r){const{secondary:a,tertiary:o,primary:n}=r;return e.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:[a,o,n]})}function Ye(r){const{control:a,scope:o,detail:n}=r;return e.jsxs("div",{className:"flex items-start gap-2.5 rounded-control border border-border/60 bg-muted/30 px-3 py-2.5",children:[e.jsx(m.CircleCheck,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground"}),e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:a.label}),e.jsxs("div",{className:"text-[12px] text-muted-foreground",children:[s.getFriendlyTypeOption(a.type).label," ·"," ",s.getControlOptionPreview(a)," ·"," ",s.getPlacementLabel(o,a.placement)]}),n?e.jsx("div",{className:"text-[12px] text-muted-foreground",children:n}):null]})]})}function ve(r){const{control:a,defaultValue:o,availableFieldChoices:n,availableMetricChoices:i,previewControlDefinitions:c,previewControlValues:f,onControlChange:h,onLabelChange:p,onDefaultValueChange:v,onBack:g,onNext:x,nextDisabled:S}=r;return e.jsxs("div",{className:"space-y-3",children:[e.jsx(De,{control:a,onChange:p}),e.jsx(m.ControlDefinitionOptionsEditor,{control:a,availableFieldChoices:n,availableMetricChoices:i,previewControlDefinitions:c,previewControlValues:f,controlLifecycle:"create",onChange:h}),e.jsx(m.ControlDefaultValueEditor,{control:a,value:o,onChange:v,allowNoDefault:!0,allowCardDefault:!0,hint:"This is the value viewers will see first.",previewControlDefinitions:c,previewControlValues:f}),e.jsx(se,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:g,children:"Back"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:x,disabled:S,children:"Next"})})]})}const Ke=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]);function Ce(r){const{text:a,ariaLabel:o}=r,[n,i]=C.useState(!1);return e.jsxs("button",{type:"button","aria-label":o,onClick:async()=>{try{await navigator.clipboard.writeText(a),i(!0),setTimeout(()=>i(!1),1200)}catch(c){console.error("Failed to copy",c)}},className:"group flex w-full items-center justify-between gap-2 rounded-control 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:[e.jsx("code",{className:"min-w-0 truncate font-mono text-[12px] text-foreground",children:a}),e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100",children:n?"Copied":"Click to copy"})]})}function Se(r){const{control:a,scope:o,createdReference:n,explorerContent:i,sqlDescription:c,summaryDetail:f,onBack:h,onCancel:p,onDone:v}=r,g=Ke.has(a.type),x=n.match(/\[\[param\.(.+?)\]\]/),S=x?`{{ param('${x[1]}') }}`:"";return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ye,{control:a,scope:o,detail:f}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[13px] font-medium text-foreground",children:"How cards use this control"}),e.jsxs("div",{className:"divide-y divide-border/60 overflow-hidden rounded-control border border-border/60",children:[g?e.jsxs("div",{className:"space-y-1 px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Explorer cards"}),e.jsx("div",{className:"text-[12px] text-muted-foreground",children:i})]}):null,e.jsxs("div",{className:"space-y-1.5 px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"SQL cards"}),e.jsx(Ce,{text:n,ariaLabel:"Copy SQL control reference"}),S?e.jsx(Ce,{text:S,ariaLabel:"Copy Jinja control reference"}):null,e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[c," ",e.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"}),"."]})]})]})]}),e.jsx(se,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:h,children:"Back"}),tertiary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:p,children:"Cancel"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:v,children:"Done"})})]})}function We(r){const a=s.createBlankControl(r.scope,r.existingControls,r.reservedIds),o=r.type===a.type?{...a,label:s.DEFAULT_LABEL_BY_TYPE[r.type]}:{...s.applyControlTypeChange({controls:[{...a,label:s.DEFAULT_LABEL_BY_TYPE[r.type]}],controlId:a.id,nextType:r.type}).controls[0],label:s.DEFAULT_LABEL_BY_TYPE[r.type]};return{step:2,control:o,defaultValue:s.getDefaultValueForType(o,void 0)}}function Ge({scope:r,controls:a,reservedControlIds:o,defaultValues:n,onChange:i,emptyMessage:c,initialCreateFlow:f=!1,usageByControlId:h,availableFieldChoices:p,availableMetricChoices:v,structuralParticipants:g,structuralParticipantIdsByControlId:x,card:S,allowedControlTypes:w,onCreateFlowActiveChange:k,onCreateFlowComplete:E}){const V=C.useMemo(()=>new Set(o||[]),[o]),U=s.getPlacementOptionsForScope(r),H=s.getDefaultPlacement(r),[W,Y]=C.useState(null),[J,M]=C.useState(null),[l,D]=C.useState(()=>f?{step:1,control:s.createBlankControl(r,a,Array.from(V))}:null),T=C.useRef({}),q=C.useRef(void 0),Q=C.useRef(f),K=C.useMemo(()=>{const t=s.getFriendlyControlTypeOptions({scope:r,card:S});if(!w)return t;const u=new Set(w);return t.filter(d=>u.has(d.value))},[w,S,r]),G=C.useCallback(t=>{const u=s.getFriendlyControlTypeOptions({scope:r,card:S,includeType:w?void 0:t});if(!w)return u;const d=new Set(w);return u.filter(b=>d.has(b.value))},[w,S,r]),_=C.useCallback(t=>r==="dashboard"&&(t==="field_selector"||t==="metric_selector"),[r]),z=C.useMemo(()=>l?s.getEligibleParticipantsForStructuralControl(g||[],l.control.type):[],[l,g]),$=C.useMemo(()=>{if(!l)return{fields:p||[],metrics:v||[]};if(!_(l.control.type))return{fields:p||[],metrics:v||[]};const t=l.selectedCardIds||[],u=s.getCompatibleStructuralChoiceCatalog({controlType:l.control.type,participants:g||[],selectedCardIds:t});return{fields:l.control.type==="field_selector"?u.choices.map(d=>({option:d,target:u.fieldTargetMap[d.value]})):[],metrics:l.control.type==="metric_selector"?u.choices.map(d=>({option:d,target:u.metricTargetMap[d.value]})):[]}},[p,v,l,_,g]);C.useEffect(()=>{k==null||k(!!l)},[l,k]),C.useEffect(()=>{const t=f&&!Q.current;Q.current=f,t&&(D({step:1,control:s.createBlankControl(r,a,Array.from(V))}),M(null),Y(null))},[a,f,V,r]);const ne=t=>{if(!_(t.type))return{fields:p||[],metrics:v||[]};const u=(x==null?void 0:x[t.id])||[];if(u.length===0)return{fields:p||[],metrics:v||[]};const d=s.getCompatibleStructuralChoiceCatalog({controlType:t.type,participants:g||[],selectedCardIds:u});return{fields:t.type==="field_selector"?d.choices.map(b=>({option:b,target:d.fieldTargetMap[b.value]})):[],metrics:t.type==="metric_selector"?d.choices.map(b=>({option:b,target:d.metricTargetMap[b.value]})):[]}},A=t=>{if(!_(t.control.type))return{nextControl:t.control,cardBindingsById:void 0};const u=(x==null?void 0:x[t.control.id])||[],d=s.getCompatibleStructuralChoiceCatalog({controlType:t.control.type,participants:g||[],selectedCardIds:t.nextSelectedCardIds}),b=s.reconcileStructuralControlChoices({control:t.control,choices:d.choices}),j=Object.fromEntries(u.filter(N=>!t.nextSelectedCardIds.includes(N)).map(N=>[N,void 0]));return t.nextSelectedCardIds.length>0&&b.source.kind==="manual"&&b.source.options.length>0&&Object.assign(j,s.buildStructuralControlBindingsForParticipants({control:b,participants:g||[],selectedCardIds:t.nextSelectedCardIds})),{nextControl:b,cardBindingsById:j}},F=C.useCallback((t,u=n,d={type:"update"})=>{const b=t.map(j=>(s.resolveAuthoringControlDefaultValue({control:j,defaultValues:u}),s.syncSqlQueryControlExecutionRequirement(j)));i(b,u,d)},[n,i]),P=(t,u)=>{const d=a.find(L=>L.id===t);let b=a.map(L=>L.id!==t?L:u(L));const j=b.find(L=>L.id===t);let N,y;if(j&&r==="dashboard"&&(j.type==="field_selector"||j.type==="metric_selector")){const L=(x==null?void 0:x[j.id])||[],Z=A({control:j,nextSelectedCardIds:L});b=b.map(X=>X.id===t?Z.nextControl:X),N=Z.cardBindingsById,y=[j.id]}else if(d&&r==="dashboard"&&(d.type==="field_selector"||d.type==="metric_selector")){const L=(x==null?void 0:x[d.id])||[];N=Object.fromEntries(L.map(Z=>[Z,void 0])),y=[d.id]}const I=b.find(L=>L.id===t);let O=n;if(d&&I){const L=s.resolveAuthoringControlDefaultValue({control:d,defaultValues:n});d.source.kind==="manual"&&I.source.kind==="sql_query"&&(T.current[t]=L);const Z=L===void 0&&d.source.kind==="sql_query"&&I.source.kind==="manual"?T.current[t]:L,X=s.getNextEditedControlDefaultValue({previousControl:d,nextControl:I,currentDefaultValue:Z});I.source.kind==="manual"&&(T.current[t]=X),n&&(O={...n},X===void 0?delete O[t]:O[t]=X),b=b.map(be=>be.id===t?{...I,defaultValue:X}:be)}F(b,O,{type:"update",cardBindingsById:N,affectedBindingControlIds:y})},B=(t,u)=>{if(!u.trim())return;const d=m.normalizeDashboardInputVariableName(u);if(d===t||V.has(d)||a.some(N=>N.id===d&&N.id!==t))return;const b=a.map(N=>N.id===t?{...N,id:d}:N);if(!n){F(b,void 0,{type:"rename",oldId:t,newId:d});return}const j={...n};Object.prototype.hasOwnProperty.call(j,t)&&(j[d]=j[t],delete j[t]),F(b,j,{type:"rename",oldId:t,newId:d})},oe=t=>{const u=a.filter(b=>b.id!==t);if(!n){F(u,void 0,{type:"remove",controlId:t});return}const d={...n};delete d[t],F(u,d,{type:"remove",controlId:t})},re=C.useCallback(()=>{q.current=void 0,D({step:1,control:s.createBlankControl(r,a,Array.from(V))}),M(null),Y(null)},[a,V,r]),R=t=>{D(u=>u&&(()=>{const d=t(u.control);u.control.source.kind==="manual"&&d.source.kind==="sql_query"&&(q.current=u.defaultValue);const b=u.defaultValue===void 0&&u.control.source.kind==="sql_query"&&d.source.kind==="manual"?q.current:u.defaultValue,j=s.getNextEditedControlDefaultValue({previousControl:u.control,nextControl:d,currentDefaultValue:b});return d.source.kind==="manual"&&(q.current=j),{...u,control:d,defaultValue:j}})())},te=t=>{D(u=>u&&(u.control.source.kind==="manual"&&(q.current=t),{...u,defaultValue:t}))},le=(()=>{if(!l)return!1;if(l.step===2&&_(l.control.type))return(l.selectedCardIds||[]).length>0;if(l.step!==2&&l.step!==3||!l.control.label.trim())return!1;const u=l.control.source.kind==="sql_query"?l.control:s.ensureManualSource(l.control);if(u.source.kind==="manual"&&(s.needsManualOptions(u)&&u.source.options.length===0||u.source.options.some(b=>b.label.trim().length===0||b.value.trim().length===0)))return!1;if(u.source.kind==="sql_query"){const{connectionId:d,sql:b,valueColumn:j}=u.source;return d.trim().length>0&&b.trim().length>0&&j.trim().length>0}return s.hasConcreteDefaultValue(s.getDefaultValueForType(u,l.defaultValue))})(),fe=()=>{var N;if(!l)return;const t=s.ensureManualSource(l.control),u=s.deriveUniqueControlId({label:t.label,fallbackId:t.id,existingControls:a,reservedIds:Array.from(V)}),d={...t,id:u},b=r==="dashboard"&&(d.type==="field_selector"||d.type==="metric_selector")&&((N=l.selectedCardIds)!=null&&N.length)?s.buildStructuralControlBindingsForParticipants({control:d,participants:g||[],selectedCardIds:l.selectedCardIds}):void 0,j=s.getDefaultValueForType(d,l.defaultValue);D({step:r==="dashboard"&&(d.type==="field_selector"||d.type==="metric_selector")?4:3,control:d,defaultValue:j,createdControlId:u,selectedCardIds:l.selectedCardIds,cardBindingsById:b})},ie=C.useCallback(()=>{D(null)},[]),he=C.useCallback(()=>{if(!(l!=null&&l.createdControlId)){D(null);return}const t=l.control,u=l.createdControlId,d=s.getDefaultValueForType(t,l.defaultValue);if(n){const b={...n};d===void 0?delete b[u]:b[u]=d,F([...a,{...t,defaultValue:d}],b,{type:"add",cardBindingsById:l.cardBindingsById})}else F([...a,{...t,defaultValue:d}],void 0,{type:"add",cardBindingsById:l.cardBindingsById});M(u),D(null),E==null||E()},[a,l,n,F,E]),Fe=l?_(l.control.type)?["Choose type","Select cards","Configure","Finish"]:["Choose type","Configure","Finish"]:[],xe=l!=null&&l.createdControlId?`[[param.${l.createdControlId}]]`:l?`[[param.${s.slugifyControlValue(l.control.label)||l.control.id}]]`:"",de=s.buildAuthoringPreviewControlValues({controls:a,defaultValues:n}),ce=l?[...a,l.control]:a,ge=l?s.buildAuthoringPreviewControlValues({controls:ce,defaultValues:n,overrides:[{controlId:l.control.id,value:l.defaultValue}]}):de;return e.jsxs("div",{className:"space-y-4",children:[l?e.jsxs("div",{className:"space-y-4 pb-1",children:[e.jsx(He,{currentStep:l.step,labels:Fe}),l.step===1&&(()=>{const t=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]),u=new Set(["date","text"]),d=K.filter(N=>!t.has(N.value)&&!u.has(N.value)),b=K.filter(N=>t.has(N.value)),j=N=>e.jsxs("button",{type:"button",className:"rounded-control 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:()=>D(We({scope:r,existingControls:a,reservedIds:Array.from(V),type:N.value})),children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:N.label}),e.jsx("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:N.description})]},N.value);return e.jsxs("div",{className:"space-y-4",children:[r==="card"&&(S==null?void 0:S.sql)==null?e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Explorer cards support displayed metric, group by field, aggregation, and time grain controls here."}):null,d.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Input controls"}),e.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:d.map(j)})]}),b.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data-driven controls"}),e.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:b.map(j)})]}),e.jsx(se,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:ie,children:"Back to controls"})})]})})(),l.step===2&&_(l.control.type)&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(De,{control:l.control,onChange:t=>R(u=>({...u,label:t}))}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Choose which cards should respond to this shared control."})]}),z.length===0?e.jsx("div",{className:"rounded-control 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."}):e.jsx("div",{className:"space-y-1 rounded-control border border-border/60 bg-background p-2",children:z.map(t=>{const u=(l.selectedCardIds||[]).includes(t.cardId);return e.jsxs("label",{className:"flex items-start gap-2 rounded-control px-1.5 py-1 text-[13px] hover:bg-muted/40",children:[e.jsx(m.Checkbox,{checked:u,onCheckedChange:d=>D(b=>b&&{...b,selectedCardIds:d===!0?[...b.selectedCardIds||[],t.cardId]:(b.selectedCardIds||[]).filter(j=>j!==t.cardId)})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-foreground",children:t.title}),e.jsx("div",{className:"text-[12px] text-muted-foreground",children:l.control.type==="field_selector"?`${t.fieldChoices.length} compatible group-by fields`:`${t.metricChoices.length} compatible metrics`})]})]},t.cardId)})}),e.jsx(se,{secondary:e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>D(t=>t&&{...t,step:1,selectedCardIds:[]}),children:"Back"}),primary:e.jsx(s.Button,{type:"button",size:"xs",onClick:()=>D(t=>t&&{...t,step:3}),disabled:!le,children:"Next"})})]}),l.step===2&&!_(l.control.type)&&e.jsx(ve,{control:l.control,defaultValue:l.defaultValue,availableFieldChoices:$.fields,availableMetricChoices:$.metrics,previewControlDefinitions:ce,previewControlValues:ge,onControlChange:t=>R(()=>t),onLabelChange:t=>R(u=>({...u,label:t})),onDefaultValueChange:te,onBack:()=>D(t=>t&&{...t,step:1}),onNext:fe,nextDisabled:!le}),l.step===3&&_(l.control.type)&&e.jsx(ve,{control:l.control,defaultValue:l.defaultValue,availableFieldChoices:$.fields,availableMetricChoices:$.metrics,previewControlDefinitions:ce,previewControlValues:ge,onControlChange:t=>R(()=>t),onLabelChange:t=>R(u=>({...u,label:t})),onDefaultValueChange:te,onBack:()=>D(t=>t&&{...t,step:2}),onNext:fe,nextDisabled:!le}),l.step===3&&!_(l.control.type)&&e.jsx(Se,{control:l.control,scope:r,createdReference:xe,explorerContent:e.jsxs(e.Fragment,{children:["Open the card and use"," ",e.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:()=>D(t=>t&&{...t,step:2}),onCancel:ie,onDone:he}),l.step===4&&_(l.control.type)&&e.jsx(Se,{control:l.control,scope:r,createdReference:xe,summaryDetail:e.jsxs(e.Fragment,{children:["Used by ",(l.selectedCardIds||[]).length," selected card",(l.selectedCardIds||[]).length===1?"":"s"]}),explorerContent:e.jsx(e.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:()=>D(t=>t&&{...t,step:3}),onCancel:ie,onDone:he})]}):null,!l&&a.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:c}):null,!l&&a.map(t=>{const u=ne(t),d=h==null?void 0:h[t.id],b=s.resolveAuthoringControlDefaultValue({control:t,defaultValues:n}),j=J===t.id,N="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 e.jsxs("div",{className:"rounded-control border border-border/60",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-start gap-2 rounded-control text-left focus:outline-none focus-visible:bg-muted/40",onClick:()=>M(y=>y===t.id?null:t.id),children:[j?e.jsx(s.ChevronDown,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(m.ChevronRight,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:t.label||"Untitled control"}),e.jsx("span",{className:N,children:s.getFriendlyTypeOption(t.type).label}),e.jsx("span",{className:N,children:s.getPlacementLabel(r,t.placement)})]}),e.jsxs("div",{className:"mt-0.5 text-[12px] text-muted-foreground",children:[s.getControlOptionPreview(t),d!=null&&d.status?` · ${d.status}`:""]})]})]}),e.jsx(s.Button,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 shrink-0 p-0 text-muted-foreground",onClick:()=>oe(t.id),"aria-label":`Remove ${t.label}`,children:e.jsx(m.Trash2,{className:"h-3.5 w-3.5"})})]}),j&&e.jsxs("div",{className:"space-y-4 border-t border-border/60 px-3 py-3",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(s.Input,{size:"xs",value:t.label,placeholder:"Control label",onChange:y=>P(t.id,I=>({...I,label:y.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Type"}),e.jsxs(s.Select,{value:t.type,onValueChange:y=>{const I=s.applyControlTypeChange({controls:a,controlId:t.id,nextType:y,defaultValues:n});F(I.controls,I.defaultValues)},children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:G(t.type).map(y=>e.jsx(s.SelectItem,{value:y.value,children:y.label},y.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Show in"}),e.jsxs(s.Select,{value:t.placement||H,onValueChange:y=>P(t.id,I=>({...I,placement:y})),children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:U.map(y=>e.jsx(s.SelectItem,{value:y.value,children:y.label},y.value))})]})]})]}),_(t.type)?e.jsx(m.StructuralParticipantSelector,{type:t.type,participants:s.getEligibleParticipantsForStructuralControl(g||[],t.type).map(y=>({cardId:y.cardId,title:y.title,choiceCount:t.type==="field_selector"?y.fieldChoices.length:y.metricChoices.length})),selectedCardIds:(x==null?void 0:x[t.id])||[],onChange:y=>{const I=A({control:t,nextSelectedCardIds:y}),O=a.map(L=>L.id===t.id?I.nextControl:L);F(O,n,{type:"update",cardBindingsById:I.cardBindingsById})}}):null,e.jsx(m.ControlDefinitionOptionsEditor,{control:t,availableFieldChoices:u.fields,availableMetricChoices:u.metrics,previewControlDefinitions:a,previewControlValues:de,controlLifecycle:"edit",onChange:y=>P(t.id,()=>y)}),t.initialValueStrategy==="saved_default"&&e.jsx(m.ControlDefaultValueEditor,{control:t,value:b,allowNoDefault:!0,allowCardDefault:!0,previewControlDefinitions:a,previewControlValues:de,onChange:y=>{const I=a.map(O=>O.id===t.id?{...O,defaultValue:y}:O);if(t.source.kind==="manual"&&(T.current[t.id]=y),n){const O={...n};y===void 0?delete O[t.id]:O[t.id]=y,F(I,O);return}F(I,void 0)}}),e.jsxs(m.Collapsible,{open:W===t.id,onOpenChange:y=>Y(y?t.id:null),children:[e.jsx(m.CollapsibleTrigger,{asChild:!0,children:e.jsxs(s.Button,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 gap-1 text-muted-foreground hover:text-foreground",children:[W===t.id?e.jsx(s.ChevronDown,{className:"h-3.5 w-3.5"}):e.jsx(m.ChevronRight,{className:"h-3.5 w-3.5"}),"Advanced"]})}),e.jsxs(m.CollapsibleContent,{className:"space-y-3 pt-2",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Variable name"}),e.jsx(m.ControlIdInput,{controlId:t.id,onCommit:y=>B(t.id,y)},t.id)]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(s.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Initial value"}),e.jsxs(s.Select,{value:t.initialValueStrategy,onValueChange:y=>P(t.id,I=>({...I,initialValueStrategy:y})),children:[e.jsx(s.SelectTrigger,{size:"xs",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:s.INITIAL_VALUE_STRATEGY_OPTIONS.map(y=>e.jsx(s.SelectItem,{value:y.value,children:y.label},y.value))})]})]})]}),e.jsx(m.ControlVisibilitySettings,{control:t,onChange:y=>P(t.id,()=>y)})]})]})]})]},t.id)}),!l&&e.jsxs(s.Button,{type:"button",variant:"outline",size:"xs",onClick:re,children:[e.jsx(m.Plus,{className:"h-3.5 w-3.5"}),"Add control"]})]})}function Xe(r){const{open:a,onOpenChange:o,initialCreateFlowActive:n=!1,dismissMode:i="passive"}=r,c=a!==void 0,[f,h]=C.useState(!1),[p,v]=C.useState(n),g=c?a:f,x=C.useCallback(k=>{!k&&p&&i==="passive"||(c||h(k),k||v(!1),o==null||o(k))},[c,p,i,o]),S=C.useCallback(()=>{c||h(!1),v(!1),o==null||o(!1)},[c,o]);C.useEffect(()=>{g||v(!1)},[g]);const w=C.useCallback(k=>{p&&k.preventDefault()},[p]);return{forceClose:S,handleOpenChange:x,isCreateFlowActive:p,preventPassiveDismissDuringCreate:w,resolvedOpen:g,setIsCreateFlowActive:v}}exports.ControlDefinitionListEditor=Ge;exports.EditorAcceptButton=ze;exports.EditorCancelButton=Pe;exports.EditorClearButton=$e;exports.Library=ke;exports.Link2=Ne;exports.Rows3=Ie;exports.SendHorizontal=Ve;exports.VisualBadge=Oe;exports.VisualSaveAndApplyButton=Qe;exports.VisualSaveButton=Re;exports.flushPendingEditorDrafts=Ee;exports.registerPendingEditorDraftFlusher=Ae;exports.useCreateFlowOverlayState=Xe;exports.useEffectiveEditorCardType=pe;exports.useSyncLegacyEditorState=qe;exports.useVisualUtils=ae;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { c as ge,
|
|
2
|
-
import { useState as K, useEffect as
|
|
3
|
-
import {
|
|
1
|
+
import { c as ge, X as et } from "./x-IdR_js6f.js";
|
|
2
|
+
import { useState as K, useEffect as ie, useCallback as R, useMemo as P, useRef as Se, Fragment as bt } from "react";
|
|
3
|
+
import { G as de, D as Le, u as Z, F as M, a5 as yt, V as vt, W as xt, X as Ct, c as fe, Z as kt, a6 as St, B as q, d as Nt, e as tt, a7 as wt, a8 as Dt, a9 as pe, aa as je, ab as Qe, ac as Ne, ad as we, ae as Et, af as $e, ag as It, ah as Ft, ai as me, aj as Vt, ak as Pe, f as He, al as at, am as rt, an as st, L as oe, _ as nt, $ as De, a0 as Ee, a1 as Ie, a2 as Fe, a3 as Ve, ao as ot, ap as Tt, aq as _t, ar as We, as as Lt, at as Ke, au as At, av as Te } from "./switch-DUdaHFZQ.js";
|
|
4
|
+
import { aC as qt, u as Mt, aD as ce, aE as Ot, aF as Ae, aG as zt, aH as Ut, aI as Rt, p as B, aJ as Bt, aK as jt, aL as lt, aM as Qt, aN as $t, aO as Pt, aP as Ht, aQ as Wt, y as Kt, aR as Yt, aS as it, aT as dt, aU as Gt, aV as Xt, aW as Jt, ay as Ye, aX as Zt, aY as ea, aZ as ct, a_ as ut, a$ as ta, b0 as aa, b1 as ra, b2 as sa, b3 as na, ar as oa, b4 as la, b5 as ia } from "./index-icb12JV1.js";
|
|
4
5
|
import { jsx as a, jsxs as m, Fragment as re } from "react/jsx-runtime";
|
|
5
|
-
import "./index-CuHybtft.js";
|
|
6
6
|
import "./analyze-result-contract-DuhlklhI.js";
|
|
7
|
-
import { S as pt } from "./save-
|
|
7
|
+
import { S as pt } from "./save-16C6YSW2.js";
|
|
8
8
|
/**
|
|
9
9
|
* @license lucide-react v0.453.0 - ISC
|
|
10
10
|
*
|
|
@@ -57,7 +57,7 @@ const Va = ge("SendHorizontal", [
|
|
|
57
57
|
]);
|
|
58
58
|
function ua(t) {
|
|
59
59
|
const [r, n] = K(null), [s, l] = K(null), d = qt();
|
|
60
|
-
return
|
|
60
|
+
return ie(() => {
|
|
61
61
|
if (!t || t.trim() === "") {
|
|
62
62
|
n(null), l(null);
|
|
63
63
|
return;
|
|
@@ -211,7 +211,7 @@ function ga() {
|
|
|
211
211
|
selectedDatabaseName: v,
|
|
212
212
|
selectedTableName: b,
|
|
213
213
|
selectedConnectionId: h
|
|
214
|
-
} = M.getState(), x = l.sql, w = (F = r == null ? void 0 : r.getState()) == null ? void 0 : F.settings, k =
|
|
214
|
+
} = M.getState(), x = l.sql, w = (F = r == null ? void 0 : r.getState()) == null ? void 0 : F.settings, k = yt(l, {
|
|
215
215
|
isDevMode: d,
|
|
216
216
|
cardSql: x,
|
|
217
217
|
isShowingVisual: p,
|
|
@@ -248,14 +248,14 @@ function qe() {
|
|
|
248
248
|
setSelectedDatamodelId: j,
|
|
249
249
|
setFilterValues: G,
|
|
250
250
|
setInlineFilterValuesMap: ee,
|
|
251
|
-
setApplyFilters:
|
|
251
|
+
setApplyFilters: X,
|
|
252
252
|
clearEditorContext: se
|
|
253
|
-
} =
|
|
253
|
+
} = de(), {
|
|
254
254
|
setIsDashboardEditing: O,
|
|
255
255
|
setIsVisualEditing: o,
|
|
256
256
|
setSelectedFrameId: D,
|
|
257
257
|
clearSelectedFrameId: V
|
|
258
|
-
} = Le(), z = Z((_) => _.selectedSheetId), H = Z((_) => _.selectedFrameId),
|
|
258
|
+
} = Le(), z = Z((_) => _.selectedSheetId), H = Z((_) => _.selectedFrameId), J = Z((_) => _.dashboard), te = Z((_) => _.filterValues), L = Z(
|
|
259
259
|
(_) => _.inlineFilterValuesMap
|
|
260
260
|
), Q = Ut((l == null ? void 0 : l.id) || "", {
|
|
261
261
|
enabled: !!(l != null && l.id) && !!(t != null && t.accessToken)
|
|
@@ -285,10 +285,10 @@ function qe() {
|
|
|
285
285
|
setSelectedDatamodelId: j,
|
|
286
286
|
setFilterValues: G,
|
|
287
287
|
setInlineFilterValuesMap: ee,
|
|
288
|
-
setApplyFilters:
|
|
288
|
+
setApplyFilters: X,
|
|
289
289
|
setIsDashboardEditing: O,
|
|
290
290
|
setIsVisualEditing: o,
|
|
291
|
-
dashboard:
|
|
291
|
+
dashboard: J,
|
|
292
292
|
selectedSheetId: z,
|
|
293
293
|
selectedFrameId: H,
|
|
294
294
|
filterValues: te,
|
|
@@ -321,10 +321,10 @@ function qe() {
|
|
|
321
321
|
j,
|
|
322
322
|
G,
|
|
323
323
|
ee,
|
|
324
|
-
|
|
324
|
+
X,
|
|
325
325
|
se,
|
|
326
326
|
V,
|
|
327
|
-
|
|
327
|
+
J,
|
|
328
328
|
z,
|
|
329
329
|
H,
|
|
330
330
|
te,
|
|
@@ -394,8 +394,8 @@ function _a() {
|
|
|
394
394
|
setSelectedSchemaName: s,
|
|
395
395
|
setSelectedTableName: l,
|
|
396
396
|
setSelectedDatamodelId: d
|
|
397
|
-
} =
|
|
398
|
-
|
|
397
|
+
} = de();
|
|
398
|
+
ie(() => {
|
|
399
399
|
var w;
|
|
400
400
|
if (!t) return;
|
|
401
401
|
const { tableName: p, schemaName: f, databaseName: u, connectionId: v } = jt(t), b = (w = t.selectedEntities) == null ? void 0 : w[0], x = (b == null ? void 0 : b.type) === "model" && "id" in b ? b.id : "";
|
|
@@ -496,8 +496,8 @@ function La({
|
|
|
496
496
|
linked: "Linked",
|
|
497
497
|
library: "Library"
|
|
498
498
|
};
|
|
499
|
-
return /* @__PURE__ */ a(
|
|
500
|
-
/* @__PURE__ */ a(
|
|
499
|
+
return /* @__PURE__ */ a(vt, { children: /* @__PURE__ */ m(xt, { delayDuration: 300, children: [
|
|
500
|
+
/* @__PURE__ */ a(Ct, { asChild: !0, children: /* @__PURE__ */ m(
|
|
501
501
|
Yt,
|
|
502
502
|
{
|
|
503
503
|
variant: "outline",
|
|
@@ -513,12 +513,12 @@ function La({
|
|
|
513
513
|
}
|
|
514
514
|
) }),
|
|
515
515
|
/* @__PURE__ */ m(
|
|
516
|
-
|
|
516
|
+
kt,
|
|
517
517
|
{
|
|
518
518
|
side: "bottom",
|
|
519
519
|
className: fe("max-w-xs", h[u]),
|
|
520
520
|
children: [
|
|
521
|
-
/* @__PURE__ */ a(
|
|
521
|
+
/* @__PURE__ */ a(St, { className: x[u] }),
|
|
522
522
|
/* @__PURE__ */ a("p", { children: b[u] })
|
|
523
523
|
]
|
|
524
524
|
}
|
|
@@ -542,7 +542,7 @@ function ba(t, r) {
|
|
|
542
542
|
};
|
|
543
543
|
}
|
|
544
544
|
function Me(t) {
|
|
545
|
-
const r =
|
|
545
|
+
const r = wt(t);
|
|
546
546
|
return r ? (B.error(r), !1) : !0;
|
|
547
547
|
}
|
|
548
548
|
function Aa({
|
|
@@ -562,7 +562,7 @@ function Aa({
|
|
|
562
562
|
size: "xs",
|
|
563
563
|
variant: r,
|
|
564
564
|
children: [
|
|
565
|
-
/* @__PURE__ */ a(
|
|
565
|
+
/* @__PURE__ */ a(Nt, { className: "h-3.5 w-3.5" }),
|
|
566
566
|
"Accept"
|
|
567
567
|
]
|
|
568
568
|
}
|
|
@@ -646,7 +646,7 @@ function Ma({
|
|
|
646
646
|
...N,
|
|
647
647
|
visualId: k
|
|
648
648
|
// Keep the link to library visual
|
|
649
|
-
}, j =
|
|
649
|
+
}, j = Xt(f, F.id), G = await x(F, {
|
|
650
650
|
previousFrame: j
|
|
651
651
|
});
|
|
652
652
|
await h.mutateAsync({
|
|
@@ -682,7 +682,7 @@ function Ma({
|
|
|
682
682
|
);
|
|
683
683
|
}
|
|
684
684
|
function Oa({ className: t }) {
|
|
685
|
-
const { setTempQueryData: r, setSqlGen: n } =
|
|
685
|
+
const { setTempQueryData: r, setSqlGen: n } = de(), s = ce(), l = M((h) => h.tempQueryData), d = M((h) => h.onClose), p = M((h) => h.card), f = ft(), u = P(() => f !== p.type ? { ...p, type: f } : p, [p, f]), { queryKey: v } = it(u);
|
|
686
686
|
function b() {
|
|
687
687
|
if (l) {
|
|
688
688
|
const { queryKey: h, queryData: x } = l;
|
|
@@ -709,7 +709,7 @@ function za({
|
|
|
709
709
|
variant: r = "secondary",
|
|
710
710
|
className: n
|
|
711
711
|
} = {}) {
|
|
712
|
-
const { setTempQueryData: s } =
|
|
712
|
+
const { setTempQueryData: s } = de(), l = ce(), d = M((O) => O.tempQueryData), p = M((O) => O.card), f = ft(), u = P(() => f !== p.type ? { ...p, type: f } : p, [p, f]), { queryKey: v } = it(u), {
|
|
713
713
|
setCardSql: b,
|
|
714
714
|
setSqlGen: h,
|
|
715
715
|
setCardPython: x,
|
|
@@ -720,22 +720,22 @@ function za({
|
|
|
720
720
|
setCardType: j,
|
|
721
721
|
setFrame: G,
|
|
722
722
|
setCard: ee,
|
|
723
|
-
setActiveTabCardId:
|
|
724
|
-
} =
|
|
723
|
+
setActiveTabCardId: X
|
|
724
|
+
} = de();
|
|
725
725
|
function se() {
|
|
726
|
-
var
|
|
726
|
+
var J, te, L, Q;
|
|
727
727
|
const O = l.getQueryData(v);
|
|
728
728
|
d != null && d.queryData || s({
|
|
729
729
|
queryKey: v,
|
|
730
730
|
queryData: O
|
|
731
731
|
}), l.setQueryData(v, null), l.removeQueries({ queryKey: v, exact: !0 }), b(""), h({}), N(), F(void 0), x(""), w(""), k({});
|
|
732
|
-
const o = M.getState().frame, D = M.getState().card, V = lt(o, D), z = ((
|
|
732
|
+
const o = M.getState().frame, D = M.getState().card, V = lt(o, D), z = ((J = V == null ? void 0 : V.customCardPreferences) == null ? void 0 : J.visualType) === "multiple" || !!((te = V == null ? void 0 : V.customCardPreferences) != null && te.dataInputCardIds) || (((L = V == null ? void 0 : V.customCardPreferences) == null ? void 0 : L.minInputs) || 0) > 1 || (((Q = V == null ? void 0 : V.customCardPreferences) == null ? void 0 : Q.maxInputs) || 0) > 1, H = ba(D, z);
|
|
733
733
|
G({
|
|
734
734
|
...o,
|
|
735
735
|
cards: o.cards.map(
|
|
736
736
|
(Y) => Y.id === H.id ? H : Y
|
|
737
737
|
)
|
|
738
|
-
}),
|
|
738
|
+
}), X(H.id), ee(H), z || j("bar");
|
|
739
739
|
}
|
|
740
740
|
return /* @__PURE__ */ m(
|
|
741
741
|
q,
|
|
@@ -770,7 +770,7 @@ function ya(t) {
|
|
|
770
770
|
const { currentStep: r, labels: n } = t;
|
|
771
771
|
return /* @__PURE__ */ a("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: /* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-2 sm:gap-2.5", children: n.map((s, l) => {
|
|
772
772
|
const d = l + 1, p = d === r, f = d < r;
|
|
773
|
-
return /* @__PURE__ */ m(
|
|
773
|
+
return /* @__PURE__ */ m(bt, { children: [
|
|
774
774
|
/* @__PURE__ */ m("div", { className: "flex items-center gap-1.5", children: [
|
|
775
775
|
/* @__PURE__ */ a(
|
|
776
776
|
"span",
|
|
@@ -830,7 +830,7 @@ function va(t) {
|
|
|
830
830
|
] })
|
|
831
831
|
] });
|
|
832
832
|
}
|
|
833
|
-
function
|
|
833
|
+
function Xe(t) {
|
|
834
834
|
const {
|
|
835
835
|
control: r,
|
|
836
836
|
defaultValue: n,
|
|
@@ -896,7 +896,7 @@ const xa = /* @__PURE__ */ new Set([
|
|
|
896
896
|
"field_selector",
|
|
897
897
|
"metric_selector"
|
|
898
898
|
]);
|
|
899
|
-
function
|
|
899
|
+
function Je(t) {
|
|
900
900
|
const { text: r, ariaLabel: n } = t, [s, l] = K(!1);
|
|
901
901
|
return /* @__PURE__ */ m(
|
|
902
902
|
"button",
|
|
@@ -949,14 +949,14 @@ function Ze(t) {
|
|
|
949
949
|
/* @__PURE__ */ m("div", { className: "space-y-1.5 px-3 py-2.5", children: [
|
|
950
950
|
/* @__PURE__ */ a("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "SQL cards" }),
|
|
951
951
|
/* @__PURE__ */ a(
|
|
952
|
-
|
|
952
|
+
Je,
|
|
953
953
|
{
|
|
954
954
|
text: s,
|
|
955
955
|
ariaLabel: "Copy SQL control reference"
|
|
956
956
|
}
|
|
957
957
|
),
|
|
958
958
|
x ? /* @__PURE__ */ a(
|
|
959
|
-
|
|
959
|
+
Je,
|
|
960
960
|
{
|
|
961
961
|
text: x,
|
|
962
962
|
ariaLabel: "Copy Jinja control reference"
|
|
@@ -997,19 +997,19 @@ function Ca(t) {
|
|
|
997
997
|
t.reservedIds
|
|
998
998
|
), n = t.type === r.type ? {
|
|
999
999
|
...r,
|
|
1000
|
-
label:
|
|
1000
|
+
label: Te[t.type]
|
|
1001
1001
|
} : {
|
|
1002
1002
|
...ot({
|
|
1003
1003
|
controls: [
|
|
1004
1004
|
{
|
|
1005
1005
|
...r,
|
|
1006
|
-
label:
|
|
1006
|
+
label: Te[t.type]
|
|
1007
1007
|
}
|
|
1008
1008
|
],
|
|
1009
1009
|
controlId: r.id,
|
|
1010
1010
|
nextType: t.type
|
|
1011
1011
|
}).controls[0],
|
|
1012
|
-
label:
|
|
1012
|
+
label: Te[t.type]
|
|
1013
1013
|
};
|
|
1014
1014
|
return {
|
|
1015
1015
|
step: 2,
|
|
@@ -1038,7 +1038,7 @@ function Ua({
|
|
|
1038
1038
|
const F = P(
|
|
1039
1039
|
() => new Set(n || []),
|
|
1040
1040
|
[n]
|
|
1041
|
-
), j =
|
|
1041
|
+
), j = Tt(t), G = Dt(t), [ee, X] = K(
|
|
1042
1042
|
null
|
|
1043
1043
|
), [se, O] = K(
|
|
1044
1044
|
null
|
|
@@ -1047,7 +1047,7 @@ function Ua({
|
|
|
1047
1047
|
step: 1,
|
|
1048
1048
|
control: pe(t, r, Array.from(F))
|
|
1049
1049
|
} : null
|
|
1050
|
-
), V =
|
|
1050
|
+
), V = Se({}), z = Se(void 0), H = Se(p), J = P(() => {
|
|
1051
1051
|
const e = je({ scope: t, card: x });
|
|
1052
1052
|
if (!w)
|
|
1053
1053
|
return e;
|
|
@@ -1086,7 +1086,7 @@ function Ua({
|
|
|
1086
1086
|
fields: u || [],
|
|
1087
1087
|
metrics: v || []
|
|
1088
1088
|
};
|
|
1089
|
-
const e = o.selectedCardIds || [], c =
|
|
1089
|
+
const e = o.selectedCardIds || [], c = Ne({
|
|
1090
1090
|
controlType: o.control.type,
|
|
1091
1091
|
participants: b || [],
|
|
1092
1092
|
selectedCardIds: e
|
|
@@ -1108,14 +1108,14 @@ function Ua({
|
|
|
1108
1108
|
L,
|
|
1109
1109
|
b
|
|
1110
1110
|
]);
|
|
1111
|
-
|
|
1111
|
+
ie(() => {
|
|
1112
1112
|
k == null || k(!!o);
|
|
1113
|
-
}, [o, k]),
|
|
1113
|
+
}, [o, k]), ie(() => {
|
|
1114
1114
|
const e = p && !H.current;
|
|
1115
1115
|
H.current = p, e && (D({
|
|
1116
1116
|
step: 1,
|
|
1117
1117
|
control: pe(t, r, Array.from(F))
|
|
1118
|
-
}), O(null),
|
|
1118
|
+
}), O(null), X(null));
|
|
1119
1119
|
}, [r, p, F, t]);
|
|
1120
1120
|
const be = (e) => {
|
|
1121
1121
|
if (!L(e.type))
|
|
@@ -1129,7 +1129,7 @@ function Ua({
|
|
|
1129
1129
|
fields: u || [],
|
|
1130
1130
|
metrics: v || []
|
|
1131
1131
|
};
|
|
1132
|
-
const i =
|
|
1132
|
+
const i = Ne({
|
|
1133
1133
|
controlType: e.type,
|
|
1134
1134
|
participants: b || [],
|
|
1135
1135
|
selectedCardIds: c
|
|
@@ -1150,11 +1150,11 @@ function Ua({
|
|
|
1150
1150
|
nextControl: e.control,
|
|
1151
1151
|
cardBindingsById: void 0
|
|
1152
1152
|
};
|
|
1153
|
-
const c = (h == null ? void 0 : h[e.control.id]) || [], i =
|
|
1153
|
+
const c = (h == null ? void 0 : h[e.control.id]) || [], i = Ne({
|
|
1154
1154
|
controlType: e.control.type,
|
|
1155
1155
|
participants: b || [],
|
|
1156
1156
|
selectedCardIds: e.nextSelectedCardIds
|
|
1157
|
-
}), g =
|
|
1157
|
+
}), g = At({
|
|
1158
1158
|
control: e.control,
|
|
1159
1159
|
choices: i.choices
|
|
1160
1160
|
}), C = Object.fromEntries(
|
|
@@ -1173,10 +1173,10 @@ function Ua({
|
|
|
1173
1173
|
};
|
|
1174
1174
|
}, E = R(
|
|
1175
1175
|
(e, c = s, i = { type: "update" }) => {
|
|
1176
|
-
const g = e.map((C) => (
|
|
1176
|
+
const g = e.map((C) => (we({
|
|
1177
1177
|
control: C,
|
|
1178
1178
|
defaultValues: c
|
|
1179
|
-
}),
|
|
1179
|
+
}), Et(
|
|
1180
1180
|
C
|
|
1181
1181
|
)));
|
|
1182
1182
|
l(g, c, i);
|
|
@@ -1210,7 +1210,7 @@ function Ua({
|
|
|
1210
1210
|
);
|
|
1211
1211
|
let U = s;
|
|
1212
1212
|
if (i && I) {
|
|
1213
|
-
const T =
|
|
1213
|
+
const T = we({
|
|
1214
1214
|
control: i,
|
|
1215
1215
|
defaultValues: s
|
|
1216
1216
|
});
|
|
@@ -1266,7 +1266,7 @@ function Ua({
|
|
|
1266
1266
|
z.current = void 0, D({
|
|
1267
1267
|
step: 1,
|
|
1268
1268
|
control: pe(t, r, Array.from(F))
|
|
1269
|
-
}), O(null),
|
|
1269
|
+
}), O(null), X(null);
|
|
1270
1270
|
}, [r, F, t]), $ = (e) => {
|
|
1271
1271
|
D(
|
|
1272
1272
|
(c) => c && (() => {
|
|
@@ -1299,7 +1299,7 @@ function Ua({
|
|
|
1299
1299
|
if (o.step !== 2 && o.step !== 3 || !o.control.label.trim())
|
|
1300
1300
|
return !1;
|
|
1301
1301
|
const c = o.control.source.kind === "sql_query" ? o.control : $e(o.control);
|
|
1302
|
-
if (c.source.kind === "manual" && (
|
|
1302
|
+
if (c.source.kind === "manual" && (It(c) && c.source.options.length === 0 || c.source.options.some(
|
|
1303
1303
|
(g) => g.label.trim().length === 0 || g.value.trim().length === 0
|
|
1304
1304
|
)))
|
|
1305
1305
|
return !1;
|
|
@@ -1307,14 +1307,14 @@ function Ua({
|
|
|
1307
1307
|
const { connectionId: i, sql: g, valueColumn: C } = c.source;
|
|
1308
1308
|
return i.trim().length > 0 && g.trim().length > 0 && C.trim().length > 0;
|
|
1309
1309
|
}
|
|
1310
|
-
return
|
|
1310
|
+
return Ft(
|
|
1311
1311
|
me(c, o.defaultValue)
|
|
1312
1312
|
);
|
|
1313
1313
|
})(), Oe = () => {
|
|
1314
1314
|
var S;
|
|
1315
1315
|
if (!o)
|
|
1316
1316
|
return;
|
|
1317
|
-
const e = $e(o.control), c =
|
|
1317
|
+
const e = $e(o.control), c = Lt({
|
|
1318
1318
|
label: e.label,
|
|
1319
1319
|
fallbackId: e.id,
|
|
1320
1320
|
existingControls: r,
|
|
@@ -1381,7 +1381,7 @@ function Ua({
|
|
|
1381
1381
|
}
|
|
1382
1382
|
);
|
|
1383
1383
|
O(c), D(null), N == null || N();
|
|
1384
|
-
}, [r, o, s, E, N]), gt = o ? L(o.control.type) ? ["Choose type", "Select cards", "Configure", "Finish"] : ["Choose type", "Configure", "Finish"] : [], Ue = o != null && o.createdControlId ? `[[param.${o.createdControlId}]]` : o ? `[[param.${
|
|
1384
|
+
}, [r, o, s, E, N]), gt = o ? L(o.control.type) ? ["Choose type", "Select cards", "Configure", "Finish"] : ["Choose type", "Configure", "Finish"] : [], Ue = o != null && o.createdControlId ? `[[param.${o.createdControlId}]]` : o ? `[[param.${Vt(o.control.label) || o.control.id}]]` : "", Ce = Pe({
|
|
1385
1385
|
controls: r,
|
|
1386
1386
|
defaultValues: s
|
|
1387
1387
|
}), ke = o ? [...r, o.control] : r, Re = o ? Pe({
|
|
@@ -1414,9 +1414,9 @@ function Ua({
|
|
|
1414
1414
|
// keeping the shared definitions for existing controls.
|
|
1415
1415
|
"date",
|
|
1416
1416
|
"text"
|
|
1417
|
-
]), i =
|
|
1417
|
+
]), i = J.filter(
|
|
1418
1418
|
(S) => !e.has(S.value) && !c.has(S.value)
|
|
1419
|
-
), g =
|
|
1419
|
+
), g = J.filter(
|
|
1420
1420
|
(S) => e.has(S.value)
|
|
1421
1421
|
), C = (S) => /* @__PURE__ */ m(
|
|
1422
1422
|
"button",
|
|
@@ -1487,7 +1487,7 @@ function Ua({
|
|
|
1487
1487
|
className: "flex items-start gap-2 rounded-control px-1.5 py-1 text-[13px] hover:bg-muted/40",
|
|
1488
1488
|
children: [
|
|
1489
1489
|
/* @__PURE__ */ a(
|
|
1490
|
-
|
|
1490
|
+
Jt,
|
|
1491
1491
|
{
|
|
1492
1492
|
checked: c,
|
|
1493
1493
|
onCheckedChange: (i) => D(
|
|
@@ -1550,7 +1550,7 @@ function Ua({
|
|
|
1550
1550
|
)
|
|
1551
1551
|
] }),
|
|
1552
1552
|
o.step === 2 && !L(o.control.type) && /* @__PURE__ */ a(
|
|
1553
|
-
|
|
1553
|
+
Xe,
|
|
1554
1554
|
{
|
|
1555
1555
|
control: o.control,
|
|
1556
1556
|
defaultValue: o.defaultValue,
|
|
@@ -1575,7 +1575,7 @@ function Ua({
|
|
|
1575
1575
|
}
|
|
1576
1576
|
),
|
|
1577
1577
|
o.step === 3 && L(o.control.type) && /* @__PURE__ */ a(
|
|
1578
|
-
|
|
1578
|
+
Xe,
|
|
1579
1579
|
{
|
|
1580
1580
|
control: o.control,
|
|
1581
1581
|
defaultValue: o.defaultValue,
|
|
@@ -1650,7 +1650,7 @@ function Ua({
|
|
|
1650
1650
|
] }) : null,
|
|
1651
1651
|
!o && r.length === 0 ? /* @__PURE__ */ a("div", { className: "rounded-md border border-dashed p-3 text-sm text-muted-foreground", children: d }) : null,
|
|
1652
1652
|
!o && r.map((e) => {
|
|
1653
|
-
const c = be(e), i = f == null ? void 0 : f[e.id], g =
|
|
1653
|
+
const c = be(e), i = f == null ? void 0 : f[e.id], g = we({
|
|
1654
1654
|
control: e,
|
|
1655
1655
|
defaultValues: s
|
|
1656
1656
|
}), C = se === e.id, S = "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";
|
|
@@ -1717,7 +1717,7 @@ function Ua({
|
|
|
1717
1717
|
/* @__PURE__ */ m("div", { className: "flex flex-col gap-1.5", children: [
|
|
1718
1718
|
/* @__PURE__ */ a(oe, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Type" }),
|
|
1719
1719
|
/* @__PURE__ */ m(
|
|
1720
|
-
|
|
1720
|
+
De,
|
|
1721
1721
|
{
|
|
1722
1722
|
value: e.type,
|
|
1723
1723
|
onValueChange: (y) => {
|
|
@@ -1730,10 +1730,10 @@ function Ua({
|
|
|
1730
1730
|
E(I.controls, I.defaultValues);
|
|
1731
1731
|
},
|
|
1732
1732
|
children: [
|
|
1733
|
-
/* @__PURE__ */ a(
|
|
1734
|
-
/* @__PURE__ */ a(
|
|
1733
|
+
/* @__PURE__ */ a(Ee, { size: "xs", children: /* @__PURE__ */ a(Ie, {}) }),
|
|
1734
|
+
/* @__PURE__ */ a(Fe, { children: te(e.type).map(
|
|
1735
1735
|
(y) => /* @__PURE__ */ a(
|
|
1736
|
-
|
|
1736
|
+
Ve,
|
|
1737
1737
|
{
|
|
1738
1738
|
value: y.value,
|
|
1739
1739
|
children: y.label
|
|
@@ -1748,7 +1748,7 @@ function Ua({
|
|
|
1748
1748
|
/* @__PURE__ */ m("div", { className: "flex flex-col gap-1.5", children: [
|
|
1749
1749
|
/* @__PURE__ */ a(oe, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Show in" }),
|
|
1750
1750
|
/* @__PURE__ */ m(
|
|
1751
|
-
|
|
1751
|
+
De,
|
|
1752
1752
|
{
|
|
1753
1753
|
value: e.placement || G,
|
|
1754
1754
|
onValueChange: (y) => W(e.id, (I) => ({
|
|
@@ -1756,8 +1756,8 @@ function Ua({
|
|
|
1756
1756
|
placement: y
|
|
1757
1757
|
})),
|
|
1758
1758
|
children: [
|
|
1759
|
-
/* @__PURE__ */ a(
|
|
1760
|
-
/* @__PURE__ */ a(
|
|
1759
|
+
/* @__PURE__ */ a(Ee, { size: "xs", children: /* @__PURE__ */ a(Ie, {}) }),
|
|
1760
|
+
/* @__PURE__ */ a(Fe, { children: j.map((y) => /* @__PURE__ */ a(Ve, { value: y.value, children: y.label }, y.value)) })
|
|
1761
1761
|
]
|
|
1762
1762
|
}
|
|
1763
1763
|
)
|
|
@@ -1828,7 +1828,7 @@ function Ua({
|
|
|
1828
1828
|
ta,
|
|
1829
1829
|
{
|
|
1830
1830
|
open: ee === e.id,
|
|
1831
|
-
onOpenChange: (y) =>
|
|
1831
|
+
onOpenChange: (y) => X(y ? e.id : null),
|
|
1832
1832
|
children: [
|
|
1833
1833
|
/* @__PURE__ */ a(aa, { asChild: !0, children: /* @__PURE__ */ m(
|
|
1834
1834
|
q,
|
|
@@ -1859,7 +1859,7 @@ function Ua({
|
|
|
1859
1859
|
/* @__PURE__ */ m("div", { className: "flex flex-col gap-1.5", children: [
|
|
1860
1860
|
/* @__PURE__ */ a(oe, { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Initial value" }),
|
|
1861
1861
|
/* @__PURE__ */ m(
|
|
1862
|
-
|
|
1862
|
+
De,
|
|
1863
1863
|
{
|
|
1864
1864
|
value: e.initialValueStrategy,
|
|
1865
1865
|
onValueChange: (y) => W(e.id, (I) => ({
|
|
@@ -1867,9 +1867,9 @@ function Ua({
|
|
|
1867
1867
|
initialValueStrategy: y
|
|
1868
1868
|
})),
|
|
1869
1869
|
children: [
|
|
1870
|
-
/* @__PURE__ */ a(
|
|
1871
|
-
/* @__PURE__ */ a(
|
|
1872
|
-
|
|
1870
|
+
/* @__PURE__ */ a(Ee, { size: "xs", children: /* @__PURE__ */ a(Ie, {}) }),
|
|
1871
|
+
/* @__PURE__ */ a(Fe, { children: _t.map((y) => /* @__PURE__ */ a(
|
|
1872
|
+
Ve,
|
|
1873
1873
|
{
|
|
1874
1874
|
value: y.value,
|
|
1875
1875
|
children: y.label
|
|
@@ -1929,7 +1929,7 @@ function Ra(t) {
|
|
|
1929
1929
|
), x = R(() => {
|
|
1930
1930
|
d || f(!1), v(!1), n == null || n(!1);
|
|
1931
1931
|
}, [d, n]);
|
|
1932
|
-
|
|
1932
|
+
ie(() => {
|
|
1933
1933
|
b || v(!1);
|
|
1934
1934
|
}, [b]);
|
|
1935
1935
|
const w = R(
|