semaphor 0.0.53 → 0.0.54

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.
@@ -1,4 +1,4 @@
1
- "use strict";const e=require("./index-cTryqFB1.js"),f=require("react");/**
1
+ "use strict";const e=require("./index-9r5iCf6G.js"),f=require("react");/**
2
2
  * @license lucide-react v0.379.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -207,4 +207,4 @@ SELECT label, measure FROM table
207
207
  Table Columns: ${g==null?void 0:g.map(R=>`${R.column_name} | ${R.data_type}`).join(", ")}
208
208
  User SQL: ${z}
209
209
  ${v&&`Base Queries: ${JSON.stringify(v)} `}`,E=` When the user asks for a specific chart please use the following query structure to generate the chart query. Do not make up the column names. Use only the table columns provided above for the query. Replace x-axis, y-axis, and lables with the appropriate column names.
210
- Visual Query Syntax: ${$s}`,{data:N,isLoading:A,isFetching:I,isError:O,refetch:F}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(l==null?void 0:l.accessToken)||"",{user_content:`userContent: ${k} ${h?E:""}`}),enabled:!1});function B(R){if(R.toLowerCase().includes("bar"))m("bar");else if(R.toLowerCase().includes("line"))m("line");else if(R.toLowerCase().includes("bubble"))m("bubble");else if(R.toLowerCase().includes("scatter"))m("scatter");else if(R.toLowerCase().includes("stacked"))m("stackedBar");else if(R.toLowerCase().includes("pie"))m("pie");else if(R.toLowerCase().includes("donut")||R.toLowerCase().includes("doughnut"))m("doughnut");else if(R.toLowerCase().includes("radar"))m("radar");else return m("bar"),!1;return!0}f.useEffect(()=>{N&&C(R=>[...R,{role:"ai",content:N.response}])},[N]),f.useEffect(()=>{const R=setTimeout(()=>{var b;o.current&&(o.current.scroll({top:o.current.scrollHeight,behavior:"smooth"}),(b=c.current)==null||b.focus())},100);return()=>clearTimeout(R)},[j]);function T(){t&&(C(R=>[...R,{role:"user",content:t}]),B(t)&&u(!0),r(""),F())}f.useEffect(()=>{i&&(T(),a(!1))},[i,a]);const G={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},V={fontFamily:"monospace",fontSize:14,lineHeight:1.6},P={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},H={p:({node:R,...b})=>e.jsxRuntimeExports.jsx("p",{style:G,...b}),code:({node:R,...b})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...b}),pre:({node:R,...b})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:V,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:b.children}),e.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:q,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:w=>{const D=q(w);D&&(n(!1),d(D),x(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:R,...b})=>e.jsxRuntimeExports.jsx("li",{style:P,...b})};function q(R){const b=R.currentTarget.closest("pre");if(!b)return;const w=b.textContent||b.innerText;return navigator.clipboard.writeText(w).then(()=>console.log("Text copied to clipboard")).catch(D=>console.error("Error in copying text: ",D)),w}function L(){return j==null?void 0:j.map((R,b)=>R.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(Is,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:R.content})]},b):R.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:H,children:N==null?void 0:N.response.replace(/DuckDB/gi,"Semaphor")},b):e.jsxRuntimeExports.jsx("div",{},b))}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",className:"w-full justify-start border font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",variant:"secondary",children:"Type your question here..."})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Assistant"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"What can I help you with?"})]}),e.jsxRuntimeExports.jsx("div",{ref:o,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:L()})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[e.jsxRuntimeExports.jsx(e.Textarea,{autoFocus:!0,ref:c,onKeyDown:R=>{R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),r(""),T())},placeholder:"Type your question here...",onFocus:R=>{const b=R.target,w=b.value.length;b.setSelectionRange(w,w)},className:e.cn("max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"),disabled:A||I,value:t,onChange:R=>r(R.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:T,children:!A&&!I?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var Pe={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Le=f.createContext&&f.createContext(Pe),Ks=["attr","size","title"];function Us(s,n){if(s==null)return{};var t=Qs(s,n),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(s);for(i=0;i<a.length;i++)r=a[i],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(s,r)&&(t[r]=s[r])}return t}function Qs(s,n){if(s==null)return{};var t={},r=Object.keys(s),i,a;for(a=0;a<r.length;a++)i=r[a],!(n.indexOf(i)>=0)&&(t[i]=s[i]);return t}function fe(){return fe=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(s[r]=t[r])}return s},fe.apply(this,arguments)}function Ie(s,n){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(s);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(s,i).enumerable})),t.push.apply(t,r)}return t}function ge(s){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?Ie(Object(t),!0).forEach(function(r){Js(s,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Ie(Object(t)).forEach(function(r){Object.defineProperty(s,r,Object.getOwnPropertyDescriptor(t,r))})}return s}function Js(s,n,t){return n=Ws(n),n in s?Object.defineProperty(s,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[n]=t,s}function Ws(s){var n=Ys(s,"string");return typeof n=="symbol"?n:String(n)}function Ys(s,n){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var r=t.call(s,n||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(s)}function $e(s){return s&&s.map((n,t)=>f.createElement(n.tag,ge({key:t},n.attr),$e(n.child)))}function Z(s){return n=>f.createElement(Xs,fe({attr:ge({},s.attr)},n),$e(s.child))}function Xs(s){var n=t=>{var{attr:r,size:i,title:a}=s,c=Us(s,Ks),o=i||t.size||"1em",l;return t.className&&(l=t.className),s.className&&(l=(l?l+" ":"")+s.className),f.createElement("svg",fe({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,r,c,{className:l,style:ge(ge({color:s.color||t.color},t.style),s.style),height:o,width:o,xmlns:"http://www.w3.org/2000/svg"}),a&&f.createElement("title",null,a),s.children)};return Le!==void 0?f.createElement(Le.Consumer,null,t=>n(t)):n(Pe)}function Zs(s){return Z({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(s)}function et(){const{theme:s}=e.useTheme(),n=f.useRef(),t=f.useRef(),[r,i]=f.useState(!1),[a,c]=f.useState(!1),[o,l]=f.useState(!1),[h,u]=f.useState(""),[d,v]=f.useState(!1),{authToken:x}=e.useSemaphorContext();e.useDashboardStore(p=>p.selectedSheetId);const m=e.useDashboardStore(p=>p.dashboard.baseQueries),j=e.useEditorStore(p=>p.card),C=e.useDashboardStore(p=>p.theme),g=e.useEditorStore(p=>p.isShowingVisual),z=e.useEditorStore(p=>p.selectedConnectionId),S=e.useEditorStore(p=>p.selectedDatabaseName),k=e.useEditorStore(p=>p.selectedSchemaName);e.useDashboardStore(p=>p.actions.updateFrameCard);const E=e.useEditorStore(p=>p.selectedTableName),N=e.useEditorStore(p=>p.card.sql),A=e.useEditorStore(p=>p.card.python),I=e.resolveBaseQuery(N,m),O=e.useEditorStore(p=>p.selectedConnectionId),F=e.useEditorStore(p=>p.frame),B=e.useEditorStore(p=>p.filterValues),T=e.useEditorStore(p=>p.applyFilters),{setCardCustomCfg:G,setQueryResultColumns:V,setFilterValues:P,setCardSql:H,setCardPython:q,setQueryError:L,setPythonStdOut:R,setCardPreferences:b}=e.useEditorStore(p=>p.actions),w=e.useEditorStore(p=>p.onSave),D=e.useEditorStore(p=>p.actions.setApplyFilters),ee=e.useEditorStore(p=>p.onClose),$=e.useEditorStore(p=>p.actions.setCardData),re=e.useEditorStore(p=>p.actions.setSqlGen),ne=e.useEditorStore(p=>p.runSql),oe=e.useEditorStore(p=>p.actions.setRunSql),se=e.useEditorStore(p=>p.actions.setIsSqlRunning),{data:M,isLoading:K,isFetching:U,isSuccess:ie,isError:Q,error:de,status:be,refetch:ae}=e.useQuery({queryKey:[I,A],queryFn:()=>e.postRequest("https://semaphor.cloud/api/v1/query",(x==null?void 0:x.accessToken)||"",{connection_id:O,sql:I,python:A===e.PYTHON_DEFAULT_CODE?"":A,active_filters:T?B:[]}),enabled:!1,retry:!1});f.useEffect(()=>{if(M&&($(M.records),M.rowLimitExceeded&&e.Jt.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),R((M==null?void 0:M.output)||""),M.records.length>0)){const{dimensionKeys:p}=e.getKeys(M.records);V(p)}},[M,$,V,R]),f.useEffect(()=>{ne&&(ae(),oe(!1))},[ne,ae,oe]),f.useEffect(()=>{(K||U)&&se(!0),(Q||ie)&&se(!1),Q?(L(de.message),$([]),V([]),R("")):L("")},[K,U,M,R,Q,ie,se,$,V,L,de]);function je(){H(""),$([]),re({}),G(""),b({})}const me=p=>{t.current=p};function y(){let p=N;N&&!N.includes("{{")&&(p=Vs(N),H(p));const J={...j,lastSelectedSchema:k,lastSelectedDatabase:S,lastSelectedTable:E,connectionId:z,type:g?j.type:"table",sql:p,customCfg:g?j.customCfg:null},pe=F.cards.map(le=>le.id===j.id?J:le);w==null||w({...F,cards:pe})}function ts(){ee==null||ee()}function rs(p){const J=getComputedStyle(document.documentElement).getPropertyValue(p);return ns(J)}function ns(p){const[J,pe,le]=p.split(" "),_=parseFloat(J),as=parseFloat(pe),ls=parseFloat(le),cs=as/100,Te=ls/100,te=(1-Math.abs(2*Te-1))*cs,ce=te*(1-Math.abs(_/60%2-1)),Se=Te-te/2;let W=0,Y=0,X=0;0<=_&&_<60?(W=te,Y=ce,X=0):60<=_&&_<120?(W=ce,Y=te,X=0):120<=_&&_<180?(W=0,Y=te,X=ce):180<=_&&_<240?(W=0,Y=ce,X=te):240<=_&&_<300?(W=ce,Y=0,X=te):300<=_&&_<360&&(W=te,Y=0,X=ce),W=Math.round((W+Se)*255),Y=Math.round((Y+Se)*255),X=Math.round((X+Se)*255);const ye=xs=>{const ve=xs.toString(16);return ve.length==1?"0"+ve:ve};return`#${ye(W)}${ye(Y)}${ye(X)}`}f.useEffect(()=>{const p=n.current,J=t.current;if(p){const pe=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",le=C==="system"?pe:C;p.editor.defineTheme("default",{base:le==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":le==="light"?"#ffffff":rs("--semaphor-background")}}),p.editor.setTheme("default")}return J&&p&&J.addCommand(p.KeyMod.Shift|p.KeyCode.Enter,function(){return console.log("Executing query..."),ae(),!1}),()=>{}},[s,C,n.current]);function ze(p){n.current=p}function os(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[a&&e.jsxRuntimeExports.jsx("div",{className:"xbg-yellow-100 relative flex w-1/3 min-w-0 grow overflow-hidden border-l p-1 text-xs",role:"editor-filter-container",children:e.jsxRuntimeExports.jsxs("div",{className:"w-[99%]",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[e.jsxRuntimeExports.jsx(Hs,{checked:T,onCheckedChange:()=>D(!T),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(Ps,{}),B&&a&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>c(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:p=>{if(p)try{JSON.parse(p),P(JSON.parse(p))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(B,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),B&&!a&&e.jsxRuntimeExports.jsx(Oe,{onClick:()=>c(!0),className:e.cn("absolute bottom-4 right-6 h-3 w-3 text-foreground/50 hover:cursor-pointer hover:text-foreground",{"font-bold text-red-800":T})})]})}function is(){return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"1",order:1,defaultSize:r?20:100,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"sql-container",className:"relative flex w-[99%]",children:e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",className:"pt-3",onChange:p=>{H(p)},value:N,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:ze,onMount:me})}),r&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),r&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"pt-3",theme:"default",onChange:p=>{q(p&&p.trim()||"")},value:A||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:ze,onMount:me})}),e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"python"})]})]})]})}return e.jsxRuntimeExports.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxRuntimeExports.jsxs("div",{role:"sql-editor",className:"relative flex grow justify-between overflow-y-scroll",children:[is(),os()]}),e.jsxRuntimeExports.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{title:"Shift + Enter",disabled:K||U,onClick:()=>{ae()},className:"shrink-0",size:"sm",variant:"outline",children:[K||U?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(Cs,{className:"mr-2 h-4 w-4"}),"Run"]}),Q&&e.jsxRuntimeExports.jsx(_s,{error:de.message,setShowAIDialog:l,setTriggerAIRun:v,setUserInputforAI:u}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:je,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(hs,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:r,onPressedChange:p=>i(p),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(Zs,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(Gs,{open:o,setOpen:l,userInput:h,triggerAIRun:d,setTriggerAIRun:v,setUserInput:p=>u(p)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:y,size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:ts,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function st({data:s}){var c;const[n,t]=f.useState([]),i=Object.keys(s[0]).map(o=>({accessorKey:o,header:({column:l})=>{const h=l.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>l.toggleSorting(l.getIsSorted()==="asc"),children:[o,h==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):h==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),a=e.useReactTable({data:s,columns:i,getCoreRowModel:e.getCoreRowModel(),getPaginationRowModel:e.getPaginationRowModel(),onSortingChange:t,getSortedRowModel:e.getSortedRowModel(),manualPagination:!0,state:{sorting:n}});return e.jsxRuntimeExports.jsxs(e.Table$1,{children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:a.getHeaderGroups().map(o=>e.jsxRuntimeExports.jsx(e.TableRow,{children:o.headers.map(l=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 bg-muted",children:l.isPlaceholder?null:e.flexRender(l.column.columnDef.header,l.getContext())},l.id))},o.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(c=a.getRowModel().rows)!=null&&c.length?a.getRowModel().rows.map(o=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":o.getIsSelected()&&"selected",children:o.getVisibleCells().map(l=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(l.column.columnDef.cell,l.getContext())},l.id))},o.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:i.length,className:"h-24 text-center",children:"No results."})})})]})}function Ge({className:s,...n}){var c;f.useState(0);const t=e.useDashboardStore(o=>o.themeStyle),r=e.useEditorStore(o=>o.card),i=e.useEditorStore(o=>o.actions.setCard);if(f.useEffect(()=>{},[r.data,r.type,r.cfg,r.customCfg,t,r.preferences]),!r.id)return null;let a;return r.data&&r.data.length>0&&(a=e.createChartConfig({data:r.data,cardType:r.type,cfg:r.cfg,customCfg:r.customCfg,preferences:r.preferences})),e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",s),...n,children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"py-4",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:r.title,onSave:o=>i({...r,title:o}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:r.title})})},r.title),e.jsxRuntimeExports.jsx(e.Editable,{text:r.description||"",onSave:o=>i({...r,description:o}),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",r.description]})},r.description)]}),e.jsxRuntimeExports.jsxs(e.CardContent,{className:"flex grow flex-col pb-3",children:[r.type!=="table"&&a&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:a},JSON.stringify(a)+JSON.stringify(r.preferences)+((c=r==null?void 0:r.preferences)==null?void 0:c.customVisualCode)),r.type==="table"&&r.data&&r.data.length>0&&e.jsxRuntimeExports.jsx(e.$57acba87d6e25586$export$ccf8d8d7bbf3c2cc,{className:"flex min-h-0 flex-1 grow basis-0",children:e.jsxRuntimeExports.jsx(e.TableVisual,{card:r,data:r==null?void 0:r.data})})]})]})}function tt(){const[s,n]=f.useState(!1),[t,r]=f.useState(""),[i,a]=f.useState(""),[c,o]=f.useState(""),[l,h]=f.useState(""),u=e.useEditorStore(S=>S.card),d=e.useEditorStore(S=>S.card.customCfg),{setCardCustomCfg:v,setCustomVisualCode:x}=e.useEditorActions();function m(S){var N,A;const k={...S,data:{...S==null?void 0:S.data,datasets:(A=(N=S==null?void 0:S.data)==null?void 0:N.datasets)==null?void 0:A.map(I=>({...I,data:[]}))}};return JSON.stringify(k,null,1)}function j(){var k,E;if(!u.data||u.data.length===0)return;const S=e.createChartConfig({data:u.data,cardType:u.type,cfg:u.cfg,preferences:u.preferences});S&&(r(JSON.stringify(S,null,1)),(k=u==null?void 0:u.preferences)!=null&&k.customVisualCode&&o((E=u==null?void 0:u.preferences)==null?void 0:E.customVisualCode),d&&a(JSON.stringify(d,null,1)))}function C(){if(c&&x(c),!!i)try{const S=JSON.parse(i);return S?(v(S),h(""),a(""),S):void 0}catch(S){console.log(S),h("Invalid JSON")}}function g(){a(""),v(null)}function z(){let S;if(d){const k=e._.cloneDeep(u.cfg),E=e._.merge(k,d);return S=m(E),S}return t?(S=m(JSON.parse(t)),S):""}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{onClick:j,className:` ${d&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.Settings,{className:"h-4 w-4"})})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"max-h-[70vh] min-h-[70vh] overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{className:"",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Customize Card"}),e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:e.jsxRuntimeExports.jsx(gs,{onClick:()=>{navigator.clipboard.writeText(u.id)},className:"size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:"Copy Card ID"})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogDescription,{children:["See the configuration options and documentation",e.jsxRuntimeExports.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[e.jsxRuntimeExports.jsx(Ge,{className:"w-1/2 rounded shadow-none"}),e.jsxRuntimeExports.jsxs(e.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[e.jsxRuntimeExports.jsxs(e.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsxRuntimeExports.jsxs(e.TabsTrigger,{value:"custom-config",children:[d&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),d?"Custom Config":"Default Config"]}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"output",children:"Output"}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"custom-code",children:"Custom Code"})]}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"bg-red-x mt-0 grow rounded-b border border-t-0 p-2",value:"output",children:e.jsxRuntimeExports.jsx(e.Textarea,{disabled:!0,value:t,className:"h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-config",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"json",value:z(),onChange:S=>a(S)})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-code",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"javascript",value:c,onChange:S=>o(S||"")})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:l}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!d,onClick:g,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:C,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>n(!1),variant:"outline",children:"Close"})]})]})]})}function Ke(s){return Z({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M926.8 397.1l-396-288a31.81 31.81 0 0 0-37.6 0l-396 288a31.99 31.99 0 0 0-11.6 35.8l151.3 466a32 32 0 0 0 30.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z"},child:[]}]})(s)}function Ue(s){return Z({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137.39,24.06A16,16,0,0,0,120,40V80.67a15.86,15.86,0,0,0,13.25,15.76A32,32,0,1,1,96,129.68c-.41-8.22,1.27-15,5-20.26h0a15.86,15.86,0,0,0-1.69-20.47L71.69,60.68a16,16,0,0,0-23.63,1.1A103.6,103.6,0,0,0,55,202.05,103.24,103.24,0,0,0,128,232h1.49A104.3,104.3,0,0,0,232,129.48C232.75,75.18,191.19,28.88,137.39,24.06ZM60.32,71.94l27.61,28.19,0,.06A43.29,43.29,0,0,0,80.44,120H40.36A87.13,87.13,0,0,1,60.32,71.94ZM40.37,136h40.3A48,48,0,0,0,120,175.34v40.3A88,88,0,0,1,40.37,136Zm149.77,54.14A87.45,87.45,0,0,1,136,215.61V175.34a47.55,47.55,0,0,0,24.73-12.23A48,48,0,0,0,136,80.66L136,40c45.52,4.08,80.67,43.28,80,89.25A87.45,87.45,0,0,1,190.14,190.14Z"},child:[]}]})(s)}function Qe(s){return Z({tag:"svg",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 Je(s){return Z({tag:"svg",attr:{viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},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 We(s){return Z({tag:"svg",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 Ye(s){return Z({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M4 9h4v11H4zM4 4h4v4H4zM10 7h4v4h-4zM16 10h4v4h-4zM16 15h4v5h-4zM10 12h4v8h-4z"},child:[]}]})(s)}function Xe(s){return Z({tag:"svg",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 Ze(s){return Z({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M217 25v14h78V25h-78zm0 32v46h14V71h50v32h14V57h-78zm32 32v14h14V89h-14zm-64 32v46h30v-46h-30zm48 0v14h46v-14h-46zm64 0v46h30v-46h-30zm-64 32v14h46v-14h-46zm-80 32v46h62v-46h-62zm80 0v14h46v-14h-46zm64 0v46h62v-46h-62zm-64 32v14h46v-14h-46zm-112 32v46h94v-46h-94zm112 0v14h46v-14h-46zm64 0v46h94v-46h-94zm-64 32v14h46v-14h-46zM89 313v46h126v-46H89zm144 0v14h46v-14h-46zm64 0v46h126v-46H297zm-64 32v14h46v-14h-46zM57 377v46h158v-46H57zm176 0v14h46v-14h-46zm64 0v46h158v-46H297zm-64 32v14h46v-14h-46zM25 441v46h190v-46H25zm208 0v14h46v-14h-46zm64 0v46h190v-46H297zm-64 32v14h46v-14h-46z"},child:[]}]})(s)}function rt(){const[s,n]=f.useState(!1),t=e.useEditorStore(l=>l.card.type),{setCardType:r,setCardPreferences:i,setChartOrientation:a}=e.useEditorStore(l=>l.actions),c=e.useEditorStore(l=>l.actions.setCardCustomCfg);function o(l){c(null),i({}),r(l),n(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(nt,{className:"h-4 w-4",chartType:t})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-50",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(Ce,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ne,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ye,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(We,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ve,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Je,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(qe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ue,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ke,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Qe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ze,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Me,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Xe,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ke,{className:"size-4"})})]})})]})}function nt({chartType:s,className:n}){switch(s){case"bar":return e.jsxRuntimeExports.jsx(Ce,{className:n});case"line":return e.jsxRuntimeExports.jsx(Ne,{className:n});case"pie":return e.jsxRuntimeExports.jsx(qe,{className:n});case"radar":return e.jsxRuntimeExports.jsx(Ke,{className:n});case"scatter":return e.jsxRuntimeExports.jsx(Ve,{className:n});case"bubble":return e.jsxRuntimeExports.jsx(Je,{className:n});case"doughnut":return e.jsxRuntimeExports.jsx(Ue,{className:n});case"stackedBar":return e.jsxRuntimeExports.jsx(Ye,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(We,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(Qe,{className:n});case"pyramid":return e.jsxRuntimeExports.jsx(Ze,{className:n});case"range":return e.jsxRuntimeExports.jsx(Me,{className:n});case"kpi":return e.jsxRuntimeExports.jsx(Xe,{className:n});case"text":return e.jsxRuntimeExports.jsx(ke,{className:n});default:return e.jsxRuntimeExports.jsx(e.Table,{className:n})}}function ot(){const s=e.useEditorStore(t=>t.card.refreshInterval),n=e.useEditorStore(t=>t.actions.setCardRefreshInterval);return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(us,{className:"w-4 h-4"})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-[200px]",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-4",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),e.jsxRuntimeExports.jsx(e.Input,{value:s||"",onChange:t=>n(t.target.value),id:"width",placeholder:"30s",className:"col-span-2 h-7 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0"})]})})})})]})}function De(){e.useEditorStore(o=>o.frame);const s=e.useEditorStore(o=>o.card),n=e.useEditorStore(o=>o.card.data),t=e.useEditorStore(o=>o.isShowingVisual),r=e.useEditorStore(o=>o.isSqlRunning),i=e.useEditorStore(o=>o.queryError),a=e.useEditorStore(o=>o.pythonStdOut);if(e.useEditorStore(o=>o.onSave),e.useEditorStore(o=>o.onClose),e.useEditorStore(o=>o.actions.setCardSql),e.useEditorStore(o=>o.actions.setCardType),e.useEditorStore(o=>o.actions.setSqlGen),!s)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function c(){return s.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:r,card:s})})}):s.type==="text"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.TextCard,{isLoading:r,card:s})})}):e.jsxRuntimeExports.jsx(Ge,{className:"grow border-none shadow-none"})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col pt-3",children:[r&&e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"absolute bottom-0 left-0 right-0 top-0 z-10 m-auto h-10 w-10 animate-spin text-foreground/10"}),e.jsxRuntimeExports.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[t&&e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsx(rt,{}),s.type!=="table"&&e.jsxRuntimeExports.jsx(tt,{}),e.jsxRuntimeExports.jsx(ot,{})]}),e.jsxRuntimeExports.jsx(at,{})]}),t?c():e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[a&&e.jsxRuntimeExports.jsx(it,{}),s.data&&s.data.length>0&&e.jsxRuntimeExports.jsx(st,{data:n||[]}),i&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:i})]})]})}function it(){const s=e.useEditorStore(t=>t.pythonStdOut);if(!s)return null;const n=s.replace(/\n/g,"<br>");return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("p",{className:"font-mono text-sm",children:"Output:"}),e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:n},className:"bg-muted p-2 font-mono text-sm"}),e.jsxRuntimeExports.jsx(e.Separator,{className:"mb-2"})]})}function at(){const s=e.useEditorStore(t=>t.isShowingVisual),n=e.useEditorStore(t=>t.actions.setIsShowingVisual);return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"visualize",children:"Chart"}),e.jsxRuntimeExports.jsx(e.Switch,{checked:s,onCheckedChange:()=>n(!s),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function ue(){const[s,n]=f.useState([]);e.useEditorStore(u=>u.card.cfg);const t=e.useEditorStore(u=>u.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:i,setCardPreferences:a}=e.useEditorStore(u=>u.actions),c=e.useEditorStore(u=>u.queryResultColumns);e.useEditorStore(u=>{var d;return(d=u.card.preferences)==null?void 0:d.filterOnClickColumnIndex}),f.useEffect(()=>{c&&n(new Array(c.length).fill(!1))},[c]);function o(u,d){var v,x;d?t!=null&&t.onClickFilter&&((v=t==null?void 0:t.onClickFilter)==null?void 0:v.length)>0?a({...t,onClickFilter:[...t.onClickFilter,{columnIndex:u,expression:""}]}):a({...t,onClickFilter:[{columnIndex:u,expression:""}]}):(a({...t,onClickFilter:(x=t==null?void 0:t.onClickFilter)==null?void 0:x.filter(m=>m.columnIndex!==u)}),n(m=>{const j=[...m];return j[u]=!1,j}))}function l(u,d){var x;const v=(x=t==null?void 0:t.onClickFilter)==null?void 0:x.map(m=>m.columnIndex===u?{...m,expression:d.target.value}:m);a({...t,onClickFilter:v})}function h(u){var d,v,x,m;if(s!=null&&s[u]||(v=(d=t==null?void 0:t.onClickFilter)==null?void 0:d.find(j=>j.columnIndex===u))!=null&&v.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(m=(x=t==null?void 0:t.onClickFilter)==null?void 0:x.find(j=>j.columnIndex===u))==null?void 0:m.expression,onChange:j=>l(u,j),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:c==null?void 0:c.map((u,d)=>{var v,x;return e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:e.jsxRuntimeExports.jsxs("div",{className:" grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((v=t==null?void 0:t.onClickFilter)!=null&&v.find(m=>m.columnIndex===d)),onCheckedChange:m=>o(d,m)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:u}),e.jsxRuntimeExports.jsx("div",{className:"flex gap-2 items-center ",children:((x=t==null?void 0:t.onClickFilter)==null?void 0:x.find(m=>m.columnIndex===d))&&e.jsxRuntimeExports.jsx(Be,{onClick:()=>{n(m=>{const j=[...m];return j[d]=!m[d],j})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),h(d)]})},u)})})}function Re(){var c,o,l;const s=e.useEditorStore(h=>h.card.preferences),n=e.useEditorStore(h=>h.card.cfg),{setCardCfg:t,setCardPreferences:r,setChartOrientation:i}=e.useEditorStore(h=>h.actions);(c=n==null?void 0:n.options)!=null&&c.indexAxis;function a(h){i(h)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((o=s==null?void 0:s.chartOptions)==null?void 0:o.indexAxis)||((l=n==null?void 0:n.options)==null?void 0:l.indexAxis)||"x",onValueChange:a,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"x",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"y",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const xe="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function Fe(s,n){var r,i,a;const t=e.getNumberAxis(s,n);return((a=(i=(r=s==null?void 0:s.chartOptions)==null?void 0:r.scales)==null?void 0:i[t])==null?void 0:a.type)||"linear"}function es(){var V,P,H,q,L,R;const[s,n]=f.useState(!1),t=e.useEditorStore(b=>{var w;return(w=b.card)==null?void 0:w.preferences}),r=e.useEditorStore(b=>{var w;return(w=b.card)==null?void 0:w.cfg}),i=e.getNumberAxis(t,r),[a,c]=f.useState(Fe(t)),[o,l]=f.useState(((H=(P=(V=t==null?void 0:t.chartOptions)==null?void 0:V.scales)==null?void 0:P[i])==null?void 0:H.min)||""),[h,u]=f.useState(((R=(L=(q=t==null?void 0:t.chartOptions)==null?void 0:q.scales)==null?void 0:L[i])==null?void 0:R.max)||""),[d,v]=f.useState(o||h?"custom":"auto"),[x,m]=f.useState(""),[j,C]=f.useState(0),[g,z]=f.useState(""),[S,k]=f.useState(""),[E,N]=f.useState(""),A=e.useEditorStore(b=>b.actions.setCardPreferences),I=e.useEditorStore(b=>{var w;return(w=b.card)==null?void 0:w.type}),O=["pie","doughnut","polarArea"].includes(I);f.useEffect(()=>{var b,w,D,ee,$,re,ne,oe,se,M,K,U,ie,Q;c(Fe(t)),l(((D=(w=(b=t==null?void 0:t.chartOptions)==null?void 0:b.scales)==null?void 0:w[i])==null?void 0:D.min)===0?0:""),u(((re=($=(ee=t==null?void 0:t.chartOptions)==null?void 0:ee.scales)==null?void 0:$[i])==null?void 0:re.max)||""),m(((M=(se=(oe=(ne=t==null?void 0:t.chartOptions)==null?void 0:ne.scales)==null?void 0:oe[i])==null?void 0:se.ticks)==null?void 0:M.stepSize)||""),C(((K=t==null?void 0:t.numberAxisFormat)==null?void 0:K.decimalPlaces)||0),z(((U=t==null?void 0:t.numberAxisFormat)==null?void 0:U.suffix)||""),k(((ie=t==null?void 0:t.numberAxisFormat)==null?void 0:ie.currency)||""),N(((Q=t==null?void 0:t.numberAxisFormat)==null?void 0:Q.locale)||"")},[s,t,i]);function F(b,w){return w===""||/^[0-9\b]+$/.test(w)?Number(w):Number(b)}function B(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsxRuntimeExports.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxRuntimeExports.jsx(e.Input,{value:S,placeholder:"USD",onChange:b=>k(b.target.value),id:"currency",className:`col-span-2 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:E,placeholder:"en-US",onChange:b=>N(b.target.value),id:"locale",className:`col-span-2 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsxRuntimeExports.jsx(e.Input,{value:j,onChange:b=>C(Number(b.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${xe}`})]})]})}function T(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"range",children:"Range"}),e.jsxRuntimeExports.jsx(e.Input,{id:"min",value:o,onChange:b=>l(w=>F(w,b.target.value)),className:`col-span-1 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:h,onChange:b=>u(w=>F(w,b.target.value)),id:"max",className:`col-span-1 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsxRuntimeExports.jsx(e.Input,{value:x,onChange:b=>m(w=>F(w,b.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${xe}`})]})]})}function G(){var D;let b={};d==="custom"&&(b={min:o,max:h,ticks:{stepSize:x}});const w={...t||{},chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(D=t==null?void 0:t.chartOptions)==null?void 0:D.scales,[i]:{type:a,...a==="linear"?b:{}}}},numberAxisFormat:{decimalPlaces:j,suffix:g,currency:S,locale:E}};console.log(w),A(w)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:b=>n(b),children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"max-w-65",children:e.jsxRuntimeExports.jsxs("div",{className:"grid gap-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale",children:"Type"}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:O,value:a,onValueChange:b=>c(b),children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{id:"type",children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Option"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"linear",children:"Linear"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),a=="linear"&&e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxRuntimeExports.jsxs(e.RadioGroup,{disabled:O,id:"scale-option",value:d,onValueChange:b=>v(b),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"auto",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"custom",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),d==="custom"&&a=="linear"&&T(),B(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:G,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function lt({idx:s}){var o;const n=e.useEditorStore(l=>{var h;return(h=l.card)==null?void 0:h.preferences}),t=e.useEditorStore(l=>{var h;return(h=l.card.preferences)==null?void 0:h.datasetOptions}),r=e.useEditorStore(l=>l.actions.setCardPreferences),i=(o=n==null?void 0:n.chartOptions)==null?void 0:o.indexAxis,a=t==null?void 0:t.find(l=>l.idx===s);function c(l,h){(l==="end"||l==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const u={display:l!=="none",align:l,anchor:l,clamp:!0};if(!a)r({...n,datasetOptions:[...t||[],{idx:h,datalabels:u}]});else{const d={...a};d.datalabels=u;const v=t==null?void 0:t.map(x=>x.idx===h?d:x);r({...n,datasetOptions:v})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(Ts,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-fit p-1",children:e.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("none",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(e.X,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(Rs,{className:e.cn("h-4 w-4",{"rotate-90":i==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(Ss,{className:e.cn("h-4 w-4",{"rotate-90":i==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(bs,{className:e.cn("h-4 w-4",{"rotate-90":i==="y"})})})]})})]})}function ss(){const s=e.useEditorStore(l=>l.card),n=e.useEditorStore(l=>{var h,u,d;return(d=(u=(h=l==null?void 0:l.card)==null?void 0:h.preferences)==null?void 0:u.chartOptions)==null?void 0:d.indexAxis}),t=n==="y"?"Y axis":"X axis",r=n==="y"?"X axis":"Y axis",{keys:i,metricKeys:a,dimensionKeys:c}=e.getKeys(s.data||[]);let o=a;if(["stackedBar","stackedLine"].includes(s.type)){const l=e.pivotData({dataArray:s.data||[],groupKey:c[0],pivotKey:c[1],valueKey:o[0]}),{metricKeys:h}=e.getKeys(l);o=h}return i.length===0?null:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:t}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:e.jsxRuntimeExports.jsx("p",{children:c[0]})})})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxRuntimeExports.jsx(e.Label,{children:r}),e.jsxRuntimeExports.jsx(es,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:o.map((l,h)=>e.jsxRuntimeExports.jsx(ct,{col:l,idx:h},l))})]})]})}function ct({col:s,idx:n}){const t=e.useEditorStore(o=>{var l;return(l=o.card)==null?void 0:l.preferences}),r=e.useEditorStore(o=>{var l;return(l=o.card.preferences)==null?void 0:l.datasetOptions}),i=r==null?void 0:r.find(o=>o.idx===n),{setCardPreferences:a}=e.useEditorStore(o=>o.actions);function c(o){if(!i)a({...t,datasetOptions:[...r||[],{idx:n,type:o==="area"?"line":o,fill:o==="area"?"origin":""}]});else{const l={...i};l.type=o==="area"?"line":o,l.fill=o==="area"?"origin":"";const h=r==null?void 0:r.map(u=>u.idx===n?l:u);a({...t,datasetOptions:h})}}return e.jsxRuntimeExports.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[e.jsxRuntimeExports.jsx("p",{children:s}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsx(Ce,{onClick:()=>c("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Ne,{onClick:()=>c("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ds,{onClick:()=>c("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(e.Separator,{orientation:"vertical",className:"invisible size-4 cursor-pointer py-2 text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(lt,{idx:n})]})]})}function xt({cardType:s}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.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.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis1 - number"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis2 - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Re,{}),e.jsxRuntimeExports.jsx(ss,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(ue,{})})]})]})})}function Ae(){var i,a,c;const s=e.useEditorStore(o=>o.card.cfg),n=e.useEditorStore(o=>o.actions.setCardCfg),t=e.useEditorStore(o=>o.card.type);function r(o){var u;const l={datalabels:{display:o!=="none",align:o,anchor:o,clamp:!0}},h={...s,options:{...s==null?void 0:s.options,plugins:{...(u=s==null?void 0:s.options)==null?void 0:u.plugins,...l}}};n(h),console.log(o)}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxRuntimeExports.jsx("label",{className:"font-medium",children:"Data Labels"}),!["pyramid"].includes(t)&&e.jsxRuntimeExports.jsx(es,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(c=(a=(i=s==null?void 0:s.options)==null?void 0:i.plugins)==null?void 0:a.datalabels)==null?void 0:c.anchor,onValueChange:r,defaultValue:"none",children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:"Select position"})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Data Labels"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"start",children:"Start"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"center",children:"Center"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"end",children:"End"})]})})]})]})}function ut({cardType:s}){function n(t){const r="SELECT label, [group], x-axis, y-axis, radius FROM table",i="SELECT label, [group], x-axis, y-axis FROM table";return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:t==="bubble"?r:i}),e.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"group - category"}),e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),t==="bubble"&&e.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:a=>a.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return e.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:n(s)})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(Ae,{})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(ue,{})})]})]})})}const dt={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},mt={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function pt(){const s=e.useEditorStore(n=>n.card.type);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxRuntimeExports.jsx(e.Accordion,{className:" ",type:"single",collapsible:!0,children:ht(s)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(s)&&e.jsxRuntimeExports.jsx(Re,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(s)&&e.jsxRuntimeExports.jsx(Ae,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(s)&&e.jsxRuntimeExports.jsx(ue,{})})]})}function ht(s){if(["line","bar"].includes(s))return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsx("p",{children:"Chart Query"})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.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.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(dt,null,2)})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.jsxRuntimeExports.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.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(mt,null,2)})]})]})]});if(s==="bubble")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.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.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsxRuntimeExports.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(s==="scatter")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.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.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(s))return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:[e.jsxRuntimeExports.jsx("span",{children:s==="polarArea"?"Polar":s.charAt(0).toUpperCase()+s.slice(1)})," ","chart query"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function jt(){var l,h,u,d,v;const s=e.useEditorStore(x=>x.card.preferences),n=e.useEditorStore(x=>x.actions.setCardPreferences),t=e.useEditorStore(x=>x.actions.setNumberFormat);e.useEditorStore(x=>{var m,j;return(j=(m=x.card.preferences)==null?void 0:m.formatNumber)==null?void 0:j.decimalPlaces});const r=e.useEditorStore(x=>{var m,j;return(j=(m=x.card.preferences)==null?void 0:m.formatNumber)==null?void 0:j.locale}),i=e.useEditorStore(x=>{var m,j;return(j=(m=x.card.preferences)==null?void 0:m.formatNumber)==null?void 0:j.currency});e.useEditorStore(x=>x.actions.setFilterOnClickField);const a=e.useEditorStore(x=>{var m,j;return(j=(m=x.card.preferences)==null?void 0:m.formatNumber)==null?void 0:j.colorRanges})||[],c=e.useEditorStore(x=>x.actions.setColorRanges),o=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(x=>x.currency))];return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((l=s==null?void 0:s.formatNumber)!=null&&l.enabled),onCheckedChange:x=>{n({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:x}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((h=s==null?void 0:s.formatNumber)==null?void 0:h.enabled)===!0&&e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Locale"}),e.jsxRuntimeExports.jsxs(e.Select,{value:r||"en-US",onValueChange:x=>{var m,j,C;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((j=s==null?void 0:s.formatNumber)==null?void 0:j.currency)||"",x||"en-US",((C=s==null?void 0:s.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Format"}),e.LOCALE_CURRENCY_PAIRS.map(x=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:x.locale,children:x.locale},x.locale))]})})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Currency"}),e.jsxRuntimeExports.jsxs(e.Select,{value:i||"none",onValueChange:x=>{var m,j,C;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,x==="none"?"":x,((j=s==null?void 0:s.formatNumber)==null?void 0:j.locale)||"",((C=s==null?void 0:s.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),o.map(x=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:x,children:x},x))]})})]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Decimals"}),e.jsxRuntimeExports.jsxs(e.Select,{value:((d=(u=s==null?void 0:s.formatNumber)==null?void 0:u.decimalPlaces)==null?void 0:d.toString())||"0",onValueChange:x=>{var m,j,C;return t(Number(x),((m=s==null?void 0:s.formatNumber)==null?void 0:m.currency)||"",((j=s==null?void 0:s.formatNumber)==null?void 0:j.locale)||"",((C=s==null?void 0:s.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:["0","1","2","3","4"].map(x=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:x,children:x},x))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.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:x=>{var m,j,C;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((j=s==null?void 0:s.formatNumber)==null?void 0:j.currency)||"",((C=s==null?void 0:s.formatNumber)==null?void 0:C.locale)||"",x.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:a,setColorRanges:c})]})]})}function Et(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{type:"single",collapsible:!0,children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"font-mono",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"current - number"}),e.jsxRuntimeExports.jsx("li",{children:"previous - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),e.jsxRuntimeExports.jsx("section",{className:"",children:e.jsxRuntimeExports.jsx(jt,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}function ft(){var r;const s=e.useEditorStore(i=>i.card.preferences),{setCardPreferences:n}=e.useEditorStore(i=>i.actions);function t(i){n({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:i==="dynamic"}})}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:(r=s==null?void 0:s.textVisualOptions)!=null&&r.isDynamicText?"dynamic":"static",onValueChange:t,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"static",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Static"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function Ee({cardType:s,docContent:n,suffix:t="Chart"}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} ${t}`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{children:n||e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"measure - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[s==="range"&&e.jsxRuntimeExports.jsx(Re,{}),s!=="text"&&e.jsxRuntimeExports.jsx(Ae,{}),s==="text"&&e.jsxRuntimeExports.jsx(ft,{})]})]}),!["range","text"].includes(s)&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(ue,{})})]})]})})}function gt(){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Stacked Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"stack by - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Re,{}),e.jsxRuntimeExports.jsx(ss,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(ue,{})})]})]})})}function Rt({}){const s=e.useEditorStore(r=>{var i;return(i=r.card)==null?void 0:i.preferences}),n=e.useEditorStore(r=>r.actions.setCardPreferences),t=r=>{n({...s,allowDownload:r})};return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(ue,{})})]})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{onCheckedChange:t,id:"allow-download"}),e.jsxRuntimeExports.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 bt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pyramid-chart",children:"example"})," in the docs."]})]}),St=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.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.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#range-charts",children:"example"})," in the docs."]})]}),yt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT text FROM table limit 1"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#text-visual",children:"example"})," in the docs."]})]});function vt(){const s=e.useEditorStore(t=>t.card.type);function n(t){switch(t){case"stackedBar":case"stackedLine":return e.jsxRuntimeExports.jsx(gt,{});case"pyramid":return e.jsxRuntimeExports.jsx(Ee,{docContent:bt,cardType:t});case"kpi":return e.jsxRuntimeExports.jsx(Et,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(xt,{cardType:t});case"range":return e.jsxRuntimeExports.jsx(Ee,{docContent:St,cardType:t});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(Ee,{cardType:t});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(ut,{cardType:t});case"table":return e.jsxRuntimeExports.jsx(Rt,{cardType:t});case"text":return e.jsxRuntimeExports.jsx(Ee,{docContent:yt,cardType:t,suffix:"Visual"});default:return e.jsxRuntimeExports.jsx(pt,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:n(s)})}function Ct(){const s=e.useEditorStore(n=>n.isShowingVisual);return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:[e.jsxRuntimeExports.jsx(e.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsxRuntimeExports.jsx(et,{})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:s?e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"horizontal",children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:e.jsxRuntimeExports.jsx(vt,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(De,{})})]}):e.jsxRuntimeExports.jsx(De,{})})]})}function Nt({authToken:s,onSave:n,onClose:t}){const r=e.useEditorStore(c=>c.actions.setOnSave),i=e.useEditorStore(c=>c.actions.setOnClose),a=e.useDashboardStore(c=>c.actions.setAuthToken);return f.useEffect(()=>{n&&r(n),t&&i(t)},[n,r,t,i]),f.useEffect(()=>{s&&s.accessToken&&a(s)},[s,a]),e.jsxRuntimeExports.jsxs(e.EditorPanel,{className:"rounded-none",role:"editor-panel",children:[e.jsxRuntimeExports.jsx(e.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsxRuntimeExports.jsx(He,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(Ct,{})})]})}function kt(){e.useDashboardStore(c=>c.selectedCardId);const s=e.useDashboardStore(c=>c.selectedSheetId),{setIsVisualEditing:n}=e.useDashboardStore(c=>c.actions),t=e.useDashboardStore(c=>c.isVisualEditing),r=e.useDashboardStore(c=>c.actions.updateFrame);function i(c){s&&(r(s,c),n(!1))}function a(){n(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{block:t,hidden:!t}),children:e.jsxRuntimeExports.jsx(Nt,{onSave:i,onClose:a})})}function wt({columns:s,tableName:n}){const t=e.useEditorStore(d=>d.selectedConnectionId),r=e.useEditorStore(d=>d.selectedDatabaseName),i=e.useEditorStore(d=>d.selectedSchemaName),a=e.useEditorStore(d=>d.selectedTableName),c=e.useDashboardStore(d=>d.dashboard.filters)||[],o=e.useDashboardStore(d=>d.actions.addFilter),l=e.useDashboardStore(d=>d.actions.removeFilter),h=e.useDashboardStore(d=>d.actions.removeFilterValue);function u(d){const v=e.fmt(d.column_name),x=e.fmt(r||""),m=e.fmt(i||""),j=e.fmt(n),C=e.getQualifiedTableName(m,j),g=`${C}.${v}`;console.log("find",g,j,x);const z=c==null?void 0:c.find(S=>S.column===g&&S.table===j&&(S.database===x||S.database===r));if(z)h(z.id),l(z.id);else{if(n==="api"&&t){o({id:e.v4(),column:g,title:d.column_name,dataType:d.data_type,table:"api",database:"",connectionId:t,operation:"in",sql:e.getDefaultFilterSql(d.data_type,C,v)});return}o({id:e.v4(),column:`${C}.${v}`,title:d.column_name,dataType:d.data_type,table:a||"",database:r||"",connectionId:t||"",operation:"in",sql:e.getDefaultFilterSql(d.data_type,C,v)})}}return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:s==null?void 0:s.map(d=>{const v=c==null?void 0:c.find(x=>x.column===e.fmt(d.column_name)&&x.table===a&&x.database===r);return e.jsxRuntimeExports.jsx("div",{onClick:()=>u(d),className:e.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":v}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(_e,{column:d}),e.jsxRuntimeExports.jsx("span",{children:d.column_name})]})},d.column_name)})})}function At(){e.useDashboardStore(n=>n.showFilters);const s=e.useDashboardStore(n=>n.actions.setShowFilters);return e.jsxRuntimeExports.jsxs("section",{className:"relative flex grow flex-col border-l px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-lg",children:"Filters"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>s(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{})})]}),e.jsxRuntimeExports.jsx("div",{className:"flex grow",children:e.jsxRuntimeExports.jsx(He,{ColumnsComponent:(n,t,r)=>e.jsxRuntimeExports.jsx(wt,{schemaName:n,tableName:t,columns:r})})})]})}function zt(){e.useDashboardStore(t=>t.dashboard);const s=e.useDashboardStore(t=>t.showFilters),n=e.useDashboardStore(t=>t.isVisualEditing);return e.useDashboardStore(t=>t.bookmarkKey),e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("grow",{hidden:n,flex:!n}),children:[e.jsxRuntimeExports.jsx(e.DashboardTabs,{}),s&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(At,{})})]})}function Tt(){const s=e.useDashboardStore(r=>r.dashboard),n=e.useDashboardStore(r=>r.actions.setDashboard),t=e.useDashboardStore(r=>r.showDashboardJSON);return e.useDashboardStore(r=>r.actions.setShowDashboardJSON),e.jsxRuntimeExports.jsx("div",{className:e.cn(" p-2",{hidden:!t}),children:e.jsxRuntimeExports.jsx(e.de,{onChange:r=>{if(r)try{JSON.parse(r),n(JSON.parse(r))}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 Lt({showControls:s=!1,showFooter:n=!0,showAssistant:t=!1,...r}){return e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:r,children:[e.jsxRuntimeExports.jsx(e.Te,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(Tt,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...r,children:[s&&e.jsxRuntimeExports.jsx(Ms,{}),e.jsxRuntimeExports.jsx(kt,{}),e.jsxRuntimeExports.jsx(zt,{})]})]})]})}exports.DashboardPlus=Lt;exports.SelectComponent=he;exports.useEditorAside=we;
210
+ Visual Query Syntax: ${$s}`,{data:N,isLoading:A,isFetching:I,isError:O,refetch:F}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(l==null?void 0:l.accessToken)||"",{user_content:`userContent: ${k} ${h?E:""}`}),enabled:!1});function B(R){if(R.toLowerCase().includes("bar"))m("bar");else if(R.toLowerCase().includes("line"))m("line");else if(R.toLowerCase().includes("bubble"))m("bubble");else if(R.toLowerCase().includes("scatter"))m("scatter");else if(R.toLowerCase().includes("stacked"))m("stackedBar");else if(R.toLowerCase().includes("pie"))m("pie");else if(R.toLowerCase().includes("donut")||R.toLowerCase().includes("doughnut"))m("doughnut");else if(R.toLowerCase().includes("radar"))m("radar");else return m("bar"),!1;return!0}f.useEffect(()=>{N&&C(R=>[...R,{role:"ai",content:N.response}])},[N]),f.useEffect(()=>{const R=setTimeout(()=>{var b;o.current&&(o.current.scroll({top:o.current.scrollHeight,behavior:"smooth"}),(b=c.current)==null||b.focus())},100);return()=>clearTimeout(R)},[j]);function T(){t&&(C(R=>[...R,{role:"user",content:t}]),B(t)&&u(!0),r(""),F())}f.useEffect(()=>{i&&(T(),a(!1))},[i,a]);const G={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},V={fontFamily:"monospace",fontSize:14,lineHeight:1.6},P={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},H={p:({node:R,...b})=>e.jsxRuntimeExports.jsx("p",{style:G,...b}),code:({node:R,...b})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...b}),pre:({node:R,...b})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:V,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:b.children}),e.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:q,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:w=>{const D=q(w);D&&(n(!1),d(D),x(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:R,...b})=>e.jsxRuntimeExports.jsx("li",{style:P,...b})};function q(R){const b=R.currentTarget.closest("pre");if(!b)return;const w=b.textContent||b.innerText;return navigator.clipboard.writeText(w).then(()=>console.log("Text copied to clipboard")).catch(D=>console.error("Error in copying text: ",D)),w}function L(){return j==null?void 0:j.map((R,b)=>R.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(Is,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:R.content})]},b):R.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:H,children:N==null?void 0:N.response.replace(/DuckDB/gi,"Semaphor")},b):e.jsxRuntimeExports.jsx("div",{},b))}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",className:"w-full justify-start border font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",variant:"secondary",children:"Type your question here..."})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Assistant"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"What can I help you with?"})]}),e.jsxRuntimeExports.jsx("div",{ref:o,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:L()})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[e.jsxRuntimeExports.jsx(e.Textarea,{autoFocus:!0,ref:c,onKeyDown:R=>{R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),r(""),T())},placeholder:"Type your question here...",onFocus:R=>{const b=R.target,w=b.value.length;b.setSelectionRange(w,w)},className:e.cn("max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"),disabled:A||I,value:t,onChange:R=>r(R.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:T,children:!A&&!I?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var Pe={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Le=f.createContext&&f.createContext(Pe),Ks=["attr","size","title"];function Us(s,n){if(s==null)return{};var t=Qs(s,n),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(s);for(i=0;i<a.length;i++)r=a[i],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(s,r)&&(t[r]=s[r])}return t}function Qs(s,n){if(s==null)return{};var t={},r=Object.keys(s),i,a;for(a=0;a<r.length;a++)i=r[a],!(n.indexOf(i)>=0)&&(t[i]=s[i]);return t}function fe(){return fe=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(s[r]=t[r])}return s},fe.apply(this,arguments)}function Ie(s,n){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(s);n&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(s,i).enumerable})),t.push.apply(t,r)}return t}function ge(s){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?Ie(Object(t),!0).forEach(function(r){Js(s,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Ie(Object(t)).forEach(function(r){Object.defineProperty(s,r,Object.getOwnPropertyDescriptor(t,r))})}return s}function Js(s,n,t){return n=Ws(n),n in s?Object.defineProperty(s,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[n]=t,s}function Ws(s){var n=Ys(s,"string");return typeof n=="symbol"?n:String(n)}function Ys(s,n){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var r=t.call(s,n||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(s)}function $e(s){return s&&s.map((n,t)=>f.createElement(n.tag,ge({key:t},n.attr),$e(n.child)))}function Z(s){return n=>f.createElement(Xs,fe({attr:ge({},s.attr)},n),$e(s.child))}function Xs(s){var n=t=>{var{attr:r,size:i,title:a}=s,c=Us(s,Ks),o=i||t.size||"1em",l;return t.className&&(l=t.className),s.className&&(l=(l?l+" ":"")+s.className),f.createElement("svg",fe({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,r,c,{className:l,style:ge(ge({color:s.color||t.color},t.style),s.style),height:o,width:o,xmlns:"http://www.w3.org/2000/svg"}),a&&f.createElement("title",null,a),s.children)};return Le!==void 0?f.createElement(Le.Consumer,null,t=>n(t)):n(Pe)}function Zs(s){return Z({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(s)}function et(){const{theme:s}=e.useTheme(),n=f.useRef(),t=f.useRef(),[r,i]=f.useState(!1),[a,c]=f.useState(!1),[o,l]=f.useState(!1),[h,u]=f.useState(""),[d,v]=f.useState(!1),{authToken:x}=e.useSemaphorContext();e.useDashboardStore(p=>p.selectedSheetId);const m=e.useDashboardStore(p=>p.dashboard.baseQueries),j=e.useEditorStore(p=>p.card),C=e.useDashboardStore(p=>p.theme),g=e.useEditorStore(p=>p.isShowingVisual),z=e.useEditorStore(p=>p.selectedConnectionId),S=e.useEditorStore(p=>p.selectedDatabaseName),k=e.useEditorStore(p=>p.selectedSchemaName);e.useDashboardStore(p=>p.actions.updateFrameCard);const E=e.useEditorStore(p=>p.selectedTableName),N=e.useEditorStore(p=>p.card.sql),A=e.useEditorStore(p=>p.card.python),I=e.resolveBaseQuery(N,m),O=e.useEditorStore(p=>p.selectedConnectionId),F=e.useEditorStore(p=>p.frame),B=e.useEditorStore(p=>p.filterValues),T=e.useEditorStore(p=>p.applyFilters),{setCardCustomCfg:G,setQueryResultColumns:V,setFilterValues:P,setCardSql:H,setCardPython:q,setQueryError:L,setPythonStdOut:R,setCardPreferences:b}=e.useEditorStore(p=>p.actions),w=e.useEditorStore(p=>p.onSave),D=e.useEditorStore(p=>p.actions.setApplyFilters),ee=e.useEditorStore(p=>p.onClose),$=e.useEditorStore(p=>p.actions.setCardData),re=e.useEditorStore(p=>p.actions.setSqlGen),ne=e.useEditorStore(p=>p.runSql),oe=e.useEditorStore(p=>p.actions.setRunSql),se=e.useEditorStore(p=>p.actions.setIsSqlRunning),{data:M,isLoading:K,isFetching:U,isSuccess:ie,isError:Q,error:de,status:be,refetch:ae}=e.useQuery({queryKey:[I,A],queryFn:()=>e.postRequest("https://semaphor.cloud/api/v1/query",(x==null?void 0:x.accessToken)||"",{connection_id:O,sql:I,python:A===e.PYTHON_DEFAULT_CODE?"":A,active_filters:T?B:[]}),enabled:!1,retry:!1});f.useEffect(()=>{if(M&&($(M.records),M.rowLimitExceeded&&e.Jt.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),R((M==null?void 0:M.output)||""),M.records.length>0)){const{dimensionKeys:p}=e.getKeys(M.records);V(p)}},[M,$,V,R]),f.useEffect(()=>{ne&&(ae(),oe(!1))},[ne,ae,oe]),f.useEffect(()=>{(K||U)&&se(!0),(Q||ie)&&se(!1),Q?(L(de.message),$([]),V([]),R("")):L("")},[K,U,M,R,Q,ie,se,$,V,L,de]);function je(){H(""),$([]),re({}),G(""),b({})}const me=p=>{t.current=p};function y(){let p=N;N&&!N.includes("{{")&&(p=Vs(N),H(p));const J={...j,lastSelectedSchema:k,lastSelectedDatabase:S,lastSelectedTable:E,connectionId:z,type:g?j.type:"table",sql:p,customCfg:g?j.customCfg:null},pe=F.cards.map(le=>le.id===j.id?J:le);w==null||w({...F,cards:pe})}function ts(){ee==null||ee()}function rs(p){const J=getComputedStyle(document.documentElement).getPropertyValue(p);return ns(J)}function ns(p){const[J,pe,le]=p.split(" "),_=parseFloat(J),as=parseFloat(pe),ls=parseFloat(le),cs=as/100,Te=ls/100,te=(1-Math.abs(2*Te-1))*cs,ce=te*(1-Math.abs(_/60%2-1)),Se=Te-te/2;let W=0,Y=0,X=0;0<=_&&_<60?(W=te,Y=ce,X=0):60<=_&&_<120?(W=ce,Y=te,X=0):120<=_&&_<180?(W=0,Y=te,X=ce):180<=_&&_<240?(W=0,Y=ce,X=te):240<=_&&_<300?(W=ce,Y=0,X=te):300<=_&&_<360&&(W=te,Y=0,X=ce),W=Math.round((W+Se)*255),Y=Math.round((Y+Se)*255),X=Math.round((X+Se)*255);const ye=xs=>{const ve=xs.toString(16);return ve.length==1?"0"+ve:ve};return`#${ye(W)}${ye(Y)}${ye(X)}`}f.useEffect(()=>{const p=n.current,J=t.current;if(p){const pe=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",le=C==="system"?pe:C;p.editor.defineTheme("default",{base:le==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":le==="light"?"#ffffff":rs("--semaphor-background")}}),p.editor.setTheme("default")}return J&&p&&J.addCommand(p.KeyMod.Shift|p.KeyCode.Enter,function(){return console.log("Executing query..."),ae(),!1}),()=>{}},[s,C,n.current]);function ze(p){n.current=p}function os(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[a&&e.jsxRuntimeExports.jsx("div",{className:"xbg-yellow-100 relative flex w-1/3 min-w-0 grow overflow-hidden border-l p-1 text-xs",role:"editor-filter-container",children:e.jsxRuntimeExports.jsxs("div",{className:"w-[99%]",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[e.jsxRuntimeExports.jsx(Hs,{checked:T,onCheckedChange:()=>D(!T),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(Ps,{}),B&&a&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>c(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:p=>{if(p)try{JSON.parse(p),P(JSON.parse(p))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(B,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),B&&!a&&e.jsxRuntimeExports.jsx(Oe,{onClick:()=>c(!0),className:e.cn("absolute bottom-4 right-6 h-3 w-3 text-foreground/50 hover:cursor-pointer hover:text-foreground",{"font-bold text-red-800":T})})]})}function is(){return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"1",order:1,defaultSize:r?20:100,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"sql-container",className:"relative flex w-[99%]",children:e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",className:"pt-3",onChange:p=>{H(p)},value:N,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:ze,onMount:me})}),r&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),r&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"pt-3",theme:"default",onChange:p=>{q(p&&p.trim()||"")},value:A||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:ze,onMount:me})}),e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"python"})]})]})]})}return e.jsxRuntimeExports.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxRuntimeExports.jsxs("div",{role:"sql-editor",className:"relative flex grow justify-between overflow-y-scroll",children:[is(),os()]}),e.jsxRuntimeExports.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{title:"Shift + Enter",disabled:K||U,onClick:()=>{ae()},className:"shrink-0",size:"sm",variant:"outline",children:[K||U?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(Cs,{className:"mr-2 h-4 w-4"}),"Run"]}),Q&&e.jsxRuntimeExports.jsx(_s,{error:de.message,setShowAIDialog:l,setTriggerAIRun:v,setUserInputforAI:u}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:je,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(hs,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:r,onPressedChange:p=>i(p),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(Zs,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(Gs,{open:o,setOpen:l,userInput:h,triggerAIRun:d,setTriggerAIRun:v,setUserInput:p=>u(p)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:y,size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:ts,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function st({data:s}){var c;const[n,t]=f.useState([]),i=Object.keys(s[0]).map(o=>({accessorKey:o,header:({column:l})=>{const h=l.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>l.toggleSorting(l.getIsSorted()==="asc"),children:[o,h==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):h==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),a=e.useReactTable({data:s,columns:i,getCoreRowModel:e.getCoreRowModel(),getPaginationRowModel:e.getPaginationRowModel(),onSortingChange:t,getSortedRowModel:e.getSortedRowModel(),manualPagination:!0,state:{sorting:n}});return e.jsxRuntimeExports.jsxs(e.Table$1,{children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:a.getHeaderGroups().map(o=>e.jsxRuntimeExports.jsx(e.TableRow,{children:o.headers.map(l=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 bg-muted",children:l.isPlaceholder?null:e.flexRender(l.column.columnDef.header,l.getContext())},l.id))},o.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(c=a.getRowModel().rows)!=null&&c.length?a.getRowModel().rows.map(o=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":o.getIsSelected()&&"selected",children:o.getVisibleCells().map(l=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(l.column.columnDef.cell,l.getContext())},l.id))},o.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:i.length,className:"h-24 text-center",children:"No results."})})})]})}function Ge({className:s,...n}){var c;f.useState(0);const t=e.useDashboardStore(o=>o.themeStyle),r=e.useEditorStore(o=>o.card),i=e.useEditorStore(o=>o.actions.setCard);if(f.useEffect(()=>{},[r.data,r.type,r.cfg,r.customCfg,t,r.preferences]),!r.id)return null;let a;return r.data&&r.data.length>0&&(a=e.createChartConfig({data:r.data,cardType:r.type,cfg:r.cfg,customCfg:r.customCfg,preferences:r.preferences})),e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",s),...n,children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"py-4",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:r.title,onSave:o=>i({...r,title:o}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:r.title})})},r.title),e.jsxRuntimeExports.jsx(e.Editable,{text:r.description||"",onSave:o=>i({...r,description:o}),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",r.description]})},r.description)]}),e.jsxRuntimeExports.jsxs(e.CardContent,{className:"flex grow flex-col pb-3",children:[r.type!=="table"&&a&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:a},JSON.stringify(a)+JSON.stringify(r.preferences)+((c=r==null?void 0:r.preferences)==null?void 0:c.customVisualCode)),r.type==="table"&&r.data&&r.data.length>0&&e.jsxRuntimeExports.jsx(e.$57acba87d6e25586$export$ccf8d8d7bbf3c2cc,{className:"flex min-h-0 flex-1 grow basis-0",children:e.jsxRuntimeExports.jsx(e.TableVisual,{card:r,data:r==null?void 0:r.data})})]})]})}function tt(){const[s,n]=f.useState(!1),[t,r]=f.useState(""),[i,a]=f.useState(""),[c,o]=f.useState(""),[l,h]=f.useState(""),u=e.useEditorStore(S=>S.card),d=e.useEditorStore(S=>S.card.customCfg),{setCardCustomCfg:v,setCustomVisualCode:x}=e.useEditorActions();function m(S){var N,A;const k={...S,data:{...S==null?void 0:S.data,datasets:(A=(N=S==null?void 0:S.data)==null?void 0:N.datasets)==null?void 0:A.map(I=>({...I,data:[]}))}};return JSON.stringify(k,null,1)}function j(){var k,E;if(!u.data||u.data.length===0)return;const S=e.createChartConfig({data:u.data,cardType:u.type,cfg:u.cfg,preferences:u.preferences});S&&(r(JSON.stringify(S,null,1)),(k=u==null?void 0:u.preferences)!=null&&k.customVisualCode&&o((E=u==null?void 0:u.preferences)==null?void 0:E.customVisualCode),d&&a(JSON.stringify(d,null,1)))}function C(){if(c&&x(c),!!i)try{const S=JSON.parse(i);return S?(v(S),h(""),a(""),S):void 0}catch(S){console.log(S),h("Invalid JSON")}}function g(){a(""),v(null)}function z(){let S;if(d){const k=e._.cloneDeep(u.cfg),E=e._.merge(k,d);return S=m(E),S}return t?(S=m(JSON.parse(t)),S):""}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{onClick:j,className:` ${d&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.Settings,{className:"h-4 w-4"})})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"max-h-[70vh] min-h-[70vh] overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{className:"",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Customize Card"}),e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:e.jsxRuntimeExports.jsx(gs,{onClick:()=>{navigator.clipboard.writeText(u.id)},className:"size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:"Copy Card ID"})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogDescription,{children:["See the configuration options and documentation",e.jsxRuntimeExports.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[e.jsxRuntimeExports.jsx(Ge,{className:"w-1/2 rounded shadow-none"}),e.jsxRuntimeExports.jsxs(e.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[e.jsxRuntimeExports.jsxs(e.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsxRuntimeExports.jsxs(e.TabsTrigger,{value:"custom-config",children:[d&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),d?"Custom Config":"Default Config"]}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"output",children:"Output"}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"custom-code",children:"Custom Code"})]}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"bg-red-x mt-0 grow rounded-b border border-t-0 p-2",value:"output",children:e.jsxRuntimeExports.jsx(e.Textarea,{disabled:!0,value:t,className:"h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-config",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"json",value:z(),onChange:S=>a(S)})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-code",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"javascript",value:c,onChange:S=>o(S||"")})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:l}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!d,onClick:g,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:C,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>n(!1),variant:"outline",children:"Close"})]})]})]})}function Ke(s){return Z({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M926.8 397.1l-396-288a31.81 31.81 0 0 0-37.6 0l-396 288a31.99 31.99 0 0 0-11.6 35.8l151.3 466a32 32 0 0 0 30.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z"},child:[]}]})(s)}function Ue(s){return Z({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137.39,24.06A16,16,0,0,0,120,40V80.67a15.86,15.86,0,0,0,13.25,15.76A32,32,0,1,1,96,129.68c-.41-8.22,1.27-15,5-20.26h0a15.86,15.86,0,0,0-1.69-20.47L71.69,60.68a16,16,0,0,0-23.63,1.1A103.6,103.6,0,0,0,55,202.05,103.24,103.24,0,0,0,128,232h1.49A104.3,104.3,0,0,0,232,129.48C232.75,75.18,191.19,28.88,137.39,24.06ZM60.32,71.94l27.61,28.19,0,.06A43.29,43.29,0,0,0,80.44,120H40.36A87.13,87.13,0,0,1,60.32,71.94ZM40.37,136h40.3A48,48,0,0,0,120,175.34v40.3A88,88,0,0,1,40.37,136Zm149.77,54.14A87.45,87.45,0,0,1,136,215.61V175.34a47.55,47.55,0,0,0,24.73-12.23A48,48,0,0,0,136,80.66L136,40c45.52,4.08,80.67,43.28,80,89.25A87.45,87.45,0,0,1,190.14,190.14Z"},child:[]}]})(s)}function Qe(s){return Z({tag:"svg",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 Je(s){return Z({tag:"svg",attr:{viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},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 We(s){return Z({tag:"svg",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 Ye(s){return Z({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M4 9h4v11H4zM4 4h4v4H4zM10 7h4v4h-4zM16 10h4v4h-4zM16 15h4v5h-4zM10 12h4v8h-4z"},child:[]}]})(s)}function Xe(s){return Z({tag:"svg",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 Ze(s){return Z({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M217 25v14h78V25h-78zm0 32v46h14V71h50v32h14V57h-78zm32 32v14h14V89h-14zm-64 32v46h30v-46h-30zm48 0v14h46v-14h-46zm64 0v46h30v-46h-30zm-64 32v14h46v-14h-46zm-80 32v46h62v-46h-62zm80 0v14h46v-14h-46zm64 0v46h62v-46h-62zm-64 32v14h46v-14h-46zm-112 32v46h94v-46h-94zm112 0v14h46v-14h-46zm64 0v46h94v-46h-94zm-64 32v14h46v-14h-46zM89 313v46h126v-46H89zm144 0v14h46v-14h-46zm64 0v46h126v-46H297zm-64 32v14h46v-14h-46zM57 377v46h158v-46H57zm176 0v14h46v-14h-46zm64 0v46h158v-46H297zm-64 32v14h46v-14h-46zM25 441v46h190v-46H25zm208 0v14h46v-14h-46zm64 0v46h190v-46H297zm-64 32v14h46v-14h-46z"},child:[]}]})(s)}function rt(){const[s,n]=f.useState(!1),t=e.useEditorStore(l=>l.card.type),{setCardType:r,setCardPreferences:i,setChartOrientation:a}=e.useEditorStore(l=>l.actions),c=e.useEditorStore(l=>l.actions.setCardCustomCfg);function o(l){c(null),i({}),r(l),n(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(nt,{className:"h-4 w-4",chartType:t})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-50",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(Ce,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ne,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ye,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(We,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ve,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Je,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(qe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ue,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ke,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Qe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ze,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Me,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Xe,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ke,{className:"size-4"})})]})})]})}function nt({chartType:s,className:n}){switch(s){case"bar":return e.jsxRuntimeExports.jsx(Ce,{className:n});case"line":return e.jsxRuntimeExports.jsx(Ne,{className:n});case"pie":return e.jsxRuntimeExports.jsx(qe,{className:n});case"radar":return e.jsxRuntimeExports.jsx(Ke,{className:n});case"scatter":return e.jsxRuntimeExports.jsx(Ve,{className:n});case"bubble":return e.jsxRuntimeExports.jsx(Je,{className:n});case"doughnut":return e.jsxRuntimeExports.jsx(Ue,{className:n});case"stackedBar":return e.jsxRuntimeExports.jsx(Ye,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(We,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(Qe,{className:n});case"pyramid":return e.jsxRuntimeExports.jsx(Ze,{className:n});case"range":return e.jsxRuntimeExports.jsx(Me,{className:n});case"kpi":return e.jsxRuntimeExports.jsx(Xe,{className:n});case"text":return e.jsxRuntimeExports.jsx(ke,{className:n});default:return e.jsxRuntimeExports.jsx(e.Table,{className:n})}}function ot(){const s=e.useEditorStore(t=>t.card.refreshInterval),n=e.useEditorStore(t=>t.actions.setCardRefreshInterval);return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(us,{className:"w-4 h-4"})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-[200px]",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-4",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),e.jsxRuntimeExports.jsx(e.Input,{value:s||"",onChange:t=>n(t.target.value),id:"width",placeholder:"30s",className:"col-span-2 h-7 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0"})]})})})})]})}function De(){e.useEditorStore(o=>o.frame);const s=e.useEditorStore(o=>o.card),n=e.useEditorStore(o=>o.card.data),t=e.useEditorStore(o=>o.isShowingVisual),r=e.useEditorStore(o=>o.isSqlRunning),i=e.useEditorStore(o=>o.queryError),a=e.useEditorStore(o=>o.pythonStdOut);if(e.useEditorStore(o=>o.onSave),e.useEditorStore(o=>o.onClose),e.useEditorStore(o=>o.actions.setCardSql),e.useEditorStore(o=>o.actions.setCardType),e.useEditorStore(o=>o.actions.setSqlGen),!s)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function c(){return s.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:r,card:s})})}):s.type==="text"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.TextCard,{isLoading:r,card:s})})}):e.jsxRuntimeExports.jsx(Ge,{className:"grow border-none shadow-none"})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col pt-3",children:[r&&e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"absolute bottom-0 left-0 right-0 top-0 z-10 m-auto h-10 w-10 animate-spin text-foreground/10"}),e.jsxRuntimeExports.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[t&&e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsx(rt,{}),s.type!=="table"&&e.jsxRuntimeExports.jsx(tt,{}),e.jsxRuntimeExports.jsx(ot,{})]}),e.jsxRuntimeExports.jsx(at,{})]}),t?c():e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[a&&e.jsxRuntimeExports.jsx(it,{}),s.data&&s.data.length>0&&e.jsxRuntimeExports.jsx(st,{data:n||[]}),i&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:i})]})]})}function it(){const s=e.useEditorStore(t=>t.pythonStdOut);if(!s)return null;const n=s.replace(/\n/g,"<br>");return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("p",{className:"font-mono text-sm",children:"Output:"}),e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:n},className:"bg-muted p-2 font-mono text-sm"}),e.jsxRuntimeExports.jsx(e.Separator,{className:"mb-2"})]})}function at(){const s=e.useEditorStore(t=>t.isShowingVisual),n=e.useEditorStore(t=>t.actions.setIsShowingVisual);return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"visualize",children:"Chart"}),e.jsxRuntimeExports.jsx(e.Switch,{checked:s,onCheckedChange:()=>n(!s),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function ue(){const[s,n]=f.useState([]);e.useEditorStore(u=>u.card.cfg);const t=e.useEditorStore(u=>u.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:i,setCardPreferences:a}=e.useEditorStore(u=>u.actions),c=e.useEditorStore(u=>u.queryResultColumns);e.useEditorStore(u=>{var d;return(d=u.card.preferences)==null?void 0:d.filterOnClickColumnIndex}),f.useEffect(()=>{c&&n(new Array(c.length).fill(!1))},[c]);function o(u,d){var v,x;d?t!=null&&t.onClickFilter&&((v=t==null?void 0:t.onClickFilter)==null?void 0:v.length)>0?a({...t,onClickFilter:[...t.onClickFilter,{columnIndex:u,expression:""}]}):a({...t,onClickFilter:[{columnIndex:u,expression:""}]}):(a({...t,onClickFilter:(x=t==null?void 0:t.onClickFilter)==null?void 0:x.filter(m=>m.columnIndex!==u)}),n(m=>{const j=[...m];return j[u]=!1,j}))}function l(u,d){var x;const v=(x=t==null?void 0:t.onClickFilter)==null?void 0:x.map(m=>m.columnIndex===u?{...m,expression:d.target.value}:m);a({...t,onClickFilter:v})}function h(u){var d,v,x,m;if(s!=null&&s[u]||(v=(d=t==null?void 0:t.onClickFilter)==null?void 0:d.find(j=>j.columnIndex===u))!=null&&v.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(m=(x=t==null?void 0:t.onClickFilter)==null?void 0:x.find(j=>j.columnIndex===u))==null?void 0:m.expression,onChange:j=>l(u,j),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:c==null?void 0:c.map((u,d)=>{var v,x;return e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:e.jsxRuntimeExports.jsxs("div",{className:" grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((v=t==null?void 0:t.onClickFilter)!=null&&v.find(m=>m.columnIndex===d)),onCheckedChange:m=>o(d,m)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:u}),e.jsxRuntimeExports.jsx("div",{className:"flex gap-2 items-center ",children:((x=t==null?void 0:t.onClickFilter)==null?void 0:x.find(m=>m.columnIndex===d))&&e.jsxRuntimeExports.jsx(Be,{onClick:()=>{n(m=>{const j=[...m];return j[d]=!m[d],j})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),h(d)]})},u)})})}function Re(){var c,o,l;const s=e.useEditorStore(h=>h.card.preferences),n=e.useEditorStore(h=>h.card.cfg),{setCardCfg:t,setCardPreferences:r,setChartOrientation:i}=e.useEditorStore(h=>h.actions);(c=n==null?void 0:n.options)!=null&&c.indexAxis;function a(h){i(h)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((o=s==null?void 0:s.chartOptions)==null?void 0:o.indexAxis)||((l=n==null?void 0:n.options)==null?void 0:l.indexAxis)||"x",onValueChange:a,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"x",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"y",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const xe="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function Fe(s,n){var r,i,a;const t=e.getNumberAxis(s,n);return((a=(i=(r=s==null?void 0:s.chartOptions)==null?void 0:r.scales)==null?void 0:i[t])==null?void 0:a.type)||"linear"}function es(){var V,P,H,q,L,R;const[s,n]=f.useState(!1),t=e.useEditorStore(b=>{var w;return(w=b.card)==null?void 0:w.preferences}),r=e.useEditorStore(b=>{var w;return(w=b.card)==null?void 0:w.cfg}),i=e.getNumberAxis(t,r),[a,c]=f.useState(Fe(t)),[o,l]=f.useState(((H=(P=(V=t==null?void 0:t.chartOptions)==null?void 0:V.scales)==null?void 0:P[i])==null?void 0:H.min)||""),[h,u]=f.useState(((R=(L=(q=t==null?void 0:t.chartOptions)==null?void 0:q.scales)==null?void 0:L[i])==null?void 0:R.max)||""),[d,v]=f.useState(o||h?"custom":"auto"),[x,m]=f.useState(""),[j,C]=f.useState(0),[g,z]=f.useState(""),[S,k]=f.useState(""),[E,N]=f.useState(""),A=e.useEditorStore(b=>b.actions.setCardPreferences),I=e.useEditorStore(b=>{var w;return(w=b.card)==null?void 0:w.type}),O=["pie","doughnut","polarArea"].includes(I);f.useEffect(()=>{var b,w,D,ee,$,re,ne,oe,se,M,K,U,ie,Q;c(Fe(t)),l(((D=(w=(b=t==null?void 0:t.chartOptions)==null?void 0:b.scales)==null?void 0:w[i])==null?void 0:D.min)===0?0:""),u(((re=($=(ee=t==null?void 0:t.chartOptions)==null?void 0:ee.scales)==null?void 0:$[i])==null?void 0:re.max)||""),m(((M=(se=(oe=(ne=t==null?void 0:t.chartOptions)==null?void 0:ne.scales)==null?void 0:oe[i])==null?void 0:se.ticks)==null?void 0:M.stepSize)||""),C(((K=t==null?void 0:t.numberAxisFormat)==null?void 0:K.decimalPlaces)||0),z(((U=t==null?void 0:t.numberAxisFormat)==null?void 0:U.suffix)||""),k(((ie=t==null?void 0:t.numberAxisFormat)==null?void 0:ie.currency)||""),N(((Q=t==null?void 0:t.numberAxisFormat)==null?void 0:Q.locale)||"")},[s,t,i]);function F(b,w){return w===""||/^[0-9\b]+$/.test(w)?Number(w):Number(b)}function B(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsxRuntimeExports.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxRuntimeExports.jsx(e.Input,{value:S,placeholder:"USD",onChange:b=>k(b.target.value),id:"currency",className:`col-span-2 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:E,placeholder:"en-US",onChange:b=>N(b.target.value),id:"locale",className:`col-span-2 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsxRuntimeExports.jsx(e.Input,{value:j,onChange:b=>C(Number(b.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${xe}`})]})]})}function T(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"range",children:"Range"}),e.jsxRuntimeExports.jsx(e.Input,{id:"min",value:o,onChange:b=>l(w=>F(w,b.target.value)),className:`col-span-1 h-8 w-full ${xe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:h,onChange:b=>u(w=>F(w,b.target.value)),id:"max",className:`col-span-1 h-8 w-full ${xe}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsxRuntimeExports.jsx(e.Input,{value:x,onChange:b=>m(w=>F(w,b.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${xe}`})]})]})}function G(){var D;let b={};d==="custom"&&(b={min:o,max:h,ticks:{stepSize:x}});const w={...t||{},chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(D=t==null?void 0:t.chartOptions)==null?void 0:D.scales,[i]:{type:a,...a==="linear"?b:{}}}},numberAxisFormat:{decimalPlaces:j,suffix:g,currency:S,locale:E}};console.log(w),A(w)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:b=>n(b),children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"max-w-65",children:e.jsxRuntimeExports.jsxs("div",{className:"grid gap-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale",children:"Type"}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:O,value:a,onValueChange:b=>c(b),children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{id:"type",children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Option"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"linear",children:"Linear"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),a=="linear"&&e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxRuntimeExports.jsxs(e.RadioGroup,{disabled:O,id:"scale-option",value:d,onValueChange:b=>v(b),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"auto",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"custom",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),d==="custom"&&a=="linear"&&T(),B(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:G,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function lt({idx:s}){var o;const n=e.useEditorStore(l=>{var h;return(h=l.card)==null?void 0:h.preferences}),t=e.useEditorStore(l=>{var h;return(h=l.card.preferences)==null?void 0:h.datasetOptions}),r=e.useEditorStore(l=>l.actions.setCardPreferences),i=(o=n==null?void 0:n.chartOptions)==null?void 0:o.indexAxis,a=t==null?void 0:t.find(l=>l.idx===s);function c(l,h){(l==="end"||l==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const u={display:l!=="none",align:l,anchor:l,clamp:!0};if(!a)r({...n,datasetOptions:[...t||[],{idx:h,datalabels:u}]});else{const d={...a};d.datalabels=u;const v=t==null?void 0:t.map(x=>x.idx===h?d:x);r({...n,datasetOptions:v})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(Ts,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-fit p-1",children:e.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("none",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(e.X,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(Rs,{className:e.cn("h-4 w-4",{"rotate-90":i==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(Ss,{className:e.cn("h-4 w-4",{"rotate-90":i==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>c("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(bs,{className:e.cn("h-4 w-4",{"rotate-90":i==="y"})})})]})})]})}function ss(){const s=e.useEditorStore(l=>l.card),n=e.useEditorStore(l=>{var h,u,d;return(d=(u=(h=l==null?void 0:l.card)==null?void 0:h.preferences)==null?void 0:u.chartOptions)==null?void 0:d.indexAxis}),t=n==="y"?"Y axis":"X axis",r=n==="y"?"X axis":"Y axis",{keys:i,metricKeys:a,dimensionKeys:c}=e.getKeys(s.data||[]);let o=a;if(["stackedBar","stackedLine"].includes(s.type)){const l=e.pivotData({dataArray:s.data||[],groupKey:c[0],pivotKey:c[1],valueKey:o[0]}),{metricKeys:h}=e.getKeys(l);o=h}return i.length===0?null:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:t}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:e.jsxRuntimeExports.jsx("p",{children:c[0]})})})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxRuntimeExports.jsx(e.Label,{children:r}),e.jsxRuntimeExports.jsx(es,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:o.map((l,h)=>e.jsxRuntimeExports.jsx(ct,{col:l,idx:h},l))})]})]})}function ct({col:s,idx:n}){const t=e.useEditorStore(o=>{var l;return(l=o.card)==null?void 0:l.preferences}),r=e.useEditorStore(o=>{var l;return(l=o.card.preferences)==null?void 0:l.datasetOptions}),i=r==null?void 0:r.find(o=>o.idx===n),{setCardPreferences:a}=e.useEditorStore(o=>o.actions);function c(o){if(!i)a({...t,datasetOptions:[...r||[],{idx:n,type:o==="area"?"line":o,fill:o==="area"?"origin":""}]});else{const l={...i};l.type=o==="area"?"line":o,l.fill=o==="area"?"origin":"";const h=r==null?void 0:r.map(u=>u.idx===n?l:u);a({...t,datasetOptions:h})}}return e.jsxRuntimeExports.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[e.jsxRuntimeExports.jsx("p",{children:s}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsx(Ce,{onClick:()=>c("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Ne,{onClick:()=>c("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ds,{onClick:()=>c("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(e.Separator,{orientation:"vertical",className:"invisible size-4 cursor-pointer py-2 text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(lt,{idx:n})]})]})}function xt({cardType:s}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.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.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis1 - number"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis2 - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Re,{}),e.jsxRuntimeExports.jsx(ss,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(ue,{})})]})]})})}function Ae(){var i,a,c;const s=e.useEditorStore(o=>o.card.cfg),n=e.useEditorStore(o=>o.actions.setCardCfg),t=e.useEditorStore(o=>o.card.type);function r(o){var u;const l={datalabels:{display:o!=="none",align:o,anchor:o,clamp:!0}},h={...s,options:{...s==null?void 0:s.options,plugins:{...(u=s==null?void 0:s.options)==null?void 0:u.plugins,...l}}};n(h),console.log(o)}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxRuntimeExports.jsx("label",{className:"font-medium",children:"Data Labels"}),!["pyramid"].includes(t)&&e.jsxRuntimeExports.jsx(es,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(c=(a=(i=s==null?void 0:s.options)==null?void 0:i.plugins)==null?void 0:a.datalabels)==null?void 0:c.anchor,onValueChange:r,defaultValue:"none",children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:"Select position"})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Data Labels"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"start",children:"Start"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"center",children:"Center"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"end",children:"End"})]})})]})]})}function ut({cardType:s}){function n(t){const r="SELECT label, [group], x-axis, y-axis, radius FROM table",i="SELECT label, [group], x-axis, y-axis FROM table";return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:t==="bubble"?r:i}),e.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"group - category"}),e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),t==="bubble"&&e.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:a=>a.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return e.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:n(s)})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(Ae,{})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(ue,{})})]})]})})}const dt={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},mt={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function pt(){const s=e.useEditorStore(n=>n.card.type);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxRuntimeExports.jsx(e.Accordion,{className:" ",type:"single",collapsible:!0,children:ht(s)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(s)&&e.jsxRuntimeExports.jsx(Re,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(s)&&e.jsxRuntimeExports.jsx(Ae,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(s)&&e.jsxRuntimeExports.jsx(ue,{})})]})}function ht(s){if(["line","bar"].includes(s))return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsx("p",{children:"Chart Query"})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.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.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(dt,null,2)})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.jsxRuntimeExports.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.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(mt,null,2)})]})]})]});if(s==="bubble")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.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.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsxRuntimeExports.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(s==="scatter")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.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.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(s))return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:[e.jsxRuntimeExports.jsx("span",{children:s==="polarArea"?"Polar":s.charAt(0).toUpperCase()+s.slice(1)})," ","chart query"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function jt(){var l,h,u,d,v;const s=e.useEditorStore(x=>x.card.preferences),n=e.useEditorStore(x=>x.actions.setCardPreferences),t=e.useEditorStore(x=>x.actions.setNumberFormat);e.useEditorStore(x=>{var m,j;return(j=(m=x.card.preferences)==null?void 0:m.formatNumber)==null?void 0:j.decimalPlaces});const r=e.useEditorStore(x=>{var m,j;return(j=(m=x.card.preferences)==null?void 0:m.formatNumber)==null?void 0:j.locale}),i=e.useEditorStore(x=>{var m,j;return(j=(m=x.card.preferences)==null?void 0:m.formatNumber)==null?void 0:j.currency});e.useEditorStore(x=>x.actions.setFilterOnClickField);const a=e.useEditorStore(x=>{var m,j;return(j=(m=x.card.preferences)==null?void 0:m.formatNumber)==null?void 0:j.colorRanges})||[],c=e.useEditorStore(x=>x.actions.setColorRanges),o=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(x=>x.currency))];return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((l=s==null?void 0:s.formatNumber)!=null&&l.enabled),onCheckedChange:x=>{n({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:x}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((h=s==null?void 0:s.formatNumber)==null?void 0:h.enabled)===!0&&e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Locale"}),e.jsxRuntimeExports.jsxs(e.Select,{value:r||"en-US",onValueChange:x=>{var m,j,C;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((j=s==null?void 0:s.formatNumber)==null?void 0:j.currency)||"",x||"en-US",((C=s==null?void 0:s.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Format"}),e.LOCALE_CURRENCY_PAIRS.map(x=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:x.locale,children:x.locale},x.locale))]})})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Currency"}),e.jsxRuntimeExports.jsxs(e.Select,{value:i||"none",onValueChange:x=>{var m,j,C;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,x==="none"?"":x,((j=s==null?void 0:s.formatNumber)==null?void 0:j.locale)||"",((C=s==null?void 0:s.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),o.map(x=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:x,children:x},x))]})})]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Decimals"}),e.jsxRuntimeExports.jsxs(e.Select,{value:((d=(u=s==null?void 0:s.formatNumber)==null?void 0:u.decimalPlaces)==null?void 0:d.toString())||"0",onValueChange:x=>{var m,j,C;return t(Number(x),((m=s==null?void 0:s.formatNumber)==null?void 0:m.currency)||"",((j=s==null?void 0:s.formatNumber)==null?void 0:j.locale)||"",((C=s==null?void 0:s.formatNumber)==null?void 0:C.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:["0","1","2","3","4"].map(x=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:x,children:x},x))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.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:x=>{var m,j,C;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((j=s==null?void 0:s.formatNumber)==null?void 0:j.currency)||"",((C=s==null?void 0:s.formatNumber)==null?void 0:C.locale)||"",x.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:a,setColorRanges:c})]})]})}function Et(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{type:"single",collapsible:!0,children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"font-mono",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"current - number"}),e.jsxRuntimeExports.jsx("li",{children:"previous - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),e.jsxRuntimeExports.jsx("section",{className:"",children:e.jsxRuntimeExports.jsx(jt,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}function ft(){var r;const s=e.useEditorStore(i=>i.card.preferences),{setCardPreferences:n}=e.useEditorStore(i=>i.actions);function t(i){n({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:i==="dynamic"}})}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:(r=s==null?void 0:s.textVisualOptions)!=null&&r.isDynamicText?"dynamic":"static",onValueChange:t,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"static",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Static"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function Ee({cardType:s,docContent:n,suffix:t="Chart"}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} ${t}`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{children:n||e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"measure - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[s==="range"&&e.jsxRuntimeExports.jsx(Re,{}),s!=="text"&&e.jsxRuntimeExports.jsx(Ae,{}),s==="text"&&e.jsxRuntimeExports.jsx(ft,{})]})]}),!["range","text"].includes(s)&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(ue,{})})]})]})})}function gt(){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Stacked Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"stack by - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(Re,{}),e.jsxRuntimeExports.jsx(ss,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(ue,{})})]})]})})}function Rt({}){const s=e.useEditorStore(r=>{var i;return(i=r.card)==null?void 0:i.preferences}),n=e.useEditorStore(r=>r.actions.setCardPreferences),t=r=>{n({...s,allowDownload:r})};return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(ue,{})})]})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{onCheckedChange:t,id:"allow-download"}),e.jsxRuntimeExports.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 bt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pyramid-chart",children:"example"})," in the docs."]})]}),St=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.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.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#range-charts",children:"example"})," in the docs."]})]}),yt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT text FROM table limit 1"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#text-visual",children:"example"})," in the docs."]})]});function vt(){const s=e.useEditorStore(t=>t.card.type);function n(t){switch(t){case"stackedBar":case"stackedLine":return e.jsxRuntimeExports.jsx(gt,{});case"pyramid":return e.jsxRuntimeExports.jsx(Ee,{docContent:bt,cardType:t});case"kpi":return e.jsxRuntimeExports.jsx(Et,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(xt,{cardType:t});case"range":return e.jsxRuntimeExports.jsx(Ee,{docContent:St,cardType:t});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(Ee,{cardType:t});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(ut,{cardType:t});case"table":return e.jsxRuntimeExports.jsx(Rt,{cardType:t});case"text":return e.jsxRuntimeExports.jsx(Ee,{docContent:yt,cardType:t,suffix:"Visual"});default:return e.jsxRuntimeExports.jsx(pt,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:n(s)})}function Ct(){const s=e.useEditorStore(n=>n.isShowingVisual);return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:[e.jsxRuntimeExports.jsx(e.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsxRuntimeExports.jsx(et,{})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:s?e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"horizontal",children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:e.jsxRuntimeExports.jsx(vt,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(De,{})})]}):e.jsxRuntimeExports.jsx(De,{})})]})}function Nt({authToken:s,onSave:n,onClose:t}){const r=e.useEditorStore(c=>c.actions.setOnSave),i=e.useEditorStore(c=>c.actions.setOnClose),a=e.useDashboardStore(c=>c.actions.setAuthToken);return f.useEffect(()=>{n&&r(n),t&&i(t)},[n,r,t,i]),f.useEffect(()=>{s&&s.accessToken&&a(s)},[s,a]),e.jsxRuntimeExports.jsxs(e.EditorPanel,{className:"rounded-none",role:"editor-panel",children:[e.jsxRuntimeExports.jsx(e.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsxRuntimeExports.jsx(He,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(Ct,{})})]})}function kt(){e.useDashboardStore(c=>c.selectedCardId);const s=e.useDashboardStore(c=>c.selectedSheetId),{setIsVisualEditing:n}=e.useDashboardStore(c=>c.actions),t=e.useDashboardStore(c=>c.isVisualEditing),r=e.useDashboardStore(c=>c.actions.updateFrame);function i(c){s&&(r(s,c),n(!1))}function a(){n(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{block:t,hidden:!t}),children:e.jsxRuntimeExports.jsx(Nt,{onSave:i,onClose:a})})}function wt({columns:s,tableName:n}){const t=e.useEditorStore(d=>d.selectedConnectionId),r=e.useEditorStore(d=>d.selectedDatabaseName),i=e.useEditorStore(d=>d.selectedSchemaName),a=e.useEditorStore(d=>d.selectedTableName),c=e.useDashboardStore(d=>d.dashboard.filters)||[],o=e.useDashboardStore(d=>d.actions.addFilter),l=e.useDashboardStore(d=>d.actions.removeFilter),h=e.useDashboardStore(d=>d.actions.removeFilterValue);function u(d){const v=e.fmt(d.column_name),x=e.fmt(r||""),m=e.fmt(i||""),j=e.fmt(n),C=e.getQualifiedTableName(m,j),g=`${C}.${v}`;console.log("find",g,j,x);const z=c==null?void 0:c.find(S=>S.column===g&&S.table===j&&(S.database===x||S.database===r));if(z)h(z.id),l(z.id);else{if(n==="api"&&t){o({id:e.v4(),column:g,title:d.column_name,dataType:d.data_type,table:"api",database:"",connectionId:t,operation:"in",sql:e.getDefaultFilterSql(d.data_type,C,v)});return}o({id:e.v4(),column:`${C}.${v}`,title:d.column_name,dataType:d.data_type,table:a||"",database:r||"",connectionId:t||"",operation:"in",sql:e.getDefaultFilterSql(d.data_type,C,v)})}}return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:s==null?void 0:s.map(d=>{const v=c==null?void 0:c.find(x=>x.column===e.fmt(d.column_name)&&x.table===a&&x.database===r);return e.jsxRuntimeExports.jsx("div",{onClick:()=>u(d),className:e.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":v}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(_e,{column:d}),e.jsxRuntimeExports.jsx("span",{children:d.column_name})]})},d.column_name)})})}function At(){e.useDashboardStore(n=>n.showFilters);const s=e.useDashboardStore(n=>n.actions.setShowFilters);return e.jsxRuntimeExports.jsxs("section",{className:"relative flex grow flex-col border-l px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-lg",children:"Filters"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>s(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{})})]}),e.jsxRuntimeExports.jsx("div",{className:"flex grow",children:e.jsxRuntimeExports.jsx(He,{ColumnsComponent:(n,t,r)=>e.jsxRuntimeExports.jsx(wt,{schemaName:n,tableName:t,columns:r})})})]})}function zt(){e.useDashboardStore(t=>t.dashboard);const s=e.useDashboardStore(t=>t.showFilters),n=e.useDashboardStore(t=>t.isVisualEditing);return e.useDashboardStore(t=>t.bookmarkKey),e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("grow",{hidden:n,flex:!n}),children:[e.jsxRuntimeExports.jsx(e.DashboardTabs,{}),s&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(At,{})})]})}function Tt(){const s=e.useDashboardStore(r=>r.dashboard),n=e.useDashboardStore(r=>r.actions.setDashboard),t=e.useDashboardStore(r=>r.showDashboardJSON);return e.useDashboardStore(r=>r.actions.setShowDashboardJSON),e.jsxRuntimeExports.jsx("div",{className:e.cn(" p-2",{hidden:!t}),children:e.jsxRuntimeExports.jsx(e.de,{onChange:r=>{if(r)try{JSON.parse(r),n(JSON.parse(r))}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 Lt({showControls:s=!1,showFooter:n=!0,...t}){return e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:t,children:[e.jsxRuntimeExports.jsx(e.Te,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(Tt,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...t,children:[s&&e.jsxRuntimeExports.jsx(Ms,{}),e.jsxRuntimeExports.jsx(kt,{}),e.jsxRuntimeExports.jsx(zt,{})]})]})]})}exports.DashboardPlus=Lt;exports.SelectComponent=he;exports.useEditorAside=we;
@@ -1,4 +1,4 @@
1
- import { P as A, b as w, j as e, Q as ps, R as fs, U as k, V as Gs, W as gs, X as js, Y as bs, Z as ys, _ as B, $ as ae, a0 as Js, J as Qs, O as Ae, a1 as Ra, a2 as _a, a3 as Ha, a4 as Ba, a5 as $a, a6 as Pa, a7 as Es, a8 as He, a9 as Ke, aa as Xe, T as vs, e as Ws, g as Ns, ab as Oe, ac as Me, f as Y, ad as Te, ae as Le, af as Be, ag as Ee, ah as X, ai as Cs, G as i, aj as Ue, ak as Ge, al as Ka, am as Je, w as Ys, v as Xs, t as he, an as Ua, r as Ga, N as Zs, s as Ja, ao as Qa, B as Wa, ap as ea, aq as Ya, L as $e, S as Ss, z as Xa, n as Ds, ar as ds, A as hs, u as ss, as as Ce, at as ze, au as sa, av as aa, aw as ta, ax as na, ay as ra, az as Za, aA as et, aB as la, aC as st, aD as at, aE as tt, aF as nt, aG as rt, aH as ms, aI as lt, aJ as _e, aK as us, aL as Fe, aM as xs, aN as Is, aO as it, aP as ot, aQ as ct, aR as dt, aS as ht, aT as is, aU as mt, aV as Vs, aW as ut, aX as qs, aY as xt, aZ as pt, a_ as ft, a$ as ia, l as gt, C as jt, E as Rs, d as bt, h as yt, i as vt, o as Nt, b0 as Ct, m as St, H as kt, b1 as wt, b2 as zt, b3 as Ft, b4 as os, b5 as Ot, b6 as cs, b7 as _s, K as Mt, b8 as Tt, b9 as ks, ba as Lt, bb as ws, bc as De, bd as oa, be as At, bf as Et, bg as Dt, bh as It, bi as Vt, bj as qt, bk as Se, bl as q, bm as R, bn as zs, bo as _, bp as Hs, bq as Rt, br as _t, bs as Ht, bt as Bt, bu as Bs, bv as $t, bw as Pt, bx as Kt, by as Ut, bz as Gt, bA as Jt } from "./index-9kntHAhm.js";
1
+ import { P as A, b as w, j as e, Q as ps, R as fs, U as k, V as Gs, W as gs, X as js, Y as bs, Z as ys, _ as B, $ as ae, a0 as Js, J as Qs, O as Ae, a1 as Ra, a2 as _a, a3 as Ha, a4 as Ba, a5 as $a, a6 as Pa, a7 as Es, a8 as He, a9 as Ke, aa as Xe, T as vs, e as Ws, g as Ns, ab as Oe, ac as Me, f as Y, ad as Te, ae as Le, af as Be, ag as Ee, ah as X, ai as Cs, G as i, aj as Ue, ak as Ge, al as Ka, am as Je, w as Ys, v as Xs, t as he, an as Ua, r as Ga, N as Zs, s as Ja, ao as Qa, B as Wa, ap as ea, aq as Ya, L as $e, S as Ss, z as Xa, n as Ds, ar as ds, A as hs, u as ss, as as Ce, at as ze, au as sa, av as aa, aw as ta, ax as na, ay as ra, az as Za, aA as et, aB as la, aC as st, aD as at, aE as tt, aF as nt, aG as rt, aH as ms, aI as lt, aJ as _e, aK as us, aL as Fe, aM as xs, aN as Is, aO as it, aP as ot, aQ as ct, aR as dt, aS as ht, aT as is, aU as mt, aV as Vs, aW as ut, aX as qs, aY as xt, aZ as pt, a_ as ft, a$ as ia, l as gt, C as jt, E as Rs, d as bt, h as yt, i as vt, o as Nt, b0 as Ct, m as St, H as kt, b1 as wt, b2 as zt, b3 as Ft, b4 as os, b5 as Ot, b6 as cs, b7 as _s, K as Mt, b8 as Tt, b9 as ks, ba as Lt, bb as ws, bc as De, bd as oa, be as At, bf as Et, bg as Dt, bh as It, bi as Vt, bj as qt, bk as Se, bl as q, bm as R, bn as zs, bo as _, bp as Hs, bq as Rt, br as _t, bs as Ht, bt as Bt, bu as Bs, bv as $t, bw as Pt, bx as Kt, by as Ut, bz as Gt, bA as Jt } from "./index-scpiGxfy.js";
2
2
  import me, { useState as T, useEffect as P, useMemo as Qt, useRef as Pe } from "react";
3
3
  /**
4
4
  * @license lucide-react v0.379.0 - ISC
@@ -4386,14 +4386,13 @@ function gr() {
4386
4386
  function yr({
4387
4387
  showControls: s = !1,
4388
4388
  showFooter: n = !0,
4389
- showAssistant: a = !1,
4390
- ...t
4389
+ ...a
4391
4390
  }) {
4392
- return /* @__PURE__ */ e.jsxs(Kt, { dashboardProps: t, children: [
4391
+ return /* @__PURE__ */ e.jsxs(Kt, { dashboardProps: a, children: [
4393
4392
  /* @__PURE__ */ e.jsx(Ut, {}),
4394
4393
  /* @__PURE__ */ e.jsxs(Gt, { children: [
4395
4394
  /* @__PURE__ */ e.jsx(gr, {}),
4396
- /* @__PURE__ */ e.jsxs(Jt, { ...t, children: [
4395
+ /* @__PURE__ */ e.jsxs(Jt, { ...a, children: [
4397
4396
  s && /* @__PURE__ */ e.jsx(Cn, {}),
4398
4397
  /* @__PURE__ */ e.jsx(ur, {}),
4399
4398
  /* @__PURE__ */ e.jsx(fr, {})