react-semaphor 0.0.121 → 0.0.122
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react-semaphor.js
CHANGED
|
@@ -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: "
|
|
50628
|
-
/* @__PURE__ */ v.jsx(fm, { children: "
|
|
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",
|
|
@@ -567,7 +567,7 @@ 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
|
|