semaphor 0.0.78 → 0.0.79

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-1p9AH5Uv.js"),S=require("react");require("react-dom");function Gs(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const $e=Gs(S);/**
1
+ "use strict";const e=require("./index-tJEATyF7.js"),S=require("react");require("react-dom");function Gs(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const $e=Gs(S);/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -242,4 +242,4 @@ SELECT label, measure FROM table
242
242
  Table Columns: ${b==null?void 0:b.map(C=>`${C.column_name} | ${C.data_type}`).join(", ")}
243
243
  User SQL: ${T}
244
244
  ${j&&`Base Queries: ${JSON.stringify(j)} `}`,y=` 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.
245
- Visual Query Syntax: ${rt}`,{data:I,isLoading:O,isFetching:u,isError:R,refetch:p}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(l==null?void 0:l.accessToken)||"",{user_content:`userContent: ${w} ${m?y:""}`}),enabled:!1});function N(C){if(C.toLowerCase().includes("bar"))h("bar");else if(C.toLowerCase().includes("line"))h("line");else if(C.toLowerCase().includes("bubble"))h("bubble");else if(C.toLowerCase().includes("scatter"))h("scatter");else if(C.toLowerCase().includes("stacked"))h("stackedBar");else if(C.toLowerCase().includes("pie"))h("pie");else if(C.toLowerCase().includes("donut")||C.toLowerCase().includes("doughnut"))h("doughnut");else if(C.toLowerCase().includes("radar"))h("radar");else return h("bar"),!1;return!0}S.useEffect(()=>{I&&D(C=>[...C,{role:"ai",content:I.response}])},[I]),S.useEffect(()=>{const C=setTimeout(()=>{var F;c.current&&(c.current.scroll({top:c.current.scrollHeight,behavior:"smooth"}),(F=i.current)==null||F.focus())},100);return()=>clearTimeout(C)},[E]);function z(){t&&(D(C=>[...C,{role:"user",content:t}]),N(t)&&x(!0),r(""),p())}S.useEffect(()=>{o&&(z(),a(!1))},[o,a]);const M={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},q={fontFamily:"monospace",fontSize:14,lineHeight:1.6},B={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},J={p:({node:C,...F})=>e.jsxRuntimeExports.jsx("p",{style:M,...F}),code:({node:C,...F})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...F}),pre:({node:C,...F})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:q,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:F.children}),e.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:_,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:P=>{const A=_(P);A&&(n(!1),g(A),d(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:C,...F})=>e.jsxRuntimeExports.jsx("li",{style:B,...F})};function _(C){const F=C.currentTarget.closest("pre");if(!F)return;const P=F.textContent||F.innerText;return navigator.clipboard.writeText(P).then(()=>console.log("Text copied to clipboard")).catch(A=>console.error("Error in copying text: ",A)),P}function U(){return E==null?void 0:E.map((C,F)=>C.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(bs,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:C.content})]},F):C.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:J,children:I==null?void 0:I.response.replace(/DuckDB/gi,"Semaphor")},F):e.jsxRuntimeExports.jsx("div",{},F))}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:c,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:U()})}),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:i,onKeyDown:C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),r(""),z())},placeholder:"Type your question here...",onFocus:C=>{const F=C.target,P=F.value.length;F.setSelectionRange(P,P)},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:O||u,value:t,onChange:C=>r(C.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:z,children:!O&&!u?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(de,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var Cs={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Qe=S.createContext&&S.createContext(Cs),it=["attr","size","title"];function at(s,n){if(s==null)return{};var t=lt(s,n),r,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(s);for(o=0;o<a.length;o++)r=a[o],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(s,r)&&(t[r]=s[r])}return t}function lt(s,n){if(s==null)return{};var t={},r=Object.keys(s),o,a;for(a=0;a<r.length;a++)o=r[a],!(n.indexOf(o)>=0)&&(t[o]=s[o]);return t}function Ce(){return Ce=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},Ce.apply(this,arguments)}function Ue(s,n){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(s);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(s,o).enumerable})),t.push.apply(t,r)}return t}function Ne(s){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?Ue(Object(t),!0).forEach(function(r){ct(s,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Ue(Object(t)).forEach(function(r){Object.defineProperty(s,r,Object.getOwnPropertyDescriptor(t,r))})}return s}function ct(s,n,t){return n=xt(n),n in s?Object.defineProperty(s,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[n]=t,s}function xt(s){var n=ut(s,"string");return typeof n=="symbol"?n:String(n)}function ut(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 Ns(s){return s&&s.map((n,t)=>S.createElement(n.tag,Ne({key:t},n.attr),Ns(n.child)))}function ee(s){return n=>S.createElement(dt,Ce({attr:Ne({},s.attr)},n),Ns(s.child))}function dt(s){var n=t=>{var{attr:r,size:o,title:a}=s,i=at(s,it),c=o||t.size||"1em",l;return t.className&&(l=t.className),s.className&&(l=(l?l+" ":"")+s.className),S.createElement("svg",Ce({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,r,i,{className:l,style:Ne(Ne({color:s.color||t.color},t.style),s.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),a&&S.createElement("title",null,a),s.children)};return Qe!==void 0?S.createElement(Qe.Consumer,null,t=>n(t)):n(Cs)}function mt(s){return ee({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 pt(){const[s,n]=S.useState({queryKey:[],queryData:null}),{theme:t}=e.useTheme(),r=e.useQueryClient(),o=S.useRef(),a=S.useRef(),[i,c]=S.useState(!1),[l,m]=S.useState(!1),[x,g]=S.useState(!1),[j,d]=S.useState(""),[h,E]=S.useState(!1),D=e.useDashboardStore(f=>f.selectedSheetId);e.useDashboardStore(f=>f.dashboard.baseQueries);const b=e.useEditorStore(f=>f.card),T=e.useDashboardStore(f=>f.theme),k=e.useEditorStore(f=>f.isShowingVisual);e.useDashboardStore(f=>f.onAcceptChanges);const w=e.useEditorStore(f=>f.selectedConnectionId),y=e.useEditorStore(f=>f.selectedDatabaseName),I=e.useEditorStore(f=>f.selectedDatamodelId),O=e.useEditorStore(f=>f.selectedSchemaName);e.useDashboardStore(f=>f.actions.updateFrameCard);const u=e.useEditorStore(f=>f.selectedTableName),R=e.useEditorStore(f=>f.card.sql),p=e.useEditorStore(f=>f.card.python),N=e.useEditorStore(f=>f.frame),z=e.useDashboardStore(f=>f.dashboard.filters),M=e.useDashboardStore(f=>f.filterValues),q=z==null?void 0:z.filter(f=>f.sheetId===D||!f.sheetId),B=M==null?void 0:M.filter(f=>(q==null?void 0:q.some(Q=>Q.id===f.filterId))||f.filterId.endsWith(D)),J=e.useEditorStore(f=>f.applyFilters),{setCardCustomCfg:_,setQueryResultColumns:U,setFilterValues:C,setCardSql:F,setCard:P,setCardPython:A,setQueryError:L,setPythonStdOut:G,setCardPreferences:V}=e.useEditorStore(f=>f.actions),H=e.useEditorStore(f=>f.onSave),K=e.useEditorStore(f=>f.actions.setApplyFilters),se=e.useEditorStore(f=>f.onClose),le=e.useEditorStore(f=>f.actions.setSqlGen),te=e.useEditorStore(f=>f.runSql),re=e.useEditorStore(f=>f.actions.setRunSql);e.useEditorStore(f=>f.actions.setCardCfg);const ne=e.useEditorStore(f=>f.actions.setIsSqlRunning),{data:$,isLoading:Y,isFetching:X,isSuccess:ge,isError:ce,error:pe,queryKey:je,refetch:xe}=e.useDashboardCardQuery(b);S.useEffect(()=>{if($&&($.rowLimitExceeded&&e.Jt.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),G(($==null?void 0:$.output)||""),$.records.length>0)){const{dimensionKeys:f}=e.getKeys($.records);U(f)}},[$,U,G]),S.useEffect(()=>{(Y||X)&&ne(!0),(ce||ge)&&ne(!1),ce?(L(pe.message),U([]),G("")):L("")},[Y,X,$,G,ce,ge,ne,U,L,pe]),S.useEffect(()=>{te&&(xe(),re(!1))},[te,xe,re]);function Le(){const f=r.getQueryData(je);s.queryData||n({queryKey:je,queryData:f}),r.setQueryData(je,null),F(""),le({}),_(""),V({})}const he=f=>{a.current=f};function Re(f,Q){if(f.length===0)return"";if(Q){const oe=f.find(W=>W.id===Q);if(oe){const W=oe.tabTitle;if(W=="All__Header")return f[0].id;if(W&&W.endsWith("__Header")){const Hs=W.split("__")[0],Ge=f.find(Ps=>Ps.tabTitle===Hs);return Ge?Ge.id:f[0].id}return Q}}return f[0].id}function be(){let f=R;R&&!R.includes("{{")&&(f=Zs(R),F(f));const Q={...b,lastSelectedSchema:O,lastSelectedDatamodelId:I,lastSelectedDatabase:y,lastSelectedTable:u,connectionId:w,type:k?b.type:"table",sql:f,customCfg:k?b.customCfg:null},oe=N.cards.map(Te=>Te.id===b.id?Q:Te),W={...N,cards:oe,activeCardId:Re(oe,N.activeCardId)};H==null||H(W)}function ye(){const{queryKey:f,queryData:Q}=s;f&&Q&&r.setQueryData(f,Q),se==null||se()}S.useEffect(()=>{const f=o.current,Q=a.current;if(f){const oe=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",W=T==="system"?oe:T;f.editor.defineTheme("default",{base:W==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":W==="light"?"#ffffff":e.getCssVariableValue("--semaphor-background")}}),f.editor.setTheme("default")}return Q&&f&&Q.addCommand(f.KeyMod.Shift|f.KeyCode.Enter,function(){return console.log("Executing query..."),xe(),!1}),()=>{}},[t,T,o.current]);function Ee(f){o.current=f}function v(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[l&&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(st,{checked:J,onCheckedChange:()=>K(!J),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(nt,{}),B&&l&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>m(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:f=>{if(f)try{JSON.parse(f),C(JSON.parse(f))}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&&!l&&e.jsxRuntimeExports.jsx(e.Filter,{onClick:()=>m(!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":J})})]})}function Bs(){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:i?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:f=>{F(f)},value:R,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",beforeMount:Ee,onMount:he})}),i&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),i&&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:f=>{A(f&&f.trim()||"")},value:p||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:Ee,onMount:he})}),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:[Bs(),v()]}),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:Y||X,onClick:()=>{xe()},className:"shrink-0",size:"sm",variant:"outline",children:[Y||X?e.jsxRuntimeExports.jsx(de,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(ms,{className:"mr-2 h-4 w-4"}),"Run"]}),ce&&e.jsxRuntimeExports.jsx(et,{error:pe.message,setShowAIDialog:g,setTriggerAIRun:E,setUserInputforAI:d}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:Le,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(ss,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:i,onPressedChange:f=>c(f),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(mt,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(ot,{open:x,setOpen:g,userInput:j,triggerAIRun:h,setTriggerAIRun:E,setUserInput:f=>d(f)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:be,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:ye,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function jt({data:s}){var i;const[n,t]=S.useState([]),o=Object.keys(s[0]).map(c=>({accessorKey:c,header:({column:l})=>{const m=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:[c,m==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):m==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),a=e.useReactTable({data:s,columns:o,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(c=>e.jsxRuntimeExports.jsx(e.TableRow,{children:c.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))},c.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(i=a.getRowModel().rows)!=null&&i.length?a.getRowModel().rows.map(c=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":c.getIsSelected()&&"selected",children:c.getVisibleCells().map(l=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(l.column.columnDef.cell,l.getContext())},l.id))},c.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:o.length,className:"h-24 text-center",children:"No results."})})})]})}function ht({card:s}){var x,g,j,d,h,E,D,b,T,k;const n=e.useDashboardStore(w=>w.themeStyle),t={colors:((g=(x=n==null?void 0:n.chart)==null?void 0:x.dataset)==null?void 0:g.backgroundColor)||[]};(j=s.customCardPreferences)!=null&&j.inputData;const{getCard:r}=e.useCustomVisual(((d=s.customCardPreferences)==null?void 0:d.url)||""),o=((h=s.customCardPreferences)==null?void 0:h.visualType)||"single",a=e.useEditorStore(w=>w.frame);e.useEditorActions();const{data:i}=e.useDashboardCardQuery(s);if(!((E=s.customCardPreferences)!=null&&E.componentName))return null;const c=r((D=s.customCardPreferences)==null?void 0:D.componentName),l=w=>{console.log("data",w),s.customCardPreferences},m=Object.keys(((b=s.customCardPreferences)==null?void 0:b.dataInputCardIds)||{}).map(w=>{var O,u,R;const y=(u=(O=s.customCardPreferences)==null?void 0:O.dataInputCardIds)==null?void 0:u[w].cardId,I=(R=a==null?void 0:a.cards)==null?void 0:R.find(p=>p.id===y);return I||null});return e.jsxRuntimeExports.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:e.jsxRuntimeExports.jsxs(S.Suspense,{fallback:e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),children:[c&&o==="single"&&e.jsxRuntimeExports.jsx(c,{theme:t,settings:(T=s.customCardPreferences)==null?void 0:T.settings,onDataChange:l,data:(i==null?void 0:i.records)||[]}),c&&o==="multiple"&&e.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-2",children:e.jsxRuntimeExports.jsx(c,{theme:t,onDataChange:l,settings:m.map(w=>{var y;return(y=w==null?void 0:w.customCardPreferences)==null?void 0:y.settings}),data:m.map(w=>(w==null?void 0:w.data)||[])})})]},(k=s.customCardPreferences)==null?void 0:k.componentName)})}function ws({className:s,...n}){var d,h;const t=e.useEditorStore(E=>E.card),r=((d=t.customCardPreferences)==null?void 0:d.showCardHeader)??!0,o=e.useEditorStore(E=>E.frame),a=e.useDashboardStore(E=>E.dashboard.filters);e.useEditorStore(E=>E.actions.setRunSql);const{updateFilter:i}=e.useDashboardActions(),c=a==null?void 0:a.find(E=>E.id===o.filterId),{data:l}=e.useDashboardCardQuery(t),{setCard:m}=e.useEditorActions(),{data:x}=e.useTopoJson(t);if(!t.id)return null;let g;l!=null&&l.records&&(l==null?void 0:l.records.length)>0&&(g=e.createChartConfig({data:l==null?void 0:l.records,cardType:t.type,cfg:t.cfg,customCfg:t.customCfg,preferences:t.preferences,topoJson:x}));function j(E){return e.jsxRuntimeExports.jsx(ht,{card:E})}return e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",s),...n,children:[r&&e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"flex flex-row items-start justify-between py-4",children:[e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsx(e.Editable,{text:t.title,onSave:E=>m({...t,title:E}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-5",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:t.title||"Edit title..."})})},t.title),e.jsxRuntimeExports.jsx(e.Editable,{text:t.description||"",onSave:E=>m({...t,description:E}),children:e.jsxRuntimeExports.jsx(e.CardDescription,{children:t.description||"Edit description..."})},t.description)]}),c&&e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Editable,{className:"my-1",text:c.title||c.column,onSave:E=>i({...c,title:E}),children:e.jsxRuntimeExports.jsx(e.Label,{children:c.title})}),e.getFilterComponent(c)]})]}),e.jsxRuntimeExports.jsxs(e.CardContent,{className:"flex grow flex-col",children:[t.type==="custom"&&j(t),!["table","custom"].includes(t.type)&&g&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:g},JSON.stringify(g)+JSON.stringify(t.preferences)+((h=t==null?void 0:t.preferences)==null?void 0:h.customVisualCode)),t.type==="table"&&(l==null?void 0:l.records)&&(l==null?void 0:l.records.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:t,data:l==null?void 0:l.records})})]})]})}function Et(){const[s,n]=S.useState(!1),[t,r]=S.useState(""),[o,a]=S.useState(""),[i,c]=S.useState(""),[l,m]=S.useState(""),x=e.useEditorStore(y=>y.card),g=e.useEditorStore(y=>y.card.customCfg),{data:j}=e.useDashboardCardQuery(x),{data:d}=e.useTopoJson(x),{setCardCustomCfg:h,setCustomVisualCode:E}=e.useEditorActions();function D(y){var u,R;const I={...y,data:{...y==null?void 0:y.data,datasets:(R=(u=y==null?void 0:y.data)==null?void 0:u.datasets)==null?void 0:R.map(p=>({...p,data:[]}))}};return JSON.stringify(I,null,1)}function b(){var I,O;if(!(j!=null&&j.records)||(j==null?void 0:j.records.length)===0)return;const y=e.createChartConfig({data:j==null?void 0:j.records,cardType:x.type,cfg:x.cfg,preferences:x.preferences,topoJson:d});y&&(r(JSON.stringify(y,null,1)),(I=x==null?void 0:x.preferences)!=null&&I.customVisualCode&&c((O=x==null?void 0:x.preferences)==null?void 0:O.customVisualCode),g&&a(JSON.stringify(g,null,1)))}function T(){if(i&&E(i),!!o)try{const y=JSON.parse(o);return y?(h(y),m(""),a(""),y):void 0}catch(y){console.log(y),m("Invalid JSON")}}function k(){a(""),h(null)}function w(){let y;if(g){const I=e._.cloneDeep(x.cfg),O=e._.merge(I,g);return y=D(O),y}return t?(y=D(JSON.parse(t)),y):""}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:b,className:` ${g&&"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(Ve,{onClick:()=>{navigator.clipboard.writeText(x.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(e.ErrorBoundary,{FallbackComponent:e.FallbackEditorCard,children:e.jsxRuntimeExports.jsx(ws,{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:[g&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),g?"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:w(),onChange:y=>a(y)})}),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:i,onChange:y=>c(y||"")})})]})]}),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:!g,onClick:k,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:T,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>n(!1),variant:"outline",children:"Close"})]})]})]})}function ks(s){return ee({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 Is(s){return ee({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 Ds(s){return ee({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 Ls(s){return ee({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 Ts(s){return ee({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 As(s){return ee({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 Os(s){return ee({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 zs(s){return ee({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 Fs(s){const[n,t]=S.useState(null);return S.useEffect(()=>{s&&(async()=>{const a=(await Promise.resolve().then(()=>require("./lucide-react-vDdGhe6o.js")))[s];t(a)})()},[s]),n}function Ms(){const{authToken:s}=e.useSemaphorContext(),{data:n,isLoading:t,isFetching:r,isError:o}=e.useQuery({queryKey:["plugins",s==null?void 0:s.accessToken],queryFn:()=>e.getPlugins(s==null?void 0:s.accessToken)});return{data:n,isLoading:t,isFetching:r,isError:o}}function ft({onChartTypeChange:s}){const[n,t]=S.useState([]),{data:r}=Ms();return S.useEffect(()=>{(async()=>{var a;if(r){const c=(await Promise.all((a=r==null?void 0:r.plugins)==null?void 0:a.map(async l=>(await e.loadManifest(l.value)).visuals.map(g=>({name:g.name,icon:g.icon,url:l.value}))))).flat();t(c)}})()},[r]),n.length===0?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.Separator,{className:"my-2"}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-4 place-items-center",children:n.map((o,a)=>e.jsxRuntimeExports.jsx(gt,{text:o.name,onClick:()=>s("custom",o),icon:o.icon},o.url+o.name+a))})]})}const gt=({text:s,icon:n,onClick:t})=>{const r=Fs(n||""),o=s.charAt(0).toUpperCase();return e.jsxRuntimeExports.jsx(e.Button,{onClick:t,title:s,variant:"ghost",children:r?e.jsxRuntimeExports.jsx(r,{className:"h-4 w-4"}):o})};function Rt(){var x,g;const[s,n]=S.useState(!1),t=e.useEditorStore(j=>j.card),r=t.type,{setCardType:o,setCardPreferences:a,setChartOrientation:i}=e.useEditorStore(j=>j.actions),{setCardCustomCfg:c,setCustomCardPreferences:l}=e.useEditorActions();function m(j,d){c(null),a({}),o(j),d&&l({type:"component",visualType:"single",url:d.url,componentName:d.name,icon:d.icon}),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(bt,{className:"h-4 w-4",chartType:r,customIcon:(x=t.customCardPreferences)==null?void 0:x.icon,componentName:(g=t.customCardPreferences)==null?void 0:g.componentName})})}),e.jsxRuntimeExports.jsxs(e.PopoverContent,{className:"w-50",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-4 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(we,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ke,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(As,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ts,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Fe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ls,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ze,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Is,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ks,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ds,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(zs,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Oe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Os,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ie,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("map"),variant:"ghost",children:e.jsxRuntimeExports.jsx(qe,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("custom"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Be,{className:"size-4"})})]}),e.jsxRuntimeExports.jsx(ft,{onChartTypeChange:m})]})]})}function bt({chartType:s,className:n,customIcon:t,componentName:r}){const o=Fs(t||"");switch(s){case"bar":return e.jsxRuntimeExports.jsx(we,{className:n});case"line":return e.jsxRuntimeExports.jsx(ke,{className:n});case"pie":return e.jsxRuntimeExports.jsx(ze,{className:n});case"radar":return e.jsxRuntimeExports.jsx(ks,{className:n});case"scatter":return e.jsxRuntimeExports.jsx(Fe,{className:n});case"bubble":return e.jsxRuntimeExports.jsx(Ls,{className:n});case"doughnut":return e.jsxRuntimeExports.jsx(Is,{className:n});case"stackedBar":return e.jsxRuntimeExports.jsx(As,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(Ts,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(Ds,{className:n});case"pyramid":return e.jsxRuntimeExports.jsx(zs,{className:n});case"range":return e.jsxRuntimeExports.jsx(Oe,{className:n});case"kpi":return e.jsxRuntimeExports.jsx(Os,{className:n});case"text":return e.jsxRuntimeExports.jsx(Ie,{className:n});case"map":return e.jsxRuntimeExports.jsx(qe,{className:n});case"custom":return t&&o?e.jsxRuntimeExports.jsx(o,{className:n}):r?r==null?void 0:r.charAt(0).toUpperCase():e.jsxRuntimeExports.jsx(Be,{className:n});default:return e.jsxRuntimeExports.jsx(e.Table,{className:n})}}function yt(){var o;const s=e.useEditorStore(a=>a.card),n=((o=s.customCardPreferences)==null?void 0:o.showCardHeader)??!0,{setCustomCardPreferences:t}=e.useEditorActions(),r=a=>{s.customCardPreferences&&t({...s.customCardPreferences,showCardHeader:a===!0})};return e.jsxRuntimeExports.jsxs(e.DropdownMenu,{children:[e.jsxRuntimeExports.jsx(e.DropdownMenuTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(Me,{className:"size-4 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsxs(e.DropdownMenuContent,{align:"start",className:"w-40 text-muted-foreground",children:[e.jsxRuntimeExports.jsx(e.DropdownMenuCheckboxItem,{checked:n,onCheckedChange:r,children:"Card Header"}),e.jsxRuntimeExports.jsxs(e.DropdownMenuItem,{onClick:()=>{navigator.clipboard.writeText(s.id),e.Jt.success("Card ID copied to clipboard")},className:"cursor-pointer space-x-2",children:[e.jsxRuntimeExports.jsx(Ve,{className:"size-4"}),e.jsxRuntimeExports.jsx("span",{children:"Copy Card ID"})]})]})]})}function Je(){const s=e.useEditorStore(u=>u.frame),n=e.useEditorStore(u=>u.card),t=e.useEditorStore(u=>u.isShowingVisual),r=e.useEditorStore(u=>u.isSqlRunning),o=e.useEditorStore(u=>u.queryError),a=e.useEditorStore(u=>u.pythonStdOut),i=e.useEditorStore(u=>u.actions.setRunSql);e.useEditorStore(u=>u.onSave),e.useEditorStore(u=>u.onClose),e.useEditorStore(u=>u.actions.setCardSql),e.useEditorStore(u=>u.actions.setCardType),e.useEditorStore(u=>u.actions.setSqlGen);const{setFrame:c,setCard:l,updateCardInFrame:m}=e.useEditorActions(),{data:x,isLoading:g,isFetching:j}=e.useDashboardCardQuery(n);if(!n)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function d(){const u={connectionId:n.connectionId,id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]};h(u)}function h(u){const R={...s,cards:[...s.cards,u],activeCardId:u.id};c(R),l(u)}function E(){const u={...n,id:e.v4(),title:`${n.title} Copy`,tabTitle:`${n.tabTitle} Copy`};h(u)}function D(u){const R=s.cards.filter(z=>z.id!==u),p=R[0],N={...s,cards:R,activeCardId:p.id};c(N),l(p)}function b(u){const R={...s,cards:s.cards.map(N=>N.id===n.id?n:N),activeCardId:u};c(R);const p=R.cards.find(N=>N.id===u);p.sql&&i(!0),l(p)}const T=(u,R)=>{console.log("handleDragStart",R),u.dataTransfer.setData("tabIndex",R.toString())},k=u=>{u.preventDefault()},w=(u,R)=>{const p=u.dataTransfer.getData("tabIndex");if(p===R.toString())return;const N=Array.from(s.cards),[z]=N.splice(parseInt(p),1);N.splice(R,0,z),c({...s,cards:N})};function y(u,R){return u.cards.length===1&&(R.displayTab===!0||R.displayTab===void 0)||u.activeCardId!==R.id&&(R.displayTab===!0||R.displayTab===void 0)?null:e.jsxRuntimeExports.jsx("div",{onClick:()=>{const p=R.displayTab===void 0?!1:!R.displayTab;l({...R,displayTab:p}),m({...R,displayTab:p})},children:R.displayTab===!0||R.displayTab===void 0?e.jsxRuntimeExports.jsx(ns,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"}):e.jsxRuntimeExports.jsx(ts,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"})})}function I(){return e.jsxRuntimeExports.jsxs(e.Tabs,{onValueChange:b,value:s.activeCardId,className:"flex grow flex-col",children:[s.cards.map(u=>e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow",value:u.id,children:O()},u.id)),e.jsxRuntimeExports.jsx(e.TabsList,{className:"group mx-6 justify-between",children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[s.cards.map((u,R)=>e.jsxRuntimeExports.jsx(e.Editable,{text:u.tabTitle||u.title,onSave:p=>{l({...n,tabTitle:p}),m({...n,tabTitle:p})},children:e.jsxRuntimeExports.jsxs(e.TabsTrigger,{draggable:!0,onDragStart:p=>T(p,R),onDragOver:k,onDrop:p=>w(p,R),className:"",value:u.id,children:[y(s,u),u.tabTitle||u.title,s.activeCardId===u.id&&s.cards.length>1&&e.jsxRuntimeExports.jsx(e.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>D(u.id)})]})},u.id)),e.jsxRuntimeExports.jsx(e.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:d,children:e.jsxRuntimeExports.jsx(e.Plus,{className:"h-4 w-4"})}),e.jsxRuntimeExports.jsx(e.Button,{className:"invisible ml-1 h-8 px-2 hover:bg-muted-foreground/50 group-hover:visible",variant:"outline",onClick:E,children:e.jsxRuntimeExports.jsx(Ze,{className:"h-4 w-4"})})]})})]})}function O(){return n.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.KPICard,{card:n,data:x==null?void 0:x.records})})}):n.type==="text"?e.jsxRuntimeExports.jsx("div",{className:"flex h-full 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:n,data:x==null?void 0:x.records})})}):e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.FallbackEditorCard,children:e.jsxRuntimeExports.jsx(ws,{className:"grow border-none shadow-none"})})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col py-3",children:[(g||j)&&e.jsxRuntimeExports.jsx(de,{className:"absolute bottom-0 left-0 right-0 top-0 z-50 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,{}),!["table","custom"].includes(n.type)&&e.jsxRuntimeExports.jsx(Et,{}),e.jsxRuntimeExports.jsx(yt,{})]}),e.jsxRuntimeExports.jsx(St,{})]}),t?I():e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[a&&e.jsxRuntimeExports.jsx(vt,{}),(x==null?void 0:x.records)&&(x==null?void 0:x.records.length)>0&&e.jsxRuntimeExports.jsx(jt,{data:(x==null?void 0:x.records)||[]}),o&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:o})]})]})}function vt(){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 St(){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 Ct({options:s,value:n,onValueChange:t}){return e.jsxRuntimeExports.jsx(e.RadioGroup,{value:n,onValueChange:t,className:"flex gap-4",defaultValue:s[0].value,children:s.map(r=>e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:r.value,id:r.value}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:r.value,children:r.label})]},r.value))})}function Z({label:s,options:n,value:t,onValueChange:r,className:o}){return e.jsxRuntimeExports.jsxs(e.Select,{value:t,onValueChange:r,children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:e.cn("w-full focus:ring-0 focus:ring-offset-0",o),children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:s})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:s}),n.map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a.value,children:a.label},a.value))]})})]})}function fe({children:s,summary:n,open:t,className:r}){return e.jsxRuntimeExports.jsxs("details",{open:t,className:e.cn("space-y-4 [&_summary>svg]:open:-rotate-180",r),children:[e.jsxRuntimeExports.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-4",children:[e.jsxRuntimeExports.jsx(e.Label,{children:n}),e.jsxRuntimeExports.jsx(e.ChevronUp,{className:"h-4 w-4"})]}),e.jsxRuntimeExports.jsx("div",{className:"transition-all ease-in-out",children:s})]})}function Nt(){var E,D;const s=e.useEditorStore(b=>b.card.customCardPreferences),{data:n}=Ms(),t=(n==null?void 0:n.plugins)||[],r=e.useEditorStore(b=>b.card),o=e.useEditorStore(b=>b.frame),a=(s==null?void 0:s.visualType)||"single",{setCustomCardPreferences:i}=e.useEditorActions(),{components:c,manifest:l}=e.useCustomVisual((s==null?void 0:s.url)||""),m=(E=l==null?void 0:l.visuals)==null?void 0:E.find(b=>b.name===(s==null?void 0:s.componentName));function x(b,T){if(!s)return;const w={...(s==null?void 0:s.dataInputCardIds)||{},[b]:{cardId:T,hookRef:null}};i({...s,dataInputCardIds:w})}function g(b){var k,w;const T=(k=o==null?void 0:o.cards)==null?void 0:k.filter(y=>{var I;return((I=y==null?void 0:y.customCardPreferences)==null?void 0:I.visualType)!=="multiple"}).map(y=>({value:y.id,label:y.tabTitle||y.title}));return e.jsxRuntimeExports.jsx("div",{className:"space-y-2",children:(w=b==null?void 0:b.dataInputs)==null?void 0:w.map((y,I)=>{var O,u;return e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-10 gap-2",children:[e.jsxRuntimeExports.jsx("div",{className:"col-span-4 flex items-center",children:y}),e.jsxRuntimeExports.jsx(Z,{className:"col-span-6 h-8 w-full justify-between",label:"",options:T||[],value:((u=(O=s==null?void 0:s.dataInputCardIds)==null?void 0:O[I])==null?void 0:u.cardId)||"",onValueChange:R=>x(I,R)})]},I+Math.random())})})}function j(b,T,k=[]){var w,y;return s?b==="input"?e.jsxRuntimeExports.jsx(e.Input,{className:`h-8 w-full ${e.removeRing}`,value:((w=s==null?void 0:s.settings)==null?void 0:w[T])||"",onChange:I=>{i({...s,settings:{...s==null?void 0:s.settings,[T]:I.target.value}})}},T):b==="select"?e.jsxRuntimeExports.jsx(Z,{className:"h-8 w-full",label:"",options:k,value:((y=s==null?void 0:s.settings)==null?void 0:y[T])||"",onValueChange:I=>{i({...s,settings:{...s==null?void 0:s.settings,[T]:I}})}}):null:null}function d(b){const T=Object.entries((b==null?void 0:b.settings)||{});return e.jsxRuntimeExports.jsx("div",{className:"space-y-3",children:T.map(([k,w])=>e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:w.title}),j(w.ui,k,w.options)]},k))})}function h(b){s&&i({...s,visualType:b,componentName:""})}return e.jsxRuntimeExports.jsxs("div",{className:"p-6",children:[e.jsxRuntimeExports.jsx(fe,{summary:"Plugin Settings",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 text-sm",children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsxRuntimeExports.jsx("div",{className:"space-y-2",children:e.jsxRuntimeExports.jsx("div",{className:"px-2",children:e.jsxRuntimeExports.jsx(Z,{className:"h-8 w-full",label:"",options:t,value:(s==null?void 0:s.url)||"",onValueChange:b=>i({...s||{url:"",componentName:""},url:b})})})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&e.jsxRuntimeExports.jsx(Ct,{options:[{value:"single",label:"Single Visual"},{value:"multiple",label:"Multi-Visual"}],value:a,onValueChange:h}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&s&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Component"}),e.jsxRuntimeExports.jsx("div",{className:"space-y-2 px-2",children:c&&e.jsxRuntimeExports.jsx(Z,{className:"h-8 w-full",label:"",options:(c==null?void 0:c.filter(b=>b.type===a).map(b=>({value:b.name,label:b.name})))||[],value:s.componentName,onValueChange:b=>{console.log("changing value",b),i({...s,componentName:b})}})})]})})]})})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),((D=r==null?void 0:r.customCardPreferences)==null?void 0:D.componentName)&&e.jsxRuntimeExports.jsxs(fe,{summary:"Component Settings",children:[m&&m.dataInputs&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Input Mapping"}),e.jsxRuntimeExports.jsx("div",{className:"px-2",children:g(m)})]}),m&&m.settings&&e.jsxRuntimeExports.jsx("div",{className:"space-y-3",children:e.jsxRuntimeExports.jsx("div",{className:"px-2",children:d(m)})})]})]})}function ae(){const[s,n]=S.useState([]);e.useEditorStore(x=>x.card.cfg);const t=e.useEditorStore(x=>x.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:o,setCardPreferences:a}=e.useEditorStore(x=>x.actions),i=e.useEditorStore(x=>x.queryResultColumns);e.useEditorStore(x=>{var g;return(g=x.card.preferences)==null?void 0:g.filterOnClickColumnIndex}),S.useEffect(()=>{i&&n(new Array(i.length).fill(!1))},[i]);function c(x,g){var j,d;g?t!=null&&t.onClickFilter&&((j=t==null?void 0:t.onClickFilter)==null?void 0:j.length)>0?a({...t,onClickFilter:[...t.onClickFilter,{columnIndex:x,expression:""}]}):a({...t,onClickFilter:[{columnIndex:x,expression:""}]}):(a({...t,onClickFilter:(d=t==null?void 0:t.onClickFilter)==null?void 0:d.filter(h=>h.columnIndex!==x)}),n(h=>{const E=[...h];return E[x]=!1,E}))}function l(x,g){var d;const j=(d=t==null?void 0:t.onClickFilter)==null?void 0:d.map(h=>h.columnIndex===x?{...h,expression:g.target.value}:h);a({...t,onClickFilter:j})}function m(x){var g,j,d,h;if(s!=null&&s[x]||(j=(g=t==null?void 0:t.onClickFilter)==null?void 0:g.find(E=>E.columnIndex===x))!=null&&j.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(h=(d=t==null?void 0:t.onClickFilter)==null?void 0:d.find(E=>E.columnIndex===x))==null?void 0:h.expression,onChange:E=>l(x,E),type:"text",className:"h-9 w-full font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"Expression"})}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"On Click"}),i==null?void 0:i.map((x,g)=>{var j,d;return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 group flex items-center justify-between space-y-2",children:e.jsxRuntimeExports.jsxs("div",{className:"grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2 py-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((j=t==null?void 0:t.onClickFilter)!=null&&j.find(h=>h.columnIndex===g)),onCheckedChange:h=>c(g,h)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:x}),e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:((d=t==null?void 0:t.onClickFilter)==null?void 0:d.find(h=>h.columnIndex===g))&&e.jsxRuntimeExports.jsx(_e,{onClick:()=>{n(h=>{const E=[...h];return E[g]=!h[g],E})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),m(g)]})},x)})]})}function De(){var i,c,l;const s=e.useEditorStore(m=>m.card.preferences),n=e.useEditorStore(m=>m.card.cfg),{setCardCfg:t,setCardPreferences:r,setChartOrientation:o}=e.useEditorStore(m=>m.actions);(i=n==null?void 0:n.options)!=null&&i.indexAxis;function a(m){o(m)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((c=s==null?void 0:s.chartOptions)==null?void 0:c.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 ve="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function Ke(s,n){var r,o,a;const t=e.getNumberAxis(s,n);return((a=(o=(r=s==null?void 0:s.chartOptions)==null?void 0:r.scales)==null?void 0:o[t])==null?void 0:a.type)||"linear"}function Vs(){var J,_,U,C,F,P;const[s,n]=S.useState(!1),t=e.useEditorStore(A=>{var L;return(L=A.card)==null?void 0:L.preferences}),r=e.useEditorStore(A=>{var L;return(L=A.card)==null?void 0:L.cfg}),o=e.getNumberAxis(t,r),[a,i]=S.useState(Ke(t)),[c,l]=S.useState(((U=(_=(J=t==null?void 0:t.chartOptions)==null?void 0:J.scales)==null?void 0:_[o])==null?void 0:U.min)||""),[m,x]=S.useState(((P=(F=(C=t==null?void 0:t.chartOptions)==null?void 0:C.scales)==null?void 0:F[o])==null?void 0:P.max)||""),[g,j]=S.useState(c||m?"custom":"auto"),[d,h]=S.useState(""),[E,D]=S.useState(0),[b,T]=S.useState(""),[k,w]=S.useState(""),[y,I]=S.useState(""),O=e.useEditorStore(A=>A.actions.setCardPreferences),{updateCardInFrame:u}=e.useEditorActions(),R=e.useEditorStore(A=>A.card),p=e.useEditorStore(A=>{var L;return(L=A.card)==null?void 0:L.type}),N=["pie","doughnut","polarArea"].includes(p);S.useEffect(()=>{var A,L,G,V,H,K,se,le,te,re,ne,$,Y,X;i(Ke(t)),l(((G=(L=(A=t==null?void 0:t.chartOptions)==null?void 0:A.scales)==null?void 0:L[o])==null?void 0:G.min)===0?0:""),x(((K=(H=(V=t==null?void 0:t.chartOptions)==null?void 0:V.scales)==null?void 0:H[o])==null?void 0:K.max)||""),h(((re=(te=(le=(se=t==null?void 0:t.chartOptions)==null?void 0:se.scales)==null?void 0:le[o])==null?void 0:te.ticks)==null?void 0:re.stepSize)||""),D(((ne=t==null?void 0:t.numberAxisFormat)==null?void 0:ne.decimalPlaces)||0),T((($=t==null?void 0:t.numberAxisFormat)==null?void 0:$.suffix)||""),w(((Y=t==null?void 0:t.numberAxisFormat)==null?void 0:Y.currency)||""),I(((X=t==null?void 0:t.numberAxisFormat)==null?void 0:X.locale)||"")},[s,t,o]);function z(A,L){return L===""||/^[0-9\b]+$/.test(L)?Number(L):Number(A)}function M(){const A=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(L=>L.currency))];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.jsxs(e.Select,{value:k||"none",onValueChange:L=>w(L==="none"?"":L),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,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),A.map(L=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:L,children:L},L))]})})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:y,onValueChange:L=>I(L),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,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Locale"}),e.LOCALE_CURRENCY_PAIRS.map(L=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:L.locale,children:L.locale},L.locale))]})})]})]}),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:E,onChange:L=>D(Number(L.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${ve}`})]})]})}function q(){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:c,onChange:A=>l(L=>z(L,A.target.value)),className:`col-span-1 h-8 w-full ${ve}`}),e.jsxRuntimeExports.jsx(e.Input,{value:m,onChange:A=>x(L=>z(L,A.target.value)),id:"max",className:`col-span-1 h-8 w-full ${ve}`})]}),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:d,onChange:A=>h(L=>z(L,A.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${ve}`})]})]})}function B(){var V;let A={};g==="custom"&&(A={min:c,max:m,ticks:{stepSize:d}});const L={...t||{},chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(V=t==null?void 0:t.chartOptions)==null?void 0:V.scales,[o]:{type:a,...a==="linear"?A:{}}}},numberAxisFormat:{decimalPlaces:E,suffix:b,currency:k,locale:y}};console.log(L),O(L);const G={...R,preferences:L};u(G)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:A=>n(A),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:N,value:a,onValueChange:A=>i(A),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:N,id:"scale-option",value:g,onValueChange:A=>j(A),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"})]})]})]}),g==="custom"&&a=="linear"&&q(),M(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:B,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function wt({idx:s}){var c;const n=e.useEditorStore(l=>{var m;return(m=l.card)==null?void 0:m.preferences}),t=e.useEditorStore(l=>{var m;return(m=l.card.preferences)==null?void 0:m.datasetOptions}),r=e.useEditorStore(l=>l.actions.setCardPreferences),o=(c=n==null?void 0:n.chartOptions)==null?void 0:c.indexAxis,a=t==null?void 0:t.find(l=>l.idx===s);function i(l,m){(l==="end"||l==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const x={display:l!=="none",align:l,anchor:l,clamp:!0};if(!a)r({...n,datasetOptions:[...t||[],{idx:m,datalabels:x}]});else{const g={...a};g.datalabels=x;const j=t==null?void 0:t.map(d=>d.idx===m?g:d);r({...n,datasetOptions:j})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(gs,{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:()=>i("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:()=>i("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(ls,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(xs,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(cs,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function qs(){const s=e.useEditorStore(m=>m.card),n=e.useEditorStore(m=>{var x,g,j;return(j=(g=(x=m==null?void 0:m.card)==null?void 0:x.preferences)==null?void 0:g.chartOptions)==null?void 0:j.indexAxis}),{data:t}=e.useDashboardCardQuery(s),r=n==="y"?"Y axis":"X axis",o=n==="y"?"X axis":"Y axis",{keys:a,metricKeys:i,dimensionKeys:c}=e.getKeys((t==null?void 0:t.records)||[]);let l=i;if(["stackedBar","stackedLine"].includes(s.type)){const m=e.pivotData({dataArray:(t==null?void 0:t.records)||[],groupKey:c[0],pivotKey:c[1],valueKey:l[0]}),{metricKeys:x}=e.getKeys(m);l=x}return a.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:r}),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:o}),e.jsxRuntimeExports.jsx(Vs,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:l.map((m,x)=>e.jsxRuntimeExports.jsx(kt,{col:m,idx:x},m))})]})]})}function kt({col:s,idx:n}){const t=e.useEditorStore(c=>{var l;return(l=c.card)==null?void 0:l.preferences}),r=e.useEditorStore(c=>{var l;return(l=c.card.preferences)==null?void 0:l.datasetOptions}),o=r==null?void 0:r.find(c=>c.idx===n),{setCardPreferences:a}=e.useEditorStore(c=>c.actions);function i(c){if(!o)a({...t,datasetOptions:[...r||[],{idx:n,type:c==="area"?"line":c,fill:c==="area"?"origin":""}]});else{const l={...o};l.type=c==="area"?"line":c,l.fill=c==="area"?"origin":"";const m=r==null?void 0:r.map(x=>x.idx===n?l:x);a({...t,datasetOptions:m})}}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(we,{onClick:()=>i("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ke,{onClick:()=>i("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Ye,{onClick:()=>i("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(wt,{idx:n})]})]})}function _s(){const s=e.useEditorStore(j=>j.selectedConnectionId),n=e.useEditorStore(j=>j.selectedDatamodelId),t=e.useEditorStore(j=>j.selectedDatabaseName),r=e.useEditorStore(j=>j.selectedSchemaName),o=e.useEditorStore(j=>j.selectedTableName),a=e.useDashboardStore(j=>j.dashboard.filters)||[],i=e.useDashboardStore(j=>j.actions.addFilter),c=e.useDashboardStore(j=>j.actions.removeFilter),l=e.useDashboardStore(j=>j.actions.removeFilterValue),{modelItems:m,tableName:x}=ie();function g(j,d="dashboard"){var I;const h=e.fmt(j.column_name),E=e.fmt(t||""),D=e.fmt(r||""),b=e.fmt(x);let T=e.getQualifiedTableName(D,b),k=`${T}.${h}`;const w=(I=m==null?void 0:m.find(O=>O.id===n))==null?void 0:I.name;n&&n!=="none"&&(k=`${e.DATAMODEL_NAMESPCACE}.${w}.${h}`,T=`${e.DATAMODEL_NAMESPCACE}.${w}`);const y=a==null?void 0:a.find(O=>O.column===k&&O.table===b&&(O.database===E||O.database===t));if(y)l(y.id),c(y.id);else{const O=e.v4();return x==="api"&&s?(i({location:d,id:O,column:k,title:j.column_name,dataType:j.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:e.getDefaultFilterSql(j.data_type,T,h)}),O):(i({id:O,location:d,column:k,title:j.column_name,dataType:j.data_type,table:o||"",database:t||"",connectionId:s||"",operation:"in",sql:e.getDefaultFilterSql(j.data_type,T,h)}),O)}}return{assignFilter:g}}function me(){const s=e.useDashboardStore(c=>c.dashboard.filters),n=e.useEditorStore(c=>c.frame),{setFrame:t}=e.useEditorActions(),{columns:r}=ie(),{assignFilter:o}=_s();function a(c){const l=o(c,"frame");t({...n,filterId:l})}const i=s==null?void 0:s.find(c=>c.id===n.filterId);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Card Filter"}),e.jsxRuntimeExports.jsx(It,{onSelect:a,columns:r}),i&&e.jsxRuntimeExports.jsx(e.FilterHeader,{filter:i})]})}function It({columns:s,onSelect:n}){var i;const[t,r]=$e.useState(!1),[o,a]=$e.useState("");return e.jsxRuntimeExports.jsxs(e.Popover,{open:t,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs(e.Button,{size:"sm",variant:"outline",role:"combobox","aria-expanded":t,className:"w-full justify-between font-normal",children:[o?(i=s.find(c=>c.column_name===o))==null?void 0:i.column_name:"Select Column...",e.jsxRuntimeExports.jsx(e.CaretSortIcon,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-[200px] p-0",children:e.jsxRuntimeExports.jsxs(e.Command,{children:[e.jsxRuntimeExports.jsx(e.CommandInput,{placeholder:"Search column",className:"h-9"}),e.jsxRuntimeExports.jsxs(e.CommandList,{children:[e.jsxRuntimeExports.jsx(e.CommandEmpty,{children:"No framework found."}),e.jsxRuntimeExports.jsx(e.CommandGroup,{children:s.map(c=>e.jsxRuntimeExports.jsxs(e.CommandItem,{value:c.column_name,onSelect:l=>{const m=l===o?"":l;a(m),r(!1),m&&n(c)},children:[c.column_name,e.jsxRuntimeExports.jsx(e.CheckIcon,{className:e.cn("ml-auto h-4 w-4",o===c.column_name?"opacity-100":"opacity-0")})]},c.column_name))})]})]})})]})}function Dt({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(De,{}),e.jsxRuntimeExports.jsx(qs,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ae,{}),e.jsxRuntimeExports.jsx(me,{})]})]})]})})}function Pe(){var o,a,i;const s=e.useEditorStore(c=>c.card.cfg),n=e.useEditorStore(c=>c.actions.setCardCfg),t=e.useEditorStore(c=>c.card.type);function r(c){var x;const l={datalabels:{display:c!=="none",align:c,anchor:c,clamp:!0}},m={...s,options:{...s==null?void 0:s.options,plugins:{...(x=s==null?void 0:s.options)==null?void 0:x.plugins,...l}}};n(m),console.log(c)}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(Vs,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(i=(a=(o=s==null?void 0:s.options)==null?void 0:o.plugins)==null?void 0:a.datalabels)==null?void 0:i.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 Lt({cardType:s}){function n(t){const r="SELECT label, [group], x-axis, y-axis, radius FROM table",o="SELECT label, [group], x-axis, y-axis FROM table";return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:t==="bubble"?r:o}),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:"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:"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.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(Pe,{})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ae,{}),e.jsxRuntimeExports.jsx(me,{})]})]})]})})}const Tt={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},At={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function Ot(){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:zt(s)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(s)&&e.jsxRuntimeExports.jsx(De,{})}),!["kpi"].includes(s)&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsx(Pe,{}),e.jsxRuntimeExports.jsx(ae,{}),e.jsxRuntimeExports.jsx(me,{})]})]})}function zt(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(Tt,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(At,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 Ft(){var l,m,x,g,j;const s=e.useEditorStore(d=>d.card.preferences),n=e.useEditorStore(d=>d.actions.setCardPreferences),t=e.useEditorStore(d=>d.actions.setNumberFormat);e.useEditorStore(d=>{var h,E;return(E=(h=d.card.preferences)==null?void 0:h.formatNumber)==null?void 0:E.decimalPlaces});const r=e.useEditorStore(d=>{var h,E;return(E=(h=d.card.preferences)==null?void 0:h.formatNumber)==null?void 0:E.locale}),o=e.useEditorStore(d=>{var h,E;return(E=(h=d.card.preferences)==null?void 0:h.formatNumber)==null?void 0:E.currency});e.useEditorStore(d=>d.actions.setFilterOnClickField);const a=e.useEditorStore(d=>{var h,E;return(E=(h=d.card.preferences)==null?void 0:h.formatNumber)==null?void 0:E.colorRanges})||[],i=e.useEditorStore(d=>d.actions.setColorRanges),c=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(d=>d.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:d=>{n({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:d}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((m=s==null?void 0:s.formatNumber)==null?void 0:m.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||"none",onValueChange:d=>{var h,E,D;return t(((h=s==null?void 0:s.formatNumber)==null?void 0:h.decimalPlaces)||0,((E=s==null?void 0:s.formatNumber)==null?void 0:E.currency)||"",d,((D=s==null?void 0:s.formatNumber)==null?void 0:D.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.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),e.LOCALE_CURRENCY_PAIRS.map(d=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:d.locale,children:d.locale},d.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:o||"none",onValueChange:d=>{var h,E,D;console.log("currency",d),t(((h=s==null?void 0:s.formatNumber)==null?void 0:h.decimalPlaces)||0,d==="none"?"":d,((E=s==null?void 0:s.formatNumber)==null?void 0:E.locale)||"",((D=s==null?void 0:s.formatNumber)==null?void 0:D.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"),c.map(d=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:d,children:d},d))]})})]})]})]}),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:((g=(x=s==null?void 0:s.formatNumber)==null?void 0:x.decimalPlaces)==null?void 0:g.toString())||"0",onValueChange:d=>{var h,E,D;return t(Number(d),((h=s==null?void 0:s.formatNumber)==null?void 0:h.currency)||"",((E=s==null?void 0:s.formatNumber)==null?void 0:E.locale)||"",((D=s==null?void 0:s.formatNumber)==null?void 0:D.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(d=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:d,children:d},d))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.Input,{value:((j=s==null?void 0:s.formatNumber)==null?void 0:j.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:d=>{var h,E,D;return t(((h=s==null?void 0:s.formatNumber)==null?void 0:h.decimalPlaces)||0,((E=s==null?void 0:s.formatNumber)==null?void 0:E.currency)||"",((D=s==null?void 0:s.formatNumber)==null?void 0:D.locale)||"",d.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:a,setColorRanges:i})]})]})}function Mt(){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(Ft,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}const Vt=[{label:"Mercator",value:"mercator"},{label:"Azimuthal Equidistant",value:"azimuthalEquidistant"},{label:"Gnomonic",value:"gnomonic"},{label:"Orthographic",value:"orthographic"},{label:"Stereographic",value:"stereographic"},{label:"Equal Earth",value:"equalEarth"},{label:"Albers",value:"albers"},{label:"Albers USA",value:"albersUsa"},{label:"Conic Conformal",value:"conicConformal"},{label:"Conic Equal Area",value:"conicEqualArea"},{label:"Conic Equidistant",value:"conicEquidistant"},{label:"Equirectangular",value:"equirectangular"},{label:"Transverse Mercator",value:"transverseMercator"},{label:"Natural Earth 1",value:"naturalEarth1"}],qt=["blues","brBG","buGn","buPu","cividis","cool","cubehelixDefault","gnBu","greens","greys","inferno","magma","orRd","oranges","pRGn","piYG","plasma","puBu","puBuGn","puOr","puRd","purples","rainbow","rdBu","rdGy","rdPu","rdYlBu","rdYlGn","reds","sinebow","spectral","turbo","viridis","warm","ylGn","ylGnBu","ylOrBr","ylOrRd"],_t=qt.map(s=>({label:s,value:s}));function Bt(){var l,m,x,g,j,d,h,E,D,b,T,k,w,y,I,O,u,R;const s=e.useEditorStore(p=>p.card),n=(m=(l=s==null?void 0:s.preferences)==null?void 0:l.mapVisualOptions)==null?void 0:m.topoJsonUrl,[t,r]=S.useState(((g=(x=s==null?void 0:s.preferences)==null?void 0:x.mapVisualOptions)==null?void 0:g.customTopoJsonUrl)||""),{setCardPreferences:o}=e.useEditorActions(),{data:a}=e.useTopoJson(s),i=Object.keys((a==null?void 0:a.objects)||{}).map(p=>({label:p,value:p}))||[],c=[{label:"US States 10m",value:"https://unpkg.com/us-atlas/states-10m.json"},{label:"Countries 50m",value:"https://unpkg.com/world-atlas/countries-50m.json"},{label:"Custom",value:"custom"}];return e.jsxRuntimeExports.jsxs("div",{className:"p-6",children:[e.jsxRuntimeExports.jsx(fe,{summary:"Map Query",children:e.jsxRuntimeExports.jsx("p",{className:"rounded-md bg-muted p-2 font-mono text-xs",children:"SELECT country, value FROM table"})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),e.jsxRuntimeExports.jsx(fe,{open:!0,summary:"Settings",children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-3 px-2",children:[e.jsxRuntimeExports.jsx(Z,{className:"h-9",options:c,onValueChange:p=>{console.log("value",p),o({...s.preferences,mapVisualOptions:{topoJsonUrl:p}})},value:n||"",label:"Select Map"}),n==="custom"&&e.jsxRuntimeExports.jsx(e.Input,{onChange:p=>{r(p.target.value)},onBlur:()=>{var p;console.log("onBlur",t),o({...s.preferences,mapVisualOptions:{...(p=s.preferences)==null?void 0:p.mapVisualOptions,customTopoJsonUrl:t}})},value:t,className:`h-9 w-full ${e.removeRing}`,placeholder:"Custom URL"}),a&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Map Object"}),e.jsxRuntimeExports.jsx(Z,{className:"h-9",options:i,value:((d=(j=s.preferences)==null?void 0:j.mapVisualOptions)==null?void 0:d.objectKey)||"",label:"Map Object",onValueChange:p=>{var N;o({...s.preferences,mapVisualOptions:{...(N=s.preferences)==null?void 0:N.mapVisualOptions,objectKey:p}})}})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Projection"}),e.jsxRuntimeExports.jsx(Z,{className:"h-9",options:Vt,value:((E=(h=s.preferences)==null?void 0:h.mapVisualOptions)==null?void 0:E.projection)||"",label:"Projection",onValueChange:p=>{var N;o({...s.preferences,mapVisualOptions:{...(N=s.preferences)==null?void 0:N.mapVisualOptions,projection:p}})}})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Colors"}),e.jsxRuntimeExports.jsx(Z,{className:"h-9",options:_t,value:((b=(D=s.preferences)==null?void 0:D.mapVisualOptions)==null?void 0:b.colorScale)||"",label:"Select Color Scale",onValueChange:p=>{var N;o({...s.preferences,mapVisualOptions:{...(N=s.preferences)==null?void 0:N.mapVisualOptions,colorScale:p}})}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),e.jsxRuntimeExports.jsx(fe,{className:"",summary:"Scale Options",children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Input,{className:`h-9 w-full ${e.removeRing}`,type:"number",step:.1,value:((k=(T=s.preferences)==null?void 0:T.mapVisualOptions)==null?void 0:k.projectionScale)||1,onChange:p=>{var N;o({...s.preferences,mapVisualOptions:{...(N=s.preferences)==null?void 0:N.mapVisualOptions,projectionScale:Number(p.target.value)}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"X"}),e.jsxRuntimeExports.jsx(e.Input,{className:`h-9 w-full ${e.removeRing}`,type:"number",step:10,value:((I=(y=(w=s.preferences)==null?void 0:w.mapVisualOptions)==null?void 0:y.projectionOffset)==null?void 0:I[0])||0,onChange:p=>{var N,z,M,q;o({...s.preferences,mapVisualOptions:{...(N=s.preferences)==null?void 0:N.mapVisualOptions,projectionOffset:[Number(p.target.value),((q=(M=(z=s.preferences)==null?void 0:z.mapVisualOptions)==null?void 0:M.projectionOffset)==null?void 0:q[1])||0]}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Y"}),e.jsxRuntimeExports.jsx(e.Input,{className:`h-9 w-full ${e.removeRing}`,type:"number",step:10,value:((R=(u=(O=s.preferences)==null?void 0:O.mapVisualOptions)==null?void 0:u.projectionOffset)==null?void 0:R[1])||0,onChange:p=>{var N,z,M,q;o({...s.preferences,mapVisualOptions:{...(N=s.preferences)==null?void 0:N.mapVisualOptions,projectionOffset:[((q=(M=(z=s.preferences)==null?void 0:z.mapVisualOptions)==null?void 0:M.projectionOffset)==null?void 0:q[0])||0,Number(p.target.value)]}})}})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),e.jsxRuntimeExports.jsx(ae,{})]})}function Ht(){var r;const s=e.useEditorStore(o=>o.card.preferences),{setCardPreferences:n}=e.useEditorStore(o=>o.actions);function t(o){n({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:o==="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 Se({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(De,{}),s!=="text"&&e.jsxRuntimeExports.jsx(Pe,{}),s==="text"&&e.jsxRuntimeExports.jsx(Ht,{})]})]}),!["range","text"].includes(s)&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ae,{}),e.jsxRuntimeExports.jsx(me,{})]})]})]})})}function Pt(){const s=e.useEditorStore(r=>{var o,a;return(a=(o=r==null?void 0:r.card)==null?void 0:o.preferences)==null?void 0:a.sortChart}),{setSortChart:n}=e.useEditorActions();function t(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Sort"}),e.jsxRuntimeExports.jsx(Z,{className:"h-8",label:"Sort Chart",options:[{label:"None",value:"none"},{label:"ASC",value:"asc"},{label:"DESC",value:"desc"}],value:s||"none",onValueChange:r=>{n(r)}})]})}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:r=>r.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(De,{}),t(),e.jsxRuntimeExports.jsx(qs,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ae,{}),e.jsxRuntimeExports.jsx(me,{})]})]})]})})}function Gt({}){const s=e.useEditorStore(r=>{var o;return(o=r.card)==null?void 0:o.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:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ae,{}),e.jsxRuntimeExports.jsx(me,{})]})]})}),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 $t=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."]})]}),Qt=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."]})]}),Ut=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 Jt(){const s=e.useEditorStore(t=>t.card.type);function n(t){switch(t){case"stackedBar":case"stackedLine":return e.jsxRuntimeExports.jsx(Pt,{});case"pyramid":return e.jsxRuntimeExports.jsx(Se,{docContent:$t,cardType:t});case"kpi":return e.jsxRuntimeExports.jsx(Mt,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(Dt,{cardType:t});case"range":return e.jsxRuntimeExports.jsx(Se,{docContent:Qt,cardType:t});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(Se,{cardType:t});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(Lt,{cardType:t});case"table":return e.jsxRuntimeExports.jsx(Gt,{cardType:t});case"text":return e.jsxRuntimeExports.jsx(Se,{docContent:Ut,cardType:t,suffix:"Visual"});case"map":return e.jsxRuntimeExports.jsx(Bt,{});case"custom":return e.jsxRuntimeExports.jsx(Nt,{});default:return e.jsxRuntimeExports.jsx(Ot,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:n(s)})}function Kt(){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(pt,{})}),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(Jt,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(Je,{})})]}):e.jsxRuntimeExports.jsx(Je,{})})]})}function Wt({authToken:s,onSave:n,onClose:t}){e.useDashboardStore(i=>i.themeStyle);const r=e.useEditorStore(i=>i.actions.setOnSave),o=e.useEditorStore(i=>i.actions.setOnClose),a=e.useDashboardStore(i=>i.actions.setAuthToken);return S.useEffect(()=>{n&&r(n),t&&o(t)},[n,r,t,o]),S.useEffect(()=>{s&&s.accessToken&&a(s)},[s,a]),e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:e.jsxRuntimeExports.jsxs(e.EditorPanel,{style:{},className:"rounded-none",role:"editor-panel",children:[e.jsxRuntimeExports.jsx(e.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsxRuntimeExports.jsx(Ss,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(Kt,{})})]})})}function Yt(){e.useDashboardStore(i=>i.selectedCardId);const s=e.useDashboardStore(i=>i.selectedSheetId),{setIsVisualEditing:n}=e.useDashboardStore(i=>i.actions),t=e.useDashboardStore(i=>i.isVisualEditing),r=e.useDashboardStore(i=>i.actions.updateFrame);function o(i){s&&(r(s,i),n(!1))}function a(){n(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{"max-h-0 overflow-hidden":!t}),children:e.jsxRuntimeExports.jsx(Wt,{onSave:o,onClose:a})})}function Xt(){e.useEditorStore(i=>i.selectedConnectionId),e.useEditorStore(i=>i.selectedDatamodelId);const s=e.useEditorStore(i=>i.selectedDatabaseName);e.useEditorStore(i=>i.selectedSchemaName);const n=e.useEditorStore(i=>i.selectedTableName),t=e.useDashboardStore(i=>i.dashboard.filters)||[];e.useDashboardStore(i=>i.actions.addFilter),e.useDashboardStore(i=>i.actions.removeFilter),e.useDashboardStore(i=>i.actions.removeFilterValue);const{modelItems:r,columns:o}=ie(),{assignFilter:a}=_s();return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:o==null?void 0:o.map(i=>{const c=t==null?void 0:t.find(l=>l.column===e.fmt(i.column_name)&&l.table===n&&l.database===s);return e.jsxRuntimeExports.jsx("div",{onClick:()=>a(i),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":c}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(vs,{column:i}),e.jsxRuntimeExports.jsx("span",{children:i.column_name})]})},i.column_name)})})}function Zt(){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(Ss,{ColumnsComponent:()=>e.jsxRuntimeExports.jsx(Xt,{})})})]})}function en(){const s=e.useDashboardStore(t=>t.showFilters),n=e.useDashboardStore(t=>t.isVisualEditing);return e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("",{"max-h-0 overflow-hidden":n,"flex grow":!n}),children:[e.jsxRuntimeExports.jsx(e.DashboardTabs,{}),s&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(Zt,{})})]})}function sn(){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 tn({showControls:s=!1,showFooter:n=!0,...t}){return e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:t,children:[e.jsxRuntimeExports.jsx(e.Te,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(sn,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...t,children:[s&&e.jsxRuntimeExports.jsx(Ws,{}),e.jsxRuntimeExports.jsx(Yt,{}),e.jsxRuntimeExports.jsx(en,{})]})]})]})})}exports.Box=We;exports.ChartArea=Ye;exports.ChartColumnIncreasing=we;exports.ChartLine=ke;exports.ChartNoAxesGantt=Oe;exports.ChartPie=ze;exports.ChartScatter=Fe;exports.CircleX=Xe;exports.CopyPlus=Ze;exports.DashboardPlus=tn;exports.Database=es;exports.EllipsisVertical=Me;exports.Eraser=ss;exports.Eye=ns;exports.EyeClosed=ts;exports.Glasses=rs;exports.Hammer=os;exports.Hash=is;exports.House=as;exports.Key=Ve;exports.ListEnd=ls;exports.ListStart=cs;exports.ListX=xs;exports.LoaderCircle=de;exports.Map=qe;exports.MessageSquareMore=us;exports.Network=ds;exports.Pencil=_e;exports.Play=ms;exports.Plug2=ps;exports.Save=js;exports.SelectComponent=ue;exports.Shapes=Be;exports.ShieldQuestion=hs;exports.Sigma=Es;exports.SwatchBook=fs;exports.Tag=gs;exports.ToggleLeft=Rs;exports.Type=Ie;exports.User=bs;exports.cleanCard=ys;exports.getDashbaordStateWithoutData=He;exports.useEditorAside=ie;
245
+ Visual Query Syntax: ${rt}`,{data:I,isLoading:O,isFetching:u,isError:R,refetch:p}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(l==null?void 0:l.accessToken)||"",{user_content:`userContent: ${w} ${m?y:""}`}),enabled:!1});function N(C){if(C.toLowerCase().includes("bar"))h("bar");else if(C.toLowerCase().includes("line"))h("line");else if(C.toLowerCase().includes("bubble"))h("bubble");else if(C.toLowerCase().includes("scatter"))h("scatter");else if(C.toLowerCase().includes("stacked"))h("stackedBar");else if(C.toLowerCase().includes("pie"))h("pie");else if(C.toLowerCase().includes("donut")||C.toLowerCase().includes("doughnut"))h("doughnut");else if(C.toLowerCase().includes("radar"))h("radar");else return h("bar"),!1;return!0}S.useEffect(()=>{I&&D(C=>[...C,{role:"ai",content:I.response}])},[I]),S.useEffect(()=>{const C=setTimeout(()=>{var F;c.current&&(c.current.scroll({top:c.current.scrollHeight,behavior:"smooth"}),(F=i.current)==null||F.focus())},100);return()=>clearTimeout(C)},[E]);function z(){t&&(D(C=>[...C,{role:"user",content:t}]),N(t)&&x(!0),r(""),p())}S.useEffect(()=>{o&&(z(),a(!1))},[o,a]);const M={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},q={fontFamily:"monospace",fontSize:14,lineHeight:1.6},B={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},J={p:({node:C,...F})=>e.jsxRuntimeExports.jsx("p",{style:M,...F}),code:({node:C,...F})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...F}),pre:({node:C,...F})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:q,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:F.children}),e.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:_,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:P=>{const A=_(P);A&&(n(!1),g(A),d(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:C,...F})=>e.jsxRuntimeExports.jsx("li",{style:B,...F})};function _(C){const F=C.currentTarget.closest("pre");if(!F)return;const P=F.textContent||F.innerText;return navigator.clipboard.writeText(P).then(()=>console.log("Text copied to clipboard")).catch(A=>console.error("Error in copying text: ",A)),P}function U(){return E==null?void 0:E.map((C,F)=>C.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(bs,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:C.content})]},F):C.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:J,children:I==null?void 0:I.response.replace(/DuckDB/gi,"Semaphor")},F):e.jsxRuntimeExports.jsx("div",{},F))}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:c,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:U()})}),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:i,onKeyDown:C=>{C.key==="Enter"&&!C.shiftKey&&(C.preventDefault(),r(""),z())},placeholder:"Type your question here...",onFocus:C=>{const F=C.target,P=F.value.length;F.setSelectionRange(P,P)},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:O||u,value:t,onChange:C=>r(C.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:z,children:!O&&!u?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(de,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var Cs={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Qe=S.createContext&&S.createContext(Cs),it=["attr","size","title"];function at(s,n){if(s==null)return{};var t=lt(s,n),r,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(s);for(o=0;o<a.length;o++)r=a[o],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(s,r)&&(t[r]=s[r])}return t}function lt(s,n){if(s==null)return{};var t={},r=Object.keys(s),o,a;for(a=0;a<r.length;a++)o=r[a],!(n.indexOf(o)>=0)&&(t[o]=s[o]);return t}function Ce(){return Ce=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},Ce.apply(this,arguments)}function Ue(s,n){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(s);n&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(s,o).enumerable})),t.push.apply(t,r)}return t}function Ne(s){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?Ue(Object(t),!0).forEach(function(r){ct(s,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Ue(Object(t)).forEach(function(r){Object.defineProperty(s,r,Object.getOwnPropertyDescriptor(t,r))})}return s}function ct(s,n,t){return n=xt(n),n in s?Object.defineProperty(s,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[n]=t,s}function xt(s){var n=ut(s,"string");return typeof n=="symbol"?n:String(n)}function ut(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 Ns(s){return s&&s.map((n,t)=>S.createElement(n.tag,Ne({key:t},n.attr),Ns(n.child)))}function ee(s){return n=>S.createElement(dt,Ce({attr:Ne({},s.attr)},n),Ns(s.child))}function dt(s){var n=t=>{var{attr:r,size:o,title:a}=s,i=at(s,it),c=o||t.size||"1em",l;return t.className&&(l=t.className),s.className&&(l=(l?l+" ":"")+s.className),S.createElement("svg",Ce({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,r,i,{className:l,style:Ne(Ne({color:s.color||t.color},t.style),s.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),a&&S.createElement("title",null,a),s.children)};return Qe!==void 0?S.createElement(Qe.Consumer,null,t=>n(t)):n(Cs)}function mt(s){return ee({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 pt(){const[s,n]=S.useState({queryKey:[],queryData:null}),{theme:t}=e.useTheme(),r=e.useQueryClient(),o=S.useRef(),a=S.useRef(),[i,c]=S.useState(!1),[l,m]=S.useState(!1),[x,g]=S.useState(!1),[j,d]=S.useState(""),[h,E]=S.useState(!1),D=e.useDashboardStore(f=>f.selectedSheetId);e.useDashboardStore(f=>f.dashboard.baseQueries);const b=e.useEditorStore(f=>f.card),T=e.useDashboardStore(f=>f.theme),k=e.useEditorStore(f=>f.isShowingVisual);e.useDashboardStore(f=>f.onAcceptChanges);const w=e.useEditorStore(f=>f.selectedConnectionId),y=e.useEditorStore(f=>f.selectedDatabaseName),I=e.useEditorStore(f=>f.selectedDatamodelId),O=e.useEditorStore(f=>f.selectedSchemaName);e.useDashboardStore(f=>f.actions.updateFrameCard);const u=e.useEditorStore(f=>f.selectedTableName),R=e.useEditorStore(f=>f.card.sql),p=e.useEditorStore(f=>f.card.python),N=e.useEditorStore(f=>f.frame),z=e.useDashboardStore(f=>f.dashboard.filters),M=e.useDashboardStore(f=>f.filterValues),q=z==null?void 0:z.filter(f=>f.sheetId===D||!f.sheetId),B=M==null?void 0:M.filter(f=>(q==null?void 0:q.some(Q=>Q.id===f.filterId))||f.filterId.endsWith(D)),J=e.useEditorStore(f=>f.applyFilters),{setCardCustomCfg:_,setQueryResultColumns:U,setFilterValues:C,setCardSql:F,setCard:P,setCardPython:A,setQueryError:L,setPythonStdOut:G,setCardPreferences:V}=e.useEditorStore(f=>f.actions),H=e.useEditorStore(f=>f.onSave),K=e.useEditorStore(f=>f.actions.setApplyFilters),se=e.useEditorStore(f=>f.onClose),le=e.useEditorStore(f=>f.actions.setSqlGen),te=e.useEditorStore(f=>f.runSql),re=e.useEditorStore(f=>f.actions.setRunSql);e.useEditorStore(f=>f.actions.setCardCfg);const ne=e.useEditorStore(f=>f.actions.setIsSqlRunning),{data:$,isLoading:Y,isFetching:X,isSuccess:ge,isError:ce,error:pe,queryKey:je,refetch:xe}=e.useDashboardCardQuery(b);S.useEffect(()=>{if($&&($.rowLimitExceeded&&e.Jt.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),G(($==null?void 0:$.output)||""),$.records.length>0)){const{dimensionKeys:f}=e.getKeys($.records);U(f)}},[$,U,G]),S.useEffect(()=>{(Y||X)&&ne(!0),(ce||ge)&&ne(!1),ce?(L(pe.message),U([]),G("")):L("")},[Y,X,$,G,ce,ge,ne,U,L,pe]),S.useEffect(()=>{te&&(xe(),re(!1))},[te,xe,re]);function Le(){const f=r.getQueryData(je);s.queryData||n({queryKey:je,queryData:f}),r.setQueryData(je,null),F(""),le({}),_(""),V({})}const he=f=>{a.current=f};function Re(f,Q){if(f.length===0)return"";if(Q){const oe=f.find(W=>W.id===Q);if(oe){const W=oe.tabTitle;if(W=="All__Header")return f[0].id;if(W&&W.endsWith("__Header")){const Hs=W.split("__")[0],Ge=f.find(Ps=>Ps.tabTitle===Hs);return Ge?Ge.id:f[0].id}return Q}}return f[0].id}function be(){let f=R;R&&!R.includes("{{")&&(f=Zs(R),F(f));const Q={...b,lastSelectedSchema:O,lastSelectedDatamodelId:I,lastSelectedDatabase:y,lastSelectedTable:u,connectionId:w,type:k?b.type:"table",sql:f,customCfg:k?b.customCfg:null},oe=N.cards.map(Te=>Te.id===b.id?Q:Te),W={...N,cards:oe,activeCardId:Re(oe,N.activeCardId)};H==null||H(W)}function ye(){const{queryKey:f,queryData:Q}=s;f&&Q&&r.setQueryData(f,Q),se==null||se()}S.useEffect(()=>{const f=o.current,Q=a.current;if(f){const oe=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",W=T==="system"?oe:T;f.editor.defineTheme("default",{base:W==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":W==="light"?"#ffffff":e.getCssVariableValue("--semaphor-background")}}),f.editor.setTheme("default")}return Q&&f&&Q.addCommand(f.KeyMod.Shift|f.KeyCode.Enter,function(){return console.log("Executing query..."),xe(),!1}),()=>{}},[t,T,o.current]);function Ee(f){o.current=f}function v(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[l&&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(st,{checked:J,onCheckedChange:()=>K(!J),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(nt,{}),B&&l&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>m(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:f=>{if(f)try{JSON.parse(f),C(JSON.parse(f))}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&&!l&&e.jsxRuntimeExports.jsx(e.Filter,{onClick:()=>m(!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":J})})]})}function Bs(){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:i?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:f=>{F(f)},value:R,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",beforeMount:Ee,onMount:he})}),i&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),i&&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:f=>{A(f&&f.trim()||"")},value:p||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:Ee,onMount:he})}),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:[Bs(),v()]}),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:Y||X,onClick:()=>{xe()},className:"shrink-0",size:"sm",variant:"outline",children:[Y||X?e.jsxRuntimeExports.jsx(de,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(ms,{className:"mr-2 h-4 w-4"}),"Run"]}),ce&&e.jsxRuntimeExports.jsx(et,{error:pe.message,setShowAIDialog:g,setTriggerAIRun:E,setUserInputforAI:d}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:Le,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(ss,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:i,onPressedChange:f=>c(f),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(mt,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(ot,{open:x,setOpen:g,userInput:j,triggerAIRun:h,setTriggerAIRun:E,setUserInput:f=>d(f)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:be,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:ye,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function jt({data:s}){var i;const[n,t]=S.useState([]),o=Object.keys(s[0]).map(c=>({accessorKey:c,header:({column:l})=>{const m=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:[c,m==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):m==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),a=e.useReactTable({data:s,columns:o,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(c=>e.jsxRuntimeExports.jsx(e.TableRow,{children:c.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))},c.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(i=a.getRowModel().rows)!=null&&i.length?a.getRowModel().rows.map(c=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":c.getIsSelected()&&"selected",children:c.getVisibleCells().map(l=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(l.column.columnDef.cell,l.getContext())},l.id))},c.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:o.length,className:"h-24 text-center",children:"No results."})})})]})}function ht({card:s}){var x,g,j,d,h,E,D,b,T,k;const n=e.useDashboardStore(w=>w.themeStyle),t={colors:((g=(x=n==null?void 0:n.chart)==null?void 0:x.dataset)==null?void 0:g.backgroundColor)||[]};(j=s.customCardPreferences)!=null&&j.inputData;const{getCard:r}=e.useCustomVisual(((d=s.customCardPreferences)==null?void 0:d.url)||""),o=((h=s.customCardPreferences)==null?void 0:h.visualType)||"single",a=e.useEditorStore(w=>w.frame);e.useEditorActions();const{data:i}=e.useDashboardCardQuery(s);if(!((E=s.customCardPreferences)!=null&&E.componentName))return null;const c=r((D=s.customCardPreferences)==null?void 0:D.componentName),l=w=>{console.log("data",w),s.customCardPreferences},m=Object.keys(((b=s.customCardPreferences)==null?void 0:b.dataInputCardIds)||{}).map(w=>{var O,u,R;const y=(u=(O=s.customCardPreferences)==null?void 0:O.dataInputCardIds)==null?void 0:u[w].cardId,I=(R=a==null?void 0:a.cards)==null?void 0:R.find(p=>p.id===y);return I||null});return e.jsxRuntimeExports.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:e.jsxRuntimeExports.jsxs(S.Suspense,{fallback:e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),children:[c&&o==="single"&&e.jsxRuntimeExports.jsx(c,{theme:t,settings:(T=s.customCardPreferences)==null?void 0:T.settings,onDataChange:l,data:(i==null?void 0:i.records)||[]}),c&&o==="multiple"&&e.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-2",children:e.jsxRuntimeExports.jsx(c,{theme:t,onDataChange:l,settings:m.map(w=>{var y;return(y=w==null?void 0:w.customCardPreferences)==null?void 0:y.settings}),data:m.map(w=>(w==null?void 0:w.data)||[])})})]},(k=s.customCardPreferences)==null?void 0:k.componentName)})}function ws({className:s,...n}){var d,h;const t=e.useEditorStore(E=>E.card),r=((d=t.customCardPreferences)==null?void 0:d.showCardHeader)??!0,o=e.useEditorStore(E=>E.frame),a=e.useDashboardStore(E=>E.dashboard.filters);e.useEditorStore(E=>E.actions.setRunSql);const{updateFilter:i}=e.useDashboardActions(),c=a==null?void 0:a.find(E=>E.id===o.filterId),{data:l}=e.useDashboardCardQuery(t),{setCard:m}=e.useEditorActions(),{data:x}=e.useTopoJson(t);if(!t.id)return null;let g;l!=null&&l.records&&(l==null?void 0:l.records.length)>0&&(g=e.createChartConfig({data:l==null?void 0:l.records,cardType:t.type,cfg:t.cfg,customCfg:t.customCfg,preferences:t.preferences,topoJson:x}));function j(E){return e.jsxRuntimeExports.jsx(ht,{card:E})}return e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",s),...n,children:[r&&e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"flex flex-row items-start justify-between py-4",children:[e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsx(e.Editable,{text:t.title,onSave:E=>m({...t,title:E}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-5",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:t.title||"Edit title..."})})},t.title),e.jsxRuntimeExports.jsx(e.Editable,{text:t.description||"",onSave:E=>m({...t,description:E}),children:e.jsxRuntimeExports.jsx(e.CardDescription,{children:t.description||"Edit description..."})},t.description)]}),c&&e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Editable,{className:"my-1",text:c.title||c.column,onSave:E=>i({...c,title:E}),children:e.jsxRuntimeExports.jsx(e.Label,{children:c.title})}),e.getFilterComponent(c)]})]}),e.jsxRuntimeExports.jsxs(e.CardContent,{className:"flex grow flex-col",children:[t.type==="custom"&&j(t),!["table","custom"].includes(t.type)&&g&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:g},JSON.stringify(g)+JSON.stringify(t.preferences)+((h=t==null?void 0:t.preferences)==null?void 0:h.customVisualCode)),t.type==="table"&&(l==null?void 0:l.records)&&(l==null?void 0:l.records.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:t,data:l==null?void 0:l.records})})]})]})}function Et(){const[s,n]=S.useState(!1),[t,r]=S.useState(""),[o,a]=S.useState(""),[i,c]=S.useState(""),[l,m]=S.useState(""),x=e.useEditorStore(y=>y.card),g=e.useEditorStore(y=>y.card.customCfg),{data:j}=e.useDashboardCardQuery(x),{data:d}=e.useTopoJson(x),{setCardCustomCfg:h,setCustomVisualCode:E}=e.useEditorActions();function D(y){var u,R;const I={...y,data:{...y==null?void 0:y.data,datasets:(R=(u=y==null?void 0:y.data)==null?void 0:u.datasets)==null?void 0:R.map(p=>({...p,data:[]}))}};return JSON.stringify(I,null,1)}function b(){var I,O;if(!(j!=null&&j.records)||(j==null?void 0:j.records.length)===0)return;const y=e.createChartConfig({data:j==null?void 0:j.records,cardType:x.type,cfg:x.cfg,preferences:x.preferences,topoJson:d});y&&(r(JSON.stringify(y,null,1)),(I=x==null?void 0:x.preferences)!=null&&I.customVisualCode&&c((O=x==null?void 0:x.preferences)==null?void 0:O.customVisualCode),g&&a(JSON.stringify(g,null,1)))}function T(){if(i&&E(i),!!o)try{const y=JSON.parse(o);return y?(h(y),m(""),a(""),y):void 0}catch(y){console.log(y),m("Invalid JSON")}}function k(){a(""),h(null)}function w(){let y;if(g){const I=e._.cloneDeep(x.cfg),O=e._.merge(I,g);return y=D(O),y}return t?(y=D(JSON.parse(t)),y):""}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:b,className:` ${g&&"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(Ve,{onClick:()=>{navigator.clipboard.writeText(x.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(e.ErrorBoundary,{FallbackComponent:e.FallbackEditorCard,children:e.jsxRuntimeExports.jsx(ws,{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:[g&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),g?"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:w(),onChange:y=>a(y)})}),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:i,onChange:y=>c(y||"")})})]})]}),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:!g,onClick:k,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:T,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>n(!1),variant:"outline",children:"Close"})]})]})]})}function ks(s){return ee({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 Is(s){return ee({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 Ds(s){return ee({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 Ls(s){return ee({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 Ts(s){return ee({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 As(s){return ee({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 Os(s){return ee({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 zs(s){return ee({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 Fs(s){const[n,t]=S.useState(null);return S.useEffect(()=>{s&&(async()=>{const a=(await Promise.resolve().then(()=>require("./lucide-react-gzKKmZHH.js")))[s];t(a)})()},[s]),n}function Ms(){const{authToken:s}=e.useSemaphorContext(),{data:n,isLoading:t,isFetching:r,isError:o}=e.useQuery({queryKey:["plugins",s==null?void 0:s.accessToken],queryFn:()=>e.getPlugins(s==null?void 0:s.accessToken)});return{data:n,isLoading:t,isFetching:r,isError:o}}function ft({onChartTypeChange:s}){const[n,t]=S.useState([]),{data:r}=Ms();return S.useEffect(()=>{(async()=>{var a;if(r){const c=(await Promise.all((a=r==null?void 0:r.plugins)==null?void 0:a.map(async l=>(await e.loadManifest(l.value)).visuals.map(g=>({name:g.name,icon:g.icon,url:l.value}))))).flat();t(c)}})()},[r]),n.length===0?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.Separator,{className:"my-2"}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-4 place-items-center",children:n.map((o,a)=>e.jsxRuntimeExports.jsx(gt,{text:o.name,onClick:()=>s("custom",o),icon:o.icon},o.url+o.name+a))})]})}const gt=({text:s,icon:n,onClick:t})=>{const r=Fs(n||""),o=s.charAt(0).toUpperCase();return e.jsxRuntimeExports.jsx(e.Button,{onClick:t,title:s,variant:"ghost",children:r?e.jsxRuntimeExports.jsx(r,{className:"h-4 w-4"}):o})};function Rt(){var x,g;const[s,n]=S.useState(!1),t=e.useEditorStore(j=>j.card),r=t.type,{setCardType:o,setCardPreferences:a,setChartOrientation:i}=e.useEditorStore(j=>j.actions),{setCardCustomCfg:c,setCustomCardPreferences:l}=e.useEditorActions();function m(j,d){c(null),a({}),o(j),d&&l({type:"component",visualType:"single",url:d.url,componentName:d.name,icon:d.icon}),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(bt,{className:"h-4 w-4",chartType:r,customIcon:(x=t.customCardPreferences)==null?void 0:x.icon,componentName:(g=t.customCardPreferences)==null?void 0:g.componentName})})}),e.jsxRuntimeExports.jsxs(e.PopoverContent,{className:"w-50",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-4 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(we,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ke,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(As,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ts,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Fe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ls,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ze,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Is,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ks,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ds,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(zs,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Oe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Os,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ie,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("map"),variant:"ghost",children:e.jsxRuntimeExports.jsx(qe,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("custom"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Be,{className:"size-4"})})]}),e.jsxRuntimeExports.jsx(ft,{onChartTypeChange:m})]})]})}function bt({chartType:s,className:n,customIcon:t,componentName:r}){const o=Fs(t||"");switch(s){case"bar":return e.jsxRuntimeExports.jsx(we,{className:n});case"line":return e.jsxRuntimeExports.jsx(ke,{className:n});case"pie":return e.jsxRuntimeExports.jsx(ze,{className:n});case"radar":return e.jsxRuntimeExports.jsx(ks,{className:n});case"scatter":return e.jsxRuntimeExports.jsx(Fe,{className:n});case"bubble":return e.jsxRuntimeExports.jsx(Ls,{className:n});case"doughnut":return e.jsxRuntimeExports.jsx(Is,{className:n});case"stackedBar":return e.jsxRuntimeExports.jsx(As,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(Ts,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(Ds,{className:n});case"pyramid":return e.jsxRuntimeExports.jsx(zs,{className:n});case"range":return e.jsxRuntimeExports.jsx(Oe,{className:n});case"kpi":return e.jsxRuntimeExports.jsx(Os,{className:n});case"text":return e.jsxRuntimeExports.jsx(Ie,{className:n});case"map":return e.jsxRuntimeExports.jsx(qe,{className:n});case"custom":return t&&o?e.jsxRuntimeExports.jsx(o,{className:n}):r?r==null?void 0:r.charAt(0).toUpperCase():e.jsxRuntimeExports.jsx(Be,{className:n});default:return e.jsxRuntimeExports.jsx(e.Table,{className:n})}}function yt(){var o;const s=e.useEditorStore(a=>a.card),n=((o=s.customCardPreferences)==null?void 0:o.showCardHeader)??!0,{setCustomCardPreferences:t}=e.useEditorActions(),r=a=>{s.customCardPreferences&&t({...s.customCardPreferences,showCardHeader:a===!0})};return e.jsxRuntimeExports.jsxs(e.DropdownMenu,{children:[e.jsxRuntimeExports.jsx(e.DropdownMenuTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(Me,{className:"size-4 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsxs(e.DropdownMenuContent,{align:"start",className:"w-40 text-muted-foreground",children:[e.jsxRuntimeExports.jsx(e.DropdownMenuCheckboxItem,{checked:n,onCheckedChange:r,children:"Card Header"}),e.jsxRuntimeExports.jsxs(e.DropdownMenuItem,{onClick:()=>{navigator.clipboard.writeText(s.id),e.Jt.success("Card ID copied to clipboard")},className:"cursor-pointer space-x-2",children:[e.jsxRuntimeExports.jsx(Ve,{className:"size-4"}),e.jsxRuntimeExports.jsx("span",{children:"Copy Card ID"})]})]})]})}function Je(){const s=e.useEditorStore(u=>u.frame),n=e.useEditorStore(u=>u.card),t=e.useEditorStore(u=>u.isShowingVisual),r=e.useEditorStore(u=>u.isSqlRunning),o=e.useEditorStore(u=>u.queryError),a=e.useEditorStore(u=>u.pythonStdOut),i=e.useEditorStore(u=>u.actions.setRunSql);e.useEditorStore(u=>u.onSave),e.useEditorStore(u=>u.onClose),e.useEditorStore(u=>u.actions.setCardSql),e.useEditorStore(u=>u.actions.setCardType),e.useEditorStore(u=>u.actions.setSqlGen);const{setFrame:c,setCard:l,updateCardInFrame:m}=e.useEditorActions(),{data:x,isLoading:g,isFetching:j}=e.useDashboardCardQuery(n);if(!n)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function d(){const u={connectionId:n.connectionId,id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]};h(u)}function h(u){const R={...s,cards:[...s.cards,u],activeCardId:u.id};c(R),l(u)}function E(){const u={...n,id:e.v4(),title:`${n.title} Copy`,tabTitle:`${n.tabTitle} Copy`};h(u)}function D(u){const R=s.cards.filter(z=>z.id!==u),p=R[0],N={...s,cards:R,activeCardId:p.id};c(N),l(p)}function b(u){const R={...s,cards:s.cards.map(N=>N.id===n.id?n:N),activeCardId:u};c(R);const p=R.cards.find(N=>N.id===u);p.sql&&i(!0),l(p)}const T=(u,R)=>{console.log("handleDragStart",R),u.dataTransfer.setData("tabIndex",R.toString())},k=u=>{u.preventDefault()},w=(u,R)=>{const p=u.dataTransfer.getData("tabIndex");if(p===R.toString())return;const N=Array.from(s.cards),[z]=N.splice(parseInt(p),1);N.splice(R,0,z),c({...s,cards:N})};function y(u,R){return u.cards.length===1&&(R.displayTab===!0||R.displayTab===void 0)||u.activeCardId!==R.id&&(R.displayTab===!0||R.displayTab===void 0)?null:e.jsxRuntimeExports.jsx("div",{onClick:()=>{const p=R.displayTab===void 0?!1:!R.displayTab;l({...R,displayTab:p}),m({...R,displayTab:p})},children:R.displayTab===!0||R.displayTab===void 0?e.jsxRuntimeExports.jsx(ns,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"}):e.jsxRuntimeExports.jsx(ts,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"})})}function I(){return e.jsxRuntimeExports.jsxs(e.Tabs,{onValueChange:b,value:s.activeCardId,className:"flex grow flex-col",children:[s.cards.map(u=>e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow",value:u.id,children:O()},u.id)),e.jsxRuntimeExports.jsx(e.TabsList,{className:"group mx-6 justify-between",children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[s.cards.map((u,R)=>e.jsxRuntimeExports.jsx(e.Editable,{text:u.tabTitle||u.title,onSave:p=>{l({...n,tabTitle:p}),m({...n,tabTitle:p})},children:e.jsxRuntimeExports.jsxs(e.TabsTrigger,{draggable:!0,onDragStart:p=>T(p,R),onDragOver:k,onDrop:p=>w(p,R),className:"",value:u.id,children:[y(s,u),u.tabTitle||u.title,s.activeCardId===u.id&&s.cards.length>1&&e.jsxRuntimeExports.jsx(e.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>D(u.id)})]})},u.id)),e.jsxRuntimeExports.jsx(e.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:d,children:e.jsxRuntimeExports.jsx(e.Plus,{className:"h-4 w-4"})}),e.jsxRuntimeExports.jsx(e.Button,{className:"invisible ml-1 h-8 px-2 hover:bg-muted-foreground/50 group-hover:visible",variant:"outline",onClick:E,children:e.jsxRuntimeExports.jsx(Ze,{className:"h-4 w-4"})})]})})]})}function O(){return n.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.KPICard,{card:n,data:x==null?void 0:x.records})})}):n.type==="text"?e.jsxRuntimeExports.jsx("div",{className:"flex h-full 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:n,data:x==null?void 0:x.records})})}):e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.FallbackEditorCard,children:e.jsxRuntimeExports.jsx(ws,{className:"grow border-none shadow-none"})})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col py-3",children:[(g||j)&&e.jsxRuntimeExports.jsx(de,{className:"absolute bottom-0 left-0 right-0 top-0 z-50 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,{}),!["table","custom"].includes(n.type)&&e.jsxRuntimeExports.jsx(Et,{}),e.jsxRuntimeExports.jsx(yt,{})]}),e.jsxRuntimeExports.jsx(St,{})]}),t?I():e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[a&&e.jsxRuntimeExports.jsx(vt,{}),(x==null?void 0:x.records)&&(x==null?void 0:x.records.length)>0&&e.jsxRuntimeExports.jsx(jt,{data:(x==null?void 0:x.records)||[]}),o&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:o})]})]})}function vt(){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 St(){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 Ct({options:s,value:n,onValueChange:t}){return e.jsxRuntimeExports.jsx(e.RadioGroup,{value:n,onValueChange:t,className:"flex gap-4",defaultValue:s[0].value,children:s.map(r=>e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:r.value,id:r.value}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:r.value,children:r.label})]},r.value))})}function Z({label:s,options:n,value:t,onValueChange:r,className:o}){return e.jsxRuntimeExports.jsxs(e.Select,{value:t,onValueChange:r,children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:e.cn("w-full focus:ring-0 focus:ring-offset-0",o),children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:s})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:s}),n.map(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a.value,children:a.label},a.value))]})})]})}function fe({children:s,summary:n,open:t,className:r}){return e.jsxRuntimeExports.jsxs("details",{open:t,className:e.cn("space-y-4 [&_summary>svg]:open:-rotate-180",r),children:[e.jsxRuntimeExports.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-4",children:[e.jsxRuntimeExports.jsx(e.Label,{children:n}),e.jsxRuntimeExports.jsx(e.ChevronUp,{className:"h-4 w-4"})]}),e.jsxRuntimeExports.jsx("div",{className:"transition-all ease-in-out",children:s})]})}function Nt(){var E,D;const s=e.useEditorStore(b=>b.card.customCardPreferences),{data:n}=Ms(),t=(n==null?void 0:n.plugins)||[],r=e.useEditorStore(b=>b.card),o=e.useEditorStore(b=>b.frame),a=(s==null?void 0:s.visualType)||"single",{setCustomCardPreferences:i}=e.useEditorActions(),{components:c,manifest:l}=e.useCustomVisual((s==null?void 0:s.url)||""),m=(E=l==null?void 0:l.visuals)==null?void 0:E.find(b=>b.name===(s==null?void 0:s.componentName));function x(b,T){if(!s)return;const w={...(s==null?void 0:s.dataInputCardIds)||{},[b]:{cardId:T,hookRef:null}};i({...s,dataInputCardIds:w})}function g(b){var k,w;const T=(k=o==null?void 0:o.cards)==null?void 0:k.filter(y=>{var I;return((I=y==null?void 0:y.customCardPreferences)==null?void 0:I.visualType)!=="multiple"}).map(y=>({value:y.id,label:y.tabTitle||y.title}));return e.jsxRuntimeExports.jsx("div",{className:"space-y-2",children:(w=b==null?void 0:b.dataInputs)==null?void 0:w.map((y,I)=>{var O,u;return e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-10 gap-2",children:[e.jsxRuntimeExports.jsx("div",{className:"col-span-4 flex items-center",children:y}),e.jsxRuntimeExports.jsx(Z,{className:"col-span-6 h-8 w-full justify-between",label:"",options:T||[],value:((u=(O=s==null?void 0:s.dataInputCardIds)==null?void 0:O[I])==null?void 0:u.cardId)||"",onValueChange:R=>x(I,R)})]},I+Math.random())})})}function j(b,T,k=[]){var w,y;return s?b==="input"?e.jsxRuntimeExports.jsx(e.Input,{className:`h-8 w-full ${e.removeRing}`,value:((w=s==null?void 0:s.settings)==null?void 0:w[T])||"",onChange:I=>{i({...s,settings:{...s==null?void 0:s.settings,[T]:I.target.value}})}},T):b==="select"?e.jsxRuntimeExports.jsx(Z,{className:"h-8 w-full",label:"",options:k,value:((y=s==null?void 0:s.settings)==null?void 0:y[T])||"",onValueChange:I=>{i({...s,settings:{...s==null?void 0:s.settings,[T]:I}})}}):null:null}function d(b){const T=Object.entries((b==null?void 0:b.settings)||{});return e.jsxRuntimeExports.jsx("div",{className:"space-y-3",children:T.map(([k,w])=>e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:w.title}),j(w.ui,k,w.options)]},k))})}function h(b){s&&i({...s,visualType:b,componentName:""})}return e.jsxRuntimeExports.jsxs("div",{className:"p-6",children:[e.jsxRuntimeExports.jsx(fe,{summary:"Plugin Settings",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 text-sm",children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsxRuntimeExports.jsx("div",{className:"space-y-2",children:e.jsxRuntimeExports.jsx("div",{className:"px-2",children:e.jsxRuntimeExports.jsx(Z,{className:"h-8 w-full",label:"",options:t,value:(s==null?void 0:s.url)||"",onValueChange:b=>i({...s||{url:"",componentName:""},url:b})})})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&e.jsxRuntimeExports.jsx(Ct,{options:[{value:"single",label:"Single Visual"},{value:"multiple",label:"Multi-Visual"}],value:a,onValueChange:h}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&s&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Component"}),e.jsxRuntimeExports.jsx("div",{className:"space-y-2 px-2",children:c&&e.jsxRuntimeExports.jsx(Z,{className:"h-8 w-full",label:"",options:(c==null?void 0:c.filter(b=>b.type===a).map(b=>({value:b.name,label:b.name})))||[],value:s.componentName,onValueChange:b=>{console.log("changing value",b),i({...s,componentName:b})}})})]})})]})})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),((D=r==null?void 0:r.customCardPreferences)==null?void 0:D.componentName)&&e.jsxRuntimeExports.jsxs(fe,{summary:"Component Settings",children:[m&&m.dataInputs&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Input Mapping"}),e.jsxRuntimeExports.jsx("div",{className:"px-2",children:g(m)})]}),m&&m.settings&&e.jsxRuntimeExports.jsx("div",{className:"space-y-3",children:e.jsxRuntimeExports.jsx("div",{className:"px-2",children:d(m)})})]})]})}function ae(){const[s,n]=S.useState([]);e.useEditorStore(x=>x.card.cfg);const t=e.useEditorStore(x=>x.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:o,setCardPreferences:a}=e.useEditorStore(x=>x.actions),i=e.useEditorStore(x=>x.queryResultColumns);e.useEditorStore(x=>{var g;return(g=x.card.preferences)==null?void 0:g.filterOnClickColumnIndex}),S.useEffect(()=>{i&&n(new Array(i.length).fill(!1))},[i]);function c(x,g){var j,d;g?t!=null&&t.onClickFilter&&((j=t==null?void 0:t.onClickFilter)==null?void 0:j.length)>0?a({...t,onClickFilter:[...t.onClickFilter,{columnIndex:x,expression:""}]}):a({...t,onClickFilter:[{columnIndex:x,expression:""}]}):(a({...t,onClickFilter:(d=t==null?void 0:t.onClickFilter)==null?void 0:d.filter(h=>h.columnIndex!==x)}),n(h=>{const E=[...h];return E[x]=!1,E}))}function l(x,g){var d;const j=(d=t==null?void 0:t.onClickFilter)==null?void 0:d.map(h=>h.columnIndex===x?{...h,expression:g.target.value}:h);a({...t,onClickFilter:j})}function m(x){var g,j,d,h;if(s!=null&&s[x]||(j=(g=t==null?void 0:t.onClickFilter)==null?void 0:g.find(E=>E.columnIndex===x))!=null&&j.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(h=(d=t==null?void 0:t.onClickFilter)==null?void 0:d.find(E=>E.columnIndex===x))==null?void 0:h.expression,onChange:E=>l(x,E),type:"text",className:"h-9 w-full font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"Expression"})}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"On Click"}),i==null?void 0:i.map((x,g)=>{var j,d;return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 group flex items-center justify-between space-y-2",children:e.jsxRuntimeExports.jsxs("div",{className:"grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2 py-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((j=t==null?void 0:t.onClickFilter)!=null&&j.find(h=>h.columnIndex===g)),onCheckedChange:h=>c(g,h)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:x}),e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:((d=t==null?void 0:t.onClickFilter)==null?void 0:d.find(h=>h.columnIndex===g))&&e.jsxRuntimeExports.jsx(_e,{onClick:()=>{n(h=>{const E=[...h];return E[g]=!h[g],E})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),m(g)]})},x)})]})}function De(){var i,c,l;const s=e.useEditorStore(m=>m.card.preferences),n=e.useEditorStore(m=>m.card.cfg),{setCardCfg:t,setCardPreferences:r,setChartOrientation:o}=e.useEditorStore(m=>m.actions);(i=n==null?void 0:n.options)!=null&&i.indexAxis;function a(m){o(m)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((c=s==null?void 0:s.chartOptions)==null?void 0:c.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 ve="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function Ke(s,n){var r,o,a;const t=e.getNumberAxis(s,n);return((a=(o=(r=s==null?void 0:s.chartOptions)==null?void 0:r.scales)==null?void 0:o[t])==null?void 0:a.type)||"linear"}function Vs(){var J,_,U,C,F,P;const[s,n]=S.useState(!1),t=e.useEditorStore(A=>{var L;return(L=A.card)==null?void 0:L.preferences}),r=e.useEditorStore(A=>{var L;return(L=A.card)==null?void 0:L.cfg}),o=e.getNumberAxis(t,r),[a,i]=S.useState(Ke(t)),[c,l]=S.useState(((U=(_=(J=t==null?void 0:t.chartOptions)==null?void 0:J.scales)==null?void 0:_[o])==null?void 0:U.min)||""),[m,x]=S.useState(((P=(F=(C=t==null?void 0:t.chartOptions)==null?void 0:C.scales)==null?void 0:F[o])==null?void 0:P.max)||""),[g,j]=S.useState(c||m?"custom":"auto"),[d,h]=S.useState(""),[E,D]=S.useState(0),[b,T]=S.useState(""),[k,w]=S.useState(""),[y,I]=S.useState(""),O=e.useEditorStore(A=>A.actions.setCardPreferences),{updateCardInFrame:u}=e.useEditorActions(),R=e.useEditorStore(A=>A.card),p=e.useEditorStore(A=>{var L;return(L=A.card)==null?void 0:L.type}),N=["pie","doughnut","polarArea"].includes(p);S.useEffect(()=>{var A,L,G,V,H,K,se,le,te,re,ne,$,Y,X;i(Ke(t)),l(((G=(L=(A=t==null?void 0:t.chartOptions)==null?void 0:A.scales)==null?void 0:L[o])==null?void 0:G.min)===0?0:""),x(((K=(H=(V=t==null?void 0:t.chartOptions)==null?void 0:V.scales)==null?void 0:H[o])==null?void 0:K.max)||""),h(((re=(te=(le=(se=t==null?void 0:t.chartOptions)==null?void 0:se.scales)==null?void 0:le[o])==null?void 0:te.ticks)==null?void 0:re.stepSize)||""),D(((ne=t==null?void 0:t.numberAxisFormat)==null?void 0:ne.decimalPlaces)||0),T((($=t==null?void 0:t.numberAxisFormat)==null?void 0:$.suffix)||""),w(((Y=t==null?void 0:t.numberAxisFormat)==null?void 0:Y.currency)||""),I(((X=t==null?void 0:t.numberAxisFormat)==null?void 0:X.locale)||"")},[s,t,o]);function z(A,L){return L===""||/^[0-9\b]+$/.test(L)?Number(L):Number(A)}function M(){const A=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(L=>L.currency))];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.jsxs(e.Select,{value:k||"none",onValueChange:L=>w(L==="none"?"":L),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,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),A.map(L=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:L,children:L},L))]})})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:y,onValueChange:L=>I(L),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,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Locale"}),e.LOCALE_CURRENCY_PAIRS.map(L=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:L.locale,children:L.locale},L.locale))]})})]})]}),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:E,onChange:L=>D(Number(L.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${ve}`})]})]})}function q(){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:c,onChange:A=>l(L=>z(L,A.target.value)),className:`col-span-1 h-8 w-full ${ve}`}),e.jsxRuntimeExports.jsx(e.Input,{value:m,onChange:A=>x(L=>z(L,A.target.value)),id:"max",className:`col-span-1 h-8 w-full ${ve}`})]}),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:d,onChange:A=>h(L=>z(L,A.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${ve}`})]})]})}function B(){var V;let A={};g==="custom"&&(A={min:c,max:m,ticks:{stepSize:d}});const L={...t||{},chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(V=t==null?void 0:t.chartOptions)==null?void 0:V.scales,[o]:{type:a,...a==="linear"?A:{}}}},numberAxisFormat:{decimalPlaces:E,suffix:b,currency:k,locale:y}};console.log(L),O(L);const G={...R,preferences:L};u(G)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:A=>n(A),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:N,value:a,onValueChange:A=>i(A),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:N,id:"scale-option",value:g,onValueChange:A=>j(A),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"})]})]})]}),g==="custom"&&a=="linear"&&q(),M(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:B,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function wt({idx:s}){var c;const n=e.useEditorStore(l=>{var m;return(m=l.card)==null?void 0:m.preferences}),t=e.useEditorStore(l=>{var m;return(m=l.card.preferences)==null?void 0:m.datasetOptions}),r=e.useEditorStore(l=>l.actions.setCardPreferences),o=(c=n==null?void 0:n.chartOptions)==null?void 0:c.indexAxis,a=t==null?void 0:t.find(l=>l.idx===s);function i(l,m){(l==="end"||l==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const x={display:l!=="none",align:l,anchor:l,clamp:!0};if(!a)r({...n,datasetOptions:[...t||[],{idx:m,datalabels:x}]});else{const g={...a};g.datalabels=x;const j=t==null?void 0:t.map(d=>d.idx===m?g:d);r({...n,datasetOptions:j})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(gs,{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:()=>i("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:()=>i("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(ls,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(xs,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(cs,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function qs(){const s=e.useEditorStore(m=>m.card),n=e.useEditorStore(m=>{var x,g,j;return(j=(g=(x=m==null?void 0:m.card)==null?void 0:x.preferences)==null?void 0:g.chartOptions)==null?void 0:j.indexAxis}),{data:t}=e.useDashboardCardQuery(s),r=n==="y"?"Y axis":"X axis",o=n==="y"?"X axis":"Y axis",{keys:a,metricKeys:i,dimensionKeys:c}=e.getKeys((t==null?void 0:t.records)||[]);let l=i;if(["stackedBar","stackedLine"].includes(s.type)){const m=e.pivotData({dataArray:(t==null?void 0:t.records)||[],groupKey:c[0],pivotKey:c[1],valueKey:l[0]}),{metricKeys:x}=e.getKeys(m);l=x}return a.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:r}),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:o}),e.jsxRuntimeExports.jsx(Vs,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:l.map((m,x)=>e.jsxRuntimeExports.jsx(kt,{col:m,idx:x},m))})]})]})}function kt({col:s,idx:n}){const t=e.useEditorStore(c=>{var l;return(l=c.card)==null?void 0:l.preferences}),r=e.useEditorStore(c=>{var l;return(l=c.card.preferences)==null?void 0:l.datasetOptions}),o=r==null?void 0:r.find(c=>c.idx===n),{setCardPreferences:a}=e.useEditorStore(c=>c.actions);function i(c){if(!o)a({...t,datasetOptions:[...r||[],{idx:n,type:c==="area"?"line":c,fill:c==="area"?"origin":""}]});else{const l={...o};l.type=c==="area"?"line":c,l.fill=c==="area"?"origin":"";const m=r==null?void 0:r.map(x=>x.idx===n?l:x);a({...t,datasetOptions:m})}}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(we,{onClick:()=>i("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ke,{onClick:()=>i("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Ye,{onClick:()=>i("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(wt,{idx:n})]})]})}function _s(){const s=e.useEditorStore(j=>j.selectedConnectionId),n=e.useEditorStore(j=>j.selectedDatamodelId),t=e.useEditorStore(j=>j.selectedDatabaseName),r=e.useEditorStore(j=>j.selectedSchemaName),o=e.useEditorStore(j=>j.selectedTableName),a=e.useDashboardStore(j=>j.dashboard.filters)||[],i=e.useDashboardStore(j=>j.actions.addFilter),c=e.useDashboardStore(j=>j.actions.removeFilter),l=e.useDashboardStore(j=>j.actions.removeFilterValue),{modelItems:m,tableName:x}=ie();function g(j,d="dashboard"){var I;const h=e.fmt(j.column_name),E=e.fmt(t||""),D=e.fmt(r||""),b=e.fmt(x);let T=e.getQualifiedTableName(D,b),k=`${T}.${h}`;const w=(I=m==null?void 0:m.find(O=>O.id===n))==null?void 0:I.name;n&&n!=="none"&&(k=`${e.DATAMODEL_NAMESPCACE}.${w}.${h}`,T=`${e.DATAMODEL_NAMESPCACE}.${w}`);const y=a==null?void 0:a.find(O=>O.column===k&&O.table===b&&(O.database===E||O.database===t));if(y)l(y.id),c(y.id);else{const O=e.v4();return x==="api"&&s?(i({location:d,id:O,column:k,title:j.column_name,dataType:j.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:e.getDefaultFilterSql(j.data_type,T,h)}),O):(i({id:O,location:d,column:k,title:j.column_name,dataType:j.data_type,table:o||"",database:t||"",connectionId:s||"",operation:"in",sql:e.getDefaultFilterSql(j.data_type,T,h)}),O)}}return{assignFilter:g}}function me(){const s=e.useDashboardStore(c=>c.dashboard.filters),n=e.useEditorStore(c=>c.frame),{setFrame:t}=e.useEditorActions(),{columns:r}=ie(),{assignFilter:o}=_s();function a(c){const l=o(c,"frame");t({...n,filterId:l})}const i=s==null?void 0:s.find(c=>c.id===n.filterId);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Card Filter"}),e.jsxRuntimeExports.jsx(It,{onSelect:a,columns:r}),i&&e.jsxRuntimeExports.jsx(e.FilterHeader,{filter:i})]})}function It({columns:s,onSelect:n}){var i;const[t,r]=$e.useState(!1),[o,a]=$e.useState("");return e.jsxRuntimeExports.jsxs(e.Popover,{open:t,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs(e.Button,{size:"sm",variant:"outline",role:"combobox","aria-expanded":t,className:"w-full justify-between font-normal",children:[o?(i=s.find(c=>c.column_name===o))==null?void 0:i.column_name:"Select Column...",e.jsxRuntimeExports.jsx(e.CaretSortIcon,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-[200px] p-0",children:e.jsxRuntimeExports.jsxs(e.Command,{children:[e.jsxRuntimeExports.jsx(e.CommandInput,{placeholder:"Search column",className:"h-9"}),e.jsxRuntimeExports.jsxs(e.CommandList,{children:[e.jsxRuntimeExports.jsx(e.CommandEmpty,{children:"No framework found."}),e.jsxRuntimeExports.jsx(e.CommandGroup,{children:s.map(c=>e.jsxRuntimeExports.jsxs(e.CommandItem,{value:c.column_name,onSelect:l=>{const m=l===o?"":l;a(m),r(!1),m&&n(c)},children:[c.column_name,e.jsxRuntimeExports.jsx(e.CheckIcon,{className:e.cn("ml-auto h-4 w-4",o===c.column_name?"opacity-100":"opacity-0")})]},c.column_name))})]})]})})]})}function Dt({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(De,{}),e.jsxRuntimeExports.jsx(qs,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ae,{}),e.jsxRuntimeExports.jsx(me,{})]})]})]})})}function Pe(){var o,a,i;const s=e.useEditorStore(c=>c.card.cfg),n=e.useEditorStore(c=>c.actions.setCardCfg),t=e.useEditorStore(c=>c.card.type);function r(c){var x;const l={datalabels:{display:c!=="none",align:c,anchor:c,clamp:!0}},m={...s,options:{...s==null?void 0:s.options,plugins:{...(x=s==null?void 0:s.options)==null?void 0:x.plugins,...l}}};n(m),console.log(c)}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(Vs,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(i=(a=(o=s==null?void 0:s.options)==null?void 0:o.plugins)==null?void 0:a.datalabels)==null?void 0:i.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 Lt({cardType:s}){function n(t){const r="SELECT label, [group], x-axis, y-axis, radius FROM table",o="SELECT label, [group], x-axis, y-axis FROM table";return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:t==="bubble"?r:o}),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:"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:"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.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(Pe,{})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ae,{}),e.jsxRuntimeExports.jsx(me,{})]})]})]})})}const Tt={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},At={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function Ot(){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:zt(s)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(s)&&e.jsxRuntimeExports.jsx(De,{})}),!["kpi"].includes(s)&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsx(Pe,{}),e.jsxRuntimeExports.jsx(ae,{}),e.jsxRuntimeExports.jsx(me,{})]})]})}function zt(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(Tt,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(At,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 Ft(){var l,m,x,g,j;const s=e.useEditorStore(d=>d.card.preferences),n=e.useEditorStore(d=>d.actions.setCardPreferences),t=e.useEditorStore(d=>d.actions.setNumberFormat);e.useEditorStore(d=>{var h,E;return(E=(h=d.card.preferences)==null?void 0:h.formatNumber)==null?void 0:E.decimalPlaces});const r=e.useEditorStore(d=>{var h,E;return(E=(h=d.card.preferences)==null?void 0:h.formatNumber)==null?void 0:E.locale}),o=e.useEditorStore(d=>{var h,E;return(E=(h=d.card.preferences)==null?void 0:h.formatNumber)==null?void 0:E.currency});e.useEditorStore(d=>d.actions.setFilterOnClickField);const a=e.useEditorStore(d=>{var h,E;return(E=(h=d.card.preferences)==null?void 0:h.formatNumber)==null?void 0:E.colorRanges})||[],i=e.useEditorStore(d=>d.actions.setColorRanges),c=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(d=>d.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:d=>{n({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:d}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((m=s==null?void 0:s.formatNumber)==null?void 0:m.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||"none",onValueChange:d=>{var h,E,D;return t(((h=s==null?void 0:s.formatNumber)==null?void 0:h.decimalPlaces)||0,((E=s==null?void 0:s.formatNumber)==null?void 0:E.currency)||"",d,((D=s==null?void 0:s.formatNumber)==null?void 0:D.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.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),e.LOCALE_CURRENCY_PAIRS.map(d=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:d.locale,children:d.locale},d.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:o||"none",onValueChange:d=>{var h,E,D;console.log("currency",d),t(((h=s==null?void 0:s.formatNumber)==null?void 0:h.decimalPlaces)||0,d==="none"?"":d,((E=s==null?void 0:s.formatNumber)==null?void 0:E.locale)||"",((D=s==null?void 0:s.formatNumber)==null?void 0:D.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"),c.map(d=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:d,children:d},d))]})})]})]})]}),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:((g=(x=s==null?void 0:s.formatNumber)==null?void 0:x.decimalPlaces)==null?void 0:g.toString())||"0",onValueChange:d=>{var h,E,D;return t(Number(d),((h=s==null?void 0:s.formatNumber)==null?void 0:h.currency)||"",((E=s==null?void 0:s.formatNumber)==null?void 0:E.locale)||"",((D=s==null?void 0:s.formatNumber)==null?void 0:D.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(d=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:d,children:d},d))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.Input,{value:((j=s==null?void 0:s.formatNumber)==null?void 0:j.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:d=>{var h,E,D;return t(((h=s==null?void 0:s.formatNumber)==null?void 0:h.decimalPlaces)||0,((E=s==null?void 0:s.formatNumber)==null?void 0:E.currency)||"",((D=s==null?void 0:s.formatNumber)==null?void 0:D.locale)||"",d.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:a,setColorRanges:i})]})]})}function Mt(){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(Ft,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}const Vt=[{label:"Mercator",value:"mercator"},{label:"Azimuthal Equidistant",value:"azimuthalEquidistant"},{label:"Gnomonic",value:"gnomonic"},{label:"Orthographic",value:"orthographic"},{label:"Stereographic",value:"stereographic"},{label:"Equal Earth",value:"equalEarth"},{label:"Albers",value:"albers"},{label:"Albers USA",value:"albersUsa"},{label:"Conic Conformal",value:"conicConformal"},{label:"Conic Equal Area",value:"conicEqualArea"},{label:"Conic Equidistant",value:"conicEquidistant"},{label:"Equirectangular",value:"equirectangular"},{label:"Transverse Mercator",value:"transverseMercator"},{label:"Natural Earth 1",value:"naturalEarth1"}],qt=["blues","brBG","buGn","buPu","cividis","cool","cubehelixDefault","gnBu","greens","greys","inferno","magma","orRd","oranges","pRGn","piYG","plasma","puBu","puBuGn","puOr","puRd","purples","rainbow","rdBu","rdGy","rdPu","rdYlBu","rdYlGn","reds","sinebow","spectral","turbo","viridis","warm","ylGn","ylGnBu","ylOrBr","ylOrRd"],_t=qt.map(s=>({label:s,value:s}));function Bt(){var l,m,x,g,j,d,h,E,D,b,T,k,w,y,I,O,u,R;const s=e.useEditorStore(p=>p.card),n=(m=(l=s==null?void 0:s.preferences)==null?void 0:l.mapVisualOptions)==null?void 0:m.topoJsonUrl,[t,r]=S.useState(((g=(x=s==null?void 0:s.preferences)==null?void 0:x.mapVisualOptions)==null?void 0:g.customTopoJsonUrl)||""),{setCardPreferences:o}=e.useEditorActions(),{data:a}=e.useTopoJson(s),i=Object.keys((a==null?void 0:a.objects)||{}).map(p=>({label:p,value:p}))||[],c=[{label:"US States 10m",value:"https://unpkg.com/us-atlas/states-10m.json"},{label:"Countries 50m",value:"https://unpkg.com/world-atlas/countries-50m.json"},{label:"Custom",value:"custom"}];return e.jsxRuntimeExports.jsxs("div",{className:"p-6",children:[e.jsxRuntimeExports.jsx(fe,{summary:"Map Query",children:e.jsxRuntimeExports.jsx("p",{className:"rounded-md bg-muted p-2 font-mono text-xs",children:"SELECT country, value FROM table"})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),e.jsxRuntimeExports.jsx(fe,{open:!0,summary:"Settings",children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-3 px-2",children:[e.jsxRuntimeExports.jsx(Z,{className:"h-9",options:c,onValueChange:p=>{console.log("value",p),o({...s.preferences,mapVisualOptions:{topoJsonUrl:p}})},value:n||"",label:"Select Map"}),n==="custom"&&e.jsxRuntimeExports.jsx(e.Input,{onChange:p=>{r(p.target.value)},onBlur:()=>{var p;console.log("onBlur",t),o({...s.preferences,mapVisualOptions:{...(p=s.preferences)==null?void 0:p.mapVisualOptions,customTopoJsonUrl:t}})},value:t,className:`h-9 w-full ${e.removeRing}`,placeholder:"Custom URL"}),a&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Map Object"}),e.jsxRuntimeExports.jsx(Z,{className:"h-9",options:i,value:((d=(j=s.preferences)==null?void 0:j.mapVisualOptions)==null?void 0:d.objectKey)||"",label:"Map Object",onValueChange:p=>{var N;o({...s.preferences,mapVisualOptions:{...(N=s.preferences)==null?void 0:N.mapVisualOptions,objectKey:p}})}})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Projection"}),e.jsxRuntimeExports.jsx(Z,{className:"h-9",options:Vt,value:((E=(h=s.preferences)==null?void 0:h.mapVisualOptions)==null?void 0:E.projection)||"",label:"Projection",onValueChange:p=>{var N;o({...s.preferences,mapVisualOptions:{...(N=s.preferences)==null?void 0:N.mapVisualOptions,projection:p}})}})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Colors"}),e.jsxRuntimeExports.jsx(Z,{className:"h-9",options:_t,value:((b=(D=s.preferences)==null?void 0:D.mapVisualOptions)==null?void 0:b.colorScale)||"",label:"Select Color Scale",onValueChange:p=>{var N;o({...s.preferences,mapVisualOptions:{...(N=s.preferences)==null?void 0:N.mapVisualOptions,colorScale:p}})}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),e.jsxRuntimeExports.jsx(fe,{className:"",summary:"Scale Options",children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Input,{className:`h-9 w-full ${e.removeRing}`,type:"number",step:.1,value:((k=(T=s.preferences)==null?void 0:T.mapVisualOptions)==null?void 0:k.projectionScale)||1,onChange:p=>{var N;o({...s.preferences,mapVisualOptions:{...(N=s.preferences)==null?void 0:N.mapVisualOptions,projectionScale:Number(p.target.value)}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"X"}),e.jsxRuntimeExports.jsx(e.Input,{className:`h-9 w-full ${e.removeRing}`,type:"number",step:10,value:((I=(y=(w=s.preferences)==null?void 0:w.mapVisualOptions)==null?void 0:y.projectionOffset)==null?void 0:I[0])||0,onChange:p=>{var N,z,M,q;o({...s.preferences,mapVisualOptions:{...(N=s.preferences)==null?void 0:N.mapVisualOptions,projectionOffset:[Number(p.target.value),((q=(M=(z=s.preferences)==null?void 0:z.mapVisualOptions)==null?void 0:M.projectionOffset)==null?void 0:q[1])||0]}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Y"}),e.jsxRuntimeExports.jsx(e.Input,{className:`h-9 w-full ${e.removeRing}`,type:"number",step:10,value:((R=(u=(O=s.preferences)==null?void 0:O.mapVisualOptions)==null?void 0:u.projectionOffset)==null?void 0:R[1])||0,onChange:p=>{var N,z,M,q;o({...s.preferences,mapVisualOptions:{...(N=s.preferences)==null?void 0:N.mapVisualOptions,projectionOffset:[((q=(M=(z=s.preferences)==null?void 0:z.mapVisualOptions)==null?void 0:M.projectionOffset)==null?void 0:q[0])||0,Number(p.target.value)]}})}})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),e.jsxRuntimeExports.jsx(ae,{})]})}function Ht(){var r;const s=e.useEditorStore(o=>o.card.preferences),{setCardPreferences:n}=e.useEditorStore(o=>o.actions);function t(o){n({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:o==="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 Se({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(De,{}),s!=="text"&&e.jsxRuntimeExports.jsx(Pe,{}),s==="text"&&e.jsxRuntimeExports.jsx(Ht,{})]})]}),!["range","text"].includes(s)&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ae,{}),e.jsxRuntimeExports.jsx(me,{})]})]})]})})}function Pt(){const s=e.useEditorStore(r=>{var o,a;return(a=(o=r==null?void 0:r.card)==null?void 0:o.preferences)==null?void 0:a.sortChart}),{setSortChart:n}=e.useEditorActions();function t(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Sort"}),e.jsxRuntimeExports.jsx(Z,{className:"h-8",label:"Sort Chart",options:[{label:"None",value:"none"},{label:"ASC",value:"asc"},{label:"DESC",value:"desc"}],value:s||"none",onValueChange:r=>{n(r)}})]})}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:r=>r.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(De,{}),t(),e.jsxRuntimeExports.jsx(qs,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ae,{}),e.jsxRuntimeExports.jsx(me,{})]})]})]})})}function Gt({}){const s=e.useEditorStore(r=>{var o;return(o=r.card)==null?void 0:o.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:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ae,{}),e.jsxRuntimeExports.jsx(me,{})]})]})}),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 $t=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."]})]}),Qt=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."]})]}),Ut=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 Jt(){const s=e.useEditorStore(t=>t.card.type);function n(t){switch(t){case"stackedBar":case"stackedLine":return e.jsxRuntimeExports.jsx(Pt,{});case"pyramid":return e.jsxRuntimeExports.jsx(Se,{docContent:$t,cardType:t});case"kpi":return e.jsxRuntimeExports.jsx(Mt,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(Dt,{cardType:t});case"range":return e.jsxRuntimeExports.jsx(Se,{docContent:Qt,cardType:t});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(Se,{cardType:t});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(Lt,{cardType:t});case"table":return e.jsxRuntimeExports.jsx(Gt,{cardType:t});case"text":return e.jsxRuntimeExports.jsx(Se,{docContent:Ut,cardType:t,suffix:"Visual"});case"map":return e.jsxRuntimeExports.jsx(Bt,{});case"custom":return e.jsxRuntimeExports.jsx(Nt,{});default:return e.jsxRuntimeExports.jsx(Ot,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:n(s)})}function Kt(){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(pt,{})}),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(Jt,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(Je,{})})]}):e.jsxRuntimeExports.jsx(Je,{})})]})}function Wt({authToken:s,onSave:n,onClose:t}){e.useDashboardStore(i=>i.themeStyle);const r=e.useEditorStore(i=>i.actions.setOnSave),o=e.useEditorStore(i=>i.actions.setOnClose),a=e.useDashboardStore(i=>i.actions.setAuthToken);return S.useEffect(()=>{n&&r(n),t&&o(t)},[n,r,t,o]),S.useEffect(()=>{s&&s.accessToken&&a(s)},[s,a]),e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:e.jsxRuntimeExports.jsxs(e.EditorPanel,{style:{},className:"rounded-none",role:"editor-panel",children:[e.jsxRuntimeExports.jsx(e.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsxRuntimeExports.jsx(Ss,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(Kt,{})})]})})}function Yt(){e.useDashboardStore(i=>i.selectedCardId);const s=e.useDashboardStore(i=>i.selectedSheetId),{setIsVisualEditing:n}=e.useDashboardStore(i=>i.actions),t=e.useDashboardStore(i=>i.isVisualEditing),r=e.useDashboardStore(i=>i.actions.updateFrame);function o(i){s&&(r(s,i),n(!1))}function a(){n(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{"max-h-0 overflow-hidden":!t}),children:e.jsxRuntimeExports.jsx(Wt,{onSave:o,onClose:a})})}function Xt(){e.useEditorStore(i=>i.selectedConnectionId),e.useEditorStore(i=>i.selectedDatamodelId);const s=e.useEditorStore(i=>i.selectedDatabaseName);e.useEditorStore(i=>i.selectedSchemaName);const n=e.useEditorStore(i=>i.selectedTableName),t=e.useDashboardStore(i=>i.dashboard.filters)||[];e.useDashboardStore(i=>i.actions.addFilter),e.useDashboardStore(i=>i.actions.removeFilter),e.useDashboardStore(i=>i.actions.removeFilterValue);const{modelItems:r,columns:o}=ie(),{assignFilter:a}=_s();return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:o==null?void 0:o.map(i=>{const c=t==null?void 0:t.find(l=>l.column===e.fmt(i.column_name)&&l.table===n&&l.database===s);return e.jsxRuntimeExports.jsx("div",{onClick:()=>a(i),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":c}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(vs,{column:i}),e.jsxRuntimeExports.jsx("span",{children:i.column_name})]})},i.column_name)})})}function Zt(){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(Ss,{ColumnsComponent:()=>e.jsxRuntimeExports.jsx(Xt,{})})})]})}function en(){const s=e.useDashboardStore(t=>t.showFilters),n=e.useDashboardStore(t=>t.isVisualEditing);return e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("",{"max-h-0 overflow-hidden":n,"flex grow":!n}),children:[e.jsxRuntimeExports.jsx(e.DashboardTabs,{}),s&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(Zt,{})})]})}function sn(){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 tn({showControls:s=!1,showFooter:n=!0,...t}){return e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:t,children:[e.jsxRuntimeExports.jsx(e.Te,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(sn,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...t,children:[s&&e.jsxRuntimeExports.jsx(Ws,{}),e.jsxRuntimeExports.jsx(Yt,{}),e.jsxRuntimeExports.jsx(en,{})]})]})]})})}exports.Box=We;exports.ChartArea=Ye;exports.ChartColumnIncreasing=we;exports.ChartLine=ke;exports.ChartNoAxesGantt=Oe;exports.ChartPie=ze;exports.ChartScatter=Fe;exports.CircleX=Xe;exports.CopyPlus=Ze;exports.DashboardPlus=tn;exports.Database=es;exports.EllipsisVertical=Me;exports.Eraser=ss;exports.Eye=ns;exports.EyeClosed=ts;exports.Glasses=rs;exports.Hammer=os;exports.Hash=is;exports.House=as;exports.Key=Ve;exports.ListEnd=ls;exports.ListStart=cs;exports.ListX=xs;exports.LoaderCircle=de;exports.Map=qe;exports.MessageSquareMore=us;exports.Network=ds;exports.Pencil=_e;exports.Play=ms;exports.Plug2=ps;exports.Save=js;exports.SelectComponent=ue;exports.Shapes=Be;exports.ShieldQuestion=hs;exports.Sigma=Es;exports.SwatchBook=fs;exports.Tag=gs;exports.ToggleLeft=Rs;exports.Type=Ie;exports.User=bs;exports.cleanCard=ys;exports.getDashbaordStateWithoutData=He;exports.useEditorAside=ie;
@@ -58242,7 +58242,7 @@ function D_e() {
58242
58242
  h(w);
58243
58243
  }
58244
58244
  function m() {
58245
- return (l == null ? void 0 : l.canvasTheme) === "muted" || !(l != null && l.canvasTheme) ? "hsl(var(--semaphor-muted))" : (l == null ? void 0 : l.canvasTheme) === "clear" ? "#fff" : l == null ? void 0 : l.canvasTheme;
58245
+ return (l == null ? void 0 : l.canvasTheme) === "muted" || !(l != null && l.canvasTheme) ? "hsl(var(--semaphor-muted))" : (l == null ? void 0 : l.canvasTheme) === "clear" ? "" : l == null ? void 0 : l.canvasTheme;
58246
58246
  }
58247
58247
  return /* @__PURE__ */ E.jsxs(
58248
58248
  u6,
@@ -427,7 +427,7 @@ You can add a description to the \`${Ou}\` by passing a \`${DN}\` component as a
427
427
 
428
428
  Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Ou}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
429
429
 
430
- For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return j.useEffect(()=>{var r;document.getElementById((r=e.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},K_e=EN,X_e=RN,NN=PN,LN=$N,FN=MN,jN=IN,zN=TN,BN=AN;const Q_e=K_e,J_e=X_e,VN=j.forwardRef(({className:e,...t},n)=>R.jsx(NN,{className:ye("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));VN.displayName=NN.displayName;const HN=j.forwardRef(({className:e,...t},n)=>R.jsx(J_e,{children:R.jsxs(bc,{children:[R.jsx(VN,{}),R.jsx(LN,{ref:n,className:ye("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]})}));HN.displayName=LN.displayName;const WN=({className:e,...t})=>R.jsx("div",{className:ye("flex flex-col space-y-2 text-center sm:text-left",e),...t});WN.displayName="AlertDialogHeader";const UN=({className:e,...t})=>R.jsx("div",{className:ye("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});UN.displayName="AlertDialogFooter";const qN=j.forwardRef(({className:e,...t},n)=>R.jsx(zN,{ref:n,className:ye("text-lg font-semibold",e),...t}));qN.displayName=zN.displayName;const GN=j.forwardRef(({className:e,...t},n)=>R.jsx(BN,{ref:n,className:ye("text-sm text-muted-foreground",e),...t}));GN.displayName=BN.displayName;const YN=j.forwardRef(({className:e,...t},n)=>R.jsx(FN,{ref:n,className:ye(xh(),e),...t}));YN.displayName=FN.displayName;const KN=j.forwardRef(({className:e,...t},n)=>R.jsx(jN,{ref:n,className:ye(xh({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));KN.displayName=jN.displayName;function Z_e({open:e,setOpen:t}){const n=we(i=>i.selectedSheetId),{deleteSheet:r}=dr();function o(){n&&(r(n),t(!1))}return R.jsx(Q_e,{open:e,onOpenChange:t,children:R.jsxs(HN,{children:[R.jsxs(WN,{children:[R.jsx(qN,{children:"Delete Sheet"}),R.jsx(GN,{children:"Are you sure you want to delete this sheet along with all its cards? This action cannot be undone."})]}),R.jsxs(UN,{children:[R.jsx(KN,{children:"Cancel"}),R.jsx(YN,{onClick:o,children:"Delete"})]})]})})}function XN(){var x,y;const[e,t]=m.useState(!1),n=we(_=>{var S;return(S=_.dashboard)==null?void 0:S.sheets}),{showAssistant:r}=_i(),o=m.useRef(null),[i,a]=m.useState(!1),s=we(_=>_.isDashboardEditing),l=we(_=>_.themeStyle);we(_=>_.isVisualEditing);const c=we(_=>_.selectedSheetId),{setSelectedSheetId:u,setSheetTitle:d,addSheet:h}=dr();if(!n)return null;function p(_){var S,C;_?((S=o.current)==null||S.resize(35),a(!0)):(a(!1),(C=o.current)==null||C.resize(0))}function v(){const _={id:Fs(),title:"New Sheet"};h(_)}function b(){return(l==null?void 0:l.canvasTheme)==="muted"||!(l!=null&&l.canvasTheme)?"hsl(var(--semaphor-muted))":(l==null?void 0:l.canvasTheme)==="clear"?"#fff":l==null?void 0:l.canvasTheme}return R.jsxs(VS,{role:"dashboard-tabs-container",className:ye("relative flex grow flex-col",l==null?void 0:l.dashboardTabsContainer),onValueChange:_=>{u(_)},value:c||n[0].id,children:[R.jsx("div",{children:(n.length>1||s)&&R.jsxs(Sb,{role:"tab-list",className:"flex h-11 items-center justify-start gap-2 rounded-none bg-transparent px-2.5 py-3",children:[n==null?void 0:n.map(_=>{var S,C;return R.jsx(qi,{text:_.title,onSave:E=>d(_.id,E),children:R.jsxs(Cb,{style:{borderRadius:(C=(S=l==null?void 0:l.chart)==null?void 0:S.options)==null?void 0:C.borderRadius},onClick:()=>u(_.id),className:"flex items-center gap-1 rounded-none border px-2 py-1",value:_.id,children:[_.title,s&&c===_.id&&n.length>1&&R.jsx(md,{className:"ml-1 size-3",onClick:()=>t(!0)})]})},_.id)}),s&&R.jsx("div",{style:{borderRadius:(y=(x=l==null?void 0:l.chart)==null?void 0:x.options)==null?void 0:y.borderRadius},className:"flex h-7 items-center justify-center border-none bg-muted p-2 hover:cursor-pointer dark:border-l-background",onClick:v,children:R.jsx(bC,{className:"size-3"})})]})}),R.jsxs(U9,{className:"grow",direction:"horizontal",children:[R.jsx(lS,{children:R.jsx("div",{style:{},children:n==null?void 0:n.map(_=>R.jsx(HS,{style:{backgroundColor:b()},className:ye("mt-0",{}),value:_.id,children:R.jsx(N0e,{sheet:_})},_.id))})}),r===!0&&R.jsxs(R.Fragment,{children:[R.jsx(kwe,{open:i,onTabClick:p,withHandle:!0}),R.jsx(lS,{onResize:_=>{_<1?a(!1):i||a(!0)},defaultSize:0,ref:o,children:R.jsx(hwe,{})})]})]}),R.jsx(Z_e,{open:e,setOpen:t})]})}function QN({children:e}){return R.jsx(dG,{defaultTheme:"system",storageKey:"vite-ui-theme",children:R.jsx(ole,{delayDuration:0,children:e})})}function JN(e){return R.jsx(zb,{FallbackComponent:yC,children:R.jsx(ak,{dashboardProps:e,children:R.jsx(QN,{children:R.jsx(uk,{...e,children:R.jsx(XN,{})})})})})}const ZN=m.forwardRef((e,t)=>{const{children:n,...r}=e,o=m.Children.toArray(n),i=o.find(tSe);if(i){const a=i.props.children,s=o.map(l=>l===i?m.Children.count(a)>1?m.Children.only(null):m.isValidElement(a)?a.props.children:null:l);return m.createElement(dS,ue({},r,{ref:t}),m.isValidElement(a)?m.cloneElement(a,void 0,s):null)}return m.createElement(dS,ue({},r,{ref:t}),n)});ZN.displayName="Slot";const dS=m.forwardRef((e,t)=>{const{children:n,...r}=e;return m.isValidElement(n)?m.cloneElement(n,{...nSe(r,n.props),ref:t?Ba(t,n.ref):n.ref}):m.Children.count(n)>1?m.Children.only(null):null});dS.displayName="SlotClone";const eSe=({children:e})=>m.createElement(m.Fragment,null,e);function tSe(e){return m.isValidElement(e)&&e.type===eSe}function nSe(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...s)=>{i(...s),o(...s)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}const fS=["Enter"," "],rSe=["ArrowDown","PageUp","Home"],eL=["ArrowUp","PageDown","End"],oSe=[...rSe,...eL],iSe={ltr:[...fS,"ArrowRight"],rtl:[...fS,"ArrowLeft"]},aSe={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Dv="Menu",[Hh,sSe,lSe]=_b(Dv),[$c,tL]=hr(Dv,[lSe,oa,gd]),M2=oa(),nL=gd(),[cSe,Oc]=$c(Dv),[uSe,Mp]=$c(Dv),dSe=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:i,modal:a=!0}=e,s=M2(t),[l,c]=m.useState(null),u=m.useRef(!1),d=Xn(i),h=vc(o);return m.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),m.createElement(mp,s,m.createElement(cSe,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c},m.createElement(uSe,{scope:t,onClose:m.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:h,modal:a},r)))},rL=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=M2(n);return m.createElement(bp,ue({},o,r,{ref:t}))}),oL="MenuPortal",[fSe,iL]=$c(oL,{forceMount:void 0}),hSe=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,i=Oc(oL,t);return m.createElement(fSe,{scope:t,forceMount:n},m.createElement(pr,{present:n||i.open},m.createElement(aE,{asChild:!0,container:o},r)))},vi="MenuContent",[pSe,k2]=$c(vi),gSe=m.forwardRef((e,t)=>{const n=iL(vi,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,i=Oc(vi,e.__scopeMenu),a=Mp(vi,e.__scopeMenu);return m.createElement(Hh.Provider,{scope:e.__scopeMenu},m.createElement(pr,{present:r||i.open},m.createElement(Hh.Slot,{scope:e.__scopeMenu},a.modal?m.createElement(mSe,ue({},o,{ref:t})):m.createElement(bSe,ue({},o,{ref:t})))))}),mSe=m.forwardRef((e,t)=>{const n=Oc(vi,e.__scopeMenu),r=m.useRef(null),o=Rt(t,r);return m.useEffect(()=>{const i=r.current;if(i)return _p(i)},[]),m.createElement(I2,ue({},e,{ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ke(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)}))}),bSe=m.forwardRef((e,t)=>{const n=Oc(vi,e.__scopeMenu);return m.createElement(I2,ue({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)}))}),I2=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:s,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:p,disableOutsideScroll:v,...b}=e,x=Oc(vi,n),y=Mp(vi,n),_=M2(n),S=nL(n),C=sSe(n),[E,$]=m.useState(null),T=m.useRef(null),D=Rt(t,T,x.onContentChange),M=m.useRef(0),L=m.useRef(""),F=m.useRef(0),z=m.useRef(null),X=m.useRef("right"),G=m.useRef(0),A=v?TE:m.Fragment,U=v?{as:ZN,allowPinchZoom:!0}:void 0,V=q=>{var O,H;const Y=L.current+q,I=C().filter(re=>!re.disabled),te=document.activeElement,ce=(O=I.find(re=>re.ref.current===te))===null||O===void 0?void 0:O.textValue,de=I.map(re=>re.textValue),he=NSe(de,Y,ce),ie=(H=I.find(re=>re.textValue===he))===null||H===void 0?void 0:H.ref.current;(function re(le){L.current=le,window.clearTimeout(M.current),le!==""&&(M.current=window.setTimeout(()=>re(""),1e3))})(Y),ie&&setTimeout(()=>ie.focus())};m.useEffect(()=>()=>window.clearTimeout(M.current),[]),SE();const K=m.useCallback(q=>{var O,H;return X.current===((O=z.current)===null||O===void 0?void 0:O.side)&&FSe(q,(H=z.current)===null||H===void 0?void 0:H.area)},[]);return m.createElement(pSe,{scope:n,searchRef:L,onItemEnter:m.useCallback(q=>{K(q)&&q.preventDefault()},[K]),onItemLeave:m.useCallback(q=>{var O;K(q)||((O=T.current)===null||O===void 0||O.focus(),$(null))},[K]),onTriggerLeave:m.useCallback(q=>{K(q)&&q.preventDefault()},[K]),pointerGraceTimerRef:F,onPointerGraceIntentChange:m.useCallback(q=>{z.current=q},[])},m.createElement(A,U,m.createElement(CE,{asChild:!0,trapped:o,onMountAutoFocus:ke(i,q=>{var O;q.preventDefault(),(O=T.current)===null||O===void 0||O.focus()}),onUnmountAutoFocus:a},m.createElement(yp,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:p},m.createElement(jS,ue({asChild:!0},S,{dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:E,onCurrentTabStopIdChange:$,onEntryFocus:ke(l,q=>{y.isUsingKeyboardRef.current||q.preventDefault()})}),m.createElement(vp,ue({role:"menu","aria-orientation":"vertical","data-state":uL(x.open),"data-radix-menu-content":"",dir:y.dir},_,b,{ref:D,style:{outline:"none",...b.style},onKeyDown:ke(b.onKeyDown,q=>{const H=q.target.closest("[data-radix-menu-content]")===q.currentTarget,Y=q.ctrlKey||q.altKey||q.metaKey,I=q.key.length===1;H&&(q.key==="Tab"&&q.preventDefault(),!Y&&I&&V(q.key));const te=T.current;if(q.target!==te||!oSe.includes(q.key))return;q.preventDefault();const de=C().filter(he=>!he.disabled).map(he=>he.ref.current);eL.includes(q.key)&&de.reverse(),kSe(de)}),onBlur:ke(e.onBlur,q=>{q.currentTarget.contains(q.target)||(window.clearTimeout(M.current),L.current="")}),onPointerMove:ke(e.onPointerMove,Wh(q=>{const O=q.target,H=G.current!==q.clientX;if(q.currentTarget.contains(O)&&H){const Y=q.clientX>G.current?"right":"left";X.current=Y,G.current=q.clientX}}))})))))))}),vSe=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.createElement(Qe.div,ue({role:"group"},r,{ref:t}))}),ySe=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.createElement(Qe.div,ue({},r,{ref:t}))}),hS="MenuItem",GA="menu.itemSelect",N2=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,i=m.useRef(null),a=Mp(hS,e.__scopeMenu),s=k2(hS,e.__scopeMenu),l=Rt(t,i),c=m.useRef(!1),u=()=>{const d=i.current;if(!n&&d){const h=new CustomEvent(GA,{bubbles:!0,cancelable:!0});d.addEventListener(GA,p=>r==null?void 0:r(p),{once:!0}),fk(d,h),h.defaultPrevented?c.current=!1:a.onClose()}};return m.createElement(aL,ue({},o,{ref:l,disabled:n,onClick:ke(e.onClick,u),onPointerDown:d=>{var h;(h=e.onPointerDown)===null||h===void 0||h.call(e,d),c.current=!0},onPointerUp:ke(e.onPointerUp,d=>{var h;c.current||(h=d.currentTarget)===null||h===void 0||h.click()}),onKeyDown:ke(e.onKeyDown,d=>{const h=s.searchRef.current!=="";n||h&&d.key===" "||fS.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})}))}),aL=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...i}=e,a=k2(hS,n),s=nL(n),l=m.useRef(null),c=Rt(t,l),[u,d]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const v=l.current;if(v){var b;p(((b=v.textContent)!==null&&b!==void 0?b:"").trim())}},[i.children]),m.createElement(Hh.ItemSlot,{scope:n,disabled:r,textValue:o??h},m.createElement(zS,ue({asChild:!0},s,{focusable:!r}),m.createElement(Qe.div,ue({role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0},i,{ref:c,onPointerMove:ke(e.onPointerMove,Wh(v=>{r?a.onItemLeave(v):(a.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus())})),onPointerLeave:ke(e.onPointerLeave,Wh(v=>a.onItemLeave(v))),onFocus:ke(e.onFocus,()=>d(!0)),onBlur:ke(e.onBlur,()=>d(!1))}))))}),xSe=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return m.createElement(lL,{scope:e.__scopeMenu,checked:n},m.createElement(N2,ue({role:"menuitemcheckbox","aria-checked":cb(n)?"mixed":n},o,{ref:t,"data-state":L2(n),onSelect:ke(o.onSelect,()=>r==null?void 0:r(cb(n)?!0:!n),{checkForDefaultPrevented:!1})})))}),wSe="MenuRadioGroup",[_Se,SSe]=$c(wSe,{value:void 0,onValueChange:()=>{}}),CSe=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,i=Xn(r);return m.createElement(_Se,{scope:e.__scopeMenu,value:n,onValueChange:i},m.createElement(vSe,ue({},o,{ref:t})))}),ESe="MenuRadioItem",RSe=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=SSe(ESe,e.__scopeMenu),i=n===o.value;return m.createElement(lL,{scope:e.__scopeMenu,checked:i},m.createElement(N2,ue({role:"menuitemradio","aria-checked":i},r,{ref:t,"data-state":L2(i),onSelect:ke(r.onSelect,()=>{var a;return(a=o.onValueChange)===null||a===void 0?void 0:a.call(o,n)},{checkForDefaultPrevented:!1})})))}),sL="MenuItemIndicator",[lL,PSe]=$c(sL,{checked:!1}),$Se=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,i=PSe(sL,n);return m.createElement(pr,{present:r||cb(i.checked)||i.checked===!0},m.createElement(Qe.span,ue({},o,{ref:t,"data-state":L2(i.checked)})))}),OSe=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.createElement(Qe.div,ue({role:"separator","aria-orientation":"horizontal"},r,{ref:t}))}),TSe="MenuSub",[m5e,cL]=$c(TSe),Nm="MenuSubTrigger",DSe=m.forwardRef((e,t)=>{const n=Oc(Nm,e.__scopeMenu),r=Mp(Nm,e.__scopeMenu),o=cL(Nm,e.__scopeMenu),i=k2(Nm,e.__scopeMenu),a=m.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:l}=i,c={__scopeMenu:e.__scopeMenu},u=m.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return m.useEffect(()=>u,[u]),m.useEffect(()=>{const d=s.current;return()=>{window.clearTimeout(d),l(null)}},[s,l]),m.createElement(rL,ue({asChild:!0},c),m.createElement(aL,ue({id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":uL(n.open)},e,{ref:Ba(t,o.onTriggerChange),onClick:d=>{var h;(h=e.onClick)===null||h===void 0||h.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ke(e.onPointerMove,Wh(d=>{i.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!a.current&&(i.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:ke(e.onPointerLeave,Wh(d=>{var h;u();const p=(h=n.content)===null||h===void 0?void 0:h.getBoundingClientRect();if(p){var v;const b=(v=n.content)===null||v===void 0?void 0:v.dataset.side,x=b==="right",y=x?-5:5,_=p[x?"left":"right"],S=p[x?"right":"left"];i.onPointerGraceIntentChange({area:[{x:d.clientX+y,y:d.clientY},{x:_,y:p.top},{x:S,y:p.top},{x:S,y:p.bottom},{x:_,y:p.bottom}],side:b}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(d),d.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:ke(e.onKeyDown,d=>{const h=i.searchRef.current!=="";if(!(e.disabled||h&&d.key===" ")&&iSe[r.dir].includes(d.key)){var p;n.onOpenChange(!0),(p=n.content)===null||p===void 0||p.focus(),d.preventDefault()}})})))}),ASe="MenuSubContent",MSe=m.forwardRef((e,t)=>{const n=iL(vi,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,i=Oc(vi,e.__scopeMenu),a=Mp(vi,e.__scopeMenu),s=cL(ASe,e.__scopeMenu),l=m.useRef(null),c=Rt(t,l);return m.createElement(Hh.Provider,{scope:e.__scopeMenu},m.createElement(pr,{present:r||i.open},m.createElement(Hh.Slot,{scope:e.__scopeMenu},m.createElement(I2,ue({id:s.contentId,"aria-labelledby":s.triggerId},o,{ref:c,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var d;a.isUsingKeyboardRef.current&&((d=l.current)===null||d===void 0||d.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:ke(e.onFocusOutside,u=>{u.target!==s.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:ke(e.onEscapeKeyDown,u=>{a.onClose(),u.preventDefault()}),onKeyDown:ke(e.onKeyDown,u=>{const d=u.currentTarget.contains(u.target),h=aSe[a.dir].includes(u.key);if(d&&h){var p;i.onOpenChange(!1),(p=s.trigger)===null||p===void 0||p.focus(),u.preventDefault()}})})))))});function uL(e){return e?"open":"closed"}function cb(e){return e==="indeterminate"}function L2(e){return cb(e)?"indeterminate":e?"checked":"unchecked"}function kSe(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ISe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function NSe(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let a=ISe(e,Math.max(i,0));o.length===1&&(a=a.filter(c=>c!==n));const l=a.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function LSe(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const s=t[i].x,l=t[i].y,c=t[a].x,u=t[a].y;l>r!=u>r&&n<(c-s)*(r-l)/(u-l)+s&&(o=!o)}return o}function FSe(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return LSe(n,t)}function Wh(e){return t=>t.pointerType==="mouse"?e(t):void 0}const jSe=dSe,zSe=rL,BSe=hSe,VSe=gSe,HSe=ySe,WSe=N2,USe=xSe,qSe=CSe,GSe=RSe,YSe=$Se,KSe=OSe,XSe=DSe,QSe=MSe,dL="DropdownMenu",[JSe,b5e]=hr(dL,[tL]),Mo=tL(),[ZSe,fL]=JSe(dL),eCe=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:i,onOpenChange:a,modal:s=!0}=e,l=Mo(t),c=m.useRef(null),[u=!1,d]=Fr({prop:o,defaultProp:i,onChange:a});return m.createElement(ZSe,{scope:t,triggerId:yi(),triggerRef:c,contentId:yi(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(h=>!h),[d]),modal:s},m.createElement(jSe,ue({},l,{open:u,onOpenChange:d,dir:r,modal:s}),n))},tCe="DropdownMenuTrigger",nCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,i=fL(tCe,n),a=Mo(n);return m.createElement(zSe,ue({asChild:!0},a),m.createElement(Qe.button,ue({type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r},o,{ref:Ba(t,i.triggerRef),onPointerDown:ke(e.onPointerDown,s=>{!r&&s.button===0&&s.ctrlKey===!1&&(i.onOpenToggle(),i.open||s.preventDefault())}),onKeyDown:ke(e.onKeyDown,s=>{r||(["Enter"," "].includes(s.key)&&i.onOpenToggle(),s.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(s.key)&&s.preventDefault())})})))}),rCe=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Mo(t);return m.createElement(BSe,ue({},r,n))},oCe="DropdownMenuContent",iCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=fL(oCe,n),i=Mo(n),a=m.useRef(!1);return m.createElement(VSe,ue({id:o.contentId,"aria-labelledby":o.triggerId},i,r,{ref:t,onCloseAutoFocus:ke(e.onCloseAutoFocus,s=>{var l;a.current||(l=o.triggerRef.current)===null||l===void 0||l.focus(),a.current=!1,s.preventDefault()}),onInteractOutside:ke(e.onInteractOutside,s=>{const l=s.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!o.modal||u)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))}),aCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(HSe,ue({},o,r,{ref:t}))}),sCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(WSe,ue({},o,r,{ref:t}))}),lCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(USe,ue({},o,r,{ref:t}))}),cCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(qSe,ue({},o,r,{ref:t}))}),uCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(GSe,ue({},o,r,{ref:t}))}),dCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(YSe,ue({},o,r,{ref:t}))}),fCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(KSe,ue({},o,r,{ref:t}))}),hCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(XSe,ue({},o,r,{ref:t}))}),pCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(QSe,ue({},o,r,{ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))}),gCe=eCe,mCe=nCe,bCe=rCe,hL=iCe,pL=aCe,gL=sCe,mL=lCe,vCe=cCe,bL=uCe,vL=dCe,yL=fCe,xL=hCe,wL=pCe,yCe=gCe,xCe=mCe,wCe=vCe,_Ce=j.forwardRef(({className:e,inset:t,children:n,...r},o)=>R.jsxs(xL,{ref:o,className:ye("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,R.jsx(jb,{className:"ml-auto h-4 w-4"})]}));_Ce.displayName=xL.displayName;const SCe=j.forwardRef(({className:e,...t},n)=>R.jsx(bc,{children:R.jsx(wL,{ref:n,className:ye("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t})}));SCe.displayName=wL.displayName;const _L=j.forwardRef(({className:e,sideOffset:t=4,...n},r)=>R.jsx(bCe,{children:R.jsx(bc,{children:R.jsx(hL,{ref:r,sideOffset:t,className:ye("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})})}));_L.displayName=hL.displayName;const SL=j.forwardRef(({className:e,inset:t,...n},r)=>R.jsx(gL,{ref:r,className:ye("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));SL.displayName=gL.displayName;const CL=j.forwardRef(({className:e,children:t,checked:n,...r},o)=>R.jsxs(mL,{ref:o,className:ye("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[R.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:R.jsx(vL,{children:R.jsx(up,{className:"h-4 w-4"})})}),t]}));CL.displayName=mL.displayName;const EL=j.forwardRef(({className:e,children:t,...n},r)=>R.jsxs(bL,{ref:r,className:ye("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[R.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:R.jsx(vL,{children:R.jsx(gC,{className:"h-2 w-2 fill-current"})})}),t]}));EL.displayName=bL.displayName;const RL=j.forwardRef(({className:e,inset:t,...n},r)=>R.jsx(pL,{ref:r,className:ye("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));RL.displayName=pL.displayName;const PL=j.forwardRef(({className:e,...t},n)=>R.jsx(yL,{ref:n,className:ye("-mx-1 my-1 h-px bg-muted",e),...t}));PL.displayName=yL.displayName;const CCe=wN,ECe=_N,RCe=SN,$L=j.forwardRef(({className:e,...t},n)=>R.jsx($2,{ref:n,className:ye("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));$L.displayName=$2.displayName;const OL=j.forwardRef(({className:e,children:t,...n},r)=>R.jsx(RCe,{children:R.jsxs(bc,{children:[R.jsx($L,{}),R.jsxs(O2,{ref:r,className:ye("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,R.jsxs(A2,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[R.jsx(md,{className:"h-4 w-4"}),R.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}));OL.displayName=O2.displayName;const TL=({className:e,...t})=>R.jsx("div",{className:ye("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});TL.displayName="DialogHeader";const DL=({className:e,...t})=>R.jsx("div",{className:ye("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});DL.displayName="DialogFooter";const AL=j.forwardRef(({className:e,...t},n)=>R.jsx(T2,{ref:n,className:ye("text-lg font-semibold leading-none tracking-tight",e),...t}));AL.displayName=T2.displayName;const ML=j.forwardRef(({className:e,...t},n)=>R.jsx(D2,{ref:n,className:ye("text-sm text-muted-foreground",e),...t}));ML.displayName=D2.displayName;const kL=m.forwardRef(({className:e,...t},n)=>R.jsx("div",{role:"editor-panel",ref:n,className:ye("flex grow h-full",e),...t}));kL.displayName="EditorPanel";const IL=m.forwardRef(({className:e,...t},n)=>R.jsx("div",{ref:n,className:ye(" flex flex-col space-y-2 w-[270px]",e),...t}));IL.displayName="EditorAside";const NL=m.forwardRef(({className:e,...t},n)=>R.jsx("div",{ref:n,className:ye(" grow",e),...t}));NL.displayName="EditorMain";function PCe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function YA(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function KA(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?YA(Object(n),!0).forEach(function(r){PCe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YA(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function $Ce(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,i;for(i=0;i<r.length;i++)o=r[i],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}function OCe(e,t){if(e==null)return{};var n=$Ce(e,t),r,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)r=i[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function TCe(e,t){return DCe(e)||ACe(e,t)||MCe(e,t)||kCe()}function DCe(e){if(Array.isArray(e))return e}function ACe(e,t){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(e)))){var n=[],r=!0,o=!1,i=void 0;try{for(var a=e[Symbol.iterator](),s;!(r=(s=a.next()).done)&&(n.push(s.value),!(t&&n.length===t));r=!0);}catch(l){o=!0,i=l}finally{try{!r&&a.return!=null&&a.return()}finally{if(o)throw i}}return n}}function MCe(e,t){if(e){if(typeof e=="string")return XA(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return XA(e,t)}}function XA(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function kCe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
430
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return j.useEffect(()=>{var r;document.getElementById((r=e.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},K_e=EN,X_e=RN,NN=PN,LN=$N,FN=MN,jN=IN,zN=TN,BN=AN;const Q_e=K_e,J_e=X_e,VN=j.forwardRef(({className:e,...t},n)=>R.jsx(NN,{className:ye("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));VN.displayName=NN.displayName;const HN=j.forwardRef(({className:e,...t},n)=>R.jsx(J_e,{children:R.jsxs(bc,{children:[R.jsx(VN,{}),R.jsx(LN,{ref:n,className:ye("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]})}));HN.displayName=LN.displayName;const WN=({className:e,...t})=>R.jsx("div",{className:ye("flex flex-col space-y-2 text-center sm:text-left",e),...t});WN.displayName="AlertDialogHeader";const UN=({className:e,...t})=>R.jsx("div",{className:ye("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});UN.displayName="AlertDialogFooter";const qN=j.forwardRef(({className:e,...t},n)=>R.jsx(zN,{ref:n,className:ye("text-lg font-semibold",e),...t}));qN.displayName=zN.displayName;const GN=j.forwardRef(({className:e,...t},n)=>R.jsx(BN,{ref:n,className:ye("text-sm text-muted-foreground",e),...t}));GN.displayName=BN.displayName;const YN=j.forwardRef(({className:e,...t},n)=>R.jsx(FN,{ref:n,className:ye(xh(),e),...t}));YN.displayName=FN.displayName;const KN=j.forwardRef(({className:e,...t},n)=>R.jsx(jN,{ref:n,className:ye(xh({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));KN.displayName=jN.displayName;function Z_e({open:e,setOpen:t}){const n=we(i=>i.selectedSheetId),{deleteSheet:r}=dr();function o(){n&&(r(n),t(!1))}return R.jsx(Q_e,{open:e,onOpenChange:t,children:R.jsxs(HN,{children:[R.jsxs(WN,{children:[R.jsx(qN,{children:"Delete Sheet"}),R.jsx(GN,{children:"Are you sure you want to delete this sheet along with all its cards? This action cannot be undone."})]}),R.jsxs(UN,{children:[R.jsx(KN,{children:"Cancel"}),R.jsx(YN,{onClick:o,children:"Delete"})]})]})})}function XN(){var x,y;const[e,t]=m.useState(!1),n=we(_=>{var S;return(S=_.dashboard)==null?void 0:S.sheets}),{showAssistant:r}=_i(),o=m.useRef(null),[i,a]=m.useState(!1),s=we(_=>_.isDashboardEditing),l=we(_=>_.themeStyle);we(_=>_.isVisualEditing);const c=we(_=>_.selectedSheetId),{setSelectedSheetId:u,setSheetTitle:d,addSheet:h}=dr();if(!n)return null;function p(_){var S,C;_?((S=o.current)==null||S.resize(35),a(!0)):(a(!1),(C=o.current)==null||C.resize(0))}function v(){const _={id:Fs(),title:"New Sheet"};h(_)}function b(){return(l==null?void 0:l.canvasTheme)==="muted"||!(l!=null&&l.canvasTheme)?"hsl(var(--semaphor-muted))":(l==null?void 0:l.canvasTheme)==="clear"?"":l==null?void 0:l.canvasTheme}return R.jsxs(VS,{role:"dashboard-tabs-container",className:ye("relative flex grow flex-col",l==null?void 0:l.dashboardTabsContainer),onValueChange:_=>{u(_)},value:c||n[0].id,children:[R.jsx("div",{children:(n.length>1||s)&&R.jsxs(Sb,{role:"tab-list",className:"flex h-11 items-center justify-start gap-2 rounded-none bg-transparent px-2.5 py-3",children:[n==null?void 0:n.map(_=>{var S,C;return R.jsx(qi,{text:_.title,onSave:E=>d(_.id,E),children:R.jsxs(Cb,{style:{borderRadius:(C=(S=l==null?void 0:l.chart)==null?void 0:S.options)==null?void 0:C.borderRadius},onClick:()=>u(_.id),className:"flex items-center gap-1 rounded-none border px-2 py-1",value:_.id,children:[_.title,s&&c===_.id&&n.length>1&&R.jsx(md,{className:"ml-1 size-3",onClick:()=>t(!0)})]})},_.id)}),s&&R.jsx("div",{style:{borderRadius:(y=(x=l==null?void 0:l.chart)==null?void 0:x.options)==null?void 0:y.borderRadius},className:"flex h-7 items-center justify-center border-none bg-muted p-2 hover:cursor-pointer dark:border-l-background",onClick:v,children:R.jsx(bC,{className:"size-3"})})]})}),R.jsxs(U9,{className:"grow",direction:"horizontal",children:[R.jsx(lS,{children:R.jsx("div",{style:{},children:n==null?void 0:n.map(_=>R.jsx(HS,{style:{backgroundColor:b()},className:ye("mt-0",{}),value:_.id,children:R.jsx(N0e,{sheet:_})},_.id))})}),r===!0&&R.jsxs(R.Fragment,{children:[R.jsx(kwe,{open:i,onTabClick:p,withHandle:!0}),R.jsx(lS,{onResize:_=>{_<1?a(!1):i||a(!0)},defaultSize:0,ref:o,children:R.jsx(hwe,{})})]})]}),R.jsx(Z_e,{open:e,setOpen:t})]})}function QN({children:e}){return R.jsx(dG,{defaultTheme:"system",storageKey:"vite-ui-theme",children:R.jsx(ole,{delayDuration:0,children:e})})}function JN(e){return R.jsx(zb,{FallbackComponent:yC,children:R.jsx(ak,{dashboardProps:e,children:R.jsx(QN,{children:R.jsx(uk,{...e,children:R.jsx(XN,{})})})})})}const ZN=m.forwardRef((e,t)=>{const{children:n,...r}=e,o=m.Children.toArray(n),i=o.find(tSe);if(i){const a=i.props.children,s=o.map(l=>l===i?m.Children.count(a)>1?m.Children.only(null):m.isValidElement(a)?a.props.children:null:l);return m.createElement(dS,ue({},r,{ref:t}),m.isValidElement(a)?m.cloneElement(a,void 0,s):null)}return m.createElement(dS,ue({},r,{ref:t}),n)});ZN.displayName="Slot";const dS=m.forwardRef((e,t)=>{const{children:n,...r}=e;return m.isValidElement(n)?m.cloneElement(n,{...nSe(r,n.props),ref:t?Ba(t,n.ref):n.ref}):m.Children.count(n)>1?m.Children.only(null):null});dS.displayName="SlotClone";const eSe=({children:e})=>m.createElement(m.Fragment,null,e);function tSe(e){return m.isValidElement(e)&&e.type===eSe}function nSe(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...s)=>{i(...s),o(...s)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}const fS=["Enter"," "],rSe=["ArrowDown","PageUp","Home"],eL=["ArrowUp","PageDown","End"],oSe=[...rSe,...eL],iSe={ltr:[...fS,"ArrowRight"],rtl:[...fS,"ArrowLeft"]},aSe={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Dv="Menu",[Hh,sSe,lSe]=_b(Dv),[$c,tL]=hr(Dv,[lSe,oa,gd]),M2=oa(),nL=gd(),[cSe,Oc]=$c(Dv),[uSe,Mp]=$c(Dv),dSe=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:i,modal:a=!0}=e,s=M2(t),[l,c]=m.useState(null),u=m.useRef(!1),d=Xn(i),h=vc(o);return m.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),m.createElement(mp,s,m.createElement(cSe,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c},m.createElement(uSe,{scope:t,onClose:m.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:h,modal:a},r)))},rL=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=M2(n);return m.createElement(bp,ue({},o,r,{ref:t}))}),oL="MenuPortal",[fSe,iL]=$c(oL,{forceMount:void 0}),hSe=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,i=Oc(oL,t);return m.createElement(fSe,{scope:t,forceMount:n},m.createElement(pr,{present:n||i.open},m.createElement(aE,{asChild:!0,container:o},r)))},vi="MenuContent",[pSe,k2]=$c(vi),gSe=m.forwardRef((e,t)=>{const n=iL(vi,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,i=Oc(vi,e.__scopeMenu),a=Mp(vi,e.__scopeMenu);return m.createElement(Hh.Provider,{scope:e.__scopeMenu},m.createElement(pr,{present:r||i.open},m.createElement(Hh.Slot,{scope:e.__scopeMenu},a.modal?m.createElement(mSe,ue({},o,{ref:t})):m.createElement(bSe,ue({},o,{ref:t})))))}),mSe=m.forwardRef((e,t)=>{const n=Oc(vi,e.__scopeMenu),r=m.useRef(null),o=Rt(t,r);return m.useEffect(()=>{const i=r.current;if(i)return _p(i)},[]),m.createElement(I2,ue({},e,{ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ke(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)}))}),bSe=m.forwardRef((e,t)=>{const n=Oc(vi,e.__scopeMenu);return m.createElement(I2,ue({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)}))}),I2=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:s,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:p,disableOutsideScroll:v,...b}=e,x=Oc(vi,n),y=Mp(vi,n),_=M2(n),S=nL(n),C=sSe(n),[E,$]=m.useState(null),T=m.useRef(null),D=Rt(t,T,x.onContentChange),M=m.useRef(0),L=m.useRef(""),F=m.useRef(0),z=m.useRef(null),X=m.useRef("right"),G=m.useRef(0),A=v?TE:m.Fragment,U=v?{as:ZN,allowPinchZoom:!0}:void 0,V=q=>{var O,H;const Y=L.current+q,I=C().filter(re=>!re.disabled),te=document.activeElement,ce=(O=I.find(re=>re.ref.current===te))===null||O===void 0?void 0:O.textValue,de=I.map(re=>re.textValue),he=NSe(de,Y,ce),ie=(H=I.find(re=>re.textValue===he))===null||H===void 0?void 0:H.ref.current;(function re(le){L.current=le,window.clearTimeout(M.current),le!==""&&(M.current=window.setTimeout(()=>re(""),1e3))})(Y),ie&&setTimeout(()=>ie.focus())};m.useEffect(()=>()=>window.clearTimeout(M.current),[]),SE();const K=m.useCallback(q=>{var O,H;return X.current===((O=z.current)===null||O===void 0?void 0:O.side)&&FSe(q,(H=z.current)===null||H===void 0?void 0:H.area)},[]);return m.createElement(pSe,{scope:n,searchRef:L,onItemEnter:m.useCallback(q=>{K(q)&&q.preventDefault()},[K]),onItemLeave:m.useCallback(q=>{var O;K(q)||((O=T.current)===null||O===void 0||O.focus(),$(null))},[K]),onTriggerLeave:m.useCallback(q=>{K(q)&&q.preventDefault()},[K]),pointerGraceTimerRef:F,onPointerGraceIntentChange:m.useCallback(q=>{z.current=q},[])},m.createElement(A,U,m.createElement(CE,{asChild:!0,trapped:o,onMountAutoFocus:ke(i,q=>{var O;q.preventDefault(),(O=T.current)===null||O===void 0||O.focus()}),onUnmountAutoFocus:a},m.createElement(yp,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:p},m.createElement(jS,ue({asChild:!0},S,{dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:E,onCurrentTabStopIdChange:$,onEntryFocus:ke(l,q=>{y.isUsingKeyboardRef.current||q.preventDefault()})}),m.createElement(vp,ue({role:"menu","aria-orientation":"vertical","data-state":uL(x.open),"data-radix-menu-content":"",dir:y.dir},_,b,{ref:D,style:{outline:"none",...b.style},onKeyDown:ke(b.onKeyDown,q=>{const H=q.target.closest("[data-radix-menu-content]")===q.currentTarget,Y=q.ctrlKey||q.altKey||q.metaKey,I=q.key.length===1;H&&(q.key==="Tab"&&q.preventDefault(),!Y&&I&&V(q.key));const te=T.current;if(q.target!==te||!oSe.includes(q.key))return;q.preventDefault();const de=C().filter(he=>!he.disabled).map(he=>he.ref.current);eL.includes(q.key)&&de.reverse(),kSe(de)}),onBlur:ke(e.onBlur,q=>{q.currentTarget.contains(q.target)||(window.clearTimeout(M.current),L.current="")}),onPointerMove:ke(e.onPointerMove,Wh(q=>{const O=q.target,H=G.current!==q.clientX;if(q.currentTarget.contains(O)&&H){const Y=q.clientX>G.current?"right":"left";X.current=Y,G.current=q.clientX}}))})))))))}),vSe=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.createElement(Qe.div,ue({role:"group"},r,{ref:t}))}),ySe=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.createElement(Qe.div,ue({},r,{ref:t}))}),hS="MenuItem",GA="menu.itemSelect",N2=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,i=m.useRef(null),a=Mp(hS,e.__scopeMenu),s=k2(hS,e.__scopeMenu),l=Rt(t,i),c=m.useRef(!1),u=()=>{const d=i.current;if(!n&&d){const h=new CustomEvent(GA,{bubbles:!0,cancelable:!0});d.addEventListener(GA,p=>r==null?void 0:r(p),{once:!0}),fk(d,h),h.defaultPrevented?c.current=!1:a.onClose()}};return m.createElement(aL,ue({},o,{ref:l,disabled:n,onClick:ke(e.onClick,u),onPointerDown:d=>{var h;(h=e.onPointerDown)===null||h===void 0||h.call(e,d),c.current=!0},onPointerUp:ke(e.onPointerUp,d=>{var h;c.current||(h=d.currentTarget)===null||h===void 0||h.click()}),onKeyDown:ke(e.onKeyDown,d=>{const h=s.searchRef.current!=="";n||h&&d.key===" "||fS.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})}))}),aL=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...i}=e,a=k2(hS,n),s=nL(n),l=m.useRef(null),c=Rt(t,l),[u,d]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const v=l.current;if(v){var b;p(((b=v.textContent)!==null&&b!==void 0?b:"").trim())}},[i.children]),m.createElement(Hh.ItemSlot,{scope:n,disabled:r,textValue:o??h},m.createElement(zS,ue({asChild:!0},s,{focusable:!r}),m.createElement(Qe.div,ue({role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0},i,{ref:c,onPointerMove:ke(e.onPointerMove,Wh(v=>{r?a.onItemLeave(v):(a.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus())})),onPointerLeave:ke(e.onPointerLeave,Wh(v=>a.onItemLeave(v))),onFocus:ke(e.onFocus,()=>d(!0)),onBlur:ke(e.onBlur,()=>d(!1))}))))}),xSe=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return m.createElement(lL,{scope:e.__scopeMenu,checked:n},m.createElement(N2,ue({role:"menuitemcheckbox","aria-checked":cb(n)?"mixed":n},o,{ref:t,"data-state":L2(n),onSelect:ke(o.onSelect,()=>r==null?void 0:r(cb(n)?!0:!n),{checkForDefaultPrevented:!1})})))}),wSe="MenuRadioGroup",[_Se,SSe]=$c(wSe,{value:void 0,onValueChange:()=>{}}),CSe=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,i=Xn(r);return m.createElement(_Se,{scope:e.__scopeMenu,value:n,onValueChange:i},m.createElement(vSe,ue({},o,{ref:t})))}),ESe="MenuRadioItem",RSe=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=SSe(ESe,e.__scopeMenu),i=n===o.value;return m.createElement(lL,{scope:e.__scopeMenu,checked:i},m.createElement(N2,ue({role:"menuitemradio","aria-checked":i},r,{ref:t,"data-state":L2(i),onSelect:ke(r.onSelect,()=>{var a;return(a=o.onValueChange)===null||a===void 0?void 0:a.call(o,n)},{checkForDefaultPrevented:!1})})))}),sL="MenuItemIndicator",[lL,PSe]=$c(sL,{checked:!1}),$Se=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,i=PSe(sL,n);return m.createElement(pr,{present:r||cb(i.checked)||i.checked===!0},m.createElement(Qe.span,ue({},o,{ref:t,"data-state":L2(i.checked)})))}),OSe=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.createElement(Qe.div,ue({role:"separator","aria-orientation":"horizontal"},r,{ref:t}))}),TSe="MenuSub",[m5e,cL]=$c(TSe),Nm="MenuSubTrigger",DSe=m.forwardRef((e,t)=>{const n=Oc(Nm,e.__scopeMenu),r=Mp(Nm,e.__scopeMenu),o=cL(Nm,e.__scopeMenu),i=k2(Nm,e.__scopeMenu),a=m.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:l}=i,c={__scopeMenu:e.__scopeMenu},u=m.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return m.useEffect(()=>u,[u]),m.useEffect(()=>{const d=s.current;return()=>{window.clearTimeout(d),l(null)}},[s,l]),m.createElement(rL,ue({asChild:!0},c),m.createElement(aL,ue({id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":uL(n.open)},e,{ref:Ba(t,o.onTriggerChange),onClick:d=>{var h;(h=e.onClick)===null||h===void 0||h.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ke(e.onPointerMove,Wh(d=>{i.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!a.current&&(i.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:ke(e.onPointerLeave,Wh(d=>{var h;u();const p=(h=n.content)===null||h===void 0?void 0:h.getBoundingClientRect();if(p){var v;const b=(v=n.content)===null||v===void 0?void 0:v.dataset.side,x=b==="right",y=x?-5:5,_=p[x?"left":"right"],S=p[x?"right":"left"];i.onPointerGraceIntentChange({area:[{x:d.clientX+y,y:d.clientY},{x:_,y:p.top},{x:S,y:p.top},{x:S,y:p.bottom},{x:_,y:p.bottom}],side:b}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(d),d.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:ke(e.onKeyDown,d=>{const h=i.searchRef.current!=="";if(!(e.disabled||h&&d.key===" ")&&iSe[r.dir].includes(d.key)){var p;n.onOpenChange(!0),(p=n.content)===null||p===void 0||p.focus(),d.preventDefault()}})})))}),ASe="MenuSubContent",MSe=m.forwardRef((e,t)=>{const n=iL(vi,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,i=Oc(vi,e.__scopeMenu),a=Mp(vi,e.__scopeMenu),s=cL(ASe,e.__scopeMenu),l=m.useRef(null),c=Rt(t,l);return m.createElement(Hh.Provider,{scope:e.__scopeMenu},m.createElement(pr,{present:r||i.open},m.createElement(Hh.Slot,{scope:e.__scopeMenu},m.createElement(I2,ue({id:s.contentId,"aria-labelledby":s.triggerId},o,{ref:c,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var d;a.isUsingKeyboardRef.current&&((d=l.current)===null||d===void 0||d.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:ke(e.onFocusOutside,u=>{u.target!==s.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:ke(e.onEscapeKeyDown,u=>{a.onClose(),u.preventDefault()}),onKeyDown:ke(e.onKeyDown,u=>{const d=u.currentTarget.contains(u.target),h=aSe[a.dir].includes(u.key);if(d&&h){var p;i.onOpenChange(!1),(p=s.trigger)===null||p===void 0||p.focus(),u.preventDefault()}})})))))});function uL(e){return e?"open":"closed"}function cb(e){return e==="indeterminate"}function L2(e){return cb(e)?"indeterminate":e?"checked":"unchecked"}function kSe(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ISe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function NSe(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let a=ISe(e,Math.max(i,0));o.length===1&&(a=a.filter(c=>c!==n));const l=a.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function LSe(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const s=t[i].x,l=t[i].y,c=t[a].x,u=t[a].y;l>r!=u>r&&n<(c-s)*(r-l)/(u-l)+s&&(o=!o)}return o}function FSe(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return LSe(n,t)}function Wh(e){return t=>t.pointerType==="mouse"?e(t):void 0}const jSe=dSe,zSe=rL,BSe=hSe,VSe=gSe,HSe=ySe,WSe=N2,USe=xSe,qSe=CSe,GSe=RSe,YSe=$Se,KSe=OSe,XSe=DSe,QSe=MSe,dL="DropdownMenu",[JSe,b5e]=hr(dL,[tL]),Mo=tL(),[ZSe,fL]=JSe(dL),eCe=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:i,onOpenChange:a,modal:s=!0}=e,l=Mo(t),c=m.useRef(null),[u=!1,d]=Fr({prop:o,defaultProp:i,onChange:a});return m.createElement(ZSe,{scope:t,triggerId:yi(),triggerRef:c,contentId:yi(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(h=>!h),[d]),modal:s},m.createElement(jSe,ue({},l,{open:u,onOpenChange:d,dir:r,modal:s}),n))},tCe="DropdownMenuTrigger",nCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,i=fL(tCe,n),a=Mo(n);return m.createElement(zSe,ue({asChild:!0},a),m.createElement(Qe.button,ue({type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r},o,{ref:Ba(t,i.triggerRef),onPointerDown:ke(e.onPointerDown,s=>{!r&&s.button===0&&s.ctrlKey===!1&&(i.onOpenToggle(),i.open||s.preventDefault())}),onKeyDown:ke(e.onKeyDown,s=>{r||(["Enter"," "].includes(s.key)&&i.onOpenToggle(),s.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(s.key)&&s.preventDefault())})})))}),rCe=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Mo(t);return m.createElement(BSe,ue({},r,n))},oCe="DropdownMenuContent",iCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=fL(oCe,n),i=Mo(n),a=m.useRef(!1);return m.createElement(VSe,ue({id:o.contentId,"aria-labelledby":o.triggerId},i,r,{ref:t,onCloseAutoFocus:ke(e.onCloseAutoFocus,s=>{var l;a.current||(l=o.triggerRef.current)===null||l===void 0||l.focus(),a.current=!1,s.preventDefault()}),onInteractOutside:ke(e.onInteractOutside,s=>{const l=s.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!o.modal||u)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))}),aCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(HSe,ue({},o,r,{ref:t}))}),sCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(WSe,ue({},o,r,{ref:t}))}),lCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(USe,ue({},o,r,{ref:t}))}),cCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(qSe,ue({},o,r,{ref:t}))}),uCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(GSe,ue({},o,r,{ref:t}))}),dCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(YSe,ue({},o,r,{ref:t}))}),fCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(KSe,ue({},o,r,{ref:t}))}),hCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(XSe,ue({},o,r,{ref:t}))}),pCe=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mo(n);return m.createElement(QSe,ue({},o,r,{ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))}),gCe=eCe,mCe=nCe,bCe=rCe,hL=iCe,pL=aCe,gL=sCe,mL=lCe,vCe=cCe,bL=uCe,vL=dCe,yL=fCe,xL=hCe,wL=pCe,yCe=gCe,xCe=mCe,wCe=vCe,_Ce=j.forwardRef(({className:e,inset:t,children:n,...r},o)=>R.jsxs(xL,{ref:o,className:ye("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,R.jsx(jb,{className:"ml-auto h-4 w-4"})]}));_Ce.displayName=xL.displayName;const SCe=j.forwardRef(({className:e,...t},n)=>R.jsx(bc,{children:R.jsx(wL,{ref:n,className:ye("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t})}));SCe.displayName=wL.displayName;const _L=j.forwardRef(({className:e,sideOffset:t=4,...n},r)=>R.jsx(bCe,{children:R.jsx(bc,{children:R.jsx(hL,{ref:r,sideOffset:t,className:ye("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})})}));_L.displayName=hL.displayName;const SL=j.forwardRef(({className:e,inset:t,...n},r)=>R.jsx(gL,{ref:r,className:ye("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));SL.displayName=gL.displayName;const CL=j.forwardRef(({className:e,children:t,checked:n,...r},o)=>R.jsxs(mL,{ref:o,className:ye("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[R.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:R.jsx(vL,{children:R.jsx(up,{className:"h-4 w-4"})})}),t]}));CL.displayName=mL.displayName;const EL=j.forwardRef(({className:e,children:t,...n},r)=>R.jsxs(bL,{ref:r,className:ye("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[R.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:R.jsx(vL,{children:R.jsx(gC,{className:"h-2 w-2 fill-current"})})}),t]}));EL.displayName=bL.displayName;const RL=j.forwardRef(({className:e,inset:t,...n},r)=>R.jsx(pL,{ref:r,className:ye("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));RL.displayName=pL.displayName;const PL=j.forwardRef(({className:e,...t},n)=>R.jsx(yL,{ref:n,className:ye("-mx-1 my-1 h-px bg-muted",e),...t}));PL.displayName=yL.displayName;const CCe=wN,ECe=_N,RCe=SN,$L=j.forwardRef(({className:e,...t},n)=>R.jsx($2,{ref:n,className:ye("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));$L.displayName=$2.displayName;const OL=j.forwardRef(({className:e,children:t,...n},r)=>R.jsx(RCe,{children:R.jsxs(bc,{children:[R.jsx($L,{}),R.jsxs(O2,{ref:r,className:ye("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,R.jsxs(A2,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[R.jsx(md,{className:"h-4 w-4"}),R.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}));OL.displayName=O2.displayName;const TL=({className:e,...t})=>R.jsx("div",{className:ye("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});TL.displayName="DialogHeader";const DL=({className:e,...t})=>R.jsx("div",{className:ye("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});DL.displayName="DialogFooter";const AL=j.forwardRef(({className:e,...t},n)=>R.jsx(T2,{ref:n,className:ye("text-lg font-semibold leading-none tracking-tight",e),...t}));AL.displayName=T2.displayName;const ML=j.forwardRef(({className:e,...t},n)=>R.jsx(D2,{ref:n,className:ye("text-sm text-muted-foreground",e),...t}));ML.displayName=D2.displayName;const kL=m.forwardRef(({className:e,...t},n)=>R.jsx("div",{role:"editor-panel",ref:n,className:ye("flex grow h-full",e),...t}));kL.displayName="EditorPanel";const IL=m.forwardRef(({className:e,...t},n)=>R.jsx("div",{ref:n,className:ye(" flex flex-col space-y-2 w-[270px]",e),...t}));IL.displayName="EditorAside";const NL=m.forwardRef(({className:e,...t},n)=>R.jsx("div",{ref:n,className:ye(" grow",e),...t}));NL.displayName="EditorMain";function PCe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function YA(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function KA(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?YA(Object(n),!0).forEach(function(r){PCe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YA(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function $Ce(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,i;for(i=0;i<r.length;i++)o=r[i],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}function OCe(e,t){if(e==null)return{};var n=$Ce(e,t),r,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)r=i[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function TCe(e,t){return DCe(e)||ACe(e,t)||MCe(e,t)||kCe()}function DCe(e){if(Array.isArray(e))return e}function ACe(e,t){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(e)))){var n=[],r=!0,o=!1,i=void 0;try{for(var a=e[Symbol.iterator](),s;!(r=(s=a.next()).done)&&(n.push(s.value),!(t&&n.length===t));r=!0);}catch(l){o=!0,i=l}finally{try{!r&&a.return!=null&&a.return()}finally{if(o)throw i}}return n}}function MCe(e,t){if(e){if(typeof e=="string")return XA(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return XA(e,t)}}function XA(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function kCe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
431
431
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ICe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function QA(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function JA(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?QA(Object(n),!0).forEach(function(r){ICe(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):QA(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function NCe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r){return t.reduceRight(function(o,i){return i(o)},r)}}function Nf(e){return function t(){for(var n=this,r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var a=arguments.length,s=new Array(a),l=0;l<a;l++)s[l]=arguments[l];return t.apply(n,[].concat(o,s))}}}function ub(e){return{}.toString.call(e).includes("Object")}function LCe(e){return!Object.keys(e).length}function Uh(e){return typeof e=="function"}function FCe(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function jCe(e,t){return ub(t)||Ls("changeType"),Object.keys(t).some(function(n){return!FCe(e,n)})&&Ls("changeField"),t}function zCe(e){Uh(e)||Ls("selectorType")}function BCe(e){Uh(e)||ub(e)||Ls("handlerType"),ub(e)&&Object.values(e).some(function(t){return!Uh(t)})&&Ls("handlersType")}function VCe(e){e||Ls("initialIsRequired"),ub(e)||Ls("initialType"),LCe(e)&&Ls("initialContent")}function HCe(e,t){throw new Error(e[t]||e.default)}var WCe={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},Ls=Nf(HCe)(WCe),Lm={changes:jCe,selector:zCe,handler:BCe,initial:VCe};function UCe(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Lm.initial(e),Lm.handler(t);var n={current:e},r=Nf(YCe)(n,t),o=Nf(GCe)(n),i=Nf(Lm.changes)(e),a=Nf(qCe)(n);function s(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(u){return u};return Lm.selector(c),c(n.current)}function l(c){NCe(r,o,i,a)(c)}return[s,l]}function qCe(e,t){return Uh(t)?t(e.current):t}function GCe(e,t){return e.current=JA(JA({},e.current),t),t}function YCe(e,t,n){return Uh(t)?t(e.current):Object.keys(n).forEach(function(r){var o;return(o=t[r])===null||o===void 0?void 0:o.call(t,e.current[r])}),n}var KCe={create:UCe},XCe={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs"}};function QCe(e){return function t(){for(var n=this,r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return o.length>=e.length?e.apply(this,o):function(){for(var a=arguments.length,s=new Array(a),l=0;l<a;l++)s[l]=arguments[l];return t.apply(n,[].concat(o,s))}}}function JCe(e){return{}.toString.call(e).includes("Object")}function ZCe(e){return e||ZA("configIsRequired"),JCe(e)||ZA("configType"),e.urls?(eEe(),{paths:{vs:e.urls.monacoBase}}):e}function eEe(){console.warn(LL.deprecation)}function tEe(e,t){throw new Error(e[t]||e.default)}var LL={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
432
432
  You are using deprecated way of configuration.
433
433
 
@@ -1,4 +1,4 @@
1
- import { c as q, p as hs, u as z, n as Fs, o as Oe, q as e, r as Is, s as Ts, t as F, j as Ds, v as Ms, w as Ls, x as Es, y as As, L as H, z as re, A as oa, E as ca, H as da, J as ua, K as rt, M as it, N as ot, O as Ys, Q as W, R as Je, V as u, W as ct, F as ha, Y as We, Z as Ye, _ as Vs, $ as ma, a0 as qs, a1 as fe, a2 as ge, a3 as je, a4 as be, a5 as ke, a6 as ye, a7 as Q, T as Rs, a8 as _s, a9 as Hs, aa as $s, ab as xa, ac as pa, ad as xe, ae as dt, af as ut, ag as fa, ah as ht, C as mt, ai as xt, aj as ga, B as pt, ak as Ps, al as ft, am as Xs, an as ja, ao as Ns, ap as me, aq as we, ar as de, as as ms, at as ba, au as gt, av as jt, aw as ya, ax as bt, ay as yt, az as vt, aA as Ct, aB as Nt, aC as qe, aD as Ss, aE as St, a as wt, aF as Ke, aG as ws, aH as Ve, aI as ks, aJ as kt, aK as zt, aL as Ot, aM as Ft, aN as It, aO as Tt, aP as Cs, aQ as Dt, aR as Zs, aS as Mt, aT as ea, aU as Lt, aV as Et, aW as At, aX as va, aY as ce, aZ as Bs, a_ as Ca, a$ as Vt, b0 as qt, b1 as rs, b2 as Rt, b3 as _t, b4 as Ht, b5 as $t, b6 as Pt, b7 as Bt, b8 as Ut, l as Gt, b9 as xs, ba as Na, bb as Sa, bc as wa, bd as is, be as ka, bf as os, bg as sa, bh as Kt, bi as Qt, bj as ps, bk as fs, bl as gs, bm as Jt, bn as Wt, X as za, bo as Yt, bp as Xt, bq as Zt, br as js, bs as Te, f as en, bt as Ge, bu as Oa, bv as sn, bw as an, bx as cs, by as tn, bz as nn, bA as ln, bB as aa, bC as rn, bD as on, bE as cn, bF as dn, bG as un, bH as hn, bI as mn, bJ as xn, bK as De, bL as U, bM as G, bN as Us, bO as K, bP as pn, bQ as Fa, bR as fn, bS as gn, bT as jn, bU as bn, bV as yn, bW as vn, bX as Cn, bY as Nn, bZ as Sn } from "./index-zdZ1lpAC.js";
1
+ import { c as q, p as hs, u as z, n as Fs, o as Oe, q as e, r as Is, s as Ts, t as F, j as Ds, v as Ms, w as Ls, x as Es, y as As, L as H, z as re, A as oa, E as ca, H as da, J as ua, K as rt, M as it, N as ot, O as Ys, Q as W, R as Je, V as u, W as ct, F as ha, Y as We, Z as Ye, _ as Vs, $ as ma, a0 as qs, a1 as fe, a2 as ge, a3 as je, a4 as be, a5 as ke, a6 as ye, a7 as Q, T as Rs, a8 as _s, a9 as Hs, aa as $s, ab as xa, ac as pa, ad as xe, ae as dt, af as ut, ag as fa, ah as ht, C as mt, ai as xt, aj as ga, B as pt, ak as Ps, al as ft, am as Xs, an as ja, ao as Ns, ap as me, aq as we, ar as de, as as ms, at as ba, au as gt, av as jt, aw as ya, ax as bt, ay as yt, az as vt, aA as Ct, aB as Nt, aC as qe, aD as Ss, aE as St, a as wt, aF as Ke, aG as ws, aH as Ve, aI as ks, aJ as kt, aK as zt, aL as Ot, aM as Ft, aN as It, aO as Tt, aP as Cs, aQ as Dt, aR as Zs, aS as Mt, aT as ea, aU as Lt, aV as Et, aW as At, aX as va, aY as ce, aZ as Bs, a_ as Ca, a$ as Vt, b0 as qt, b1 as rs, b2 as Rt, b3 as _t, b4 as Ht, b5 as $t, b6 as Pt, b7 as Bt, b8 as Ut, l as Gt, b9 as xs, ba as Na, bb as Sa, bc as wa, bd as is, be as ka, bf as os, bg as sa, bh as Kt, bi as Qt, bj as ps, bk as fs, bl as gs, bm as Jt, bn as Wt, X as za, bo as Yt, bp as Xt, bq as Zt, br as js, bs as Te, f as en, bt as Ge, bu as Oa, bv as sn, bw as an, bx as cs, by as tn, bz as nn, bA as ln, bB as aa, bC as rn, bD as on, bE as cn, bF as dn, bG as un, bH as hn, bI as mn, bJ as xn, bK as De, bL as U, bM as G, bN as Us, bO as K, bP as pn, bQ as Fa, bR as fn, bS as gn, bT as jn, bU as bn, bV as yn, bW as vn, bX as Cn, bY as Nn, bZ as Sn } from "./index-7j85QQRg.js";
2
2
  import * as ta from "react";
3
3
  import ze, { useState as R, useMemo as zs, useEffect as Z, useRef as Xe, Suspense as wn } from "react";
4
4
  import "react-dom";
@@ -2962,7 +2962,7 @@ function Xa(s) {
2962
2962
  const [t, a] = R(null);
2963
2963
  return Z(() => {
2964
2964
  s && (async () => {
2965
- const i = (await import("./lucide-react-Mpu2F2_p.js"))[s];
2965
+ const i = (await import("./lucide-react-DAVXh0-V.js"))[s];
2966
2966
  a(i);
2967
2967
  })();
2968
2968
  }, [s]), t;
@@ -1,6 +1,6 @@
1
- import { c as a, B as e, C as t, a as c, b as h, d, e as o, f as y, g as i, h as s, F as n, i as r, G as k, I as p, P as l, j as M, S as u, k as v, l as g, T as m, U as x, X as L } from "./index-zdZ1lpAC.js";
2
- import { m as Pv } from "./index-zdZ1lpAC.js";
3
- import { B as w, C, a as f, b as I, c as S, d as q, e as b, f as H, g as A, h as z, E as P, i as V, j, k as B, G as F, H as D, l as R, m as T, K as U, L as O, n as Z, o as G, p as W, M as E, q as X, N, P as K, r as J, s as Q, S as Y, t as _, u as $, v as a1, w as e1, T as t1, x as c1, y as h1, U as d1 } from "./index-7kOro_zu.js";
1
+ import { c as a, B as e, C as t, a as c, b as h, d, e as o, f as y, g as i, h as s, F as n, i as r, G as k, I as p, P as l, j as M, S as u, k as v, l as g, T as m, U as x, X as L } from "./index-7j85QQRg.js";
2
+ import { m as Pv } from "./index-7j85QQRg.js";
3
+ import { B as w, C, a as f, b as I, c as S, d as q, e as b, f as H, g as A, h as z, E as P, i as V, j, k as B, G as F, H as D, l as R, m as T, K as U, L as O, n as Z, o as G, p as W, M as E, q as X, N, P as K, r as J, s as Q, S as Y, t as _, u as $, v as a1, w as e1, T as t1, x as c1, y as h1, U as d1 } from "./index-xD7LZFEm.js";
4
4
  import "react";
5
5
  import "react-dom";
6
6
  /**
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-1p9AH5Uv.js"),a=require("./index-DoHEkv9j.js");require("react");require("react-dom");/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-tJEATyF7.js"),a=require("./index-5EyduRKw.js");require("react");require("react-dom");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-1p9AH5Uv.js");require("react");require("react-dom");exports.Dashboard=e.Dashboard;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-tJEATyF7.js");require("react");require("react-dom");exports.Dashboard=e.Dashboard;
@@ -1,4 +1,4 @@
1
- import { D as p } from "../chunks/index-zdZ1lpAC.js";
1
+ import { D as p } from "../chunks/index-7j85QQRg.js";
2
2
  import "react";
3
3
  import "react-dom";
4
4
  export {
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-1p9AH5Uv.js"),a=require("./chunks/index-DoHEkv9j.js");require("react");require("react-dom");exports.BOOLEAN_DATA_TYPES=e.BOOLEAN_DATA_TYPES;exports.DATE_DATA_TYPES=e.DATE_DATA_TYPES;exports.Dashboard=e.Dashboard;exports.DashboardWC=e.DashboardWC;exports.NUMBER_DATA_TYPES=e.NUMBER_DATA_TYPES;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.TEXT_DATA_TYPES=e.TEXT_DATA_TYPES;exports.createSqlGenConfig=e.createSqlGenConfig;exports.fmt=e.fmt;exports.getColumnDataType=e.getColumnDataType;exports.getFilterValueType=e.getFilterValueType;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.resolveDataType=e.resolveDataType;exports.useCard=e.useCard;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardStore=e.useDashboardStore;exports.useEditorActions=e.useEditorActions;exports.useEditorStore=e.useEditorStore;exports.SelectComponent=a.SelectComponent;exports.Surfboard=a.DashboardPlus;exports.cleanCard=a.cleanCard;exports.getDashbaordStateWithoutData=a.getDashbaordStateWithoutData;exports.useEditorAside=a.useEditorAside;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-tJEATyF7.js"),a=require("./chunks/index-5EyduRKw.js");require("react");require("react-dom");exports.BOOLEAN_DATA_TYPES=e.BOOLEAN_DATA_TYPES;exports.DATE_DATA_TYPES=e.DATE_DATA_TYPES;exports.Dashboard=e.Dashboard;exports.DashboardWC=e.DashboardWC;exports.NUMBER_DATA_TYPES=e.NUMBER_DATA_TYPES;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.TEXT_DATA_TYPES=e.TEXT_DATA_TYPES;exports.createSqlGenConfig=e.createSqlGenConfig;exports.fmt=e.fmt;exports.getColumnDataType=e.getColumnDataType;exports.getFilterValueType=e.getFilterValueType;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.resolveDataType=e.resolveDataType;exports.useCard=e.useCard;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardStore=e.useDashboardStore;exports.useEditorActions=e.useEditorActions;exports.useEditorStore=e.useEditorStore;exports.SelectComponent=a.SelectComponent;exports.Surfboard=a.DashboardPlus;exports.cleanCard=a.cleanCard;exports.getDashbaordStateWithoutData=a.getDashbaordStateWithoutData;exports.useEditorAside=a.useEditorAside;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ai as o, ah as r, D as i, b$ as D, ag as T, c3 as d, af as l, ab as n, ad as u, c1 as A, c0 as S, an as E, ac as b, al as c, c2 as m, b_ as p, n as _, u as h, aY as C, V as f } from "./chunks/index-zdZ1lpAC.js";
2
- import { A as Y, D as y, I as P, F as q, z as N } from "./chunks/index-7kOro_zu.js";
1
+ import { ai as o, ah as r, D as i, b$ as D, ag as T, c3 as d, af as l, ab as n, ad as u, c1 as A, c0 as S, an as E, ac as b, al as c, c2 as m, b_ as p, n as _, u as h, aY as C, V as f } from "./chunks/index-7j85QQRg.js";
2
+ import { A as Y, D as y, I as P, F as q, z as N } from "./chunks/index-xD7LZFEm.js";
3
3
  import "react";
4
4
  import "react-dom";
5
5
  export {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-DoHEkv9j.js");require("../chunks/index-1p9AH5Uv.js");require("react");require("react-dom");exports.Surfboard=e.DashboardPlus;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-5EyduRKw.js");require("../chunks/index-tJEATyF7.js");require("react");require("react-dom");exports.Surfboard=e.DashboardPlus;
@@ -1,5 +1,5 @@
1
- import { D as i } from "../chunks/index-7kOro_zu.js";
2
- import "../chunks/index-zdZ1lpAC.js";
1
+ import { D as i } from "../chunks/index-xD7LZFEm.js";
2
+ import "../chunks/index-7j85QQRg.js";
3
3
  import "react";
4
4
  import "react-dom";
5
5
  export {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.0.78",
8
+ "version": "0.0.79",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",