semaphor 0.0.13 → 0.0.15

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.
@@ -39403,7 +39403,7 @@ function qre() {
39403
39403
  "div",
39404
39404
  {
39405
39405
  className: `flex items-center justify-between gap-2 border-b-[3px]
39406
- border-b-muted py-2 `,
39406
+ border-b-muted py-2 px-4 `,
39407
39407
  role: "dashboard-controls",
39408
39408
  children: [
39409
39409
  /* @__PURE__ */ w.jsxs("div", { className: "flex gap-3 items-center", children: [
@@ -51371,7 +51371,17 @@ function hfe() {
51371
51371
  function o() {
51372
51372
  t(!1);
51373
51373
  }
51374
- return /* @__PURE__ */ w.jsx("div", { className: `grow flex ${n ? "block" : "hidden"}`, children: /* @__PURE__ */ w.jsx(ffe, { onSave: i, onClose: o }) });
51374
+ return /* @__PURE__ */ w.jsx(
51375
+ "div",
51376
+ {
51377
+ role: "editor-container",
51378
+ className: Me("grow flex", {
51379
+ block: n,
51380
+ hidden: !n
51381
+ }),
51382
+ children: /* @__PURE__ */ w.jsx(ffe, { onSave: i, onClose: o })
51383
+ }
51384
+ );
51375
51385
  }
51376
51386
  function pfe({
51377
51387
  columns: e,
@@ -51479,14 +51489,16 @@ function mfe() {
51479
51489
  "div",
51480
51490
  {
51481
51491
  role: "dashboard-plus-main",
51482
- className: ` flex grow ${t ? "hidden" : "block"}`,
51492
+ className: Me(" grow", {
51493
+ hidden: t,
51494
+ flex: !t
51495
+ }),
51483
51496
  children: [
51484
51497
  /* @__PURE__ */ w.jsx(oM, {}),
51485
51498
  e && /* @__PURE__ */ w.jsx(
51486
51499
  "div",
51487
51500
  {
51488
51501
  role: "filter-aside-container",
51489
- className: "",
51490
51502
  children: /* @__PURE__ */ w.jsx(gfe, {})
51491
51503
  }
51492
51504
  )
@@ -425,7 +425,7 @@ Check the top-level render call using <`+ae+">.")}return Y}}function ja(M,Y){{if
425
425
  .block-interactivity-`.concat(e,` {pointer-events: none;}
426
426
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
427
427
  `)},vG=0,Ll=[];function bG(e){var t=ue.useRef([]),n=ue.useRef([0,0]),r=ue.useRef(),i=ue.useState(vG++)[0],o=ue.useState(function(){return $P()})[0],s=ue.useRef(e);ue.useEffect(function(){s.current=e},[e]),ue.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var y=zU([e.lockRef.current],(e.shards||[]).map(HP),!0).filter(Boolean);return y.forEach(function(x){return x.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),y.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=ue.useCallback(function(y,x){if("touches"in y&&y.touches.length===2)return!s.current.allowPinchZoom;var w=fp(y),S=n.current,C="deltaX"in y?y.deltaX:S[0]-w[0],P="deltaY"in y?y.deltaY:S[1]-w[1],O,k=y.target,A=Math.abs(C)>Math.abs(P)?"h":"v";if("touches"in y&&A==="h"&&k.type==="range")return!1;var L=jP(A,k);if(!L)return!0;if(L?O=A:(O=A==="v"?"h":"v",L=jP(A,k)),!L)return!1;if(!r.current&&"changedTouches"in y&&(C||P)&&(r.current=O),!O)return!0;var F=r.current||O;return pG(F,x,y,F==="h"?C:P,!0)},[]),l=ue.useCallback(function(y){var x=y;if(!(!Ll.length||Ll[Ll.length-1]!==o)){var w="deltaY"in x?VP(x):fp(x),S=t.current.filter(function(O){return O.name===x.type&&O.target===x.target&&gG(O.delta,w)})[0];if(S&&S.should){x.cancelable&&x.preventDefault();return}if(!S){var C=(s.current.shards||[]).map(HP).filter(Boolean).filter(function(O){return O.contains(x.target)}),P=C.length>0?a(x,C[0]):!s.current.noIsolation;P&&x.cancelable&&x.preventDefault()}}},[]),c=ue.useCallback(function(y,x,w,S){var C={name:y,delta:x,target:w,should:S};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(P){return P!==C})},1)},[]),d=ue.useCallback(function(y){n.current=fp(y),r.current=void 0},[]),f=ue.useCallback(function(y){c(y.type,VP(y),y.target,a(y,e.lockRef.current))},[]),p=ue.useCallback(function(y){c(y.type,fp(y),y.target,a(y,e.lockRef.current))},[]);ue.useEffect(function(){return Ll.push(o),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",l,Rl),document.addEventListener("touchmove",l,Rl),document.addEventListener("touchstart",d,Rl),function(){Ll=Ll.filter(function(y){return y!==o}),document.removeEventListener("wheel",l,Rl),document.removeEventListener("touchmove",l,Rl),document.removeEventListener("touchstart",d,Rl)}},[]);var g=e.removeScrollBar,v=e.inert;return ue.createElement(ue.Fragment,null,v?ue.createElement(o,{styles:mG(i)}):null,g?ue.createElement(aG,{gapMode:"margin"}):null)}const yG=KU(RP,bG);var WP=ue.forwardRef(function(e,t){return ue.createElement(up,Wi({},e,{ref:t,sideCar:yG}))});WP.classNames=up.classNames;const hp=WP,qP="Popover",[UP,tfe]=Pn(qP,[Fi]),sy=Fi(),[xG,$l]=UP(qP),wG=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:s=!1}=e,a=sy(t),l=m.useRef(null),[c,d]=m.useState(!1),[f=!1,p]=Qn({prop:r,defaultProp:i,onChange:o});return m.createElement(Cu,a,m.createElement(xG,{scope:t,contentId:or(),triggerRef:l,open:f,onOpenChange:p,onOpenToggle:m.useCallback(()=>p(g=>!g),[p]),hasCustomAnchor:c,onCustomAnchorAdd:m.useCallback(()=>d(!0),[]),onCustomAnchorRemove:m.useCallback(()=>d(!1),[]),modal:s},n))},_G="PopoverTrigger",SG=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=$l(_G,n),o=sy(n),s=et(t,i.triggerRef),a=m.createElement(Be.button,le({type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":KP(i.open)},r,{ref:s,onClick:Ce(e.onClick,i.onOpenToggle)}));return i.hasCustomAnchor?a:m.createElement(Eu,le({asChild:!0},o),a)}),GP="PopoverPortal",[CG,EG]=UP(GP,{forceMount:void 0}),OG=e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,o=$l(GP,t);return m.createElement(CG,{scope:t,forceMount:n},m.createElement(vn,{present:n||o.open},m.createElement(Dh,{asChild:!0,container:i},r)))},Hu="PopoverContent",PG=m.forwardRef((e,t)=>{const n=EG(Hu,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,o=$l(Hu,e.__scopePopover);return m.createElement(vn,{present:r||o.open},o.modal?m.createElement(kG,le({},i,{ref:t})):m.createElement(MG,le({},i,{ref:t})))}),kG=m.forwardRef((e,t)=>{const n=$l(Hu,e.__scopePopover),r=m.useRef(null),i=et(t,r),o=m.useRef(!1);return m.useEffect(()=>{const s=r.current;if(s)return ap(s)},[]),m.createElement(hp,{as:no,allowPinchZoom:!0},m.createElement(YP,le({},e,{ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ce(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),o.current||(a=n.triggerRef.current)===null||a===void 0||a.focus()}),onPointerDownOutside:Ce(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;o.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:Ce(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})))}),MG=m.forwardRef((e,t)=>{const n=$l(Hu,e.__scopePopover),r=m.useRef(!1),i=m.useRef(!1);return m.createElement(YP,le({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var s;if((s=e.onCloseAutoFocus)===null||s===void 0||s.call(e,o),!o.defaultPrevented){var a;r.current||(a=n.triggerRef.current)===null||a===void 0||a.focus(),o.preventDefault()}r.current=!1,i.current=!1},onInteractOutside:o=>{var s,a;(s=e.onInteractOutside)===null||s===void 0||s.call(e,o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const l=o.target;((a=n.triggerRef.current)===null||a===void 0?void 0:a.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}}))}),YP=m.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:d,...f}=e,p=$l(Hu,n),g=sy(n);return rp(),m.createElement(ip,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o},m.createElement(_l,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:d,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>p.onOpenChange(!1)},m.createElement(Ou,le({"data-state":KP(p.open),role:"dialog",id:p.contentId},g,f,{ref:t,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}}))))});function KP(e){return e?"open":"closed"}const DG=wG,TG=SG,AG=OG,XP=PG,pp=DG,gp=TG,Wu=ue.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},i)=>_.jsx(AG,{children:_.jsx(XP,{ref:i,align:t,sideOffset:n,className:Pe("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})}));Wu.displayName=XP.displayName;function IG({filter:e,className:t}){const[n,r]=m.useState(!1),[i,o]=m.useState(),[s,a]=m.useState(),l=ge(C=>C.filterValues),c=ge(C=>C.authToken),d=ge(C=>C.actions.addOrUpdateFilterValue),f=ge(C=>C.actions.removeFilterValue),{data:p,isLoading:g,isFetching:v,isError:y,refetch:x}=Sr({queryKey:[e.sql],queryFn:()=>Is("https://semaphor.cloud/api/v1/query",(c==null?void 0:c.accessToken)||"",{connection_id:e.connectionId,sql:e.sql}),enabled:!!e.sql&&!!e.connectionId&&!!e.database});m.useEffect(()=>{var C;if(((C=p==null?void 0:p.records)==null?void 0:C.length)>0){const P=p.records[0];if(!P.min||!P.max)return;o({from:new Date(P.min),to:new Date(P.max)}),a({from:new Date(P.min),to:new Date(P.max)})}},[p]),m.useEffect(()=>{if(l&&!l.find(P=>P.filterId===e.id)){o(s);return}},[l,e.id,s]);function w(){f(e.id),o(s),r(!1)}function S(){if(!i)return;console.log(i);const C=[i==null?void 0:i.from,i==null?void 0:i.to];console.log(C);const P={filterId:e.id,connectionType:e.database==="NA"?"api":"database",valueType:k0(e),name:e.column,operation:"between",values:C};d(P),r(!1)}return g?_.jsx("div",{children:_.jsx(lf,{className:" bg-foreground/10 h-8 w-[250px]"})}):y?_.jsx("div",{className:"bg-muted h-8 w-[250px] px-2",children:"Error"}):p?_.jsx("div",{className:Pe("grid gap-2",t),children:_.jsxs(pp,{open:n,onOpenChange:r,children:[_.jsx(gp,{asChild:!0,children:_.jsxs(it,{size:"sm",id:"date",variant:"outline",className:Pe("w-[250px] justify-start text-left font-normal rounded-sm h-[34px]",!i&&"text-muted-foreground"),children:[_.jsx(qB,{className:"mr-2 h-4 w-4"}),i!=null&&i.from?i.to?_.jsxs(_.Fragment,{children:[Hi(i.from,"LLL dd, y")," -"," ",Hi(i.to,"LLL dd, y")]}):Hi(i.from,"LLL dd, y"):_.jsx("span",{children:"Pick a date"})]})}),_.jsxs(Wu,{className:"w-auto p-0",align:"start",children:[_.jsx(EP,{initialFocus:!0,mode:"range",defaultMonth:i==null?void 0:i.from,selected:i,onSelect:o,numberOfMonths:2}),_.jsxs("div",{className:"flex justify-end px-4 py-3 gap-2",children:[_.jsx(it,{size:"sm",variant:"outline",onClick:S,children:"Apply"}),_.jsx(it,{size:"sm",variant:"outline",onClick:w,children:"Clear"})]})]})]})}):null}function NG(){const e=ge(s=>s.dashboard.filters),t=ge(s=>s.isDashboardEditing),n=ge(s=>s.actions.removeFilter),r=ge(s=>s.actions.updateFilter),i=ge(s=>s.actions.removeFilterValue);if(!e)return null;const o=s=>Iu.includes(s.dataType)?_.jsx(IG,{filter:s}):_.jsx(HW,{filter:s});return _.jsx("section",{role:"dashboard-filters",className:" px-[10px] pt-0 grow w-full items-center flex gap-2 flex-wrap ",children:e.map(s=>_.jsxs("div",{children:[_.jsx(qc,{className:" my-1 ",text:s.title||s.column,onSave:a=>r({...s,title:a}),children:_.jsxs("div",{className:"flex items-center justify-between group mb-1",children:[_.jsxs("div",{className:"flex gap-1 items-center ",children:[_.jsx(ns,{className:" inline-block text-sm ",children:s.title}),t&&_.jsx(ia,{onClick:()=>{i(s.id),n(s.id)},className:"w-3 h-3 invisible text-muted-foreground group-hover:visible hover:text-foreground cursor-pointer"})]}),_.jsx("div",{onClick:()=>i(s.id),className:" text-xs invisible group-hover:visible group-hover:underline cursor-pointer text-muted-foreground hover:text-foreground",children:"Clear"})]})}),o(s)]},s.id))})}function QP(){const e=ge(i=>{var o;return(o=i.dashboard)==null?void 0:o.sheets});ge(i=>i.isDashboardEditing);const t=ge(i=>i.themeStyle);ge(i=>i.isVisualEditing);const n=ge(i=>i.selectedSheetId),r=ge(i=>i.actions.setSelectedSheetId);return ge(i=>i.actions.setSheetTitle),e?_.jsxs(a_,{role:"dashboard-tabs-container",className:Pe(" grow bg-muted dark:bg-foreground/5 p-2 ",t==null?void 0:t.dashboardTabsContainer),onValueChange:i=>{r(i)},value:n||e[0].id,children:[_.jsx(NG,{}),e==null?void 0:e.map(i=>_.jsx(ff,{className:"mt-0",value:i.id,children:_.jsx(uH,{})},i.id))]}):null}function ZP({children:e}){const t=new MN;return _.jsx(KN,{defaultTheme:"dark",storageKey:"vite-ui-theme",children:_.jsx($B,{delayDuration:0,children:_.jsx(NN,{client:t,children:e})})})}function JP(e){return _.jsx(ZP,{children:_.jsx(Kw,{...e,children:_.jsx(QP,{})})})}var RG=Object.defineProperty,LG=(e,t,n)=>t in e?RG(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mp=(e,t,n)=>(LG(e,typeof t!="symbol"?t+"":t,n),n);const $G={stringify:e=>e,parse:e=>e},FG={stringify:e=>`${e}`,parse:e=>parseFloat(e)},jG={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},zG={stringify:e=>e.name,parse:(e,t)=>{const n=(()=>{if(typeof window<"u"&&e in window)return window[e];if(typeof global<"u"&&e in global)return global[e]})();return typeof n=="function"?n.bind(t):void 0}},BG={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)},ay={string:$G,number:FG,boolean:jG,function:zG,json:BG},ly=Symbol.for("r2wc.render"),vp=Symbol.for("r2wc.connected"),ma=Symbol.for("r2wc.context"),os=Symbol.for("r2wc.props");function VG(e,t,n){var r,i,o;t.props||(t.props=e.propTypes?Object.keys(e.propTypes):[]);const s=(Array.isArray(t.props)?t.props.slice():Object.keys(t.props)).filter(f=>f!=="container"),a={},l={},c={};for(const f of s){a[f]=Array.isArray(t.props)?"string":t.props[f];const p=HG(f);l[f]=p,c[p]=f}class d extends HTMLElement{constructor(){super(),mp(this,r,!0),mp(this,i),mp(this,o,{}),mp(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[os].container=this.container;for(const p of s){const g=l[p],v=this.getAttribute(g),y=a[p],x=ay[y];v&&x!=null&&x.parse&&(this[os][p]=x.parse(v,this))}}static get observedAttributes(){return Object.keys(c)}connectedCallback(){this[vp]=!0,this[ly]()}disconnectedCallback(){this[vp]=!1,this[ma]&&n.unmount(this[ma]),delete this[ma]}attributeChangedCallback(p,g,v){const y=c[p],x=a[y],w=ay[x];y in a&&w!=null&&w.parse&&(this[os][y]=w.parse(v,this),this[ly]())}[(r=vp,i=ma,o=os,ly)](){this[vp]&&(this[ma]?n.update(this[ma],this[os]):this[ma]=n.mount(this.container,e,this[os]))}}for(const f of s){const p=l[f],g=a[f];Object.defineProperty(d.prototype,f,{enumerable:!0,configurable:!0,get(){return this[os][f]},set(v){this[os][f]=v;const y=ay[g];if(y!=null&&y.stringify){const x=y.stringify(v);this.getAttribute(p)!==x&&this.setAttribute(p,x)}}})}return d}function HG(e=""){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function WG(e,t,n){const r=tf(e),i=m.createElement(t,n);return r.render(i),{root:r,ReactComponent:t}}function qG({root:e,ReactComponent:t},n){const r=m.createElement(t,n);e.render(r)}function UG({root:e}){e.unmount()}function GG(e,t={}){return VG(e,t,{mount:WG,update:qG,unmount:UG})}const YG=GG(JP,{props:{id:"string",authToken:"json",currentTheme:"string",style:"json",onEvent:"function",onSave:"function",LoadingComponent:"function",ErrorComponent:"function"}}),cy=["Enter"," "],KG=["ArrowDown","PageUp","Home"],ek=["ArrowUp","PageDown","End"],XG=[...KG,...ek],QG={ltr:[...cy,"ArrowRight"],rtl:[...cy,"ArrowLeft"]},ZG={ltr:["ArrowLeft"],rtl:["ArrowRight"]},bp="Menu",[qu,JG,eY]=uf(bp),[va,tk]=Pn(bp,[eY,Fi,ol]),uy=Fi(),nk=ol(),[tY,ba]=va(bp),[nY,Uu]=va(bp),rY=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:o,modal:s=!0}=e,a=uy(t),[l,c]=m.useState(null),d=m.useRef(!1),f=xn(o),p=Fs(i);return m.useEffect(()=>{const g=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),m.createElement(Cu,a,m.createElement(tY,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c},m.createElement(nY,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:p,modal:s},r)))},rk=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=uy(n);return m.createElement(Eu,le({},i,r,{ref:t}))}),ik="MenuPortal",[iY,ok]=va(ik,{forceMount:void 0}),oY=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,o=ba(ik,t);return m.createElement(iY,{scope:t,forceMount:n},m.createElement(vn,{present:n||o.open},m.createElement(Dh,{asChild:!0,container:i},r)))},wi="MenuContent",[sY,dy]=va(wi),aY=m.forwardRef((e,t)=>{const n=ok(wi,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=ba(wi,e.__scopeMenu),s=Uu(wi,e.__scopeMenu);return m.createElement(qu.Provider,{scope:e.__scopeMenu},m.createElement(vn,{present:r||o.open},m.createElement(qu.Slot,{scope:e.__scopeMenu},s.modal?m.createElement(lY,le({},i,{ref:t})):m.createElement(cY,le({},i,{ref:t})))))}),lY=m.forwardRef((e,t)=>{const n=ba(wi,e.__scopeMenu),r=m.useRef(null),i=et(t,r);return m.useEffect(()=>{const o=r.current;if(o)return ap(o)},[]),m.createElement(fy,le({},e,{ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ce(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)}))}),cY=m.forwardRef((e,t)=>{const n=ba(wi,e.__scopeMenu);return m.createElement(fy,le({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)}))}),fy=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:g,disableOutsideScroll:v,...y}=e,x=ba(wi,n),w=Uu(wi,n),S=uy(n),C=nk(n),P=JG(n),[O,k]=m.useState(null),A=m.useRef(null),L=et(t,A,x.onContentChange),F=m.useRef(0),z=m.useRef(""),B=m.useRef(0),V=m.useRef(null),X=m.useRef("right"),K=m.useRef(0),$=v?hp:m.Fragment,J=v?{as:no,allowPinchZoom:!0}:void 0,G=se=>{var D,W;const re=z.current+se,N=P().filter(ee=>!ee.disabled),ne=document.activeElement,me=(D=N.find(ee=>ee.ref.current===ne))===null||D===void 0?void 0:D.textValue,he=N.map(ee=>ee.textValue),de=kY(he,re,me),ie=(W=N.find(ee=>ee.textValue===de))===null||W===void 0?void 0:W.ref.current;(function ee(H){z.current=H,window.clearTimeout(F.current),H!==""&&(F.current=window.setTimeout(()=>ee(""),1e3))})(re),ie&&setTimeout(()=>ie.focus())};m.useEffect(()=>()=>window.clearTimeout(F.current),[]),rp();const q=m.useCallback(se=>{var D,W;return X.current===((D=V.current)===null||D===void 0?void 0:D.side)&&DY(se,(W=V.current)===null||W===void 0?void 0:W.area)},[]);return m.createElement(sY,{scope:n,searchRef:z,onItemEnter:m.useCallback(se=>{q(se)&&se.preventDefault()},[q]),onItemLeave:m.useCallback(se=>{var D;q(se)||((D=A.current)===null||D===void 0||D.focus(),k(null))},[q]),onTriggerLeave:m.useCallback(se=>{q(se)&&se.preventDefault()},[q]),pointerGraceTimerRef:B,onPointerGraceIntentChange:m.useCallback(se=>{V.current=se},[])},m.createElement($,J,m.createElement(ip,{asChild:!0,trapped:i,onMountAutoFocus:Ce(o,se=>{var D;se.preventDefault(),(D=A.current)===null||D===void 0||D.focus()}),onUnmountAutoFocus:s},m.createElement(_l,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:g},m.createElement(Dm,le({asChild:!0},C,{dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:O,onCurrentTabStopIdChange:k,onEntryFocus:Ce(l,se=>{w.isUsingKeyboardRef.current||se.preventDefault()})}),m.createElement(Ou,le({role:"menu","aria-orientation":"vertical","data-state":dk(x.open),"data-radix-menu-content":"",dir:w.dir},S,y,{ref:L,style:{outline:"none",...y.style},onKeyDown:Ce(y.onKeyDown,se=>{const W=se.target.closest("[data-radix-menu-content]")===se.currentTarget,re=se.ctrlKey||se.altKey||se.metaKey,N=se.key.length===1;W&&(se.key==="Tab"&&se.preventDefault(),!re&&N&&G(se.key));const ne=A.current;if(se.target!==ne||!XG.includes(se.key))return;se.preventDefault();const he=P().filter(de=>!de.disabled).map(de=>de.ref.current);ek.includes(se.key)&&he.reverse(),OY(he)}),onBlur:Ce(e.onBlur,se=>{se.currentTarget.contains(se.target)||(window.clearTimeout(F.current),z.current="")}),onPointerMove:Ce(e.onPointerMove,Gu(se=>{const D=se.target,W=K.current!==se.clientX;if(se.currentTarget.contains(D)&&W){const re=se.clientX>K.current?"right":"left";X.current=re,K.current=se.clientX}}))})))))))}),uY=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.createElement(Be.div,le({role:"group"},r,{ref:t}))}),dY=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.createElement(Be.div,le({},r,{ref:t}))}),hy="MenuItem",sk="menu.itemSelect",py=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,o=m.useRef(null),s=Uu(hy,e.__scopeMenu),a=dy(hy,e.__scopeMenu),l=et(t,o),c=m.useRef(!1),d=()=>{const f=o.current;if(!n&&f){const p=new CustomEvent(sk,{bubbles:!0,cancelable:!0});f.addEventListener(sk,g=>r==null?void 0:r(g),{once:!0}),Qw(f,p),p.defaultPrevented?c.current=!1:s.onClose()}};return m.createElement(ak,le({},i,{ref:l,disabled:n,onClick:Ce(e.onClick,d),onPointerDown:f=>{var p;(p=e.onPointerDown)===null||p===void 0||p.call(e,f),c.current=!0},onPointerUp:Ce(e.onPointerUp,f=>{var p;c.current||(p=f.currentTarget)===null||p===void 0||p.click()}),onKeyDown:Ce(e.onKeyDown,f=>{const p=a.searchRef.current!=="";n||p&&f.key===" "||cy.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})}))}),ak=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...o}=e,s=dy(hy,n),a=nk(n),l=m.useRef(null),c=et(t,l),[d,f]=m.useState(!1),[p,g]=m.useState("");return m.useEffect(()=>{const v=l.current;if(v){var y;g(((y=v.textContent)!==null&&y!==void 0?y:"").trim())}},[o.children]),m.createElement(qu.ItemSlot,{scope:n,disabled:r,textValue:i??p},m.createElement(Tm,le({asChild:!0},a,{focusable:!r}),m.createElement(Be.div,le({role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0},o,{ref:c,onPointerMove:Ce(e.onPointerMove,Gu(v=>{r?s.onItemLeave(v):(s.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus())})),onPointerLeave:Ce(e.onPointerLeave,Gu(v=>s.onItemLeave(v))),onFocus:Ce(e.onFocus,()=>f(!0)),onBlur:Ce(e.onBlur,()=>f(!1))}))))}),fY=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return m.createElement(ck,{scope:e.__scopeMenu,checked:n},m.createElement(py,le({role:"menuitemcheckbox","aria-checked":xp(n)?"mixed":n},i,{ref:t,"data-state":gy(n),onSelect:Ce(i.onSelect,()=>r==null?void 0:r(xp(n)?!0:!n),{checkForDefaultPrevented:!1})})))}),hY="MenuRadioGroup",[pY,gY]=va(hY,{value:void 0,onValueChange:()=>{}}),mY=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,o=xn(r);return m.createElement(pY,{scope:e.__scopeMenu,value:n,onValueChange:o},m.createElement(uY,le({},i,{ref:t})))}),vY="MenuRadioItem",bY=m.forwardRef((e,t)=>{const{value:n,...r}=e,i=gY(vY,e.__scopeMenu),o=n===i.value;return m.createElement(ck,{scope:e.__scopeMenu,checked:o},m.createElement(py,le({role:"menuitemradio","aria-checked":o},r,{ref:t,"data-state":gy(o),onSelect:Ce(r.onSelect,()=>{var s;return(s=i.onValueChange)===null||s===void 0?void 0:s.call(i,n)},{checkForDefaultPrevented:!1})})))}),lk="MenuItemIndicator",[ck,yY]=va(lk,{checked:!1}),xY=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,o=yY(lk,n);return m.createElement(vn,{present:r||xp(o.checked)||o.checked===!0},m.createElement(Be.span,le({},i,{ref:t,"data-state":gy(o.checked)})))}),wY=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.createElement(Be.div,le({role:"separator","aria-orientation":"horizontal"},r,{ref:t}))}),_Y="MenuSub",[rfe,uk]=va(_Y),yp="MenuSubTrigger",SY=m.forwardRef((e,t)=>{const n=ba(yp,e.__scopeMenu),r=Uu(yp,e.__scopeMenu),i=uk(yp,e.__scopeMenu),o=dy(yp,e.__scopeMenu),s=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=o,c={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),m.createElement(rk,le({asChild:!0},c),m.createElement(ak,le({id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":dk(n.open)},e,{ref:cf(t,i.onTriggerChange),onClick:f=>{var p;(p=e.onClick)===null||p===void 0||p.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ce(e.onPointerMove,Gu(f=>{o.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!s.current&&(o.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:Ce(e.onPointerLeave,Gu(f=>{var p;d();const g=(p=n.content)===null||p===void 0?void 0:p.getBoundingClientRect();if(g){var v;const y=(v=n.content)===null||v===void 0?void 0:v.dataset.side,x=y==="right",w=x?-5:5,S=g[x?"left":"right"],C=g[x?"right":"left"];o.onPointerGraceIntentChange({area:[{x:f.clientX+w,y:f.clientY},{x:S,y:g.top},{x:C,y:g.top},{x:C,y:g.bottom},{x:S,y:g.bottom}],side:y}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(f),f.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Ce(e.onKeyDown,f=>{const p=o.searchRef.current!=="";if(!(e.disabled||p&&f.key===" ")&&QG[r.dir].includes(f.key)){var g;n.onOpenChange(!0),(g=n.content)===null||g===void 0||g.focus(),f.preventDefault()}})})))}),CY="MenuSubContent",EY=m.forwardRef((e,t)=>{const n=ok(wi,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=ba(wi,e.__scopeMenu),s=Uu(wi,e.__scopeMenu),a=uk(CY,e.__scopeMenu),l=m.useRef(null),c=et(t,l);return m.createElement(qu.Provider,{scope:e.__scopeMenu},m.createElement(vn,{present:r||o.open},m.createElement(qu.Slot,{scope:e.__scopeMenu},m.createElement(fy,le({id:a.contentId,"aria-labelledby":a.triggerId},i,{ref:c,align:"start",side:s.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;s.isUsingKeyboardRef.current&&((f=l.current)===null||f===void 0||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:Ce(e.onFocusOutside,d=>{d.target!==a.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Ce(e.onEscapeKeyDown,d=>{s.onClose(),d.preventDefault()}),onKeyDown:Ce(e.onKeyDown,d=>{const f=d.currentTarget.contains(d.target),p=ZG[s.dir].includes(d.key);if(f&&p){var g;o.onOpenChange(!1),(g=a.trigger)===null||g===void 0||g.focus(),d.preventDefault()}})})))))});function dk(e){return e?"open":"closed"}function xp(e){return e==="indeterminate"}function gy(e){return xp(e)?"indeterminate":e?"checked":"unchecked"}function OY(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function PY(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function kY(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let s=PY(e,Math.max(o,0));i.length===1&&(s=s.filter(c=>c!==n));const l=s.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function MY(e,t){const{x:n,y:r}=e;let i=!1;for(let o=0,s=t.length-1;o<t.length;s=o++){const a=t[o].x,l=t[o].y,c=t[s].x,d=t[s].y;l>r!=d>r&&n<(c-a)*(r-l)/(d-l)+a&&(i=!i)}return i}function DY(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return MY(n,t)}function Gu(e){return t=>t.pointerType==="mouse"?e(t):void 0}const TY=rY,AY=rk,IY=oY,NY=aY,RY=dY,LY=py,$Y=fY,FY=mY,jY=bY,zY=xY,BY=wY,VY=SY,HY=EY,fk="DropdownMenu",[WY,ife]=Pn(fk,[tk]),Nr=tk(),[qY,hk]=WY(fk),UY=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:o,onOpenChange:s,modal:a=!0}=e,l=Nr(t),c=m.useRef(null),[d=!1,f]=Qn({prop:i,defaultProp:o,onChange:s});return m.createElement(qY,{scope:t,triggerId:or(),triggerRef:c,contentId:or(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(p=>!p),[f]),modal:a},m.createElement(TY,le({},l,{open:d,onOpenChange:f,dir:r,modal:a}),n))},GY="DropdownMenuTrigger",YY=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,o=hk(GY,n),s=Nr(n);return m.createElement(AY,le({asChild:!0},s),m.createElement(Be.button,le({type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,disabled:r},i,{ref:cf(t,o.triggerRef),onPointerDown:Ce(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(o.onOpenToggle(),o.open||a.preventDefault())}),onKeyDown:Ce(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&o.onOpenToggle(),a.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})))}),KY=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Nr(t);return m.createElement(IY,le({},r,n))},XY="DropdownMenuContent",QY=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=hk(XY,n),o=Nr(n),s=m.useRef(!1);return m.createElement(NY,le({id:i.contentId,"aria-labelledby":i.triggerId},o,r,{ref:t,onCloseAutoFocus:Ce(e.onCloseAutoFocus,a=>{var l;s.current||(l=i.triggerRef.current)===null||l===void 0||l.focus(),s.current=!1,a.preventDefault()}),onInteractOutside:Ce(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!i.modal||d)&&(s.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))}),ZY=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement(RY,le({},i,r,{ref:t}))}),JY=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement(LY,le({},i,r,{ref:t}))}),eK=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement($Y,le({},i,r,{ref:t}))}),tK=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement(FY,le({},i,r,{ref:t}))}),nK=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement(jY,le({},i,r,{ref:t}))}),rK=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement(zY,le({},i,r,{ref:t}))}),iK=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement(BY,le({},i,r,{ref:t}))}),oK=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement(VY,le({},i,r,{ref:t}))}),sK=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement(HY,le({},i,r,{ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))}),aK=UY,lK=YY,cK=KY,pk=QY,gk=ZY,mk=JY,vk=eK,uK=tK,bk=nK,yk=rK,xk=iK,wk=oK,_k=sK,Sk=aK,Ck=lK,dK=uK,fK=ue.forwardRef(({className:e,inset:t,children:n,...r},i)=>_.jsxs(wk,{ref:i,className:Pe("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,_.jsx(V2,{className:"ml-auto h-4 w-4"})]}));fK.displayName=wk.displayName;const hK=ue.forwardRef(({className:e,...t},n)=>_.jsx(_k,{ref:n,className:Pe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));hK.displayName=_k.displayName;const my=ue.forwardRef(({className:e,sideOffset:t=4,...n},r)=>_.jsx(cK,{children:_.jsx(pk,{ref:r,sideOffset:t,className:Pe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));my.displayName=pk.displayName;const wp=ue.forwardRef(({className:e,inset:t,...n},r)=>_.jsx(mk,{ref:r,className:Pe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));wp.displayName=mk.displayName;const pK=ue.forwardRef(({className:e,children:t,checked:n,...r},i)=>_.jsxs(vk,{ref:i,className:Pe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[_.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:_.jsx(yk,{children:_.jsx(Rh,{className:"h-4 w-4"})})}),t]}));pK.displayName=vk.displayName;const vy=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsxs(bk,{ref:r,className:Pe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[_.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:_.jsx(yk,{children:_.jsx(H2,{className:"h-2 w-2 fill-current"})})}),t]}));vy.displayName=bk.displayName;const Ek=ue.forwardRef(({className:e,inset:t,...n},r)=>_.jsx(gk,{ref:r,className:Pe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Ek.displayName=gk.displayName;const Ok=ue.forwardRef(({className:e,...t},n)=>_.jsx(xk,{ref:n,className:Pe("-mx-1 my-1 h-px bg-muted",e),...t}));Ok.displayName=xk.displayName;function gK(){const{setTheme:e}=Em(),t=ge(n=>n.actions.setDashboardTheme);return _.jsxs(Sk,{children:[_.jsx(Ck,{asChild:!0,children:_.jsxs(it,{className:"h-7 p-2",variant:"outline",size:"sm",children:[_.jsx(rV,{strokeWidth:1.5,className:"h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),_.jsx(QB,{strokeWidth:1.5,className:"absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),_.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),_.jsxs(my,{align:"end",children:[_.jsx(wp,{onClick:()=>{e("light"),t("light")},children:"Light"}),_.jsx(wp,{onClick:()=>{e("dark"),t("dark")},children:"Dark"}),_.jsx(wp,{onClick:()=>{e("system"),t("system")},children:"System"})]})]})}function by(e){var t;return{...e,sheets:(t=e==null?void 0:e.sheets)==null?void 0:t.map(n=>{var r;return{...n,cards:(r=n==null?void 0:n.cards)==null?void 0:r.map(i=>Pk(i))}})}}function Pk(e){var t,n,r,i;return{...e,cfg:{...e.cfg,data:{...(t=e.cfg)==null?void 0:t.data,labels:[],datasets:(i=(r=(n=e.cfg)==null?void 0:n.data)==null?void 0:r.datasets)==null?void 0:i.map(o=>({...o,data:[]}))}},customCfg:mK(e.customCfg),data:[]}}function mK(e){var t,n;return e?{...e,data:{...e==null?void 0:e.data,labels:[],datasets:(n=(t=e==null?void 0:e.data)==null?void 0:t.datasets)==null?void 0:n.map(r=>({...r,data:[]}))}}:null}function ss(e){return`semaphor:bookmark:${e}`}const kk="Dialog",[Mk,ofe]=Pn(kk),[vK,_i]=Mk(kk),bK=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:s=!0}=e,a=m.useRef(null),l=m.useRef(null),[c=!1,d]=Qn({prop:r,defaultProp:i,onChange:o});return m.createElement(vK,{scope:t,triggerRef:a,contentRef:l,contentId:or(),titleId:or(),descriptionId:or(),open:c,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:s},n)},yK="DialogTrigger",xK=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=_i(yK,n),o=et(t,i.triggerRef);return m.createElement(Be.button,le({type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":xy(i.open)},r,{ref:o,onClick:Ce(e.onClick,i.onOpenToggle)}))}),Dk="DialogPortal",[wK,Tk]=Mk(Dk,{forceMount:void 0}),_K=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,o=_i(Dk,t);return m.createElement(wK,{scope:t,forceMount:n},m.Children.map(r,s=>m.createElement(vn,{present:n||o.open},m.createElement(Dh,{asChild:!0,container:i},s))))},yy="DialogOverlay",SK=m.forwardRef((e,t)=>{const n=Tk(yy,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=_i(yy,e.__scopeDialog);return o.modal?m.createElement(vn,{present:r||o.open},m.createElement(CK,le({},i,{ref:t}))):null}),CK=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=_i(yy,n);return m.createElement(hp,{as:no,allowPinchZoom:!0,shards:[i.contentRef]},m.createElement(Be.div,le({"data-state":xy(i.open)},r,{ref:t,style:{pointerEvents:"auto",...r.style}})))}),Yu="DialogContent",EK=m.forwardRef((e,t)=>{const n=Tk(Yu,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=_i(Yu,e.__scopeDialog);return m.createElement(vn,{present:r||o.open},o.modal?m.createElement(OK,le({},i,{ref:t})):m.createElement(PK,le({},i,{ref:t})))}),OK=m.forwardRef((e,t)=>{const n=_i(Yu,e.__scopeDialog),r=m.useRef(null),i=et(t,n.contentRef,r);return m.useEffect(()=>{const o=r.current;if(o)return ap(o)},[]),m.createElement(Ak,le({},e,{ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ce(e.onCloseAutoFocus,o=>{var s;o.preventDefault(),(s=n.triggerRef.current)===null||s===void 0||s.focus()}),onPointerDownOutside:Ce(e.onPointerDownOutside,o=>{const s=o.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&o.preventDefault()}),onFocusOutside:Ce(e.onFocusOutside,o=>o.preventDefault())}))}),PK=m.forwardRef((e,t)=>{const n=_i(Yu,e.__scopeDialog),r=m.useRef(!1),i=m.useRef(!1);return m.createElement(Ak,le({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var s;if((s=e.onCloseAutoFocus)===null||s===void 0||s.call(e,o),!o.defaultPrevented){var a;r.current||(a=n.triggerRef.current)===null||a===void 0||a.focus(),o.preventDefault()}r.current=!1,i.current=!1},onInteractOutside:o=>{var s,a;(s=e.onInteractOutside)===null||s===void 0||s.call(e,o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const l=o.target;((a=n.triggerRef.current)===null||a===void 0?void 0:a.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}}))}),Ak=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...s}=e,a=_i(Yu,n),l=m.useRef(null),c=et(t,l);return rp(),m.createElement(m.Fragment,null,m.createElement(ip,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o},m.createElement(_l,le({role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":xy(a.open)},s,{ref:c,onDismiss:()=>a.onOpenChange(!1)}))),!1)}),kK="DialogTitle",MK=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=_i(kK,n);return m.createElement(Be.h2,le({id:i.titleId},r,{ref:t}))}),DK="DialogDescription",TK=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=_i(DK,n);return m.createElement(Be.p,le({id:i.descriptionId},r,{ref:t}))}),AK="DialogClose",IK=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=_i(AK,n);return m.createElement(Be.button,le({type:"button"},r,{ref:t,onClick:Ce(e.onClick,()=>i.onOpenChange(!1))}))});function xy(e){return e?"open":"closed"}const NK=bK,RK=xK,LK=_K,Ik=SK,Nk=EK,Rk=MK,Lk=TK,$K=IK,wy=NK,_y=RK,FK=LK,$k=ue.forwardRef(({className:e,...t},n)=>_.jsx(Ik,{ref:n,className:Pe("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));$k.displayName=Ik.displayName;const _p=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsxs(FK,{children:[_.jsx($k,{}),_.jsxs(Nk,{ref:r,className:Pe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,_.jsxs($K,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[_.jsx(sV,{className:"h-4 w-4"}),_.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));_p.displayName=Nk.displayName;const Sp=({className:e,...t})=>_.jsx("div",{className:Pe("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Sp.displayName="DialogHeader";const Sy=({className:e,...t})=>_.jsx("div",{className:Pe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Sy.displayName="DialogFooter";const Cp=ue.forwardRef(({className:e,...t},n)=>_.jsx(Rk,{ref:n,className:Pe("text-lg font-semibold leading-none tracking-tight",e),...t}));Cp.displayName=Rk.displayName;const Ep=ue.forwardRef(({className:e,...t},n)=>_.jsx(Lk,{ref:n,className:Pe("text-sm text-muted-foreground",e),...t}));Ep.displayName=Lk.displayName;const Ku=ue.forwardRef(({className:e,type:t,...n},r)=>_.jsx("input",{type:t,className:Pe("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));Ku.displayName="Input";function jK(){const[e,t]=m.useState(""),[n,r]=m.useState(!1),[i,o]=m.useState(!1),s=ge(l=>l.dashboard);function a(){const l=by(s),c=ss(s.id),d=JSON.parse(localStorage.getItem(c)||"[]");if(d.some(p=>p.name===e)){r(!0);return}d.push({name:e,template:l}),localStorage.setItem(c,JSON.stringify(d)),o(!1)}return _.jsxs(wy,{open:i,onOpenChange:o,children:[_.jsx(_y,{asChild:!0,children:_.jsx(it,{variant:"outline",className:"h-7 p-2",size:"sm",children:_.jsx(WB,{className:"h-4 w-4",strokeWidth:1.5})})}),_.jsxs(_p,{className:"sm:max-w-[425px]",children:[_.jsxs(Sp,{children:[_.jsx(Cp,{children:"Add a Lens"}),_.jsx(Ep,{children:"Lenses are private by default and are only visible to you."})]}),_.jsx("div",{className:"grid gap-4 py-4",children:_.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[_.jsx(ns,{className:"text-right",children:"Name"}),_.jsx(Ku,{value:e,onChange:l=>{n&&r(!1),t(l.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),n&&_.jsx("p",{className:"text-sm",children:"The bookmark name already exists. Use a differnet name."}),_.jsx(Sy,{children:_.jsx(it,{type:"submit",disabled:!e,onClick:a,children:"Save"})})]})]})}function zK(){const[e,t]=m.useState(!1),[n,r]=m.useState(""),i=ge(p=>p.dashboard),o=ge(p=>p.bookmarkKey),[s,a]=m.useState([]),l=ge(p=>p.actions.setDashboard),c=ge(p=>p.actions.setBookmarkKey);m.useEffect(()=>{const p=ss(i.id),g=JSON.parse(localStorage.getItem(p)||"[]");a(g);const v=g.find(y=>y.default);v&&v.name===o&&r(v.name)},[e,i,o]);function d(p){if(p===n)return;const g=s.find(y=>y.name===p),v=g==null?void 0:g.template;v&&(l(v),c(p==="Original"?"":p)),r(p)}function f(p){const g=ss(i.id),y=JSON.parse(localStorage.getItem(g)||"[]").filter(x=>x.name!==p);localStorage.setItem(g,JSON.stringify(y)),a(y)}return _.jsxs(Sk,{open:e,onOpenChange:t,children:[_.jsx(Ck,{asChild:!0,children:_.jsx(it,{variant:"outline",className:"h-7 p-2",children:"Lenses"})}),_.jsxs(my,{className:"w-56",children:[_.jsx(Ek,{children:"Personalized Views"}),_.jsx(Ok,{}),_.jsxs(dK,{value:n,onValueChange:d,children:[_.jsx(vy,{value:"Original",children:"Original"}),s.filter(p=>p.name!="Original").map((p,g)=>_.jsxs(vy,{className:"xbg-red-100 flex justify-between",value:p.name,defaultChecked:p.name===o,children:[_.jsx("p",{children:p.name}),_.jsx(ia,{onClick:v=>{v.preventDefault(),f(p.name)},className:"h-3 w-3 hover:cursor-pointer",strokeWidth:1.5})]},g))]})]})]})}function Op(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}const Fk="Checkbox",[BK,sfe]=Pn(Fk),[VK,HK]=BK(Fk),WK=m.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:i,defaultChecked:o,required:s,disabled:a,value:l="on",onCheckedChange:c,...d}=e,[f,p]=m.useState(null),g=et(t,C=>p(C)),v=m.useRef(!1),y=f?!!f.closest("form"):!0,[x=!1,w]=Qn({prop:i,defaultProp:o,onChange:c}),S=m.useRef(x);return m.useEffect(()=>{const C=f==null?void 0:f.form;if(C){const P=()=>w(S.current);return C.addEventListener("reset",P),()=>C.removeEventListener("reset",P)}},[f,w]),m.createElement(VK,{scope:n,state:x,disabled:a},m.createElement(Be.button,le({type:"button",role:"checkbox","aria-checked":ya(x)?"mixed":x,"aria-required":s,"data-state":jk(x),"data-disabled":a?"":void 0,disabled:a,value:l},d,{ref:g,onKeyDown:Ce(e.onKeyDown,C=>{C.key==="Enter"&&C.preventDefault()}),onClick:Ce(e.onClick,C=>{w(P=>ya(P)?!0:!P),y&&(v.current=C.isPropagationStopped(),v.current||C.stopPropagation())})})),y&&m.createElement(GK,{control:f,bubbles:!v.current,name:r,value:l,checked:x,required:s,disabled:a,style:{transform:"translateX(-100%)"}}))}),qK="CheckboxIndicator",UK=m.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...i}=e,o=HK(qK,n);return m.createElement(vn,{present:r||ya(o.state)||o.state===!0},m.createElement(Be.span,le({"data-state":jk(o.state),"data-disabled":o.disabled?"":void 0},i,{ref:t,style:{pointerEvents:"none",...e.style}})))}),GK=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Op(n),a=Mh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const p=new Event("click",{bubbles:r});l.indeterminate=ya(n),f.call(l,ya(n)?!1:n),l.dispatchEvent(p)}},[s,n,r]),m.createElement("input",le({type:"checkbox","aria-hidden":!0,defaultChecked:ya(n)?!1:n},i,{tabIndex:-1,ref:o,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function ya(e){return e==="indeterminate"}function jk(e){return ya(e)?"indeterminate":e?"checked":"unchecked"}const zk=WK,YK=UK,Pp=ue.forwardRef(({className:e,...t},n)=>_.jsx(zk,{ref:n,className:Pe("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:_.jsx(YK,{className:Pe("flex items-center justify-center text-current"),children:_.jsx(Rh,{className:"h-4 w-4"})})}));Pp.displayName=zk.displayName;function KK(){const[e,t]=m.useState(!1),n=ge(o=>o.dashboard),r=ge(o=>o.bookmarkKey);m.useEffect(()=>{if(!r){t(!1);return}const o=ss(n.id),a=JSON.parse(localStorage.getItem(o)||"[]").find(l=>l.name===r);t(a?a.default:!1)},[r,n.id]);function i(o){if(t(o),!r)return;const s=ss(n.id),l=JSON.parse(localStorage.getItem(s)||"[]").map(c=>(c.name===r?c.default=o:c.default=!1,c));console.log(l),localStorage.setItem(s,JSON.stringify(l))}return _.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx(Pp,{checked:e,onCheckedChange:i,id:"terms"}),_.jsx("label",{htmlFor:"terms",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Set as default"})]})}function XK(){const e=ge(C=>C.bookmarkKey),t=ge(C=>C.dashboard),n=ge(C=>C.selectedSheetId),r=ge(C=>C.isDashboardEditing),i=ge(C=>C.isVisualEditing),o=ge(C=>C.showFilters),s=ge(C=>C.showDashboardJSON),a=ge(C=>C.actions.setShowDashboardJSON),l=ge(C=>C.onSaveFunction),c=ge(C=>C.actions.setShowFilters),{addCard:d,getSelectedSheet:f,setIsDashboardEditing:p,setSelectedCardId:g,setSelectedCard:v}=ge(C=>C.actions),y=f(),x=()=>{if(!r||!y)return;const C={id:yh(),title:"New Card",description:"New Card Description",preferences:{filterOnClick:!0},type:"bar",sql:"select COUNT(*) from YOUR_TABLE",data:[]};d(y.id,C),g(n,C.id),v(C)},w=()=>{p(!0)};function S(){if(!e||e==="")return;const C=by(t),P=ss(t.id),O=JSON.parse(localStorage.getItem(P)||"[]"),k=O.findIndex(A=>A.name===e);k!==-1?O[k]={name:e,template:C}:O.push({name:e,template:C}),localStorage.setItem(P,JSON.stringify(O)),l==null||l(C)}return _.jsxs("div",{className:`flex items-center justify-between gap-2 border-b-[3px]
428
- border-b-muted py-2 `,role:"dashboard-controls",children:[_.jsxs("div",{className:"flex gap-3 items-center",children:[_.jsx(ns,{children:e}),!!e&&_.jsxs(_.Fragment,{children:[_.jsx("span",{className:" text-muted-foreground",children:"|"}),_.jsx(KK,{})]})]}),_.jsxs("div",{className:"flex gap-2",children:[r&&!i&&_.jsx(jK,{}),!i&&_.jsx(zK,{}),r&&!i&&_.jsxs(it,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!r,onClick:x,children:[_.jsx(eV,{className:" mr-2 h-4 w-4",strokeWidth:1.5}),"Add Card"]}),!r&&_.jsx(it,{variant:"outline",className:"h-7 p-2",onClick:w,size:"sm",children:_.jsx(ZB,{className:"h-4 w-4",strokeWidth:1.5})}),r&&!i&&_.jsx(it,{variant:"outline",role:"close",className:"h-7 p-2",onClick:()=>p(!1),size:"sm",children:_.jsx(ia,{className:"h-4 w-4",strokeWidth:1.5})}),r&&!i&&_.jsx(it,{className:"h-7 p-2",variant:"outline",onClick:S,size:"sm",children:_.jsx(tV,{className:"h-4 w-4",strokeWidth:1.5})}),!o&&!i&&r&&_.jsx(it,{className:"h-7 p-2",variant:"outline",onClick:()=>c(!0),size:"sm",children:_.jsx(W2,{className:"h-4 w-4",strokeWidth:1.5})}),!i&&r&&_.jsx("div",{className:" flex items-center space-x-2",children:_.jsx(it,{className:"h-7 p-2",onClick:()=>a(!s),size:"sm",variant:"outline",children:_.jsx(YB,{className:"h-4 w-4",strokeWidth:1.5})})}),_.jsx(gK,{})]})]})}const Bk=m.forwardRef(({className:e,...t},n)=>_.jsx("div",{role:"editor-panel",ref:n,className:Pe("flex grow min-h-[80vh]",e),...t}));Bk.displayName="EditorPanel";const Vk=m.forwardRef(({className:e,...t},n)=>_.jsx("div",{ref:n,className:Pe(" flex flex-col space-y-2 w-[270px]",e),...t}));Vk.displayName="EditorAside";const Hk=m.forwardRef(({className:e,...t},n)=>_.jsx("div",{ref:n,className:Pe(" grow",e),...t}));Hk.displayName="EditorMain";const QK=[" ","Enter","ArrowUp","ArrowDown"],ZK=[" ","Enter"],kp="Select",[Mp,Dp,JK]=uf(kp),[Fl,afe]=Pn(kp,[JK,Fi]),Cy=Fi(),[eX,xa]=Fl(kp),[tX,nX]=Fl(kp),rX=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:o,value:s,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:f,disabled:p,required:g}=e,v=Cy(t),[y,x]=m.useState(null),[w,S]=m.useState(null),[C,P]=m.useState(!1),O=Fs(c),[k=!1,A]=Qn({prop:r,defaultProp:i,onChange:o}),[L,F]=Qn({prop:s,defaultProp:a,onChange:l}),z=m.useRef(null),B=y?!!y.closest("form"):!0,[V,X]=m.useState(new Set),K=Array.from(V).map($=>$.props.value).join(";");return m.createElement(Cu,v,m.createElement(eX,{required:g,scope:t,trigger:y,onTriggerChange:x,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:C,onValueNodeHasChildrenChange:P,contentId:or(),value:L,onValueChange:F,open:k,onOpenChange:A,dir:O,triggerPointerDownPosRef:z,disabled:p},m.createElement(Mp.Provider,{scope:t},m.createElement(tX,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback($=>{X(J=>new Set(J).add($))},[]),onNativeOptionRemove:m.useCallback($=>{X(J=>{const G=new Set(J);return G.delete($),G})},[])},n)),B?m.createElement(Zk,{key:K,"aria-hidden":!0,required:g,tabIndex:-1,name:d,autoComplete:f,value:L,onChange:$=>F($.target.value),disabled:p},L===void 0?m.createElement("option",{value:""}):null,Array.from(V)):null))},iX="SelectTrigger",oX=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...i}=e,o=Cy(n),s=xa(iX,n),a=s.disabled||r,l=et(t,s.onTriggerChange),c=Dp(n),[d,f,p]=Jk(v=>{const y=c().filter(S=>!S.disabled),x=y.find(S=>S.value===s.value),w=eM(y,v,x);w!==void 0&&s.onValueChange(w.value)}),g=()=>{a||(s.onOpenChange(!0),p())};return m.createElement(Eu,le({asChild:!0},o),m.createElement(Be.button,le({type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Qk(s.value)?"":void 0},i,{ref:l,onClick:Ce(i.onClick,v=>{v.currentTarget.focus()}),onPointerDown:Ce(i.onPointerDown,v=>{const y=v.target;y.hasPointerCapture(v.pointerId)&&y.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&(g(),s.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)},v.preventDefault())}),onKeyDown:Ce(i.onKeyDown,v=>{const y=d.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&f(v.key),!(y&&v.key===" ")&&QK.includes(v.key)&&(g(),v.preventDefault())})})))}),sX="SelectValue",aX=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,children:o,placeholder:s="",...a}=e,l=xa(sX,n),{onValueNodeHasChildrenChange:c}=l,d=o!==void 0,f=et(t,l.onValueNodeChange);return Vn(()=>{c(d)},[c,d]),m.createElement(Be.span,le({},a,{ref:f,style:{pointerEvents:"none"}}),Qk(l.value)?m.createElement(m.Fragment,null,s):o)}),lX=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...i}=e;return m.createElement(Be.span,le({"aria-hidden":!0},i,{ref:t}),r||"▼")}),cX=e=>m.createElement(Dh,le({asChild:!0},e)),jl="SelectContent",uX=m.forwardRef((e,t)=>{const n=xa(jl,e.__scopeSelect),[r,i]=m.useState();if(Vn(()=>{i(new DocumentFragment)},[]),!n.open){const o=r;return o?kt.createPortal(m.createElement(Wk,{scope:e.__scopeSelect},m.createElement(Mp.Slot,{scope:e.__scopeSelect},m.createElement("div",null,e.children))),o):null}return m.createElement(dX,le({},e,{ref:t}))}),_o=10,[Wk,wa]=Fl(jl),dX=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:o,onPointerDownOutside:s,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:g,sticky:v,hideWhenDetached:y,avoidCollisions:x,...w}=e,S=xa(jl,n),[C,P]=m.useState(null),[O,k]=m.useState(null),A=et(t,de=>P(de)),[L,F]=m.useState(null),[z,B]=m.useState(null),V=Dp(n),[X,K]=m.useState(!1),$=m.useRef(!1);m.useEffect(()=>{if(C)return ap(C)},[C]),rp();const J=m.useCallback(de=>{const[ie,...ee]=V().map(oe=>oe.ref.current),[H]=ee.slice(-1),ye=document.activeElement;for(const oe of de)if(oe===ye||(oe==null||oe.scrollIntoView({block:"nearest"}),oe===ie&&O&&(O.scrollTop=0),oe===H&&O&&(O.scrollTop=O.scrollHeight),oe==null||oe.focus(),document.activeElement!==ye))return},[V,O]),G=m.useCallback(()=>J([L,C]),[J,L,C]);m.useEffect(()=>{X&&G()},[X,G]);const{onOpenChange:q,triggerPointerDownPosRef:se}=S;m.useEffect(()=>{if(C){let de={x:0,y:0};const ie=H=>{var ye,oe,Te,Fe;de={x:Math.abs(Math.round(H.pageX)-((ye=(oe=se.current)===null||oe===void 0?void 0:oe.x)!==null&&ye!==void 0?ye:0)),y:Math.abs(Math.round(H.pageY)-((Te=(Fe=se.current)===null||Fe===void 0?void 0:Fe.y)!==null&&Te!==void 0?Te:0))}},ee=H=>{de.x<=10&&de.y<=10?H.preventDefault():C.contains(H.target)||q(!1),document.removeEventListener("pointermove",ie),se.current=null};return se.current!==null&&(document.addEventListener("pointermove",ie),document.addEventListener("pointerup",ee,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ie),document.removeEventListener("pointerup",ee,{capture:!0})}}},[C,q,se]),m.useEffect(()=>{const de=()=>q(!1);return window.addEventListener("blur",de),window.addEventListener("resize",de),()=>{window.removeEventListener("blur",de),window.removeEventListener("resize",de)}},[q]);const[D,W]=Jk(de=>{const ie=V().filter(ye=>!ye.disabled),ee=ie.find(ye=>ye.ref.current===document.activeElement),H=eM(ie,de,ee);H&&setTimeout(()=>H.ref.current.focus())}),re=m.useCallback((de,ie,ee)=>{const H=!$.current&&!ee;(S.value!==void 0&&S.value===ie||H)&&(F(de),H&&($.current=!0))},[S.value]),N=m.useCallback(()=>C==null?void 0:C.focus(),[C]),ne=m.useCallback((de,ie,ee)=>{const H=!$.current&&!ee;(S.value!==void 0&&S.value===ie||H)&&B(de)},[S.value]),me=r==="popper"?qk:fX,he=me===qk?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:g,sticky:v,hideWhenDetached:y,avoidCollisions:x}:{};return m.createElement(Wk,{scope:n,content:C,viewport:O,onViewportChange:k,itemRefCallback:re,selectedItem:L,onItemLeave:N,itemTextRefCallback:ne,focusSelectedItem:G,selectedItemText:z,position:r,isPositioned:X,searchRef:D},m.createElement(hp,{as:no,allowPinchZoom:!0},m.createElement(ip,{asChild:!0,trapped:S.open,onMountAutoFocus:de=>{de.preventDefault()},onUnmountAutoFocus:Ce(i,de=>{var ie;(ie=S.trigger)===null||ie===void 0||ie.focus({preventScroll:!0}),de.preventDefault()})},m.createElement(_l,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:de=>de.preventDefault(),onDismiss:()=>S.onOpenChange(!1)},m.createElement(me,le({role:"listbox",id:S.contentId,"data-state":S.open?"open":"closed",dir:S.dir,onContextMenu:de=>de.preventDefault()},w,he,{onPlaced:()=>K(!0),ref:A,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:Ce(w.onKeyDown,de=>{const ie=de.ctrlKey||de.altKey||de.metaKey;if(de.key==="Tab"&&de.preventDefault(),!ie&&de.key.length===1&&W(de.key),["ArrowUp","ArrowDown","Home","End"].includes(de.key)){let H=V().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);if(["ArrowUp","End"].includes(de.key)&&(H=H.slice().reverse()),["ArrowUp","ArrowDown"].includes(de.key)){const ye=de.target,oe=H.indexOf(ye);H=H.slice(oe+1)}setTimeout(()=>J(H)),de.preventDefault()}})}))))))}),fX=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...i}=e,o=xa(jl,n),s=wa(jl,n),[a,l]=m.useState(null),[c,d]=m.useState(null),f=et(t,A=>d(A)),p=Dp(n),g=m.useRef(!1),v=m.useRef(!0),{viewport:y,selectedItem:x,selectedItemText:w,focusSelectedItem:S}=s,C=m.useCallback(()=>{if(o.trigger&&o.valueNode&&a&&c&&y&&x&&w){const A=o.trigger.getBoundingClientRect(),L=c.getBoundingClientRect(),F=o.valueNode.getBoundingClientRect(),z=w.getBoundingClientRect();if(o.dir!=="rtl"){const ye=z.left-L.left,oe=F.left-ye,Te=A.left-oe,Fe=A.width+Te,He=Math.max(Fe,L.width),Ke=window.innerWidth-_o,St=l0(oe,[_o,Ke-He]);a.style.minWidth=Fe+"px",a.style.left=St+"px"}else{const ye=L.right-z.right,oe=window.innerWidth-F.right-ye,Te=window.innerWidth-A.right-oe,Fe=A.width+Te,He=Math.max(Fe,L.width),Ke=window.innerWidth-_o,St=l0(oe,[_o,Ke-He]);a.style.minWidth=Fe+"px",a.style.right=St+"px"}const B=p(),V=window.innerHeight-_o*2,X=y.scrollHeight,K=window.getComputedStyle(c),$=parseInt(K.borderTopWidth,10),J=parseInt(K.paddingTop,10),G=parseInt(K.borderBottomWidth,10),q=parseInt(K.paddingBottom,10),se=$+J+X+q+G,D=Math.min(x.offsetHeight*5,se),W=window.getComputedStyle(y),re=parseInt(W.paddingTop,10),N=parseInt(W.paddingBottom,10),ne=A.top+A.height/2-_o,me=V-ne,he=x.offsetHeight/2,de=x.offsetTop+he,ie=$+J+de,ee=se-ie;if(ie<=ne){const ye=x===B[B.length-1].ref.current;a.style.bottom="0px";const oe=c.clientHeight-y.offsetTop-y.offsetHeight,Te=Math.max(me,he+(ye?N:0)+oe+G),Fe=ie+Te;a.style.height=Fe+"px"}else{const ye=x===B[0].ref.current;a.style.top="0px";const Te=Math.max(ne,$+y.offsetTop+(ye?re:0)+he)+ee;a.style.height=Te+"px",y.scrollTop=ie-ne+y.offsetTop}a.style.margin=`${_o}px 0`,a.style.minHeight=D+"px",a.style.maxHeight=V+"px",r==null||r(),requestAnimationFrame(()=>g.current=!0)}},[p,o.trigger,o.valueNode,a,c,y,x,w,o.dir,r]);Vn(()=>C(),[C]);const[P,O]=m.useState();Vn(()=>{c&&O(window.getComputedStyle(c).zIndex)},[c]);const k=m.useCallback(A=>{A&&v.current===!0&&(C(),S==null||S(),v.current=!1)},[C,S]);return m.createElement(hX,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:g,onScrollButtonChange:k},m.createElement("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:P}},m.createElement(Be.div,le({},i,{ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}}))))}),qk=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=_o,...o}=e,s=Cy(n);return m.createElement(Ou,le({},s,o,{ref:t,align:r,collisionPadding:i,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}}))}),[hX,Ey]=Fl(jl,{}),Uk="SelectViewport",pX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=wa(Uk,n),o=Ey(Uk,n),s=et(t,i.onViewportChange),a=m.useRef(0);return m.createElement(m.Fragment,null,m.createElement("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"}}),m.createElement(Mp.Slot,{scope:n},m.createElement(Be.div,le({"data-radix-select-viewport":"",role:"presentation"},r,{ref:s,style:{position:"relative",flex:1,overflow:"auto",...r.style},onScroll:Ce(r.onScroll,l=>{const c=l.currentTarget,{contentWrapper:d,shouldExpandOnScrollRef:f}=o;if(f!=null&&f.current&&d){const p=Math.abs(a.current-c.scrollTop);if(p>0){const g=window.innerHeight-_o*2,v=parseFloat(d.style.minHeight),y=parseFloat(d.style.height),x=Math.max(v,y);if(x<g){const w=x+p,S=Math.min(g,w),C=w-S;d.style.height=S+"px",d.style.bottom==="0px"&&(c.scrollTop=C>0?C:0,d.style.justifyContent="flex-end")}}}a.current=c.scrollTop})}))))}),gX="SelectGroup",[mX,vX]=Fl(gX),bX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=or();return m.createElement(mX,{scope:n,id:i},m.createElement(Be.div,le({role:"group","aria-labelledby":i},r,{ref:t})))}),yX="SelectLabel",xX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=vX(yX,n);return m.createElement(Be.div,le({id:i.id},r,{ref:t}))}),Oy="SelectItem",[wX,Gk]=Fl(Oy),_X=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:i=!1,textValue:o,...s}=e,a=xa(Oy,n),l=wa(Oy,n),c=a.value===r,[d,f]=m.useState(o??""),[p,g]=m.useState(!1),v=et(t,w=>{var S;return(S=l.itemRefCallback)===null||S===void 0?void 0:S.call(l,w,r,i)}),y=or(),x=()=>{i||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return m.createElement(wX,{scope:n,value:r,disabled:i,textId:y,isSelected:c,onItemTextChange:m.useCallback(w=>{f(S=>{var C;return S||((C=w==null?void 0:w.textContent)!==null&&C!==void 0?C:"").trim()})},[])},m.createElement(Mp.ItemSlot,{scope:n,value:r,disabled:i,textValue:d},m.createElement(Be.div,le({role:"option","aria-labelledby":y,"data-highlighted":p?"":void 0,"aria-selected":c&&p,"data-state":c?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1},s,{ref:v,onFocus:Ce(s.onFocus,()=>g(!0)),onBlur:Ce(s.onBlur,()=>g(!1)),onPointerUp:Ce(s.onPointerUp,x),onPointerMove:Ce(s.onPointerMove,w=>{if(i){var S;(S=l.onItemLeave)===null||S===void 0||S.call(l)}else w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ce(s.onPointerLeave,w=>{if(w.currentTarget===document.activeElement){var S;(S=l.onItemLeave)===null||S===void 0||S.call(l)}}),onKeyDown:Ce(s.onKeyDown,w=>{var S;((S=l.searchRef)===null||S===void 0?void 0:S.current)!==""&&w.key===" "||(ZK.includes(w.key)&&x(),w.key===" "&&w.preventDefault())})}))))}),Tp="SelectItemText",SX=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,...o}=e,s=xa(Tp,n),a=wa(Tp,n),l=Gk(Tp,n),c=nX(Tp,n),[d,f]=m.useState(null),p=et(t,w=>f(w),l.onItemTextChange,w=>{var S;return(S=a.itemTextRefCallback)===null||S===void 0?void 0:S.call(a,w,l.value,l.disabled)}),g=d==null?void 0:d.textContent,v=m.useMemo(()=>m.createElement("option",{key:l.value,value:l.value,disabled:l.disabled},g),[l.disabled,l.value,g]),{onNativeOptionAdd:y,onNativeOptionRemove:x}=c;return Vn(()=>(y(v),()=>x(v)),[y,x,v]),m.createElement(m.Fragment,null,m.createElement(Be.span,le({id:l.textId},o,{ref:p})),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren?kt.createPortal(o.children,s.valueNode):null)}),CX="SelectItemIndicator",EX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Gk(CX,n).isSelected?m.createElement(Be.span,le({"aria-hidden":!0},r,{ref:t})):null}),Yk="SelectScrollUpButton",OX=m.forwardRef((e,t)=>{const n=wa(Yk,e.__scopeSelect),r=Ey(Yk,e.__scopeSelect),[i,o]=m.useState(!1),s=et(t,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const c=a.scrollTop>0;o(c)};const a=n.viewport;return l(),a.addEventListener("scroll",l),()=>a.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?m.createElement(Xk,le({},e,{ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}})):null}),Kk="SelectScrollDownButton",PX=m.forwardRef((e,t)=>{const n=wa(Kk,e.__scopeSelect),r=Ey(Kk,e.__scopeSelect),[i,o]=m.useState(!1),s=et(t,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const c=a.scrollHeight-a.clientHeight,d=Math.ceil(a.scrollTop)<c;o(d)};const a=n.viewport;return l(),a.addEventListener("scroll",l),()=>a.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?m.createElement(Xk,le({},e,{ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}})):null}),Xk=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...i}=e,o=wa("SelectScrollButton",n),s=m.useRef(null),a=Dp(n),l=m.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),Vn(()=>{var c;const d=a().find(f=>f.ref.current===document.activeElement);d==null||(c=d.ref.current)===null||c===void 0||c.scrollIntoView({block:"nearest"})},[a]),m.createElement(Be.div,le({"aria-hidden":!0},i,{ref:t,style:{flexShrink:0,...i.style},onPointerDown:Ce(i.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:Ce(i.onPointerMove,()=>{var c;(c=o.onItemLeave)===null||c===void 0||c.call(o),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:Ce(i.onPointerLeave,()=>{l()})}))}),kX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return m.createElement(Be.div,le({"aria-hidden":!0},r,{ref:t}))});function Qk(e){return e===""||e===void 0}const Zk=m.forwardRef((e,t)=>{const{value:n,...r}=e,i=m.useRef(null),o=et(t,i),s=Op(n);return m.useEffect(()=>{const a=i.current,l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(s!==n&&d){const f=new Event("change",{bubbles:!0});d.call(a,n),a.dispatchEvent(f)}},[s,n]),m.createElement(T2,{asChild:!0},m.createElement("select",le({},r,{ref:o,defaultValue:n})))});Zk.displayName="BubbleSelect";function Jk(e){const t=xn(e),n=m.useRef(""),r=m.useRef(0),i=m.useCallback(s=>{const a=n.current+s;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),o=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,o]}function eM(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let s=MX(e,Math.max(o,0));i.length===1&&(s=s.filter(c=>c!==n));const l=s.find(c=>c.textValue.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function MX(e,t){return e.map((n,r)=>e[(t+r)%e.length])}const DX=rX,tM=oX,TX=aX,AX=lX,IX=cX,nM=uX,NX=pX,RX=bX,rM=xX,iM=_X,LX=SX,$X=EX,oM=OX,sM=PX,aM=kX,lM=DX,cM=RX,uM=TX,Py=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsxs(tM,{ref:r,className:Pe("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,_.jsx(AX,{asChild:!0,children:_.jsx(Wb,{className:"h-4 w-4 opacity-50"})})]}));Py.displayName=tM.displayName;const dM=ue.forwardRef(({className:e,...t},n)=>_.jsx(oM,{ref:n,className:Pe("flex cursor-default items-center justify-center py-1",e),...t,children:_.jsx(GB,{className:"h-4 w-4"})}));dM.displayName=oM.displayName;const fM=ue.forwardRef(({className:e,...t},n)=>_.jsx(sM,{ref:n,className:Pe("flex cursor-default items-center justify-center py-1",e),...t,children:_.jsx(Wb,{className:"h-4 w-4"})}));fM.displayName=sM.displayName;const ky=ue.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>_.jsx(IX,{children:_.jsxs(nM,{ref:i,className:Pe("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[_.jsx(dM,{}),_.jsx(NX,{className:Pe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),_.jsx(fM,{})]})}));ky.displayName=nM.displayName;const Ap=ue.forwardRef(({className:e,...t},n)=>_.jsx(rM,{ref:n,className:Pe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Ap.displayName=rM.displayName;const _a=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsxs(iM,{ref:r,className:Pe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[_.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:_.jsx($X,{children:_.jsx(Rh,{className:"h-4 w-4"})})}),_.jsx(LX,{children:t})]}));_a.displayName=iM.displayName;const FX=ue.forwardRef(({className:e,...t},n)=>_.jsx(aM,{ref:n,className:Pe("-mx-1 my-1 h-px bg-muted",e),...t}));FX.displayName=aM.displayName;function Ip({title:e,items:t,value:n,isLoading:r,isError:i,onChange:o}){const s=r?"Loading...":i?"Error":n;function a(){if(e==="Connection")return _.jsx(JB,{className:" rotate-90",strokeWidth:1,size:16});if(e==="Database")return _.jsx(KB,{strokeWidth:1,size:16});if(e==="Schema")return _.jsx(iV,{strokeWidth:1,size:16});if(e==="Table")return _.jsx(qb,{strokeWidth:1,size:16})}return _.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx("div",{className:" shrink-0",children:a()}),_.jsxs(lM,{value:s,onValueChange:o,children:[_.jsx(Py,{className:"focus:ring-offset-0 focus:ring-1 h-7 w-[190px] ",children:_.jsx(uM,{placeholder:r?"Loading...":i?"Error":`Select ${e}`})}),_.jsx(ky,{children:_.jsxs(cM,{children:[r?_.jsx(Ap,{children:"Loading..."}):_.jsx(Ap,{children:e}),_.jsx(_.Fragment,{children:t&&t.map(l=>_.jsx(_a,{value:l.id,children:l.name},l.id))}),(r||i)&&_.jsx(_a,{value:s,children:s})]})})]})]})}function jX({column:e}){const[t,n]=m.useState(!1),r=_e(d=>d.selectedTableName),i=_e(d=>d.selectedSchemaName),o=_e(d=>d.sqlGen),s=_e(d=>d.actions.setSqlGen),a=_e(d=>d.actions.setCardSql),l=_e(d=>d.actions.setRunSql);function c(d,f){const p=WO(d,o,f);s(p);const g=HO(p,i||"",r);g&&(a(g),l(!0)),n(!1)}return _.jsxs(pp,{open:t,onOpenChange:n,children:[_.jsx(gp,{asChild:!0,children:_.jsx(Hj,{className:"w-3 h-3 text-foreground/40 cursor-pointer"})}),_.jsx(Wu,{align:"center",className:" p-0 w-18 rounded-none shadow-none border-muted",children:_.jsxs("ul",{className:"text-xs ",children:[_.jsx("li",{onClick:()=>c(e,"COUNT"),className:" px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Count"}),_.jsx("li",{onClick:()=>c(e,"AVG"),className:" px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Avg"}),_.jsx("li",{onClick:()=>c(e,"SUM"),className:"px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Sum"}),_.jsx("li",{onClick:()=>c(e,"MAX"),className:"px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Max"}),_.jsx("li",{onClick:()=>c(e,"MIN"),className:"px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Min"})]})})]})}function hM({column:e}){return _.jsxs(Vb,{children:[_.jsx(I2,{asChild:!0,children:P0.includes(e.data_type.toLowerCase())?_.jsx("span",{className:" font-thin",children:"T"}):Tl.includes(e.data_type.toLowerCase())?_.jsx("span",{className:" font-thin",children:"#"}):Iu.includes(e.data_type.toLowerCase())?_.jsx("span",{className:" font-thin",children:"D"}):VO.includes(e.data_type.toLowerCase())?_.jsx("span",{className:" font-thin",children:"B"}):_.jsx("span",{className:" font-thin",children:"?"})}),_.jsx(Ih,{children:_.jsx("p",{className:"text-xs font-mono",children:e.data_type})})]})}function zX({schemaName:e,tableName:t,columns:n,status:r}){const i=_e(f=>f.sqlGen),o=_e(f=>f.actions.setRunSql),s=_e(f=>f.actions.setSqlGen),a=_e(f=>f.actions.setIsShowingVisual),l=_e(f=>f.actions.setCardSql);function c(f){const p=WO(f,i);s(p);const g=HO(p,e,t);g&&(l(g),o(!0))}function d(){const f=M0(e,t);a(!1),l(`SELECT * FROM ${f} LIMIT 10`),o(!0)}return _.jsxs("div",{className:"px-4",children:[_.jsx("div",{className:" font-medium px-2 pt-2 pb-3",children:_.jsxs(it,{disabled:r!=="Success",onClick:d,variant:"secondary",className:" h-7 flex w-full",children:[r!=="Success"&&_.jsx(ku,{className:" w-4 h-4 animate-spin mr-2 text-foreground/50"}),"Show top 10 rows"]})}),_.jsxs(kl,{className:`w-full ${t==="api"?"h-[74vh]":"h-[60vh]"}`,children:[n==null?void 0:n.map(f=>_.jsxs("div",{onClick:()=>c(f),className:Pe(" text-sm flex items-center justify-between px-3 py-[6px] transition-colors hover:bg-muted/50 cursor-pointer rounded ",{" bg-muted":BW(f,i)}),children:[_.jsxs("div",{className:"flex items-center space-x-2 ",children:[_.jsx(hM,{column:f}),_.jsx("span",{children:f.column_name})]}),Tl.includes(f.data_type)&&_.jsx("div",{onClick:p=>p.stopPropagation(),className:" flex items-center justify-end ",children:_.jsx(jX,{column:f})})]},f.column_name)),_.jsx(Hh,{orientation:"vertical"}),_.jsx(Hh,{orientation:"horizontal"})]})]})}function pM({ColumnsComponent:e}){const t=_e(K=>K.selectedConnectionId);_e(K=>K.card.sql);const n=_e(K=>K.selectedDatabaseName),r=_e(K=>K.selectedSchemaName),i=_e(K=>K.selectedTableName),o=_e(K=>K.actions.setSelectedConnectionId),s=_e(K=>K.actions.setSelectedDatabaseName),a=_e(K=>K.actions.setSelectedSchemaName),l=_e(K=>K.actions.setSelectedTableName),c=_e(K=>K.actions.setCardSql),{connectionItems:d,schemaItems:f,databaseItems:p,tableItems:g,columns:v,isConnectionsLoading:y,isConnectionsError:x,isDatabasesLoadingOrFetching:w,isDatabaseError:S,isSchemaLoadingOrFetching:C,isSchemaError:P,isColumnsError:O,isColumnsLoadingOrFetching:k,isAPIConnection:A}=iH();m.useEffect(()=>{A&&(s("NA"),a(""),l("api"))},[A,c,l,a,s]);const L=A?"api":i||"",F=A?"":r||"";function z(K){a(K),l("")}function B(K){s(K),a(""),l("")}function V(K){o(K)}function X(){return e?e(F,L,v):_.jsx(zX,{schemaName:F,tableName:L,columns:v,status:k?"Loading...":O?"Error":"Success"})}return _.jsxs("aside",{className:" grow flex flex-col xbg-red-100 ",children:[_.jsxs("section",{className:"space-y-3 pt-4 pb-3 px-6",children:[_.jsx(Ip,{items:d,title:"Connection",value:t||"",onChange:V,isLoading:y,isError:x}),!A&&_.jsxs(_.Fragment,{children:[_.jsx(Ip,{onChange:B,isError:S,isLoading:w,items:p,value:n||"",title:"Database"}),_.jsx(Ip,{onChange:z,isError:P,isLoading:C,items:f,value:r||"",title:"Schema"}),_.jsx(Ip,{onChange:l,isError:S,items:g,isLoading:w,value:i||"",title:"Table"})]})]}),X(),_.jsx("div",{className:" grow justify-end flex flex-col pt-6 "})]})}const{createElement:zl,createContext:BX,createRef:lfe,forwardRef:gM,useCallback:Rr,useContext:mM,useEffect:Sa,useImperativeHandle:vM,useLayoutEffect:VX,useMemo:HX,useRef:ei,useState:Np}=ue,bM=ue.useId,Rp=BX(null);Rp.displayName="PanelGroupContext";const Xu=VX,WX=typeof bM=="function"?bM:()=>null;let qX=0;function My(e=null){const t=WX(),n=ei(e||t||null);return n.current===null&&(n.current=""+qX++),e??n.current}function yM({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:o,id:s,maxSize:a,minSize:l,onCollapse:c,onExpand:d,onResize:f,order:p,style:g,tagName:v="div",...y}){const x=mM(Rp);if(x===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:w,expandPanel:S,getPanelSize:C,getPanelStyle:P,groupId:O,isPanelCollapsed:k,registerPanel:A,resizePanel:L,unregisterPanel:F}=x,z=My(s),B=ei({callbacks:{onCollapse:c,onExpand:d,onResize:f},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:a,minSize:l},id:z,idIsFromProps:s!==void 0,order:p});ei({didLogMissingDefaultSizeWarning:!1}),Xu(()=>{const{callbacks:X,constraints:K}=B.current;B.current.id=z,B.current.idIsFromProps=s!==void 0,B.current.order=p,X.onCollapse=c,X.onExpand=d,X.onResize=f,K.collapsedSize=n,K.collapsible=r,K.defaultSize=i,K.maxSize=a,K.minSize=l}),Xu(()=>{const X=B.current;return A(X),()=>{F(X)}},[p,z,A,F]),vM(o,()=>({collapse:()=>{w(B.current)},expand:()=>{S(B.current)},getId(){return z},getSize(){return C(B.current)},isCollapsed(){return k(B.current)},isExpanded(){return!k(B.current)},resize:X=>{L(B.current,X)}}),[w,S,C,k,z,L]);const V=P(B.current,i);return zl(v,{...y,children:e,className:t,style:{...V,...g},"data-panel":"","data-panel-id":z,"data-panel-group-id":O,"data-panel-collapsible":void 0,"data-panel-size":void 0})}const xM=gM((e,t)=>zl(yM,{...e,forwardedRef:t}));yM.displayName="Panel",xM.displayName="forwardRef(Panel)";function st(e,t="Assertion failed!"){if(!e)throw console.error(t),Error(t)}const wM=10;function Qu(e,t,n=wM){e=parseFloat(e.toFixed(n)),t=parseFloat(t.toFixed(n));const r=e-t;return r===0?0:r>0?1:-1}function Lr(e,t,n){return Qu(e,t,n)===0}function Bl({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];st(r!=null);let{collapsedSize:i=0,collapsible:o,maxSize:s=100,minSize:a=0}=r;if(Qu(n,a)<0)if(o){const l=(i+a)/2;Qu(n,l)<0?n=i:n=a}else n=a;return n=Math.min(s,n),n=parseFloat(n.toFixed(wM)),n}function Zu({delta:e,layout:t,panelConstraints:n,pivotIndices:r,trigger:i}){if(Lr(e,0))return t;const o=[...t],[s,a]=r;st(s!=null),st(a!=null);let l=0;if(i==="keyboard"){{const d=e<0?a:s,f=n[d];if(st(f),f.collapsible){const p=t[d];st(p!=null);const g=n[d];st(g);const{collapsedSize:v=0,minSize:y=0}=g;if(Lr(p,v)){const x=y-p;Qu(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const d=e<0?s:a,f=n[d];st(f);const{collapsible:p}=f;if(p){const g=t[d];st(g!=null);const v=n[d];st(v);const{collapsedSize:y=0,minSize:x=0}=v;if(Lr(g,x)){const w=g-y;Qu(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}}{const d=e<0?1:-1;let f=e<0?a:s,p=0;for(;;){const v=t[f];st(v!=null);const x=Bl({panelConstraints:n,panelIndex:f,size:100})-v;if(p+=x,f+=d,f<0||f>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let f=e<0?s:a;for(;f>=0&&f<n.length;){const p=Math.abs(e)-Math.abs(l),g=t[f];st(g!=null);const v=g-p,y=Bl({panelConstraints:n,panelIndex:f,size:v});if(!Lr(g,y)&&(l+=g-y,o[f]=y,l.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?f--:f++}}if(Lr(l,0))return t;{const d=e<0?a:s,f=t[d];st(f!=null);const p=f+l,g=Bl({panelConstraints:n,panelIndex:d,size:p});if(o[d]=g,!Lr(g,p)){let v=p-g,x=e<0?a:s;for(;x>=0&&x<n.length;){const w=o[x];st(w!=null);const S=w+v,C=Bl({panelConstraints:n,panelIndex:x,size:S});if(Lr(w,C)||(v-=C-w,o[x]=C),Lr(v,0))break;e>0?x--:x++}}}const c=o.reduce((d,f)=>f+d,0);return Lr(c,100)?o:t}function UX({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,o=0,s=0;const a=n[0];st(a!=null),t.forEach((f,p)=>{const{constraints:g}=f,{maxSize:v=100,minSize:y=0}=g;p===a?(r=y,i=v):(o+=y,s+=v)});const l=Math.min(i,100-o),c=Math.max(r,100-s),d=e[a];return{valueMax:l,valueMin:c,valueNow:d}}function Ju(e){return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function _M(e,t){const r=Ju(e).findIndex(i=>i.getAttribute("data-panel-resize-handle-id")===t);return r??null}function SM(e,t){const n=_M(e,t);return n!=null?[n,n+1]:[-1,-1]}function CM(e){const t=document.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return t||null}function Lp(e){const t=document.querySelector(`[data-panel-resize-handle-id="${e}"]`);return t||null}function GX(e,t,n){var r,i,o,s;const a=Lp(t),l=Ju(e),c=a?l.indexOf(a):-1,d=(r=(i=n[c])===null||i===void 0?void 0:i.id)!==null&&r!==void 0?r:null,f=(o=(s=n[c+1])===null||s===void 0?void 0:s.id)!==null&&o!==void 0?o:null;return[d,f]}function YX({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,setLayout:o}){ei({didWarnAboutMissingResizeHandle:!1}),Xu(()=>{const s=Ju(n);for(let a=0;a<i.length-1;a++){const{valueMax:l,valueMin:c,valueNow:d}=UX({layout:r,panelsArray:i,pivotIndices:[a,a+1]}),f=s[a];if(f!=null){const p=i[a];st(p),f.setAttribute("aria-controls",p.id),f.setAttribute("aria-valuemax",""+Math.round(l)),f.setAttribute("aria-valuemin",""+Math.round(c)),f.setAttribute("aria-valuenow",d!=null?""+Math.round(d):"")}}return()=>{s.forEach((a,l)=>{a.removeAttribute("aria-controls"),a.removeAttribute("aria-valuemax"),a.removeAttribute("aria-valuemin"),a.removeAttribute("aria-valuenow")})}},[n,r,i]),Sa(()=>{const s=t.current;st(s);const{panelDataArray:a}=s,l=CM(n);st(l!=null,`No group found for id "${n}"`);const c=Ju(n);st(c);const d=c.map(f=>{const p=f.getAttribute("data-panel-resize-handle-id");st(p);const[g,v]=GX(n,p,a);if(g==null||v==null)return()=>{};const y=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const w=a.findIndex(S=>S.id===g);if(w>=0){const S=a[w];st(S);const C=r[w],{collapsedSize:P=0,collapsible:O,minSize:k=0}=S.constraints;if(C!=null&&O){const A=Zu({delta:Lr(C,P)?k-P:P-C,layout:r,panelConstraints:a.map(L=>L.constraints),pivotIndices:SM(n,p),trigger:"keyboard"});r!==A&&o(A)}}break}}};return f.addEventListener("keydown",y),()=>{f.removeEventListener("keydown",y)}});return()=>{d.forEach(f=>f())}},[e,t,n,r,i,o])}function EM(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function OM(e){return e.type==="keydown"}function PM(e){return e.type.startsWith("mouse")}function kM(e){return e.type.startsWith("touch")}function MM(e,t){const n=e==="horizontal";if(PM(t))return n?t.clientX:t.clientY;if(kM(t)){const r=t.touches[0];return st(r),n?r.screenX:r.screenY}else throw Error(`Unsupported event type "${t.type}"`)}function KX(e,t,n,r){const i=n==="horizontal",o=Lp(t);st(o);const s=o.getAttribute("data-panel-group-id");st(s);let{initialCursorPosition:a}=r;const l=MM(n,e),c=CM(s);st(c);const d=c.getBoundingClientRect(),f=i?d.width:d.height;return(l-a)/f*100}function XX(e,t,n,r,i){if(OM(e)){const o=n==="horizontal";let s=0;e.shiftKey?s=100:i!=null?s=i:s=10;let a=0;switch(e.key){case"ArrowDown":a=o?0:s;break;case"ArrowLeft":a=o?-s:0;break;case"ArrowRight":a=o?s:0;break;case"ArrowUp":a=o?0:-s;break;case"End":a=100;break;case"Home":a=-100;break}return a}else return r==null?0:KX(e,t,n,r)}function QX({panelDataArray:e}){const t=Array(e.length),n=e.map(o=>o.constraints);let r=0,i=100;for(let o=0;o<e.length;o++){const s=n[o];st(s);const{defaultSize:a}=s;a!=null&&(r++,t[o]=a,i-=a)}for(let o=0;o<e.length;o++){const s=n[o];st(s);const{defaultSize:a}=s;if(a!=null)continue;const l=e.length-r,c=i/l;r++,t[o]=c,i-=c}return t}function Vl(e,t,n){t.forEach((r,i)=>{const o=e[i];st(o);const{callbacks:s,constraints:a,id:l}=o,{collapsedSize:c=0,collapsible:d}=a,f=n[l];if(f==null||r!==f){n[l]=r;const{onCollapse:p,onExpand:g,onResize:v}=s;v&&v(r,f),d&&(p||g)&&(g&&(f==null||f===c)&&r!==c&&g(),p&&(f==null||f!==c)&&r===c&&p())}})}function $p(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function ZX({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:i,precision:o=3}){const s=n[i];let a;return s==null?a=e??"1":r.length===1?a="1":a=s.toPrecision(o),{flexBasis:0,flexGrow:a,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}let Dy=null,Ca=null;function DM(e){switch(e){case"horizontal":return"ew-resize";case"horizontal-max":return"w-resize";case"horizontal-min":return"e-resize";case"vertical":return"ns-resize";case"vertical-max":return"n-resize";case"vertical-min":return"s-resize"}}function JX(){Ca!==null&&(document.head.removeChild(Ca),Dy=null,Ca=null)}function Ty(e){if(Dy===e)return;Dy=e;const t=DM(e);Ca===null&&(Ca=document.createElement("style"),document.head.appendChild(Ca)),Ca.innerHTML=`*{cursor: ${t}!important;}`}function eQ(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function TM(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function AM(e){return`react-resizable-panels:${e}`}function IM(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:i,order:o}=t;return i?r:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function NM(e,t){try{const n=AM(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function tQ(e,t,n){var r,i;const o=(r=NM(e,n))!==null&&r!==void 0?r:{},s=IM(t);return(i=o[s])!==null&&i!==void 0?i:null}function nQ(e,t,n,r,i){var o;const s=AM(e),a=IM(t),l=(o=NM(e,i))!==null&&o!==void 0?o:{};l[a]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(s,JSON.stringify(l))}catch(c){console.error(c)}}function RM({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((o,s)=>o+s,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!Lr(r,100))for(let o=0;o<t.length;o++){const s=n[o];st(s!=null);const a=100/r*s;n[o]=a}let i=0;for(let o=0;o<t.length;o++){const s=n[o];st(s!=null);const a=Bl({panelConstraints:t,panelIndex:o,size:s});s!=a&&(i+=s-a,n[o]=a)}if(!Lr(i,0))for(let o=0;o<t.length;o++){const s=n[o];st(s!=null);const a=s+i,l=Bl({panelConstraints:t,panelIndex:o,size:a});if(s!==l&&(i-=l-s,n[o]=l,Lr(i,0)))break}return n}const rQ=100,ed={getItem:e=>(TM(ed),ed.getItem(e)),setItem:(e,t)=>{TM(ed),ed.setItem(e,t)}},LM={};function $M({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:o=null,onLayout:s=null,keyboardResizeBy:a=null,storage:l=ed,style:c,tagName:d="div",...f}){const p=My(o),[g,v]=Np(null),[y,x]=Np([]),w=ei({}),S=ei(new Map),C=ei(0),P=ei({autoSaveId:e,direction:r,dragState:g,id:p,keyboardResizeBy:a,onLayout:s,storage:l}),O=ei({layout:y,panelDataArray:[],panelDataArrayChanged:!1});ei({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),vM(i,()=>({getId:()=>P.current.id,getLayout:()=>{const{layout:D}=O.current;return D},setLayout:D=>{const{onLayout:W}=P.current,{layout:re,panelDataArray:N}=O.current,ne=RM({layout:D,panelConstraints:N.map(me=>me.constraints)});EM(re,ne)||(x(ne),O.current.layout=ne,W&&W(ne),Vl(N,ne,w.current))}}),[]),Xu(()=>{P.current.autoSaveId=e,P.current.direction=r,P.current.dragState=g,P.current.id=p,P.current.onLayout=s,P.current.storage=l}),YX({committedValuesRef:P,eagerValuesRef:O,groupId:p,layout:y,panelDataArray:O.current.panelDataArray,setLayout:x}),Sa(()=>{const{panelDataArray:D}=O.current;if(e){if(y.length===0||y.length!==D.length)return;let W=LM[e];W==null&&(W=eQ(nQ,rQ),LM[e]=W);const re=[...D],N=new Map(S.current);W(e,re,N,y,l)}},[e,y,l]),Sa(()=>{});const k=Rr(D=>{const{onLayout:W}=P.current,{layout:re,panelDataArray:N}=O.current;if(D.constraints.collapsible){const ne=N.map(ie=>ie.constraints),{collapsedSize:me=0,panelSize:he,pivotIndices:de}=Wl(N,D,re);if(st(he!=null),he!==me){S.current.set(D.id,he);const ee=Hl(N,D)===N.length-1?he-me:me-he,H=Zu({delta:ee,layout:re,panelConstraints:ne,pivotIndices:de,trigger:"imperative-api"});$p(re,H)||(x(H),O.current.layout=H,W&&W(H),Vl(N,H,w.current))}}},[]),A=Rr(D=>{const{onLayout:W}=P.current,{layout:re,panelDataArray:N}=O.current;if(D.constraints.collapsible){const ne=N.map(ee=>ee.constraints),{collapsedSize:me=0,panelSize:he,minSize:de=0,pivotIndices:ie}=Wl(N,D,re);if(he===me){const ee=S.current.get(D.id),H=ee!=null&&ee>=de?ee:de,oe=Hl(N,D)===N.length-1?he-H:H-he,Te=Zu({delta:oe,layout:re,panelConstraints:ne,pivotIndices:ie,trigger:"imperative-api"});$p(re,Te)||(x(Te),O.current.layout=Te,W&&W(Te),Vl(N,Te,w.current))}}},[]),L=Rr(D=>{const{layout:W,panelDataArray:re}=O.current,{panelSize:N}=Wl(re,D,W);return st(N!=null),N},[]),F=Rr((D,W)=>{const{panelDataArray:re}=O.current,N=Hl(re,D);return ZX({defaultSize:W,dragState:g,layout:y,panelData:re,panelIndex:N})},[g,y]),z=Rr(D=>{const{layout:W,panelDataArray:re}=O.current,{collapsedSize:N=0,collapsible:ne,panelSize:me}=Wl(re,D,W);return ne===!0&&me===N},[]),B=Rr(D=>{const{layout:W,panelDataArray:re}=O.current,{collapsedSize:N=0,collapsible:ne,panelSize:me}=Wl(re,D,W);return st(me!=null),!ne||me>N},[]),V=Rr(D=>{const{panelDataArray:W}=O.current;W.push(D),W.sort((re,N)=>{const ne=re.order,me=N.order;return ne==null&&me==null?0:ne==null?-1:me==null?1:ne-me}),O.current.panelDataArrayChanged=!0},[]);Xu(()=>{if(O.current.panelDataArrayChanged){O.current.panelDataArrayChanged=!1;const{autoSaveId:D,onLayout:W,storage:re}=P.current,{layout:N,panelDataArray:ne}=O.current;let me=null;if(D){const de=tQ(D,ne,re);de&&(S.current=new Map(Object.entries(de.expandToSizes)),me=de.layout)}me==null&&(me=QX({panelDataArray:ne}));const he=RM({layout:me,panelConstraints:ne.map(de=>de.constraints)});EM(N,he)||(x(he),O.current.layout=he,W&&W(he),Vl(ne,he,w.current))}});const X=Rr(D=>function(re){re.preventDefault();const{direction:N,dragState:ne,id:me,keyboardResizeBy:he,onLayout:de}=P.current,{layout:ie,panelDataArray:ee}=O.current,{initialLayout:H}=ne??{},ye=SM(me,D);let oe=XX(re,D,N,ne,he);if(oe===0)return;const Te=N==="horizontal";document.dir==="rtl"&&Te&&(oe=-oe);const Fe=ee.map(St=>St.constraints),He=Zu({delta:oe,layout:H??ie,panelConstraints:Fe,pivotIndices:ye,trigger:OM(re)?"keyboard":"mouse-or-touch"}),Ke=!$p(ie,He);(PM(re)||kM(re))&&C.current!=oe&&(C.current=oe,Ty(Ke?Te?"horizontal":"vertical":Te?oe<0?"horizontal-min":"horizontal-max":oe<0?"vertical-min":"vertical-max")),Ke&&(x(He),O.current.layout=He,de&&de(He),Vl(ee,He,w.current))},[]),K=Rr((D,W)=>{const{onLayout:re}=P.current,{layout:N,panelDataArray:ne}=O.current,me=ne.map(ye=>ye.constraints),{panelSize:he,pivotIndices:de}=Wl(ne,D,N);st(he!=null);const ee=Hl(ne,D)===ne.length-1?he-W:W-he,H=Zu({delta:ee,layout:N,panelConstraints:me,pivotIndices:de,trigger:"imperative-api"});$p(N,H)||(x(H),O.current.layout=H,re&&re(H),Vl(ne,H,w.current))},[]),$=Rr((D,W)=>{const{direction:re}=P.current,{layout:N}=O.current,ne=Lp(D);st(ne);const me=MM(re,W);v({dragHandleId:D,dragHandleRect:ne.getBoundingClientRect(),initialCursorPosition:me,initialLayout:N})},[]),J=Rr(()=>{JX(),v(null)},[]),G=Rr(D=>{const{panelDataArray:W}=O.current,re=Hl(W,D);re>=0&&(W.splice(re,1),delete w.current[D.id],O.current.panelDataArrayChanged=!0)},[]),q=HX(()=>({collapsePanel:k,direction:r,dragState:g,expandPanel:A,getPanelSize:L,getPanelStyle:F,groupId:p,isPanelCollapsed:z,isPanelExpanded:B,registerPanel:V,registerResizeHandle:X,resizePanel:K,startDragging:$,stopDragging:J,unregisterPanel:G}),[k,g,r,A,L,F,p,z,B,V,X,K,$,J,G]),se={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return zl(Rp.Provider,{value:q},zl(d,{...f,children:t,className:n,style:{...se,...c},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":p}))}const FM=gM((e,t)=>zl($M,{...e,forwardedRef:t}));$M.displayName="PanelGroup",FM.displayName="forwardRef(PanelGroup)";function Hl(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Wl(e,t,n){const r=e.map(c=>c.constraints),i=Hl(e,t),o=r[i],a=i===e.length-1?[i-1,i]:[i,i+1],l=n[i];return{...o,panelSize:l,pivotIndices:a}}function iQ({disabled:e,handleId:t,resizeHandler:n}){Sa(()=>{if(e||n==null)return;const r=Lp(t);if(r==null)return;const i=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{o.preventDefault(),n(o);break}case"F6":{o.preventDefault();const s=r.getAttribute("data-panel-group-id");st(s);const a=Ju(s),l=_M(s,t);st(l!==null);const c=o.shiftKey?l>0?l-1:a.length-1:l+1<a.length?l+1:0;a[c].focus();break}}};return r.addEventListener("keydown",i),()=>{r.removeEventListener("keydown",i)}},[e,t,n])}function jM({children:e=null,className:t="",disabled:n=!1,id:r,onDragging:i,style:o={},tabIndex:s=0,tagName:a="div",...l}){const c=ei(null),d=ei({onDragging:i});Sa(()=>{d.current.onDragging=i});const f=mM(Rp);if(f===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:p,dragState:g,groupId:v,registerResizeHandle:y,startDragging:x,stopDragging:w}=f,S=My(r),C=(g==null?void 0:g.dragHandleId)===S,[P,O]=Np(!1),[k,A]=Np(null),L=Rr(()=>{const z=c.current;st(z),z.blur(),w();const{onDragging:B}=d.current;B&&B(!1)},[w]);Sa(()=>{if(n)A(null);else{const z=y(S);A(()=>z)}},[n,S,y]),Sa(()=>{if(n||k==null||!C)return;const z=K=>{k(K)},B=K=>{k(K)},V=c.current;st(V);const X=V.ownerDocument;return X.body.addEventListener("contextmenu",L),X.body.addEventListener("mousemove",z),X.body.addEventListener("touchmove",z),X.body.addEventListener("mouseleave",B),window.addEventListener("mouseup",L),window.addEventListener("touchend",L),()=>{X.body.removeEventListener("contextmenu",L),X.body.removeEventListener("mousemove",z),X.body.removeEventListener("touchmove",z),X.body.removeEventListener("mouseleave",B),window.removeEventListener("mouseup",L),window.removeEventListener("touchend",L)}},[p,n,C,k,L]),iQ({disabled:n,handleId:S,resizeHandler:k});const F={cursor:DM(p),touchAction:"none",userSelect:"none"};return zl(a,{...l,children:e,className:t,onBlur:()=>O(!1),onFocus:()=>O(!0),onMouseDown:z=>{x(S,z.nativeEvent);const B=d.current;st(B);const{onDragging:V}=B;V&&V(!0)},onMouseUp:L,onTouchCancel:L,onTouchEnd:L,onTouchStart:z=>{x(S,z.nativeEvent);const B=d.current;st(B);const{onDragging:V}=B;V&&V(!0)},ref:c,role:"separator",style:{...F,...o},tabIndex:s,"data-panel-group-direction":p,"data-panel-group-id":v,"data-resize-handle":"","data-resize-handle-active":C?"pointer":P?"keyboard":void 0,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":S})}jM.displayName="PanelResizeHandle";const zM=({className:e,...t})=>_.jsx(FM,{className:Pe("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),Fp=xM,BM=({withHandle:e,className:t,...n})=>_.jsx(jM,{className:Pe("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&_.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:_.jsx(XB,{className:"h-2.5 w-2.5"})})});function oQ(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function VM(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 HM(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?VM(Object(n),!0).forEach(function(r){oQ(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):VM(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function sQ(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 aQ(e,t){if(e==null)return{};var n=sQ(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 lQ(e,t){return cQ(e)||uQ(e,t)||dQ(e,t)||fQ()}function cQ(e){if(Array.isArray(e))return e}function uQ(e,t){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(e)))){var n=[],r=!0,i=!1,o=void 0;try{for(var s=e[Symbol.iterator](),a;!(r=(a=s.next()).done)&&(n.push(a.value),!(t&&n.length===t));r=!0);}catch(l){i=!0,o=l}finally{try{!r&&s.return!=null&&s.return()}finally{if(i)throw o}}return n}}function dQ(e,t){if(e){if(typeof e=="string")return WM(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return WM(e,t)}}function WM(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function fQ(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
428
+ border-b-muted py-2 px-4 `,role:"dashboard-controls",children:[_.jsxs("div",{className:"flex gap-3 items-center",children:[_.jsx(ns,{children:e}),!!e&&_.jsxs(_.Fragment,{children:[_.jsx("span",{className:" text-muted-foreground",children:"|"}),_.jsx(KK,{})]})]}),_.jsxs("div",{className:"flex gap-2",children:[r&&!i&&_.jsx(jK,{}),!i&&_.jsx(zK,{}),r&&!i&&_.jsxs(it,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!r,onClick:x,children:[_.jsx(eV,{className:" mr-2 h-4 w-4",strokeWidth:1.5}),"Add Card"]}),!r&&_.jsx(it,{variant:"outline",className:"h-7 p-2",onClick:w,size:"sm",children:_.jsx(ZB,{className:"h-4 w-4",strokeWidth:1.5})}),r&&!i&&_.jsx(it,{variant:"outline",role:"close",className:"h-7 p-2",onClick:()=>p(!1),size:"sm",children:_.jsx(ia,{className:"h-4 w-4",strokeWidth:1.5})}),r&&!i&&_.jsx(it,{className:"h-7 p-2",variant:"outline",onClick:S,size:"sm",children:_.jsx(tV,{className:"h-4 w-4",strokeWidth:1.5})}),!o&&!i&&r&&_.jsx(it,{className:"h-7 p-2",variant:"outline",onClick:()=>c(!0),size:"sm",children:_.jsx(W2,{className:"h-4 w-4",strokeWidth:1.5})}),!i&&r&&_.jsx("div",{className:" flex items-center space-x-2",children:_.jsx(it,{className:"h-7 p-2",onClick:()=>a(!s),size:"sm",variant:"outline",children:_.jsx(YB,{className:"h-4 w-4",strokeWidth:1.5})})}),_.jsx(gK,{})]})]})}const Bk=m.forwardRef(({className:e,...t},n)=>_.jsx("div",{role:"editor-panel",ref:n,className:Pe("flex grow min-h-[80vh]",e),...t}));Bk.displayName="EditorPanel";const Vk=m.forwardRef(({className:e,...t},n)=>_.jsx("div",{ref:n,className:Pe(" flex flex-col space-y-2 w-[270px]",e),...t}));Vk.displayName="EditorAside";const Hk=m.forwardRef(({className:e,...t},n)=>_.jsx("div",{ref:n,className:Pe(" grow",e),...t}));Hk.displayName="EditorMain";const QK=[" ","Enter","ArrowUp","ArrowDown"],ZK=[" ","Enter"],kp="Select",[Mp,Dp,JK]=uf(kp),[Fl,afe]=Pn(kp,[JK,Fi]),Cy=Fi(),[eX,xa]=Fl(kp),[tX,nX]=Fl(kp),rX=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:o,value:s,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:f,disabled:p,required:g}=e,v=Cy(t),[y,x]=m.useState(null),[w,S]=m.useState(null),[C,P]=m.useState(!1),O=Fs(c),[k=!1,A]=Qn({prop:r,defaultProp:i,onChange:o}),[L,F]=Qn({prop:s,defaultProp:a,onChange:l}),z=m.useRef(null),B=y?!!y.closest("form"):!0,[V,X]=m.useState(new Set),K=Array.from(V).map($=>$.props.value).join(";");return m.createElement(Cu,v,m.createElement(eX,{required:g,scope:t,trigger:y,onTriggerChange:x,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:C,onValueNodeHasChildrenChange:P,contentId:or(),value:L,onValueChange:F,open:k,onOpenChange:A,dir:O,triggerPointerDownPosRef:z,disabled:p},m.createElement(Mp.Provider,{scope:t},m.createElement(tX,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback($=>{X(J=>new Set(J).add($))},[]),onNativeOptionRemove:m.useCallback($=>{X(J=>{const G=new Set(J);return G.delete($),G})},[])},n)),B?m.createElement(Zk,{key:K,"aria-hidden":!0,required:g,tabIndex:-1,name:d,autoComplete:f,value:L,onChange:$=>F($.target.value),disabled:p},L===void 0?m.createElement("option",{value:""}):null,Array.from(V)):null))},iX="SelectTrigger",oX=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...i}=e,o=Cy(n),s=xa(iX,n),a=s.disabled||r,l=et(t,s.onTriggerChange),c=Dp(n),[d,f,p]=Jk(v=>{const y=c().filter(S=>!S.disabled),x=y.find(S=>S.value===s.value),w=eM(y,v,x);w!==void 0&&s.onValueChange(w.value)}),g=()=>{a||(s.onOpenChange(!0),p())};return m.createElement(Eu,le({asChild:!0},o),m.createElement(Be.button,le({type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Qk(s.value)?"":void 0},i,{ref:l,onClick:Ce(i.onClick,v=>{v.currentTarget.focus()}),onPointerDown:Ce(i.onPointerDown,v=>{const y=v.target;y.hasPointerCapture(v.pointerId)&&y.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&(g(),s.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)},v.preventDefault())}),onKeyDown:Ce(i.onKeyDown,v=>{const y=d.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&f(v.key),!(y&&v.key===" ")&&QK.includes(v.key)&&(g(),v.preventDefault())})})))}),sX="SelectValue",aX=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,children:o,placeholder:s="",...a}=e,l=xa(sX,n),{onValueNodeHasChildrenChange:c}=l,d=o!==void 0,f=et(t,l.onValueNodeChange);return Vn(()=>{c(d)},[c,d]),m.createElement(Be.span,le({},a,{ref:f,style:{pointerEvents:"none"}}),Qk(l.value)?m.createElement(m.Fragment,null,s):o)}),lX=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...i}=e;return m.createElement(Be.span,le({"aria-hidden":!0},i,{ref:t}),r||"▼")}),cX=e=>m.createElement(Dh,le({asChild:!0},e)),jl="SelectContent",uX=m.forwardRef((e,t)=>{const n=xa(jl,e.__scopeSelect),[r,i]=m.useState();if(Vn(()=>{i(new DocumentFragment)},[]),!n.open){const o=r;return o?kt.createPortal(m.createElement(Wk,{scope:e.__scopeSelect},m.createElement(Mp.Slot,{scope:e.__scopeSelect},m.createElement("div",null,e.children))),o):null}return m.createElement(dX,le({},e,{ref:t}))}),_o=10,[Wk,wa]=Fl(jl),dX=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:o,onPointerDownOutside:s,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:g,sticky:v,hideWhenDetached:y,avoidCollisions:x,...w}=e,S=xa(jl,n),[C,P]=m.useState(null),[O,k]=m.useState(null),A=et(t,de=>P(de)),[L,F]=m.useState(null),[z,B]=m.useState(null),V=Dp(n),[X,K]=m.useState(!1),$=m.useRef(!1);m.useEffect(()=>{if(C)return ap(C)},[C]),rp();const J=m.useCallback(de=>{const[ie,...ee]=V().map(oe=>oe.ref.current),[H]=ee.slice(-1),ye=document.activeElement;for(const oe of de)if(oe===ye||(oe==null||oe.scrollIntoView({block:"nearest"}),oe===ie&&O&&(O.scrollTop=0),oe===H&&O&&(O.scrollTop=O.scrollHeight),oe==null||oe.focus(),document.activeElement!==ye))return},[V,O]),G=m.useCallback(()=>J([L,C]),[J,L,C]);m.useEffect(()=>{X&&G()},[X,G]);const{onOpenChange:q,triggerPointerDownPosRef:se}=S;m.useEffect(()=>{if(C){let de={x:0,y:0};const ie=H=>{var ye,oe,Te,Fe;de={x:Math.abs(Math.round(H.pageX)-((ye=(oe=se.current)===null||oe===void 0?void 0:oe.x)!==null&&ye!==void 0?ye:0)),y:Math.abs(Math.round(H.pageY)-((Te=(Fe=se.current)===null||Fe===void 0?void 0:Fe.y)!==null&&Te!==void 0?Te:0))}},ee=H=>{de.x<=10&&de.y<=10?H.preventDefault():C.contains(H.target)||q(!1),document.removeEventListener("pointermove",ie),se.current=null};return se.current!==null&&(document.addEventListener("pointermove",ie),document.addEventListener("pointerup",ee,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ie),document.removeEventListener("pointerup",ee,{capture:!0})}}},[C,q,se]),m.useEffect(()=>{const de=()=>q(!1);return window.addEventListener("blur",de),window.addEventListener("resize",de),()=>{window.removeEventListener("blur",de),window.removeEventListener("resize",de)}},[q]);const[D,W]=Jk(de=>{const ie=V().filter(ye=>!ye.disabled),ee=ie.find(ye=>ye.ref.current===document.activeElement),H=eM(ie,de,ee);H&&setTimeout(()=>H.ref.current.focus())}),re=m.useCallback((de,ie,ee)=>{const H=!$.current&&!ee;(S.value!==void 0&&S.value===ie||H)&&(F(de),H&&($.current=!0))},[S.value]),N=m.useCallback(()=>C==null?void 0:C.focus(),[C]),ne=m.useCallback((de,ie,ee)=>{const H=!$.current&&!ee;(S.value!==void 0&&S.value===ie||H)&&B(de)},[S.value]),me=r==="popper"?qk:fX,he=me===qk?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:g,sticky:v,hideWhenDetached:y,avoidCollisions:x}:{};return m.createElement(Wk,{scope:n,content:C,viewport:O,onViewportChange:k,itemRefCallback:re,selectedItem:L,onItemLeave:N,itemTextRefCallback:ne,focusSelectedItem:G,selectedItemText:z,position:r,isPositioned:X,searchRef:D},m.createElement(hp,{as:no,allowPinchZoom:!0},m.createElement(ip,{asChild:!0,trapped:S.open,onMountAutoFocus:de=>{de.preventDefault()},onUnmountAutoFocus:Ce(i,de=>{var ie;(ie=S.trigger)===null||ie===void 0||ie.focus({preventScroll:!0}),de.preventDefault()})},m.createElement(_l,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:de=>de.preventDefault(),onDismiss:()=>S.onOpenChange(!1)},m.createElement(me,le({role:"listbox",id:S.contentId,"data-state":S.open?"open":"closed",dir:S.dir,onContextMenu:de=>de.preventDefault()},w,he,{onPlaced:()=>K(!0),ref:A,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:Ce(w.onKeyDown,de=>{const ie=de.ctrlKey||de.altKey||de.metaKey;if(de.key==="Tab"&&de.preventDefault(),!ie&&de.key.length===1&&W(de.key),["ArrowUp","ArrowDown","Home","End"].includes(de.key)){let H=V().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);if(["ArrowUp","End"].includes(de.key)&&(H=H.slice().reverse()),["ArrowUp","ArrowDown"].includes(de.key)){const ye=de.target,oe=H.indexOf(ye);H=H.slice(oe+1)}setTimeout(()=>J(H)),de.preventDefault()}})}))))))}),fX=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...i}=e,o=xa(jl,n),s=wa(jl,n),[a,l]=m.useState(null),[c,d]=m.useState(null),f=et(t,A=>d(A)),p=Dp(n),g=m.useRef(!1),v=m.useRef(!0),{viewport:y,selectedItem:x,selectedItemText:w,focusSelectedItem:S}=s,C=m.useCallback(()=>{if(o.trigger&&o.valueNode&&a&&c&&y&&x&&w){const A=o.trigger.getBoundingClientRect(),L=c.getBoundingClientRect(),F=o.valueNode.getBoundingClientRect(),z=w.getBoundingClientRect();if(o.dir!=="rtl"){const ye=z.left-L.left,oe=F.left-ye,Te=A.left-oe,Fe=A.width+Te,He=Math.max(Fe,L.width),Ke=window.innerWidth-_o,St=l0(oe,[_o,Ke-He]);a.style.minWidth=Fe+"px",a.style.left=St+"px"}else{const ye=L.right-z.right,oe=window.innerWidth-F.right-ye,Te=window.innerWidth-A.right-oe,Fe=A.width+Te,He=Math.max(Fe,L.width),Ke=window.innerWidth-_o,St=l0(oe,[_o,Ke-He]);a.style.minWidth=Fe+"px",a.style.right=St+"px"}const B=p(),V=window.innerHeight-_o*2,X=y.scrollHeight,K=window.getComputedStyle(c),$=parseInt(K.borderTopWidth,10),J=parseInt(K.paddingTop,10),G=parseInt(K.borderBottomWidth,10),q=parseInt(K.paddingBottom,10),se=$+J+X+q+G,D=Math.min(x.offsetHeight*5,se),W=window.getComputedStyle(y),re=parseInt(W.paddingTop,10),N=parseInt(W.paddingBottom,10),ne=A.top+A.height/2-_o,me=V-ne,he=x.offsetHeight/2,de=x.offsetTop+he,ie=$+J+de,ee=se-ie;if(ie<=ne){const ye=x===B[B.length-1].ref.current;a.style.bottom="0px";const oe=c.clientHeight-y.offsetTop-y.offsetHeight,Te=Math.max(me,he+(ye?N:0)+oe+G),Fe=ie+Te;a.style.height=Fe+"px"}else{const ye=x===B[0].ref.current;a.style.top="0px";const Te=Math.max(ne,$+y.offsetTop+(ye?re:0)+he)+ee;a.style.height=Te+"px",y.scrollTop=ie-ne+y.offsetTop}a.style.margin=`${_o}px 0`,a.style.minHeight=D+"px",a.style.maxHeight=V+"px",r==null||r(),requestAnimationFrame(()=>g.current=!0)}},[p,o.trigger,o.valueNode,a,c,y,x,w,o.dir,r]);Vn(()=>C(),[C]);const[P,O]=m.useState();Vn(()=>{c&&O(window.getComputedStyle(c).zIndex)},[c]);const k=m.useCallback(A=>{A&&v.current===!0&&(C(),S==null||S(),v.current=!1)},[C,S]);return m.createElement(hX,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:g,onScrollButtonChange:k},m.createElement("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:P}},m.createElement(Be.div,le({},i,{ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}}))))}),qk=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=_o,...o}=e,s=Cy(n);return m.createElement(Ou,le({},s,o,{ref:t,align:r,collisionPadding:i,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}}))}),[hX,Ey]=Fl(jl,{}),Uk="SelectViewport",pX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=wa(Uk,n),o=Ey(Uk,n),s=et(t,i.onViewportChange),a=m.useRef(0);return m.createElement(m.Fragment,null,m.createElement("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"}}),m.createElement(Mp.Slot,{scope:n},m.createElement(Be.div,le({"data-radix-select-viewport":"",role:"presentation"},r,{ref:s,style:{position:"relative",flex:1,overflow:"auto",...r.style},onScroll:Ce(r.onScroll,l=>{const c=l.currentTarget,{contentWrapper:d,shouldExpandOnScrollRef:f}=o;if(f!=null&&f.current&&d){const p=Math.abs(a.current-c.scrollTop);if(p>0){const g=window.innerHeight-_o*2,v=parseFloat(d.style.minHeight),y=parseFloat(d.style.height),x=Math.max(v,y);if(x<g){const w=x+p,S=Math.min(g,w),C=w-S;d.style.height=S+"px",d.style.bottom==="0px"&&(c.scrollTop=C>0?C:0,d.style.justifyContent="flex-end")}}}a.current=c.scrollTop})}))))}),gX="SelectGroup",[mX,vX]=Fl(gX),bX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=or();return m.createElement(mX,{scope:n,id:i},m.createElement(Be.div,le({role:"group","aria-labelledby":i},r,{ref:t})))}),yX="SelectLabel",xX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=vX(yX,n);return m.createElement(Be.div,le({id:i.id},r,{ref:t}))}),Oy="SelectItem",[wX,Gk]=Fl(Oy),_X=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:i=!1,textValue:o,...s}=e,a=xa(Oy,n),l=wa(Oy,n),c=a.value===r,[d,f]=m.useState(o??""),[p,g]=m.useState(!1),v=et(t,w=>{var S;return(S=l.itemRefCallback)===null||S===void 0?void 0:S.call(l,w,r,i)}),y=or(),x=()=>{i||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return m.createElement(wX,{scope:n,value:r,disabled:i,textId:y,isSelected:c,onItemTextChange:m.useCallback(w=>{f(S=>{var C;return S||((C=w==null?void 0:w.textContent)!==null&&C!==void 0?C:"").trim()})},[])},m.createElement(Mp.ItemSlot,{scope:n,value:r,disabled:i,textValue:d},m.createElement(Be.div,le({role:"option","aria-labelledby":y,"data-highlighted":p?"":void 0,"aria-selected":c&&p,"data-state":c?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1},s,{ref:v,onFocus:Ce(s.onFocus,()=>g(!0)),onBlur:Ce(s.onBlur,()=>g(!1)),onPointerUp:Ce(s.onPointerUp,x),onPointerMove:Ce(s.onPointerMove,w=>{if(i){var S;(S=l.onItemLeave)===null||S===void 0||S.call(l)}else w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ce(s.onPointerLeave,w=>{if(w.currentTarget===document.activeElement){var S;(S=l.onItemLeave)===null||S===void 0||S.call(l)}}),onKeyDown:Ce(s.onKeyDown,w=>{var S;((S=l.searchRef)===null||S===void 0?void 0:S.current)!==""&&w.key===" "||(ZK.includes(w.key)&&x(),w.key===" "&&w.preventDefault())})}))))}),Tp="SelectItemText",SX=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,...o}=e,s=xa(Tp,n),a=wa(Tp,n),l=Gk(Tp,n),c=nX(Tp,n),[d,f]=m.useState(null),p=et(t,w=>f(w),l.onItemTextChange,w=>{var S;return(S=a.itemTextRefCallback)===null||S===void 0?void 0:S.call(a,w,l.value,l.disabled)}),g=d==null?void 0:d.textContent,v=m.useMemo(()=>m.createElement("option",{key:l.value,value:l.value,disabled:l.disabled},g),[l.disabled,l.value,g]),{onNativeOptionAdd:y,onNativeOptionRemove:x}=c;return Vn(()=>(y(v),()=>x(v)),[y,x,v]),m.createElement(m.Fragment,null,m.createElement(Be.span,le({id:l.textId},o,{ref:p})),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren?kt.createPortal(o.children,s.valueNode):null)}),CX="SelectItemIndicator",EX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Gk(CX,n).isSelected?m.createElement(Be.span,le({"aria-hidden":!0},r,{ref:t})):null}),Yk="SelectScrollUpButton",OX=m.forwardRef((e,t)=>{const n=wa(Yk,e.__scopeSelect),r=Ey(Yk,e.__scopeSelect),[i,o]=m.useState(!1),s=et(t,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const c=a.scrollTop>0;o(c)};const a=n.viewport;return l(),a.addEventListener("scroll",l),()=>a.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?m.createElement(Xk,le({},e,{ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}})):null}),Kk="SelectScrollDownButton",PX=m.forwardRef((e,t)=>{const n=wa(Kk,e.__scopeSelect),r=Ey(Kk,e.__scopeSelect),[i,o]=m.useState(!1),s=et(t,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const c=a.scrollHeight-a.clientHeight,d=Math.ceil(a.scrollTop)<c;o(d)};const a=n.viewport;return l(),a.addEventListener("scroll",l),()=>a.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?m.createElement(Xk,le({},e,{ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}})):null}),Xk=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...i}=e,o=wa("SelectScrollButton",n),s=m.useRef(null),a=Dp(n),l=m.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),Vn(()=>{var c;const d=a().find(f=>f.ref.current===document.activeElement);d==null||(c=d.ref.current)===null||c===void 0||c.scrollIntoView({block:"nearest"})},[a]),m.createElement(Be.div,le({"aria-hidden":!0},i,{ref:t,style:{flexShrink:0,...i.style},onPointerDown:Ce(i.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:Ce(i.onPointerMove,()=>{var c;(c=o.onItemLeave)===null||c===void 0||c.call(o),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:Ce(i.onPointerLeave,()=>{l()})}))}),kX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return m.createElement(Be.div,le({"aria-hidden":!0},r,{ref:t}))});function Qk(e){return e===""||e===void 0}const Zk=m.forwardRef((e,t)=>{const{value:n,...r}=e,i=m.useRef(null),o=et(t,i),s=Op(n);return m.useEffect(()=>{const a=i.current,l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(s!==n&&d){const f=new Event("change",{bubbles:!0});d.call(a,n),a.dispatchEvent(f)}},[s,n]),m.createElement(T2,{asChild:!0},m.createElement("select",le({},r,{ref:o,defaultValue:n})))});Zk.displayName="BubbleSelect";function Jk(e){const t=xn(e),n=m.useRef(""),r=m.useRef(0),i=m.useCallback(s=>{const a=n.current+s;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),o=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,o]}function eM(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let s=MX(e,Math.max(o,0));i.length===1&&(s=s.filter(c=>c!==n));const l=s.find(c=>c.textValue.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function MX(e,t){return e.map((n,r)=>e[(t+r)%e.length])}const DX=rX,tM=oX,TX=aX,AX=lX,IX=cX,nM=uX,NX=pX,RX=bX,rM=xX,iM=_X,LX=SX,$X=EX,oM=OX,sM=PX,aM=kX,lM=DX,cM=RX,uM=TX,Py=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsxs(tM,{ref:r,className:Pe("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,_.jsx(AX,{asChild:!0,children:_.jsx(Wb,{className:"h-4 w-4 opacity-50"})})]}));Py.displayName=tM.displayName;const dM=ue.forwardRef(({className:e,...t},n)=>_.jsx(oM,{ref:n,className:Pe("flex cursor-default items-center justify-center py-1",e),...t,children:_.jsx(GB,{className:"h-4 w-4"})}));dM.displayName=oM.displayName;const fM=ue.forwardRef(({className:e,...t},n)=>_.jsx(sM,{ref:n,className:Pe("flex cursor-default items-center justify-center py-1",e),...t,children:_.jsx(Wb,{className:"h-4 w-4"})}));fM.displayName=sM.displayName;const ky=ue.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>_.jsx(IX,{children:_.jsxs(nM,{ref:i,className:Pe("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[_.jsx(dM,{}),_.jsx(NX,{className:Pe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),_.jsx(fM,{})]})}));ky.displayName=nM.displayName;const Ap=ue.forwardRef(({className:e,...t},n)=>_.jsx(rM,{ref:n,className:Pe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Ap.displayName=rM.displayName;const _a=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsxs(iM,{ref:r,className:Pe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[_.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:_.jsx($X,{children:_.jsx(Rh,{className:"h-4 w-4"})})}),_.jsx(LX,{children:t})]}));_a.displayName=iM.displayName;const FX=ue.forwardRef(({className:e,...t},n)=>_.jsx(aM,{ref:n,className:Pe("-mx-1 my-1 h-px bg-muted",e),...t}));FX.displayName=aM.displayName;function Ip({title:e,items:t,value:n,isLoading:r,isError:i,onChange:o}){const s=r?"Loading...":i?"Error":n;function a(){if(e==="Connection")return _.jsx(JB,{className:" rotate-90",strokeWidth:1,size:16});if(e==="Database")return _.jsx(KB,{strokeWidth:1,size:16});if(e==="Schema")return _.jsx(iV,{strokeWidth:1,size:16});if(e==="Table")return _.jsx(qb,{strokeWidth:1,size:16})}return _.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx("div",{className:" shrink-0",children:a()}),_.jsxs(lM,{value:s,onValueChange:o,children:[_.jsx(Py,{className:"focus:ring-offset-0 focus:ring-1 h-7 w-[190px] ",children:_.jsx(uM,{placeholder:r?"Loading...":i?"Error":`Select ${e}`})}),_.jsx(ky,{children:_.jsxs(cM,{children:[r?_.jsx(Ap,{children:"Loading..."}):_.jsx(Ap,{children:e}),_.jsx(_.Fragment,{children:t&&t.map(l=>_.jsx(_a,{value:l.id,children:l.name},l.id))}),(r||i)&&_.jsx(_a,{value:s,children:s})]})})]})]})}function jX({column:e}){const[t,n]=m.useState(!1),r=_e(d=>d.selectedTableName),i=_e(d=>d.selectedSchemaName),o=_e(d=>d.sqlGen),s=_e(d=>d.actions.setSqlGen),a=_e(d=>d.actions.setCardSql),l=_e(d=>d.actions.setRunSql);function c(d,f){const p=WO(d,o,f);s(p);const g=HO(p,i||"",r);g&&(a(g),l(!0)),n(!1)}return _.jsxs(pp,{open:t,onOpenChange:n,children:[_.jsx(gp,{asChild:!0,children:_.jsx(Hj,{className:"w-3 h-3 text-foreground/40 cursor-pointer"})}),_.jsx(Wu,{align:"center",className:" p-0 w-18 rounded-none shadow-none border-muted",children:_.jsxs("ul",{className:"text-xs ",children:[_.jsx("li",{onClick:()=>c(e,"COUNT"),className:" px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Count"}),_.jsx("li",{onClick:()=>c(e,"AVG"),className:" px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Avg"}),_.jsx("li",{onClick:()=>c(e,"SUM"),className:"px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Sum"}),_.jsx("li",{onClick:()=>c(e,"MAX"),className:"px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Max"}),_.jsx("li",{onClick:()=>c(e,"MIN"),className:"px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Min"})]})})]})}function hM({column:e}){return _.jsxs(Vb,{children:[_.jsx(I2,{asChild:!0,children:P0.includes(e.data_type.toLowerCase())?_.jsx("span",{className:" font-thin",children:"T"}):Tl.includes(e.data_type.toLowerCase())?_.jsx("span",{className:" font-thin",children:"#"}):Iu.includes(e.data_type.toLowerCase())?_.jsx("span",{className:" font-thin",children:"D"}):VO.includes(e.data_type.toLowerCase())?_.jsx("span",{className:" font-thin",children:"B"}):_.jsx("span",{className:" font-thin",children:"?"})}),_.jsx(Ih,{children:_.jsx("p",{className:"text-xs font-mono",children:e.data_type})})]})}function zX({schemaName:e,tableName:t,columns:n,status:r}){const i=_e(f=>f.sqlGen),o=_e(f=>f.actions.setRunSql),s=_e(f=>f.actions.setSqlGen),a=_e(f=>f.actions.setIsShowingVisual),l=_e(f=>f.actions.setCardSql);function c(f){const p=WO(f,i);s(p);const g=HO(p,e,t);g&&(l(g),o(!0))}function d(){const f=M0(e,t);a(!1),l(`SELECT * FROM ${f} LIMIT 10`),o(!0)}return _.jsxs("div",{className:"px-4",children:[_.jsx("div",{className:" font-medium px-2 pt-2 pb-3",children:_.jsxs(it,{disabled:r!=="Success",onClick:d,variant:"secondary",className:" h-7 flex w-full",children:[r!=="Success"&&_.jsx(ku,{className:" w-4 h-4 animate-spin mr-2 text-foreground/50"}),"Show top 10 rows"]})}),_.jsxs(kl,{className:`w-full ${t==="api"?"h-[74vh]":"h-[60vh]"}`,children:[n==null?void 0:n.map(f=>_.jsxs("div",{onClick:()=>c(f),className:Pe(" text-sm flex items-center justify-between px-3 py-[6px] transition-colors hover:bg-muted/50 cursor-pointer rounded ",{" bg-muted":BW(f,i)}),children:[_.jsxs("div",{className:"flex items-center space-x-2 ",children:[_.jsx(hM,{column:f}),_.jsx("span",{children:f.column_name})]}),Tl.includes(f.data_type)&&_.jsx("div",{onClick:p=>p.stopPropagation(),className:" flex items-center justify-end ",children:_.jsx(jX,{column:f})})]},f.column_name)),_.jsx(Hh,{orientation:"vertical"}),_.jsx(Hh,{orientation:"horizontal"})]})]})}function pM({ColumnsComponent:e}){const t=_e(K=>K.selectedConnectionId);_e(K=>K.card.sql);const n=_e(K=>K.selectedDatabaseName),r=_e(K=>K.selectedSchemaName),i=_e(K=>K.selectedTableName),o=_e(K=>K.actions.setSelectedConnectionId),s=_e(K=>K.actions.setSelectedDatabaseName),a=_e(K=>K.actions.setSelectedSchemaName),l=_e(K=>K.actions.setSelectedTableName),c=_e(K=>K.actions.setCardSql),{connectionItems:d,schemaItems:f,databaseItems:p,tableItems:g,columns:v,isConnectionsLoading:y,isConnectionsError:x,isDatabasesLoadingOrFetching:w,isDatabaseError:S,isSchemaLoadingOrFetching:C,isSchemaError:P,isColumnsError:O,isColumnsLoadingOrFetching:k,isAPIConnection:A}=iH();m.useEffect(()=>{A&&(s("NA"),a(""),l("api"))},[A,c,l,a,s]);const L=A?"api":i||"",F=A?"":r||"";function z(K){a(K),l("")}function B(K){s(K),a(""),l("")}function V(K){o(K)}function X(){return e?e(F,L,v):_.jsx(zX,{schemaName:F,tableName:L,columns:v,status:k?"Loading...":O?"Error":"Success"})}return _.jsxs("aside",{className:" grow flex flex-col xbg-red-100 ",children:[_.jsxs("section",{className:"space-y-3 pt-4 pb-3 px-6",children:[_.jsx(Ip,{items:d,title:"Connection",value:t||"",onChange:V,isLoading:y,isError:x}),!A&&_.jsxs(_.Fragment,{children:[_.jsx(Ip,{onChange:B,isError:S,isLoading:w,items:p,value:n||"",title:"Database"}),_.jsx(Ip,{onChange:z,isError:P,isLoading:C,items:f,value:r||"",title:"Schema"}),_.jsx(Ip,{onChange:l,isError:S,items:g,isLoading:w,value:i||"",title:"Table"})]})]}),X(),_.jsx("div",{className:" grow justify-end flex flex-col pt-6 "})]})}const{createElement:zl,createContext:BX,createRef:lfe,forwardRef:gM,useCallback:Rr,useContext:mM,useEffect:Sa,useImperativeHandle:vM,useLayoutEffect:VX,useMemo:HX,useRef:ei,useState:Np}=ue,bM=ue.useId,Rp=BX(null);Rp.displayName="PanelGroupContext";const Xu=VX,WX=typeof bM=="function"?bM:()=>null;let qX=0;function My(e=null){const t=WX(),n=ei(e||t||null);return n.current===null&&(n.current=""+qX++),e??n.current}function yM({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:o,id:s,maxSize:a,minSize:l,onCollapse:c,onExpand:d,onResize:f,order:p,style:g,tagName:v="div",...y}){const x=mM(Rp);if(x===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:w,expandPanel:S,getPanelSize:C,getPanelStyle:P,groupId:O,isPanelCollapsed:k,registerPanel:A,resizePanel:L,unregisterPanel:F}=x,z=My(s),B=ei({callbacks:{onCollapse:c,onExpand:d,onResize:f},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:a,minSize:l},id:z,idIsFromProps:s!==void 0,order:p});ei({didLogMissingDefaultSizeWarning:!1}),Xu(()=>{const{callbacks:X,constraints:K}=B.current;B.current.id=z,B.current.idIsFromProps=s!==void 0,B.current.order=p,X.onCollapse=c,X.onExpand=d,X.onResize=f,K.collapsedSize=n,K.collapsible=r,K.defaultSize=i,K.maxSize=a,K.minSize=l}),Xu(()=>{const X=B.current;return A(X),()=>{F(X)}},[p,z,A,F]),vM(o,()=>({collapse:()=>{w(B.current)},expand:()=>{S(B.current)},getId(){return z},getSize(){return C(B.current)},isCollapsed(){return k(B.current)},isExpanded(){return!k(B.current)},resize:X=>{L(B.current,X)}}),[w,S,C,k,z,L]);const V=P(B.current,i);return zl(v,{...y,children:e,className:t,style:{...V,...g},"data-panel":"","data-panel-id":z,"data-panel-group-id":O,"data-panel-collapsible":void 0,"data-panel-size":void 0})}const xM=gM((e,t)=>zl(yM,{...e,forwardedRef:t}));yM.displayName="Panel",xM.displayName="forwardRef(Panel)";function st(e,t="Assertion failed!"){if(!e)throw console.error(t),Error(t)}const wM=10;function Qu(e,t,n=wM){e=parseFloat(e.toFixed(n)),t=parseFloat(t.toFixed(n));const r=e-t;return r===0?0:r>0?1:-1}function Lr(e,t,n){return Qu(e,t,n)===0}function Bl({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];st(r!=null);let{collapsedSize:i=0,collapsible:o,maxSize:s=100,minSize:a=0}=r;if(Qu(n,a)<0)if(o){const l=(i+a)/2;Qu(n,l)<0?n=i:n=a}else n=a;return n=Math.min(s,n),n=parseFloat(n.toFixed(wM)),n}function Zu({delta:e,layout:t,panelConstraints:n,pivotIndices:r,trigger:i}){if(Lr(e,0))return t;const o=[...t],[s,a]=r;st(s!=null),st(a!=null);let l=0;if(i==="keyboard"){{const d=e<0?a:s,f=n[d];if(st(f),f.collapsible){const p=t[d];st(p!=null);const g=n[d];st(g);const{collapsedSize:v=0,minSize:y=0}=g;if(Lr(p,v)){const x=y-p;Qu(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const d=e<0?s:a,f=n[d];st(f);const{collapsible:p}=f;if(p){const g=t[d];st(g!=null);const v=n[d];st(v);const{collapsedSize:y=0,minSize:x=0}=v;if(Lr(g,x)){const w=g-y;Qu(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}}{const d=e<0?1:-1;let f=e<0?a:s,p=0;for(;;){const v=t[f];st(v!=null);const x=Bl({panelConstraints:n,panelIndex:f,size:100})-v;if(p+=x,f+=d,f<0||f>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let f=e<0?s:a;for(;f>=0&&f<n.length;){const p=Math.abs(e)-Math.abs(l),g=t[f];st(g!=null);const v=g-p,y=Bl({panelConstraints:n,panelIndex:f,size:v});if(!Lr(g,y)&&(l+=g-y,o[f]=y,l.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?f--:f++}}if(Lr(l,0))return t;{const d=e<0?a:s,f=t[d];st(f!=null);const p=f+l,g=Bl({panelConstraints:n,panelIndex:d,size:p});if(o[d]=g,!Lr(g,p)){let v=p-g,x=e<0?a:s;for(;x>=0&&x<n.length;){const w=o[x];st(w!=null);const S=w+v,C=Bl({panelConstraints:n,panelIndex:x,size:S});if(Lr(w,C)||(v-=C-w,o[x]=C),Lr(v,0))break;e>0?x--:x++}}}const c=o.reduce((d,f)=>f+d,0);return Lr(c,100)?o:t}function UX({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,o=0,s=0;const a=n[0];st(a!=null),t.forEach((f,p)=>{const{constraints:g}=f,{maxSize:v=100,minSize:y=0}=g;p===a?(r=y,i=v):(o+=y,s+=v)});const l=Math.min(i,100-o),c=Math.max(r,100-s),d=e[a];return{valueMax:l,valueMin:c,valueNow:d}}function Ju(e){return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function _M(e,t){const r=Ju(e).findIndex(i=>i.getAttribute("data-panel-resize-handle-id")===t);return r??null}function SM(e,t){const n=_M(e,t);return n!=null?[n,n+1]:[-1,-1]}function CM(e){const t=document.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return t||null}function Lp(e){const t=document.querySelector(`[data-panel-resize-handle-id="${e}"]`);return t||null}function GX(e,t,n){var r,i,o,s;const a=Lp(t),l=Ju(e),c=a?l.indexOf(a):-1,d=(r=(i=n[c])===null||i===void 0?void 0:i.id)!==null&&r!==void 0?r:null,f=(o=(s=n[c+1])===null||s===void 0?void 0:s.id)!==null&&o!==void 0?o:null;return[d,f]}function YX({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,setLayout:o}){ei({didWarnAboutMissingResizeHandle:!1}),Xu(()=>{const s=Ju(n);for(let a=0;a<i.length-1;a++){const{valueMax:l,valueMin:c,valueNow:d}=UX({layout:r,panelsArray:i,pivotIndices:[a,a+1]}),f=s[a];if(f!=null){const p=i[a];st(p),f.setAttribute("aria-controls",p.id),f.setAttribute("aria-valuemax",""+Math.round(l)),f.setAttribute("aria-valuemin",""+Math.round(c)),f.setAttribute("aria-valuenow",d!=null?""+Math.round(d):"")}}return()=>{s.forEach((a,l)=>{a.removeAttribute("aria-controls"),a.removeAttribute("aria-valuemax"),a.removeAttribute("aria-valuemin"),a.removeAttribute("aria-valuenow")})}},[n,r,i]),Sa(()=>{const s=t.current;st(s);const{panelDataArray:a}=s,l=CM(n);st(l!=null,`No group found for id "${n}"`);const c=Ju(n);st(c);const d=c.map(f=>{const p=f.getAttribute("data-panel-resize-handle-id");st(p);const[g,v]=GX(n,p,a);if(g==null||v==null)return()=>{};const y=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const w=a.findIndex(S=>S.id===g);if(w>=0){const S=a[w];st(S);const C=r[w],{collapsedSize:P=0,collapsible:O,minSize:k=0}=S.constraints;if(C!=null&&O){const A=Zu({delta:Lr(C,P)?k-P:P-C,layout:r,panelConstraints:a.map(L=>L.constraints),pivotIndices:SM(n,p),trigger:"keyboard"});r!==A&&o(A)}}break}}};return f.addEventListener("keydown",y),()=>{f.removeEventListener("keydown",y)}});return()=>{d.forEach(f=>f())}},[e,t,n,r,i,o])}function EM(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function OM(e){return e.type==="keydown"}function PM(e){return e.type.startsWith("mouse")}function kM(e){return e.type.startsWith("touch")}function MM(e,t){const n=e==="horizontal";if(PM(t))return n?t.clientX:t.clientY;if(kM(t)){const r=t.touches[0];return st(r),n?r.screenX:r.screenY}else throw Error(`Unsupported event type "${t.type}"`)}function KX(e,t,n,r){const i=n==="horizontal",o=Lp(t);st(o);const s=o.getAttribute("data-panel-group-id");st(s);let{initialCursorPosition:a}=r;const l=MM(n,e),c=CM(s);st(c);const d=c.getBoundingClientRect(),f=i?d.width:d.height;return(l-a)/f*100}function XX(e,t,n,r,i){if(OM(e)){const o=n==="horizontal";let s=0;e.shiftKey?s=100:i!=null?s=i:s=10;let a=0;switch(e.key){case"ArrowDown":a=o?0:s;break;case"ArrowLeft":a=o?-s:0;break;case"ArrowRight":a=o?s:0;break;case"ArrowUp":a=o?0:-s;break;case"End":a=100;break;case"Home":a=-100;break}return a}else return r==null?0:KX(e,t,n,r)}function QX({panelDataArray:e}){const t=Array(e.length),n=e.map(o=>o.constraints);let r=0,i=100;for(let o=0;o<e.length;o++){const s=n[o];st(s);const{defaultSize:a}=s;a!=null&&(r++,t[o]=a,i-=a)}for(let o=0;o<e.length;o++){const s=n[o];st(s);const{defaultSize:a}=s;if(a!=null)continue;const l=e.length-r,c=i/l;r++,t[o]=c,i-=c}return t}function Vl(e,t,n){t.forEach((r,i)=>{const o=e[i];st(o);const{callbacks:s,constraints:a,id:l}=o,{collapsedSize:c=0,collapsible:d}=a,f=n[l];if(f==null||r!==f){n[l]=r;const{onCollapse:p,onExpand:g,onResize:v}=s;v&&v(r,f),d&&(p||g)&&(g&&(f==null||f===c)&&r!==c&&g(),p&&(f==null||f!==c)&&r===c&&p())}})}function $p(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function ZX({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:i,precision:o=3}){const s=n[i];let a;return s==null?a=e??"1":r.length===1?a="1":a=s.toPrecision(o),{flexBasis:0,flexGrow:a,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}let Dy=null,Ca=null;function DM(e){switch(e){case"horizontal":return"ew-resize";case"horizontal-max":return"w-resize";case"horizontal-min":return"e-resize";case"vertical":return"ns-resize";case"vertical-max":return"n-resize";case"vertical-min":return"s-resize"}}function JX(){Ca!==null&&(document.head.removeChild(Ca),Dy=null,Ca=null)}function Ty(e){if(Dy===e)return;Dy=e;const t=DM(e);Ca===null&&(Ca=document.createElement("style"),document.head.appendChild(Ca)),Ca.innerHTML=`*{cursor: ${t}!important;}`}function eQ(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function TM(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function AM(e){return`react-resizable-panels:${e}`}function IM(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:i,order:o}=t;return i?r:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function NM(e,t){try{const n=AM(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function tQ(e,t,n){var r,i;const o=(r=NM(e,n))!==null&&r!==void 0?r:{},s=IM(t);return(i=o[s])!==null&&i!==void 0?i:null}function nQ(e,t,n,r,i){var o;const s=AM(e),a=IM(t),l=(o=NM(e,i))!==null&&o!==void 0?o:{};l[a]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(s,JSON.stringify(l))}catch(c){console.error(c)}}function RM({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((o,s)=>o+s,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!Lr(r,100))for(let o=0;o<t.length;o++){const s=n[o];st(s!=null);const a=100/r*s;n[o]=a}let i=0;for(let o=0;o<t.length;o++){const s=n[o];st(s!=null);const a=Bl({panelConstraints:t,panelIndex:o,size:s});s!=a&&(i+=s-a,n[o]=a)}if(!Lr(i,0))for(let o=0;o<t.length;o++){const s=n[o];st(s!=null);const a=s+i,l=Bl({panelConstraints:t,panelIndex:o,size:a});if(s!==l&&(i-=l-s,n[o]=l,Lr(i,0)))break}return n}const rQ=100,ed={getItem:e=>(TM(ed),ed.getItem(e)),setItem:(e,t)=>{TM(ed),ed.setItem(e,t)}},LM={};function $M({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:o=null,onLayout:s=null,keyboardResizeBy:a=null,storage:l=ed,style:c,tagName:d="div",...f}){const p=My(o),[g,v]=Np(null),[y,x]=Np([]),w=ei({}),S=ei(new Map),C=ei(0),P=ei({autoSaveId:e,direction:r,dragState:g,id:p,keyboardResizeBy:a,onLayout:s,storage:l}),O=ei({layout:y,panelDataArray:[],panelDataArrayChanged:!1});ei({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),vM(i,()=>({getId:()=>P.current.id,getLayout:()=>{const{layout:D}=O.current;return D},setLayout:D=>{const{onLayout:W}=P.current,{layout:re,panelDataArray:N}=O.current,ne=RM({layout:D,panelConstraints:N.map(me=>me.constraints)});EM(re,ne)||(x(ne),O.current.layout=ne,W&&W(ne),Vl(N,ne,w.current))}}),[]),Xu(()=>{P.current.autoSaveId=e,P.current.direction=r,P.current.dragState=g,P.current.id=p,P.current.onLayout=s,P.current.storage=l}),YX({committedValuesRef:P,eagerValuesRef:O,groupId:p,layout:y,panelDataArray:O.current.panelDataArray,setLayout:x}),Sa(()=>{const{panelDataArray:D}=O.current;if(e){if(y.length===0||y.length!==D.length)return;let W=LM[e];W==null&&(W=eQ(nQ,rQ),LM[e]=W);const re=[...D],N=new Map(S.current);W(e,re,N,y,l)}},[e,y,l]),Sa(()=>{});const k=Rr(D=>{const{onLayout:W}=P.current,{layout:re,panelDataArray:N}=O.current;if(D.constraints.collapsible){const ne=N.map(ie=>ie.constraints),{collapsedSize:me=0,panelSize:he,pivotIndices:de}=Wl(N,D,re);if(st(he!=null),he!==me){S.current.set(D.id,he);const ee=Hl(N,D)===N.length-1?he-me:me-he,H=Zu({delta:ee,layout:re,panelConstraints:ne,pivotIndices:de,trigger:"imperative-api"});$p(re,H)||(x(H),O.current.layout=H,W&&W(H),Vl(N,H,w.current))}}},[]),A=Rr(D=>{const{onLayout:W}=P.current,{layout:re,panelDataArray:N}=O.current;if(D.constraints.collapsible){const ne=N.map(ee=>ee.constraints),{collapsedSize:me=0,panelSize:he,minSize:de=0,pivotIndices:ie}=Wl(N,D,re);if(he===me){const ee=S.current.get(D.id),H=ee!=null&&ee>=de?ee:de,oe=Hl(N,D)===N.length-1?he-H:H-he,Te=Zu({delta:oe,layout:re,panelConstraints:ne,pivotIndices:ie,trigger:"imperative-api"});$p(re,Te)||(x(Te),O.current.layout=Te,W&&W(Te),Vl(N,Te,w.current))}}},[]),L=Rr(D=>{const{layout:W,panelDataArray:re}=O.current,{panelSize:N}=Wl(re,D,W);return st(N!=null),N},[]),F=Rr((D,W)=>{const{panelDataArray:re}=O.current,N=Hl(re,D);return ZX({defaultSize:W,dragState:g,layout:y,panelData:re,panelIndex:N})},[g,y]),z=Rr(D=>{const{layout:W,panelDataArray:re}=O.current,{collapsedSize:N=0,collapsible:ne,panelSize:me}=Wl(re,D,W);return ne===!0&&me===N},[]),B=Rr(D=>{const{layout:W,panelDataArray:re}=O.current,{collapsedSize:N=0,collapsible:ne,panelSize:me}=Wl(re,D,W);return st(me!=null),!ne||me>N},[]),V=Rr(D=>{const{panelDataArray:W}=O.current;W.push(D),W.sort((re,N)=>{const ne=re.order,me=N.order;return ne==null&&me==null?0:ne==null?-1:me==null?1:ne-me}),O.current.panelDataArrayChanged=!0},[]);Xu(()=>{if(O.current.panelDataArrayChanged){O.current.panelDataArrayChanged=!1;const{autoSaveId:D,onLayout:W,storage:re}=P.current,{layout:N,panelDataArray:ne}=O.current;let me=null;if(D){const de=tQ(D,ne,re);de&&(S.current=new Map(Object.entries(de.expandToSizes)),me=de.layout)}me==null&&(me=QX({panelDataArray:ne}));const he=RM({layout:me,panelConstraints:ne.map(de=>de.constraints)});EM(N,he)||(x(he),O.current.layout=he,W&&W(he),Vl(ne,he,w.current))}});const X=Rr(D=>function(re){re.preventDefault();const{direction:N,dragState:ne,id:me,keyboardResizeBy:he,onLayout:de}=P.current,{layout:ie,panelDataArray:ee}=O.current,{initialLayout:H}=ne??{},ye=SM(me,D);let oe=XX(re,D,N,ne,he);if(oe===0)return;const Te=N==="horizontal";document.dir==="rtl"&&Te&&(oe=-oe);const Fe=ee.map(St=>St.constraints),He=Zu({delta:oe,layout:H??ie,panelConstraints:Fe,pivotIndices:ye,trigger:OM(re)?"keyboard":"mouse-or-touch"}),Ke=!$p(ie,He);(PM(re)||kM(re))&&C.current!=oe&&(C.current=oe,Ty(Ke?Te?"horizontal":"vertical":Te?oe<0?"horizontal-min":"horizontal-max":oe<0?"vertical-min":"vertical-max")),Ke&&(x(He),O.current.layout=He,de&&de(He),Vl(ee,He,w.current))},[]),K=Rr((D,W)=>{const{onLayout:re}=P.current,{layout:N,panelDataArray:ne}=O.current,me=ne.map(ye=>ye.constraints),{panelSize:he,pivotIndices:de}=Wl(ne,D,N);st(he!=null);const ee=Hl(ne,D)===ne.length-1?he-W:W-he,H=Zu({delta:ee,layout:N,panelConstraints:me,pivotIndices:de,trigger:"imperative-api"});$p(N,H)||(x(H),O.current.layout=H,re&&re(H),Vl(ne,H,w.current))},[]),$=Rr((D,W)=>{const{direction:re}=P.current,{layout:N}=O.current,ne=Lp(D);st(ne);const me=MM(re,W);v({dragHandleId:D,dragHandleRect:ne.getBoundingClientRect(),initialCursorPosition:me,initialLayout:N})},[]),J=Rr(()=>{JX(),v(null)},[]),G=Rr(D=>{const{panelDataArray:W}=O.current,re=Hl(W,D);re>=0&&(W.splice(re,1),delete w.current[D.id],O.current.panelDataArrayChanged=!0)},[]),q=HX(()=>({collapsePanel:k,direction:r,dragState:g,expandPanel:A,getPanelSize:L,getPanelStyle:F,groupId:p,isPanelCollapsed:z,isPanelExpanded:B,registerPanel:V,registerResizeHandle:X,resizePanel:K,startDragging:$,stopDragging:J,unregisterPanel:G}),[k,g,r,A,L,F,p,z,B,V,X,K,$,J,G]),se={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return zl(Rp.Provider,{value:q},zl(d,{...f,children:t,className:n,style:{...se,...c},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":p}))}const FM=gM((e,t)=>zl($M,{...e,forwardedRef:t}));$M.displayName="PanelGroup",FM.displayName="forwardRef(PanelGroup)";function Hl(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Wl(e,t,n){const r=e.map(c=>c.constraints),i=Hl(e,t),o=r[i],a=i===e.length-1?[i-1,i]:[i,i+1],l=n[i];return{...o,panelSize:l,pivotIndices:a}}function iQ({disabled:e,handleId:t,resizeHandler:n}){Sa(()=>{if(e||n==null)return;const r=Lp(t);if(r==null)return;const i=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{o.preventDefault(),n(o);break}case"F6":{o.preventDefault();const s=r.getAttribute("data-panel-group-id");st(s);const a=Ju(s),l=_M(s,t);st(l!==null);const c=o.shiftKey?l>0?l-1:a.length-1:l+1<a.length?l+1:0;a[c].focus();break}}};return r.addEventListener("keydown",i),()=>{r.removeEventListener("keydown",i)}},[e,t,n])}function jM({children:e=null,className:t="",disabled:n=!1,id:r,onDragging:i,style:o={},tabIndex:s=0,tagName:a="div",...l}){const c=ei(null),d=ei({onDragging:i});Sa(()=>{d.current.onDragging=i});const f=mM(Rp);if(f===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:p,dragState:g,groupId:v,registerResizeHandle:y,startDragging:x,stopDragging:w}=f,S=My(r),C=(g==null?void 0:g.dragHandleId)===S,[P,O]=Np(!1),[k,A]=Np(null),L=Rr(()=>{const z=c.current;st(z),z.blur(),w();const{onDragging:B}=d.current;B&&B(!1)},[w]);Sa(()=>{if(n)A(null);else{const z=y(S);A(()=>z)}},[n,S,y]),Sa(()=>{if(n||k==null||!C)return;const z=K=>{k(K)},B=K=>{k(K)},V=c.current;st(V);const X=V.ownerDocument;return X.body.addEventListener("contextmenu",L),X.body.addEventListener("mousemove",z),X.body.addEventListener("touchmove",z),X.body.addEventListener("mouseleave",B),window.addEventListener("mouseup",L),window.addEventListener("touchend",L),()=>{X.body.removeEventListener("contextmenu",L),X.body.removeEventListener("mousemove",z),X.body.removeEventListener("touchmove",z),X.body.removeEventListener("mouseleave",B),window.removeEventListener("mouseup",L),window.removeEventListener("touchend",L)}},[p,n,C,k,L]),iQ({disabled:n,handleId:S,resizeHandler:k});const F={cursor:DM(p),touchAction:"none",userSelect:"none"};return zl(a,{...l,children:e,className:t,onBlur:()=>O(!1),onFocus:()=>O(!0),onMouseDown:z=>{x(S,z.nativeEvent);const B=d.current;st(B);const{onDragging:V}=B;V&&V(!0)},onMouseUp:L,onTouchCancel:L,onTouchEnd:L,onTouchStart:z=>{x(S,z.nativeEvent);const B=d.current;st(B);const{onDragging:V}=B;V&&V(!0)},ref:c,role:"separator",style:{...F,...o},tabIndex:s,"data-panel-group-direction":p,"data-panel-group-id":v,"data-resize-handle":"","data-resize-handle-active":C?"pointer":P?"keyboard":void 0,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":S})}jM.displayName="PanelResizeHandle";const zM=({className:e,...t})=>_.jsx(FM,{className:Pe("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),Fp=xM,BM=({withHandle:e,className:t,...n})=>_.jsx(jM,{className:Pe("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&_.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:_.jsx(XB,{className:"h-2.5 w-2.5"})})});function oQ(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function VM(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 HM(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?VM(Object(n),!0).forEach(function(r){oQ(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):VM(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function sQ(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 aQ(e,t){if(e==null)return{};var n=sQ(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 lQ(e,t){return cQ(e)||uQ(e,t)||dQ(e,t)||fQ()}function cQ(e){if(Array.isArray(e))return e}function uQ(e,t){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(e)))){var n=[],r=!0,i=!1,o=void 0;try{for(var s=e[Symbol.iterator](),a;!(r=(a=s.next()).done)&&(n.push(a.value),!(t&&n.length===t));r=!0);}catch(l){i=!0,o=l}finally{try{!r&&s.return!=null&&s.return()}finally{if(i)throw o}}return n}}function dQ(e,t){if(e){if(typeof e=="string")return WM(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return WM(e,t)}}function WM(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function fQ(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
429
429
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hQ(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function qM(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 UM(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?qM(Object(n),!0).forEach(function(r){hQ(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qM(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function pQ(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r){return t.reduceRight(function(i,o){return o(i)},r)}}function td(e){return function t(){for(var n=this,r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return i.length>=e.length?e.apply(this,i):function(){for(var s=arguments.length,a=new Array(s),l=0;l<s;l++)a[l]=arguments[l];return t.apply(n,[].concat(i,a))}}}function jp(e){return{}.toString.call(e).includes("Object")}function gQ(e){return!Object.keys(e).length}function nd(e){return typeof e=="function"}function mQ(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function vQ(e,t){return jp(t)||as("changeType"),Object.keys(t).some(function(n){return!mQ(e,n)})&&as("changeField"),t}function bQ(e){nd(e)||as("selectorType")}function yQ(e){nd(e)||jp(e)||as("handlerType"),jp(e)&&Object.values(e).some(function(t){return!nd(t)})&&as("handlersType")}function xQ(e){e||as("initialIsRequired"),jp(e)||as("initialType"),gQ(e)&&as("initialContent")}function wQ(e,t){throw new Error(e[t]||e.default)}var _Q={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},as=td(wQ)(_Q),zp={changes:vQ,selector:bQ,handler:yQ,initial:xQ};function SQ(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};zp.initial(e),zp.handler(t);var n={current:e},r=td(OQ)(n,t),i=td(EQ)(n),o=td(zp.changes)(e),s=td(CQ)(n);function a(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(d){return d};return zp.selector(c),c(n.current)}function l(c){pQ(r,i,o,s)(c)}return[a,l]}function CQ(e,t){return nd(t)?t(e.current):t}function EQ(e,t){return e.current=UM(UM({},e.current),t),t}function OQ(e,t,n){return nd(t)?t(e.current):Object.keys(n).forEach(function(r){var i;return(i=t[r])===null||i===void 0?void 0:i.call(t,e.current[r])}),n}var PQ={create:SQ},kQ={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs"}};function MQ(e){return function t(){for(var n=this,r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return i.length>=e.length?e.apply(this,i):function(){for(var s=arguments.length,a=new Array(s),l=0;l<s;l++)a[l]=arguments[l];return t.apply(n,[].concat(i,a))}}}function DQ(e){return{}.toString.call(e).includes("Object")}function TQ(e){return e||YM("configIsRequired"),DQ(e)||YM("configType"),e.urls?(AQ(),{paths:{vs:e.urls.monacoBase}}):e}function AQ(){console.warn(GM.deprecation)}function IQ(e,t){throw new Error(e[t]||e.default)}var GM={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
430
430
  You are using deprecated way of configuration.
431
431
 
@@ -502,4 +502,4 @@ SELECT label, measure FROM table
502
502
  Table Columns: ${p==null?void 0:p.map(X=>`${X.column_name} | ${X.data_type}`).join(", ")}
503
503
  User SQL: ${g}
504
504
  `,x=` 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.
505
- Visual Query Syntax: ${Vne}`,{data:w,isLoading:S,isFetching:C,isError:P,refetch:O}=Sr({queryKey:["ai-query"],queryFn:()=>tl("https://semaphor.cloud/api/v1/ai",(s==null?void 0:s.accessToken)||"",{user_content:`userContent: ${y} ${a?x:""}`}),enabled:!1});function k(X){if(X.toLowerCase().includes("bar"))f("bar");else if(X.toLowerCase().includes("line"))f("line");else if(X.toLowerCase().includes("bubble"))f("bubble");else if(X.toLowerCase().includes("scatter"))f("scatter");else if(X.toLowerCase().includes("stacked"))f("stackedBar");else if(X.toLowerCase().includes("pie"))f("pie");else if(X.toLowerCase().includes("donut")||X.toLowerCase().includes("doughnut"))f("doughnut");else if(X.toLowerCase().includes("radar"))f("radar");else return f("bar"),!1;return!0}function A(){n&&(k(n)&&l(!0),O())}m.useEffect(()=>{i&&(A(),o(!1))},[i,o]);const L={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"5px",width:"100%"},F={fontFamily:"monospace",fontSize:14,lineHeight:1.6},z={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},B={p:({node:X,...K})=>_.jsx("p",{style:L,...K}),pre:({node:X,...K})=>_.jsxs("pre",{className:" bg-muted/50 space-y-2 p-3 rounded-sm",style:F,children:[_.jsx("code",{className:" whitespace-normal",children:K.children}),_.jsxs("div",{className:" flex justify-start gap-2",children:[_.jsx(it,{onClick:V,size:"sm",variant:"outline",children:_.jsx(JE,{})}),_.jsx(it,{onClick:$=>{const J=V($);J&&(t(!1),c(J),d(!0))},size:"sm",variant:"outline",children:_.jsx(Zj,{})})]})]}),li:({node:X,...K})=>_.jsx("li",{style:z,...K})};function V(X){const K=X.currentTarget.closest("pre");if(!K)return;const $=K.textContent||K.innerText;return navigator.clipboard.writeText($).then(()=>console.log("Text copied to clipboard")).catch(J=>console.error("Error in copying text: ",J)),$}return _.jsxs(wy,{open:e,onOpenChange:t,children:[_.jsx(_y,{asChild:!0,children:_.jsx(it,{size:"sm",className:"",variant:"outline",children:_.jsx(nV,{strokeWidth:1,size:16})})}),_.jsxs(_p,{className:" border-muted sm:max-w-[425px] md:min-w-[625px] md:max-h-[625px] flex flex-col justify-between overflow-auto",children:[_.jsxs(Sp,{children:[_.jsx(Cp,{children:"Ask"}),_.jsx(Ep,{children:"Need assistance with SQL queries? Feel free to ask me any question!"})]}),_.jsx(kl,{className:"h-[625px] w-full border-t border-t-muted ",children:(!S||!C)&&_.jsx(zne,{className:" pl-1 pr-3 py-1 w-full xbg-red-100 overflow-auto ",components:B,children:w==null?void 0:w.response})}),_.jsxs("div",{children:[_.jsx(lf,{className:Pe(" invisible h-1 w-full animate-pulse",{visible:S||C})}),_.jsxs("div",{className:" border rounded-md flex items-center w-full",children:[_.jsx(By,{onKeyDown:X=>{X.key==="Enter"&&!X.shiftKey&&(X.preventDefault(),r(""),A())},placeholder:"Type something...",onFocus:X=>{const K=X.target,$=K.value.length;K.setSelectionRange($,$)},className:" border-none resize-none min-h-7 max-h-10 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",value:n,onChange:X=>r(X.target.value)})," ",_.jsx(it,{className:"h-8",size:"sm",variant:"ghost",onClick:A,children:!S&&!C?_.jsx(Xj,{}):_.jsx(ku,{className:" w-4 h-4 animate-spin mr-2 text-foreground/50"})})]})]})]})]})}function Wne(){const{theme:e}=Em(),t=m.useRef(),n=m.useRef(),[r,i]=m.useState(!1),[o,s]=m.useState(!1),[a,l]=m.useState(""),[c,d]=m.useState(!1);m.useState("");const f=ge(H=>H.authToken),p=_e(H=>H.card),g=ge(H=>H.theme),v=_e(H=>H.selectedConnectionId),y=_e(H=>H.selectedDatabaseName),x=_e(H=>H.selectedSchemaName),w=_e(H=>H.selectedTableName),S=_e(H=>H.actions.setCardSql),C=_e(H=>H.card.sql),P=_e(H=>H.selectedConnectionId),O=_e(H=>H.filterValues),k=_e(H=>H.applyFilters),A=_e(H=>H.actions.setCardCustomCfg),L=_e(H=>H.actions.setFilterValues),F=_e(H=>H.onSave),z=_e(H=>H.actions.setApplyFilters),B=_e(H=>H.onClose),V=_e(H=>H.actions.setCardData),X=_e(H=>H.actions.setSqlGen),K=_e(H=>H.runSql),$=_e(H=>H.actions.setRunSql),J=_e(H=>H.actions.setIsSqlRunning),{data:G,isLoading:q,isFetching:se,isSuccess:D,isError:W,error:re,status:N,refetch:ne}=Sr({queryKey:[C],queryFn:()=>Is("https://semaphor.cloud/api/v1/query",(f==null?void 0:f.accessToken)||"",{connection_id:P,sql:C,active_filters:k?O:[]}),enabled:!1,retry:!1});m.useEffect(()=>{G&&(console.log("queryData",G),V(G.records))},[G,V]),m.useEffect(()=>{K&&(ne(),$(!1))},[K,ne,$]),m.useEffect(()=>{(q||se)&&J(!0),(W||D)&&J(!1)},[q,se,W,D,J]);function me(){S(""),V([]),X({}),A("")}const he=H=>{n.current=H};function de(){if(C&&!C.includes("{{")){const H=cZ(C);S(H),F==null||F({...p,sql:H,lastSelectedSchema:x,lastSelectedDatabase:y,lastSelectedTable:w,connectionId:v})}else F==null||F(p)}function ie(){B==null||B()}m.useEffect(()=>{const H=t.current,ye=n.current;if(H){const oe=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",Te=g==="system"?oe:g;H.editor.defineTheme("default",{base:Te==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":Te==="light"?"#ffffff":"#020817"}}),H.editor.setTheme("default")}return ye&&H&&ye.addCommand(H.KeyMod.Shift|H.KeyCode.Enter,function(){return console.log("Executing query..."),ne(),!1}),()=>{}},[e,g,t.current]);function ee(H){t.current=H}return _.jsxs("section",{role:"editor-section",className:"grow flex flex-col justify-end pt-3 p-1 ",children:[_.jsxs("div",{className:" grow flex relative overflow-y-scroll justify-between ",children:[_.jsx("div",{role:"editor-container",className:`flex ${r?"w-2/3":"w-[95%]"} xbg-red-100 p-1`,children:_.jsx(Ry,{theme:"default",onChange:H=>{S(H),console.log(H)},value:C,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:ee,onMount:he})}),r&&_.jsx("div",{className:" w-1/3 text-xs relative overflow-hidden xbg-yellow-100 p-1 ",children:_.jsxs("div",{className:"min-h-0 ",children:[_.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx(_Z,{checked:k,onCheckedChange:()=>z(!k),text:"Apply Filters"}),_.jsx(SZ,{})]}),_.jsx(Ry,{theme:"default",onChange:H=>{if(H)try{JSON.parse(H),L(JSON.parse(H))}catch{}},defaultLanguage:"json",className:"min-h-[220px] mt-1",value:JSON.stringify(O,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),O&&r&&_.jsx(ia,{onClick:()=>i(!1),className:"absolute right-6 top-1 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer"}),O&&!r&&_.jsx(W2,{onClick:()=>i(!0),className:Pe("absolute right-6 top-1 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer",{"text-red-800 font-bold":k})})]}),_.jsxs("div",{className:" flex grow px-6 pt-3 pb-4 gap-2 justify-between item-center",children:[_.jsxs("div",{className:"flex grow gap-2 items-center",children:[_.jsxs(it,{disabled:q||se,onClick:()=>{ne()},className:" shrink-0",size:"sm",variant:"outline",children:[(q||se)&&_.jsx(ku,{className:"w-4 h-4 mr-2 animate-spin text-foreground/50"}),"Run"]}),W&&_.jsx(wZ,{error:re.message}),_.jsx(it,{onClick:me,className:"",size:"sm",variant:"outline",children:"Clear"}),_.jsx(Ku,{value:a,placeholder:"Type something...",onChange:H=>{l(H.target.value)},onKeyDown:H=>{H.key==="Enter"&&(H.preventDefault(),console.log("enter pressed"),d(!0),s(!0))},className:" bg-muted border-none h-9 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"}),_.jsx(Hne,{open:o,setOpen:s,userInput:a,triggerAIRun:c,setTriggerAIRun:d,setUserInput:H=>l(H)})]}),_.jsxs("div",{className:"flex gap-2 items-end ",children:[_.jsx(it,{onClick:de,size:"sm",variant:"outline",children:_.jsx(Rh,{size:16,strokeWidth:2,className:"text-green-600 font-bold"})}),_.jsx(it,{onClick:ie,className:" w-full",size:"sm",variant:"outline",children:_.jsx(ia,{className:" h-3.5 w-3.5"})})]})]})]})}const $T="Switch",[qne,Sfe]=Pn($T),[Une,Gne]=qne($T),Yne=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:o,required:s,disabled:a,value:l="on",onCheckedChange:c,...d}=e,[f,p]=m.useState(null),g=et(t,S=>p(S)),v=m.useRef(!1),y=f?!!f.closest("form"):!0,[x=!1,w]=Qn({prop:i,defaultProp:o,onChange:c});return m.createElement(Une,{scope:n,checked:x,disabled:a},m.createElement(Be.button,le({type:"button",role:"switch","aria-checked":x,"aria-required":s,"data-state":FT(x),"data-disabled":a?"":void 0,disabled:a,value:l},d,{ref:g,onClick:Ce(e.onClick,S=>{w(C=>!C),y&&(v.current=S.isPropagationStopped(),v.current||S.stopPropagation())})})),y&&m.createElement(Qne,{control:f,bubbles:!v.current,name:r,value:l,checked:x,required:s,disabled:a,style:{transform:"translateX(-100%)"}}))}),Kne="SwitchThumb",Xne=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=Gne(Kne,n);return m.createElement(Be.span,le({"data-state":FT(i.checked),"data-disabled":i.disabled?"":void 0},r,{ref:t}))}),Qne=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Op(n),a=Mh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const p=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(p)}},[s,n,r]),m.createElement("input",le({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 FT(e){return e?"checked":"unchecked"}const jT=Yne,Zne=Xne,zT=ue.forwardRef(({className:e,...t},n)=>_.jsx(jT,{className:Pe("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:_.jsx(Zne,{className:Pe("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")})}));zT.displayName=jT.displayName;function BT({className:e,...t}){const[n,r]=m.useState(0),i=ge(l=>l.themeStyle),o=_e(l=>l.card),s=_e(l=>l.actions.setCard);if(m.useEffect(()=>{r(n+1)},[o.data,o.type,o.cfg,o.customCfg,i]),!o.id)return null;let a;return o.data&&o.data.length>0&&(a=kb({data:o.data,cardType:o.type,cfg:o.cfg,customCfg:o.customCfg})),_.jsxs(Mv,{role:"editor-visual-card",className:Pe(" relative h-full flex flex-col rounded-none",e),...t,children:[_.jsxs(Dv,{children:[_.jsx(qc,{text:o.title,onSave:l=>s({...o,title:l}),children:_.jsx(Tv,{className:"text-base",children:o.title})}),_.jsx(qc,{text:o.description||"",onSave:l=>s({...o,description:l}),children:_.jsxs(Av,{children:[" ",o.description]})})]}),_.jsxs(Iv,{className:"flex flex-col pb-3 grow",children:[o.type!=="table"&&a&&_.jsx(QE,{cfg:a},n),o.type==="table"&&o.data&&o.data.length>0&&_.jsx(cO,{children:_.jsx(a0,{data:o==null?void 0:o.data})})]})]})}function Jne(){const[e,t]=m.useState(!1),[n,r]=m.useState(""),[i,o]=m.useState(""),[s,a]=m.useState(""),l=_e(x=>x.card),c=_e(x=>x.card.customCfg),d=_e(x=>x.actions.setCardCustomCfg);function f(x){var C,P;const w={...x,data:{...x==null?void 0:x.data,datasets:(P=(C=x==null?void 0:x.data)==null?void 0:C.datasets)==null?void 0:P.map(O=>({...O,data:[]}))}};return JSON.stringify(w,null,1)}function p(){if(!l.data||l.data.length===0)return;const x=kb({data:l.data,cardType:l.type,cfg:l.cfg});x&&(r(JSON.stringify(x,null,1)),c&&o(JSON.stringify(c,null,1)))}function g(){if(i)try{const x=JSON.parse(i);return x?(d(x),a(""),o(""),x):void 0}catch(x){console.log(x),a("Invalid JSON")}}function v(){o(""),d(null)}function y(){let x;if(c){const w=$s.cloneDeep(l.cfg),S=$s.merge(w,c);return x=f(S),x}return n?(x=f(JSON.parse(n)),x):""}return _.jsxs(wy,{open:e,onOpenChange:t,children:[_.jsx(_y,{asChild:!0,children:_.jsx(it,{onClick:p,className:`h-7 ${c&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:c?"Custom Config":"Customize"})}),_.jsx(_p,{className:" sm:max-w-[425px] md:min-w-[600px] md:min-h-[700px] lg:min-w-[800px] xl:min-w-[1000px]",children:_.jsxs("div",{className:"bg-red-x100 flex flex-col gap-2 justify-between",children:[_.jsxs(Sp,{className:"",children:[_.jsx(Cp,{children:"Customize Chart"}),_.jsxs(Ep,{children:["See the configuration options and documentation",_.jsx("a",{target:"_blank",className:"ml-1 underline text-blue-500 ",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),_.jsxs("div",{className:"grow flex flex-wrap gap-2",children:[_.jsx(BT,{className:"flex-1 rounded shadow-none"}),_.jsxs(a_,{defaultValue:"custom-config",className:" flex flex-col flex-1",children:[_.jsxs(l_,{className:" justify-start border rounded-sm rounded-b-none border-b-0 ",children:[_.jsxs(Im,{value:"custom-config",children:[c&&_.jsx(ZE,{className:"w-5 h-5 mr-1 text-green-600"}),c?"Custom Config":"Default Config"]}),_.jsx(Im,{className:"",value:"output",children:"Output"})]}),_.jsx(ff,{className:" grow mt-0 bg-red-x p-2 border border-t-0 rounded-b ",value:"output",children:_.jsx(By,{disabled:!0,value:n,className:" border-none resize-none font-mono h-full focus-visible:ring-0 focus-visible:ring-offset-0"})}),_.jsx(ff,{className:"grow mt-0 border border-t-0 rounded-b ",value:"custom-config",children:_.jsx(Ry,{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:x=>o(x)})})]})]}),_.jsxs(Sy,{className:"flex items-center",children:[_.jsx(ns,{className:"text-red-500 mr-2",children:s}),_.jsx(it,{disabled:!c,onClick:v,variant:"outline",children:"Reset"}),_.jsx(it,{onClick:g,variant:"outline",children:"Apply"}),_.jsx(it,{onClick:()=>t(!1),variant:"outline",children:"Close"})]})]})})]})}var VT={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},HT=m.createContext&&m.createContext(VT),ere=["attr","size","title"];function tre(e,t){if(e==null)return{};var n=nre(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 nre(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 tg(){return tg=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},tg.apply(this,arguments)}function WT(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 ng(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?WT(Object(n),!0).forEach(function(r){rre(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):WT(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function rre(e,t,n){return t=ire(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ire(e){var t=ore(e,"string");return typeof t=="symbol"?t:String(t)}function ore(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 qT(e){return e&&e.map((t,n)=>m.createElement(t.tag,ng({key:n},t.attr),qT(t.child)))}function dd(e){return t=>m.createElement(sre,tg({attr:ng({},e.attr)},t),qT(e.child))}function sre(e){var t=n=>{var{attr:r,size:i,title:o}=e,s=tre(e,ere),a=i||n.size||"1em",l;return n.className&&(l=n.className),e.className&&(l=(l?l+" ":"")+e.className),m.createElement("svg",tg({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,s,{className:l,style:ng(ng({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 HT!==void 0?m.createElement(HT.Consumer,null,n=>t(n)):t(VT)}function UT(e){return dd({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 GT(e){return dd({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 YT(e){return dd({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137,28.05a11.94,11.94,0,0,0-9.12,3.08A12.09,12.09,0,0,0,124,40V80.67a11.88,11.88,0,0,0,9.9,11.81,36,36,0,1,1-41.85,37.4c-.47-9.14,1.47-16.8,5.75-22.79h0a11.89,11.89,0,0,0-1.3-15.35L68.87,63.51a12,12,0,0,0-17.74.83A99.6,99.6,0,0,0,57.79,199.2,99.24,99.24,0,0,0,128,228h1.43A100.29,100.29,0,0,0,228,129.42C228.72,77.21,188.76,32.68,137,28.05ZM57.28,69.46A4,4,0,0,1,60.2,68h.19a3.91,3.91,0,0,1,2.79,1.14L90.81,97.36a3.93,3.93,0,0,1,.48,5.08A40.47,40.47,0,0,0,84.08,124h-48A90.36,90.36,0,0,1,57.28,69.46ZM36.09,132H84.18A44,44,0,0,0,124,171.81V219.9A92,92,0,0,1,36.09,132ZM193,193a91.43,91.43,0,0,1-61,26.92V171.82a43.51,43.51,0,0,0,26-11.63,44,44,0,0,0-22.79-75.6A4,4,0,0,1,132,80.67V40a4,4,0,0,1,1.31-3,3.89,3.89,0,0,1,3-1c47.59,4.26,84.34,45.24,83.67,93.29A91.42,91.42,0,0,1,193,193Z"},child:[]}]})(e)}function KT(e){return dd({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 XT(e){return dd({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 are(){const[e,t]=m.useState(!1),n=_e(s=>s.card.type),r=_e(s=>s.actions.setCardType),i=_e(s=>s.actions.setCardCustomCfg);function o(s){r(s),i(null),t(!1)}return _.jsxs(pp,{open:e,onOpenChange:t,children:[_.jsx(gp,{asChild:!0,children:_.jsx(it,{className:"h-7 px-2",variant:"outline",children:_.jsx(lre,{className:"h-4 w-4",chartType:n})})}),_.jsx(Wu,{className:"w-50",children:_.jsxs("div",{className:"grid grid-cols-3 place-items-center ",children:[_.jsx(it,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:_.jsx(B2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("line"),variant:"ghost",children:_.jsx(q2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("stackedBar"),variant:"ghost",children:_.jsx(XT,{className:"h-6 w-6 text-foreground/50 ",strokeWidth:0})}),_.jsx(it,{onClick:()=>o("scatter"),variant:"ghost",children:_.jsx(G2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("bubble"),variant:"ghost",children:_.jsx(KT,{strokeWidth:2})}),_.jsx(it,{onClick:()=>o("pie"),variant:"ghost",children:_.jsx(U2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("doughnut"),variant:"ghost",children:_.jsx(YT,{className:"h-7 w-7",strokeWidth:.5})}),_.jsx(it,{onClick:()=>o("radar"),variant:"ghost",children:_.jsx(UT,{className:"h-6 w-6 text-foreground/50 font-extralight",strokeWidth:.5})}),_.jsx(it,{onClick:()=>o("polarArea"),variant:"ghost",children:_.jsx(GT,{className:"h-6 w-6 text-foreground/50",strokeWidth:1})}),_.jsx(it,{onClick:()=>o("table"),variant:"ghost",children:_.jsx(qb,{className:"h-6 w-6 text-foreground/90",strokeWidth:1})})]})})]})}function lre({chartType:e,className:t}){switch(e){case"bar":return _.jsx(B2,{className:t});case"line":return _.jsx(q2,{className:t});case"pie":return _.jsx(U2,{className:t});case"radar":return _.jsx(UT,{className:t});case"scatter":return _.jsx(G2,{className:t});case"bubble":return _.jsx(KT,{className:t});case"doughnut":return _.jsx(YT,{className:t});case"stackedBar":return _.jsx(XT,{className:"h-5 w-5 text-foreground/50 ",strokeWidth:0});case"polarArea":return _.jsx(GT,{className:t});default:return _.jsx(qb,{className:t})}}function cre(){const e=_e(n=>n.card.refreshInterval),t=_e(n=>n.actions.setCardRefreshInterval);return _.jsxs(pp,{children:[_.jsx(gp,{asChild:!0,children:_.jsx(it,{className:"h-7",variant:"outline",children:"Realtime"})}),_.jsx(Wu,{className:"w-[200px]",children:_.jsx("div",{className:"grid gap-4",children:_.jsx("div",{className:"grid gap-2",children:_.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[_.jsx(ns,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),_.jsx(Ku,{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"})]})})})})]})}function QT(){const e=_e(r=>r.card),t=_e(r=>r.isShowingVisual),n=_e(r=>r.isSqlRunning);return _e(r=>r.onSave),_e(r=>r.onClose),_e(r=>r.actions.setCardSql),_e(r=>r.actions.setCardType),_e(r=>r.actions.setSqlGen),_.jsxs("div",{className:" h-full relative flex flex-col",children:[n&&_.jsx(ku,{className:" w-10 h-10 z-10 absolute m-auto left-0 right-0 top-0 bottom-0 animate-spin text-foreground/10 "}),_.jsxs("div",{className:" h-10 px-6 pt-6 bg-red-x100 mb-0 z-10 right-0 flex justify-end items-center gap-2",children:[t&&_.jsxs("div",{className:"bg-red-x00 flex grow gap-2",children:[_.jsx(are,{}),_.jsx(Jne,{}),_.jsx(cre,{})]}),_.jsx(ure,{})]}),t?_.jsx(BT,{className:"grow border-none shadow-none "}):_.jsx("div",{className:"w-full mt-4 px-6 bg-red-x00 grow border-none shadow-none overflow-y-auto ",children:e.data&&e.data.length>0&&_.jsx(a0,{data:e.data})})]})}function ure(){const e=_e(n=>n.isShowingVisual),t=_e(n=>n.actions.setIsShowingVisual);return _.jsxs("div",{className:" flex items-center space-x-2",children:[_.jsx(ns,{htmlFor:"visualize",children:"Chart"}),_.jsx(zT,{checked:e,onCheckedChange:()=>t(!e),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}const ZT="Collapsible",[dre,JT]=Pn(ZT),[fre,_x]=dre(ZT),hre=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(fre,{scope:n,disabled:o,contentId:or(),open:l,onOpenToggle:m.useCallback(()=>c(d=>!d),[c])},m.createElement(Be.div,le({"data-state":Sx(l),"data-disabled":o?"":void 0},a,{ref:t})))}),pre="CollapsibleTrigger",gre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=_x(pre,n);return m.createElement(Be.button,le({type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":Sx(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled},r,{ref:t,onClick:Ce(e.onClick,i.onOpenToggle)}))}),eA="CollapsibleContent",mre=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=_x(eA,e.__scopeCollapsible);return m.createElement(vn,{present:n||i.open},({present:o})=>m.createElement(vre,le({},r,{ref:t,present:o})))}),vre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...o}=e,s=_x(eA,n),[a,l]=m.useState(r),c=m.useRef(null),d=et(t,c),f=m.useRef(0),p=f.current,g=m.useRef(0),v=g.current,y=s.open||a,x=m.useRef(y),w=m.useRef();return m.useEffect(()=>{const S=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(S)},[]),Vn(()=>{const S=c.current;if(S){w.current=w.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,g.current=C.width,x.current||(S.style.transitionDuration=w.current.transitionDuration,S.style.animationName=w.current.animationName),l(r)}},[s.open,r]),m.createElement(Be.div,le({"data-state":Sx(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!y},o,{ref:d,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style}}),y&&i)});function Sx(e){return e?"open":"closed"}const bre=hre,yre=gre,xre=mre,us="Accordion",wre=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Cx,_re,Sre]=uf(us),[rg,Cfe]=Pn(us,[Sre,JT]),Ex=JT(),tA=m.forwardRef((e,t)=>{const{type:n,...r}=e,i=r,o=r;return m.createElement(Cx.Provider,{scope:e.__scopeAccordion},n==="multiple"?m.createElement(Pre,le({},o,{ref:t})):m.createElement(Ore,le({},i,{ref:t})))});tA.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[nA,Cre]=rg(us),[rA,Ere]=rg(us,{collapsible:!1}),Ore=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(nA,{scope:e.__scopeAccordion,value:a?[a]:[],onItemOpen:l,onItemClose:m.useCallback(()=>o&&l(""),[o,l])},m.createElement(rA,{scope:e.__scopeAccordion,collapsible:o},m.createElement(iA,le({},s,{ref:t}))))}),Pre=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(d=>a((f=[])=>[...f,d]),[a]),c=m.useCallback(d=>a((f=[])=>f.filter(p=>p!==d)),[a]);return m.createElement(nA,{scope:e.__scopeAccordion,value:s,onItemOpen:l,onItemClose:c},m.createElement(rA,{scope:e.__scopeAccordion,collapsible:!0},m.createElement(iA,le({},o,{ref:t}))))}),[kre,ig]=rg(us),iA=m.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:i,orientation:o="vertical",...s}=e,a=m.useRef(null),l=et(a,t),c=_re(n),f=Fs(i)==="ltr",p=Ce(e.onKeyDown,g=>{var v;if(!wre.includes(g.key))return;const y=g.target,x=c().filter(F=>{var z;return!((z=F.ref.current)!==null&&z!==void 0&&z.disabled)}),w=x.findIndex(F=>F.ref.current===y),S=x.length;if(w===-1)return;g.preventDefault();let C=w;const P=0,O=S-1,k=()=>{C=w+1,C>O&&(C=P)},A=()=>{C=w-1,C<P&&(C=O)};switch(g.key){case"Home":C=P;break;case"End":C=O;break;case"ArrowRight":o==="horizontal"&&(f?k():A());break;case"ArrowDown":o==="vertical"&&k();break;case"ArrowLeft":o==="horizontal"&&(f?A():k());break;case"ArrowUp":o==="vertical"&&A();break}const L=C%S;(v=x[L].ref.current)===null||v===void 0||v.focus()});return m.createElement(kre,{scope:n,disabled:r,direction:i,orientation:o},m.createElement(Cx.Slot,{scope:n},m.createElement(Be.div,le({},s,{"data-orientation":o,ref:l,onKeyDown:r?void 0:p}))))}),Ox="AccordionItem",[Mre,Px]=rg(Ox),Dre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...i}=e,o=ig(Ox,n),s=Cre(Ox,n),a=Ex(n),l=or(),c=r&&s.value.includes(r)||!1,d=o.disabled||e.disabled;return m.createElement(Mre,{scope:n,open:c,disabled:d,triggerId:l},m.createElement(bre,le({"data-orientation":o.orientation,"data-state":sA(c)},a,i,{ref:t,disabled:d,open:c,onOpenChange:f=>{f?s.onItemOpen(r):s.onItemClose(r)}})))}),Tre="AccordionHeader",Are=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=ig(us,n),o=Px(Tre,n);return m.createElement(Be.h3,le({"data-orientation":i.orientation,"data-state":sA(o.open),"data-disabled":o.disabled?"":void 0},r,{ref:t}))}),oA="AccordionTrigger",Ire=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=ig(us,n),o=Px(oA,n),s=Ere(oA,n),a=Ex(n);return m.createElement(Cx.ItemSlot,{scope:n},m.createElement(yre,le({"aria-disabled":o.open&&!s.collapsible||void 0,"data-orientation":i.orientation,id:o.triggerId},a,r,{ref:t})))}),Nre="AccordionContent",Rre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=ig(us,n),o=Px(Nre,n),s=Ex(n);return m.createElement(xre,le({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 sA(e){return e?"open":"closed"}const Lre=tA,$re=Dre,Fre=Are,aA=Ire,lA=Rre,cA=Lre,ds=ue.forwardRef(({className:e,...t},n)=>_.jsx($re,{ref:n,className:Pe("border-b",e),...t}));ds.displayName="AccordionItem";const fs=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsx(Fre,{className:"flex",children:_.jsxs(aA,{ref:r,className:Pe("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,_.jsx(Wb,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));fs.displayName=aA.displayName;const hs=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsx(lA,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:_.jsx("div",{className:Pe("pb-4 pt-0",e),children:t})}));hs.displayName=lA.displayName;const uA="Radio",[jre,dA]=Pn(uA),[zre,Bre]=jre(uA),Vre=m.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:i=!1,required:o,disabled:s,value:a="on",onCheck:l,...c}=e,[d,f]=m.useState(null),p=et(t,y=>f(y)),g=m.useRef(!1),v=d?!!d.closest("form"):!0;return m.createElement(zre,{scope:n,checked:i,disabled:s},m.createElement(Be.button,le({type:"button",role:"radio","aria-checked":i,"data-state":fA(i),"data-disabled":s?"":void 0,disabled:s,value:a},c,{ref:p,onClick:Ce(e.onClick,y=>{i||l==null||l(),v&&(g.current=y.isPropagationStopped(),g.current||y.stopPropagation())})})),v&&m.createElement(qre,{control:d,bubbles:!g.current,name:r,value:a,checked:i,required:o,disabled:s,style:{transform:"translateX(-100%)"}}))}),Hre="RadioIndicator",Wre=m.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...i}=e,o=Bre(Hre,n);return m.createElement(vn,{present:r||o.checked},m.createElement(Be.span,le({"data-state":fA(o.checked),"data-disabled":o.disabled?"":void 0},i,{ref:t})))}),qre=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Op(n),a=Mh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const p=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(p)}},[s,n,r]),m.createElement("input",le({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 fA(e){return e?"checked":"unchecked"}const Ure=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],hA="RadioGroup",[Gre,Efe]=Pn(hA,[ol,dA]),pA=ol(),gA=dA(),[Yre,Kre]=Gre(hA),Xre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:i,value:o,required:s=!1,disabled:a=!1,orientation:l,dir:c,loop:d=!0,onValueChange:f,...p}=e,g=pA(n),v=Fs(c),[y,x]=Qn({prop:o,defaultProp:i,onChange:f});return m.createElement(Yre,{scope:n,name:r,required:s,disabled:a,value:y,onValueChange:x},m.createElement(Dm,le({asChild:!0},g,{orientation:l,dir:v,loop:d}),m.createElement(Be.div,le({role:"radiogroup","aria-required":s,"aria-orientation":l,"data-disabled":a?"":void 0,dir:v},p,{ref:t}))))}),Qre="RadioGroupItem",Zre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...i}=e,o=Kre(Qre,n),s=o.disabled||r,a=pA(n),l=gA(n),c=m.useRef(null),d=et(t,c),f=o.value===i.value,p=m.useRef(!1);return m.useEffect(()=>{const g=y=>{Ure.includes(y.key)&&(p.current=!0)},v=()=>p.current=!1;return document.addEventListener("keydown",g),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",g),document.removeEventListener("keyup",v)}},[]),m.createElement(Tm,le({asChild:!0},a,{focusable:!s,active:f}),m.createElement(Vre,le({disabled:s,required:o.required,checked:f},l,i,{name:o.name,ref:d,onCheck:()=>o.onValueChange(i.value),onKeyDown:Ce(g=>{g.key==="Enter"&&g.preventDefault()}),onFocus:Ce(i.onFocus,()=>{var g;p.current&&((g=c.current)===null||g===void 0||g.click())})})))}),Jre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,i=gA(n);return m.createElement(Wre,le({},i,r,{ref:t}))}),mA=Xre,vA=Zre,eie=Jre,bA=ue.forwardRef(({className:e,...t},n)=>_.jsx(mA,{className:Pe("grid gap-2",e),...t,ref:n}));bA.displayName=mA.displayName;const kx=ue.forwardRef(({className:e,...t},n)=>_.jsx(vA,{ref:n,className:Pe("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:_.jsx(eie,{className:"flex items-center justify-center",children:_.jsx(H2,{className:"h-2.5 w-2.5 fill-current text-current"})})}));kx.displayName=vA.displayName;function yA(){var i;const e=_e(o=>o.card.cfg),t=_e(o=>o.actions.setCardCfg),n=(i=e==null?void 0:e.options)==null?void 0:i.indexAxis;function r(o){const s={...e,options:{...e==null?void 0:e.options,indexAxis:o}};t(s)}return _.jsxs("div",{children:[_.jsx("p",{className:"font-semibold",children:"Orientation"}),_.jsxs(bA,{value:n,onValueChange:r,className:"flex gap-3 mt-2 ",defaultValue:"x",children:[_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx(kx,{value:"x",id:"r1"}),_.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx(kx,{value:"y",id:"r2"}),_.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})]})}function xA(){var r,i,o;const e=_e(s=>s.card.cfg),t=_e(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 _.jsxs(_.Fragment,{children:[_.jsx("label",{className:"font-medium",children:"Data Labels"}),_.jsxs(lM,{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:[_.jsx(Py,{className:"w-[180px] mt-2 focus:ring-1 focus:ring-offset-0 h-7",children:_.jsx(uM,{placeholder:"Select position"})}),_.jsx(ky,{children:_.jsxs(cM,{children:[_.jsx(Ap,{children:"Data Labels"}),_.jsx(_a,{value:"none",children:"None"}),_.jsx(_a,{value:"start",children:"Start"}),_.jsx(_a,{value:"center",children:"Center"}),_.jsx(_a,{value:"end",children:"End"})]})})]})]})}function wA(){const e=_e(i=>i.card.preferences),t=_e(i=>i.actions.setCardPreferences),n=_e(i=>{var o;return(o=i.card.preferences)==null?void 0:o.filterOnClickField}),r=_e(i=>i.actions.setFilterOnClickField);return _.jsxs("div",{children:[_.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[_.jsx(Pp,{checked:!!(e!=null&&e.filterOnClick),onCheckedChange:i=>{t({...e,filterOnClick:!!i})}}),_.jsx(ns,{children:"Filter on click"})]}),(e==null?void 0:e.filterOnClick)===!0&&_.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx(Ku,{value:n||"",className:" h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"expression (optional)",onChange:i=>r(i.target.value)}),_.jsxs(Vb,{children:[_.jsx(L2,{children:_.jsx(e2,{className:"h-4 w-4 opacity-70"})}),_.jsx(Ih,{children:_.jsxs("div",{className:"max-w-[200px]",children:["The x-axis expression of your query. Example:",_.jsx("div",{className:" mt-1 text-xs font-mono",children:"TO_CHAR(order_date, 'YYYY-MM')"})]})})]})]})]})}const tie={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},nie={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function rie(){const e=_e(t=>t.card.type);return _.jsxs("div",{className:"p-6 space-y-6",children:[_.jsx(cA,{className:" ",type:"single",collapsible:!0,children:iie(e)}),_.jsx("section",{className:"",children:["line","bar"].includes(e)&&_.jsx(yA,{})}),_.jsx("div",{children:_.jsx(xA,{})}),_.jsx("div",{children:_.jsx(wA,{})})]})}function iie(e){if(["line","bar"].includes(e))return _.jsxs(_.Fragment,{children:[_.jsxs(ds,{className:"border-muted",value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:_.jsx("p",{children:"Chart Query"})}),_.jsxs(hs,{className:" ",children:[_.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"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"X-axis - Category (ex. city)"}),_.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),_.jsxs(ds,{className:"border-muted",value:"item-2",children:[_.jsx(fs,{className:" font-normal",children:"Mixed Chart"}),_.jsxs(hs,{className:" text-xs space-y-2",children:[_.jsxs("p",{children:["Click ",_.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),_.jsx("pre",{children:JSON.stringify(tie,null,2)})]})]}),_.jsxs(ds,{className:"border-muted",value:"item-3",children:[_.jsx(fs,{className:" font-normal",children:"Area Chart"}),_.jsxs(hs,{className:" text-xs space-y-2",children:[_.jsxs("p",{children:["Click ",_.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",_.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."]}),_.jsx("pre",{children:JSON.stringify(nie,null,2)})]})]})]});if(e==="bubble")return _.jsx(_.Fragment,{children:_.jsxs(ds,{className:"border-muted",value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:_.jsxs("p",{children:["How to create a ",_.jsx("span",{children:e})," chart query?"]})}),_.jsxs(hs,{className:" ",children:[_.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"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),_.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),_.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),_.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(e==="scatter")return _.jsx(_.Fragment,{children:_.jsxs(ds,{value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:_.jsxs("p",{children:["How to create a ",_.jsx("span",{children:e})," chart query?"]})}),_.jsxs(hs,{className:" ",children:[_.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"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Group (opt) - Category (ex. state)"}),_.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),_.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(e))return _.jsx(_.Fragment,{children:_.jsxs(ds,{value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:_.jsxs("p",{children:["How to create a"," ",_.jsxs("span",{children:[e==="polarArea"?"polar":e," "]})," ","chart query?"]})}),_.jsxs(hs,{className:" ",children:[_.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, measure FROM table"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function oie(){return _.jsxs("div",{className:"px-6 py-2 space-y-6",children:[_.jsx(cA,{className:" ",type:"single",collapsible:!0,children:_.jsxs(ds,{className:"border-muted",value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:"Stacked chart query?"}),_.jsxs(hs,{className:" ",children:[_.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"X-axis - Category (ex. country)"}),_.jsx("li",{children:"Stack by - Category (ex. city)"}),_.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]})}),_.jsx("section",{className:"",children:_.jsx(yA,{})}),_.jsx("div",{children:_.jsx(xA,{})}),_.jsx("div",{children:_.jsx(wA,{})})]})}function sie(){const e=_e(t=>t.card.type);return _.jsx(kl,{className:" text-sm h-full w-full ",children:e==="stackedBar"?_.jsx(oie,{}):_.jsx(rie,{})})}function aie(){const e=_e(t=>t.isShowingVisual);return _.jsxs(zM,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[_.jsx(Fp,{className:"flex",minSize:40,defaultSize:40,children:_.jsx(Wne,{})}),_.jsx(BM,{className:"border-[1.5px] border-muted"}),_.jsx(Fp,{minSize:60,defaultSize:60,children:e?_.jsxs(zM,{direction:"horizontal",children:[_.jsx(_.Fragment,{children:_.jsx(Fp,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:_.jsx(sie,{})})}),_.jsx(BM,{className:"border-[1.5px] border-muted"}),_.jsx(Fp,{minSize:40,defaultSize:75,maxSize:100,children:_.jsx(QT,{})})]}):_.jsx(QT,{})})]})}function lie({authToken:e,onSave:t,onClose:n}){_e(s=>s.actions.setCard);const r=_e(s=>s.actions.setOnSave),i=_e(s=>s.actions.setOnClose),o=ge(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]),_.jsxs(Bk,{className:"border-x border-b rounded-none border-muted ",children:[_.jsx(Vk,{className:" rounded-none border-r-[3px] border-muted ",children:_.jsx(pM,{})}),_.jsx(Hk,{children:_.jsx(aie,{})})]})}function cie(){ge(s=>s.selectedCardId);const e=ge(s=>s.selectedSheetId),t=ge(s=>s.actions.setIsVisualEditing);ge(s=>s.actions.setIsEditorSaveEvent);const n=ge(s=>s.isVisualEditing);ge(s=>s.actions.getSelectedCard());const r=ge(s=>s.actions.updateCard);function i(s){e&&(r(e,s),t(!1))}function o(){t(!1)}return _.jsx("div",{className:`grow flex ${n?"block":"hidden"}`,children:_.jsx(lie,{onSave:i,onClose:o})})}function uie({columns:e,tableName:t}){const n=_e(f=>f.selectedConnectionId),r=_e(f=>f.selectedDatabaseName),i=_e(f=>f.selectedSchemaName),o=_e(f=>f.selectedTableName),s=ge(f=>f.dashboard.filters)||[],a=ge(f=>f.actions.addFilter),l=ge(f=>f.actions.removeFilter),c=ge(f=>f.actions.removeFilterValue);function d(f){const p=s==null?void 0:s.find(g=>g.column===f.column_name&&g.table===o&&g.database===r);if(p)c(p.id),l(p.id);else{const g=M0(i||"",t),v=`SELECT ${f.column_name}, COUNT(*) FROM ${g} GROUP BY ${f.column_name} ORDER BY ${f.column_name} ASC LIMIT 50`,y=`SELECT min(${f.column_name}) as min, max(${f.column_name}) as max FROM ${g}`;if(t==="api"&&n){a({id:yh(),column:f.column_name,title:f.column_name,dataType:f.data_type,table:"api",database:"NA",connectionId:n,sql:Iu.includes(f.data_type)?y:v});return}if(!n||!r||!o)throw new Error("missing connectionId, database, or table");a({id:yh(),column:f.column_name,title:f.column_name,dataType:f.data_type,table:o,database:r,connectionId:n,sql:Iu.includes(f.data_type)?y:v})}}return _.jsx(kl,{className:" h-[70vh] mt-2 xbg-red-100 px-3",children:e==null?void 0:e.map(f=>{const p=s==null?void 0:s.find(g=>g.column===f.column_name&&g.table===o&&g.database===r);return _.jsx("div",{onClick:()=>d(f),className:Pe(" 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 ":p}),children:_.jsxs("div",{className:"flex items-center gap-2 ",children:[_.jsx(hM,{column:f}),_.jsx("span",{children:f.column_name})]})},f.column_name)})})}function die(){ge(t=>t.showFilters);const e=ge(t=>t.actions.setShowFilters);return _.jsxs("section",{className:" relative space-y-4 py-0 px-4 border-muted bg-red-x100",children:[_.jsx(it,{onClick:()=>e(!1),className:" p-0 h-7 w-7 absolute top-0 right-4",variant:"outline",children:_.jsx(ia,{})}),_.jsx("p",{className:"text-md px-2",children:"Data Columns"}),_.jsx("div",{children:_.jsx(pM,{ColumnsComponent:(t,n,r)=>_.jsx(uie,{schemaName:t,tableName:n,columns:r})})})]})}function fie(){ge(n=>n.dashboard);const e=ge(n=>n.showFilters),t=ge(n=>n.isVisualEditing);return ge(n=>n.bookmarkKey),_.jsxs("div",{role:"dashboard-plus-main",className:` flex grow ${t?"hidden":"block"}`,children:[_.jsx(QP,{}),e&&_.jsx("div",{role:"filter-aside-container",className:"",children:_.jsx(die,{})})]})}function hie(){const e=ge(r=>r.dashboard),t=ge(r=>r.actions.setDashboard),n=ge(r=>r.showDashboardJSON);return ge(r=>r.actions.setShowDashboardJSON),_.jsx("div",{className:Pe(" p-2",{hidden:!n}),children:_.jsx(nD,{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 pie({showControls:e=!1,showFooter:t=!0,...n}){return ge(r=>r.isVisualEditing),_.jsxs(ZP,{children:[_.jsx(hie,{}),_.jsxs(Kw,{...n,children:[e&&_.jsx(XK,{}),_.jsx(cie,{}),_.jsx(fie,{})]})]})}function gie(){const e=ge(t=>t.actions);return{setDashboardTitle:e.setDashboardTitle,getStyle:e.getStyle,getDashboard:e.getDashboard,setOnSaveFunction:e.setOnSaveFunction,setOnAddCard:e.setOnAddCard,setOnUpateCard:e.setOnUpdateCard,setOnRemoveCard:e.setOnRemoveCard}}ct.Dashboard=JP,ct.DashboardPlus=pie,ct.DashboardWC=YG,ct.cleanCard=Pk,ct.getBookmarkKey=ss,ct.getDashbaordStateWithoutData=by,ct.useActions=gie,ct.useDashboardStore=ge,Object.defineProperty(ct,Symbol.toStringTag,{value:"Module"})});
505
+ Visual Query Syntax: ${Vne}`,{data:w,isLoading:S,isFetching:C,isError:P,refetch:O}=Sr({queryKey:["ai-query"],queryFn:()=>tl("https://semaphor.cloud/api/v1/ai",(s==null?void 0:s.accessToken)||"",{user_content:`userContent: ${y} ${a?x:""}`}),enabled:!1});function k(X){if(X.toLowerCase().includes("bar"))f("bar");else if(X.toLowerCase().includes("line"))f("line");else if(X.toLowerCase().includes("bubble"))f("bubble");else if(X.toLowerCase().includes("scatter"))f("scatter");else if(X.toLowerCase().includes("stacked"))f("stackedBar");else if(X.toLowerCase().includes("pie"))f("pie");else if(X.toLowerCase().includes("donut")||X.toLowerCase().includes("doughnut"))f("doughnut");else if(X.toLowerCase().includes("radar"))f("radar");else return f("bar"),!1;return!0}function A(){n&&(k(n)&&l(!0),O())}m.useEffect(()=>{i&&(A(),o(!1))},[i,o]);const L={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"5px",width:"100%"},F={fontFamily:"monospace",fontSize:14,lineHeight:1.6},z={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},B={p:({node:X,...K})=>_.jsx("p",{style:L,...K}),pre:({node:X,...K})=>_.jsxs("pre",{className:" bg-muted/50 space-y-2 p-3 rounded-sm",style:F,children:[_.jsx("code",{className:" whitespace-normal",children:K.children}),_.jsxs("div",{className:" flex justify-start gap-2",children:[_.jsx(it,{onClick:V,size:"sm",variant:"outline",children:_.jsx(JE,{})}),_.jsx(it,{onClick:$=>{const J=V($);J&&(t(!1),c(J),d(!0))},size:"sm",variant:"outline",children:_.jsx(Zj,{})})]})]}),li:({node:X,...K})=>_.jsx("li",{style:z,...K})};function V(X){const K=X.currentTarget.closest("pre");if(!K)return;const $=K.textContent||K.innerText;return navigator.clipboard.writeText($).then(()=>console.log("Text copied to clipboard")).catch(J=>console.error("Error in copying text: ",J)),$}return _.jsxs(wy,{open:e,onOpenChange:t,children:[_.jsx(_y,{asChild:!0,children:_.jsx(it,{size:"sm",className:"",variant:"outline",children:_.jsx(nV,{strokeWidth:1,size:16})})}),_.jsxs(_p,{className:" border-muted sm:max-w-[425px] md:min-w-[625px] md:max-h-[625px] flex flex-col justify-between overflow-auto",children:[_.jsxs(Sp,{children:[_.jsx(Cp,{children:"Ask"}),_.jsx(Ep,{children:"Need assistance with SQL queries? Feel free to ask me any question!"})]}),_.jsx(kl,{className:"h-[625px] w-full border-t border-t-muted ",children:(!S||!C)&&_.jsx(zne,{className:" pl-1 pr-3 py-1 w-full xbg-red-100 overflow-auto ",components:B,children:w==null?void 0:w.response})}),_.jsxs("div",{children:[_.jsx(lf,{className:Pe(" invisible h-1 w-full animate-pulse",{visible:S||C})}),_.jsxs("div",{className:" border rounded-md flex items-center w-full",children:[_.jsx(By,{onKeyDown:X=>{X.key==="Enter"&&!X.shiftKey&&(X.preventDefault(),r(""),A())},placeholder:"Type something...",onFocus:X=>{const K=X.target,$=K.value.length;K.setSelectionRange($,$)},className:" border-none resize-none min-h-7 max-h-10 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",value:n,onChange:X=>r(X.target.value)})," ",_.jsx(it,{className:"h-8",size:"sm",variant:"ghost",onClick:A,children:!S&&!C?_.jsx(Xj,{}):_.jsx(ku,{className:" w-4 h-4 animate-spin mr-2 text-foreground/50"})})]})]})]})]})}function Wne(){const{theme:e}=Em(),t=m.useRef(),n=m.useRef(),[r,i]=m.useState(!1),[o,s]=m.useState(!1),[a,l]=m.useState(""),[c,d]=m.useState(!1);m.useState("");const f=ge(H=>H.authToken),p=_e(H=>H.card),g=ge(H=>H.theme),v=_e(H=>H.selectedConnectionId),y=_e(H=>H.selectedDatabaseName),x=_e(H=>H.selectedSchemaName),w=_e(H=>H.selectedTableName),S=_e(H=>H.actions.setCardSql),C=_e(H=>H.card.sql),P=_e(H=>H.selectedConnectionId),O=_e(H=>H.filterValues),k=_e(H=>H.applyFilters),A=_e(H=>H.actions.setCardCustomCfg),L=_e(H=>H.actions.setFilterValues),F=_e(H=>H.onSave),z=_e(H=>H.actions.setApplyFilters),B=_e(H=>H.onClose),V=_e(H=>H.actions.setCardData),X=_e(H=>H.actions.setSqlGen),K=_e(H=>H.runSql),$=_e(H=>H.actions.setRunSql),J=_e(H=>H.actions.setIsSqlRunning),{data:G,isLoading:q,isFetching:se,isSuccess:D,isError:W,error:re,status:N,refetch:ne}=Sr({queryKey:[C],queryFn:()=>Is("https://semaphor.cloud/api/v1/query",(f==null?void 0:f.accessToken)||"",{connection_id:P,sql:C,active_filters:k?O:[]}),enabled:!1,retry:!1});m.useEffect(()=>{G&&(console.log("queryData",G),V(G.records))},[G,V]),m.useEffect(()=>{K&&(ne(),$(!1))},[K,ne,$]),m.useEffect(()=>{(q||se)&&J(!0),(W||D)&&J(!1)},[q,se,W,D,J]);function me(){S(""),V([]),X({}),A("")}const he=H=>{n.current=H};function de(){if(C&&!C.includes("{{")){const H=cZ(C);S(H),F==null||F({...p,sql:H,lastSelectedSchema:x,lastSelectedDatabase:y,lastSelectedTable:w,connectionId:v})}else F==null||F(p)}function ie(){B==null||B()}m.useEffect(()=>{const H=t.current,ye=n.current;if(H){const oe=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",Te=g==="system"?oe:g;H.editor.defineTheme("default",{base:Te==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":Te==="light"?"#ffffff":"#020817"}}),H.editor.setTheme("default")}return ye&&H&&ye.addCommand(H.KeyMod.Shift|H.KeyCode.Enter,function(){return console.log("Executing query..."),ne(),!1}),()=>{}},[e,g,t.current]);function ee(H){t.current=H}return _.jsxs("section",{role:"editor-section",className:"grow flex flex-col justify-end pt-3 p-1 ",children:[_.jsxs("div",{className:" grow flex relative overflow-y-scroll justify-between ",children:[_.jsx("div",{role:"editor-container",className:`flex ${r?"w-2/3":"w-[95%]"} xbg-red-100 p-1`,children:_.jsx(Ry,{theme:"default",onChange:H=>{S(H),console.log(H)},value:C,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:ee,onMount:he})}),r&&_.jsx("div",{className:" w-1/3 text-xs relative overflow-hidden xbg-yellow-100 p-1 ",children:_.jsxs("div",{className:"min-h-0 ",children:[_.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx(_Z,{checked:k,onCheckedChange:()=>z(!k),text:"Apply Filters"}),_.jsx(SZ,{})]}),_.jsx(Ry,{theme:"default",onChange:H=>{if(H)try{JSON.parse(H),L(JSON.parse(H))}catch{}},defaultLanguage:"json",className:"min-h-[220px] mt-1",value:JSON.stringify(O,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),O&&r&&_.jsx(ia,{onClick:()=>i(!1),className:"absolute right-6 top-1 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer"}),O&&!r&&_.jsx(W2,{onClick:()=>i(!0),className:Pe("absolute right-6 top-1 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer",{"text-red-800 font-bold":k})})]}),_.jsxs("div",{className:" flex grow px-6 pt-3 pb-4 gap-2 justify-between item-center",children:[_.jsxs("div",{className:"flex grow gap-2 items-center",children:[_.jsxs(it,{disabled:q||se,onClick:()=>{ne()},className:" shrink-0",size:"sm",variant:"outline",children:[(q||se)&&_.jsx(ku,{className:"w-4 h-4 mr-2 animate-spin text-foreground/50"}),"Run"]}),W&&_.jsx(wZ,{error:re.message}),_.jsx(it,{onClick:me,className:"",size:"sm",variant:"outline",children:"Clear"}),_.jsx(Ku,{value:a,placeholder:"Type something...",onChange:H=>{l(H.target.value)},onKeyDown:H=>{H.key==="Enter"&&(H.preventDefault(),console.log("enter pressed"),d(!0),s(!0))},className:" bg-muted border-none h-9 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"}),_.jsx(Hne,{open:o,setOpen:s,userInput:a,triggerAIRun:c,setTriggerAIRun:d,setUserInput:H=>l(H)})]}),_.jsxs("div",{className:"flex gap-2 items-end ",children:[_.jsx(it,{onClick:de,size:"sm",variant:"outline",children:_.jsx(Rh,{size:16,strokeWidth:2,className:"text-green-600 font-bold"})}),_.jsx(it,{onClick:ie,className:" w-full",size:"sm",variant:"outline",children:_.jsx(ia,{className:" h-3.5 w-3.5"})})]})]})]})}const $T="Switch",[qne,Sfe]=Pn($T),[Une,Gne]=qne($T),Yne=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:o,required:s,disabled:a,value:l="on",onCheckedChange:c,...d}=e,[f,p]=m.useState(null),g=et(t,S=>p(S)),v=m.useRef(!1),y=f?!!f.closest("form"):!0,[x=!1,w]=Qn({prop:i,defaultProp:o,onChange:c});return m.createElement(Une,{scope:n,checked:x,disabled:a},m.createElement(Be.button,le({type:"button",role:"switch","aria-checked":x,"aria-required":s,"data-state":FT(x),"data-disabled":a?"":void 0,disabled:a,value:l},d,{ref:g,onClick:Ce(e.onClick,S=>{w(C=>!C),y&&(v.current=S.isPropagationStopped(),v.current||S.stopPropagation())})})),y&&m.createElement(Qne,{control:f,bubbles:!v.current,name:r,value:l,checked:x,required:s,disabled:a,style:{transform:"translateX(-100%)"}}))}),Kne="SwitchThumb",Xne=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=Gne(Kne,n);return m.createElement(Be.span,le({"data-state":FT(i.checked),"data-disabled":i.disabled?"":void 0},r,{ref:t}))}),Qne=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Op(n),a=Mh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const p=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(p)}},[s,n,r]),m.createElement("input",le({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 FT(e){return e?"checked":"unchecked"}const jT=Yne,Zne=Xne,zT=ue.forwardRef(({className:e,...t},n)=>_.jsx(jT,{className:Pe("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:_.jsx(Zne,{className:Pe("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")})}));zT.displayName=jT.displayName;function BT({className:e,...t}){const[n,r]=m.useState(0),i=ge(l=>l.themeStyle),o=_e(l=>l.card),s=_e(l=>l.actions.setCard);if(m.useEffect(()=>{r(n+1)},[o.data,o.type,o.cfg,o.customCfg,i]),!o.id)return null;let a;return o.data&&o.data.length>0&&(a=kb({data:o.data,cardType:o.type,cfg:o.cfg,customCfg:o.customCfg})),_.jsxs(Mv,{role:"editor-visual-card",className:Pe(" relative h-full flex flex-col rounded-none",e),...t,children:[_.jsxs(Dv,{children:[_.jsx(qc,{text:o.title,onSave:l=>s({...o,title:l}),children:_.jsx(Tv,{className:"text-base",children:o.title})}),_.jsx(qc,{text:o.description||"",onSave:l=>s({...o,description:l}),children:_.jsxs(Av,{children:[" ",o.description]})})]}),_.jsxs(Iv,{className:"flex flex-col pb-3 grow",children:[o.type!=="table"&&a&&_.jsx(QE,{cfg:a},n),o.type==="table"&&o.data&&o.data.length>0&&_.jsx(cO,{children:_.jsx(a0,{data:o==null?void 0:o.data})})]})]})}function Jne(){const[e,t]=m.useState(!1),[n,r]=m.useState(""),[i,o]=m.useState(""),[s,a]=m.useState(""),l=_e(x=>x.card),c=_e(x=>x.card.customCfg),d=_e(x=>x.actions.setCardCustomCfg);function f(x){var C,P;const w={...x,data:{...x==null?void 0:x.data,datasets:(P=(C=x==null?void 0:x.data)==null?void 0:C.datasets)==null?void 0:P.map(O=>({...O,data:[]}))}};return JSON.stringify(w,null,1)}function p(){if(!l.data||l.data.length===0)return;const x=kb({data:l.data,cardType:l.type,cfg:l.cfg});x&&(r(JSON.stringify(x,null,1)),c&&o(JSON.stringify(c,null,1)))}function g(){if(i)try{const x=JSON.parse(i);return x?(d(x),a(""),o(""),x):void 0}catch(x){console.log(x),a("Invalid JSON")}}function v(){o(""),d(null)}function y(){let x;if(c){const w=$s.cloneDeep(l.cfg),S=$s.merge(w,c);return x=f(S),x}return n?(x=f(JSON.parse(n)),x):""}return _.jsxs(wy,{open:e,onOpenChange:t,children:[_.jsx(_y,{asChild:!0,children:_.jsx(it,{onClick:p,className:`h-7 ${c&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:c?"Custom Config":"Customize"})}),_.jsx(_p,{className:" sm:max-w-[425px] md:min-w-[600px] md:min-h-[700px] lg:min-w-[800px] xl:min-w-[1000px]",children:_.jsxs("div",{className:"bg-red-x100 flex flex-col gap-2 justify-between",children:[_.jsxs(Sp,{className:"",children:[_.jsx(Cp,{children:"Customize Chart"}),_.jsxs(Ep,{children:["See the configuration options and documentation",_.jsx("a",{target:"_blank",className:"ml-1 underline text-blue-500 ",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),_.jsxs("div",{className:"grow flex flex-wrap gap-2",children:[_.jsx(BT,{className:"flex-1 rounded shadow-none"}),_.jsxs(a_,{defaultValue:"custom-config",className:" flex flex-col flex-1",children:[_.jsxs(l_,{className:" justify-start border rounded-sm rounded-b-none border-b-0 ",children:[_.jsxs(Im,{value:"custom-config",children:[c&&_.jsx(ZE,{className:"w-5 h-5 mr-1 text-green-600"}),c?"Custom Config":"Default Config"]}),_.jsx(Im,{className:"",value:"output",children:"Output"})]}),_.jsx(ff,{className:" grow mt-0 bg-red-x p-2 border border-t-0 rounded-b ",value:"output",children:_.jsx(By,{disabled:!0,value:n,className:" border-none resize-none font-mono h-full focus-visible:ring-0 focus-visible:ring-offset-0"})}),_.jsx(ff,{className:"grow mt-0 border border-t-0 rounded-b ",value:"custom-config",children:_.jsx(Ry,{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:x=>o(x)})})]})]}),_.jsxs(Sy,{className:"flex items-center",children:[_.jsx(ns,{className:"text-red-500 mr-2",children:s}),_.jsx(it,{disabled:!c,onClick:v,variant:"outline",children:"Reset"}),_.jsx(it,{onClick:g,variant:"outline",children:"Apply"}),_.jsx(it,{onClick:()=>t(!1),variant:"outline",children:"Close"})]})]})})]})}var VT={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},HT=m.createContext&&m.createContext(VT),ere=["attr","size","title"];function tre(e,t){if(e==null)return{};var n=nre(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 nre(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 tg(){return tg=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},tg.apply(this,arguments)}function WT(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 ng(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?WT(Object(n),!0).forEach(function(r){rre(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):WT(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function rre(e,t,n){return t=ire(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ire(e){var t=ore(e,"string");return typeof t=="symbol"?t:String(t)}function ore(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 qT(e){return e&&e.map((t,n)=>m.createElement(t.tag,ng({key:n},t.attr),qT(t.child)))}function dd(e){return t=>m.createElement(sre,tg({attr:ng({},e.attr)},t),qT(e.child))}function sre(e){var t=n=>{var{attr:r,size:i,title:o}=e,s=tre(e,ere),a=i||n.size||"1em",l;return n.className&&(l=n.className),e.className&&(l=(l?l+" ":"")+e.className),m.createElement("svg",tg({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,s,{className:l,style:ng(ng({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 HT!==void 0?m.createElement(HT.Consumer,null,n=>t(n)):t(VT)}function UT(e){return dd({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 GT(e){return dd({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 YT(e){return dd({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137,28.05a11.94,11.94,0,0,0-9.12,3.08A12.09,12.09,0,0,0,124,40V80.67a11.88,11.88,0,0,0,9.9,11.81,36,36,0,1,1-41.85,37.4c-.47-9.14,1.47-16.8,5.75-22.79h0a11.89,11.89,0,0,0-1.3-15.35L68.87,63.51a12,12,0,0,0-17.74.83A99.6,99.6,0,0,0,57.79,199.2,99.24,99.24,0,0,0,128,228h1.43A100.29,100.29,0,0,0,228,129.42C228.72,77.21,188.76,32.68,137,28.05ZM57.28,69.46A4,4,0,0,1,60.2,68h.19a3.91,3.91,0,0,1,2.79,1.14L90.81,97.36a3.93,3.93,0,0,1,.48,5.08A40.47,40.47,0,0,0,84.08,124h-48A90.36,90.36,0,0,1,57.28,69.46ZM36.09,132H84.18A44,44,0,0,0,124,171.81V219.9A92,92,0,0,1,36.09,132ZM193,193a91.43,91.43,0,0,1-61,26.92V171.82a43.51,43.51,0,0,0,26-11.63,44,44,0,0,0-22.79-75.6A4,4,0,0,1,132,80.67V40a4,4,0,0,1,1.31-3,3.89,3.89,0,0,1,3-1c47.59,4.26,84.34,45.24,83.67,93.29A91.42,91.42,0,0,1,193,193Z"},child:[]}]})(e)}function KT(e){return dd({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 XT(e){return dd({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 are(){const[e,t]=m.useState(!1),n=_e(s=>s.card.type),r=_e(s=>s.actions.setCardType),i=_e(s=>s.actions.setCardCustomCfg);function o(s){r(s),i(null),t(!1)}return _.jsxs(pp,{open:e,onOpenChange:t,children:[_.jsx(gp,{asChild:!0,children:_.jsx(it,{className:"h-7 px-2",variant:"outline",children:_.jsx(lre,{className:"h-4 w-4",chartType:n})})}),_.jsx(Wu,{className:"w-50",children:_.jsxs("div",{className:"grid grid-cols-3 place-items-center ",children:[_.jsx(it,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:_.jsx(B2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("line"),variant:"ghost",children:_.jsx(q2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("stackedBar"),variant:"ghost",children:_.jsx(XT,{className:"h-6 w-6 text-foreground/50 ",strokeWidth:0})}),_.jsx(it,{onClick:()=>o("scatter"),variant:"ghost",children:_.jsx(G2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("bubble"),variant:"ghost",children:_.jsx(KT,{strokeWidth:2})}),_.jsx(it,{onClick:()=>o("pie"),variant:"ghost",children:_.jsx(U2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("doughnut"),variant:"ghost",children:_.jsx(YT,{className:"h-7 w-7",strokeWidth:.5})}),_.jsx(it,{onClick:()=>o("radar"),variant:"ghost",children:_.jsx(UT,{className:"h-6 w-6 text-foreground/50 font-extralight",strokeWidth:.5})}),_.jsx(it,{onClick:()=>o("polarArea"),variant:"ghost",children:_.jsx(GT,{className:"h-6 w-6 text-foreground/50",strokeWidth:1})}),_.jsx(it,{onClick:()=>o("table"),variant:"ghost",children:_.jsx(qb,{className:"h-6 w-6 text-foreground/90",strokeWidth:1})})]})})]})}function lre({chartType:e,className:t}){switch(e){case"bar":return _.jsx(B2,{className:t});case"line":return _.jsx(q2,{className:t});case"pie":return _.jsx(U2,{className:t});case"radar":return _.jsx(UT,{className:t});case"scatter":return _.jsx(G2,{className:t});case"bubble":return _.jsx(KT,{className:t});case"doughnut":return _.jsx(YT,{className:t});case"stackedBar":return _.jsx(XT,{className:"h-5 w-5 text-foreground/50 ",strokeWidth:0});case"polarArea":return _.jsx(GT,{className:t});default:return _.jsx(qb,{className:t})}}function cre(){const e=_e(n=>n.card.refreshInterval),t=_e(n=>n.actions.setCardRefreshInterval);return _.jsxs(pp,{children:[_.jsx(gp,{asChild:!0,children:_.jsx(it,{className:"h-7",variant:"outline",children:"Realtime"})}),_.jsx(Wu,{className:"w-[200px]",children:_.jsx("div",{className:"grid gap-4",children:_.jsx("div",{className:"grid gap-2",children:_.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[_.jsx(ns,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),_.jsx(Ku,{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"})]})})})})]})}function QT(){const e=_e(r=>r.card),t=_e(r=>r.isShowingVisual),n=_e(r=>r.isSqlRunning);return _e(r=>r.onSave),_e(r=>r.onClose),_e(r=>r.actions.setCardSql),_e(r=>r.actions.setCardType),_e(r=>r.actions.setSqlGen),_.jsxs("div",{className:" h-full relative flex flex-col",children:[n&&_.jsx(ku,{className:" w-10 h-10 z-10 absolute m-auto left-0 right-0 top-0 bottom-0 animate-spin text-foreground/10 "}),_.jsxs("div",{className:" h-10 px-6 pt-6 bg-red-x100 mb-0 z-10 right-0 flex justify-end items-center gap-2",children:[t&&_.jsxs("div",{className:"bg-red-x00 flex grow gap-2",children:[_.jsx(are,{}),_.jsx(Jne,{}),_.jsx(cre,{})]}),_.jsx(ure,{})]}),t?_.jsx(BT,{className:"grow border-none shadow-none "}):_.jsx("div",{className:"w-full mt-4 px-6 bg-red-x00 grow border-none shadow-none overflow-y-auto ",children:e.data&&e.data.length>0&&_.jsx(a0,{data:e.data})})]})}function ure(){const e=_e(n=>n.isShowingVisual),t=_e(n=>n.actions.setIsShowingVisual);return _.jsxs("div",{className:" flex items-center space-x-2",children:[_.jsx(ns,{htmlFor:"visualize",children:"Chart"}),_.jsx(zT,{checked:e,onCheckedChange:()=>t(!e),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}const ZT="Collapsible",[dre,JT]=Pn(ZT),[fre,_x]=dre(ZT),hre=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(fre,{scope:n,disabled:o,contentId:or(),open:l,onOpenToggle:m.useCallback(()=>c(d=>!d),[c])},m.createElement(Be.div,le({"data-state":Sx(l),"data-disabled":o?"":void 0},a,{ref:t})))}),pre="CollapsibleTrigger",gre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=_x(pre,n);return m.createElement(Be.button,le({type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":Sx(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled},r,{ref:t,onClick:Ce(e.onClick,i.onOpenToggle)}))}),eA="CollapsibleContent",mre=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=_x(eA,e.__scopeCollapsible);return m.createElement(vn,{present:n||i.open},({present:o})=>m.createElement(vre,le({},r,{ref:t,present:o})))}),vre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...o}=e,s=_x(eA,n),[a,l]=m.useState(r),c=m.useRef(null),d=et(t,c),f=m.useRef(0),p=f.current,g=m.useRef(0),v=g.current,y=s.open||a,x=m.useRef(y),w=m.useRef();return m.useEffect(()=>{const S=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(S)},[]),Vn(()=>{const S=c.current;if(S){w.current=w.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,g.current=C.width,x.current||(S.style.transitionDuration=w.current.transitionDuration,S.style.animationName=w.current.animationName),l(r)}},[s.open,r]),m.createElement(Be.div,le({"data-state":Sx(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!y},o,{ref:d,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style}}),y&&i)});function Sx(e){return e?"open":"closed"}const bre=hre,yre=gre,xre=mre,us="Accordion",wre=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Cx,_re,Sre]=uf(us),[rg,Cfe]=Pn(us,[Sre,JT]),Ex=JT(),tA=m.forwardRef((e,t)=>{const{type:n,...r}=e,i=r,o=r;return m.createElement(Cx.Provider,{scope:e.__scopeAccordion},n==="multiple"?m.createElement(Pre,le({},o,{ref:t})):m.createElement(Ore,le({},i,{ref:t})))});tA.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[nA,Cre]=rg(us),[rA,Ere]=rg(us,{collapsible:!1}),Ore=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(nA,{scope:e.__scopeAccordion,value:a?[a]:[],onItemOpen:l,onItemClose:m.useCallback(()=>o&&l(""),[o,l])},m.createElement(rA,{scope:e.__scopeAccordion,collapsible:o},m.createElement(iA,le({},s,{ref:t}))))}),Pre=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(d=>a((f=[])=>[...f,d]),[a]),c=m.useCallback(d=>a((f=[])=>f.filter(p=>p!==d)),[a]);return m.createElement(nA,{scope:e.__scopeAccordion,value:s,onItemOpen:l,onItemClose:c},m.createElement(rA,{scope:e.__scopeAccordion,collapsible:!0},m.createElement(iA,le({},o,{ref:t}))))}),[kre,ig]=rg(us),iA=m.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:i,orientation:o="vertical",...s}=e,a=m.useRef(null),l=et(a,t),c=_re(n),f=Fs(i)==="ltr",p=Ce(e.onKeyDown,g=>{var v;if(!wre.includes(g.key))return;const y=g.target,x=c().filter(F=>{var z;return!((z=F.ref.current)!==null&&z!==void 0&&z.disabled)}),w=x.findIndex(F=>F.ref.current===y),S=x.length;if(w===-1)return;g.preventDefault();let C=w;const P=0,O=S-1,k=()=>{C=w+1,C>O&&(C=P)},A=()=>{C=w-1,C<P&&(C=O)};switch(g.key){case"Home":C=P;break;case"End":C=O;break;case"ArrowRight":o==="horizontal"&&(f?k():A());break;case"ArrowDown":o==="vertical"&&k();break;case"ArrowLeft":o==="horizontal"&&(f?A():k());break;case"ArrowUp":o==="vertical"&&A();break}const L=C%S;(v=x[L].ref.current)===null||v===void 0||v.focus()});return m.createElement(kre,{scope:n,disabled:r,direction:i,orientation:o},m.createElement(Cx.Slot,{scope:n},m.createElement(Be.div,le({},s,{"data-orientation":o,ref:l,onKeyDown:r?void 0:p}))))}),Ox="AccordionItem",[Mre,Px]=rg(Ox),Dre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...i}=e,o=ig(Ox,n),s=Cre(Ox,n),a=Ex(n),l=or(),c=r&&s.value.includes(r)||!1,d=o.disabled||e.disabled;return m.createElement(Mre,{scope:n,open:c,disabled:d,triggerId:l},m.createElement(bre,le({"data-orientation":o.orientation,"data-state":sA(c)},a,i,{ref:t,disabled:d,open:c,onOpenChange:f=>{f?s.onItemOpen(r):s.onItemClose(r)}})))}),Tre="AccordionHeader",Are=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=ig(us,n),o=Px(Tre,n);return m.createElement(Be.h3,le({"data-orientation":i.orientation,"data-state":sA(o.open),"data-disabled":o.disabled?"":void 0},r,{ref:t}))}),oA="AccordionTrigger",Ire=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=ig(us,n),o=Px(oA,n),s=Ere(oA,n),a=Ex(n);return m.createElement(Cx.ItemSlot,{scope:n},m.createElement(yre,le({"aria-disabled":o.open&&!s.collapsible||void 0,"data-orientation":i.orientation,id:o.triggerId},a,r,{ref:t})))}),Nre="AccordionContent",Rre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=ig(us,n),o=Px(Nre,n),s=Ex(n);return m.createElement(xre,le({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 sA(e){return e?"open":"closed"}const Lre=tA,$re=Dre,Fre=Are,aA=Ire,lA=Rre,cA=Lre,ds=ue.forwardRef(({className:e,...t},n)=>_.jsx($re,{ref:n,className:Pe("border-b",e),...t}));ds.displayName="AccordionItem";const fs=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsx(Fre,{className:"flex",children:_.jsxs(aA,{ref:r,className:Pe("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,_.jsx(Wb,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));fs.displayName=aA.displayName;const hs=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsx(lA,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:_.jsx("div",{className:Pe("pb-4 pt-0",e),children:t})}));hs.displayName=lA.displayName;const uA="Radio",[jre,dA]=Pn(uA),[zre,Bre]=jre(uA),Vre=m.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:i=!1,required:o,disabled:s,value:a="on",onCheck:l,...c}=e,[d,f]=m.useState(null),p=et(t,y=>f(y)),g=m.useRef(!1),v=d?!!d.closest("form"):!0;return m.createElement(zre,{scope:n,checked:i,disabled:s},m.createElement(Be.button,le({type:"button",role:"radio","aria-checked":i,"data-state":fA(i),"data-disabled":s?"":void 0,disabled:s,value:a},c,{ref:p,onClick:Ce(e.onClick,y=>{i||l==null||l(),v&&(g.current=y.isPropagationStopped(),g.current||y.stopPropagation())})})),v&&m.createElement(qre,{control:d,bubbles:!g.current,name:r,value:a,checked:i,required:o,disabled:s,style:{transform:"translateX(-100%)"}}))}),Hre="RadioIndicator",Wre=m.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...i}=e,o=Bre(Hre,n);return m.createElement(vn,{present:r||o.checked},m.createElement(Be.span,le({"data-state":fA(o.checked),"data-disabled":o.disabled?"":void 0},i,{ref:t})))}),qre=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Op(n),a=Mh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const p=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(p)}},[s,n,r]),m.createElement("input",le({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 fA(e){return e?"checked":"unchecked"}const Ure=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],hA="RadioGroup",[Gre,Efe]=Pn(hA,[ol,dA]),pA=ol(),gA=dA(),[Yre,Kre]=Gre(hA),Xre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:i,value:o,required:s=!1,disabled:a=!1,orientation:l,dir:c,loop:d=!0,onValueChange:f,...p}=e,g=pA(n),v=Fs(c),[y,x]=Qn({prop:o,defaultProp:i,onChange:f});return m.createElement(Yre,{scope:n,name:r,required:s,disabled:a,value:y,onValueChange:x},m.createElement(Dm,le({asChild:!0},g,{orientation:l,dir:v,loop:d}),m.createElement(Be.div,le({role:"radiogroup","aria-required":s,"aria-orientation":l,"data-disabled":a?"":void 0,dir:v},p,{ref:t}))))}),Qre="RadioGroupItem",Zre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...i}=e,o=Kre(Qre,n),s=o.disabled||r,a=pA(n),l=gA(n),c=m.useRef(null),d=et(t,c),f=o.value===i.value,p=m.useRef(!1);return m.useEffect(()=>{const g=y=>{Ure.includes(y.key)&&(p.current=!0)},v=()=>p.current=!1;return document.addEventListener("keydown",g),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",g),document.removeEventListener("keyup",v)}},[]),m.createElement(Tm,le({asChild:!0},a,{focusable:!s,active:f}),m.createElement(Vre,le({disabled:s,required:o.required,checked:f},l,i,{name:o.name,ref:d,onCheck:()=>o.onValueChange(i.value),onKeyDown:Ce(g=>{g.key==="Enter"&&g.preventDefault()}),onFocus:Ce(i.onFocus,()=>{var g;p.current&&((g=c.current)===null||g===void 0||g.click())})})))}),Jre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,i=gA(n);return m.createElement(Wre,le({},i,r,{ref:t}))}),mA=Xre,vA=Zre,eie=Jre,bA=ue.forwardRef(({className:e,...t},n)=>_.jsx(mA,{className:Pe("grid gap-2",e),...t,ref:n}));bA.displayName=mA.displayName;const kx=ue.forwardRef(({className:e,...t},n)=>_.jsx(vA,{ref:n,className:Pe("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:_.jsx(eie,{className:"flex items-center justify-center",children:_.jsx(H2,{className:"h-2.5 w-2.5 fill-current text-current"})})}));kx.displayName=vA.displayName;function yA(){var i;const e=_e(o=>o.card.cfg),t=_e(o=>o.actions.setCardCfg),n=(i=e==null?void 0:e.options)==null?void 0:i.indexAxis;function r(o){const s={...e,options:{...e==null?void 0:e.options,indexAxis:o}};t(s)}return _.jsxs("div",{children:[_.jsx("p",{className:"font-semibold",children:"Orientation"}),_.jsxs(bA,{value:n,onValueChange:r,className:"flex gap-3 mt-2 ",defaultValue:"x",children:[_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx(kx,{value:"x",id:"r1"}),_.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx(kx,{value:"y",id:"r2"}),_.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})]})}function xA(){var r,i,o;const e=_e(s=>s.card.cfg),t=_e(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 _.jsxs(_.Fragment,{children:[_.jsx("label",{className:"font-medium",children:"Data Labels"}),_.jsxs(lM,{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:[_.jsx(Py,{className:"w-[180px] mt-2 focus:ring-1 focus:ring-offset-0 h-7",children:_.jsx(uM,{placeholder:"Select position"})}),_.jsx(ky,{children:_.jsxs(cM,{children:[_.jsx(Ap,{children:"Data Labels"}),_.jsx(_a,{value:"none",children:"None"}),_.jsx(_a,{value:"start",children:"Start"}),_.jsx(_a,{value:"center",children:"Center"}),_.jsx(_a,{value:"end",children:"End"})]})})]})]})}function wA(){const e=_e(i=>i.card.preferences),t=_e(i=>i.actions.setCardPreferences),n=_e(i=>{var o;return(o=i.card.preferences)==null?void 0:o.filterOnClickField}),r=_e(i=>i.actions.setFilterOnClickField);return _.jsxs("div",{children:[_.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[_.jsx(Pp,{checked:!!(e!=null&&e.filterOnClick),onCheckedChange:i=>{t({...e,filterOnClick:!!i})}}),_.jsx(ns,{children:"Filter on click"})]}),(e==null?void 0:e.filterOnClick)===!0&&_.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx(Ku,{value:n||"",className:" h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"expression (optional)",onChange:i=>r(i.target.value)}),_.jsxs(Vb,{children:[_.jsx(L2,{children:_.jsx(e2,{className:"h-4 w-4 opacity-70"})}),_.jsx(Ih,{children:_.jsxs("div",{className:"max-w-[200px]",children:["The x-axis expression of your query. Example:",_.jsx("div",{className:" mt-1 text-xs font-mono",children:"TO_CHAR(order_date, 'YYYY-MM')"})]})})]})]})]})}const tie={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},nie={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function rie(){const e=_e(t=>t.card.type);return _.jsxs("div",{className:"p-6 space-y-6",children:[_.jsx(cA,{className:" ",type:"single",collapsible:!0,children:iie(e)}),_.jsx("section",{className:"",children:["line","bar"].includes(e)&&_.jsx(yA,{})}),_.jsx("div",{children:_.jsx(xA,{})}),_.jsx("div",{children:_.jsx(wA,{})})]})}function iie(e){if(["line","bar"].includes(e))return _.jsxs(_.Fragment,{children:[_.jsxs(ds,{className:"border-muted",value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:_.jsx("p",{children:"Chart Query"})}),_.jsxs(hs,{className:" ",children:[_.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"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"X-axis - Category (ex. city)"}),_.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),_.jsxs(ds,{className:"border-muted",value:"item-2",children:[_.jsx(fs,{className:" font-normal",children:"Mixed Chart"}),_.jsxs(hs,{className:" text-xs space-y-2",children:[_.jsxs("p",{children:["Click ",_.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),_.jsx("pre",{children:JSON.stringify(tie,null,2)})]})]}),_.jsxs(ds,{className:"border-muted",value:"item-3",children:[_.jsx(fs,{className:" font-normal",children:"Area Chart"}),_.jsxs(hs,{className:" text-xs space-y-2",children:[_.jsxs("p",{children:["Click ",_.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",_.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."]}),_.jsx("pre",{children:JSON.stringify(nie,null,2)})]})]})]});if(e==="bubble")return _.jsx(_.Fragment,{children:_.jsxs(ds,{className:"border-muted",value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:_.jsxs("p",{children:["How to create a ",_.jsx("span",{children:e})," chart query?"]})}),_.jsxs(hs,{className:" ",children:[_.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"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),_.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),_.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),_.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(e==="scatter")return _.jsx(_.Fragment,{children:_.jsxs(ds,{value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:_.jsxs("p",{children:["How to create a ",_.jsx("span",{children:e})," chart query?"]})}),_.jsxs(hs,{className:" ",children:[_.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"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Group (opt) - Category (ex. state)"}),_.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),_.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(e))return _.jsx(_.Fragment,{children:_.jsxs(ds,{value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:_.jsxs("p",{children:["How to create a"," ",_.jsxs("span",{children:[e==="polarArea"?"polar":e," "]})," ","chart query?"]})}),_.jsxs(hs,{className:" ",children:[_.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, measure FROM table"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function oie(){return _.jsxs("div",{className:"px-6 py-2 space-y-6",children:[_.jsx(cA,{className:" ",type:"single",collapsible:!0,children:_.jsxs(ds,{className:"border-muted",value:"item-1",children:[_.jsx(fs,{className:" font-normal",children:"Stacked chart query?"}),_.jsxs(hs,{className:" ",children:[_.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"X-axis - Category (ex. country)"}),_.jsx("li",{children:"Stack by - Category (ex. city)"}),_.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]})}),_.jsx("section",{className:"",children:_.jsx(yA,{})}),_.jsx("div",{children:_.jsx(xA,{})}),_.jsx("div",{children:_.jsx(wA,{})})]})}function sie(){const e=_e(t=>t.card.type);return _.jsx(kl,{className:" text-sm h-full w-full ",children:e==="stackedBar"?_.jsx(oie,{}):_.jsx(rie,{})})}function aie(){const e=_e(t=>t.isShowingVisual);return _.jsxs(zM,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[_.jsx(Fp,{className:"flex",minSize:40,defaultSize:40,children:_.jsx(Wne,{})}),_.jsx(BM,{className:"border-[1.5px] border-muted"}),_.jsx(Fp,{minSize:60,defaultSize:60,children:e?_.jsxs(zM,{direction:"horizontal",children:[_.jsx(_.Fragment,{children:_.jsx(Fp,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:_.jsx(sie,{})})}),_.jsx(BM,{className:"border-[1.5px] border-muted"}),_.jsx(Fp,{minSize:40,defaultSize:75,maxSize:100,children:_.jsx(QT,{})})]}):_.jsx(QT,{})})]})}function lie({authToken:e,onSave:t,onClose:n}){_e(s=>s.actions.setCard);const r=_e(s=>s.actions.setOnSave),i=_e(s=>s.actions.setOnClose),o=ge(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]),_.jsxs(Bk,{className:"border-x border-b rounded-none border-muted ",children:[_.jsx(Vk,{className:" rounded-none border-r-[3px] border-muted ",children:_.jsx(pM,{})}),_.jsx(Hk,{children:_.jsx(aie,{})})]})}function cie(){ge(s=>s.selectedCardId);const e=ge(s=>s.selectedSheetId),t=ge(s=>s.actions.setIsVisualEditing);ge(s=>s.actions.setIsEditorSaveEvent);const n=ge(s=>s.isVisualEditing);ge(s=>s.actions.getSelectedCard());const r=ge(s=>s.actions.updateCard);function i(s){e&&(r(e,s),t(!1))}function o(){t(!1)}return _.jsx("div",{role:"editor-container",className:Pe("grow flex",{block:n,hidden:!n}),children:_.jsx(lie,{onSave:i,onClose:o})})}function uie({columns:e,tableName:t}){const n=_e(f=>f.selectedConnectionId),r=_e(f=>f.selectedDatabaseName),i=_e(f=>f.selectedSchemaName),o=_e(f=>f.selectedTableName),s=ge(f=>f.dashboard.filters)||[],a=ge(f=>f.actions.addFilter),l=ge(f=>f.actions.removeFilter),c=ge(f=>f.actions.removeFilterValue);function d(f){const p=s==null?void 0:s.find(g=>g.column===f.column_name&&g.table===o&&g.database===r);if(p)c(p.id),l(p.id);else{const g=M0(i||"",t),v=`SELECT ${f.column_name}, COUNT(*) FROM ${g} GROUP BY ${f.column_name} ORDER BY ${f.column_name} ASC LIMIT 50`,y=`SELECT min(${f.column_name}) as min, max(${f.column_name}) as max FROM ${g}`;if(t==="api"&&n){a({id:yh(),column:f.column_name,title:f.column_name,dataType:f.data_type,table:"api",database:"NA",connectionId:n,sql:Iu.includes(f.data_type)?y:v});return}if(!n||!r||!o)throw new Error("missing connectionId, database, or table");a({id:yh(),column:f.column_name,title:f.column_name,dataType:f.data_type,table:o,database:r,connectionId:n,sql:Iu.includes(f.data_type)?y:v})}}return _.jsx(kl,{className:" h-[70vh] mt-2 xbg-red-100 px-3",children:e==null?void 0:e.map(f=>{const p=s==null?void 0:s.find(g=>g.column===f.column_name&&g.table===o&&g.database===r);return _.jsx("div",{onClick:()=>d(f),className:Pe(" 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 ":p}),children:_.jsxs("div",{className:"flex items-center gap-2 ",children:[_.jsx(hM,{column:f}),_.jsx("span",{children:f.column_name})]})},f.column_name)})})}function die(){ge(t=>t.showFilters);const e=ge(t=>t.actions.setShowFilters);return _.jsxs("section",{className:" relative space-y-4 py-0 px-4 border-muted bg-red-x100",children:[_.jsx(it,{onClick:()=>e(!1),className:" p-0 h-7 w-7 absolute top-0 right-4",variant:"outline",children:_.jsx(ia,{})}),_.jsx("p",{className:"text-md px-2",children:"Data Columns"}),_.jsx("div",{children:_.jsx(pM,{ColumnsComponent:(t,n,r)=>_.jsx(uie,{schemaName:t,tableName:n,columns:r})})})]})}function fie(){ge(n=>n.dashboard);const e=ge(n=>n.showFilters),t=ge(n=>n.isVisualEditing);return ge(n=>n.bookmarkKey),_.jsxs("div",{role:"dashboard-plus-main",className:Pe(" grow",{hidden:t,flex:!t}),children:[_.jsx(QP,{}),e&&_.jsx("div",{role:"filter-aside-container",children:_.jsx(die,{})})]})}function hie(){const e=ge(r=>r.dashboard),t=ge(r=>r.actions.setDashboard),n=ge(r=>r.showDashboardJSON);return ge(r=>r.actions.setShowDashboardJSON),_.jsx("div",{className:Pe(" p-2",{hidden:!n}),children:_.jsx(nD,{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 pie({showControls:e=!1,showFooter:t=!0,...n}){return ge(r=>r.isVisualEditing),_.jsxs(ZP,{children:[_.jsx(hie,{}),_.jsxs(Kw,{...n,children:[e&&_.jsx(XK,{}),_.jsx(cie,{}),_.jsx(fie,{})]})]})}function gie(){const e=ge(t=>t.actions);return{setDashboardTitle:e.setDashboardTitle,getStyle:e.getStyle,getDashboard:e.getDashboard,setOnSaveFunction:e.setOnSaveFunction,setOnAddCard:e.setOnAddCard,setOnUpateCard:e.setOnUpdateCard,setOnRemoveCard:e.setOnRemoveCard}}ct.Dashboard=JP,ct.DashboardPlus=pie,ct.DashboardWC=YG,ct.cleanCard=Pk,ct.getBookmarkKey=ss,ct.getDashbaordStateWithoutData=by,ct.useActions=gie,ct.useDashboardStore=ge,Object.defineProperty(ct,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.13",
8
+ "version": "0.0.15",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",