react-semaphor 0.0.122 → 0.0.123

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52643,7 +52643,9 @@ function che() {
52643
52643
  );
52644
52644
  ye(() => {
52645
52645
  var D, N, j, z, V, se, J, F, Z, G;
52646
- o(FP(n)), a(((j = (N = (D = n == null ? void 0 : n.chartOptions) == null ? void 0 : D.scales) == null ? void 0 : N[r]) == null ? void 0 : j.min) || ""), c(((se = (V = (z = n == null ? void 0 : n.chartOptions) == null ? void 0 : z.scales) == null ? void 0 : V[r]) == null ? void 0 : se.max) || ""), p(
52646
+ o(FP(n)), a(
52647
+ ((j = (N = (D = n == null ? void 0 : n.chartOptions) == null ? void 0 : D.scales) == null ? void 0 : N[r]) == null ? void 0 : j.min) === 0 ? 0 : ""
52648
+ ), c(((se = (V = (z = n == null ? void 0 : n.chartOptions) == null ? void 0 : z.scales) == null ? void 0 : V[r]) == null ? void 0 : se.max) || ""), p(
52647
52649
  ((G = (Z = (F = (J = n == null ? void 0 : n.chartOptions) == null ? void 0 : J.scales) == null ? void 0 : F[r]) == null ? void 0 : Z.ticks) == null ? void 0 : G.stepSize) || ""
52648
52650
  );
52649
52651
  }, [e, n, r]);
@@ -52733,7 +52735,7 @@ function che() {
52733
52735
  /* @__PURE__ */ v.jsx(bm, { id: "type", children: /* @__PURE__ */ v.jsxs(gw, { children: [
52734
52736
  /* @__PURE__ */ v.jsx(wd, { children: "Option" }),
52735
52737
  /* @__PURE__ */ v.jsx(qo, { value: "linear", children: "Linear" }),
52736
- /* @__PURE__ */ v.jsx(qo, { value: "logarithmic", children: "logarithmic" })
52738
+ /* @__PURE__ */ v.jsx(qo, { value: "logarithmic", children: "Logarithmic" })
52737
52739
  ] }) })
52738
52740
  ]
52739
52741
  }
@@ -571,7 +571,7 @@ SELECT label, measure FROM table
571
571
  - horizontal
572
572
  - vertical
573
573
 
574
- Defaulting to \`${e1}\`.`}function RT(e){return hie.includes(e)}const LT=NT,FT=de.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>b.jsx(LT,{ref:i,decorative:n,orientation:t,className:Ee("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));FT.displayName=LT.displayName;function jT(){pe(s=>s.frame);const e=pe(s=>s.card),t=pe(s=>s.card.data),n=pe(s=>s.isShowingVisual),r=pe(s=>s.isSqlRunning),i=pe(s=>s.queryError),o=pe(s=>s.pythonStdOut);return pe(s=>s.onSave),pe(s=>s.onClose),pe(s=>s.actions.setCardSql),pe(s=>s.actions.setCardType),pe(s=>s.actions.setSqlGen),e?b.jsxs("div",{className:" h-full relative flex flex-col py-3",children:[r&&b.jsx(ma,{className:" w-10 h-10 z-10 absolute m-auto left-0 right-0 top-0 bottom-0 animate-spin text-foreground/10 "}),b.jsxs("div",{className:" px-6 min-h-10 mb-0 flex justify-end items-center gap-2",children:[n&&b.jsxs("div",{className:"flex grow gap-2 items-center ",children:[b.jsx(uie,{}),b.jsx(cie,{}),b.jsx(fie,{})]}),b.jsx(mie,{})]}),n?e.type==="kpi"?b.jsx("div",{className:"grow flex items-center justify-center ",children:b.jsx("div",{className:" w-1/2 border rounded-md",children:b.jsx(L0,{isLoading:r,card:e})})}):b.jsx(PT,{className:"grow border-none shadow-none "}):b.jsxs("div",{className:"w-full px-6 bg-red-x00 grow border-none shadow-none overflow-y-auto ",children:[o&&b.jsx(gie,{}),e.data&&e.data.length>0&&b.jsx(sp,{data:t||[]}),i&&b.jsx("span",{className:"font-mono text-sm",children:i})]})]}):b.jsx(b.Fragment,{children:"No Active Card"})}function gie(){const e=pe(n=>n.pythonStdOut);if(!e)return null;const t=e.replace(/\n/g,"<br>");return b.jsxs(b.Fragment,{children:[b.jsx("p",{className:"font-mono text-sm",children:"Output:"}),b.jsx("div",{dangerouslySetInnerHTML:{__html:t},className:"font-mono text-sm p-2 bg-muted"}),b.jsx(FT,{className:" mb-2"})]})}function mie(){const e=pe(n=>n.isShowingVisual),t=pe(n=>n.actions.setIsShowingVisual);return b.jsxs("div",{className:" flex items-center space-x-2",children:[b.jsx(Fn,{htmlFor:"visualize",children:"Chart"}),b.jsx(OT,{checked:e,onCheckedChange:()=>t(!e),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}const $T="Collapsible",[vie,zT]=Rn($T),[bie,t1]=vie($T),yie=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:o,onOpenChange:s,...a}=e,[l=!1,c]=Qn({prop:r,defaultProp:i,onChange:s});return m.createElement(bie,{scope:n,disabled:o,contentId:pr(),open:l,onOpenToggle:m.useCallback(()=>c(u=>!u),[c])},m.createElement(ze.div,ae({"data-state":n1(l),"data-disabled":o?"":void 0},a,{ref:t})))}),xie="CollapsibleTrigger",wie=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=t1(xie,n);return m.createElement(ze.button,ae({type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":n1(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled},r,{ref:t,onClick:Oe(e.onClick,i.onOpenToggle)}))}),BT="CollapsibleContent",_ie=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=t1(BT,e.__scopeCollapsible);return m.createElement(wn,{present:n||i.open},({present:o})=>m.createElement(Sie,ae({},r,{ref:t,present:o})))}),Sie=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...o}=e,s=t1(BT,n),[a,l]=m.useState(r),c=m.useRef(null),u=rt(t,c),f=m.useRef(0),g=f.current,p=m.useRef(0),v=p.current,y=s.open||a,w=m.useRef(y),_=m.useRef();return m.useEffect(()=>{const S=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(S)},[]),Xn(()=>{const S=c.current;if(S){_.current=_.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const C=S.getBoundingClientRect();f.current=C.height,p.current=C.width,w.current||(S.style.transitionDuration=_.current.transitionDuration,S.style.animationName=_.current.animationName),l(r)}},[s.open,r]),m.createElement(ze.div,ae({"data-state":n1(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!y},o,{ref:u,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style}}),y&&i)});function n1(e){return e?"open":"closed"}const Cie=yie,Eie=wie,Oie=_ie,Es="Accordion",Pie=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[r1,kie,Mie]=Af(Es),[kg,$he]=Rn(Es,[Mie,zT]),i1=zT(),VT=m.forwardRef((e,t)=>{const{type:n,...r}=e,i=r,o=r;return m.createElement(r1.Provider,{scope:e.__scopeAccordion},n==="multiple"?m.createElement(Iie,ae({},o,{ref:t})):m.createElement(Aie,ae({},i,{ref:t})))});VT.propTypes={type(e){const t=e.value||e.defaultValue;return e.type&&!["single","multiple"].includes(e.type)?new Error("Invalid prop `type` supplied to `Accordion`. Expected one of `single | multiple`."):e.type==="multiple"&&typeof t=="string"?new Error("Invalid prop `type` supplied to `Accordion`. Expected `single` when `defaultValue` or `value` is type `string`."):e.type==="single"&&Array.isArray(t)?new Error("Invalid prop `type` supplied to `Accordion`. Expected `multiple` when `defaultValue` or `value` is type `string[]`."):null}};const[HT,Die]=kg(Es),[WT,Tie]=kg(Es,{collapsible:!1}),Aie=m.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:i=()=>{},collapsible:o=!1,...s}=e,[a,l]=Qn({prop:n,defaultProp:r,onChange:i});return m.createElement(HT,{scope:e.__scopeAccordion,value:a?[a]:[],onItemOpen:l,onItemClose:m.useCallback(()=>o&&l(""),[o,l])},m.createElement(WT,{scope:e.__scopeAccordion,collapsible:o},m.createElement(UT,ae({},s,{ref:t}))))}),Iie=m.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:i=()=>{},...o}=e,[s=[],a]=Qn({prop:n,defaultProp:r,onChange:i}),l=m.useCallback(u=>a((f=[])=>[...f,u]),[a]),c=m.useCallback(u=>a((f=[])=>f.filter(g=>g!==u)),[a]);return m.createElement(HT,{scope:e.__scopeAccordion,value:s,onItemOpen:l,onItemClose:c},m.createElement(WT,{scope:e.__scopeAccordion,collapsible:!0},m.createElement(UT,ae({},o,{ref:t}))))}),[Nie,Mg]=kg(Es),UT=m.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:i,orientation:o="vertical",...s}=e,a=m.useRef(null),l=rt(a,t),c=kie(n),f=Ys(i)==="ltr",g=Oe(e.onKeyDown,p=>{var v;if(!Pie.includes(p.key))return;const y=p.target,w=c().filter(F=>{var $;return!(($=F.ref.current)!==null&&$!==void 0&&$.disabled)}),_=w.findIndex(F=>F.ref.current===y),S=w.length;if(_===-1)return;p.preventDefault();let C=_;const P=0,O=S-1,k=()=>{C=_+1,C>O&&(C=P)},T=()=>{C=_-1,C<P&&(C=O)};switch(p.key){case"Home":C=P;break;case"End":C=O;break;case"ArrowRight":o==="horizontal"&&(f?k():T());break;case"ArrowDown":o==="vertical"&&k();break;case"ArrowLeft":o==="horizontal"&&(f?T():k());break;case"ArrowUp":o==="vertical"&&T();break}const I=C%S;(v=w[I].ref.current)===null||v===void 0||v.focus()});return m.createElement(Nie,{scope:n,disabled:r,direction:i,orientation:o},m.createElement(r1.Slot,{scope:n},m.createElement(ze.div,ae({},s,{"data-orientation":o,ref:l,onKeyDown:r?void 0:g}))))}),o1="AccordionItem",[Rie,s1]=kg(o1),Lie=m.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...i}=e,o=Mg(o1,n),s=Die(o1,n),a=i1(n),l=pr(),c=r&&s.value.includes(r)||!1,u=o.disabled||e.disabled;return m.createElement(Rie,{scope:n,open:c,disabled:u,triggerId:l},m.createElement(Cie,ae({"data-orientation":o.orientation,"data-state":GT(c)},a,i,{ref:t,disabled:u,open:c,onOpenChange:f=>{f?s.onItemOpen(r):s.onItemClose(r)}})))}),Fie="AccordionHeader",jie=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Mg(Es,n),o=s1(Fie,n);return m.createElement(ze.h3,ae({"data-orientation":i.orientation,"data-state":GT(o.open),"data-disabled":o.disabled?"":void 0},r,{ref:t}))}),qT="AccordionTrigger",$ie=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Mg(Es,n),o=s1(qT,n),s=Tie(qT,n),a=i1(n);return m.createElement(r1.ItemSlot,{scope:n},m.createElement(Eie,ae({"aria-disabled":o.open&&!s.collapsible||void 0,"data-orientation":i.orientation,id:o.triggerId},a,r,{ref:t})))}),zie="AccordionContent",Bie=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Mg(Es,n),o=s1(zie,n),s=i1(n);return m.createElement(Oie,ae({role:"region","aria-labelledby":o.triggerId,"data-orientation":i.orientation},s,r,{ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}}))});function GT(e){return e?"open":"closed"}const Vie=VT,Hie=Lie,Wie=jie,YT=$ie,KT=Bie,uc=Vie,Cn=de.forwardRef(({className:e,...t},n)=>b.jsx(Hie,{ref:n,className:Ee("border-b",e),...t}));Cn.displayName="AccordionItem";const En=de.forwardRef(({className:e,children:t,...n},r)=>b.jsx(Wie,{className:"flex",children:b.jsxs(YT,{ref:r,className:Ee("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,b.jsx(dp,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));En.displayName=YT.displayName;const On=de.forwardRef(({className:e,children:t,...n},r)=>b.jsx(KT,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:b.jsx("div",{className:Ee("pb-4 pt-0",e),children:t})}));On.displayName=KT.displayName;function Td(){var r,i,o;const e=pe(s=>s.card.cfg),t=pe(s=>s.actions.setCardCfg);function n(s){var c;const a={datalabels:{display:s!=="none",align:s,anchor:s,clamp:!0}},l={...e,options:{...e==null?void 0:e.options,plugins:{...(c=e==null?void 0:e.options)==null?void 0:c.plugins,...a}}};t(l),console.log(s)}return b.jsxs("div",{className:"space-y-2",children:[b.jsx("label",{className:"font-medium",children:"Data Labels"}),b.jsxs(lx,{value:(o=(i=(r=e==null?void 0:e.options)==null?void 0:r.plugins)==null?void 0:i.datalabels)==null?void 0:o.anchor,onValueChange:n,defaultValue:"none",children:[b.jsx(rg,{className:"h-8 w-[180px] focus:ring-1 focus:ring-offset-0",children:b.jsx(ux,{placeholder:"Select position"})}),b.jsx(ig,{children:b.jsxs(cx,{children:[b.jsx(pd,{children:"Data Labels"}),b.jsx(Ro,{value:"none",children:"None"}),b.jsx(Ro,{value:"start",children:"Start"}),b.jsx(Ro,{value:"center",children:"Center"}),b.jsx(Ro,{value:"end",children:"End"})]})})]})]})}function Ad(){const[e,t]=m.useState([]);pe(u=>u.card.cfg);const n=pe(u=>u.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:i,setCardPreferences:o}=pe(u=>u.actions),s=pe(u=>u.queryResultColumns);pe(u=>{var f;return(f=u.card.preferences)==null?void 0:f.filterOnClickColumnIndex}),m.useEffect(()=>{s&&t(new Array(s.length).fill(!1))},[s]);function a(u,f){var g,p;f?n!=null&&n.onClickFilter&&((g=n==null?void 0:n.onClickFilter)==null?void 0:g.length)>0?o({...n,onClickFilter:[...n.onClickFilter,{columnIndex:u,expression:""}]}):o({...n,onClickFilter:[{columnIndex:u,expression:""}]}):(o({...n,onClickFilter:(p=n==null?void 0:n.onClickFilter)==null?void 0:p.filter(v=>v.columnIndex!==u)}),t(v=>{const y=[...v];return y[u]=!1,y}))}function l(u,f){var p;const g=(p=n==null?void 0:n.onClickFilter)==null?void 0:p.map(v=>v.columnIndex===u?{...v,expression:f.target.value}:v);o({...n,onClickFilter:g})}function c(u){var f,g,p,v;if(e!=null&&e[u]||(g=(f=n==null?void 0:n.onClickFilter)==null?void 0:f.find(y=>y.columnIndex===u))!=null&&g.expression)return b.jsx(Ii,{value:(v=(p=n==null?void 0:n.onClickFilter)==null?void 0:p.find(y=>y.columnIndex===u))==null?void 0:v.expression,onChange:y=>l(u,y),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return b.jsx(b.Fragment,{children:s==null?void 0:s.map((u,f)=>{var g,p;return b.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:b.jsxs("div",{className:" grow",children:[b.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[b.jsx(hd,{checked:!!((g=n==null?void 0:n.onClickFilter)!=null&&g.find(v=>v.columnIndex===f)),onCheckedChange:v=>a(f,v)}),b.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:u}),b.jsx("div",{className:"flex gap-2 items-center ",children:((p=n==null?void 0:n.onClickFilter)==null?void 0:p.find(v=>v.columnIndex===f))&&b.jsx(oP,{onClick:()=>{t(v=>{const y=[...v];return y[f]=!v[f],y})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),c(f)]})},u)})})}const XT="Radio",[Uie,QT]=Rn(XT),[qie,Gie]=Uie(XT),Yie=m.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:i=!1,required:o,disabled:s,value:a="on",onCheck:l,...c}=e,[u,f]=m.useState(null),g=rt(t,y=>f(y)),p=m.useRef(!1),v=u?!!u.closest("form"):!0;return m.createElement(qie,{scope:n,checked:i,disabled:s},m.createElement(ze.button,ae({type:"button",role:"radio","aria-checked":i,"data-state":ZT(i),"data-disabled":s?"":void 0,disabled:s,value:a},c,{ref:g,onClick:Oe(e.onClick,y=>{i||l==null||l(),v&&(p.current=y.isPropagationStopped(),p.current||y.stopPropagation())})})),v&&m.createElement(Qie,{control:u,bubbles:!p.current,name:r,value:a,checked:i,required:o,disabled:s,style:{transform:"translateX(-100%)"}}))}),Kie="RadioIndicator",Xie=m.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...i}=e,o=Gie(Kie,n);return m.createElement(wn,{present:r||o.checked},m.createElement(ze.span,ae({"data-state":ZT(o.checked),"data-disabled":o.disabled?"":void 0},i,{ref:t})))}),Qie=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Zp(n),a=Xh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const g=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(g)}},[s,n,r]),m.createElement("input",ae({type:"radio","aria-hidden":!0,defaultChecked:n},i,{tabIndex:-1,ref:o,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function ZT(e){return e?"checked":"unchecked"}const Zie=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],JT="RadioGroup",[Jie,zhe]=Rn(JT,[gl,QT]),eA=gl(),tA=QT(),[eoe,toe]=Jie(JT),noe=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:i,value:o,required:s=!1,disabled:a=!1,orientation:l,dir:c,loop:u=!0,onValueChange:f,...g}=e,p=eA(n),v=Ys(c),[y,w]=Qn({prop:o,defaultProp:i,onChange:f});return m.createElement(eoe,{scope:n,name:r,required:s,disabled:a,value:y,onValueChange:w},m.createElement(iv,ae({asChild:!0},p,{orientation:l,dir:v,loop:u}),m.createElement(ze.div,ae({role:"radiogroup","aria-required":s,"aria-orientation":l,"data-disabled":a?"":void 0,dir:v},g,{ref:t}))))}),roe="RadioGroupItem",ioe=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...i}=e,o=toe(roe,n),s=o.disabled||r,a=eA(n),l=tA(n),c=m.useRef(null),u=rt(t,c),f=o.value===i.value,g=m.useRef(!1);return m.useEffect(()=>{const p=y=>{Zie.includes(y.key)&&(g.current=!0)},v=()=>g.current=!1;return document.addEventListener("keydown",p),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",v)}},[]),m.createElement(ov,ae({asChild:!0},a,{focusable:!s,active:f}),m.createElement(Yie,ae({disabled:s,required:o.required,checked:f},l,i,{name:o.name,ref:u,onCheck:()=>o.onValueChange(i.value),onKeyDown:Oe(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:Oe(i.onFocus,()=>{var p;g.current&&((p=c.current)===null||p===void 0||p.click())})})))}),ooe=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,i=tA(n);return m.createElement(Xie,ae({},i,r,{ref:t}))}),nA=noe,rA=ioe,soe=ooe,a1=de.forwardRef(({className:e,...t},n)=>b.jsx(nA,{className:Ee("grid gap-2",e),...t,ref:n}));a1.displayName=nA.displayName;const Id=de.forwardRef(({className:e,...t},n)=>b.jsx(rA,{ref:n,className:Ee("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:b.jsx(soe,{className:"flex items-center justify-center",children:b.jsx(rP,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Id.displayName=rA.displayName;function l1(){var o,s;const e=pe(a=>a.card.preferences),t=pe(a=>a.card.cfg),{setCardCfg:n,setCardPreferences:r}=pe(a=>a.actions);(o=t==null?void 0:t.options)!=null&&o.indexAxis;function i(a){var u,f,g,p,v,y;let l={};(u=e==null?void 0:e.chartOptions)!=null&&u.scales&&(l={x:(g=(f=e==null?void 0:e.chartOptions)==null?void 0:f.scales)==null?void 0:g.y,y:(v=(p=e==null?void 0:e.chartOptions)==null?void 0:p.scales)==null?void 0:v.x});const c={...e,chartOptions:{...e==null?void 0:e.chartOptions,scales:{...(y=e==null?void 0:e.chartOptions)==null?void 0:y.scales,...l},indexAxis:a}};r(c)}return b.jsxs(a1,{value:((s=e==null?void 0:e.chartOptions)==null?void 0:s.indexAxis)||"x",onValueChange:i,className:"flex gap-3",defaultValue:"x",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(Id,{value:"x",id:"r1"}),b.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(Id,{value:"y",id:"r2"}),b.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const c1="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function iA(e){var n,r;return(n=e==null?void 0:e.chartOptions)!=null&&n.indexAxis?((r=e==null?void 0:e.chartOptions)==null?void 0:r.indexAxis)==="x"?"y":"x":"y"}function oA(e){var n,r,i;const t=iA(e);return((i=(r=(n=e==null?void 0:e.chartOptions)==null?void 0:n.scales)==null?void 0:r[t])==null?void 0:i.type)||"linear"}function aoe(){var S,C,P,O,k,T;const[e,t]=m.useState(!1),n=pe(I=>{var F;return(F=I.card)==null?void 0:F.preferences}),r=iA(n),[i,o]=m.useState(oA(n)),[s,a]=m.useState(((P=(C=(S=n==null?void 0:n.chartOptions)==null?void 0:S.scales)==null?void 0:C[r])==null?void 0:P.min)||""),[l,c]=m.useState(((T=(k=(O=n==null?void 0:n.chartOptions)==null?void 0:O.scales)==null?void 0:k[r])==null?void 0:T.max)||""),[u,f]=m.useState(s||l?"custom":"auto"),[g,p]=m.useState(""),v=pe(I=>I.actions.setCardPreferences);m.useEffect(()=>{var I,F,$,z,V,se,J,j,Z,G;o(oA(n)),a((($=(F=(I=n==null?void 0:n.chartOptions)==null?void 0:I.scales)==null?void 0:F[r])==null?void 0:$.min)||""),c(((se=(V=(z=n==null?void 0:n.chartOptions)==null?void 0:z.scales)==null?void 0:V[r])==null?void 0:se.max)||""),p(((G=(Z=(j=(J=n==null?void 0:n.chartOptions)==null?void 0:J.scales)==null?void 0:j[r])==null?void 0:Z.ticks)==null?void 0:G.stepSize)||"")},[e,n,r]);function y(I,F){return F===""||/^[0-9\b]+$/.test(F)?Number(F):Number(I)}function w(){return b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[b.jsx(Fn,{htmlFor:"range",children:"Range"}),b.jsx(Ii,{id:"min",value:s,onChange:I=>a(F=>y(F,I.target.value)),className:`col-span-1 h-8 w-full ${c1}`}),b.jsx(Ii,{value:l,onChange:I=>c(F=>y(F,I.target.value)),id:"max",className:`col-span-1 h-8 w-full ${c1}`})]}),b.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[b.jsx(Fn,{htmlFor:"step-size",children:"Step Size"}),b.jsx(Ii,{value:g,onChange:I=>p(F=>y(F,I.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${c1}`})]})]})}function _(){var $;let I={};u==="custom"&&(I={min:s,max:l,ticks:{stepSize:g}});const F={...n||{},chartOptions:{...n==null?void 0:n.chartOptions,scales:{...($=n==null?void 0:n.chartOptions)==null?void 0:$.scales,[r]:{type:i,...i==="linear"?I:{}}}}};v(F)}return b.jsxs(ad,{onOpenChange:I=>t(I),children:[b.jsx(ld,{asChild:!0,children:b.jsx(Vz,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),b.jsx(Kl,{align:"center",className:"max-w-65",children:b.jsxs("div",{className:"grid gap-4",children:[b.jsxs("div",{className:"space-y-2",children:[b.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),b.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),b.jsxs("div",{className:"grid gap-2",children:[b.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[b.jsx(Fn,{htmlFor:"scale",children:"Type"}),b.jsxs(lx,{value:i,onValueChange:I=>o(I),children:[b.jsx(rg,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:b.jsx(ux,{})}),b.jsx(ig,{id:"type",children:b.jsxs(cx,{children:[b.jsx(pd,{children:"Option"}),b.jsx(Ro,{value:"linear",children:"Linear"}),b.jsx(Ro,{value:"logarithmic",children:"logarithmic"})]})})]})]}),i=="linear"&&b.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[b.jsx(Fn,{htmlFor:"scale-option",children:"Setup"}),b.jsxs(a1,{id:"scale-option",value:u,onValueChange:I=>f(I),className:"col-span-2 flex gap-3",defaultValue:"x",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(Id,{value:"auto",id:"r1"}),b.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(Id,{value:"custom",id:"r2"}),b.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),u==="custom"&&i=="linear"&&w(),b.jsx(JM,{}),b.jsx("div",{className:"grid grid-cols-3",children:b.jsx(Je,{onClick:_,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function sA(){const e=pe(l=>l.card),t=pe(l=>{var c,u,f;return(f=(u=(c=l==null?void 0:l.card)==null?void 0:c.cfg)==null?void 0:u.options)==null?void 0:f.indexAxis}),n=t==="y"?"Y Axis":"X Axis",r=t==="y"?"X Axis":"Y Axis",{keys:i,metricKeys:o,dimensionKeys:s}=oi(e.data||[]);let a=o;if(e.type==="stackedBar"){const l=Zb({dataArray:e.data||[],groupKey:s[0],pivotKey:s[1],valueKey:a[0]}),{metricKeys:c}=oi(l);a=c}return i.length===0?null:b.jsxs("div",{className:"space-y-4",children:[b.jsxs("div",{className:"space-y-2",children:[b.jsx(Fn,{children:n}),b.jsx("div",{className:"my-1 space-y-1",children:b.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:b.jsx("p",{children:s[0]})})})]}),b.jsxs("div",{className:"space-y-2",children:[b.jsxs("div",{className:"flex items-center justify-between gap-5",children:[b.jsx(Fn,{children:r}),b.jsx(aoe,{})]}),b.jsx("div",{className:"my-1 space-y-1",children:a.map((l,c)=>b.jsx(loe,{col:l,idx:c},l))})]})]})}function loe({col:e,idx:t}){const n=pe(a=>{var l;return(l=a.card)==null?void 0:l.preferences}),r=pe(a=>{var l;return(l=a.card.preferences)==null?void 0:l.datasetOptions}),i=r==null?void 0:r.find(a=>a.idx===t),{setCardPreferences:o}=pe(a=>a.actions);function s(a){if(!i)o({...n,datasetOptions:[...r||[],{idx:t,type:a==="area"?"line":a,fill:a==="area"?"origin":""}]});else{const l={...i};l.type=a==="area"?"line":a,l.fill=a==="area"?"origin":"";const c=r==null?void 0:r.map(u=>u.idx===t?l:u);o({...n,datasetOptions:c})}}return b.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[b.jsx("p",{children:e}),b.jsxs("div",{className:"flex gap-2",children:[b.jsx(I0,{onClick:()=>s("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),b.jsx(N0,{onClick:()=>s("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),b.jsx(g6,{onClick:()=>s("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})]})]})}function coe({cardType:e}){return b.jsx("div",{className:"space-y-6 px-6 py-2",children:b.jsxs(uc,{defaultValue:["item-2"],type:"multiple",children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{children:`${Em(e)} Chart`}),b.jsxs(On,{className:"space-y-4 font-mono text-xs",children:[b.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),b.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[b.jsx("li",{children:"x-axis - category"}),b.jsx("li",{children:"y-axis1 - number"}),b.jsx("li",{children:"y-axis2 - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{children:"Settings"}),b.jsxs(On,{className:"space-y-4 px-2",children:[b.jsx(l1,{}),b.jsx(sA,{}),b.jsx(Td,{})]})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{children:"Filter on click"}),b.jsx(On,{className:"px-2",children:b.jsx(Ad,{})})]})]})})}function uoe({cardType:e}){function t(n){const r="SELECT label, [group], x-axis, y-axis, radius FROM table",i="SELECT label, [group], x-axis, y-axis FROM table";return b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:n==="bubble"?r:i}),b.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[b.jsx("li",{children:"label - category"}),b.jsx("li",{children:"group - category"}),b.jsx("li",{children:"x-axis - category"}),b.jsx("li",{children:"y-axis - category"}),n==="bubble"&&b.jsx("li",{children:"radius - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:o=>o.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return b.jsx("div",{className:"px-6 py-2 space-y-6",children:b.jsxs(uc,{defaultValue:["item-2"],type:"multiple",children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{children:`${Em(e)} Chart`}),b.jsx(On,{className:" space-y-4 font-mono text-xs ",children:t(e)})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{children:"Settings"}),b.jsx(On,{className:"px-2",children:b.jsx(Td,{})})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{children:"Filter on click"}),b.jsx(On,{className:"px-2",children:b.jsx(Ad,{})})]})]})})}const doe={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},foe={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function hoe(){const e=pe(t=>t.card.type);return b.jsxs("div",{className:"p-6 space-y-6",children:[b.jsx(uc,{className:" ",type:"single",collapsible:!0,children:poe(e)}),b.jsx("section",{className:"",children:["line","bar"].includes(e)&&b.jsx(l1,{})}),b.jsx("div",{children:!["kpi"].includes(e)&&b.jsx(Td,{})}),b.jsx("div",{children:!["kpi"].includes(e)&&b.jsx(Ad,{})})]})}function poe(e){if(["line","bar"].includes(e))return b.jsxs(b.Fragment,{children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:" font-normal",children:b.jsx("p",{children:"Chart Query"})}),b.jsxs(On,{className:" ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[b.jsx("li",{children:"X-axis - Category (ex. city)"}),b.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{className:" font-normal",children:"Mixed Chart"}),b.jsxs(On,{className:" text-xs space-y-2",children:[b.jsxs("p",{children:["Click ",b.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),b.jsx("pre",{children:JSON.stringify(doe,null,2)})]})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{className:" font-normal",children:"Area Chart"}),b.jsxs(On,{className:" text-xs space-y-2",children:[b.jsxs("p",{children:["Click ",b.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",b.jsx("a",{className:"text-blue-500 hover:underline mx-1",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),b.jsx("pre",{children:JSON.stringify(foe,null,2)})]})]})]});if(e==="bubble")return b.jsx(b.Fragment,{children:b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:" font-normal",children:b.jsxs("p",{children:["How to create a ",b.jsx("span",{children:e})," chart query?"]})}),b.jsxs(On,{className:" ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis, radius FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[b.jsx("li",{children:"Label - Category (ex. city)"}),b.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),b.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),b.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),b.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(e==="scatter")return b.jsx(b.Fragment,{children:b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:" font-normal",children:b.jsxs("p",{children:["How to create a ",b.jsx("span",{children:e})," chart query?"]})}),b.jsxs(On,{className:" ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[b.jsx("li",{children:"Label - Category (ex. city)"}),b.jsx("li",{children:"Group (opt) - Category (ex. state)"}),b.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),b.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(e))return b.jsx(b.Fragment,{children:b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:" font-normal",children:b.jsxs("p",{children:[b.jsx("span",{children:e==="polarArea"?"Polar":e.charAt(0).toUpperCase()+e.slice(1)})," ","chart query"]})}),b.jsxs(On,{className:" ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, measure FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[b.jsx("li",{children:"Label - Category (ex. city)"}),b.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function goe(){var s,a,l;const e=pe(c=>c.card.preferences),t=pe(c=>c.actions.setCardPreferences),n=pe(c=>c.actions.setNumberFormat),r=pe(c=>{var u,f;return(f=(u=c.card.preferences)==null?void 0:u.formatNumber)==null?void 0:f.format}),i=pe(c=>{var u,f;return(f=(u=c.card.preferences)==null?void 0:u.formatNumber)==null?void 0:f.locale}),o=pe(c=>{var u,f;return(f=(u=c.card.preferences)==null?void 0:u.formatNumber)==null?void 0:f.currency});return pe(c=>c.actions.setFilterOnClickField),b.jsxs("div",{children:[b.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[b.jsx(hd,{checked:!!((s=e==null?void 0:e.formatNumber)!=null&&s.enabled),onCheckedChange:c=>{t({...e,formatNumber:{...e==null?void 0:e.formatNumber,enabled:c}})}}),b.jsx(Fn,{children:"Format Number"})]}),((a=e==null?void 0:e.formatNumber)==null?void 0:a.enabled)===!0&&b.jsxs("div",{className:"flex flex-col gap-2 ",children:[b.jsxs("div",{children:[b.jsx(Fn,{className:"text-xs",children:"Currency"}),b.jsxs("div",{className:"flex gap-1",children:[b.jsx(Ii,{value:o||"",className:" h-7 w-20 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"USD",onChange:c=>{var u,f,g;return n(((u=e==null?void 0:e.formatNumber)==null?void 0:u.format)||"",c.target.value,((f=e==null?void 0:e.formatNumber)==null?void 0:f.locale)||"",((g=e==null?void 0:e.formatNumber)==null?void 0:g.suffix)||"")}}),b.jsx(Ii,{value:i||"",className:" h-7 w-20 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"en-US",onChange:c=>{var u,f,g;return n(((u=e==null?void 0:e.formatNumber)==null?void 0:u.format)||"",((f=e==null?void 0:e.formatNumber)==null?void 0:f.currency)||"",c.target.value,((g=e==null?void 0:e.formatNumber)==null?void 0:g.suffix)||"")}})]})]}),b.jsxs("div",{children:[b.jsxs("div",{className:" flex gap-1",children:[b.jsx(Fn,{className:"text-xs",children:"Format"}),b.jsxs(ep,{children:[b.jsx(h0,{children:b.jsx(H2,{strokeWidth:1,className:"h-3 w-3 opacity-70"})}),b.jsx(Uu,{children:b.jsxs("div",{className:"max-w-[200px]",children:["Format number",b.jsx("div",{className:" mt-1 text-xs font-mono",children:"#.## for 123.43"})]})})]})]}),b.jsx("div",{children:b.jsx(Ii,{value:r||"",className:" h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"###,###.##",onChange:c=>{var u,f,g;return n(c.target.value,((u=e==null?void 0:e.formatNumber)==null?void 0:u.currency)||"",((f=e==null?void 0:e.formatNumber)==null?void 0:f.locale)||"",((g=e==null?void 0:e.formatNumber)==null?void 0:g.suffix)||"")}})})]}),b.jsxs("div",{children:[b.jsx(Fn,{className:"text-xs",children:"Suffix"}),b.jsx(Ii,{value:((l=e==null?void 0:e.formatNumber)==null?void 0:l.suffix)||"",className:" h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B",onChange:c=>{var u,f,g;return n(((u=e==null?void 0:e.formatNumber)==null?void 0:u.format)||"",((f=e==null?void 0:e.formatNumber)==null?void 0:f.currency)||"",((g=e==null?void 0:e.formatNumber)==null?void 0:g.locale)||"",c.target.value)}})]})]})]})}function moe(){return b.jsxs("div",{className:"px-6 py-2 space-y-6",children:[b.jsx(uc,{type:"single",collapsible:!0,children:b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:"",children:"KPI Query"}),b.jsxs(On,{className:"font-mono ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono text-xs",children:"SELECT current, previous FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 text-xs",children:[b.jsx("li",{children:"current - number"}),b.jsx("li",{children:"previous - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:e=>e.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),b.jsx("section",{className:"",children:b.jsx(goe,{})}),b.jsx("div",{}),b.jsx("div",{})]})}function voe({cardType:e}){return b.jsx("div",{className:"px-6 py-2 space-y-6",children:b.jsxs(uc,{defaultValue:["item-2"],type:"multiple",children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{children:`${Em(e)} Chart`}),b.jsxs(On,{className:" space-y-4 font-mono text-xs ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:"SELECT label, measure FROM table"}),b.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[b.jsx("li",{children:"label - category"}),b.jsx("li",{children:"measure - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{children:"Settings"}),b.jsx(On,{className:"px-2",children:b.jsx(Td,{})})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{children:"Filter on click"}),b.jsx(On,{className:"px-2",children:b.jsx(Ad,{})})]})]})})}function boe(){return b.jsx("div",{className:"px-6 py-2 space-y-6",children:b.jsxs(uc,{defaultValue:["item-2"],type:"multiple",children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{children:"Stacked Chart"}),b.jsxs(On,{className:" space-y-4 font-mono text-xs ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),b.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[b.jsx("li",{children:"x-axis - category"}),b.jsx("li",{children:"stack by - category"}),b.jsx("li",{children:"y-axis - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:e=>e.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{children:"Settings"}),b.jsxs(On,{className:"px-2 space-y-4",children:[b.jsx(l1,{}),b.jsx(sA,{}),b.jsx(Td,{})]})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{children:"Filter on click"}),b.jsx(On,{className:"px-2",children:b.jsx(Ad,{})})]})]})})}function yoe(){const e=pe(n=>n.card.type);function t(n){switch(n){case"stackedBar":return b.jsx(boe,{});case"kpi":return b.jsx(moe,{});case"line":case"bar":return b.jsx(coe,{cardType:n});case"pie":case"doughnut":case"polarArea":case"radar":return b.jsx(voe,{cardType:n});case"bubble":case"scatter":return b.jsx(uoe,{cardType:n});case"table":return b.jsx(b.Fragment,{});default:return b.jsx(hoe,{})}}return b.jsx(Rl,{className:" text-sm h-full w-full ",children:t(e)})}function xoe(){const e=pe(t=>t.isShowingVisual);return b.jsxs(px,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[b.jsx(rc,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:b.jsx(eie,{})}),b.jsx(gx,{withHandle:!0,className:"border "}),b.jsx(rc,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:e?b.jsxs(px,{direction:"horizontal",children:[b.jsx(b.Fragment,{children:b.jsx(rc,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:b.jsx(yoe,{})})}),b.jsx(gx,{className:"border "}),b.jsx(rc,{minSize:40,defaultSize:75,maxSize:100,children:b.jsx(jT,{})})]}):b.jsx(jT,{})})]})}function woe({authToken:e,onSave:t,onClose:n}){pe(s=>s.actions.setCard);const r=pe(s=>s.actions.setOnSave),i=pe(s=>s.actions.setOnClose),o=he(s=>s.actions.setAuthToken);return m.useEffect(()=>{t&&r(t),n&&i(n)},[t,r,n,i]),m.useEffect(()=>{e&&e.accessToken&&o(e)},[e,o]),b.jsxs(DM,{className:"rounded-none",role:"editor-panel",children:[b.jsx(TM,{className:" rounded-none border-r-[1.5px] ",children:b.jsx(tD,{})}),b.jsx(AM,{children:b.jsx(xoe,{})})]})}function _oe(){he(s=>s.selectedCardId);const e=he(s=>s.selectedSheetId),{setIsVisualEditing:t}=he(s=>s.actions),n=he(s=>s.isVisualEditing),r=he(s=>s.actions.updateFrame);function i(s){e&&(r(e,s),t(!1))}function o(){t(!1)}return b.jsx("div",{role:"editor-container",className:Ee("grow flex",{block:n,hidden:!n}),children:b.jsx(woe,{onSave:i,onClose:o})})}function Soe({columns:e,tableName:t}){const n=pe(f=>f.selectedConnectionId),r=pe(f=>f.selectedDatabaseName),i=pe(f=>f.selectedSchemaName),o=pe(f=>f.selectedTableName),s=he(f=>f.dashboard.filters)||[],a=he(f=>f.actions.addFilter),l=he(f=>f.actions.removeFilter),c=he(f=>f.actions.removeFilterValue);function u(f){const g=ki(f.column_name),p=ki(r||""),v=ki(i||""),y=ki(t),w=s==null?void 0:s.find(_=>_.column===g&&_.table===y&&_.database===p);if(w)c(w.id),l(w.id);else{const _=Op(v,y),S=`SELECT ${g}, COUNT(*) FROM ${_} GROUP BY ${g} ORDER BY ${g} ASC LIMIT 50`,C=`SELECT min(${g}) as min, max(${g}) as max FROM ${_}`;if(t==="api"&&n){a({id:Qo(),column:`${_}.${g}`,title:f.column_name,dataType:f.data_type,table:"api",database:"NA",connectionId:n,sql:Sa.includes(f.data_type)?C:S});return}if(!n||!r||!o)throw new Error("missing connectionId, database, or table");a({id:Qo(),column:`${_}.${g}`,title:f.column_name,dataType:f.data_type,table:o,database:r,connectionId:n,sql:Sa.includes(f.data_type)?C:S})}}return b.jsx("div",{className:" flex-1 basis-0 overflow-scroll flex-col xbg-red-100 px-3",children:e==null?void 0:e.map(f=>{const g=s==null?void 0:s.find(p=>p.column===ki(f.column_name)&&p.table===o&&p.database===r);return b.jsx("div",{onClick:()=>u(f),className:Ee(" group flex text-sm items-center justify-between px-3 py-[6px] transition-colors hover:bg-muted/50 cursor-pointer border border-background border-dashed",{"bg-muted ":g}),children:b.jsxs("div",{className:"flex items-center gap-2 ",children:[b.jsx(eD,{column:f}),b.jsx("span",{children:f.column_name})]})},f.column_name)})})}function Coe(){he(t=>t.showFilters);const e=he(t=>t.actions.setShowFilters);return b.jsxs("section",{className:" grow flex flex-col border-l relative px-4 ",children:[b.jsxs("div",{className:"flex justify-between items-center gap-2 mt-4 px-3",children:[b.jsx(Fn,{className:"text-lg",children:"Filters"}),b.jsx(Je,{onClick:()=>e(!1),className:" p-0 h-7 w-7 ",variant:"ghost",children:b.jsx(pa,{})})]}),b.jsx("div",{className:"grow flex",children:b.jsx(tD,{ColumnsComponent:(t,n,r)=>b.jsx(Soe,{schemaName:t,tableName:n,columns:r})})})]})}function Eoe(){he(n=>n.dashboard);const e=he(n=>n.showFilters),t=he(n=>n.isVisualEditing);return he(n=>n.bookmarkKey),b.jsxs("div",{role:"dashboard-plus-main",className:Ee(" grow",{hidden:t,flex:!t}),children:[b.jsx(zk,{}),e&&b.jsx("div",{role:"filter-aside-container",className:" flex",children:b.jsx(Coe,{})})]})}function Ooe(){const e=he(r=>r.dashboard),t=he(r=>r.actions.setDashboard),n=he(r=>r.showDashboardJSON);return he(r=>r.actions.setShowDashboardJSON),b.jsx("div",{className:Ee(" p-2",{hidden:!n}),children:b.jsx(BD,{onChange:r=>{if(r)try{JSON.parse(r),t(JSON.parse(r))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(e,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function Poe({showControls:e=!1,showFooter:t=!0,...n}){return he(r=>r.isVisualEditing),b.jsx(A_,{dashboardProps:n,children:b.jsxs(By,{children:[b.jsx(Ooe,{}),b.jsxs($_,{...n,children:[e&&b.jsx(cQ,{}),b.jsx(_oe,{}),b.jsx(Eoe,{})]})]})})}function koe({card:e,footer:t,className:n,...r}){const{customCards:i}=zi(),o=m.useRef(null),{isError:s,isLoading:a,isFetching:l,cfg:c,visualKey:u,handleDatapointClick:f}=j0(e),g=he(I=>I.themeStyle),p=he(I=>I.selectedSheetId),v=he(I=>I.selectedCardId),y=he(I=>I.isDashboardEditing),{setCardTitle:w,setCardDescription:_,setSelectedCardId:S}=pl();function C(I){I.stopPropagation(),S(p,e.id)}function P(){if(i&&i.length>0){const I=i.find(F=>F.cardId===e.id);if(I&&I.replaceDefault){const F=I.content;if(F)return b.jsx(F,{card:e})}}return e.type==="kpi"?e.data&&e.data.length>0&&b.jsx(L0,{isLoading:a||l,card:e}):T}function O(){if(s)return b.jsx("p",{className:"text-sm",children:"Oops! It seems like something went wrong. Please review your connection or filters."});if(e.type==="table"&&e.data&&e.data.length>0)return b.jsxs(Rl,{children:[b.jsx(sp,{data:e.data}),b.jsx(Ll,{orientation:"horizontal"})]});if(i&&i.length>0){const I=i.find(F=>F.cardId===e.id);if(I&&I.content){const F=I.content;return b.jsx(F,{card:e})}}if(c)return b.jsx(Xb,{cfg:c,onDatapointClick:f},u)}function k(){if(i&&i.length>0){const I=i.find(F=>F.cardId===e.id);if(I&&I.footer){const F=I.footer;if(F)return b.jsx(F,{card:e})}}return t||null}if(!e.id)return null;const T=b.jsxs(b.Fragment,{children:[b.jsxs(su,{className:"pb-4",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx(Ui,{text:e.title,onSave:I=>w(p,e.id,I),children:b.jsx(au,{className:"text-base",children:e.title})}),e.refreshInterval&&b.jsxs(ep,{children:[b.jsx(h0,{className:"pr-1",children:b.jsx("div",{className:Ee("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":a||l})})}),b.jsx(Uu,{side:"right",align:"center",children:b.jsx("p",{className:"text-xs",children:`Realtime (${e==null?void 0:e.refreshInterval})`})})]}),!e.refreshInterval&&(a||l)&&b.jsx(ma,{className:"h-4 w-4 animate-spin text-muted-foreground"})]}),b.jsx(Ui,{text:(e==null?void 0:e.description)||"",onSave:I=>_(p,e.id,I),children:b.jsxs(rh,{children:[" ",e.description]})})]}),b.jsx(lu,{className:"relative flex grow flex-col overflow-auto pb-0",children:O()}),b.jsx(rb,{children:k()})]});return b.jsx(nh,{tabIndex:-1,ref:o,role:"dashboard-card",onClick:C,className:Ee("relative flex h-full flex-col rounded-sm",{"border-dashed border-foreground/50":v===e.id&&y},g==null?void 0:g.dashboardCard,n),...r,children:P()})}const Dg=`import pandas as pd
574
+ Defaulting to \`${e1}\`.`}function RT(e){return hie.includes(e)}const LT=NT,FT=de.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},i)=>b.jsx(LT,{ref:i,decorative:n,orientation:t,className:Ee("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));FT.displayName=LT.displayName;function jT(){pe(s=>s.frame);const e=pe(s=>s.card),t=pe(s=>s.card.data),n=pe(s=>s.isShowingVisual),r=pe(s=>s.isSqlRunning),i=pe(s=>s.queryError),o=pe(s=>s.pythonStdOut);return pe(s=>s.onSave),pe(s=>s.onClose),pe(s=>s.actions.setCardSql),pe(s=>s.actions.setCardType),pe(s=>s.actions.setSqlGen),e?b.jsxs("div",{className:" h-full relative flex flex-col py-3",children:[r&&b.jsx(ma,{className:" w-10 h-10 z-10 absolute m-auto left-0 right-0 top-0 bottom-0 animate-spin text-foreground/10 "}),b.jsxs("div",{className:" px-6 min-h-10 mb-0 flex justify-end items-center gap-2",children:[n&&b.jsxs("div",{className:"flex grow gap-2 items-center ",children:[b.jsx(uie,{}),b.jsx(cie,{}),b.jsx(fie,{})]}),b.jsx(mie,{})]}),n?e.type==="kpi"?b.jsx("div",{className:"grow flex items-center justify-center ",children:b.jsx("div",{className:" w-1/2 border rounded-md",children:b.jsx(L0,{isLoading:r,card:e})})}):b.jsx(PT,{className:"grow border-none shadow-none "}):b.jsxs("div",{className:"w-full px-6 bg-red-x00 grow border-none shadow-none overflow-y-auto ",children:[o&&b.jsx(gie,{}),e.data&&e.data.length>0&&b.jsx(sp,{data:t||[]}),i&&b.jsx("span",{className:"font-mono text-sm",children:i})]})]}):b.jsx(b.Fragment,{children:"No Active Card"})}function gie(){const e=pe(n=>n.pythonStdOut);if(!e)return null;const t=e.replace(/\n/g,"<br>");return b.jsxs(b.Fragment,{children:[b.jsx("p",{className:"font-mono text-sm",children:"Output:"}),b.jsx("div",{dangerouslySetInnerHTML:{__html:t},className:"font-mono text-sm p-2 bg-muted"}),b.jsx(FT,{className:" mb-2"})]})}function mie(){const e=pe(n=>n.isShowingVisual),t=pe(n=>n.actions.setIsShowingVisual);return b.jsxs("div",{className:" flex items-center space-x-2",children:[b.jsx(Fn,{htmlFor:"visualize",children:"Chart"}),b.jsx(OT,{checked:e,onCheckedChange:()=>t(!e),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}const $T="Collapsible",[vie,zT]=Rn($T),[bie,t1]=vie($T),yie=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:o,onOpenChange:s,...a}=e,[l=!1,c]=Qn({prop:r,defaultProp:i,onChange:s});return m.createElement(bie,{scope:n,disabled:o,contentId:pr(),open:l,onOpenToggle:m.useCallback(()=>c(u=>!u),[c])},m.createElement(ze.div,ae({"data-state":n1(l),"data-disabled":o?"":void 0},a,{ref:t})))}),xie="CollapsibleTrigger",wie=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=t1(xie,n);return m.createElement(ze.button,ae({type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":n1(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled},r,{ref:t,onClick:Oe(e.onClick,i.onOpenToggle)}))}),BT="CollapsibleContent",_ie=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=t1(BT,e.__scopeCollapsible);return m.createElement(wn,{present:n||i.open},({present:o})=>m.createElement(Sie,ae({},r,{ref:t,present:o})))}),Sie=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...o}=e,s=t1(BT,n),[a,l]=m.useState(r),c=m.useRef(null),u=rt(t,c),f=m.useRef(0),g=f.current,p=m.useRef(0),v=p.current,y=s.open||a,w=m.useRef(y),_=m.useRef();return m.useEffect(()=>{const S=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(S)},[]),Xn(()=>{const S=c.current;if(S){_.current=_.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const C=S.getBoundingClientRect();f.current=C.height,p.current=C.width,w.current||(S.style.transitionDuration=_.current.transitionDuration,S.style.animationName=_.current.animationName),l(r)}},[s.open,r]),m.createElement(ze.div,ae({"data-state":n1(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!y},o,{ref:u,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style}}),y&&i)});function n1(e){return e?"open":"closed"}const Cie=yie,Eie=wie,Oie=_ie,Es="Accordion",Pie=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[r1,kie,Mie]=Af(Es),[kg,$he]=Rn(Es,[Mie,zT]),i1=zT(),VT=m.forwardRef((e,t)=>{const{type:n,...r}=e,i=r,o=r;return m.createElement(r1.Provider,{scope:e.__scopeAccordion},n==="multiple"?m.createElement(Iie,ae({},o,{ref:t})):m.createElement(Aie,ae({},i,{ref:t})))});VT.propTypes={type(e){const t=e.value||e.defaultValue;return e.type&&!["single","multiple"].includes(e.type)?new Error("Invalid prop `type` supplied to `Accordion`. Expected one of `single | multiple`."):e.type==="multiple"&&typeof t=="string"?new Error("Invalid prop `type` supplied to `Accordion`. Expected `single` when `defaultValue` or `value` is type `string`."):e.type==="single"&&Array.isArray(t)?new Error("Invalid prop `type` supplied to `Accordion`. Expected `multiple` when `defaultValue` or `value` is type `string[]`."):null}};const[HT,Die]=kg(Es),[WT,Tie]=kg(Es,{collapsible:!1}),Aie=m.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:i=()=>{},collapsible:o=!1,...s}=e,[a,l]=Qn({prop:n,defaultProp:r,onChange:i});return m.createElement(HT,{scope:e.__scopeAccordion,value:a?[a]:[],onItemOpen:l,onItemClose:m.useCallback(()=>o&&l(""),[o,l])},m.createElement(WT,{scope:e.__scopeAccordion,collapsible:o},m.createElement(UT,ae({},s,{ref:t}))))}),Iie=m.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:i=()=>{},...o}=e,[s=[],a]=Qn({prop:n,defaultProp:r,onChange:i}),l=m.useCallback(u=>a((f=[])=>[...f,u]),[a]),c=m.useCallback(u=>a((f=[])=>f.filter(g=>g!==u)),[a]);return m.createElement(HT,{scope:e.__scopeAccordion,value:s,onItemOpen:l,onItemClose:c},m.createElement(WT,{scope:e.__scopeAccordion,collapsible:!0},m.createElement(UT,ae({},o,{ref:t}))))}),[Nie,Mg]=kg(Es),UT=m.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:i,orientation:o="vertical",...s}=e,a=m.useRef(null),l=rt(a,t),c=kie(n),f=Ys(i)==="ltr",g=Oe(e.onKeyDown,p=>{var v;if(!Pie.includes(p.key))return;const y=p.target,w=c().filter(F=>{var $;return!(($=F.ref.current)!==null&&$!==void 0&&$.disabled)}),_=w.findIndex(F=>F.ref.current===y),S=w.length;if(_===-1)return;p.preventDefault();let C=_;const P=0,O=S-1,k=()=>{C=_+1,C>O&&(C=P)},T=()=>{C=_-1,C<P&&(C=O)};switch(p.key){case"Home":C=P;break;case"End":C=O;break;case"ArrowRight":o==="horizontal"&&(f?k():T());break;case"ArrowDown":o==="vertical"&&k();break;case"ArrowLeft":o==="horizontal"&&(f?T():k());break;case"ArrowUp":o==="vertical"&&T();break}const I=C%S;(v=w[I].ref.current)===null||v===void 0||v.focus()});return m.createElement(Nie,{scope:n,disabled:r,direction:i,orientation:o},m.createElement(r1.Slot,{scope:n},m.createElement(ze.div,ae({},s,{"data-orientation":o,ref:l,onKeyDown:r?void 0:g}))))}),o1="AccordionItem",[Rie,s1]=kg(o1),Lie=m.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...i}=e,o=Mg(o1,n),s=Die(o1,n),a=i1(n),l=pr(),c=r&&s.value.includes(r)||!1,u=o.disabled||e.disabled;return m.createElement(Rie,{scope:n,open:c,disabled:u,triggerId:l},m.createElement(Cie,ae({"data-orientation":o.orientation,"data-state":GT(c)},a,i,{ref:t,disabled:u,open:c,onOpenChange:f=>{f?s.onItemOpen(r):s.onItemClose(r)}})))}),Fie="AccordionHeader",jie=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Mg(Es,n),o=s1(Fie,n);return m.createElement(ze.h3,ae({"data-orientation":i.orientation,"data-state":GT(o.open),"data-disabled":o.disabled?"":void 0},r,{ref:t}))}),qT="AccordionTrigger",$ie=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Mg(Es,n),o=s1(qT,n),s=Tie(qT,n),a=i1(n);return m.createElement(r1.ItemSlot,{scope:n},m.createElement(Eie,ae({"aria-disabled":o.open&&!s.collapsible||void 0,"data-orientation":i.orientation,id:o.triggerId},a,r,{ref:t})))}),zie="AccordionContent",Bie=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=Mg(Es,n),o=s1(zie,n),s=i1(n);return m.createElement(Oie,ae({role:"region","aria-labelledby":o.triggerId,"data-orientation":i.orientation},s,r,{ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}}))});function GT(e){return e?"open":"closed"}const Vie=VT,Hie=Lie,Wie=jie,YT=$ie,KT=Bie,uc=Vie,Cn=de.forwardRef(({className:e,...t},n)=>b.jsx(Hie,{ref:n,className:Ee("border-b",e),...t}));Cn.displayName="AccordionItem";const En=de.forwardRef(({className:e,children:t,...n},r)=>b.jsx(Wie,{className:"flex",children:b.jsxs(YT,{ref:r,className:Ee("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,b.jsx(dp,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));En.displayName=YT.displayName;const On=de.forwardRef(({className:e,children:t,...n},r)=>b.jsx(KT,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:b.jsx("div",{className:Ee("pb-4 pt-0",e),children:t})}));On.displayName=KT.displayName;function Td(){var r,i,o;const e=pe(s=>s.card.cfg),t=pe(s=>s.actions.setCardCfg);function n(s){var c;const a={datalabels:{display:s!=="none",align:s,anchor:s,clamp:!0}},l={...e,options:{...e==null?void 0:e.options,plugins:{...(c=e==null?void 0:e.options)==null?void 0:c.plugins,...a}}};t(l),console.log(s)}return b.jsxs("div",{className:"space-y-2",children:[b.jsx("label",{className:"font-medium",children:"Data Labels"}),b.jsxs(lx,{value:(o=(i=(r=e==null?void 0:e.options)==null?void 0:r.plugins)==null?void 0:i.datalabels)==null?void 0:o.anchor,onValueChange:n,defaultValue:"none",children:[b.jsx(rg,{className:"h-8 w-[180px] focus:ring-1 focus:ring-offset-0",children:b.jsx(ux,{placeholder:"Select position"})}),b.jsx(ig,{children:b.jsxs(cx,{children:[b.jsx(pd,{children:"Data Labels"}),b.jsx(Ro,{value:"none",children:"None"}),b.jsx(Ro,{value:"start",children:"Start"}),b.jsx(Ro,{value:"center",children:"Center"}),b.jsx(Ro,{value:"end",children:"End"})]})})]})]})}function Ad(){const[e,t]=m.useState([]);pe(u=>u.card.cfg);const n=pe(u=>u.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:i,setCardPreferences:o}=pe(u=>u.actions),s=pe(u=>u.queryResultColumns);pe(u=>{var f;return(f=u.card.preferences)==null?void 0:f.filterOnClickColumnIndex}),m.useEffect(()=>{s&&t(new Array(s.length).fill(!1))},[s]);function a(u,f){var g,p;f?n!=null&&n.onClickFilter&&((g=n==null?void 0:n.onClickFilter)==null?void 0:g.length)>0?o({...n,onClickFilter:[...n.onClickFilter,{columnIndex:u,expression:""}]}):o({...n,onClickFilter:[{columnIndex:u,expression:""}]}):(o({...n,onClickFilter:(p=n==null?void 0:n.onClickFilter)==null?void 0:p.filter(v=>v.columnIndex!==u)}),t(v=>{const y=[...v];return y[u]=!1,y}))}function l(u,f){var p;const g=(p=n==null?void 0:n.onClickFilter)==null?void 0:p.map(v=>v.columnIndex===u?{...v,expression:f.target.value}:v);o({...n,onClickFilter:g})}function c(u){var f,g,p,v;if(e!=null&&e[u]||(g=(f=n==null?void 0:n.onClickFilter)==null?void 0:f.find(y=>y.columnIndex===u))!=null&&g.expression)return b.jsx(Ii,{value:(v=(p=n==null?void 0:n.onClickFilter)==null?void 0:p.find(y=>y.columnIndex===u))==null?void 0:v.expression,onChange:y=>l(u,y),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return b.jsx(b.Fragment,{children:s==null?void 0:s.map((u,f)=>{var g,p;return b.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:b.jsxs("div",{className:" grow",children:[b.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[b.jsx(hd,{checked:!!((g=n==null?void 0:n.onClickFilter)!=null&&g.find(v=>v.columnIndex===f)),onCheckedChange:v=>a(f,v)}),b.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:u}),b.jsx("div",{className:"flex gap-2 items-center ",children:((p=n==null?void 0:n.onClickFilter)==null?void 0:p.find(v=>v.columnIndex===f))&&b.jsx(oP,{onClick:()=>{t(v=>{const y=[...v];return y[f]=!v[f],y})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),c(f)]})},u)})})}const XT="Radio",[Uie,QT]=Rn(XT),[qie,Gie]=Uie(XT),Yie=m.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:i=!1,required:o,disabled:s,value:a="on",onCheck:l,...c}=e,[u,f]=m.useState(null),g=rt(t,y=>f(y)),p=m.useRef(!1),v=u?!!u.closest("form"):!0;return m.createElement(qie,{scope:n,checked:i,disabled:s},m.createElement(ze.button,ae({type:"button",role:"radio","aria-checked":i,"data-state":ZT(i),"data-disabled":s?"":void 0,disabled:s,value:a},c,{ref:g,onClick:Oe(e.onClick,y=>{i||l==null||l(),v&&(p.current=y.isPropagationStopped(),p.current||y.stopPropagation())})})),v&&m.createElement(Qie,{control:u,bubbles:!p.current,name:r,value:a,checked:i,required:o,disabled:s,style:{transform:"translateX(-100%)"}}))}),Kie="RadioIndicator",Xie=m.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...i}=e,o=Gie(Kie,n);return m.createElement(wn,{present:r||o.checked},m.createElement(ze.span,ae({"data-state":ZT(o.checked),"data-disabled":o.disabled?"":void 0},i,{ref:t})))}),Qie=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Zp(n),a=Xh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const g=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(g)}},[s,n,r]),m.createElement("input",ae({type:"radio","aria-hidden":!0,defaultChecked:n},i,{tabIndex:-1,ref:o,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function ZT(e){return e?"checked":"unchecked"}const Zie=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],JT="RadioGroup",[Jie,zhe]=Rn(JT,[gl,QT]),eA=gl(),tA=QT(),[eoe,toe]=Jie(JT),noe=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:i,value:o,required:s=!1,disabled:a=!1,orientation:l,dir:c,loop:u=!0,onValueChange:f,...g}=e,p=eA(n),v=Ys(c),[y,w]=Qn({prop:o,defaultProp:i,onChange:f});return m.createElement(eoe,{scope:n,name:r,required:s,disabled:a,value:y,onValueChange:w},m.createElement(iv,ae({asChild:!0},p,{orientation:l,dir:v,loop:u}),m.createElement(ze.div,ae({role:"radiogroup","aria-required":s,"aria-orientation":l,"data-disabled":a?"":void 0,dir:v},g,{ref:t}))))}),roe="RadioGroupItem",ioe=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...i}=e,o=toe(roe,n),s=o.disabled||r,a=eA(n),l=tA(n),c=m.useRef(null),u=rt(t,c),f=o.value===i.value,g=m.useRef(!1);return m.useEffect(()=>{const p=y=>{Zie.includes(y.key)&&(g.current=!0)},v=()=>g.current=!1;return document.addEventListener("keydown",p),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",v)}},[]),m.createElement(ov,ae({asChild:!0},a,{focusable:!s,active:f}),m.createElement(Yie,ae({disabled:s,required:o.required,checked:f},l,i,{name:o.name,ref:u,onCheck:()=>o.onValueChange(i.value),onKeyDown:Oe(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:Oe(i.onFocus,()=>{var p;g.current&&((p=c.current)===null||p===void 0||p.click())})})))}),ooe=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,i=tA(n);return m.createElement(Xie,ae({},i,r,{ref:t}))}),nA=noe,rA=ioe,soe=ooe,a1=de.forwardRef(({className:e,...t},n)=>b.jsx(nA,{className:Ee("grid gap-2",e),...t,ref:n}));a1.displayName=nA.displayName;const Id=de.forwardRef(({className:e,...t},n)=>b.jsx(rA,{ref:n,className:Ee("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:b.jsx(soe,{className:"flex items-center justify-center",children:b.jsx(rP,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Id.displayName=rA.displayName;function l1(){var o,s;const e=pe(a=>a.card.preferences),t=pe(a=>a.card.cfg),{setCardCfg:n,setCardPreferences:r}=pe(a=>a.actions);(o=t==null?void 0:t.options)!=null&&o.indexAxis;function i(a){var u,f,g,p,v,y;let l={};(u=e==null?void 0:e.chartOptions)!=null&&u.scales&&(l={x:(g=(f=e==null?void 0:e.chartOptions)==null?void 0:f.scales)==null?void 0:g.y,y:(v=(p=e==null?void 0:e.chartOptions)==null?void 0:p.scales)==null?void 0:v.x});const c={...e,chartOptions:{...e==null?void 0:e.chartOptions,scales:{...(y=e==null?void 0:e.chartOptions)==null?void 0:y.scales,...l},indexAxis:a}};r(c)}return b.jsxs(a1,{value:((s=e==null?void 0:e.chartOptions)==null?void 0:s.indexAxis)||"x",onValueChange:i,className:"flex gap-3",defaultValue:"x",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(Id,{value:"x",id:"r1"}),b.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(Id,{value:"y",id:"r2"}),b.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const c1="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function iA(e){var n,r;return(n=e==null?void 0:e.chartOptions)!=null&&n.indexAxis?((r=e==null?void 0:e.chartOptions)==null?void 0:r.indexAxis)==="x"?"y":"x":"y"}function oA(e){var n,r,i;const t=iA(e);return((i=(r=(n=e==null?void 0:e.chartOptions)==null?void 0:n.scales)==null?void 0:r[t])==null?void 0:i.type)||"linear"}function aoe(){var S,C,P,O,k,T;const[e,t]=m.useState(!1),n=pe(I=>{var F;return(F=I.card)==null?void 0:F.preferences}),r=iA(n),[i,o]=m.useState(oA(n)),[s,a]=m.useState(((P=(C=(S=n==null?void 0:n.chartOptions)==null?void 0:S.scales)==null?void 0:C[r])==null?void 0:P.min)||""),[l,c]=m.useState(((T=(k=(O=n==null?void 0:n.chartOptions)==null?void 0:O.scales)==null?void 0:k[r])==null?void 0:T.max)||""),[u,f]=m.useState(s||l?"custom":"auto"),[g,p]=m.useState(""),v=pe(I=>I.actions.setCardPreferences);m.useEffect(()=>{var I,F,$,z,V,se,J,j,Z,G;o(oA(n)),a((($=(F=(I=n==null?void 0:n.chartOptions)==null?void 0:I.scales)==null?void 0:F[r])==null?void 0:$.min)===0?0:""),c(((se=(V=(z=n==null?void 0:n.chartOptions)==null?void 0:z.scales)==null?void 0:V[r])==null?void 0:se.max)||""),p(((G=(Z=(j=(J=n==null?void 0:n.chartOptions)==null?void 0:J.scales)==null?void 0:j[r])==null?void 0:Z.ticks)==null?void 0:G.stepSize)||"")},[e,n,r]);function y(I,F){return F===""||/^[0-9\b]+$/.test(F)?Number(F):Number(I)}function w(){return b.jsxs(b.Fragment,{children:[b.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[b.jsx(Fn,{htmlFor:"range",children:"Range"}),b.jsx(Ii,{id:"min",value:s,onChange:I=>a(F=>y(F,I.target.value)),className:`col-span-1 h-8 w-full ${c1}`}),b.jsx(Ii,{value:l,onChange:I=>c(F=>y(F,I.target.value)),id:"max",className:`col-span-1 h-8 w-full ${c1}`})]}),b.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[b.jsx(Fn,{htmlFor:"step-size",children:"Step Size"}),b.jsx(Ii,{value:g,onChange:I=>p(F=>y(F,I.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${c1}`})]})]})}function _(){var $;let I={};u==="custom"&&(I={min:s,max:l,ticks:{stepSize:g}});const F={...n||{},chartOptions:{...n==null?void 0:n.chartOptions,scales:{...($=n==null?void 0:n.chartOptions)==null?void 0:$.scales,[r]:{type:i,...i==="linear"?I:{}}}}};v(F)}return b.jsxs(ad,{onOpenChange:I=>t(I),children:[b.jsx(ld,{asChild:!0,children:b.jsx(Vz,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),b.jsx(Kl,{align:"center",className:"max-w-65",children:b.jsxs("div",{className:"grid gap-4",children:[b.jsxs("div",{className:"space-y-2",children:[b.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),b.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),b.jsxs("div",{className:"grid gap-2",children:[b.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[b.jsx(Fn,{htmlFor:"scale",children:"Type"}),b.jsxs(lx,{value:i,onValueChange:I=>o(I),children:[b.jsx(rg,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:b.jsx(ux,{})}),b.jsx(ig,{id:"type",children:b.jsxs(cx,{children:[b.jsx(pd,{children:"Option"}),b.jsx(Ro,{value:"linear",children:"Linear"}),b.jsx(Ro,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),i=="linear"&&b.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[b.jsx(Fn,{htmlFor:"scale-option",children:"Setup"}),b.jsxs(a1,{id:"scale-option",value:u,onValueChange:I=>f(I),className:"col-span-2 flex gap-3",defaultValue:"x",children:[b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(Id,{value:"auto",id:"r1"}),b.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),b.jsxs("div",{className:"flex items-center space-x-2",children:[b.jsx(Id,{value:"custom",id:"r2"}),b.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),u==="custom"&&i=="linear"&&w(),b.jsx(JM,{}),b.jsx("div",{className:"grid grid-cols-3",children:b.jsx(Je,{onClick:_,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function sA(){const e=pe(l=>l.card),t=pe(l=>{var c,u,f;return(f=(u=(c=l==null?void 0:l.card)==null?void 0:c.cfg)==null?void 0:u.options)==null?void 0:f.indexAxis}),n=t==="y"?"Y Axis":"X Axis",r=t==="y"?"X Axis":"Y Axis",{keys:i,metricKeys:o,dimensionKeys:s}=oi(e.data||[]);let a=o;if(e.type==="stackedBar"){const l=Zb({dataArray:e.data||[],groupKey:s[0],pivotKey:s[1],valueKey:a[0]}),{metricKeys:c}=oi(l);a=c}return i.length===0?null:b.jsxs("div",{className:"space-y-4",children:[b.jsxs("div",{className:"space-y-2",children:[b.jsx(Fn,{children:n}),b.jsx("div",{className:"my-1 space-y-1",children:b.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:b.jsx("p",{children:s[0]})})})]}),b.jsxs("div",{className:"space-y-2",children:[b.jsxs("div",{className:"flex items-center justify-between gap-5",children:[b.jsx(Fn,{children:r}),b.jsx(aoe,{})]}),b.jsx("div",{className:"my-1 space-y-1",children:a.map((l,c)=>b.jsx(loe,{col:l,idx:c},l))})]})]})}function loe({col:e,idx:t}){const n=pe(a=>{var l;return(l=a.card)==null?void 0:l.preferences}),r=pe(a=>{var l;return(l=a.card.preferences)==null?void 0:l.datasetOptions}),i=r==null?void 0:r.find(a=>a.idx===t),{setCardPreferences:o}=pe(a=>a.actions);function s(a){if(!i)o({...n,datasetOptions:[...r||[],{idx:t,type:a==="area"?"line":a,fill:a==="area"?"origin":""}]});else{const l={...i};l.type=a==="area"?"line":a,l.fill=a==="area"?"origin":"";const c=r==null?void 0:r.map(u=>u.idx===t?l:u);o({...n,datasetOptions:c})}}return b.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[b.jsx("p",{children:e}),b.jsxs("div",{className:"flex gap-2",children:[b.jsx(I0,{onClick:()=>s("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),b.jsx(N0,{onClick:()=>s("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),b.jsx(g6,{onClick:()=>s("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})]})]})}function coe({cardType:e}){return b.jsx("div",{className:"space-y-6 px-6 py-2",children:b.jsxs(uc,{defaultValue:["item-2"],type:"multiple",children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{children:`${Em(e)} Chart`}),b.jsxs(On,{className:"space-y-4 font-mono text-xs",children:[b.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),b.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[b.jsx("li",{children:"x-axis - category"}),b.jsx("li",{children:"y-axis1 - number"}),b.jsx("li",{children:"y-axis2 - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{children:"Settings"}),b.jsxs(On,{className:"space-y-4 px-2",children:[b.jsx(l1,{}),b.jsx(sA,{}),b.jsx(Td,{})]})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{children:"Filter on click"}),b.jsx(On,{className:"px-2",children:b.jsx(Ad,{})})]})]})})}function uoe({cardType:e}){function t(n){const r="SELECT label, [group], x-axis, y-axis, radius FROM table",i="SELECT label, [group], x-axis, y-axis FROM table";return b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:n==="bubble"?r:i}),b.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[b.jsx("li",{children:"label - category"}),b.jsx("li",{children:"group - category"}),b.jsx("li",{children:"x-axis - category"}),b.jsx("li",{children:"y-axis - category"}),n==="bubble"&&b.jsx("li",{children:"radius - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:o=>o.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return b.jsx("div",{className:"px-6 py-2 space-y-6",children:b.jsxs(uc,{defaultValue:["item-2"],type:"multiple",children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{children:`${Em(e)} Chart`}),b.jsx(On,{className:" space-y-4 font-mono text-xs ",children:t(e)})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{children:"Settings"}),b.jsx(On,{className:"px-2",children:b.jsx(Td,{})})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{children:"Filter on click"}),b.jsx(On,{className:"px-2",children:b.jsx(Ad,{})})]})]})})}const doe={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},foe={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function hoe(){const e=pe(t=>t.card.type);return b.jsxs("div",{className:"p-6 space-y-6",children:[b.jsx(uc,{className:" ",type:"single",collapsible:!0,children:poe(e)}),b.jsx("section",{className:"",children:["line","bar"].includes(e)&&b.jsx(l1,{})}),b.jsx("div",{children:!["kpi"].includes(e)&&b.jsx(Td,{})}),b.jsx("div",{children:!["kpi"].includes(e)&&b.jsx(Ad,{})})]})}function poe(e){if(["line","bar"].includes(e))return b.jsxs(b.Fragment,{children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:" font-normal",children:b.jsx("p",{children:"Chart Query"})}),b.jsxs(On,{className:" ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[b.jsx("li",{children:"X-axis - Category (ex. city)"}),b.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{className:" font-normal",children:"Mixed Chart"}),b.jsxs(On,{className:" text-xs space-y-2",children:[b.jsxs("p",{children:["Click ",b.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),b.jsx("pre",{children:JSON.stringify(doe,null,2)})]})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{className:" font-normal",children:"Area Chart"}),b.jsxs(On,{className:" text-xs space-y-2",children:[b.jsxs("p",{children:["Click ",b.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",b.jsx("a",{className:"text-blue-500 hover:underline mx-1",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),b.jsx("pre",{children:JSON.stringify(foe,null,2)})]})]})]});if(e==="bubble")return b.jsx(b.Fragment,{children:b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:" font-normal",children:b.jsxs("p",{children:["How to create a ",b.jsx("span",{children:e})," chart query?"]})}),b.jsxs(On,{className:" ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis, radius FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[b.jsx("li",{children:"Label - Category (ex. city)"}),b.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),b.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),b.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),b.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(e==="scatter")return b.jsx(b.Fragment,{children:b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:" font-normal",children:b.jsxs("p",{children:["How to create a ",b.jsx("span",{children:e})," chart query?"]})}),b.jsxs(On,{className:" ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[b.jsx("li",{children:"Label - Category (ex. city)"}),b.jsx("li",{children:"Group (opt) - Category (ex. state)"}),b.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),b.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(e))return b.jsx(b.Fragment,{children:b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:" font-normal",children:b.jsxs("p",{children:[b.jsx("span",{children:e==="polarArea"?"Polar":e.charAt(0).toUpperCase()+e.slice(1)})," ","chart query"]})}),b.jsxs(On,{className:" ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, measure FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[b.jsx("li",{children:"Label - Category (ex. city)"}),b.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function goe(){var s,a,l;const e=pe(c=>c.card.preferences),t=pe(c=>c.actions.setCardPreferences),n=pe(c=>c.actions.setNumberFormat),r=pe(c=>{var u,f;return(f=(u=c.card.preferences)==null?void 0:u.formatNumber)==null?void 0:f.format}),i=pe(c=>{var u,f;return(f=(u=c.card.preferences)==null?void 0:u.formatNumber)==null?void 0:f.locale}),o=pe(c=>{var u,f;return(f=(u=c.card.preferences)==null?void 0:u.formatNumber)==null?void 0:f.currency});return pe(c=>c.actions.setFilterOnClickField),b.jsxs("div",{children:[b.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[b.jsx(hd,{checked:!!((s=e==null?void 0:e.formatNumber)!=null&&s.enabled),onCheckedChange:c=>{t({...e,formatNumber:{...e==null?void 0:e.formatNumber,enabled:c}})}}),b.jsx(Fn,{children:"Format Number"})]}),((a=e==null?void 0:e.formatNumber)==null?void 0:a.enabled)===!0&&b.jsxs("div",{className:"flex flex-col gap-2 ",children:[b.jsxs("div",{children:[b.jsx(Fn,{className:"text-xs",children:"Currency"}),b.jsxs("div",{className:"flex gap-1",children:[b.jsx(Ii,{value:o||"",className:" h-7 w-20 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"USD",onChange:c=>{var u,f,g;return n(((u=e==null?void 0:e.formatNumber)==null?void 0:u.format)||"",c.target.value,((f=e==null?void 0:e.formatNumber)==null?void 0:f.locale)||"",((g=e==null?void 0:e.formatNumber)==null?void 0:g.suffix)||"")}}),b.jsx(Ii,{value:i||"",className:" h-7 w-20 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"en-US",onChange:c=>{var u,f,g;return n(((u=e==null?void 0:e.formatNumber)==null?void 0:u.format)||"",((f=e==null?void 0:e.formatNumber)==null?void 0:f.currency)||"",c.target.value,((g=e==null?void 0:e.formatNumber)==null?void 0:g.suffix)||"")}})]})]}),b.jsxs("div",{children:[b.jsxs("div",{className:" flex gap-1",children:[b.jsx(Fn,{className:"text-xs",children:"Format"}),b.jsxs(ep,{children:[b.jsx(h0,{children:b.jsx(H2,{strokeWidth:1,className:"h-3 w-3 opacity-70"})}),b.jsx(Uu,{children:b.jsxs("div",{className:"max-w-[200px]",children:["Format number",b.jsx("div",{className:" mt-1 text-xs font-mono",children:"#.## for 123.43"})]})})]})]}),b.jsx("div",{children:b.jsx(Ii,{value:r||"",className:" h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"###,###.##",onChange:c=>{var u,f,g;return n(c.target.value,((u=e==null?void 0:e.formatNumber)==null?void 0:u.currency)||"",((f=e==null?void 0:e.formatNumber)==null?void 0:f.locale)||"",((g=e==null?void 0:e.formatNumber)==null?void 0:g.suffix)||"")}})})]}),b.jsxs("div",{children:[b.jsx(Fn,{className:"text-xs",children:"Suffix"}),b.jsx(Ii,{value:((l=e==null?void 0:e.formatNumber)==null?void 0:l.suffix)||"",className:" h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B",onChange:c=>{var u,f,g;return n(((u=e==null?void 0:e.formatNumber)==null?void 0:u.format)||"",((f=e==null?void 0:e.formatNumber)==null?void 0:f.currency)||"",((g=e==null?void 0:e.formatNumber)==null?void 0:g.locale)||"",c.target.value)}})]})]})]})}function moe(){return b.jsxs("div",{className:"px-6 py-2 space-y-6",children:[b.jsx(uc,{type:"single",collapsible:!0,children:b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{className:"",children:"KPI Query"}),b.jsxs(On,{className:"font-mono ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono text-xs",children:"SELECT current, previous FROM table"}),b.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 text-xs",children:[b.jsx("li",{children:"current - number"}),b.jsx("li",{children:"previous - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:e=>e.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),b.jsx("section",{className:"",children:b.jsx(goe,{})}),b.jsx("div",{}),b.jsx("div",{})]})}function voe({cardType:e}){return b.jsx("div",{className:"px-6 py-2 space-y-6",children:b.jsxs(uc,{defaultValue:["item-2"],type:"multiple",children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{children:`${Em(e)} Chart`}),b.jsxs(On,{className:" space-y-4 font-mono text-xs ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:"SELECT label, measure FROM table"}),b.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[b.jsx("li",{children:"label - category"}),b.jsx("li",{children:"measure - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:t=>t.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{children:"Settings"}),b.jsx(On,{className:"px-2",children:b.jsx(Td,{})})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{children:"Filter on click"}),b.jsx(On,{className:"px-2",children:b.jsx(Ad,{})})]})]})})}function boe(){return b.jsx("div",{className:"px-6 py-2 space-y-6",children:b.jsxs(uc,{defaultValue:["item-2"],type:"multiple",children:[b.jsxs(Cn,{value:"item-1",children:[b.jsx(En,{children:"Stacked Chart"}),b.jsxs(On,{className:" space-y-4 font-mono text-xs ",children:[b.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),b.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[b.jsx("li",{children:"x-axis - category"}),b.jsx("li",{children:"stack by - category"}),b.jsx("li",{children:"y-axis - number"})]}),b.jsxs("div",{children:["See ",b.jsx("a",{target:"_blank",onClick:e=>e.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),b.jsxs(Cn,{value:"item-2",children:[b.jsx(En,{children:"Settings"}),b.jsxs(On,{className:"px-2 space-y-4",children:[b.jsx(l1,{}),b.jsx(sA,{}),b.jsx(Td,{})]})]}),b.jsxs(Cn,{value:"item-3",children:[b.jsx(En,{children:"Filter on click"}),b.jsx(On,{className:"px-2",children:b.jsx(Ad,{})})]})]})})}function yoe(){const e=pe(n=>n.card.type);function t(n){switch(n){case"stackedBar":return b.jsx(boe,{});case"kpi":return b.jsx(moe,{});case"line":case"bar":return b.jsx(coe,{cardType:n});case"pie":case"doughnut":case"polarArea":case"radar":return b.jsx(voe,{cardType:n});case"bubble":case"scatter":return b.jsx(uoe,{cardType:n});case"table":return b.jsx(b.Fragment,{});default:return b.jsx(hoe,{})}}return b.jsx(Rl,{className:" text-sm h-full w-full ",children:t(e)})}function xoe(){const e=pe(t=>t.isShowingVisual);return b.jsxs(px,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[b.jsx(rc,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:b.jsx(eie,{})}),b.jsx(gx,{withHandle:!0,className:"border "}),b.jsx(rc,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:e?b.jsxs(px,{direction:"horizontal",children:[b.jsx(b.Fragment,{children:b.jsx(rc,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:b.jsx(yoe,{})})}),b.jsx(gx,{className:"border "}),b.jsx(rc,{minSize:40,defaultSize:75,maxSize:100,children:b.jsx(jT,{})})]}):b.jsx(jT,{})})]})}function woe({authToken:e,onSave:t,onClose:n}){pe(s=>s.actions.setCard);const r=pe(s=>s.actions.setOnSave),i=pe(s=>s.actions.setOnClose),o=he(s=>s.actions.setAuthToken);return m.useEffect(()=>{t&&r(t),n&&i(n)},[t,r,n,i]),m.useEffect(()=>{e&&e.accessToken&&o(e)},[e,o]),b.jsxs(DM,{className:"rounded-none",role:"editor-panel",children:[b.jsx(TM,{className:" rounded-none border-r-[1.5px] ",children:b.jsx(tD,{})}),b.jsx(AM,{children:b.jsx(xoe,{})})]})}function _oe(){he(s=>s.selectedCardId);const e=he(s=>s.selectedSheetId),{setIsVisualEditing:t}=he(s=>s.actions),n=he(s=>s.isVisualEditing),r=he(s=>s.actions.updateFrame);function i(s){e&&(r(e,s),t(!1))}function o(){t(!1)}return b.jsx("div",{role:"editor-container",className:Ee("grow flex",{block:n,hidden:!n}),children:b.jsx(woe,{onSave:i,onClose:o})})}function Soe({columns:e,tableName:t}){const n=pe(f=>f.selectedConnectionId),r=pe(f=>f.selectedDatabaseName),i=pe(f=>f.selectedSchemaName),o=pe(f=>f.selectedTableName),s=he(f=>f.dashboard.filters)||[],a=he(f=>f.actions.addFilter),l=he(f=>f.actions.removeFilter),c=he(f=>f.actions.removeFilterValue);function u(f){const g=ki(f.column_name),p=ki(r||""),v=ki(i||""),y=ki(t),w=s==null?void 0:s.find(_=>_.column===g&&_.table===y&&_.database===p);if(w)c(w.id),l(w.id);else{const _=Op(v,y),S=`SELECT ${g}, COUNT(*) FROM ${_} GROUP BY ${g} ORDER BY ${g} ASC LIMIT 50`,C=`SELECT min(${g}) as min, max(${g}) as max FROM ${_}`;if(t==="api"&&n){a({id:Qo(),column:`${_}.${g}`,title:f.column_name,dataType:f.data_type,table:"api",database:"NA",connectionId:n,sql:Sa.includes(f.data_type)?C:S});return}if(!n||!r||!o)throw new Error("missing connectionId, database, or table");a({id:Qo(),column:`${_}.${g}`,title:f.column_name,dataType:f.data_type,table:o,database:r,connectionId:n,sql:Sa.includes(f.data_type)?C:S})}}return b.jsx("div",{className:" flex-1 basis-0 overflow-scroll flex-col xbg-red-100 px-3",children:e==null?void 0:e.map(f=>{const g=s==null?void 0:s.find(p=>p.column===ki(f.column_name)&&p.table===o&&p.database===r);return b.jsx("div",{onClick:()=>u(f),className:Ee(" group flex text-sm items-center justify-between px-3 py-[6px] transition-colors hover:bg-muted/50 cursor-pointer border border-background border-dashed",{"bg-muted ":g}),children:b.jsxs("div",{className:"flex items-center gap-2 ",children:[b.jsx(eD,{column:f}),b.jsx("span",{children:f.column_name})]})},f.column_name)})})}function Coe(){he(t=>t.showFilters);const e=he(t=>t.actions.setShowFilters);return b.jsxs("section",{className:" grow flex flex-col border-l relative px-4 ",children:[b.jsxs("div",{className:"flex justify-between items-center gap-2 mt-4 px-3",children:[b.jsx(Fn,{className:"text-lg",children:"Filters"}),b.jsx(Je,{onClick:()=>e(!1),className:" p-0 h-7 w-7 ",variant:"ghost",children:b.jsx(pa,{})})]}),b.jsx("div",{className:"grow flex",children:b.jsx(tD,{ColumnsComponent:(t,n,r)=>b.jsx(Soe,{schemaName:t,tableName:n,columns:r})})})]})}function Eoe(){he(n=>n.dashboard);const e=he(n=>n.showFilters),t=he(n=>n.isVisualEditing);return he(n=>n.bookmarkKey),b.jsxs("div",{role:"dashboard-plus-main",className:Ee(" grow",{hidden:t,flex:!t}),children:[b.jsx(zk,{}),e&&b.jsx("div",{role:"filter-aside-container",className:" flex",children:b.jsx(Coe,{})})]})}function Ooe(){const e=he(r=>r.dashboard),t=he(r=>r.actions.setDashboard),n=he(r=>r.showDashboardJSON);return he(r=>r.actions.setShowDashboardJSON),b.jsx("div",{className:Ee(" p-2",{hidden:!n}),children:b.jsx(BD,{onChange:r=>{if(r)try{JSON.parse(r),t(JSON.parse(r))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(e,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function Poe({showControls:e=!1,showFooter:t=!0,...n}){return he(r=>r.isVisualEditing),b.jsx(A_,{dashboardProps:n,children:b.jsxs(By,{children:[b.jsx(Ooe,{}),b.jsxs($_,{...n,children:[e&&b.jsx(cQ,{}),b.jsx(_oe,{}),b.jsx(Eoe,{})]})]})})}function koe({card:e,footer:t,className:n,...r}){const{customCards:i}=zi(),o=m.useRef(null),{isError:s,isLoading:a,isFetching:l,cfg:c,visualKey:u,handleDatapointClick:f}=j0(e),g=he(I=>I.themeStyle),p=he(I=>I.selectedSheetId),v=he(I=>I.selectedCardId),y=he(I=>I.isDashboardEditing),{setCardTitle:w,setCardDescription:_,setSelectedCardId:S}=pl();function C(I){I.stopPropagation(),S(p,e.id)}function P(){if(i&&i.length>0){const I=i.find(F=>F.cardId===e.id);if(I&&I.replaceDefault){const F=I.content;if(F)return b.jsx(F,{card:e})}}return e.type==="kpi"?e.data&&e.data.length>0&&b.jsx(L0,{isLoading:a||l,card:e}):T}function O(){if(s)return b.jsx("p",{className:"text-sm",children:"Oops! It seems like something went wrong. Please review your connection or filters."});if(e.type==="table"&&e.data&&e.data.length>0)return b.jsxs(Rl,{children:[b.jsx(sp,{data:e.data}),b.jsx(Ll,{orientation:"horizontal"})]});if(i&&i.length>0){const I=i.find(F=>F.cardId===e.id);if(I&&I.content){const F=I.content;return b.jsx(F,{card:e})}}if(c)return b.jsx(Xb,{cfg:c,onDatapointClick:f},u)}function k(){if(i&&i.length>0){const I=i.find(F=>F.cardId===e.id);if(I&&I.footer){const F=I.footer;if(F)return b.jsx(F,{card:e})}}return t||null}if(!e.id)return null;const T=b.jsxs(b.Fragment,{children:[b.jsxs(su,{className:"pb-4",children:[b.jsxs("div",{className:"flex items-center gap-2",children:[b.jsx(Ui,{text:e.title,onSave:I=>w(p,e.id,I),children:b.jsx(au,{className:"text-base",children:e.title})}),e.refreshInterval&&b.jsxs(ep,{children:[b.jsx(h0,{className:"pr-1",children:b.jsx("div",{className:Ee("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":a||l})})}),b.jsx(Uu,{side:"right",align:"center",children:b.jsx("p",{className:"text-xs",children:`Realtime (${e==null?void 0:e.refreshInterval})`})})]}),!e.refreshInterval&&(a||l)&&b.jsx(ma,{className:"h-4 w-4 animate-spin text-muted-foreground"})]}),b.jsx(Ui,{text:(e==null?void 0:e.description)||"",onSave:I=>_(p,e.id,I),children:b.jsxs(rh,{children:[" ",e.description]})})]}),b.jsx(lu,{className:"relative flex grow flex-col overflow-auto pb-0",children:O()}),b.jsx(rb,{children:k()})]});return b.jsx(nh,{tabIndex:-1,ref:o,role:"dashboard-card",onClick:C,className:Ee("relative flex h-full flex-col rounded-sm",{"border-dashed border-foreground/50":v===e.id&&y},g==null?void 0:g.dashboardCard,n),...r,children:P()})}const Dg=`import pandas as pd
575
575
  df = pd.DataFrame(data) # 'data' contains the query result
576
576
  result = df.to_dict('records') # must return 'result' as [dict] type
577
577
  `;function Moe(){const e=he(t=>t.actions);return{getStyle:e.getStyle,getDashboard:e.getDashboard,setOnSaveFunction:e.setOnSaveFunction,setOnAddCard:e.setOnAddCard,setOnUpateCard:e.setOnUpdateCard,setOnRemoveCard:e.setOnRemoveCard}}Fe.BOOLEAN_DATA_TYPES=Cp,Fe.DATE_DATA_TYPES=Sa,Fe.Dashboard=Vk,Fe.DashboardCard=koe,Fe.DashboardPlus=Poe,Fe.DashboardProvider=By,Fe.DashboardWC=aK,Fe.NUMBER_DATA_TYPES=vs,Fe.PYTHON_DEFAULT_CODE=Dg,Fe.SelectComponent=gd,Fe.SemaphorQueryClient=Bk,Fe.TEXT_DATA_TYPES=Xu,Fe.cleanCard=mM,Fe.createSqlGenConfig=ly,Fe.fmt=ki,Fe.getBookmarkKey=ws,Fe.getColumnDataType=eU,Fe.getDashbaordStateWithoutData=Jy,Fe.getFilterValueType=Ep,Fe.getQualifiedTableName=Op,Fe.getSql=ay,Fe.isColumnInSqlGen=NP,Fe.resolveDataType=Mf,Fe.useActions=Moe,Fe.useCard=aH,Fe.useDashboard=j_,Fe.useDashboardActions=pl,Fe.useDashboardStore=he,Fe.useEditorActions=R4,Fe.useEditorAside=I_,Fe.useEditorStore=pe,Object.defineProperty(Fe,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.0.122",
8
+ "version": "0.0.123",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",