react-semaphor 0.0.420 → 0.0.422

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.
@@ -42199,7 +42199,7 @@ function Zse({
42199
42199
  K5,
42200
42200
  {
42201
42201
  className: aa(
42202
- "h-8 w-full rounded-lg border border-border bg-background py-1.5 pl-3 pr-8 text-sm",
42202
+ "h-8 w-full rounded-sm border border-border bg-background py-1.5 pl-3 pr-8 text-sm",
42203
42203
  "data-[focus]:outline-border-none focus:outline-none data-[focus]:outline-none data-[focus]:-outline-offset-2"
42204
42204
  ),
42205
42205
  style: {
@@ -42220,7 +42220,7 @@ function Zse({
42220
42220
  borderRadius: c == null ? void 0 : c.controlInputRadius
42221
42221
  },
42222
42222
  className: aa(
42223
- "mt-1 !max-h-60 w-[var(--input-width)] overflow-y-auto rounded-xl border border-border bg-background p-1 text-sm [--anchor-gap:var(--spacing-1)] empty:invisible",
42223
+ "mt-1 !max-h-60 w-[var(--input-width)] overflow-y-auto rounded-sm border border-border bg-background p-1 text-sm [--anchor-gap:var(--spacing-1)] empty:invisible",
42224
42224
  "transition duration-100 ease-in data-[leave]:data-[closed]:opacity-0"
42225
42225
  ),
42226
42226
  children: [
@@ -42234,9 +42234,9 @@ function Zse({
42234
42234
  borderRadius: c == null ? void 0 : c.controlInputRadius
42235
42235
  },
42236
42236
  value: g,
42237
- className: "group flex cursor-default select-none items-center gap-2 rounded-lg px-3 py-1.5 data-[focus]:bg-muted",
42237
+ className: "group flex cursor-default select-none items-start gap-2 rounded-sm px-3 py-1.5 data-[focus]:bg-muted",
42238
42238
  children: [
42239
- /* @__PURE__ */ y(Rc, { className: "invisible size-4 group-data-[selected]:visible" }),
42239
+ /* @__PURE__ */ y(Rc, { className: "invisible size-4 shrink-0 group-data-[selected]:visible" }),
42240
42240
  /* @__PURE__ */ y("div", { className: "text-sm text-foreground", children: g.value })
42241
42241
  ]
42242
42242
  },
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-ByLlV1KJ.js");exports.Dashboard=e.Dashboard;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-B83SwU1c.js");exports.Dashboard=e.Dashboard;
@@ -1,4 +1,4 @@
1
- import { D as r } from "../chunks/index-COIhzXpT.js";
1
+ import { D as r } from "../chunks/index-CLv0skGQ.js";
2
2
  export {
3
3
  r as Dashboard
4
4
  };
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./chunks/index-ByLlV1KJ.js"),e=require("react/jsx-runtime"),I=require("react");require("react-dom");function Qs(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(a,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return a.default=t,Object.freeze(a)}const de=Qs(I);/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./chunks/index-B83SwU1c.js"),e=require("react/jsx-runtime"),I=require("react");require("react-dom");function Qs(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(a,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return a.default=t,Object.freeze(a)}const de=Qs(I);/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -339,4 +339,4 @@
339
339
  ${d}
340
340
 
341
341
  `;v(j)}function U(){return e.jsxs(e.Fragment,{children:[r&&e.jsx("div",{className:"relative flex w-1/3 min-w-0 grow overflow-hidden text-xs",role:"editor-filter-container",children:e.jsx("div",{className:"mt-2 w-[99%]",children:e.jsx(cn,{jsonString:JSON.stringify(m,null,2)})})}),m&&m.length>0&&e.jsx(s.Button,{variant:"ghost",onClick:()=>o(!r),className:"absolute bottom-0 right-6 size-7 p-1",children:r?e.jsx(s.X,{className:"size-3.5 text-muted-foreground"}):e.jsx(ds,{className:"size-3.5 text-muted-foreground"})})]})}function V(){return e.jsxs(s.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxs(s.ResizablePanel,{id:"1",order:1,defaultSize:a?20:100,className:"relative flex grow",children:[e.jsx("div",{id:"sql-container",className:"relative flex w-[99%]",children:e.jsx(on,{})}),a&&e.jsx("code",{className:"absolute right-6 top-3 text-xs text-muted-foreground/70",children:"sql"})]}),a&&e.jsxs(e.Fragment,{children:[e.jsx(s.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxs(s.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsx("div",{id:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsx(ln,{})}),e.jsx("code",{className:"absolute right-6 top-3 text-xs text-muted-foreground/70",children:"python"})]})]})]})}function w(){return e.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxs(s.Button,{title:"Shift + Enter",disabled:B||R,onClick:()=>{O()},className:"shrink-0",size:"sm",children:[B||R?e.jsx(re,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(s.Play,{className:"mr-2 h-4 w-4"}),"Run"]}),e.jsx(ks,{sql:A==null?void 0:A.sql,error:S,onClick:P}),e.jsx(Ls,{}),e.jsx(s.Toggle,{pressed:a,onPressedChange:j=>n(j),className:"",size:"sm",children:e.jsx(rn,{className:"size-4 text-foreground/70"})}),e.jsx("button",{disabled:i,onClick:()=>{q(),M(!0)},className:"h-9 w-full cursor-text px-3 text-left text-sm text-muted-foreground",children:i?"":"Type your question..."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ms,{}),e.jsx(As,{})]})]})}return e.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxs("div",{className:"relative flex grow justify-between overflow-y-scroll",children:[V(),U()]}),w()]})}function hn({data:t}){var i;const[a,n]=I.useState([]),o=Object.keys(t[0]).map(d=>({accessorKey:d,header:({column:m})=>{const p=m.getIsSorted();return e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>m.toggleSorting(m.getIsSorted()==="asc"),children:[d,p==="asc"?e.jsx(s.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):p==="desc"?e.jsx(s.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),l=s.useReactTable({data:t,columns:o,getCoreRowModel:s.getCoreRowModel(),getPaginationRowModel:s.getPaginationRowModel(),onSortingChange:n,getSortedRowModel:s.getSortedRowModel(),manualPagination:!0,state:{sorting:a}});return e.jsx(s.CustomScrollArea,{className:"grow overflow-auto font-mono text-xs text-foreground/95",children:e.jsxs("table",{className:"w-full",children:[e.jsx(s.TableHeader,{className:"sticky top-0 z-50 h-0 bg-muted",children:l.getHeaderGroups().map(d=>e.jsx(s.TableRow,{className:"",children:d.headers.map(m=>e.jsx(s.TableHead,{className:"h-11 font-semibold text-foreground",children:m.isPlaceholder?null:s.flexRender(m.column.columnDef.header,m.getContext())},m.id))},d.id))}),e.jsx(s.TableBody,{children:(i=l.getRowModel().rows)!=null&&i.length?l.getRowModel().rows.map(d=>e.jsx(s.TableRow,{className:"h-11 whitespace-nowrap py-2","data-state":d.getIsSelected()&&"selected",children:d.getVisibleCells().map(m=>e.jsx(s.TableCell,{className:"py-2",children:s.flexRender(m.column.columnDef.cell,m.getContext())},m.id))},d.id)):e.jsx(s.TableRow,{children:e.jsx(s.TableCell,{colSpan:o.length,className:"h-24 text-center",children:"No results."})})})]})})}function pn({card:t}){var M,D,L,k,A,B,R,G,g,N,T;const[a,n]=I.useState(!1),[r,o]=I.useState([]),{authToken:l}=s.useSemaphorContext(),i=s.getTokenParams(l==null?void 0:l.accessToken),d=s.useDashboardStore(O=>O.themeStyle),m={colors:((D=(M=d==null?void 0:d.chart)==null?void 0:M.dataset)==null?void 0:D.backgroundColor)||[]};(L=t.customCardPreferences)!=null&&L.inputData;const{getCard:p}=s.useCustomVisual(((k=t.customCardPreferences)==null?void 0:k.url)||""),u=((A=t.customCardPreferences)==null?void 0:A.visualType)||"single",x=s.useEditorStore(O=>O.frame),{setCustomCardPreferences:f}=s.useEditorActions(),{data:c}=s.useDashboardCardQuery(t),y=I.useCallback((O,S)=>{o(q=>({...q,[O]:S}))},[]);if(!((B=t.customCardPreferences)!=null&&B.componentName))return null;const h=p((R=t.customCardPreferences)==null?void 0:R.componentName);function C(O){n(O)}const v=Object.keys(((G=t.customCardPreferences)==null?void 0:G.dataInputCardIds)||{}).map(O=>{var P,U,V;const S=(U=(P=t.customCardPreferences)==null?void 0:P.dataInputCardIds)==null?void 0:U[O].cardId,q=(V=x==null?void 0:x.cards)==null?void 0:V.find(w=>w.id===S);return q||null});return e.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:e.jsxs(I.Suspense,{fallback:e.jsx(e.Fragment,{}),children:[h&&u==="single"&&e.jsx(h,{params:i,theme:m,settings:(g=t.customCardPreferences)==null?void 0:g.settings,onDataChange:y,data:(c==null?void 0:c.records)||[]}),h&&u==="multiple"&&e.jsxs(e.Fragment,{children:[Object.keys(((N=t.customCardPreferences)==null?void 0:N.dataInputCardIds)||{}).map(O=>{var P,U,V;const S=(U=(P=t.customCardPreferences)==null?void 0:P.dataInputCardIds)==null?void 0:U[O].cardId,q=(V=x==null?void 0:x.cards)==null?void 0:V.find(w=>w.id===S);if(q)return e.jsx(s.MultiInputEmptyRenderer,{onLoadingStatus:C,onDataChange:y,dataInputIndex:O,card:q},q.id+O)}),e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(h,{theme:m,onDataChange:y,settings:v.map(O=>{var S;return(S=O==null?void 0:O.customCardPreferences)==null?void 0:S.settings}),data:v.map(O=>O!=null&&O.id?r==null?void 0:r[O.id]:[])})})]})]},(T=t.customCardPreferences)==null?void 0:T.componentName)})}function Os({className:t,...a}){var C;const n=s.useEditorStore(v=>v.card),r=((C=n.customCardPreferences)==null?void 0:C.showCardHeader)??!0,o=s.useEditorStore(v=>v.frame),l=s.useDashboardStore(v=>v.dashboard.filters);s.useEditorStore(v=>v.actions.setRunSql);const{updateFilter:i}=s.useDashboardActions(),d=l==null?void 0:l.find(v=>v.id===o.filterId),{data:m,isLoading:p,isFetching:u}=s.useDashboardCardQuery(n),{setCard:x}=s.useEditorActions(),{data:f}=s.useTopoJson(n),c=I.useMemo(()=>!n.id||!(m!=null&&m.records)?null:s.createChartConfig({data:m==null?void 0:m.records,cardType:n.type,customCfg:n.customCfg,preferences:n.preferences,topoJson:f}),[n.id,m==null?void 0:m.records,n.type,n.customCfg,n.preferences,f]);function y(v){return e.jsx(pn,{card:v})}function h(){if(m!=null&&m.records&&(m==null?void 0:m.records.length)===0&&!p&&!u)return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[e.jsx(s.TreePalm,{className:"size-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No records to display"})]});if(!n.id)return null;if(n.type==="custom")return y(n);if(!["table","custom"].includes(n.type)&&c)return e.jsx(e.Fragment,{children:p||u?e.jsx(e.Fragment,{}):e.jsx(s.ChartJsVisual,{cfg:c})});if(n.type==="table"&&(m!=null&&m.records)&&(m==null?void 0:m.records.length)>0)return e.jsxs(s.ScrollArea,{className:"relative mb-2 flex h-full min-h-0 w-full flex-1 grow basis-0",children:[e.jsx(s.TableVisual,{card:n,data:m==null?void 0:m.records}),e.jsx(s.ScrollBar,{orientation:"horizontal"})]})}return e.jsxs(s.Card,{role:"editor-visual-card",className:s.cn("relative flex h-full flex-col rounded-none",t),...a,children:[r&&e.jsxs(s.CardHeader,{className:"flex flex-row items-start justify-between py-4",children:[e.jsxs("div",{children:[e.jsx(s.Editable,{text:n.title,onSave:v=>x({...n,title:v}),children:e.jsx("div",{className:"flex items-center gap-5",children:e.jsx(s.CardTitle,{className:"text-base",children:n.title||"Edit title..."})})},n.title),e.jsx(s.Editable,{text:n.description||"",onSave:v=>x({...n,description:v}),children:e.jsx(s.CardDescription,{children:n.description||"Edit description..."})},n.description)]}),d&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(s.Editable,{className:"my-1",text:d.title||d.column,onSave:v=>i({...d,title:v}),children:e.jsx(s.Label,{children:d.title})}),e.jsx(s.FilterComponent,{filter:d})]})]}),e.jsx(s.CardContent,{className:"flex grow flex-col",children:h()})]})}const we=({language:t,value:a,onChange:n,readonly:r})=>e.jsx(s.Ft,{className:"h-full w-full overflow-hidden text-xs",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,lineHeight:16,renderLineHighlight:"none",readOnly:r},defaultLanguage:t,value:a,onChange:n}),xn=()=>e.jsxs(s.DialogHeader,{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(s.DialogTitle,{children:"Customize Card"})}),e.jsxs(s.DialogDescription,{children:["See the configuration options and documentation",e.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),fn=({customCode:t,cardCustomCfgString:a,mergedConfig:n,onConfigChange:r,onCodeChange:o})=>e.jsxs(s.Tabs,{defaultValue:"final-config",className:"flex w-1/2 flex-col",children:[e.jsxs(s.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsx(s.TabsTrigger,{value:"final-config",children:"Config"}),e.jsx(s.TabsTrigger,{value:"custom-config",children:"Changes"}),e.jsx(s.TabsTrigger,{value:"custom-code",children:"Custom Code"})]}),e.jsx(s.TabsContent,{value:"final-config",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(we,{language:"json",value:n,onChange:r})}),e.jsx(s.TabsContent,{value:"custom-config",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(we,{readonly:!0,language:"json",value:a,onChange:()=>{}})}),e.jsx(s.TabsContent,{value:"custom-code",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(we,{language:"javascript",value:t,onChange:o})})]}),gn=({error:t,hasCardCustomConfig:a,onReset:n,onApply:r,onClose:o})=>e.jsxs(s.DialogFooter,{className:"flex items-center",children:[e.jsx(s.Label,{className:"mr-2 text-red-500",children:t}),e.jsx(s.Button,{disabled:!a,onClick:n,variant:"outline",children:"Reset"}),e.jsx(s.Button,{onClick:r,variant:"outline",children:"Apply"}),e.jsx(s.Button,{onClick:o,variant:"outline",children:"Close"})]});function jn(){const[t,a]=I.useState(!1),[n,r]=I.useState(""),[o,l]=I.useState(""),[i,d]=I.useState(""),[m,p]=I.useState(""),u=s.useEditorStore(k=>k.card),x=s.useEditorStore(k=>k.card.customCfg),f=x?JSON.stringify(x,null,2):"",{data:c}=s.useDashboardCardQuery(u),{data:y}=s.useTopoJson(u),{setCardCustomCfg:h,setCustomVisualCode:C}=s.useEditorActions(),v=k=>{var A,B;return JSON.stringify({...k,data:{...k.data,datasets:(B=(A=k.data)==null?void 0:A.datasets)==null?void 0:B.map(R=>({...R,data:[]}))}},null,2)},M=()=>{var A,B;if(!((A=c==null?void 0:c.records)!=null&&A.length))return;const k=s.createChartConfig({data:c.records,cardType:u.type,preferences:u.preferences,topoJson:y});if(k){r(v(k)),d(((B=u.preferences)==null?void 0:B.customVisualCode)||"");const R=s.merge(k,x);l(v(R))}},D=()=>{try{if(i&&C(i),o){const k=JSON.parse(o),A=s.getObjectDiff(JSON.parse(n),k);h(A),p("")}}catch{p("Invalid JSON configuration")}},L=Object.keys(x||{}).length===0;return e.jsxs(s.Dialog,{open:t,onOpenChange:a,children:[e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"Customize Visual",onClick:M,className:L?"":"text-green-600 hover:text-green-700",children:e.jsx(s.Settings,{className:"h-4 w-4"})})}),e.jsxs(s.DialogContent,{className:"flex h-[600px] grow flex-col overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsx(xn,{}),e.jsxs("div",{className:"flex grow gap-2",children:[e.jsx(s.ErrorBoundary,{FallbackComponent:s.FallbackEditorCard,children:e.jsx(Os,{className:"w-1/2 rounded shadow-none"})}),e.jsx(fn,{customCode:i,cardCustomCfgString:f,mergedConfig:o,onConfigChange:k=>l(k??""),onCodeChange:k=>d(k??"")})]}),e.jsx(gn,{error:m,hasCardCustomConfig:!!x,onReset:()=>{l(n),h(null)},onApply:D,onClose:()=>a(!1)})]})]})}function zs(t){return ue({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm87.63,96H191.48A64.1,64.1,0,0,0,136,64.52V40.37A88.13,88.13,0,0,1,215.63,120ZM120,120H80.68A48.09,48.09,0,0,1,120,80.68Zm0,16v39.32A48.09,48.09,0,0,1,80.68,136Zm16,0h39.32A48.09,48.09,0,0,1,136,175.32Zm0-16V80.68A48.09,48.09,0,0,1,175.32,120ZM120,40.37V64.52A64.1,64.1,0,0,0,64.52,120H40.37A88.13,88.13,0,0,1,120,40.37ZM40.37,136H64.52A64.1,64.1,0,0,0,120,191.48v24.15A88.13,88.13,0,0,1,40.37,136ZM136,215.63V191.48A64.1,64.1,0,0,0,191.48,136h24.15A88.13,88.13,0,0,1,136,215.63Z"},child:[]}]})(t)}function yn(t){return ue({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M48,180c0,11,7.18,20,16,20a14.24,14.24,0,0,0,10.22-4.66A8,8,0,0,1,85.78,206.4,30.06,30.06,0,0,1,64,216c-17.65,0-32-16.15-32-36s14.35-36,32-36a30.06,30.06,0,0,1,21.78,9.6,8,8,0,0,1-11.56,11.06A14.24,14.24,0,0,0,64,160C55.18,160,48,169,48,180Zm79.6-8.69c-4-1.16-8.14-2.35-10.45-3.84-1.25-.81-1.23-1-1.12-1.9a4.57,4.57,0,0,1,2-3.67c4.6-3.12,15.34-1.73,19.82-.56A8,8,0,0,0,142,145.86c-2.12-.55-21-5.22-32.84,2.76a20.58,20.58,0,0,0-9,14.95c-2,15.88,13.65,20.41,23,23.11,12.06,3.49,13.12,4.92,12.78,7.59-.31,2.41-1.26,3.34-2.14,3.93-4.6,3.06-15.17,1.56-19.55.36A8,8,0,0,0,109.94,214a61.34,61.34,0,0,0,15.19,2c5.82,0,12.3-1,17.49-4.46a20.82,20.82,0,0,0,9.19-15.23C154,179,137.49,174.17,127.6,171.31Zm83.09-26.84a8,8,0,0,0-10.23,4.84L188,184.21l-12.47-34.9a8,8,0,0,0-15.07,5.38l20,56a8,8,0,0,0,15.07,0l20-56A8,8,0,0,0,210.69,144.47ZM216,88v24a8,8,0,0,1-16,0V96H152a8,8,0,0,1-8-8V40H56v72a8,8,0,0,1-16,0V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88Zm-27.31-8L160,51.31V80Z"},child:[]}]})(t)}function Fs(t){return ue({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0"},child:[]}]})(t)}function Rs(t){return ue({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m2 19.99 7.5-7.51 4 4 7.09-7.97L22 9.92l-8.5 9.56-4-4-6 6.01-1.5-1.5zm1.5-4.5 6-6.01 4 4L22 3.92l-1.41-1.41-7.09 7.97-4-4L2 13.99l1.5 1.5z"},child:[]}]})(t)}function _s(t){return ue({attr:{version:"1.2",baseProfile:"tiny",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M4 18c-.552 0-1-.448-1-1v-6.382l-.553.276c-.495.248-1.095.046-1.342-.447-.247-.494-.046-1.094.448-1.342l2-1c.31-.155.678-.139.973.044.294.183.474.504.474.851v8c0 .552-.448 1-1 1zM13 18h-5c-.404 0-.769-.244-.924-.617-.155-.374-.069-.804.217-1.09l4-4c.254-.254.394-.591.394-.95 0-.358-.14-.695-.394-.949-.508-.508-1.39-.508-1.9.001-.253.252-.393.589-.393.948 0 .552-.448 1-1 1s-1-.448-1-1c0-.894.348-1.733.98-2.364 1.265-1.263 3.464-1.263 4.727.001.632.631.979 1.471.979 2.363 0 .893-.348 1.733-.979 2.364l-2.293 2.293h2.586c.552 0 1 .448 1 1s-.448 1-1 1zM20.955 12.377c.338-.457.545-1.016.545-1.627 0-1.517-1.234-2.75-2.75-2.75-1.031 0-1.966.569-2.44 1.484-.254.49-.063 1.094.428 1.348.49.254 1.094.062 1.348-.428.128-.249.383-.404.664-.404.414 0 .75.336.75.75s-.336.75-.75.75c-.552 0-1 .448-1 1s.448 1 1 1c.689 0 1.25.561 1.25 1.25s-.561 1.25-1.25 1.25-1.25-.561-1.25-1.25c0-.552-.448-1-1-1s-1 .448-1 1c0 1.792 1.458 3.25 3.25 3.25s3.25-1.458 3.25-3.25c0-.939-.406-1.779-1.045-2.373z"},child:[]}]})(t)}function Bs(t){const[a,n]=I.useState(null);return a}function Vs(){const{authToken:t}=s.useSemaphorContext(),{data:a,isLoading:n,isFetching:r,isError:o}=s.useQuery({queryKey:["plugins",t==null?void 0:t.accessToken],queryFn:()=>s.getPlugins(t==null?void 0:t.accessToken)});return{data:a,isLoading:n,isFetching:r,isError:o}}function bn({onChartTypeChange:t}){const[a,n]=I.useState([]),{data:r}=Vs();return I.useEffect(()=>{(async()=>{var l;if(r){const d=(await Promise.all((l=r==null?void 0:r.plugins)==null?void 0:l.map(async m=>(await s.loadManifest(m.value)).visuals.map(x=>({name:x.name,icon:x.icon,url:m.value}))))).flat();n(d)}})()},[r]),a.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx(s.Separator,{className:"my-2"}),e.jsx("div",{className:"grid grid-cols-4 place-items-center",children:a.map((o,l)=>e.jsx(Sn,{text:o.name,onClick:()=>t("custom",o),icon:o.icon},o.url+o.name+l))})]})}const Sn=({text:t,icon:a,onClick:n})=>{const r=Bs(),o=t.charAt(0).toUpperCase();return e.jsx(s.IconButton,{onClick:n,tooltip:t,children:r?e.jsx(r,{className:"h-4 w-4"}):o})};function Cn(){var x,f;const[t,a]=I.useState(!1),n=s.useEditorStore(c=>c.card),r=n.type,o=s.useDashboardStore(c=>c.isVisualEditing),{setCardType:l,setCardPreferences:i,setChartOrientation:d}=s.useEditorStore(c=>c.actions),{setCardCustomCfg:m,setCustomCardPreferences:p}=s.useEditorActions();function u(c,y){m(null),i({}),l(c),y&&p({type:"component",visualType:"single",url:y.url,componentName:y.name,icon:y.icon}),a(!1)}return e.jsxs(s.Popover,{open:t,onOpenChange:a,children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsx(s.Button,{size:"sm",variant:o?"ghost":"outline",children:e.jsx(vn,{className:"size-4",chartType:r,customIcon:(x=n.customCardPreferences)==null?void 0:x.icon,componentName:(f=n.customCardPreferences)==null?void 0:f.componentName})})}),e.jsxs(s.PopoverContentCustom,{onOpenAutoFocus:c=>c.preventDefault(),className:"w-50",children:[e.jsxs("div",{className:"grid grid-cols-4 place-items-center",children:[e.jsx(s.IconButton,{tooltip:"Bar Chart",onClick:()=>u("bar"),className:"h-10 p-4",children:e.jsx(Be,{className:"size-5"})}),e.jsx(s.IconButton,{tooltip:"Line Chart",onClick:()=>u("line"),className:"h-10 p-4",children:e.jsx(Ve,{className:"size-5"})}),e.jsx(s.IconButton,{tooltip:"Stacked Bar Chart",onClick:()=>u("stackedBar"),className:"h-10 p-4",children:e.jsx(ns,{className:"size-5"})}),e.jsx(s.IconButton,{tooltip:"Stacked Line Chart",onClick:()=>u("stackedLine"),className:"h-10 p-4",children:e.jsx(Rs,{className:"size-5",strokeWidth:0})}),e.jsx(s.IconButton,{tooltip:"Scatter Chart",onClick:()=>u("scatter"),className:"h-10 p-4",children:e.jsx(os,{className:"size-5"})}),e.jsx(s.IconButton,{tooltip:"Bubble Chart",onClick:()=>u("bubble"),className:"h-10 p-4",children:e.jsx(Fs,{className:"size-5"})}),e.jsx(s.IconButton,{tooltip:"Pie Chart",onClick:()=>u("pie"),className:"h-10 p-4",children:e.jsx(rs,{className:"size-5"})}),e.jsx(s.IconButton,{tooltip:"Doughnut Chart",onClick:()=>u("doughnut"),className:"h-10 p-4",children:e.jsx(ls,{className:"size-5"})}),e.jsx(s.IconButton,{tooltip:"Radar Chart",onClick:()=>u("radar"),className:"h-10 p-4",children:e.jsx(hs,{className:"size-5"})}),e.jsx(s.IconButton,{tooltip:"Polar Area Chart",onClick:()=>u("polarArea"),className:"h-10 p-4",children:e.jsx(zs,{className:"size-6"})}),e.jsx(s.IconButton,{tooltip:"Pyramid Chart",onClick:()=>u("pyramid"),className:"h-10 p-4",children:e.jsx(gs,{className:"size-5"})}),e.jsx(s.IconButton,{tooltip:"Range Chart",onClick:()=>u("range"),className:"h-10 p-4",children:e.jsx(as,{className:"size-5"})}),e.jsx(s.IconButton,{tooltip:"Table",onClick:()=>u("table"),className:"h-10 p-4",children:e.jsx(qe,{className:"size-5"})}),e.jsx(s.IconButton,{tooltip:"KPI",onClick:()=>u("kpi"),className:"h-10 p-4",children:e.jsx(_s,{className:"size-6"})}),e.jsx(s.IconButton,{tooltip:"Text",onClick:()=>u("text"),className:"h-10 p-4",children:e.jsx(tt,{className:"size-5"})}),e.jsx(s.IconButton,{tooltip:"Map",onClick:()=>u("map"),className:"h-10 p-4",children:e.jsx(ms,{className:"size-5"})}),e.jsx(s.IconButton,{tooltip:"Custom",onClick:()=>u("custom"),className:"h-10 p-4",children:e.jsx(xs,{className:"size-5"})})]}),e.jsx(bn,{onChartTypeChange:u})]})]})}function vn({chartType:t,className:a,customIcon:n,componentName:r}){const o=Bs();switch(t){case"bar":return e.jsx(Be,{className:a});case"line":return e.jsx(Ve,{className:a});case"pie":return e.jsx(rs,{className:a});case"radar":return e.jsx(hs,{className:a});case"scatter":return e.jsx(os,{className:a});case"bubble":return e.jsx(Fs,{className:a});case"doughnut":return e.jsx(ls,{className:a});case"stackedBar":return e.jsx(ns,{className:a});case"stackedLine":return e.jsx(Rs,{className:a});case"polarArea":return e.jsx(zs,{className:a});case"pyramid":return e.jsx(gs,{className:a});case"range":return e.jsx(as,{className:a});case"kpi":return e.jsx(_s,{className:a});case"text":return e.jsx(js,{className:a});case"map":return e.jsx(ms,{className:a});case"custom":return n&&o?e.jsx(o,{className:a}):r?r==null?void 0:r.charAt(0).toUpperCase():e.jsx(xs,{className:a});default:return e.jsx(qe,{className:a})}}const pe="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function es(t,a){var r,o,l;const n=s.getNumberAxis(t,a);return((l=(o=(r=t==null?void 0:t.chartOptions)==null?void 0:r.scales)==null?void 0:o[n])==null?void 0:l.type)||"linear"}function Nn(){var q,P,U,V,w,j;const[t,a]=I.useState(!1),n=s.useEditorStore(E=>{var b;return(b=E.card)==null?void 0:b.preferences}),r=s.getNumberAxis(n,{}),[o,l]=I.useState(es(n)),[i,d]=I.useState(((U=(P=(q=n==null?void 0:n.chartOptions)==null?void 0:q.scales)==null?void 0:P[r])==null?void 0:U.min)||""),[m,p]=I.useState(((j=(w=(V=n==null?void 0:n.chartOptions)==null?void 0:V.scales)==null?void 0:w[r])==null?void 0:j.max)||""),[u,x]=I.useState(i||m?"custom":"auto"),[f,c]=I.useState(""),[y,h]=I.useState(0),[C,v]=I.useState(""),[M,D]=I.useState(""),[L,k]=I.useState(""),A=s.useEditorStore(E=>E.actions.setCardPreferences),{updateCardInFrame:B}=s.useEditorActions(),R=s.useEditorStore(E=>E.card),G=s.useEditorStore(E=>{var b;return(b=E.card)==null?void 0:b.type}),g=["pie","doughnut","polarArea"].includes(G);I.useEffect(()=>{var E,b,H,_,J,W,Z,ee,se,F,$,K,te,ie;l(es(n)),d(((H=(b=(E=n==null?void 0:n.chartOptions)==null?void 0:E.scales)==null?void 0:b[r])==null?void 0:H.min)===0?0:""),p(((W=(J=(_=n==null?void 0:n.chartOptions)==null?void 0:_.scales)==null?void 0:J[r])==null?void 0:W.max)||""),c(((F=(se=(ee=(Z=n==null?void 0:n.chartOptions)==null?void 0:Z.scales)==null?void 0:ee[r])==null?void 0:se.ticks)==null?void 0:F.stepSize)||""),h((($=n==null?void 0:n.numberAxisFormat)==null?void 0:$.decimalPlaces)||0),v(((K=n==null?void 0:n.numberAxisFormat)==null?void 0:K.suffix)||""),D(((te=n==null?void 0:n.numberAxisFormat)==null?void 0:te.currency)||""),k(((ie=n==null?void 0:n.numberAxisFormat)==null?void 0:ie.locale)||"")},[t,n,r]);function N(E,b){return b===""||/^[0-9\b]+$/.test(b)?Number(b):Number(E)}function T(){const E=[...new Set(s.LOCALE_CURRENCY_PAIRS.map(b=>b.currency))];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsx(s.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxs(s.Select,{value:M||"none",onValueChange:b=>D(b==="none"?"":b),children:[e.jsx(s.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Currency"}),e.jsx(s.SelectItem,{value:"none",children:"None"}),E.map(b=>e.jsx(s.SelectItem,{value:b,children:b},b))]})})]}),e.jsxs(s.Select,{value:L,onValueChange:b=>k(b),children:[e.jsx(s.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Locale"}),s.LOCALE_CURRENCY_PAIRS.map(b=>e.jsx(s.SelectItem,{value:b.locale,children:b.locale},b.locale))]})})]})]}),e.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsx(s.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsx(s.Input,{value:y,onChange:b=>h(Number(b.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${pe}`})]})]})}function O(){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsx(s.Label,{htmlFor:"range",children:"Range"}),e.jsx(s.Input,{id:"min",value:i,onChange:E=>d(b=>N(b,E.target.value)),className:`col-span-1 h-8 w-full ${pe}`}),e.jsx(s.Input,{value:m,onChange:E=>p(b=>N(b,E.target.value)),id:"max",className:`col-span-1 h-8 w-full ${pe}`})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsx(s.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsx(s.Input,{value:f,onChange:E=>c(b=>N(b,E.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${pe}`})]})]})}function S(){var _;let E={};u==="custom"&&(E={min:i,max:m,ticks:{stepSize:f}});const b={...n||{},chartOptions:{...n==null?void 0:n.chartOptions,scales:{...(_=n==null?void 0:n.chartOptions)==null?void 0:_.scales,[r]:{type:o,...o==="linear"?E:{}}}},numberAxisFormat:{decimalPlaces:y,suffix:C,currency:M,locale:L}};console.log(b),A(b);const H={...R,preferences:b};B(H)}return e.jsxs(s.Popover,{onOpenChange:E=>a(E),children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"Scale Options",children:e.jsx(Mt,{className:"size-4 rotate-45"})})}),e.jsx(s.PopoverContentCustom,{align:"center",className:"max-w-65",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsx(s.Label,{htmlFor:"scale",children:"Type"}),e.jsxs(s.Select,{disabled:g,value:o,onValueChange:E=>l(E),children:[e.jsx(s.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{id:"type",children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Option"}),e.jsx(s.SelectItem,{value:"linear",children:"Linear"}),e.jsx(s.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),o=="linear"&&e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsx(s.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxs(s.RadioGroup,{disabled:g,id:"scale-option",value:u,onValueChange:E=>x(E),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"auto",id:"r1"}),e.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"custom",id:"r2"}),e.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),u==="custom"&&o=="linear"&&O(),T(),e.jsx(s.SelectSeparator,{}),e.jsx("div",{className:"grid grid-cols-3",children:e.jsx(s.Button,{onClick:S,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function wn(){const t=s.useEditorStore(d=>{var m,p,u,x;return(x=(u=(p=(m=d.card.preferences)==null?void 0:m.chartOptions)==null?void 0:p.plugins)==null?void 0:u.legend)==null?void 0:x.position}),a=s.useEditorStore(d=>{var m,p,u,x;return(x=(u=(p=(m=d.card.preferences)==null?void 0:m.chartOptions)==null?void 0:p.plugins)==null?void 0:u.legend)==null?void 0:x.align}),n=s.useEditorStore(d=>{var m,p,u,x;return(x=(u=(p=(m=d.card.preferences)==null?void 0:m.chartOptions)==null?void 0:p.plugins)==null?void 0:u.legend)==null?void 0:x.display}),{setLegendOptions:r}=s.useEditorActions(),o=d=>{r({display:d,position:t,align:a})},l=d=>{r({display:n,position:d,align:a})},i=d=>{r({display:n,position:t,align:d})};return e.jsxs(s.Popover,{children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"Legend Settings",children:e.jsx(bt,{className:"size-4"})})}),e.jsx(s.PopoverContentCustom,{className:"w-72",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium leading-none",children:"Legend Options"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the legend options for the chart."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(s.Label,{htmlFor:"displayLegend",children:"Display"}),e.jsx("div",{className:"col-span-2 flex h-8 items-center",children:e.jsx(s.SmallSwitch,{checked:n,onCheckedChange:o,defaultChecked:!0,id:"displayLegend"})})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(s.Label,{htmlFor:"position",children:"Position"}),e.jsxs("div",{className:"col-span-2 flex h-8 items-center",children:[e.jsx(s.IconButton,{tooltip:"Top",onClick:()=>l("top"),children:e.jsx(s.ArrowUp,{className:"size-4"})}),e.jsx(s.IconButton,{tooltip:"Left",onClick:()=>l("left"),children:e.jsx(Ys,{className:"size-4"})}),e.jsx(s.IconButton,{tooltip:"Bottom",onClick:()=>l("bottom"),children:e.jsx(ts,{className:"size-4"})}),e.jsx(s.IconButton,{tooltip:"Right",onClick:()=>l("right"),children:e.jsx(Zs,{className:"size-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(s.Label,{htmlFor:"align",children:"Align"}),e.jsxs("div",{className:"col-span-2 flex h-8 items-center",children:[e.jsx(s.IconButton,{tooltip:"Start",onClick:()=>i("start"),children:e.jsx(Ks,{className:"size-4"})}),e.jsx(s.IconButton,{tooltip:"Center",onClick:()=>i("center"),children:e.jsx(Js,{className:"size-4"})}),e.jsx(s.IconButton,{tooltip:"End",onClick:()=>i("end"),children:e.jsx(Ws,{className:"size-4"})})]})]})]})]})})]})}function kn(){var l;const t=s.useEditorStore(i=>i.card.preferences),{setCardPreferences:a,setChartOrientation:n}=s.useEditorStore(i=>i.actions);function r(i){n(i)}const o=((l=t==null?void 0:t.chartOptions)==null?void 0:l.indexAxis)||"x";return e.jsx(s.IconButton,{onClick:()=>r(o==="y"?"x":"y"),tooltip:"Chart Orientation",children:o==="y"?e.jsx(Dt,{className:"size-4"}):e.jsx(It,{className:"size-4"})})}function In(){const t=s.useEditorStore(i=>i.card),a=s.useEditorStore(i=>i.isShowingVisual),n=s.useEditorStore(i=>{var d,m;return(m=(d=i.card)==null?void 0:d.preferences)==null?void 0:m.chartOptions}),r=s.getChartGridStyle(n),{setChartGrid:o}=s.useEditorActions();function l(){const i=["xy","none","x","y"],m=(i.indexOf(r)+1)%i.length;o(i[m])}return a?e.jsxs("div",{"data-info":"visual-settings",className:"flex items-center",children:[["line","bar","range","stackedBar","stackedLine","horizontalBar"].includes(t.type)&&e.jsx(kn,{}),!["kpi","text","custom","table"].includes(t.type)&&e.jsxs(e.Fragment,{children:[e.jsx(Nn,{}),e.jsx(wn,{})]}),!["pie","doughnut","radar","polarArea","table","custom","kpi","text","map"].includes(t.type)&&e.jsxs(s.IconButton,{tooltip:"Grid Style",onClick:l,children:[(r==="xy"||!r)&&e.jsx(gt,{className:"size-4"}),r==="x"&&e.jsx(lt,{className:"size-4"}),r==="y"&&e.jsx(At,{className:"size-4"}),r==="none"&&e.jsx(zt,{className:"size-4"})]})]}):null}function xe(){var V;const t=s.useEditorStore(w=>w.frame),a=s.useEditorStore(w=>w.card),n=s.useEditorStore(w=>w.isDevMode),r=s.useEditorStore(w=>w.isShowingVisual),o=s.useDashboardStore(w=>w.isVisualEditing),l=s.useEditorStore(w=>w.isSqlRunning),i=s.useEditorStore(w=>w.pythonStdOut),d=s.useEditorStore(w=>{var j;return(j=w.card.preferences)==null?void 0:j.chartOptions}),m=s.useEditorStore(w=>w.actions.setRunSql);s.getChartGridStyle(d);const{setFrame:p,setCard:u,updateCardInFrame:x,setActiveTabCardId:f,runAssistant:c,setChartGrid:y}=s.useEditorActions(),{data:h,isLoading:C,isFetching:v,error:M}=s.useDashboardCardQuery(a);if(!a)return e.jsx(e.Fragment,{children:"No Active Card"});function D(){const w={connectionId:a.connectionId,lastSelectedDatabase:a.lastSelectedDatabase,lastSelectedSchema:a.lastSelectedSchema,lastSelectedTable:a.lastSelectedTable,lastSelectedDatamodelId:a.lastSelectedDatamodelId,id:s.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]};L(w)}function L(w){const j={...t,cards:[...t.cards,w],activeCardId:w.id};p(j),u(w),f(w.id)}function k(){const w={...a,id:s.v4(),title:`${a.title} Copy`,tabTitle:`${a.tabTitle||a.title} Copy`};L(w)}function A(w){const j=t.cards.filter(H=>H.id!==w),E=j[0],b={...t,cards:j,activeCardId:E.id};p(b),f(E.id),u(E)}function B(w){n||R(w),f(w)}function R(w){const j={...t,cards:t.cards.map(b=>b.id===a.id?a:b),activeCardId:w};p(j);const E=j.cards.find(b=>b.id===w);E.sql&&m(!0),u(E)}const G=(w,j)=>{console.log("handleDragStart",j),w.dataTransfer.setData("tabIndex",j.toString())},g=w=>{w.preventDefault()},N=(w,j)=>{const E=w.dataTransfer.getData("tabIndex");if(E===j.toString())return;const b=Array.from(t.cards),[H]=b.splice(parseInt(E),1);b.splice(j,0,H),p({...t,cards:b})};function T(w,j){return w.cards.length===1&&(j.displayTab===!0||j.displayTab===void 0)||w.activeCardId!==j.id&&(j.displayTab===!0||j.displayTab===void 0)?null:e.jsx("div",{onClick:()=>{const E=j.displayTab===void 0?!1:!j.displayTab;u({...j,displayTab:E}),x({...j,displayTab:E})},children:j.displayTab===!0||j.displayTab===void 0?e.jsx(s.Eye,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"}):e.jsx(ht,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"})})}function O(){return e.jsxs(s.Tabs,{onValueChange:B,value:t.activeCardId,className:"flex grow flex-col",children:[t.cards.map(w=>e.jsx(s.TabsContent,{className:"mt-0 grow",value:w.id,children:S()},w.id)),e.jsx(s.TabsList,{className:"group mx-6 justify-between overflow-x-auto",children:e.jsxs("div",{className:"flex items-center",children:[t.cards.map((w,j)=>e.jsx(s.Editable,{text:w.tabTitle||w.title,onSave:E=>{u({...a,tabTitle:E}),x({...a,tabTitle:E})},children:e.jsxs(s.TabsTrigger,{draggable:!0,onDragStart:E=>G(E,j),onDragOver:g,onDrop:E=>N(E,j),className:"",value:w.id,children:[T(t,w),w.tabTitle||w.title,t.activeCardId===w.id&&t.cards.length>1&&e.jsx(s.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>A(w.id)})]})},w.id)),e.jsx(s.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:D,children:e.jsx(s.Plus,{className:"h-4 w-4"})}),e.jsx(s.Button,{className:"invisible ml-1 h-8 px-2 hover:bg-muted-foreground/50 group-hover:visible",variant:"outline",onClick:k,children:e.jsx(dt,{className:"h-4 w-4"})})]})})]})}function S(){return a.type==="kpi"?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsx(s.KPICard,{card:a,data:h==null?void 0:h.records})})}):a.type==="text"?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsx(s.ScrollArea,{className:"mx-3 my-6 h-[300px] overflow-y-auto break-words px-3",children:e.jsx(s.TextCard,{isLoading:l,card:a,data:h==null?void 0:h.records})})})}):e.jsx(s.ErrorBoundary,{FallbackComponent:s.FallbackEditorCard,children:e.jsx(Os,{className:"grow border-none shadow-none"})})}function q(){const w=JSON.stringify(h==null?void 0:h.records,null,2),j=new Blob([w],{type:"application/json"}),E=URL.createObjectURL(j),b=document.createElement("a");b.href=E,b.download=`${a.title}.json`,b.click()}function P(){const j=[Object.keys(h==null?void 0:h.records.reduce((_,J)=>({..._,...J}),{})).join(","),...((h==null?void 0:h.records)||[]).map(_=>Object.values(_).join(","))].join(`
342
- `),E=new Blob([j],{type:"text/csv"}),b=URL.createObjectURL(E),H=document.createElement("a");H.href=b,H.download=`${a.title}.csv`,H.click()}function U(){const w=`Can you get the documentation for ${a.type} chart?`;c(w)}return e.jsxs("div",{className:"relative isolate flex h-full flex-col py-3",children:[(C||v)&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 top-0 z-50 m-auto flex h-10 w-10 items-center justify-center rounded-md bg-muted",children:e.jsx(re,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),e.jsxs("div",{className:"z-10 mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[r&&e.jsxs("div",{className:"flex grow items-center",children:[e.jsx(Cn,{}),o&&e.jsx(s.IconButton,{tooltip:"Visual Docs",onClick:U,children:e.jsx(st,{className:"size-4"})}),!["table","custom"].includes(a.type)&&o&&e.jsx(jn,{})]}),!r&&e.jsxs("div",{className:"flex grow items-center gap-1",children:[e.jsx(s.Button,{className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",variant:"ghost",size:"icon",onClick:P,children:e.jsx(yn,{className:"size-4"})}),e.jsx(s.Button,{className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",variant:"ghost",size:"icon",onClick:q,children:e.jsx(pt,{strokeWidth:1.5,className:"size-4"})}),e.jsx(s.CopyButton,{text:JSON.stringify(h==null?void 0:h.records,null,2),className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70"})]}),e.jsx(In,{}),e.jsx(En,{})]}),r?O():e.jsxs(s.ResizablePanelGroup,{className:"px-6",direction:"horizontal",children:[i&&e.jsxs(e.Fragment,{children:[e.jsx(s.ResizablePanel,{id:"1",order:1,defaultSize:30,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:i&&e.jsx(Dn,{})}),e.jsx(s.ResizableHandle,{})]}),e.jsxs(s.ResizablePanel,{id:"2",order:2,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:[(h==null?void 0:h.records)&&(h==null?void 0:h.records.length)>0&&e.jsx(hn,{data:(h==null?void 0:h.records)||[]}),(M||(h==null?void 0:h.error))&&e.jsx("span",{className:"font-mono text-xs",children:(M==null?void 0:M.message)||((V=h==null?void 0:h.error)==null?void 0:V.message)})]})]})]})}function Dn(){const t=s.useEditorStore(n=>n.pythonStdOut);if(!t)return null;const a=t.replace(/\n/g,"<br>");return e.jsxs("div",{className:"relative flex w-full flex-col border-r",children:[e.jsx("div",{className:"sticky top-0 flex max-h-11 min-h-11 grow items-center border-b bg-muted px-3 font-mono text-xs font-semibold text-foreground/70",children:"Python Output"}),e.jsxs(s.ScrollArea,{className:"overflow-y-auto px-2 pt-1 font-mono text-xs text-foreground/90",children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:a}}),e.jsx(s.ScrollBar,{orientation:"horizontal"})]})]})}function En(){const t=s.useEditorStore(n=>n.isShowingVisual),a=s.useEditorStore(n=>n.actions.setIsShowingVisual);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Label,{htmlFor:"visualize",children:"Chart"}),e.jsx(s.SmallSwitch,{checked:t,onCheckedChange:()=>a(!t),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function Tn(){var h,C;const t=s.useEditorStore(v=>v.card.customCardPreferences),{data:a}=Vs(),n=(a==null?void 0:a.plugins)||[],r=s.useEditorStore(v=>v.card),o=s.useEditorStore(v=>v.frame),l=(t==null?void 0:t.visualType)||"single",{setCustomCardPreferences:i}=s.useEditorActions(),{components:d,manifest:m}=s.useCustomVisual((t==null?void 0:t.url)||""),p=(h=m==null?void 0:m.visuals)==null?void 0:h.find(v=>v.name===(t==null?void 0:t.componentName));function u(v,M){if(!t)return;const L={...(t==null?void 0:t.dataInputCardIds)||{},[v]:{cardId:M,hookRef:null}};i({...t,dataInputCardIds:L})}function x(v){var D,L;const M=(D=o==null?void 0:o.cards)==null?void 0:D.filter(k=>{var A;return((A=k==null?void 0:k.customCardPreferences)==null?void 0:A.visualType)!=="multiple"}).map(k=>({value:k.id,label:k.tabTitle||k.title}));return e.jsx("div",{className:"space-y-2",children:(L=v==null?void 0:v.dataInputs)==null?void 0:L.map((k,A)=>{var B,R;return e.jsxs("div",{className:"grid grid-cols-10 gap-2",children:[e.jsx("div",{className:"col-span-4 flex items-center",children:k}),e.jsx(Y,{className:"col-span-6 h-8 w-full justify-between",label:"",options:M||[],value:((R=(B=t==null?void 0:t.dataInputCardIds)==null?void 0:B[A])==null?void 0:R.cardId)||"",onValueChange:G=>u(A,G)})]},A+Math.random())})})}function f(v,M,D=[],L=""){var k,A;return t?v==="input"?e.jsx(s.Input,{className:`h-8 w-full ${s.removeRing}`,value:((k=t==null?void 0:t.settings)==null?void 0:k[M])||L,onChange:B=>{i({...t,settings:{...t==null?void 0:t.settings,[M]:B.target.value}})}},M):v==="select"?e.jsx(Y,{className:"h-8 w-full",label:"",options:D,value:((A=t==null?void 0:t.settings)==null?void 0:A[M])||L,onValueChange:B=>{i({...t,settings:{...t==null?void 0:t.settings,[M]:B}})}}):null:null}function c(v){const M=Object.entries((v==null?void 0:v.settings)||{});return e.jsx("div",{className:"space-y-3",children:M.map(([D,L])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(s.Label,{children:L.title}),f(L.ui,D,L.options,L.defaultValue)]},D))})}function y(v){t&&i({...t,visualType:v,componentName:""})}return e.jsxs(s.Accordion,{type:"multiple",defaultValue:["component-settings"],className:"px-6 py-2",children:[e.jsxs(s.AccordionItem,{value:"plugin-settings",children:[e.jsx(s.AccordionTrigger,{children:"Plugin"}),e.jsx(s.AccordionContent,{children:e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Y,{icon:e.jsx(et,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Plugin",options:n,value:(t==null?void 0:t.url)||"",onValueChange:v=>i({...t||{url:"",componentName:""},url:v})}),((t==null?void 0:t.type)==="component"||(t==null?void 0:t.type)===void 0)&&e.jsx(s.Tabs,{value:l,onValueChange:y,children:e.jsxs(s.TabsList,{className:"h-9 w-full",children:[e.jsx(s.TabsTrigger,{className:"h-7 w-full",value:"single",children:"Single Visual"}),e.jsx(s.TabsTrigger,{className:"h-7 w-full",value:"multiple",children:"Multi-Visual"})]})})]})}),((t==null?void 0:t.type)==="component"||(t==null?void 0:t.type)===void 0)&&t&&e.jsx(e.Fragment,{children:d&&e.jsx(Y,{icon:e.jsx(ct,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Component",options:(d==null?void 0:d.filter(v=>v.type===l).map(v=>({value:v.name,label:v.name})))||[],value:t.componentName,onValueChange:v=>{console.log("changing value",v),i({...t,componentName:v})}})})]})})]}),((C=r==null?void 0:r.customCardPreferences)==null?void 0:C.componentName)&&e.jsxs(s.AccordionItem,{className:"border-none",value:"component-settings",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsxs(s.AccordionContent,{children:[p&&p.dataInputs&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(s.Label,{children:"Input Mapping"}),e.jsx("div",{className:"px-2",children:x(p)})]}),p&&p.settings&&e.jsx("div",{className:"space-y-3",children:e.jsx("div",{className:"px-2",children:c(p)})})]})]})]})}function oe(){const[t,a]=I.useState([]),n=s.useEditorStore(p=>p.card.preferences),{setFilterOnClickColumnIndex:r,setCardPreferences:o}=s.useEditorStore(p=>p.actions),l=s.useEditorStore(p=>p.queryResultColumns);s.useEditorStore(p=>{var u;return(u=p.card.preferences)==null?void 0:u.filterOnClickColumnIndex}),I.useEffect(()=>{l&&a(new Array(l.length).fill(!1))},[l]);function i(p,u){var x,f;u?n!=null&&n.onClickFilter&&((x=n==null?void 0:n.onClickFilter)==null?void 0:x.length)>0?o({...n,onClickFilter:[...n.onClickFilter,{columnIndex:p,expression:""}]}):o({...n,onClickFilter:[{columnIndex:p,expression:""}]}):(o({...n,onClickFilter:(f=n==null?void 0:n.onClickFilter)==null?void 0:f.filter(c=>c.columnIndex!==p)}),a(c=>{const y=[...c];return y[p]=!1,y}))}function d(p,u){var f;const x=(f=n==null?void 0:n.onClickFilter)==null?void 0:f.map(c=>c.columnIndex===p?{...c,expression:u.target.value}:c);o({...n,onClickFilter:x})}function m(p){var u,x,f,c;if(t!=null&&t[p]||(x=(u=n==null?void 0:n.onClickFilter)==null?void 0:u.find(y=>y.columnIndex===p))!=null&&x.expression)return e.jsx(s.Input,{value:(c=(f=n==null?void 0:n.onClickFilter)==null?void 0:f.find(y=>y.columnIndex===p))==null?void 0:c.expression,onChange:y=>d(p,y),type:"text",className:"h-9 w-full font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"Expression"})}return e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"On Click"}),l==null?void 0:l.map((p,u)=>{var x,f;return e.jsx("div",{className:"xbg-red-100 group flex items-center justify-between space-y-2",children:e.jsxs("div",{className:"grow",children:[e.jsxs("div",{className:"flex items-center space-x-2 py-2",children:[e.jsx(s.Checkbox,{checked:!!((x=n==null?void 0:n.onClickFilter)!=null&&x.find(c=>c.columnIndex===u)),onCheckedChange:c=>i(u,c)}),e.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:p}),e.jsx("div",{className:"flex items-center gap-2",children:((f=n==null?void 0:n.onClickFilter)==null?void 0:f.find(c=>c.columnIndex===u))&&e.jsx(s.Pencil,{onClick:()=>{a(c=>{const y=[...c];return y[u]=!c[u],y})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),m(u)]})},p)})]})}function An({idx:t}){var d;const a=s.useEditorStore(m=>{var p;return(p=m.card)==null?void 0:p.preferences}),n=s.useEditorStore(m=>{var p;return(p=m.card.preferences)==null?void 0:p.datasetOptions}),r=s.useEditorStore(m=>m.actions.setCardPreferences),o=(d=a==null?void 0:a.chartOptions)==null?void 0:d.indexAxis,l=n==null?void 0:n.find(m=>m.idx===t);function i(m,p){(m==="end"||m==="start")&&s.getContrastColor(s.getCanvasBackgroundColor());const u={display:m!=="none",align:m,anchor:m,clamp:!0};if(!l)r({...a,datasetOptions:[...n||[],{idx:p,datalabels:u}]});else{const x={...l};x.datalabels=u;const f=n==null?void 0:n.map(c=>c.idx===p?x:c);r({...a,datasetOptions:f})}}return e.jsxs(s.Popover,{children:[e.jsx(s.PopoverTrigger,{children:e.jsx(Ft,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsx(s.PopoverContent,{className:"w-fit p-1",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(s.Button,{onClick:()=>i("none",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(s.X,{className:"size-4"})}),e.jsx(s.Button,{onClick:()=>i("start",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(St,{className:s.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsx(s.Button,{onClick:()=>i("center",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(vt,{className:s.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsx(s.Button,{onClick:()=>i("end",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(Ct,{className:s.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function qs(){const t=s.useEditorStore(p=>p.card),a=s.useEditorStore(p=>{var u,x,f;return(f=(x=(u=p==null?void 0:p.card)==null?void 0:u.preferences)==null?void 0:x.chartOptions)==null?void 0:f.indexAxis}),{data:n}=s.useDashboardCardQuery(t),r=a==="y"?"Metric":"Dimension",o=a==="y"?"Dimension":"Metric",{keys:l,metricKeys:i,dimensionKeys:d}=s.getKeys((n==null?void 0:n.records)||[]);let m=i;if(["stackedBar","stackedLine"].includes(t.type)){const p=s.pivotData({dataArray:(n==null?void 0:n.records)||[],groupKey:d[0],pivotKey:d[1],valueKey:m[0]}),{metricKeys:u}=s.getKeys(p);m=u}return l.length===0?null:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:r}),e.jsx("div",{className:"max-h-[125px] space-y-1 overflow-y-auto",children:d.map(p=>e.jsx("p",{className:"rounded-md bg-muted/70 px-3 py-2 hover:bg-muted",title:p,children:Ps(p)},p))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:o}),e.jsx("div",{className:"my-1 max-h-[125px] space-y-1 overflow-y-auto",children:m.map((p,u)=>e.jsx(Mn,{col:p,idx:u},p))})]})]})}function Ps(t,a=30){return t.length>a?t.slice(0,a)+"...":t}function Mn({col:t,idx:a}){const n=s.useEditorStore(d=>{var m;return(m=d.card)==null?void 0:m.preferences}),r=s.useEditorStore(d=>{var m;return(m=d.card.preferences)==null?void 0:m.datasetOptions}),o=r==null?void 0:r.find(d=>d.idx===a),{setCardPreferences:l}=s.useEditorStore(d=>d.actions);function i(d){if(!o)l({...n,datasetOptions:[...r||[],{idx:a,type:d==="area"?"line":d,fill:d==="area"?"origin":""}]});else{const m={...o};m.type=d==="area"?"line":d,m.fill=d==="area"?"origin":"";const p=r==null?void 0:r.map(u=>u.idx===a?m:u);l({...n,datasetOptions:p})}}return e.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-3 py-2 hover:bg-muted",children:[e.jsx("p",{title:t,children:Ps(t)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{onClick:()=>i("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsx(Ve,{onClick:()=>i("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsx(rt,{onClick:()=>i("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsx(An,{idx:a})]})]})}function Hs(){const t=s.useEditorStore(c=>c.selectedConnectionId),a=s.useEditorStore(c=>c.selectedDatamodelId),n=s.useEditorStore(c=>c.selectedDatabaseName),r=s.useEditorStore(c=>c.selectedSchemaName),o=s.useEditorStore(c=>c.selectedTableName),l=s.useDashboardStore(c=>c.dashboard.filters)||[],i=s.useDashboardStore(c=>c.actions.addFilter),d=s.useDashboardStore(c=>c.actions.removeFilter),{removeFilterValues:m}=s.useDashboardActions(),{modelItems:p,tableName:u,connectionType:x}=ne();function f(c,y="dashboard"){var B;const h=s.fmt(c.column_name),C=s.fmt(n||""),v=s.fmt(r||""),M=s.fmt(u);let D=s.getQualifiedTableName({schemaName:v,tableName:M,connectionType:x,databaseName:C}),L=`${D}.${h}`;const k=(B=p==null?void 0:p.find(R=>R.id===a))==null?void 0:B.name;a&&a!=="none"&&(L=`${s.DATAMODEL_NAMESPCACE}.${k}.${h}`,D=`${s.DATAMODEL_NAMESPCACE}.${k}`);const A=l==null?void 0:l.find(R=>R.column===L&&R.table===M&&(R.database===C||R.database===n));if(A)m(A.id),d(A.id);else{const R=s.v4();return u==="api"&&t?(i({location:y,id:R,column:L,title:c.column_name,dataType:c.data_type,table:"api",database:"",connectionId:t,operation:"in",sql:s.getDefaultFilterSql(c.data_type,D,h)}),R):(i({id:R,location:y,column:L,title:c.column_name,dataType:c.data_type,table:o||"",database:n||"",connectionId:t||"",operation:"in",sql:s.getDefaultFilterSql(c.data_type,D,h)}),R)}}return{assignFilter:f}}function me(){const t=s.useDashboardStore(d=>d.dashboard.filters),a=s.useEditorStore(d=>d.frame),{setFrame:n}=s.useEditorActions(),{columns:r}=ne(),{assignFilter:o}=Hs();function l(d){const m=o(d,"frame");n({...a,filterId:m})}const i=t==null?void 0:t.find(d=>d.id===a.filterId);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(s.Label,{children:"Card Filter"}),e.jsx(Ln,{onSelect:l,columns:r}),i&&e.jsx(s.FilterHeader,{filter:i})]})}function Ln({columns:t,onSelect:a}){var i;const[n,r]=de.useState(!1),[o,l]=de.useState("");return e.jsxs(s.Popover,{open:n,onOpenChange:r,children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsxs(s.Button,{size:"sm",variant:"outline",role:"combobox","aria-expanded":n,className:"w-full justify-between font-normal",children:[o?(i=t.find(d=>d.column_name===o))==null?void 0:i.column_name:"Select Column...",e.jsx(s.CaretSortIcon,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(s.PopoverContent,{className:"w-[200px] p-0",children:e.jsxs(s.Command,{children:[e.jsx(s.CommandInput,{placeholder:"Search column",className:"h-9"}),e.jsxs(s.CommandList,{children:[e.jsx(s.CommandEmpty,{children:"No framework found."}),e.jsx(s.CommandGroup,{children:t.map(d=>e.jsxs(s.CommandItem,{value:d.column_name,onSelect:m=>{const p=m===o?"":m;l(p),r(!1),p&&a(d)},children:[d.column_name,e.jsx(s.CheckIcon,{className:s.cn("ml-auto h-4 w-4",o===d.column_name?"opacity-100":"opacity-0")})]},d.column_name))})]})]})})]})}function On({cardType:t}){return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(s.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{children:`${s.titleCase(t)} Chart`}),e.jsxs(s.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"x-axis - category"}),e.jsx("li",{children:"y-axis1 - number"}),e.jsx("li",{children:"y-axis2 - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:a=>a.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/bar-line-area",children:"example"})," in the docs."]})]})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsx(s.AccordionContent,{className:"space-y-4 px-2",children:e.jsx(qs,{})})]}),e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(oe,{}),e.jsx(me,{})]})]})]})})}function Ge(){var o,l,i;const t=s.useEditorStore(d=>d.card.type),a=s.useEditorStore(d=>d.card.preferences),{setCardPreferences:n}=s.useEditorStore(d=>d.actions);function r(d){var u;const m={datalabels:{display:d!=="none",align:d,anchor:d,clamp:!0}},p={...a,chartOptions:{...a==null?void 0:a.chartOptions,plugins:{...(u=a==null?void 0:a.chartOptions)==null?void 0:u.plugins,...m}}};n(p),console.log(d)}return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"font-medium",children:"Data Labels"}),e.jsxs(s.Select,{value:((i=(l=(o=a==null?void 0:a.chartOptions)==null?void 0:o.plugins)==null?void 0:l.datalabels)==null?void 0:i.anchor)||"none",onValueChange:r,defaultValue:"none",children:[e.jsx(s.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{placeholder:"Select position"})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Data Labels"}),e.jsx(s.SelectItem,{value:"none",children:"None"}),t!=="pyramid"&&e.jsx(s.SelectItem,{value:"start",children:"Start"}),e.jsx(s.SelectItem,{value:"center",children:"Center"}),t!=="pyramid"&&e.jsx(s.SelectItem,{value:"end",children:"End"})]})})]})]})}function zn({cardType:t}){function a(n){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:n==="bubble"?"SELECT label, [group], x-axis, y-axis, radius FROM table":"SELECT label, [group], x-axis, y-axis FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"label - category"}),e.jsx("li",{children:"group (optional) - category"}),e.jsx("li",{children:"x-axis - number"}),e.jsx("li",{children:"y-axis - number"}),n==="bubble"&&e.jsx("li",{children:"radius - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:l=>l.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/bubble",children:"example"})," in the docs."]})]})}return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(s.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{children:`${s.titleCase(t)} Chart`}),e.jsx(s.AccordionContent,{className:"space-y-4 font-mono text-xs",children:a(t)})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsx(s.AccordionContent,{className:"px-2",children:e.jsx(Ge,{})})]}),e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(oe,{}),e.jsx(me,{})]})]})]})})}const Fn={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},Rn={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function _n(){const t=s.useEditorStore(a=>a.card.type);return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(s.Accordion,{className:" ",type:"single",collapsible:!0,children:Bn(t)}),!["kpi"].includes(t)&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ge,{}),e.jsx(oe,{}),e.jsx(me,{})]})]})}function Bn(t){if(["line","bar"].includes(t))return e.jsxs(e.Fragment,{children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:e.jsx("p",{children:"Chart Query"})}),e.jsxs(s.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxs(s.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxs("p",{children:["Click ",e.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsx("pre",{children:JSON.stringify(Fn,null,2)})]})]}),e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxs(s.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxs("p",{children:["Click ",e.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.jsx("a",{className:"mx-1 text-blue-500 hover:underline",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),e.jsx("pre",{children:JSON.stringify(Rn,null,2)})]})]})]});if(t==="bubble")return e.jsx(e.Fragment,{children:e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:["How to create a ",e.jsx("span",{children:t})," chart query?"]})}),e.jsxs(s.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(t==="scatter")return e.jsx(e.Fragment,{children:e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:["How to create a ",e.jsx("span",{children:t})," chart query?"]})}),e.jsxs(s.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(t))return e.jsx(e.Fragment,{children:e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:[e.jsx("span",{children:t==="polarArea"?"Polar":t.charAt(0).toUpperCase()+t.slice(1)})," ","chart query"]})}),e.jsxs(s.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function Vn(){var m,p,u,x,f;const t=s.useEditorStore(c=>c.card.preferences),a=s.useEditorStore(c=>c.actions.setCardPreferences),n=s.useEditorStore(c=>c.actions.setNumberFormat);s.useEditorStore(c=>{var y,h;return(h=(y=c.card.preferences)==null?void 0:y.formatNumber)==null?void 0:h.decimalPlaces});const r=s.useEditorStore(c=>{var y,h;return(h=(y=c.card.preferences)==null?void 0:y.formatNumber)==null?void 0:h.locale}),o=s.useEditorStore(c=>{var y,h;return(h=(y=c.card.preferences)==null?void 0:y.formatNumber)==null?void 0:h.currency});s.useEditorStore(c=>c.actions.setFilterOnClickField);const l=s.useEditorStore(c=>{var y,h;return(h=(y=c.card.preferences)==null?void 0:y.formatNumber)==null?void 0:h.colorRanges})||[],i=s.useEditorStore(c=>c.actions.setColorRanges),d=[...new Set(s.LOCALE_CURRENCY_PAIRS.map(c=>c.currency))];return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(s.Checkbox,{checked:!!((m=t==null?void 0:t.formatNumber)!=null&&m.enabled),onCheckedChange:c=>{a({...t,formatNumber:{...t==null?void 0:t.formatNumber,enabled:c}})}}),e.jsx(s.Label,{children:"Format Number"})]}),((p=t==null?void 0:t.formatNumber)==null?void 0:p.enabled)===!0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{children:e.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(s.Label,{children:"Locale"}),e.jsxs(s.Select,{value:r||"none",onValueChange:c=>{var y,h,C;return n(((y=t==null?void 0:t.formatNumber)==null?void 0:y.decimalPlaces)||0,((h=t==null?void 0:t.formatNumber)==null?void 0:h.currency)||"",c,((C=t==null?void 0:t.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsx(s.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Format"}),e.jsx(s.SelectItem,{value:"none",children:"None"},"none"),s.LOCALE_CURRENCY_PAIRS.map(c=>e.jsx(s.SelectItem,{value:c.locale,children:c.locale},c.locale))]})})]})]}),e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(s.Label,{children:"Currency"}),e.jsxs(s.Select,{value:o||"none",onValueChange:c=>{var y,h,C;console.log("currency",c),n(((y=t==null?void 0:t.formatNumber)==null?void 0:y.decimalPlaces)||0,c==="none"?"":c,((h=t==null?void 0:t.formatNumber)==null?void 0:h.locale)||"",((C=t==null?void 0:t.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsx(s.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Currency"}),e.jsx(s.SelectItem,{value:"none",children:"None"},"none"),d.map(c=>e.jsx(s.SelectItem,{value:c,children:c},c))]})})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(s.Label,{children:"Decimals"}),e.jsxs(s.Select,{value:((x=(u=t==null?void 0:t.formatNumber)==null?void 0:u.decimalPlaces)==null?void 0:x.toString())||"0",onValueChange:c=>{var y,h,C;return n(Number(c),((y=t==null?void 0:t.formatNumber)==null?void 0:y.currency)||"",((h=t==null?void 0:t.formatNumber)==null?void 0:h.locale)||"",((C=t==null?void 0:t.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsx(s.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:["0","1","2","3","4"].map(c=>e.jsx(s.SelectItem,{value:c,children:c},c))})]})]}),e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(s.Label,{children:"Suffix"}),e.jsx(s.Input,{value:((f=t==null?void 0:t.formatNumber)==null?void 0:f.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:c=>{var y,h,C;return n(((y=t==null?void 0:t.formatNumber)==null?void 0:y.decimalPlaces)||0,((h=t==null?void 0:t.formatNumber)==null?void 0:h.currency)||"",((C=t==null?void 0:t.formatNumber)==null?void 0:C.locale)||"",c.target.value)}})]})]})]})}),e.jsx(s.Separator,{className:"my-3"}),e.jsx(s.ColorFormat,{colorRanges:l,setColorRanges:i})]})]})}function qn(){return e.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsx(s.Accordion,{type:"single",collapsible:!0,children:e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxs(s.AccordionContent,{className:"font-mono",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"current - number"}),e.jsx("li",{children:"previous - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/kpi",children:"example"})," in the docs."]})]})]})}),e.jsx("section",{className:"",children:e.jsx(Vn,{})}),e.jsx("div",{}),e.jsx("div",{})]})}function ke({children:t,summary:a,open:n,className:r}){return e.jsxs("details",{open:n,className:s.cn("space-y-4 [&_summary>svg]:open:-rotate-180",r),children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-4",children:[e.jsx(s.Label,{children:a}),e.jsx(s.ChevronUp,{className:"h-4 w-4"})]}),e.jsx("div",{className:"transition-all ease-in-out",children:t})]})}const Pn=[{label:"Mercator",value:"mercator"},{label:"Azimuthal Equidistant",value:"azimuthalEquidistant"},{label:"Gnomonic",value:"gnomonic"},{label:"Orthographic",value:"orthographic"},{label:"Stereographic",value:"stereographic"},{label:"Equal Earth",value:"equalEarth"},{label:"Albers",value:"albers"},{label:"Albers USA",value:"albersUsa"},{label:"Conic Conformal",value:"conicConformal"},{label:"Conic Equal Area",value:"conicEqualArea"},{label:"Conic Equidistant",value:"conicEquidistant"},{label:"Equirectangular",value:"equirectangular"},{label:"Transverse Mercator",value:"transverseMercator"},{label:"Natural Earth 1",value:"naturalEarth1"}],Hn=["blues","brBG","buGn","buPu","cividis","cool","cubehelixDefault","gnBu","greens","greys","inferno","magma","orRd","oranges","pRGn","piYG","plasma","puBu","puBuGn","puOr","puRd","purples","rainbow","rdBu","rdGy","rdPu","rdYlBu","rdYlGn","reds","sinebow","spectral","turbo","viridis","warm","ylGn","ylGnBu","ylOrBr","ylOrRd"],Gn=Hn.map(t=>({label:t,value:t}));function Un(){var m,p,u,x,f,c,y,h,C,v,M,D,L,k,A,B,R,G;const t=s.useEditorStore(g=>g.card),a=(p=(m=t==null?void 0:t.preferences)==null?void 0:m.mapVisualOptions)==null?void 0:p.topoJsonUrl,[n,r]=I.useState(((x=(u=t==null?void 0:t.preferences)==null?void 0:u.mapVisualOptions)==null?void 0:x.customTopoJsonUrl)||""),{setCardPreferences:o}=s.useEditorActions(),{data:l}=s.useTopoJson(t),i=Object.keys((l==null?void 0:l.objects)||{}).map(g=>({label:g,value:g}))||[],d=[{label:"US States 10m",value:"https://unpkg.com/us-atlas/states-10m.json"},{label:"Countries 50m",value:"https://unpkg.com/world-atlas/countries-50m.json"},{label:"Custom",value:"custom"}];return e.jsxs("div",{className:"p-6",children:[e.jsx(ke,{summary:"Map Chart",children:e.jsx("p",{className:"rounded-md bg-muted p-2 font-mono text-xs",children:"SELECT country, value FROM table"})}),e.jsx(s.Separator,{className:"my-4"}),e.jsx(ke,{open:!0,summary:"Settings",children:e.jsxs("div",{className:"space-y-3 px-2",children:[e.jsx(Y,{className:"h-9",options:d,onValueChange:g=>{console.log("value",g),o({...t.preferences,mapVisualOptions:{topoJsonUrl:g}})},value:a||"",label:"Select Map"}),a==="custom"&&e.jsx(s.Input,{onChange:g=>{r(g.target.value)},onBlur:()=>{var g;console.log("onBlur",n),o({...t.preferences,mapVisualOptions:{...(g=t.preferences)==null?void 0:g.mapVisualOptions,customTopoJsonUrl:n}})},value:n,className:`h-9 w-full ${s.removeRing}`,placeholder:"Custom URL"}),l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(s.Label,{children:"Map Object"}),e.jsx(Y,{className:"h-9",options:i,value:((c=(f=t.preferences)==null?void 0:f.mapVisualOptions)==null?void 0:c.objectKey)||"",label:"Map Object",onValueChange:g=>{var N;o({...t.preferences,mapVisualOptions:{...(N=t.preferences)==null?void 0:N.mapVisualOptions,objectKey:g}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(s.Label,{children:"Projection"}),e.jsx(Y,{className:"h-9",options:Pn,value:((h=(y=t.preferences)==null?void 0:y.mapVisualOptions)==null?void 0:h.projection)||"",label:"Projection",onValueChange:g=>{var N;o({...t.preferences,mapVisualOptions:{...(N=t.preferences)==null?void 0:N.mapVisualOptions,projection:g}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(s.Label,{children:"Colors"}),e.jsx(Y,{className:"h-9",options:Gn,value:((v=(C=t.preferences)==null?void 0:C.mapVisualOptions)==null?void 0:v.colorScale)||"",label:"Select Color Scale",onValueChange:g=>{var N;o({...t.preferences,mapVisualOptions:{...(N=t.preferences)==null?void 0:N.mapVisualOptions,colorScale:g}})}})]})]})]})}),e.jsx(s.Separator,{className:"my-4"}),e.jsx(ke,{className:"",summary:"Scale Options",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(s.Input,{className:`h-9 w-full ${s.removeRing}`,type:"number",step:.1,value:((D=(M=t.preferences)==null?void 0:M.mapVisualOptions)==null?void 0:D.projectionScale)||1,onChange:g=>{var N;o({...t.preferences,mapVisualOptions:{...(N=t.preferences)==null?void 0:N.mapVisualOptions,projectionScale:Number(g.target.value)}})}}),e.jsx(s.Label,{children:"X"}),e.jsx(s.Input,{className:`h-9 w-full ${s.removeRing}`,type:"number",step:10,value:((A=(k=(L=t.preferences)==null?void 0:L.mapVisualOptions)==null?void 0:k.projectionOffset)==null?void 0:A[0])||0,onChange:g=>{var N,T,O,S;o({...t.preferences,mapVisualOptions:{...(N=t.preferences)==null?void 0:N.mapVisualOptions,projectionOffset:[Number(g.target.value),((S=(O=(T=t.preferences)==null?void 0:T.mapVisualOptions)==null?void 0:O.projectionOffset)==null?void 0:S[1])||0]}})}}),e.jsx(s.Label,{children:"Y"}),e.jsx(s.Input,{className:`h-9 w-full ${s.removeRing}`,type:"number",step:10,value:((G=(R=(B=t.preferences)==null?void 0:B.mapVisualOptions)==null?void 0:R.projectionOffset)==null?void 0:G[1])||0,onChange:g=>{var N,T,O,S;o({...t.preferences,mapVisualOptions:{...(N=t.preferences)==null?void 0:N.mapVisualOptions,projectionOffset:[((S=(O=(T=t.preferences)==null?void 0:T.mapVisualOptions)==null?void 0:O.projectionOffset)==null?void 0:S[0])||0,Number(g.target.value)]}})}})]})}),e.jsx(s.Separator,{className:"my-4"}),e.jsx(oe,{})]})}function $n(){var r;const t=s.useEditorStore(o=>o.card.preferences),{setCardPreferences:a}=s.useEditorStore(o=>o.actions);function n(o){a({...t,textVisualOptions:{...t==null?void 0:t.textVisualOptions,isDynamicText:o==="dynamic"}})}return e.jsxs(s.RadioGroup,{value:(r=t==null?void 0:t.textVisualOptions)!=null&&r.isDynamicText?"dynamic":"static",onValueChange:n,className:"flex gap-3",defaultValue:"x",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"static",id:"r1"}),e.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Static"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function fe({cardType:t,docContent:a,suffix:n="Chart"}){return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(s.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{children:`${s.titleCase(t)} ${n}`}),e.jsx(s.AccordionContent,{children:a||e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"label - category"}),e.jsx("li",{children:"measure - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/pie-donut-polar",children:"example"})," in the docs."]})]})})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[t!=="text"&&e.jsx(Ge,{}),t==="text"&&e.jsx($n,{})]})]}),!["range","text"].includes(t)&&e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(oe,{}),e.jsx(me,{})]})]})]})})}function Qn(){const t=s.useEditorStore(r=>{var o,l;return(l=(o=r==null?void 0:r.card)==null?void 0:o.preferences)==null?void 0:l.sortChart}),{setSortChart:a}=s.useEditorActions();function n(){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"Sort"}),e.jsx(Y,{className:"h-8",label:"Sort Chart",options:[{label:"None",value:"none"},{label:"ASC",value:"asc"},{label:"DESC",value:"desc"}],value:t||"none",onValueChange:r=>{a(r)}})]})}return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(s.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{children:"Stacked Chart"}),e.jsxs(s.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"x-axis - category"}),e.jsx("li",{children:"stack by - category"}),e.jsx("li",{children:"y-axis - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/stacked",children:"example"})," in the docs."]})]})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[n(),e.jsx(qs,{})]})]}),e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(oe,{}),e.jsx(me,{})]})]})]})})}function Jn({cardType:t="table"}){console.log("cardType",t);const a=s.useEditorStore(o=>{var l;return(l=o.card)==null?void 0:l.preferences}),n=s.useEditorStore(o=>o.actions.setCardPreferences),r=o=>{n({...a,allowDownload:o})};return e.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsx(s.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(oe,{}),e.jsx(me,{})]})]})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Checkbox,{onCheckedChange:r,id:"allow-download"}),e.jsx("label",{htmlFor:"allow-download",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Allow Download"})]})]})}const Kn=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/tornado",children:"example"})," in the docs."]})]}),Wn=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT y-axis, label, range-from, range-to, range-value FROM table"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/range",children:"example"})," in the docs."]})]}),Yn=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT text FROM table limit 1"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/text",children:"example"})," in the docs."]})]});function Zn(){const t=s.useEditorStore(n=>n.card.type);function a(n){switch(n){case"stackedBar":case"stackedLine":return e.jsx(Qn,{});case"pyramid":return e.jsx(fe,{docContent:Kn,cardType:n});case"kpi":return e.jsx(qn,{});case"line":case"bar":return e.jsx(On,{cardType:n});case"range":return e.jsx(fe,{docContent:Wn,cardType:n});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsx(fe,{cardType:n});case"bubble":case"scatter":return e.jsx(zn,{cardType:n});case"table":return e.jsx(Jn,{cardType:n});case"text":return e.jsx(fe,{docContent:Yn,cardType:n,suffix:"Visual"});case"map":return e.jsx(Un,{});case"custom":return e.jsx(Tn,{});default:return e.jsx(_n,{})}}return e.jsxs(s.ScrollArea,{className:"h-full w-full text-sm",children:[a(t),e.jsx(s.ScrollBar,{orientation:"horizontal"})]})}const Ie={id:"__placeholder__",role:"groupby",type:"string"},De={id:"__placeholder__",role:"metric",type:"number"},Ee={id:"__placeholder__",role:"trendby",type:"date"},Te={id:"__placeholder__",role:"filter",type:"string"},Xn={id:"__placeholder__"},Se="droppable-group-by",Ce="droppable-metrics",Le="sortable-group-by",Oe="sortable-metrics",ze="droppable-trend-by",Fe="sortable-trend-by",Re="droppable-filters",_e="sortable-filters";function ea(){const t=s.useDndStore(g=>g.insertIndex),a=s.useEditorStore(g=>{var N;return((N=g.card.queryConfig)==null?void 0:N.groupByColumns)||[]}),n=s.useEditorStore(g=>{var N;return((N=g.card.queryConfig)==null?void 0:N.metricColumns)||[]}),r=s.useEditorStore(g=>{var N;return((N=g.card.queryConfig)==null?void 0:N.trendByColumns)||[]}),o=s.useEditorStore(g=>{var N;return((N=g.card.queryConfig)==null?void 0:N.filterColumns)||[]}),{setInsertIndex:l,setActiveId:i,setPreviewGroupByColumns:d,setPreviewMetricColumns:m,setPreviewTrendByColumns:p,setPreviewFilterColumns:u}=s.useDndActions(),{setGroupByColumns:x,setMetricColumns:f,setTrendByColumns:c,setFilterColumns:y}=s.useEditorActions(),{columns:h}=Ns(),C=s.useSensors(s.useSensor(s.MouseSensor,{activationConstraint:{distance:1}})),v=g=>{var O;const{active:N,over:T}=g;if(((O=N.data.current)==null?void 0:O.type)==="column"&&T){const S=T.id,q=h.find(w=>w.column_name===N.id);if(!q)return;const P=s.isNumberDataType(q.data_type),U=s.isTextDataType(q.data_type),V=s.isDateDataType(q.data_type);if(U){if(a.some(j=>j.id===S)){const j=a.findIndex(b=>b.id===S);l(j);const E=a.filter(b=>b.id!==Ie.id);E.splice(j,0,Ie),d(E)}else if(T.id===Se){l(a.length);const j=[...a,Ie];d(j),m(n),p(r),u(o)}}if(P||U){if(n.some(j=>j.id===S)){console.log("isOverMetricSortable",S);const j=n.findIndex(b=>b.id===S);l(j);const E=n.filter(b=>b.id!==De.id);E.splice(j,0,De),m(E)}else if(T.id===Ce){l(n.length);const j=[...n,De];m(j),p(r),u(o),d(a)}}if(V){if(r.some(j=>j.id===S)){const j=r.findIndex(b=>b.id===S);l(j);const E=r.filter(b=>b.id!==Ee.id);E.splice(j,0,Ee),p(E)}else if(T.id===ze){l(r.length);const j=[...r,Ee];p(j),m(n),u(o),d(a)}}if(D(q)){if(o.some(j=>j.id===S)){const j=o.findIndex(b=>b.id===S);l(j);const E=o.filter(b=>b.id!==Te.id);E.splice(j,0,Te),u(E)}else if(T.id===Re){l(o.length);const j=[...o,Te];u(j),m(n),p(r),d(a)}}}else d(a),m(n),p(r),u(o)};function M(g){i(g.active.id),l(null),d(a),m(n),p(r),u(o)}function D(g){return!o.some(N=>N.name===g.column_name)}function L(g,N="SUM"){const{column_name:T,data_type:O}=g,S=[...n],q=t!==null?t:n.length,P={...g,id:ae(T),name:T,label:je(N,T),type:O,role:"metric",aggregate:N};S.splice(q,0,P),f(S)}function k(g){const N=[...a],T=t!==null?t:a.length,O={...g,id:ae(g.column_name),name:g.column_name,type:g.data_type,role:"groupby"};N.splice(T,0,O),x(N)}function A(g){const N=[...r],T=t!==null?t:r.length,O={...g,id:ae(g.column_name),name:g.column_name,type:g.data_type,role:"trendby"};N.splice(T,0,O),c(N)}function B(g){const N=[...o],T=t!==null?t:o.length,O={...g,id:ae(g.column_name),name:g.column_name,type:g.data_type,role:"filter"};N.splice(T,0,O),y(N)}function R(g){var S,q,P,U,V,w,j,E;const{active:N,over:T}=g,O=N.data.current;if((O==null?void 0:O.type)==="column"&&T){const b=h.find(W=>W.column_name===N.id);if(!b)return;const H=s.isNumberDataType(b.data_type),_=s.isTextDataType(b.data_type),J=s.isDateDataType(b.data_type);_&&(T.id===Se||((S=T.data.current)==null?void 0:S.type)===Le)?k(b):(H||_)&&(T.id===Ce||((q=T.data.current)==null?void 0:q.type)===Oe)?(H&&L(b),_&&L(b,"COUNT")):J&&(T.id===ze||((P=T.data.current)==null?void 0:P.type)===Fe)?A(b):D(b)&&(T.id===Re||((U=T.data.current)==null?void 0:U.type)===_e)&&B(b)}if(T&&((V=T.data.current)==null?void 0:V.type)===Le&&a.some(b=>b.id===N.id)){const b=a.findIndex(_=>_.id===N.id),H=a.findIndex(_=>_.id===T.id);if(b!==-1&&H!==-1&&b!==H){const _=[...a],[J]=_.splice(b,1);_.splice(H,0,J),x(_)}}if(T&&((w=T.data.current)==null?void 0:w.type)===Oe&&n.some(b=>b.id===N.id)){const b=n.findIndex(_=>_.id===N.id),H=n.findIndex(_=>_.id===T.id);if(b!==-1&&H!==-1&&b!==H){const _=[...n],[J]=_.splice(b,1);_.splice(H,0,J),f(_)}}if(T&&((j=T.data.current)==null?void 0:j.type)===Fe&&r.some(b=>b.id===N.id)){const b=r.findIndex(_=>_.id===N.id),H=r.findIndex(_=>_.id===T.id);if(b!==-1&&H!==-1&&b!==H){const _=[...r],[J]=_.splice(b,1);_.splice(H,0,J),c(_)}}if(T&&((E=T.data.current)==null?void 0:E.type)===_e&&o.some(b=>b.id===N.id)){const b=o.findIndex(_=>_.id===N.id),H=o.findIndex(_=>_.id===T.id);if(b!==-1&&H!==-1&&b!==H){const _=[...o],[J]=_.splice(b,1);_.splice(H,0,J),y(_)}}i(null),l(null),d(a),m(n),p(r),u(o)}function G(){i(null),l(null),d(a),m(n),p(r),u(o)}return{handleDragOver:v,handleDragEnd:R,handleDragStart:M,handleDragCancel:G,sensors:C}}const ce=[{label:"Sum",value:"SUM",logo:e.jsx(fs,{className:"size-3.5"})},{label:"Count",value:"COUNT",logo:e.jsx(us,{className:"size-3.5"})},{label:"Count Distinct",value:"DISTINCT",logo:e.jsx(xt,{className:"size-3.5"})},{label:"Average",value:"AVG",logo:e.jsx(Xs,{className:"size-3.5"})},{label:"Min",value:"MIN",logo:e.jsx(ts,{className:"size-3.5"})},{label:"Max",value:"MAX",logo:e.jsx(s.ArrowUp,{className:"size-3.5"})}];function Gs({column:t,type:a,onRemoveColumn:n,droppableId:r}){const[o,l]=I.useState(!1),[i,d]=I.useState(ce[0]),{attributes:m,listeners:p,setNodeRef:u,transform:x,transition:f,isDragging:c}=s.useSortable({id:t.id,data:{type:a}}),y=x?{opacity:c?.5:void 0,transform:s.CSS.Translate.toString(x),transition:f}:void 0;function h(){return e.jsx("div",{"data-setting-container":"",className:"h-32 rounded-b-md border-x border-b border-border p-3 text-sm",children:e.jsx(e.Fragment,{})})}return e.jsxs("div",{...p,...m,ref:u,style:y,children:[e.jsxs("div",{className:s.cn("group flex h-9 items-center rounded-t-md bg-muted pl-0.5 pr-2.5",!o&&"rounded-b-md",o&&"border border-border",{"pl-2":r===Se}),children:[r===Ce&&e.jsx(ta,{column:t}),e.jsx("div",{children:e.jsx(s.GripVertical,{className:"mr-2 size-3.5 cursor-move items-center justify-center p-0 text-muted-foreground/60 hover:text-foreground"})}),e.jsx("div",{className:"max-w-[250px] grow cursor-pointer overflow-hidden truncate text-ellipsis whitespace-nowrap",children:e.jsx(sa,{col:t})}),e.jsxs("div",{"data-setting-actions":"",className:"hidden h-full items-center gap-2 group-hover:flex",children:[e.jsx("button",{onClick:()=>l(!o),children:e.jsx(s.ChevronDown,{className:s.cn("ml-1 size-4 cursor-pointer items-center justify-center rounded-r-sm bg-muted text-muted-foreground",o&&"rotate-180")})}),e.jsx("button",{onClick:()=>n(t.id),children:e.jsx(s.X,{className:"size-3.5 cursor-pointer items-center justify-center rounded-r-sm bg-muted text-muted-foreground"})})]})]}),o&&h()]})}function sa({col:t}){return e.jsx(s.Editable,{text:t.label||t.name,className:"h-6 rounded-none",onSave:a=>{console.log("saved",a)},children:e.jsx("span",{className:"w-[250px] truncate text-ellipsis whitespace-nowrap text-sm",children:t.label||t.name})})}function ta({column:t}){const[a,n]=I.useState(ce[0]),{updateMetricColumn:r}=s.useEditorActions();let o=ce;s.isTextDataType(t.type)&&(o=o.filter(i=>["COUNT","DISTINCT"].includes(i.value))),s.isNumberDataType(t.type)&&(o=o.filter(i=>!["DISTINCT","COUNT"].includes(i.value))),I.useEffect(()=>{n(ce.find(i=>i.value===t.aggregate)||ce[0])},[t]);function l(i){const d=ce.find(p=>p.value===i);if(!d)return;n(d);const m={...t,aggregate:i,label:je(i,t.name)};r(t.id,m)}return e.jsx(Y,{className:"size-7 overflow-clip rounded-none rounded-l-md border-none bg-muted px-2",icon:a.logo,options:o,value:a.value,onValueChange:i=>l(i),label:"Aggregation"})}function Ae({id:t,label:a,columns:n,previewColumns:r,sortableType:o,onRemoveColumn:l}){const{setNodeRef:i}=s.useDroppable({id:t}),d=s.useDndStore(u=>u.activeId),m={},p=d?r:n;return e.jsx(s.SortableContext,{items:n==null?void 0:n.map(u=>u.id),children:e.jsxs("div",{className:"space-y-2 rounded-md border-2 border-dashed p-5",ref:i,style:m,children:[e.jsx(s.Label,{className:"text-sm",children:a}),e.jsx("div",{className:"space-y-2",children:p==null?void 0:p.map(u=>u.id===Xn.id?e.jsx(na,{},u.id):e.jsx(Gs,{droppableId:t,type:o,column:u,onRemoveColumn:l},u.id))})]})})}function na(){return e.jsx("div",{className:"flex h-7 grow items-center space-x-2 rounded-md border border-dashed border-muted-foreground bg-background px-2 py-1 text-sm"})}function ss(){const t=s.useEditorStore(c=>{var y;return((y=c.card.queryConfig)==null?void 0:y.groupByColumns)||[]}),a=s.useDndStore(c=>c.previewGroupByColumns),n=s.useEditorStore(c=>{var y;return((y=c.card.queryConfig)==null?void 0:y.metricColumns)||[]}),r=s.useDndStore(c=>c.previewMetricColumns),o=s.useEditorStore(c=>{var y;return((y=c.card.queryConfig)==null?void 0:y.trendByColumns)||[]}),l=s.useDndStore(c=>c.previewTrendByColumns),{setSelectedConnectionId:i,removeColumnFromGroupBy:d,removeColumnFromMetricColumns:m,removeColumnFromTrendByColumns:p}=s.useEditorActions();I.useEffect(()=>{i("c_2d3646f0-68a6-47e7-942d-d9cbc80fb7d4")},[i]);function u(c){d(c)}function x(c){p(c)}function f(c){m(c)}return e.jsxs("div",{className:"h-full w-full space-y-2 p-4",children:[e.jsx(Ae,{onRemoveColumn:u,sortableType:Le,id:Se,label:"Group By",columns:t,previewColumns:a}),e.jsx(Ae,{onRemoveColumn:x,sortableType:Fe,id:ze,label:"Trend By",columns:o,previewColumns:l}),e.jsx(Ae,{onRemoveColumn:f,sortableType:Oe,id:Ce,label:"Metrics",columns:n,previewColumns:r})]})}function aa({id:t,label:a,columns:n,previewColumns:r,sortableType:o,onRemoveColumn:l}){const{setNodeRef:i,isOver:d}=s.useDroppable({id:t}),m=s.useDndStore(x=>x.activeId),p={borderColor:d?"green":void 0},u=m?r:n;return e.jsx(s.SortableContext,{items:n==null?void 0:n.map(x=>x.id),children:e.jsxs("div",{className:"space-y-2 rounded-md border-2 border-dashed p-5",ref:i,style:p,children:[e.jsx(s.Label,{className:"text-sm",children:a}),e.jsx("div",{className:"flex flex-wrap gap-4",children:u==null?void 0:u.map(x=>e.jsx(Gs,{droppableId:t,type:o,column:x,onRemoveColumn:l},x.id))})]})})}function ra(){const t=s.useEditorStore(o=>{var l;return((l=o.card.queryConfig)==null?void 0:l.filterColumns)||[]}),a=s.useDndStore(o=>o.previewFilterColumns),{removeColumnFromFilterColumns:n}=s.useEditorActions();function r(o){n(o)}return e.jsx("div",{className:"size-full p-4",children:e.jsx(aa,{onRemoveColumn:r,sortableType:_e,id:Re,label:"Filters",renderComponent:o=>e.jsx(ge,{className:"rounded-md bg-muted",column:{column_name:o.name,data_type:o.type}}),columns:t,previewColumns:a})})}function oa(){const t=s.useEditorStore(r=>r.card),{data:a,errorMessage:n}=s.useDashboardCardQuery(t);return e.jsxs("section",{className:"flex justify-between gap-2 p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ls,{}),e.jsx(ks,{sql:a==null?void 0:a.sql,error:n})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Ms,{}),e.jsx(As,{variant:"default"})]})]})}function ia(){const t=I.useRef(null),a=s.useEditorStore(i=>i.isShowingVisual),n=s.useEditorStore(i=>i.showAIDialog),r=s.useEditorStore(i=>i.isDevMode);I.useEffect(()=>{var i,d;n?(i=t.current)==null||i.resize(0):(d=t.current)==null||d.resize(25)},[n]);function o(){return e.jsxs(e.Fragment,{children:[e.jsx(s.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsx(mn,{})}),e.jsx(s.ResizableHandle,{withHandle:!0,className:"border"}),e.jsx(s.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:a&&!n?e.jsxs(s.ResizablePanelGroup,{direction:"horizontal",children:[e.jsx(e.Fragment,{children:e.jsx(s.ResizablePanel,{ref:t,className:"flex",defaultSize:25,maxSize:30,children:r?e.jsx(Zn,{}):e.jsx(ss,{})})}),!n&&e.jsx(s.ResizableHandle,{className:"border"}),e.jsx(s.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsx(xe,{})})]}):e.jsx(xe,{})})]})}function l(){return e.jsx(e.Fragment,{children:e.jsx(s.ResizablePanel,{className:"pb-1","data-biz-mode-container":"",minSize:0,defaultSize:100,children:a&&!n?e.jsxs(s.ResizablePanelGroup,{direction:"horizontal",children:[e.jsx(e.Fragment,{children:e.jsx(s.ResizablePanel,{ref:t,className:"flex min-w-[320px]",defaultSize:25,maxSize:30,children:e.jsx(ss,{})})}),!n&&e.jsx(s.ResizableHandle,{className:"border"}),e.jsx(s.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxs(s.ResizablePanelGroup,{direction:"vertical",children:[e.jsxs(s.ResizablePanel,{className:"flex min-h-fit flex-col",minSize:10,defaultSize:20,children:[e.jsx(oa,{}),e.jsx(ra,{})]}),e.jsx(s.ResizableHandle,{className:"border"}),e.jsx(s.ResizablePanel,{minSize:20,defaultSize:80,children:e.jsx(xe,{})})]})})]}):e.jsx(xe,{})})})}return e.jsx(s.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:r?o():l()})}const la=[{title:"Help me write a query for",subtitle:"orders by month"},{title:"Create a bar chart for",subtitle:"sales by category"}];function ca(){const t=I.useRef(null),a=I.useRef(null),[n,r]=I.useState(!1),[o,l]=I.useState(s.isDevEnv),[i,d]=I.useState(!1),m=s.useEditorStore(V=>V.actions.setCardSql),p=s.useEditorStore(V=>V.actions.setRunSql),u=s.useEditorStore(V=>V.showAIDialog),{setShowAIDialog:x}=s.useEditorActions(),{messages:f,setMessages:c,reload:y,append:h,input:C,setInput:v,isLoading:M,handleAddCurrentTableToScope:D,removeFromCurrentSelections:L,currentAssitantScope:k,handleInputChange:A,handleSubmit:B,stop:R,chatStatus:G,toolStatus:g,llmUsage:N,errorMessage:T}=Ts();s.useAssistantScroll({scrollContainerRef:t,inputRef:a,messages:f}),I.useEffect(()=>{var V;u&&((V=a.current)==null||V.focus())},[u]);function O(V){m(V),p(!0)}function S(V){const w={role:"user",content:V.title+" "+V.subtitle};h(w)}function q(){return e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",children:e.jsx(cs,{className:"size-3.5 text-muted-foreground/70 hover:text-muted-foreground"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[e.jsx(s.DropdownMenuLabel,{children:"Options"}),e.jsx(s.DropdownMenuSeparator,{}),e.jsx(s.DropdownMenuCheckboxItem,{checked:n,onCheckedChange:r,children:"Token Usage"}),e.jsx(s.DropdownMenuCheckboxItem,{checked:o,onCheckedChange:l,children:"Tool Invocations"}),e.jsx(s.DropdownMenuCheckboxItem,{checked:i,onCheckedChange:d,children:"System Message"})]})]})}function P(){return e.jsxs("div",{"data-role":"header",children:[e.jsx("div",{className:"text-lg font-semibold",children:"Assistant"}),k&&k.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:k==null?void 0:k.map((V,w)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted px-2 py-1 text-xs",children:[s.getFormattedTableNameForQuery({schemaName:V.schemaName||"",tableName:V.tableName||"",modelName:V.datamodelName||"",connectionType:V.connectionType||"",databaseName:V.databaseName||""}),e.jsx("button",{onClick:()=>{L(V)},children:e.jsx(s.X,{className:"size-3 text-muted-foreground hover:text-foreground"})})]},w))}),(k==null?void 0:k.length)===0&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Context: None"}),e.jsxs(s.Button,{className:"h-6 text-xs",size:"sm",variant:"secondary",onClick:D,children:[e.jsx(s.Plus,{className:"mr-2 size-3"}),"Current Table"]})]})]})}const U=(C==null?void 0:C.length)===0&&(f==null?void 0:f.filter(V=>V.role==="user").length)===0;return e.jsxs("div",{"data-role":"editor-assistant",className:"flex h-full w-full flex-col justify-between gap-2 px-6 py-4",children:[e.jsxs("div",{"data-role":"header-section",className:"flex items-start justify-between gap-2",children:[P(),e.jsxs("div",{"data-role":"header-actions",className:"flex items-center",children:[q(),e.jsx(s.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",onClick:()=>{c([]),y()},children:e.jsx(s.RefreshCcw,{className:"size-3.5 text-muted-foreground"})}),e.jsx(s.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",onClick:()=>{x(!1)},children:e.jsx(s.X,{className:"size-4"})})]})]}),e.jsx(s.CustomScrollArea,{ref:t,className:"flex w-full grow basis-0",children:e.jsxs("div",{className:"space-y-4 py-2 pr-3","data-role":"messages",children:[e.jsx(s.PrintMessages,{messages:f,showTools:o,handleRun:O,showSystemMessage:i}),e.jsx(s.ChatStatus,{status:s.getStatus(G,g),isLoading:M})]})}),U&&e.jsx(s.Placeholders,{onClick:S,placeholders:la}),e.jsx(s.ChatInput,{onFocus:()=>{D()},stop:R,ref:a,setInput:v,input:C,handleInputChange:A,handleSubmit:B,isLoading:M}),N&&n&&e.jsx("div",{className:"flex h-8 items-center justify-between",children:e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Usage: ",N.promptTokens," prompt tokens,"," ",N.completionTokens," completion tokens,"," ",N.totalTokens," total tokens"]})}),T&&e.jsx("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:e.jsx("span",{children:T})})]})}function da({authToken:t,onSave:a,onClose:n}){const r=I.useRef(null),o=s.useEditorStore(C=>C.showAIDialog),{setAuthToken:l}=s.useDashboardActions(),{setShowAIDialog:i,setOnSave:d,setOnClose:m}=s.useEditorActions(),{handleDragOver:p,handleDragEnd:u,handleDragStart:x,handleDragCancel:f,sensors:c}=ea();I.useEffect(()=>{a&&d(a),n&&m(n)},[a,d,n,m]),I.useEffect(()=>{t&&t.accessToken&&l(t)},[t,l]),I.useEffect(()=>{var C,v;o?((C=r.current)==null||C.resize(40),i(!0)):(i(!1),(v=r.current)==null||v.resize(0))},[o,i]);function y(C){C<1?i(!1):o||i(!0)}function h(){return e.jsxs(s.ResizablePanelGroup,{"data-content":"editor-main",className:"grow",direction:"horizontal",children:[e.jsx(s.ResizablePanel,{className:"min-w-[510px] rounded-none border-x-[1px]",children:e.jsx(ia,{})}),e.jsx(s.ResizableHandle,{}),e.jsx(s.ResizablePanel,{"data-role":"editor-assistant-panel",ref:r,onResize:y,defaultSize:0,children:e.jsx(ca,{})})]})}return e.jsx(s.ErrorBoundary,{FallbackComponent:s.Fallback,children:e.jsx(s.DndContext,{sensors:c,onDragStart:x,onDragEnd:u,onDragOver:p,onDragCancel:f,children:e.jsxs("section",{className:"isolate flex h-full grow","data-content":"editor-panel",children:[e.jsx(ws,{type:"main"}),h()]})})})}function ua(){s.useDashboardStore(i=>i.selectedCardId);const t=s.useDashboardStore(i=>i.selectedSheetId),{setIsVisualEditing:a}=s.useDashboardStore(i=>i.actions),n=s.useDashboardStore(i=>i.isVisualEditing),r=s.useDashboardStore(i=>i.actions.updateFrame);function o(i){t&&(r(t,i),a(!1))}function l(){a(!1)}return e.jsx("div",{role:"editor-container",className:s.cn("flex grow",{"max-h-0 overflow-hidden":!n}),children:e.jsx(da,{onSave:o,onClose:l})})}function ma(){const t=s.useEditorStore(l=>l.selectedDatabaseName),a=s.useEditorStore(l=>l.selectedTableName),n=s.useDashboardStore(l=>l.dashboard.filters)||[],{columns:r}=ne(),{assignFilter:o}=Hs();return e.jsx(s.ScrollArea,{className:"flex-1 basis-0 flex-col px-3",children:r==null?void 0:r.map(l=>{const i=n==null?void 0:n.find(d=>d.column===s.fmt(l.column_name)&&d.table===a&&d.database===t);return e.jsx("div",{onClick:()=>o(l),className:s.cn("group flex cursor-pointer items-center justify-between border border-dashed border-background px-3 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":i}),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(He,{column:l}),e.jsx("span",{children:l.column_name})]})},l.column_name)})})}function ha(){s.useDashboardStore(a=>a.showFilters);const t=s.useDashboardStore(a=>a.actions.setShowFilters);return e.jsxs("section",{className:"relative flex min-w-[320px] grow flex-col border-l px-1",children:[e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsx(s.Label,{className:"px-2 text-lg",children:"Filters"}),e.jsx(s.Button,{onClick:()=>t(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsx(s.Cross2Icon,{})})]}),e.jsx("div",{className:"flex grow",children:e.jsx(ws,{type:"filter",ColumnsComponent:()=>e.jsx(ma,{})})})]})}function pa(){const t=s.useDashboardStore(r=>r.dashboard.filters),a=s.useDashboardStore(r=>r.theme),n=t==null?void 0:t.filter(r=>r.hide);return n!=null&&n.length?e.jsx("div",{className:s.cn("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5",{"bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]":a==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":a==="dark"}),children:n==null?void 0:n.map(r=>e.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[e.jsx(s.FilterHeader,{filter:r}),e.jsx(s.FilterComponent,{filter:r})]},r.id))}):null}function xa(){const t=s.useDashboardStore(r=>r.showFilters),a=s.useDashboardStore(r=>r.isVisualEditing),n=s.useDashboardStore(r=>r.isDashboardEditing);return e.jsxs("div",{role:"dashboard-plus-main",className:s.cn("",{"max-h-0 overflow-hidden":a,"flex grow overflow-auto":!a}),children:[e.jsxs("section",{className:"flex grow flex-col",children:[n&&e.jsx(pa,{}),e.jsx(s.DashboardTabs,{})]}),t&&e.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsx(ha,{})})]})}function fa(){const t=s.useDashboardStore(o=>o.dashboard),a=s.useDashboardStore(o=>o.actions.setDashboard),n=s.useDashboardStore(o=>o.showDashboardJSON),r=s.useDashboardStore(o=>o.actions.setShowDashboardJSON);return e.jsxs("div",{className:s.cn("relative p-2",{hidden:!n}),children:[e.jsxs(s.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>r(!1),children:[e.jsx(s.X,{className:"mr-2 h-4 w-4"}),"Close"]}),e.jsx(s.de,{onChange:o=>{if(o)try{JSON.parse(o),a(JSON.parse(o))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto",value:JSON.stringify(t,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}function ga({showControls:t=!1,showFooter:a=!0,...n}){return e.jsx(s.ErrorBoundary,{FallbackComponent:s.Fallback,children:e.jsxs(s.SemaphorContextProvider,{dashboardProps:n,children:[e.jsx(s.$e,{}),e.jsxs(s.UXProvider,{children:[e.jsx(fa,{}),e.jsxs(s.DashboardPanel,{...n,children:[t&&e.jsx($t,{}),e.jsx(ua,{}),e.jsx(xa,{})]})]})]})})}exports.Dashboard=s.Dashboard;exports.DashboardWC=s.DashboardWC;exports.SemaphorDataProvider=s.SemaphorQueryClient;exports.SemaphorQueryClient=s.SemaphorQueryClient;exports.createSqlGenConfig=s.createSqlGenConfig;exports.fmt=s.fmt;exports.getColumnDataType=s.getColumnDataType;exports.getFilterValueType=s.getFilterValueType;exports.getFormattedTableNameForQuery=s.getFormattedTableNameForQuery;exports.getQualifiedTableName=s.getQualifiedTableName;exports.getSql=s.getSql;exports.invalidateToken=s.invalidateToken;exports.isBooleanDataType=s.isBooleanDataType;exports.isColumnInSqlGen=s.isColumnInSqlGen;exports.isDateDataType=s.isDateDataType;exports.isNumberDataType=s.isNumberDataType;exports.isTextDataType=s.isTextDataType;exports.resolveDataType=s.resolveDataType;exports.resolveDatamodelName=s.resolveDatamodelName;exports.useCard=s.useCard;exports.useDashboardActions=s.useDashboardActions;exports.useDashboardStore=s.useDashboardStore;exports.useDateFilterHook=s.useDateFilterHook;exports.useEditorActions=s.useEditorActions;exports.useEditorStore=s.useEditorStore;exports.useTextFilterHook=s.useTextFilterHook;exports.ScheduleDashboard=Cs;exports.SelectComponent=le;exports.Surfboard=ga;exports.cleanCard=ys;exports.downloadPdf=Ss;exports.getDashbaordStateWithoutData=Pe;exports.useEditorAside=ne;
342
+ `),E=new Blob([j],{type:"text/csv"}),b=URL.createObjectURL(E),H=document.createElement("a");H.href=b,H.download=`${a.title}.csv`,H.click()}function U(){const w=`Can you get the documentation for ${a.type} chart?`;c(w)}return e.jsxs("div",{className:"relative isolate flex h-full flex-col py-3",children:[(C||v)&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 top-0 z-50 m-auto flex h-10 w-10 items-center justify-center rounded-md bg-muted",children:e.jsx(re,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),e.jsxs("div",{className:"z-10 mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[r&&e.jsxs("div",{className:"flex grow items-center",children:[e.jsx(Cn,{}),o&&e.jsx(s.IconButton,{tooltip:"Visual Docs",onClick:U,children:e.jsx(st,{className:"size-4"})}),!["table","custom"].includes(a.type)&&o&&e.jsx(jn,{})]}),!r&&e.jsxs("div",{className:"flex grow items-center gap-1",children:[e.jsx(s.Button,{className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",variant:"ghost",size:"icon",onClick:P,children:e.jsx(yn,{className:"size-4"})}),e.jsx(s.Button,{className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",variant:"ghost",size:"icon",onClick:q,children:e.jsx(pt,{strokeWidth:1.5,className:"size-4"})}),e.jsx(s.CopyButton,{text:JSON.stringify(h==null?void 0:h.records,null,2),className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70"})]}),e.jsx(In,{}),e.jsx(En,{})]}),r?O():e.jsxs(s.ResizablePanelGroup,{className:"px-6",direction:"horizontal",children:[i&&e.jsxs(e.Fragment,{children:[e.jsx(s.ResizablePanel,{id:"1",order:1,defaultSize:30,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:i&&e.jsx(Dn,{})}),e.jsx(s.ResizableHandle,{})]}),e.jsxs(s.ResizablePanel,{id:"2",order:2,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:[(h==null?void 0:h.records)&&(h==null?void 0:h.records.length)>0&&e.jsx(hn,{data:(h==null?void 0:h.records)||[]}),(M||(h==null?void 0:h.error))&&e.jsx("span",{className:"font-mono text-xs",children:(M==null?void 0:M.message)||((V=h==null?void 0:h.error)==null?void 0:V.message)})]})]})]})}function Dn(){const t=s.useEditorStore(n=>n.pythonStdOut);if(!t)return null;const a=t.replace(/\n/g,"<br>");return e.jsxs("div",{className:"relative flex w-full flex-col border-r",children:[e.jsx("div",{className:"sticky top-0 flex max-h-11 min-h-11 grow items-center border-b bg-muted px-3 font-mono text-xs font-semibold text-foreground/70",children:"Python Output"}),e.jsxs(s.ScrollArea,{className:"overflow-y-auto px-2 pt-1 font-mono text-xs text-foreground/90",children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:a}}),e.jsx(s.ScrollBar,{orientation:"horizontal"})]})]})}function En(){const t=s.useEditorStore(n=>n.isShowingVisual),a=s.useEditorStore(n=>n.actions.setIsShowingVisual);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Label,{htmlFor:"visualize",children:"Chart"}),e.jsx(s.SmallSwitch,{checked:t,onCheckedChange:()=>a(!t),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function Tn(){var h,C;const t=s.useEditorStore(v=>v.card.customCardPreferences),{data:a}=Vs(),n=(a==null?void 0:a.plugins)||[],r=s.useEditorStore(v=>v.card),o=s.useEditorStore(v=>v.frame),l=(t==null?void 0:t.visualType)||"single",{setCustomCardPreferences:i}=s.useEditorActions(),{components:d,manifest:m}=s.useCustomVisual((t==null?void 0:t.url)||""),p=(h=m==null?void 0:m.visuals)==null?void 0:h.find(v=>v.name===(t==null?void 0:t.componentName));function u(v,M){if(!t)return;const L={...(t==null?void 0:t.dataInputCardIds)||{},[v]:{cardId:M,hookRef:null}};i({...t,dataInputCardIds:L})}function x(v){var D,L;const M=(D=o==null?void 0:o.cards)==null?void 0:D.filter(k=>{var A;return((A=k==null?void 0:k.customCardPreferences)==null?void 0:A.visualType)!=="multiple"}).map(k=>({value:k.id,label:k.tabTitle||k.title}));return e.jsx("div",{className:"space-y-2",children:(L=v==null?void 0:v.dataInputs)==null?void 0:L.map((k,A)=>{var B,R;return e.jsxs("div",{className:"grid grid-cols-10 gap-2",children:[e.jsx("div",{className:"col-span-4 flex items-center",children:k}),e.jsx(Y,{className:"col-span-6 h-8 w-full justify-between",label:"",options:M||[],value:((R=(B=t==null?void 0:t.dataInputCardIds)==null?void 0:B[A])==null?void 0:R.cardId)||"",onValueChange:G=>u(A,G)})]},A+Math.random())})})}function f(v,M,D=[],L=""){var k,A;return t?v==="input"?e.jsx(s.Input,{className:`h-8 w-full ${s.removeRing}`,value:((k=t==null?void 0:t.settings)==null?void 0:k[M])||L,onChange:B=>{i({...t,settings:{...t==null?void 0:t.settings,[M]:B.target.value}})}},M):v==="select"?e.jsx(Y,{className:"h-8 w-full",label:"",options:D,value:((A=t==null?void 0:t.settings)==null?void 0:A[M])||L,onValueChange:B=>{i({...t,settings:{...t==null?void 0:t.settings,[M]:B}})}}):null:null}function c(v){const M=Object.entries((v==null?void 0:v.settings)||{});return e.jsx("div",{className:"space-y-3",children:M.map(([D,L])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(s.Label,{children:L.title}),f(L.ui,D,L.options,L.defaultValue)]},D))})}function y(v){t&&i({...t,visualType:v,componentName:""})}return e.jsxs(s.Accordion,{type:"multiple",defaultValue:["component-settings"],className:"px-6 py-2",children:[e.jsxs(s.AccordionItem,{value:"plugin-settings",children:[e.jsx(s.AccordionTrigger,{children:"Plugin"}),e.jsx(s.AccordionContent,{children:e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Y,{icon:e.jsx(et,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Plugin",options:n,value:(t==null?void 0:t.url)||"",onValueChange:v=>i({...t||{url:"",componentName:""},url:v})}),((t==null?void 0:t.type)==="component"||(t==null?void 0:t.type)===void 0)&&e.jsx(s.Tabs,{value:l,onValueChange:y,children:e.jsxs(s.TabsList,{className:"h-9 w-full",children:[e.jsx(s.TabsTrigger,{className:"h-7 w-full",value:"single",children:"Single Visual"}),e.jsx(s.TabsTrigger,{className:"h-7 w-full",value:"multiple",children:"Multi-Visual"})]})})]})}),((t==null?void 0:t.type)==="component"||(t==null?void 0:t.type)===void 0)&&t&&e.jsx(e.Fragment,{children:d&&e.jsx(Y,{icon:e.jsx(ct,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Component",options:(d==null?void 0:d.filter(v=>v.type===l).map(v=>({value:v.name,label:v.name})))||[],value:t.componentName,onValueChange:v=>{console.log("changing value",v),i({...t,componentName:v})}})})]})})]}),((C=r==null?void 0:r.customCardPreferences)==null?void 0:C.componentName)&&e.jsxs(s.AccordionItem,{className:"border-none",value:"component-settings",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsxs(s.AccordionContent,{children:[p&&p.dataInputs&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(s.Label,{children:"Input Mapping"}),e.jsx("div",{className:"px-2",children:x(p)})]}),p&&p.settings&&e.jsx("div",{className:"space-y-3",children:e.jsx("div",{className:"px-2",children:c(p)})})]})]})]})}function oe(){const[t,a]=I.useState([]),n=s.useEditorStore(p=>p.card.preferences),{setFilterOnClickColumnIndex:r,setCardPreferences:o}=s.useEditorStore(p=>p.actions),l=s.useEditorStore(p=>p.queryResultColumns);s.useEditorStore(p=>{var u;return(u=p.card.preferences)==null?void 0:u.filterOnClickColumnIndex}),I.useEffect(()=>{l&&a(new Array(l.length).fill(!1))},[l]);function i(p,u){var x,f;u?n!=null&&n.onClickFilter&&((x=n==null?void 0:n.onClickFilter)==null?void 0:x.length)>0?o({...n,onClickFilter:[...n.onClickFilter,{columnIndex:p,expression:""}]}):o({...n,onClickFilter:[{columnIndex:p,expression:""}]}):(o({...n,onClickFilter:(f=n==null?void 0:n.onClickFilter)==null?void 0:f.filter(c=>c.columnIndex!==p)}),a(c=>{const y=[...c];return y[p]=!1,y}))}function d(p,u){var f;const x=(f=n==null?void 0:n.onClickFilter)==null?void 0:f.map(c=>c.columnIndex===p?{...c,expression:u.target.value}:c);o({...n,onClickFilter:x})}function m(p){var u,x,f,c;if(t!=null&&t[p]||(x=(u=n==null?void 0:n.onClickFilter)==null?void 0:u.find(y=>y.columnIndex===p))!=null&&x.expression)return e.jsx(s.Input,{value:(c=(f=n==null?void 0:n.onClickFilter)==null?void 0:f.find(y=>y.columnIndex===p))==null?void 0:c.expression,onChange:y=>d(p,y),type:"text",className:"h-9 w-full font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"Expression"})}return e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"On Click"}),l==null?void 0:l.map((p,u)=>{var x,f;return e.jsx("div",{className:"xbg-red-100 group flex items-center justify-between space-y-2",children:e.jsxs("div",{className:"grow",children:[e.jsxs("div",{className:"flex items-center space-x-2 py-2",children:[e.jsx(s.Checkbox,{checked:!!((x=n==null?void 0:n.onClickFilter)!=null&&x.find(c=>c.columnIndex===u)),onCheckedChange:c=>i(u,c)}),e.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:p}),e.jsx("div",{className:"flex items-center gap-2",children:((f=n==null?void 0:n.onClickFilter)==null?void 0:f.find(c=>c.columnIndex===u))&&e.jsx(s.Pencil,{onClick:()=>{a(c=>{const y=[...c];return y[u]=!c[u],y})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),m(u)]})},p)})]})}function An({idx:t}){var d;const a=s.useEditorStore(m=>{var p;return(p=m.card)==null?void 0:p.preferences}),n=s.useEditorStore(m=>{var p;return(p=m.card.preferences)==null?void 0:p.datasetOptions}),r=s.useEditorStore(m=>m.actions.setCardPreferences),o=(d=a==null?void 0:a.chartOptions)==null?void 0:d.indexAxis,l=n==null?void 0:n.find(m=>m.idx===t);function i(m,p){(m==="end"||m==="start")&&s.getContrastColor(s.getCanvasBackgroundColor());const u={display:m!=="none",align:m,anchor:m,clamp:!0};if(!l)r({...a,datasetOptions:[...n||[],{idx:p,datalabels:u}]});else{const x={...l};x.datalabels=u;const f=n==null?void 0:n.map(c=>c.idx===p?x:c);r({...a,datasetOptions:f})}}return e.jsxs(s.Popover,{children:[e.jsx(s.PopoverTrigger,{children:e.jsx(Ft,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsx(s.PopoverContent,{className:"w-fit p-1",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(s.Button,{onClick:()=>i("none",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(s.X,{className:"size-4"})}),e.jsx(s.Button,{onClick:()=>i("start",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(St,{className:s.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsx(s.Button,{onClick:()=>i("center",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(vt,{className:s.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsx(s.Button,{onClick:()=>i("end",t),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(Ct,{className:s.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function qs(){const t=s.useEditorStore(p=>p.card),a=s.useEditorStore(p=>{var u,x,f;return(f=(x=(u=p==null?void 0:p.card)==null?void 0:u.preferences)==null?void 0:x.chartOptions)==null?void 0:f.indexAxis}),{data:n}=s.useDashboardCardQuery(t),r=a==="y"?"Metric":"Dimension",o=a==="y"?"Dimension":"Metric",{keys:l,metricKeys:i,dimensionKeys:d}=s.getKeys((n==null?void 0:n.records)||[]);let m=i;if(["stackedBar","stackedLine"].includes(t.type)){const p=s.pivotData({dataArray:(n==null?void 0:n.records)||[],groupKey:d[0],pivotKey:d[1],valueKey:m[0]}),{metricKeys:u}=s.getKeys(p);m=u}return l.length===0?null:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:r}),e.jsx("div",{className:"max-h-[125px] space-y-1 overflow-y-auto",children:d.map(p=>e.jsx("p",{className:"rounded-md bg-muted/70 px-3 py-2 hover:bg-muted",title:p,children:Ps(p)},p))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:o}),e.jsx("div",{className:"my-1 max-h-[125px] space-y-1 overflow-y-auto",children:m.map((p,u)=>e.jsx(Mn,{col:p,idx:u},p))})]})]})}function Ps(t,a=30){return t.length>a?t.slice(0,a)+"...":t}function Mn({col:t,idx:a}){const n=s.useEditorStore(d=>{var m;return(m=d.card)==null?void 0:m.preferences}),r=s.useEditorStore(d=>{var m;return(m=d.card.preferences)==null?void 0:m.datasetOptions}),o=r==null?void 0:r.find(d=>d.idx===a),{setCardPreferences:l}=s.useEditorStore(d=>d.actions);function i(d){if(!o)l({...n,datasetOptions:[...r||[],{idx:a,type:d==="area"?"line":d,fill:d==="area"?"origin":""}]});else{const m={...o};m.type=d==="area"?"line":d,m.fill=d==="area"?"origin":"";const p=r==null?void 0:r.map(u=>u.idx===a?m:u);l({...n,datasetOptions:p})}}return e.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-3 py-2 hover:bg-muted",children:[e.jsx("p",{title:t,children:Ps(t)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Be,{onClick:()=>i("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsx(Ve,{onClick:()=>i("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsx(rt,{onClick:()=>i("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsx(An,{idx:a})]})]})}function Hs(){const t=s.useEditorStore(c=>c.selectedConnectionId),a=s.useEditorStore(c=>c.selectedDatamodelId),n=s.useEditorStore(c=>c.selectedDatabaseName),r=s.useEditorStore(c=>c.selectedSchemaName),o=s.useEditorStore(c=>c.selectedTableName),l=s.useDashboardStore(c=>c.dashboard.filters)||[],i=s.useDashboardStore(c=>c.actions.addFilter),d=s.useDashboardStore(c=>c.actions.removeFilter),{removeFilterValues:m}=s.useDashboardActions(),{modelItems:p,tableName:u,connectionType:x}=ne();function f(c,y="dashboard"){var B;const h=s.fmt(c.column_name),C=s.fmt(n||""),v=s.fmt(r||""),M=s.fmt(u);let D=s.getQualifiedTableName({schemaName:v,tableName:M,connectionType:x,databaseName:C}),L=`${D}.${h}`;const k=(B=p==null?void 0:p.find(R=>R.id===a))==null?void 0:B.name;a&&a!=="none"&&(L=`${s.DATAMODEL_NAMESPCACE}.${k}.${h}`,D=`${s.DATAMODEL_NAMESPCACE}.${k}`);const A=l==null?void 0:l.find(R=>R.column===L&&R.table===M&&(R.database===C||R.database===n));if(A)m(A.id),d(A.id);else{const R=s.v4();return u==="api"&&t?(i({location:y,id:R,column:L,title:c.column_name,dataType:c.data_type,table:"api",database:"",connectionId:t,operation:"in",sql:s.getDefaultFilterSql(c.data_type,D,h)}),R):(i({id:R,location:y,column:L,title:c.column_name,dataType:c.data_type,table:o||"",database:n||"",connectionId:t||"",operation:"in",sql:s.getDefaultFilterSql(c.data_type,D,h)}),R)}}return{assignFilter:f}}function me(){const t=s.useDashboardStore(d=>d.dashboard.filters),a=s.useEditorStore(d=>d.frame),{setFrame:n}=s.useEditorActions(),{columns:r}=ne(),{assignFilter:o}=Hs();function l(d){const m=o(d,"frame");n({...a,filterId:m})}const i=t==null?void 0:t.find(d=>d.id===a.filterId);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(s.Label,{children:"Card Filter"}),e.jsx(Ln,{onSelect:l,columns:r}),i&&e.jsx(s.FilterHeader,{filter:i})]})}function Ln({columns:t,onSelect:a}){var i;const[n,r]=de.useState(!1),[o,l]=de.useState("");return e.jsxs(s.Popover,{open:n,onOpenChange:r,children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsxs(s.Button,{size:"sm",variant:"outline",role:"combobox","aria-expanded":n,className:"w-full justify-between font-normal",children:[o?(i=t.find(d=>d.column_name===o))==null?void 0:i.column_name:"Select Column...",e.jsx(s.CaretSortIcon,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(s.PopoverContent,{className:"w-[200px] p-0",children:e.jsxs(s.Command,{children:[e.jsx(s.CommandInput,{placeholder:"Search column",className:"h-9"}),e.jsxs(s.CommandList,{children:[e.jsx(s.CommandEmpty,{children:"No framework found."}),e.jsx(s.CommandGroup,{children:t==null?void 0:t.map(d=>e.jsxs(s.CommandItem,{value:d.column_name,onSelect:m=>{const p=m===o?"":m;l(p),r(!1),p&&a(d)},children:[d.column_name,e.jsx(s.CheckIcon,{className:s.cn("ml-auto h-4 w-4",o===d.column_name?"opacity-100":"opacity-0")})]},d.column_name))})]})]})})]})}function On({cardType:t}){return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(s.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{children:`${s.titleCase(t)} Chart`}),e.jsxs(s.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"x-axis - category"}),e.jsx("li",{children:"y-axis1 - number"}),e.jsx("li",{children:"y-axis2 - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:a=>a.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/bar-line-area",children:"example"})," in the docs."]})]})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsx(s.AccordionContent,{className:"space-y-4 px-2",children:e.jsx(qs,{})})]}),e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(oe,{}),e.jsx(me,{})]})]})]})})}function Ge(){var o,l,i;const t=s.useEditorStore(d=>d.card.type),a=s.useEditorStore(d=>d.card.preferences),{setCardPreferences:n}=s.useEditorStore(d=>d.actions);function r(d){var u;const m={datalabels:{display:d!=="none",align:d,anchor:d,clamp:!0}},p={...a,chartOptions:{...a==null?void 0:a.chartOptions,plugins:{...(u=a==null?void 0:a.chartOptions)==null?void 0:u.plugins,...m}}};n(p),console.log(d)}return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"font-medium",children:"Data Labels"}),e.jsxs(s.Select,{value:((i=(l=(o=a==null?void 0:a.chartOptions)==null?void 0:o.plugins)==null?void 0:l.datalabels)==null?void 0:i.anchor)||"none",onValueChange:r,defaultValue:"none",children:[e.jsx(s.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{placeholder:"Select position"})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Data Labels"}),e.jsx(s.SelectItem,{value:"none",children:"None"}),t!=="pyramid"&&e.jsx(s.SelectItem,{value:"start",children:"Start"}),e.jsx(s.SelectItem,{value:"center",children:"Center"}),t!=="pyramid"&&e.jsx(s.SelectItem,{value:"end",children:"End"})]})})]})]})}function zn({cardType:t}){function a(n){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:n==="bubble"?"SELECT label, [group], x-axis, y-axis, radius FROM table":"SELECT label, [group], x-axis, y-axis FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"label - category"}),e.jsx("li",{children:"group (optional) - category"}),e.jsx("li",{children:"x-axis - number"}),e.jsx("li",{children:"y-axis - number"}),n==="bubble"&&e.jsx("li",{children:"radius - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:l=>l.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/bubble",children:"example"})," in the docs."]})]})}return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(s.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{children:`${s.titleCase(t)} Chart`}),e.jsx(s.AccordionContent,{className:"space-y-4 font-mono text-xs",children:a(t)})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsx(s.AccordionContent,{className:"px-2",children:e.jsx(Ge,{})})]}),e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(oe,{}),e.jsx(me,{})]})]})]})})}const Fn={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},Rn={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function _n(){const t=s.useEditorStore(a=>a.card.type);return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(s.Accordion,{className:" ",type:"single",collapsible:!0,children:Bn(t)}),!["kpi"].includes(t)&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ge,{}),e.jsx(oe,{}),e.jsx(me,{})]})]})}function Bn(t){if(["line","bar"].includes(t))return e.jsxs(e.Fragment,{children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:e.jsx("p",{children:"Chart Query"})}),e.jsxs(s.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxs(s.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxs("p",{children:["Click ",e.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsx("pre",{children:JSON.stringify(Fn,null,2)})]})]}),e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxs(s.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxs("p",{children:["Click ",e.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.jsx("a",{className:"mx-1 text-blue-500 hover:underline",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),e.jsx("pre",{children:JSON.stringify(Rn,null,2)})]})]})]});if(t==="bubble")return e.jsx(e.Fragment,{children:e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:["How to create a ",e.jsx("span",{children:t})," chart query?"]})}),e.jsxs(s.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(t==="scatter")return e.jsx(e.Fragment,{children:e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:["How to create a ",e.jsx("span",{children:t})," chart query?"]})}),e.jsxs(s.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(t))return e.jsx(e.Fragment,{children:e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:[e.jsx("span",{children:t==="polarArea"?"Polar":t.charAt(0).toUpperCase()+t.slice(1)})," ","chart query"]})}),e.jsxs(s.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function Vn(){var m,p,u,x,f;const t=s.useEditorStore(c=>c.card.preferences),a=s.useEditorStore(c=>c.actions.setCardPreferences),n=s.useEditorStore(c=>c.actions.setNumberFormat);s.useEditorStore(c=>{var y,h;return(h=(y=c.card.preferences)==null?void 0:y.formatNumber)==null?void 0:h.decimalPlaces});const r=s.useEditorStore(c=>{var y,h;return(h=(y=c.card.preferences)==null?void 0:y.formatNumber)==null?void 0:h.locale}),o=s.useEditorStore(c=>{var y,h;return(h=(y=c.card.preferences)==null?void 0:y.formatNumber)==null?void 0:h.currency});s.useEditorStore(c=>c.actions.setFilterOnClickField);const l=s.useEditorStore(c=>{var y,h;return(h=(y=c.card.preferences)==null?void 0:y.formatNumber)==null?void 0:h.colorRanges})||[],i=s.useEditorStore(c=>c.actions.setColorRanges),d=[...new Set(s.LOCALE_CURRENCY_PAIRS.map(c=>c.currency))];return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(s.Checkbox,{checked:!!((m=t==null?void 0:t.formatNumber)!=null&&m.enabled),onCheckedChange:c=>{a({...t,formatNumber:{...t==null?void 0:t.formatNumber,enabled:c}})}}),e.jsx(s.Label,{children:"Format Number"})]}),((p=t==null?void 0:t.formatNumber)==null?void 0:p.enabled)===!0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{children:e.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(s.Label,{children:"Locale"}),e.jsxs(s.Select,{value:r||"none",onValueChange:c=>{var y,h,C;return n(((y=t==null?void 0:t.formatNumber)==null?void 0:y.decimalPlaces)||0,((h=t==null?void 0:t.formatNumber)==null?void 0:h.currency)||"",c,((C=t==null?void 0:t.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsx(s.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Format"}),e.jsx(s.SelectItem,{value:"none",children:"None"},"none"),s.LOCALE_CURRENCY_PAIRS.map(c=>e.jsx(s.SelectItem,{value:c.locale,children:c.locale},c.locale))]})})]})]}),e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(s.Label,{children:"Currency"}),e.jsxs(s.Select,{value:o||"none",onValueChange:c=>{var y,h,C;console.log("currency",c),n(((y=t==null?void 0:t.formatNumber)==null?void 0:y.decimalPlaces)||0,c==="none"?"":c,((h=t==null?void 0:t.formatNumber)==null?void 0:h.locale)||"",((C=t==null?void 0:t.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsx(s.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:e.jsxs(s.SelectGroup,{children:[e.jsx(s.SelectLabel,{children:"Currency"}),e.jsx(s.SelectItem,{value:"none",children:"None"},"none"),d.map(c=>e.jsx(s.SelectItem,{value:c,children:c},c))]})})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(s.Label,{children:"Decimals"}),e.jsxs(s.Select,{value:((x=(u=t==null?void 0:t.formatNumber)==null?void 0:u.decimalPlaces)==null?void 0:x.toString())||"0",onValueChange:c=>{var y,h,C;return n(Number(c),((y=t==null?void 0:t.formatNumber)==null?void 0:y.currency)||"",((h=t==null?void 0:t.formatNumber)==null?void 0:h.locale)||"",((C=t==null?void 0:t.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsx(s.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(s.SelectValue,{})}),e.jsx(s.SelectContent,{children:["0","1","2","3","4"].map(c=>e.jsx(s.SelectItem,{value:c,children:c},c))})]})]}),e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(s.Label,{children:"Suffix"}),e.jsx(s.Input,{value:((f=t==null?void 0:t.formatNumber)==null?void 0:f.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:c=>{var y,h,C;return n(((y=t==null?void 0:t.formatNumber)==null?void 0:y.decimalPlaces)||0,((h=t==null?void 0:t.formatNumber)==null?void 0:h.currency)||"",((C=t==null?void 0:t.formatNumber)==null?void 0:C.locale)||"",c.target.value)}})]})]})]})}),e.jsx(s.Separator,{className:"my-3"}),e.jsx(s.ColorFormat,{colorRanges:l,setColorRanges:i})]})]})}function qn(){return e.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsx(s.Accordion,{type:"single",collapsible:!0,children:e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxs(s.AccordionContent,{className:"font-mono",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"current - number"}),e.jsx("li",{children:"previous - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/kpi",children:"example"})," in the docs."]})]})]})}),e.jsx("section",{className:"",children:e.jsx(Vn,{})}),e.jsx("div",{}),e.jsx("div",{})]})}function ke({children:t,summary:a,open:n,className:r}){return e.jsxs("details",{open:n,className:s.cn("space-y-4 [&_summary>svg]:open:-rotate-180",r),children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-4",children:[e.jsx(s.Label,{children:a}),e.jsx(s.ChevronUp,{className:"h-4 w-4"})]}),e.jsx("div",{className:"transition-all ease-in-out",children:t})]})}const Pn=[{label:"Mercator",value:"mercator"},{label:"Azimuthal Equidistant",value:"azimuthalEquidistant"},{label:"Gnomonic",value:"gnomonic"},{label:"Orthographic",value:"orthographic"},{label:"Stereographic",value:"stereographic"},{label:"Equal Earth",value:"equalEarth"},{label:"Albers",value:"albers"},{label:"Albers USA",value:"albersUsa"},{label:"Conic Conformal",value:"conicConformal"},{label:"Conic Equal Area",value:"conicEqualArea"},{label:"Conic Equidistant",value:"conicEquidistant"},{label:"Equirectangular",value:"equirectangular"},{label:"Transverse Mercator",value:"transverseMercator"},{label:"Natural Earth 1",value:"naturalEarth1"}],Hn=["blues","brBG","buGn","buPu","cividis","cool","cubehelixDefault","gnBu","greens","greys","inferno","magma","orRd","oranges","pRGn","piYG","plasma","puBu","puBuGn","puOr","puRd","purples","rainbow","rdBu","rdGy","rdPu","rdYlBu","rdYlGn","reds","sinebow","spectral","turbo","viridis","warm","ylGn","ylGnBu","ylOrBr","ylOrRd"],Gn=Hn.map(t=>({label:t,value:t}));function Un(){var m,p,u,x,f,c,y,h,C,v,M,D,L,k,A,B,R,G;const t=s.useEditorStore(g=>g.card),a=(p=(m=t==null?void 0:t.preferences)==null?void 0:m.mapVisualOptions)==null?void 0:p.topoJsonUrl,[n,r]=I.useState(((x=(u=t==null?void 0:t.preferences)==null?void 0:u.mapVisualOptions)==null?void 0:x.customTopoJsonUrl)||""),{setCardPreferences:o}=s.useEditorActions(),{data:l}=s.useTopoJson(t),i=Object.keys((l==null?void 0:l.objects)||{}).map(g=>({label:g,value:g}))||[],d=[{label:"US States 10m",value:"https://unpkg.com/us-atlas/states-10m.json"},{label:"Countries 50m",value:"https://unpkg.com/world-atlas/countries-50m.json"},{label:"Custom",value:"custom"}];return e.jsxs("div",{className:"p-6",children:[e.jsx(ke,{summary:"Map Chart",children:e.jsx("p",{className:"rounded-md bg-muted p-2 font-mono text-xs",children:"SELECT country, value FROM table"})}),e.jsx(s.Separator,{className:"my-4"}),e.jsx(ke,{open:!0,summary:"Settings",children:e.jsxs("div",{className:"space-y-3 px-2",children:[e.jsx(Y,{className:"h-9",options:d,onValueChange:g=>{console.log("value",g),o({...t.preferences,mapVisualOptions:{topoJsonUrl:g}})},value:a||"",label:"Select Map"}),a==="custom"&&e.jsx(s.Input,{onChange:g=>{r(g.target.value)},onBlur:()=>{var g;console.log("onBlur",n),o({...t.preferences,mapVisualOptions:{...(g=t.preferences)==null?void 0:g.mapVisualOptions,customTopoJsonUrl:n}})},value:n,className:`h-9 w-full ${s.removeRing}`,placeholder:"Custom URL"}),l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(s.Label,{children:"Map Object"}),e.jsx(Y,{className:"h-9",options:i,value:((c=(f=t.preferences)==null?void 0:f.mapVisualOptions)==null?void 0:c.objectKey)||"",label:"Map Object",onValueChange:g=>{var N;o({...t.preferences,mapVisualOptions:{...(N=t.preferences)==null?void 0:N.mapVisualOptions,objectKey:g}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(s.Label,{children:"Projection"}),e.jsx(Y,{className:"h-9",options:Pn,value:((h=(y=t.preferences)==null?void 0:y.mapVisualOptions)==null?void 0:h.projection)||"",label:"Projection",onValueChange:g=>{var N;o({...t.preferences,mapVisualOptions:{...(N=t.preferences)==null?void 0:N.mapVisualOptions,projection:g}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(s.Label,{children:"Colors"}),e.jsx(Y,{className:"h-9",options:Gn,value:((v=(C=t.preferences)==null?void 0:C.mapVisualOptions)==null?void 0:v.colorScale)||"",label:"Select Color Scale",onValueChange:g=>{var N;o({...t.preferences,mapVisualOptions:{...(N=t.preferences)==null?void 0:N.mapVisualOptions,colorScale:g}})}})]})]})]})}),e.jsx(s.Separator,{className:"my-4"}),e.jsx(ke,{className:"",summary:"Scale Options",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(s.Input,{className:`h-9 w-full ${s.removeRing}`,type:"number",step:.1,value:((D=(M=t.preferences)==null?void 0:M.mapVisualOptions)==null?void 0:D.projectionScale)||1,onChange:g=>{var N;o({...t.preferences,mapVisualOptions:{...(N=t.preferences)==null?void 0:N.mapVisualOptions,projectionScale:Number(g.target.value)}})}}),e.jsx(s.Label,{children:"X"}),e.jsx(s.Input,{className:`h-9 w-full ${s.removeRing}`,type:"number",step:10,value:((A=(k=(L=t.preferences)==null?void 0:L.mapVisualOptions)==null?void 0:k.projectionOffset)==null?void 0:A[0])||0,onChange:g=>{var N,T,O,S;o({...t.preferences,mapVisualOptions:{...(N=t.preferences)==null?void 0:N.mapVisualOptions,projectionOffset:[Number(g.target.value),((S=(O=(T=t.preferences)==null?void 0:T.mapVisualOptions)==null?void 0:O.projectionOffset)==null?void 0:S[1])||0]}})}}),e.jsx(s.Label,{children:"Y"}),e.jsx(s.Input,{className:`h-9 w-full ${s.removeRing}`,type:"number",step:10,value:((G=(R=(B=t.preferences)==null?void 0:B.mapVisualOptions)==null?void 0:R.projectionOffset)==null?void 0:G[1])||0,onChange:g=>{var N,T,O,S;o({...t.preferences,mapVisualOptions:{...(N=t.preferences)==null?void 0:N.mapVisualOptions,projectionOffset:[((S=(O=(T=t.preferences)==null?void 0:T.mapVisualOptions)==null?void 0:O.projectionOffset)==null?void 0:S[0])||0,Number(g.target.value)]}})}})]})}),e.jsx(s.Separator,{className:"my-4"}),e.jsx(oe,{})]})}function $n(){var r;const t=s.useEditorStore(o=>o.card.preferences),{setCardPreferences:a}=s.useEditorStore(o=>o.actions);function n(o){a({...t,textVisualOptions:{...t==null?void 0:t.textVisualOptions,isDynamicText:o==="dynamic"}})}return e.jsxs(s.RadioGroup,{value:(r=t==null?void 0:t.textVisualOptions)!=null&&r.isDynamicText?"dynamic":"static",onValueChange:n,className:"flex gap-3",defaultValue:"x",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"static",id:"r1"}),e.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Static"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function fe({cardType:t,docContent:a,suffix:n="Chart"}){return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(s.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{children:`${s.titleCase(t)} ${n}`}),e.jsx(s.AccordionContent,{children:a||e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"label - category"}),e.jsx("li",{children:"measure - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/pie-donut-polar",children:"example"})," in the docs."]})]})})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[t!=="text"&&e.jsx(Ge,{}),t==="text"&&e.jsx($n,{})]})]}),!["range","text"].includes(t)&&e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(oe,{}),e.jsx(me,{})]})]})]})})}function Qn(){const t=s.useEditorStore(r=>{var o,l;return(l=(o=r==null?void 0:r.card)==null?void 0:o.preferences)==null?void 0:l.sortChart}),{setSortChart:a}=s.useEditorActions();function n(){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"Sort"}),e.jsx(Y,{className:"h-8",label:"Sort Chart",options:[{label:"None",value:"none"},{label:"ASC",value:"asc"},{label:"DESC",value:"desc"}],value:t||"none",onValueChange:r=>{a(r)}})]})}return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(s.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(s.AccordionItem,{value:"item-1",children:[e.jsx(s.AccordionTrigger,{children:"Stacked Chart"}),e.jsxs(s.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"x-axis - category"}),e.jsx("li",{children:"stack by - category"}),e.jsx("li",{children:"y-axis - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/stacked",children:"example"})," in the docs."]})]})]}),e.jsxs(s.AccordionItem,{value:"item-2",children:[e.jsx(s.AccordionTrigger,{children:"Settings"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[n(),e.jsx(qs,{})]})]}),e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(oe,{}),e.jsx(me,{})]})]})]})})}function Jn({cardType:t="table"}){console.log("cardType",t);const a=s.useEditorStore(o=>{var l;return(l=o.card)==null?void 0:l.preferences}),n=s.useEditorStore(o=>o.actions.setCardPreferences),r=o=>{n({...a,allowDownload:o})};return e.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsx(s.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxs(s.AccordionItem,{value:"item-3",children:[e.jsx(s.AccordionTrigger,{children:"Filters"}),e.jsxs(s.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(oe,{}),e.jsx(me,{})]})]})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Checkbox,{onCheckedChange:r,id:"allow-download"}),e.jsx("label",{htmlFor:"allow-download",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Allow Download"})]})]})}const Kn=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/tornado",children:"example"})," in the docs."]})]}),Wn=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT y-axis, label, range-from, range-to, range-value FROM table"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/range",children:"example"})," in the docs."]})]}),Yn=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT text FROM table limit 1"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/text",children:"example"})," in the docs."]})]});function Zn(){const t=s.useEditorStore(n=>n.card.type);function a(n){switch(n){case"stackedBar":case"stackedLine":return e.jsx(Qn,{});case"pyramid":return e.jsx(fe,{docContent:Kn,cardType:n});case"kpi":return e.jsx(qn,{});case"line":case"bar":return e.jsx(On,{cardType:n});case"range":return e.jsx(fe,{docContent:Wn,cardType:n});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsx(fe,{cardType:n});case"bubble":case"scatter":return e.jsx(zn,{cardType:n});case"table":return e.jsx(Jn,{cardType:n});case"text":return e.jsx(fe,{docContent:Yn,cardType:n,suffix:"Visual"});case"map":return e.jsx(Un,{});case"custom":return e.jsx(Tn,{});default:return e.jsx(_n,{})}}return e.jsxs(s.ScrollArea,{className:"h-full w-full text-sm",children:[a(t),e.jsx(s.ScrollBar,{orientation:"horizontal"})]})}const Ie={id:"__placeholder__",role:"groupby",type:"string"},De={id:"__placeholder__",role:"metric",type:"number"},Ee={id:"__placeholder__",role:"trendby",type:"date"},Te={id:"__placeholder__",role:"filter",type:"string"},Xn={id:"__placeholder__"},Se="droppable-group-by",Ce="droppable-metrics",Le="sortable-group-by",Oe="sortable-metrics",ze="droppable-trend-by",Fe="sortable-trend-by",Re="droppable-filters",_e="sortable-filters";function ea(){const t=s.useDndStore(g=>g.insertIndex),a=s.useEditorStore(g=>{var N;return((N=g.card.queryConfig)==null?void 0:N.groupByColumns)||[]}),n=s.useEditorStore(g=>{var N;return((N=g.card.queryConfig)==null?void 0:N.metricColumns)||[]}),r=s.useEditorStore(g=>{var N;return((N=g.card.queryConfig)==null?void 0:N.trendByColumns)||[]}),o=s.useEditorStore(g=>{var N;return((N=g.card.queryConfig)==null?void 0:N.filterColumns)||[]}),{setInsertIndex:l,setActiveId:i,setPreviewGroupByColumns:d,setPreviewMetricColumns:m,setPreviewTrendByColumns:p,setPreviewFilterColumns:u}=s.useDndActions(),{setGroupByColumns:x,setMetricColumns:f,setTrendByColumns:c,setFilterColumns:y}=s.useEditorActions(),{columns:h}=Ns(),C=s.useSensors(s.useSensor(s.MouseSensor,{activationConstraint:{distance:1}})),v=g=>{var O;const{active:N,over:T}=g;if(((O=N.data.current)==null?void 0:O.type)==="column"&&T){const S=T.id,q=h.find(w=>w.column_name===N.id);if(!q)return;const P=s.isNumberDataType(q.data_type),U=s.isTextDataType(q.data_type),V=s.isDateDataType(q.data_type);if(U){if(a.some(j=>j.id===S)){const j=a.findIndex(b=>b.id===S);l(j);const E=a.filter(b=>b.id!==Ie.id);E.splice(j,0,Ie),d(E)}else if(T.id===Se){l(a.length);const j=[...a,Ie];d(j),m(n),p(r),u(o)}}if(P||U){if(n.some(j=>j.id===S)){console.log("isOverMetricSortable",S);const j=n.findIndex(b=>b.id===S);l(j);const E=n.filter(b=>b.id!==De.id);E.splice(j,0,De),m(E)}else if(T.id===Ce){l(n.length);const j=[...n,De];m(j),p(r),u(o),d(a)}}if(V){if(r.some(j=>j.id===S)){const j=r.findIndex(b=>b.id===S);l(j);const E=r.filter(b=>b.id!==Ee.id);E.splice(j,0,Ee),p(E)}else if(T.id===ze){l(r.length);const j=[...r,Ee];p(j),m(n),u(o),d(a)}}if(D(q)){if(o.some(j=>j.id===S)){const j=o.findIndex(b=>b.id===S);l(j);const E=o.filter(b=>b.id!==Te.id);E.splice(j,0,Te),u(E)}else if(T.id===Re){l(o.length);const j=[...o,Te];u(j),m(n),p(r),d(a)}}}else d(a),m(n),p(r),u(o)};function M(g){i(g.active.id),l(null),d(a),m(n),p(r),u(o)}function D(g){return!o.some(N=>N.name===g.column_name)}function L(g,N="SUM"){const{column_name:T,data_type:O}=g,S=[...n],q=t!==null?t:n.length,P={...g,id:ae(T),name:T,label:je(N,T),type:O,role:"metric",aggregate:N};S.splice(q,0,P),f(S)}function k(g){const N=[...a],T=t!==null?t:a.length,O={...g,id:ae(g.column_name),name:g.column_name,type:g.data_type,role:"groupby"};N.splice(T,0,O),x(N)}function A(g){const N=[...r],T=t!==null?t:r.length,O={...g,id:ae(g.column_name),name:g.column_name,type:g.data_type,role:"trendby"};N.splice(T,0,O),c(N)}function B(g){const N=[...o],T=t!==null?t:o.length,O={...g,id:ae(g.column_name),name:g.column_name,type:g.data_type,role:"filter"};N.splice(T,0,O),y(N)}function R(g){var S,q,P,U,V,w,j,E;const{active:N,over:T}=g,O=N.data.current;if((O==null?void 0:O.type)==="column"&&T){const b=h.find(W=>W.column_name===N.id);if(!b)return;const H=s.isNumberDataType(b.data_type),_=s.isTextDataType(b.data_type),J=s.isDateDataType(b.data_type);_&&(T.id===Se||((S=T.data.current)==null?void 0:S.type)===Le)?k(b):(H||_)&&(T.id===Ce||((q=T.data.current)==null?void 0:q.type)===Oe)?(H&&L(b),_&&L(b,"COUNT")):J&&(T.id===ze||((P=T.data.current)==null?void 0:P.type)===Fe)?A(b):D(b)&&(T.id===Re||((U=T.data.current)==null?void 0:U.type)===_e)&&B(b)}if(T&&((V=T.data.current)==null?void 0:V.type)===Le&&a.some(b=>b.id===N.id)){const b=a.findIndex(_=>_.id===N.id),H=a.findIndex(_=>_.id===T.id);if(b!==-1&&H!==-1&&b!==H){const _=[...a],[J]=_.splice(b,1);_.splice(H,0,J),x(_)}}if(T&&((w=T.data.current)==null?void 0:w.type)===Oe&&n.some(b=>b.id===N.id)){const b=n.findIndex(_=>_.id===N.id),H=n.findIndex(_=>_.id===T.id);if(b!==-1&&H!==-1&&b!==H){const _=[...n],[J]=_.splice(b,1);_.splice(H,0,J),f(_)}}if(T&&((j=T.data.current)==null?void 0:j.type)===Fe&&r.some(b=>b.id===N.id)){const b=r.findIndex(_=>_.id===N.id),H=r.findIndex(_=>_.id===T.id);if(b!==-1&&H!==-1&&b!==H){const _=[...r],[J]=_.splice(b,1);_.splice(H,0,J),c(_)}}if(T&&((E=T.data.current)==null?void 0:E.type)===_e&&o.some(b=>b.id===N.id)){const b=o.findIndex(_=>_.id===N.id),H=o.findIndex(_=>_.id===T.id);if(b!==-1&&H!==-1&&b!==H){const _=[...o],[J]=_.splice(b,1);_.splice(H,0,J),y(_)}}i(null),l(null),d(a),m(n),p(r),u(o)}function G(){i(null),l(null),d(a),m(n),p(r),u(o)}return{handleDragOver:v,handleDragEnd:R,handleDragStart:M,handleDragCancel:G,sensors:C}}const ce=[{label:"Sum",value:"SUM",logo:e.jsx(fs,{className:"size-3.5"})},{label:"Count",value:"COUNT",logo:e.jsx(us,{className:"size-3.5"})},{label:"Count Distinct",value:"DISTINCT",logo:e.jsx(xt,{className:"size-3.5"})},{label:"Average",value:"AVG",logo:e.jsx(Xs,{className:"size-3.5"})},{label:"Min",value:"MIN",logo:e.jsx(ts,{className:"size-3.5"})},{label:"Max",value:"MAX",logo:e.jsx(s.ArrowUp,{className:"size-3.5"})}];function Gs({column:t,type:a,onRemoveColumn:n,droppableId:r}){const[o,l]=I.useState(!1),[i,d]=I.useState(ce[0]),{attributes:m,listeners:p,setNodeRef:u,transform:x,transition:f,isDragging:c}=s.useSortable({id:t.id,data:{type:a}}),y=x?{opacity:c?.5:void 0,transform:s.CSS.Translate.toString(x),transition:f}:void 0;function h(){return e.jsx("div",{"data-setting-container":"",className:"h-32 rounded-b-md border-x border-b border-border p-3 text-sm",children:e.jsx(e.Fragment,{})})}return e.jsxs("div",{...p,...m,ref:u,style:y,children:[e.jsxs("div",{className:s.cn("group flex h-9 items-center rounded-t-md bg-muted pl-0.5 pr-2.5",!o&&"rounded-b-md",o&&"border border-border",{"pl-2":r===Se}),children:[r===Ce&&e.jsx(ta,{column:t}),e.jsx("div",{children:e.jsx(s.GripVertical,{className:"mr-2 size-3.5 cursor-move items-center justify-center p-0 text-muted-foreground/60 hover:text-foreground"})}),e.jsx("div",{className:"max-w-[250px] grow cursor-pointer overflow-hidden truncate text-ellipsis whitespace-nowrap",children:e.jsx(sa,{col:t})}),e.jsxs("div",{"data-setting-actions":"",className:"hidden h-full items-center gap-2 group-hover:flex",children:[e.jsx("button",{onClick:()=>l(!o),children:e.jsx(s.ChevronDown,{className:s.cn("ml-1 size-4 cursor-pointer items-center justify-center rounded-r-sm bg-muted text-muted-foreground",o&&"rotate-180")})}),e.jsx("button",{onClick:()=>n(t.id),children:e.jsx(s.X,{className:"size-3.5 cursor-pointer items-center justify-center rounded-r-sm bg-muted text-muted-foreground"})})]})]}),o&&h()]})}function sa({col:t}){return e.jsx(s.Editable,{text:t.label||t.name,className:"h-6 rounded-none",onSave:a=>{console.log("saved",a)},children:e.jsx("span",{className:"w-[250px] truncate text-ellipsis whitespace-nowrap text-sm",children:t.label||t.name})})}function ta({column:t}){const[a,n]=I.useState(ce[0]),{updateMetricColumn:r}=s.useEditorActions();let o=ce;s.isTextDataType(t.type)&&(o=o.filter(i=>["COUNT","DISTINCT"].includes(i.value))),s.isNumberDataType(t.type)&&(o=o.filter(i=>!["DISTINCT","COUNT"].includes(i.value))),I.useEffect(()=>{n(ce.find(i=>i.value===t.aggregate)||ce[0])},[t]);function l(i){const d=ce.find(p=>p.value===i);if(!d)return;n(d);const m={...t,aggregate:i,label:je(i,t.name)};r(t.id,m)}return e.jsx(Y,{className:"size-7 overflow-clip rounded-none rounded-l-md border-none bg-muted px-2",icon:a.logo,options:o,value:a.value,onValueChange:i=>l(i),label:"Aggregation"})}function Ae({id:t,label:a,columns:n,previewColumns:r,sortableType:o,onRemoveColumn:l}){const{setNodeRef:i}=s.useDroppable({id:t}),d=s.useDndStore(u=>u.activeId),m={},p=d?r:n;return e.jsx(s.SortableContext,{items:n==null?void 0:n.map(u=>u.id),children:e.jsxs("div",{className:"space-y-2 rounded-md border-2 border-dashed p-5",ref:i,style:m,children:[e.jsx(s.Label,{className:"text-sm",children:a}),e.jsx("div",{className:"space-y-2",children:p==null?void 0:p.map(u=>u.id===Xn.id?e.jsx(na,{},u.id):e.jsx(Gs,{droppableId:t,type:o,column:u,onRemoveColumn:l},u.id))})]})})}function na(){return e.jsx("div",{className:"flex h-7 grow items-center space-x-2 rounded-md border border-dashed border-muted-foreground bg-background px-2 py-1 text-sm"})}function ss(){const t=s.useEditorStore(c=>{var y;return((y=c.card.queryConfig)==null?void 0:y.groupByColumns)||[]}),a=s.useDndStore(c=>c.previewGroupByColumns),n=s.useEditorStore(c=>{var y;return((y=c.card.queryConfig)==null?void 0:y.metricColumns)||[]}),r=s.useDndStore(c=>c.previewMetricColumns),o=s.useEditorStore(c=>{var y;return((y=c.card.queryConfig)==null?void 0:y.trendByColumns)||[]}),l=s.useDndStore(c=>c.previewTrendByColumns),{setSelectedConnectionId:i,removeColumnFromGroupBy:d,removeColumnFromMetricColumns:m,removeColumnFromTrendByColumns:p}=s.useEditorActions();I.useEffect(()=>{i("c_2d3646f0-68a6-47e7-942d-d9cbc80fb7d4")},[i]);function u(c){d(c)}function x(c){p(c)}function f(c){m(c)}return e.jsxs("div",{className:"h-full w-full space-y-2 p-4",children:[e.jsx(Ae,{onRemoveColumn:u,sortableType:Le,id:Se,label:"Group By",columns:t,previewColumns:a}),e.jsx(Ae,{onRemoveColumn:x,sortableType:Fe,id:ze,label:"Trend By",columns:o,previewColumns:l}),e.jsx(Ae,{onRemoveColumn:f,sortableType:Oe,id:Ce,label:"Metrics",columns:n,previewColumns:r})]})}function aa({id:t,label:a,columns:n,previewColumns:r,sortableType:o,onRemoveColumn:l}){const{setNodeRef:i,isOver:d}=s.useDroppable({id:t}),m=s.useDndStore(x=>x.activeId),p={borderColor:d?"green":void 0},u=m?r:n;return e.jsx(s.SortableContext,{items:n==null?void 0:n.map(x=>x.id),children:e.jsxs("div",{className:"space-y-2 rounded-md border-2 border-dashed p-5",ref:i,style:p,children:[e.jsx(s.Label,{className:"text-sm",children:a}),e.jsx("div",{className:"flex flex-wrap gap-4",children:u==null?void 0:u.map(x=>e.jsx(Gs,{droppableId:t,type:o,column:x,onRemoveColumn:l},x.id))})]})})}function ra(){const t=s.useEditorStore(o=>{var l;return((l=o.card.queryConfig)==null?void 0:l.filterColumns)||[]}),a=s.useDndStore(o=>o.previewFilterColumns),{removeColumnFromFilterColumns:n}=s.useEditorActions();function r(o){n(o)}return e.jsx("div",{className:"size-full p-4",children:e.jsx(aa,{onRemoveColumn:r,sortableType:_e,id:Re,label:"Filters",renderComponent:o=>e.jsx(ge,{className:"rounded-md bg-muted",column:{column_name:o.name,data_type:o.type}}),columns:t,previewColumns:a})})}function oa(){const t=s.useEditorStore(r=>r.card),{data:a,errorMessage:n}=s.useDashboardCardQuery(t);return e.jsxs("section",{className:"flex justify-between gap-2 p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ls,{}),e.jsx(ks,{sql:a==null?void 0:a.sql,error:n})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Ms,{}),e.jsx(As,{variant:"default"})]})]})}function ia(){const t=I.useRef(null),a=s.useEditorStore(i=>i.isShowingVisual),n=s.useEditorStore(i=>i.showAIDialog),r=s.useEditorStore(i=>i.isDevMode);I.useEffect(()=>{var i,d;n?(i=t.current)==null||i.resize(0):(d=t.current)==null||d.resize(25)},[n]);function o(){return e.jsxs(e.Fragment,{children:[e.jsx(s.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsx(mn,{})}),e.jsx(s.ResizableHandle,{withHandle:!0,className:"border"}),e.jsx(s.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:a&&!n?e.jsxs(s.ResizablePanelGroup,{direction:"horizontal",children:[e.jsx(e.Fragment,{children:e.jsx(s.ResizablePanel,{ref:t,className:"flex",defaultSize:25,maxSize:30,children:r?e.jsx(Zn,{}):e.jsx(ss,{})})}),!n&&e.jsx(s.ResizableHandle,{className:"border"}),e.jsx(s.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsx(xe,{})})]}):e.jsx(xe,{})})]})}function l(){return e.jsx(e.Fragment,{children:e.jsx(s.ResizablePanel,{className:"pb-1","data-biz-mode-container":"",minSize:0,defaultSize:100,children:a&&!n?e.jsxs(s.ResizablePanelGroup,{direction:"horizontal",children:[e.jsx(e.Fragment,{children:e.jsx(s.ResizablePanel,{ref:t,className:"flex min-w-[320px]",defaultSize:25,maxSize:30,children:e.jsx(ss,{})})}),!n&&e.jsx(s.ResizableHandle,{className:"border"}),e.jsx(s.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxs(s.ResizablePanelGroup,{direction:"vertical",children:[e.jsxs(s.ResizablePanel,{className:"flex min-h-fit flex-col",minSize:10,defaultSize:20,children:[e.jsx(oa,{}),e.jsx(ra,{})]}),e.jsx(s.ResizableHandle,{className:"border"}),e.jsx(s.ResizablePanel,{minSize:20,defaultSize:80,children:e.jsx(xe,{})})]})})]}):e.jsx(xe,{})})})}return e.jsx(s.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:r?o():l()})}const la=[{title:"Help me write a query for",subtitle:"orders by month"},{title:"Create a bar chart for",subtitle:"sales by category"}];function ca(){const t=I.useRef(null),a=I.useRef(null),[n,r]=I.useState(!1),[o,l]=I.useState(s.isDevEnv),[i,d]=I.useState(!1),m=s.useEditorStore(V=>V.actions.setCardSql),p=s.useEditorStore(V=>V.actions.setRunSql),u=s.useEditorStore(V=>V.showAIDialog),{setShowAIDialog:x}=s.useEditorActions(),{messages:f,setMessages:c,reload:y,append:h,input:C,setInput:v,isLoading:M,handleAddCurrentTableToScope:D,removeFromCurrentSelections:L,currentAssitantScope:k,handleInputChange:A,handleSubmit:B,stop:R,chatStatus:G,toolStatus:g,llmUsage:N,errorMessage:T}=Ts();s.useAssistantScroll({scrollContainerRef:t,inputRef:a,messages:f}),I.useEffect(()=>{var V;u&&((V=a.current)==null||V.focus())},[u]);function O(V){m(V),p(!0)}function S(V){const w={role:"user",content:V.title+" "+V.subtitle};h(w)}function q(){return e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",children:e.jsx(cs,{className:"size-3.5 text-muted-foreground/70 hover:text-muted-foreground"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[e.jsx(s.DropdownMenuLabel,{children:"Options"}),e.jsx(s.DropdownMenuSeparator,{}),e.jsx(s.DropdownMenuCheckboxItem,{checked:n,onCheckedChange:r,children:"Token Usage"}),e.jsx(s.DropdownMenuCheckboxItem,{checked:o,onCheckedChange:l,children:"Tool Invocations"}),e.jsx(s.DropdownMenuCheckboxItem,{checked:i,onCheckedChange:d,children:"System Message"})]})]})}function P(){return e.jsxs("div",{"data-role":"header",children:[e.jsx("div",{className:"text-lg font-semibold",children:"Assistant"}),k&&k.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:k==null?void 0:k.map((V,w)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted px-2 py-1 text-xs",children:[s.getFormattedTableNameForQuery({schemaName:V.schemaName||"",tableName:V.tableName||"",modelName:V.datamodelName||"",connectionType:V.connectionType||"",databaseName:V.databaseName||""}),e.jsx("button",{onClick:()=>{L(V)},children:e.jsx(s.X,{className:"size-3 text-muted-foreground hover:text-foreground"})})]},w))}),(k==null?void 0:k.length)===0&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Context: None"}),e.jsxs(s.Button,{className:"h-6 text-xs",size:"sm",variant:"secondary",onClick:D,children:[e.jsx(s.Plus,{className:"mr-2 size-3"}),"Current Table"]})]})]})}const U=(C==null?void 0:C.length)===0&&(f==null?void 0:f.filter(V=>V.role==="user").length)===0;return e.jsxs("div",{"data-role":"editor-assistant",className:"flex h-full w-full flex-col justify-between gap-2 px-6 py-4",children:[e.jsxs("div",{"data-role":"header-section",className:"flex items-start justify-between gap-2",children:[P(),e.jsxs("div",{"data-role":"header-actions",className:"flex items-center",children:[q(),e.jsx(s.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",onClick:()=>{c([]),y()},children:e.jsx(s.RefreshCcw,{className:"size-3.5 text-muted-foreground"})}),e.jsx(s.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",onClick:()=>{x(!1)},children:e.jsx(s.X,{className:"size-4"})})]})]}),e.jsx(s.CustomScrollArea,{ref:t,className:"flex w-full grow basis-0",children:e.jsxs("div",{className:"space-y-4 py-2 pr-3","data-role":"messages",children:[e.jsx(s.PrintMessages,{messages:f,showTools:o,handleRun:O,showSystemMessage:i}),e.jsx(s.ChatStatus,{status:s.getStatus(G,g),isLoading:M})]})}),U&&e.jsx(s.Placeholders,{onClick:S,placeholders:la}),e.jsx(s.ChatInput,{onFocus:()=>{D()},stop:R,ref:a,setInput:v,input:C,handleInputChange:A,handleSubmit:B,isLoading:M}),N&&n&&e.jsx("div",{className:"flex h-8 items-center justify-between",children:e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Usage: ",N.promptTokens," prompt tokens,"," ",N.completionTokens," completion tokens,"," ",N.totalTokens," total tokens"]})}),T&&e.jsx("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:e.jsx("span",{children:T})})]})}function da({authToken:t,onSave:a,onClose:n}){const r=I.useRef(null),o=s.useEditorStore(C=>C.showAIDialog),{setAuthToken:l}=s.useDashboardActions(),{setShowAIDialog:i,setOnSave:d,setOnClose:m}=s.useEditorActions(),{handleDragOver:p,handleDragEnd:u,handleDragStart:x,handleDragCancel:f,sensors:c}=ea();I.useEffect(()=>{a&&d(a),n&&m(n)},[a,d,n,m]),I.useEffect(()=>{t&&t.accessToken&&l(t)},[t,l]),I.useEffect(()=>{var C,v;o?((C=r.current)==null||C.resize(40),i(!0)):(i(!1),(v=r.current)==null||v.resize(0))},[o,i]);function y(C){C<1?i(!1):o||i(!0)}function h(){return e.jsxs(s.ResizablePanelGroup,{"data-content":"editor-main",className:"grow",direction:"horizontal",children:[e.jsx(s.ResizablePanel,{className:"min-w-[510px] rounded-none border-x-[1px]",children:e.jsx(ia,{})}),e.jsx(s.ResizableHandle,{}),e.jsx(s.ResizablePanel,{"data-role":"editor-assistant-panel",ref:r,onResize:y,defaultSize:0,children:e.jsx(ca,{})})]})}return e.jsx(s.ErrorBoundary,{FallbackComponent:s.Fallback,children:e.jsx(s.DndContext,{sensors:c,onDragStart:x,onDragEnd:u,onDragOver:p,onDragCancel:f,children:e.jsxs("section",{className:"isolate flex h-full grow","data-content":"editor-panel",children:[e.jsx(ws,{type:"main"}),h()]})})})}function ua(){s.useDashboardStore(i=>i.selectedCardId);const t=s.useDashboardStore(i=>i.selectedSheetId),{setIsVisualEditing:a}=s.useDashboardStore(i=>i.actions),n=s.useDashboardStore(i=>i.isVisualEditing),r=s.useDashboardStore(i=>i.actions.updateFrame);function o(i){t&&(r(t,i),a(!1))}function l(){a(!1)}return e.jsx("div",{role:"editor-container",className:s.cn("flex grow",{"max-h-0 overflow-hidden":!n}),children:e.jsx(da,{onSave:o,onClose:l})})}function ma(){const t=s.useEditorStore(l=>l.selectedDatabaseName),a=s.useEditorStore(l=>l.selectedTableName),n=s.useDashboardStore(l=>l.dashboard.filters)||[],{columns:r}=ne(),{assignFilter:o}=Hs();return e.jsx(s.ScrollArea,{className:"flex-1 basis-0 flex-col px-3",children:r==null?void 0:r.map(l=>{const i=n==null?void 0:n.find(d=>d.column===s.fmt(l.column_name)&&d.table===a&&d.database===t);return e.jsx("div",{onClick:()=>o(l),className:s.cn("group flex cursor-pointer items-center justify-between border border-dashed border-background px-3 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":i}),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(He,{column:l}),e.jsx("span",{children:l.column_name})]})},l.column_name)})})}function ha(){s.useDashboardStore(a=>a.showFilters);const t=s.useDashboardStore(a=>a.actions.setShowFilters);return e.jsxs("section",{className:"relative flex min-w-[320px] grow flex-col border-l px-1",children:[e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsx(s.Label,{className:"px-2 text-lg",children:"Filters"}),e.jsx(s.Button,{onClick:()=>t(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsx(s.Cross2Icon,{})})]}),e.jsx("div",{className:"flex grow",children:e.jsx(ws,{type:"filter",ColumnsComponent:()=>e.jsx(ma,{})})})]})}function pa(){const t=s.useDashboardStore(r=>r.dashboard.filters),a=s.useDashboardStore(r=>r.theme),n=t==null?void 0:t.filter(r=>r.hide);return n!=null&&n.length?e.jsx("div",{className:s.cn("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5",{"bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]":a==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":a==="dark"}),children:n==null?void 0:n.map(r=>e.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[e.jsx(s.FilterHeader,{filter:r}),e.jsx(s.FilterComponent,{filter:r})]},r.id))}):null}function xa(){const t=s.useDashboardStore(r=>r.showFilters),a=s.useDashboardStore(r=>r.isVisualEditing),n=s.useDashboardStore(r=>r.isDashboardEditing);return e.jsxs("div",{role:"dashboard-plus-main",className:s.cn("",{"max-h-0 overflow-hidden":a,"flex grow overflow-auto":!a}),children:[e.jsxs("section",{className:"flex grow flex-col",children:[n&&e.jsx(pa,{}),e.jsx(s.DashboardTabs,{})]}),t&&e.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsx(ha,{})})]})}function fa(){const t=s.useDashboardStore(o=>o.dashboard),a=s.useDashboardStore(o=>o.actions.setDashboard),n=s.useDashboardStore(o=>o.showDashboardJSON),r=s.useDashboardStore(o=>o.actions.setShowDashboardJSON);return e.jsxs("div",{className:s.cn("relative p-2",{hidden:!n}),children:[e.jsxs(s.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>r(!1),children:[e.jsx(s.X,{className:"mr-2 h-4 w-4"}),"Close"]}),e.jsx(s.de,{onChange:o=>{if(o)try{JSON.parse(o),a(JSON.parse(o))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto",value:JSON.stringify(t,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}function ga({showControls:t=!1,showFooter:a=!0,...n}){return e.jsx(s.ErrorBoundary,{FallbackComponent:s.Fallback,children:e.jsxs(s.SemaphorContextProvider,{dashboardProps:n,children:[e.jsx(s.$e,{}),e.jsxs(s.UXProvider,{children:[e.jsx(fa,{}),e.jsxs(s.DashboardPanel,{...n,children:[t&&e.jsx($t,{}),e.jsx(ua,{}),e.jsx(xa,{})]})]})]})})}exports.Dashboard=s.Dashboard;exports.DashboardWC=s.DashboardWC;exports.SemaphorDataProvider=s.SemaphorQueryClient;exports.SemaphorQueryClient=s.SemaphorQueryClient;exports.createSqlGenConfig=s.createSqlGenConfig;exports.fmt=s.fmt;exports.getColumnDataType=s.getColumnDataType;exports.getFilterValueType=s.getFilterValueType;exports.getFormattedTableNameForQuery=s.getFormattedTableNameForQuery;exports.getQualifiedTableName=s.getQualifiedTableName;exports.getSql=s.getSql;exports.invalidateToken=s.invalidateToken;exports.isBooleanDataType=s.isBooleanDataType;exports.isColumnInSqlGen=s.isColumnInSqlGen;exports.isDateDataType=s.isDateDataType;exports.isNumberDataType=s.isNumberDataType;exports.isTextDataType=s.isTextDataType;exports.resolveDataType=s.resolveDataType;exports.resolveDatamodelName=s.resolveDatamodelName;exports.useCard=s.useCard;exports.useDashboardActions=s.useDashboardActions;exports.useDashboardStore=s.useDashboardStore;exports.useDateFilterHook=s.useDateFilterHook;exports.useEditorActions=s.useEditorActions;exports.useEditorStore=s.useEditorStore;exports.useTextFilterHook=s.useTextFilterHook;exports.ScheduleDashboard=Cs;exports.SelectComponent=le;exports.Surfboard=ga;exports.cleanCard=ys;exports.downloadPdf=Ss;exports.getDashbaordStateWithoutData=Pe;exports.useEditorAside=ne;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { c as A, p as Qt, u as E, a as Ze, b as Fe, d as Oa, e as za, B as J, P as rt, f as Aa, g as Fa, h as La, i as Ea, L as G, I as de, j as _a, k as Va, l as Ra, m as K, n as qa, o as ja, q as Pa, r as ds, s as ya, t as X, C as Kt, v as us, S as be, w as Ce, x as ve, y as xe, z as Ie, A as Ne, E as ie, T as Ba, F as je, G as Pe, H as Nt, J as Me, K as Wt, M as Zt, N as Ha, O as Yt, Q as Te, R as Xt, U as St, V as Ua, W as De, X as ba, Y as Ee, Z as p, _ as Ga, $ as Qe, a0 as mt, a1 as $a, a2 as Ja, a3 as Qa, a4 as Ka, a5 as Wa, a6 as Za, a7 as Ya, a8 as ms, a9 as Xa, aa as en, ab as tn, ac as an, ad as nn, ae as ye, af as hs, ag as nt, ah as Ke, ai as ht, aj as ps, ak as fs, al as gs, am as Vt, an as Oe, ao as ys, ap as ee, aq as ea, ar as st, as as sn, at as pt, au as Rt, av as pe, aw as bs, ax as Ye, ay as Cs, az as vs, aA as xs, aB as rn, aC as Ns, aD as wt, aE as Ss, aF as ws, aG as ks, aH as Ca, aI as Ms, aJ as Ds, aK as ta, aL as Ae, aM as Is, aN as qt, aO as _e, aP as ce, aQ as Ve, aR as Ts, aS as Os, aT as zs, aU as As, aV as Fs, aW as It, aX as Ls, aY as va, aZ as Es, a_ as xa, a$ as _s, b0 as Vs, b1 as Rs, b2 as qs, b3 as ln, b4 as js, b5 as aa, b6 as on, b7 as Ps, b8 as Bs, b9 as at, ba as Hs, bb as Us, bc as cn, bd as Gs, be as $s, bf as Js, bg as Qs, bh as Ks, bi as kt, bj as dn, bk as Ws, bl as na, bm as sa, bn as Je, bo as dt, bp as Zs, bq as Ys, br as Xs, bs as ra, bt as un, bu as mn, bv as ft, bw as er, bx as gt, by as hn, bz as pn, bA as fn, bB as tr, bC as ar, bD as nr, bE as sr, bF as Le, bG as ae, bH as ne, bI as se, bJ as la, bK as rr, bL as lr, bM as ir, bN as or, bO as Na, bP as Sa, bQ as gn, bR as cr, bS as dr, bT as ur, bU as mr, bV as hr, bW as pr, bX as fr, bY as gr, bZ as yr, b_ as br, b$ as yn, c0 as bn, c1 as Cr, c2 as vr, c3 as xr, c4 as Nr, c5 as Sr, c6 as wr, c7 as kr, c8 as Tt, c9 as Cn, ca as Mr, cb as Dr, cc as Ir, cd as Tr, ce as Or, cf as zr, cg as Ar } from "./chunks/index-COIhzXpT.js";
2
- import { D as ho, cl as po, cj as fo, cj as go, co as yo, cn as bo, cm as Co, cp as vo, cq as xo, ck as No, ch as So, ci as wo } from "./chunks/index-COIhzXpT.js";
1
+ import { c as A, p as Qt, u as E, a as Ze, b as Fe, d as Oa, e as za, B as J, P as rt, f as Aa, g as Fa, h as La, i as Ea, L as G, I as de, j as _a, k as Va, l as Ra, m as K, n as qa, o as ja, q as Pa, r as ds, s as ya, t as X, C as Kt, v as us, S as be, w as Ce, x as ve, y as xe, z as Ie, A as Ne, E as ie, T as Ba, F as je, G as Pe, H as Nt, J as Me, K as Wt, M as Zt, N as Ha, O as Yt, Q as Te, R as Xt, U as St, V as Ua, W as De, X as ba, Y as Ee, Z as p, _ as Ga, $ as Qe, a0 as mt, a1 as $a, a2 as Ja, a3 as Qa, a4 as Ka, a5 as Wa, a6 as Za, a7 as Ya, a8 as ms, a9 as Xa, aa as en, ab as tn, ac as an, ad as nn, ae as ye, af as hs, ag as nt, ah as Ke, ai as ht, aj as ps, ak as fs, al as gs, am as Vt, an as Oe, ao as ys, ap as ee, aq as ea, ar as st, as as sn, at as pt, au as Rt, av as pe, aw as bs, ax as Ye, ay as Cs, az as vs, aA as xs, aB as rn, aC as Ns, aD as wt, aE as Ss, aF as ws, aG as ks, aH as Ca, aI as Ms, aJ as Ds, aK as ta, aL as Ae, aM as Is, aN as qt, aO as _e, aP as ce, aQ as Ve, aR as Ts, aS as Os, aT as zs, aU as As, aV as Fs, aW as It, aX as Ls, aY as va, aZ as Es, a_ as xa, a$ as _s, b0 as Vs, b1 as Rs, b2 as qs, b3 as ln, b4 as js, b5 as aa, b6 as on, b7 as Ps, b8 as Bs, b9 as at, ba as Hs, bb as Us, bc as cn, bd as Gs, be as $s, bf as Js, bg as Qs, bh as Ks, bi as kt, bj as dn, bk as Ws, bl as na, bm as sa, bn as Je, bo as dt, bp as Zs, bq as Ys, br as Xs, bs as ra, bt as un, bu as mn, bv as ft, bw as er, bx as gt, by as hn, bz as pn, bA as fn, bB as tr, bC as ar, bD as nr, bE as sr, bF as Le, bG as ae, bH as ne, bI as se, bJ as la, bK as rr, bL as lr, bM as ir, bN as or, bO as Na, bP as Sa, bQ as gn, bR as cr, bS as dr, bT as ur, bU as mr, bV as hr, bW as pr, bX as fr, bY as gr, bZ as yr, b_ as br, b$ as yn, c0 as bn, c1 as Cr, c2 as vr, c3 as xr, c4 as Nr, c5 as Sr, c6 as wr, c7 as kr, c8 as Tt, c9 as Cn, ca as Mr, cb as Dr, cc as Ir, cd as Tr, ce as Or, cf as zr, cg as Ar } from "./chunks/index-CLv0skGQ.js";
2
+ import { D as ho, cl as po, cj as fo, cj as go, co as yo, cn as bo, cm as Co, cp as vo, cq as xo, ck as No, ch as So, ci as wo } from "./chunks/index-CLv0skGQ.js";
3
3
  import { jsxs as r, jsx as e, Fragment as te } from "react/jsx-runtime";
4
4
  import * as $e from "react";
5
5
  import ze, { useState as U, useMemo as jt, useEffect as oe, useRef as We, useCallback as vn, Suspense as Fr } from "react";
@@ -5604,7 +5604,7 @@ function xi({
5604
5604
  /* @__PURE__ */ e(Qa, { placeholder: "Search column", className: "h-9" }),
5605
5605
  /* @__PURE__ */ r(Ka, { children: [
5606
5606
  /* @__PURE__ */ e(Wa, { children: "No framework found." }),
5607
- /* @__PURE__ */ e(Za, { children: t.map((d) => /* @__PURE__ */ r(
5607
+ /* @__PURE__ */ e(Za, { children: t == null ? void 0 : t.map((d) => /* @__PURE__ */ r(
5608
5608
  Ya,
5609
5609
  {
5610
5610
  value: d.column_name,