react-semaphor 0.0.489 → 0.0.490
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{index-C1sBpCcr.js → index-1AZBqWCM.js} +7736 -7739
- package/dist/chunks/{index-BoBbG6pt.js → index-DIAWqd3Y.js} +96 -96
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +3 -2
- package/dist/types/main.d.ts +8 -0
- package/package.json +1 -1
package/dist/dashboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-DIAWqd3Y.js"),r=require("../types/index.cjs");exports.Dashboard=e.Dashboard;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
|
package/dist/dashboard/index.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./chunks/index-DIAWqd3Y.js"),Wt=require("./types/index.cjs"),e=require("react/jsx-runtime"),E=require("react");require("react-dom");function Kt(s){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(a,n,r.get?r:{enumerable:!0,get:()=>s[n]})}}return a.default=s,Object.freeze(a)}const de=Kt(E);/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -366,4 +366,4 @@
|
|
|
366
366
|
${c?`Python:
|
|
367
367
|
${c}`:""}
|
|
368
368
|
`;N(y)}function _(){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(gn,{jsonString:JSON.stringify(h,null,2)})})}),h&&h.length>0&&e.jsx(t.Button,{variant:"ghost",onClick:()=>o(!r),className:"absolute bottom-0 right-6 size-7 p-1",children:r?e.jsx(t.X,{className:"size-3.5 text-muted-foreground"}):e.jsx(it,{className:"size-3.5 text-muted-foreground"})})]})}function H(){return e.jsxs(t.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxs(t.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(pn,{})}),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(t.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxs(t.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(fn,{})}),e.jsx("code",{className:"absolute right-6 top-3 text-xs text-muted-foreground/70",children:"python"})]})]})]})}function Q(){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(t.Button,{title:"Shift + Enter",disabled:F||G,onClick:()=>{D()},className:"shrink-0",size:"sm",children:[F||G?e.jsx(oe,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(t.Play,{className:"mr-2 h-4 w-4"}),"Run"]}),e.jsx(vt,{sql:L==null?void 0:L.sql,error:j,onClick:V}),e.jsx(It,{}),e.jsx(t.Toggle,{pressed:a,onPressedChange:y=>n(y),className:"",size:"sm",children:e.jsx(xn,{className:"size-4 text-foreground/70"})}),e.jsx("button",{disabled:i,onClick:()=>{M(),S(!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(Dt,{}),e.jsx(kt,{})]})]})}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:[H(),_()]}),Q()]})}function vn({data:s}){var i;const[a,n]=E.useState([]),o=Object.keys(s[0]).map(d=>({accessorKey:d,header:({column:c})=>{const h=c.getIsSorted();return e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>c.toggleSorting(c.getIsSorted()==="asc"),children:[d,h==="asc"?e.jsx(t.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):h==="desc"?e.jsx(t.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),l=t.useReactTable({data:s,columns:o,getCoreRowModel:t.getCoreRowModel(),getPaginationRowModel:t.getPaginationRowModel(),onSortingChange:n,getSortedRowModel:t.getSortedRowModel(),manualPagination:!0,state:{sorting:a}});return e.jsxs(t.CustomScrollArea,{className:"grow overflow-auto font-mono text-xs text-foreground/95",children:[e.jsxs("table",{className:"w-full",children:[e.jsx(t.TableHeader,{className:"sticky top-0 z-50 h-0 bg-muted",children:l.getHeaderGroups().map(d=>e.jsx(t.TableRow,{className:"",children:d.headers.map(c=>e.jsx(t.TableHead,{className:"h-11 font-semibold text-foreground",children:c.isPlaceholder?null:t.flexRender(c.column.columnDef.header,c.getContext())},c.id))},d.id))}),e.jsx(t.TableBody,{children:(i=l.getRowModel().rows)!=null&&i.length?l.getRowModel().rows.map(d=>e.jsx(t.TableRow,{className:"h-11 whitespace-nowrap py-2","data-state":d.getIsSelected()&&"selected",children:d.getVisibleCells().map(c=>e.jsx(t.TableCell,{className:"py-2",children:t.flexRender(c.column.columnDef.cell,c.getContext())},c.id))},d.id)):e.jsx(t.TableRow,{children:e.jsx(t.TableCell,{colSpan:o.length,className:"h-24 text-center",children:"No results."})})})]}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})}function Cn({card:s}){var N,S,A,k,T,L,F,G,w,R,U;const[a,n]=E.useState(!1),[r,o]=E.useState([]),{authToken:l}=t.useSemaphorContext(),i=t.getTokenParams(l==null?void 0:l.accessToken),d=t.useDashboardStore(q=>q.themeStyle),c={colors:((S=(N=d==null?void 0:d.chart)==null?void 0:N.dataset)==null?void 0:S.backgroundColor)||[]};(A=s.customCardPreferences)!=null&&A.inputData;const{getCard:h}=t.useCustomVisual(((k=s.customCardPreferences)==null?void 0:k.url)||""),u=((T=s.customCardPreferences)==null?void 0:T.visualType)||"single",x=t.useEditorStore(q=>q.frame),{setCustomCardPreferences:v}=t.useEditorActions(),{data:m}=t.useDashboardCardQuery(s),b=E.useCallback((q,D)=>{o(j=>({...j,[q]:D}))},[]);if(!((L=s.customCardPreferences)!=null&&L.componentName))return null;const p=h((F=s.customCardPreferences)==null?void 0:F.componentName);function f(q){n(q)}const g=Object.keys(((G=s.customCardPreferences)==null?void 0:G.dataInputCardIds)||{}).map(q=>{var M,V,_;const D=(V=(M=s.customCardPreferences)==null?void 0:M.dataInputCardIds)==null?void 0:V[q].cardId,j=(_=x==null?void 0:x.cards)==null?void 0:_.find(H=>H.id===D);return j||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(E.Suspense,{fallback:e.jsx(e.Fragment,{}),children:[p&&u==="single"&&e.jsx(p,{params:i,theme:c,settings:(w=s.customCardPreferences)==null?void 0:w.settings,onDataChange:b,data:(m==null?void 0:m.records)||[]}),p&&u==="multiple"&&e.jsxs(e.Fragment,{children:[Object.keys(((R=s.customCardPreferences)==null?void 0:R.dataInputCardIds)||{}).map(q=>{var M,V,_;const D=(V=(M=s.customCardPreferences)==null?void 0:M.dataInputCardIds)==null?void 0:V[q].cardId,j=(_=x==null?void 0:x.cards)==null?void 0:_.find(H=>H.id===D);if(j)return e.jsx(t.MultiInputEmptyRenderer,{onLoadingStatus:f,onDataChange:b,dataInputIndex:q,card:j},j.id+q)}),e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(p,{theme:c,onDataChange:b,settings:g.map(q=>{var D;return(D=q==null?void 0:q.customCardPreferences)==null?void 0:D.settings}),data:g.map(q=>q!=null&&q.id?r==null?void 0:r[q.id]:[])})})]})]},(U=s.customCardPreferences)==null?void 0:U.componentName)})}function Et({className:s,...a}){var f;const n=t.useEditorStore(g=>g.card),r=((f=n.customCardPreferences)==null?void 0:f.showCardHeader)??!0,o=t.useEditorStore(g=>g.frame),l=t.useDashboardStore(g=>g.dashboard.filters);t.useEditorStore(g=>g.actions.setRunSql);const{updateFilter:i}=t.useDashboardActions(),d=l==null?void 0:l.find(g=>g.id===o.filterId),{data:c,isLoading:h,isFetching:u}=t.useDashboardCardQuery(n),{setCard:x}=t.useEditorActions(),{data:v}=t.useTopoJson(n),m=E.useMemo(()=>!n.id||!(c!=null&&c.records)?null:t.createChartConfig({data:c==null?void 0:c.records,cardType:n.type,queryConfig:n.queryConfig,customCfg:n.customCfg,preferences:n.preferences,topoJson:v}),[n.id,c==null?void 0:c.records,n.type,n.queryConfig,n.customCfg,n.preferences,v]);function b(g){return e.jsx(Cn,{card:g})}function p(){if(c!=null&&c.records&&(c==null?void 0:c.records.length)===0&&!h&&!u)return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[e.jsx(t.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 b(n);if(!["table","custom"].includes(n.type)&&m)return e.jsx(e.Fragment,{children:h||u?e.jsx(e.Fragment,{}):e.jsx(t.ChartJsVisual,{cfg:m})});if(n.type==="table"&&(c!=null&&c.records)&&(c==null?void 0:c.records.length)>0)return e.jsx("div",{className:"relative mb-2 flex h-full min-h-0 w-full flex-1 grow basis-0",children:e.jsx(t.TableVisual,{card:n,data:c==null?void 0:c.records})})}return e.jsxs(t.Card,{role:"editor-visual-card",className:t.cn("relative flex h-full flex-col rounded-none",s),...a,children:[r&&e.jsxs(t.CardHeader,{className:"flex flex-row items-start justify-between py-4",children:[e.jsxs("div",{children:[e.jsx(t.Editable,{enabled:!0,text:n.title,onSave:g=>x({...n,title:g}),children:e.jsx("div",{className:"flex items-center gap-5",children:e.jsx(t.CardTitle,{className:"text-base",children:n.title||"Add title"})})},n.title),e.jsx(t.Editable,{enabled:!0,text:n.description||"",onSave:g=>x({...n,description:g}),children:e.jsx(t.CardDescription,{children:n.description||"Add description"})},n.description)]}),d&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(t.Editable,{enabled:!0,className:"my-1",text:d.title||d.column,onSave:g=>i({...d,title:g}),children:e.jsx(t.Label,{children:d.title})}),e.jsx(t.FilterComponent,{filter:d})]})]}),e.jsx(t.CardContent,{className:"flex grow flex-col",children:p()})]})}const Te=({language:s,value:a,onChange:n,readonly:r})=>e.jsx(t.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:s,value:a,onChange:n}),Sn=()=>e.jsxs(t.DialogHeader,{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(t.DialogTitle,{children:"Customize Card"})}),e.jsxs(t.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."})]})]}),Nn=({customCode:s,cardCustomCfgString:a,mergedConfig:n,onConfigChange:r,onCodeChange:o})=>e.jsxs(t.Tabs,{defaultValue:"final-config",className:"flex w-1/2 flex-col",children:[e.jsxs(t.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsx(t.TabsTrigger,{value:"final-config",children:"Config"}),e.jsx(t.TabsTrigger,{value:"custom-config",children:"Changes"}),e.jsx(t.TabsTrigger,{value:"custom-code",children:"Custom Code"})]}),e.jsx(t.TabsContent,{value:"final-config",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(Te,{language:"json",value:n,onChange:r})}),e.jsx(t.TabsContent,{value:"custom-config",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(Te,{readonly:!0,language:"json",value:a,onChange:()=>{}})}),e.jsx(t.TabsContent,{value:"custom-code",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(Te,{language:"javascript",value:s,onChange:o})})]}),wn=({error:s,hasCardCustomConfig:a,onReset:n,onApply:r,onClose:o})=>e.jsxs(t.DialogFooter,{className:"flex items-center",children:[e.jsx(t.Label,{className:"mr-2 text-red-500",children:s}),e.jsx(t.Button,{disabled:!a,onClick:n,variant:"outline",children:"Reset"}),e.jsx(t.Button,{onClick:r,variant:"outline",children:"Apply"}),e.jsx(t.Button,{onClick:o,variant:"outline",children:"Close"})]});function kn(){const[s,a]=E.useState(!1),[n,r]=E.useState(""),[o,l]=E.useState(""),[i,d]=E.useState(""),[c,h]=E.useState(""),u=t.useEditorStore(k=>k.card),x=t.useEditorStore(k=>k.card.customCfg),v=x?JSON.stringify(x,null,2):"",{data:m}=t.useDashboardCardQuery(u),{data:b}=t.useTopoJson(u),{setCardCustomCfg:p,setCustomVisualCode:f}=t.useEditorActions(),g=k=>{var T,L;return JSON.stringify({...k,data:{...k.data,datasets:(L=(T=k.data)==null?void 0:T.datasets)==null?void 0:L.map(F=>({...F,data:[]}))}},null,2)},N=()=>{var T,L;if(!((T=m==null?void 0:m.records)!=null&&T.length))return;const k=t.createChartConfig({data:m.records,cardType:u.type,queryConfig:u.queryConfig,preferences:u.preferences,topoJson:b});if(k){r(g(k)),d(((L=u.preferences)==null?void 0:L.customVisualCode)||"");const F=t.merge(k,x);l(g(F))}},S=()=>{try{if(i&&f(i),o){const k=JSON.parse(o),T=t.getObjectDiff(JSON.parse(n),k);p(T),h("")}}catch{h("Invalid JSON configuration")}},A=Object.keys(x||{}).length===0;return e.jsxs(t.Dialog,{open:s,onOpenChange:a,children:[e.jsx(t.DialogTrigger,{asChild:!0,children:e.jsx(t.IconButton,{tooltip:"Customize Visual",onClick:N,className:A?"":"text-green-600 hover:text-green-700",children:e.jsx(t.Settings,{className:"h-4 w-4"})})}),e.jsxs(t.DialogContent,{className:"flex h-[600px] grow flex-col overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsx(Sn,{}),e.jsxs("div",{className:"flex grow gap-2",children:[e.jsx(t.ErrorBoundary,{FallbackComponent:t.FallbackEditorCard,children:e.jsx(Et,{className:"w-1/2 rounded shadow-none"})}),e.jsx(Nn,{customCode:i,cardCustomCfgString:v,mergedConfig:o,onConfigChange:k=>l(k??""),onCodeChange:k=>d(k??"")})]}),e.jsx(wn,{error:c,hasCardCustomConfig:!!x,onReset:()=>{l(n),p(null)},onApply:S,onClose:()=>a(!1)})]})]})}function Tt(s){const[a,n]=E.useState(null);return a}function Mt(){const{authToken:s}=t.useSemaphorContext(),{data:a,isLoading:n,isFetching:r,isError:o}=t.useQuery({queryKey:["plugins",s==null?void 0:s.accessToken],queryFn:()=>t.getPlugins(s==null?void 0:s.accessToken)});return{data:a,isLoading:n,isFetching:r,isError:o}}function Dn({onChartTypeChange:s}){const[a,n]=E.useState([]),{setCardCustomCfg:r,setCardPreferences:o,setCardType:l,setCustomCardPreferences:i}=t.useEditorActions(),{data:d}=Mt();function c(h,u){r(null),o({}),l(h),u&&i({type:"component",visualType:"single",url:u.url,componentName:u.name,icon:u.icon}),s==null||s()}return E.useEffect(()=>{(async()=>{var u;if(d){const v=(await Promise.all((u=d==null?void 0:d.plugins)==null?void 0:u.map(async m=>(await t.loadManifest(m.value)).visuals.map(f=>({name:f.name,icon:f.icon,url:m.value}))))).flat();n(v)}})()},[d]),a.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx(t.Separator,{className:"my-2"}),e.jsx("div",{className:"grid grid-cols-4 place-items-center",children:a.map((h,u)=>e.jsx(In,{text:h.name,onClick:()=>c("custom",h),icon:h.icon},h.url+h.name+u))})]})}const In=({text:s,icon:a,onClick:n})=>{const r=Tt(),o=s.charAt(0).toUpperCase();return e.jsx(t.IconButton,{onClick:n,tooltip:s,children:r?e.jsx(r,{className:"h-4 w-4"}):o})};function At(s){return ie({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:[]}]})(s)}function En(s){return ie({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:[]}]})(s)}function Lt(s){return ie({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:[]}]})(s)}function Ot(s){return ie({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M4.387 3h15.226a1 1 0 0 1 .948 1.316l-5.105 15.316a2 2 0 0 1 -1.898 1.368h-3.116a2 2 0 0 1 -1.898 -1.368l-5.104 -15.316a1 1 0 0 1 .947 -1.316"},child:[]},{tag:"path",attr:{d:"M5 9h14"},child:[]},{tag:"path",attr:{d:"M7 15h10"},child:[]}]})(s)}function zt(s){return ie({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:[]}]})(s)}function Ft(s){return ie({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:[]}]})(s)}function Rt({onChartTypeChange:s,iconClassName:a}){const{setCardType:n,setCardPreferences:r,setIsDevMode:o}=t.useEditorStore(u=>u.actions),{setCardCustomCfg:l,setCustomCardPreferences:i,setQueryConfig:d}=t.useEditorActions();function c(u,x){l(null),r({}),n(u),["kpi","custom","text","map"].includes(u)&&(o(!0),d(void 0)),s==null||s()}const h=1e3;return e.jsxs("div",{className:"grid grid-cols-4 place-items-center",children:[e.jsx(t.IconButton,{openDelay:h,tooltip:"Table",onClick:()=>c("table"),className:"h-10 p-4",children:e.jsx(Ve,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Bar Chart",onClick:()=>c("bar"),className:"h-10 p-4",children:e.jsx(Re,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Line Chart",onClick:()=>c("line"),className:"h-10 p-4",children:e.jsx(Be,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Stacked Bar Chart",onClick:()=>c("stackedBar"),className:"h-10 p-4",children:e.jsx(et,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Stacked Line Chart",onClick:()=>c("stackedLine"),className:"h-10 p-4",children:e.jsx(zt,{className:t.cn("size-5",a),strokeWidth:0})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Scatter Chart",onClick:()=>c("scatter"),className:"h-10 p-4",children:e.jsx(nt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Bubble Chart",onClick:()=>c("bubble"),className:"h-10 p-4",children:e.jsx(Lt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Pie Chart",onClick:()=>c("pie"),className:"h-10 p-4",children:e.jsx(st,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Doughnut Chart",onClick:()=>c("doughnut"),className:"h-10 p-4",children:e.jsx(rt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Funnel Chart",onClick:()=>c("funnel"),className:"h-10 p-4",children:e.jsx(Ot,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Radar Chart",onClick:()=>c("radar"),className:"h-10 p-4",children:e.jsx(dt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Polar Area Chart",onClick:()=>c("polarArea"),className:"h-10 p-4",children:e.jsx(At,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Tornado Chart",onClick:()=>c("tornado"),className:"h-10 p-4",children:e.jsx(xt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{tooltip:"Range Chart",onClick:()=>c("range"),className:"h-10 p-4",children:e.jsx(tt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"KPI",onClick:()=>c("kpi"),className:"h-10 p-4",children:e.jsx(Ft,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Text",onClick:()=>c("text"),className:"h-10 p-4",children:e.jsx(cs,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{tooltip:"Map",onClick:()=>c("map"),className:"h-10 p-4",children:e.jsx(ct,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Custom",onClick:()=>c("custom"),className:"h-10 p-4",children:e.jsx(mt,{className:t.cn("size-5",a)})})]})}function Tn({chartType:s,className:a,customIcon:n,componentName:r}){const o=Tt();switch(s){case"bar":return e.jsx(Re,{className:a});case"line":return e.jsx(Be,{className:a});case"pie":return e.jsx(st,{className:a});case"radar":return e.jsx(dt,{className:a});case"scatter":return e.jsx(nt,{className:a});case"bubble":return e.jsx(Lt,{className:a});case"doughnut":return e.jsx(rt,{className:a});case"stackedBar":return e.jsx(et,{className:a});case"stackedLine":return e.jsx(zt,{className:a});case"polarArea":return e.jsx(At,{className:a});case"funnel":return e.jsx(Ot,{className:a});case"tornado":case"pyramid":return e.jsx(xt,{className:a});case"range":return e.jsx(tt,{className:a});case"kpi":return e.jsx(Ft,{className:a});case"text":return e.jsx(Us,{className:a});case"map":return e.jsx(ct,{className:a});case"custom":return n&&o?e.jsx(o,{className:a}):r?r==null?void 0:r.charAt(0).toUpperCase():e.jsx(mt,{className:a});default:return e.jsx(Ve,{className:a})}}function Mn(){var l,i;const[s,a]=E.useState(!1),n=t.useEditorStore(d=>d.card),r=n.type,o=t.useDashboardStore(d=>d.isVisualEditing);return e.jsxs(t.Popover,{open:s,onOpenChange:a,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx(t.Button,{size:"sm",variant:o?"ghost":"outline",children:e.jsx(Tn,{className:"size-4",chartType:r,customIcon:(l=n.customCardPreferences)==null?void 0:l.icon,componentName:(i=n.customCardPreferences)==null?void 0:i.componentName})})}),e.jsxs(t.PopoverContentCustom,{onOpenAutoFocus:d=>d.preventDefault(),className:"w-50",children:[e.jsx(Rt,{onChartTypeChange:()=>a(!1)}),e.jsx(Dn,{onChartTypeChange:()=>a(!1)})]})]})}const ge="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function Ze(s,a){var r,o,l;const n=t.getNumberAxis(s,{});return["pie","doughnut","polarArea","funnel"].includes(a)?"category":((l=(o=(r=s==null?void 0:s.chartOptions)==null?void 0:r.scales)==null?void 0:o[n])==null?void 0:l.type)||"linear"}function An(){var M,V,_,H,Q,y;const[s,a]=E.useState(!1),n=t.useEditorStore(C=>{var I;return(I=C.card)==null?void 0:I.preferences}),r=t.useEditorStore(C=>{var I;return(I=C.card)==null?void 0:I.type}),o=t.getNumberAxis(n,{}),[l,i]=E.useState(Ze(n,r)),[d,c]=E.useState(((_=(V=(M=n==null?void 0:n.chartOptions)==null?void 0:M.scales)==null?void 0:V[o])==null?void 0:_.min)||""),[h,u]=E.useState(((y=(Q=(H=n==null?void 0:n.chartOptions)==null?void 0:H.scales)==null?void 0:Q[o])==null?void 0:y.max)||""),[x,v]=E.useState(d||h?"custom":"auto"),[m,b]=E.useState(""),[p,f]=E.useState(0),[g,N]=E.useState(""),[S,A]=E.useState(""),[k,T]=E.useState(""),L=t.useEditorStore(C=>C.actions.setCardPreferences),{updateCardInFrame:F}=t.useEditorActions(),G=t.useEditorStore(C=>C.card),w=["pie","doughnut","polarArea","funnel"].includes(r);E.useEffect(()=>{var C,I,B,$,z,W,P,Y,O,J,Z,te,pe,fe;i(Ze(n,r)),c(((B=(I=(C=n==null?void 0:n.chartOptions)==null?void 0:C.scales)==null?void 0:I[o])==null?void 0:B.min)===0?0:""),u(((W=(z=($=n==null?void 0:n.chartOptions)==null?void 0:$.scales)==null?void 0:z[o])==null?void 0:W.max)||""),b(((J=(O=(Y=(P=n==null?void 0:n.chartOptions)==null?void 0:P.scales)==null?void 0:Y[o])==null?void 0:O.ticks)==null?void 0:J.stepSize)||""),f(((Z=n==null?void 0:n.numberAxisFormat)==null?void 0:Z.decimalPlaces)||0),N(((te=n==null?void 0:n.numberAxisFormat)==null?void 0:te.suffix)||""),A(((pe=n==null?void 0:n.numberAxisFormat)==null?void 0:pe.currency)||""),T(((fe=n==null?void 0:n.numberAxisFormat)==null?void 0:fe.locale)||"")},[s,n,o,r]);function R(C,I){return I===""||/^[0-9\b]+$/.test(I)?Number(I):Number(C)}function U(){const C=[...new Set(t.LOCALE_CURRENCY_PAIRS.map(I=>I.currency))];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsx(t.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(t.Select,{value:S||"none",onValueChange:I=>A(I==="none"?"":I),children:[e.jsx(t.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Currency"}),e.jsx(t.SelectItem,{value:"none",children:"None"}),C.map(I=>e.jsx(t.SelectItem,{value:I,children:I},I))]})})]}),e.jsxs(t.Select,{value:k,onValueChange:I=>T(I),children:[e.jsx(t.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Locale"}),t.LOCALE_CURRENCY_PAIRS.map(I=>e.jsx(t.SelectItem,{value:I.locale,children:I.locale},I.locale))]})})]})]}),e.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsx(t.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsx(t.Input,{value:p,onChange:I=>f(Number(I.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${ge}`})]})]})}function q(){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-4 space-y-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for number axis"})}),e.jsxs("div",{className:"mt-2 grid grid-cols-3 items-center gap-2",children:[e.jsx(t.Label,{htmlFor:"scale",children:"Type"}),e.jsxs(t.Select,{disabled:w,value:l,onValueChange:C=>i(C),children:[e.jsx(t.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{id:"type",children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Option"}),e.jsx(t.SelectItem,{value:"linear",children:"Linear"}),e.jsx(t.SelectItem,{value:"logarithmic",children:"Logarithmic"}),e.jsx(t.SelectItem,{value:"category",children:"Category"})]})})]})]}),l=="linear"&&e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsx(t.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxs(t.RadioGroup,{disabled:w,id:"scale-option",value:x,onValueChange:C=>v(C),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.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(t.RadioGroupItem,{value:"custom",id:"r2"}),e.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),x==="custom"&&l=="linear"&&D()]})}function D(){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsx(t.Label,{htmlFor:"range",children:"Range"}),e.jsx(t.Input,{id:"min",value:d,onChange:C=>c(I=>R(I,C.target.value)),className:`col-span-1 h-8 w-full ${ge}`}),e.jsx(t.Input,{value:h,onChange:C=>u(I=>R(I,C.target.value)),id:"max",className:`col-span-1 h-8 w-full ${ge}`})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsx(t.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsx(t.Input,{value:m,onChange:C=>b(I=>R(I,C.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${ge}`})]})]})}function j(){var $;let C={};x==="custom"&&(C={min:d,max:h,ticks:{stepSize:m}});const I={...n||{},chartOptions:{...n==null?void 0:n.chartOptions,scales:{...($=n==null?void 0:n.chartOptions)==null?void 0:$.scales,[o]:{type:l,...l==="linear"?C:{}}}},numberAxisFormat:{decimalPlaces:p,suffix:g,currency:S,locale:k}};console.log(I),L(I);const B={...G,preferences:I};F(B)}return e.jsxs(t.Popover,{onOpenChange:C=>a(C),children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx(t.IconButton,{tooltip:"Format Number",children:e.jsx(ys,{className:"size-4"})})}),e.jsx(t.PopoverContentCustom,{align:"end",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:"Format Options"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the format for number axis"})]}),e.jsxs("div",{className:"grid gap-2",children:[U(),q(),e.jsx(t.SelectSeparator,{}),e.jsx("div",{className:"grid grid-cols-3",children:e.jsx(t.Button,{onClick:j,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function Ln(){const s=t.useEditorStore(d=>{var c,h,u,x;return(x=(u=(h=(c=d.card.preferences)==null?void 0:c.chartOptions)==null?void 0:h.plugins)==null?void 0:u.legend)==null?void 0:x.position}),a=t.useEditorStore(d=>{var c,h,u,x;return(x=(u=(h=(c=d.card.preferences)==null?void 0:c.chartOptions)==null?void 0:h.plugins)==null?void 0:u.legend)==null?void 0:x.align}),n=t.useEditorStore(d=>{var c,h,u,x;return(x=(u=(h=(c=d.card.preferences)==null?void 0:c.chartOptions)==null?void 0:h.plugins)==null?void 0:u.legend)==null?void 0:x.display}),{setLegendOptions:r}=t.useEditorActions(),o=d=>{r({display:d,position:s,align:a})},l=d=>{r({display:n,position:d,align:a})},i=d=>{r({display:n,position:s,align:d})};return e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx(t.IconButton,{tooltip:"Legend Settings",children:e.jsx(Es,{className:"size-4"})})}),e.jsx(t.PopoverContentCustom,{align:"end",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(t.Label,{htmlFor:"displayLegend",children:"Display"}),e.jsx("div",{className:"col-span-2 flex h-8 items-center",children:e.jsx(t.SmallSwitch,{checked:n,onCheckedChange:o,id:"displayLegend"})})]}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(t.Label,{htmlFor:"position",children:"Position"}),e.jsxs("div",{className:"col-span-2 flex h-8 items-center",children:[e.jsx(t.IconButton,{tooltip:"Top",onClick:()=>l("top"),children:e.jsx(t.ArrowUp,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Left",onClick:()=>l("left"),children:e.jsx(ns,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Bottom",onClick:()=>l("bottom"),children:e.jsx(Xe,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Right",onClick:()=>l("right"),children:e.jsx(as,{className:"size-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(t.Label,{htmlFor:"align",children:"Align"}),e.jsxs("div",{className:"col-span-2 flex h-8 items-center",children:[e.jsx(t.IconButton,{tooltip:"Start",onClick:()=>i("start"),children:e.jsx(Zt,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Center",onClick:()=>i("center"),children:e.jsx(Yt,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"End",onClick:()=>i("end"),children:e.jsx(Xt,{className:"size-4"})})]})]})]})]})]})})]})}function On(){const s=t.useEditorStore(l=>{var i,d;return(d=(i=l.card.preferences)==null?void 0:i.chartOptions)==null?void 0:d.indexAxis}),a=t.useEditorStore(l=>l.card.type),{setChartOrientation:n}=t.useEditorStore(l=>l.actions);function r(){return e.jsx(t.IconButton,{onClick:()=>{n(s==="x"||s===void 0?"y":"x")},tooltip:"Chart Orientation",children:s==="x"||s===void 0?e.jsx(Qe,{className:"size-4"}):e.jsx($e,{className:"size-4"})})}function o(){return e.jsx(t.IconButton,{onClick:()=>{n(s==="y"||s===void 0?"x":"y")},tooltip:"Chart Orientation",children:s==="y"||s===void 0?e.jsx(Qe,{className:"size-4"}):e.jsx($e,{className:"size-4"})})}return e.jsx(e.Fragment,{children:a==="funnel"?o():r()})}function zn(){const s=t.useEditorStore(i=>i.card),a=t.useEditorStore(i=>i.isShowingVisual),n=t.useEditorStore(i=>{var d,c;return(c=(d=i.card)==null?void 0:d.preferences)==null?void 0:c.chartOptions}),r=t.getChartGridStyle(n),{setChartGrid:o}=t.useEditorActions();function l(){const i=["xy","none","x","y"],c=(i.indexOf(r)+1)%i.length;o(i[c])}return a?e.jsxs("div",{"data-info":"visual-settings",className:"flex items-center",children:[["line","bar","range","stackedBar","stackedLine","horizontalBar","funnel"].includes(s.type)&&e.jsx(On,{}),!["kpi","text","custom","table"].includes(s.type)&&e.jsxs(e.Fragment,{children:[e.jsx(An,{}),e.jsx(Ln,{})]}),!["pie","doughnut","funnel","radar","polarArea","table","custom","kpi","text","map"].includes(s.type)&&e.jsxs(t.IconButton,{tooltip:"Grid Style",onClick:l,children:[(r==="xy"||!r)&&e.jsx(ks,{className:"size-4"}),r==="x"&&e.jsx(ps,{className:"size-4"}),r==="y"&&e.jsx(Vs,{className:"size-4"}),r==="none"&&e.jsx(Ps,{className:"size-4"})]})]}):null}function je(){var Q;const s=t.useEditorStore(y=>y.frame),a=t.useEditorStore(y=>y.card),n=t.useEditorStore(y=>y.isDevMode),r=t.useEditorStore(y=>y.isShowingVisual),o=t.useDashboardStore(y=>y.isVisualEditing),l=t.useEditorStore(y=>y.isSqlRunning),i=t.useEditorStore(y=>y.pythonStdOut),d=t.useEditorStore(y=>{var C;return(C=y.card.preferences)==null?void 0:C.chartOptions}),c=t.useEditorStore(y=>y.actions.setRunSql);t.getChartGridStyle(d);const{setFrame:h,setCard:u,updateCardInFrame:x,setActiveTabCardId:v,runAssistant:m,setChartGrid:b,setIsDevMode:p}=t.useEditorActions(),{data:f,isLoading:g,isFetching:N,error:S,isPending:A}=t.useDashboardCardQuery(a);if(!a)return e.jsx(e.Fragment,{children:"No Active Card"});function k(y){const C={connectionId:y.connectionId,lastSelectedDatabase:y.lastSelectedDatabase,lastSelectedSchema:y.lastSelectedSchema,lastSelectedTable:y.lastSelectedTable,lastSelectedDatamodelId:y.lastSelectedDatamodelId,id:t.v4(),title:"Title",description:"",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]};T(y,C)}function T(y,C){const I={...s,cards:[...s.cards,C],activeCardId:y.id};h(I),v(C.id)}function L(){const y={...a,id:t.v4(),title:`${a.title} Copy`,tabTitle:`${a.tabTitle||a.title} Copy`};T(a,y)}function F(y){const C=s.cards.filter($=>$.id!==y),I=C[0],B={...s,cards:C,activeCardId:I.id};h(B),v(I.id),u(I)}function G(y){const C=s.cards.find(I=>I.id===y);if(C!=null&&C.sql){n||p(!0),v(y);return}if(C!=null&&C.queryConfig){n&&p(!1),w(y),v(y);return}n||w(y),v(y)}function w(y){const C={...s,cards:s.cards.map(B=>B.id===a.id?a:B),activeCardId:y};h(C);const I=C.cards.find(B=>B.id===y);I.sql&&c(!0),u(I)}const R=(y,C)=>{console.log("handleDragStart",C),y.dataTransfer.setData("tabIndex",C.toString())},U=y=>{y.preventDefault()},q=(y,C)=>{const I=y.dataTransfer.getData("tabIndex");if(I===C.toString())return;const B=Array.from(s.cards),[$]=B.splice(parseInt(I),1);B.splice(C,0,$),h({...s,cards:B})};function D(y,C){return y.cards.length===1&&(C.displayTab===!0||C.displayTab===void 0)||y.activeCardId!==C.id&&(C.displayTab===!0||C.displayTab===void 0)?null:e.jsx("div",{onClick:()=>{const I=C.displayTab===void 0?!1:!C.displayTab;u({...C,displayTab:I}),x({...C,displayTab:I})},children:C.displayTab===!0||C.displayTab===void 0?e.jsx(t.Eye,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"}):e.jsx(vs,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"})})}function j(){return e.jsxs(t.Tabs,{onValueChange:G,value:s.activeCardId,className:"flex grow flex-col",children:[s.cards.map(y=>e.jsx(t.TabsContent,{className:"mt-0 grow",value:y.id,children:M()},y.id)),e.jsx(t.TabsList,{className:"group mx-4 justify-between overflow-x-auto",children:e.jsxs("div",{className:"flex items-center",children:[s.cards.map((y,C)=>e.jsxs(t.TabsTrigger,{draggable:!0,onDragStart:I=>R(I,C),onDragOver:U,onDrop:I=>q(I,C),className:"",value:y.id,children:[D(s,y),e.jsx(t.Editable,{enabled:s.activeCardId===y.id,text:y.tabTitle||y.title,onSave:I=>{u({...a,tabTitle:I}),x({...a,tabTitle:I})},children:y.tabTitle||y.title},y.id),s.activeCardId===y.id&&s.cards.length>1&&e.jsx(t.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>F(y.id)})]},y.id)),e.jsx(t.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:()=>k(a),children:e.jsx(t.Plus,{className:"h-4 w-4"})}),e.jsx(t.Button,{className:"invisible ml-1 h-8 px-2 hover:bg-muted-foreground/50 group-hover:visible",variant:"outline",onClick:L,children:e.jsx(gs,{className:"h-4 w-4"})})]})})]})}function M(){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(t.KPICard,{card:a,data:f==null?void 0:f.records,isPending:A})})}):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(t.ScrollArea,{className:"mx-3 my-6 h-[300px] overflow-y-auto break-words px-3",children:e.jsx(t.TextCard,{isLoading:l,card:a,data:f==null?void 0:f.records})})})}):e.jsx(t.ErrorBoundary,{FallbackComponent:t.FallbackEditorCard,children:e.jsx(Et,{className:"grow border-none shadow-none"})})}function V(){const y=JSON.stringify(f==null?void 0:f.records,null,2),C=new Blob([y],{type:"application/json"}),I=URL.createObjectURL(C),B=document.createElement("a");B.href=I,B.download=`${a.title}.json`,B.click()}function _(){const C=[Object.keys(f==null?void 0:f.records.reduce((z,W)=>({...z,...W}),{})).join(","),...((f==null?void 0:f.records)||[]).map(z=>Object.values(z).join(","))].join(`
|
|
369
|
-
`),I=new Blob([C],{type:"text/csv"}),B=URL.createObjectURL(I),$=document.createElement("a");$.href=B,$.download=`${a.title}.csv`,$.click()}function H(){const y=`Can you get the documentation for ${a.type} chart?`;m(y)}return e.jsxs("div",{className:"relative isolate flex h-full flex-col py-2 pb-3",children:[(g||N)&&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(oe,{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(Mn,{}),o&&e.jsx(t.IconButton,{tooltip:"Visual Docs",onClick:H,children:e.jsx(ls,{className:"size-4"})}),!["table","custom"].includes(a.type)&&o&&e.jsx(kn,{})]}),!r&&e.jsxs("div",{className:"flex grow items-center gap-1",children:[e.jsx(t.Button,{className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",variant:"ghost",size:"icon",onClick:_,children:e.jsx(En,{className:"size-4"})}),e.jsx(t.Button,{className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",variant:"ghost",size:"icon",onClick:V,children:e.jsx(Ss,{strokeWidth:1.5,className:"size-4"})}),e.jsx(t.CopyButton,{text:JSON.stringify(f==null?void 0:f.records,null,2),className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70"})]}),e.jsx(zn,{}),n&&e.jsx(Rn,{})]}),r?j():e.jsxs(t.ResizablePanelGroup,{className:"px-6",direction:"horizontal",children:[i&&e.jsxs(e.Fragment,{children:[e.jsx(t.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(Fn,{})}),e.jsx(t.ResizableHandle,{})]}),e.jsxs(t.ResizablePanel,{id:"2",order:2,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:[(f==null?void 0:f.records)&&(f==null?void 0:f.records.length)>0&&e.jsx(vn,{data:(f==null?void 0:f.records)||[]}),(S||(f==null?void 0:f.error))&&e.jsx("span",{className:"font-mono text-xs",children:(S==null?void 0:S.message)||((Q=f==null?void 0:f.error)==null?void 0:Q.message)})]})]})]})}function Fn(){const s=t.useEditorStore(n=>n.pythonStdOut);if(!s)return null;const a=s.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(t.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(t.ScrollBar,{orientation:"horizontal"})]})]})}function Rn(){const s=t.useEditorStore(n=>n.isShowingVisual),a=t.useEditorStore(n=>n.actions.setIsShowingVisual);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Label,{htmlFor:"visualize",children:"Chart"}),e.jsx(t.SmallSwitch,{checked:s,onCheckedChange:()=>a(!s),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function Bn(){var p,f;const s=t.useEditorStore(g=>g.card.customCardPreferences),{data:a}=Mt(),n=(a==null?void 0:a.plugins)||[],r=t.useEditorStore(g=>g.card),o=t.useEditorStore(g=>g.frame),l=(s==null?void 0:s.visualType)||"single",{setCustomCardPreferences:i}=t.useEditorActions(),{components:d,manifest:c}=t.useCustomVisual((s==null?void 0:s.url)||""),h=(p=c==null?void 0:c.visuals)==null?void 0:p.find(g=>g.name===(s==null?void 0:s.componentName));function u(g,N){if(!s)return;const A={...(s==null?void 0:s.dataInputCardIds)||{},[g]:{cardId:N,hookRef:null}};i({...s,dataInputCardIds:A})}function x(g){var S,A;const N=(S=o==null?void 0:o.cards)==null?void 0:S.filter(k=>{var T;return((T=k==null?void 0:k.customCardPreferences)==null?void 0:T.visualType)!=="multiple"}).map(k=>({value:k.id,label:k.tabTitle||k.title}));return e.jsx("div",{className:"space-y-2",children:(A=g==null?void 0:g.dataInputs)==null?void 0:A.map((k,T)=>{var L,F;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(X,{className:"col-span-6 h-8 w-full justify-between",label:"",options:N||[],value:((F=(L=s==null?void 0:s.dataInputCardIds)==null?void 0:L[T])==null?void 0:F.cardId)||"",onValueChange:G=>u(T,G)})]},T+Math.random())})})}function v(g,N,S=[],A=""){var k,T;return s?g==="input"?e.jsx(t.Input,{className:`h-8 w-full ${t.removeRing}`,value:((k=s==null?void 0:s.settings)==null?void 0:k[N])||A,onChange:L=>{i({...s,settings:{...s==null?void 0:s.settings,[N]:L.target.value}})}},N):g==="select"?e.jsx(X,{className:"h-8 w-full",label:"",options:S,value:((T=s==null?void 0:s.settings)==null?void 0:T[N])||A,onValueChange:L=>{i({...s,settings:{...s==null?void 0:s.settings,[N]:L}})}}):null:null}function m(g){const N=Object.entries((g==null?void 0:g.settings)||{});return e.jsx("div",{className:"space-y-3",children:N.map(([S,A])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:A.title}),v(A.ui,S,A.options,A.defaultValue)]},S))})}function b(g){s&&i({...s,visualType:g,componentName:""})}return e.jsxs(t.Accordion,{type:"multiple",defaultValue:["component-settings"],className:"px-6 py-2",children:[e.jsxs(t.AccordionItem,{value:"plugin-settings",children:[e.jsx(t.AccordionTrigger,{children:"Plugin"}),e.jsx(t.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(X,{icon:e.jsx(is,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Plugin",options:n,value:(s==null?void 0:s.url)||"",onValueChange:g=>i({...s||{url:"",componentName:""},url:g})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&e.jsx(t.Tabs,{value:l,onValueChange:b,children:e.jsxs(t.TabsList,{className:"h-9 w-full",children:[e.jsx(t.TabsTrigger,{className:"h-7 w-full",value:"single",children:"Single Visual"}),e.jsx(t.TabsTrigger,{className:"h-7 w-full",value:"multiple",children:"Multi-Visual"})]})})]})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&s&&e.jsx(e.Fragment,{children:d&&e.jsx(X,{icon:e.jsx(fs,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Component",options:(d==null?void 0:d.filter(g=>g.type===l).map(g=>({value:g.name,label:g.name})))||[],value:s.componentName,onValueChange:g=>{console.log("changing value",g),i({...s,componentName:g})}})})]})})]}),((f=r==null?void 0:r.customCardPreferences)==null?void 0:f.componentName)&&e.jsxs(t.AccordionItem,{className:"border-none",value:"component-settings",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsxs(t.AccordionContent,{children:[h&&h.dataInputs&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(t.Label,{children:"Input Mapping"}),e.jsx("div",{className:"px-2",children:x(h)})]}),h&&h.settings&&e.jsx("div",{className:"space-y-3",children:e.jsx("div",{className:"px-2",children:m(h)})})]})]})]})}function le(){const[s,a]=E.useState([]),n=t.useEditorStore(h=>h.card.preferences),{setFilterOnClickColumnIndex:r,setCardPreferences:o}=t.useEditorStore(h=>h.actions),l=t.useEditorStore(h=>h.queryResultColumns);t.useEditorStore(h=>{var u;return(u=h.card.preferences)==null?void 0:u.filterOnClickColumnIndex}),E.useEffect(()=>{l&&a(new Array(l.length).fill(!1))},[l]);function i(h,u){var x,v;u?n!=null&&n.onClickFilter&&((x=n==null?void 0:n.onClickFilter)==null?void 0:x.length)>0?o({...n,onClickFilter:[...n.onClickFilter,{columnIndex:h,expression:""}]}):o({...n,onClickFilter:[{columnIndex:h,expression:""}]}):(o({...n,onClickFilter:(v=n==null?void 0:n.onClickFilter)==null?void 0:v.filter(m=>m.columnIndex!==h)}),a(m=>{const b=[...m];return b[h]=!1,b}))}function d(h,u){var v;const x=(v=n==null?void 0:n.onClickFilter)==null?void 0:v.map(m=>m.columnIndex===h?{...m,expression:u.target.value}:m);o({...n,onClickFilter:x})}function c(h){var u,x,v,m;if(s!=null&&s[h]||(x=(u=n==null?void 0:n.onClickFilter)==null?void 0:u.find(b=>b.columnIndex===h))!=null&&x.expression)return e.jsx(t.Input,{value:(m=(v=n==null?void 0:n.onClickFilter)==null?void 0:v.find(b=>b.columnIndex===h))==null?void 0:m.expression,onChange:b=>d(h,b),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:"max-h-[150px] space-y-2 overflow-y-auto",children:[e.jsx(t.Label,{children:"On Click"}),l==null?void 0:l.map((h,u)=>{var x,v;return e.jsx("div",{className:"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(t.Checkbox,{checked:!!((x=n==null?void 0:n.onClickFilter)!=null&&x.find(m=>m.columnIndex===u)),onCheckedChange:m=>i(u,m)}),e.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:h}),e.jsx("div",{className:"flex items-center gap-2",children:((v=n==null?void 0:n.onClickFilter)==null?void 0:v.find(m=>m.columnIndex===u))&&e.jsx(t.Pencil,{onClick:()=>{a(m=>{const b=[...m];return b[u]=!m[u],b})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),c(u)]})},h)})]})}function Vn({idx:s}){var d;const a=t.useEditorStore(c=>{var h;return(h=c.card)==null?void 0:h.preferences}),n=t.useEditorStore(c=>{var h;return(h=c.card.preferences)==null?void 0:h.datasetOptions}),r=t.useEditorStore(c=>c.actions.setCardPreferences),o=(d=a==null?void 0:a.chartOptions)==null?void 0:d.indexAxis,l=n==null?void 0:n.find(c=>c.idx===s);function i(c,h){(c==="end"||c==="start")&&t.getContrastColor(t.getCanvasBackgroundColor());const u={display:c!=="none",align:c,anchor:c,clamp:!0};if(!l)r({...a,datasetOptions:[...n||[],{idx:h,datalabels:u}]});else{const x={...l};x.datalabels=u;const v=n==null?void 0:n.map(m=>m.idx===h?x:m);r({...a,datasetOptions:v})}}return e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{children:e.jsx(Hs,{className:"size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsx(t.PopoverContent,{className:"w-fit px-2 py-1",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>i("none",s),className:"h-7 p-1 text-xs font-normal",children:e.jsx(t.X,{className:"size-3.5"})}),e.jsx("button",{onClick:()=>i("start",s),className:"h-7 p-1 text-xs font-normal",children:e.jsx(Ts,{className:t.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsx("button",{onClick:()=>i("center",s),className:"h-7 p-1 text-xs font-normal",children:e.jsx(As,{className:t.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsx("button",{onClick:()=>i("end",s),className:"h-7 p-1 text-xs font-normal",children:e.jsx(Ms,{className:t.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function Bt(){const s=t.useEditorStore(l=>l.card),{data:a}=t.useDashboardCardQuery(s),{keys:n}=t.getKeys((a==null?void 0:a.records)||[]),r=n.slice(1).filter(l=>!t.METADATA_KEYS.includes(l));let o=r;if(["stackedBar","stackedLine"].includes(s.type)){const l=t.pivotData({dataArray:(a==null?void 0:a.records)||[],groupKey:n[0],pivotKey:n[1],valueKey:n[2]}),{keys:i}=t.getKeys(l);o=i.slice(1)}return{transformedMetricKeys:o,dimensionKeys:n.slice(0,1),keys:n,defaultMetricKeys:r}}function Ne({children:s,className:a,delayDuration:n}){return e.jsx(t.TooltipProvider$1,{children:e.jsxs(t.Tooltip,{delayDuration:n,children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsx("span",{className:t.cn("overflow-hidden text-ellipsis whitespace-nowrap",a),children:s})}),e.jsx(t.TooltipContent,{children:s})]})})}function Vt(){const s=t.useEditorStore(c=>c.card),a=t.useEditorStore(c=>{var h,u,x;return(x=(u=(h=c==null?void 0:c.card)==null?void 0:h.preferences)==null?void 0:u.chartOptions)==null?void 0:x.indexAxis}),{data:n}=t.useDashboardCardQuery(s),r=a==="y"?"Metric":"Dimension",o=a==="y"?"Dimension":"Metric",{dimensionKeys:l,transformedMetricKeys:i,keys:d}=Bt();return d.length===0?null:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:r}),e.jsx("div",{className:"max-h-[125px] space-y-1 overflow-y-auto",children:l.map(c=>e.jsx("p",{className:"flex h-8 items-center rounded-md bg-muted/70 px-3 hover:bg-muted",title:c,children:_t(c)},c))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:o}),e.jsx("div",{className:"my-1 max-h-[125px] space-y-1 overflow-y-auto",children:i.map((c,h)=>e.jsx(qt,{className:"flex h-8 items-center bg-muted/70 px-3 hover:bg-muted",iconClassName:"invisible group-hover:visible",col:c,idx:h},c))})]})]})}function _t(s,a=30){return s.length>a?s.slice(0,a)+"...":s}function qt({col:s,idx:a,className:n,iconClassName:r,children:o}){const l=t.useEditorStore(u=>{var x;return(x=u.card)==null?void 0:x.preferences}),i=t.useEditorStore(u=>{var x,v;return(v=(x=u.card)==null?void 0:x.preferences)==null?void 0:v.datasetOptions}),d=i==null?void 0:i.find(u=>u.idx===a),{setCardPreferences:c}=t.useEditorStore(u=>u.actions);function h(u){if(!d)c({...l,datasetOptions:[...i||[],{idx:a,type:u==="area"?"line":u,fill:u==="area"?"origin":""}]});else{const x={...d};x.type=u==="area"?"line":u,x.fill=u==="area"?"origin":"";const v=i==null?void 0:i.map(m=>m.idx===a?x:m);c({...l,datasetOptions:v})}}return e.jsxs("div",{className:t.cn("group flex items-center justify-between gap-2 rounded-md",n),children:[o||e.jsx(Ne,{className:"max-w-[100px]",title:s,children:_t(s)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{onClick:()=>h("bar"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",r)}),e.jsx(Be,{onClick:()=>h("line"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",r)}),e.jsx(ms,{onClick:()=>h("area"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",r)}),e.jsx(Vn,{idx:a})]})]})}function Pt(){const s=t.useEditorStore(m=>m.selectedConnectionId),a=t.useEditorStore(m=>m.selectedDatamodelId),n=t.useEditorStore(m=>m.selectedDatabaseName),r=t.useEditorStore(m=>m.selectedSchemaName),o=t.useEditorStore(m=>m.selectedTableName),l=t.useDashboardStore(m=>m.dashboard.filters)||[],i=t.useDashboardStore(m=>m.actions.addFilter),d=t.useDashboardStore(m=>m.actions.removeFilter),{removeFilterValues:c}=t.useDashboardActions(),{modelItems:h,tableName:u,connectionType:x}=t.useEditorAside();function v(m,b="dashboard"){var L;const p=t.fmt(m.column_name),f=t.fmt(n||""),g=t.fmt(r||""),N=t.fmt(u);let S=t.getQualifiedTableName({schemaName:g,tableName:N,connectionType:x,databaseName:f}),A=`${S}.${p}`;const k=(L=h==null?void 0:h.find(F=>F.id===a))==null?void 0:L.name;a&&a!=="none"&&(A=`${t.DATAMODEL_NAMESPCACE}.${k}.${p}`,S=`${t.DATAMODEL_NAMESPCACE}.${k}`);const T=l==null?void 0:l.find(F=>F.column===A&&F.table===N&&(F.database===f||F.database===n));if(T)c(T.id),d(T.id);else{const F=t.v4();return u==="api"&&s?(i({location:b,id:F,column:A,title:m.column_name,dataType:m.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:t.getDefaultFilterSql(m.data_type,S,p)}),F):(i({id:F,location:b,column:A,title:m.column_name,dataType:m.data_type,table:o||"",database:n||"",connectionId:s||"",operation:"in",sql:t.getDefaultFilterSql(m.data_type,S,p)}),F)}}return{assignFilter:v}}function me(){const s=t.useDashboardStore(d=>d.dashboard.filters),a=t.useEditorStore(d=>d.frame),{setFrame:n}=t.useEditorActions(),{columns:r}=t.useEditorAside(),{assignFilter:o}=Pt();function l(d){const c=o(d,"frame");n({...a,filterId:c})}const i=s==null?void 0:s.find(d=>d.id===a.filterId);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(t.Label,{children:"Card Filter"}),e.jsx(_n,{onSelect:l,columns:r}),i&&e.jsx(t.FilterHeader,{filter:i})]})}function _n({columns:s,onSelect:a}){var i;const[n,r]=de.useState(!1),[o,l]=de.useState("");return e.jsxs(t.Popover,{open:n,onOpenChange:r,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{size:"sm",variant:"outline",role:"combobox","aria-expanded":n,className:"w-full justify-between font-normal",children:[o?(i=s.find(d=>d.column_name===o))==null?void 0:i.column_name:"Select Column...",e.jsx(t.CaretSortIcon,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(t.PopoverContent,{className:"w-[200px] p-0",children:e.jsxs(t.Command,{children:[e.jsx(t.CommandInput,{placeholder:"Search column",className:"h-9"}),e.jsxs(t.CommandList,{children:[e.jsx(t.CommandEmpty,{children:"No framework found."}),e.jsx(t.CommandGroup,{children:s==null?void 0:s.map(d=>e.jsxs(t.CommandItem,{value:d.column_name,onSelect:c=>{const h=c===o?"":c;l(h),r(!1),h&&a(d)},children:[d.column_name,e.jsx(t.CheckIcon,{className:t.cn("ml-auto h-4 w-4",o===d.column_name?"opacity-100":"opacity-0")})]},d.column_name))})]})]})})]})}function qn({cardType:s}){return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{children:`${t.titleCase(s)} Chart`}),e.jsxs(t.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(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsx(t.AccordionContent,{className:"space-y-4 px-2",children:e.jsx(Vt,{})})]}),e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(le,{}),e.jsx(me,{})]})]})]})})}function He(){var o,l,i;const s=t.useEditorStore(d=>d.card.type),a=t.useEditorStore(d=>d.card.preferences),{setCardPreferences:n}=t.useEditorStore(d=>d.actions);function r(d){var u;const c={datalabels:{display:d!=="none",align:d,anchor:d,clamp:!0}},h={...a,chartOptions:{...a==null?void 0:a.chartOptions,plugins:{...(u=a==null?void 0:a.chartOptions)==null?void 0:u.plugins,...c}}};n(h),console.log(d)}return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"font-medium",children:"Data Labels"}),e.jsxs(t.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(t.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{placeholder:"Select position"})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Data Labels"}),e.jsx(t.SelectItem,{value:"none",children:"None"}),!["pyramid","funnel"].includes(s)&&e.jsx(t.SelectItem,{value:"start",children:"Start"}),e.jsx(t.SelectItem,{value:"center",children:"Center"}),!["pyramid","funnel"].includes(s)&&e.jsx(t.SelectItem,{value:"end",children:"End"})]})})]})]})}function Pn({cardType:s}){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(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{children:`${t.titleCase(s)} Chart`}),e.jsx(t.AccordionContent,{className:"space-y-4 font-mono text-xs",children:a(s)})]}),e.jsxs(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsx(t.AccordionContent,{className:"px-2",children:e.jsx(He,{})})]}),e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(le,{}),e.jsx(me,{})]})]})]})})}const Hn={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},Gn={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function Un(){const s=t.useEditorStore(a=>a.card.type);return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(t.Accordion,{className:" ",type:"single",collapsible:!0,children:$n(s)}),!["kpi"].includes(s)&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(He,{}),e.jsx(le,{}),e.jsx(me,{})]})]})}function $n(s){if(["line","bar"].includes(s))return e.jsxs(e.Fragment,{children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:e.jsx("p",{children:"Chart Query"})}),e.jsxs(t.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(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxs(t.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(Hn,null,2)})]})]}),e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxs(t.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(Gn,null,2)})]})]})]});if(s==="bubble")return e.jsx(e.Fragment,{children:e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:["How to create a ",e.jsx("span",{children:s})," chart query?"]})}),e.jsxs(t.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(s==="scatter")return e.jsx(e.Fragment,{children:e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:["How to create a ",e.jsx("span",{children:s})," chart query?"]})}),e.jsxs(t.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","funnel"].includes(s))return e.jsx(e.Fragment,{children:e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:[e.jsx("span",{children:s==="polarArea"?"Polar":s.charAt(0).toUpperCase()+s.slice(1)})," ","chart query"]})}),e.jsxs(t.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 Qn(){var c,h,u,x,v;const s=t.useEditorStore(m=>m.card.preferences),a=t.useEditorStore(m=>m.actions.setCardPreferences),n=t.useEditorStore(m=>m.actions.setNumberFormat);t.useEditorStore(m=>{var b,p;return(p=(b=m.card.preferences)==null?void 0:b.formatNumber)==null?void 0:p.decimalPlaces});const r=t.useEditorStore(m=>{var b,p;return(p=(b=m.card.preferences)==null?void 0:b.formatNumber)==null?void 0:p.locale}),o=t.useEditorStore(m=>{var b,p;return(p=(b=m.card.preferences)==null?void 0:b.formatNumber)==null?void 0:p.currency});t.useEditorStore(m=>m.actions.setFilterOnClickField);const l=t.useEditorStore(m=>{var b,p;return(p=(b=m.card.preferences)==null?void 0:b.formatNumber)==null?void 0:p.colorRanges})||[],i=t.useEditorStore(m=>m.actions.setColorRanges),d=[...new Set(t.LOCALE_CURRENCY_PAIRS.map(m=>m.currency))];return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(t.Checkbox,{checked:!!((c=s==null?void 0:s.formatNumber)!=null&&c.enabled),onCheckedChange:m=>{a({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:m}})}}),e.jsx(t.Label,{children:"Format Number"})]}),((h=s==null?void 0:s.formatNumber)==null?void 0:h.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(t.Label,{children:"Locale"}),e.jsxs(t.Select,{value:r||"none",onValueChange:m=>{var b,p,f;return n(((b=s==null?void 0:s.formatNumber)==null?void 0:b.decimalPlaces)||0,((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",m,((f=s==null?void 0:s.formatNumber)==null?void 0:f.suffix)||"")},children:[e.jsx(t.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Format"}),e.jsx(t.SelectItem,{value:"none",children:"None"},"none"),t.LOCALE_CURRENCY_PAIRS.map(m=>e.jsx(t.SelectItem,{value:m.locale,children:m.locale},m.locale))]})})]})]}),e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(t.Label,{children:"Currency"}),e.jsxs(t.Select,{value:o||"none",onValueChange:m=>{var b,p,f;console.log("currency",m),n(((b=s==null?void 0:s.formatNumber)==null?void 0:b.decimalPlaces)||0,m==="none"?"":m,((p=s==null?void 0:s.formatNumber)==null?void 0:p.locale)||"",((f=s==null?void 0:s.formatNumber)==null?void 0:f.suffix)||"")},children:[e.jsx(t.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Currency"}),e.jsx(t.SelectItem,{value:"none",children:"None"},"none"),d.map(m=>e.jsx(t.SelectItem,{value:m,children:m},m))]})})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(t.Label,{children:"Decimals"}),e.jsxs(t.Select,{value:((x=(u=s==null?void 0:s.formatNumber)==null?void 0:u.decimalPlaces)==null?void 0:x.toString())||"0",onValueChange:m=>{var b,p,f;return n(Number(m),((b=s==null?void 0:s.formatNumber)==null?void 0:b.currency)||"",((p=s==null?void 0:s.formatNumber)==null?void 0:p.locale)||"",((f=s==null?void 0:s.formatNumber)==null?void 0:f.suffix)||"")},children:[e.jsx(t.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:["0","1","2","3","4"].map(m=>e.jsx(t.SelectItem,{value:m,children:m},m))})]})]}),e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(t.Label,{children:"Suffix"}),e.jsx(t.Input,{value:((v=s==null?void 0:s.formatNumber)==null?void 0:v.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:m=>{var b,p,f;return n(((b=s==null?void 0:s.formatNumber)==null?void 0:b.decimalPlaces)||0,((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",((f=s==null?void 0:s.formatNumber)==null?void 0:f.locale)||"",m.target.value)}})]})]})]})}),e.jsx(t.Separator,{className:"my-3"}),e.jsx(t.ColorFormat,{colorRanges:l,setColorRanges:i})]})]})}function Jn(){return e.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsx(t.Accordion,{type:"single",collapsible:!0,children:e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxs(t.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:s=>s.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(Qn,{})}),e.jsx("div",{}),e.jsx("div",{})]})}function Me({children:s,summary:a,open:n,className:r}){return e.jsxs("details",{open:n,className:t.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(t.Label,{children:a}),e.jsx(t.ChevronUp,{className:"h-4 w-4"})]}),e.jsx("div",{className:"transition-all ease-in-out",children:s})]})}const Wn=[{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"}],Kn=["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"],Yn=Kn.map(s=>({label:s,value:s}));function Zn(){var c,h,u,x,v,m,b,p,f,g,N,S,A,k,T,L,F,G;const s=t.useEditorStore(w=>w.card),a=(h=(c=s==null?void 0:s.preferences)==null?void 0:c.mapVisualOptions)==null?void 0:h.topoJsonUrl,[n,r]=E.useState(((x=(u=s==null?void 0:s.preferences)==null?void 0:u.mapVisualOptions)==null?void 0:x.customTopoJsonUrl)||""),{setCardPreferences:o}=t.useEditorActions(),{data:l}=t.useTopoJson(s),i=Object.keys((l==null?void 0:l.objects)||{}).map(w=>({label:w,value:w}))||[],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(Me,{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(t.Separator,{className:"my-4"}),e.jsx(Me,{open:!0,summary:"Settings",children:e.jsxs("div",{className:"space-y-3 px-2",children:[e.jsx(X,{className:"h-9",options:d,onValueChange:w=>{console.log("value",w),o({...s.preferences,mapVisualOptions:{topoJsonUrl:w}})},value:a||"",label:"Select Map"}),a==="custom"&&e.jsx(t.Input,{onChange:w=>{r(w.target.value)},onBlur:()=>{var w;console.log("onBlur",n),o({...s.preferences,mapVisualOptions:{...(w=s.preferences)==null?void 0:w.mapVisualOptions,customTopoJsonUrl:n}})},value:n,className:`h-9 w-full ${t.removeRing}`,placeholder:"Custom URL"}),l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:"Map Object"}),e.jsx(X,{className:"h-9",options:i,value:((m=(v=s.preferences)==null?void 0:v.mapVisualOptions)==null?void 0:m.objectKey)||"",label:"Map Object",onValueChange:w=>{var R;o({...s.preferences,mapVisualOptions:{...(R=s.preferences)==null?void 0:R.mapVisualOptions,objectKey:w}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:"Projection"}),e.jsx(X,{className:"h-9",options:Wn,value:((p=(b=s.preferences)==null?void 0:b.mapVisualOptions)==null?void 0:p.projection)||"",label:"Projection",onValueChange:w=>{var R;o({...s.preferences,mapVisualOptions:{...(R=s.preferences)==null?void 0:R.mapVisualOptions,projection:w}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:"Colors"}),e.jsx(X,{className:"h-9",options:Yn,value:((g=(f=s.preferences)==null?void 0:f.mapVisualOptions)==null?void 0:g.colorScale)||"",label:"Select Color Scale",onValueChange:w=>{var R;o({...s.preferences,mapVisualOptions:{...(R=s.preferences)==null?void 0:R.mapVisualOptions,colorScale:w}})}})]})]})]})}),e.jsx(t.Separator,{className:"my-4"}),e.jsx(Me,{className:"",summary:"Scale Options",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(t.Input,{className:`h-9 w-full ${t.removeRing}`,type:"number",step:.1,value:((S=(N=s.preferences)==null?void 0:N.mapVisualOptions)==null?void 0:S.projectionScale)||1,onChange:w=>{var R;o({...s.preferences,mapVisualOptions:{...(R=s.preferences)==null?void 0:R.mapVisualOptions,projectionScale:Number(w.target.value)}})}}),e.jsx(t.Label,{children:"X"}),e.jsx(t.Input,{className:`h-9 w-full ${t.removeRing}`,type:"number",step:10,value:((T=(k=(A=s.preferences)==null?void 0:A.mapVisualOptions)==null?void 0:k.projectionOffset)==null?void 0:T[0])||0,onChange:w=>{var R,U,q,D;o({...s.preferences,mapVisualOptions:{...(R=s.preferences)==null?void 0:R.mapVisualOptions,projectionOffset:[Number(w.target.value),((D=(q=(U=s.preferences)==null?void 0:U.mapVisualOptions)==null?void 0:q.projectionOffset)==null?void 0:D[1])||0]}})}}),e.jsx(t.Label,{children:"Y"}),e.jsx(t.Input,{className:`h-9 w-full ${t.removeRing}`,type:"number",step:10,value:((G=(F=(L=s.preferences)==null?void 0:L.mapVisualOptions)==null?void 0:F.projectionOffset)==null?void 0:G[1])||0,onChange:w=>{var R,U,q,D;o({...s.preferences,mapVisualOptions:{...(R=s.preferences)==null?void 0:R.mapVisualOptions,projectionOffset:[((D=(q=(U=s.preferences)==null?void 0:U.mapVisualOptions)==null?void 0:q.projectionOffset)==null?void 0:D[0])||0,Number(w.target.value)]}})}})]})}),e.jsx(t.Separator,{className:"my-4"}),e.jsx(le,{})]})}function Xn(){var r;const s=t.useEditorStore(o=>o.card.preferences),{setCardPreferences:a}=t.useEditorStore(o=>o.actions);function n(o){a({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:o==="dynamic"}})}return e.jsxs(t.RadioGroup,{value:(r=s==null?void 0:s.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(t.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(t.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function ye({cardType:s,docContent:a,suffix:n="Chart"}){let r="pie-donut-polar";return s==="funnel"&&(r="funnel"),e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{children:`${t.titleCase(s)} ${n}`}),e.jsx(t.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:o=>o.stopPropagation(),className:"text-blue-700",href:`https://docs.semaphor.cloud/docs/charts/${r}`,children:"example"})," in the docs."]})]})})]}),e.jsxs(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[s!=="text"&&e.jsx(He,{}),s==="text"&&e.jsx(Xn,{})]})]}),!["range","text"].includes(s)&&e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(le,{}),e.jsx(me,{})]})]})]})})}function ea(){const s=t.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}=t.useEditorActions();function n(){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:"Sort"}),e.jsx(X,{className:"h-8",label:"Sort Chart",options:[{label:"None",value:"none"},{label:"ASC",value:"asc"},{label:"DESC",value:"desc"}],value:s||"none",onValueChange:r=>{a(r)}})]})}return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{children:"Stacked Chart"}),e.jsxs(t.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(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[n(),e.jsx(Vt,{})]})]}),e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(le,{}),e.jsx(me,{})]})]})]})})}function ta({cardType:s="table"}){console.log("cardType",s);const a=t.useEditorStore(o=>{var l;return(l=o.card)==null?void 0:l.preferences}),n=t.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(t.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(le,{}),e.jsx(me,{})]})]})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.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 sa=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:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/tornado",children:"example"})," in the docs."]})]}),na=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:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/range",children:"example"})," in the docs."]})]}),aa=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:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/text",children:"example"})," in the docs."]})]});function ra(){const s=t.useEditorStore(n=>n.card.type);function a(n){switch(n){case"stackedBar":case"stackedLine":return e.jsx(ea,{});case"tornado":case"pyramid":return e.jsx(ye,{docContent:sa,cardType:n});case"kpi":return e.jsx(Jn,{});case"line":case"bar":return e.jsx(qn,{cardType:n});case"range":return e.jsx(ye,{docContent:na,cardType:n});case"pie":case"doughnut":case"polarArea":case"radar":case"funnel":return e.jsx(ye,{cardType:n});case"bubble":case"scatter":return e.jsx(Pn,{cardType:n});case"table":return e.jsx(ta,{cardType:n});case"text":return e.jsx(ye,{docContent:aa,cardType:n,suffix:"Visual"});case"map":return e.jsx(Zn,{});case"custom":return e.jsx(Bn,{});default:return e.jsx(Un,{})}}return e.jsxs(t.ScrollArea,{className:"h-full w-full text-sm",children:[a(s),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})}function Ht({label:s,column:a,functions:n,onFunctionChange:r}){let o=n[0];"aggregate"in a?o=n.find(i=>i.value===a.aggregate)||n[0]:"granularity"in a&&(o=n.find(i=>i.value===a.granularity)||n[0]);function l(i){r(i)}return e.jsx(X,{className:"flex h-8 w-8 justify-center overflow-clip rounded-none border-none bg-muted px-0 [&>svg]:hidden",icon:o.logo,options:n,value:o.value,onValueChange:i=>l(i),label:s,showPlaceholderLabel:!1})}const oa=[{label:"Sum",value:"SUM",logo:e.jsx(ht,{className:"size-3.5"})},{label:"Count",value:"COUNT",logo:e.jsx(lt,{className:"size-3.5"})},{label:"Unique",value:"DISTINCT",logo:e.jsx(Ns,{className:"size-3.5"})},{label:"Average",value:"AVG",logo:e.jsx(ss,{className:"size-3.5"})},{label:"Min",value:"MIN",logo:e.jsx(Xe,{className:"size-3.5"})},{label:"Max",value:"MAX",logo:e.jsx(t.ArrowUp,{className:"size-3.5"})}];function ia({column:s}){const{updateMetricColumn:a}=t.useEditorActions();let n=oa;t.isTextDataType(s.type)&&(n=n.filter(o=>["COUNT","DISTINCT"].includes(o.value))),t.isNumberDataType(s.type)&&(n=n.filter(o=>!["DISTINCT"].includes(o.value)));function r(o){const l={...s,aggregate:o,label:xe(s.name,o)};a(s.id,l)}return e.jsx(Ht,{column:s,functions:n,onFunctionChange:o=>r(o),label:"Aggregation"})}const la=[{label:"Day (D)",value:"day",logo:e.jsx(t.Label,{className:"cursor-pointer text-xs",children:"D"})},{label:"Week (W)",value:"week",logo:e.jsx(t.Label,{className:"cursor-pointer text-xs",children:"W"})},{label:"Month (M)",value:"month",logo:e.jsx(t.Label,{className:"cursor-pointer text-xs",children:"M"})},{label:"Year (Y)",value:"year",logo:e.jsx(t.Label,{className:"cursor-pointer text-xs",children:"Y"})}];function ca({column:s}){const{updateGroupByColumn:a}=t.useEditorActions();function n(r){const o={...s,granularity:r,label:ue(s.name,r)};a(s.id,o)}return e.jsx(Ht,{column:s,functions:la,onFunctionChange:r=>n(r),label:"Granularity"})}function da({col:s,onChange:a,droppableId:n}){const{columns:r}=t.useDataColumns(),o=E.useMemo(()=>{let d=[];(n===ne||n===ae||n===re)&&(d=r);const c=d==null?void 0:d.filter(h=>h.column_name!==s.name);return c==null?void 0:c.map(h=>({id:h.column_name,value:h.column_name}))},[r,n,s.name]),l=[{id:s.name,value:s.name}];function i(d){const c=r==null?void 0:r.find(h=>{var u;return h.column_name===((u=d[0])==null?void 0:u.id)});c&&a(c)}return o!=null&&o.length?e.jsx(t.ComboBox2,{multiple:!1,options:o,selectedOptions:l,onChange:i,selectAllChecked:!1,onSelectAllCheckedChange:()=>{},inputClassName:"border-none bg-muted pl-0 pr-8"}):e.jsx("input",{disabled:!0,type:"text",className:"overflow-hidden truncate text-ellipsis whitespace-nowrap bg-muted text-sm",value:s.name})}function ua({column:s}){const{updateMetricColumn:a}=t.useEditorActions(),{transformedMetricKeys:n,dimensionKeys:r}=Bt();console.log(n,r);const o=t.useEditorStore(c=>{var h;return(h=c.card.queryConfig)==null?void 0:h.pivotColumns}),l=!!(o&&o.length>0),i=n.find(c=>c===s.label||c===s.name),d=i?n.indexOf(i):-1;return e.jsxs("div",{className:"space-y-3",children:[i&&e.jsx(qt,{idx:d,col:i,children:e.jsx(t.Editable,{enabled:!0,className:"w-[130px]",text:s.label||"",placeholder:"Enter label",onSave:c=>{a(s.id,{...s,label:c||s.name})},children:e.jsx(Ne,{className:"w-[130px]",children:s.label||s.name})})}),l&&e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(t.Label,{children:"Pivot Header"}),e.jsx(t.Editable,{enabled:!0,text:s.aliasTemplate||"",placeholder:"{label} ({pivot})",onSave:c=>{a(s.id,{...s,aliasTemplate:c||""})},children:e.jsx(Ne,{className:"font-mono text-xs text-muted-foreground",children:s.aliasTemplate||"{label} ({pivot})"})})]})]})}function ma({column:s,type:a,onRemoveColumn:n,droppableId:r}){const[o,l]=E.useState(!1),{updateGroupByColumn:i,updateMetricColumn:d,updatePivotByColumn:c}=t.useEditorActions(),{attributes:h,listeners:u,setNodeRef:x,transform:v,transition:m,isDragging:b}=t.useSortable({id:s.id,data:{type:a}}),p=v?{opacity:b?.5:void 0,transform:t.CSS.Translate.toString(v),transition:m}:void 0,f=t.isTextDataType(s.type);function g(T){const L=t.isNumberDataType(T.data_type),F=t.isTextDataType(T.data_type),G=t.isDateDataType(T.data_type),w=L?"number":F?"string":G?"date":"string";if(r===ne){if(F){const R={id:s.id,name:T.column_name,type:w,role:"groupby"};i(s.id,R)}if(G){const R={id:s.id,name:T.column_name,type:w,role:"groupby",label:ue(T.column_name,"month"),granularity:"month"};i(s.id,R)}}if(r===re){if(F){const R={id:s.id,name:T.column_name,type:w,role:"groupby"};c(s.id,R)}if(G){const R={id:s.id,name:T.column_name,type:w,label:ue(T.column_name,"month"),granularity:"month",role:"groupby"};c(s.id,R)}}if(r===ae){const R={id:s.id,name:T.column_name,type:w,role:"metric",label:xe(T.column_name,"SUM"),aggregate:L?"SUM":"COUNT"};d(s.id,R)}}function N(){if(r===ae)return e.jsx("div",{"data-setting-container":"",className:"mt-1.5 max-h-32 overflow-y-auto rounded-md border border-border p-3 text-sm",children:e.jsx(ua,{column:s})})}function S(){const T=t.isDateDataType(s.type);if(r===ae)return e.jsx(ia,{column:s});if((r===ne||r===re)&&T)return e.jsx(ca,{column:s})}function A(){return e.jsx("div",{className:t.cn("grow",{"pl-3":(r===ne||r===re)&&f}),children:e.jsx(da,{col:s,onChange:g,droppableId:r})})}function k(){return e.jsx("div",{"data-setting-actions":"",className:"flex h-full items-center gap-2",children:e.jsx("button",{className:"h-full pl-2",onClick:()=>l(!o),children:o?e.jsx(qs,{className:t.cn("size-3 cursor-pointer items-center justify-center rounded-r-sm text-muted-foreground")}):e.jsx(ot,{className:t.cn("size-3 cursor-pointer items-center justify-center rounded-r-sm text-muted-foreground")})})})}return e.jsx("div",{...u,...h,ref:x,style:p,children:e.jsxs("div",{className:"group flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"grow",children:[e.jsxs("div",{className:"flex h-8 grow items-center justify-between rounded-md bg-muted",children:[k(),S(),A()]}),o&&N()]}),e.jsx("div",{className:t.cn("opacity-0 transition-opacity duration-200 group-hover:opacity-100",{hidden:o}),children:e.jsx("button",{onClick:()=>n(s.id),children:e.jsx(t.X,{className:"size-3 cursor-pointer text-muted-foreground"})})})]})})}function Ae({id:s,label:a,columns:n,previewColumns:r,sortableType:o,onRemoveColumn:l}){var p,f;const{setNodeRef:i,isOver:d,over:c}=t.useDroppable({id:s}),h=t.useDndStore(g=>g.activeId),u=t.useEditorStore(g=>{var N;return(N=g.card)==null?void 0:N.type}),x=d||((f=(p=c==null?void 0:c.data)==null?void 0:p.current)==null?void 0:f.type)===o,v=h?r:n,m=o===be?"Rows":o===ve?"Pivot Columns":"Columns";function b(){if(!v||v.length===0)return e.jsx("div",{className:"mr-5 flex h-8 grow items-center space-x-2 rounded-md border border-dashed border-muted-foreground/80 bg-background px-2 py-1 text-sm text-muted-foreground",children:e.jsx("span",{className:"invisible text-muted-foreground/70 group-hover:visible",children:"Drag here"})})}return e.jsx(t.SortableContext,{items:n==null?void 0:n.map(g=>g.id),children:e.jsxs("div",{className:t.cn("group space-y-2 rounded-md p-4",x&&"border border-muted-foreground/20"),ref:i,children:[e.jsxs("div",{className:"flex items-center justify-between pr-5",children:[e.jsx(t.Label,{className:"text-sm",children:a}),u!=="table"&&e.jsx("span",{className:"text-xs text-muted-foreground/50",children:m})]}),b(),e.jsx("div",{className:"space-y-2",children:v==null?void 0:v.map(g=>g.id===yt.id?e.jsx(ha,{},g.id):e.jsx(ma,{droppableId:s,type:o,column:g,onRemoveColumn:l},g.id))})]})})}function ha(){return e.jsx("div",{className:"mr-5 flex h-8 grow items-center space-x-2 rounded-md border border-dashed border-muted-foreground bg-background px-2 py-1 text-sm",children:e.jsx("span",{className:"text-muted-foreground/70",children:"Drop here"})})}function Gt({children:s,id:a,type:n}){const{attributes:r,listeners:o,setNodeRef:l,transform:i,transition:d,isDragging:c}=t.useSortable({id:a,data:{type:n}}),h=i?{opacity:c?.5:void 0,transform:t.CSS.Translate.toString(i),transition:d}:void 0;return e.jsx("div",{...o,...r,ref:l,style:h,children:s})}function xa(){const s=t.useEditorStore(g=>{var N;return(N=g.card.queryConfig)==null?void 0:N.orderBy})||[],a=t.useEditorStore(g=>{var N;return(N=g.card.queryConfig)==null?void 0:N.groupByColumns})||[],n=t.useEditorStore(g=>{var N;return(N=g.card.queryConfig)==null?void 0:N.metricColumns})||[],{addOrderByColumn:r,removeOrderByColumn:o,updateOrderByColumn:l}=t.useEditorActions(),i=[...a,...n];if(i.length===0)return e.jsx(e.Fragment,{});const d=e.jsx(os,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),c=e.jsx(ts,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),h=e.jsx(rs,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),u=e.jsx(es,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),x=i==null?void 0:i.filter(g=>!s.some(N=>N.columnId===g.id)).map(g=>({id:g.id,value:g.label||g.name}));function v(g,N){const S=m(g);return S?S.role==="metric"?N==="asc"?h:u:N==="asc"?d:c:null}function m(g){return i.find(N=>N.id===g)}function b(g){const N=s.find(S=>S.columnId===g);if(N){const S={...N,direction:N.direction==="asc"?"desc":"asc"};l(S)}}const p=g=>{r({columnId:g.id,direction:"asc"})};function f(g){const N=s.find(S=>S.columnId===g);N&&o(N)}return e.jsx(t.SortableContext,{items:s.map(g=>he(g.columnId)),children:e.jsxs("div",{className:"space-y-2 rounded-md p-4 text-sm",children:[e.jsx(t.Label,{className:"text-sm",children:"Sort By"}),x.length>0&&e.jsx("div",{className:"mr-5",children:e.jsx(t.ComboBox2,{multiple:!1,options:x,selectedOptions:[],onChange:g=>p(g[0]),selectAllChecked:!1,onSelectAllCheckedChange:()=>{},inputClassName:"h-8 bg-muted border-none"})}),s.map(g=>{var N,S;return e.jsx(Gt,{id:he(g.columnId),type:Pe,children:e.jsx("div",{className:"group flex h-8 items-center gap-2 rounded-sm p-0",children:e.jsxs("div",{className:"flex h-full grow items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex h-full grow items-center justify-between gap-2 rounded-sm bg-muted px-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ot,{className:"size-3 cursor-move text-muted-foreground hover:text-foreground"}),e.jsx(Ne,{className:"w-[175px] text-sm",children:((N=m(g.columnId))==null?void 0:N.label)||((S=m(g.columnId))==null?void 0:S.name)})]}),e.jsx("button",{title:g.direction==="asc"?"Ascending":"Descending",onClick:()=>b(g.columnId),className:"rounded-sm p-0",children:v(g.columnId,g.direction)})]}),e.jsx("div",{children:e.jsx("button",{onClick:()=>f(g.columnId),className:"rounded-sm p-0",children:e.jsx(t.X,{className:"size-3 text-muted-foreground opacity-0 transition-opacity duration-200 hover:text-foreground group-hover:opacity-100"})})})]})},g.columnId)},he(g.columnId))})]})})}function pa(){const s=t.useEditorStore(f=>{var g;return((g=f.card.queryConfig)==null?void 0:g.groupByColumns)||[]}),a=t.useEditorStore(f=>f.card.type),n=t.useDndStore(f=>f.previewGroupByColumns),r=t.useEditorStore(f=>{var g;return((g=f.card.queryConfig)==null?void 0:g.metricColumns)||[]}),o=t.useDndStore(f=>f.previewMetricColumns),l=t.useEditorStore(f=>{var g;return((g=f.card.queryConfig)==null?void 0:g.pivotColumns)||[]}),i=t.useDndStore(f=>f.previewPivotColumns),{removeColumnFromGroupBy:d,removeColumnFromMetricColumns:c,removeColumnFromPivotBy:h}=t.useEditorActions();function u(f){d(f)}function x(f){c(f)}function v(f){h(f)}let m="Group By",b="Metrics",p="Stack By";return a==="table"&&(m="Rows",b="Metrics",p="Columns"),e.jsxs("div",{className:"flex h-full w-full flex-col gap-3 py-4",children:[e.jsx(Rt,{iconClassName:"size-[19px]"}),e.jsxs(t.CustomScrollArea,{className:"flex min-h-0 grow basis-0 flex-col gap-4 overflow-y-auto",children:[e.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[e.jsx(Ae,{onRemoveColumn:u,sortableType:be,id:ne,label:m,columns:s,previewColumns:n}),e.jsx(Ae,{onRemoveColumn:v,sortableType:ve,id:re,label:p,columns:l,previewColumns:i}),e.jsx(Ae,{onRemoveColumn:x,sortableType:Oe,id:ae,label:b,columns:r,previewColumns:o}),e.jsx(xa,{})]}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})]})}function Ge({children:s,column:a,id:n,sortableType:r,className:o}){const[l,i]=E.useState(!1),{removeEditorFilter:d,clearEditorFilter:c}=t.useEditorActions(),h=t.useEditorStore(x=>{var v,m;return(m=(v=x.card.queryConfig)==null?void 0:v.filters)==null?void 0:m.some(b=>b.filterColumnName===a.name)});function u(x){d(x)}return e.jsx(Gt,{id:n,type:r,children:e.jsxs("div",{className:t.cn("group space-y-1 rounded-md bg-muted px-3 py-2",{"border-border":l}),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"text-sm",children:a.name}),h&&e.jsx("button",{onClick:()=>c(a),children:e.jsx(t.FilterX,{className:"size-3 cursor-pointer items-center justify-center text-muted-foreground hover:text-foreground"})})]}),e.jsx("div",{"data-setting-actions":"",className:"invisible flex h-full items-center gap-2 group-hover:visible",children:e.jsx("button",{onClick:()=>u(a),children:e.jsx(t.X,{className:"size-3.5 cursor-pointer items-center justify-center rounded-r-sm text-muted-foreground"})})})]}),e.jsxs("div",{className:t.cn("group flex items-center rounded-t-md text-sm",!l&&"rounded-b-md",l&&"border border-border"),children:[e.jsx("div",{children:e.jsx(t.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:t.cn("grow cursor-pointer overflow-hidden truncate text-ellipsis whitespace-nowrap",o),children:s})]})]})})}function fa({column:s,sortableType:a}){const n=t.useDashboardStore(S=>S.themeStyle),r=t.useEditorStore(S=>{var A,k;return(k=(A=S.card)==null?void 0:A.queryConfig)==null?void 0:k.filters}),o=t.useEditorStore(S=>{var A,k;return(k=(A=S.card.queryConfig)==null?void 0:A.filterColumns)==null?void 0:k.find(T=>T.name===s.name)}),{selectedConnectionId:l,selectedDatabaseName:i,selectedTableName:d}=t.useEditorAside(),c=E.useMemo(()=>{var S;return(S=r==null?void 0:r.find(A=>A.filterColumnName===s.name))==null?void 0:S.filterValue},[r,s.name]),h=E.useMemo(()=>Array.isArray(c)?c.map(S=>({id:S,value:S})):[],[c]),{updateEditorFilterValue:u}=t.useEditorActions(),x={column:s.name,sql:s.sql,id:s.name,connectionId:l,dataType:s.type},{data:v,isLoading:m,isFetching:b,isError:p}=t.useFilterQuery(x),f=E.useMemo(()=>{var A;return x.column?(A=v==null?void 0:v.records)==null?void 0:A.map(k=>{let T=x.column.split(".").slice(-1)[0].replace(/"/g,"");return k[T]===void 0&&(T=T.toLowerCase()),{id:k[T],value:k[T]}}):[]},[v,x.column]);function g(S){const A=S.map(k=>k.id);u(s.name,A)}function N(){return m||b?e.jsx(t.Skeleton,{style:{borderRadius:n==null?void 0:n.controlInputRadius},className:"h-8 min-w-60 bg-foreground/10"}):p?e.jsx("div",{className:"flex h-8 min-w-60 items-center bg-muted px-2 text-sm",children:"Error"}):e.jsx(t.ComboBox2,{renderFilterModeButton:()=>e.jsx(ga,{columnName:s.name}),showNegativeIndicator:(o==null?void 0:o.mode)==="exclude",options:f,onChange:g,selectedOptions:h,selectAllChecked:!1,onSelectAllCheckedChange:()=>{}})}return e.jsx(Ge,{className:"w-60",id:s.id,sortableType:a,column:s,children:N()})}function ga({columnName:s}){const{setEditorFilterMode:a}=t.useEditorActions(),n=t.useEditorStore(o=>{var l,i;return(i=(l=o.card.queryConfig)==null?void 0:l.filterColumns)==null?void 0:i.find(d=>d.name===s)});function r(){(n==null?void 0:n.mode)==="exclude"?a(s,"include"):a(s,"exclude")}return e.jsx(t.Button,{onClick:r,variant:"secondary",size:"sm",className:t.cn("h-5 text-xs hover:underline",{}),children:t.titleCase((n==null?void 0:n.mode)==="exclude"?"exclude":"include")})}function ja({column:s,sortableType:a}){const[n,r]=E.useState(!1),{selectedConnectionId:o,selectedDatabaseName:l,selectedTableName:i}=t.useEditorAside(),d={column:s.name,sql:s.sql,id:s.name,connectionId:o,title:"",dataType:s.type},{isLoading:c,isFetching:h,isError:u,data:x}=t.useFilterQuery(d),v=x==null?void 0:x.records,{dateRange:m,setDateRange:b,initialDateRange:p}=t.useDateRangeFromRecords(v),{updateEditorFilterValue:f}=t.useEditorActions();function g(A){var T,L;const k={gte:(T=A==null?void 0:A.from)==null?void 0:T.toISOString(),lte:(L=A==null?void 0:A.to)==null?void 0:L.toISOString()};f(s.name,k)}function N(){f(s.name,null,!0),b(p)}function S(){return c||h?e.jsx("div",{children:e.jsx(t.Skeleton,{className:"h-8 w-72 bg-foreground/10"})}):u?e.jsx("div",{className:"h-8 w-72 bg-muted px-2",children:"Error"}):v?e.jsx(t.DateRangePopover,{title:d.title,open:n,inputClassName:"h-8",setOpen:r,dateRange:m,setDateRange:b,onApply:g,onClear:N}):e.jsx(t.Label,{className:"flex h-8 w-72 items-center bg-muted px-2",children:"No Data"})}return e.jsx(Ge,{className:"w-72",id:s.id,sortableType:a,column:s,children:S()})}function ya({id:s,label:a,columns:n,previewColumns:r,sortableType:o}){var b,p;const{setNodeRef:l,isOver:i,over:d}=t.useDroppable({id:s}),c=t.useDndStore(f=>f.activeId),h={},u=i||((p=(b=d==null?void 0:d.data)==null?void 0:b.current)==null?void 0:p.type)===o;function x(){if(!m||m.length===0)return e.jsx("div",{className:"flex h-8 grow items-center space-x-2 rounded-md border border-dashed border-muted-foreground/80 bg-background px-2 py-1 text-sm text-muted-foreground",children:e.jsx("span",{className:"invisible text-muted-foreground/70 group-hover:visible",children:"Drag here"})})}function v(f){const g=t.isDateDataType(f.type);return f.id===yt.id?e.jsx(Ge,{id:f.id,sortableType:o,column:f,children:e.jsx(ba,{})},f.id):g?e.jsx(ja,{droppableId:s,sortableType:o,column:f},f.id):e.jsx(fa,{droppableId:s,sortableType:o,column:f},f.id)}const m=c?r:n;return e.jsx(t.SortableContext,{items:n==null?void 0:n.map(f=>f.id),children:e.jsxs("div",{className:t.cn("group space-y-2 rounded-md border-muted-foreground/50 p-4",u&&"border border-muted-foreground/20"),ref:l,style:h,children:[e.jsx(t.Label,{className:"text-sm",children:a}),x(),e.jsx("div",{className:"flex flex-wrap items-center gap-4",children:m==null?void 0:m.map(f=>v(f))})]})})}function ba(){return e.jsx("div",{className:"flex h-8 w-60 items-center space-x-2 rounded-md border border-dashed border-muted-foreground bg-background px-2 py-1 text-sm text-muted-foreground",children:"Drop here"})}function va(){const s=t.useEditorStore(o=>{var l;return((l=o.card.queryConfig)==null?void 0:l.filterColumns)||[]}),a=t.useDndStore(o=>o.previewFilterColumns),{removeColumnFromFilterColumns:n}=t.useEditorActions();function r(o){n(o)}return e.jsx("section",{className:"size-full px-4 pb-4",children:e.jsx(ya,{onRemoveColumn:r,sortableType:Fe,id:ze,label:"Filters",columns:s,previewColumns:a})})}function Ca(){const s=t.useEditorStore(l=>l.card),a=t.useEditorStore(l=>l.showAIDialog),{setShowAIDialog:n}=t.useEditorActions(),{data:r,errorMessage:o}=t.useDashboardCardQuery(s);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(It,{}),!a&&e.jsxs(t.Button,{onClick:()=>n(!0),variant:"secondary",size:"sm",children:[e.jsx(Fs,{className:"mr-2 h-4 w-4"}),"Assistant"]}),e.jsx(vt,{sql:r==null?void 0:r.sql,error:o})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-green-300 px-3 py-1 text-xs font-medium text-black",children:"Preview"}),e.jsx(Dt,{}),e.jsx(kt,{variant:"default"})]})]})}function Sa(){const s=E.useRef(null),a=E.useRef(null),n=t.useEditorStore(d=>d.isShowingVisual),r=t.useEditorStore(d=>d.showAIDialog),o=t.useEditorStore(d=>d.isDevMode);E.useEffect(()=>{var d,c,h,u;r?((d=s.current)==null||d.resize(0),(c=a.current)==null||c.resize(0)):((h=s.current)==null||h.resize(25),(u=a.current)==null||u.resize(25))},[r]);function l(){return e.jsxs(e.Fragment,{children:[e.jsx(t.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsx(bn,{})}),e.jsx(t.ResizableHandle,{withHandle:!0}),e.jsx(t.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:n&&!r?e.jsxs(t.ResizablePanelGroup,{direction:"horizontal",children:[e.jsx(e.Fragment,{children:e.jsx(t.ResizablePanel,{ref:s,className:"flex",defaultSize:25,maxSize:30,children:e.jsx(ra,{})})}),!r&&e.jsx(t.ResizableHandle,{}),e.jsx(t.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsx(je,{})})]}):e.jsx(je,{})})]})}function i(){return e.jsx(e.Fragment,{children:e.jsx("div",{className:"grow","data-biz-mode-container":"",children:n?e.jsxs(t.ResizablePanelGroup,{direction:"horizontal",children:[e.jsx(e.Fragment,{children:e.jsx(t.ResizablePanel,{ref:a,defaultSize:25,maxSize:30,children:e.jsx(pa,{})})}),e.jsx(t.ResizableHandle,{}),e.jsx(t.ResizablePanel,{defaultSize:75,maxSize:100,children:e.jsxs(t.ResizablePanelGroup,{direction:"vertical",children:[e.jsxs(t.ResizablePanel,{className:"flex min-h-fit flex-col",minSize:10,defaultSize:20,children:[e.jsx(Ca,{}),e.jsx(va,{})]}),e.jsx(t.ResizableHandle,{}),e.jsx(t.ResizablePanel,{minSize:60,defaultSize:80,children:e.jsx(je,{})})]})})]}):e.jsx(je,{})})})}return e.jsx(t.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:o?l():i()})}const Na=[{title:"Help me write a query for",subtitle:"orders by month"},{title:"Create a bar chart for",subtitle:"sales by category"}];function wa(){const s=E.useRef(null),a=E.useRef(null),[n,r]=E.useState(!1),[o,l]=E.useState(t.isDevEnv),[i,d]=E.useState(!1),c=t.useEditorStore(C=>C.actions.setCardSql),h=t.useEditorStore(C=>C.actions.setRunSql),u=t.useEditorStore(C=>C.showAIDialog),x=t.useDashboardStore(C=>C.handleOpenAssistantProfile),{setShowAIDialog:v,setCardPython:m}=t.useEditorActions(),{assistantProfile:b}=t.useAssistantProfile(),{messages:p,setMessages:f,reload:g,append:N,input:S,setInput:A,isLoading:k,handleAddCurrentTableToScope:T,removeFromCurrentSelections:L,currentAssitantScope:F,handleInputChange:G,handleSubmit:w,stop:R,chatStatus:U,llmUsage:q,errorMessage:D}=wt();t.useAssistantScroll({scrollContainerRef:s,inputRef:a,messages:p}),E.useEffect(()=>{var C;u&&((C=a.current)==null||C.focus())},[u]);function j(C,I){I==="sql"?(c(C),h(!0)):I==="python"&&(m(C),h(!0))}function M(C){const I={role:"user",content:C.title+" "+C.subtitle};N(I)}function V(C){N({role:"user",content:C})}function _(){return e.jsxs(t.DropdownMenu,{children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",children:e.jsx(t.EllipsisVertical,{className:"size-3.5"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",children:[e.jsx(t.DropdownMenuLabel,{children:"Options"}),e.jsx(t.DropdownMenuSeparator,{}),e.jsx(t.DropdownMenuCheckboxItem,{checked:n,onCheckedChange:r,children:"Token Usage"}),e.jsx(t.DropdownMenuCheckboxItem,{checked:o,onCheckedChange:l,children:"Tool Invocations"}),e.jsx(t.DropdownMenuCheckboxItem,{checked:i,onCheckedChange:d,children:"System Message"})]})]})}function H(){return e.jsxs("div",{children:[F&&F.length>0&&e.jsx("div",{className:"mt-2 flex max-h-16 flex-wrap items-center gap-2 overflow-y-auto",children:F==null?void 0:F.map((C,I)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted px-2 py-1 text-xs",children:[t.getFormattedTableNameForQuery({schemaName:C.schemaName||"",tableName:C.tableName||"",modelName:C.datamodelName||"",connectionType:C.connectionType||"",databaseName:C.databaseName||""}),e.jsx("button",{onClick:()=>{L(C)},children:e.jsx(t.X,{className:"size-3 text-muted-foreground hover:text-foreground"})})]},I))}),(F==null?void 0:F.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(t.Button,{className:"h-6 text-xs",size:"sm",variant:"secondary",onClick:T,children:[e.jsx(t.Plus,{className:"mr-2 size-3"}),"Current Table"]})]})]})}function Q(){return e.jsx("div",{"data-role":"header",children:e.jsx("div",{className:"text-lg font-semibold",children:"Assistant"})})}const y=(S==null?void 0:S.length)===0&&(p==null?void 0:p.filter(C=>C.role==="user").length)===0;return e.jsxs("div",{"data-role":"editor-assistant",className:"flex h-full w-full flex-col justify-between px-6 py-4",children:[e.jsxs("div",{"data-role":"header-section",className:"flex items-start justify-between gap-2",children:[Q(),x&&e.jsx(t.Button,{variant:"outline",size:"sm",className:"h-7 p-2",onClick:x,children:(b==null?void 0:b.name)||"Default Profile"}),e.jsxs("div",{"data-role":"header-actions",className:"flex items-center",children:[_(),e.jsx(t.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",onClick:()=>{f([]),g()},children:e.jsx(t.Plus,{className:"size-4"})}),e.jsx(t.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",onClick:()=>{v(!1)},children:e.jsx(t.PanelRight,{className:"size-4"})})]})]}),H(),e.jsx(t.CustomScrollArea,{ref:s,className:"mt-2 flex w-full grow basis-0",children:e.jsxs("div",{className:"space-y-4 py-2 pr-3","data-role":"messages",children:[e.jsx(t.PrintMessages,{messages:p,showTools:o,handleRun:j,showSystemMessage:i}),e.jsx(t.ChatStatus,{messages:p,chatStatus:U,errorMessage:D})]})}),e.jsxs("div",{className:"mb-3",children:[y&&!b&&e.jsx(t.Placeholders,{onClick:M,placeholders:Na}),e.jsx("div",{children:y&&b&&e.jsx(t.SeedQuestions,{seedQuestions:b.seedQuestions||[],handleSeedQuestionClick:V})})]}),e.jsx(t.ChatInput,{onFocus:()=>{T()},stop:R,ref:a,setInput:A,input:S,handleInputChange:G,handleSubmit:w,isLoading:k}),q&&n&&e.jsx("div",{className:"flex h-8 items-center justify-between",children:e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Usage: ",q.promptTokens," prompt tokens,"," ",q.completionTokens," completion tokens,"," ",q.totalTokens," total tokens"]})})]})}function ka({authToken:s,onSave:a,onClose:n}){const r=E.useRef(null),o=t.useEditorStore(f=>f.showAIDialog),{setAuthToken:l}=t.useDashboardActions(),{setShowAIDialog:i,setOnSave:d,setOnClose:c}=t.useEditorActions(),{handleDragOver:h,handleDragEnd:u,handleDragStart:x,handleDragCancel:v,sensors:m}=an();E.useEffect(()=>{a&&d(a),n&&c(n)},[a,d,n,c]),E.useEffect(()=>{s&&s.accessToken&&l(s)},[s,l]),E.useEffect(()=>{var f,g;o?((f=r.current)==null||f.resize(40),i(!0)):(i(!1),(g=r.current)==null||g.resize(0))},[o,i]);function b(f){f<1?i(!1):o||i(!0)}function p(){return e.jsxs(t.ResizablePanelGroup,{"data-content":"editor-main",className:"grow",direction:"horizontal",children:[e.jsx(t.ResizablePanel,{className:"min-w-[510px] rounded-none",children:e.jsx(Sa,{})}),e.jsx(t.ResizableHandle,{}),e.jsx(t.ResizablePanel,{"data-role":"editor-assistant-panel",ref:r,onResize:b,defaultSize:0,children:e.jsx(wa,{})})]})}return e.jsx(t.ErrorBoundary,{FallbackComponent:t.Fallback,children:e.jsx(t.DndContext,{sensors:m,onDragStart:x,onDragEnd:u,onDragOver:h,onDragCancel:v,children:e.jsxs("section",{className:"isolate flex h-full grow","data-content":"editor-panel",children:[e.jsx(bt,{type:"main"}),p()]})})})}function Da(){t.useDashboardStore(i=>i.selectedCardId);const s=t.useDashboardStore(i=>i.selectedSheetId),{setIsVisualEditing:a}=t.useDashboardStore(i=>i.actions),n=t.useDashboardStore(i=>i.isVisualEditing),r=t.useDashboardStore(i=>i.actions.updateFrame);function o(i){s&&(r(s,i),a(!1))}function l(){a(!1)}return e.jsx("div",{role:"editor-container",className:t.cn("flex grow",{"max-h-0 overflow-hidden":!n}),children:e.jsx(ka,{onSave:o,onClose:l})})}function Ia(){const s=t.useEditorStore(l=>l.selectedDatabaseName),a=t.useEditorStore(l=>l.selectedTableName),n=t.useDashboardStore(l=>l.dashboard.filters)||[],{columns:r}=t.useEditorAside(),{assignFilter:o}=Pt();return e.jsx(t.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===t.fmt(l.column_name)&&d.table===a&&d.database===s);return e.jsx("div",{onClick:()=>o(l),className:t.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(qe,{column:l}),e.jsx("span",{children:l.column_name})]})},l.column_name)})})}function Ea(){t.useDashboardStore(a=>a.showFilters);const s=t.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(t.Label,{className:"px-2 text-lg",children:"Filters"}),e.jsx(t.Button,{onClick:()=>s(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsx(t.Cross2Icon,{})})]}),e.jsx("div",{className:"flex grow",children:e.jsx(bt,{type:"filter",ColumnsComponent:()=>e.jsx(Ia,{})})})]})}function Ta(){const s=t.useDashboardStore(r=>r.dashboard.filters),a=t.useDashboardStore(r=>r.theme),n=s==null?void 0:s.filter(r=>r.hide);return n!=null&&n.length?e.jsx("div",{className:t.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(t.FilterHeader,{filter:r}),e.jsx(t.FilterComponent,{filter:r})]},r.id))}):null}function Ma(){const s=t.useDashboardStore(r=>r.showFilters),a=t.useDashboardStore(r=>r.isVisualEditing),n=t.useDashboardStore(r=>r.isDashboardEditing);return e.jsxs("div",{role:"dashboard-plus-main",className:t.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(Ta,{}),e.jsx(t.DashboardTabs,{})]}),s&&e.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsx(Ea,{})})]})}function Aa(){const s=t.useDashboardStore(o=>o.dashboard),a=t.useDashboardStore(o=>o.actions.setDashboard),n=t.useDashboardStore(o=>o.showDashboardJSON),r=t.useDashboardStore(o=>o.actions.setShowDashboardJSON);return e.jsxs("div",{className:t.cn("relative p-2",{hidden:!n}),children:[e.jsxs(t.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>r(!1),children:[e.jsx(t.X,{className:"mr-2 h-4 w-4"}),"Close"]}),e.jsx(t.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(s,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}function La({showControls:s=!1,showFooter:a=!0,...n}){return e.jsx(t.ErrorBoundary,{FallbackComponent:t.Fallback,children:e.jsxs(t.SemaphorContextProvider,{dashboardProps:n,children:[e.jsx(t.$e,{}),e.jsxs(t.UXProvider,{children:[e.jsx(Aa,{}),e.jsxs(t.DashboardPanel,{...n,children:[s&&e.jsx(Xs,{}),e.jsx(Da,{}),e.jsx(Ma,{})]})]})]})})}exports.Dashboard=t.Dashboard;exports.DashboardWC=t.DashboardWC;exports.SemaphorDataProvider=t.SemaphorQueryClient;exports.SemaphorQueryClient=t.SemaphorQueryClient;exports.createSqlGenConfig=t.createSqlGenConfig;exports.fmt=t.fmt;exports.getColumnDataType=t.getColumnDataType;exports.getFilterValueType=t.getFilterValueType;exports.getFormattedTableNameForQuery=t.getFormattedTableNameForQuery;exports.getQualifiedTableName=t.getQualifiedTableName;exports.getSql=t.getSql;exports.invalidateToken=t.invalidateToken;exports.isBooleanDataType=t.isBooleanDataType;exports.isColumnInSqlGen=t.isColumnInSqlGen;exports.isDateDataType=t.isDateDataType;exports.isNumberDataType=t.isNumberDataType;exports.isTextDataType=t.isTextDataType;exports.resolveDataType=t.resolveDataType;exports.resolveDatamodelName=t.resolveDatamodelName;exports.useCard=t.useCard;exports.useDashboardActions=t.useDashboardActions;exports.useDashboardStore=t.useDashboardStore;exports.useDateFilterHook=t.useDateFilterHook;exports.useEditorActions=t.useEditorActions;exports.useEditorAside=t.useEditorAside;exports.useEditorStore=t.useEditorStore;exports.useTextFilterHook=t.useTextFilterHook;exports.EMPTY_SELECTION=Wt.EMPTY_SELECTION;exports.ScheduleDashboard=jt;exports.SelectComponent=ce;exports.Surfboard=La;exports.cleanCard=pt;exports.downloadPdf=gt;exports.getDashbaordStateWithoutData=_e;
|
|
369
|
+
`),I=new Blob([C],{type:"text/csv"}),B=URL.createObjectURL(I),$=document.createElement("a");$.href=B,$.download=`${a.title}.csv`,$.click()}function H(){const y=`Can you get the documentation for ${a.type} chart?`;m(y)}return e.jsxs("div",{className:"relative isolate flex h-full flex-col py-2 pb-3",children:[(g||N)&&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(oe,{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(Mn,{}),o&&e.jsx(t.IconButton,{tooltip:"Visual Docs",onClick:H,children:e.jsx(ls,{className:"size-4"})}),!["table","custom"].includes(a.type)&&o&&e.jsx(kn,{})]}),!r&&e.jsxs("div",{className:"flex grow items-center gap-1",children:[e.jsx(t.Button,{className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",variant:"ghost",size:"icon",onClick:_,children:e.jsx(En,{className:"size-4"})}),e.jsx(t.Button,{className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",variant:"ghost",size:"icon",onClick:V,children:e.jsx(Ss,{strokeWidth:1.5,className:"size-4"})}),e.jsx(t.CopyButton,{text:JSON.stringify(f==null?void 0:f.records,null,2),className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70"})]}),e.jsx(zn,{}),n&&e.jsx(Rn,{})]}),r?j():e.jsxs(t.ResizablePanelGroup,{className:"px-6",direction:"horizontal",children:[i&&e.jsxs(e.Fragment,{children:[e.jsx(t.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(Fn,{})}),e.jsx(t.ResizableHandle,{})]}),e.jsxs(t.ResizablePanel,{id:"2",order:2,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:[(f==null?void 0:f.records)&&(f==null?void 0:f.records.length)>0&&e.jsx(vn,{data:(f==null?void 0:f.records)||[]}),(S||(f==null?void 0:f.error))&&e.jsx("span",{className:"font-mono text-xs",children:(S==null?void 0:S.message)||((Q=f==null?void 0:f.error)==null?void 0:Q.message)})]})]})]})}function Fn(){const s=t.useEditorStore(n=>n.pythonStdOut);if(!s)return null;const a=s.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(t.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(t.ScrollBar,{orientation:"horizontal"})]})]})}function Rn(){const s=t.useEditorStore(n=>n.isShowingVisual),a=t.useEditorStore(n=>n.actions.setIsShowingVisual);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Label,{htmlFor:"visualize",children:"Chart"}),e.jsx(t.SmallSwitch,{checked:s,onCheckedChange:()=>a(!s),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function Bn(){var p,f;const s=t.useEditorStore(g=>g.card.customCardPreferences),{data:a}=Mt(),n=(a==null?void 0:a.plugins)||[],r=t.useEditorStore(g=>g.card),o=t.useEditorStore(g=>g.frame),l=(s==null?void 0:s.visualType)||"single",{setCustomCardPreferences:i}=t.useEditorActions(),{components:d,manifest:c}=t.useCustomVisual((s==null?void 0:s.url)||""),h=(p=c==null?void 0:c.visuals)==null?void 0:p.find(g=>g.name===(s==null?void 0:s.componentName));function u(g,N){if(!s)return;const A={...(s==null?void 0:s.dataInputCardIds)||{},[g]:{cardId:N,hookRef:null}};i({...s,dataInputCardIds:A})}function x(g){var S,A;const N=(S=o==null?void 0:o.cards)==null?void 0:S.filter(k=>{var T;return((T=k==null?void 0:k.customCardPreferences)==null?void 0:T.visualType)!=="multiple"}).map(k=>({value:k.id,label:k.tabTitle||k.title}));return e.jsx("div",{className:"space-y-2",children:(A=g==null?void 0:g.dataInputs)==null?void 0:A.map((k,T)=>{var L,F;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(X,{className:"col-span-6 h-8 w-full justify-between",label:"",options:N||[],value:((F=(L=s==null?void 0:s.dataInputCardIds)==null?void 0:L[T])==null?void 0:F.cardId)||"",onValueChange:G=>u(T,G)})]},T+Math.random())})})}function v(g,N,S=[],A=""){var k,T;return s?g==="input"?e.jsx(t.Input,{className:`h-8 w-full ${t.removeRing}`,value:((k=s==null?void 0:s.settings)==null?void 0:k[N])||A,onChange:L=>{i({...s,settings:{...s==null?void 0:s.settings,[N]:L.target.value}})}},N):g==="select"?e.jsx(X,{className:"h-8 w-full",label:"",options:S,value:((T=s==null?void 0:s.settings)==null?void 0:T[N])||A,onValueChange:L=>{i({...s,settings:{...s==null?void 0:s.settings,[N]:L}})}}):null:null}function m(g){const N=Object.entries((g==null?void 0:g.settings)||{});return e.jsx("div",{className:"space-y-3",children:N.map(([S,A])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:A.title}),v(A.ui,S,A.options,A.defaultValue)]},S))})}function b(g){s&&i({...s,visualType:g,componentName:""})}return e.jsxs(t.Accordion,{type:"multiple",defaultValue:["component-settings"],className:"px-6 py-2",children:[e.jsxs(t.AccordionItem,{value:"plugin-settings",children:[e.jsx(t.AccordionTrigger,{children:"Plugin"}),e.jsx(t.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(X,{icon:e.jsx(is,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Plugin",options:n,value:(s==null?void 0:s.url)||"",onValueChange:g=>i({...s||{url:"",componentName:""},url:g})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&e.jsx(t.Tabs,{value:l,onValueChange:b,children:e.jsxs(t.TabsList,{className:"h-9 w-full",children:[e.jsx(t.TabsTrigger,{className:"h-7 w-full",value:"single",children:"Single Visual"}),e.jsx(t.TabsTrigger,{className:"h-7 w-full",value:"multiple",children:"Multi-Visual"})]})})]})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&s&&e.jsx(e.Fragment,{children:d&&e.jsx(X,{icon:e.jsx(fs,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Component",options:(d==null?void 0:d.filter(g=>g.type===l).map(g=>({value:g.name,label:g.name})))||[],value:s.componentName,onValueChange:g=>{console.log("changing value",g),i({...s,componentName:g})}})})]})})]}),((f=r==null?void 0:r.customCardPreferences)==null?void 0:f.componentName)&&e.jsxs(t.AccordionItem,{className:"border-none",value:"component-settings",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsxs(t.AccordionContent,{children:[h&&h.dataInputs&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(t.Label,{children:"Input Mapping"}),e.jsx("div",{className:"px-2",children:x(h)})]}),h&&h.settings&&e.jsx("div",{className:"space-y-3",children:e.jsx("div",{className:"px-2",children:m(h)})})]})]})]})}function le(){const[s,a]=E.useState([]),n=t.useEditorStore(h=>h.card.preferences),{setFilterOnClickColumnIndex:r,setCardPreferences:o}=t.useEditorStore(h=>h.actions),l=t.useEditorStore(h=>h.queryResultColumns);t.useEditorStore(h=>{var u;return(u=h.card.preferences)==null?void 0:u.filterOnClickColumnIndex}),E.useEffect(()=>{l&&a(new Array(l.length).fill(!1))},[l]);function i(h,u){var x,v;u?n!=null&&n.onClickFilter&&((x=n==null?void 0:n.onClickFilter)==null?void 0:x.length)>0?o({...n,onClickFilter:[...n.onClickFilter,{columnIndex:h,expression:""}]}):o({...n,onClickFilter:[{columnIndex:h,expression:""}]}):(o({...n,onClickFilter:(v=n==null?void 0:n.onClickFilter)==null?void 0:v.filter(m=>m.columnIndex!==h)}),a(m=>{const b=[...m];return b[h]=!1,b}))}function d(h,u){var v;const x=(v=n==null?void 0:n.onClickFilter)==null?void 0:v.map(m=>m.columnIndex===h?{...m,expression:u.target.value}:m);o({...n,onClickFilter:x})}function c(h){var u,x,v,m;if(s!=null&&s[h]||(x=(u=n==null?void 0:n.onClickFilter)==null?void 0:u.find(b=>b.columnIndex===h))!=null&&x.expression)return e.jsx(t.Input,{value:(m=(v=n==null?void 0:n.onClickFilter)==null?void 0:v.find(b=>b.columnIndex===h))==null?void 0:m.expression,onChange:b=>d(h,b),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:"max-h-[150px] space-y-2 overflow-y-auto",children:[e.jsx(t.Label,{children:"On Click"}),l==null?void 0:l.map((h,u)=>{var x,v;return e.jsx("div",{className:"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(t.Checkbox,{checked:!!((x=n==null?void 0:n.onClickFilter)!=null&&x.find(m=>m.columnIndex===u)),onCheckedChange:m=>i(u,m)}),e.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:h}),e.jsx("div",{className:"flex items-center gap-2",children:((v=n==null?void 0:n.onClickFilter)==null?void 0:v.find(m=>m.columnIndex===u))&&e.jsx(t.Pencil,{onClick:()=>{a(m=>{const b=[...m];return b[u]=!m[u],b})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),c(u)]})},h)})]})}function Vn({idx:s}){var d;const a=t.useEditorStore(c=>{var h;return(h=c.card)==null?void 0:h.preferences}),n=t.useEditorStore(c=>{var h;return(h=c.card.preferences)==null?void 0:h.datasetOptions}),r=t.useEditorStore(c=>c.actions.setCardPreferences),o=(d=a==null?void 0:a.chartOptions)==null?void 0:d.indexAxis,l=n==null?void 0:n.find(c=>c.idx===s);function i(c,h){(c==="end"||c==="start")&&t.getContrastColor(t.getCanvasBackgroundColor());const u={display:c!=="none",align:c,anchor:c,clamp:!0};if(!l)r({...a,datasetOptions:[...n||[],{idx:h,datalabels:u}]});else{const x={...l};x.datalabels=u;const v=n==null?void 0:n.map(m=>m.idx===h?x:m);r({...a,datasetOptions:v})}}return e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{children:e.jsx(Hs,{className:"size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsx(t.PopoverContent,{className:"w-fit px-2 py-1",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>i("none",s),className:"h-7 p-1 text-xs font-normal",children:e.jsx(t.X,{className:"size-3.5"})}),e.jsx("button",{onClick:()=>i("start",s),className:"h-7 p-1 text-xs font-normal",children:e.jsx(Ts,{className:t.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsx("button",{onClick:()=>i("center",s),className:"h-7 p-1 text-xs font-normal",children:e.jsx(As,{className:t.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsx("button",{onClick:()=>i("end",s),className:"h-7 p-1 text-xs font-normal",children:e.jsx(Ms,{className:t.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function Bt(){const s=t.useEditorStore(l=>l.card),{data:a}=t.useDashboardCardQuery(s),{keys:n}=t.getKeys((a==null?void 0:a.records)||[]),r=n.slice(1).filter(l=>!t.METADATA_KEYS.includes(l));let o=r;if(["stackedBar","stackedLine"].includes(s.type)){const l=t.pivotData({dataArray:(a==null?void 0:a.records)||[],groupKey:n[0],pivotKey:n[1],valueKey:n[2]}),{keys:i}=t.getKeys(l);o=i.slice(1)}return{transformedMetricKeys:o,dimensionKeys:n.slice(0,1),keys:n,defaultMetricKeys:r}}function Ne({children:s,className:a,delayDuration:n}){return e.jsx(t.TooltipProvider$1,{children:e.jsxs(t.Tooltip,{delayDuration:n,children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsx("span",{className:t.cn("overflow-hidden text-ellipsis whitespace-nowrap",a),children:s})}),e.jsx(t.TooltipContent,{children:s})]})})}function Vt(){const s=t.useEditorStore(c=>c.card),a=t.useEditorStore(c=>{var h,u,x;return(x=(u=(h=c==null?void 0:c.card)==null?void 0:h.preferences)==null?void 0:u.chartOptions)==null?void 0:x.indexAxis}),{data:n}=t.useDashboardCardQuery(s),r=a==="y"?"Metric":"Dimension",o=a==="y"?"Dimension":"Metric",{dimensionKeys:l,transformedMetricKeys:i,keys:d}=Bt();return d.length===0?null:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:r}),e.jsx("div",{className:"max-h-[125px] space-y-1 overflow-y-auto",children:l.map(c=>e.jsx("p",{className:"flex h-8 items-center rounded-md bg-muted/70 px-3 hover:bg-muted",title:c,children:_t(c)},c))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:o}),e.jsx("div",{className:"my-1 max-h-[125px] space-y-1 overflow-y-auto",children:i.map((c,h)=>e.jsx(qt,{className:"flex h-8 items-center bg-muted/70 px-3 hover:bg-muted",iconClassName:"invisible group-hover:visible",col:c,idx:h},c))})]})]})}function _t(s,a=30){return s.length>a?s.slice(0,a)+"...":s}function qt({col:s,idx:a,className:n,iconClassName:r,children:o}){const l=t.useEditorStore(u=>{var x;return(x=u.card)==null?void 0:x.preferences}),i=t.useEditorStore(u=>{var x,v;return(v=(x=u.card)==null?void 0:x.preferences)==null?void 0:v.datasetOptions}),d=i==null?void 0:i.find(u=>u.idx===a),{setCardPreferences:c}=t.useEditorStore(u=>u.actions);function h(u){if(!d)c({...l,datasetOptions:[...i||[],{idx:a,type:u==="area"?"line":u,fill:u==="area"?"origin":""}]});else{const x={...d};x.type=u==="area"?"line":u,x.fill=u==="area"?"origin":"";const v=i==null?void 0:i.map(m=>m.idx===a?x:m);c({...l,datasetOptions:v})}}return e.jsxs("div",{className:t.cn("group flex items-center justify-between gap-2 rounded-md",n),children:[o||e.jsx(Ne,{className:"max-w-[100px]",title:s,children:_t(s)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Re,{onClick:()=>h("bar"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",r)}),e.jsx(Be,{onClick:()=>h("line"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",r)}),e.jsx(ms,{onClick:()=>h("area"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",r)}),e.jsx(Vn,{idx:a})]})]})}function Pt(){const s=t.useEditorStore(m=>m.selectedConnectionId),a=t.useEditorStore(m=>m.selectedDatamodelId),n=t.useEditorStore(m=>m.selectedDatabaseName),r=t.useEditorStore(m=>m.selectedSchemaName),o=t.useEditorStore(m=>m.selectedTableName),l=t.useDashboardStore(m=>m.dashboard.filters)||[],i=t.useDashboardStore(m=>m.actions.addFilter),d=t.useDashboardStore(m=>m.actions.removeFilter),{removeFilterValues:c}=t.useDashboardActions(),{modelItems:h,tableName:u,connectionType:x}=t.useEditorAside();function v(m,b="dashboard"){var L;const p=t.fmt(m.column_name),f=t.fmt(n||""),g=t.fmt(r||""),N=t.fmt(u);let S=t.getQualifiedTableName({schemaName:g,tableName:N,connectionType:x,databaseName:f}),A=`${S}.${p}`;const k=(L=h==null?void 0:h.find(F=>F.id===a))==null?void 0:L.name;a&&a!=="none"&&(A=`${t.DATAMODEL_NAMESPCACE}.${k}.${p}`,S=`${t.DATAMODEL_NAMESPCACE}.${k}`);const T=l==null?void 0:l.find(F=>F.column===A&&F.table===N&&(F.database===f||F.database===n));if(T)c(T.id),d(T.id);else{const F=t.v4();return u==="api"&&s?(i({location:b,id:F,column:A,title:m.column_name,dataType:m.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:t.getDefaultFilterSql(m.data_type,S,p)}),F):(i({id:F,location:b,column:A,title:m.column_name,dataType:m.data_type,table:o||"",database:n||"",connectionId:s||"",operation:"in",sql:t.getDefaultFilterSql(m.data_type,S,p)}),F)}}return{assignFilter:v}}function me(){const s=t.useDashboardStore(d=>d.dashboard.filters),a=t.useEditorStore(d=>d.frame),{setFrame:n}=t.useEditorActions(),{columns:r}=t.useEditorAside(),{assignFilter:o}=Pt();function l(d){const c=o(d,"frame");n({...a,filterId:c})}const i=s==null?void 0:s.find(d=>d.id===a.filterId);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(t.Label,{children:"Card Filter"}),e.jsx(_n,{onSelect:l,columns:r}),i&&e.jsx(t.FilterHeader,{filter:i})]})}function _n({columns:s,onSelect:a}){var i;const[n,r]=de.useState(!1),[o,l]=de.useState("");return e.jsxs(t.Popover,{open:n,onOpenChange:r,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{size:"sm",variant:"outline",role:"combobox","aria-expanded":n,className:"w-full justify-between font-normal",children:[o?(i=s.find(d=>d.column_name===o))==null?void 0:i.column_name:"Select Column...",e.jsx(t.CaretSortIcon,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(t.PopoverContent,{className:"w-[200px] p-0",children:e.jsxs(t.Command,{children:[e.jsx(t.CommandInput,{placeholder:"Search column",className:"h-9"}),e.jsxs(t.CommandList,{children:[e.jsx(t.CommandEmpty,{children:"No framework found."}),e.jsx(t.CommandGroup,{children:s==null?void 0:s.map(d=>e.jsxs(t.CommandItem,{value:d.column_name,onSelect:c=>{const h=c===o?"":c;l(h),r(!1),h&&a(d)},children:[d.column_name,e.jsx(t.CheckIcon,{className:t.cn("ml-auto h-4 w-4",o===d.column_name?"opacity-100":"opacity-0")})]},d.column_name))})]})]})})]})}function qn({cardType:s}){return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{children:`${t.titleCase(s)} Chart`}),e.jsxs(t.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(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsx(t.AccordionContent,{className:"space-y-4 px-2",children:e.jsx(Vt,{})})]}),e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(le,{}),e.jsx(me,{})]})]})]})})}function He(){var o,l,i;const s=t.useEditorStore(d=>d.card.type),a=t.useEditorStore(d=>d.card.preferences),{setCardPreferences:n}=t.useEditorStore(d=>d.actions);function r(d){var u;const c={datalabels:{display:d!=="none",align:d,anchor:d,clamp:!0}},h={...a,chartOptions:{...a==null?void 0:a.chartOptions,plugins:{...(u=a==null?void 0:a.chartOptions)==null?void 0:u.plugins,...c}}};n(h),console.log(d)}return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"font-medium",children:"Data Labels"}),e.jsxs(t.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(t.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{placeholder:"Select position"})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Data Labels"}),e.jsx(t.SelectItem,{value:"none",children:"None"}),!["pyramid","funnel"].includes(s)&&e.jsx(t.SelectItem,{value:"start",children:"Start"}),e.jsx(t.SelectItem,{value:"center",children:"Center"}),!["pyramid","funnel"].includes(s)&&e.jsx(t.SelectItem,{value:"end",children:"End"})]})})]})]})}function Pn({cardType:s}){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(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{children:`${t.titleCase(s)} Chart`}),e.jsx(t.AccordionContent,{className:"space-y-4 font-mono text-xs",children:a(s)})]}),e.jsxs(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsx(t.AccordionContent,{className:"px-2",children:e.jsx(He,{})})]}),e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(le,{}),e.jsx(me,{})]})]})]})})}const Hn={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},Gn={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function Un(){const s=t.useEditorStore(a=>a.card.type);return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(t.Accordion,{className:" ",type:"single",collapsible:!0,children:$n(s)}),!["kpi"].includes(s)&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(He,{}),e.jsx(le,{}),e.jsx(me,{})]})]})}function $n(s){if(["line","bar"].includes(s))return e.jsxs(e.Fragment,{children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:e.jsx("p",{children:"Chart Query"})}),e.jsxs(t.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(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxs(t.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(Hn,null,2)})]})]}),e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxs(t.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(Gn,null,2)})]})]})]});if(s==="bubble")return e.jsx(e.Fragment,{children:e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:["How to create a ",e.jsx("span",{children:s})," chart query?"]})}),e.jsxs(t.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(s==="scatter")return e.jsx(e.Fragment,{children:e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:["How to create a ",e.jsx("span",{children:s})," chart query?"]})}),e.jsxs(t.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","funnel"].includes(s))return e.jsx(e.Fragment,{children:e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:[e.jsx("span",{children:s==="polarArea"?"Polar":s.charAt(0).toUpperCase()+s.slice(1)})," ","chart query"]})}),e.jsxs(t.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 Qn(){var c,h,u,x,v;const s=t.useEditorStore(m=>m.card.preferences),a=t.useEditorStore(m=>m.actions.setCardPreferences),n=t.useEditorStore(m=>m.actions.setNumberFormat);t.useEditorStore(m=>{var b,p;return(p=(b=m.card.preferences)==null?void 0:b.formatNumber)==null?void 0:p.decimalPlaces});const r=t.useEditorStore(m=>{var b,p;return(p=(b=m.card.preferences)==null?void 0:b.formatNumber)==null?void 0:p.locale}),o=t.useEditorStore(m=>{var b,p;return(p=(b=m.card.preferences)==null?void 0:b.formatNumber)==null?void 0:p.currency});t.useEditorStore(m=>m.actions.setFilterOnClickField);const l=t.useEditorStore(m=>{var b,p;return(p=(b=m.card.preferences)==null?void 0:b.formatNumber)==null?void 0:p.colorRanges})||[],i=t.useEditorStore(m=>m.actions.setColorRanges),d=[...new Set(t.LOCALE_CURRENCY_PAIRS.map(m=>m.currency))];return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(t.Checkbox,{checked:!!((c=s==null?void 0:s.formatNumber)!=null&&c.enabled),onCheckedChange:m=>{a({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:m}})}}),e.jsx(t.Label,{children:"Format Number"})]}),((h=s==null?void 0:s.formatNumber)==null?void 0:h.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(t.Label,{children:"Locale"}),e.jsxs(t.Select,{value:r||"none",onValueChange:m=>{var b,p,f;return n(((b=s==null?void 0:s.formatNumber)==null?void 0:b.decimalPlaces)||0,((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",m,((f=s==null?void 0:s.formatNumber)==null?void 0:f.suffix)||"")},children:[e.jsx(t.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Format"}),e.jsx(t.SelectItem,{value:"none",children:"None"},"none"),t.LOCALE_CURRENCY_PAIRS.map(m=>e.jsx(t.SelectItem,{value:m.locale,children:m.locale},m.locale))]})})]})]}),e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(t.Label,{children:"Currency"}),e.jsxs(t.Select,{value:o||"none",onValueChange:m=>{var b,p,f;console.log("currency",m),n(((b=s==null?void 0:s.formatNumber)==null?void 0:b.decimalPlaces)||0,m==="none"?"":m,((p=s==null?void 0:s.formatNumber)==null?void 0:p.locale)||"",((f=s==null?void 0:s.formatNumber)==null?void 0:f.suffix)||"")},children:[e.jsx(t.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Currency"}),e.jsx(t.SelectItem,{value:"none",children:"None"},"none"),d.map(m=>e.jsx(t.SelectItem,{value:m,children:m},m))]})})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(t.Label,{children:"Decimals"}),e.jsxs(t.Select,{value:((x=(u=s==null?void 0:s.formatNumber)==null?void 0:u.decimalPlaces)==null?void 0:x.toString())||"0",onValueChange:m=>{var b,p,f;return n(Number(m),((b=s==null?void 0:s.formatNumber)==null?void 0:b.currency)||"",((p=s==null?void 0:s.formatNumber)==null?void 0:p.locale)||"",((f=s==null?void 0:s.formatNumber)==null?void 0:f.suffix)||"")},children:[e.jsx(t.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:["0","1","2","3","4"].map(m=>e.jsx(t.SelectItem,{value:m,children:m},m))})]})]}),e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(t.Label,{children:"Suffix"}),e.jsx(t.Input,{value:((v=s==null?void 0:s.formatNumber)==null?void 0:v.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:m=>{var b,p,f;return n(((b=s==null?void 0:s.formatNumber)==null?void 0:b.decimalPlaces)||0,((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",((f=s==null?void 0:s.formatNumber)==null?void 0:f.locale)||"",m.target.value)}})]})]})]})}),e.jsx(t.Separator,{className:"my-3"}),e.jsx(t.ColorFormat,{colorRanges:l,setColorRanges:i})]})]})}function Jn(){return e.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsx(t.Accordion,{type:"single",collapsible:!0,children:e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxs(t.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:s=>s.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(Qn,{})}),e.jsx("div",{}),e.jsx("div",{})]})}function Me({children:s,summary:a,open:n,className:r}){return e.jsxs("details",{open:n,className:t.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(t.Label,{children:a}),e.jsx(t.ChevronUp,{className:"h-4 w-4"})]}),e.jsx("div",{className:"transition-all ease-in-out",children:s})]})}const Wn=[{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"}],Kn=["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"],Yn=Kn.map(s=>({label:s,value:s}));function Zn(){var c,h,u,x,v,m,b,p,f,g,N,S,A,k,T,L,F,G;const s=t.useEditorStore(w=>w.card),a=(h=(c=s==null?void 0:s.preferences)==null?void 0:c.mapVisualOptions)==null?void 0:h.topoJsonUrl,[n,r]=E.useState(((x=(u=s==null?void 0:s.preferences)==null?void 0:u.mapVisualOptions)==null?void 0:x.customTopoJsonUrl)||""),{setCardPreferences:o}=t.useEditorActions(),{data:l}=t.useTopoJson(s),i=Object.keys((l==null?void 0:l.objects)||{}).map(w=>({label:w,value:w}))||[],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(Me,{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(t.Separator,{className:"my-4"}),e.jsx(Me,{open:!0,summary:"Settings",children:e.jsxs("div",{className:"space-y-3 px-2",children:[e.jsx(X,{className:"h-9",options:d,onValueChange:w=>{console.log("value",w),o({...s.preferences,mapVisualOptions:{topoJsonUrl:w}})},value:a||"",label:"Select Map"}),a==="custom"&&e.jsx(t.Input,{onChange:w=>{r(w.target.value)},onBlur:()=>{var w;console.log("onBlur",n),o({...s.preferences,mapVisualOptions:{...(w=s.preferences)==null?void 0:w.mapVisualOptions,customTopoJsonUrl:n}})},value:n,className:`h-9 w-full ${t.removeRing}`,placeholder:"Custom URL"}),l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:"Map Object"}),e.jsx(X,{className:"h-9",options:i,value:((m=(v=s.preferences)==null?void 0:v.mapVisualOptions)==null?void 0:m.objectKey)||"",label:"Map Object",onValueChange:w=>{var R;o({...s.preferences,mapVisualOptions:{...(R=s.preferences)==null?void 0:R.mapVisualOptions,objectKey:w}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:"Projection"}),e.jsx(X,{className:"h-9",options:Wn,value:((p=(b=s.preferences)==null?void 0:b.mapVisualOptions)==null?void 0:p.projection)||"",label:"Projection",onValueChange:w=>{var R;o({...s.preferences,mapVisualOptions:{...(R=s.preferences)==null?void 0:R.mapVisualOptions,projection:w}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:"Colors"}),e.jsx(X,{className:"h-9",options:Yn,value:((g=(f=s.preferences)==null?void 0:f.mapVisualOptions)==null?void 0:g.colorScale)||"",label:"Select Color Scale",onValueChange:w=>{var R;o({...s.preferences,mapVisualOptions:{...(R=s.preferences)==null?void 0:R.mapVisualOptions,colorScale:w}})}})]})]})]})}),e.jsx(t.Separator,{className:"my-4"}),e.jsx(Me,{className:"",summary:"Scale Options",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(t.Input,{className:`h-9 w-full ${t.removeRing}`,type:"number",step:.1,value:((S=(N=s.preferences)==null?void 0:N.mapVisualOptions)==null?void 0:S.projectionScale)||1,onChange:w=>{var R;o({...s.preferences,mapVisualOptions:{...(R=s.preferences)==null?void 0:R.mapVisualOptions,projectionScale:Number(w.target.value)}})}}),e.jsx(t.Label,{children:"X"}),e.jsx(t.Input,{className:`h-9 w-full ${t.removeRing}`,type:"number",step:10,value:((T=(k=(A=s.preferences)==null?void 0:A.mapVisualOptions)==null?void 0:k.projectionOffset)==null?void 0:T[0])||0,onChange:w=>{var R,U,q,D;o({...s.preferences,mapVisualOptions:{...(R=s.preferences)==null?void 0:R.mapVisualOptions,projectionOffset:[Number(w.target.value),((D=(q=(U=s.preferences)==null?void 0:U.mapVisualOptions)==null?void 0:q.projectionOffset)==null?void 0:D[1])||0]}})}}),e.jsx(t.Label,{children:"Y"}),e.jsx(t.Input,{className:`h-9 w-full ${t.removeRing}`,type:"number",step:10,value:((G=(F=(L=s.preferences)==null?void 0:L.mapVisualOptions)==null?void 0:F.projectionOffset)==null?void 0:G[1])||0,onChange:w=>{var R,U,q,D;o({...s.preferences,mapVisualOptions:{...(R=s.preferences)==null?void 0:R.mapVisualOptions,projectionOffset:[((D=(q=(U=s.preferences)==null?void 0:U.mapVisualOptions)==null?void 0:q.projectionOffset)==null?void 0:D[0])||0,Number(w.target.value)]}})}})]})}),e.jsx(t.Separator,{className:"my-4"}),e.jsx(le,{})]})}function Xn(){var r;const s=t.useEditorStore(o=>o.card.preferences),{setCardPreferences:a}=t.useEditorStore(o=>o.actions);function n(o){a({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:o==="dynamic"}})}return e.jsxs(t.RadioGroup,{value:(r=s==null?void 0:s.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(t.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(t.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function ye({cardType:s,docContent:a,suffix:n="Chart"}){let r="pie-donut-polar";return s==="funnel"&&(r="funnel"),e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{children:`${t.titleCase(s)} ${n}`}),e.jsx(t.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:o=>o.stopPropagation(),className:"text-blue-700",href:`https://docs.semaphor.cloud/docs/charts/${r}`,children:"example"})," in the docs."]})]})})]}),e.jsxs(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[s!=="text"&&e.jsx(He,{}),s==="text"&&e.jsx(Xn,{})]})]}),!["range","text"].includes(s)&&e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(le,{}),e.jsx(me,{})]})]})]})})}function ea(){const s=t.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}=t.useEditorActions();function n(){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:"Sort"}),e.jsx(X,{className:"h-8",label:"Sort Chart",options:[{label:"None",value:"none"},{label:"ASC",value:"asc"},{label:"DESC",value:"desc"}],value:s||"none",onValueChange:r=>{a(r)}})]})}return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{children:"Stacked Chart"}),e.jsxs(t.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(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[n(),e.jsx(Vt,{})]})]}),e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(le,{}),e.jsx(me,{})]})]})]})})}function ta({cardType:s="table"}){console.log("cardType",s);const a=t.useEditorStore(o=>{var l;return(l=o.card)==null?void 0:l.preferences}),n=t.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(t.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(le,{}),e.jsx(me,{})]})]})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.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 sa=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:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/tornado",children:"example"})," in the docs."]})]}),na=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:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/range",children:"example"})," in the docs."]})]}),aa=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:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/text",children:"example"})," in the docs."]})]});function ra(){const s=t.useEditorStore(n=>n.card.type);function a(n){switch(n){case"stackedBar":case"stackedLine":return e.jsx(ea,{});case"tornado":case"pyramid":return e.jsx(ye,{docContent:sa,cardType:n});case"kpi":return e.jsx(Jn,{});case"line":case"bar":return e.jsx(qn,{cardType:n});case"range":return e.jsx(ye,{docContent:na,cardType:n});case"pie":case"doughnut":case"polarArea":case"radar":case"funnel":return e.jsx(ye,{cardType:n});case"bubble":case"scatter":return e.jsx(Pn,{cardType:n});case"table":return e.jsx(ta,{cardType:n});case"text":return e.jsx(ye,{docContent:aa,cardType:n,suffix:"Visual"});case"map":return e.jsx(Zn,{});case"custom":return e.jsx(Bn,{});default:return e.jsx(Un,{})}}return e.jsxs(t.ScrollArea,{className:"h-full w-full text-sm",children:[a(s),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})}function Ht({label:s,column:a,functions:n,onFunctionChange:r}){let o=n[0];"aggregate"in a?o=n.find(i=>i.value===a.aggregate)||n[0]:"granularity"in a&&(o=n.find(i=>i.value===a.granularity)||n[0]);function l(i){r(i)}return e.jsx(X,{className:"flex h-8 w-8 justify-center overflow-clip rounded-none border-none bg-muted px-0 [&>svg]:hidden",icon:o.logo,options:n,value:o.value,onValueChange:i=>l(i),label:s,showPlaceholderLabel:!1})}const oa=[{label:"Sum",value:"SUM",logo:e.jsx(ht,{className:"size-3.5"})},{label:"Count",value:"COUNT",logo:e.jsx(lt,{className:"size-3.5"})},{label:"Unique",value:"DISTINCT",logo:e.jsx(Ns,{className:"size-3.5"})},{label:"Average",value:"AVG",logo:e.jsx(ss,{className:"size-3.5"})},{label:"Min",value:"MIN",logo:e.jsx(Xe,{className:"size-3.5"})},{label:"Max",value:"MAX",logo:e.jsx(t.ArrowUp,{className:"size-3.5"})}];function ia({column:s}){const{updateMetricColumn:a}=t.useEditorActions();let n=oa;t.isTextDataType(s.type)&&(n=n.filter(o=>["COUNT","DISTINCT"].includes(o.value))),t.isNumberDataType(s.type)&&(n=n.filter(o=>!["DISTINCT"].includes(o.value)));function r(o){const l={...s,aggregate:o,label:xe(s.name,o)};a(s.id,l)}return e.jsx(Ht,{column:s,functions:n,onFunctionChange:o=>r(o),label:"Aggregation"})}const la=[{label:"Day (D)",value:"day",logo:e.jsx(t.Label,{className:"cursor-pointer text-xs",children:"D"})},{label:"Week (W)",value:"week",logo:e.jsx(t.Label,{className:"cursor-pointer text-xs",children:"W"})},{label:"Month (M)",value:"month",logo:e.jsx(t.Label,{className:"cursor-pointer text-xs",children:"M"})},{label:"Year (Y)",value:"year",logo:e.jsx(t.Label,{className:"cursor-pointer text-xs",children:"Y"})}];function ca({column:s}){const{updateGroupByColumn:a}=t.useEditorActions();function n(r){const o={...s,granularity:r,label:ue(s.name,r)};a(s.id,o)}return e.jsx(Ht,{column:s,functions:la,onFunctionChange:r=>n(r),label:"Granularity"})}function da({col:s,onChange:a,droppableId:n}){const{columns:r}=t.useDataColumns(),o=E.useMemo(()=>{let d=[];(n===ne||n===ae||n===re)&&(d=r);const c=d==null?void 0:d.filter(h=>h.column_name!==s.name);return c==null?void 0:c.map(h=>({id:h.column_name,value:h.column_name}))},[r,n,s.name]),l=[{id:s.name,value:s.name}];function i(d){const c=r==null?void 0:r.find(h=>{var u;return h.column_name===((u=d[0])==null?void 0:u.id)});c&&a(c)}return o!=null&&o.length?e.jsx(t.ComboBox2,{multiple:!1,options:o,selectedOptions:l,onChange:i,selectAllChecked:!1,onSelectAllCheckedChange:()=>{},inputClassName:"border-none bg-muted pl-0 pr-8"}):e.jsx("input",{disabled:!0,type:"text",className:"overflow-hidden truncate text-ellipsis whitespace-nowrap bg-muted text-sm",value:s.name})}function ua({column:s}){const{updateMetricColumn:a}=t.useEditorActions(),{transformedMetricKeys:n,dimensionKeys:r}=Bt();console.log(n,r);const o=t.useEditorStore(c=>{var h;return(h=c.card.queryConfig)==null?void 0:h.pivotColumns}),l=!!(o&&o.length>0),i=n.find(c=>c===s.label||c===s.name),d=i?n.indexOf(i):-1;return e.jsxs("div",{className:"space-y-3",children:[i&&e.jsx(qt,{idx:d,col:i,children:e.jsx(t.Editable,{enabled:!0,className:"w-[130px]",text:s.label||"",placeholder:"Enter label",onSave:c=>{a(s.id,{...s,label:c||s.name})},children:e.jsx(Ne,{className:"w-[130px]",children:s.label||s.name})})}),l&&e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(t.Label,{children:"Pivot Header"}),e.jsx(t.Editable,{enabled:!0,text:s.aliasTemplate||"",placeholder:"{label} ({pivot})",onSave:c=>{a(s.id,{...s,aliasTemplate:c||""})},children:e.jsx(Ne,{className:"font-mono text-xs text-muted-foreground",children:s.aliasTemplate||"{label} ({pivot})"})})]})]})}function ma({column:s,type:a,onRemoveColumn:n,droppableId:r}){const[o,l]=E.useState(!1),{updateGroupByColumn:i,updateMetricColumn:d,updatePivotByColumn:c}=t.useEditorActions(),{attributes:h,listeners:u,setNodeRef:x,transform:v,transition:m,isDragging:b}=t.useSortable({id:s.id,data:{type:a}}),p=v?{opacity:b?.5:void 0,transform:t.CSS.Translate.toString(v),transition:m}:void 0,f=t.isTextDataType(s.type);function g(T){const L=t.isNumberDataType(T.data_type),F=t.isTextDataType(T.data_type),G=t.isDateDataType(T.data_type),w=L?"number":F?"string":G?"date":"string";if(r===ne){if(F){const R={id:s.id,name:T.column_name,type:w,role:"groupby"};i(s.id,R)}if(G){const R={id:s.id,name:T.column_name,type:w,role:"groupby",label:ue(T.column_name,"month"),granularity:"month"};i(s.id,R)}}if(r===re){if(F){const R={id:s.id,name:T.column_name,type:w,role:"groupby"};c(s.id,R)}if(G){const R={id:s.id,name:T.column_name,type:w,label:ue(T.column_name,"month"),granularity:"month",role:"groupby"};c(s.id,R)}}if(r===ae){const R={id:s.id,name:T.column_name,type:w,role:"metric",label:xe(T.column_name,"SUM"),aggregate:L?"SUM":"COUNT"};d(s.id,R)}}function N(){if(r===ae)return e.jsx("div",{"data-setting-container":"",className:"mt-1.5 max-h-32 overflow-y-auto rounded-md border border-border p-3 text-sm",children:e.jsx(ua,{column:s})})}function S(){const T=t.isDateDataType(s.type);if(r===ae)return e.jsx(ia,{column:s});if((r===ne||r===re)&&T)return e.jsx(ca,{column:s})}function A(){return e.jsx("div",{className:t.cn("grow",{"pl-3":(r===ne||r===re)&&f}),children:e.jsx(da,{col:s,onChange:g,droppableId:r})})}function k(){return e.jsx("div",{"data-setting-actions":"",className:"flex h-full items-center gap-2",children:e.jsx("button",{className:"h-full pl-2",onClick:()=>l(!o),children:o?e.jsx(qs,{className:t.cn("size-3 cursor-pointer items-center justify-center rounded-r-sm text-muted-foreground")}):e.jsx(ot,{className:t.cn("size-3 cursor-pointer items-center justify-center rounded-r-sm text-muted-foreground")})})})}return e.jsx("div",{...u,...h,ref:x,style:p,children:e.jsxs("div",{className:"group flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"grow",children:[e.jsxs("div",{className:"flex h-8 grow items-center justify-between rounded-md bg-muted",children:[k(),S(),A()]}),o&&N()]}),e.jsx("div",{className:t.cn("opacity-0 transition-opacity duration-200 group-hover:opacity-100",{hidden:o}),children:e.jsx("button",{onClick:()=>n(s.id),children:e.jsx(t.X,{className:"size-3 cursor-pointer text-muted-foreground"})})})]})})}function Ae({id:s,label:a,columns:n,previewColumns:r,sortableType:o,onRemoveColumn:l}){var p,f;const{setNodeRef:i,isOver:d,over:c}=t.useDroppable({id:s}),h=t.useDndStore(g=>g.activeId),u=t.useEditorStore(g=>{var N;return(N=g.card)==null?void 0:N.type}),x=d||((f=(p=c==null?void 0:c.data)==null?void 0:p.current)==null?void 0:f.type)===o,v=h?r:n,m=o===be?"Rows":o===ve?"Pivot Columns":"Columns";function b(){if(!v||v.length===0)return e.jsx("div",{className:"mr-5 flex h-8 grow items-center space-x-2 rounded-md border border-dashed border-muted-foreground/80 bg-background px-2 py-1 text-sm text-muted-foreground",children:e.jsx("span",{className:"invisible text-muted-foreground/70 group-hover:visible",children:"Drag here"})})}return e.jsx(t.SortableContext,{items:n==null?void 0:n.map(g=>g.id),children:e.jsxs("div",{className:t.cn("group space-y-2 rounded-md p-4",x&&"border border-muted-foreground/20"),ref:i,children:[e.jsxs("div",{className:"flex items-center justify-between pr-5",children:[e.jsx(t.Label,{className:"text-sm",children:a}),u!=="table"&&e.jsx("span",{className:"text-xs text-muted-foreground/50",children:m})]}),b(),e.jsx("div",{className:"space-y-2",children:v==null?void 0:v.map(g=>g.id===yt.id?e.jsx(ha,{},g.id):e.jsx(ma,{droppableId:s,type:o,column:g,onRemoveColumn:l},g.id))})]})})}function ha(){return e.jsx("div",{className:"mr-5 flex h-8 grow items-center space-x-2 rounded-md border border-dashed border-muted-foreground bg-background px-2 py-1 text-sm",children:e.jsx("span",{className:"text-muted-foreground/70",children:"Drop here"})})}function Gt({children:s,id:a,type:n}){const{attributes:r,listeners:o,setNodeRef:l,transform:i,transition:d,isDragging:c}=t.useSortable({id:a,data:{type:n}}),h=i?{opacity:c?.5:void 0,transform:t.CSS.Translate.toString(i),transition:d}:void 0;return e.jsx("div",{...o,...r,ref:l,style:h,children:s})}function xa(){const s=t.useEditorStore(g=>{var N;return(N=g.card.queryConfig)==null?void 0:N.orderBy})||[],a=t.useEditorStore(g=>{var N;return(N=g.card.queryConfig)==null?void 0:N.groupByColumns})||[],n=t.useEditorStore(g=>{var N;return(N=g.card.queryConfig)==null?void 0:N.metricColumns})||[],{addOrderByColumn:r,removeOrderByColumn:o,updateOrderByColumn:l}=t.useEditorActions(),i=[...a,...n];if(i.length===0)return e.jsx(e.Fragment,{});const d=e.jsx(os,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),c=e.jsx(ts,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),h=e.jsx(rs,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),u=e.jsx(es,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),x=i==null?void 0:i.filter(g=>!s.some(N=>N.columnId===g.id)).map(g=>({id:g.id,value:g.label||g.name}));function v(g,N){const S=m(g);return S?S.role==="metric"?N==="asc"?h:u:N==="asc"?d:c:null}function m(g){return i.find(N=>N.id===g)}function b(g){const N=s.find(S=>S.columnId===g);if(N){const S={...N,direction:N.direction==="asc"?"desc":"asc"};l(S)}}const p=g=>{r({columnId:g.id,direction:"asc"})};function f(g){const N=s.find(S=>S.columnId===g);N&&o(N)}return e.jsx(t.SortableContext,{items:s.map(g=>he(g.columnId)),children:e.jsxs("div",{className:"space-y-2 rounded-md p-4 text-sm",children:[e.jsx(t.Label,{className:"text-sm",children:"Sort By"}),x.length>0&&e.jsx("div",{className:"mr-5",children:e.jsx(t.ComboBox2,{multiple:!1,options:x,selectedOptions:[],onChange:g=>p(g[0]),selectAllChecked:!1,onSelectAllCheckedChange:()=>{},inputClassName:"h-8 bg-muted border-none"})}),s.map(g=>{var N,S;return e.jsx(Gt,{id:he(g.columnId),type:Pe,children:e.jsx("div",{className:"group flex h-8 items-center gap-2 rounded-sm p-0",children:e.jsxs("div",{className:"flex h-full grow items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex h-full grow items-center justify-between gap-2 rounded-sm bg-muted px-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ot,{className:"size-3 cursor-move text-muted-foreground hover:text-foreground"}),e.jsx(Ne,{className:"w-[175px] text-sm",children:((N=m(g.columnId))==null?void 0:N.label)||((S=m(g.columnId))==null?void 0:S.name)})]}),e.jsx("button",{title:g.direction==="asc"?"Ascending":"Descending",onClick:()=>b(g.columnId),className:"rounded-sm p-0",children:v(g.columnId,g.direction)})]}),e.jsx("div",{children:e.jsx("button",{onClick:()=>f(g.columnId),className:"rounded-sm p-0",children:e.jsx(t.X,{className:"size-3 text-muted-foreground opacity-0 transition-opacity duration-200 hover:text-foreground group-hover:opacity-100"})})})]})},g.columnId)},he(g.columnId))})]})})}function pa(){const s=t.useEditorStore(f=>{var g;return((g=f.card.queryConfig)==null?void 0:g.groupByColumns)||[]}),a=t.useEditorStore(f=>f.card.type),n=t.useDndStore(f=>f.previewGroupByColumns),r=t.useEditorStore(f=>{var g;return((g=f.card.queryConfig)==null?void 0:g.metricColumns)||[]}),o=t.useDndStore(f=>f.previewMetricColumns),l=t.useEditorStore(f=>{var g;return((g=f.card.queryConfig)==null?void 0:g.pivotColumns)||[]}),i=t.useDndStore(f=>f.previewPivotColumns),{removeColumnFromGroupBy:d,removeColumnFromMetricColumns:c,removeColumnFromPivotBy:h}=t.useEditorActions();function u(f){d(f)}function x(f){c(f)}function v(f){h(f)}let m="Group By",b="Metrics",p="Stack By";return a==="table"&&(m="Rows",b="Metrics",p="Columns"),e.jsxs("div",{className:"flex h-full w-full flex-col gap-3 py-4",children:[e.jsx(Rt,{iconClassName:"size-[19px]"}),e.jsxs(t.CustomScrollArea,{className:"flex min-h-0 grow basis-0 flex-col gap-4 overflow-y-auto",children:[e.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[e.jsx(Ae,{onRemoveColumn:u,sortableType:be,id:ne,label:m,columns:s,previewColumns:n}),e.jsx(Ae,{onRemoveColumn:v,sortableType:ve,id:re,label:p,columns:l,previewColumns:i}),e.jsx(Ae,{onRemoveColumn:x,sortableType:Oe,id:ae,label:b,columns:r,previewColumns:o}),e.jsx(xa,{})]}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})]})}function Ge({children:s,column:a,id:n,sortableType:r,className:o}){const[l,i]=E.useState(!1),{removeEditorFilter:d,clearEditorFilter:c}=t.useEditorActions(),h=t.useEditorStore(x=>{var v,m;return(m=(v=x.card.queryConfig)==null?void 0:v.filters)==null?void 0:m.some(b=>b.filterColumnName===a.name)});function u(x){d(x)}return e.jsx(Gt,{id:n,type:r,children:e.jsxs("div",{className:t.cn("group space-y-1 rounded-md bg-muted px-3 py-2",{"border-border":l}),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Label,{className:"text-sm",children:a.name}),h&&e.jsx("button",{onClick:()=>c(a),children:e.jsx(t.FilterX,{className:"size-3 cursor-pointer items-center justify-center text-muted-foreground hover:text-foreground"})})]}),e.jsx("div",{"data-setting-actions":"",className:"invisible flex h-full items-center gap-2 group-hover:visible",children:e.jsx("button",{onClick:()=>u(a),children:e.jsx(t.X,{className:"size-3.5 cursor-pointer items-center justify-center rounded-r-sm text-muted-foreground"})})})]}),e.jsxs("div",{className:t.cn("group flex items-center rounded-t-md text-sm",!l&&"rounded-b-md",l&&"border border-border"),children:[e.jsx("div",{children:e.jsx(t.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:t.cn("grow cursor-pointer overflow-hidden truncate text-ellipsis whitespace-nowrap",o),children:s})]})]})})}function fa({column:s,sortableType:a}){const n=t.useDashboardStore(S=>S.themeStyle),r=t.useEditorStore(S=>{var A,k;return(k=(A=S.card)==null?void 0:A.queryConfig)==null?void 0:k.filters}),o=t.useEditorStore(S=>{var A,k;return(k=(A=S.card.queryConfig)==null?void 0:A.filterColumns)==null?void 0:k.find(T=>T.name===s.name)}),{selectedConnectionId:l,selectedDatabaseName:i,selectedTableName:d}=t.useEditorAside(),c=E.useMemo(()=>{var S;return(S=r==null?void 0:r.find(A=>A.filterColumnName===s.name))==null?void 0:S.filterValue},[r,s.name]),h=E.useMemo(()=>Array.isArray(c)?c.map(S=>({id:S,value:S})):[],[c]),{updateEditorFilterValue:u}=t.useEditorActions(),x={column:s.name,sql:s.sql,id:s.name,connectionId:l,dataType:s.type},{data:v,isLoading:m,isFetching:b,isError:p}=t.useFilterQuery(x),f=E.useMemo(()=>{var A;return x.column?(A=v==null?void 0:v.records)==null?void 0:A.map(k=>{let T=x.column.split(".").slice(-1)[0].replace(/"/g,"");return k[T]===void 0&&(T=T.toLowerCase()),{id:k[T],value:k[T]}}):[]},[v,x.column]);function g(S){const A=S.map(k=>k.id);u(s.name,A)}function N(){return m||b?e.jsx(t.Skeleton,{style:{borderRadius:n==null?void 0:n.controlInputRadius},className:"h-8 min-w-60 bg-foreground/10"}):p?e.jsx("div",{className:"flex h-8 min-w-60 items-center bg-muted px-2 text-sm",children:"Error"}):e.jsx(t.ComboBox2,{renderFilterModeButton:()=>e.jsx(ga,{columnName:s.name}),showNegativeIndicator:(o==null?void 0:o.mode)==="exclude",options:f,onChange:g,selectedOptions:h,selectAllChecked:!1,onSelectAllCheckedChange:()=>{}})}return e.jsx(Ge,{className:"w-60",id:s.id,sortableType:a,column:s,children:N()})}function ga({columnName:s}){const{setEditorFilterMode:a}=t.useEditorActions(),n=t.useEditorStore(o=>{var l,i;return(i=(l=o.card.queryConfig)==null?void 0:l.filterColumns)==null?void 0:i.find(d=>d.name===s)});function r(){(n==null?void 0:n.mode)==="exclude"?a(s,"include"):a(s,"exclude")}return e.jsx(t.Button,{onClick:r,variant:"secondary",size:"sm",className:t.cn("h-5 text-xs hover:underline",{}),children:t.titleCase((n==null?void 0:n.mode)==="exclude"?"exclude":"include")})}function ja({column:s,sortableType:a}){const[n,r]=E.useState(!1),{selectedConnectionId:o,selectedDatabaseName:l,selectedTableName:i}=t.useEditorAside(),d={column:s.name,sql:s.sql,id:s.name,connectionId:o,title:"",dataType:s.type},{isLoading:c,isFetching:h,isError:u,data:x}=t.useFilterQuery(d),v=x==null?void 0:x.records,{dateRange:m,setDateRange:b,initialDateRange:p}=t.useDateRangeFromRecords(v),{updateEditorFilterValue:f}=t.useEditorActions();function g(A){var T,L;const k={gte:(T=A==null?void 0:A.from)==null?void 0:T.toISOString(),lte:(L=A==null?void 0:A.to)==null?void 0:L.toISOString()};f(s.name,k)}function N(){f(s.name,null,!0),b(p)}function S(){return c||h?e.jsx("div",{children:e.jsx(t.Skeleton,{className:"h-8 w-72 bg-foreground/10"})}):u?e.jsx("div",{className:"h-8 w-72 bg-muted px-2",children:"Error"}):v?e.jsx(t.DateRangePopover,{title:d.title,open:n,inputClassName:"h-8",setOpen:r,dateRange:m,setDateRange:b,onApply:g,onClear:N}):e.jsx(t.Label,{className:"flex h-8 w-72 items-center bg-muted px-2",children:"No Data"})}return e.jsx(Ge,{className:"w-72",id:s.id,sortableType:a,column:s,children:S()})}function ya({id:s,label:a,columns:n,previewColumns:r,sortableType:o}){var b,p;const{setNodeRef:l,isOver:i,over:d}=t.useDroppable({id:s}),c=t.useDndStore(f=>f.activeId),h={},u=i||((p=(b=d==null?void 0:d.data)==null?void 0:b.current)==null?void 0:p.type)===o;function x(){if(!m||m.length===0)return e.jsx("div",{className:"flex h-8 grow items-center space-x-2 rounded-md border border-dashed border-muted-foreground/80 bg-background px-2 py-1 text-sm text-muted-foreground",children:e.jsx("span",{className:"invisible text-muted-foreground/70 group-hover:visible",children:"Drag here"})})}function v(f){const g=t.isDateDataType(f.type);return f.id===yt.id?e.jsx(Ge,{id:f.id,sortableType:o,column:f,children:e.jsx(ba,{})},f.id):g?e.jsx(ja,{droppableId:s,sortableType:o,column:f},f.id):e.jsx(fa,{droppableId:s,sortableType:o,column:f},f.id)}const m=c?r:n;return e.jsx(t.SortableContext,{items:n==null?void 0:n.map(f=>f.id),children:e.jsxs("div",{className:t.cn("group space-y-2 rounded-md border-muted-foreground/50 p-4",u&&"border border-muted-foreground/20"),ref:l,style:h,children:[e.jsx(t.Label,{className:"text-sm",children:a}),x(),e.jsx("div",{className:"flex flex-wrap items-center gap-4",children:m==null?void 0:m.map(f=>v(f))})]})})}function ba(){return e.jsx("div",{className:"flex h-8 w-60 items-center space-x-2 rounded-md border border-dashed border-muted-foreground bg-background px-2 py-1 text-sm text-muted-foreground",children:"Drop here"})}function va(){const s=t.useEditorStore(o=>{var l;return((l=o.card.queryConfig)==null?void 0:l.filterColumns)||[]}),a=t.useDndStore(o=>o.previewFilterColumns),{removeColumnFromFilterColumns:n}=t.useEditorActions();function r(o){n(o)}return e.jsx("section",{className:"size-full px-4 pb-4",children:e.jsx(ya,{onRemoveColumn:r,sortableType:Fe,id:ze,label:"Filters",columns:s,previewColumns:a})})}function Ca(){const s=t.useEditorStore(l=>l.card),a=t.useEditorStore(l=>l.showAIDialog),{setShowAIDialog:n}=t.useEditorActions(),{data:r,errorMessage:o}=t.useDashboardCardQuery(s);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(It,{}),!a&&e.jsxs(t.Button,{onClick:()=>n(!0),variant:"secondary",size:"sm",children:[e.jsx(Fs,{className:"mr-2 h-4 w-4"}),"Assistant"]}),e.jsx(vt,{sql:r==null?void 0:r.sql,error:o})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-green-300 px-3 py-1 text-xs font-medium text-black",children:"Preview"}),e.jsx(Dt,{}),e.jsx(kt,{variant:"default"})]})]})}function Sa(){const s=E.useRef(null),a=E.useRef(null),n=t.useEditorStore(d=>d.isShowingVisual),r=t.useEditorStore(d=>d.showAIDialog),o=t.useEditorStore(d=>d.isDevMode);E.useEffect(()=>{var d,c,h,u;r?((d=s.current)==null||d.resize(0),(c=a.current)==null||c.resize(0)):((h=s.current)==null||h.resize(25),(u=a.current)==null||u.resize(25))},[r]);function l(){return e.jsxs(e.Fragment,{children:[e.jsx(t.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsx(bn,{})}),e.jsx(t.ResizableHandle,{withHandle:!0}),e.jsx(t.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:n&&!r?e.jsxs(t.ResizablePanelGroup,{direction:"horizontal",children:[e.jsx(e.Fragment,{children:e.jsx(t.ResizablePanel,{ref:s,className:"flex",defaultSize:25,maxSize:30,children:e.jsx(ra,{})})}),!r&&e.jsx(t.ResizableHandle,{}),e.jsx(t.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsx(je,{})})]}):e.jsx(je,{})})]})}function i(){return e.jsx(e.Fragment,{children:e.jsx("div",{className:"grow","data-biz-mode-container":"",children:n?e.jsxs(t.ResizablePanelGroup,{direction:"horizontal",children:[e.jsx(e.Fragment,{children:e.jsx(t.ResizablePanel,{ref:a,defaultSize:25,maxSize:30,children:e.jsx(pa,{})})}),e.jsx(t.ResizableHandle,{}),e.jsx(t.ResizablePanel,{defaultSize:75,maxSize:100,children:e.jsxs(t.ResizablePanelGroup,{direction:"vertical",children:[e.jsxs(t.ResizablePanel,{className:"flex min-h-fit flex-col",minSize:10,defaultSize:20,children:[e.jsx(Ca,{}),e.jsx(va,{})]}),e.jsx(t.ResizableHandle,{}),e.jsx(t.ResizablePanel,{minSize:60,defaultSize:80,children:e.jsx(je,{})})]})})]}):e.jsx(je,{})})})}return e.jsx(t.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:o?l():i()})}const Na=[{title:"Help me write a query for",subtitle:"orders by month"},{title:"Create a bar chart for",subtitle:"sales by category"}];function wa(){const s=E.useRef(null),a=E.useRef(null),[n,r]=E.useState(!1),[o,l]=E.useState(t.isDevEnv),[i,d]=E.useState(!1),c=t.useEditorStore(C=>C.actions.setCardSql),h=t.useEditorStore(C=>C.actions.setRunSql),u=t.useEditorStore(C=>C.showAIDialog),x=t.useDashboardStore(C=>C.handleOpenAssistantProfile),{setShowAIDialog:v,setCardPython:m}=t.useEditorActions(),{assistantProfile:b}=t.useAssistantProfile(),{messages:p,setMessages:f,reload:g,append:N,input:S,setInput:A,isLoading:k,handleAddCurrentTableToScope:T,removeFromCurrentSelections:L,currentAssitantScope:F,handleInputChange:G,handleSubmit:w,stop:R,chatStatus:U,llmUsage:q,errorMessage:D}=wt();t.useAssistantScroll({scrollContainerRef:s,inputRef:a,messages:p}),E.useEffect(()=>{var C;u&&((C=a.current)==null||C.focus())},[u]);function j(C,I){I==="sql"?(c(C),h(!0)):I==="python"&&(m(C),h(!0))}function M(C){const I={role:"user",content:C.title+" "+C.subtitle};N(I)}function V(C){N({role:"user",content:C})}function _(){return e.jsxs(t.DropdownMenu,{children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",children:e.jsx(t.EllipsisVertical,{className:"size-3.5"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",children:[e.jsx(t.DropdownMenuLabel,{children:"Options"}),e.jsx(t.DropdownMenuSeparator,{}),e.jsx(t.DropdownMenuCheckboxItem,{checked:n,onCheckedChange:r,children:"Token Usage"}),e.jsx(t.DropdownMenuCheckboxItem,{checked:o,onCheckedChange:l,children:"Tool Invocations"}),e.jsx(t.DropdownMenuCheckboxItem,{checked:i,onCheckedChange:d,children:"System Message"})]})]})}function H(){return e.jsxs("div",{children:[F&&F.length>0&&e.jsx("div",{className:"mt-2 flex max-h-16 flex-wrap items-center gap-2 overflow-y-auto",children:F==null?void 0:F.map((C,I)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted px-2 py-1 text-xs",children:[t.getFormattedTableNameForQuery({schemaName:C.schemaName||"",tableName:C.tableName||"",modelName:C.datamodelName||"",connectionType:C.connectionType||"",databaseName:C.databaseName||""}),e.jsx("button",{onClick:()=>{L(C)},children:e.jsx(t.X,{className:"size-3 text-muted-foreground hover:text-foreground"})})]},I))}),(F==null?void 0:F.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(t.Button,{className:"h-6 text-xs",size:"sm",variant:"secondary",onClick:T,children:[e.jsx(t.Plus,{className:"mr-2 size-3"}),"Current Table"]})]})]})}function Q(){return e.jsx("div",{"data-role":"header",children:e.jsx("div",{className:"text-lg font-semibold",children:"Assistant"})})}const y=(S==null?void 0:S.length)===0&&(p==null?void 0:p.filter(C=>C.role==="user").length)===0;return e.jsxs("div",{"data-role":"editor-assistant",className:"flex h-full w-full flex-col justify-between px-6 py-4",children:[e.jsxs("div",{"data-role":"header-section",className:"flex items-start justify-between gap-2",children:[Q(),x&&e.jsx(t.Button,{variant:"outline",size:"sm",className:"h-7 p-2",onClick:x,children:(b==null?void 0:b.name)||"Default Profile"}),e.jsxs("div",{"data-role":"header-actions",className:"flex items-center",children:[_(),e.jsx(t.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",onClick:()=>{f([]),g()},children:e.jsx(t.Plus,{className:"size-4"})}),e.jsx(t.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",onClick:()=>{v(!1)},children:e.jsx(t.PanelRight,{className:"size-4"})})]})]}),H(),e.jsx(t.CustomScrollArea,{ref:s,className:"mt-2 flex w-full grow basis-0",children:e.jsxs("div",{className:"space-y-4 py-2 pr-3","data-role":"messages",children:[e.jsx(t.PrintMessages,{messages:p,showTools:o,handleRun:j,showSystemMessage:i}),e.jsx(t.ChatStatus,{messages:p,chatStatus:U,errorMessage:D})]})}),e.jsxs("div",{className:"mb-3",children:[y&&!b&&e.jsx(t.Placeholders,{onClick:M,placeholders:Na}),e.jsx("div",{children:y&&b&&e.jsx(t.SeedQuestions,{seedQuestions:b.seedQuestions||[],handleSeedQuestionClick:V})})]}),e.jsx(t.ChatInput,{onFocus:()=>{T()},stop:R,ref:a,setInput:A,input:S,handleInputChange:G,handleSubmit:w,isLoading:k}),q&&n&&e.jsx("div",{className:"flex h-8 items-center justify-between",children:e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Usage: ",q.promptTokens," prompt tokens,"," ",q.completionTokens," completion tokens,"," ",q.totalTokens," total tokens"]})})]})}function ka({authToken:s,onSave:a,onClose:n}){const r=E.useRef(null),o=t.useEditorStore(f=>f.showAIDialog),{setAuthToken:l}=t.useDashboardActions(),{setShowAIDialog:i,setOnSave:d,setOnClose:c}=t.useEditorActions(),{handleDragOver:h,handleDragEnd:u,handleDragStart:x,handleDragCancel:v,sensors:m}=an();E.useEffect(()=>{a&&d(a),n&&c(n)},[a,d,n,c]),E.useEffect(()=>{s&&s.accessToken&&l(s)},[s,l]),E.useEffect(()=>{var f,g;o?((f=r.current)==null||f.resize(40),i(!0)):(i(!1),(g=r.current)==null||g.resize(0))},[o,i]);function b(f){f<1?i(!1):o||i(!0)}function p(){return e.jsxs(t.ResizablePanelGroup,{"data-content":"editor-main",className:"grow",direction:"horizontal",children:[e.jsx(t.ResizablePanel,{className:"min-w-[510px] rounded-none",children:e.jsx(Sa,{})}),e.jsx(t.ResizableHandle,{}),e.jsx(t.ResizablePanel,{"data-role":"editor-assistant-panel",ref:r,onResize:b,defaultSize:0,children:e.jsx(wa,{})})]})}return e.jsx(t.ErrorBoundary,{FallbackComponent:t.Fallback,children:e.jsx(t.DndContext,{sensors:m,onDragStart:x,onDragEnd:u,onDragOver:h,onDragCancel:v,children:e.jsxs("section",{className:"isolate flex h-full grow","data-content":"editor-panel",children:[e.jsx(bt,{type:"main"}),p()]})})})}function Da(){t.useDashboardStore(i=>i.selectedCardId);const s=t.useDashboardStore(i=>i.selectedSheetId),{setIsVisualEditing:a}=t.useDashboardStore(i=>i.actions),n=t.useDashboardStore(i=>i.isVisualEditing),r=t.useDashboardStore(i=>i.actions.updateFrame);function o(i){s&&(r(s,i),a(!1))}function l(){a(!1)}return e.jsx("div",{role:"editor-container",className:t.cn("flex grow",{"max-h-0 overflow-hidden":!n}),children:e.jsx(ka,{onSave:o,onClose:l})})}function Ia(){const s=t.useEditorStore(l=>l.selectedDatabaseName),a=t.useEditorStore(l=>l.selectedTableName),n=t.useDashboardStore(l=>l.dashboard.filters)||[],{columns:r}=t.useEditorAside(),{assignFilter:o}=Pt();return e.jsx(t.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===t.fmt(l.column_name)&&d.table===a&&d.database===s);return e.jsx("div",{onClick:()=>o(l),className:t.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(qe,{column:l}),e.jsx("span",{children:l.column_name})]})},l.column_name)})})}function Ea(){t.useDashboardStore(a=>a.showFilters);const s=t.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(t.Label,{className:"px-2 text-lg",children:"Filters"}),e.jsx(t.Button,{onClick:()=>s(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsx(t.Cross2Icon,{})})]}),e.jsx("div",{className:"flex grow",children:e.jsx(bt,{type:"filter",ColumnsComponent:()=>e.jsx(Ia,{})})})]})}function Ta(){const s=t.useDashboardStore(r=>r.dashboard.filters),a=t.useDashboardStore(r=>r.theme),n=s==null?void 0:s.filter(r=>r.hide);return n!=null&&n.length?e.jsx("div",{className:t.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(t.FilterHeader,{filter:r}),e.jsx(t.FilterComponent,{filter:r})]},r.id))}):null}function Ma(){const s=t.useDashboardStore(r=>r.showFilters),a=t.useDashboardStore(r=>r.isVisualEditing),n=t.useDashboardStore(r=>r.isDashboardEditing);return e.jsxs("div",{role:"dashboard-plus-main",className:t.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(Ta,{}),e.jsx(t.DashboardTabs,{})]}),s&&e.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsx(Ea,{})})]})}function Aa(){const s=t.useDashboardStore(o=>o.dashboard),a=t.useDashboardStore(o=>o.actions.setDashboard),n=t.useDashboardStore(o=>o.showDashboardJSON),r=t.useDashboardStore(o=>o.actions.setShowDashboardJSON);return e.jsxs("div",{className:t.cn("relative p-2",{hidden:!n}),children:[e.jsxs(t.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>r(!1),children:[e.jsx(t.X,{className:"mr-2 h-4 w-4"}),"Close"]}),e.jsx(t.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(s,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}function La({showControls:s=!1,showFooter:a=!0,...n}){return e.jsx(t.ErrorBoundary,{FallbackComponent:t.Fallback,children:e.jsxs(t.SemaphorContextProvider,{dashboardProps:n,children:[e.jsx(t.$e,{}),e.jsxs(t.UXProvider,{children:[e.jsx(Aa,{}),e.jsxs(t.DashboardPanel,{...n,children:[s&&e.jsx(Xs,{}),e.jsx(Da,{}),e.jsx(Ma,{})]})]})]})})}exports.Dashboard=t.Dashboard;exports.DashboardWC=t.DashboardWC;exports.SemaphorDataProvider=t.SemaphorQueryClient;exports.SemaphorQueryClient=t.SemaphorQueryClient;exports.createSqlGenConfig=t.createSqlGenConfig;exports.fmt=t.fmt;exports.getColumnDataType=t.getColumnDataType;exports.getFilterValueType=t.getFilterValueType;exports.getFormattedTableNameForQuery=t.getFormattedTableNameForQuery;exports.getQualifiedTableName=t.getQualifiedTableName;exports.getSql=t.getSql;exports.invalidateToken=t.invalidateToken;exports.isBooleanDataType=t.isBooleanDataType;exports.isColumnInSqlGen=t.isColumnInSqlGen;exports.isDateDataType=t.isDateDataType;exports.isNumberDataType=t.isNumberDataType;exports.isTextDataType=t.isTextDataType;exports.resolveDataType=t.resolveDataType;exports.resolveDatamodelName=t.resolveDatamodelName;exports.useCard=t.useCard;exports.useDashboardActions=t.useDashboardActions;exports.useDashboardStore=t.useDashboardStore;exports.useDataColumns=t.useDataColumns;exports.useDateFilterHook=t.useDateFilterHook;exports.useEditorActions=t.useEditorActions;exports.useEditorAside=t.useEditorAside;exports.useEditorStore=t.useEditorStore;exports.useTextFilterHook=t.useTextFilterHook;exports.EMPTY_SELECTION=Wt.EMPTY_SELECTION;exports.ScheduleDashboard=jt;exports.SelectComponent=ce;exports.Surfboard=La;exports.cleanCard=pt;exports.downloadPdf=gt;exports.getDashbaordStateWithoutData=_e;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as F, p as Wt, u as L, a as at, b as Ue, d as Tn, e as zn, B as K, P as Xe, f as An, g as Fn, h as En, i as Ln, L as H, I as ue, j as Vn, k as _n, l as qn, m as W, n as Rn, o as jn, q as Bn, r as vs, s as yn, t as R, C as Kt, v as xs, S as Ne, w as we, x as Se, y as ke, z as Te, A as Me, E as ce, T as Pn, F as $e, G as Qe, H as Mt, J as Oe, K as Yt, M as Dt, N as Zt, O as It, Q as ze, R as Hn, U as ot, V as Cs, W as Gn, X as Un, Y as bn, Z as Ns, _ as p, $ as $n, a0 as et, a1 as gt, a2 as ws, a3 as Qn, a4 as Jn, a5 as Wn, a6 as Kn, a7 as Yn, a8 as Zn, a9 as Xn, aa as ve, ab as ea, ac as ta, ad as na, ae as aa, af as sa, ag as ra, ah as be, ai as Ss, aj as xe, ak as ks, al as Pe, am as Ce, an as Ms, ao as Ds, ap as Is, aq as Os, ar as yt, as as Ae, at as Ts, au as zs, av as J, aw as la, ax as As, ay as Fs, az as Es, aA as Pt, aB as ia, aC as Xt, aD as Ot, aE as tt, aF as oa, aG as bt, aH as Ht, aI as fe, aJ as Ls, aK as Vs, aL as ct, aM as _s, aN as qs, aO as Rs, aP as ca, aQ as js, aR as Tt, aS as Bs, aT as Ps, aU as Hs, aV as vn, aW as Gs, aX as Us, aY as $s, aZ as en, a_ as De, a$ as Qs, b0 as Gt, b1 as Ve, b2 as he, b3 as _e, b4 as Js, b5 as Ws, b6 as Ks, b7 as Ys, b8 as Zs, b9 as At, ba as Xs, bb as xn, bc as er, bd as Cn, be as tr, bf as nr, bg as ar, bh as sr, bi as da, bj as rr, bk as tn, bl as ua, bm as lr, bn as ir, bo as Ye, bp as or, bq as cr, br as ma, bs as dr, bt as ur, bu as mr, bv as hr, bw as pr, bx as zt, by as ha, bz as fr, bA as nn, bB as an, bC as Ze, bD as ft, bE as gr, bF as yr, bG as br, bH as sn, bI as pa, bJ as vr, bK as vt, bL as fa, bM as xt, bN as ga, bO as ya, bP as ba, bQ as xr, bR as Cr, bS as Nr, bT as wr, bU as Ee, bV as le, bW as ie, bX as oe, bY as rn, bZ as Sr, b_ as kr, b$ as Mr, c0 as Dr, c1 as Ir, c2 as Nn, c3 as va, c4 as Or, c5 as Tr, c6 as zr, c7 as Ar, c8 as ln, c9 as xa, ca as Ca, cb as on, cc as Fr, cd as Er, ce as Na, cf as Lr, cg as Vr, ch as _r, ci as qr, cj as Rr, ck as jr, cl as Br, cm as Pr, cn as Hr, co as Gr, cp as Ft, cq as wa, cr as Ur, cs as $r, ct as Qr, cu as Jr, cv as Wr, cw as Kr, cx as Yr } from "./chunks/index-
|
|
2
|
-
import { D as Uo, cC as $o, cA as Qo, cA as Jo, cF as Wo, cE as Ko, cD as Yo, cG as Zo, cH as Xo, cB as ec, cy as tc, cz as nc } from "./chunks/index-
|
|
1
|
+
import { c as F, p as Wt, u as L, a as at, b as Ue, d as Tn, e as zn, B as K, P as Xe, f as An, g as Fn, h as En, i as Ln, L as H, I as ue, j as Vn, k as _n, l as qn, m as W, n as Rn, o as jn, q as Bn, r as vs, s as yn, t as R, C as Kt, v as xs, S as Ne, w as we, x as Se, y as ke, z as Te, A as Me, E as ce, T as Pn, F as $e, G as Qe, H as Mt, J as Oe, K as Yt, M as Dt, N as Zt, O as It, Q as ze, R as Hn, U as ot, V as Cs, W as Gn, X as Un, Y as bn, Z as Ns, _ as p, $ as $n, a0 as et, a1 as gt, a2 as ws, a3 as Qn, a4 as Jn, a5 as Wn, a6 as Kn, a7 as Yn, a8 as Zn, a9 as Xn, aa as ve, ab as ea, ac as ta, ad as na, ae as aa, af as sa, ag as ra, ah as be, ai as Ss, aj as xe, ak as ks, al as Pe, am as Ce, an as Ms, ao as Ds, ap as Is, aq as Os, ar as yt, as as Ae, at as Ts, au as zs, av as J, aw as la, ax as As, ay as Fs, az as Es, aA as Pt, aB as ia, aC as Xt, aD as Ot, aE as tt, aF as oa, aG as bt, aH as Ht, aI as fe, aJ as Ls, aK as Vs, aL as ct, aM as _s, aN as qs, aO as Rs, aP as ca, aQ as js, aR as Tt, aS as Bs, aT as Ps, aU as Hs, aV as vn, aW as Gs, aX as Us, aY as $s, aZ as en, a_ as De, a$ as Qs, b0 as Gt, b1 as Ve, b2 as he, b3 as _e, b4 as Js, b5 as Ws, b6 as Ks, b7 as Ys, b8 as Zs, b9 as At, ba as Xs, bb as xn, bc as er, bd as Cn, be as tr, bf as nr, bg as ar, bh as sr, bi as da, bj as rr, bk as tn, bl as ua, bm as lr, bn as ir, bo as Ye, bp as or, bq as cr, br as ma, bs as dr, bt as ur, bu as mr, bv as hr, bw as pr, bx as zt, by as ha, bz as fr, bA as nn, bB as an, bC as Ze, bD as ft, bE as gr, bF as yr, bG as br, bH as sn, bI as pa, bJ as vr, bK as vt, bL as fa, bM as xt, bN as ga, bO as ya, bP as ba, bQ as xr, bR as Cr, bS as Nr, bT as wr, bU as Ee, bV as le, bW as ie, bX as oe, bY as rn, bZ as Sr, b_ as kr, b$ as Mr, c0 as Dr, c1 as Ir, c2 as Nn, c3 as va, c4 as Or, c5 as Tr, c6 as zr, c7 as Ar, c8 as ln, c9 as xa, ca as Ca, cb as on, cc as Fr, cd as Er, ce as Na, cf as Lr, cg as Vr, ch as _r, ci as qr, cj as Rr, ck as jr, cl as Br, cm as Pr, cn as Hr, co as Gr, cp as Ft, cq as wa, cr as Ur, cs as $r, ct as Qr, cu as Jr, cv as Wr, cw as Kr, cx as Yr } from "./chunks/index-1AZBqWCM.js";
|
|
2
|
+
import { D as Uo, cC as $o, cA as Qo, cA as Jo, cF as Wo, cE as Ko, cD as Yo, cG as Zo, cH as Xo, cB as ec, cy as tc, cz as nc } from "./chunks/index-1AZBqWCM.js";
|
|
3
3
|
import { EMPTY_SELECTION as sc } from "./types/index.js";
|
|
4
4
|
import { jsxs as r, jsx as e, Fragment as ae } from "react/jsx-runtime";
|
|
5
5
|
import * as Ke from "react";
|
|
@@ -8695,6 +8695,7 @@ export {
|
|
|
8695
8695
|
ec as useCard,
|
|
8696
8696
|
at as useDashboardActions,
|
|
8697
8697
|
L as useDashboardStore,
|
|
8698
|
+
la as useDataColumns,
|
|
8698
8699
|
tc as useDateFilterHook,
|
|
8699
8700
|
J as useEditorActions,
|
|
8700
8701
|
ve as useEditorAside,
|
package/dist/types/main.d.ts
CHANGED
|
@@ -1097,6 +1097,14 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
|
|
|
1097
1097
|
setState(nextStateOrUpdater: DashboardStore | Partial<DashboardStore> | ((state: WritableDraft<DashboardStore>) => void), shouldReplace?: boolean | undefined): void;
|
|
1098
1098
|
}>;
|
|
1099
1099
|
|
|
1100
|
+
export declare function useDataColumns(token?: AuthToken): {
|
|
1101
|
+
columns: TDataColumn[];
|
|
1102
|
+
isColumnsLoading: boolean;
|
|
1103
|
+
isColumnsFetching: boolean;
|
|
1104
|
+
isColumnsError: boolean;
|
|
1105
|
+
refetchColumns: (options?: RefetchOptions) => Promise<QueryObserverResult<any, Error>>;
|
|
1106
|
+
};
|
|
1107
|
+
|
|
1100
1108
|
export declare function useDateFilterHook(filterId: string): {
|
|
1101
1109
|
records: any;
|
|
1102
1110
|
isLoading: boolean;
|