react-semaphor 0.0.347 → 0.0.348
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{index-DGgEJUE9.js → index-622sBsAD.js} +1 -1
- package/dist/chunks/{index-D3FspidB.js → index-BI4RIp9g.js} +2 -2
- package/dist/chunks/{index-CLf_4nXr.js → index-BbkT5FU1.js} +2 -2
- package/dist/chunks/{index-CpBdXQXJ.js → index-Bq5AyXcJ.js} +9 -8
- package/dist/chunks/{lucide-react-CoTyczdi.js → lucide-react-BQZLQzXT.js} +3 -3
- package/dist/chunks/{lucide-react-CDQZoJjz.js → lucide-react-D6rsddg8.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +1 -1
- package/package.json +1 -1
|
@@ -280,7 +280,7 @@ Valid keys: `+JSON.stringify(Object.keys(I),null," "));var ie=pe(J,ce,ee,K,oe+"
|
|
|
280
280
|
* This source code is licensed under the ISC license.
|
|
281
281
|
* See the LICENSE file in the root directory of this source tree.
|
|
282
282
|
*/const Td=Gt("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Mee=({data:e,filename:t="output.csv"})=>{const n=()=>{if(e.length===0)return;const r=[],i=Object.keys(e[0]);r.push(i.join(","));for(const c of e){const u=i.map(d=>`"${(""+c[d]).replace(/"/g,'""')}"`);r.push(u.join(","))}const o=r.join(`
|
|
283
|
-
`),s=new Blob([o],{type:"text/csv"}),a=window.URL.createObjectURL(s),l=document.createElement("a");l.setAttribute("hidden",""),l.setAttribute("href",a),l.setAttribute("download",t),document.body.appendChild(l),l.click(),document.body.removeChild(l)};return y.jsx(q5,{onClick:n,className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})};var id=1e3,od=id*60,sd=od*60,bc=sd*24,Tee=bc*7,Oee=bc*365.25,Dee=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0)return Aee(e);if(n==="number"&&isFinite(e))return t.long?kee(e):Iee(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Aee(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*Oee;case"weeks":case"week":case"w":return n*Tee;case"days":case"day":case"d":return n*bc;case"hours":case"hour":case"hrs":case"hr":case"h":return n*sd;case"minutes":case"minute":case"mins":case"min":case"m":return n*od;case"seconds":case"second":case"secs":case"sec":case"s":return n*id;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function Iee(e){var t=Math.abs(e);return t>=bc?Math.round(e/bc)+"d":t>=sd?Math.round(e/sd)+"h":t>=od?Math.round(e/od)+"m":t>=id?Math.round(e/id)+"s":e+"ms"}function kee(e){var t=Math.abs(e);return t>=bc?Jg(e,t,bc,"day"):t>=sd?Jg(e,t,sd,"hour"):t>=od?Jg(e,t,od,"minute"):t>=id?Jg(e,t,id,"second"):e+" ms"}function Jg(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+" "+r+(i?"s":"")}const Nee=Oc(Dee);function Lee(e){const t=ye(d=>d.selectedSheetId),n=ye(d=>d.selectedLensId),r=ye(d=>d.dashboard.baseQueries),i=ye(d=>d.dashboard.filters),o=ye(d=>d.filterValues),s=i==null?void 0:i.filter(d=>d.sheetId===t||!d.sheetId),a=o==null?void 0:o.filter(d=>(s==null?void 0:s.some(p=>p.id===d.filterId))||d.filterId.endsWith(t)),l=sK(e==null?void 0:e.sql,r),c=jee((e==null?void 0:e.python)||"");return{queryKey:["query",e==null?void 0:e.id,e==null?void 0:e.title,l,c,n||"",JSON.stringify(a)],sql:l,sheetFilterValues:a}}function Fee(e){const t=BigInt("0x100000001b3");let r=BigInt("0xcbf29ce484222325");for(let i=0;i<e.length;i++)r^=BigInt(e.charCodeAt(i)),r=r*t%BigInt(2)**BigInt(64);return r.toString(16).padStart(16,"0")}function jee(e){return e===G_?"":Fee(e)}function Wa(e,t){const{authToken:n}=Vi(),r=ye(d=>d.isVisualEditing),i=ye(d=>d.authToken),o=Nee((e==null?void 0:e.refreshInterval)||"0"),{queryKey:s,sql:a,sheetFilterValues:l}=Lee(e);return{...xp({queryKey:s,queryFn:async()=>{var p;return!(e!=null&&e.connectionId)||!((p=e==null?void 0:e.sql)!=null&&p.trim())?null:await Ey("https://semaphor.cloud/api/v1/query",(n==null?void 0:n.accessToken)||(i==null?void 0:i.accessToken)||"",{connection_id:e.connectionId,sql:a,python:e.python===G_?"":e.python,active_filters:l,cache_config:X_()})},refetchInterval:o,placeholderData:ZK,enabled:!!(e!=null&&e.connectionId)&&!!(e!=null&&e.sql)&&!0&&!r}),queryKey:s}}function d4({frame:e}){var E;const t=ye(C=>C.isDashboardEditing),n=ye(C=>C.filterValues),r=ye(C=>C.isVisualEditing),i=ye(C=>C.selectedSheetId);ye(C=>C.currentBreakpoint);const{removeFrame:o}=ye(C=>C.actions),s=ye(C=>C.actions.setIsVisualEditing),a=Ur(C=>C.actions.setFilterValues),l=Ur(C=>C.actions.setApplyFilters),{setCard:c,setFrame:u,setQueryResultColumns:d}=Ur(C=>C.actions),p=Ur(C=>C.actions.setSelectedConnectionId),h=Ur(C=>C.actions.setSelectedDatamodelId),m=Ur(C=>C.actions.setSelectedDatabaseName),b=Ur(C=>C.actions.setSelectedSchemaName),v=Ur(C=>C.actions.setSelectedTableName),x=e.cards.find(C=>C.id===e.activeCardId),{data:S}=Wa(x);function _(){s(!r),c(x);const{dimensionKeys:C}=sr((S==null?void 0:S.records)||[]);d(C),u(e),x!=null&&x.connectionId&&p(x==null?void 0:x.connectionId),x!=null&&x.datamodelId&&x.datamodelId!=="none"&&(h(x==null?void 0:x.datamodelId),m("")),x!=null&&x.lastSelectedDatabase&&x.lastSelectedDatabase!=="none"&&(m(x==null?void 0:x.lastSelectedDatabase),h("")),x!=null&&x.lastSelectedSchema&&b(x==null?void 0:x.lastSelectedSchema),x!=null&&x.lastSelectedTable&&v(x==null?void 0:x.lastSelectedTable),n&&(a(n),l(!0))}return y.jsx("section",{onMouseDown:C=>{C.stopPropagation()},className:"absolute right-2 top-2 z-50",children:y.jsxs("div",{className:"flex items-center gap-2",children:[t&&(r?y.jsx("button",{onClick:()=>{s(!r)},children:y.jsx(tee,{className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})}):y.jsx("button",{role:"edit-visual",onClick:_,children:y.jsx(ree,{className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})})),t&&y.jsx("button",{onClick:()=>o(i,e.id),children:y.jsx(j5,{className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})}),((E=x.preferences)==null?void 0:E.allowDownload)===!0&&y.jsx(Mee,{data:(S==null?void 0:S.records)||[],filename:x.title})]})})}function $ee(e,t){ye(s=>s.selectedSheetId);const n=ye(s=>s.selectedFrameId),r=ye(s=>s.isDashboardEditing),i=ye(s=>s.isVisualEditing);ye(s=>s.actions),P.useEffect(()=>{n===e.id&&r&&!i&&o()},[n,e.id,r,i]);function o(){const s=t==null?void 0:t.current;s==null||s.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}}const zee=P.createContext(null),Lx={didCatch:!1,error:null};class e0 extends P.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Lx}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,i=arguments.length,o=new Array(i),s=0;s<i;s++)o[s]=arguments[s];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:o,reason:"imperative-api"}),this.setState(Lx)}}componentDidCatch(t,n){var r,i;(r=(i=this.props).onError)===null||r===void 0||r.call(i,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:i}=this.props;if(r&&n.error!==null&&Bee(t.resetKeys,i)){var o,s;(o=(s=this.props).onReset)===null||o===void 0||o.call(s,{next:i,prev:t.resetKeys,reason:"keys"}),this.setState(Lx)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:i}=this.props,{didCatch:o,error:s}=this.state;let a=t;if(o){const l={error:s,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(l);else if(r)a=P.createElement(r,l);else if(i!==void 0)a=i;else throw s}return P.createElement(zee.Provider,{value:{didCatch:o,error:s,resetErrorBoundary:this.resetErrorBoundary}},a)}}function Bee(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}function jC({error:e}){return y.jsx("div",{className:"flex flex-col items-center justify-center",role:"alert",style:{height:"100%"},children:y.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md bg-muted p-10",children:[y.jsx("p",{className:"text-lg font-semibold",children:"Oops! Looks like we tripped on a loose wire!"}),y.jsx("p",{className:"text-sm",children:"Something went wrong:"}),y.jsx("pre",{className:"text-xs",children:e.message})]})})}function Hee({error:e,frame:t}){return y.jsxs("div",{className:"flex h-full flex-col items-center justify-center border",role:"alert",children:[y.jsx(d4,{frame:t}),y.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),y.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[y.jsx("p",{className:"text-lg font-semibold",children:"Oops! Looks like we tripped on a loose wire!"}),y.jsx("p",{className:"text-sm",children:"Something went wrong:"}),y.jsx("pre",{className:"text-xs",children:e.message})]})]})}function Vee({error:e}){return y.jsxs("div",{className:"flex h-full flex-col items-center justify-center",role:"alert",children:[y.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),y.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[y.jsx("p",{className:"text-lg font-semibold",children:"Oops! Something went wrong!"}),y.jsx("p",{className:"text-sm",children:"Something went wrong:"}),y.jsx("pre",{className:"text-xs",children:e.message})]})]})}function Qs({number:e,decimalPlaces:t=0,useSuffix:n=!1,customSuffix:r="",currency:i="",locale:o="en-US"}){let s=1,a=r,l=o;const c=t;n&&!r&&(e>=1e9?(s=1e9,a="B"):e>=1e7&&o==="en-IN"?(s=1e7,a="Cr"):e>=1e5&&o==="en-IN"?(s=1e5,a="L"):e>=1e6?(s=1e6,a="M"):e>=1e3&&(s=1e3,a="K"));const u=e/s,d={maximumFractionDigits:c,minimumFractionDigits:c};if(i){d.style="currency",d.currency=i;try{new Intl.NumberFormat(o,d).format(0)}catch{}}try{new Intl.NumberFormat(o,d).format(0)}catch{l="en-US"}let h=new Intl.NumberFormat(l,d).format(u);return n&&(h+=a),h}function $C(e,t){if(!t)return"";const n=t.find(r=>e>=r.start&&e<=r.end);return(n==null?void 0:n.color)||""}function tS(e){try{const n=new Function("getDatalabelColor",e)(Cw);return{options:n==null?void 0:n.options,plugins:(n==null?void 0:n.plugins)||[]}}catch(t){return console.error("Error processing custom visual code",t),{options:{},plugins:[]}}}function Wee(e){const t=getComputedStyle(document.documentElement).getPropertyValue(e);return f4(t)}function f4(e){const[t,n,r]=e.split(" "),i=parseFloat(t),o=parseFloat(n),s=parseFloat(r),a=o/100,l=s/100,c=(1-Math.abs(2*l-1))*a,u=c*(1-Math.abs(i/60%2-1)),d=l-c/2;let p=0,h=0,m=0;0<=i&&i<60?(p=c,h=u,m=0):60<=i&&i<120?(p=u,h=c,m=0):120<=i&&i<180?(p=0,h=c,m=u):180<=i&&i<240?(p=0,h=u,m=c):240<=i&&i<300?(p=u,h=0,m=c):300<=i&&i<360&&(p=c,h=0,m=u),p=Math.round((p+d)*255),h=Math.round((h+d)*255),m=Math.round((m+d)*255);const b=v=>{const x=v.toString(16);return x.length==1?"0"+x:x};return`#${b(p)}${b(h)}${b(m)}`}function xl({data:e,cfg:t,customCfg:n,preferences:r,cardType:i}){ye.getState().themeStyle;const o=i==="radar"?.2:1,{dimensionKeys:s,metricKeys:a}=sr(e),l=vee(a,e,r,o),c=zf(l,n),u=s[0],d=Zw(e,u);zC(r,t),h4(r);const{options:p,plugins:h}=g4({cfg:t,preferences:r,customCfg:n});return{type:(n==null?void 0:n.type)||(t==null?void 0:t.type)||"bar",data:{labels:d,datasets:c},options:p,plugins:h}}function zC(e,t){var i,o,s;const n=((i=t==null?void 0:t.options)==null?void 0:i.indexAxis)==="y"?"x":"y";return(o=e==null?void 0:e.chartOptions)!=null&&o.indexAxis?((s=e==null?void 0:e.chartOptions)==null?void 0:s.indexAxis)==="x"?"y":"x":n}function h4(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"?"x":"y":"x"}function p4(e,t){var o,s,a,l,c,u,d,p,h,m,b,v;const n=zC(t,e),r=h4(t);return{...e==null?void 0:e.options,scales:{...(o=e==null?void 0:e.options)==null?void 0:o.scales,[n]:{...(a=(s=e==null?void 0:e.options)==null?void 0:s.scales)==null?void 0:a[n],ticks:{...(u=(c=(l=e==null?void 0:e.options)==null?void 0:l.scales)==null?void 0:c[n])==null?void 0:u.ticks,callback:x=>{var S,_,E,C;return Qs({number:Number(x),decimalPlaces:((S=t==null?void 0:t.numberAxisFormat)==null?void 0:S.decimalPlaces)||0,useSuffix:!!((_=t==null?void 0:t.numberAxisFormat)!=null&&_.suffix),customSuffix:"",locale:((E=t==null?void 0:t.numberAxisFormat)==null?void 0:E.locale)||"",currency:((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.currency)||""})}}},[r]:{...(h=(p=(d=e==null?void 0:e.options)==null?void 0:d.scales)==null?void 0:p[r])==null?void 0:h.ticks,callback:null}},plugins:{...(m=e==null?void 0:e.options)==null?void 0:m.plugins,datalabels:{...(v=(b=e==null?void 0:e.options)==null?void 0:b.plugins)==null?void 0:v.datalabels,formatter:function(x){var S,_,E,C;return Qs({number:Number(x),decimalPlaces:((S=t==null?void 0:t.numberAxisFormat)==null?void 0:S.decimalPlaces)||0,useSuffix:!!((_=t==null?void 0:t.numberAxisFormat)!=null&&_.suffix),customSuffix:"",locale:((E=t==null?void 0:t.numberAxisFormat)==null?void 0:E.locale)||"",currency:((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.currency)||""})}}}}}function g4({cfg:e,preferences:t,customCfg:n}){var p,h,m,b,v,x,S,_,E,C,T,O,A,N,F,j,$,X,V,L,U,B,W,q,I,Y,G,D,ee;const r=ye.getState().themeStyle,i=p4(e,t),o=Oi((e==null?void 0:e.options)||{},t==null?void 0:t.chartOptions),s=Oi(i,o),a=Oi(s,(n==null?void 0:n.options)||{}),l={...a,scales:{...a==null?void 0:a.scales,x:{...(p=a==null?void 0:a.scales)==null?void 0:p.x,grid:{...(m=(h=a==null?void 0:a.scales)==null?void 0:h.x)==null?void 0:m.grid,color:(_=(S=(x=(v=(b=r==null?void 0:r.chart)==null?void 0:b.options)==null?void 0:v.scales)==null?void 0:x.x)==null?void 0:S.grid)==null?void 0:_.color}},y:{...(E=a==null?void 0:a.scales)==null?void 0:E.y,grid:{...(T=(C=a==null?void 0:a.scales)==null?void 0:C.y)==null?void 0:T.grid,color:(j=(F=(N=(A=(O=r==null?void 0:r.chart)==null?void 0:O.options)==null?void 0:A.scales)==null?void 0:N.y)==null?void 0:F.grid)==null?void 0:j.color}}},plugins:{...a==null?void 0:a.plugins,tooltip:{...($=a==null?void 0:a.plugins)==null?void 0:$.tooltip,backgroundColor:(U=(L=(V=(X=r==null?void 0:r.chart)==null?void 0:X.options)==null?void 0:V.plugins)==null?void 0:L.tooltip)==null?void 0:U.backgroundColor,bodyColor:(I=(q=(W=(B=r==null?void 0:r.chart)==null?void 0:B.options)==null?void 0:W.plugins)==null?void 0:q.tooltip)==null?void 0:I.bodyColor,titleColor:(ee=(D=(G=(Y=r==null?void 0:r.chart)==null?void 0:Y.options)==null?void 0:G.plugins)==null?void 0:D.tooltip)==null?void 0:ee.titleColor}}},{plugins:c,options:u}=tS((t==null?void 0:t.customVisualCode)||"");return{options:Oi(l,u),plugins:c}}/*!
|
|
283
|
+
`),s=new Blob([o],{type:"text/csv"}),a=window.URL.createObjectURL(s),l=document.createElement("a");l.setAttribute("hidden",""),l.setAttribute("href",a),l.setAttribute("download",t),document.body.appendChild(l),l.click(),document.body.removeChild(l)};return y.jsx(q5,{onClick:n,className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})};var id=1e3,od=id*60,sd=od*60,bc=sd*24,Tee=bc*7,Oee=bc*365.25,Dee=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0)return Aee(e);if(n==="number"&&isFinite(e))return t.long?kee(e):Iee(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Aee(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*Oee;case"weeks":case"week":case"w":return n*Tee;case"days":case"day":case"d":return n*bc;case"hours":case"hour":case"hrs":case"hr":case"h":return n*sd;case"minutes":case"minute":case"mins":case"min":case"m":return n*od;case"seconds":case"second":case"secs":case"sec":case"s":return n*id;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function Iee(e){var t=Math.abs(e);return t>=bc?Math.round(e/bc)+"d":t>=sd?Math.round(e/sd)+"h":t>=od?Math.round(e/od)+"m":t>=id?Math.round(e/id)+"s":e+"ms"}function kee(e){var t=Math.abs(e);return t>=bc?Jg(e,t,bc,"day"):t>=sd?Jg(e,t,sd,"hour"):t>=od?Jg(e,t,od,"minute"):t>=id?Jg(e,t,id,"second"):e+" ms"}function Jg(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+" "+r+(i?"s":"")}const Nee=Oc(Dee);function Lee(e){const t=ye(d=>d.selectedSheetId),n=ye(d=>d.selectedLensId),r=ye(d=>d.dashboard.baseQueries),i=ye(d=>d.dashboard.filters),o=ye(d=>d.filterValues),s=i==null?void 0:i.filter(d=>d.sheetId===t||!d.sheetId),a=o==null?void 0:o.filter(d=>(s==null?void 0:s.some(p=>p.id===d.filterId))||d.filterId.endsWith(t)),l=sK(e==null?void 0:e.sql,r),c=jee((e==null?void 0:e.python)||"");return{queryKey:["query",e==null?void 0:e.id,e==null?void 0:e.title,l,c,n||"",JSON.stringify(a)],sql:l,sheetFilterValues:a}}function Fee(e){const t=BigInt("0x100000001b3");let r=BigInt("0xcbf29ce484222325");for(let i=0;i<e.length;i++)r^=BigInt(e.charCodeAt(i)),r=r*t%BigInt(2)**BigInt(64);return r.toString(16).padStart(16,"0")}function jee(e){return e===G_?"":Fee(e)}function Wa(e,t){const{authToken:n}=Vi(),r=ye(p=>p.isVisualEditing),i=ye(p=>p.authToken),o=Nee((e==null?void 0:e.refreshInterval)||"0"),{queryKey:s,sql:a,sheetFilterValues:l}=Lee(e);let c={};return r||(c={refetchInterval:o,placeholderData:ZK}),{...xp({queryKey:s,queryFn:async()=>{var h;return!(e!=null&&e.connectionId)||!((h=e==null?void 0:e.sql)!=null&&h.trim())?null:await Ey("https://semaphor.cloud/api/v1/query",(n==null?void 0:n.accessToken)||(i==null?void 0:i.accessToken)||"",{connection_id:e.connectionId,sql:a,python:e.python===G_?"":e.python,active_filters:l,cache_config:X_()})},...c,enabled:!!(e!=null&&e.connectionId)&&!!(e!=null&&e.sql)&&!0&&!r}),queryKey:s}}function d4({frame:e}){var E;const t=ye(C=>C.isDashboardEditing),n=ye(C=>C.filterValues),r=ye(C=>C.isVisualEditing),i=ye(C=>C.selectedSheetId);ye(C=>C.currentBreakpoint);const{removeFrame:o}=ye(C=>C.actions),s=ye(C=>C.actions.setIsVisualEditing),a=Ur(C=>C.actions.setFilterValues),l=Ur(C=>C.actions.setApplyFilters),{setCard:c,setFrame:u,setQueryResultColumns:d}=Ur(C=>C.actions),p=Ur(C=>C.actions.setSelectedConnectionId),h=Ur(C=>C.actions.setSelectedDatamodelId),m=Ur(C=>C.actions.setSelectedDatabaseName),b=Ur(C=>C.actions.setSelectedSchemaName),v=Ur(C=>C.actions.setSelectedTableName),x=e.cards.find(C=>C.id===e.activeCardId),{data:S}=Wa(x);function _(){s(!r),c(x);const{dimensionKeys:C}=sr((S==null?void 0:S.records)||[]);d(C),u(e),x!=null&&x.connectionId&&p(x==null?void 0:x.connectionId),x!=null&&x.datamodelId&&x.datamodelId!=="none"&&(h(x==null?void 0:x.datamodelId),m("")),x!=null&&x.lastSelectedDatabase&&x.lastSelectedDatabase!=="none"&&(m(x==null?void 0:x.lastSelectedDatabase),h("")),x!=null&&x.lastSelectedSchema&&b(x==null?void 0:x.lastSelectedSchema),x!=null&&x.lastSelectedTable&&v(x==null?void 0:x.lastSelectedTable),n&&(a(n),l(!0))}return y.jsx("section",{onMouseDown:C=>{C.stopPropagation()},className:"absolute right-2 top-2 z-50",children:y.jsxs("div",{className:"flex items-center gap-2",children:[t&&(r?y.jsx("button",{onClick:()=>{s(!r)},children:y.jsx(tee,{className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})}):y.jsx("button",{role:"edit-visual",onClick:_,children:y.jsx(ree,{className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})})),t&&y.jsx("button",{onClick:()=>o(i,e.id),children:y.jsx(j5,{className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})}),((E=x.preferences)==null?void 0:E.allowDownload)===!0&&y.jsx(Mee,{data:(S==null?void 0:S.records)||[],filename:x.title})]})})}function $ee(e,t){ye(s=>s.selectedSheetId);const n=ye(s=>s.selectedFrameId),r=ye(s=>s.isDashboardEditing),i=ye(s=>s.isVisualEditing);ye(s=>s.actions),P.useEffect(()=>{n===e.id&&r&&!i&&o()},[n,e.id,r,i]);function o(){const s=t==null?void 0:t.current;s==null||s.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}}const zee=P.createContext(null),Lx={didCatch:!1,error:null};class e0 extends P.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Lx}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,i=arguments.length,o=new Array(i),s=0;s<i;s++)o[s]=arguments[s];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:o,reason:"imperative-api"}),this.setState(Lx)}}componentDidCatch(t,n){var r,i;(r=(i=this.props).onError)===null||r===void 0||r.call(i,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:i}=this.props;if(r&&n.error!==null&&Bee(t.resetKeys,i)){var o,s;(o=(s=this.props).onReset)===null||o===void 0||o.call(s,{next:i,prev:t.resetKeys,reason:"keys"}),this.setState(Lx)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:i}=this.props,{didCatch:o,error:s}=this.state;let a=t;if(o){const l={error:s,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(l);else if(r)a=P.createElement(r,l);else if(i!==void 0)a=i;else throw s}return P.createElement(zee.Provider,{value:{didCatch:o,error:s,resetErrorBoundary:this.resetErrorBoundary}},a)}}function Bee(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}function jC({error:e}){return y.jsx("div",{className:"flex flex-col items-center justify-center",role:"alert",style:{height:"100%"},children:y.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md bg-muted p-10",children:[y.jsx("p",{className:"text-lg font-semibold",children:"Oops! Looks like we tripped on a loose wire!"}),y.jsx("p",{className:"text-sm",children:"Something went wrong:"}),y.jsx("pre",{className:"text-xs",children:e.message})]})})}function Hee({error:e,frame:t}){return y.jsxs("div",{className:"flex h-full flex-col items-center justify-center border",role:"alert",children:[y.jsx(d4,{frame:t}),y.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),y.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[y.jsx("p",{className:"text-lg font-semibold",children:"Oops! Looks like we tripped on a loose wire!"}),y.jsx("p",{className:"text-sm",children:"Something went wrong:"}),y.jsx("pre",{className:"text-xs",children:e.message})]})]})}function Vee({error:e}){return y.jsxs("div",{className:"flex h-full flex-col items-center justify-center",role:"alert",children:[y.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),y.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[y.jsx("p",{className:"text-lg font-semibold",children:"Oops! Something went wrong!"}),y.jsx("p",{className:"text-sm",children:"Something went wrong:"}),y.jsx("pre",{className:"text-xs",children:e.message})]})]})}function Qs({number:e,decimalPlaces:t=0,useSuffix:n=!1,customSuffix:r="",currency:i="",locale:o="en-US"}){let s=1,a=r,l=o;const c=t;n&&!r&&(e>=1e9?(s=1e9,a="B"):e>=1e7&&o==="en-IN"?(s=1e7,a="Cr"):e>=1e5&&o==="en-IN"?(s=1e5,a="L"):e>=1e6?(s=1e6,a="M"):e>=1e3&&(s=1e3,a="K"));const u=e/s,d={maximumFractionDigits:c,minimumFractionDigits:c};if(i){d.style="currency",d.currency=i;try{new Intl.NumberFormat(o,d).format(0)}catch{}}try{new Intl.NumberFormat(o,d).format(0)}catch{l="en-US"}let h=new Intl.NumberFormat(l,d).format(u);return n&&(h+=a),h}function $C(e,t){if(!t)return"";const n=t.find(r=>e>=r.start&&e<=r.end);return(n==null?void 0:n.color)||""}function tS(e){try{const n=new Function("getDatalabelColor",e)(Cw);return{options:n==null?void 0:n.options,plugins:(n==null?void 0:n.plugins)||[]}}catch(t){return console.error("Error processing custom visual code",t),{options:{},plugins:[]}}}function Wee(e){const t=getComputedStyle(document.documentElement).getPropertyValue(e);return f4(t)}function f4(e){const[t,n,r]=e.split(" "),i=parseFloat(t),o=parseFloat(n),s=parseFloat(r),a=o/100,l=s/100,c=(1-Math.abs(2*l-1))*a,u=c*(1-Math.abs(i/60%2-1)),d=l-c/2;let p=0,h=0,m=0;0<=i&&i<60?(p=c,h=u,m=0):60<=i&&i<120?(p=u,h=c,m=0):120<=i&&i<180?(p=0,h=c,m=u):180<=i&&i<240?(p=0,h=u,m=c):240<=i&&i<300?(p=u,h=0,m=c):300<=i&&i<360&&(p=c,h=0,m=u),p=Math.round((p+d)*255),h=Math.round((h+d)*255),m=Math.round((m+d)*255);const b=v=>{const x=v.toString(16);return x.length==1?"0"+x:x};return`#${b(p)}${b(h)}${b(m)}`}function xl({data:e,cfg:t,customCfg:n,preferences:r,cardType:i}){ye.getState().themeStyle;const o=i==="radar"?.2:1,{dimensionKeys:s,metricKeys:a}=sr(e),l=vee(a,e,r,o),c=zf(l,n),u=s[0],d=Zw(e,u);zC(r,t),h4(r);const{options:p,plugins:h}=g4({cfg:t,preferences:r,customCfg:n});return{type:(n==null?void 0:n.type)||(t==null?void 0:t.type)||"bar",data:{labels:d,datasets:c},options:p,plugins:h}}function zC(e,t){var i,o,s;const n=((i=t==null?void 0:t.options)==null?void 0:i.indexAxis)==="y"?"x":"y";return(o=e==null?void 0:e.chartOptions)!=null&&o.indexAxis?((s=e==null?void 0:e.chartOptions)==null?void 0:s.indexAxis)==="x"?"y":"x":n}function h4(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"?"x":"y":"x"}function p4(e,t){var o,s,a,l,c,u,d,p,h,m,b,v;const n=zC(t,e),r=h4(t);return{...e==null?void 0:e.options,scales:{...(o=e==null?void 0:e.options)==null?void 0:o.scales,[n]:{...(a=(s=e==null?void 0:e.options)==null?void 0:s.scales)==null?void 0:a[n],ticks:{...(u=(c=(l=e==null?void 0:e.options)==null?void 0:l.scales)==null?void 0:c[n])==null?void 0:u.ticks,callback:x=>{var S,_,E,C;return Qs({number:Number(x),decimalPlaces:((S=t==null?void 0:t.numberAxisFormat)==null?void 0:S.decimalPlaces)||0,useSuffix:!!((_=t==null?void 0:t.numberAxisFormat)!=null&&_.suffix),customSuffix:"",locale:((E=t==null?void 0:t.numberAxisFormat)==null?void 0:E.locale)||"",currency:((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.currency)||""})}}},[r]:{...(h=(p=(d=e==null?void 0:e.options)==null?void 0:d.scales)==null?void 0:p[r])==null?void 0:h.ticks,callback:null}},plugins:{...(m=e==null?void 0:e.options)==null?void 0:m.plugins,datalabels:{...(v=(b=e==null?void 0:e.options)==null?void 0:b.plugins)==null?void 0:v.datalabels,formatter:function(x){var S,_,E,C;return Qs({number:Number(x),decimalPlaces:((S=t==null?void 0:t.numberAxisFormat)==null?void 0:S.decimalPlaces)||0,useSuffix:!!((_=t==null?void 0:t.numberAxisFormat)!=null&&_.suffix),customSuffix:"",locale:((E=t==null?void 0:t.numberAxisFormat)==null?void 0:E.locale)||"",currency:((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.currency)||""})}}}}}function g4({cfg:e,preferences:t,customCfg:n}){var p,h,m,b,v,x,S,_,E,C,T,O,A,N,F,j,$,X,V,L,U,B,W,q,I,Y,G,D,ee;const r=ye.getState().themeStyle,i=p4(e,t),o=Oi((e==null?void 0:e.options)||{},t==null?void 0:t.chartOptions),s=Oi(i,o),a=Oi(s,(n==null?void 0:n.options)||{}),l={...a,scales:{...a==null?void 0:a.scales,x:{...(p=a==null?void 0:a.scales)==null?void 0:p.x,grid:{...(m=(h=a==null?void 0:a.scales)==null?void 0:h.x)==null?void 0:m.grid,color:(_=(S=(x=(v=(b=r==null?void 0:r.chart)==null?void 0:b.options)==null?void 0:v.scales)==null?void 0:x.x)==null?void 0:S.grid)==null?void 0:_.color}},y:{...(E=a==null?void 0:a.scales)==null?void 0:E.y,grid:{...(T=(C=a==null?void 0:a.scales)==null?void 0:C.y)==null?void 0:T.grid,color:(j=(F=(N=(A=(O=r==null?void 0:r.chart)==null?void 0:O.options)==null?void 0:A.scales)==null?void 0:N.y)==null?void 0:F.grid)==null?void 0:j.color}}},plugins:{...a==null?void 0:a.plugins,tooltip:{...($=a==null?void 0:a.plugins)==null?void 0:$.tooltip,backgroundColor:(U=(L=(V=(X=r==null?void 0:r.chart)==null?void 0:X.options)==null?void 0:V.plugins)==null?void 0:L.tooltip)==null?void 0:U.backgroundColor,bodyColor:(I=(q=(W=(B=r==null?void 0:r.chart)==null?void 0:B.options)==null?void 0:W.plugins)==null?void 0:q.tooltip)==null?void 0:I.bodyColor,titleColor:(ee=(D=(G=(Y=r==null?void 0:r.chart)==null?void 0:Y.options)==null?void 0:G.plugins)==null?void 0:D.tooltip)==null?void 0:ee.titleColor}}},{plugins:c,options:u}=tS((t==null?void 0:t.customVisualCode)||"");return{options:Oi(l,u),plugins:c}}/*!
|
|
284
284
|
* @kurkle/color v0.3.4
|
|
285
285
|
* https://github.com/kurkle/color#readme
|
|
286
286
|
* (c) 2024 Jukka Kurkela
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const e=require("./index-
|
|
1
|
+
"use strict";const e=require("./index-622sBsAD.js"),b=require("react");require("react-dom");function Ms(s){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:()=>s[t]})}}return r.default=s,Object.freeze(r)}const Fe=Ms(b);/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -237,4 +237,4 @@ SELECT label, measure FROM table
|
|
|
237
237
|
Table Columns: ${g==null?void 0:g.map(N=>`${N.column_name} | ${N.data_type}`).join(", ")}
|
|
238
238
|
User SQL: ${z}
|
|
239
239
|
${h&&`Base Queries: ${JSON.stringify(h)} `}`,I=` 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.
|
|
240
|
-
Visual Query Syntax: ${Ks}`,{data:L,isLoading:O,isFetching:d,isError:R,refetch:E}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(x==null?void 0:x.accessToken)||"",{user_content:`userContent: ${w} ${m?I:""}`}),enabled:!1});function k(N){if(N.toLowerCase().includes("bar"))j("bar");else if(N.toLowerCase().includes("line"))j("line");else if(N.toLowerCase().includes("bubble"))j("bubble");else if(N.toLowerCase().includes("scatter"))j("scatter");else if(N.toLowerCase().includes("stacked"))j("stackedBar");else if(N.toLowerCase().includes("pie"))j("pie");else if(N.toLowerCase().includes("donut")||N.toLowerCase().includes("doughnut"))j("doughnut");else if(N.toLowerCase().includes("radar"))j("radar");else return j("bar"),!1;return!0}b.useEffect(()=>{L&&v(N=>[...N,{role:"ai",content:L.response}])},[L]),b.useEffect(()=>{const N=setTimeout(()=>{var F;a.current&&(a.current.scroll({top:a.current.scrollHeight,behavior:"smooth"}),(F=l.current)==null||F.focus())},100);return()=>clearTimeout(N)},[p]);function S(){t&&(v(N=>[...N,{role:"user",content:t}]),k(t)&&c(!0),n(""),E())}b.useEffect(()=>{o&&(S(),i(!1))},[o,i]);const M={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},V={fontFamily:"monospace",fontSize:14,lineHeight:1.6},H={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},P={p:({node:N,...F})=>e.jsxRuntimeExports.jsx("p",{style:M,...F}),code:({node:N,...F})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...F}),pre:({node:N,...F})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:V,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:F.children}),e.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:_,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:B=>{const A=_(B);A&&(r(!1),f(A),u(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:N,...F})=>e.jsxRuntimeExports.jsx("li",{style:H,...F})};function _(N){const F=N.currentTarget.closest("pre");if(!F)return;const B=F.textContent||F.innerText;return navigator.clipboard.writeText(B).then(()=>console.log("Text copied to clipboard")).catch(A=>console.error("Error in copying text: ",A)),B}function G(){return p==null?void 0:p.map((N,F)=>N.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(js,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:N.content})]},F):N.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:P,children:L==null?void 0:L.response.replace(/DuckDB/gi,"Semaphor")},F):e.jsxRuntimeExports.jsx("div",{},F))}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",className:"w-full justify-start border font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",variant:"secondary",children:"Type your question here..."})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Assistant"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"What can I help you with?"})]}),e.jsxRuntimeExports.jsx("div",{ref:a,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:G()})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[e.jsxRuntimeExports.jsx(e.Textarea,{autoFocus:!0,ref:l,onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),n(""),S())},placeholder:"Type your question here...",onFocus:N=>{const F=N.target,B=F.value.length;F.setSelectionRange(B,B)},className:e.cn("max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"),disabled:O||d,value:t,onChange:N=>n(N.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:S,children:!O&&!d?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(se,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var gs={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ve=b.createContext&&b.createContext(gs),Ws=["attr","size","title"];function Ys(s,r){if(s==null)return{};var t=Xs(s,r),n,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);for(o=0;o<i.length;o++)n=i[o],!(r.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(s,n)&&(t[n]=s[n])}return t}function Xs(s,r){if(s==null)return{};var t={};for(var n in s)if(Object.prototype.hasOwnProperty.call(s,n)){if(r.indexOf(n)>=0)continue;t[n]=s[n]}return t}function Ee(){return Ee=Object.assign?Object.assign.bind():function(s){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n]=t[n])}return s},Ee.apply(this,arguments)}function qe(s,r){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);r&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(s,o).enumerable})),t.push.apply(t,n)}return t}function fe(s){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?qe(Object(t),!0).forEach(function(n){Zs(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):qe(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function Zs(s,r,t){return r=et(r),r in s?Object.defineProperty(s,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[r]=t,s}function et(s){var r=st(s,"string");return typeof r=="symbol"?r:r+""}function st(s,r){if(typeof s!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,r||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(s)}function Rs(s){return s&&s.map((r,t)=>b.createElement(r.tag,fe({key:t},r.attr),Rs(r.child)))}function Y(s){return r=>b.createElement(tt,Ee({attr:fe({},s.attr)},r),Rs(s.child))}function tt(s){var r=t=>{var{attr:n,size:o,title:i}=s,l=Ys(s,Ws),a=o||t.size||"1em",x;return t.className&&(x=t.className),s.className&&(x=(x?x+" ":"")+s.className),b.createElement("svg",Ee({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,n,l,{className:x,style:fe(fe({color:s.color||t.color},t.style),s.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),i&&b.createElement("title",null,i),s.children)};return Ve!==void 0?b.createElement(Ve.Consumer,null,t=>r(t)):r(gs)}function nt(s){return Y({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(s)}function rt({sql:s}){return e.jsxRuntimeExports.jsxs(e.HoverCard,{children:[e.jsxRuntimeExports.jsx(e.HoverCardTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{variant:"link",className:"h-5 p-0",children:e.jsxRuntimeExports.jsx(e.Info,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxRuntimeExports.jsx(e.HoverCardContent,{align:"end",className:"w-full min-w-fit max-w-[700px] p-3 pt-2",children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-xs font-semibold",children:"Resolved Query"}),e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col space-y-2",children:e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"max-h-[250px] min-h-0 overflow-scroll",children:e.jsxRuntimeExports.jsx("p",{className:"overflow-auto rounded-md bg-muted p-2 font-mono text-xs leading-relaxed",children:s})})})]})})]})}function bs(s){const{theme:r}=e.useTheme(),t=e.useDashboardStore(p=>p.theme),n=e.useEditorStore(p=>p.frame),o=e.useEditorStore(p=>p.card),i=e.useEditorStore(p=>p.activeTabCardId),l=e.Le(),{refetch:a}=e.useDashboardCardQuery(o),{updateCardTab:x,setRunSql:m}=e.useEditorActions(),c=b.useRef(),f=b.useRef({}),h=n.cards.find(p=>p.id===i),u=b.useCallback(()=>{let p="";return s==="python"&&(p=(h==null?void 0:h.python)||e.PYTHON_DEFAULT_CODE),s==="sql"&&(p=(h==null?void 0:h.sql)||""),p},[s,h]);b.useEffect(()=>{if(i&&o.id&&o.id!==i){if(c.current&&l){const p=c.current.getModel();p&&(f.current[o.id]=p);let v=f.current[i];if(!v){const g=u();v=l.editor.createModel(g,s),f.current[i]=v}c.current.setModel(v)}x(i,o),m(!0)}},[i,o,x,l,m,s,u]),b.useEffect(()=>{if(!l)return;const p=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",v=t==="system"?p:t;l.editor.defineTheme("default",{base:v==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":v==="light"?"#ffffff":e.hslStringToHex("240 10% 10%")}}),l.editor.setTheme("default")},[r,t,l]),b.useEffect(()=>{const p=c.current;p&&l&&o&&p.addCommand(l.KeyMod.Shift|l.KeyCode.Enter,function(){return a(),!1})},[l,a,o]);function j(p,v){if(c.current=p,!f.current[o.id]){const g=p.getModel(),z=u();f.current[o.id]=g||(v==null?void 0:v.editor.createModel(z,s))||p.getModel()}p.setModel(f.current[o.id])}return{handleEditorDidMount:j}}function ot(){const s=e.useEditorStore(l=>l.card.sql),r=e.useEditorStore(l=>l.sqlGen),{setCardSql:t,setSqlGen:n}=e.useEditorActions(),{handleEditorDidMount:o}=bs("sql");function i(l){t(l),e.isObjectEmpty(r)||n({})}return e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",className:"pt-3",onChange:i,value:s||"",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"sql",onMount:o})}function it(){const s=e.useEditorStore(o=>o.card.python),{setCardPython:r}=e.useEditorActions(),{handleEditorDidMount:t}=bs("python");function n(o){r(o)}return e.jsxRuntimeExports.jsx(e.Ft,{className:"pt-3",theme:"default",onChange:n,value:s||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"python",onMount:t})}function at(){const s=e.useDashboardStore(i=>i.dashboard.filters),r=e.useDashboardStore(i=>i.filterValues),t=e.useDashboardStore(i=>i.selectedSheetId),n=s==null?void 0:s.filter(i=>i.sheetId===t||!i.sheetId),o=r==null?void 0:r.filter(i=>(n==null?void 0:n.some(l=>l.id===i.filterId))||i.filterId.endsWith(t));return e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",defaultLanguage:"json",className:"mt-1 min-h-[220px]",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"}})}function lt(){const[s,r]=b.useState({queryKey:[],queryData:null}),t=e.useQueryClient(),[n,o]=b.useState(!1),[i,l]=b.useState(!1),[a,x]=b.useState(!1),[m,c]=b.useState(""),[f,h]=b.useState(!1),u=e.useEditorStore(C=>C.frame),j=e.useEditorStore(C=>C.card),p=e.useEditorStore(C=>C.isShowingVisual),v=e.useEditorStore(C=>C.selectedConnectionId),g=e.useEditorStore(C=>C.selectedDatabaseName),z=e.useEditorStore(C=>C.selectedDatamodelId),D=e.useEditorStore(C=>C.selectedSchemaName),w=e.useEditorStore(C=>C.selectedTableName),I=e.useEditorStore(C=>{var Q;return(Q=C==null?void 0:C.card)==null?void 0:Q.sql}),L=e.useEditorStore(C=>C.applyFilters),{setCardCustomCfg:O,setQueryResultColumns:d,setCardSql:R,setQueryError:E,setPythonStdOut:k,setCardPreferences:S,setCardType:M}=e.useEditorActions(),V=e.useEditorStore(C=>C.onSave),H=e.useEditorStore(C=>C.onClose),P=e.useEditorStore(C=>C.actions.setSqlGen),_=e.useEditorStore(C=>C.runSql),G=e.useEditorStore(C=>C.actions.setRunSql),N=e.useEditorStore(C=>C.actions.setCardCfg),F=e.useEditorStore(C=>C.actions.setIsSqlRunning),{data:B,isLoading:A,isFetching:T,isSuccess:K,isError:q,error:$,queryKey:U,refetch:X}=e.useDashboardCardQuery(j);b.useEffect(()=>{if(B&&(B.rowLimitExceeded&&e.ce.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),k((B==null?void 0:B.output)||""),B.records.length>0)){const{dimensionKeys:C}=e.getKeys(B.records);d(C)}},[B,d,k]),b.useEffect(()=>{(A||T)&&F(!0),(q||K)&&F(!1),q?(E($.message),d([]),k("")):E("")},[A,T,B,k,q,K,F,d,E,$]),b.useEffect(()=>{_&&(t.getQueryData(U)||X(),G(!1))},[_,X,G,U,t]);function re(){const C=t.getQueryData(U);s.queryData||r({queryKey:U,queryData:C}),t.setQueryData(U,null),R(""),P({}),N(void 0),O(""),S({}),M("bar")}function Z(C,Q){if(C.length===0)return"";if(Q){const ee=C.find(J=>J.id===Q);if(ee){const J=ee.tabTitle;if(J=="All__Header")return C[0].id;if(J&&J.endsWith("__Header")){const ve=J.split("__")[0],me=C.find(pe=>pe.tabTitle===ve);return me?me.id:C[0].id}return Q}}return C[0].id}function oe(){let C=I;I&&!I.includes("{{")&&(C=Us(I),R(C));const Q={...j,lastSelectedSchema:D,lastSelectedDatamodelId:z,lastSelectedDatabase:g,lastSelectedTable:w,connectionId:v,type:p?j.type:"table",sql:C,customCfg:p?j.customCfg:null},ee=u.cards.map(ue=>ue.id===j.id?Q:ue),J={...u,cards:ee,activeCardId:Z(ee,u.activeCardId)};V==null||V(J)}function ie(){const{queryKey:C,queryData:Q}=s;C&&Q&&t.setQueryData(C,Q),H==null||H()}function ae(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[i&&e.jsxRuntimeExports.jsx("div",{className:"relative flex w-1/3 min-w-0 grow overflow-hidden border-l p-1 text-xs",role:"editor-filter-container",children:e.jsxRuntimeExports.jsxs("div",{className:"w-[99%]",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"ml-6 text-xs font-semibold",children:"Filters"}),i&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>l(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(at,{})]})}),!i&&e.jsxRuntimeExports.jsx(e.Filter,{onClick:()=>l(!0),className:e.cn("absolute bottom-4 right-6 h-3 w-3 text-foreground/50 hover:cursor-pointer hover:text-foreground",{"font-bold text-red-800":L})})]})}function le(){return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"1",order:1,defaultSize:n?20:100,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{id:"sql-container",className:"relative flex w-[99%]",children:e.jsxRuntimeExports.jsx(ot,{})}),n&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-xs text-muted-foreground/70",children:"sql"})]}),n&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{id:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsxRuntimeExports.jsx(it,{})}),e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-xs text-muted-foreground/70",children:"python"})]})]})]})}return e.jsxRuntimeExports.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxRuntimeExports.jsxs("div",{className:"relative flex grow justify-between overflow-y-scroll",children:[le(),ae()]}),e.jsxRuntimeExports.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{title:"Shift + Enter",disabled:A||T,onClick:()=>{X()},className:"shrink-0",size:"sm",variant:"outline",children:[A||T?e.jsxRuntimeExports.jsx(se,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(as,{className:"mr-2 h-4 w-4"}),"Run"]}),q&&e.jsxRuntimeExports.jsx(Qs,{error:$.message,setShowAIDialog:x,setTriggerAIRun:h,setUserInputforAI:c}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:re,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(Je,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:n,onPressedChange:C=>o(C),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(nt,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(Js,{open:a,setOpen:x,userInput:m,triggerAIRun:f,setTriggerAIRun:h,setUserInput:C=>c(C)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[(B==null?void 0:B.sql)&&e.jsxRuntimeExports.jsx(rt,{sql:B.sql}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:ie,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:oe,size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]})]})]})]})}function ct({data:s}){var l;const[r,t]=b.useState([]),o=Object.keys(s[0]).map(a=>({accessorKey:a,header:({column:x})=>{const m=x.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>x.toggleSorting(x.getIsSorted()==="asc"),children:[a,m==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):m==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),i=e.useReactTable({data:s,columns:o,getCoreRowModel:e.getCoreRowModel(),getPaginationRowModel:e.getPaginationRowModel(),onSortingChange:t,getSortedRowModel:e.getSortedRowModel(),manualPagination:!0,state:{sorting:r}});return e.jsxRuntimeExports.jsx("div",{className:"font-mono text-xs text-foreground/95",children:e.jsxRuntimeExports.jsxs("table",{className:"w-full",children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:i.getHeaderGroups().map(a=>e.jsxRuntimeExports.jsx(e.TableRow,{children:a.headers.map(x=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 h-11 bg-muted font-semibold",children:x.isPlaceholder?null:e.flexRender(x.column.columnDef.header,x.getContext())},x.id))},a.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(l=i.getRowModel().rows)!=null&&l.length?i.getRowModel().rows.map(a=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":a.getIsSelected()&&"selected",children:a.getVisibleCells().map(x=>e.jsxRuntimeExports.jsx(e.TableCell,{className:"py-3",children:e.flexRender(x.column.columnDef.cell,x.getContext())},x.id))},a.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:o.length,className:"h-24 text-center",children:"No results."})})})]})})}function xt({card:s}){var g,z,D,w,I,L,O,d,R,E,k;const[r,t]=b.useState(!1),[n,o]=b.useState([]),{authToken:i}=e.useSemaphorContext(),l=e.getTokenParams(i==null?void 0:i.accessToken),a=e.useDashboardStore(S=>S.themeStyle),x={colors:((z=(g=a==null?void 0:a.chart)==null?void 0:g.dataset)==null?void 0:z.backgroundColor)||[]};(D=s.customCardPreferences)!=null&&D.inputData;const{getCard:m}=e.useCustomVisual(((w=s.customCardPreferences)==null?void 0:w.url)||""),c=((I=s.customCardPreferences)==null?void 0:I.visualType)||"single",f=e.useEditorStore(S=>S.frame);e.useEditorActions();const{data:h}=e.useDashboardCardQuery(s),u=b.useCallback((S,M)=>{o(V=>({...V,[S]:M}))},[]);if(!((L=s.customCardPreferences)!=null&&L.componentName))return null;const j=m((O=s.customCardPreferences)==null?void 0:O.componentName);function p(S){t(S)}const v=Object.keys(((d=s.customCardPreferences)==null?void 0:d.dataInputCardIds)||{}).map(S=>{var H,P,_;const M=(P=(H=s.customCardPreferences)==null?void 0:H.dataInputCardIds)==null?void 0:P[S].cardId,V=(_=f==null?void 0:f.cards)==null?void 0:_.find(G=>G.id===M);return V||null});return e.jsxRuntimeExports.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:e.jsxRuntimeExports.jsxs(b.Suspense,{fallback:e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),children:[j&&c==="single"&&e.jsxRuntimeExports.jsx(j,{params:l,theme:x,settings:(R=s.customCardPreferences)==null?void 0:R.settings,onDataChange:u,data:(h==null?void 0:h.records)||[]}),j&&c==="multiple"&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[Object.keys(((E=s.customCardPreferences)==null?void 0:E.dataInputCardIds)||{}).map(S=>{var H,P,_;const M=(P=(H=s.customCardPreferences)==null?void 0:H.dataInputCardIds)==null?void 0:P[S].cardId,V=(_=f==null?void 0:f.cards)==null?void 0:_.find(G=>G.id===M);if(V)return e.jsxRuntimeExports.jsx(e.MultiInputEmptyRenderer,{onLoadingStatus:p,onDataChange:u,dataInputIndex:S,card:V},V.id+S)}),e.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-2",children:e.jsxRuntimeExports.jsx(j,{theme:x,onDataChange:u,settings:v.map(S=>{var M;return(M=S==null?void 0:S.customCardPreferences)==null?void 0:M.settings}),data:v.map(S=>S!=null&&S.id?n==null?void 0:n[S.id]:[])})})]})]},(k=s.customCardPreferences)==null?void 0:k.componentName)})}function ys({className:s,...r}){var v;const t=e.useEditorStore(g=>g.card),n=((v=t.customCardPreferences)==null?void 0:v.showCardHeader)??!0,o=e.useEditorStore(g=>g.frame),i=e.useDashboardStore(g=>g.dashboard.filters);e.useEditorStore(g=>g.actions.setRunSql);const{updateFilter:l}=e.useDashboardActions(),a=i==null?void 0:i.find(g=>g.id===o.filterId),{data:x,isLoading:m,isFetching:c}=e.useDashboardCardQuery(t),{setCard:f}=e.useEditorActions(),{data:h}=e.useTopoJson(t);if(!t.id)return null;let u;x!=null&&x.records&&(x==null?void 0:x.records.length)>0&&(u=e.createChartConfig({data:x==null?void 0:x.records,cardType:t.type,cfg:t.cfg,customCfg:t.customCfg,preferences:t.preferences,topoJson:h}));function j(g){return e.jsxRuntimeExports.jsx(xt,{card:g})}function p(){var g;if(x!=null&&x.records&&(x==null?void 0:x.records.length)===0&&!m&&!c)return e.jsxRuntimeExports.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[e.jsxRuntimeExports.jsx(e.TreePalm,{className:"size-8 text-muted-foreground"}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"No records to display"})]});if(t.type==="custom")return j(t);if(!["table","custom"].includes(t.type)&&u)return e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:u},JSON.stringify(u)+JSON.stringify(t.preferences)+((g=t==null?void 0:t.preferences)==null?void 0:g.customVisualCode));if(t.type==="table"&&(x!=null&&x.records)&&(x==null?void 0:x.records.length)>0)return e.jsxRuntimeExports.jsxs(e.ScrollArea,{className:"relative mb-2 flex h-full min-h-0 w-full flex-1 grow basis-0",children:[e.jsxRuntimeExports.jsx(e.TableVisual,{card:t,data:x==null?void 0:x.records}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]})}return e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",s),...r,children:[n&&e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"flex flex-row items-start justify-between py-4",children:[e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsx(e.Editable,{text:t.title,onSave:g=>f({...t,title:g}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-5",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:t.title||"Edit title..."})})},t.title),e.jsxRuntimeExports.jsx(e.Editable,{text:t.description||"",onSave:g=>f({...t,description:g}),children:e.jsxRuntimeExports.jsx(e.CardDescription,{children:t.description||"Edit description..."})},t.description)]}),a&&e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Editable,{className:"my-1",text:a.title||a.column,onSave:g=>l({...a,title:g}),children:e.jsxRuntimeExports.jsx(e.Label,{children:a.title})}),e.jsxRuntimeExports.jsx(e.FilterComponent,{filter:a})]})]}),e.jsxRuntimeExports.jsx(e.CardContent,{className:"flex grow flex-col",children:p()})]})}const Be=({language:s,value:r,onChange:t})=>e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:s,value:r,onChange:t}),ut=({card:s})=>e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Customize Card"}),e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:e.jsxRuntimeExports.jsx(ss,{onClick:()=>navigator.clipboard.writeText(s.id),className:"size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:"Copy Card ID"})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogDescription,{children:["See the configuration options and documentation",e.jsxRuntimeExports.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),dt=({defaultConfig:s,customCode:r,customConfig:t,onConfigChange:n,onCodeChange:o})=>e.jsxRuntimeExports.jsxs(e.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[e.jsxRuntimeExports.jsxs(e.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsxRuntimeExports.jsxs(e.TabsTrigger,{value:"custom-config",children:[t&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),t?"Custom Config":"Default Config"]}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{value:"output",children:"Output"}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{value:"custom-code",children:"Custom Code"})]}),e.jsxRuntimeExports.jsx(e.TabsContent,{value:"output",className:"mt-0 grow rounded-b border border-t-0 p-2",children:e.jsxRuntimeExports.jsx(e.Textarea,{readOnly:!0,value:s,className:"h-full resize-none border-none font-mono focus-visible:ring-0"})}),e.jsxRuntimeExports.jsx(e.TabsContent,{value:"custom-config",className:"mt-0 grow rounded-b border border-t-0",children:e.jsxRuntimeExports.jsx(Be,{language:"json",value:t,onChange:n})}),e.jsxRuntimeExports.jsx(e.TabsContent,{value:"custom-code",className:"mt-0 grow rounded-b border border-t-0",children:e.jsxRuntimeExports.jsx(Be,{language:"javascript",value:r,onChange:o})})]}),mt=({error:s,hasCustomConfig:r,onReset:t,onApply:n,onClose:o})=>e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:s}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!r,onClick:t,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:n,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:o,variant:"outline",children:"Close"})]});function pt(){const[s,r]=b.useState(!1),[t,n]=b.useState(""),[o,i]=b.useState(""),[l,a]=b.useState(""),[x,m]=b.useState(""),c=e.useEditorStore(w=>w.card),f=e.useEditorStore(w=>w.card.customCfg),{data:h}=e.useDashboardCardQuery(c),{data:u}=e.useTopoJson(c),{setCardCustomCfg:j,setCustomVisualCode:p}=e.useEditorActions(),v=w=>{var I,L;return JSON.stringify({...w,data:{...w.data,datasets:(L=(I=w.data)==null?void 0:I.datasets)==null?void 0:L.map(O=>({...O,data:[]}))}},null,2)},g=()=>{var I,L;if(!((I=h==null?void 0:h.records)!=null&&I.length))return;const w=e.createChartConfig({data:h.records,cardType:c.type,cfg:c.cfg,preferences:c.preferences,topoJson:u});w&&(n(v(w)),a(((L=c.preferences)==null?void 0:L.customVisualCode)||""),i(f?JSON.stringify(f,null,2):""))},z=()=>{try{if(l&&p(l),o){const w=JSON.parse(o);j(w),m("")}}catch{m("Invalid JSON configuration")}},D=()=>{if(f){const w=e._.merge(e._.cloneDeep(c.cfg),f);return v(w)}return t?v(JSON.parse(t)):""};return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{onClick:g,size:"sm",variant:"outline",className:f?"border-foreground/50 dark:border-foreground/70":"",children:e.jsxRuntimeExports.jsx(e.Settings,{className:"h-4 w-4"})})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"max-h-[70vh] min-h-[70vh] overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsxRuntimeExports.jsx(ut,{card:c}),e.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.FallbackEditorCard,children:e.jsxRuntimeExports.jsx(ys,{className:"w-1/2 rounded shadow-none"})}),e.jsxRuntimeExports.jsx(dt,{defaultConfig:t,customCode:l,customConfig:D(),onConfigChange:w=>i(w??""),onCodeChange:w=>a(w??"")})]}),e.jsxRuntimeExports.jsx(mt,{error:x,hasCustomConfig:!!f,onReset:()=>{i(""),j(null)},onApply:z,onClose:()=>r(!1)})]})]})}function vs(s){return Y({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M926.8 397.1l-396-288a31.81 31.81 0 0 0-37.6 0l-396 288a31.99 31.99 0 0 0-11.6 35.8l151.3 466a32 32 0 0 0 30.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z"},child:[]}]})(s)}function Ss(s){return Y({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24a8,8,0,0,0-8,8V88a8,8,0,0,0,8,8,32,32,0,1,1-27.72,16,8,8,0,0,0-2.93-10.93l-48.5-28A8,8,0,0,0,37.92,76,104,104,0,1,0,128,24ZM48.09,91.1,83,111.26A48.09,48.09,0,0,0,80,128c0,1.53.08,3,.22,4.52L41.28,143A88.16,88.16,0,0,1,48.09,91.1Zm-2.67,67.31,39-10.44A48.1,48.1,0,0,0,120,175.32v40.31A88.2,88.2,0,0,1,45.42,158.41ZM136,215.63V175.32a48,48,0,0,0,0-94.65V40.36a88,88,0,0,1,0,175.27Z"},child:[]}]})(s)}function Cs(s){return Y({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm87.63,96H191.48A64.1,64.1,0,0,0,136,64.52V40.37A88.13,88.13,0,0,1,215.63,120ZM120,120H80.68A48.09,48.09,0,0,1,120,80.68Zm0,16v39.32A48.09,48.09,0,0,1,80.68,136Zm16,0h39.32A48.09,48.09,0,0,1,136,175.32Zm0-16V80.68A48.09,48.09,0,0,1,175.32,120ZM120,40.37V64.52A64.1,64.1,0,0,0,64.52,120H40.37A88.13,88.13,0,0,1,120,40.37ZM40.37,136H64.52A64.1,64.1,0,0,0,120,191.48v24.15A88.13,88.13,0,0,1,40.37,136ZM136,215.63V191.48A64.1,64.1,0,0,0,191.48,136h24.15A88.13,88.13,0,0,1,136,215.63Z"},child:[]}]})(s)}function Ns(s){return Y({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0"},child:[]}]})(s)}function ws(s){return Y({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m2 19.99 7.5-7.51 4 4 7.09-7.97L22 9.92l-8.5 9.56-4-4-6 6.01-1.5-1.5zm1.5-4.5 6-6.01 4 4L22 3.92l-1.41-1.41-7.09 7.97-4-4L2 13.99l1.5 1.5z"},child:[]}]})(s)}function ks(s){return Y({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M4 9h4v11H4zM4 4h4v4H4zM10 7h4v4h-4zM16 10h4v4h-4zM16 15h4v5h-4zM10 12h4v8h-4z"},child:[]}]})(s)}function Ds(s){return Y({tag:"svg",attr:{version:"1.2",baseProfile:"tiny",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M4 18c-.552 0-1-.448-1-1v-6.382l-.553.276c-.495.248-1.095.046-1.342-.447-.247-.494-.046-1.094.448-1.342l2-1c.31-.155.678-.139.973.044.294.183.474.504.474.851v8c0 .552-.448 1-1 1zM13 18h-5c-.404 0-.769-.244-.924-.617-.155-.374-.069-.804.217-1.09l4-4c.254-.254.394-.591.394-.95 0-.358-.14-.695-.394-.949-.508-.508-1.39-.508-1.9.001-.253.252-.393.589-.393.948 0 .552-.448 1-1 1s-1-.448-1-1c0-.894.348-1.733.98-2.364 1.265-1.263 3.464-1.263 4.727.001.632.631.979 1.471.979 2.363 0 .893-.348 1.733-.979 2.364l-2.293 2.293h2.586c.552 0 1 .448 1 1s-.448 1-1 1zM20.955 12.377c.338-.457.545-1.016.545-1.627 0-1.517-1.234-2.75-2.75-2.75-1.031 0-1.966.569-2.44 1.484-.254.49-.063 1.094.428 1.348.49.254 1.094.062 1.348-.428.128-.249.383-.404.664-.404.414 0 .75.336.75.75s-.336.75-.75.75c-.552 0-1 .448-1 1s.448 1 1 1c.689 0 1.25.561 1.25 1.25s-.561 1.25-1.25 1.25-1.25-.561-1.25-1.25c0-.552-.448-1-1-1s-1 .448-1 1c0 1.792 1.458 3.25 3.25 3.25s3.25-1.458 3.25-3.25c0-.939-.406-1.779-1.045-2.373z"},child:[]}]})(s)}function Is(s){return Y({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M217 25v14h78V25h-78zm0 32v46h14V71h50v32h14V57h-78zm32 32v14h14V89h-14zm-64 32v46h30v-46h-30zm48 0v14h46v-14h-46zm64 0v46h30v-46h-30zm-64 32v14h46v-14h-46zm-80 32v46h62v-46h-62zm80 0v14h46v-14h-46zm64 0v46h62v-46h-62zm-64 32v14h46v-14h-46zm-112 32v46h94v-46h-94zm112 0v14h46v-14h-46zm64 0v46h94v-46h-94zm-64 32v14h46v-14h-46zM89 313v46h126v-46H89zm144 0v14h46v-14h-46zm64 0v46h126v-46H297zm-64 32v14h46v-14h-46zM57 377v46h158v-46H57zm176 0v14h46v-14h-46zm64 0v46h158v-46H297zm-64 32v14h46v-14h-46zM25 441v46h190v-46H25zm208 0v14h46v-14h-46zm64 0v46h190v-46H297zm-64 32v14h46v-14h-46z"},child:[]}]})(s)}function Ls(s){const[r,t]=b.useState(null);return b.useEffect(()=>{s&&(async()=>{const i=(await Promise.resolve().then(()=>require("./lucide-react-CDQZoJjz.js")))[s];t(i)})()},[s]),r}function Ts(){const{authToken:s}=e.useSemaphorContext(),{data:r,isLoading:t,isFetching:n,isError:o}=e.useQuery({queryKey:["plugins",s==null?void 0:s.accessToken],queryFn:()=>e.getPlugins(s==null?void 0:s.accessToken)});return{data:r,isLoading:t,isFetching:n,isError:o}}function jt({onChartTypeChange:s}){const[r,t]=b.useState([]),{data:n}=Ts();return b.useEffect(()=>{(async()=>{var i;if(n){const a=(await Promise.all((i=n==null?void 0:n.plugins)==null?void 0:i.map(async x=>(await e.loadManifest(x.value)).visuals.map(f=>({name:f.name,icon:f.icon,url:x.value}))))).flat();t(a)}})()},[n]),r.length===0?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.Separator,{className:"my-2"}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-4 place-items-center",children:r.map((o,i)=>e.jsxRuntimeExports.jsx(ht,{text:o.name,onClick:()=>s("custom",o),icon:o.icon},o.url+o.name+i))})]})}const ht=({text:s,icon:r,onClick:t})=>{const n=Ls(r||""),o=s.charAt(0).toUpperCase();return e.jsxRuntimeExports.jsx(e.Button,{onClick:t,title:s,variant:"ghost",children:n?e.jsxRuntimeExports.jsx(n,{className:"h-4 w-4"}):o})};function Et(){var c,f;const[s,r]=b.useState(!1),t=e.useEditorStore(h=>h.card),n=t.type,{setCardType:o,setCardPreferences:i,setChartOrientation:l}=e.useEditorStore(h=>h.actions),{setCardCustomCfg:a,setCustomCardPreferences:x}=e.useEditorActions();function m(h,u){a(null),i({}),o(h),u&&x({type:"component",visualType:"single",url:u.url,componentName:u.name,icon:u.icon}),r(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:s,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(ft,{className:"h-4 w-4",chartType:n,customIcon:(c=t.customCardPreferences)==null?void 0:c.icon,componentName:(f=t.customCardPreferences)==null?void 0:f.componentName})})}),e.jsxRuntimeExports.jsxs(e.PopoverContent,{className:"w-50",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-4 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(ge,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Re,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ks,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ws,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(we,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ns,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ne,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ss,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(vs,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Cs,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Is,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ce,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ds,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(be,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("map"),variant:"ghost",children:e.jsxRuntimeExports.jsx(De,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("custom"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ie,{className:"size-4"})})]}),e.jsxRuntimeExports.jsx(jt,{onChartTypeChange:m})]})]})}function ft({chartType:s,className:r,customIcon:t,componentName:n}){const o=Ls(t||"");switch(s){case"bar":return e.jsxRuntimeExports.jsx(ge,{className:r});case"line":return e.jsxRuntimeExports.jsx(Re,{className:r});case"pie":return e.jsxRuntimeExports.jsx(Ne,{className:r});case"radar":return e.jsxRuntimeExports.jsx(vs,{className:r});case"scatter":return e.jsxRuntimeExports.jsx(we,{className:r});case"bubble":return e.jsxRuntimeExports.jsx(Ns,{className:r});case"doughnut":return e.jsxRuntimeExports.jsx(Ss,{className:r});case"stackedBar":return e.jsxRuntimeExports.jsx(ks,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(ws,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(Cs,{className:r});case"pyramid":return e.jsxRuntimeExports.jsx(Is,{className:r});case"range":return e.jsxRuntimeExports.jsx(Ce,{className:r});case"kpi":return e.jsxRuntimeExports.jsx(Ds,{className:r});case"text":return e.jsxRuntimeExports.jsx(be,{className:r});case"map":return e.jsxRuntimeExports.jsx(De,{className:r});case"custom":return t&&o?e.jsxRuntimeExports.jsx(o,{className:r}):n?n==null?void 0:n.charAt(0).toUpperCase():e.jsxRuntimeExports.jsx(Ie,{className:r});default:return e.jsxRuntimeExports.jsx(e.Table,{className:r})}}function gt(){var r;const s=e.useEditorStore(t=>t.card);return(r=s.customCardPreferences)==null||r.showCardHeader,e.useEditorActions(),e.jsxRuntimeExports.jsxs(e.DropdownMenu,{children:[e.jsxRuntimeExports.jsx(e.DropdownMenuTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(ke,{className:"size-4 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsx(e.DropdownMenuContent,{align:"start",className:"w-40 text-muted-foreground",children:e.jsxRuntimeExports.jsxs(e.DropdownMenuItem,{onClick:()=>{navigator.clipboard.writeText(s.id),e.ce.success("Card ID copied to clipboard")},className:"cursor-pointer space-x-2",children:[e.jsxRuntimeExports.jsx(e.IdCard,{className:"size-5"}),e.jsxRuntimeExports.jsx("span",{children:"Copy Card ID"})]})})]})}function _e(){const s=e.useEditorStore(d=>d.frame),r=e.useEditorStore(d=>d.card),t=e.useEditorStore(d=>d.isShowingVisual),n=e.useEditorStore(d=>d.isSqlRunning),o=e.useEditorStore(d=>d.queryError),i=e.useEditorStore(d=>d.pythonStdOut);e.useEditorStore(d=>d.actions.setRunSql);const{setFrame:l,setCard:a,updateCardInFrame:x,setActiveTabCardId:m}=e.useEditorActions(),{data:c,isLoading:f,isFetching:h}=e.useDashboardCardQuery(r);if(!r)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function u(){const d={connectionId:r.connectionId,id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]};j(d)}function j(d){const R={...s,cards:[...s.cards,d],activeCardId:d.id};l(R),m(d.id)}function p(){const d={...r,id:e.v4(),title:`${r.title} Copy`,tabTitle:`${r.tabTitle||r.title} Copy`};j(d)}function v(d){const R=s.cards.filter(S=>S.id!==d),E=R[0],k={...s,cards:R,activeCardId:E.id};l(k),a(E)}function g(d){m(d)}const z=(d,R)=>{console.log("handleDragStart",R),d.dataTransfer.setData("tabIndex",R.toString())},D=d=>{d.preventDefault()},w=(d,R)=>{const E=d.dataTransfer.getData("tabIndex");if(E===R.toString())return;const k=Array.from(s.cards),[S]=k.splice(parseInt(E),1);k.splice(R,0,S),l({...s,cards:k})};function I(d,R){return d.cards.length===1&&(R.displayTab===!0||R.displayTab===void 0)||d.activeCardId!==R.id&&(R.displayTab===!0||R.displayTab===void 0)?null:e.jsxRuntimeExports.jsx("div",{onClick:()=>{const E=R.displayTab===void 0?!1:!R.displayTab;a({...R,displayTab:E}),x({...R,displayTab:E})},children:R.displayTab===!0||R.displayTab===void 0?e.jsxRuntimeExports.jsx(e.Eye,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"}):e.jsxRuntimeExports.jsx(We,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"})})}function L(){return e.jsxRuntimeExports.jsxs(e.Tabs,{onValueChange:g,value:s.activeCardId,className:"flex grow flex-col",children:[s.cards.map(d=>e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow",value:d.id,children:O()},d.id)),e.jsxRuntimeExports.jsx(e.TabsList,{className:"group mx-6 justify-between",children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[s.cards.map((d,R)=>e.jsxRuntimeExports.jsx(e.Editable,{text:d.tabTitle||d.title,onSave:E=>{a({...r,tabTitle:E}),x({...r,tabTitle:E})},children:e.jsxRuntimeExports.jsxs(e.TabsTrigger,{draggable:!0,onDragStart:E=>z(E,R),onDragOver:D,onDrop:E=>w(E,R),className:"",value:d.id,children:[I(s,d),d.tabTitle||d.title,s.activeCardId===d.id&&s.cards.length>1&&e.jsxRuntimeExports.jsx(e.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>v(d.id)})]})},d.id)),e.jsxRuntimeExports.jsx(e.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:u,children:e.jsxRuntimeExports.jsx(e.Plus,{className:"h-4 w-4"})}),e.jsxRuntimeExports.jsx(e.Button,{className:"invisible ml-1 h-8 px-2 hover:bg-muted-foreground/50 group-hover:visible",variant:"outline",onClick:p,children:e.jsxRuntimeExports.jsx(Qe,{className:"h-4 w-4"})})]})})]})}function O(){return r.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.KPICard,{card:r,data:c==null?void 0:c.records})})}):r.type==="text"?e.jsxRuntimeExports.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"mx-3 my-6 h-[300px] overflow-y-auto break-words px-3",children:e.jsxRuntimeExports.jsx(e.TextCard,{isLoading:n,card:r,data:c==null?void 0:c.records})})})}):e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.FallbackEditorCard,children:e.jsxRuntimeExports.jsx(ys,{className:"grow border-none shadow-none"})})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col py-3",children:[(f||h)&&e.jsxRuntimeExports.jsx(se,{className:"absolute bottom-0 left-0 right-0 top-0 z-50 m-auto h-10 w-10 animate-spin text-foreground/10"}),e.jsxRuntimeExports.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[t&&e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsx(Et,{}),!["table","custom"].includes(r.type)&&e.jsxRuntimeExports.jsx(pt,{}),e.jsxRuntimeExports.jsx(gt,{})]}),e.jsxRuntimeExports.jsx(bt,{})]}),t?L():e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{className:"px-6",direction:"horizontal",children:[i&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.ResizablePanel,{id:"1",order:1,defaultSize:30,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:i&&e.jsxRuntimeExports.jsx(Rt,{})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{})]}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{id:"2",order:2,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:e.jsxRuntimeExports.jsxs(e.ScrollArea,{className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:[(c==null?void 0:c.records)&&(c==null?void 0:c.records.length)>0&&e.jsxRuntimeExports.jsx(ct,{data:(c==null?void 0:c.records)||[]}),o&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-xs",children:o}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]})})]})]})}function Rt(){const s=e.useEditorStore(t=>t.pythonStdOut);if(!s)return null;const r=s.replace(/\n/g,"<br>");return e.jsxRuntimeExports.jsxs("div",{className:"relative flex w-full flex-col border-r",children:[e.jsxRuntimeExports.jsx("div",{className:"sticky top-0 flex max-h-11 min-h-11 grow items-center border-b bg-muted px-3 font-mono text-xs font-semibold text-foreground/70",children:"Python Output"}),e.jsxRuntimeExports.jsxs(e.ScrollArea,{className:"overflow-y-auto px-2 pt-1 font-mono text-xs text-foreground/90",children:[e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:r}}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]})]})}function bt(){const s=e.useEditorStore(t=>t.isShowingVisual),r=e.useEditorStore(t=>t.actions.setIsShowingVisual);return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"visualize",children:"Chart"}),e.jsxRuntimeExports.jsx(e.Switch,{checked:s,onCheckedChange:()=>r(!s),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function yt({options:s,value:r,onValueChange:t}){return e.jsxRuntimeExports.jsx(e.RadioGroup,{value:r,onValueChange:t,className:"flex gap-4",defaultValue:s[0].value,children:s.map(n=>e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:n.value,id:n.value}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:n.value,children:n.label})]},n.value))})}function W({label:s,options:r,value:t,onValueChange:n,className:o}){return e.jsxRuntimeExports.jsxs(e.Select,{value:t,onValueChange:n,children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:e.cn("w-full focus:ring-0 focus:ring-offset-0",o),children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:s})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:s}),r.map(i=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:i.value,children:i.label},i.value))]})})]})}function de({children:s,summary:r,open:t,className:n}){return e.jsxRuntimeExports.jsxs("details",{open:t,className:e.cn("space-y-4 [&_summary>svg]:open:-rotate-180",n),children:[e.jsxRuntimeExports.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-4",children:[e.jsxRuntimeExports.jsx(e.Label,{children:r}),e.jsxRuntimeExports.jsx(e.ChevronUp,{className:"h-4 w-4"})]}),e.jsxRuntimeExports.jsx("div",{className:"transition-all ease-in-out",children:s})]})}function vt(){var p,v;const s=e.useEditorStore(g=>g.card.customCardPreferences),{data:r}=Ts(),t=(r==null?void 0:r.plugins)||[],n=e.useEditorStore(g=>g.card),o=e.useEditorStore(g=>g.frame),i=(s==null?void 0:s.visualType)||"single",{setCustomCardPreferences:l}=e.useEditorActions(),{components:a,manifest:x}=e.useCustomVisual((s==null?void 0:s.url)||""),m=(p=x==null?void 0:x.visuals)==null?void 0:p.find(g=>g.name===(s==null?void 0:s.componentName));function c(g,z){if(!s)return;const w={...(s==null?void 0:s.dataInputCardIds)||{},[g]:{cardId:z,hookRef:null}};l({...s,dataInputCardIds:w})}function f(g){var D,w;const z=(D=o==null?void 0:o.cards)==null?void 0:D.filter(I=>{var L;return((L=I==null?void 0:I.customCardPreferences)==null?void 0:L.visualType)!=="multiple"}).map(I=>({value:I.id,label:I.tabTitle||I.title}));return e.jsxRuntimeExports.jsx("div",{className:"space-y-2",children:(w=g==null?void 0:g.dataInputs)==null?void 0:w.map((I,L)=>{var O,d;return e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-10 gap-2",children:[e.jsxRuntimeExports.jsx("div",{className:"col-span-4 flex items-center",children:I}),e.jsxRuntimeExports.jsx(W,{className:"col-span-6 h-8 w-full justify-between",label:"",options:z||[],value:((d=(O=s==null?void 0:s.dataInputCardIds)==null?void 0:O[L])==null?void 0:d.cardId)||"",onValueChange:R=>c(L,R)})]},L+Math.random())})})}function h(g,z,D=[]){var w,I;return s?g==="input"?e.jsxRuntimeExports.jsx(e.Input,{className:`h-8 w-full ${e.removeRing}`,value:((w=s==null?void 0:s.settings)==null?void 0:w[z])||"",onChange:L=>{l({...s,settings:{...s==null?void 0:s.settings,[z]:L.target.value}})}},z):g==="select"?e.jsxRuntimeExports.jsx(W,{className:"h-8 w-full",label:"",options:D,value:((I=s==null?void 0:s.settings)==null?void 0:I[z])||"",onValueChange:L=>{l({...s,settings:{...s==null?void 0:s.settings,[z]:L}})}}):null:null}function u(g){const z=Object.entries((g==null?void 0:g.settings)||{});return e.jsxRuntimeExports.jsx("div",{className:"space-y-3",children:z.map(([D,w])=>e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:w.title}),h(w.ui,D,w.options)]},D))})}function j(g){s&&l({...s,visualType:g,componentName:""})}return e.jsxRuntimeExports.jsxs("div",{className:"p-6",children:[e.jsxRuntimeExports.jsx(de,{summary:"Plugin Settings",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 text-sm",children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsxRuntimeExports.jsx("div",{className:"space-y-2",children:e.jsxRuntimeExports.jsx("div",{className:"px-2",children:e.jsxRuntimeExports.jsx(W,{className:"h-8 w-full",label:"",options:t,value:(s==null?void 0:s.url)||"",onValueChange:g=>l({...s||{url:"",componentName:""},url:g})})})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&e.jsxRuntimeExports.jsx(yt,{options:[{value:"single",label:"Single Visual"},{value:"multiple",label:"Multi-Visual"}],value:i,onValueChange:j}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&s&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Component"}),e.jsxRuntimeExports.jsx("div",{className:"space-y-2 px-2",children:a&&e.jsxRuntimeExports.jsx(W,{className:"h-8 w-full",label:"",options:(a==null?void 0:a.filter(g=>g.type===i).map(g=>({value:g.name,label:g.name})))||[],value:s.componentName,onValueChange:g=>{console.log("changing value",g),l({...s,componentName:g})}})})]})})]})})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),((v=n==null?void 0:n.customCardPreferences)==null?void 0:v.componentName)&&e.jsxRuntimeExports.jsxs(de,{summary:"Component Settings",children:[m&&m.dataInputs&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Input Mapping"}),e.jsxRuntimeExports.jsx("div",{className:"px-2",children:f(m)})]}),m&&m.settings&&e.jsxRuntimeExports.jsx("div",{className:"space-y-3",children:e.jsxRuntimeExports.jsx("div",{className:"px-2",children:u(m)})})]})]})}function ne(){const[s,r]=b.useState([]);e.useEditorStore(c=>c.card.cfg);const t=e.useEditorStore(c=>c.card.preferences),{setCardCfg:n,setFilterOnClickColumnIndex:o,setCardPreferences:i}=e.useEditorStore(c=>c.actions),l=e.useEditorStore(c=>c.queryResultColumns);e.useEditorStore(c=>{var f;return(f=c.card.preferences)==null?void 0:f.filterOnClickColumnIndex}),b.useEffect(()=>{l&&r(new Array(l.length).fill(!1))},[l]);function a(c,f){var h,u;f?t!=null&&t.onClickFilter&&((h=t==null?void 0:t.onClickFilter)==null?void 0:h.length)>0?i({...t,onClickFilter:[...t.onClickFilter,{columnIndex:c,expression:""}]}):i({...t,onClickFilter:[{columnIndex:c,expression:""}]}):(i({...t,onClickFilter:(u=t==null?void 0:t.onClickFilter)==null?void 0:u.filter(j=>j.columnIndex!==c)}),r(j=>{const p=[...j];return p[c]=!1,p}))}function x(c,f){var u;const h=(u=t==null?void 0:t.onClickFilter)==null?void 0:u.map(j=>j.columnIndex===c?{...j,expression:f.target.value}:j);i({...t,onClickFilter:h})}function m(c){var f,h,u,j;if(s!=null&&s[c]||(h=(f=t==null?void 0:t.onClickFilter)==null?void 0:f.find(p=>p.columnIndex===c))!=null&&h.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(j=(u=t==null?void 0:t.onClickFilter)==null?void 0:u.find(p=>p.columnIndex===c))==null?void 0:j.expression,onChange:p=>x(c,p),type:"text",className:"h-9 w-full font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"Expression"})}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"On Click"}),l==null?void 0:l.map((c,f)=>{var h,u;return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 group flex items-center justify-between space-y-2",children:e.jsxRuntimeExports.jsxs("div",{className:"grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2 py-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((h=t==null?void 0:t.onClickFilter)!=null&&h.find(j=>j.columnIndex===f)),onCheckedChange:j=>a(f,j)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:c}),e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:((u=t==null?void 0:t.onClickFilter)==null?void 0:u.find(j=>j.columnIndex===f))&&e.jsxRuntimeExports.jsx(e.Pencil,{onClick:()=>{r(j=>{const p=[...j];return p[f]=!j[f],p})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),m(f)]})},c)})]})}function ye(){var l,a,x;const s=e.useEditorStore(m=>m.card.preferences),r=e.useEditorStore(m=>m.card.cfg),{setCardCfg:t,setCardPreferences:n,setChartOrientation:o}=e.useEditorStore(m=>m.actions);(l=r==null?void 0:r.options)!=null&&l.indexAxis;function i(m){o(m)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((a=s==null?void 0:s.chartOptions)==null?void 0:a.indexAxis)||((x=r==null?void 0:r.options)==null?void 0:x.indexAxis)||"x",onValueChange:i,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"x",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"y",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const je="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function He(s,r){var n,o,i;const t=e.getNumberAxis(s,r);return((i=(o=(n=s==null?void 0:s.chartOptions)==null?void 0:n.scales)==null?void 0:o[t])==null?void 0:i.type)||"linear"}function As(){var P,_,G,N,F,B;const[s,r]=b.useState(!1),t=e.useEditorStore(A=>{var T;return(T=A.card)==null?void 0:T.preferences}),n=e.useEditorStore(A=>{var T;return(T=A.card)==null?void 0:T.cfg}),o=e.getNumberAxis(t,n),[i,l]=b.useState(He(t)),[a,x]=b.useState(((G=(_=(P=t==null?void 0:t.chartOptions)==null?void 0:P.scales)==null?void 0:_[o])==null?void 0:G.min)||""),[m,c]=b.useState(((B=(F=(N=t==null?void 0:t.chartOptions)==null?void 0:N.scales)==null?void 0:F[o])==null?void 0:B.max)||""),[f,h]=b.useState(a||m?"custom":"auto"),[u,j]=b.useState(""),[p,v]=b.useState(0),[g,z]=b.useState(""),[D,w]=b.useState(""),[I,L]=b.useState(""),O=e.useEditorStore(A=>A.actions.setCardPreferences),{updateCardInFrame:d}=e.useEditorActions(),R=e.useEditorStore(A=>A.card),E=e.useEditorStore(A=>{var T;return(T=A.card)==null?void 0:T.type}),k=["pie","doughnut","polarArea"].includes(E);b.useEffect(()=>{var A,T,K,q,$,U,X,re,Z,oe,ie,ae,le,C;l(He(t)),x(((K=(T=(A=t==null?void 0:t.chartOptions)==null?void 0:A.scales)==null?void 0:T[o])==null?void 0:K.min)===0?0:""),c(((U=($=(q=t==null?void 0:t.chartOptions)==null?void 0:q.scales)==null?void 0:$[o])==null?void 0:U.max)||""),j(((oe=(Z=(re=(X=t==null?void 0:t.chartOptions)==null?void 0:X.scales)==null?void 0:re[o])==null?void 0:Z.ticks)==null?void 0:oe.stepSize)||""),v(((ie=t==null?void 0:t.numberAxisFormat)==null?void 0:ie.decimalPlaces)||0),z(((ae=t==null?void 0:t.numberAxisFormat)==null?void 0:ae.suffix)||""),w(((le=t==null?void 0:t.numberAxisFormat)==null?void 0:le.currency)||""),L(((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.locale)||"")},[s,t,o]);function S(A,T){return T===""||/^[0-9\b]+$/.test(T)?Number(T):Number(A)}function M(){const A=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(T=>T.currency))];return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsxRuntimeExports.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxRuntimeExports.jsxs(e.Select,{value:D||"none",onValueChange:T=>w(T==="none"?"":T),children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),A.map(T=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:T,children:T},T))]})})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:I,onValueChange:T=>L(T),children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Locale"}),e.LOCALE_CURRENCY_PAIRS.map(T=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:T.locale,children:T.locale},T.locale))]})})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsxRuntimeExports.jsx(e.Input,{value:p,onChange:T=>v(Number(T.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${je}`})]})]})}function V(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"range",children:"Range"}),e.jsxRuntimeExports.jsx(e.Input,{id:"min",value:a,onChange:A=>x(T=>S(T,A.target.value)),className:`col-span-1 h-8 w-full ${je}`}),e.jsxRuntimeExports.jsx(e.Input,{value:m,onChange:A=>c(T=>S(T,A.target.value)),id:"max",className:`col-span-1 h-8 w-full ${je}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsxRuntimeExports.jsx(e.Input,{value:u,onChange:A=>j(T=>S(T,A.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${je}`})]})]})}function H(){var q;let A={};f==="custom"&&(A={min:a,max:m,ticks:{stepSize:u}});const T={...t||{},chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(q=t==null?void 0:t.chartOptions)==null?void 0:q.scales,[o]:{type:i,...i==="linear"?A:{}}}},numberAxisFormat:{decimalPlaces:p,suffix:g,currency:D,locale:I}};console.log(T),O(T);const K={...R,preferences:T};d(K)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:A=>r(A),children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"max-w-65",children:e.jsxRuntimeExports.jsxs("div",{className:"grid gap-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale",children:"Type"}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:k,value:i,onValueChange:A=>l(A),children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{id:"type",children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Option"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"linear",children:"Linear"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),i=="linear"&&e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxRuntimeExports.jsxs(e.RadioGroup,{disabled:k,id:"scale-option",value:f,onValueChange:A=>h(A),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"auto",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"custom",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),f==="custom"&&i=="linear"&&V(),M(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:H,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function St({idx:s}){var a;const r=e.useEditorStore(x=>{var m;return(m=x.card)==null?void 0:m.preferences}),t=e.useEditorStore(x=>{var m;return(m=x.card.preferences)==null?void 0:m.datasetOptions}),n=e.useEditorStore(x=>x.actions.setCardPreferences),o=(a=r==null?void 0:r.chartOptions)==null?void 0:a.indexAxis,i=t==null?void 0:t.find(x=>x.idx===s);function l(x,m){(x==="end"||x==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const c={display:x!=="none",align:x,anchor:x,clamp:!0};if(!i)n({...r,datasetOptions:[...t||[],{idx:m,datalabels:c}]});else{const f={...i};f.datalabels=c;const h=t==null?void 0:t.map(u=>u.idx===m?f:u);n({...r,datasetOptions:h})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(ms,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-fit p-1",children:e.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>l("none",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(e.X,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>l("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(ts,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>l("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(rs,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>l("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(ns,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function zs(){const s=e.useEditorStore(m=>m.card),r=e.useEditorStore(m=>{var c,f,h;return(h=(f=(c=m==null?void 0:m.card)==null?void 0:c.preferences)==null?void 0:f.chartOptions)==null?void 0:h.indexAxis}),{data:t}=e.useDashboardCardQuery(s),n=r==="y"?"Y axis":"X axis",o=r==="y"?"X axis":"Y axis",{keys:i,metricKeys:l,dimensionKeys:a}=e.getKeys((t==null?void 0:t.records)||[]);let x=l;if(["stackedBar","stackedLine"].includes(s.type)){const m=e.pivotData({dataArray:(t==null?void 0:t.records)||[],groupKey:a[0],pivotKey:a[1],valueKey:x[0]}),{metricKeys:c}=e.getKeys(m);x=c}return i.length===0?null:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:n}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:e.jsxRuntimeExports.jsx("p",{children:a[0]})})})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxRuntimeExports.jsx(e.Label,{children:o}),e.jsxRuntimeExports.jsx(As,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:x.map((m,c)=>e.jsxRuntimeExports.jsx(Ct,{col:m,idx:c},m))})]})]})}function Ct({col:s,idx:r}){const t=e.useEditorStore(a=>{var x;return(x=a.card)==null?void 0:x.preferences}),n=e.useEditorStore(a=>{var x;return(x=a.card.preferences)==null?void 0:x.datasetOptions}),o=n==null?void 0:n.find(a=>a.idx===r),{setCardPreferences:i}=e.useEditorStore(a=>a.actions);function l(a){if(!o)i({...t,datasetOptions:[...n||[],{idx:r,type:a==="area"?"line":a,fill:a==="area"?"origin":""}]});else{const x={...o};x.type=a==="area"?"line":a,x.fill=a==="area"?"origin":"";const m=n==null?void 0:n.map(c=>c.idx===r?x:c);i({...t,datasetOptions:m})}}return e.jsxRuntimeExports.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[e.jsxRuntimeExports.jsx("p",{children:s}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsx(ge,{onClick:()=>l("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Re,{onClick:()=>l("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx($e,{onClick:()=>l("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(St,{idx:r})]})]})}function Os(){const s=e.useEditorStore(h=>h.selectedConnectionId),r=e.useEditorStore(h=>h.selectedDatamodelId),t=e.useEditorStore(h=>h.selectedDatabaseName),n=e.useEditorStore(h=>h.selectedSchemaName),o=e.useEditorStore(h=>h.selectedTableName),i=e.useDashboardStore(h=>h.dashboard.filters)||[],l=e.useDashboardStore(h=>h.actions.addFilter),a=e.useDashboardStore(h=>h.actions.removeFilter),{removeFilterValues:x}=e.useDashboardActions(),{modelItems:m,tableName:c}=te();function f(h,u="dashboard"){var L;const j=e.fmt(h.column_name),p=e.fmt(t||""),v=e.fmt(n||""),g=e.fmt(c);let z=e.getQualifiedTableName(v,g),D=`${z}.${j}`;const w=(L=m==null?void 0:m.find(O=>O.id===r))==null?void 0:L.name;r&&r!=="none"&&(D=`${e.DATAMODEL_NAMESPCACE}.${w}.${j}`,z=`${e.DATAMODEL_NAMESPCACE}.${w}`);const I=i==null?void 0:i.find(O=>O.column===D&&O.table===g&&(O.database===p||O.database===t));if(I)x(I.id),a(I.id);else{const O=e.v4();return c==="api"&&s?(l({location:u,id:O,column:D,title:h.column_name,dataType:h.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:e.getDefaultFilterSql(h.data_type,z,j)}),O):(l({id:O,location:u,column:D,title:h.column_name,dataType:h.data_type,table:o||"",database:t||"",connectionId:s||"",operation:"in",sql:e.getDefaultFilterSql(h.data_type,z,j)}),O)}}return{assignFilter:f}}function xe(){const s=e.useDashboardStore(a=>a.dashboard.filters),r=e.useEditorStore(a=>a.frame),{setFrame:t}=e.useEditorActions(),{columns:n}=te(),{assignFilter:o}=Os();function i(a){const x=o(a,"frame");t({...r,filterId:x})}const l=s==null?void 0:s.find(a=>a.id===r.filterId);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Card Filter"}),e.jsxRuntimeExports.jsx(Nt,{onSelect:i,columns:n}),l&&e.jsxRuntimeExports.jsx(e.FilterHeader,{filter:l})]})}function Nt({columns:s,onSelect:r}){var l;const[t,n]=Fe.useState(!1),[o,i]=Fe.useState("");return e.jsxRuntimeExports.jsxs(e.Popover,{open:t,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs(e.Button,{size:"sm",variant:"outline",role:"combobox","aria-expanded":t,className:"w-full justify-between font-normal",children:[o?(l=s.find(a=>a.column_name===o))==null?void 0:l.column_name:"Select Column...",e.jsxRuntimeExports.jsx(e.CaretSortIcon,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-[200px] p-0",children:e.jsxRuntimeExports.jsxs(e.Command,{children:[e.jsxRuntimeExports.jsx(e.CommandInput,{placeholder:"Search column",className:"h-9"}),e.jsxRuntimeExports.jsxs(e.CommandList,{children:[e.jsxRuntimeExports.jsx(e.CommandEmpty,{children:"No framework found."}),e.jsxRuntimeExports.jsx(e.CommandGroup,{children:s.map(a=>e.jsxRuntimeExports.jsxs(e.CommandItem,{value:a.column_name,onSelect:x=>{const m=x===o?"":x;i(m),n(!1),m&&r(a)},children:[a.column_name,e.jsxRuntimeExports.jsx(e.CheckIcon,{className:e.cn("ml-auto h-4 w-4",o===a.column_name?"opacity-100":"opacity-0")})]},a.column_name))})]})]})})]})}function wt({cardType:s}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis1 - number"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis2 - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ye,{}),e.jsxRuntimeExports.jsx(zs,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ne,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function Te(){var o,i,l;const s=e.useEditorStore(a=>a.card.cfg),r=e.useEditorStore(a=>a.actions.setCardCfg),t=e.useEditorStore(a=>a.card.type);function n(a){var c;const x={datalabels:{display:a!=="none",align:a,anchor:a,clamp:!0}},m={...s,options:{...s==null?void 0:s.options,plugins:{...(c=s==null?void 0:s.options)==null?void 0:c.plugins,...x}}};r(m),console.log(a)}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxRuntimeExports.jsx("label",{className:"font-medium",children:"Data Labels"}),!["pyramid"].includes(t)&&e.jsxRuntimeExports.jsx(As,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(l=(i=(o=s==null?void 0:s.options)==null?void 0:o.plugins)==null?void 0:i.datalabels)==null?void 0:l.anchor,onValueChange:n,defaultValue:"none",children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:"Select position"})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Data Labels"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"start",children:"Start"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"center",children:"Center"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"end",children:"End"})]})})]})]})}function kt({cardType:s}){function r(t){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:t==="bubble"?"SELECT label, [group], x-axis, y-axis, radius FROM table":"SELECT label, [group], x-axis, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"group - category"}),e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),t==="bubble"&&e.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:i=>i.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:r(s)})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(Te,{})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ne,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}const Dt={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},It={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function Lt(){const s=e.useEditorStore(r=>r.card.type);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxRuntimeExports.jsx(e.Accordion,{className:" ",type:"single",collapsible:!0,children:Tt(s)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(s)&&e.jsxRuntimeExports.jsx(ye,{})}),!["kpi"].includes(s)&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsx(Te,{}),e.jsxRuntimeExports.jsx(ne,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})}function Tt(s){if(["line","bar"].includes(s))return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsx("p",{children:"Chart Query"})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(Dt,null,2)})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.jsxRuntimeExports.jsx("a",{className:"mx-1 text-blue-500 hover:underline",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(It,null,2)})]})]})]});if(s==="bubble")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsxRuntimeExports.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(s==="scatter")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(s))return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:[e.jsxRuntimeExports.jsx("span",{children:s==="polarArea"?"Polar":s.charAt(0).toUpperCase()+s.slice(1)})," ","chart query"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function At(){var x,m,c,f,h;const s=e.useEditorStore(u=>u.card.preferences),r=e.useEditorStore(u=>u.actions.setCardPreferences),t=e.useEditorStore(u=>u.actions.setNumberFormat);e.useEditorStore(u=>{var j,p;return(p=(j=u.card.preferences)==null?void 0:j.formatNumber)==null?void 0:p.decimalPlaces});const n=e.useEditorStore(u=>{var j,p;return(p=(j=u.card.preferences)==null?void 0:j.formatNumber)==null?void 0:p.locale}),o=e.useEditorStore(u=>{var j,p;return(p=(j=u.card.preferences)==null?void 0:j.formatNumber)==null?void 0:p.currency});e.useEditorStore(u=>u.actions.setFilterOnClickField);const i=e.useEditorStore(u=>{var j,p;return(p=(j=u.card.preferences)==null?void 0:j.formatNumber)==null?void 0:p.colorRanges})||[],l=e.useEditorStore(u=>u.actions.setColorRanges),a=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(u=>u.currency))];return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((x=s==null?void 0:s.formatNumber)!=null&&x.enabled),onCheckedChange:u=>{r({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:u}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((m=s==null?void 0:s.formatNumber)==null?void 0:m.enabled)===!0&&e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Locale"}),e.jsxRuntimeExports.jsxs(e.Select,{value:n||"none",onValueChange:u=>{var j,p,v;return t(((j=s==null?void 0:s.formatNumber)==null?void 0:j.decimalPlaces)||0,((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",u,((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Format"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),e.LOCALE_CURRENCY_PAIRS.map(u=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:u.locale,children:u.locale},u.locale))]})})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Currency"}),e.jsxRuntimeExports.jsxs(e.Select,{value:o||"none",onValueChange:u=>{var j,p,v;console.log("currency",u),t(((j=s==null?void 0:s.formatNumber)==null?void 0:j.decimalPlaces)||0,u==="none"?"":u,((p=s==null?void 0:s.formatNumber)==null?void 0:p.locale)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),a.map(u=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:u,children:u},u))]})})]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Decimals"}),e.jsxRuntimeExports.jsxs(e.Select,{value:((f=(c=s==null?void 0:s.formatNumber)==null?void 0:c.decimalPlaces)==null?void 0:f.toString())||"0",onValueChange:u=>{var j,p,v;return t(Number(u),((j=s==null?void 0:s.formatNumber)==null?void 0:j.currency)||"",((p=s==null?void 0:s.formatNumber)==null?void 0:p.locale)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:["0","1","2","3","4"].map(u=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:u,children:u},u))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.Input,{value:((h=s==null?void 0:s.formatNumber)==null?void 0:h.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:u=>{var j,p,v;return t(((j=s==null?void 0:s.formatNumber)==null?void 0:j.decimalPlaces)||0,((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.locale)||"",u.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:i,setColorRanges:l})]})]})}function zt(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{type:"single",collapsible:!0,children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"font-mono",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"current - number"}),e.jsxRuntimeExports.jsx("li",{children:"previous - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),e.jsxRuntimeExports.jsx("section",{className:"",children:e.jsxRuntimeExports.jsx(At,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}const Ot=[{label:"Mercator",value:"mercator"},{label:"Azimuthal Equidistant",value:"azimuthalEquidistant"},{label:"Gnomonic",value:"gnomonic"},{label:"Orthographic",value:"orthographic"},{label:"Stereographic",value:"stereographic"},{label:"Equal Earth",value:"equalEarth"},{label:"Albers",value:"albers"},{label:"Albers USA",value:"albersUsa"},{label:"Conic Conformal",value:"conicConformal"},{label:"Conic Equal Area",value:"conicEqualArea"},{label:"Conic Equidistant",value:"conicEquidistant"},{label:"Equirectangular",value:"equirectangular"},{label:"Transverse Mercator",value:"transverseMercator"},{label:"Natural Earth 1",value:"naturalEarth1"}],Mt=["blues","brBG","buGn","buPu","cividis","cool","cubehelixDefault","gnBu","greens","greys","inferno","magma","orRd","oranges","pRGn","piYG","plasma","puBu","puBuGn","puOr","puRd","purples","rainbow","rdBu","rdGy","rdPu","rdYlBu","rdYlGn","reds","sinebow","spectral","turbo","viridis","warm","ylGn","ylGnBu","ylOrBr","ylOrRd"],Ft=Mt.map(s=>({label:s,value:s}));function Vt(){var x,m,c,f,h,u,j,p,v,g,z,D,w,I,L,O,d,R;const s=e.useEditorStore(E=>E.card),r=(m=(x=s==null?void 0:s.preferences)==null?void 0:x.mapVisualOptions)==null?void 0:m.topoJsonUrl,[t,n]=b.useState(((f=(c=s==null?void 0:s.preferences)==null?void 0:c.mapVisualOptions)==null?void 0:f.customTopoJsonUrl)||""),{setCardPreferences:o}=e.useEditorActions(),{data:i}=e.useTopoJson(s),l=Object.keys((i==null?void 0:i.objects)||{}).map(E=>({label:E,value:E}))||[],a=[{label:"US States 10m",value:"https://unpkg.com/us-atlas/states-10m.json"},{label:"Countries 50m",value:"https://unpkg.com/world-atlas/countries-50m.json"},{label:"Custom",value:"custom"}];return e.jsxRuntimeExports.jsxs("div",{className:"p-6",children:[e.jsxRuntimeExports.jsx(de,{summary:"Map Query",children:e.jsxRuntimeExports.jsx("p",{className:"rounded-md bg-muted p-2 font-mono text-xs",children:"SELECT country, value FROM table"})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),e.jsxRuntimeExports.jsx(de,{open:!0,summary:"Settings",children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-3 px-2",children:[e.jsxRuntimeExports.jsx(W,{className:"h-9",options:a,onValueChange:E=>{console.log("value",E),o({...s.preferences,mapVisualOptions:{topoJsonUrl:E}})},value:r||"",label:"Select Map"}),r==="custom"&&e.jsxRuntimeExports.jsx(e.Input,{onChange:E=>{n(E.target.value)},onBlur:()=>{var E;console.log("onBlur",t),o({...s.preferences,mapVisualOptions:{...(E=s.preferences)==null?void 0:E.mapVisualOptions,customTopoJsonUrl:t}})},value:t,className:`h-9 w-full ${e.removeRing}`,placeholder:"Custom URL"}),i&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Map Object"}),e.jsxRuntimeExports.jsx(W,{className:"h-9",options:l,value:((u=(h=s.preferences)==null?void 0:h.mapVisualOptions)==null?void 0:u.objectKey)||"",label:"Map Object",onValueChange:E=>{var k;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,objectKey:E}})}})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Projection"}),e.jsxRuntimeExports.jsx(W,{className:"h-9",options:Ot,value:((p=(j=s.preferences)==null?void 0:j.mapVisualOptions)==null?void 0:p.projection)||"",label:"Projection",onValueChange:E=>{var k;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,projection:E}})}})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Colors"}),e.jsxRuntimeExports.jsx(W,{className:"h-9",options:Ft,value:((g=(v=s.preferences)==null?void 0:v.mapVisualOptions)==null?void 0:g.colorScale)||"",label:"Select Color Scale",onValueChange:E=>{var k;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,colorScale:E}})}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),e.jsxRuntimeExports.jsx(de,{className:"",summary:"Scale Options",children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Input,{className:`h-9 w-full ${e.removeRing}`,type:"number",step:.1,value:((D=(z=s.preferences)==null?void 0:z.mapVisualOptions)==null?void 0:D.projectionScale)||1,onChange:E=>{var k;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,projectionScale:Number(E.target.value)}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"X"}),e.jsxRuntimeExports.jsx(e.Input,{className:`h-9 w-full ${e.removeRing}`,type:"number",step:10,value:((L=(I=(w=s.preferences)==null?void 0:w.mapVisualOptions)==null?void 0:I.projectionOffset)==null?void 0:L[0])||0,onChange:E=>{var k,S,M,V;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,projectionOffset:[Number(E.target.value),((V=(M=(S=s.preferences)==null?void 0:S.mapVisualOptions)==null?void 0:M.projectionOffset)==null?void 0:V[1])||0]}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Y"}),e.jsxRuntimeExports.jsx(e.Input,{className:`h-9 w-full ${e.removeRing}`,type:"number",step:10,value:((R=(d=(O=s.preferences)==null?void 0:O.mapVisualOptions)==null?void 0:d.projectionOffset)==null?void 0:R[1])||0,onChange:E=>{var k,S,M,V;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,projectionOffset:[((V=(M=(S=s.preferences)==null?void 0:S.mapVisualOptions)==null?void 0:M.projectionOffset)==null?void 0:V[0])||0,Number(E.target.value)]}})}})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),e.jsxRuntimeExports.jsx(ne,{})]})}function qt(){var n;const s=e.useEditorStore(o=>o.card.preferences),{setCardPreferences:r}=e.useEditorStore(o=>o.actions);function t(o){r({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:o==="dynamic"}})}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:(n=s==null?void 0:s.textVisualOptions)!=null&&n.isDynamicText?"dynamic":"static",onValueChange:t,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"static",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Static"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function he({cardType:s,docContent:r,suffix:t="Chart"}){let n="pie-chart";return s==="radar"&&(n="radar-chart"),e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} ${t}`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{children:r||e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"measure - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:o=>o.stopPropagation(),className:"text-blue-700",href:`https://docs.semaphor.cloud/concepts/visuals#${n}`,children:"example"})," in the docs."]})]})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[s==="range"&&e.jsxRuntimeExports.jsx(ye,{}),s!=="text"&&e.jsxRuntimeExports.jsx(Te,{}),s==="text"&&e.jsxRuntimeExports.jsx(qt,{})]})]}),!["range","text"].includes(s)&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ne,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function Bt(){const s=e.useEditorStore(n=>{var o,i;return(i=(o=n==null?void 0:n.card)==null?void 0:o.preferences)==null?void 0:i.sortChart}),{setSortChart:r}=e.useEditorActions();function t(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Sort"}),e.jsxRuntimeExports.jsx(W,{className:"h-8",label:"Sort Chart",options:[{label:"None",value:"none"},{label:"ASC",value:"asc"},{label:"DESC",value:"desc"}],value:s||"none",onValueChange:n=>{r(n)}})]})}return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Stacked Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"stack by - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ye,{}),t(),e.jsxRuntimeExports.jsx(zs,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ne,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function _t({}){const s=e.useEditorStore(n=>{var o;return(o=n.card)==null?void 0:o.preferences}),r=e.useEditorStore(n=>n.actions.setCardPreferences),t=n=>{r({...s,allowDownload:n})};return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ne,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{onCheckedChange:t,id:"allow-download"}),e.jsxRuntimeExports.jsx("label",{htmlFor:"allow-download",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Allow Download"})]})]})}const Ht=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pyramid-chart",children:"example"})," in the docs."]})]}),Pt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT y-axis, label, range-from, range-to, range-value FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#range-charts",children:"example"})," in the docs."]})]}),Gt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT text FROM table limit 1"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#text-visual",children:"example"})," in the docs."]})]});function $t(){const s=e.useEditorStore(t=>t.card.type);function r(t){switch(t){case"stackedBar":case"stackedLine":return e.jsxRuntimeExports.jsx(Bt,{});case"pyramid":return e.jsxRuntimeExports.jsx(he,{docContent:Ht,cardType:t});case"kpi":return e.jsxRuntimeExports.jsx(zt,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(wt,{cardType:t});case"range":return e.jsxRuntimeExports.jsx(he,{docContent:Pt,cardType:t});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(he,{cardType:t});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(kt,{cardType:t});case"table":return e.jsxRuntimeExports.jsx(_t,{cardType:t});case"text":return e.jsxRuntimeExports.jsx(he,{docContent:Gt,cardType:t,suffix:"Visual"});case"map":return e.jsxRuntimeExports.jsx(Vt,{});case"custom":return e.jsxRuntimeExports.jsx(vt,{});default:return e.jsxRuntimeExports.jsx(Lt,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:r(s)})}function Ut(){const s=e.useEditorStore(r=>r.isShowingVisual);return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:[e.jsxRuntimeExports.jsx(e.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsxRuntimeExports.jsx(lt,{})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:s?e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"horizontal",children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:e.jsxRuntimeExports.jsx($t,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(_e,{})})]}):e.jsxRuntimeExports.jsx(_e,{})})]})}function Qt({authToken:s,onSave:r,onClose:t}){e.useDashboardStore(l=>l.themeStyle);const n=e.useEditorStore(l=>l.actions.setOnSave),o=e.useEditorStore(l=>l.actions.setOnClose),i=e.useDashboardStore(l=>l.actions.setAuthToken);return b.useEffect(()=>{r&&n(r),t&&o(t)},[r,n,t,o]),b.useEffect(()=>{s&&s.accessToken&&i(s)},[s,i]),e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:e.jsxRuntimeExports.jsxs(e.EditorPanel,{style:{},className:"rounded-none",role:"editor-panel",children:[e.jsxRuntimeExports.jsx(e.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsxRuntimeExports.jsx(fs,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(Ut,{})})]})})}function Kt(){e.useDashboardStore(l=>l.selectedCardId);const s=e.useDashboardStore(l=>l.selectedSheetId),{setIsVisualEditing:r}=e.useDashboardStore(l=>l.actions),t=e.useDashboardStore(l=>l.isVisualEditing),n=e.useDashboardStore(l=>l.actions.updateFrame);function o(l){s&&(n(s,l),r(!1))}function i(){r(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{"max-h-0 overflow-hidden":!t}),children:e.jsxRuntimeExports.jsx(Qt,{onSave:o,onClose:i})})}function Jt(){const s=e.useEditorStore(i=>i.selectedDatabaseName),r=e.useEditorStore(i=>i.selectedTableName),t=e.useDashboardStore(i=>i.dashboard.filters)||[],{columns:n}=te(),{assignFilter:o}=Os();return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"flex-1 basis-0 flex-col px-3",children:n==null?void 0:n.map(i=>{const l=t==null?void 0:t.find(a=>a.column===e.fmt(i.column_name)&&a.table===r&&a.database===s);return e.jsxRuntimeExports.jsx("div",{onClick:()=>o(i),className:e.cn("group flex cursor-pointer items-center justify-between border border-dashed border-background px-3 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":l}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(Es,{column:i}),e.jsxRuntimeExports.jsx("span",{children:i.column_name})]})},i.column_name)})})}function Wt(){e.useDashboardStore(r=>r.showFilters);const s=e.useDashboardStore(r=>r.actions.setShowFilters);return e.jsxRuntimeExports.jsxs("section",{className:"relative flex min-w-72 grow flex-col border-l px-1",children:[e.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"px-2 text-lg",children:"Filters"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>s(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{})})]}),e.jsxRuntimeExports.jsx("div",{className:"flex grow",children:e.jsxRuntimeExports.jsx(fs,{ColumnsComponent:()=>e.jsxRuntimeExports.jsx(Jt,{})})})]})}function Yt(){const s=e.useDashboardStore(n=>n.dashboard.filters),r=e.useDashboardStore(n=>n.theme),t=s==null?void 0:s.filter(n=>n.hide);return t!=null&&t.length?e.jsxRuntimeExports.jsx("div",{className:e.cn("mb-1 flex items-center gap-2 border-y pb-0.5",{"bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]":r==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":r==="dark"}),children:t==null?void 0:t.map(n=>e.jsxRuntimeExports.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[e.jsxRuntimeExports.jsx(e.FilterHeader,{filter:n}),e.jsxRuntimeExports.jsx(e.FilterComponent,{filter:n})]},n.id))}):null}function Xt(){const s=e.useDashboardStore(n=>n.showFilters),r=e.useDashboardStore(n=>n.isVisualEditing),t=e.useDashboardStore(n=>n.isDashboardEditing);return e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("",{"max-h-0 overflow-hidden":r,"flex grow":!r}),children:[e.jsxRuntimeExports.jsxs("section",{className:"flex grow flex-col",children:[t&&e.jsxRuntimeExports.jsx(Yt,{}),e.jsxRuntimeExports.jsx(e.DashboardTabs,{})]}),s&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(Wt,{})})]})}function Zt(){const s=e.useDashboardStore(n=>n.dashboard),r=e.useDashboardStore(n=>n.actions.setDashboard),t=e.useDashboardStore(n=>n.showDashboardJSON);return e.useDashboardStore(n=>n.actions.setShowDashboardJSON),e.jsxRuntimeExports.jsx("div",{className:e.cn(" p-2",{hidden:!t}),children:e.jsxRuntimeExports.jsx(e.de,{onChange:n=>{if(n)try{JSON.parse(n),r(JSON.parse(n))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(s,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function en({showControls:s=!1,showFooter:r=!0,...t}){return e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:t,children:[e.jsxRuntimeExports.jsx(e.Oe,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(Zt,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...t,children:[s&&e.jsxRuntimeExports.jsx(Ps,{}),e.jsxRuntimeExports.jsx(Kt,{}),e.jsxRuntimeExports.jsx(Xt,{})]})]})]})})}exports.Box=Pe;exports.Braces=Ge;exports.ChartArea=$e;exports.ChartColumnIncreasing=ge;exports.ChartLine=Re;exports.ChartNoAxesGantt=Ce;exports.ChartPie=Ne;exports.ChartScatter=we;exports.CircleX=Ue;exports.CopyPlus=Qe;exports.DashboardPlus=en;exports.Database=Ke;exports.EllipsisVertical=ke;exports.Eraser=Je;exports.EyeClosed=We;exports.Glasses=Ye;exports.Hammer=Xe;exports.Hash=Ze;exports.House=es;exports.Key=ss;exports.ListEnd=ts;exports.ListStart=ns;exports.ListX=rs;exports.LoaderCircle=se;exports.Map=De;exports.MessageSquareMore=os;exports.Network=is;exports.Play=as;exports.Plug2=ls;exports.Save=cs;exports.SelectComponent=ce;exports.Shapes=Ie;exports.ShieldQuestion=xs;exports.Sigma=us;exports.SwatchBook=ds;exports.Tag=ms;exports.ToggleLeft=ps;exports.Type=be;exports.User=js;exports.cleanCard=hs;exports.getDashbaordStateWithoutData=Le;exports.useEditorAside=te;
|
|
240
|
+
Visual Query Syntax: ${Ks}`,{data:L,isLoading:O,isFetching:d,isError:R,refetch:E}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(x==null?void 0:x.accessToken)||"",{user_content:`userContent: ${w} ${m?I:""}`}),enabled:!1});function k(N){if(N.toLowerCase().includes("bar"))j("bar");else if(N.toLowerCase().includes("line"))j("line");else if(N.toLowerCase().includes("bubble"))j("bubble");else if(N.toLowerCase().includes("scatter"))j("scatter");else if(N.toLowerCase().includes("stacked"))j("stackedBar");else if(N.toLowerCase().includes("pie"))j("pie");else if(N.toLowerCase().includes("donut")||N.toLowerCase().includes("doughnut"))j("doughnut");else if(N.toLowerCase().includes("radar"))j("radar");else return j("bar"),!1;return!0}b.useEffect(()=>{L&&v(N=>[...N,{role:"ai",content:L.response}])},[L]),b.useEffect(()=>{const N=setTimeout(()=>{var F;a.current&&(a.current.scroll({top:a.current.scrollHeight,behavior:"smooth"}),(F=l.current)==null||F.focus())},100);return()=>clearTimeout(N)},[p]);function S(){t&&(v(N=>[...N,{role:"user",content:t}]),k(t)&&c(!0),n(""),E())}b.useEffect(()=>{o&&(S(),i(!1))},[o,i]);const M={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},V={fontFamily:"monospace",fontSize:14,lineHeight:1.6},H={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},P={p:({node:N,...F})=>e.jsxRuntimeExports.jsx("p",{style:M,...F}),code:({node:N,...F})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...F}),pre:({node:N,...F})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:V,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:F.children}),e.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:_,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:B=>{const A=_(B);A&&(r(!1),f(A),u(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:N,...F})=>e.jsxRuntimeExports.jsx("li",{style:H,...F})};function _(N){const F=N.currentTarget.closest("pre");if(!F)return;const B=F.textContent||F.innerText;return navigator.clipboard.writeText(B).then(()=>console.log("Text copied to clipboard")).catch(A=>console.error("Error in copying text: ",A)),B}function G(){return p==null?void 0:p.map((N,F)=>N.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(js,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:N.content})]},F):N.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:P,children:L==null?void 0:L.response.replace(/DuckDB/gi,"Semaphor")},F):e.jsxRuntimeExports.jsx("div",{},F))}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",className:"w-full justify-start border font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",variant:"secondary",children:"Type your question here..."})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Assistant"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"What can I help you with?"})]}),e.jsxRuntimeExports.jsx("div",{ref:a,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:G()})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[e.jsxRuntimeExports.jsx(e.Textarea,{autoFocus:!0,ref:l,onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),n(""),S())},placeholder:"Type your question here...",onFocus:N=>{const F=N.target,B=F.value.length;F.setSelectionRange(B,B)},className:e.cn("max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"),disabled:O||d,value:t,onChange:N=>n(N.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:S,children:!O&&!d?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(se,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var gs={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ve=b.createContext&&b.createContext(gs),Ws=["attr","size","title"];function Ys(s,r){if(s==null)return{};var t=Xs(s,r),n,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);for(o=0;o<i.length;o++)n=i[o],!(r.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(s,n)&&(t[n]=s[n])}return t}function Xs(s,r){if(s==null)return{};var t={};for(var n in s)if(Object.prototype.hasOwnProperty.call(s,n)){if(r.indexOf(n)>=0)continue;t[n]=s[n]}return t}function Ee(){return Ee=Object.assign?Object.assign.bind():function(s){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n]=t[n])}return s},Ee.apply(this,arguments)}function qe(s,r){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);r&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(s,o).enumerable})),t.push.apply(t,n)}return t}function fe(s){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?qe(Object(t),!0).forEach(function(n){Zs(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):qe(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function Zs(s,r,t){return r=et(r),r in s?Object.defineProperty(s,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[r]=t,s}function et(s){var r=st(s,"string");return typeof r=="symbol"?r:r+""}function st(s,r){if(typeof s!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,r||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(s)}function Rs(s){return s&&s.map((r,t)=>b.createElement(r.tag,fe({key:t},r.attr),Rs(r.child)))}function Y(s){return r=>b.createElement(tt,Ee({attr:fe({},s.attr)},r),Rs(s.child))}function tt(s){var r=t=>{var{attr:n,size:o,title:i}=s,l=Ys(s,Ws),a=o||t.size||"1em",x;return t.className&&(x=t.className),s.className&&(x=(x?x+" ":"")+s.className),b.createElement("svg",Ee({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,n,l,{className:x,style:fe(fe({color:s.color||t.color},t.style),s.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),i&&b.createElement("title",null,i),s.children)};return Ve!==void 0?b.createElement(Ve.Consumer,null,t=>r(t)):r(gs)}function nt(s){return Y({tag:"svg",attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(s)}function rt({sql:s}){return e.jsxRuntimeExports.jsxs(e.HoverCard,{children:[e.jsxRuntimeExports.jsx(e.HoverCardTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{variant:"link",className:"h-5 p-0",children:e.jsxRuntimeExports.jsx(e.Info,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxRuntimeExports.jsx(e.HoverCardContent,{align:"end",className:"w-full min-w-fit max-w-[700px] p-3 pt-2",children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-xs font-semibold",children:"Resolved Query"}),e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col space-y-2",children:e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"max-h-[250px] min-h-0 overflow-scroll",children:e.jsxRuntimeExports.jsx("p",{className:"overflow-auto rounded-md bg-muted p-2 font-mono text-xs leading-relaxed",children:s})})})]})})]})}function bs(s){const{theme:r}=e.useTheme(),t=e.useDashboardStore(p=>p.theme),n=e.useEditorStore(p=>p.frame),o=e.useEditorStore(p=>p.card),i=e.useEditorStore(p=>p.activeTabCardId),l=e.Le(),{refetch:a}=e.useDashboardCardQuery(o),{updateCardTab:x,setRunSql:m}=e.useEditorActions(),c=b.useRef(),f=b.useRef({}),h=n.cards.find(p=>p.id===i),u=b.useCallback(()=>{let p="";return s==="python"&&(p=(h==null?void 0:h.python)||e.PYTHON_DEFAULT_CODE),s==="sql"&&(p=(h==null?void 0:h.sql)||""),p},[s,h]);b.useEffect(()=>{if(i&&o.id&&o.id!==i){if(c.current&&l){const p=c.current.getModel();p&&(f.current[o.id]=p);let v=f.current[i];if(!v){const g=u();v=l.editor.createModel(g,s),f.current[i]=v}c.current.setModel(v)}x(i,o),m(!0)}},[i,o,x,l,m,s,u]),b.useEffect(()=>{if(!l)return;const p=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",v=t==="system"?p:t;l.editor.defineTheme("default",{base:v==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":v==="light"?"#ffffff":e.hslStringToHex("240 10% 10%")}}),l.editor.setTheme("default")},[r,t,l]),b.useEffect(()=>{const p=c.current;p&&l&&o&&p.addCommand(l.KeyMod.Shift|l.KeyCode.Enter,function(){return a(),!1})},[l,a,o]);function j(p,v){if(c.current=p,!f.current[o.id]){const g=p.getModel(),z=u();f.current[o.id]=g||(v==null?void 0:v.editor.createModel(z,s))||p.getModel()}p.setModel(f.current[o.id])}return{handleEditorDidMount:j}}function ot(){const s=e.useEditorStore(l=>l.card.sql),r=e.useEditorStore(l=>l.sqlGen),{setCardSql:t,setSqlGen:n}=e.useEditorActions(),{handleEditorDidMount:o}=bs("sql");function i(l){t(l),e.isObjectEmpty(r)||n({})}return e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",className:"pt-3",onChange:i,value:s||"",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"sql",onMount:o})}function it(){const s=e.useEditorStore(o=>o.card.python),{setCardPython:r}=e.useEditorActions(),{handleEditorDidMount:t}=bs("python");function n(o){r(o)}return e.jsxRuntimeExports.jsx(e.Ft,{className:"pt-3",theme:"default",onChange:n,value:s||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"python",onMount:t})}function at(){const s=e.useDashboardStore(i=>i.dashboard.filters),r=e.useDashboardStore(i=>i.filterValues),t=e.useDashboardStore(i=>i.selectedSheetId),n=s==null?void 0:s.filter(i=>i.sheetId===t||!i.sheetId),o=r==null?void 0:r.filter(i=>(n==null?void 0:n.some(l=>l.id===i.filterId))||i.filterId.endsWith(t));return e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",defaultLanguage:"json",className:"mt-1 min-h-[220px]",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"}})}function lt(){const[s,r]=b.useState({queryKey:[],queryData:null}),t=e.useQueryClient(),[n,o]=b.useState(!1),[i,l]=b.useState(!1),[a,x]=b.useState(!1),[m,c]=b.useState(""),[f,h]=b.useState(!1),u=e.useEditorStore(C=>C.frame),j=e.useEditorStore(C=>C.card),p=e.useEditorStore(C=>C.isShowingVisual),v=e.useEditorStore(C=>C.selectedConnectionId),g=e.useEditorStore(C=>C.selectedDatabaseName),z=e.useEditorStore(C=>C.selectedDatamodelId),D=e.useEditorStore(C=>C.selectedSchemaName),w=e.useEditorStore(C=>C.selectedTableName),I=e.useEditorStore(C=>{var Q;return(Q=C==null?void 0:C.card)==null?void 0:Q.sql}),L=e.useEditorStore(C=>C.applyFilters),{setCardCustomCfg:O,setQueryResultColumns:d,setCardSql:R,setQueryError:E,setPythonStdOut:k,setCardPreferences:S,setCardType:M}=e.useEditorActions(),V=e.useEditorStore(C=>C.onSave),H=e.useEditorStore(C=>C.onClose),P=e.useEditorStore(C=>C.actions.setSqlGen),_=e.useEditorStore(C=>C.runSql),G=e.useEditorStore(C=>C.actions.setRunSql),N=e.useEditorStore(C=>C.actions.setCardCfg),F=e.useEditorStore(C=>C.actions.setIsSqlRunning),{data:B,isLoading:A,isFetching:T,isSuccess:K,isError:q,error:$,queryKey:U,refetch:X}=e.useDashboardCardQuery(j);b.useEffect(()=>{if(B&&(B.rowLimitExceeded&&e.ce.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),k((B==null?void 0:B.output)||""),B.records.length>0)){const{dimensionKeys:C}=e.getKeys(B.records);d(C)}},[B,d,k]),b.useEffect(()=>{(A||T)&&F(!0),(q||K)&&F(!1),q?(E($.message),d([]),k("")):E("")},[A,T,B,k,q,K,F,d,E,$]),b.useEffect(()=>{_&&(t.getQueryData(U)||X(),G(!1))},[_,X,G,U,t]);function re(){const C=t.getQueryData(U);s.queryData||r({queryKey:U,queryData:C}),t.setQueryData(U,null),R(""),P({}),N(void 0),O(""),S({}),M("bar")}function Z(C,Q){if(C.length===0)return"";if(Q){const ee=C.find(J=>J.id===Q);if(ee){const J=ee.tabTitle;if(J=="All__Header")return C[0].id;if(J&&J.endsWith("__Header")){const ve=J.split("__")[0],me=C.find(pe=>pe.tabTitle===ve);return me?me.id:C[0].id}return Q}}return C[0].id}function oe(){let C=I;I&&!I.includes("{{")&&(C=Us(I),R(C));const Q={...j,lastSelectedSchema:D,lastSelectedDatamodelId:z,lastSelectedDatabase:g,lastSelectedTable:w,connectionId:v,type:p?j.type:"table",sql:C,customCfg:p?j.customCfg:null},ee=u.cards.map(ue=>ue.id===j.id?Q:ue),J={...u,cards:ee,activeCardId:Z(ee,u.activeCardId)};V==null||V(J)}function ie(){const{queryKey:C,queryData:Q}=s;C&&Q&&t.setQueryData(C,Q),H==null||H()}function ae(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[i&&e.jsxRuntimeExports.jsx("div",{className:"relative flex w-1/3 min-w-0 grow overflow-hidden border-l p-1 text-xs",role:"editor-filter-container",children:e.jsxRuntimeExports.jsxs("div",{className:"w-[99%]",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"ml-6 text-xs font-semibold",children:"Filters"}),i&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>l(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(at,{})]})}),!i&&e.jsxRuntimeExports.jsx(e.Filter,{onClick:()=>l(!0),className:e.cn("absolute bottom-4 right-6 h-3 w-3 text-foreground/50 hover:cursor-pointer hover:text-foreground",{"font-bold text-red-800":L})})]})}function le(){return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"1",order:1,defaultSize:n?20:100,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{id:"sql-container",className:"relative flex w-[99%]",children:e.jsxRuntimeExports.jsx(ot,{})}),n&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-xs text-muted-foreground/70",children:"sql"})]}),n&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{id:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsxRuntimeExports.jsx(it,{})}),e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-xs text-muted-foreground/70",children:"python"})]})]})]})}return e.jsxRuntimeExports.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxRuntimeExports.jsxs("div",{className:"relative flex grow justify-between overflow-y-scroll",children:[le(),ae()]}),e.jsxRuntimeExports.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{title:"Shift + Enter",disabled:A||T,onClick:()=>{X()},className:"shrink-0",size:"sm",variant:"outline",children:[A||T?e.jsxRuntimeExports.jsx(se,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(as,{className:"mr-2 h-4 w-4"}),"Run"]}),q&&e.jsxRuntimeExports.jsx(Qs,{error:$.message,setShowAIDialog:x,setTriggerAIRun:h,setUserInputforAI:c}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:re,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(Je,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:n,onPressedChange:C=>o(C),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(nt,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(Js,{open:a,setOpen:x,userInput:m,triggerAIRun:f,setTriggerAIRun:h,setUserInput:C=>c(C)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[(B==null?void 0:B.sql)&&e.jsxRuntimeExports.jsx(rt,{sql:B.sql}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:ie,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:oe,size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]})]})]})]})}function ct({data:s}){var l;const[r,t]=b.useState([]),o=Object.keys(s[0]).map(a=>({accessorKey:a,header:({column:x})=>{const m=x.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>x.toggleSorting(x.getIsSorted()==="asc"),children:[a,m==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):m==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),i=e.useReactTable({data:s,columns:o,getCoreRowModel:e.getCoreRowModel(),getPaginationRowModel:e.getPaginationRowModel(),onSortingChange:t,getSortedRowModel:e.getSortedRowModel(),manualPagination:!0,state:{sorting:r}});return e.jsxRuntimeExports.jsx("div",{className:"font-mono text-xs text-foreground/95",children:e.jsxRuntimeExports.jsxs("table",{className:"w-full",children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:i.getHeaderGroups().map(a=>e.jsxRuntimeExports.jsx(e.TableRow,{children:a.headers.map(x=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 h-11 bg-muted font-semibold",children:x.isPlaceholder?null:e.flexRender(x.column.columnDef.header,x.getContext())},x.id))},a.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(l=i.getRowModel().rows)!=null&&l.length?i.getRowModel().rows.map(a=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":a.getIsSelected()&&"selected",children:a.getVisibleCells().map(x=>e.jsxRuntimeExports.jsx(e.TableCell,{className:"py-3",children:e.flexRender(x.column.columnDef.cell,x.getContext())},x.id))},a.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:o.length,className:"h-24 text-center",children:"No results."})})})]})})}function xt({card:s}){var g,z,D,w,I,L,O,d,R,E,k;const[r,t]=b.useState(!1),[n,o]=b.useState([]),{authToken:i}=e.useSemaphorContext(),l=e.getTokenParams(i==null?void 0:i.accessToken),a=e.useDashboardStore(S=>S.themeStyle),x={colors:((z=(g=a==null?void 0:a.chart)==null?void 0:g.dataset)==null?void 0:z.backgroundColor)||[]};(D=s.customCardPreferences)!=null&&D.inputData;const{getCard:m}=e.useCustomVisual(((w=s.customCardPreferences)==null?void 0:w.url)||""),c=((I=s.customCardPreferences)==null?void 0:I.visualType)||"single",f=e.useEditorStore(S=>S.frame);e.useEditorActions();const{data:h}=e.useDashboardCardQuery(s),u=b.useCallback((S,M)=>{o(V=>({...V,[S]:M}))},[]);if(!((L=s.customCardPreferences)!=null&&L.componentName))return null;const j=m((O=s.customCardPreferences)==null?void 0:O.componentName);function p(S){t(S)}const v=Object.keys(((d=s.customCardPreferences)==null?void 0:d.dataInputCardIds)||{}).map(S=>{var H,P,_;const M=(P=(H=s.customCardPreferences)==null?void 0:H.dataInputCardIds)==null?void 0:P[S].cardId,V=(_=f==null?void 0:f.cards)==null?void 0:_.find(G=>G.id===M);return V||null});return e.jsxRuntimeExports.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:e.jsxRuntimeExports.jsxs(b.Suspense,{fallback:e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),children:[j&&c==="single"&&e.jsxRuntimeExports.jsx(j,{params:l,theme:x,settings:(R=s.customCardPreferences)==null?void 0:R.settings,onDataChange:u,data:(h==null?void 0:h.records)||[]}),j&&c==="multiple"&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[Object.keys(((E=s.customCardPreferences)==null?void 0:E.dataInputCardIds)||{}).map(S=>{var H,P,_;const M=(P=(H=s.customCardPreferences)==null?void 0:H.dataInputCardIds)==null?void 0:P[S].cardId,V=(_=f==null?void 0:f.cards)==null?void 0:_.find(G=>G.id===M);if(V)return e.jsxRuntimeExports.jsx(e.MultiInputEmptyRenderer,{onLoadingStatus:p,onDataChange:u,dataInputIndex:S,card:V},V.id+S)}),e.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-2",children:e.jsxRuntimeExports.jsx(j,{theme:x,onDataChange:u,settings:v.map(S=>{var M;return(M=S==null?void 0:S.customCardPreferences)==null?void 0:M.settings}),data:v.map(S=>S!=null&&S.id?n==null?void 0:n[S.id]:[])})})]})]},(k=s.customCardPreferences)==null?void 0:k.componentName)})}function ys({className:s,...r}){var v;const t=e.useEditorStore(g=>g.card),n=((v=t.customCardPreferences)==null?void 0:v.showCardHeader)??!0,o=e.useEditorStore(g=>g.frame),i=e.useDashboardStore(g=>g.dashboard.filters);e.useEditorStore(g=>g.actions.setRunSql);const{updateFilter:l}=e.useDashboardActions(),a=i==null?void 0:i.find(g=>g.id===o.filterId),{data:x,isLoading:m,isFetching:c}=e.useDashboardCardQuery(t),{setCard:f}=e.useEditorActions(),{data:h}=e.useTopoJson(t);if(!t.id)return null;let u;x!=null&&x.records&&(x==null?void 0:x.records.length)>0&&(u=e.createChartConfig({data:x==null?void 0:x.records,cardType:t.type,cfg:t.cfg,customCfg:t.customCfg,preferences:t.preferences,topoJson:h}));function j(g){return e.jsxRuntimeExports.jsx(xt,{card:g})}function p(){var g;if(x!=null&&x.records&&(x==null?void 0:x.records.length)===0&&!m&&!c)return e.jsxRuntimeExports.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[e.jsxRuntimeExports.jsx(e.TreePalm,{className:"size-8 text-muted-foreground"}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"No records to display"})]});if(t.type==="custom")return j(t);if(!["table","custom"].includes(t.type)&&u)return e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:u},JSON.stringify(u)+JSON.stringify(t.preferences)+((g=t==null?void 0:t.preferences)==null?void 0:g.customVisualCode));if(t.type==="table"&&(x!=null&&x.records)&&(x==null?void 0:x.records.length)>0)return e.jsxRuntimeExports.jsxs(e.ScrollArea,{className:"relative mb-2 flex h-full min-h-0 w-full flex-1 grow basis-0",children:[e.jsxRuntimeExports.jsx(e.TableVisual,{card:t,data:x==null?void 0:x.records}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]})}return e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",s),...r,children:[n&&e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"flex flex-row items-start justify-between py-4",children:[e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsx(e.Editable,{text:t.title,onSave:g=>f({...t,title:g}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-5",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:t.title||"Edit title..."})})},t.title),e.jsxRuntimeExports.jsx(e.Editable,{text:t.description||"",onSave:g=>f({...t,description:g}),children:e.jsxRuntimeExports.jsx(e.CardDescription,{children:t.description||"Edit description..."})},t.description)]}),a&&e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Editable,{className:"my-1",text:a.title||a.column,onSave:g=>l({...a,title:g}),children:e.jsxRuntimeExports.jsx(e.Label,{children:a.title})}),e.jsxRuntimeExports.jsx(e.FilterComponent,{filter:a})]})]}),e.jsxRuntimeExports.jsx(e.CardContent,{className:"flex grow flex-col",children:p()})]})}const Be=({language:s,value:r,onChange:t})=>e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:s,value:r,onChange:t}),ut=({card:s})=>e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Customize Card"}),e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:e.jsxRuntimeExports.jsx(ss,{onClick:()=>navigator.clipboard.writeText(s.id),className:"size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:"Copy Card ID"})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogDescription,{children:["See the configuration options and documentation",e.jsxRuntimeExports.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),dt=({defaultConfig:s,customCode:r,customConfig:t,onConfigChange:n,onCodeChange:o})=>e.jsxRuntimeExports.jsxs(e.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[e.jsxRuntimeExports.jsxs(e.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsxRuntimeExports.jsxs(e.TabsTrigger,{value:"custom-config",children:[t&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),t?"Custom Config":"Default Config"]}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{value:"output",children:"Output"}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{value:"custom-code",children:"Custom Code"})]}),e.jsxRuntimeExports.jsx(e.TabsContent,{value:"output",className:"mt-0 grow rounded-b border border-t-0 p-2",children:e.jsxRuntimeExports.jsx(e.Textarea,{readOnly:!0,value:s,className:"h-full resize-none border-none font-mono focus-visible:ring-0"})}),e.jsxRuntimeExports.jsx(e.TabsContent,{value:"custom-config",className:"mt-0 grow rounded-b border border-t-0",children:e.jsxRuntimeExports.jsx(Be,{language:"json",value:t,onChange:n})}),e.jsxRuntimeExports.jsx(e.TabsContent,{value:"custom-code",className:"mt-0 grow rounded-b border border-t-0",children:e.jsxRuntimeExports.jsx(Be,{language:"javascript",value:r,onChange:o})})]}),mt=({error:s,hasCustomConfig:r,onReset:t,onApply:n,onClose:o})=>e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:s}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!r,onClick:t,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:n,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:o,variant:"outline",children:"Close"})]});function pt(){const[s,r]=b.useState(!1),[t,n]=b.useState(""),[o,i]=b.useState(""),[l,a]=b.useState(""),[x,m]=b.useState(""),c=e.useEditorStore(w=>w.card),f=e.useEditorStore(w=>w.card.customCfg),{data:h}=e.useDashboardCardQuery(c),{data:u}=e.useTopoJson(c),{setCardCustomCfg:j,setCustomVisualCode:p}=e.useEditorActions(),v=w=>{var I,L;return JSON.stringify({...w,data:{...w.data,datasets:(L=(I=w.data)==null?void 0:I.datasets)==null?void 0:L.map(O=>({...O,data:[]}))}},null,2)},g=()=>{var I,L;if(!((I=h==null?void 0:h.records)!=null&&I.length))return;const w=e.createChartConfig({data:h.records,cardType:c.type,cfg:c.cfg,preferences:c.preferences,topoJson:u});w&&(n(v(w)),a(((L=c.preferences)==null?void 0:L.customVisualCode)||""),i(f?JSON.stringify(f,null,2):""))},z=()=>{try{if(l&&p(l),o){const w=JSON.parse(o);j(w),m("")}}catch{m("Invalid JSON configuration")}},D=()=>{if(f){const w=e._.merge(e._.cloneDeep(c.cfg),f);return v(w)}return t?v(JSON.parse(t)):""};return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{onClick:g,size:"sm",variant:"outline",className:f?"border-foreground/50 dark:border-foreground/70":"",children:e.jsxRuntimeExports.jsx(e.Settings,{className:"h-4 w-4"})})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"max-h-[70vh] min-h-[70vh] overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsxRuntimeExports.jsx(ut,{card:c}),e.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.FallbackEditorCard,children:e.jsxRuntimeExports.jsx(ys,{className:"w-1/2 rounded shadow-none"})}),e.jsxRuntimeExports.jsx(dt,{defaultConfig:t,customCode:l,customConfig:D(),onConfigChange:w=>i(w??""),onCodeChange:w=>a(w??"")})]}),e.jsxRuntimeExports.jsx(mt,{error:x,hasCustomConfig:!!f,onReset:()=>{i(""),j(null)},onApply:z,onClose:()=>r(!1)})]})]})}function vs(s){return Y({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M926.8 397.1l-396-288a31.81 31.81 0 0 0-37.6 0l-396 288a31.99 31.99 0 0 0-11.6 35.8l151.3 466a32 32 0 0 0 30.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z"},child:[]}]})(s)}function Ss(s){return Y({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24a8,8,0,0,0-8,8V88a8,8,0,0,0,8,8,32,32,0,1,1-27.72,16,8,8,0,0,0-2.93-10.93l-48.5-28A8,8,0,0,0,37.92,76,104,104,0,1,0,128,24ZM48.09,91.1,83,111.26A48.09,48.09,0,0,0,80,128c0,1.53.08,3,.22,4.52L41.28,143A88.16,88.16,0,0,1,48.09,91.1Zm-2.67,67.31,39-10.44A48.1,48.1,0,0,0,120,175.32v40.31A88.2,88.2,0,0,1,45.42,158.41ZM136,215.63V175.32a48,48,0,0,0,0-94.65V40.36a88,88,0,0,1,0,175.27Z"},child:[]}]})(s)}function Cs(s){return Y({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm87.63,96H191.48A64.1,64.1,0,0,0,136,64.52V40.37A88.13,88.13,0,0,1,215.63,120ZM120,120H80.68A48.09,48.09,0,0,1,120,80.68Zm0,16v39.32A48.09,48.09,0,0,1,80.68,136Zm16,0h39.32A48.09,48.09,0,0,1,136,175.32Zm0-16V80.68A48.09,48.09,0,0,1,175.32,120ZM120,40.37V64.52A64.1,64.1,0,0,0,64.52,120H40.37A88.13,88.13,0,0,1,120,40.37ZM40.37,136H64.52A64.1,64.1,0,0,0,120,191.48v24.15A88.13,88.13,0,0,1,40.37,136ZM136,215.63V191.48A64.1,64.1,0,0,0,191.48,136h24.15A88.13,88.13,0,0,1,136,215.63Z"},child:[]}]})(s)}function Ns(s){return Y({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0"},child:[]}]})(s)}function ws(s){return Y({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m2 19.99 7.5-7.51 4 4 7.09-7.97L22 9.92l-8.5 9.56-4-4-6 6.01-1.5-1.5zm1.5-4.5 6-6.01 4 4L22 3.92l-1.41-1.41-7.09 7.97-4-4L2 13.99l1.5 1.5z"},child:[]}]})(s)}function ks(s){return Y({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M4 9h4v11H4zM4 4h4v4H4zM10 7h4v4h-4zM16 10h4v4h-4zM16 15h4v5h-4zM10 12h4v8h-4z"},child:[]}]})(s)}function Ds(s){return Y({tag:"svg",attr:{version:"1.2",baseProfile:"tiny",viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M4 18c-.552 0-1-.448-1-1v-6.382l-.553.276c-.495.248-1.095.046-1.342-.447-.247-.494-.046-1.094.448-1.342l2-1c.31-.155.678-.139.973.044.294.183.474.504.474.851v8c0 .552-.448 1-1 1zM13 18h-5c-.404 0-.769-.244-.924-.617-.155-.374-.069-.804.217-1.09l4-4c.254-.254.394-.591.394-.95 0-.358-.14-.695-.394-.949-.508-.508-1.39-.508-1.9.001-.253.252-.393.589-.393.948 0 .552-.448 1-1 1s-1-.448-1-1c0-.894.348-1.733.98-2.364 1.265-1.263 3.464-1.263 4.727.001.632.631.979 1.471.979 2.363 0 .893-.348 1.733-.979 2.364l-2.293 2.293h2.586c.552 0 1 .448 1 1s-.448 1-1 1zM20.955 12.377c.338-.457.545-1.016.545-1.627 0-1.517-1.234-2.75-2.75-2.75-1.031 0-1.966.569-2.44 1.484-.254.49-.063 1.094.428 1.348.49.254 1.094.062 1.348-.428.128-.249.383-.404.664-.404.414 0 .75.336.75.75s-.336.75-.75.75c-.552 0-1 .448-1 1s.448 1 1 1c.689 0 1.25.561 1.25 1.25s-.561 1.25-1.25 1.25-1.25-.561-1.25-1.25c0-.552-.448-1-1-1s-1 .448-1 1c0 1.792 1.458 3.25 3.25 3.25s3.25-1.458 3.25-3.25c0-.939-.406-1.779-1.045-2.373z"},child:[]}]})(s)}function Is(s){return Y({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M217 25v14h78V25h-78zm0 32v46h14V71h50v32h14V57h-78zm32 32v14h14V89h-14zm-64 32v46h30v-46h-30zm48 0v14h46v-14h-46zm64 0v46h30v-46h-30zm-64 32v14h46v-14h-46zm-80 32v46h62v-46h-62zm80 0v14h46v-14h-46zm64 0v46h62v-46h-62zm-64 32v14h46v-14h-46zm-112 32v46h94v-46h-94zm112 0v14h46v-14h-46zm64 0v46h94v-46h-94zm-64 32v14h46v-14h-46zM89 313v46h126v-46H89zm144 0v14h46v-14h-46zm64 0v46h126v-46H297zm-64 32v14h46v-14h-46zM57 377v46h158v-46H57zm176 0v14h46v-14h-46zm64 0v46h158v-46H297zm-64 32v14h46v-14h-46zM25 441v46h190v-46H25zm208 0v14h46v-14h-46zm64 0v46h190v-46H297zm-64 32v14h46v-14h-46z"},child:[]}]})(s)}function Ls(s){const[r,t]=b.useState(null);return b.useEffect(()=>{s&&(async()=>{const i=(await Promise.resolve().then(()=>require("./lucide-react-D6rsddg8.js")))[s];t(i)})()},[s]),r}function Ts(){const{authToken:s}=e.useSemaphorContext(),{data:r,isLoading:t,isFetching:n,isError:o}=e.useQuery({queryKey:["plugins",s==null?void 0:s.accessToken],queryFn:()=>e.getPlugins(s==null?void 0:s.accessToken)});return{data:r,isLoading:t,isFetching:n,isError:o}}function jt({onChartTypeChange:s}){const[r,t]=b.useState([]),{data:n}=Ts();return b.useEffect(()=>{(async()=>{var i;if(n){const a=(await Promise.all((i=n==null?void 0:n.plugins)==null?void 0:i.map(async x=>(await e.loadManifest(x.value)).visuals.map(f=>({name:f.name,icon:f.icon,url:x.value}))))).flat();t(a)}})()},[n]),r.length===0?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.Separator,{className:"my-2"}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-4 place-items-center",children:r.map((o,i)=>e.jsxRuntimeExports.jsx(ht,{text:o.name,onClick:()=>s("custom",o),icon:o.icon},o.url+o.name+i))})]})}const ht=({text:s,icon:r,onClick:t})=>{const n=Ls(r||""),o=s.charAt(0).toUpperCase();return e.jsxRuntimeExports.jsx(e.Button,{onClick:t,title:s,variant:"ghost",children:n?e.jsxRuntimeExports.jsx(n,{className:"h-4 w-4"}):o})};function Et(){var c,f;const[s,r]=b.useState(!1),t=e.useEditorStore(h=>h.card),n=t.type,{setCardType:o,setCardPreferences:i,setChartOrientation:l}=e.useEditorStore(h=>h.actions),{setCardCustomCfg:a,setCustomCardPreferences:x}=e.useEditorActions();function m(h,u){a(null),i({}),o(h),u&&x({type:"component",visualType:"single",url:u.url,componentName:u.name,icon:u.icon}),r(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:s,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(ft,{className:"h-4 w-4",chartType:n,customIcon:(c=t.customCardPreferences)==null?void 0:c.icon,componentName:(f=t.customCardPreferences)==null?void 0:f.componentName})})}),e.jsxRuntimeExports.jsxs(e.PopoverContent,{className:"w-50",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-4 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(ge,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Re,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ks,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ws,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(we,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ns,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ne,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ss,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(vs,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Cs,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Is,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ce,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ds,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(be,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("map"),variant:"ghost",children:e.jsxRuntimeExports.jsx(De,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>m("custom"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ie,{className:"size-4"})})]}),e.jsxRuntimeExports.jsx(jt,{onChartTypeChange:m})]})]})}function ft({chartType:s,className:r,customIcon:t,componentName:n}){const o=Ls(t||"");switch(s){case"bar":return e.jsxRuntimeExports.jsx(ge,{className:r});case"line":return e.jsxRuntimeExports.jsx(Re,{className:r});case"pie":return e.jsxRuntimeExports.jsx(Ne,{className:r});case"radar":return e.jsxRuntimeExports.jsx(vs,{className:r});case"scatter":return e.jsxRuntimeExports.jsx(we,{className:r});case"bubble":return e.jsxRuntimeExports.jsx(Ns,{className:r});case"doughnut":return e.jsxRuntimeExports.jsx(Ss,{className:r});case"stackedBar":return e.jsxRuntimeExports.jsx(ks,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(ws,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(Cs,{className:r});case"pyramid":return e.jsxRuntimeExports.jsx(Is,{className:r});case"range":return e.jsxRuntimeExports.jsx(Ce,{className:r});case"kpi":return e.jsxRuntimeExports.jsx(Ds,{className:r});case"text":return e.jsxRuntimeExports.jsx(be,{className:r});case"map":return e.jsxRuntimeExports.jsx(De,{className:r});case"custom":return t&&o?e.jsxRuntimeExports.jsx(o,{className:r}):n?n==null?void 0:n.charAt(0).toUpperCase():e.jsxRuntimeExports.jsx(Ie,{className:r});default:return e.jsxRuntimeExports.jsx(e.Table,{className:r})}}function gt(){var r;const s=e.useEditorStore(t=>t.card);return(r=s.customCardPreferences)==null||r.showCardHeader,e.useEditorActions(),e.jsxRuntimeExports.jsxs(e.DropdownMenu,{children:[e.jsxRuntimeExports.jsx(e.DropdownMenuTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(ke,{className:"size-4 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsx(e.DropdownMenuContent,{align:"start",className:"w-40 text-muted-foreground",children:e.jsxRuntimeExports.jsxs(e.DropdownMenuItem,{onClick:()=>{navigator.clipboard.writeText(s.id),e.ce.success("Card ID copied to clipboard")},className:"cursor-pointer space-x-2",children:[e.jsxRuntimeExports.jsx(e.IdCard,{className:"size-5"}),e.jsxRuntimeExports.jsx("span",{children:"Copy Card ID"})]})})]})}function _e(){const s=e.useEditorStore(d=>d.frame),r=e.useEditorStore(d=>d.card),t=e.useEditorStore(d=>d.isShowingVisual),n=e.useEditorStore(d=>d.isSqlRunning),o=e.useEditorStore(d=>d.queryError),i=e.useEditorStore(d=>d.pythonStdOut);e.useEditorStore(d=>d.actions.setRunSql);const{setFrame:l,setCard:a,updateCardInFrame:x,setActiveTabCardId:m}=e.useEditorActions(),{data:c,isLoading:f,isFetching:h}=e.useDashboardCardQuery(r);if(!r)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function u(){const d={connectionId:r.connectionId,id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]};j(d)}function j(d){const R={...s,cards:[...s.cards,d],activeCardId:d.id};l(R),m(d.id)}function p(){const d={...r,id:e.v4(),title:`${r.title} Copy`,tabTitle:`${r.tabTitle||r.title} Copy`};j(d)}function v(d){const R=s.cards.filter(S=>S.id!==d),E=R[0],k={...s,cards:R,activeCardId:E.id};l(k),a(E)}function g(d){m(d)}const z=(d,R)=>{console.log("handleDragStart",R),d.dataTransfer.setData("tabIndex",R.toString())},D=d=>{d.preventDefault()},w=(d,R)=>{const E=d.dataTransfer.getData("tabIndex");if(E===R.toString())return;const k=Array.from(s.cards),[S]=k.splice(parseInt(E),1);k.splice(R,0,S),l({...s,cards:k})};function I(d,R){return d.cards.length===1&&(R.displayTab===!0||R.displayTab===void 0)||d.activeCardId!==R.id&&(R.displayTab===!0||R.displayTab===void 0)?null:e.jsxRuntimeExports.jsx("div",{onClick:()=>{const E=R.displayTab===void 0?!1:!R.displayTab;a({...R,displayTab:E}),x({...R,displayTab:E})},children:R.displayTab===!0||R.displayTab===void 0?e.jsxRuntimeExports.jsx(e.Eye,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"}):e.jsxRuntimeExports.jsx(We,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"})})}function L(){return e.jsxRuntimeExports.jsxs(e.Tabs,{onValueChange:g,value:s.activeCardId,className:"flex grow flex-col",children:[s.cards.map(d=>e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow",value:d.id,children:O()},d.id)),e.jsxRuntimeExports.jsx(e.TabsList,{className:"group mx-6 justify-between",children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[s.cards.map((d,R)=>e.jsxRuntimeExports.jsx(e.Editable,{text:d.tabTitle||d.title,onSave:E=>{a({...r,tabTitle:E}),x({...r,tabTitle:E})},children:e.jsxRuntimeExports.jsxs(e.TabsTrigger,{draggable:!0,onDragStart:E=>z(E,R),onDragOver:D,onDrop:E=>w(E,R),className:"",value:d.id,children:[I(s,d),d.tabTitle||d.title,s.activeCardId===d.id&&s.cards.length>1&&e.jsxRuntimeExports.jsx(e.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>v(d.id)})]})},d.id)),e.jsxRuntimeExports.jsx(e.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:u,children:e.jsxRuntimeExports.jsx(e.Plus,{className:"h-4 w-4"})}),e.jsxRuntimeExports.jsx(e.Button,{className:"invisible ml-1 h-8 px-2 hover:bg-muted-foreground/50 group-hover:visible",variant:"outline",onClick:p,children:e.jsxRuntimeExports.jsx(Qe,{className:"h-4 w-4"})})]})})]})}function O(){return r.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.KPICard,{card:r,data:c==null?void 0:c.records})})}):r.type==="text"?e.jsxRuntimeExports.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"mx-3 my-6 h-[300px] overflow-y-auto break-words px-3",children:e.jsxRuntimeExports.jsx(e.TextCard,{isLoading:n,card:r,data:c==null?void 0:c.records})})})}):e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.FallbackEditorCard,children:e.jsxRuntimeExports.jsx(ys,{className:"grow border-none shadow-none"})})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col py-3",children:[(f||h)&&e.jsxRuntimeExports.jsx(se,{className:"absolute bottom-0 left-0 right-0 top-0 z-50 m-auto h-10 w-10 animate-spin text-foreground/10"}),e.jsxRuntimeExports.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[t&&e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsx(Et,{}),!["table","custom"].includes(r.type)&&e.jsxRuntimeExports.jsx(pt,{}),e.jsxRuntimeExports.jsx(gt,{})]}),e.jsxRuntimeExports.jsx(bt,{})]}),t?L():e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{className:"px-6",direction:"horizontal",children:[i&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.ResizablePanel,{id:"1",order:1,defaultSize:30,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:i&&e.jsxRuntimeExports.jsx(Rt,{})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{})]}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{id:"2",order:2,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:e.jsxRuntimeExports.jsxs(e.ScrollArea,{className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:[(c==null?void 0:c.records)&&(c==null?void 0:c.records.length)>0&&e.jsxRuntimeExports.jsx(ct,{data:(c==null?void 0:c.records)||[]}),o&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-xs",children:o}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]})})]})]})}function Rt(){const s=e.useEditorStore(t=>t.pythonStdOut);if(!s)return null;const r=s.replace(/\n/g,"<br>");return e.jsxRuntimeExports.jsxs("div",{className:"relative flex w-full flex-col border-r",children:[e.jsxRuntimeExports.jsx("div",{className:"sticky top-0 flex max-h-11 min-h-11 grow items-center border-b bg-muted px-3 font-mono text-xs font-semibold text-foreground/70",children:"Python Output"}),e.jsxRuntimeExports.jsxs(e.ScrollArea,{className:"overflow-y-auto px-2 pt-1 font-mono text-xs text-foreground/90",children:[e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:r}}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]})]})}function bt(){const s=e.useEditorStore(t=>t.isShowingVisual),r=e.useEditorStore(t=>t.actions.setIsShowingVisual);return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"visualize",children:"Chart"}),e.jsxRuntimeExports.jsx(e.Switch,{checked:s,onCheckedChange:()=>r(!s),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function yt({options:s,value:r,onValueChange:t}){return e.jsxRuntimeExports.jsx(e.RadioGroup,{value:r,onValueChange:t,className:"flex gap-4",defaultValue:s[0].value,children:s.map(n=>e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:n.value,id:n.value}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:n.value,children:n.label})]},n.value))})}function W({label:s,options:r,value:t,onValueChange:n,className:o}){return e.jsxRuntimeExports.jsxs(e.Select,{value:t,onValueChange:n,children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:e.cn("w-full focus:ring-0 focus:ring-offset-0",o),children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:s})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:s}),r.map(i=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:i.value,children:i.label},i.value))]})})]})}function de({children:s,summary:r,open:t,className:n}){return e.jsxRuntimeExports.jsxs("details",{open:t,className:e.cn("space-y-4 [&_summary>svg]:open:-rotate-180",n),children:[e.jsxRuntimeExports.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-4",children:[e.jsxRuntimeExports.jsx(e.Label,{children:r}),e.jsxRuntimeExports.jsx(e.ChevronUp,{className:"h-4 w-4"})]}),e.jsxRuntimeExports.jsx("div",{className:"transition-all ease-in-out",children:s})]})}function vt(){var p,v;const s=e.useEditorStore(g=>g.card.customCardPreferences),{data:r}=Ts(),t=(r==null?void 0:r.plugins)||[],n=e.useEditorStore(g=>g.card),o=e.useEditorStore(g=>g.frame),i=(s==null?void 0:s.visualType)||"single",{setCustomCardPreferences:l}=e.useEditorActions(),{components:a,manifest:x}=e.useCustomVisual((s==null?void 0:s.url)||""),m=(p=x==null?void 0:x.visuals)==null?void 0:p.find(g=>g.name===(s==null?void 0:s.componentName));function c(g,z){if(!s)return;const w={...(s==null?void 0:s.dataInputCardIds)||{},[g]:{cardId:z,hookRef:null}};l({...s,dataInputCardIds:w})}function f(g){var D,w;const z=(D=o==null?void 0:o.cards)==null?void 0:D.filter(I=>{var L;return((L=I==null?void 0:I.customCardPreferences)==null?void 0:L.visualType)!=="multiple"}).map(I=>({value:I.id,label:I.tabTitle||I.title}));return e.jsxRuntimeExports.jsx("div",{className:"space-y-2",children:(w=g==null?void 0:g.dataInputs)==null?void 0:w.map((I,L)=>{var O,d;return e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-10 gap-2",children:[e.jsxRuntimeExports.jsx("div",{className:"col-span-4 flex items-center",children:I}),e.jsxRuntimeExports.jsx(W,{className:"col-span-6 h-8 w-full justify-between",label:"",options:z||[],value:((d=(O=s==null?void 0:s.dataInputCardIds)==null?void 0:O[L])==null?void 0:d.cardId)||"",onValueChange:R=>c(L,R)})]},L+Math.random())})})}function h(g,z,D=[]){var w,I;return s?g==="input"?e.jsxRuntimeExports.jsx(e.Input,{className:`h-8 w-full ${e.removeRing}`,value:((w=s==null?void 0:s.settings)==null?void 0:w[z])||"",onChange:L=>{l({...s,settings:{...s==null?void 0:s.settings,[z]:L.target.value}})}},z):g==="select"?e.jsxRuntimeExports.jsx(W,{className:"h-8 w-full",label:"",options:D,value:((I=s==null?void 0:s.settings)==null?void 0:I[z])||"",onValueChange:L=>{l({...s,settings:{...s==null?void 0:s.settings,[z]:L}})}}):null:null}function u(g){const z=Object.entries((g==null?void 0:g.settings)||{});return e.jsxRuntimeExports.jsx("div",{className:"space-y-3",children:z.map(([D,w])=>e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:w.title}),h(w.ui,D,w.options)]},D))})}function j(g){s&&l({...s,visualType:g,componentName:""})}return e.jsxRuntimeExports.jsxs("div",{className:"p-6",children:[e.jsxRuntimeExports.jsx(de,{summary:"Plugin Settings",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 text-sm",children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsxRuntimeExports.jsx("div",{className:"space-y-2",children:e.jsxRuntimeExports.jsx("div",{className:"px-2",children:e.jsxRuntimeExports.jsx(W,{className:"h-8 w-full",label:"",options:t,value:(s==null?void 0:s.url)||"",onValueChange:g=>l({...s||{url:"",componentName:""},url:g})})})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&e.jsxRuntimeExports.jsx(yt,{options:[{value:"single",label:"Single Visual"},{value:"multiple",label:"Multi-Visual"}],value:i,onValueChange:j}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&s&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Component"}),e.jsxRuntimeExports.jsx("div",{className:"space-y-2 px-2",children:a&&e.jsxRuntimeExports.jsx(W,{className:"h-8 w-full",label:"",options:(a==null?void 0:a.filter(g=>g.type===i).map(g=>({value:g.name,label:g.name})))||[],value:s.componentName,onValueChange:g=>{console.log("changing value",g),l({...s,componentName:g})}})})]})})]})})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),((v=n==null?void 0:n.customCardPreferences)==null?void 0:v.componentName)&&e.jsxRuntimeExports.jsxs(de,{summary:"Component Settings",children:[m&&m.dataInputs&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Input Mapping"}),e.jsxRuntimeExports.jsx("div",{className:"px-2",children:f(m)})]}),m&&m.settings&&e.jsxRuntimeExports.jsx("div",{className:"space-y-3",children:e.jsxRuntimeExports.jsx("div",{className:"px-2",children:u(m)})})]})]})}function ne(){const[s,r]=b.useState([]);e.useEditorStore(c=>c.card.cfg);const t=e.useEditorStore(c=>c.card.preferences),{setCardCfg:n,setFilterOnClickColumnIndex:o,setCardPreferences:i}=e.useEditorStore(c=>c.actions),l=e.useEditorStore(c=>c.queryResultColumns);e.useEditorStore(c=>{var f;return(f=c.card.preferences)==null?void 0:f.filterOnClickColumnIndex}),b.useEffect(()=>{l&&r(new Array(l.length).fill(!1))},[l]);function a(c,f){var h,u;f?t!=null&&t.onClickFilter&&((h=t==null?void 0:t.onClickFilter)==null?void 0:h.length)>0?i({...t,onClickFilter:[...t.onClickFilter,{columnIndex:c,expression:""}]}):i({...t,onClickFilter:[{columnIndex:c,expression:""}]}):(i({...t,onClickFilter:(u=t==null?void 0:t.onClickFilter)==null?void 0:u.filter(j=>j.columnIndex!==c)}),r(j=>{const p=[...j];return p[c]=!1,p}))}function x(c,f){var u;const h=(u=t==null?void 0:t.onClickFilter)==null?void 0:u.map(j=>j.columnIndex===c?{...j,expression:f.target.value}:j);i({...t,onClickFilter:h})}function m(c){var f,h,u,j;if(s!=null&&s[c]||(h=(f=t==null?void 0:t.onClickFilter)==null?void 0:f.find(p=>p.columnIndex===c))!=null&&h.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(j=(u=t==null?void 0:t.onClickFilter)==null?void 0:u.find(p=>p.columnIndex===c))==null?void 0:j.expression,onChange:p=>x(c,p),type:"text",className:"h-9 w-full font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"Expression"})}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"On Click"}),l==null?void 0:l.map((c,f)=>{var h,u;return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 group flex items-center justify-between space-y-2",children:e.jsxRuntimeExports.jsxs("div",{className:"grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2 py-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((h=t==null?void 0:t.onClickFilter)!=null&&h.find(j=>j.columnIndex===f)),onCheckedChange:j=>a(f,j)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:c}),e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:((u=t==null?void 0:t.onClickFilter)==null?void 0:u.find(j=>j.columnIndex===f))&&e.jsxRuntimeExports.jsx(e.Pencil,{onClick:()=>{r(j=>{const p=[...j];return p[f]=!j[f],p})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),m(f)]})},c)})]})}function ye(){var l,a,x;const s=e.useEditorStore(m=>m.card.preferences),r=e.useEditorStore(m=>m.card.cfg),{setCardCfg:t,setCardPreferences:n,setChartOrientation:o}=e.useEditorStore(m=>m.actions);(l=r==null?void 0:r.options)!=null&&l.indexAxis;function i(m){o(m)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((a=s==null?void 0:s.chartOptions)==null?void 0:a.indexAxis)||((x=r==null?void 0:r.options)==null?void 0:x.indexAxis)||"x",onValueChange:i,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"x",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"y",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const je="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function He(s,r){var n,o,i;const t=e.getNumberAxis(s,r);return((i=(o=(n=s==null?void 0:s.chartOptions)==null?void 0:n.scales)==null?void 0:o[t])==null?void 0:i.type)||"linear"}function As(){var P,_,G,N,F,B;const[s,r]=b.useState(!1),t=e.useEditorStore(A=>{var T;return(T=A.card)==null?void 0:T.preferences}),n=e.useEditorStore(A=>{var T;return(T=A.card)==null?void 0:T.cfg}),o=e.getNumberAxis(t,n),[i,l]=b.useState(He(t)),[a,x]=b.useState(((G=(_=(P=t==null?void 0:t.chartOptions)==null?void 0:P.scales)==null?void 0:_[o])==null?void 0:G.min)||""),[m,c]=b.useState(((B=(F=(N=t==null?void 0:t.chartOptions)==null?void 0:N.scales)==null?void 0:F[o])==null?void 0:B.max)||""),[f,h]=b.useState(a||m?"custom":"auto"),[u,j]=b.useState(""),[p,v]=b.useState(0),[g,z]=b.useState(""),[D,w]=b.useState(""),[I,L]=b.useState(""),O=e.useEditorStore(A=>A.actions.setCardPreferences),{updateCardInFrame:d}=e.useEditorActions(),R=e.useEditorStore(A=>A.card),E=e.useEditorStore(A=>{var T;return(T=A.card)==null?void 0:T.type}),k=["pie","doughnut","polarArea"].includes(E);b.useEffect(()=>{var A,T,K,q,$,U,X,re,Z,oe,ie,ae,le,C;l(He(t)),x(((K=(T=(A=t==null?void 0:t.chartOptions)==null?void 0:A.scales)==null?void 0:T[o])==null?void 0:K.min)===0?0:""),c(((U=($=(q=t==null?void 0:t.chartOptions)==null?void 0:q.scales)==null?void 0:$[o])==null?void 0:U.max)||""),j(((oe=(Z=(re=(X=t==null?void 0:t.chartOptions)==null?void 0:X.scales)==null?void 0:re[o])==null?void 0:Z.ticks)==null?void 0:oe.stepSize)||""),v(((ie=t==null?void 0:t.numberAxisFormat)==null?void 0:ie.decimalPlaces)||0),z(((ae=t==null?void 0:t.numberAxisFormat)==null?void 0:ae.suffix)||""),w(((le=t==null?void 0:t.numberAxisFormat)==null?void 0:le.currency)||""),L(((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.locale)||"")},[s,t,o]);function S(A,T){return T===""||/^[0-9\b]+$/.test(T)?Number(T):Number(A)}function M(){const A=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(T=>T.currency))];return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsxRuntimeExports.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxRuntimeExports.jsxs(e.Select,{value:D||"none",onValueChange:T=>w(T==="none"?"":T),children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),A.map(T=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:T,children:T},T))]})})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:I,onValueChange:T=>L(T),children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Locale"}),e.LOCALE_CURRENCY_PAIRS.map(T=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:T.locale,children:T.locale},T.locale))]})})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsxRuntimeExports.jsx(e.Input,{value:p,onChange:T=>v(Number(T.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${je}`})]})]})}function V(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"range",children:"Range"}),e.jsxRuntimeExports.jsx(e.Input,{id:"min",value:a,onChange:A=>x(T=>S(T,A.target.value)),className:`col-span-1 h-8 w-full ${je}`}),e.jsxRuntimeExports.jsx(e.Input,{value:m,onChange:A=>c(T=>S(T,A.target.value)),id:"max",className:`col-span-1 h-8 w-full ${je}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsxRuntimeExports.jsx(e.Input,{value:u,onChange:A=>j(T=>S(T,A.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${je}`})]})]})}function H(){var q;let A={};f==="custom"&&(A={min:a,max:m,ticks:{stepSize:u}});const T={...t||{},chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(q=t==null?void 0:t.chartOptions)==null?void 0:q.scales,[o]:{type:i,...i==="linear"?A:{}}}},numberAxisFormat:{decimalPlaces:p,suffix:g,currency:D,locale:I}};console.log(T),O(T);const K={...R,preferences:T};d(K)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:A=>r(A),children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"max-w-65",children:e.jsxRuntimeExports.jsxs("div",{className:"grid gap-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale",children:"Type"}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:k,value:i,onValueChange:A=>l(A),children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{id:"type",children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Option"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"linear",children:"Linear"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),i=="linear"&&e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxRuntimeExports.jsxs(e.RadioGroup,{disabled:k,id:"scale-option",value:f,onValueChange:A=>h(A),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"auto",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"custom",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),f==="custom"&&i=="linear"&&V(),M(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:H,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function St({idx:s}){var a;const r=e.useEditorStore(x=>{var m;return(m=x.card)==null?void 0:m.preferences}),t=e.useEditorStore(x=>{var m;return(m=x.card.preferences)==null?void 0:m.datasetOptions}),n=e.useEditorStore(x=>x.actions.setCardPreferences),o=(a=r==null?void 0:r.chartOptions)==null?void 0:a.indexAxis,i=t==null?void 0:t.find(x=>x.idx===s);function l(x,m){(x==="end"||x==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const c={display:x!=="none",align:x,anchor:x,clamp:!0};if(!i)n({...r,datasetOptions:[...t||[],{idx:m,datalabels:c}]});else{const f={...i};f.datalabels=c;const h=t==null?void 0:t.map(u=>u.idx===m?f:u);n({...r,datasetOptions:h})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(ms,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-fit p-1",children:e.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>l("none",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(e.X,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>l("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(ts,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>l("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(rs,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>l("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(ns,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function zs(){const s=e.useEditorStore(m=>m.card),r=e.useEditorStore(m=>{var c,f,h;return(h=(f=(c=m==null?void 0:m.card)==null?void 0:c.preferences)==null?void 0:f.chartOptions)==null?void 0:h.indexAxis}),{data:t}=e.useDashboardCardQuery(s),n=r==="y"?"Y axis":"X axis",o=r==="y"?"X axis":"Y axis",{keys:i,metricKeys:l,dimensionKeys:a}=e.getKeys((t==null?void 0:t.records)||[]);let x=l;if(["stackedBar","stackedLine"].includes(s.type)){const m=e.pivotData({dataArray:(t==null?void 0:t.records)||[],groupKey:a[0],pivotKey:a[1],valueKey:x[0]}),{metricKeys:c}=e.getKeys(m);x=c}return i.length===0?null:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:n}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:e.jsxRuntimeExports.jsx("p",{children:a[0]})})})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxRuntimeExports.jsx(e.Label,{children:o}),e.jsxRuntimeExports.jsx(As,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:x.map((m,c)=>e.jsxRuntimeExports.jsx(Ct,{col:m,idx:c},m))})]})]})}function Ct({col:s,idx:r}){const t=e.useEditorStore(a=>{var x;return(x=a.card)==null?void 0:x.preferences}),n=e.useEditorStore(a=>{var x;return(x=a.card.preferences)==null?void 0:x.datasetOptions}),o=n==null?void 0:n.find(a=>a.idx===r),{setCardPreferences:i}=e.useEditorStore(a=>a.actions);function l(a){if(!o)i({...t,datasetOptions:[...n||[],{idx:r,type:a==="area"?"line":a,fill:a==="area"?"origin":""}]});else{const x={...o};x.type=a==="area"?"line":a,x.fill=a==="area"?"origin":"";const m=n==null?void 0:n.map(c=>c.idx===r?x:c);i({...t,datasetOptions:m})}}return e.jsxRuntimeExports.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[e.jsxRuntimeExports.jsx("p",{children:s}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsx(ge,{onClick:()=>l("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Re,{onClick:()=>l("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx($e,{onClick:()=>l("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(St,{idx:r})]})]})}function Os(){const s=e.useEditorStore(h=>h.selectedConnectionId),r=e.useEditorStore(h=>h.selectedDatamodelId),t=e.useEditorStore(h=>h.selectedDatabaseName),n=e.useEditorStore(h=>h.selectedSchemaName),o=e.useEditorStore(h=>h.selectedTableName),i=e.useDashboardStore(h=>h.dashboard.filters)||[],l=e.useDashboardStore(h=>h.actions.addFilter),a=e.useDashboardStore(h=>h.actions.removeFilter),{removeFilterValues:x}=e.useDashboardActions(),{modelItems:m,tableName:c}=te();function f(h,u="dashboard"){var L;const j=e.fmt(h.column_name),p=e.fmt(t||""),v=e.fmt(n||""),g=e.fmt(c);let z=e.getQualifiedTableName(v,g),D=`${z}.${j}`;const w=(L=m==null?void 0:m.find(O=>O.id===r))==null?void 0:L.name;r&&r!=="none"&&(D=`${e.DATAMODEL_NAMESPCACE}.${w}.${j}`,z=`${e.DATAMODEL_NAMESPCACE}.${w}`);const I=i==null?void 0:i.find(O=>O.column===D&&O.table===g&&(O.database===p||O.database===t));if(I)x(I.id),a(I.id);else{const O=e.v4();return c==="api"&&s?(l({location:u,id:O,column:D,title:h.column_name,dataType:h.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:e.getDefaultFilterSql(h.data_type,z,j)}),O):(l({id:O,location:u,column:D,title:h.column_name,dataType:h.data_type,table:o||"",database:t||"",connectionId:s||"",operation:"in",sql:e.getDefaultFilterSql(h.data_type,z,j)}),O)}}return{assignFilter:f}}function xe(){const s=e.useDashboardStore(a=>a.dashboard.filters),r=e.useEditorStore(a=>a.frame),{setFrame:t}=e.useEditorActions(),{columns:n}=te(),{assignFilter:o}=Os();function i(a){const x=o(a,"frame");t({...r,filterId:x})}const l=s==null?void 0:s.find(a=>a.id===r.filterId);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Card Filter"}),e.jsxRuntimeExports.jsx(Nt,{onSelect:i,columns:n}),l&&e.jsxRuntimeExports.jsx(e.FilterHeader,{filter:l})]})}function Nt({columns:s,onSelect:r}){var l;const[t,n]=Fe.useState(!1),[o,i]=Fe.useState("");return e.jsxRuntimeExports.jsxs(e.Popover,{open:t,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs(e.Button,{size:"sm",variant:"outline",role:"combobox","aria-expanded":t,className:"w-full justify-between font-normal",children:[o?(l=s.find(a=>a.column_name===o))==null?void 0:l.column_name:"Select Column...",e.jsxRuntimeExports.jsx(e.CaretSortIcon,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-[200px] p-0",children:e.jsxRuntimeExports.jsxs(e.Command,{children:[e.jsxRuntimeExports.jsx(e.CommandInput,{placeholder:"Search column",className:"h-9"}),e.jsxRuntimeExports.jsxs(e.CommandList,{children:[e.jsxRuntimeExports.jsx(e.CommandEmpty,{children:"No framework found."}),e.jsxRuntimeExports.jsx(e.CommandGroup,{children:s.map(a=>e.jsxRuntimeExports.jsxs(e.CommandItem,{value:a.column_name,onSelect:x=>{const m=x===o?"":x;i(m),n(!1),m&&r(a)},children:[a.column_name,e.jsxRuntimeExports.jsx(e.CheckIcon,{className:e.cn("ml-auto h-4 w-4",o===a.column_name?"opacity-100":"opacity-0")})]},a.column_name))})]})]})})]})}function wt({cardType:s}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis1 - number"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis2 - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ye,{}),e.jsxRuntimeExports.jsx(zs,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ne,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function Te(){var o,i,l;const s=e.useEditorStore(a=>a.card.cfg),r=e.useEditorStore(a=>a.actions.setCardCfg),t=e.useEditorStore(a=>a.card.type);function n(a){var c;const x={datalabels:{display:a!=="none",align:a,anchor:a,clamp:!0}},m={...s,options:{...s==null?void 0:s.options,plugins:{...(c=s==null?void 0:s.options)==null?void 0:c.plugins,...x}}};r(m),console.log(a)}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxRuntimeExports.jsx("label",{className:"font-medium",children:"Data Labels"}),!["pyramid"].includes(t)&&e.jsxRuntimeExports.jsx(As,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(l=(i=(o=s==null?void 0:s.options)==null?void 0:o.plugins)==null?void 0:i.datalabels)==null?void 0:l.anchor,onValueChange:n,defaultValue:"none",children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:"Select position"})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Data Labels"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"start",children:"Start"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"center",children:"Center"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"end",children:"End"})]})})]})]})}function kt({cardType:s}){function r(t){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:t==="bubble"?"SELECT label, [group], x-axis, y-axis, radius FROM table":"SELECT label, [group], x-axis, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"group - category"}),e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),t==="bubble"&&e.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:i=>i.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:r(s)})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(Te,{})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ne,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}const Dt={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},It={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function Lt(){const s=e.useEditorStore(r=>r.card.type);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxRuntimeExports.jsx(e.Accordion,{className:" ",type:"single",collapsible:!0,children:Tt(s)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(s)&&e.jsxRuntimeExports.jsx(ye,{})}),!["kpi"].includes(s)&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsx(Te,{}),e.jsxRuntimeExports.jsx(ne,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})}function Tt(s){if(["line","bar"].includes(s))return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsx("p",{children:"Chart Query"})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(Dt,null,2)})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.jsxRuntimeExports.jsx("a",{className:"mx-1 text-blue-500 hover:underline",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(It,null,2)})]})]})]});if(s==="bubble")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsxRuntimeExports.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(s==="scatter")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(s))return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:[e.jsxRuntimeExports.jsx("span",{children:s==="polarArea"?"Polar":s.charAt(0).toUpperCase()+s.slice(1)})," ","chart query"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function At(){var x,m,c,f,h;const s=e.useEditorStore(u=>u.card.preferences),r=e.useEditorStore(u=>u.actions.setCardPreferences),t=e.useEditorStore(u=>u.actions.setNumberFormat);e.useEditorStore(u=>{var j,p;return(p=(j=u.card.preferences)==null?void 0:j.formatNumber)==null?void 0:p.decimalPlaces});const n=e.useEditorStore(u=>{var j,p;return(p=(j=u.card.preferences)==null?void 0:j.formatNumber)==null?void 0:p.locale}),o=e.useEditorStore(u=>{var j,p;return(p=(j=u.card.preferences)==null?void 0:j.formatNumber)==null?void 0:p.currency});e.useEditorStore(u=>u.actions.setFilterOnClickField);const i=e.useEditorStore(u=>{var j,p;return(p=(j=u.card.preferences)==null?void 0:j.formatNumber)==null?void 0:p.colorRanges})||[],l=e.useEditorStore(u=>u.actions.setColorRanges),a=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(u=>u.currency))];return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((x=s==null?void 0:s.formatNumber)!=null&&x.enabled),onCheckedChange:u=>{r({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:u}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((m=s==null?void 0:s.formatNumber)==null?void 0:m.enabled)===!0&&e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Locale"}),e.jsxRuntimeExports.jsxs(e.Select,{value:n||"none",onValueChange:u=>{var j,p,v;return t(((j=s==null?void 0:s.formatNumber)==null?void 0:j.decimalPlaces)||0,((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",u,((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Format"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),e.LOCALE_CURRENCY_PAIRS.map(u=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:u.locale,children:u.locale},u.locale))]})})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Currency"}),e.jsxRuntimeExports.jsxs(e.Select,{value:o||"none",onValueChange:u=>{var j,p,v;console.log("currency",u),t(((j=s==null?void 0:s.formatNumber)==null?void 0:j.decimalPlaces)||0,u==="none"?"":u,((p=s==null?void 0:s.formatNumber)==null?void 0:p.locale)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),a.map(u=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:u,children:u},u))]})})]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Decimals"}),e.jsxRuntimeExports.jsxs(e.Select,{value:((f=(c=s==null?void 0:s.formatNumber)==null?void 0:c.decimalPlaces)==null?void 0:f.toString())||"0",onValueChange:u=>{var j,p,v;return t(Number(u),((j=s==null?void 0:s.formatNumber)==null?void 0:j.currency)||"",((p=s==null?void 0:s.formatNumber)==null?void 0:p.locale)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:["0","1","2","3","4"].map(u=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:u,children:u},u))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.Input,{value:((h=s==null?void 0:s.formatNumber)==null?void 0:h.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:u=>{var j,p,v;return t(((j=s==null?void 0:s.formatNumber)==null?void 0:j.decimalPlaces)||0,((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.locale)||"",u.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:i,setColorRanges:l})]})]})}function zt(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{type:"single",collapsible:!0,children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"font-mono",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"current - number"}),e.jsxRuntimeExports.jsx("li",{children:"previous - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),e.jsxRuntimeExports.jsx("section",{className:"",children:e.jsxRuntimeExports.jsx(At,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}const Ot=[{label:"Mercator",value:"mercator"},{label:"Azimuthal Equidistant",value:"azimuthalEquidistant"},{label:"Gnomonic",value:"gnomonic"},{label:"Orthographic",value:"orthographic"},{label:"Stereographic",value:"stereographic"},{label:"Equal Earth",value:"equalEarth"},{label:"Albers",value:"albers"},{label:"Albers USA",value:"albersUsa"},{label:"Conic Conformal",value:"conicConformal"},{label:"Conic Equal Area",value:"conicEqualArea"},{label:"Conic Equidistant",value:"conicEquidistant"},{label:"Equirectangular",value:"equirectangular"},{label:"Transverse Mercator",value:"transverseMercator"},{label:"Natural Earth 1",value:"naturalEarth1"}],Mt=["blues","brBG","buGn","buPu","cividis","cool","cubehelixDefault","gnBu","greens","greys","inferno","magma","orRd","oranges","pRGn","piYG","plasma","puBu","puBuGn","puOr","puRd","purples","rainbow","rdBu","rdGy","rdPu","rdYlBu","rdYlGn","reds","sinebow","spectral","turbo","viridis","warm","ylGn","ylGnBu","ylOrBr","ylOrRd"],Ft=Mt.map(s=>({label:s,value:s}));function Vt(){var x,m,c,f,h,u,j,p,v,g,z,D,w,I,L,O,d,R;const s=e.useEditorStore(E=>E.card),r=(m=(x=s==null?void 0:s.preferences)==null?void 0:x.mapVisualOptions)==null?void 0:m.topoJsonUrl,[t,n]=b.useState(((f=(c=s==null?void 0:s.preferences)==null?void 0:c.mapVisualOptions)==null?void 0:f.customTopoJsonUrl)||""),{setCardPreferences:o}=e.useEditorActions(),{data:i}=e.useTopoJson(s),l=Object.keys((i==null?void 0:i.objects)||{}).map(E=>({label:E,value:E}))||[],a=[{label:"US States 10m",value:"https://unpkg.com/us-atlas/states-10m.json"},{label:"Countries 50m",value:"https://unpkg.com/world-atlas/countries-50m.json"},{label:"Custom",value:"custom"}];return e.jsxRuntimeExports.jsxs("div",{className:"p-6",children:[e.jsxRuntimeExports.jsx(de,{summary:"Map Query",children:e.jsxRuntimeExports.jsx("p",{className:"rounded-md bg-muted p-2 font-mono text-xs",children:"SELECT country, value FROM table"})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),e.jsxRuntimeExports.jsx(de,{open:!0,summary:"Settings",children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-3 px-2",children:[e.jsxRuntimeExports.jsx(W,{className:"h-9",options:a,onValueChange:E=>{console.log("value",E),o({...s.preferences,mapVisualOptions:{topoJsonUrl:E}})},value:r||"",label:"Select Map"}),r==="custom"&&e.jsxRuntimeExports.jsx(e.Input,{onChange:E=>{n(E.target.value)},onBlur:()=>{var E;console.log("onBlur",t),o({...s.preferences,mapVisualOptions:{...(E=s.preferences)==null?void 0:E.mapVisualOptions,customTopoJsonUrl:t}})},value:t,className:`h-9 w-full ${e.removeRing}`,placeholder:"Custom URL"}),i&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Map Object"}),e.jsxRuntimeExports.jsx(W,{className:"h-9",options:l,value:((u=(h=s.preferences)==null?void 0:h.mapVisualOptions)==null?void 0:u.objectKey)||"",label:"Map Object",onValueChange:E=>{var k;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,objectKey:E}})}})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Projection"}),e.jsxRuntimeExports.jsx(W,{className:"h-9",options:Ot,value:((p=(j=s.preferences)==null?void 0:j.mapVisualOptions)==null?void 0:p.projection)||"",label:"Projection",onValueChange:E=>{var k;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,projection:E}})}})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Colors"}),e.jsxRuntimeExports.jsx(W,{className:"h-9",options:Ft,value:((g=(v=s.preferences)==null?void 0:v.mapVisualOptions)==null?void 0:g.colorScale)||"",label:"Select Color Scale",onValueChange:E=>{var k;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,colorScale:E}})}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),e.jsxRuntimeExports.jsx(de,{className:"",summary:"Scale Options",children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Input,{className:`h-9 w-full ${e.removeRing}`,type:"number",step:.1,value:((D=(z=s.preferences)==null?void 0:z.mapVisualOptions)==null?void 0:D.projectionScale)||1,onChange:E=>{var k;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,projectionScale:Number(E.target.value)}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"X"}),e.jsxRuntimeExports.jsx(e.Input,{className:`h-9 w-full ${e.removeRing}`,type:"number",step:10,value:((L=(I=(w=s.preferences)==null?void 0:w.mapVisualOptions)==null?void 0:I.projectionOffset)==null?void 0:L[0])||0,onChange:E=>{var k,S,M,V;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,projectionOffset:[Number(E.target.value),((V=(M=(S=s.preferences)==null?void 0:S.mapVisualOptions)==null?void 0:M.projectionOffset)==null?void 0:V[1])||0]}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Y"}),e.jsxRuntimeExports.jsx(e.Input,{className:`h-9 w-full ${e.removeRing}`,type:"number",step:10,value:((R=(d=(O=s.preferences)==null?void 0:O.mapVisualOptions)==null?void 0:d.projectionOffset)==null?void 0:R[1])||0,onChange:E=>{var k,S,M,V;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,projectionOffset:[((V=(M=(S=s.preferences)==null?void 0:S.mapVisualOptions)==null?void 0:M.projectionOffset)==null?void 0:V[0])||0,Number(E.target.value)]}})}})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),e.jsxRuntimeExports.jsx(ne,{})]})}function qt(){var n;const s=e.useEditorStore(o=>o.card.preferences),{setCardPreferences:r}=e.useEditorStore(o=>o.actions);function t(o){r({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:o==="dynamic"}})}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:(n=s==null?void 0:s.textVisualOptions)!=null&&n.isDynamicText?"dynamic":"static",onValueChange:t,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"static",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Static"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function he({cardType:s,docContent:r,suffix:t="Chart"}){let n="pie-chart";return s==="radar"&&(n="radar-chart"),e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} ${t}`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{children:r||e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"measure - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:o=>o.stopPropagation(),className:"text-blue-700",href:`https://docs.semaphor.cloud/concepts/visuals#${n}`,children:"example"})," in the docs."]})]})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[s==="range"&&e.jsxRuntimeExports.jsx(ye,{}),s!=="text"&&e.jsxRuntimeExports.jsx(Te,{}),s==="text"&&e.jsxRuntimeExports.jsx(qt,{})]})]}),!["range","text"].includes(s)&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ne,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function Bt(){const s=e.useEditorStore(n=>{var o,i;return(i=(o=n==null?void 0:n.card)==null?void 0:o.preferences)==null?void 0:i.sortChart}),{setSortChart:r}=e.useEditorActions();function t(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Sort"}),e.jsxRuntimeExports.jsx(W,{className:"h-8",label:"Sort Chart",options:[{label:"None",value:"none"},{label:"ASC",value:"asc"},{label:"DESC",value:"desc"}],value:s||"none",onValueChange:n=>{r(n)}})]})}return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Stacked Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"stack by - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ye,{}),t(),e.jsxRuntimeExports.jsx(zs,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ne,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function _t({}){const s=e.useEditorStore(n=>{var o;return(o=n.card)==null?void 0:o.preferences}),r=e.useEditorStore(n=>n.actions.setCardPreferences),t=n=>{r({...s,allowDownload:n})};return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ne,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{onCheckedChange:t,id:"allow-download"}),e.jsxRuntimeExports.jsx("label",{htmlFor:"allow-download",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Allow Download"})]})]})}const Ht=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pyramid-chart",children:"example"})," in the docs."]})]}),Pt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT y-axis, label, range-from, range-to, range-value FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#range-charts",children:"example"})," in the docs."]})]}),Gt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT text FROM table limit 1"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#text-visual",children:"example"})," in the docs."]})]});function $t(){const s=e.useEditorStore(t=>t.card.type);function r(t){switch(t){case"stackedBar":case"stackedLine":return e.jsxRuntimeExports.jsx(Bt,{});case"pyramid":return e.jsxRuntimeExports.jsx(he,{docContent:Ht,cardType:t});case"kpi":return e.jsxRuntimeExports.jsx(zt,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(wt,{cardType:t});case"range":return e.jsxRuntimeExports.jsx(he,{docContent:Pt,cardType:t});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(he,{cardType:t});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(kt,{cardType:t});case"table":return e.jsxRuntimeExports.jsx(_t,{cardType:t});case"text":return e.jsxRuntimeExports.jsx(he,{docContent:Gt,cardType:t,suffix:"Visual"});case"map":return e.jsxRuntimeExports.jsx(Vt,{});case"custom":return e.jsxRuntimeExports.jsx(vt,{});default:return e.jsxRuntimeExports.jsx(Lt,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:r(s)})}function Ut(){const s=e.useEditorStore(r=>r.isShowingVisual);return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:[e.jsxRuntimeExports.jsx(e.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsxRuntimeExports.jsx(lt,{})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:s?e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"horizontal",children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:e.jsxRuntimeExports.jsx($t,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(_e,{})})]}):e.jsxRuntimeExports.jsx(_e,{})})]})}function Qt({authToken:s,onSave:r,onClose:t}){e.useDashboardStore(l=>l.themeStyle);const n=e.useEditorStore(l=>l.actions.setOnSave),o=e.useEditorStore(l=>l.actions.setOnClose),i=e.useDashboardStore(l=>l.actions.setAuthToken);return b.useEffect(()=>{r&&n(r),t&&o(t)},[r,n,t,o]),b.useEffect(()=>{s&&s.accessToken&&i(s)},[s,i]),e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:e.jsxRuntimeExports.jsxs(e.EditorPanel,{style:{},className:"rounded-none",role:"editor-panel",children:[e.jsxRuntimeExports.jsx(e.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsxRuntimeExports.jsx(fs,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(Ut,{})})]})})}function Kt(){e.useDashboardStore(l=>l.selectedCardId);const s=e.useDashboardStore(l=>l.selectedSheetId),{setIsVisualEditing:r}=e.useDashboardStore(l=>l.actions),t=e.useDashboardStore(l=>l.isVisualEditing),n=e.useDashboardStore(l=>l.actions.updateFrame);function o(l){s&&(n(s,l),r(!1))}function i(){r(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{"max-h-0 overflow-hidden":!t}),children:e.jsxRuntimeExports.jsx(Qt,{onSave:o,onClose:i})})}function Jt(){const s=e.useEditorStore(i=>i.selectedDatabaseName),r=e.useEditorStore(i=>i.selectedTableName),t=e.useDashboardStore(i=>i.dashboard.filters)||[],{columns:n}=te(),{assignFilter:o}=Os();return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"flex-1 basis-0 flex-col px-3",children:n==null?void 0:n.map(i=>{const l=t==null?void 0:t.find(a=>a.column===e.fmt(i.column_name)&&a.table===r&&a.database===s);return e.jsxRuntimeExports.jsx("div",{onClick:()=>o(i),className:e.cn("group flex cursor-pointer items-center justify-between border border-dashed border-background px-3 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":l}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(Es,{column:i}),e.jsxRuntimeExports.jsx("span",{children:i.column_name})]})},i.column_name)})})}function Wt(){e.useDashboardStore(r=>r.showFilters);const s=e.useDashboardStore(r=>r.actions.setShowFilters);return e.jsxRuntimeExports.jsxs("section",{className:"relative flex min-w-72 grow flex-col border-l px-1",children:[e.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"px-2 text-lg",children:"Filters"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>s(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{})})]}),e.jsxRuntimeExports.jsx("div",{className:"flex grow",children:e.jsxRuntimeExports.jsx(fs,{ColumnsComponent:()=>e.jsxRuntimeExports.jsx(Jt,{})})})]})}function Yt(){const s=e.useDashboardStore(n=>n.dashboard.filters),r=e.useDashboardStore(n=>n.theme),t=s==null?void 0:s.filter(n=>n.hide);return t!=null&&t.length?e.jsxRuntimeExports.jsx("div",{className:e.cn("mb-1 flex items-center gap-2 border-y pb-0.5",{"bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]":r==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":r==="dark"}),children:t==null?void 0:t.map(n=>e.jsxRuntimeExports.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[e.jsxRuntimeExports.jsx(e.FilterHeader,{filter:n}),e.jsxRuntimeExports.jsx(e.FilterComponent,{filter:n})]},n.id))}):null}function Xt(){const s=e.useDashboardStore(n=>n.showFilters),r=e.useDashboardStore(n=>n.isVisualEditing),t=e.useDashboardStore(n=>n.isDashboardEditing);return e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("",{"max-h-0 overflow-hidden":r,"flex grow":!r}),children:[e.jsxRuntimeExports.jsxs("section",{className:"flex grow flex-col",children:[t&&e.jsxRuntimeExports.jsx(Yt,{}),e.jsxRuntimeExports.jsx(e.DashboardTabs,{})]}),s&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(Wt,{})})]})}function Zt(){const s=e.useDashboardStore(n=>n.dashboard),r=e.useDashboardStore(n=>n.actions.setDashboard),t=e.useDashboardStore(n=>n.showDashboardJSON);return e.useDashboardStore(n=>n.actions.setShowDashboardJSON),e.jsxRuntimeExports.jsx("div",{className:e.cn(" p-2",{hidden:!t}),children:e.jsxRuntimeExports.jsx(e.de,{onChange:n=>{if(n)try{JSON.parse(n),r(JSON.parse(n))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(s,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function en({showControls:s=!1,showFooter:r=!0,...t}){return e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:t,children:[e.jsxRuntimeExports.jsx(e.Oe,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(Zt,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...t,children:[s&&e.jsxRuntimeExports.jsx(Ps,{}),e.jsxRuntimeExports.jsx(Kt,{}),e.jsxRuntimeExports.jsx(Xt,{})]})]})]})})}exports.Box=Pe;exports.Braces=Ge;exports.ChartArea=$e;exports.ChartColumnIncreasing=ge;exports.ChartLine=Re;exports.ChartNoAxesGantt=Ce;exports.ChartPie=Ne;exports.ChartScatter=we;exports.CircleX=Ue;exports.CopyPlus=Qe;exports.DashboardPlus=en;exports.Database=Ke;exports.EllipsisVertical=ke;exports.Eraser=Je;exports.EyeClosed=We;exports.Glasses=Ye;exports.Hammer=Xe;exports.Hash=Ze;exports.House=es;exports.Key=ss;exports.ListEnd=ts;exports.ListStart=ns;exports.ListX=rs;exports.LoaderCircle=se;exports.Map=De;exports.MessageSquareMore=os;exports.Network=is;exports.Play=as;exports.Plug2=ls;exports.Save=cs;exports.SelectComponent=ce;exports.Shapes=Ie;exports.ShieldQuestion=xs;exports.Sigma=us;exports.SwatchBook=ds;exports.Tag=ms;exports.ToggleLeft=ps;exports.Type=be;exports.User=js;exports.cleanCard=hs;exports.getDashbaordStateWithoutData=Le;exports.useEditorAside=te;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as R, u as vs, v as M, w as is, x as Se, y as e, z as Cs, A as Ns, H as O, o as Ss, J as ws, K as ks, M as zs, N as Os, O as H, Q as ie, R as ta, V as na, W as la, Y as ra, Z as st, _ as at, $ as tt, a0 as Gs, a1 as Y, a2 as Be, i as nt, a3 as u, a4 as lt, P as ia, F as oa, a5 as Ue, a6 as Ge, a7 as Ds, a8 as ca, a9 as Ms, aa as ue, ab as he, ac as me, ad as xe, ae as ve, af as pe, ag as Z, T as Is, ah as Fs, ai as Ts, aj as Ls, ak as da, al as ua, am as ce, an as rt, ao as it, ap as ha, aq as ot, C as ct, ar as dt, as as ma, B as ut, at as fe, au as ht, av as Ke, aw as xa, ax as gs, ay as be, az as ze, aA as Ce, aB as pa, aC as mt, aD as xt, aE as pt, aF as ft, l as gt, aG as jt, aH as bt, aI as De, aJ as ne, aK as fa, aL as yt, aM as os, aN as vt, aO as Ct, aP as js, a as Nt, aQ as ss, aR as ye, aS as as, aT as St, aU as wt, aV as kt, aW as zt, aX as fs, aY as Ot, aZ as Ks, a_ as Dt, a$ as Qs, b0 as Mt, b1 as It, b2 as Ft, b3 as Tt, b4 as ga, b5 as Lt, b6 as Es, b7 as ja, b8 as Et, b9 as Vt, ba as Ze, bb as At, bc as qt, bd as ba, be as Rt, s as _t, bf as Ht, bg as $t, r as Pt, bh as cs, bi as ya, bj as va, bk as Ca, bl as Xe, bm as Na, bn as es, bo as Js, bp as Bt, bq as Ut, br as ds, bs as us, bt as hs, bu as Gt, I as Kt, X as Sa, bv as Qt, bw as Jt, bx as Wt, E as Yt, by as ms, bz as Oe, f as Zt, bA as $e, bB as Vs, bC as wa, bD as Xt, bE as en, bF as ts, bG as sn, bH as an, bI as tn, bJ as Ws, bK as ka, bL as nn, bM as ln, bN as rn, bO as on, bP as cn, bQ as dn, bR as un, bS as Me, bT as Q, bU as J, bV as As, bW as W, bX as hn, bY as za, bZ as mn, b_ as xn, b$ as pn, c0 as fn, c1 as gn, c2 as jn, c3 as bn, c4 as yn, c5 as vn } from "./index-
|
|
1
|
+
import { c as R, u as vs, v as M, w as is, x as Se, y as e, z as Cs, A as Ns, H as O, o as Ss, J as ws, K as ks, M as zs, N as Os, O as H, Q as ie, R as ta, V as na, W as la, Y as ra, Z as st, _ as at, $ as tt, a0 as Gs, a1 as Y, a2 as Be, i as nt, a3 as u, a4 as lt, P as ia, F as oa, a5 as Ue, a6 as Ge, a7 as Ds, a8 as ca, a9 as Ms, aa as ue, ab as he, ac as me, ad as xe, ae as ve, af as pe, ag as Z, T as Is, ah as Fs, ai as Ts, aj as Ls, ak as da, al as ua, am as ce, an as rt, ao as it, ap as ha, aq as ot, C as ct, ar as dt, as as ma, B as ut, at as fe, au as ht, av as Ke, aw as xa, ax as gs, ay as be, az as ze, aA as Ce, aB as pa, aC as mt, aD as xt, aE as pt, aF as ft, l as gt, aG as jt, aH as bt, aI as De, aJ as ne, aK as fa, aL as yt, aM as os, aN as vt, aO as Ct, aP as js, a as Nt, aQ as ss, aR as ye, aS as as, aT as St, aU as wt, aV as kt, aW as zt, aX as fs, aY as Ot, aZ as Ks, a_ as Dt, a$ as Qs, b0 as Mt, b1 as It, b2 as Ft, b3 as Tt, b4 as ga, b5 as Lt, b6 as Es, b7 as ja, b8 as Et, b9 as Vt, ba as Ze, bb as At, bc as qt, bd as ba, be as Rt, s as _t, bf as Ht, bg as $t, r as Pt, bh as cs, bi as ya, bj as va, bk as Ca, bl as Xe, bm as Na, bn as es, bo as Js, bp as Bt, bq as Ut, br as ds, bs as us, bt as hs, bu as Gt, I as Kt, X as Sa, bv as Qt, bw as Jt, bx as Wt, E as Yt, by as ms, bz as Oe, f as Zt, bA as $e, bB as Vs, bC as wa, bD as Xt, bE as en, bF as ts, bG as sn, bH as an, bI as tn, bJ as Ws, bK as ka, bL as nn, bM as ln, bN as rn, bO as on, bP as cn, bQ as dn, bR as un, bS as Me, bT as Q, bU as J, bV as As, bW as W, bX as hn, bY as za, bZ as mn, b_ as xn, b$ as pn, c0 as fn, c1 as gn, c2 as jn, c3 as bn, c4 as yn, c5 as vn } from "./index-Bq5AyXcJ.js";
|
|
2
2
|
import * as Ys from "react";
|
|
3
3
|
import Ne, { useState as q, useMemo as bs, useEffect as X, useRef as ns, useCallback as Oa, Suspense as Cn } from "react";
|
|
4
4
|
import "react-dom";
|
|
@@ -2987,7 +2987,7 @@ function Wa(s) {
|
|
|
2987
2987
|
const [n, a] = q(null);
|
|
2988
2988
|
return X(() => {
|
|
2989
2989
|
s && (async () => {
|
|
2990
|
-
const r = (await import("./lucide-react-
|
|
2990
|
+
const r = (await import("./lucide-react-BQZLQzXT.js"))[s];
|
|
2991
2991
|
a(r);
|
|
2992
2992
|
})();
|
|
2993
2993
|
}, [s]), n;
|
|
@@ -17765,13 +17765,17 @@ function ree(e) {
|
|
|
17765
17765
|
return e === nN ? "" : nee(e);
|
|
17766
17766
|
}
|
|
17767
17767
|
function Sc(e, t) {
|
|
17768
|
-
const { authToken: n } = xo(), r = ve((
|
|
17769
|
-
|
|
17768
|
+
const { authToken: n } = xo(), r = ve((p) => p.isVisualEditing), i = ve((p) => p.authToken), o = eee((e == null ? void 0 : e.refreshInterval) || "0"), { queryKey: s, sql: a, sheetFilterValues: l } = tee(e);
|
|
17769
|
+
let c = {};
|
|
17770
|
+
return r || (c = {
|
|
17771
|
+
refetchInterval: o,
|
|
17772
|
+
placeholderData: UY
|
|
17773
|
+
}), { ...Ly({
|
|
17770
17774
|
queryKey: s,
|
|
17771
17775
|
// ],
|
|
17772
17776
|
queryFn: async () => {
|
|
17773
|
-
var
|
|
17774
|
-
return !(e != null && e.connectionId) || !((
|
|
17777
|
+
var h;
|
|
17778
|
+
return !(e != null && e.connectionId) || !((h = e == null ? void 0 : e.sql) != null && h.trim()) ? null : await j_(
|
|
17775
17779
|
"https://semaphor.cloud/api/v1/query",
|
|
17776
17780
|
(n == null ? void 0 : n.accessToken) || (i == null ? void 0 : i.accessToken) || "",
|
|
17777
17781
|
{
|
|
@@ -17784,10 +17788,7 @@ function Sc(e, t) {
|
|
|
17784
17788
|
}
|
|
17785
17789
|
);
|
|
17786
17790
|
},
|
|
17787
|
-
|
|
17788
|
-
refetchInterval: o,
|
|
17789
|
-
placeholderData: UY,
|
|
17790
|
-
//staleTime: 60_000,
|
|
17791
|
+
...c,
|
|
17791
17792
|
enabled: !!(e != null && e.connectionId) && !!(e != null && e.sql) && !0 && !r
|
|
17792
17793
|
}), queryKey: s };
|
|
17793
17794
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as a, B as e, C as t, a as c, b as h, d, e as o, f as y, g as i, h as s, i as n, E as r, j as k, F as p, k as l, G as u, I as M, l as v, L as g, m, P as x, n as L, o as w, S as C, p as f, q as I, r as S, T as q, s as b, U as H, X as A } from "./index-
|
|
2
|
-
import { t as Av } from "./index-
|
|
3
|
-
import { B as z, a as P, C as V, b as j, c as B, d as F, e as D, f as R, g as T, h as U, i as O, E as Z, j as G, k as W, G as E, H as X, l as N, m as K, K as J, L as Q, n as Y, o as _, p as $, M as a1, q as e1, N as t1, P as c1, r as h1, S as d1, s as o1, t as y1, u as i1, v as s1, T as n1, w as r1, x as k1, U as p1 } from "./index-
|
|
1
|
+
import { c as a, B as e, C as t, a as c, b as h, d, e as o, f as y, g as i, h as s, i as n, E as r, j as k, F as p, k as l, G as u, I as M, l as v, L as g, m, P as x, n as L, o as w, S as C, p as f, q as I, r as S, T as q, s as b, U as H, X as A } from "./index-Bq5AyXcJ.js";
|
|
2
|
+
import { t as Av } from "./index-Bq5AyXcJ.js";
|
|
3
|
+
import { B as z, a as P, C as V, b as j, c as B, d as F, e as D, f as R, g as T, h as U, i as O, E as Z, j as G, k as W, G as E, H as X, l as N, m as K, K as J, L as Q, n as Y, o as _, p as $, M as a1, q as e1, N as t1, P as c1, r as h1, S as d1, s as o1, t as y1, u as i1, v as s1, T as n1, w as r1, x as k1, U as p1 } from "./index-BbkT5FU1.js";
|
|
4
4
|
/**
|
|
5
5
|
* @license lucide-react v0.453.0 - ISC
|
|
6
6
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-622sBsAD.js"),a=require("./index-BI4RIp9g.js");/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
package/dist/dashboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-622sBsAD.js");exports.Dashboard=e.Dashboard;
|
package/dist/dashboard/index.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-622sBsAD.js"),a=require("./chunks/index-BI4RIp9g.js");require("react");require("react-dom");exports.Dashboard=e.Dashboard;exports.DashboardWC=e.DashboardWC;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.createSqlGenConfig=e.createSqlGenConfig;exports.fmt=e.fmt;exports.getColumnDataType=e.getColumnDataType;exports.getFilterValueType=e.getFilterValueType;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.isBooleanDataType=e.isBooleanDataType;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.resolveDataType=e.resolveDataType;exports.useCard=e.useCard;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardStore=e.useDashboardStore;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorStore=e.useEditorStore;exports.useTextFilterHook=e.useTextFilterHook;exports.SelectComponent=a.SelectComponent;exports.Surfboard=a.DashboardPlus;exports.cleanCard=a.cleanCard;exports.getDashbaordStateWithoutData=a.getDashbaordStateWithoutData;exports.useEditorAside=a.useEditorAside;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as o, ca as r, c8 as i, c8 as l, ak as u, am as D, cc as c, cb as d, aw as p, al as m, ar as n, au as S, aq as T, ap as b, ao as y, cd as h, c9 as C, w as f, v as g, c6 as q, aJ as x, a3 as A, c7 as F } from "./chunks/index-
|
|
2
|
-
import { z as v, D as E, F as w, A as G, y as H } from "./chunks/index-
|
|
1
|
+
import { D as o, ca as r, c8 as i, c8 as l, ak as u, am as D, cc as c, cb as d, aw as p, al as m, ar as n, au as S, aq as T, ap as b, ao as y, cd as h, c9 as C, w as f, v as g, c6 as q, aJ as x, a3 as A, c7 as F } from "./chunks/index-Bq5AyXcJ.js";
|
|
2
|
+
import { z as v, D as E, F as w, A as G, y as H } from "./chunks/index-BbkT5FU1.js";
|
|
3
3
|
import "react";
|
|
4
4
|
import "react-dom";
|
|
5
5
|
export {
|
package/dist/surfboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-BI4RIp9g.js");exports.Surfboard=e.DashboardPlus;
|
package/dist/surfboard/index.js
CHANGED