react-semaphor 0.0.121 → 0.0.123

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.
@@ -50624,8 +50624,8 @@ function Ude({
50624
50624
  className: "flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",
50625
50625
  children: [
50626
50626
  /* @__PURE__ */ v.jsxs(um, { children: [
50627
- /* @__PURE__ */ v.jsx(dm, { children: "Ask" }),
50628
- /* @__PURE__ */ v.jsx(fm, { children: "Ask me about your data" })
50627
+ /* @__PURE__ */ v.jsx(dm, { children: "Assistant" }),
50628
+ /* @__PURE__ */ v.jsx(fm, { children: "What can I help you with?" })
50629
50629
  ] }),
50630
50630
  /* @__PURE__ */ v.jsx(
50631
50631
  "div",
@@ -52643,7 +52643,9 @@ function che() {
52643
52643
  );
52644
52644
  ye(() => {
52645
52645
  var D, N, j, z, V, se, J, F, Z, G;
52646
- o(FP(n)), a(((j = (N = (D = n == null ? void 0 : n.chartOptions) == null ? void 0 : D.scales) == null ? void 0 : N[r]) == null ? void 0 : j.min) || ""), c(((se = (V = (z = n == null ? void 0 : n.chartOptions) == null ? void 0 : z.scales) == null ? void 0 : V[r]) == null ? void 0 : se.max) || ""), p(
52646
+ o(FP(n)), a(
52647
+ ((j = (N = (D = n == null ? void 0 : n.chartOptions) == null ? void 0 : D.scales) == null ? void 0 : N[r]) == null ? void 0 : j.min) === 0 ? 0 : ""
52648
+ ), c(((se = (V = (z = n == null ? void 0 : n.chartOptions) == null ? void 0 : z.scales) == null ? void 0 : V[r]) == null ? void 0 : se.max) || ""), p(
52647
52649
  ((G = (Z = (F = (J = n == null ? void 0 : n.chartOptions) == null ? void 0 : J.scales) == null ? void 0 : F[r]) == null ? void 0 : Z.ticks) == null ? void 0 : G.stepSize) || ""
52648
52650
  );
52649
52651
  }, [e, n, r]);
@@ -52733,7 +52735,7 @@ function che() {
52733
52735
  /* @__PURE__ */ v.jsx(bm, { id: "type", children: /* @__PURE__ */ v.jsxs(gw, { children: [
52734
52736
  /* @__PURE__ */ v.jsx(wd, { children: "Option" }),
52735
52737
  /* @__PURE__ */ v.jsx(qo, { value: "linear", children: "Linear" }),
52736
- /* @__PURE__ */ v.jsx(qo, { value: "logarithmic", children: "logarithmic" })
52738
+ /* @__PURE__ */ v.jsx(qo, { value: "logarithmic", children: "Logarithmic" })
52737
52739
  ] }) })
52738
52740
  ]
52739
52741
  }
@@ -567,11 +567,11 @@ SELECT label, measure FROM table
567
567
  Table Columns: ${_==null?void 0:_.map(Y=>`${Y.column_name} | ${Y.data_type}`).join(", ")}
568
568
  User SQL: ${S}
569
569
  ${g&&`Base Queries: ${JSON.stringify(g)} `}`,O=` 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.
570
- Visual Query Syntax: ${Hre}`,{data:k,isLoading:T,isFetching:I,isError:F,refetch:$}=Si({queryKey:["ai-query"],queryFn:()=>cl("https://semaphor.cloud/api/v1/ai",(l==null?void 0:l.accessToken)||"",{user_content:`userContent: ${P} ${c?O:""}`}),enabled:!1});function z(Y){if(Y.toLowerCase().includes("bar"))v("bar");else if(Y.toLowerCase().includes("line"))v("line");else if(Y.toLowerCase().includes("bubble"))v("bubble");else if(Y.toLowerCase().includes("scatter"))v("scatter");else if(Y.toLowerCase().includes("stacked"))v("stackedBar");else if(Y.toLowerCase().includes("pie"))v("pie");else if(Y.toLowerCase().includes("donut")||Y.toLowerCase().includes("doughnut"))v("doughnut");else if(Y.toLowerCase().includes("radar"))v("radar");else return v("bar"),!1;return!0}m.useEffect(()=>{k&&w(Y=>[...Y,{role:"ai",content:k.response}])},[k]),m.useEffect(()=>{const Y=setTimeout(()=>{var D;a.current&&(a.current.scroll({top:a.current.scrollHeight,behavior:"smooth"}),(D=s.current)==null||D.focus())},100);return()=>clearTimeout(Y)},[y]);function V(){n&&(w(Y=>[...Y,{role:"user",content:n}]),z(n)&&u(!0),r(""),$())}m.useEffect(()=>{i&&(V(),o(!1))},[i,o]);const se={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},J={fontFamily:"monospace",fontSize:14,lineHeight:1.6},j={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},Z={p:({node:Y,...D})=>b.jsx("p",{style:se,...D}),code:({node:Y,...D})=>b.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...D}),pre:({node:Y,...D})=>b.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:J,children:[b.jsx("code",{className:"whitespace-normal text-sm",children:D.children}),b.jsxs("div",{className:"flex justify-start gap-2",children:[b.jsx(Je,{onClick:G,size:"sm",variant:"outline",children:b.jsx(V2,{})}),b.jsx(Je,{onClick:H=>{const ie=G(H);ie&&(t(!1),f(ie),p(!0))},size:"sm",variant:"outline",children:b.jsx(zz,{})})]})]}),li:({node:Y,...D})=>b.jsx("li",{style:j,...D})};function G(Y){const D=Y.currentTarget.closest("pre");if(!D)return;const H=D.textContent||D.innerText;return navigator.clipboard.writeText(H).then(()=>console.log("Text copied to clipboard")).catch(ie=>console.error("Error in copying text: ",ie)),H}function X(){return y==null?void 0:y.map((Y,D)=>Y.role==="user"?b.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[b.jsx($6,{className:"mr-2 h-5 w-5"}),b.jsx("div",{children:Y.content})]},D):Y.role==="ai"?b.jsx(b.Fragment,{children:b.jsx(Bre,{className:"w-full overflow-auto py-1",components:Z,children:k==null?void 0:k.response})}):b.jsx(b.Fragment,{}))}return b.jsxs(nx,{open:e,onOpenChange:t,children:[b.jsx(rx,{asChild:!0,children:b.jsx(Je,{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..."})}),b.jsxs(Yp,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[b.jsxs(Kp,{children:[b.jsx(Xp,{children:"Ask"}),b.jsx(Qp,{children:"Ask me about your data"})]}),b.jsx("div",{ref:a,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:b.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:X()})}),b.jsx("div",{children:b.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[b.jsx(yx,{autoFocus:!0,ref:s,onKeyDown:Y=>{Y.key==="Enter"&&!Y.shiftKey&&(Y.preventDefault(),r(""),V())},placeholder:"Type your question here...",onFocus:Y=>{const D=Y.target,H=D.value.length;D.setSelectionRange(H,H)},className:Ee("max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"),disabled:T||I,value:n,onChange:Y=>r(Y.target.value)})," ",b.jsx(Je,{className:"h-8",size:"sm",variant:"ghost",onClick:V,children:!T&&!I?b.jsx(jz,{}):b.jsx(ma,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var vT={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},bT=m.createContext&&m.createContext(vT),Ure=["attr","size","title"];function qre(e,t){if(e==null)return{};var n=Gre(e,t),r,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Gre(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o<r.length;o++)i=r[o],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function Eg(){return Eg=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Eg.apply(this,arguments)}function yT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Og(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?yT(Object(n),!0).forEach(function(r){Yre(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yT(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Yre(e,t,n){return t=Kre(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Kre(e){var t=Xre(e,"string");return typeof t=="symbol"?t:String(t)}function Xre(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function xT(e){return e&&e.map((t,n)=>m.createElement(t.tag,Og({key:n},t.attr),xT(t.child)))}function La(e){return t=>m.createElement(Qre,Eg({attr:Og({},e.attr)},t),xT(e.child))}function Qre(e){var t=n=>{var{attr:r,size:i,title:o}=e,s=qre(e,Ure),a=i||n.size||"1em",l;return n.className&&(l=n.className),e.className&&(l=(l?l+" ":"")+e.className),m.createElement("svg",Eg({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,s,{className:l,style:Og(Og({color:e.color||n.color},n.style),e.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),o&&m.createElement("title",null,o),e.children)};return bT!==void 0?m.createElement(bT.Consumer,null,n=>t(n)):t(vT)}function Zre(e){return La({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:[]}]})(e)}const wT=m.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r=!1,onPressedChange:i,...o}=e,[s=!1,a]=Qn({prop:n,onChange:i,defaultProp:r});return m.createElement(ze.button,ae({type:"button","aria-pressed":s,"data-state":s?"on":"off","data-disabled":e.disabled?"":void 0},o,{ref:t,onClick:Oe(e.onClick,()=>{e.disabled||a(!s)})}))}),Jre=cy("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),_T=de.forwardRef(({className:e,variant:t,size:n,...r},i)=>b.jsx(wT,{ref:i,className:Ee(Jre({variant:t,size:n,className:e})),...r}));_T.displayName=wT.displayName;function eie(){const{theme:e}=Zm(),t=m.useRef(),n=m.useRef(),[r,i]=m.useState(!1),[o,s]=m.useState(!1),[a,l]=m.useState(!1),[c,u]=m.useState(""),[f,g]=m.useState(!1),{authToken:p}=zi();he(W=>W.selectedSheetId);const v=he(W=>W.dashboard.baseQueries),y=pe(W=>W.card),w=he(W=>W.theme),_=pe(W=>W.isShowingVisual),S=pe(W=>W.selectedConnectionId),C=pe(W=>W.selectedDatabaseName),P=pe(W=>W.selectedSchemaName);he(W=>W.actions.updateFrameCard);const O=pe(W=>W.selectedTableName),k=pe(W=>W.card.sql),T=pe(W=>W.card.python),I=$w(k,v),F=pe(W=>W.selectedConnectionId),$=pe(W=>W.frame),z=pe(W=>W.filterValues),V=pe(W=>W.applyFilters),{setCardCustomCfg:se,setQueryResultColumns:J,setFilterValues:j,setCardSql:Z,setCardPython:G,setQueryError:X,setPythonStdOut:Y}=pe(W=>W.actions),D=pe(W=>W.onSave),H=pe(W=>W.actions.setApplyFilters),ie=pe(W=>W.onClose),R=pe(W=>W.actions.setCardData),ce=pe(W=>W.actions.setSqlGen),ve=pe(W=>W.runSql),ge=pe(W=>W.actions.setRunSql),fe=pe(W=>W.actions.setIsSqlRunning),{data:re,isLoading:ee,isFetching:oe,isSuccess:xe,isError:U,error:Te,status:$e,refetch:He}=Si({queryKey:[I,T],queryFn:()=>qc("https://semaphor.cloud/api/v1/query",(p==null?void 0:p.accessToken)||"",{connection_id:F,sql:I,python:T===Dg?"":T,active_filters:V?z:[]}),enabled:!1,retry:!1});m.useEffect(()=>{if(re&&(R(re.records),Y((re==null?void 0:re.output)||""),re.records.length>0)){const{dimensionKeys:W}=oi(re.records);J(W)}},[re,R,J,Y]),m.useEffect(()=>{ve&&(He(),ge(!1))},[ve,He,ge]),m.useEffect(()=>{(ee||oe)&&fe(!0),(U||xe)&&fe(!1),U?(X(Te.message),R([]),J([]),Y("")):X("")},[ee,oe,re,Y,U,xe,fe,R,J,X,Te]);function Xe(){Z(""),R([]),ce({}),se("")}const vt=W=>{n.current=W};function pt(){let W=k;k&&!k.includes("{{")&&(W=wJ(k),Z(W));const Se={...y,lastSelectedSchema:P,lastSelectedDatabase:C,lastSelectedTable:O,connectionId:S,type:_?y.type:"table",sql:W,customCfg:_?y.customCfg:null},Ne=$.cards.map(We=>We.id===y.id?Se:We);D==null||D({...$,cards:Ne})}function gt(){ie==null||ie()}function Kt(W){const Se=getComputedStyle(document.documentElement).getPropertyValue(W);return Bt(Se)}function Bt(W){const[Se,Ne,We]=W.split(" "),Ue=parseFloat(Se),un=parseFloat(Ne),bn=parseFloat(We),Tn=un/100,rr=bn/100,pn=(1-Math.abs(2*rr-1))*Tn,zt=pn*(1-Math.abs(Ue/60%2-1)),$n=rr-pn/2;let Vt=0,cr=0,An=0;0<=Ue&&Ue<60?(Vt=pn,cr=zt,An=0):60<=Ue&&Ue<120?(Vt=zt,cr=pn,An=0):120<=Ue&&Ue<180?(Vt=0,cr=pn,An=zt):180<=Ue&&Ue<240?(Vt=0,cr=zt,An=pn):240<=Ue&&Ue<300?(Vt=zt,cr=0,An=pn):300<=Ue&&Ue<360&&(Vt=pn,cr=0,An=zt),Vt=Math.round((Vt+$n)*255),cr=Math.round((cr+$n)*255),An=Math.round((An+$n)*255);const Ri=zn=>{const Er=zn.toString(16);return Er.length==1?"0"+Er:Er};return`#${Ri(Vt)}${Ri(cr)}${Ri(An)}`}m.useEffect(()=>{const W=t.current,Se=n.current;if(W){const Ne=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",We=w==="system"?Ne:w;W.editor.defineTheme("default",{base:We==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":We==="light"?"#ffffff":Kt("--background")}}),W.editor.setTheme("default")}return Se&&W&&Se.addCommand(W.KeyMod.Shift|W.KeyCode.Enter,function(){return console.log("Executing query..."),He(),!1}),()=>{}},[e,w,t.current]);function vn(W){t.current=W}function cn(){return b.jsxs(b.Fragment,{children:[o&&b.jsx("div",{className:" min-w-0 w-1/3 flex grow text-xs relative overflow-hidden border-l xbg-yellow-100 p-1 ",role:"editor-filter-container",children:b.jsxs("div",{className:" w-[99%] ",children:[b.jsxs("div",{className:"flex gap-2 pt-3 items-center",children:[b.jsx(SJ,{checked:V,onCheckedChange:()=>H(!V),text:"Apply Filters"}),b.jsx(CJ,{}),z&&o&&b.jsx(pa,{onClick:()=>s(!1),className:" text-foreground/50 hover:text-foreground hover:cursor-pointer bg-background/50 "})]}),b.jsx(hg,{theme:"default",onChange:W=>{if(W)try{JSON.parse(W),j(JSON.parse(W))}catch{}},defaultLanguage:"json",className:"min-h-[220px] mt-1",value:JSON.stringify(z,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),z&&!o&&b.jsx(iP,{onClick:()=>s(!0),className:Ee("absolute right-6 bottom-4 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer",{"text-red-800 font-bold":V})})]})}function Lo(){return b.jsxs(px,{className:"flex grow pb-1 ",direction:"vertical",role:"editor-resizable-group",children:[b.jsxs(rc,{id:"1",order:1,defaultSize:r?20:100,className:"flex grow relative",children:[b.jsx("div",{role:"sql-container",className:"flex relative w-[99%] ",children:b.jsx(hg,{theme:"default",className:"pt-3",onChange:W=>{Z(W)},value:k,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:vn,onMount:vt})}),r&&b.jsx("code",{className:"absolute text-sm top-3 right-6 text-muted-foreground/70",children:"sql"})]}),r&&b.jsxs(b.Fragment,{children:[b.jsx(gx,{withHandle:!0,className:"border "}),b.jsxs(rc,{id:"2",order:2,defaultSize:80,className:"flex grow relative",children:[b.jsx("div",{role:"python-container",className:"flex relative w-[99%] pt-0 ",children:b.jsx(hg,{className:"pt-3",theme:"default",onChange:W=>{G(W&&W.trim()||"")},value:T||Dg,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:vn,onMount:vt})}),b.jsx("code",{className:"absolute text-sm top-3 right-6 text-muted-foreground/70",children:"python"})]})]})]})}return b.jsxs("section",{role:"editor-section",className:"grow flex flex-col justify-end ",children:[b.jsxs("div",{role:"sql-editor",className:" grow flex relative overflow-y-scroll justify-between ",children:[Lo(),cn()]}),b.jsxs("div",{role:"editor-controls",className:" flex flex-wrap px-6 py-4 gap-2 justify-between item-center",children:[b.jsxs("div",{className:"flex grow gap-2 items-center",children:[b.jsxs(Je,{disabled:ee||oe,onClick:()=>{He()},className:" shrink-0",size:"sm",variant:"outline",children:[ee||oe?b.jsx(ma,{className:"w-4 h-4 mr-2 animate-spin text-foreground/50"}):b.jsx(D6,{className:"w-4 h-4 mr-2 "}),"Run"]}),U&&b.jsx(_J,{error:Te.message,setShowAIDialog:l,setTriggerAIRun:g,setUserInputforAI:u}),b.jsxs(Je,{onClick:Xe,className:"",size:"sm",variant:"outline",children:[b.jsx(w6,{className:" size-4 mr-2"}),"Clear"]}),b.jsx(_T,{pressed:r,onPressedChange:W=>i(W),className:"",size:"sm",variant:"outline",children:b.jsx(Zre,{className:" size-4 text-foreground/70"})}),b.jsx(Wre,{open:a,setOpen:l,userInput:c,triggerAIRun:f,setTriggerAIRun:g,setUserInput:W=>u(W)})]}),b.jsxs("div",{className:"flex gap-2 items-end ",children:[b.jsxs(Je,{onClick:pt,size:"sm",variant:"outline",children:[b.jsx(up,{className:"text-green-600 font-bold size-4 mr-2"}),"Accept"]}),b.jsxs(Je,{onClick:gt,className:" w-full",size:"sm",variant:"outline",children:[b.jsx(pa,{className:" size-4 mr-2"}),"Close"]})]})]})]})}const ST="Switch",[tie,jhe]=Rn(ST),[nie,rie]=tie(ST),iie=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:o,required:s,disabled:a,value:l="on",onCheckedChange:c,...u}=e,[f,g]=m.useState(null),p=rt(t,S=>g(S)),v=m.useRef(!1),y=f?!!f.closest("form"):!0,[w=!1,_]=Qn({prop:i,defaultProp:o,onChange:c});return m.createElement(nie,{scope:n,checked:w,disabled:a},m.createElement(ze.button,ae({type:"button",role:"switch","aria-checked":w,"aria-required":s,"data-state":CT(w),"data-disabled":a?"":void 0,disabled:a,value:l},u,{ref:p,onClick:Oe(e.onClick,S=>{_(C=>!C),y&&(v.current=S.isPropagationStopped(),v.current||S.stopPropagation())})})),y&&m.createElement(aie,{control:f,bubbles:!v.current,name:r,value:l,checked:w,required:s,disabled:a,style:{transform:"translateX(-100%)"}}))}),oie="SwitchThumb",sie=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=rie(oie,n);return m.createElement(ze.span,ae({"data-state":CT(i.checked),"data-disabled":i.disabled?"":void 0},r,{ref:t}))}),aie=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Zp(n),a=Xh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const g=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(g)}},[s,n,r]),m.createElement("input",ae({type:"checkbox","aria-hidden":!0,defaultChecked:n},i,{tabIndex:-1,ref:o,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function CT(e){return e?"checked":"unchecked"}const Pg=iie,ET=sie,OT=de.forwardRef(({className:e,...t},n)=>b.jsx(Pg,{className:Ee("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:b.jsx(ET,{className:Ee("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));OT.displayName=Pg.displayName;const lie=de.forwardRef(({className:e,...t},n)=>b.jsx(Pg,{className:Ee("peer inline-flex h-4 w-8 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:b.jsx(ET,{className:Ee("pointer-events-none block h-3 w-3 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));lie.displayName=Pg.displayName;function PT({className:e,...t}){m.useState(0);const n=he(s=>s.themeStyle),r=pe(s=>s.card),i=pe(s=>s.actions.setCard);if(m.useEffect(()=>{},[r.data,r.type,r.cfg,r.customCfg,n,r.preferences]),!r.id)return null;let o;return r.data&&r.data.length>0&&(o=F0({data:r.data,cardType:r.type,cfg:r.cfg,customCfg:r.customCfg,preferences:r.preferences})),b.jsxs(nh,{role:"editor-visual-card",className:Ee("relative flex h-full flex-col rounded-none",e),...t,children:[b.jsxs(su,{className:"py-4",children:[b.jsx(Ui,{text:r.title,onSave:s=>i({...r,title:s}),children:b.jsx(au,{className:"text-base",children:r.title})},r.title),b.jsx(Ui,{text:r.description||"",onSave:s=>i({...r,description:s}),children:b.jsxs(rh,{children:[" ",r.description]})},r.description)]}),b.jsxs(lu,{className:"flex grow flex-col pb-3",children:[r.type!=="table"&&o&&b.jsx(Xb,{cfg:o},JSON.stringify(o)),r.type==="table"&&r.data&&r.data.length>0&&b.jsx(HO,{children:b.jsx(sp,{data:r==null?void 0:r.data})})]})]})}function cie(){const[e,t]=m.useState(!1),[n,r]=m.useState(""),[i,o]=m.useState(""),[s,a]=m.useState(""),l=pe(w=>w.card),c=pe(w=>w.card.customCfg),u=pe(w=>w.actions.setCardCustomCfg);function f(w){var C,P;const _={...w,data:{...w==null?void 0:w.data,datasets:(P=(C=w==null?void 0:w.data)==null?void 0:C.datasets)==null?void 0:P.map(O=>({...O,data:[]}))}};return JSON.stringify(_,null,1)}function g(){if(!l.data||l.data.length===0)return;const w=F0({data:l.data,cardType:l.type,cfg:l.cfg,preferences:l.preferences});w&&(r(JSON.stringify(w,null,1)),c&&o(JSON.stringify(c,null,1)))}function p(){if(i)try{const w=JSON.parse(i);return w?(u(w),a(""),o(""),w):void 0}catch(w){console.log(w),a("Invalid JSON")}}function v(){o(""),u(null)}function y(){let w;if(c){const _=Zo.cloneDeep(l.cfg),S=Zo.merge(_,c);return w=f(S),w}return n?(w=f(JSON.parse(n)),w):""}return b.jsxs(nx,{open:e,onOpenChange:t,children:[b.jsx(rx,{asChild:!0,children:b.jsx(Je,{onClick:g,className:` ${c&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:b.jsx(I6,{className:"w-4 h-4"})})}),b.jsxs(Yp,{className:" min-h-[70vh] max-h-[70vh] overflow-auto min-w-[900px] ",children:[b.jsxs(Kp,{className:"",children:[b.jsx(Xp,{children:"Customize Chart"}),b.jsxs(Qp,{children:["See the configuration options and documentation",b.jsx("a",{target:"_blank",className:"ml-1 underline text-blue-500 ",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),b.jsxs("div",{className:"flex grow gap-2 ",children:[b.jsx(PT,{className:" w-1/2 rounded shadow-none"}),b.jsxs(Q_,{defaultValue:"custom-config",className:" w-1/2 flex flex-col ",children:[b.jsxs(Z_,{className:" justify-start border rounded-sm rounded-b-none border-b-0 ",children:[b.jsxs(av,{value:"custom-config",children:[c&&b.jsx(B2,{className:"w-5 h-5 mr-1 text-green-600"}),c?"Custom Config":"Default Config"]}),b.jsx(av,{className:"",value:"output",children:"Output"})]}),b.jsx(Nf,{className:" grow mt-0 bg-red-x p-2 border border-t-0 rounded-b ",value:"output",children:b.jsx(yx,{disabled:!0,value:n,className:" border-none resize-none font-mono h-full focus-visible:ring-0 focus-visible:ring-offset-0"})}),b.jsx(Nf,{className:"grow mt-0 border border-t-0 rounded-b ",value:"custom-config",children:b.jsx(hg,{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:y(),onChange:w=>o(w)})})]})]}),b.jsxs(ix,{className:"flex items-center",children:[b.jsx(Fn,{className:"text-red-500 mr-2",children:s}),b.jsx(Je,{disabled:!c,onClick:v,variant:"outline",children:"Reset"}),b.jsx(Je,{onClick:p,variant:"outline",children:"Apply"}),b.jsx(Je,{onClick:()=>t(!1),variant:"outline",children:"Close"})]})]})]})}function kT(e){return La({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:[]}]})(e)}function MT(e){return La({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:[]}]})(e)}function DT(e){return La({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:[]}]})(e)}function TT(e){return La({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:[]}]})(e)}function AT(e){return La({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:[]}]})(e)}function IT(e){return La({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:[]}]})(e)}function uie(){const[e,t]=m.useState(!1),n=pe(s=>s.card.type),r=pe(s=>s.actions.setCardType),i=pe(s=>s.actions.setCardCustomCfg);function o(s){r(s),i(null),t(!1)}return b.jsxs(ad,{open:e,onOpenChange:t,children:[b.jsx(ld,{asChild:!0,children:b.jsx(Je,{size:"sm",variant:"outline",children:b.jsx(die,{className:"h-4 w-4",chartType:n})})}),b.jsx(Kl,{className:"w-50",children:b.jsxs("div",{className:"grid grid-cols-3 place-items-center ",children:[b.jsx(Je,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:b.jsx(I0,{className:"size-5"})}),b.jsx(Je,{onClick:()=>o("line"),variant:"ghost",children:b.jsx(N0,{className:"size-5"})}),b.jsx(Je,{onClick:()=>o("stackedBar"),variant:"ghost",children:b.jsx(AT,{className:"size-5 ",strokeWidth:0})}),b.jsx(Je,{onClick:()=>o("scatter"),variant:"ghost",children:b.jsx(lP,{className:"size-5"})}),b.jsx(Je,{onClick:()=>o("bubble"),variant:"ghost",children:b.jsx(TT,{className:"size-4"})}),b.jsx(Je,{onClick:()=>o("pie"),variant:"ghost",children:b.jsx(sP,{className:"size-5"})}),b.jsx(Je,{onClick:()=>o("doughnut"),variant:"ghost",children:b.jsx(MT,{className:"size-5 ",strokeWidth:1})}),b.jsx(Je,{onClick:()=>o("radar"),variant:"ghost",children:b.jsx(kT,{className:"size-5 font-extralight",strokeWidth:.5})}),b.jsx(Je,{onClick:()=>o("polarArea"),variant:"ghost",children:b.jsx(DT,{className:"size-5 "})}),b.jsx(Je,{onClick:()=>o("table"),variant:"ghost",children:b.jsx(R0,{className:"size-5 "})}),b.jsx(Je,{onClick:()=>o("kpi"),variant:"ghost",children:b.jsx(IT,{className:"size-6 "})})]})})]})}function die({chartType:e,className:t}){switch(e){case"bar":return b.jsx(I0,{className:t});case"line":return b.jsx(N0,{className:t});case"pie":return b.jsx(sP,{className:t});case"radar":return b.jsx(kT,{className:t});case"scatter":return b.jsx(lP,{className:t});case"bubble":return b.jsx(TT,{className:t});case"doughnut":return b.jsx(MT,{className:t});case"stackedBar":return b.jsx(AT,{className:"size-4 text-foreground/70 "});case"polarArea":return b.jsx(DT,{className:t});case"kpi":return b.jsx(IT,{className:t});default:return b.jsx(R0,{className:t})}}function fie(){const e=pe(n=>n.card.refreshInterval),t=pe(n=>n.actions.setCardRefreshInterval);return b.jsxs(ad,{children:[b.jsx(ld,{asChild:!0,children:b.jsx(Je,{size:"sm",variant:"outline",children:b.jsx(p6,{className:"w-4 h-4"})})}),b.jsx(Kl,{className:"w-[200px]",children:b.jsx("div",{className:"grid gap-4",children:b.jsx("div",{className:"grid gap-2",children:b.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[b.jsx(Fn,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),b.jsx(Ii,{value:e||"",onChange:n=>t(n.target.value),id:"width",placeholder:"30s",className:"col-span-2 h-7 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0"})]})})})})]})}const e1="horizontal",hie=["horizontal","vertical"],NT=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=e1,...i}=e,o=RT(r)?r:e1,a=n?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return m.createElement(ze.div,ae({"data-orientation":o},a,i,{ref:t}))});NT.propTypes={orientation(e,t,n){const r=e[t],i=String(r);return r&&!RT(r)?new Error(pie(i,n)):null}};function pie(e,t){return`Invalid prop \`orientation\` of value \`${e}\` supplied to \`${t}\`, expected one of:
570
+ Visual Query Syntax: ${Hre}`,{data:k,isLoading:T,isFetching:I,isError:F,refetch:$}=Si({queryKey:["ai-query"],queryFn:()=>cl("https://semaphor.cloud/api/v1/ai",(l==null?void 0:l.accessToken)||"",{user_content:`userContent: ${P} ${c?O:""}`}),enabled:!1});function z(Y){if(Y.toLowerCase().includes("bar"))v("bar");else if(Y.toLowerCase().includes("line"))v("line");else if(Y.toLowerCase().includes("bubble"))v("bubble");else if(Y.toLowerCase().includes("scatter"))v("scatter");else if(Y.toLowerCase().includes("stacked"))v("stackedBar");else if(Y.toLowerCase().includes("pie"))v("pie");else if(Y.toLowerCase().includes("donut")||Y.toLowerCase().includes("doughnut"))v("doughnut");else if(Y.toLowerCase().includes("radar"))v("radar");else return v("bar"),!1;return!0}m.useEffect(()=>{k&&w(Y=>[...Y,{role:"ai",content:k.response}])},[k]),m.useEffect(()=>{const Y=setTimeout(()=>{var D;a.current&&(a.current.scroll({top:a.current.scrollHeight,behavior:"smooth"}),(D=s.current)==null||D.focus())},100);return()=>clearTimeout(Y)},[y]);function V(){n&&(w(Y=>[...Y,{role:"user",content:n}]),z(n)&&u(!0),r(""),$())}m.useEffect(()=>{i&&(V(),o(!1))},[i,o]);const se={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},J={fontFamily:"monospace",fontSize:14,lineHeight:1.6},j={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},Z={p:({node:Y,...D})=>b.jsx("p",{style:se,...D}),code:({node:Y,...D})=>b.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...D}),pre:({node:Y,...D})=>b.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:J,children:[b.jsx("code",{className:"whitespace-normal text-sm",children:D.children}),b.jsxs("div",{className:"flex justify-start gap-2",children:[b.jsx(Je,{onClick:G,size:"sm",variant:"outline",children:b.jsx(V2,{})}),b.jsx(Je,{onClick:H=>{const ie=G(H);ie&&(t(!1),f(ie),p(!0))},size:"sm",variant:"outline",children:b.jsx(zz,{})})]})]}),li:({node:Y,...D})=>b.jsx("li",{style:j,...D})};function G(Y){const D=Y.currentTarget.closest("pre");if(!D)return;const H=D.textContent||D.innerText;return navigator.clipboard.writeText(H).then(()=>console.log("Text copied to clipboard")).catch(ie=>console.error("Error in copying text: ",ie)),H}function X(){return y==null?void 0:y.map((Y,D)=>Y.role==="user"?b.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[b.jsx($6,{className:"mr-2 h-5 w-5"}),b.jsx("div",{children:Y.content})]},D):Y.role==="ai"?b.jsx(b.Fragment,{children:b.jsx(Bre,{className:"w-full overflow-auto py-1",components:Z,children:k==null?void 0:k.response})}):b.jsx(b.Fragment,{}))}return b.jsxs(nx,{open:e,onOpenChange:t,children:[b.jsx(rx,{asChild:!0,children:b.jsx(Je,{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..."})}),b.jsxs(Yp,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[b.jsxs(Kp,{children:[b.jsx(Xp,{children:"Assistant"}),b.jsx(Qp,{children:"What can I help you with?"})]}),b.jsx("div",{ref:a,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:b.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:X()})}),b.jsx("div",{children:b.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[b.jsx(yx,{autoFocus:!0,ref:s,onKeyDown:Y=>{Y.key==="Enter"&&!Y.shiftKey&&(Y.preventDefault(),r(""),V())},placeholder:"Type your question here...",onFocus:Y=>{const D=Y.target,H=D.value.length;D.setSelectionRange(H,H)},className:Ee("max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"),disabled:T||I,value:n,onChange:Y=>r(Y.target.value)})," ",b.jsx(Je,{className:"h-8",size:"sm",variant:"ghost",onClick:V,children:!T&&!I?b.jsx(jz,{}):b.jsx(ma,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var vT={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},bT=m.createContext&&m.createContext(vT),Ure=["attr","size","title"];function qre(e,t){if(e==null)return{};var n=Gre(e,t),r,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Gre(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o<r.length;o++)i=r[o],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function Eg(){return Eg=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Eg.apply(this,arguments)}function yT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Og(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?yT(Object(n),!0).forEach(function(r){Yre(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yT(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Yre(e,t,n){return t=Kre(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Kre(e){var t=Xre(e,"string");return typeof t=="symbol"?t:String(t)}function Xre(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function xT(e){return e&&e.map((t,n)=>m.createElement(t.tag,Og({key:n},t.attr),xT(t.child)))}function La(e){return t=>m.createElement(Qre,Eg({attr:Og({},e.attr)},t),xT(e.child))}function Qre(e){var t=n=>{var{attr:r,size:i,title:o}=e,s=qre(e,Ure),a=i||n.size||"1em",l;return n.className&&(l=n.className),e.className&&(l=(l?l+" ":"")+e.className),m.createElement("svg",Eg({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,s,{className:l,style:Og(Og({color:e.color||n.color},n.style),e.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),o&&m.createElement("title",null,o),e.children)};return bT!==void 0?m.createElement(bT.Consumer,null,n=>t(n)):t(vT)}function Zre(e){return La({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:[]}]})(e)}const wT=m.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r=!1,onPressedChange:i,...o}=e,[s=!1,a]=Qn({prop:n,onChange:i,defaultProp:r});return m.createElement(ze.button,ae({type:"button","aria-pressed":s,"data-state":s?"on":"off","data-disabled":e.disabled?"":void 0},o,{ref:t,onClick:Oe(e.onClick,()=>{e.disabled||a(!s)})}))}),Jre=cy("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),_T=de.forwardRef(({className:e,variant:t,size:n,...r},i)=>b.jsx(wT,{ref:i,className:Ee(Jre({variant:t,size:n,className:e})),...r}));_T.displayName=wT.displayName;function eie(){const{theme:e}=Zm(),t=m.useRef(),n=m.useRef(),[r,i]=m.useState(!1),[o,s]=m.useState(!1),[a,l]=m.useState(!1),[c,u]=m.useState(""),[f,g]=m.useState(!1),{authToken:p}=zi();he(W=>W.selectedSheetId);const v=he(W=>W.dashboard.baseQueries),y=pe(W=>W.card),w=he(W=>W.theme),_=pe(W=>W.isShowingVisual),S=pe(W=>W.selectedConnectionId),C=pe(W=>W.selectedDatabaseName),P=pe(W=>W.selectedSchemaName);he(W=>W.actions.updateFrameCard);const O=pe(W=>W.selectedTableName),k=pe(W=>W.card.sql),T=pe(W=>W.card.python),I=$w(k,v),F=pe(W=>W.selectedConnectionId),$=pe(W=>W.frame),z=pe(W=>W.filterValues),V=pe(W=>W.applyFilters),{setCardCustomCfg:se,setQueryResultColumns:J,setFilterValues:j,setCardSql:Z,setCardPython:G,setQueryError:X,setPythonStdOut:Y}=pe(W=>W.actions),D=pe(W=>W.onSave),H=pe(W=>W.actions.setApplyFilters),ie=pe(W=>W.onClose),R=pe(W=>W.actions.setCardData),ce=pe(W=>W.actions.setSqlGen),ve=pe(W=>W.runSql),ge=pe(W=>W.actions.setRunSql),fe=pe(W=>W.actions.setIsSqlRunning),{data:re,isLoading:ee,isFetching:oe,isSuccess:xe,isError:U,error:Te,status:$e,refetch:He}=Si({queryKey:[I,T],queryFn:()=>qc("https://semaphor.cloud/api/v1/query",(p==null?void 0:p.accessToken)||"",{connection_id:F,sql:I,python:T===Dg?"":T,active_filters:V?z:[]}),enabled:!1,retry:!1});m.useEffect(()=>{if(re&&(R(re.records),Y((re==null?void 0:re.output)||""),re.records.length>0)){const{dimensionKeys:W}=oi(re.records);J(W)}},[re,R,J,Y]),m.useEffect(()=>{ve&&(He(),ge(!1))},[ve,He,ge]),m.useEffect(()=>{(ee||oe)&&fe(!0),(U||xe)&&fe(!1),U?(X(Te.message),R([]),J([]),Y("")):X("")},[ee,oe,re,Y,U,xe,fe,R,J,X,Te]);function Xe(){Z(""),R([]),ce({}),se("")}const vt=W=>{n.current=W};function pt(){let W=k;k&&!k.includes("{{")&&(W=wJ(k),Z(W));const Se={...y,lastSelectedSchema:P,lastSelectedDatabase:C,lastSelectedTable:O,connectionId:S,type:_?y.type:"table",sql:W,customCfg:_?y.customCfg:null},Ne=$.cards.map(We=>We.id===y.id?Se:We);D==null||D({...$,cards:Ne})}function gt(){ie==null||ie()}function Kt(W){const Se=getComputedStyle(document.documentElement).getPropertyValue(W);return Bt(Se)}function Bt(W){const[Se,Ne,We]=W.split(" "),Ue=parseFloat(Se),un=parseFloat(Ne),bn=parseFloat(We),Tn=un/100,rr=bn/100,pn=(1-Math.abs(2*rr-1))*Tn,zt=pn*(1-Math.abs(Ue/60%2-1)),$n=rr-pn/2;let Vt=0,cr=0,An=0;0<=Ue&&Ue<60?(Vt=pn,cr=zt,An=0):60<=Ue&&Ue<120?(Vt=zt,cr=pn,An=0):120<=Ue&&Ue<180?(Vt=0,cr=pn,An=zt):180<=Ue&&Ue<240?(Vt=0,cr=zt,An=pn):240<=Ue&&Ue<300?(Vt=zt,cr=0,An=pn):300<=Ue&&Ue<360&&(Vt=pn,cr=0,An=zt),Vt=Math.round((Vt+$n)*255),cr=Math.round((cr+$n)*255),An=Math.round((An+$n)*255);const Ri=zn=>{const Er=zn.toString(16);return Er.length==1?"0"+Er:Er};return`#${Ri(Vt)}${Ri(cr)}${Ri(An)}`}m.useEffect(()=>{const W=t.current,Se=n.current;if(W){const Ne=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",We=w==="system"?Ne:w;W.editor.defineTheme("default",{base:We==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":We==="light"?"#ffffff":Kt("--background")}}),W.editor.setTheme("default")}return Se&&W&&Se.addCommand(W.KeyMod.Shift|W.KeyCode.Enter,function(){return console.log("Executing query..."),He(),!1}),()=>{}},[e,w,t.current]);function vn(W){t.current=W}function cn(){return b.jsxs(b.Fragment,{children:[o&&b.jsx("div",{className:" min-w-0 w-1/3 flex grow text-xs relative overflow-hidden border-l xbg-yellow-100 p-1 ",role:"editor-filter-container",children:b.jsxs("div",{className:" w-[99%] ",children:[b.jsxs("div",{className:"flex gap-2 pt-3 items-center",children:[b.jsx(SJ,{checked:V,onCheckedChange:()=>H(!V),text:"Apply Filters"}),b.jsx(CJ,{}),z&&o&&b.jsx(pa,{onClick:()=>s(!1),className:" text-foreground/50 hover:text-foreground hover:cursor-pointer bg-background/50 "})]}),b.jsx(hg,{theme:"default",onChange:W=>{if(W)try{JSON.parse(W),j(JSON.parse(W))}catch{}},defaultLanguage:"json",className:"min-h-[220px] mt-1",value:JSON.stringify(z,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),z&&!o&&b.jsx(iP,{onClick:()=>s(!0),className:Ee("absolute right-6 bottom-4 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer",{"text-red-800 font-bold":V})})]})}function Lo(){return b.jsxs(px,{className:"flex grow pb-1 ",direction:"vertical",role:"editor-resizable-group",children:[b.jsxs(rc,{id:"1",order:1,defaultSize:r?20:100,className:"flex grow relative",children:[b.jsx("div",{role:"sql-container",className:"flex relative w-[99%] ",children:b.jsx(hg,{theme:"default",className:"pt-3",onChange:W=>{Z(W)},value:k,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:vn,onMount:vt})}),r&&b.jsx("code",{className:"absolute text-sm top-3 right-6 text-muted-foreground/70",children:"sql"})]}),r&&b.jsxs(b.Fragment,{children:[b.jsx(gx,{withHandle:!0,className:"border "}),b.jsxs(rc,{id:"2",order:2,defaultSize:80,className:"flex grow relative",children:[b.jsx("div",{role:"python-container",className:"flex relative w-[99%] pt-0 ",children:b.jsx(hg,{className:"pt-3",theme:"default",onChange:W=>{G(W&&W.trim()||"")},value:T||Dg,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:vn,onMount:vt})}),b.jsx("code",{className:"absolute text-sm top-3 right-6 text-muted-foreground/70",children:"python"})]})]})]})}return b.jsxs("section",{role:"editor-section",className:"grow flex flex-col justify-end ",children:[b.jsxs("div",{role:"sql-editor",className:" grow flex relative overflow-y-scroll justify-between ",children:[Lo(),cn()]}),b.jsxs("div",{role:"editor-controls",className:" flex flex-wrap px-6 py-4 gap-2 justify-between item-center",children:[b.jsxs("div",{className:"flex grow gap-2 items-center",children:[b.jsxs(Je,{disabled:ee||oe,onClick:()=>{He()},className:" shrink-0",size:"sm",variant:"outline",children:[ee||oe?b.jsx(ma,{className:"w-4 h-4 mr-2 animate-spin text-foreground/50"}):b.jsx(D6,{className:"w-4 h-4 mr-2 "}),"Run"]}),U&&b.jsx(_J,{error:Te.message,setShowAIDialog:l,setTriggerAIRun:g,setUserInputforAI:u}),b.jsxs(Je,{onClick:Xe,className:"",size:"sm",variant:"outline",children:[b.jsx(w6,{className:" size-4 mr-2"}),"Clear"]}),b.jsx(_T,{pressed:r,onPressedChange:W=>i(W),className:"",size:"sm",variant:"outline",children:b.jsx(Zre,{className:" size-4 text-foreground/70"})}),b.jsx(Wre,{open:a,setOpen:l,userInput:c,triggerAIRun:f,setTriggerAIRun:g,setUserInput:W=>u(W)})]}),b.jsxs("div",{className:"flex gap-2 items-end ",children:[b.jsxs(Je,{onClick:pt,size:"sm",variant:"outline",children:[b.jsx(up,{className:"text-green-600 font-bold size-4 mr-2"}),"Accept"]}),b.jsxs(Je,{onClick:gt,className:" w-full",size:"sm",variant:"outline",children:[b.jsx(pa,{className:" size-4 mr-2"}),"Close"]})]})]})]})}const ST="Switch",[tie,jhe]=Rn(ST),[nie,rie]=tie(ST),iie=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:o,required:s,disabled:a,value:l="on",onCheckedChange:c,...u}=e,[f,g]=m.useState(null),p=rt(t,S=>g(S)),v=m.useRef(!1),y=f?!!f.closest("form"):!0,[w=!1,_]=Qn({prop:i,defaultProp:o,onChange:c});return m.createElement(nie,{scope:n,checked:w,disabled:a},m.createElement(ze.button,ae({type:"button",role:"switch","aria-checked":w,"aria-required":s,"data-state":CT(w),"data-disabled":a?"":void 0,disabled:a,value:l},u,{ref:p,onClick:Oe(e.onClick,S=>{_(C=>!C),y&&(v.current=S.isPropagationStopped(),v.current||S.stopPropagation())})})),y&&m.createElement(aie,{control:f,bubbles:!v.current,name:r,value:l,checked:w,required:s,disabled:a,style:{transform:"translateX(-100%)"}}))}),oie="SwitchThumb",sie=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=rie(oie,n);return m.createElement(ze.span,ae({"data-state":CT(i.checked),"data-disabled":i.disabled?"":void 0},r,{ref:t}))}),aie=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Zp(n),a=Xh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const g=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(g)}},[s,n,r]),m.createElement("input",ae({type:"checkbox","aria-hidden":!0,defaultChecked:n},i,{tabIndex:-1,ref:o,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function CT(e){return e?"checked":"unchecked"}const Pg=iie,ET=sie,OT=de.forwardRef(({className:e,...t},n)=>b.jsx(Pg,{className:Ee("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:b.jsx(ET,{className:Ee("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));OT.displayName=Pg.displayName;const lie=de.forwardRef(({className:e,...t},n)=>b.jsx(Pg,{className:Ee("peer inline-flex h-4 w-8 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:b.jsx(ET,{className:Ee("pointer-events-none block h-3 w-3 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));lie.displayName=Pg.displayName;function PT({className:e,...t}){m.useState(0);const n=he(s=>s.themeStyle),r=pe(s=>s.card),i=pe(s=>s.actions.setCard);if(m.useEffect(()=>{},[r.data,r.type,r.cfg,r.customCfg,n,r.preferences]),!r.id)return null;let o;return r.data&&r.data.length>0&&(o=F0({data:r.data,cardType:r.type,cfg:r.cfg,customCfg:r.customCfg,preferences:r.preferences})),b.jsxs(nh,{role:"editor-visual-card",className:Ee("relative flex h-full flex-col rounded-none",e),...t,children:[b.jsxs(su,{className:"py-4",children:[b.jsx(Ui,{text:r.title,onSave:s=>i({...r,title:s}),children:b.jsx(au,{className:"text-base",children:r.title})},r.title),b.jsx(Ui,{text:r.description||"",onSave:s=>i({...r,description:s}),children:b.jsxs(rh,{children:[" ",r.description]})},r.description)]}),b.jsxs(lu,{className:"flex grow flex-col pb-3",children:[r.type!=="table"&&o&&b.jsx(Xb,{cfg:o},JSON.stringify(o)),r.type==="table"&&r.data&&r.data.length>0&&b.jsx(HO,{children:b.jsx(sp,{data:r==null?void 0:r.data})})]})]})}function cie(){const[e,t]=m.useState(!1),[n,r]=m.useState(""),[i,o]=m.useState(""),[s,a]=m.useState(""),l=pe(w=>w.card),c=pe(w=>w.card.customCfg),u=pe(w=>w.actions.setCardCustomCfg);function f(w){var C,P;const _={...w,data:{...w==null?void 0:w.data,datasets:(P=(C=w==null?void 0:w.data)==null?void 0:C.datasets)==null?void 0:P.map(O=>({...O,data:[]}))}};return JSON.stringify(_,null,1)}function g(){if(!l.data||l.data.length===0)return;const w=F0({data:l.data,cardType:l.type,cfg:l.cfg,preferences:l.preferences});w&&(r(JSON.stringify(w,null,1)),c&&o(JSON.stringify(c,null,1)))}function p(){if(i)try{const w=JSON.parse(i);return w?(u(w),a(""),o(""),w):void 0}catch(w){console.log(w),a("Invalid JSON")}}function v(){o(""),u(null)}function y(){let w;if(c){const _=Zo.cloneDeep(l.cfg),S=Zo.merge(_,c);return w=f(S),w}return n?(w=f(JSON.parse(n)),w):""}return b.jsxs(nx,{open:e,onOpenChange:t,children:[b.jsx(rx,{asChild:!0,children:b.jsx(Je,{onClick:g,className:` ${c&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:b.jsx(I6,{className:"w-4 h-4"})})}),b.jsxs(Yp,{className:" min-h-[70vh] max-h-[70vh] overflow-auto min-w-[900px] ",children:[b.jsxs(Kp,{className:"",children:[b.jsx(Xp,{children:"Customize Chart"}),b.jsxs(Qp,{children:["See the configuration options and documentation",b.jsx("a",{target:"_blank",className:"ml-1 underline text-blue-500 ",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),b.jsxs("div",{className:"flex grow gap-2 ",children:[b.jsx(PT,{className:" w-1/2 rounded shadow-none"}),b.jsxs(Q_,{defaultValue:"custom-config",className:" w-1/2 flex flex-col ",children:[b.jsxs(Z_,{className:" justify-start border rounded-sm rounded-b-none border-b-0 ",children:[b.jsxs(av,{value:"custom-config",children:[c&&b.jsx(B2,{className:"w-5 h-5 mr-1 text-green-600"}),c?"Custom Config":"Default Config"]}),b.jsx(av,{className:"",value:"output",children:"Output"})]}),b.jsx(Nf,{className:" grow mt-0 bg-red-x p-2 border border-t-0 rounded-b ",value:"output",children:b.jsx(yx,{disabled:!0,value:n,className:" border-none resize-none font-mono h-full focus-visible:ring-0 focus-visible:ring-offset-0"})}),b.jsx(Nf,{className:"grow mt-0 border border-t-0 rounded-b ",value:"custom-config",children:b.jsx(hg,{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:y(),onChange:w=>o(w)})})]})]}),b.jsxs(ix,{className:"flex items-center",children:[b.jsx(Fn,{className:"text-red-500 mr-2",children:s}),b.jsx(Je,{disabled:!c,onClick:v,variant:"outline",children:"Reset"}),b.jsx(Je,{onClick:p,variant:"outline",children:"Apply"}),b.jsx(Je,{onClick:()=>t(!1),variant:"outline",children:"Close"})]})]})]})}function kT(e){return La({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:[]}]})(e)}function MT(e){return La({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:[]}]})(e)}function DT(e){return La({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:[]}]})(e)}function TT(e){return La({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:[]}]})(e)}function AT(e){return La({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:[]}]})(e)}function IT(e){return La({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:[]}]})(e)}function uie(){const[e,t]=m.useState(!1),n=pe(s=>s.card.type),r=pe(s=>s.actions.setCardType),i=pe(s=>s.actions.setCardCustomCfg);function o(s){r(s),i(null),t(!1)}return b.jsxs(ad,{open:e,onOpenChange:t,children:[b.jsx(ld,{asChild:!0,children:b.jsx(Je,{size:"sm",variant:"outline",children:b.jsx(die,{className:"h-4 w-4",chartType:n})})}),b.jsx(Kl,{className:"w-50",children:b.jsxs("div",{className:"grid grid-cols-3 place-items-center ",children:[b.jsx(Je,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:b.jsx(I0,{className:"size-5"})}),b.jsx(Je,{onClick:()=>o("line"),variant:"ghost",children:b.jsx(N0,{className:"size-5"})}),b.jsx(Je,{onClick:()=>o("stackedBar"),variant:"ghost",children:b.jsx(AT,{className:"size-5 ",strokeWidth:0})}),b.jsx(Je,{onClick:()=>o("scatter"),variant:"ghost",children:b.jsx(lP,{className:"size-5"})}),b.jsx(Je,{onClick:()=>o("bubble"),variant:"ghost",children:b.jsx(TT,{className:"size-4"})}),b.jsx(Je,{onClick:()=>o("pie"),variant:"ghost",children:b.jsx(sP,{className:"size-5"})}),b.jsx(Je,{onClick:()=>o("doughnut"),variant:"ghost",children:b.jsx(MT,{className:"size-5 ",strokeWidth:1})}),b.jsx(Je,{onClick:()=>o("radar"),variant:"ghost",children:b.jsx(kT,{className:"size-5 font-extralight",strokeWidth:.5})}),b.jsx(Je,{onClick:()=>o("polarArea"),variant:"ghost",children:b.jsx(DT,{className:"size-5 "})}),b.jsx(Je,{onClick:()=>o("table"),variant:"ghost",children:b.jsx(R0,{className:"size-5 "})}),b.jsx(Je,{onClick:()=>o("kpi"),variant:"ghost",children:b.jsx(IT,{className:"size-6 "})})]})})]})}function die({chartType:e,className:t}){switch(e){case"bar":return b.jsx(I0,{className:t});case"line":return b.jsx(N0,{className:t});case"pie":return b.jsx(sP,{className:t});case"radar":return b.jsx(kT,{className:t});case"scatter":return b.jsx(lP,{className:t});case"bubble":return b.jsx(TT,{className:t});case"doughnut":return b.jsx(MT,{className:t});case"stackedBar":return b.jsx(AT,{className:"size-4 text-foreground/70 "});case"polarArea":return b.jsx(DT,{className:t});case"kpi":return b.jsx(IT,{className:t});default:return b.jsx(R0,{className:t})}}function fie(){const e=pe(n=>n.card.refreshInterval),t=pe(n=>n.actions.setCardRefreshInterval);return b.jsxs(ad,{children:[b.jsx(ld,{asChild:!0,children:b.jsx(Je,{size:"sm",variant:"outline",children:b.jsx(p6,{className:"w-4 h-4"})})}),b.jsx(Kl,{className:"w-[200px]",children:b.jsx("div",{className:"grid gap-4",children:b.jsx("div",{className:"grid gap-2",children:b.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[b.jsx(Fn,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),b.jsx(Ii,{value:e||"",onChange:n=>t(n.target.value),id:"width",placeholder:"30s",className:"col-span-2 h-7 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0"})]})})})})]})}const e1="horizontal",hie=["horizontal","vertical"],NT=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=e1,...i}=e,o=RT(r)?r:e1,a=n?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return m.createElement(ze.div,ae({"data-orientation":o},a,i,{ref:t}))});NT.propTypes={orientation(e,t,n){const r=e[t],i=String(r);return r&&!RT(r)?new Error(pie(i,n)):null}};function pie(e,t){return`Invalid prop \`orientation\` of value \`${e}\` supplied to \`${t}\`, expected one of:
571
571
  - horizontal
572
572
  - vertical
573
573
 
574
- Defaulting to \`${e1}\`.`}function RT(e){return hie.includes(e)}const LT=NT,FT=de.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>b.jsx(LT,{ref:i,decorative:n,orientation:t,className:Ee("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));FT.displayName=LT.displayName;function jT(){pe(s=>s.frame);const e=pe(s=>s.card),t=pe(s=>s.card.data),n=pe(s=>s.isShowingVisual),r=pe(s=>s.isSqlRunning),i=pe(s=>s.queryError),o=pe(s=>s.pythonStdOut);return pe(s=>s.onSave),pe(s=>s.onClose),pe(s=>s.actions.setCardSql),pe(s=>s.actions.setCardType),pe(s=>s.actions.setSqlGen),e?b.jsxs("div",{className:" h-full relative flex flex-col py-3",children:[r&&b.jsx(ma,{className:" w-10 h-10 z-10 absolute m-auto left-0 right-0 top-0 bottom-0 animate-spin text-foreground/10 "}),b.jsxs("div",{className:" px-6 min-h-10 mb-0 flex justify-end items-center gap-2",children:[n&&b.jsxs("div",{className:"flex grow gap-2 items-center ",children:[b.jsx(uie,{}),b.jsx(cie,{}),b.jsx(fie,{})]}),b.jsx(mie,{})]}),n?e.type==="kpi"?b.jsx("div",{className:"grow flex items-center justify-center ",children:b.jsx("div",{className:" w-1/2 border rounded-md",children:b.jsx(L0,{isLoading:r,card:e})})}):b.jsx(PT,{className:"grow border-none shadow-none "}):b.jsxs("div",{className:"w-full px-6 bg-red-x00 grow border-none shadow-none overflow-y-auto ",children:[o&&b.jsx(gie,{}),e.data&&e.data.length>0&&b.jsx(sp,{data:t||[]}),i&&b.jsx("span",{className:"font-mono text-sm",children:i})]})]}):b.jsx(b.Fragment,{children:"No Active Card"})}function gie(){const e=pe(n=>n.pythonStdOut);if(!e)return null;const t=e.replace(/\n/g,"<br>");return b.jsxs(b.Fragment,{children:[b.jsx("p",{className:"font-mono text-sm",children:"Output:"}),b.jsx("div",{dangerouslySetInnerHTML:{__html:t},className:"font-mono text-sm p-2 bg-muted"}),b.jsx(FT,{className:" mb-2"})]})}function mie(){const e=pe(n=>n.isShowingVisual),t=pe(n=>n.actions.setIsShowingVisual);return b.jsxs("div",{className:" flex items-center space-x-2",children:[b.jsx(Fn,{htmlFor:"visualize",children:"Chart"}),b.jsx(OT,{checked:e,onCheckedChange:()=>t(!e),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}const $T="Collapsible",[vie,zT]=Rn($T),[bie,t1]=vie($T),yie=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:o,onOpenChange:s,...a}=e,[l=!1,c]=Qn({prop:r,defaultProp:i,onChange:s});return m.createElement(bie,{scope:n,disabled:o,contentId:pr(),open:l,onOpenToggle:m.useCallback(()=>c(u=>!u),[c])},m.createElement(ze.div,ae({"data-state":n1(l),"data-disabled":o?"":void 0},a,{ref:t})))}),xie="CollapsibleTrigger",wie=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=t1(xie,n);return m.createElement(ze.button,ae({type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":n1(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled},r,{ref:t,onClick:Oe(e.onClick,i.onOpenToggle)}))}),BT="CollapsibleContent",_ie=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=t1(BT,e.__scopeCollapsible);return m.createElement(wn,{present:n||i.open},({present:o})=>m.createElement(Sie,ae({},r,{ref:t,present:o})))}),Sie=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...o}=e,s=t1(BT,n),[a,l]=m.useState(r),c=m.useRef(null),u=rt(t,c),f=m.useRef(0),g=f.current,p=m.useRef(0),v=p.current,y=s.open||a,w=m.useRef(y),_=m.useRef();return m.useEffect(()=>{const S=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(S)},[]),Xn(()=>{const S=c.current;if(S){_.current=_.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const C=S.getBoundingClientRect();f.current=C.height,p.current=C.width,w.current||(S.style.transitionDuration=_.current.transitionDuration,S.style.animationName=_.current.animationName),l(r)}},[s.open,r]),m.createElement(ze.div,ae({"data-state":n1(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!y},o,{ref:u,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style}}),y&&i)});function n1(e){return e?"open":"closed"}const Cie=yie,Eie=wie,Oie=_ie,Es="Accordion",Pie=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[r1,kie,Mie]=Af(Es),[kg,$he]=Rn(Es,[Mie,zT]),i1=zT(),VT=m.forwardRef((e,t)=>{const{type:n,...r}=e,i=r,o=r;return m.createElement(r1.Provider,{scope:e.__scopeAccordion},n==="multiple"?m.createElement(Iie,ae({},o,{ref:t})):m.createElement(Aie,ae({},i,{ref:t})))});VT.propTypes={type(e){const t=e.value||e.defaultValue;return e.type&&!["single","multiple"].includes(e.type)?new Error("Invalid prop `type` supplied to `Accordion`. Expected one of `single | multiple`."):e.type==="multiple"&&typeof t=="string"?new Error("Invalid prop `type` supplied to `Accordion`. Expected `single` when `defaultValue` or `value` is type `string`."):e.type==="single"&&Array.isArray(t)?new Error("Invalid prop `type` supplied to `Accordion`. Expected `multiple` when `defaultValue` or `value` is type `string[]`."):null}};const[HT,Die]=kg(Es),[WT,Tie]=kg(Es,{collapsible:!1}),Aie=m.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:i=()=>{},collapsible:o=!1,...s}=e,[a,l]=Qn({prop:n,defaultProp:r,onChange:i});return m.createElement(HT,{scope:e.__scopeAccordion,value:a?[a]:[],onItemOpen:l,onItemClose:m.useCallback(()=>o&&l(""),[o,l])},m.createElement(WT,{scope:e.__scopeAccordion,collapsible:o},m.createElement(UT,ae({},s,{ref:t}))))}),Iie=m.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:i=()=>{},...o}=e,[s=[],a]=Qn({prop:n,defaultProp:r,onChange:i}),l=m.useCallback(u=>a((f=[])=>[...f,u]),[a]),c=m.useCallback(u=>a((f=[])=>f.filter(g=>g!==u)),[a]);return m.createElement(HT,{scope:e.__scopeAccordion,value:s,onItemOpen:l,onItemClose:c},m.createElement(WT,{scope:e.__scopeAccordion,collapsible:!0},m.createElement(UT,ae({},o,{ref:t}))))}),[Nie,Mg]=kg(Es),UT=m.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:i,orientation:o="vertical",...s}=e,a=m.useRef(null),l=rt(a,t),c=kie(n),f=Ys(i)==="ltr",g=Oe(e.onKeyDown,p=>{var v;if(!Pie.includes(p.key))return;const y=p.target,w=c().filter(F=>{var $;return!(($=F.ref.current)!==null&&$!==void 0&&$.disabled)}),_=w.findIndex(F=>F.ref.current===y),S=w.length;if(_===-1)return;p.preventDefault();let C=_;const P=0,O=S-1,k=()=>{C=_+1,C>O&&(C=P)},T=()=>{C=_-1,C<P&&(C=O)};switch(p.key){case"Home":C=P;break;case"End":C=O;break;case"ArrowRight":o==="horizontal"&&(f?k():T());break;case"ArrowDown":o==="vertical"&&k();break;case"ArrowLeft":o==="horizontal"&&(f?T():k());break;case"ArrowUp":o==="vertical"&&T();break}const I=C%S;(v=w[I].ref.current)===null||v===void 0||v.focus()});return m.createElement(Nie,{scope:n,disabled:r,direction:i,orientation:o},m.createElement(r1.Slot,{scope:n},m.createElement(ze.div,ae({},s,{"data-orientation":o,ref:l,onKeyDown:r?void 0:g}))))}),o1="AccordionItem",[Rie,s1]=kg(o1),Lie=m.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...i}=e,o=Mg(o1,n),s=Die(o1,n),a=i1(n),l=pr(),c=r&&s.value.includes(r)||!1,u=o.disabled||e.disabled;return m.createElement(Rie,{scope:n,open:c,disabled:u,triggerId:l},m.createElement(Cie,ae({"data-orientation":o.orientation,"data-state":GT(c)},a,i,{ref:t,disabled:u,open:c,onOpenChange:f=>{f?s.onItemOpen(r):s.onItemClose(r)}})))}),Fie="AccordionHeader",jie=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Mg(Es,n),o=s1(Fie,n);return m.createElement(ze.h3,ae({"data-orientation":i.orientation,"data-state":GT(o.open),"data-disabled":o.disabled?"":void 0},r,{ref:t}))}),qT="AccordionTrigger",$ie=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Mg(Es,n),o=s1(qT,n),s=Tie(qT,n),a=i1(n);return m.createElement(r1.ItemSlot,{scope:n},m.createElement(Eie,ae({"aria-disabled":o.open&&!s.collapsible||void 0,"data-orientation":i.orientation,id:o.triggerId},a,r,{ref:t})))}),zie="AccordionContent",Bie=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Mg(Es,n),o=s1(zie,n),s=i1(n);return m.createElement(Oie,ae({role:"region","aria-labelledby":o.triggerId,"data-orientation":i.orientation},s,r,{ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}}))});function GT(e){return e?"open":"closed"}const Vie=VT,Hie=Lie,Wie=jie,YT=$ie,KT=Bie,uc=Vie,Cn=de.forwardRef(({className:e,...t},n)=>b.jsx(Hie,{ref:n,className:Ee("border-b",e),...t}));Cn.displayName="AccordionItem";const En=de.forwardRef(({className:e,children:t,...n},r)=>b.jsx(Wie,{className:"flex",children:b.jsxs(YT,{ref:r,className:Ee("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,b.jsx(dp,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));En.displayName=YT.displayName;const On=de.forwardRef(({className:e,children:t,...n},r)=>b.jsx(KT,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:b.jsx("div",{className:Ee("pb-4 pt-0",e),children:t})}));On.displayName=KT.displayName;function Td(){var r,i,o;const e=pe(s=>s.card.cfg),t=pe(s=>s.actions.setCardCfg);function n(s){var c;const a={datalabels:{display:s!=="none",align:s,anchor:s,clamp:!0}},l={...e,options:{...e==null?void 0:e.options,plugins:{...(c=e==null?void 0:e.options)==null?void 0:c.plugins,...a}}};t(l),console.log(s)}return b.jsxs("div",{className:"space-y-2",children:[b.jsx("label",{className:"font-medium",children:"Data Labels"}),b.jsxs(lx,{value:(o=(i=(r=e==null?void 0:e.options)==null?void 0:r.plugins)==null?void 0:i.datalabels)==null?void 0:o.anchor,onValueChange:n,defaultValue:"none",children:[b.jsx(rg,{className:"h-8 w-[180px] focus:ring-1 focus:ring-offset-0",children:b.jsx(ux,{placeholder:"Select position"})}),b.jsx(ig,{children:b.jsxs(cx,{children:[b.jsx(pd,{children:"Data Labels"}),b.jsx(Ro,{value:"none",children:"None"}),b.jsx(Ro,{value:"start",children:"Start"}),b.jsx(Ro,{value:"center",children:"Center"}),b.jsx(Ro,{value:"end",children:"End"})]})})]})]})}function Ad(){const[e,t]=m.useState([]);pe(u=>u.card.cfg);const n=pe(u=>u.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:i,setCardPreferences:o}=pe(u=>u.actions),s=pe(u=>u.queryResultColumns);pe(u=>{var f;return(f=u.card.preferences)==null?void 0:f.filterOnClickColumnIndex}),m.useEffect(()=>{s&&t(new Array(s.length).fill(!1))},[s]);function a(u,f){var g,p;f?n!=null&&n.onClickFilter&&((g=n==null?void 0:n.onClickFilter)==null?void 0:g.length)>0?o({...n,onClickFilter:[...n.onClickFilter,{columnIndex:u,expression:""}]}):o({...n,onClickFilter:[{columnIndex:u,expression:""}]}):(o({...n,onClickFilter:(p=n==null?void 0:n.onClickFilter)==null?void 0:p.filter(v=>v.columnIndex!==u)}),t(v=>{const y=[...v];return y[u]=!1,y}))}function l(u,f){var p;const g=(p=n==null?void 0:n.onClickFilter)==null?void 0:p.map(v=>v.columnIndex===u?{...v,expression:f.target.value}:v);o({...n,onClickFilter:g})}function c(u){var f,g,p,v;if(e!=null&&e[u]||(g=(f=n==null?void 0:n.onClickFilter)==null?void 0:f.find(y=>y.columnIndex===u))!=null&&g.expression)return b.jsx(Ii,{value:(v=(p=n==null?void 0:n.onClickFilter)==null?void 0:p.find(y=>y.columnIndex===u))==null?void 0:v.expression,onChange:y=>l(u,y),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return b.jsx(b.Fragment,{children:s==null?void 0:s.map((u,f)=>{var g,p;return b.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:b.jsxs("div",{className:" grow",children:[b.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[b.jsx(hd,{checked:!!((g=n==null?void 0:n.onClickFilter)!=null&&g.find(v=>v.columnIndex===f)),onCheckedChange:v=>a(f,v)}),b.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:u}),b.jsx("div",{className:"flex gap-2 items-center ",children:((p=n==null?void 0:n.onClickFilter)==null?void 0:p.find(v=>v.columnIndex===f))&&b.jsx(oP,{onClick:()=>{t(v=>{const y=[...v];return y[f]=!v[f],y})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),c(f)]})},u)})})}const XT="Radio",[Uie,QT]=Rn(XT),[qie,Gie]=Uie(XT),Yie=m.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:i=!1,required:o,disabled:s,value:a="on",onCheck:l,...c}=e,[u,f]=m.useState(null),g=rt(t,y=>f(y)),p=m.useRef(!1),v=u?!!u.closest("form"):!0;return m.createElement(qie,{scope:n,checked:i,disabled:s},m.createElement(ze.button,ae({type:"button",role:"radio","aria-checked":i,"data-state":ZT(i),"data-disabled":s?"":void 0,disabled:s,value:a},c,{ref:g,onClick:Oe(e.onClick,y=>{i||l==null||l(),v&&(p.current=y.isPropagationStopped(),p.current||y.stopPropagation())})})),v&&m.createElement(Qie,{control:u,bubbles:!p.current,name:r,value:a,checked:i,required:o,disabled:s,style:{transform:"translateX(-100%)"}}))}),Kie="RadioIndicator",Xie=m.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...i}=e,o=Gie(Kie,n);return m.createElement(wn,{present:r||o.checked},m.createElement(ze.span,ae({"data-state":ZT(o.checked),"data-disabled":o.disabled?"":void 0},i,{ref:t})))}),Qie=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Zp(n),a=Xh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const g=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(g)}},[s,n,r]),m.createElement("input",ae({type:"radio","aria-hidden":!0,defaultChecked:n},i,{tabIndex:-1,ref:o,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function ZT(e){return e?"checked":"unchecked"}const Zie=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],JT="RadioGroup",[Jie,zhe]=Rn(JT,[gl,QT]),eA=gl(),tA=QT(),[eoe,toe]=Jie(JT),noe=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:i,value:o,required:s=!1,disabled:a=!1,orientation:l,dir:c,loop:u=!0,onValueChange:f,...g}=e,p=eA(n),v=Ys(c),[y,w]=Qn({prop:o,defaultProp:i,onChange:f});return m.createElement(eoe,{scope:n,name:r,required:s,disabled:a,value:y,onValueChange:w},m.createElement(iv,ae({asChild:!0},p,{orientation:l,dir:v,loop:u}),m.createElement(ze.div,ae({role:"radiogroup","aria-required":s,"aria-orientation":l,"data-disabled":a?"":void 0,dir:v},g,{ref:t}))))}),roe="RadioGroupItem",ioe=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...i}=e,o=toe(roe,n),s=o.disabled||r,a=eA(n),l=tA(n),c=m.useRef(null),u=rt(t,c),f=o.value===i.value,g=m.useRef(!1);return m.useEffect(()=>{const p=y=>{Zie.includes(y.key)&&(g.current=!0)},v=()=>g.current=!1;return document.addEventListener("keydown",p),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",v)}},[]),m.createElement(ov,ae({asChild:!0},a,{focusable:!s,active:f}),m.createElement(Yie,ae({disabled:s,required:o.required,checked:f},l,i,{name:o.name,ref:u,onCheck:()=>o.onValueChange(i.value),onKeyDown:Oe(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:Oe(i.onFocus,()=>{var p;g.current&&((p=c.current)===null||p===void 0||p.click())})})))}),ooe=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,i=tA(n);return m.createElement(Xie,ae({},i,r,{ref:t}))}),nA=noe,rA=ioe,soe=ooe,a1=de.forwardRef(({className:e,...t},n)=>b.jsx(nA,{className:Ee("grid gap-2",e),...t,ref:n}));a1.displayName=nA.displayName;const Id=de.forwardRef(({className:e,...t},n)=>b.jsx(rA,{ref:n,className:Ee("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:b.jsx(soe,{className:"flex items-center justify-center",children:b.jsx(rP,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Id.displayName=rA.displayName;function l1(){var o,s;const e=pe(a=>a.card.preferences),t=pe(a=>a.card.cfg),{setCardCfg:n,setCardPreferences:r}=pe(a=>a.actions);(o=t==null?void 0:t.options)!=null&&o.indexAxis;function i(a){var u,f,g,p,v,y;let l={};(u=e==null?void 0:e.chartOptions)!=null&&u.scales&&(l={x:(g=(f=e==null?void 0:e.chartOptions)==null?void 0:f.scales)==null?void 0:g.y,y:(v=(p=e==null?void 0:e.chartOptions)==null?void 0:p.scales)==null?void 0:v.x});const c={...e,chartOptions:{...e==null?void 0:e.chartOptions,scales:{...(y=e==null?void 0:e.chartOptions)==null?void 0:y.scales,...l},indexAxis:a}};r(c)}return b.jsxs(a1,{value:((s=e==null?void 0:e.chartOptions)==null?void 0:s.indexAxis)||"x",onValueChange:i,className:"flex gap-3",defaultValue:"x",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(Id,{value:"x",id:"r1"}),b.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(Id,{value:"y",id:"r2"}),b.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const c1="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function iA(e){var n,r;return(n=e==null?void 0:e.chartOptions)!=null&&n.indexAxis?((r=e==null?void 0:e.chartOptions)==null?void 0:r.indexAxis)==="x"?"y":"x":"y"}function oA(e){var n,r,i;const t=iA(e);return((i=(r=(n=e==null?void 0:e.chartOptions)==null?void 0:n.scales)==null?void 0:r[t])==null?void 0:i.type)||"linear"}function aoe(){var S,C,P,O,k,T;const[e,t]=m.useState(!1),n=pe(I=>{var F;return(F=I.card)==null?void 0:F.preferences}),r=iA(n),[i,o]=m.useState(oA(n)),[s,a]=m.useState(((P=(C=(S=n==null?void 0:n.chartOptions)==null?void 0:S.scales)==null?void 0:C[r])==null?void 0:P.min)||""),[l,c]=m.useState(((T=(k=(O=n==null?void 0:n.chartOptions)==null?void 0:O.scales)==null?void 0:k[r])==null?void 0:T.max)||""),[u,f]=m.useState(s||l?"custom":"auto"),[g,p]=m.useState(""),v=pe(I=>I.actions.setCardPreferences);m.useEffect(()=>{var I,F,$,z,V,se,J,j,Z,G;o(oA(n)),a((($=(F=(I=n==null?void 0:n.chartOptions)==null?void 0:I.scales)==null?void 0:F[r])==null?void 0:$.min)||""),c(((se=(V=(z=n==null?void 0:n.chartOptions)==null?void 0:z.scales)==null?void 0:V[r])==null?void 0:se.max)||""),p(((G=(Z=(j=(J=n==null?void 0:n.chartOptions)==null?void 0:J.scales)==null?void 0:j[r])==null?void 0:Z.ticks)==null?void 0:G.stepSize)||"")},[e,n,r]);function y(I,F){return F===""||/^[0-9\b]+$/.test(F)?Number(F):Number(I)}function w(){return b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[b.jsx(Fn,{htmlFor:"range",children:"Range"}),b.jsx(Ii,{id:"min",value:s,onChange:I=>a(F=>y(F,I.target.value)),className:`col-span-1 h-8 w-full ${c1}`}),b.jsx(Ii,{value:l,onChange:I=>c(F=>y(F,I.target.value)),id:"max",className:`col-span-1 h-8 w-full ${c1}`})]}),b.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[b.jsx(Fn,{htmlFor:"step-size",children:"Step Size"}),b.jsx(Ii,{value:g,onChange:I=>p(F=>y(F,I.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${c1}`})]})]})}function _(){var $;let I={};u==="custom"&&(I={min:s,max:l,ticks:{stepSize:g}});const F={...n||{},chartOptions:{...n==null?void 0:n.chartOptions,scales:{...($=n==null?void 0:n.chartOptions)==null?void 0:$.scales,[r]:{type:i,...i==="linear"?I:{}}}}};v(F)}return b.jsxs(ad,{onOpenChange:I=>t(I),children:[b.jsx(ld,{asChild:!0,children:b.jsx(Vz,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),b.jsx(Kl,{align:"center",className:"max-w-65",children:b.jsxs("div",{className:"grid gap-4",children:[b.jsxs("div",{className:"space-y-2",children:[b.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),b.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),b.jsxs("div",{className:"grid gap-2",children:[b.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[b.jsx(Fn,{htmlFor:"scale",children:"Type"}),b.jsxs(lx,{value:i,onValueChange:I=>o(I),children:[b.jsx(rg,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:b.jsx(ux,{})}),b.jsx(ig,{id:"type",children:b.jsxs(cx,{children:[b.jsx(pd,{children:"Option"}),b.jsx(Ro,{value:"linear",children:"Linear"}),b.jsx(Ro,{value:"logarithmic",children:"logarithmic"})]})})]})]}),i=="linear"&&b.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[b.jsx(Fn,{htmlFor:"scale-option",children:"Setup"}),b.jsxs(a1,{id:"scale-option",value:u,onValueChange:I=>f(I),className:"col-span-2 flex gap-3",defaultValue:"x",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(Id,{value:"auto",id:"r1"}),b.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(Id,{value:"custom",id:"r2"}),b.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),u==="custom"&&i=="linear"&&w(),b.jsx(JM,{}),b.jsx("div",{className:"grid grid-cols-3",children:b.jsx(Je,{onClick:_,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function sA(){const e=pe(l=>l.card),t=pe(l=>{var c,u,f;return(f=(u=(c=l==null?void 0:l.card)==null?void 0:c.cfg)==null?void 0:u.options)==null?void 0:f.indexAxis}),n=t==="y"?"Y Axis":"X Axis",r=t==="y"?"X Axis":"Y Axis",{keys:i,metricKeys:o,dimensionKeys:s}=oi(e.data||[]);let a=o;if(e.type==="stackedBar"){const l=Zb({dataArray:e.data||[],groupKey:s[0],pivotKey:s[1],valueKey:a[0]}),{metricKeys:c}=oi(l);a=c}return i.length===0?null:b.jsxs("div",{className:"space-y-4",children:[b.jsxs("div",{className:"space-y-2",children:[b.jsx(Fn,{children:n}),b.jsx("div",{className:"my-1 space-y-1",children:b.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:b.jsx("p",{children:s[0]})})})]}),b.jsxs("div",{className:"space-y-2",children:[b.jsxs("div",{className:"flex items-center justify-between gap-5",children:[b.jsx(Fn,{children:r}),b.jsx(aoe,{})]}),b.jsx("div",{className:"my-1 space-y-1",children:a.map((l,c)=>b.jsx(loe,{col:l,idx:c},l))})]})]})}function loe({col:e,idx:t}){const n=pe(a=>{var l;return(l=a.card)==null?void 0:l.preferences}),r=pe(a=>{var l;return(l=a.card.preferences)==null?void 0:l.datasetOptions}),i=r==null?void 0:r.find(a=>a.idx===t),{setCardPreferences:o}=pe(a=>a.actions);function s(a){if(!i)o({...n,datasetOptions:[...r||[],{idx:t,type:a==="area"?"line":a,fill:a==="area"?"origin":""}]});else{const l={...i};l.type=a==="area"?"line":a,l.fill=a==="area"?"origin":"";const c=r==null?void 0:r.map(u=>u.idx===t?l:u);o({...n,datasetOptions:c})}}return b.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[b.jsx("p",{children:e}),b.jsxs("div",{className:"flex gap-2",children:[b.jsx(I0,{onClick:()=>s("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),b.jsx(N0,{onClick:()=>s("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),b.jsx(g6,{onClick:()=>s("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})]})]})}function coe({cardType:e}){return b.jsx("div",{className:"space-y-6 px-6 py-2",children:b.jsxs(uc,{defaultValue:["item-2"],type:"multiple",children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{children:`${Em(e)} Chart`}),b.jsxs(On,{className:"space-y-4 font-mono text-xs",children:[b.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),b.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[b.jsx("li",{children:"x-axis - category"}),b.jsx("li",{children:"y-axis1 - number"}),b.jsx("li",{children:"y-axis2 - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{children:"Settings"}),b.jsxs(On,{className:"space-y-4 px-2",children:[b.jsx(l1,{}),b.jsx(sA,{}),b.jsx(Td,{})]})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{children:"Filter on click"}),b.jsx(On,{className:"px-2",children:b.jsx(Ad,{})})]})]})})}function uoe({cardType:e}){function t(n){const r="SELECT label, [group], x-axis, y-axis, radius FROM table",i="SELECT label, [group], x-axis, y-axis FROM table";return b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:n==="bubble"?r:i}),b.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[b.jsx("li",{children:"label - category"}),b.jsx("li",{children:"group - category"}),b.jsx("li",{children:"x-axis - category"}),b.jsx("li",{children:"y-axis - category"}),n==="bubble"&&b.jsx("li",{children:"radius - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:o=>o.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return b.jsx("div",{className:"px-6 py-2 space-y-6",children:b.jsxs(uc,{defaultValue:["item-2"],type:"multiple",children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{children:`${Em(e)} Chart`}),b.jsx(On,{className:" space-y-4 font-mono text-xs ",children:t(e)})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{children:"Settings"}),b.jsx(On,{className:"px-2",children:b.jsx(Td,{})})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{children:"Filter on click"}),b.jsx(On,{className:"px-2",children:b.jsx(Ad,{})})]})]})})}const doe={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},foe={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function hoe(){const e=pe(t=>t.card.type);return b.jsxs("div",{className:"p-6 space-y-6",children:[b.jsx(uc,{className:" ",type:"single",collapsible:!0,children:poe(e)}),b.jsx("section",{className:"",children:["line","bar"].includes(e)&&b.jsx(l1,{})}),b.jsx("div",{children:!["kpi"].includes(e)&&b.jsx(Td,{})}),b.jsx("div",{children:!["kpi"].includes(e)&&b.jsx(Ad,{})})]})}function poe(e){if(["line","bar"].includes(e))return b.jsxs(b.Fragment,{children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:" font-normal",children:b.jsx("p",{children:"Chart Query"})}),b.jsxs(On,{className:" ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[b.jsx("li",{children:"X-axis - Category (ex. city)"}),b.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{className:" font-normal",children:"Mixed Chart"}),b.jsxs(On,{className:" text-xs space-y-2",children:[b.jsxs("p",{children:["Click ",b.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),b.jsx("pre",{children:JSON.stringify(doe,null,2)})]})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{className:" font-normal",children:"Area Chart"}),b.jsxs(On,{className:" text-xs space-y-2",children:[b.jsxs("p",{children:["Click ",b.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",b.jsx("a",{className:"text-blue-500 hover:underline mx-1",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),b.jsx("pre",{children:JSON.stringify(foe,null,2)})]})]})]});if(e==="bubble")return b.jsx(b.Fragment,{children:b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:" font-normal",children:b.jsxs("p",{children:["How to create a ",b.jsx("span",{children:e})," chart query?"]})}),b.jsxs(On,{className:" ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis, radius FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[b.jsx("li",{children:"Label - Category (ex. city)"}),b.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),b.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),b.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),b.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(e==="scatter")return b.jsx(b.Fragment,{children:b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:" font-normal",children:b.jsxs("p",{children:["How to create a ",b.jsx("span",{children:e})," chart query?"]})}),b.jsxs(On,{className:" ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[b.jsx("li",{children:"Label - Category (ex. city)"}),b.jsx("li",{children:"Group (opt) - Category (ex. state)"}),b.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),b.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(e))return b.jsx(b.Fragment,{children:b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:" font-normal",children:b.jsxs("p",{children:[b.jsx("span",{children:e==="polarArea"?"Polar":e.charAt(0).toUpperCase()+e.slice(1)})," ","chart query"]})}),b.jsxs(On,{className:" ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, measure FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[b.jsx("li",{children:"Label - Category (ex. city)"}),b.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function goe(){var s,a,l;const e=pe(c=>c.card.preferences),t=pe(c=>c.actions.setCardPreferences),n=pe(c=>c.actions.setNumberFormat),r=pe(c=>{var u,f;return(f=(u=c.card.preferences)==null?void 0:u.formatNumber)==null?void 0:f.format}),i=pe(c=>{var u,f;return(f=(u=c.card.preferences)==null?void 0:u.formatNumber)==null?void 0:f.locale}),o=pe(c=>{var u,f;return(f=(u=c.card.preferences)==null?void 0:u.formatNumber)==null?void 0:f.currency});return pe(c=>c.actions.setFilterOnClickField),b.jsxs("div",{children:[b.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[b.jsx(hd,{checked:!!((s=e==null?void 0:e.formatNumber)!=null&&s.enabled),onCheckedChange:c=>{t({...e,formatNumber:{...e==null?void 0:e.formatNumber,enabled:c}})}}),b.jsx(Fn,{children:"Format Number"})]}),((a=e==null?void 0:e.formatNumber)==null?void 0:a.enabled)===!0&&b.jsxs("div",{className:"flex flex-col gap-2 ",children:[b.jsxs("div",{children:[b.jsx(Fn,{className:"text-xs",children:"Currency"}),b.jsxs("div",{className:"flex gap-1",children:[b.jsx(Ii,{value:o||"",className:" h-7 w-20 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"USD",onChange:c=>{var u,f,g;return n(((u=e==null?void 0:e.formatNumber)==null?void 0:u.format)||"",c.target.value,((f=e==null?void 0:e.formatNumber)==null?void 0:f.locale)||"",((g=e==null?void 0:e.formatNumber)==null?void 0:g.suffix)||"")}}),b.jsx(Ii,{value:i||"",className:" h-7 w-20 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"en-US",onChange:c=>{var u,f,g;return n(((u=e==null?void 0:e.formatNumber)==null?void 0:u.format)||"",((f=e==null?void 0:e.formatNumber)==null?void 0:f.currency)||"",c.target.value,((g=e==null?void 0:e.formatNumber)==null?void 0:g.suffix)||"")}})]})]}),b.jsxs("div",{children:[b.jsxs("div",{className:" flex gap-1",children:[b.jsx(Fn,{className:"text-xs",children:"Format"}),b.jsxs(ep,{children:[b.jsx(h0,{children:b.jsx(H2,{strokeWidth:1,className:"h-3 w-3 opacity-70"})}),b.jsx(Uu,{children:b.jsxs("div",{className:"max-w-[200px]",children:["Format number",b.jsx("div",{className:" mt-1 text-xs font-mono",children:"#.## for 123.43"})]})})]})]}),b.jsx("div",{children:b.jsx(Ii,{value:r||"",className:" h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"###,###.##",onChange:c=>{var u,f,g;return n(c.target.value,((u=e==null?void 0:e.formatNumber)==null?void 0:u.currency)||"",((f=e==null?void 0:e.formatNumber)==null?void 0:f.locale)||"",((g=e==null?void 0:e.formatNumber)==null?void 0:g.suffix)||"")}})})]}),b.jsxs("div",{children:[b.jsx(Fn,{className:"text-xs",children:"Suffix"}),b.jsx(Ii,{value:((l=e==null?void 0:e.formatNumber)==null?void 0:l.suffix)||"",className:" h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B",onChange:c=>{var u,f,g;return n(((u=e==null?void 0:e.formatNumber)==null?void 0:u.format)||"",((f=e==null?void 0:e.formatNumber)==null?void 0:f.currency)||"",((g=e==null?void 0:e.formatNumber)==null?void 0:g.locale)||"",c.target.value)}})]})]})]})}function moe(){return b.jsxs("div",{className:"px-6 py-2 space-y-6",children:[b.jsx(uc,{type:"single",collapsible:!0,children:b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:"",children:"KPI Query"}),b.jsxs(On,{className:"font-mono ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono text-xs",children:"SELECT current, previous FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 text-xs",children:[b.jsx("li",{children:"current - number"}),b.jsx("li",{children:"previous - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:e=>e.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),b.jsx("section",{className:"",children:b.jsx(goe,{})}),b.jsx("div",{}),b.jsx("div",{})]})}function voe({cardType:e}){return b.jsx("div",{className:"px-6 py-2 space-y-6",children:b.jsxs(uc,{defaultValue:["item-2"],type:"multiple",children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{children:`${Em(e)} Chart`}),b.jsxs(On,{className:" space-y-4 font-mono text-xs ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:"SELECT label, measure FROM table"}),b.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[b.jsx("li",{children:"label - category"}),b.jsx("li",{children:"measure - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{children:"Settings"}),b.jsx(On,{className:"px-2",children:b.jsx(Td,{})})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{children:"Filter on click"}),b.jsx(On,{className:"px-2",children:b.jsx(Ad,{})})]})]})})}function boe(){return b.jsx("div",{className:"px-6 py-2 space-y-6",children:b.jsxs(uc,{defaultValue:["item-2"],type:"multiple",children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{children:"Stacked Chart"}),b.jsxs(On,{className:" space-y-4 font-mono text-xs ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),b.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[b.jsx("li",{children:"x-axis - category"}),b.jsx("li",{children:"stack by - category"}),b.jsx("li",{children:"y-axis - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:e=>e.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{children:"Settings"}),b.jsxs(On,{className:"px-2 space-y-4",children:[b.jsx(l1,{}),b.jsx(sA,{}),b.jsx(Td,{})]})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{children:"Filter on click"}),b.jsx(On,{className:"px-2",children:b.jsx(Ad,{})})]})]})})}function yoe(){const e=pe(n=>n.card.type);function t(n){switch(n){case"stackedBar":return b.jsx(boe,{});case"kpi":return b.jsx(moe,{});case"line":case"bar":return b.jsx(coe,{cardType:n});case"pie":case"doughnut":case"polarArea":case"radar":return b.jsx(voe,{cardType:n});case"bubble":case"scatter":return b.jsx(uoe,{cardType:n});case"table":return b.jsx(b.Fragment,{});default:return b.jsx(hoe,{})}}return b.jsx(Rl,{className:" text-sm h-full w-full ",children:t(e)})}function xoe(){const e=pe(t=>t.isShowingVisual);return b.jsxs(px,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[b.jsx(rc,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:b.jsx(eie,{})}),b.jsx(gx,{withHandle:!0,className:"border "}),b.jsx(rc,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:e?b.jsxs(px,{direction:"horizontal",children:[b.jsx(b.Fragment,{children:b.jsx(rc,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:b.jsx(yoe,{})})}),b.jsx(gx,{className:"border "}),b.jsx(rc,{minSize:40,defaultSize:75,maxSize:100,children:b.jsx(jT,{})})]}):b.jsx(jT,{})})]})}function woe({authToken:e,onSave:t,onClose:n}){pe(s=>s.actions.setCard);const r=pe(s=>s.actions.setOnSave),i=pe(s=>s.actions.setOnClose),o=he(s=>s.actions.setAuthToken);return m.useEffect(()=>{t&&r(t),n&&i(n)},[t,r,n,i]),m.useEffect(()=>{e&&e.accessToken&&o(e)},[e,o]),b.jsxs(DM,{className:"rounded-none",role:"editor-panel",children:[b.jsx(TM,{className:" rounded-none border-r-[1.5px] ",children:b.jsx(tD,{})}),b.jsx(AM,{children:b.jsx(xoe,{})})]})}function _oe(){he(s=>s.selectedCardId);const e=he(s=>s.selectedSheetId),{setIsVisualEditing:t}=he(s=>s.actions),n=he(s=>s.isVisualEditing),r=he(s=>s.actions.updateFrame);function i(s){e&&(r(e,s),t(!1))}function o(){t(!1)}return b.jsx("div",{role:"editor-container",className:Ee("grow flex",{block:n,hidden:!n}),children:b.jsx(woe,{onSave:i,onClose:o})})}function Soe({columns:e,tableName:t}){const n=pe(f=>f.selectedConnectionId),r=pe(f=>f.selectedDatabaseName),i=pe(f=>f.selectedSchemaName),o=pe(f=>f.selectedTableName),s=he(f=>f.dashboard.filters)||[],a=he(f=>f.actions.addFilter),l=he(f=>f.actions.removeFilter),c=he(f=>f.actions.removeFilterValue);function u(f){const g=ki(f.column_name),p=ki(r||""),v=ki(i||""),y=ki(t),w=s==null?void 0:s.find(_=>_.column===g&&_.table===y&&_.database===p);if(w)c(w.id),l(w.id);else{const _=Op(v,y),S=`SELECT ${g}, COUNT(*) FROM ${_} GROUP BY ${g} ORDER BY ${g} ASC LIMIT 50`,C=`SELECT min(${g}) as min, max(${g}) as max FROM ${_}`;if(t==="api"&&n){a({id:Qo(),column:`${_}.${g}`,title:f.column_name,dataType:f.data_type,table:"api",database:"NA",connectionId:n,sql:Sa.includes(f.data_type)?C:S});return}if(!n||!r||!o)throw new Error("missing connectionId, database, or table");a({id:Qo(),column:`${_}.${g}`,title:f.column_name,dataType:f.data_type,table:o,database:r,connectionId:n,sql:Sa.includes(f.data_type)?C:S})}}return b.jsx("div",{className:" flex-1 basis-0 overflow-scroll flex-col xbg-red-100 px-3",children:e==null?void 0:e.map(f=>{const g=s==null?void 0:s.find(p=>p.column===ki(f.column_name)&&p.table===o&&p.database===r);return b.jsx("div",{onClick:()=>u(f),className:Ee(" group flex text-sm items-center justify-between px-3 py-[6px] transition-colors hover:bg-muted/50 cursor-pointer border border-background border-dashed",{"bg-muted ":g}),children:b.jsxs("div",{className:"flex items-center gap-2 ",children:[b.jsx(eD,{column:f}),b.jsx("span",{children:f.column_name})]})},f.column_name)})})}function Coe(){he(t=>t.showFilters);const e=he(t=>t.actions.setShowFilters);return b.jsxs("section",{className:" grow flex flex-col border-l relative px-4 ",children:[b.jsxs("div",{className:"flex justify-between items-center gap-2 mt-4 px-3",children:[b.jsx(Fn,{className:"text-lg",children:"Filters"}),b.jsx(Je,{onClick:()=>e(!1),className:" p-0 h-7 w-7 ",variant:"ghost",children:b.jsx(pa,{})})]}),b.jsx("div",{className:"grow flex",children:b.jsx(tD,{ColumnsComponent:(t,n,r)=>b.jsx(Soe,{schemaName:t,tableName:n,columns:r})})})]})}function Eoe(){he(n=>n.dashboard);const e=he(n=>n.showFilters),t=he(n=>n.isVisualEditing);return he(n=>n.bookmarkKey),b.jsxs("div",{role:"dashboard-plus-main",className:Ee(" grow",{hidden:t,flex:!t}),children:[b.jsx(zk,{}),e&&b.jsx("div",{role:"filter-aside-container",className:" flex",children:b.jsx(Coe,{})})]})}function Ooe(){const e=he(r=>r.dashboard),t=he(r=>r.actions.setDashboard),n=he(r=>r.showDashboardJSON);return he(r=>r.actions.setShowDashboardJSON),b.jsx("div",{className:Ee(" p-2",{hidden:!n}),children:b.jsx(BD,{onChange:r=>{if(r)try{JSON.parse(r),t(JSON.parse(r))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(e,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function Poe({showControls:e=!1,showFooter:t=!0,...n}){return he(r=>r.isVisualEditing),b.jsx(A_,{dashboardProps:n,children:b.jsxs(By,{children:[b.jsx(Ooe,{}),b.jsxs($_,{...n,children:[e&&b.jsx(cQ,{}),b.jsx(_oe,{}),b.jsx(Eoe,{})]})]})})}function koe({card:e,footer:t,className:n,...r}){const{customCards:i}=zi(),o=m.useRef(null),{isError:s,isLoading:a,isFetching:l,cfg:c,visualKey:u,handleDatapointClick:f}=j0(e),g=he(I=>I.themeStyle),p=he(I=>I.selectedSheetId),v=he(I=>I.selectedCardId),y=he(I=>I.isDashboardEditing),{setCardTitle:w,setCardDescription:_,setSelectedCardId:S}=pl();function C(I){I.stopPropagation(),S(p,e.id)}function P(){if(i&&i.length>0){const I=i.find(F=>F.cardId===e.id);if(I&&I.replaceDefault){const F=I.content;if(F)return b.jsx(F,{card:e})}}return e.type==="kpi"?e.data&&e.data.length>0&&b.jsx(L0,{isLoading:a||l,card:e}):T}function O(){if(s)return b.jsx("p",{className:"text-sm",children:"Oops! It seems like something went wrong. Please review your connection or filters."});if(e.type==="table"&&e.data&&e.data.length>0)return b.jsxs(Rl,{children:[b.jsx(sp,{data:e.data}),b.jsx(Ll,{orientation:"horizontal"})]});if(i&&i.length>0){const I=i.find(F=>F.cardId===e.id);if(I&&I.content){const F=I.content;return b.jsx(F,{card:e})}}if(c)return b.jsx(Xb,{cfg:c,onDatapointClick:f},u)}function k(){if(i&&i.length>0){const I=i.find(F=>F.cardId===e.id);if(I&&I.footer){const F=I.footer;if(F)return b.jsx(F,{card:e})}}return t||null}if(!e.id)return null;const T=b.jsxs(b.Fragment,{children:[b.jsxs(su,{className:"pb-4",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx(Ui,{text:e.title,onSave:I=>w(p,e.id,I),children:b.jsx(au,{className:"text-base",children:e.title})}),e.refreshInterval&&b.jsxs(ep,{children:[b.jsx(h0,{className:"pr-1",children:b.jsx("div",{className:Ee("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":a||l})})}),b.jsx(Uu,{side:"right",align:"center",children:b.jsx("p",{className:"text-xs",children:`Realtime (${e==null?void 0:e.refreshInterval})`})})]}),!e.refreshInterval&&(a||l)&&b.jsx(ma,{className:"h-4 w-4 animate-spin text-muted-foreground"})]}),b.jsx(Ui,{text:(e==null?void 0:e.description)||"",onSave:I=>_(p,e.id,I),children:b.jsxs(rh,{children:[" ",e.description]})})]}),b.jsx(lu,{className:"relative flex grow flex-col overflow-auto pb-0",children:O()}),b.jsx(rb,{children:k()})]});return b.jsx(nh,{tabIndex:-1,ref:o,role:"dashboard-card",onClick:C,className:Ee("relative flex h-full flex-col rounded-sm",{"border-dashed border-foreground/50":v===e.id&&y},g==null?void 0:g.dashboardCard,n),...r,children:P()})}const Dg=`import pandas as pd
574
+ Defaulting to \`${e1}\`.`}function RT(e){return hie.includes(e)}const LT=NT,FT=de.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>b.jsx(LT,{ref:i,decorative:n,orientation:t,className:Ee("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));FT.displayName=LT.displayName;function jT(){pe(s=>s.frame);const e=pe(s=>s.card),t=pe(s=>s.card.data),n=pe(s=>s.isShowingVisual),r=pe(s=>s.isSqlRunning),i=pe(s=>s.queryError),o=pe(s=>s.pythonStdOut);return pe(s=>s.onSave),pe(s=>s.onClose),pe(s=>s.actions.setCardSql),pe(s=>s.actions.setCardType),pe(s=>s.actions.setSqlGen),e?b.jsxs("div",{className:" h-full relative flex flex-col py-3",children:[r&&b.jsx(ma,{className:" w-10 h-10 z-10 absolute m-auto left-0 right-0 top-0 bottom-0 animate-spin text-foreground/10 "}),b.jsxs("div",{className:" px-6 min-h-10 mb-0 flex justify-end items-center gap-2",children:[n&&b.jsxs("div",{className:"flex grow gap-2 items-center ",children:[b.jsx(uie,{}),b.jsx(cie,{}),b.jsx(fie,{})]}),b.jsx(mie,{})]}),n?e.type==="kpi"?b.jsx("div",{className:"grow flex items-center justify-center ",children:b.jsx("div",{className:" w-1/2 border rounded-md",children:b.jsx(L0,{isLoading:r,card:e})})}):b.jsx(PT,{className:"grow border-none shadow-none "}):b.jsxs("div",{className:"w-full px-6 bg-red-x00 grow border-none shadow-none overflow-y-auto ",children:[o&&b.jsx(gie,{}),e.data&&e.data.length>0&&b.jsx(sp,{data:t||[]}),i&&b.jsx("span",{className:"font-mono text-sm",children:i})]})]}):b.jsx(b.Fragment,{children:"No Active Card"})}function gie(){const e=pe(n=>n.pythonStdOut);if(!e)return null;const t=e.replace(/\n/g,"<br>");return b.jsxs(b.Fragment,{children:[b.jsx("p",{className:"font-mono text-sm",children:"Output:"}),b.jsx("div",{dangerouslySetInnerHTML:{__html:t},className:"font-mono text-sm p-2 bg-muted"}),b.jsx(FT,{className:" mb-2"})]})}function mie(){const e=pe(n=>n.isShowingVisual),t=pe(n=>n.actions.setIsShowingVisual);return b.jsxs("div",{className:" flex items-center space-x-2",children:[b.jsx(Fn,{htmlFor:"visualize",children:"Chart"}),b.jsx(OT,{checked:e,onCheckedChange:()=>t(!e),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}const $T="Collapsible",[vie,zT]=Rn($T),[bie,t1]=vie($T),yie=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:o,onOpenChange:s,...a}=e,[l=!1,c]=Qn({prop:r,defaultProp:i,onChange:s});return m.createElement(bie,{scope:n,disabled:o,contentId:pr(),open:l,onOpenToggle:m.useCallback(()=>c(u=>!u),[c])},m.createElement(ze.div,ae({"data-state":n1(l),"data-disabled":o?"":void 0},a,{ref:t})))}),xie="CollapsibleTrigger",wie=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=t1(xie,n);return m.createElement(ze.button,ae({type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":n1(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled},r,{ref:t,onClick:Oe(e.onClick,i.onOpenToggle)}))}),BT="CollapsibleContent",_ie=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=t1(BT,e.__scopeCollapsible);return m.createElement(wn,{present:n||i.open},({present:o})=>m.createElement(Sie,ae({},r,{ref:t,present:o})))}),Sie=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...o}=e,s=t1(BT,n),[a,l]=m.useState(r),c=m.useRef(null),u=rt(t,c),f=m.useRef(0),g=f.current,p=m.useRef(0),v=p.current,y=s.open||a,w=m.useRef(y),_=m.useRef();return m.useEffect(()=>{const S=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(S)},[]),Xn(()=>{const S=c.current;if(S){_.current=_.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const C=S.getBoundingClientRect();f.current=C.height,p.current=C.width,w.current||(S.style.transitionDuration=_.current.transitionDuration,S.style.animationName=_.current.animationName),l(r)}},[s.open,r]),m.createElement(ze.div,ae({"data-state":n1(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!y},o,{ref:u,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style}}),y&&i)});function n1(e){return e?"open":"closed"}const Cie=yie,Eie=wie,Oie=_ie,Es="Accordion",Pie=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[r1,kie,Mie]=Af(Es),[kg,$he]=Rn(Es,[Mie,zT]),i1=zT(),VT=m.forwardRef((e,t)=>{const{type:n,...r}=e,i=r,o=r;return m.createElement(r1.Provider,{scope:e.__scopeAccordion},n==="multiple"?m.createElement(Iie,ae({},o,{ref:t})):m.createElement(Aie,ae({},i,{ref:t})))});VT.propTypes={type(e){const t=e.value||e.defaultValue;return e.type&&!["single","multiple"].includes(e.type)?new Error("Invalid prop `type` supplied to `Accordion`. Expected one of `single | multiple`."):e.type==="multiple"&&typeof t=="string"?new Error("Invalid prop `type` supplied to `Accordion`. Expected `single` when `defaultValue` or `value` is type `string`."):e.type==="single"&&Array.isArray(t)?new Error("Invalid prop `type` supplied to `Accordion`. Expected `multiple` when `defaultValue` or `value` is type `string[]`."):null}};const[HT,Die]=kg(Es),[WT,Tie]=kg(Es,{collapsible:!1}),Aie=m.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:i=()=>{},collapsible:o=!1,...s}=e,[a,l]=Qn({prop:n,defaultProp:r,onChange:i});return m.createElement(HT,{scope:e.__scopeAccordion,value:a?[a]:[],onItemOpen:l,onItemClose:m.useCallback(()=>o&&l(""),[o,l])},m.createElement(WT,{scope:e.__scopeAccordion,collapsible:o},m.createElement(UT,ae({},s,{ref:t}))))}),Iie=m.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:i=()=>{},...o}=e,[s=[],a]=Qn({prop:n,defaultProp:r,onChange:i}),l=m.useCallback(u=>a((f=[])=>[...f,u]),[a]),c=m.useCallback(u=>a((f=[])=>f.filter(g=>g!==u)),[a]);return m.createElement(HT,{scope:e.__scopeAccordion,value:s,onItemOpen:l,onItemClose:c},m.createElement(WT,{scope:e.__scopeAccordion,collapsible:!0},m.createElement(UT,ae({},o,{ref:t}))))}),[Nie,Mg]=kg(Es),UT=m.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:i,orientation:o="vertical",...s}=e,a=m.useRef(null),l=rt(a,t),c=kie(n),f=Ys(i)==="ltr",g=Oe(e.onKeyDown,p=>{var v;if(!Pie.includes(p.key))return;const y=p.target,w=c().filter(F=>{var $;return!(($=F.ref.current)!==null&&$!==void 0&&$.disabled)}),_=w.findIndex(F=>F.ref.current===y),S=w.length;if(_===-1)return;p.preventDefault();let C=_;const P=0,O=S-1,k=()=>{C=_+1,C>O&&(C=P)},T=()=>{C=_-1,C<P&&(C=O)};switch(p.key){case"Home":C=P;break;case"End":C=O;break;case"ArrowRight":o==="horizontal"&&(f?k():T());break;case"ArrowDown":o==="vertical"&&k();break;case"ArrowLeft":o==="horizontal"&&(f?T():k());break;case"ArrowUp":o==="vertical"&&T();break}const I=C%S;(v=w[I].ref.current)===null||v===void 0||v.focus()});return m.createElement(Nie,{scope:n,disabled:r,direction:i,orientation:o},m.createElement(r1.Slot,{scope:n},m.createElement(ze.div,ae({},s,{"data-orientation":o,ref:l,onKeyDown:r?void 0:g}))))}),o1="AccordionItem",[Rie,s1]=kg(o1),Lie=m.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...i}=e,o=Mg(o1,n),s=Die(o1,n),a=i1(n),l=pr(),c=r&&s.value.includes(r)||!1,u=o.disabled||e.disabled;return m.createElement(Rie,{scope:n,open:c,disabled:u,triggerId:l},m.createElement(Cie,ae({"data-orientation":o.orientation,"data-state":GT(c)},a,i,{ref:t,disabled:u,open:c,onOpenChange:f=>{f?s.onItemOpen(r):s.onItemClose(r)}})))}),Fie="AccordionHeader",jie=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Mg(Es,n),o=s1(Fie,n);return m.createElement(ze.h3,ae({"data-orientation":i.orientation,"data-state":GT(o.open),"data-disabled":o.disabled?"":void 0},r,{ref:t}))}),qT="AccordionTrigger",$ie=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Mg(Es,n),o=s1(qT,n),s=Tie(qT,n),a=i1(n);return m.createElement(r1.ItemSlot,{scope:n},m.createElement(Eie,ae({"aria-disabled":o.open&&!s.collapsible||void 0,"data-orientation":i.orientation,id:o.triggerId},a,r,{ref:t})))}),zie="AccordionContent",Bie=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Mg(Es,n),o=s1(zie,n),s=i1(n);return m.createElement(Oie,ae({role:"region","aria-labelledby":o.triggerId,"data-orientation":i.orientation},s,r,{ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}}))});function GT(e){return e?"open":"closed"}const Vie=VT,Hie=Lie,Wie=jie,YT=$ie,KT=Bie,uc=Vie,Cn=de.forwardRef(({className:e,...t},n)=>b.jsx(Hie,{ref:n,className:Ee("border-b",e),...t}));Cn.displayName="AccordionItem";const En=de.forwardRef(({className:e,children:t,...n},r)=>b.jsx(Wie,{className:"flex",children:b.jsxs(YT,{ref:r,className:Ee("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,b.jsx(dp,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));En.displayName=YT.displayName;const On=de.forwardRef(({className:e,children:t,...n},r)=>b.jsx(KT,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:b.jsx("div",{className:Ee("pb-4 pt-0",e),children:t})}));On.displayName=KT.displayName;function Td(){var r,i,o;const e=pe(s=>s.card.cfg),t=pe(s=>s.actions.setCardCfg);function n(s){var c;const a={datalabels:{display:s!=="none",align:s,anchor:s,clamp:!0}},l={...e,options:{...e==null?void 0:e.options,plugins:{...(c=e==null?void 0:e.options)==null?void 0:c.plugins,...a}}};t(l),console.log(s)}return b.jsxs("div",{className:"space-y-2",children:[b.jsx("label",{className:"font-medium",children:"Data Labels"}),b.jsxs(lx,{value:(o=(i=(r=e==null?void 0:e.options)==null?void 0:r.plugins)==null?void 0:i.datalabels)==null?void 0:o.anchor,onValueChange:n,defaultValue:"none",children:[b.jsx(rg,{className:"h-8 w-[180px] focus:ring-1 focus:ring-offset-0",children:b.jsx(ux,{placeholder:"Select position"})}),b.jsx(ig,{children:b.jsxs(cx,{children:[b.jsx(pd,{children:"Data Labels"}),b.jsx(Ro,{value:"none",children:"None"}),b.jsx(Ro,{value:"start",children:"Start"}),b.jsx(Ro,{value:"center",children:"Center"}),b.jsx(Ro,{value:"end",children:"End"})]})})]})]})}function Ad(){const[e,t]=m.useState([]);pe(u=>u.card.cfg);const n=pe(u=>u.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:i,setCardPreferences:o}=pe(u=>u.actions),s=pe(u=>u.queryResultColumns);pe(u=>{var f;return(f=u.card.preferences)==null?void 0:f.filterOnClickColumnIndex}),m.useEffect(()=>{s&&t(new Array(s.length).fill(!1))},[s]);function a(u,f){var g,p;f?n!=null&&n.onClickFilter&&((g=n==null?void 0:n.onClickFilter)==null?void 0:g.length)>0?o({...n,onClickFilter:[...n.onClickFilter,{columnIndex:u,expression:""}]}):o({...n,onClickFilter:[{columnIndex:u,expression:""}]}):(o({...n,onClickFilter:(p=n==null?void 0:n.onClickFilter)==null?void 0:p.filter(v=>v.columnIndex!==u)}),t(v=>{const y=[...v];return y[u]=!1,y}))}function l(u,f){var p;const g=(p=n==null?void 0:n.onClickFilter)==null?void 0:p.map(v=>v.columnIndex===u?{...v,expression:f.target.value}:v);o({...n,onClickFilter:g})}function c(u){var f,g,p,v;if(e!=null&&e[u]||(g=(f=n==null?void 0:n.onClickFilter)==null?void 0:f.find(y=>y.columnIndex===u))!=null&&g.expression)return b.jsx(Ii,{value:(v=(p=n==null?void 0:n.onClickFilter)==null?void 0:p.find(y=>y.columnIndex===u))==null?void 0:v.expression,onChange:y=>l(u,y),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return b.jsx(b.Fragment,{children:s==null?void 0:s.map((u,f)=>{var g,p;return b.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:b.jsxs("div",{className:" grow",children:[b.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[b.jsx(hd,{checked:!!((g=n==null?void 0:n.onClickFilter)!=null&&g.find(v=>v.columnIndex===f)),onCheckedChange:v=>a(f,v)}),b.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:u}),b.jsx("div",{className:"flex gap-2 items-center ",children:((p=n==null?void 0:n.onClickFilter)==null?void 0:p.find(v=>v.columnIndex===f))&&b.jsx(oP,{onClick:()=>{t(v=>{const y=[...v];return y[f]=!v[f],y})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),c(f)]})},u)})})}const XT="Radio",[Uie,QT]=Rn(XT),[qie,Gie]=Uie(XT),Yie=m.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:i=!1,required:o,disabled:s,value:a="on",onCheck:l,...c}=e,[u,f]=m.useState(null),g=rt(t,y=>f(y)),p=m.useRef(!1),v=u?!!u.closest("form"):!0;return m.createElement(qie,{scope:n,checked:i,disabled:s},m.createElement(ze.button,ae({type:"button",role:"radio","aria-checked":i,"data-state":ZT(i),"data-disabled":s?"":void 0,disabled:s,value:a},c,{ref:g,onClick:Oe(e.onClick,y=>{i||l==null||l(),v&&(p.current=y.isPropagationStopped(),p.current||y.stopPropagation())})})),v&&m.createElement(Qie,{control:u,bubbles:!p.current,name:r,value:a,checked:i,required:o,disabled:s,style:{transform:"translateX(-100%)"}}))}),Kie="RadioIndicator",Xie=m.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...i}=e,o=Gie(Kie,n);return m.createElement(wn,{present:r||o.checked},m.createElement(ze.span,ae({"data-state":ZT(o.checked),"data-disabled":o.disabled?"":void 0},i,{ref:t})))}),Qie=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Zp(n),a=Xh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const g=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(g)}},[s,n,r]),m.createElement("input",ae({type:"radio","aria-hidden":!0,defaultChecked:n},i,{tabIndex:-1,ref:o,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function ZT(e){return e?"checked":"unchecked"}const Zie=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],JT="RadioGroup",[Jie,zhe]=Rn(JT,[gl,QT]),eA=gl(),tA=QT(),[eoe,toe]=Jie(JT),noe=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:i,value:o,required:s=!1,disabled:a=!1,orientation:l,dir:c,loop:u=!0,onValueChange:f,...g}=e,p=eA(n),v=Ys(c),[y,w]=Qn({prop:o,defaultProp:i,onChange:f});return m.createElement(eoe,{scope:n,name:r,required:s,disabled:a,value:y,onValueChange:w},m.createElement(iv,ae({asChild:!0},p,{orientation:l,dir:v,loop:u}),m.createElement(ze.div,ae({role:"radiogroup","aria-required":s,"aria-orientation":l,"data-disabled":a?"":void 0,dir:v},g,{ref:t}))))}),roe="RadioGroupItem",ioe=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...i}=e,o=toe(roe,n),s=o.disabled||r,a=eA(n),l=tA(n),c=m.useRef(null),u=rt(t,c),f=o.value===i.value,g=m.useRef(!1);return m.useEffect(()=>{const p=y=>{Zie.includes(y.key)&&(g.current=!0)},v=()=>g.current=!1;return document.addEventListener("keydown",p),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",v)}},[]),m.createElement(ov,ae({asChild:!0},a,{focusable:!s,active:f}),m.createElement(Yie,ae({disabled:s,required:o.required,checked:f},l,i,{name:o.name,ref:u,onCheck:()=>o.onValueChange(i.value),onKeyDown:Oe(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:Oe(i.onFocus,()=>{var p;g.current&&((p=c.current)===null||p===void 0||p.click())})})))}),ooe=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,i=tA(n);return m.createElement(Xie,ae({},i,r,{ref:t}))}),nA=noe,rA=ioe,soe=ooe,a1=de.forwardRef(({className:e,...t},n)=>b.jsx(nA,{className:Ee("grid gap-2",e),...t,ref:n}));a1.displayName=nA.displayName;const Id=de.forwardRef(({className:e,...t},n)=>b.jsx(rA,{ref:n,className:Ee("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:b.jsx(soe,{className:"flex items-center justify-center",children:b.jsx(rP,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Id.displayName=rA.displayName;function l1(){var o,s;const e=pe(a=>a.card.preferences),t=pe(a=>a.card.cfg),{setCardCfg:n,setCardPreferences:r}=pe(a=>a.actions);(o=t==null?void 0:t.options)!=null&&o.indexAxis;function i(a){var u,f,g,p,v,y;let l={};(u=e==null?void 0:e.chartOptions)!=null&&u.scales&&(l={x:(g=(f=e==null?void 0:e.chartOptions)==null?void 0:f.scales)==null?void 0:g.y,y:(v=(p=e==null?void 0:e.chartOptions)==null?void 0:p.scales)==null?void 0:v.x});const c={...e,chartOptions:{...e==null?void 0:e.chartOptions,scales:{...(y=e==null?void 0:e.chartOptions)==null?void 0:y.scales,...l},indexAxis:a}};r(c)}return b.jsxs(a1,{value:((s=e==null?void 0:e.chartOptions)==null?void 0:s.indexAxis)||"x",onValueChange:i,className:"flex gap-3",defaultValue:"x",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(Id,{value:"x",id:"r1"}),b.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(Id,{value:"y",id:"r2"}),b.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const c1="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function iA(e){var n,r;return(n=e==null?void 0:e.chartOptions)!=null&&n.indexAxis?((r=e==null?void 0:e.chartOptions)==null?void 0:r.indexAxis)==="x"?"y":"x":"y"}function oA(e){var n,r,i;const t=iA(e);return((i=(r=(n=e==null?void 0:e.chartOptions)==null?void 0:n.scales)==null?void 0:r[t])==null?void 0:i.type)||"linear"}function aoe(){var S,C,P,O,k,T;const[e,t]=m.useState(!1),n=pe(I=>{var F;return(F=I.card)==null?void 0:F.preferences}),r=iA(n),[i,o]=m.useState(oA(n)),[s,a]=m.useState(((P=(C=(S=n==null?void 0:n.chartOptions)==null?void 0:S.scales)==null?void 0:C[r])==null?void 0:P.min)||""),[l,c]=m.useState(((T=(k=(O=n==null?void 0:n.chartOptions)==null?void 0:O.scales)==null?void 0:k[r])==null?void 0:T.max)||""),[u,f]=m.useState(s||l?"custom":"auto"),[g,p]=m.useState(""),v=pe(I=>I.actions.setCardPreferences);m.useEffect(()=>{var I,F,$,z,V,se,J,j,Z,G;o(oA(n)),a((($=(F=(I=n==null?void 0:n.chartOptions)==null?void 0:I.scales)==null?void 0:F[r])==null?void 0:$.min)===0?0:""),c(((se=(V=(z=n==null?void 0:n.chartOptions)==null?void 0:z.scales)==null?void 0:V[r])==null?void 0:se.max)||""),p(((G=(Z=(j=(J=n==null?void 0:n.chartOptions)==null?void 0:J.scales)==null?void 0:j[r])==null?void 0:Z.ticks)==null?void 0:G.stepSize)||"")},[e,n,r]);function y(I,F){return F===""||/^[0-9\b]+$/.test(F)?Number(F):Number(I)}function w(){return b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[b.jsx(Fn,{htmlFor:"range",children:"Range"}),b.jsx(Ii,{id:"min",value:s,onChange:I=>a(F=>y(F,I.target.value)),className:`col-span-1 h-8 w-full ${c1}`}),b.jsx(Ii,{value:l,onChange:I=>c(F=>y(F,I.target.value)),id:"max",className:`col-span-1 h-8 w-full ${c1}`})]}),b.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[b.jsx(Fn,{htmlFor:"step-size",children:"Step Size"}),b.jsx(Ii,{value:g,onChange:I=>p(F=>y(F,I.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${c1}`})]})]})}function _(){var $;let I={};u==="custom"&&(I={min:s,max:l,ticks:{stepSize:g}});const F={...n||{},chartOptions:{...n==null?void 0:n.chartOptions,scales:{...($=n==null?void 0:n.chartOptions)==null?void 0:$.scales,[r]:{type:i,...i==="linear"?I:{}}}}};v(F)}return b.jsxs(ad,{onOpenChange:I=>t(I),children:[b.jsx(ld,{asChild:!0,children:b.jsx(Vz,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),b.jsx(Kl,{align:"center",className:"max-w-65",children:b.jsxs("div",{className:"grid gap-4",children:[b.jsxs("div",{className:"space-y-2",children:[b.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),b.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),b.jsxs("div",{className:"grid gap-2",children:[b.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[b.jsx(Fn,{htmlFor:"scale",children:"Type"}),b.jsxs(lx,{value:i,onValueChange:I=>o(I),children:[b.jsx(rg,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:b.jsx(ux,{})}),b.jsx(ig,{id:"type",children:b.jsxs(cx,{children:[b.jsx(pd,{children:"Option"}),b.jsx(Ro,{value:"linear",children:"Linear"}),b.jsx(Ro,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),i=="linear"&&b.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[b.jsx(Fn,{htmlFor:"scale-option",children:"Setup"}),b.jsxs(a1,{id:"scale-option",value:u,onValueChange:I=>f(I),className:"col-span-2 flex gap-3",defaultValue:"x",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(Id,{value:"auto",id:"r1"}),b.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(Id,{value:"custom",id:"r2"}),b.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),u==="custom"&&i=="linear"&&w(),b.jsx(JM,{}),b.jsx("div",{className:"grid grid-cols-3",children:b.jsx(Je,{onClick:_,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function sA(){const e=pe(l=>l.card),t=pe(l=>{var c,u,f;return(f=(u=(c=l==null?void 0:l.card)==null?void 0:c.cfg)==null?void 0:u.options)==null?void 0:f.indexAxis}),n=t==="y"?"Y Axis":"X Axis",r=t==="y"?"X Axis":"Y Axis",{keys:i,metricKeys:o,dimensionKeys:s}=oi(e.data||[]);let a=o;if(e.type==="stackedBar"){const l=Zb({dataArray:e.data||[],groupKey:s[0],pivotKey:s[1],valueKey:a[0]}),{metricKeys:c}=oi(l);a=c}return i.length===0?null:b.jsxs("div",{className:"space-y-4",children:[b.jsxs("div",{className:"space-y-2",children:[b.jsx(Fn,{children:n}),b.jsx("div",{className:"my-1 space-y-1",children:b.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:b.jsx("p",{children:s[0]})})})]}),b.jsxs("div",{className:"space-y-2",children:[b.jsxs("div",{className:"flex items-center justify-between gap-5",children:[b.jsx(Fn,{children:r}),b.jsx(aoe,{})]}),b.jsx("div",{className:"my-1 space-y-1",children:a.map((l,c)=>b.jsx(loe,{col:l,idx:c},l))})]})]})}function loe({col:e,idx:t}){const n=pe(a=>{var l;return(l=a.card)==null?void 0:l.preferences}),r=pe(a=>{var l;return(l=a.card.preferences)==null?void 0:l.datasetOptions}),i=r==null?void 0:r.find(a=>a.idx===t),{setCardPreferences:o}=pe(a=>a.actions);function s(a){if(!i)o({...n,datasetOptions:[...r||[],{idx:t,type:a==="area"?"line":a,fill:a==="area"?"origin":""}]});else{const l={...i};l.type=a==="area"?"line":a,l.fill=a==="area"?"origin":"";const c=r==null?void 0:r.map(u=>u.idx===t?l:u);o({...n,datasetOptions:c})}}return b.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[b.jsx("p",{children:e}),b.jsxs("div",{className:"flex gap-2",children:[b.jsx(I0,{onClick:()=>s("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),b.jsx(N0,{onClick:()=>s("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),b.jsx(g6,{onClick:()=>s("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})]})]})}function coe({cardType:e}){return b.jsx("div",{className:"space-y-6 px-6 py-2",children:b.jsxs(uc,{defaultValue:["item-2"],type:"multiple",children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{children:`${Em(e)} Chart`}),b.jsxs(On,{className:"space-y-4 font-mono text-xs",children:[b.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),b.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[b.jsx("li",{children:"x-axis - category"}),b.jsx("li",{children:"y-axis1 - number"}),b.jsx("li",{children:"y-axis2 - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{children:"Settings"}),b.jsxs(On,{className:"space-y-4 px-2",children:[b.jsx(l1,{}),b.jsx(sA,{}),b.jsx(Td,{})]})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{children:"Filter on click"}),b.jsx(On,{className:"px-2",children:b.jsx(Ad,{})})]})]})})}function uoe({cardType:e}){function t(n){const r="SELECT label, [group], x-axis, y-axis, radius FROM table",i="SELECT label, [group], x-axis, y-axis FROM table";return b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:n==="bubble"?r:i}),b.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[b.jsx("li",{children:"label - category"}),b.jsx("li",{children:"group - category"}),b.jsx("li",{children:"x-axis - category"}),b.jsx("li",{children:"y-axis - category"}),n==="bubble"&&b.jsx("li",{children:"radius - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:o=>o.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return b.jsx("div",{className:"px-6 py-2 space-y-6",children:b.jsxs(uc,{defaultValue:["item-2"],type:"multiple",children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{children:`${Em(e)} Chart`}),b.jsx(On,{className:" space-y-4 font-mono text-xs ",children:t(e)})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{children:"Settings"}),b.jsx(On,{className:"px-2",children:b.jsx(Td,{})})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{children:"Filter on click"}),b.jsx(On,{className:"px-2",children:b.jsx(Ad,{})})]})]})})}const doe={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},foe={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function hoe(){const e=pe(t=>t.card.type);return b.jsxs("div",{className:"p-6 space-y-6",children:[b.jsx(uc,{className:" ",type:"single",collapsible:!0,children:poe(e)}),b.jsx("section",{className:"",children:["line","bar"].includes(e)&&b.jsx(l1,{})}),b.jsx("div",{children:!["kpi"].includes(e)&&b.jsx(Td,{})}),b.jsx("div",{children:!["kpi"].includes(e)&&b.jsx(Ad,{})})]})}function poe(e){if(["line","bar"].includes(e))return b.jsxs(b.Fragment,{children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:" font-normal",children:b.jsx("p",{children:"Chart Query"})}),b.jsxs(On,{className:" ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[b.jsx("li",{children:"X-axis - Category (ex. city)"}),b.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{className:" font-normal",children:"Mixed Chart"}),b.jsxs(On,{className:" text-xs space-y-2",children:[b.jsxs("p",{children:["Click ",b.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),b.jsx("pre",{children:JSON.stringify(doe,null,2)})]})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{className:" font-normal",children:"Area Chart"}),b.jsxs(On,{className:" text-xs space-y-2",children:[b.jsxs("p",{children:["Click ",b.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",b.jsx("a",{className:"text-blue-500 hover:underline mx-1",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),b.jsx("pre",{children:JSON.stringify(foe,null,2)})]})]})]});if(e==="bubble")return b.jsx(b.Fragment,{children:b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:" font-normal",children:b.jsxs("p",{children:["How to create a ",b.jsx("span",{children:e})," chart query?"]})}),b.jsxs(On,{className:" ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis, radius FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[b.jsx("li",{children:"Label - Category (ex. city)"}),b.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),b.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),b.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),b.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(e==="scatter")return b.jsx(b.Fragment,{children:b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:" font-normal",children:b.jsxs("p",{children:["How to create a ",b.jsx("span",{children:e})," chart query?"]})}),b.jsxs(On,{className:" ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[b.jsx("li",{children:"Label - Category (ex. city)"}),b.jsx("li",{children:"Group (opt) - Category (ex. state)"}),b.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),b.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(e))return b.jsx(b.Fragment,{children:b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:" font-normal",children:b.jsxs("p",{children:[b.jsx("span",{children:e==="polarArea"?"Polar":e.charAt(0).toUpperCase()+e.slice(1)})," ","chart query"]})}),b.jsxs(On,{className:" ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, measure FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[b.jsx("li",{children:"Label - Category (ex. city)"}),b.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function goe(){var s,a,l;const e=pe(c=>c.card.preferences),t=pe(c=>c.actions.setCardPreferences),n=pe(c=>c.actions.setNumberFormat),r=pe(c=>{var u,f;return(f=(u=c.card.preferences)==null?void 0:u.formatNumber)==null?void 0:f.format}),i=pe(c=>{var u,f;return(f=(u=c.card.preferences)==null?void 0:u.formatNumber)==null?void 0:f.locale}),o=pe(c=>{var u,f;return(f=(u=c.card.preferences)==null?void 0:u.formatNumber)==null?void 0:f.currency});return pe(c=>c.actions.setFilterOnClickField),b.jsxs("div",{children:[b.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[b.jsx(hd,{checked:!!((s=e==null?void 0:e.formatNumber)!=null&&s.enabled),onCheckedChange:c=>{t({...e,formatNumber:{...e==null?void 0:e.formatNumber,enabled:c}})}}),b.jsx(Fn,{children:"Format Number"})]}),((a=e==null?void 0:e.formatNumber)==null?void 0:a.enabled)===!0&&b.jsxs("div",{className:"flex flex-col gap-2 ",children:[b.jsxs("div",{children:[b.jsx(Fn,{className:"text-xs",children:"Currency"}),b.jsxs("div",{className:"flex gap-1",children:[b.jsx(Ii,{value:o||"",className:" h-7 w-20 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"USD",onChange:c=>{var u,f,g;return n(((u=e==null?void 0:e.formatNumber)==null?void 0:u.format)||"",c.target.value,((f=e==null?void 0:e.formatNumber)==null?void 0:f.locale)||"",((g=e==null?void 0:e.formatNumber)==null?void 0:g.suffix)||"")}}),b.jsx(Ii,{value:i||"",className:" h-7 w-20 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"en-US",onChange:c=>{var u,f,g;return n(((u=e==null?void 0:e.formatNumber)==null?void 0:u.format)||"",((f=e==null?void 0:e.formatNumber)==null?void 0:f.currency)||"",c.target.value,((g=e==null?void 0:e.formatNumber)==null?void 0:g.suffix)||"")}})]})]}),b.jsxs("div",{children:[b.jsxs("div",{className:" flex gap-1",children:[b.jsx(Fn,{className:"text-xs",children:"Format"}),b.jsxs(ep,{children:[b.jsx(h0,{children:b.jsx(H2,{strokeWidth:1,className:"h-3 w-3 opacity-70"})}),b.jsx(Uu,{children:b.jsxs("div",{className:"max-w-[200px]",children:["Format number",b.jsx("div",{className:" mt-1 text-xs font-mono",children:"#.## for 123.43"})]})})]})]}),b.jsx("div",{children:b.jsx(Ii,{value:r||"",className:" h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"###,###.##",onChange:c=>{var u,f,g;return n(c.target.value,((u=e==null?void 0:e.formatNumber)==null?void 0:u.currency)||"",((f=e==null?void 0:e.formatNumber)==null?void 0:f.locale)||"",((g=e==null?void 0:e.formatNumber)==null?void 0:g.suffix)||"")}})})]}),b.jsxs("div",{children:[b.jsx(Fn,{className:"text-xs",children:"Suffix"}),b.jsx(Ii,{value:((l=e==null?void 0:e.formatNumber)==null?void 0:l.suffix)||"",className:" h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B",onChange:c=>{var u,f,g;return n(((u=e==null?void 0:e.formatNumber)==null?void 0:u.format)||"",((f=e==null?void 0:e.formatNumber)==null?void 0:f.currency)||"",((g=e==null?void 0:e.formatNumber)==null?void 0:g.locale)||"",c.target.value)}})]})]})]})}function moe(){return b.jsxs("div",{className:"px-6 py-2 space-y-6",children:[b.jsx(uc,{type:"single",collapsible:!0,children:b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:"",children:"KPI Query"}),b.jsxs(On,{className:"font-mono ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono text-xs",children:"SELECT current, previous FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 text-xs",children:[b.jsx("li",{children:"current - number"}),b.jsx("li",{children:"previous - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:e=>e.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),b.jsx("section",{className:"",children:b.jsx(goe,{})}),b.jsx("div",{}),b.jsx("div",{})]})}function voe({cardType:e}){return b.jsx("div",{className:"px-6 py-2 space-y-6",children:b.jsxs(uc,{defaultValue:["item-2"],type:"multiple",children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{children:`${Em(e)} Chart`}),b.jsxs(On,{className:" space-y-4 font-mono text-xs ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:"SELECT label, measure FROM table"}),b.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[b.jsx("li",{children:"label - category"}),b.jsx("li",{children:"measure - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{children:"Settings"}),b.jsx(On,{className:"px-2",children:b.jsx(Td,{})})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{children:"Filter on click"}),b.jsx(On,{className:"px-2",children:b.jsx(Ad,{})})]})]})})}function boe(){return b.jsx("div",{className:"px-6 py-2 space-y-6",children:b.jsxs(uc,{defaultValue:["item-2"],type:"multiple",children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{children:"Stacked Chart"}),b.jsxs(On,{className:" space-y-4 font-mono text-xs ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),b.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[b.jsx("li",{children:"x-axis - category"}),b.jsx("li",{children:"stack by - category"}),b.jsx("li",{children:"y-axis - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:e=>e.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{children:"Settings"}),b.jsxs(On,{className:"px-2 space-y-4",children:[b.jsx(l1,{}),b.jsx(sA,{}),b.jsx(Td,{})]})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{children:"Filter on click"}),b.jsx(On,{className:"px-2",children:b.jsx(Ad,{})})]})]})})}function yoe(){const e=pe(n=>n.card.type);function t(n){switch(n){case"stackedBar":return b.jsx(boe,{});case"kpi":return b.jsx(moe,{});case"line":case"bar":return b.jsx(coe,{cardType:n});case"pie":case"doughnut":case"polarArea":case"radar":return b.jsx(voe,{cardType:n});case"bubble":case"scatter":return b.jsx(uoe,{cardType:n});case"table":return b.jsx(b.Fragment,{});default:return b.jsx(hoe,{})}}return b.jsx(Rl,{className:" text-sm h-full w-full ",children:t(e)})}function xoe(){const e=pe(t=>t.isShowingVisual);return b.jsxs(px,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[b.jsx(rc,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:b.jsx(eie,{})}),b.jsx(gx,{withHandle:!0,className:"border "}),b.jsx(rc,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:e?b.jsxs(px,{direction:"horizontal",children:[b.jsx(b.Fragment,{children:b.jsx(rc,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:b.jsx(yoe,{})})}),b.jsx(gx,{className:"border "}),b.jsx(rc,{minSize:40,defaultSize:75,maxSize:100,children:b.jsx(jT,{})})]}):b.jsx(jT,{})})]})}function woe({authToken:e,onSave:t,onClose:n}){pe(s=>s.actions.setCard);const r=pe(s=>s.actions.setOnSave),i=pe(s=>s.actions.setOnClose),o=he(s=>s.actions.setAuthToken);return m.useEffect(()=>{t&&r(t),n&&i(n)},[t,r,n,i]),m.useEffect(()=>{e&&e.accessToken&&o(e)},[e,o]),b.jsxs(DM,{className:"rounded-none",role:"editor-panel",children:[b.jsx(TM,{className:" rounded-none border-r-[1.5px] ",children:b.jsx(tD,{})}),b.jsx(AM,{children:b.jsx(xoe,{})})]})}function _oe(){he(s=>s.selectedCardId);const e=he(s=>s.selectedSheetId),{setIsVisualEditing:t}=he(s=>s.actions),n=he(s=>s.isVisualEditing),r=he(s=>s.actions.updateFrame);function i(s){e&&(r(e,s),t(!1))}function o(){t(!1)}return b.jsx("div",{role:"editor-container",className:Ee("grow flex",{block:n,hidden:!n}),children:b.jsx(woe,{onSave:i,onClose:o})})}function Soe({columns:e,tableName:t}){const n=pe(f=>f.selectedConnectionId),r=pe(f=>f.selectedDatabaseName),i=pe(f=>f.selectedSchemaName),o=pe(f=>f.selectedTableName),s=he(f=>f.dashboard.filters)||[],a=he(f=>f.actions.addFilter),l=he(f=>f.actions.removeFilter),c=he(f=>f.actions.removeFilterValue);function u(f){const g=ki(f.column_name),p=ki(r||""),v=ki(i||""),y=ki(t),w=s==null?void 0:s.find(_=>_.column===g&&_.table===y&&_.database===p);if(w)c(w.id),l(w.id);else{const _=Op(v,y),S=`SELECT ${g}, COUNT(*) FROM ${_} GROUP BY ${g} ORDER BY ${g} ASC LIMIT 50`,C=`SELECT min(${g}) as min, max(${g}) as max FROM ${_}`;if(t==="api"&&n){a({id:Qo(),column:`${_}.${g}`,title:f.column_name,dataType:f.data_type,table:"api",database:"NA",connectionId:n,sql:Sa.includes(f.data_type)?C:S});return}if(!n||!r||!o)throw new Error("missing connectionId, database, or table");a({id:Qo(),column:`${_}.${g}`,title:f.column_name,dataType:f.data_type,table:o,database:r,connectionId:n,sql:Sa.includes(f.data_type)?C:S})}}return b.jsx("div",{className:" flex-1 basis-0 overflow-scroll flex-col xbg-red-100 px-3",children:e==null?void 0:e.map(f=>{const g=s==null?void 0:s.find(p=>p.column===ki(f.column_name)&&p.table===o&&p.database===r);return b.jsx("div",{onClick:()=>u(f),className:Ee(" group flex text-sm items-center justify-between px-3 py-[6px] transition-colors hover:bg-muted/50 cursor-pointer border border-background border-dashed",{"bg-muted ":g}),children:b.jsxs("div",{className:"flex items-center gap-2 ",children:[b.jsx(eD,{column:f}),b.jsx("span",{children:f.column_name})]})},f.column_name)})})}function Coe(){he(t=>t.showFilters);const e=he(t=>t.actions.setShowFilters);return b.jsxs("section",{className:" grow flex flex-col border-l relative px-4 ",children:[b.jsxs("div",{className:"flex justify-between items-center gap-2 mt-4 px-3",children:[b.jsx(Fn,{className:"text-lg",children:"Filters"}),b.jsx(Je,{onClick:()=>e(!1),className:" p-0 h-7 w-7 ",variant:"ghost",children:b.jsx(pa,{})})]}),b.jsx("div",{className:"grow flex",children:b.jsx(tD,{ColumnsComponent:(t,n,r)=>b.jsx(Soe,{schemaName:t,tableName:n,columns:r})})})]})}function Eoe(){he(n=>n.dashboard);const e=he(n=>n.showFilters),t=he(n=>n.isVisualEditing);return he(n=>n.bookmarkKey),b.jsxs("div",{role:"dashboard-plus-main",className:Ee(" grow",{hidden:t,flex:!t}),children:[b.jsx(zk,{}),e&&b.jsx("div",{role:"filter-aside-container",className:" flex",children:b.jsx(Coe,{})})]})}function Ooe(){const e=he(r=>r.dashboard),t=he(r=>r.actions.setDashboard),n=he(r=>r.showDashboardJSON);return he(r=>r.actions.setShowDashboardJSON),b.jsx("div",{className:Ee(" p-2",{hidden:!n}),children:b.jsx(BD,{onChange:r=>{if(r)try{JSON.parse(r),t(JSON.parse(r))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(e,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function Poe({showControls:e=!1,showFooter:t=!0,...n}){return he(r=>r.isVisualEditing),b.jsx(A_,{dashboardProps:n,children:b.jsxs(By,{children:[b.jsx(Ooe,{}),b.jsxs($_,{...n,children:[e&&b.jsx(cQ,{}),b.jsx(_oe,{}),b.jsx(Eoe,{})]})]})})}function koe({card:e,footer:t,className:n,...r}){const{customCards:i}=zi(),o=m.useRef(null),{isError:s,isLoading:a,isFetching:l,cfg:c,visualKey:u,handleDatapointClick:f}=j0(e),g=he(I=>I.themeStyle),p=he(I=>I.selectedSheetId),v=he(I=>I.selectedCardId),y=he(I=>I.isDashboardEditing),{setCardTitle:w,setCardDescription:_,setSelectedCardId:S}=pl();function C(I){I.stopPropagation(),S(p,e.id)}function P(){if(i&&i.length>0){const I=i.find(F=>F.cardId===e.id);if(I&&I.replaceDefault){const F=I.content;if(F)return b.jsx(F,{card:e})}}return e.type==="kpi"?e.data&&e.data.length>0&&b.jsx(L0,{isLoading:a||l,card:e}):T}function O(){if(s)return b.jsx("p",{className:"text-sm",children:"Oops! It seems like something went wrong. Please review your connection or filters."});if(e.type==="table"&&e.data&&e.data.length>0)return b.jsxs(Rl,{children:[b.jsx(sp,{data:e.data}),b.jsx(Ll,{orientation:"horizontal"})]});if(i&&i.length>0){const I=i.find(F=>F.cardId===e.id);if(I&&I.content){const F=I.content;return b.jsx(F,{card:e})}}if(c)return b.jsx(Xb,{cfg:c,onDatapointClick:f},u)}function k(){if(i&&i.length>0){const I=i.find(F=>F.cardId===e.id);if(I&&I.footer){const F=I.footer;if(F)return b.jsx(F,{card:e})}}return t||null}if(!e.id)return null;const T=b.jsxs(b.Fragment,{children:[b.jsxs(su,{className:"pb-4",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx(Ui,{text:e.title,onSave:I=>w(p,e.id,I),children:b.jsx(au,{className:"text-base",children:e.title})}),e.refreshInterval&&b.jsxs(ep,{children:[b.jsx(h0,{className:"pr-1",children:b.jsx("div",{className:Ee("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":a||l})})}),b.jsx(Uu,{side:"right",align:"center",children:b.jsx("p",{className:"text-xs",children:`Realtime (${e==null?void 0:e.refreshInterval})`})})]}),!e.refreshInterval&&(a||l)&&b.jsx(ma,{className:"h-4 w-4 animate-spin text-muted-foreground"})]}),b.jsx(Ui,{text:(e==null?void 0:e.description)||"",onSave:I=>_(p,e.id,I),children:b.jsxs(rh,{children:[" ",e.description]})})]}),b.jsx(lu,{className:"relative flex grow flex-col overflow-auto pb-0",children:O()}),b.jsx(rb,{children:k()})]});return b.jsx(nh,{tabIndex:-1,ref:o,role:"dashboard-card",onClick:C,className:Ee("relative flex h-full flex-col rounded-sm",{"border-dashed border-foreground/50":v===e.id&&y},g==null?void 0:g.dashboardCard,n),...r,children:P()})}const Dg=`import pandas as pd
575
575
  df = pd.DataFrame(data) # 'data' contains the query result
576
576
  result = df.to_dict('records') # must return 'result' as [dict] type
577
577
  `;function Moe(){const e=he(t=>t.actions);return{getStyle:e.getStyle,getDashboard:e.getDashboard,setOnSaveFunction:e.setOnSaveFunction,setOnAddCard:e.setOnAddCard,setOnUpateCard:e.setOnUpdateCard,setOnRemoveCard:e.setOnRemoveCard}}Fe.BOOLEAN_DATA_TYPES=Cp,Fe.DATE_DATA_TYPES=Sa,Fe.Dashboard=Vk,Fe.DashboardCard=koe,Fe.DashboardPlus=Poe,Fe.DashboardProvider=By,Fe.DashboardWC=aK,Fe.NUMBER_DATA_TYPES=vs,Fe.PYTHON_DEFAULT_CODE=Dg,Fe.SelectComponent=gd,Fe.SemaphorQueryClient=Bk,Fe.TEXT_DATA_TYPES=Xu,Fe.cleanCard=mM,Fe.createSqlGenConfig=ly,Fe.fmt=ki,Fe.getBookmarkKey=ws,Fe.getColumnDataType=eU,Fe.getDashbaordStateWithoutData=Jy,Fe.getFilterValueType=Ep,Fe.getQualifiedTableName=Op,Fe.getSql=ay,Fe.isColumnInSqlGen=NP,Fe.resolveDataType=Mf,Fe.useActions=Moe,Fe.useCard=aH,Fe.useDashboard=j_,Fe.useDashboardActions=pl,Fe.useDashboardStore=he,Fe.useEditorActions=R4,Fe.useEditorAside=I_,Fe.useEditorStore=pe,Object.defineProperty(Fe,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.0.121",
8
+ "version": "0.0.123",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",