react-semaphor 0.0.278 → 0.0.279
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/{dashboard-plus-9oytE2my.js → dashboard-plus-5OdRvE8M.js} +2 -2
- package/dist/chunks/{dashboard-plus-NiwIDrBK.js → dashboard-plus-gEOVHCeC.js} +2 -2
- package/dist/chunks/{index-gVJdfFKn.js → index-6kxWR20D.js} +5 -4
- package/dist/chunks/{index-ytQCJ3Yv.js → index-cwCVAphZ.js} +1 -1
- package/dist/chunks/{lucide-react-aSeZCTQ8.js → lucide-react-Z2s0wfim.js} +3 -3
- package/dist/chunks/{lucide-react-Bh6u93Ue.js → lucide-react-t1mmrDBn.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 +4 -4
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as A, L as Ge, b as z, c as Cs, u as je, j as e, M as Ns, O as Ss, P as F, Q as ws, R as ks, U as zs, V as Fs, W as Is, X as H, Y as Se, Z as ta, _ as na, $ as la, a0 as ra, a1 as Za, a2 as et, a3 as st, a4 as Bs, f as X, a5 as He, a6 as at, a7 as ia, a8 as $e, a9 as Pe, T as Ts, e as oa, g as Ds, aa as he, ab as me, ac as xe, ad as pe, ae as we, af as fe, ag as W, ah as Ls, G as o, ai as Ms, aj as Os, ak as As, w as ca, v as da, t as ue, al as tt, r as nt, N as ua, s as lt, am as rt, B as it, an as ha, ao as ot, S as Es, z as ct, n as Us, A as ma, ap as fs, aq as ie, ar as Ne, as as Ie, at as ls, au as xa, av as dt, aw as ut, ax as pa, ay as ht, az as mt, aA as xt, aB as pt, aC as ft, aD as gs, aE as gt, aF as jt, aG as _e, aH as js, aI as Me, aJ as bs, aK as Gs, aL as bt, aM as yt, aN as vt, aO as Ct, aP as Nt, aQ as ps, aR as St, aS as Ks, aT as wt, aU as Qs, aV as kt, aW as zt, aX as Ft, aY as fa, H as be, aZ as ga, l as It, C as Tt, E as Ze, d as Dt, h as Lt, a_ as Mt, i as Ot, o as At, a$ as Et, m as Vt, b0 as qt, b1 as ja, b2 as ba, b3 as es, b4 as ya, b5 as ss, b6 as Ws, b7 as Rt, b8 as _t, b9 as rs, ba as is, bb as os, bc as Ht, bd as $t, be as va, K as Pt, bf as Bt, bg as Ut, bh as cs, bi as Te, bj as Gt, bk as Kt, bl as Ca, bm as Qt, bn as Wt, bo as as, bp as Jt, bq as Yt, br as Xt, bs as Js, bt as Zt, bu as en, bv as sn, bw as an, bx as tn, by as nn, bz as ln, bA as rn, bB as De, bC as B, bD as U, bE as Vs, bF as G, bG as on, bH as Na, bI as Sa, bJ as cn, bK as dn, bL as un, bM as hn, bN as mn, bO as xn, bP as pn, bQ as fn, bR as gn } from "./index-
|
|
1
|
+
import { J as A, L as Ge, b as z, c as Cs, u as je, j as e, M as Ns, O as Ss, P as F, Q as ws, R as ks, U as zs, V as Fs, W as Is, X as H, Y as Se, Z as ta, _ as na, $ as la, a0 as ra, a1 as Za, a2 as et, a3 as st, a4 as Bs, f as X, a5 as He, a6 as at, a7 as ia, a8 as $e, a9 as Pe, T as Ts, e as oa, g as Ds, aa as he, ab as me, ac as xe, ad as pe, ae as we, af as fe, ag as W, ah as Ls, G as o, ai as Ms, aj as Os, ak as As, w as ca, v as da, t as ue, al as tt, r as nt, N as ua, s as lt, am as rt, B as it, an as ha, ao as ot, S as Es, z as ct, n as Us, A as ma, ap as fs, aq as ie, ar as Ne, as as Ie, at as ls, au as xa, av as dt, aw as ut, ax as pa, ay as ht, az as mt, aA as xt, aB as pt, aC as ft, aD as gs, aE as gt, aF as jt, aG as _e, aH as js, aI as Me, aJ as bs, aK as Gs, aL as bt, aM as yt, aN as vt, aO as Ct, aP as Nt, aQ as ps, aR as St, aS as Ks, aT as wt, aU as Qs, aV as kt, aW as zt, aX as Ft, aY as fa, H as be, aZ as ga, l as It, C as Tt, E as Ze, d as Dt, h as Lt, a_ as Mt, i as Ot, o as At, a$ as Et, m as Vt, b0 as qt, b1 as ja, b2 as ba, b3 as es, b4 as ya, b5 as ss, b6 as Ws, b7 as Rt, b8 as _t, b9 as rs, ba as is, bb as os, bc as Ht, bd as $t, be as va, K as Pt, bf as Bt, bg as Ut, bh as cs, bi as Te, bj as Gt, bk as Kt, bl as Ca, bm as Qt, bn as Wt, bo as as, bp as Jt, bq as Yt, br as Xt, bs as Js, bt as Zt, bu as en, bv as sn, bw as an, bx as tn, by as nn, bz as ln, bA as rn, bB as De, bC as B, bD as U, bE as Vs, bF as G, bG as on, bH as Na, bI as Sa, bJ as cn, bK as dn, bL as un, bM as hn, bN as mn, bO as xn, bP as pn, bQ as fn, bR as gn } from "./index-6kxWR20D.js";
|
|
2
2
|
import * as Ys from "react";
|
|
3
3
|
import ge, { useState as E, useMemo as ys, useEffect as Y, useRef as Be, Suspense as jn } from "react";
|
|
4
4
|
import "react-dom";
|
|
@@ -2945,7 +2945,7 @@ function Ga(s) {
|
|
|
2945
2945
|
const [n, a] = E(null);
|
|
2946
2946
|
return Y(() => {
|
|
2947
2947
|
s && (async () => {
|
|
2948
|
-
const i = (await import("./lucide-react-
|
|
2948
|
+
const i = (await import("./lucide-react-Z2s0wfim.js"))[s];
|
|
2949
2949
|
a(i);
|
|
2950
2950
|
})();
|
|
2951
2951
|
}, [s]), n;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const e=require("./index-
|
|
1
|
+
"use strict";const e=require("./index-cwCVAphZ.js"),v=require("react");require("react-dom");function _s(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 Be=_s(v);/**
|
|
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: ${C==null?void 0:C.map(N=>`${N.column_name} | ${N.data_type}`).join(", ")}
|
|
238
238
|
User SQL: ${T}
|
|
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: ${et}`,{data:p,isLoading:S,isFetching:f,isError:j,refetch:z}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(l==null?void 0:l.accessToken)||"",{user_content:`userContent: ${L} ${x?I:""}`}),enabled:!1});function O(N){if(N.toLowerCase().includes("bar"))m("bar");else if(N.toLowerCase().includes("line"))m("line");else if(N.toLowerCase().includes("bubble"))m("bubble");else if(N.toLowerCase().includes("scatter"))m("scatter");else if(N.toLowerCase().includes("stacked"))m("stackedBar");else if(N.toLowerCase().includes("pie"))m("pie");else if(N.toLowerCase().includes("donut")||N.toLowerCase().includes("doughnut"))m("doughnut");else if(N.toLowerCase().includes("radar"))m("radar");else return m("bar"),!1;return!0}v.useEffect(()=>{p&&w(N=>[...N,{role:"ai",content:p.response}])},[p]),v.useEffect(()=>{const N=setTimeout(()=>{var A;c.current&&(c.current.scroll({top:c.current.scrollHeight,behavior:"smooth"}),(A=i.current)==null||A.focus())},100);return()=>clearTimeout(N)},[b]);function F(){t&&(w(N=>[...N,{role:"user",content:t}]),O(t)&&d(!0),n(""),z())}v.useEffect(()=>{o&&(F(),a(!1))},[o,a]);const V={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},P={fontFamily:"monospace",fontSize:14,lineHeight:1.6},_={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},K={p:({node:N,...A})=>e.jsxRuntimeExports.jsx("p",{style:V,...A}),code:({node:N,...A})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...A}),pre:({node:N,...A})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:P,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:A.children}),e.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:q,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:H=>{const D=q(H);D&&(r(!1),g(D),u(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:N,...A})=>e.jsxRuntimeExports.jsx("li",{style:_,...A})};function q(N){const A=N.currentTarget.closest("pre");if(!A)return;const H=A.textContent||A.innerText;return navigator.clipboard.writeText(H).then(()=>console.log("Text copied to clipboard")).catch(D=>console.error("Error in copying text: ",D)),H}function W(){return b==null?void 0:b.map((N,A)=>N.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(fs,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:N.content})]},A):N.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:K,children:p==null?void 0:p.response.replace(/DuckDB/gi,"Semaphor")},A):e.jsxRuntimeExports.jsx("div",{},A))}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:c,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:W()})}),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:i,onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),n(""),F())},placeholder:"Type your question here...",onFocus:N=>{const A=N.target,H=A.value.length;A.setSelectionRange(H,H)},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:S||f,value:t,onChange:N=>n(N.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:F,children:!S&&!f?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(le,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var ys={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},He=v.createContext&&v.createContext(ys),tt=["attr","size","title"];function nt(s,r){if(s==null)return{};var t=rt(s,r),n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(s);for(o=0;o<a.length;o++)n=a[o],!(r.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(s,n)&&(t[n]=s[n])}return t}function rt(s,r){if(s==null)return{};var t={},n=Object.keys(s),o,a;for(a=0;a<n.length;a++)o=n[a],!(r.indexOf(o)>=0)&&(t[o]=s[o]);return t}function ge(){return ge=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},ge.apply(this,arguments)}function Pe(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 Re(s){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?Pe(Object(t),!0).forEach(function(n){ot(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Pe(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function ot(s,r,t){return r=it(r),r in s?Object.defineProperty(s,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[r]=t,s}function it(s){var r=at(s,"string");return typeof r=="symbol"?r:String(r)}function at(s,r){if(typeof s!="object"||s===null)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 Ss(s){return s&&s.map((r,t)=>v.createElement(r.tag,Re({key:t},r.attr),Ss(r.child)))}function Z(s){return r=>v.createElement(lt,ge({attr:Re({},s.attr)},r),Ss(s.child))}function lt(s){var r=t=>{var{attr:n,size:o,title:a}=s,i=nt(s,tt),c=o||t.size||"1em",l;return t.className&&(l=t.className),s.className&&(l=(l?l+" ":"")+s.className),v.createElement("svg",ge({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,n,i,{className:l,style:Re(Re({color:s.color||t.color},t.style),s.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),a&&v.createElement("title",null,a),s.children)};return He!==void 0?v.createElement(He.Consumer,null,t=>r(t)):r(ys)}function ct(s){return Z({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 xt(){const{theme:s}=e.useTheme(),r=v.useRef(),t=v.useRef(),[n,o]=v.useState(!1),[a,i]=v.useState(!1),[c,l]=v.useState(!1),[x,d]=v.useState(""),[g,h]=v.useState(!1),{authToken:u}=e.useSemaphorContext();e.useDashboardStore(E=>E.selectedSheetId);const m=e.useDashboardStore(E=>E.dashboard.baseQueries),b=e.useEditorStore(E=>E.card),w=e.useDashboardStore(E=>E.theme),C=e.useEditorStore(E=>E.isShowingVisual);e.useDashboardStore(E=>E.onAcceptChanges);const T=e.useEditorStore(E=>E.selectedConnectionId),R=e.useEditorStore(E=>E.selectedDatabaseName),L=e.useEditorStore(E=>E.selectedDatamodelId),I=e.useEditorStore(E=>E.selectedSchemaName);e.useDashboardStore(E=>E.actions.updateFrameCard);const p=e.useEditorStore(E=>E.selectedTableName),S=e.useEditorStore(E=>E.card.sql),f=e.useEditorStore(E=>E.card.python),j=e.resolveBaseQuery(S,m),z=e.useEditorStore(E=>E.selectedConnectionId),O=e.useEditorStore(E=>E.frame),F=e.useDashboardStore(E=>E.filterValues),V=e.useEditorStore(E=>E.applyFilters),{setCardCustomCfg:P,setQueryResultColumns:_,setFilterValues:K,setCardSql:q,setCardPython:W,setQueryError:N,setPythonStdOut:A,setCardPreferences:H}=e.useEditorStore(E=>E.actions),D=e.useEditorStore(E=>E.onSave),k=e.useEditorStore(E=>E.actions.setApplyFilters),$=e.useEditorStore(E=>E.onClose),M=e.useEditorStore(E=>E.actions.setCardData),G=e.useEditorStore(E=>E.actions.setSqlGen),U=e.useEditorStore(E=>E.runSql),te=e.useEditorStore(E=>E.actions.setRunSql),ee=e.useEditorStore(E=>E.actions.setIsSqlRunning),{data:B,isLoading:J,isFetching:Y,isSuccess:ne,isError:X,error:se,status:qe,refetch:ie}=e.useQuery({queryKey:[j,f],queryFn:()=>e.postRequest("https://semaphor.cloud/api/v1/query",(u==null?void 0:u.accessToken)||"",{connection_id:z,sql:j,python:f===e.PYTHON_DEFAULT_CODE?"":f,active_filters:V?F:[]}),enabled:!1,retry:!1});v.useEffect(()=>{if(B&&(M(B.records),B.rowLimitExceeded&&e.Jt.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),A((B==null?void 0:B.output)||""),B.records.length>0)){const{dimensionKeys:E}=e.getKeys(B.records);_(E)}},[B,M,_,A]),v.useEffect(()=>{U&&(ie(),te(!1))},[U,ie,te]),v.useEffect(()=>{(J||Y)&&ee(!0),(X||ne)&&ee(!1),X?(N(se.message),M([]),_([]),A("")):N("")},[J,Y,B,A,X,ne,ee,M,_,N,se]);function Ce(){q(""),M([]),G({}),P(""),H({})}const me=E=>{t.current=E};function Ne(E,y){if(E.length===0)return"";if(y){const re=E.find(Q=>Q.id===y);if(re){const Q=re.tabTitle;if(Q=="All__Header")return E[0].id;if(Q&&Q.endsWith("__Header")){const Vs=Q.split("__")[0],_e=E.find(qs=>qs.tabTitle===Vs);return _e?_e.id:E[0].id}return y}}return E[0].id}function we(){let E=S;S&&!S.includes("{{")&&(E=Ws(S),q(E));const y={...b,lastSelectedSchema:I,lastSelectedDatamodelId:L,lastSelectedDatabase:R,lastSelectedTable:p,connectionId:T,type:C?b.type:"table",sql:E,customCfg:C?b.customCfg:null},re=O.cards.map(ke=>ke.id===b.id?y:ke),Q={...O,cards:re,activeCardId:Ne(re,O.activeCardId)};D==null||D(Q)}function pe(){$==null||$()}v.useEffect(()=>{const E=r.current,y=t.current;if(E){const re=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",Q=w==="system"?re:w;E.editor.defineTheme("default",{base:Q==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":Q==="light"?"#ffffff":e.getCssVariableValue("--semaphor-background")}}),E.editor.setTheme("default")}return y&&E&&y.addCommand(E.KeyMod.Shift|E.KeyCode.Enter,function(){return console.log("Executing query..."),ie(),!1}),()=>{}},[s,w,r.current]);function ue(E){r.current=E}function je(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[a&&e.jsxRuntimeExports.jsx("div",{className:"xbg-yellow-100 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(Ys,{checked:V,onCheckedChange:()=>k(!V),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(Zs,{}),F&&a&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>i(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:E=>{if(E)try{JSON.parse(E),K(JSON.parse(E))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(F,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),F&&!a&&e.jsxRuntimeExports.jsx(e.Filter,{onClick:()=>i(!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":V})})]})}function he(){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",{role:"sql-container",className:"relative flex w-[99%]",children:e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",className:"pt-3",onChange:E=>{q(E)},value:S,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",beforeMount:ue,onMount:me})}),n&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm 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",{role:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"pt-3",theme:"default",onChange:E=>{W(E&&E.trim()||"")},value:f||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:ue,onMount:me})}),e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm 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",{role:"sql-editor",className:"relative flex grow justify-between overflow-y-scroll",children:[he(),je()]}),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:J||Y,onClick:()=>{ie()},className:"shrink-0",size:"sm",variant:"outline",children:[J||Y?e.jsxRuntimeExports.jsx(le,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(xs,{className:"mr-2 h-4 w-4"}),"Run"]}),X&&e.jsxRuntimeExports.jsx(Js,{error:se.message,setShowAIDialog:l,setTriggerAIRun:h,setUserInputforAI:d}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:Ce,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(Xe,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:n,onPressedChange:E=>o(E),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(ct,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(st,{open:c,setOpen:l,userInput:x,triggerAIRun:g,setTriggerAIRun:h,setUserInput:E=>d(E)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:we,size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:pe,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function ut({data:s}){var i;const[r,t]=v.useState([]),o=Object.keys(s[0]).map(c=>({accessorKey:c,header:({column:l})=>{const x=l.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>l.toggleSorting(l.getIsSorted()==="asc"),children:[c,x==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):x==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),a=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.jsxs(e.Table$1,{children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:a.getHeaderGroups().map(c=>e.jsxRuntimeExports.jsx(e.TableRow,{children:c.headers.map(l=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 bg-muted",children:l.isPlaceholder?null:e.flexRender(l.column.columnDef.header,l.getContext())},l.id))},c.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(i=a.getRowModel().rows)!=null&&i.length?a.getRowModel().rows.map(c=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":c.getIsSelected()&&"selected",children:c.getVisibleCells().map(l=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(l.column.columnDef.cell,l.getContext())},l.id))},c.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:o.length,className:"h-24 text-center",children:"No results."})})})]})}function dt({card:s}){var x,d,g,h,u,m,b,w,C,T;const r=e.useDashboardStore(R=>R.themeStyle),t={colors:((d=(x=r==null?void 0:r.chart)==null?void 0:x.dataset)==null?void 0:d.backgroundColor)||[]};(g=s.customCardPreferences)!=null&&g.inputData;const{getCard:n}=e.useCustomVisual(((h=s.customCardPreferences)==null?void 0:h.url)||""),o=((u=s.customCardPreferences)==null?void 0:u.visualType)||"single",a=e.useEditorStore(R=>R.frame);if(e.useEditorActions(),!((m=s.customCardPreferences)!=null&&m.componentName))return null;const i=n((b=s.customCardPreferences)==null?void 0:b.componentName),c=R=>{console.log("data",R),s.customCardPreferences},l=Object.keys(((w=s.customCardPreferences)==null?void 0:w.dataInputCardIds)||{}).map(R=>{var p,S,f;const L=(S=(p=s.customCardPreferences)==null?void 0:p.dataInputCardIds)==null?void 0:S[R].cardId,I=(f=a==null?void 0:a.cards)==null?void 0:f.find(j=>j.id===L);return I||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(v.Suspense,{fallback:e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),children:[i&&o==="single"&&e.jsxRuntimeExports.jsx(i,{theme:t,settings:(C=s.customCardPreferences)==null?void 0:C.settings,onDataChange:c,data:s.data}),i&&o==="multiple"&&e.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-2",children:e.jsxRuntimeExports.jsx(i,{theme:t,onDataChange:c,settings:l.map(R=>{var L;return(L=R==null?void 0:R.customCardPreferences)==null?void 0:L.settings}),data:l.map(R=>(R==null?void 0:R.data)||[])})})]},(T=s.customCardPreferences)==null?void 0:T.componentName)})}function vs({className:s,...r}){var h,u;v.useState(0);const t=e.useDashboardStore(m=>m.themeStyle),n=e.useEditorStore(m=>m.card),o=((h=n.customCardPreferences)==null?void 0:h.showCardHeader)??!0,a=e.useEditorStore(m=>m.frame),i=e.useDashboardStore(m=>m.dashboard.filters);e.useDashboardStore(m=>m.filterValues),e.useEditorStore(m=>m.actions.setRunSql);const{updateFilter:c}=e.useDashboardActions(),l=i==null?void 0:i.find(m=>m.id===a.filterId),x=e.useEditorStore(m=>m.actions.setCard);if(v.useEffect(()=>{},[n.data,n.type,n.cfg,n.customCfg,t,n.preferences]),!n.id)return null;let d;n.data&&n.data.length>0&&(d=e.createChartConfig({data:n.data,cardType:n.type,cfg:n.cfg,customCfg:n.customCfg,preferences:n.preferences}));function g(m){return e.jsxRuntimeExports.jsx(dt,{card:m})}return e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",s),...r,children:[o&&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:n.title,onSave:m=>x({...n,title:m}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-5",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:n.title})})},n.title),e.jsxRuntimeExports.jsx(e.Editable,{text:n.description||"",onSave:m=>x({...n,description:m}),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",n.description]})},n.description)]}),l&&e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Editable,{className:"my-1",text:l.title||l.column,onSave:m=>c({...l,title:m}),children:e.jsxRuntimeExports.jsx(e.Label,{children:l.title})}),e.getFilterComponent(l)]})]}),e.jsxRuntimeExports.jsxs(e.CardContent,{className:"flex grow flex-col",children:[n.type==="custom"&&g(n),!["table","custom"].includes(n.type)&&d&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:d},JSON.stringify(d)+JSON.stringify(n.preferences)+((u=n==null?void 0:n.preferences)==null?void 0:u.customVisualCode)),n.type==="table"&&n.data&&n.data.length>0&&e.jsxRuntimeExports.jsx(e.$57acba87d6e25586$export$ccf8d8d7bbf3c2cc,{className:"flex min-h-0 flex-1 grow basis-0",children:e.jsxRuntimeExports.jsx(e.TableVisual,{card:n,data:n==null?void 0:n.data})})]})]})}function mt(){const[s,r]=v.useState(!1),[t,n]=v.useState(""),[o,a]=v.useState(""),[i,c]=v.useState(""),[l,x]=v.useState(""),d=e.useEditorStore(R=>R.card),g=e.useEditorStore(R=>R.card.customCfg),{setCardCustomCfg:h,setCustomVisualCode:u}=e.useEditorActions();function m(R){var p,S;const L={...R,data:{...R==null?void 0:R.data,datasets:(S=(p=R==null?void 0:R.data)==null?void 0:p.datasets)==null?void 0:S.map(f=>({...f,data:[]}))}};return JSON.stringify(L,null,1)}function b(){var L,I;if(!d.data||d.data.length===0)return;const R=e.createChartConfig({data:d.data,cardType:d.type,cfg:d.cfg,preferences:d.preferences});R&&(n(JSON.stringify(R,null,1)),(L=d==null?void 0:d.preferences)!=null&&L.customVisualCode&&c((I=d==null?void 0:d.preferences)==null?void 0:I.customVisualCode),g&&a(JSON.stringify(g,null,1)))}function w(){if(i&&u(i),!!o)try{const R=JSON.parse(o);return R?(h(R),x(""),a(""),R):void 0}catch(R){console.log(R),x("Invalid JSON")}}function C(){a(""),h(null)}function T(){let R;if(g){const L=e._.cloneDeep(d.cfg),I=e._.merge(L,g);return R=m(I),R}return t?(R=m(JSON.parse(t)),R):""}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:b,className:` ${g&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",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.jsxs(e.DialogHeader,{className:"",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(ze,{onClick:()=>{navigator.clipboard.writeText(d.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."})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[e.jsxRuntimeExports.jsx(vs,{className:"w-1/2 rounded shadow-none"}),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:[g&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),g?"Custom Config":"Default Config"]}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"output",children:"Output"}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"custom-code",children:"Custom Code"})]}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"bg-red-x mt-0 grow rounded-b border border-t-0 p-2",value:"output",children:e.jsxRuntimeExports.jsx(e.Textarea,{disabled:!0,value:t,className:"h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-config",children: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:"json",value:T(),onChange:R=>a(R)})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-code",children: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:"javascript",value:i,onChange:R=>c(R||"")})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:l}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!g,onClick:C,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:w,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>r(!1),variant:"outline",children:"Close"})]})]})]})}function Cs(s){return Z({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 Ns(s){return Z({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137.39,24.06A16,16,0,0,0,120,40V80.67a15.86,15.86,0,0,0,13.25,15.76A32,32,0,1,1,96,129.68c-.41-8.22,1.27-15,5-20.26h0a15.86,15.86,0,0,0-1.69-20.47L71.69,60.68a16,16,0,0,0-23.63,1.1A103.6,103.6,0,0,0,55,202.05,103.24,103.24,0,0,0,128,232h1.49A104.3,104.3,0,0,0,232,129.48C232.75,75.18,191.19,28.88,137.39,24.06ZM60.32,71.94l27.61,28.19,0,.06A43.29,43.29,0,0,0,80.44,120H40.36A87.13,87.13,0,0,1,60.32,71.94ZM40.37,136h40.3A48,48,0,0,0,120,175.34v40.3A88,88,0,0,1,40.37,136Zm149.77,54.14A87.45,87.45,0,0,1,136,215.61V175.34a47.55,47.55,0,0,0,24.73-12.23A48,48,0,0,0,136,80.66L136,40c45.52,4.08,80.67,43.28,80,89.25A87.45,87.45,0,0,1,190.14,190.14Z"},child:[]}]})(s)}function ws(s){return Z({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 ks(s){return Z({tag:"svg",attr:{viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},child:[]},{tag:"path",attr:{d:"M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0"},child:[]}]})(s)}function Is(s){return Z({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 Ds(s){return Z({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 Ls(s){return Z({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 Ts(s){return Z({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 As(s){const[r,t]=v.useState(null);return v.useEffect(()=>{s&&(async()=>{const a=(await Promise.resolve().then(()=>require("./lucide-react-Bh6u93Ue.js")))[s];t(a)})()},[s]),r}function zs(){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 pt({onChartTypeChange:s}){const[r,t]=v.useState([]),{data:n}=zs();return v.useEffect(()=>{(async()=>{var a;if(n){const c=(await Promise.all((a=n==null?void 0:n.plugins)==null?void 0:a.map(async l=>(await e.loadManifest(l.value)).visuals.map(g=>({name:g.name,icon:g.icon,url:l.value}))))).flat();t(c)}})()},[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,a)=>e.jsxRuntimeExports.jsx(jt,{text:o.name,onClick:()=>s("custom",o),icon:o.icon},o.url+o.name+a))})]})}const jt=({text:s,icon:r,onClick:t})=>{const n=As(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 ht(){var d,g;const[s,r]=v.useState(!1),t=e.useEditorStore(h=>h.card),n=t.type,{setCardType:o,setCardPreferences:a,setChartOrientation:i}=e.useEditorStore(h=>h.actions),{setCardCustomCfg:c,setCustomCardPreferences:l}=e.useEditorActions();function x(h,u){c(null),a({}),o(h),u&&l({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(Et,{className:"h-4 w-4",chartType:n,customIcon:(d=t.customCardPreferences)==null?void 0:d.icon,componentName:(g=t.customCardPreferences)==null?void 0:g.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:()=>x("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(be,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ye,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ds,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Is,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Te,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ks,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Le,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ns,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Cs,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ws,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ts,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(De,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ls,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Se,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("custom"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Me,{className:"size-4"})})]}),e.jsxRuntimeExports.jsx(pt,{onChartTypeChange:x})]})]})}function Et({chartType:s,className:r,customIcon:t,componentName:n}){const o=As(t||"");switch(s){case"bar":return e.jsxRuntimeExports.jsx(be,{className:r});case"line":return e.jsxRuntimeExports.jsx(ye,{className:r});case"pie":return e.jsxRuntimeExports.jsx(Le,{className:r});case"radar":return e.jsxRuntimeExports.jsx(Cs,{className:r});case"scatter":return e.jsxRuntimeExports.jsx(Te,{className:r});case"bubble":return e.jsxRuntimeExports.jsx(ks,{className:r});case"doughnut":return e.jsxRuntimeExports.jsx(Ns,{className:r});case"stackedBar":return e.jsxRuntimeExports.jsx(Ds,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(Is,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(ws,{className:r});case"pyramid":return e.jsxRuntimeExports.jsx(Ts,{className:r});case"range":return e.jsxRuntimeExports.jsx(De,{className:r});case"kpi":return e.jsxRuntimeExports.jsx(Ls,{className:r});case"text":return e.jsxRuntimeExports.jsx(Se,{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(Me,{className:r});default:return e.jsxRuntimeExports.jsx(e.Table,{className:r})}}function ft(){var o;const s=e.useEditorStore(a=>a.card),r=((o=s.customCardPreferences)==null?void 0:o.showCardHeader)??!0,{setCustomCardPreferences:t}=e.useEditorActions(),n=a=>{s.customCardPreferences&&t({...s.customCardPreferences,showCardHeader:a===!0})};return e.jsxRuntimeExports.jsxs(e.DropdownMenu,{children:[e.jsxRuntimeExports.jsx(e.DropdownMenuTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(Ae,{className:"size-4 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsxs(e.DropdownMenuContent,{align:"start",className:"w-40 text-muted-foreground",children:[e.jsxRuntimeExports.jsx(e.DropdownMenuCheckboxItem,{checked:r,onCheckedChange:n,children:"Card Header"}),e.jsxRuntimeExports.jsxs(e.DropdownMenuItem,{onClick:()=>{navigator.clipboard.writeText(s.id),e.Jt.success("Card ID copied to clipboard")},className:"cursor-pointer space-x-2",children:[e.jsxRuntimeExports.jsx(ze,{className:"size-4"}),e.jsxRuntimeExports.jsx("span",{children:"Copy Card ID"})]})]})]})}function $e(){const s=e.useEditorStore(p=>p.frame),r=e.useEditorStore(p=>p.card),t=e.useEditorStore(p=>p.card.data),n=e.useEditorStore(p=>p.isShowingVisual),o=e.useEditorStore(p=>p.isSqlRunning),a=e.useEditorStore(p=>p.queryError),i=e.useEditorStore(p=>p.pythonStdOut),c=e.useEditorStore(p=>p.actions.setRunSql);e.useEditorStore(p=>p.onSave),e.useEditorStore(p=>p.onClose),e.useEditorStore(p=>p.actions.setCardSql),e.useEditorStore(p=>p.actions.setCardType),e.useEditorStore(p=>p.actions.setSqlGen);const{setFrame:l,setCard:x,updateCardInFrame:d}=e.useEditorActions();if(!r)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function g(){const p={id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]};h(p)}function h(p){const S={...s,cards:[...s.cards,p],activeCardId:p.id};l(S),x(p)}function u(){const p={...r,id:e.v4(),title:`${r.title} Copy`,tabTitle:`${r.tabTitle} Copy`};h(p)}function m(p){const S=s.cards.filter(z=>z.id!==p),f=S[0],j={...s,cards:S,activeCardId:f.id};l(j),x(f)}function b(p){const S={...s,cards:s.cards.map(j=>j.id===r.id?r:j),activeCardId:p};l(S);const f=S.cards.find(j=>j.id===p);x(f),f.sql&&f.data&&f.data.length===0&&c(!0)}const w=(p,S)=>{console.log("handleDragStart",S),p.dataTransfer.setData("tabIndex",S.toString())},C=p=>{p.preventDefault()},T=(p,S)=>{const f=p.dataTransfer.getData("tabIndex");if(f===S.toString())return;const j=Array.from(s.cards),[z]=j.splice(parseInt(f),1);j.splice(S,0,z),l({...s,cards:j})};function R(p,S){return p.cards.length===1&&(S.displayTab===!0||S.displayTab===void 0)||p.activeCardId!==S.id&&(S.displayTab===!0||S.displayTab===void 0)?null:e.jsxRuntimeExports.jsx("div",{onClick:()=>{const f=S.displayTab===void 0?!1:!S.displayTab;x({...S,displayTab:f}),d({...S,displayTab:f})},children:S.displayTab===!0||S.displayTab===void 0?e.jsxRuntimeExports.jsx(es,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"}):e.jsxRuntimeExports.jsx(Ze,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"})})}function L(){return e.jsxRuntimeExports.jsxs(e.Tabs,{onValueChange:b,value:s.activeCardId,className:"flex grow flex-col",children:[s.cards.map(p=>e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow",value:p.id,children:I()},p.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((p,S)=>e.jsxRuntimeExports.jsx(e.Editable,{text:p.tabTitle||p.title,onSave:f=>{x({...r,tabTitle:f}),d({...r,tabTitle:f})},children:e.jsxRuntimeExports.jsxs(e.TabsTrigger,{draggable:!0,onDragStart:f=>w(f,S),onDragOver:C,onDrop:f=>T(f,S),className:"",value:p.id,children:[R(s,p),p.tabTitle||p.title,s.activeCardId===p.id&&s.cards.length>1&&e.jsxRuntimeExports.jsx(e.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>m(p.id)})]})},p.id)),e.jsxRuntimeExports.jsx(e.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:g,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:u,children:e.jsxRuntimeExports.jsx(Je,{className:"h-4 w-4"})})]})})]})}function I(){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,{isLoading:o,card:r})})}):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.TextCard,{isLoading:o,card:r})})}):e.jsxRuntimeExports.jsx(vs,{className:"grow border-none shadow-none"})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col py-3",children:[o&&e.jsxRuntimeExports.jsx(le,{className:"absolute bottom-0 left-0 right-0 top-0 z-10 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:[n&&e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsx(ht,{}),!["table","custom"].includes(r.type)&&e.jsxRuntimeExports.jsx(mt,{}),e.jsxRuntimeExports.jsx(ft,{})]}),e.jsxRuntimeExports.jsx(Rt,{})]}),n?L():e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[i&&e.jsxRuntimeExports.jsx(gt,{}),r.data&&r.data.length>0&&e.jsxRuntimeExports.jsx(ut,{data:t||[]}),a&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:a})]})]})}function gt(){const s=e.useEditorStore(t=>t.pythonStdOut);if(!s)return null;const r=s.replace(/\n/g,"<br>");return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("p",{className:"font-mono text-sm",children:"Output:"}),e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:r},className:"bg-muted p-2 font-mono text-sm"}),e.jsxRuntimeExports.jsx(e.Separator,{className:"mb-2"})]})}function Rt(){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 bt({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 de({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(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a.value,children:a.label},a.value))]})})]})}function Ge({children:s,summary:r}){return e.jsxRuntimeExports.jsxs("details",{className:"space-y-4 [&_summary>svg]:open:-rotate-180",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 yt(){var b,w;const s=e.useEditorStore(C=>C.card.customCardPreferences),{data:r}=zs(),t=(r==null?void 0:r.plugins)||[],n=e.useEditorStore(C=>C.card),o=e.useEditorStore(C=>C.frame),a=(s==null?void 0:s.visualType)||"single",{setCustomCardPreferences:i}=e.useEditorActions(),{components:c,manifest:l}=e.useCustomVisual((s==null?void 0:s.url)||""),x=(b=l==null?void 0:l.visuals)==null?void 0:b.find(C=>C.name===(s==null?void 0:s.componentName));function d(C,T){if(!s)return;const L={...(s==null?void 0:s.dataInputCardIds)||{},[C]:{cardId:T,hookRef:null}};i({...s,dataInputCardIds:L})}function g(C){var R,L;const T=(R=o==null?void 0:o.cards)==null?void 0:R.filter(I=>{var p;return((p=I==null?void 0:I.customCardPreferences)==null?void 0:p.visualType)!=="multiple"}).map(I=>({value:I.id,label:I.tabTitle||I.title}));return e.jsxRuntimeExports.jsx("div",{className:"space-y-2",children:(L=C==null?void 0:C.dataInputs)==null?void 0:L.map((I,p)=>{var S,f;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(de,{className:"col-span-6 h-8 w-full justify-between",label:"",options:T||[],value:((f=(S=s==null?void 0:s.dataInputCardIds)==null?void 0:S[p])==null?void 0:f.cardId)||"",onValueChange:j=>d(p,j)})]},p+Math.random())})})}function h(C,T,R=[]){var L,I;return s?C==="input"?e.jsxRuntimeExports.jsx(e.Input,{className:`h-8 w-full ${e.removeRing}`,value:((L=s==null?void 0:s.settings)==null?void 0:L[T])||"",onChange:p=>{i({...s,settings:{...s==null?void 0:s.settings,[T]:p.target.value}})}},T):C==="select"?e.jsxRuntimeExports.jsx(de,{className:"h-8 w-full",label:"",options:R,value:((I=s==null?void 0:s.settings)==null?void 0:I[T])||"",onValueChange:p=>{i({...s,settings:{...s==null?void 0:s.settings,[T]:p}})}}):null:null}function u(C){const T=Object.entries((C==null?void 0:C.settings)||{});return e.jsxRuntimeExports.jsx("div",{className:"space-y-3",children:T.map(([R,L])=>e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:L.title}),h(L.ui,R,L.options)]},R))})}function m(C){s&&i({...s,visualType:C,componentName:""})}return e.jsxRuntimeExports.jsxs("div",{className:"p-6",children:[e.jsxRuntimeExports.jsx(Ge,{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(de,{className:"h-8 w-full",label:"",options:t,value:(s==null?void 0:s.url)||"",onValueChange:C=>i({...s||{url:"",componentName:""},url:C})})})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&e.jsxRuntimeExports.jsx(bt,{options:[{value:"single",label:"Single Visual"},{value:"multiple",label:"Multi-Visual"}],value:a,onValueChange:m}),((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:c&&e.jsxRuntimeExports.jsx(de,{className:"h-8 w-full",label:"",options:(c==null?void 0:c.filter(C=>C.type===a).map(C=>({value:C.name,label:C.name})))||[],value:s.componentName,onValueChange:C=>{console.log("changing value",C),i({...s,componentName:C})}})})]})})]})})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),((w=n==null?void 0:n.customCardPreferences)==null?void 0:w.componentName)&&e.jsxRuntimeExports.jsxs(Ge,{summary:"Component Settings",children:[x&&x.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:g(x)})]}),x&&x.settings&&e.jsxRuntimeExports.jsx("div",{className:"space-y-3",children:e.jsxRuntimeExports.jsx("div",{className:"px-2",children:u(x)})})]})]})}function ce(){const[s,r]=v.useState([]);e.useEditorStore(d=>d.card.cfg);const t=e.useEditorStore(d=>d.card.preferences),{setCardCfg:n,setFilterOnClickColumnIndex:o,setCardPreferences:a}=e.useEditorStore(d=>d.actions),i=e.useEditorStore(d=>d.queryResultColumns);e.useEditorStore(d=>{var g;return(g=d.card.preferences)==null?void 0:g.filterOnClickColumnIndex}),v.useEffect(()=>{i&&r(new Array(i.length).fill(!1))},[i]);function c(d,g){var h,u;g?t!=null&&t.onClickFilter&&((h=t==null?void 0:t.onClickFilter)==null?void 0:h.length)>0?a({...t,onClickFilter:[...t.onClickFilter,{columnIndex:d,expression:""}]}):a({...t,onClickFilter:[{columnIndex:d,expression:""}]}):(a({...t,onClickFilter:(u=t==null?void 0:t.onClickFilter)==null?void 0:u.filter(m=>m.columnIndex!==d)}),r(m=>{const b=[...m];return b[d]=!1,b}))}function l(d,g){var u;const h=(u=t==null?void 0:t.onClickFilter)==null?void 0:u.map(m=>m.columnIndex===d?{...m,expression:g.target.value}:m);a({...t,onClickFilter:h})}function x(d){var g,h,u,m;if(s!=null&&s[d]||(h=(g=t==null?void 0:t.onClickFilter)==null?void 0:g.find(b=>b.columnIndex===d))!=null&&h.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(m=(u=t==null?void 0:t.onClickFilter)==null?void 0:u.find(b=>b.columnIndex===d))==null?void 0:m.expression,onChange:b=>l(d,b),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"}),i==null?void 0:i.map((d,g)=>{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(m=>m.columnIndex===g)),onCheckedChange:m=>c(g,m)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:d}),e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:((u=t==null?void 0:t.onClickFilter)==null?void 0:u.find(m=>m.columnIndex===g))&&e.jsxRuntimeExports.jsx(Fe,{onClick:()=>{r(m=>{const b=[...m];return b[g]=!m[g],b})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),x(g)]})},d)})]})}function ve(){var i,c,l;const s=e.useEditorStore(x=>x.card.preferences),r=e.useEditorStore(x=>x.card.cfg),{setCardCfg:t,setCardPreferences:n,setChartOrientation:o}=e.useEditorStore(x=>x.actions);(i=r==null?void 0:r.options)!=null&&i.indexAxis;function a(x){o(x)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((c=s==null?void 0:s.chartOptions)==null?void 0:c.indexAxis)||((l=r==null?void 0:r.options)==null?void 0:l.indexAxis)||"x",onValueChange:a,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 Ee="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function Ue(s,r){var n,o,a;const t=e.getNumberAxis(s,r);return((a=(o=(n=s==null?void 0:s.chartOptions)==null?void 0:n.scales)==null?void 0:o[t])==null?void 0:a.type)||"linear"}function Fs(){var K,q,W,N,A,H;const[s,r]=v.useState(!1),t=e.useEditorStore(D=>{var k;return(k=D.card)==null?void 0:k.preferences}),n=e.useEditorStore(D=>{var k;return(k=D.card)==null?void 0:k.cfg}),o=e.getNumberAxis(t,n),[a,i]=v.useState(Ue(t)),[c,l]=v.useState(((W=(q=(K=t==null?void 0:t.chartOptions)==null?void 0:K.scales)==null?void 0:q[o])==null?void 0:W.min)||""),[x,d]=v.useState(((H=(A=(N=t==null?void 0:t.chartOptions)==null?void 0:N.scales)==null?void 0:A[o])==null?void 0:H.max)||""),[g,h]=v.useState(c||x?"custom":"auto"),[u,m]=v.useState(""),[b,w]=v.useState(0),[C,T]=v.useState(""),[R,L]=v.useState(""),[I,p]=v.useState(""),S=e.useEditorStore(D=>D.actions.setCardPreferences),{updateCardInFrame:f}=e.useEditorActions(),j=e.useEditorStore(D=>D.card),z=e.useEditorStore(D=>{var k;return(k=D.card)==null?void 0:k.type}),O=["pie","doughnut","polarArea"].includes(z);v.useEffect(()=>{var D,k,$,M,G,U,te,ee,B,J,Y,ne,X,se;i(Ue(t)),l((($=(k=(D=t==null?void 0:t.chartOptions)==null?void 0:D.scales)==null?void 0:k[o])==null?void 0:$.min)===0?0:""),d(((U=(G=(M=t==null?void 0:t.chartOptions)==null?void 0:M.scales)==null?void 0:G[o])==null?void 0:U.max)||""),m(((J=(B=(ee=(te=t==null?void 0:t.chartOptions)==null?void 0:te.scales)==null?void 0:ee[o])==null?void 0:B.ticks)==null?void 0:J.stepSize)||""),w(((Y=t==null?void 0:t.numberAxisFormat)==null?void 0:Y.decimalPlaces)||0),T(((ne=t==null?void 0:t.numberAxisFormat)==null?void 0:ne.suffix)||""),L(((X=t==null?void 0:t.numberAxisFormat)==null?void 0:X.currency)||""),p(((se=t==null?void 0:t.numberAxisFormat)==null?void 0:se.locale)||"")},[s,t,o]);function F(D,k){return k===""||/^[0-9\b]+$/.test(k)?Number(k):Number(D)}function V(){const D=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(k=>k.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:R||"none",onValueChange:k=>L(k==="none"?"":k),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"}),D.map(k=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:k,children:k},k))]})})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:I,onValueChange:k=>p(k),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(k=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:k.locale,children:k.locale},k.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:b,onChange:k=>w(Number(k.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${Ee}`})]})]})}function P(){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:c,onChange:D=>l(k=>F(k,D.target.value)),className:`col-span-1 h-8 w-full ${Ee}`}),e.jsxRuntimeExports.jsx(e.Input,{value:x,onChange:D=>d(k=>F(k,D.target.value)),id:"max",className:`col-span-1 h-8 w-full ${Ee}`})]}),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:D=>m(k=>F(k,D.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${Ee}`})]})]})}function _(){var M;let D={};g==="custom"&&(D={min:c,max:x,ticks:{stepSize:u}});const k={...t||{},chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(M=t==null?void 0:t.chartOptions)==null?void 0:M.scales,[o]:{type:a,...a==="linear"?D:{}}}},numberAxisFormat:{decimalPlaces:b,suffix:C,currency:R,locale:I}};console.log(k),S(k);const $={...j,preferences:k};f($)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:D=>r(D),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:O,value:a,onValueChange:D=>i(D),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"})]})})]})]}),a=="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:O,id:"scale-option",value:g,onValueChange:D=>h(D),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"})]})]})]}),g==="custom"&&a=="linear"&&P(),V(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:_,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function St({idx:s}){var c;const r=e.useEditorStore(l=>{var x;return(x=l.card)==null?void 0:x.preferences}),t=e.useEditorStore(l=>{var x;return(x=l.card.preferences)==null?void 0:x.datasetOptions}),n=e.useEditorStore(l=>l.actions.setCardPreferences),o=(c=r==null?void 0:r.chartOptions)==null?void 0:c.indexAxis,a=t==null?void 0:t.find(l=>l.idx===s);function i(l,x){(l==="end"||l==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const d={display:l!=="none",align:l,anchor:l,clamp:!0};if(!a)n({...r,datasetOptions:[...t||[],{idx:x,datalabels:d}]});else{const g={...a};g.datalabels=d;const h=t==null?void 0:t.map(u=>u.idx===x?g:u);n({...r,datasetOptions:h})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(hs,{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:()=>i("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:()=>i("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(os,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(as,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(is,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function Ms(){const s=e.useEditorStore(l=>l.card),r=e.useEditorStore(l=>{var x,d,g;return(g=(d=(x=l==null?void 0:l.card)==null?void 0:x.preferences)==null?void 0:d.chartOptions)==null?void 0:g.indexAxis}),t=r==="y"?"Y axis":"X axis",n=r==="y"?"X axis":"Y axis",{keys:o,metricKeys:a,dimensionKeys:i}=e.getKeys(s.data||[]);let c=a;if(["stackedBar","stackedLine"].includes(s.type)){const l=e.pivotData({dataArray:s.data||[],groupKey:i[0],pivotKey:i[1],valueKey:c[0]}),{metricKeys:x}=e.getKeys(l);c=x}return o.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:t}),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:i[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:n}),e.jsxRuntimeExports.jsx(Fs,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:c.map((l,x)=>e.jsxRuntimeExports.jsx(vt,{col:l,idx:x},l))})]})]})}function vt({col:s,idx:r}){const t=e.useEditorStore(c=>{var l;return(l=c.card)==null?void 0:l.preferences}),n=e.useEditorStore(c=>{var l;return(l=c.card.preferences)==null?void 0:l.datasetOptions}),o=n==null?void 0:n.find(c=>c.idx===r),{setCardPreferences:a}=e.useEditorStore(c=>c.actions);function i(c){if(!o)a({...t,datasetOptions:[...n||[],{idx:r,type:c==="area"?"line":c,fill:c==="area"?"origin":""}]});else{const l={...o};l.type=c==="area"?"line":c,l.fill=c==="area"?"origin":"";const x=n==null?void 0:n.map(d=>d.idx===r?l:d);a({...t,datasetOptions:x})}}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(be,{onClick:()=>i("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ye,{onClick:()=>i("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Ke,{onClick:()=>i("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(e.Separator,{orientation:"vertical",className:"invisible size-4 cursor-pointer py-2 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),a=e.useDashboardStore(h=>h.dashboard.filters)||[],i=e.useDashboardStore(h=>h.actions.addFilter),c=e.useDashboardStore(h=>h.actions.removeFilter),l=e.useDashboardStore(h=>h.actions.removeFilterValue),{modelItems:x,tableName:d}=oe();function g(h,u="dashboard"){var p;const m=e.fmt(h.column_name),b=e.fmt(t||""),w=e.fmt(n||""),C=e.fmt(d);let T=e.getQualifiedTableName(w,C),R=`${T}.${m}`;const L=(p=x==null?void 0:x.find(S=>S.id===r))==null?void 0:p.name;r&&r!=="none"&&(R=`${e.DATAMODEL_NAMESPCACE}.${L}.${m}`,T=`${e.DATAMODEL_NAMESPCACE}.${L}`);const I=a==null?void 0:a.find(S=>S.column===R&&S.table===C&&(S.database===b||S.database===t));if(I)l(I.id),c(I.id);else{const S=e.v4();return d==="api"&&s?(i({location:u,id:S,column:R,title:h.column_name,dataType:h.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:e.getDefaultFilterSql(h.data_type,T,m)}),S):(i({id:S,location:u,column:R,title:h.column_name,dataType:h.data_type,table:o||"",database:t||"",connectionId:s||"",operation:"in",sql:e.getDefaultFilterSql(h.data_type,T,m)}),S)}}return{assignFilter:g}}function xe(){const s=e.useDashboardStore(c=>c.dashboard.filters),r=e.useEditorStore(c=>c.frame),{setFrame:t}=e.useEditorActions(),{columns:n}=oe(),{assignFilter:o}=Os();function a(c){const l=o(c,"frame");t({...r,filterId:l})}const i=s==null?void 0:s.find(c=>c.id===r.filterId);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Card Filter"}),e.jsxRuntimeExports.jsx(Ct,{onSelect:a,columns:n}),i&&e.jsxRuntimeExports.jsx(e.FilterHeader,{filter:i})]})}function Ct({columns:s,onSelect:r}){var i;const[t,n]=Be.useState(!1),[o,a]=Be.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?(i=s.find(c=>c.column_name===o))==null?void 0:i.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(c=>e.jsxRuntimeExports.jsxs(e.CommandItem,{value:c.column_name,onSelect:l=>{const x=l===o?"":l;a(x),n(!1),x&&r(c)},children:[c.column_name,e.jsxRuntimeExports.jsx(e.CheckIcon,{className:e.cn("ml-auto h-4 w-4",o===c.column_name?"opacity-100":"opacity-0")})]},c.column_name))})]})]})})]})}function Nt({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(ve,{}),e.jsxRuntimeExports.jsx(Ms,{})]})]}),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(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function Ve(){var o,a,i;const s=e.useEditorStore(c=>c.card.cfg),r=e.useEditorStore(c=>c.actions.setCardCfg),t=e.useEditorStore(c=>c.card.type);function n(c){var d;const l={datalabels:{display:c!=="none",align:c,anchor:c,clamp:!0}},x={...s,options:{...s==null?void 0:s.options,plugins:{...(d=s==null?void 0:s.options)==null?void 0:d.plugins,...l}}};r(x),console.log(c)}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(Fs,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(i=(a=(o=s==null?void 0:s.options)==null?void 0:o.plugins)==null?void 0:a.datalabels)==null?void 0:i.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 wt({cardType:s}){function r(t){const n="SELECT label, [group], x-axis, y-axis, radius FROM table",o="SELECT label, [group], x-axis, y-axis FROM table";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"?n:o}),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:a=>a.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(Ve,{})})]}),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(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}const kt={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},It={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function Dt(){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:Lt(s)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(s)&&e.jsxRuntimeExports.jsx(ve,{})}),!["kpi"].includes(s)&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsx(Ve,{}),e.jsxRuntimeExports.jsx(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})}function Lt(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(kt,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 Tt(){var l,x,d,g,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 m,b;return(b=(m=u.card.preferences)==null?void 0:m.formatNumber)==null?void 0:b.decimalPlaces});const n=e.useEditorStore(u=>{var m,b;return(b=(m=u.card.preferences)==null?void 0:m.formatNumber)==null?void 0:b.locale}),o=e.useEditorStore(u=>{var m,b;return(b=(m=u.card.preferences)==null?void 0:m.formatNumber)==null?void 0:b.currency});e.useEditorStore(u=>u.actions.setFilterOnClickField);const a=e.useEditorStore(u=>{var m,b;return(b=(m=u.card.preferences)==null?void 0:m.formatNumber)==null?void 0:b.colorRanges})||[],i=e.useEditorStore(u=>u.actions.setColorRanges),c=[...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:!!((l=s==null?void 0:s.formatNumber)!=null&&l.enabled),onCheckedChange:u=>{r({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:u}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((x=s==null?void 0:s.formatNumber)==null?void 0:x.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||"en-US",onValueChange:u=>{var m,b,w;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((b=s==null?void 0:s.formatNumber)==null?void 0:b.currency)||"",u||"en-US",((w=s==null?void 0:s.formatNumber)==null?void 0:w.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.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 m,b,w;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,u==="none"?"":u,((b=s==null?void 0:s.formatNumber)==null?void 0:b.locale)||"",((w=s==null?void 0:s.formatNumber)==null?void 0:w.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"),c.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:((g=(d=s==null?void 0:s.formatNumber)==null?void 0:d.decimalPlaces)==null?void 0:g.toString())||"0",onValueChange:u=>{var m,b,w;return t(Number(u),((m=s==null?void 0:s.formatNumber)==null?void 0:m.currency)||"",((b=s==null?void 0:s.formatNumber)==null?void 0:b.locale)||"",((w=s==null?void 0:s.formatNumber)==null?void 0:w.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 m,b,w;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((b=s==null?void 0:s.formatNumber)==null?void 0:b.currency)||"",((w=s==null?void 0:s.formatNumber)==null?void 0:w.locale)||"",u.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:a,setColorRanges:i})]})]})}function At(){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(Tt,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}function zt(){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 fe({cardType:s,docContent:r,suffix:t="Chart"}){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)} ${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:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-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:[s==="range"&&e.jsxRuntimeExports.jsx(ve,{}),s!=="text"&&e.jsxRuntimeExports.jsx(Ve,{}),s==="text"&&e.jsxRuntimeExports.jsx(zt,{})]})]}),!["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(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function Ft(){const s=e.useEditorStore(n=>{var o,a;return(a=(o=n==null?void 0:n.card)==null?void 0:o.preferences)==null?void 0:a.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(de,{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(ve,{}),t(),e.jsxRuntimeExports.jsx(Ms,{})]})]}),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(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function Mt({}){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(ce,{}),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 Ot=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."]})]}),Vt=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."]})]}),qt=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(Ft,{});case"pyramid":return e.jsxRuntimeExports.jsx(fe,{docContent:Ot,cardType:t});case"kpi":return e.jsxRuntimeExports.jsx(At,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(Nt,{cardType:t});case"range":return e.jsxRuntimeExports.jsx(fe,{docContent:Vt,cardType:t});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(fe,{cardType:t});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(wt,{cardType:t});case"table":return e.jsxRuntimeExports.jsx(Mt,{cardType:t});case"text":return e.jsxRuntimeExports.jsx(fe,{docContent:qt,cardType:t,suffix:"Visual"});case"custom":return e.jsxRuntimeExports.jsx(yt,{});default:return e.jsxRuntimeExports.jsx(Dt,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:r(s)})}function Bt(){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(xt,{})}),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 Ht({authToken:s,onSave:r,onClose:t}){e.useDashboardStore(i=>i.themeStyle);const n=e.useEditorStore(i=>i.actions.setOnSave),o=e.useEditorStore(i=>i.actions.setOnClose),a=e.useDashboardStore(i=>i.actions.setAuthToken);return v.useEffect(()=>{r&&n(r),t&&o(t)},[r,n,t,o]),v.useEffect(()=>{s&&s.accessToken&&a(s)},[s,a]),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(bs,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(Bt,{})})]})})}function Pt(){e.useDashboardStore(i=>i.selectedCardId);const s=e.useDashboardStore(i=>i.selectedSheetId),{setIsVisualEditing:r}=e.useDashboardStore(i=>i.actions),t=e.useDashboardStore(i=>i.isVisualEditing),n=e.useDashboardStore(i=>i.actions.updateFrame);function o(i){s&&(n(s,i),r(!1))}function a(){r(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{block:t,hidden:!t}),children:e.jsxRuntimeExports.jsx(Ht,{onSave:o,onClose:a})})}function $t(){e.useEditorStore(i=>i.selectedConnectionId),e.useEditorStore(i=>i.selectedDatamodelId);const s=e.useEditorStore(i=>i.selectedDatabaseName);e.useEditorStore(i=>i.selectedSchemaName);const r=e.useEditorStore(i=>i.selectedTableName),t=e.useDashboardStore(i=>i.dashboard.filters)||[];e.useDashboardStore(i=>i.actions.addFilter),e.useDashboardStore(i=>i.actions.removeFilter),e.useDashboardStore(i=>i.actions.removeFilterValue);const{modelItems:n,columns:o}=oe(),{assignFilter:a}=Os();return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:o==null?void 0:o.map(i=>{const c=t==null?void 0:t.find(l=>l.column===e.fmt(i.column_name)&&l.table===r&&l.database===s);return e.jsxRuntimeExports.jsx("div",{onClick:()=>a(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":c}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(Rs,{column:i}),e.jsxRuntimeExports.jsx("span",{children:i.column_name})]})},i.column_name)})})}function Gt(){e.useDashboardStore(r=>r.showFilters);const s=e.useDashboardStore(r=>r.actions.setShowFilters);return e.jsxRuntimeExports.jsxs("section",{className:"relative flex grow flex-col border-l px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"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(bs,{ColumnsComponent:()=>e.jsxRuntimeExports.jsx($t,{})})})]})}function Ut(){const s=e.useDashboardStore(t=>t.showFilters),r=e.useDashboardStore(t=>t.isVisualEditing);return e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("grow",{hidden:r,flex:!r}),children:[e.jsxRuntimeExports.jsx(e.DashboardTabs,{}),s&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(Gt,{})})]})}function Qt(){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 Kt({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.Te,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(Qt,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...t,children:[s&&e.jsxRuntimeExports.jsx(Us,{}),e.jsxRuntimeExports.jsx(Pt,{}),e.jsxRuntimeExports.jsx(Ut,{})]})]})]})})}exports.Box=Qe;exports.ChartArea=Ke;exports.ChartColumnIncreasing=be;exports.ChartLine=ye;exports.ChartNoAxesGantt=De;exports.ChartPie=Le;exports.ChartScatter=Te;exports.CircleX=We;exports.CopyPlus=Je;exports.DashboardPlus=Kt;exports.Database=Ye;exports.EllipsisVertical=Ae;exports.Eraser=Xe;exports.Eye=es;exports.EyeClosed=Ze;exports.Glasses=ss;exports.Hammer=ts;exports.Hash=ns;exports.House=rs;exports.Key=ze;exports.ListEnd=os;exports.ListStart=is;exports.ListX=as;exports.LoaderCircle=le;exports.MessageSquareMore=ls;exports.Network=cs;exports.Pencil=Fe;exports.Play=xs;exports.Plug2=us;exports.Save=ds;exports.SelectComponent=ae;exports.Shapes=Me;exports.ShieldQuestion=ms;exports.Sigma=ps;exports.SwatchBook=js;exports.Tag=hs;exports.ToggleLeft=Es;exports.Type=Se;exports.User=fs;exports.cleanCard=gs;exports.getDashbaordStateWithoutData=Oe;exports.useEditorAside=oe;
|
|
240
|
+
Visual Query Syntax: ${et}`,{data:p,isLoading:S,isFetching:f,isError:j,refetch:z}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(l==null?void 0:l.accessToken)||"",{user_content:`userContent: ${L} ${x?I:""}`}),enabled:!1});function O(N){if(N.toLowerCase().includes("bar"))m("bar");else if(N.toLowerCase().includes("line"))m("line");else if(N.toLowerCase().includes("bubble"))m("bubble");else if(N.toLowerCase().includes("scatter"))m("scatter");else if(N.toLowerCase().includes("stacked"))m("stackedBar");else if(N.toLowerCase().includes("pie"))m("pie");else if(N.toLowerCase().includes("donut")||N.toLowerCase().includes("doughnut"))m("doughnut");else if(N.toLowerCase().includes("radar"))m("radar");else return m("bar"),!1;return!0}v.useEffect(()=>{p&&w(N=>[...N,{role:"ai",content:p.response}])},[p]),v.useEffect(()=>{const N=setTimeout(()=>{var A;c.current&&(c.current.scroll({top:c.current.scrollHeight,behavior:"smooth"}),(A=i.current)==null||A.focus())},100);return()=>clearTimeout(N)},[b]);function F(){t&&(w(N=>[...N,{role:"user",content:t}]),O(t)&&d(!0),n(""),z())}v.useEffect(()=>{o&&(F(),a(!1))},[o,a]);const V={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},P={fontFamily:"monospace",fontSize:14,lineHeight:1.6},_={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},K={p:({node:N,...A})=>e.jsxRuntimeExports.jsx("p",{style:V,...A}),code:({node:N,...A})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...A}),pre:({node:N,...A})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:P,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:A.children}),e.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:q,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:H=>{const D=q(H);D&&(r(!1),g(D),u(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:N,...A})=>e.jsxRuntimeExports.jsx("li",{style:_,...A})};function q(N){const A=N.currentTarget.closest("pre");if(!A)return;const H=A.textContent||A.innerText;return navigator.clipboard.writeText(H).then(()=>console.log("Text copied to clipboard")).catch(D=>console.error("Error in copying text: ",D)),H}function W(){return b==null?void 0:b.map((N,A)=>N.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(fs,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:N.content})]},A):N.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:K,children:p==null?void 0:p.response.replace(/DuckDB/gi,"Semaphor")},A):e.jsxRuntimeExports.jsx("div",{},A))}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:c,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:W()})}),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:i,onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),n(""),F())},placeholder:"Type your question here...",onFocus:N=>{const A=N.target,H=A.value.length;A.setSelectionRange(H,H)},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:S||f,value:t,onChange:N=>n(N.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:F,children:!S&&!f?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(le,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var ys={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},He=v.createContext&&v.createContext(ys),tt=["attr","size","title"];function nt(s,r){if(s==null)return{};var t=rt(s,r),n,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(s);for(o=0;o<a.length;o++)n=a[o],!(r.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(s,n)&&(t[n]=s[n])}return t}function rt(s,r){if(s==null)return{};var t={},n=Object.keys(s),o,a;for(a=0;a<n.length;a++)o=n[a],!(r.indexOf(o)>=0)&&(t[o]=s[o]);return t}function ge(){return ge=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},ge.apply(this,arguments)}function Pe(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 Re(s){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?Pe(Object(t),!0).forEach(function(n){ot(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Pe(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function ot(s,r,t){return r=it(r),r in s?Object.defineProperty(s,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[r]=t,s}function it(s){var r=at(s,"string");return typeof r=="symbol"?r:String(r)}function at(s,r){if(typeof s!="object"||s===null)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 Ss(s){return s&&s.map((r,t)=>v.createElement(r.tag,Re({key:t},r.attr),Ss(r.child)))}function Z(s){return r=>v.createElement(lt,ge({attr:Re({},s.attr)},r),Ss(s.child))}function lt(s){var r=t=>{var{attr:n,size:o,title:a}=s,i=nt(s,tt),c=o||t.size||"1em",l;return t.className&&(l=t.className),s.className&&(l=(l?l+" ":"")+s.className),v.createElement("svg",ge({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,n,i,{className:l,style:Re(Re({color:s.color||t.color},t.style),s.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),a&&v.createElement("title",null,a),s.children)};return He!==void 0?v.createElement(He.Consumer,null,t=>r(t)):r(ys)}function ct(s){return Z({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 xt(){const{theme:s}=e.useTheme(),r=v.useRef(),t=v.useRef(),[n,o]=v.useState(!1),[a,i]=v.useState(!1),[c,l]=v.useState(!1),[x,d]=v.useState(""),[g,h]=v.useState(!1),{authToken:u}=e.useSemaphorContext();e.useDashboardStore(E=>E.selectedSheetId);const m=e.useDashboardStore(E=>E.dashboard.baseQueries),b=e.useEditorStore(E=>E.card),w=e.useDashboardStore(E=>E.theme),C=e.useEditorStore(E=>E.isShowingVisual);e.useDashboardStore(E=>E.onAcceptChanges);const T=e.useEditorStore(E=>E.selectedConnectionId),R=e.useEditorStore(E=>E.selectedDatabaseName),L=e.useEditorStore(E=>E.selectedDatamodelId),I=e.useEditorStore(E=>E.selectedSchemaName);e.useDashboardStore(E=>E.actions.updateFrameCard);const p=e.useEditorStore(E=>E.selectedTableName),S=e.useEditorStore(E=>E.card.sql),f=e.useEditorStore(E=>E.card.python),j=e.resolveBaseQuery(S,m),z=e.useEditorStore(E=>E.selectedConnectionId),O=e.useEditorStore(E=>E.frame),F=e.useDashboardStore(E=>E.filterValues),V=e.useEditorStore(E=>E.applyFilters),{setCardCustomCfg:P,setQueryResultColumns:_,setFilterValues:K,setCardSql:q,setCardPython:W,setQueryError:N,setPythonStdOut:A,setCardPreferences:H}=e.useEditorStore(E=>E.actions),D=e.useEditorStore(E=>E.onSave),k=e.useEditorStore(E=>E.actions.setApplyFilters),$=e.useEditorStore(E=>E.onClose),M=e.useEditorStore(E=>E.actions.setCardData),G=e.useEditorStore(E=>E.actions.setSqlGen),U=e.useEditorStore(E=>E.runSql),te=e.useEditorStore(E=>E.actions.setRunSql),ee=e.useEditorStore(E=>E.actions.setIsSqlRunning),{data:B,isLoading:J,isFetching:Y,isSuccess:ne,isError:X,error:se,status:qe,refetch:ie}=e.useQuery({queryKey:[j,f],queryFn:()=>e.postRequest("https://semaphor.cloud/api/v1/query",(u==null?void 0:u.accessToken)||"",{connection_id:z,sql:j,python:f===e.PYTHON_DEFAULT_CODE?"":f,active_filters:V?F:[]}),enabled:!1,retry:!1});v.useEffect(()=>{if(B&&(M(B.records),B.rowLimitExceeded&&e.Jt.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),A((B==null?void 0:B.output)||""),B.records.length>0)){const{dimensionKeys:E}=e.getKeys(B.records);_(E)}},[B,M,_,A]),v.useEffect(()=>{U&&(ie(),te(!1))},[U,ie,te]),v.useEffect(()=>{(J||Y)&&ee(!0),(X||ne)&&ee(!1),X?(N(se.message),M([]),_([]),A("")):N("")},[J,Y,B,A,X,ne,ee,M,_,N,se]);function Ce(){q(""),M([]),G({}),P(""),H({})}const me=E=>{t.current=E};function Ne(E,y){if(E.length===0)return"";if(y){const re=E.find(Q=>Q.id===y);if(re){const Q=re.tabTitle;if(Q=="All__Header")return E[0].id;if(Q&&Q.endsWith("__Header")){const Vs=Q.split("__")[0],_e=E.find(qs=>qs.tabTitle===Vs);return _e?_e.id:E[0].id}return y}}return E[0].id}function we(){let E=S;S&&!S.includes("{{")&&(E=Ws(S),q(E));const y={...b,lastSelectedSchema:I,lastSelectedDatamodelId:L,lastSelectedDatabase:R,lastSelectedTable:p,connectionId:T,type:C?b.type:"table",sql:E,customCfg:C?b.customCfg:null},re=O.cards.map(ke=>ke.id===b.id?y:ke),Q={...O,cards:re,activeCardId:Ne(re,O.activeCardId)};D==null||D(Q)}function pe(){$==null||$()}v.useEffect(()=>{const E=r.current,y=t.current;if(E){const re=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",Q=w==="system"?re:w;E.editor.defineTheme("default",{base:Q==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":Q==="light"?"#ffffff":e.getCssVariableValue("--semaphor-background")}}),E.editor.setTheme("default")}return y&&E&&y.addCommand(E.KeyMod.Shift|E.KeyCode.Enter,function(){return console.log("Executing query..."),ie(),!1}),()=>{}},[s,w,r.current]);function ue(E){r.current=E}function je(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[a&&e.jsxRuntimeExports.jsx("div",{className:"xbg-yellow-100 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(Ys,{checked:V,onCheckedChange:()=>k(!V),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(Zs,{}),F&&a&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>i(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:E=>{if(E)try{JSON.parse(E),K(JSON.parse(E))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(F,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),F&&!a&&e.jsxRuntimeExports.jsx(e.Filter,{onClick:()=>i(!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":V})})]})}function he(){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",{role:"sql-container",className:"relative flex w-[99%]",children:e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",className:"pt-3",onChange:E=>{q(E)},value:S,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",beforeMount:ue,onMount:me})}),n&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm 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",{role:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"pt-3",theme:"default",onChange:E=>{W(E&&E.trim()||"")},value:f||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:ue,onMount:me})}),e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm 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",{role:"sql-editor",className:"relative flex grow justify-between overflow-y-scroll",children:[he(),je()]}),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:J||Y,onClick:()=>{ie()},className:"shrink-0",size:"sm",variant:"outline",children:[J||Y?e.jsxRuntimeExports.jsx(le,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(xs,{className:"mr-2 h-4 w-4"}),"Run"]}),X&&e.jsxRuntimeExports.jsx(Js,{error:se.message,setShowAIDialog:l,setTriggerAIRun:h,setUserInputforAI:d}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:Ce,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(Xe,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:n,onPressedChange:E=>o(E),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(ct,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(st,{open:c,setOpen:l,userInput:x,triggerAIRun:g,setTriggerAIRun:h,setUserInput:E=>d(E)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:we,size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:pe,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function ut({data:s}){var i;const[r,t]=v.useState([]),o=Object.keys(s[0]).map(c=>({accessorKey:c,header:({column:l})=>{const x=l.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>l.toggleSorting(l.getIsSorted()==="asc"),children:[c,x==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):x==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),a=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.jsxs(e.Table$1,{children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:a.getHeaderGroups().map(c=>e.jsxRuntimeExports.jsx(e.TableRow,{children:c.headers.map(l=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 bg-muted",children:l.isPlaceholder?null:e.flexRender(l.column.columnDef.header,l.getContext())},l.id))},c.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(i=a.getRowModel().rows)!=null&&i.length?a.getRowModel().rows.map(c=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":c.getIsSelected()&&"selected",children:c.getVisibleCells().map(l=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(l.column.columnDef.cell,l.getContext())},l.id))},c.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:o.length,className:"h-24 text-center",children:"No results."})})})]})}function dt({card:s}){var x,d,g,h,u,m,b,w,C,T;const r=e.useDashboardStore(R=>R.themeStyle),t={colors:((d=(x=r==null?void 0:r.chart)==null?void 0:x.dataset)==null?void 0:d.backgroundColor)||[]};(g=s.customCardPreferences)!=null&&g.inputData;const{getCard:n}=e.useCustomVisual(((h=s.customCardPreferences)==null?void 0:h.url)||""),o=((u=s.customCardPreferences)==null?void 0:u.visualType)||"single",a=e.useEditorStore(R=>R.frame);if(e.useEditorActions(),!((m=s.customCardPreferences)!=null&&m.componentName))return null;const i=n((b=s.customCardPreferences)==null?void 0:b.componentName),c=R=>{console.log("data",R),s.customCardPreferences},l=Object.keys(((w=s.customCardPreferences)==null?void 0:w.dataInputCardIds)||{}).map(R=>{var p,S,f;const L=(S=(p=s.customCardPreferences)==null?void 0:p.dataInputCardIds)==null?void 0:S[R].cardId,I=(f=a==null?void 0:a.cards)==null?void 0:f.find(j=>j.id===L);return I||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(v.Suspense,{fallback:e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),children:[i&&o==="single"&&e.jsxRuntimeExports.jsx(i,{theme:t,settings:(C=s.customCardPreferences)==null?void 0:C.settings,onDataChange:c,data:s.data}),i&&o==="multiple"&&e.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-2",children:e.jsxRuntimeExports.jsx(i,{theme:t,onDataChange:c,settings:l.map(R=>{var L;return(L=R==null?void 0:R.customCardPreferences)==null?void 0:L.settings}),data:l.map(R=>(R==null?void 0:R.data)||[])})})]},(T=s.customCardPreferences)==null?void 0:T.componentName)})}function vs({className:s,...r}){var h,u;v.useState(0);const t=e.useDashboardStore(m=>m.themeStyle),n=e.useEditorStore(m=>m.card),o=((h=n.customCardPreferences)==null?void 0:h.showCardHeader)??!0,a=e.useEditorStore(m=>m.frame),i=e.useDashboardStore(m=>m.dashboard.filters);e.useDashboardStore(m=>m.filterValues),e.useEditorStore(m=>m.actions.setRunSql);const{updateFilter:c}=e.useDashboardActions(),l=i==null?void 0:i.find(m=>m.id===a.filterId),x=e.useEditorStore(m=>m.actions.setCard);if(v.useEffect(()=>{},[n.data,n.type,n.cfg,n.customCfg,t,n.preferences]),!n.id)return null;let d;n.data&&n.data.length>0&&(d=e.createChartConfig({data:n.data,cardType:n.type,cfg:n.cfg,customCfg:n.customCfg,preferences:n.preferences}));function g(m){return e.jsxRuntimeExports.jsx(dt,{card:m})}return e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",s),...r,children:[o&&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:n.title,onSave:m=>x({...n,title:m}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-5",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:n.title})})},n.title),e.jsxRuntimeExports.jsx(e.Editable,{text:n.description||"",onSave:m=>x({...n,description:m}),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",n.description]})},n.description)]}),l&&e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Editable,{className:"my-1",text:l.title||l.column,onSave:m=>c({...l,title:m}),children:e.jsxRuntimeExports.jsx(e.Label,{children:l.title})}),e.getFilterComponent(l)]})]}),e.jsxRuntimeExports.jsxs(e.CardContent,{className:"flex grow flex-col",children:[n.type==="custom"&&g(n),!["table","custom"].includes(n.type)&&d&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:d},JSON.stringify(d)+JSON.stringify(n.preferences)+((u=n==null?void 0:n.preferences)==null?void 0:u.customVisualCode)),n.type==="table"&&n.data&&n.data.length>0&&e.jsxRuntimeExports.jsx(e.$57acba87d6e25586$export$ccf8d8d7bbf3c2cc,{className:"flex min-h-0 flex-1 grow basis-0",children:e.jsxRuntimeExports.jsx(e.TableVisual,{card:n,data:n==null?void 0:n.data})})]})]})}function mt(){const[s,r]=v.useState(!1),[t,n]=v.useState(""),[o,a]=v.useState(""),[i,c]=v.useState(""),[l,x]=v.useState(""),d=e.useEditorStore(R=>R.card),g=e.useEditorStore(R=>R.card.customCfg),{setCardCustomCfg:h,setCustomVisualCode:u}=e.useEditorActions();function m(R){var p,S;const L={...R,data:{...R==null?void 0:R.data,datasets:(S=(p=R==null?void 0:R.data)==null?void 0:p.datasets)==null?void 0:S.map(f=>({...f,data:[]}))}};return JSON.stringify(L,null,1)}function b(){var L,I;if(!d.data||d.data.length===0)return;const R=e.createChartConfig({data:d.data,cardType:d.type,cfg:d.cfg,preferences:d.preferences});R&&(n(JSON.stringify(R,null,1)),(L=d==null?void 0:d.preferences)!=null&&L.customVisualCode&&c((I=d==null?void 0:d.preferences)==null?void 0:I.customVisualCode),g&&a(JSON.stringify(g,null,1)))}function w(){if(i&&u(i),!!o)try{const R=JSON.parse(o);return R?(h(R),x(""),a(""),R):void 0}catch(R){console.log(R),x("Invalid JSON")}}function C(){a(""),h(null)}function T(){let R;if(g){const L=e._.cloneDeep(d.cfg),I=e._.merge(L,g);return R=m(I),R}return t?(R=m(JSON.parse(t)),R):""}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:b,className:` ${g&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",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.jsxs(e.DialogHeader,{className:"",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(ze,{onClick:()=>{navigator.clipboard.writeText(d.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."})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[e.jsxRuntimeExports.jsx(vs,{className:"w-1/2 rounded shadow-none"}),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:[g&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),g?"Custom Config":"Default Config"]}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"output",children:"Output"}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"custom-code",children:"Custom Code"})]}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"bg-red-x mt-0 grow rounded-b border border-t-0 p-2",value:"output",children:e.jsxRuntimeExports.jsx(e.Textarea,{disabled:!0,value:t,className:"h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-config",children: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:"json",value:T(),onChange:R=>a(R)})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-code",children: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:"javascript",value:i,onChange:R=>c(R||"")})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:l}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!g,onClick:C,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:w,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>r(!1),variant:"outline",children:"Close"})]})]})]})}function Cs(s){return Z({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 Ns(s){return Z({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137.39,24.06A16,16,0,0,0,120,40V80.67a15.86,15.86,0,0,0,13.25,15.76A32,32,0,1,1,96,129.68c-.41-8.22,1.27-15,5-20.26h0a15.86,15.86,0,0,0-1.69-20.47L71.69,60.68a16,16,0,0,0-23.63,1.1A103.6,103.6,0,0,0,55,202.05,103.24,103.24,0,0,0,128,232h1.49A104.3,104.3,0,0,0,232,129.48C232.75,75.18,191.19,28.88,137.39,24.06ZM60.32,71.94l27.61,28.19,0,.06A43.29,43.29,0,0,0,80.44,120H40.36A87.13,87.13,0,0,1,60.32,71.94ZM40.37,136h40.3A48,48,0,0,0,120,175.34v40.3A88,88,0,0,1,40.37,136Zm149.77,54.14A87.45,87.45,0,0,1,136,215.61V175.34a47.55,47.55,0,0,0,24.73-12.23A48,48,0,0,0,136,80.66L136,40c45.52,4.08,80.67,43.28,80,89.25A87.45,87.45,0,0,1,190.14,190.14Z"},child:[]}]})(s)}function ws(s){return Z({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 ks(s){return Z({tag:"svg",attr:{viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},child:[]},{tag:"path",attr:{d:"M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0"},child:[]}]})(s)}function Is(s){return Z({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 Ds(s){return Z({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 Ls(s){return Z({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 Ts(s){return Z({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 As(s){const[r,t]=v.useState(null);return v.useEffect(()=>{s&&(async()=>{const a=(await Promise.resolve().then(()=>require("./lucide-react-t1mmrDBn.js")))[s];t(a)})()},[s]),r}function zs(){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 pt({onChartTypeChange:s}){const[r,t]=v.useState([]),{data:n}=zs();return v.useEffect(()=>{(async()=>{var a;if(n){const c=(await Promise.all((a=n==null?void 0:n.plugins)==null?void 0:a.map(async l=>(await e.loadManifest(l.value)).visuals.map(g=>({name:g.name,icon:g.icon,url:l.value}))))).flat();t(c)}})()},[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,a)=>e.jsxRuntimeExports.jsx(jt,{text:o.name,onClick:()=>s("custom",o),icon:o.icon},o.url+o.name+a))})]})}const jt=({text:s,icon:r,onClick:t})=>{const n=As(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 ht(){var d,g;const[s,r]=v.useState(!1),t=e.useEditorStore(h=>h.card),n=t.type,{setCardType:o,setCardPreferences:a,setChartOrientation:i}=e.useEditorStore(h=>h.actions),{setCardCustomCfg:c,setCustomCardPreferences:l}=e.useEditorActions();function x(h,u){c(null),a({}),o(h),u&&l({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(Et,{className:"h-4 w-4",chartType:n,customIcon:(d=t.customCardPreferences)==null?void 0:d.icon,componentName:(g=t.customCardPreferences)==null?void 0:g.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:()=>x("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(be,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ye,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ds,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Is,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Te,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ks,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Le,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ns,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Cs,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ws,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ts,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(De,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ls,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Se,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("custom"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Me,{className:"size-4"})})]}),e.jsxRuntimeExports.jsx(pt,{onChartTypeChange:x})]})]})}function Et({chartType:s,className:r,customIcon:t,componentName:n}){const o=As(t||"");switch(s){case"bar":return e.jsxRuntimeExports.jsx(be,{className:r});case"line":return e.jsxRuntimeExports.jsx(ye,{className:r});case"pie":return e.jsxRuntimeExports.jsx(Le,{className:r});case"radar":return e.jsxRuntimeExports.jsx(Cs,{className:r});case"scatter":return e.jsxRuntimeExports.jsx(Te,{className:r});case"bubble":return e.jsxRuntimeExports.jsx(ks,{className:r});case"doughnut":return e.jsxRuntimeExports.jsx(Ns,{className:r});case"stackedBar":return e.jsxRuntimeExports.jsx(Ds,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(Is,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(ws,{className:r});case"pyramid":return e.jsxRuntimeExports.jsx(Ts,{className:r});case"range":return e.jsxRuntimeExports.jsx(De,{className:r});case"kpi":return e.jsxRuntimeExports.jsx(Ls,{className:r});case"text":return e.jsxRuntimeExports.jsx(Se,{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(Me,{className:r});default:return e.jsxRuntimeExports.jsx(e.Table,{className:r})}}function ft(){var o;const s=e.useEditorStore(a=>a.card),r=((o=s.customCardPreferences)==null?void 0:o.showCardHeader)??!0,{setCustomCardPreferences:t}=e.useEditorActions(),n=a=>{s.customCardPreferences&&t({...s.customCardPreferences,showCardHeader:a===!0})};return e.jsxRuntimeExports.jsxs(e.DropdownMenu,{children:[e.jsxRuntimeExports.jsx(e.DropdownMenuTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(Ae,{className:"size-4 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsxs(e.DropdownMenuContent,{align:"start",className:"w-40 text-muted-foreground",children:[e.jsxRuntimeExports.jsx(e.DropdownMenuCheckboxItem,{checked:r,onCheckedChange:n,children:"Card Header"}),e.jsxRuntimeExports.jsxs(e.DropdownMenuItem,{onClick:()=>{navigator.clipboard.writeText(s.id),e.Jt.success("Card ID copied to clipboard")},className:"cursor-pointer space-x-2",children:[e.jsxRuntimeExports.jsx(ze,{className:"size-4"}),e.jsxRuntimeExports.jsx("span",{children:"Copy Card ID"})]})]})]})}function $e(){const s=e.useEditorStore(p=>p.frame),r=e.useEditorStore(p=>p.card),t=e.useEditorStore(p=>p.card.data),n=e.useEditorStore(p=>p.isShowingVisual),o=e.useEditorStore(p=>p.isSqlRunning),a=e.useEditorStore(p=>p.queryError),i=e.useEditorStore(p=>p.pythonStdOut),c=e.useEditorStore(p=>p.actions.setRunSql);e.useEditorStore(p=>p.onSave),e.useEditorStore(p=>p.onClose),e.useEditorStore(p=>p.actions.setCardSql),e.useEditorStore(p=>p.actions.setCardType),e.useEditorStore(p=>p.actions.setSqlGen);const{setFrame:l,setCard:x,updateCardInFrame:d}=e.useEditorActions();if(!r)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function g(){const p={id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]};h(p)}function h(p){const S={...s,cards:[...s.cards,p],activeCardId:p.id};l(S),x(p)}function u(){const p={...r,id:e.v4(),title:`${r.title} Copy`,tabTitle:`${r.tabTitle} Copy`};h(p)}function m(p){const S=s.cards.filter(z=>z.id!==p),f=S[0],j={...s,cards:S,activeCardId:f.id};l(j),x(f)}function b(p){const S={...s,cards:s.cards.map(j=>j.id===r.id?r:j),activeCardId:p};l(S);const f=S.cards.find(j=>j.id===p);x(f),f.sql&&f.data&&f.data.length===0&&c(!0)}const w=(p,S)=>{console.log("handleDragStart",S),p.dataTransfer.setData("tabIndex",S.toString())},C=p=>{p.preventDefault()},T=(p,S)=>{const f=p.dataTransfer.getData("tabIndex");if(f===S.toString())return;const j=Array.from(s.cards),[z]=j.splice(parseInt(f),1);j.splice(S,0,z),l({...s,cards:j})};function R(p,S){return p.cards.length===1&&(S.displayTab===!0||S.displayTab===void 0)||p.activeCardId!==S.id&&(S.displayTab===!0||S.displayTab===void 0)?null:e.jsxRuntimeExports.jsx("div",{onClick:()=>{const f=S.displayTab===void 0?!1:!S.displayTab;x({...S,displayTab:f}),d({...S,displayTab:f})},children:S.displayTab===!0||S.displayTab===void 0?e.jsxRuntimeExports.jsx(es,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"}):e.jsxRuntimeExports.jsx(Ze,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"})})}function L(){return e.jsxRuntimeExports.jsxs(e.Tabs,{onValueChange:b,value:s.activeCardId,className:"flex grow flex-col",children:[s.cards.map(p=>e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow",value:p.id,children:I()},p.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((p,S)=>e.jsxRuntimeExports.jsx(e.Editable,{text:p.tabTitle||p.title,onSave:f=>{x({...r,tabTitle:f}),d({...r,tabTitle:f})},children:e.jsxRuntimeExports.jsxs(e.TabsTrigger,{draggable:!0,onDragStart:f=>w(f,S),onDragOver:C,onDrop:f=>T(f,S),className:"",value:p.id,children:[R(s,p),p.tabTitle||p.title,s.activeCardId===p.id&&s.cards.length>1&&e.jsxRuntimeExports.jsx(e.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>m(p.id)})]})},p.id)),e.jsxRuntimeExports.jsx(e.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:g,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:u,children:e.jsxRuntimeExports.jsx(Je,{className:"h-4 w-4"})})]})})]})}function I(){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,{isLoading:o,card:r})})}):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.TextCard,{isLoading:o,card:r})})}):e.jsxRuntimeExports.jsx(vs,{className:"grow border-none shadow-none"})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col py-3",children:[o&&e.jsxRuntimeExports.jsx(le,{className:"absolute bottom-0 left-0 right-0 top-0 z-10 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:[n&&e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsx(ht,{}),!["table","custom"].includes(r.type)&&e.jsxRuntimeExports.jsx(mt,{}),e.jsxRuntimeExports.jsx(ft,{})]}),e.jsxRuntimeExports.jsx(Rt,{})]}),n?L():e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[i&&e.jsxRuntimeExports.jsx(gt,{}),r.data&&r.data.length>0&&e.jsxRuntimeExports.jsx(ut,{data:t||[]}),a&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:a})]})]})}function gt(){const s=e.useEditorStore(t=>t.pythonStdOut);if(!s)return null;const r=s.replace(/\n/g,"<br>");return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("p",{className:"font-mono text-sm",children:"Output:"}),e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:r},className:"bg-muted p-2 font-mono text-sm"}),e.jsxRuntimeExports.jsx(e.Separator,{className:"mb-2"})]})}function Rt(){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 bt({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 de({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(a=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:a.value,children:a.label},a.value))]})})]})}function Ge({children:s,summary:r}){return e.jsxRuntimeExports.jsxs("details",{className:"space-y-4 [&_summary>svg]:open:-rotate-180",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 yt(){var b,w;const s=e.useEditorStore(C=>C.card.customCardPreferences),{data:r}=zs(),t=(r==null?void 0:r.plugins)||[],n=e.useEditorStore(C=>C.card),o=e.useEditorStore(C=>C.frame),a=(s==null?void 0:s.visualType)||"single",{setCustomCardPreferences:i}=e.useEditorActions(),{components:c,manifest:l}=e.useCustomVisual((s==null?void 0:s.url)||""),x=(b=l==null?void 0:l.visuals)==null?void 0:b.find(C=>C.name===(s==null?void 0:s.componentName));function d(C,T){if(!s)return;const L={...(s==null?void 0:s.dataInputCardIds)||{},[C]:{cardId:T,hookRef:null}};i({...s,dataInputCardIds:L})}function g(C){var R,L;const T=(R=o==null?void 0:o.cards)==null?void 0:R.filter(I=>{var p;return((p=I==null?void 0:I.customCardPreferences)==null?void 0:p.visualType)!=="multiple"}).map(I=>({value:I.id,label:I.tabTitle||I.title}));return e.jsxRuntimeExports.jsx("div",{className:"space-y-2",children:(L=C==null?void 0:C.dataInputs)==null?void 0:L.map((I,p)=>{var S,f;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(de,{className:"col-span-6 h-8 w-full justify-between",label:"",options:T||[],value:((f=(S=s==null?void 0:s.dataInputCardIds)==null?void 0:S[p])==null?void 0:f.cardId)||"",onValueChange:j=>d(p,j)})]},p+Math.random())})})}function h(C,T,R=[]){var L,I;return s?C==="input"?e.jsxRuntimeExports.jsx(e.Input,{className:`h-8 w-full ${e.removeRing}`,value:((L=s==null?void 0:s.settings)==null?void 0:L[T])||"",onChange:p=>{i({...s,settings:{...s==null?void 0:s.settings,[T]:p.target.value}})}},T):C==="select"?e.jsxRuntimeExports.jsx(de,{className:"h-8 w-full",label:"",options:R,value:((I=s==null?void 0:s.settings)==null?void 0:I[T])||"",onValueChange:p=>{i({...s,settings:{...s==null?void 0:s.settings,[T]:p}})}}):null:null}function u(C){const T=Object.entries((C==null?void 0:C.settings)||{});return e.jsxRuntimeExports.jsx("div",{className:"space-y-3",children:T.map(([R,L])=>e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:L.title}),h(L.ui,R,L.options)]},R))})}function m(C){s&&i({...s,visualType:C,componentName:""})}return e.jsxRuntimeExports.jsxs("div",{className:"p-6",children:[e.jsxRuntimeExports.jsx(Ge,{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(de,{className:"h-8 w-full",label:"",options:t,value:(s==null?void 0:s.url)||"",onValueChange:C=>i({...s||{url:"",componentName:""},url:C})})})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&e.jsxRuntimeExports.jsx(bt,{options:[{value:"single",label:"Single Visual"},{value:"multiple",label:"Multi-Visual"}],value:a,onValueChange:m}),((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:c&&e.jsxRuntimeExports.jsx(de,{className:"h-8 w-full",label:"",options:(c==null?void 0:c.filter(C=>C.type===a).map(C=>({value:C.name,label:C.name})))||[],value:s.componentName,onValueChange:C=>{console.log("changing value",C),i({...s,componentName:C})}})})]})})]})})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),((w=n==null?void 0:n.customCardPreferences)==null?void 0:w.componentName)&&e.jsxRuntimeExports.jsxs(Ge,{summary:"Component Settings",children:[x&&x.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:g(x)})]}),x&&x.settings&&e.jsxRuntimeExports.jsx("div",{className:"space-y-3",children:e.jsxRuntimeExports.jsx("div",{className:"px-2",children:u(x)})})]})]})}function ce(){const[s,r]=v.useState([]);e.useEditorStore(d=>d.card.cfg);const t=e.useEditorStore(d=>d.card.preferences),{setCardCfg:n,setFilterOnClickColumnIndex:o,setCardPreferences:a}=e.useEditorStore(d=>d.actions),i=e.useEditorStore(d=>d.queryResultColumns);e.useEditorStore(d=>{var g;return(g=d.card.preferences)==null?void 0:g.filterOnClickColumnIndex}),v.useEffect(()=>{i&&r(new Array(i.length).fill(!1))},[i]);function c(d,g){var h,u;g?t!=null&&t.onClickFilter&&((h=t==null?void 0:t.onClickFilter)==null?void 0:h.length)>0?a({...t,onClickFilter:[...t.onClickFilter,{columnIndex:d,expression:""}]}):a({...t,onClickFilter:[{columnIndex:d,expression:""}]}):(a({...t,onClickFilter:(u=t==null?void 0:t.onClickFilter)==null?void 0:u.filter(m=>m.columnIndex!==d)}),r(m=>{const b=[...m];return b[d]=!1,b}))}function l(d,g){var u;const h=(u=t==null?void 0:t.onClickFilter)==null?void 0:u.map(m=>m.columnIndex===d?{...m,expression:g.target.value}:m);a({...t,onClickFilter:h})}function x(d){var g,h,u,m;if(s!=null&&s[d]||(h=(g=t==null?void 0:t.onClickFilter)==null?void 0:g.find(b=>b.columnIndex===d))!=null&&h.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(m=(u=t==null?void 0:t.onClickFilter)==null?void 0:u.find(b=>b.columnIndex===d))==null?void 0:m.expression,onChange:b=>l(d,b),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"}),i==null?void 0:i.map((d,g)=>{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(m=>m.columnIndex===g)),onCheckedChange:m=>c(g,m)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:d}),e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:((u=t==null?void 0:t.onClickFilter)==null?void 0:u.find(m=>m.columnIndex===g))&&e.jsxRuntimeExports.jsx(Fe,{onClick:()=>{r(m=>{const b=[...m];return b[g]=!m[g],b})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),x(g)]})},d)})]})}function ve(){var i,c,l;const s=e.useEditorStore(x=>x.card.preferences),r=e.useEditorStore(x=>x.card.cfg),{setCardCfg:t,setCardPreferences:n,setChartOrientation:o}=e.useEditorStore(x=>x.actions);(i=r==null?void 0:r.options)!=null&&i.indexAxis;function a(x){o(x)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((c=s==null?void 0:s.chartOptions)==null?void 0:c.indexAxis)||((l=r==null?void 0:r.options)==null?void 0:l.indexAxis)||"x",onValueChange:a,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 Ee="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function Ue(s,r){var n,o,a;const t=e.getNumberAxis(s,r);return((a=(o=(n=s==null?void 0:s.chartOptions)==null?void 0:n.scales)==null?void 0:o[t])==null?void 0:a.type)||"linear"}function Fs(){var K,q,W,N,A,H;const[s,r]=v.useState(!1),t=e.useEditorStore(D=>{var k;return(k=D.card)==null?void 0:k.preferences}),n=e.useEditorStore(D=>{var k;return(k=D.card)==null?void 0:k.cfg}),o=e.getNumberAxis(t,n),[a,i]=v.useState(Ue(t)),[c,l]=v.useState(((W=(q=(K=t==null?void 0:t.chartOptions)==null?void 0:K.scales)==null?void 0:q[o])==null?void 0:W.min)||""),[x,d]=v.useState(((H=(A=(N=t==null?void 0:t.chartOptions)==null?void 0:N.scales)==null?void 0:A[o])==null?void 0:H.max)||""),[g,h]=v.useState(c||x?"custom":"auto"),[u,m]=v.useState(""),[b,w]=v.useState(0),[C,T]=v.useState(""),[R,L]=v.useState(""),[I,p]=v.useState(""),S=e.useEditorStore(D=>D.actions.setCardPreferences),{updateCardInFrame:f}=e.useEditorActions(),j=e.useEditorStore(D=>D.card),z=e.useEditorStore(D=>{var k;return(k=D.card)==null?void 0:k.type}),O=["pie","doughnut","polarArea"].includes(z);v.useEffect(()=>{var D,k,$,M,G,U,te,ee,B,J,Y,ne,X,se;i(Ue(t)),l((($=(k=(D=t==null?void 0:t.chartOptions)==null?void 0:D.scales)==null?void 0:k[o])==null?void 0:$.min)===0?0:""),d(((U=(G=(M=t==null?void 0:t.chartOptions)==null?void 0:M.scales)==null?void 0:G[o])==null?void 0:U.max)||""),m(((J=(B=(ee=(te=t==null?void 0:t.chartOptions)==null?void 0:te.scales)==null?void 0:ee[o])==null?void 0:B.ticks)==null?void 0:J.stepSize)||""),w(((Y=t==null?void 0:t.numberAxisFormat)==null?void 0:Y.decimalPlaces)||0),T(((ne=t==null?void 0:t.numberAxisFormat)==null?void 0:ne.suffix)||""),L(((X=t==null?void 0:t.numberAxisFormat)==null?void 0:X.currency)||""),p(((se=t==null?void 0:t.numberAxisFormat)==null?void 0:se.locale)||"")},[s,t,o]);function F(D,k){return k===""||/^[0-9\b]+$/.test(k)?Number(k):Number(D)}function V(){const D=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(k=>k.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:R||"none",onValueChange:k=>L(k==="none"?"":k),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"}),D.map(k=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:k,children:k},k))]})})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:I,onValueChange:k=>p(k),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(k=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:k.locale,children:k.locale},k.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:b,onChange:k=>w(Number(k.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${Ee}`})]})]})}function P(){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:c,onChange:D=>l(k=>F(k,D.target.value)),className:`col-span-1 h-8 w-full ${Ee}`}),e.jsxRuntimeExports.jsx(e.Input,{value:x,onChange:D=>d(k=>F(k,D.target.value)),id:"max",className:`col-span-1 h-8 w-full ${Ee}`})]}),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:D=>m(k=>F(k,D.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${Ee}`})]})]})}function _(){var M;let D={};g==="custom"&&(D={min:c,max:x,ticks:{stepSize:u}});const k={...t||{},chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(M=t==null?void 0:t.chartOptions)==null?void 0:M.scales,[o]:{type:a,...a==="linear"?D:{}}}},numberAxisFormat:{decimalPlaces:b,suffix:C,currency:R,locale:I}};console.log(k),S(k);const $={...j,preferences:k};f($)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:D=>r(D),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:O,value:a,onValueChange:D=>i(D),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"})]})})]})]}),a=="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:O,id:"scale-option",value:g,onValueChange:D=>h(D),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"})]})]})]}),g==="custom"&&a=="linear"&&P(),V(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:_,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function St({idx:s}){var c;const r=e.useEditorStore(l=>{var x;return(x=l.card)==null?void 0:x.preferences}),t=e.useEditorStore(l=>{var x;return(x=l.card.preferences)==null?void 0:x.datasetOptions}),n=e.useEditorStore(l=>l.actions.setCardPreferences),o=(c=r==null?void 0:r.chartOptions)==null?void 0:c.indexAxis,a=t==null?void 0:t.find(l=>l.idx===s);function i(l,x){(l==="end"||l==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const d={display:l!=="none",align:l,anchor:l,clamp:!0};if(!a)n({...r,datasetOptions:[...t||[],{idx:x,datalabels:d}]});else{const g={...a};g.datalabels=d;const h=t==null?void 0:t.map(u=>u.idx===x?g:u);n({...r,datasetOptions:h})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(hs,{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:()=>i("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:()=>i("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(os,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(as,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>i("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(is,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function Ms(){const s=e.useEditorStore(l=>l.card),r=e.useEditorStore(l=>{var x,d,g;return(g=(d=(x=l==null?void 0:l.card)==null?void 0:x.preferences)==null?void 0:d.chartOptions)==null?void 0:g.indexAxis}),t=r==="y"?"Y axis":"X axis",n=r==="y"?"X axis":"Y axis",{keys:o,metricKeys:a,dimensionKeys:i}=e.getKeys(s.data||[]);let c=a;if(["stackedBar","stackedLine"].includes(s.type)){const l=e.pivotData({dataArray:s.data||[],groupKey:i[0],pivotKey:i[1],valueKey:c[0]}),{metricKeys:x}=e.getKeys(l);c=x}return o.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:t}),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:i[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:n}),e.jsxRuntimeExports.jsx(Fs,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:c.map((l,x)=>e.jsxRuntimeExports.jsx(vt,{col:l,idx:x},l))})]})]})}function vt({col:s,idx:r}){const t=e.useEditorStore(c=>{var l;return(l=c.card)==null?void 0:l.preferences}),n=e.useEditorStore(c=>{var l;return(l=c.card.preferences)==null?void 0:l.datasetOptions}),o=n==null?void 0:n.find(c=>c.idx===r),{setCardPreferences:a}=e.useEditorStore(c=>c.actions);function i(c){if(!o)a({...t,datasetOptions:[...n||[],{idx:r,type:c==="area"?"line":c,fill:c==="area"?"origin":""}]});else{const l={...o};l.type=c==="area"?"line":c,l.fill=c==="area"?"origin":"";const x=n==null?void 0:n.map(d=>d.idx===r?l:d);a({...t,datasetOptions:x})}}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(be,{onClick:()=>i("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ye,{onClick:()=>i("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Ke,{onClick:()=>i("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(e.Separator,{orientation:"vertical",className:"invisible size-4 cursor-pointer py-2 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),a=e.useDashboardStore(h=>h.dashboard.filters)||[],i=e.useDashboardStore(h=>h.actions.addFilter),c=e.useDashboardStore(h=>h.actions.removeFilter),l=e.useDashboardStore(h=>h.actions.removeFilterValue),{modelItems:x,tableName:d}=oe();function g(h,u="dashboard"){var p;const m=e.fmt(h.column_name),b=e.fmt(t||""),w=e.fmt(n||""),C=e.fmt(d);let T=e.getQualifiedTableName(w,C),R=`${T}.${m}`;const L=(p=x==null?void 0:x.find(S=>S.id===r))==null?void 0:p.name;r&&r!=="none"&&(R=`${e.DATAMODEL_NAMESPCACE}.${L}.${m}`,T=`${e.DATAMODEL_NAMESPCACE}.${L}`);const I=a==null?void 0:a.find(S=>S.column===R&&S.table===C&&(S.database===b||S.database===t));if(I)l(I.id),c(I.id);else{const S=e.v4();return d==="api"&&s?(i({location:u,id:S,column:R,title:h.column_name,dataType:h.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:e.getDefaultFilterSql(h.data_type,T,m)}),S):(i({id:S,location:u,column:R,title:h.column_name,dataType:h.data_type,table:o||"",database:t||"",connectionId:s||"",operation:"in",sql:e.getDefaultFilterSql(h.data_type,T,m)}),S)}}return{assignFilter:g}}function xe(){const s=e.useDashboardStore(c=>c.dashboard.filters),r=e.useEditorStore(c=>c.frame),{setFrame:t}=e.useEditorActions(),{columns:n}=oe(),{assignFilter:o}=Os();function a(c){const l=o(c,"frame");t({...r,filterId:l})}const i=s==null?void 0:s.find(c=>c.id===r.filterId);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Card Filter"}),e.jsxRuntimeExports.jsx(Ct,{onSelect:a,columns:n}),i&&e.jsxRuntimeExports.jsx(e.FilterHeader,{filter:i})]})}function Ct({columns:s,onSelect:r}){var i;const[t,n]=Be.useState(!1),[o,a]=Be.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?(i=s.find(c=>c.column_name===o))==null?void 0:i.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(c=>e.jsxRuntimeExports.jsxs(e.CommandItem,{value:c.column_name,onSelect:l=>{const x=l===o?"":l;a(x),n(!1),x&&r(c)},children:[c.column_name,e.jsxRuntimeExports.jsx(e.CheckIcon,{className:e.cn("ml-auto h-4 w-4",o===c.column_name?"opacity-100":"opacity-0")})]},c.column_name))})]})]})})]})}function Nt({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(ve,{}),e.jsxRuntimeExports.jsx(Ms,{})]})]}),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(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function Ve(){var o,a,i;const s=e.useEditorStore(c=>c.card.cfg),r=e.useEditorStore(c=>c.actions.setCardCfg),t=e.useEditorStore(c=>c.card.type);function n(c){var d;const l={datalabels:{display:c!=="none",align:c,anchor:c,clamp:!0}},x={...s,options:{...s==null?void 0:s.options,plugins:{...(d=s==null?void 0:s.options)==null?void 0:d.plugins,...l}}};r(x),console.log(c)}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(Fs,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(i=(a=(o=s==null?void 0:s.options)==null?void 0:o.plugins)==null?void 0:a.datalabels)==null?void 0:i.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 wt({cardType:s}){function r(t){const n="SELECT label, [group], x-axis, y-axis, radius FROM table",o="SELECT label, [group], x-axis, y-axis FROM table";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"?n:o}),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:a=>a.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(Ve,{})})]}),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(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}const kt={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},It={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function Dt(){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:Lt(s)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(s)&&e.jsxRuntimeExports.jsx(ve,{})}),!["kpi"].includes(s)&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsx(Ve,{}),e.jsxRuntimeExports.jsx(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})}function Lt(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(kt,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 Tt(){var l,x,d,g,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 m,b;return(b=(m=u.card.preferences)==null?void 0:m.formatNumber)==null?void 0:b.decimalPlaces});const n=e.useEditorStore(u=>{var m,b;return(b=(m=u.card.preferences)==null?void 0:m.formatNumber)==null?void 0:b.locale}),o=e.useEditorStore(u=>{var m,b;return(b=(m=u.card.preferences)==null?void 0:m.formatNumber)==null?void 0:b.currency});e.useEditorStore(u=>u.actions.setFilterOnClickField);const a=e.useEditorStore(u=>{var m,b;return(b=(m=u.card.preferences)==null?void 0:m.formatNumber)==null?void 0:b.colorRanges})||[],i=e.useEditorStore(u=>u.actions.setColorRanges),c=[...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:!!((l=s==null?void 0:s.formatNumber)!=null&&l.enabled),onCheckedChange:u=>{r({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:u}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((x=s==null?void 0:s.formatNumber)==null?void 0:x.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||"en-US",onValueChange:u=>{var m,b,w;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((b=s==null?void 0:s.formatNumber)==null?void 0:b.currency)||"",u||"en-US",((w=s==null?void 0:s.formatNumber)==null?void 0:w.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.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 m,b,w;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,u==="none"?"":u,((b=s==null?void 0:s.formatNumber)==null?void 0:b.locale)||"",((w=s==null?void 0:s.formatNumber)==null?void 0:w.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"),c.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:((g=(d=s==null?void 0:s.formatNumber)==null?void 0:d.decimalPlaces)==null?void 0:g.toString())||"0",onValueChange:u=>{var m,b,w;return t(Number(u),((m=s==null?void 0:s.formatNumber)==null?void 0:m.currency)||"",((b=s==null?void 0:s.formatNumber)==null?void 0:b.locale)||"",((w=s==null?void 0:s.formatNumber)==null?void 0:w.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 m,b,w;return t(((m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)||0,((b=s==null?void 0:s.formatNumber)==null?void 0:b.currency)||"",((w=s==null?void 0:s.formatNumber)==null?void 0:w.locale)||"",u.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:a,setColorRanges:i})]})]})}function At(){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(Tt,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}function zt(){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 fe({cardType:s,docContent:r,suffix:t="Chart"}){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)} ${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:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-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:[s==="range"&&e.jsxRuntimeExports.jsx(ve,{}),s!=="text"&&e.jsxRuntimeExports.jsx(Ve,{}),s==="text"&&e.jsxRuntimeExports.jsx(zt,{})]})]}),!["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(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function Ft(){const s=e.useEditorStore(n=>{var o,a;return(a=(o=n==null?void 0:n.card)==null?void 0:o.preferences)==null?void 0:a.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(de,{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(ve,{}),t(),e.jsxRuntimeExports.jsx(Ms,{})]})]}),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(ce,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function Mt({}){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(ce,{}),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 Ot=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."]})]}),Vt=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."]})]}),qt=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(Ft,{});case"pyramid":return e.jsxRuntimeExports.jsx(fe,{docContent:Ot,cardType:t});case"kpi":return e.jsxRuntimeExports.jsx(At,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(Nt,{cardType:t});case"range":return e.jsxRuntimeExports.jsx(fe,{docContent:Vt,cardType:t});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(fe,{cardType:t});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(wt,{cardType:t});case"table":return e.jsxRuntimeExports.jsx(Mt,{cardType:t});case"text":return e.jsxRuntimeExports.jsx(fe,{docContent:qt,cardType:t,suffix:"Visual"});case"custom":return e.jsxRuntimeExports.jsx(yt,{});default:return e.jsxRuntimeExports.jsx(Dt,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:r(s)})}function Bt(){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(xt,{})}),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 Ht({authToken:s,onSave:r,onClose:t}){e.useDashboardStore(i=>i.themeStyle);const n=e.useEditorStore(i=>i.actions.setOnSave),o=e.useEditorStore(i=>i.actions.setOnClose),a=e.useDashboardStore(i=>i.actions.setAuthToken);return v.useEffect(()=>{r&&n(r),t&&o(t)},[r,n,t,o]),v.useEffect(()=>{s&&s.accessToken&&a(s)},[s,a]),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(bs,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(Bt,{})})]})})}function Pt(){e.useDashboardStore(i=>i.selectedCardId);const s=e.useDashboardStore(i=>i.selectedSheetId),{setIsVisualEditing:r}=e.useDashboardStore(i=>i.actions),t=e.useDashboardStore(i=>i.isVisualEditing),n=e.useDashboardStore(i=>i.actions.updateFrame);function o(i){s&&(n(s,i),r(!1))}function a(){r(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{block:t,hidden:!t}),children:e.jsxRuntimeExports.jsx(Ht,{onSave:o,onClose:a})})}function $t(){e.useEditorStore(i=>i.selectedConnectionId),e.useEditorStore(i=>i.selectedDatamodelId);const s=e.useEditorStore(i=>i.selectedDatabaseName);e.useEditorStore(i=>i.selectedSchemaName);const r=e.useEditorStore(i=>i.selectedTableName),t=e.useDashboardStore(i=>i.dashboard.filters)||[];e.useDashboardStore(i=>i.actions.addFilter),e.useDashboardStore(i=>i.actions.removeFilter),e.useDashboardStore(i=>i.actions.removeFilterValue);const{modelItems:n,columns:o}=oe(),{assignFilter:a}=Os();return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:o==null?void 0:o.map(i=>{const c=t==null?void 0:t.find(l=>l.column===e.fmt(i.column_name)&&l.table===r&&l.database===s);return e.jsxRuntimeExports.jsx("div",{onClick:()=>a(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":c}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(Rs,{column:i}),e.jsxRuntimeExports.jsx("span",{children:i.column_name})]})},i.column_name)})})}function Gt(){e.useDashboardStore(r=>r.showFilters);const s=e.useDashboardStore(r=>r.actions.setShowFilters);return e.jsxRuntimeExports.jsxs("section",{className:"relative flex grow flex-col border-l px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"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(bs,{ColumnsComponent:()=>e.jsxRuntimeExports.jsx($t,{})})})]})}function Ut(){const s=e.useDashboardStore(t=>t.showFilters),r=e.useDashboardStore(t=>t.isVisualEditing);return e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("grow",{hidden:r,flex:!r}),children:[e.jsxRuntimeExports.jsx(e.DashboardTabs,{}),s&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(Gt,{})})]})}function Qt(){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 Kt({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.Te,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(Qt,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...t,children:[s&&e.jsxRuntimeExports.jsx(Us,{}),e.jsxRuntimeExports.jsx(Pt,{}),e.jsxRuntimeExports.jsx(Ut,{})]})]})]})})}exports.Box=Qe;exports.ChartArea=Ke;exports.ChartColumnIncreasing=be;exports.ChartLine=ye;exports.ChartNoAxesGantt=De;exports.ChartPie=Le;exports.ChartScatter=Te;exports.CircleX=We;exports.CopyPlus=Je;exports.DashboardPlus=Kt;exports.Database=Ye;exports.EllipsisVertical=Ae;exports.Eraser=Xe;exports.Eye=es;exports.EyeClosed=Ze;exports.Glasses=ss;exports.Hammer=ts;exports.Hash=ns;exports.House=rs;exports.Key=ze;exports.ListEnd=os;exports.ListStart=is;exports.ListX=as;exports.LoaderCircle=le;exports.MessageSquareMore=ls;exports.Network=cs;exports.Pencil=Fe;exports.Play=xs;exports.Plug2=us;exports.Save=ds;exports.SelectComponent=ae;exports.Shapes=Me;exports.ShieldQuestion=ms;exports.Sigma=ps;exports.SwatchBook=js;exports.Tag=hs;exports.ToggleLeft=Es;exports.Type=Se;exports.User=fs;exports.cleanCard=gs;exports.getDashbaordStateWithoutData=Oe;exports.useEditorAside=oe;
|
|
@@ -10918,14 +10918,15 @@ function ji() {
|
|
|
10918
10918
|
return e;
|
|
10919
10919
|
}
|
|
10920
10920
|
function yV() {
|
|
10921
|
-
const { authToken: e } = ji(),
|
|
10922
|
-
queryKey: ["dashboard",
|
|
10921
|
+
const { authToken: e, version: t } = ji(), n = De((a) => a.selectedLensId), { data: r, isLoading: o, isFetching: i, isError: s } = pw({
|
|
10922
|
+
queryKey: ["dashboard", n, e == null ? void 0 : e.accessToken],
|
|
10923
10923
|
queryFn: () => tB(e == null ? void 0 : e.accessToken, {
|
|
10924
|
-
lensId:
|
|
10924
|
+
lensId: n,
|
|
10925
|
+
version: t
|
|
10925
10926
|
})
|
|
10926
10927
|
// staleTime: Infinity,
|
|
10927
10928
|
});
|
|
10928
|
-
return { data:
|
|
10929
|
+
return { data: r, isLoading: o, isFetching: i, isError: s };
|
|
10929
10930
|
}
|
|
10930
10931
|
function SD(e) {
|
|
10931
10932
|
return e === "system" ? window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : e;
|
|
@@ -85,7 +85,7 @@ __p += '`),It&&(Pe+=`' +
|
|
|
85
85
|
function print() { __p += __j.call(arguments, '') }
|
|
86
86
|
`:`;
|
|
87
87
|
`)+Pe+`return __p
|
|
88
|
-
}`;var xt=kR(function(){return zt(V,Ye+"return "+Pe).apply(n,Y)});if(xt.source=Pe,Wb(xt))throw xt;return xt}function vz(d){return Gt(d).toLowerCase()}function bz(d){return Gt(d).toUpperCase()}function yz(d,g,x){if(d=Gt(d),d&&(x||g===n))return VC(d);if(!d||!(g=Ur(g)))return d;var P=zo(d),k=zo(g),V=HC(P,k),Y=WC(P,k)+1;return As(P,V,Y).join("")}function xz(d,g,x){if(d=Gt(d),d&&(x||g===n))return d.slice(0,GC(d)+1);if(!d||!(g=Ur(g)))return d;var P=zo(d),k=WC(P,zo(g))+1;return As(P,0,k).join("")}function wz(d,g,x){if(d=Gt(d),d&&(x||g===n))return d.replace(Vn,"");if(!d||!(g=Ur(g)))return d;var P=zo(d),k=HC(P,zo(g));return As(P,k).join("")}function _z(d,g){var x=F,P=L;if(wn(g)){var k="separator"in g?g.separator:k;x="length"in g?pt(g.length):x,P="omission"in g?Ur(g.omission):P}d=Gt(d);var V=d.length;if(Wl(d)){var Y=zo(d);V=Y.length}if(x>=V)return d;var ne=x-Ul(P);if(ne<1)return P;var le=Y?As(Y,0,ne).join(""):d.slice(0,ne);if(k===n)return le+P;if(Y&&(ne+=le.length-ne),Ub(k)){if(d.slice(ne).search(k)){var we,_e=le;for(k.global||(k=ab(k.source,Gt(Ge.exec(k))+"g")),k.lastIndex=0;we=k.exec(_e);)var Pe=we.index;le=le.slice(0,Pe===n?ne:Pe)}}else if(d.indexOf(Ur(k),ne)!=ne){var je=le.lastIndexOf(k);je>-1&&(le=le.slice(0,je))}return le+P}function Sz(d){return d=Gt(d),d&&$n.test(d)?d.replace(Qt,J7):d}var Cz=Jl(function(d,g,x){return d+(x?" ":"")+g.toUpperCase()}),Yb=ME("toUpperCase");function AR(d,g,x){return d=Gt(d),g=x?n:g,g===n?q7(d)?t6(d):F7(d):d.match(g)||[]}var kR=Ct(function(d,g){try{return Hr(d,n,g)}catch(x){return Wb(x)?x:new ct(x)}}),Ez=Hi(function(d,g){return yo(g,function(x){x=ci(x),Bi(d,x,Vb(d[x],d))}),d});function Rz(d){var g=d==null?0:d.length,x=Je();return d=g?yn(d,function(P){if(typeof P[1]!="function")throw new xo(s);return[x(P[0]),P[1]]}):[],Ct(function(P){for(var k=-1;++k<g;){var V=d[k];if(Hr(V[0],this,P))return Hr(V[1],this,P)}})}function Pz(d){return J6(_o(d,f))}function Kb(d){return function(){return d}}function Oz(d,g){return d==null||d!==d?g:d}var $z=NE(),Tz=NE(!0);function $r(d){return d}function Xb(d){return fE(typeof d=="function"?d:_o(d,f))}function Dz(d){return pE(_o(d,f))}function Az(d,g){return gE(d,_o(g,f))}var kz=Ct(function(d,g){return function(x){return Fu(x,d,g)}}),Mz=Ct(function(d,g){return function(x){return Fu(d,x,g)}});function Qb(d,g,x){var P=Wn(g),k=Wh(g,P);x==null&&!(wn(g)&&(k.length||!P.length))&&(x=g,g=d,d=this,k=Wh(g,Wn(g)));var V=!(wn(x)&&"chain"in x)||!!x.chain,Y=Ui(d);return yo(k,function(ne){var le=g[ne];d[ne]=le,Y&&(d.prototype[ne]=function(){var we=this.__chain__;if(V||we){var _e=d(this.__wrapped__),Pe=_e.__actions__=Rr(this.__actions__);return Pe.push({func:le,args:arguments,thisArg:d}),_e.__chain__=we,_e}return le.apply(d,Rs([this.value()],arguments))})}),d}function Iz(){return qn._===this&&(qn._=a6),this}function Jb(){}function Nz(d){return d=pt(d),Ct(function(g){return mE(g,d)})}var Lz=$b(yn),Fz=$b(LC),jz=$b(eb);function MR(d){return Nb(d)?tb(ci(d)):g9(d)}function zz(d){return function(g){return d==null?n:Oa(d,g)}}var Bz=FE(),Vz=FE(!0);function Zb(){return[]}function e0(){return!1}function Hz(){return{}}function Wz(){return""}function Uz(){return!0}function Gz(d,g){if(d=pt(d),d<1||d>Q)return[];var x=H,P=or(d,H);g=Je(g),d-=H;for(var k=ob(P,g);++x<d;)g(x);return k}function qz(d){return ut(d)?yn(d,ci):Gr(d)?[d]:Rr(eR(Gt(d)))}function Yz(d){var g=++i6;return Gt(d)+g}var Kz=Xh(function(d,g){return d+g},0),Xz=Tb("ceil"),Qz=Xh(function(d,g){return d/g},1),Jz=Tb("floor");function Zz(d){return d&&d.length?Hh(d,$r,gb):n}function eB(d,g){return d&&d.length?Hh(d,Je(g,2),gb):n}function tB(d){return zC(d,$r)}function nB(d,g){return zC(d,Je(g,2))}function rB(d){return d&&d.length?Hh(d,$r,yb):n}function oB(d,g){return d&&d.length?Hh(d,Je(g,2),yb):n}var iB=Xh(function(d,g){return d*g},1),sB=Tb("round"),aB=Xh(function(d,g){return d-g},0);function lB(d){return d&&d.length?rb(d,$r):0}function cB(d,g){return d&&d.length?rb(d,Je(g,2)):0}return j.after=D8,j.ary=dR,j.assign=bj,j.assignIn=ER,j.assignInWith=cp,j.assignWith=yj,j.at=xj,j.before=fR,j.bind=Vb,j.bindAll=Ez,j.bindKey=hR,j.castArray=H8,j.chain=lR,j.chunk=J9,j.compact=Z9,j.concat=e4,j.cond=Rz,j.conforms=Pz,j.constant=Kb,j.countBy=l8,j.create=wj,j.curry=pR,j.curryRight=gR,j.debounce=mR,j.defaults=_j,j.defaultsDeep=Sj,j.defer=A8,j.delay=k8,j.difference=t4,j.differenceBy=n4,j.differenceWith=r4,j.drop=o4,j.dropRight=i4,j.dropRightWhile=s4,j.dropWhile=a4,j.fill=l4,j.filter=u8,j.flatMap=h8,j.flatMapDeep=p8,j.flatMapDepth=g8,j.flatten=oR,j.flattenDeep=c4,j.flattenDepth=u4,j.flip=M8,j.flow=$z,j.flowRight=Tz,j.fromPairs=d4,j.functions=Tj,j.functionsIn=Dj,j.groupBy=m8,j.initial=h4,j.intersection=p4,j.intersectionBy=g4,j.intersectionWith=m4,j.invert=kj,j.invertBy=Mj,j.invokeMap=b8,j.iteratee=Xb,j.keyBy=y8,j.keys=Wn,j.keysIn=Or,j.map=rp,j.mapKeys=Nj,j.mapValues=Lj,j.matches=Dz,j.matchesProperty=Az,j.memoize=ip,j.merge=Fj,j.mergeWith=RR,j.method=kz,j.methodOf=Mz,j.mixin=Qb,j.negate=sp,j.nthArg=Nz,j.omit=jj,j.omitBy=zj,j.once=I8,j.orderBy=x8,j.over=Lz,j.overArgs=N8,j.overEvery=Fz,j.overSome=jz,j.partial=Hb,j.partialRight=vR,j.partition=w8,j.pick=Bj,j.pickBy=PR,j.property=MR,j.propertyOf=zz,j.pull=x4,j.pullAll=sR,j.pullAllBy=w4,j.pullAllWith=_4,j.pullAt=S4,j.range=Bz,j.rangeRight=Vz,j.rearg=L8,j.reject=C8,j.remove=C4,j.rest=F8,j.reverse=zb,j.sampleSize=R8,j.set=Hj,j.setWith=Wj,j.shuffle=P8,j.slice=E4,j.sortBy=T8,j.sortedUniq=A4,j.sortedUniqBy=k4,j.split=hz,j.spread=j8,j.tail=M4,j.take=I4,j.takeRight=N4,j.takeRightWhile=L4,j.takeWhile=F4,j.tap=Z4,j.throttle=z8,j.thru=np,j.toArray=_R,j.toPairs=OR,j.toPairsIn=$R,j.toPath=qz,j.toPlainObject=CR,j.transform=Uj,j.unary=B8,j.union=j4,j.unionBy=z4,j.unionWith=B4,j.uniq=V4,j.uniqBy=H4,j.uniqWith=W4,j.unset=Gj,j.unzip=Bb,j.unzipWith=aR,j.update=qj,j.updateWith=Yj,j.values=tc,j.valuesIn=Kj,j.without=U4,j.words=AR,j.wrap=V8,j.xor=G4,j.xorBy=q4,j.xorWith=Y4,j.zip=K4,j.zipObject=X4,j.zipObjectDeep=Q4,j.zipWith=J4,j.entries=OR,j.entriesIn=$R,j.extend=ER,j.extendWith=cp,Qb(j,j),j.add=Kz,j.attempt=kR,j.camelCase=Zj,j.capitalize=TR,j.ceil=Xz,j.clamp=Xj,j.clone=W8,j.cloneDeep=G8,j.cloneDeepWith=q8,j.cloneWith=U8,j.conformsTo=Y8,j.deburr=DR,j.defaultTo=Oz,j.divide=Qz,j.endsWith=ez,j.eq=Vo,j.escape=tz,j.escapeRegExp=nz,j.every=c8,j.find=d8,j.findIndex=nR,j.findKey=Cj,j.findLast=f8,j.findLastIndex=rR,j.findLastKey=Ej,j.floor=Jz,j.forEach=cR,j.forEachRight=uR,j.forIn=Rj,j.forInRight=Pj,j.forOwn=Oj,j.forOwnRight=$j,j.get=Gb,j.gt=K8,j.gte=X8,j.has=Aj,j.hasIn=qb,j.head=iR,j.identity=$r,j.includes=v8,j.indexOf=f4,j.inRange=Qj,j.invoke=Ij,j.isArguments=Da,j.isArray=ut,j.isArrayBuffer=Q8,j.isArrayLike=Pr,j.isArrayLikeObject=Tn,j.isBoolean=J8,j.isBuffer=ks,j.isDate=Z8,j.isElement=ej,j.isEmpty=tj,j.isEqual=nj,j.isEqualWith=rj,j.isError=Wb,j.isFinite=oj,j.isFunction=Ui,j.isInteger=bR,j.isLength=ap,j.isMap=yR,j.isMatch=ij,j.isMatchWith=sj,j.isNaN=aj,j.isNative=lj,j.isNil=uj,j.isNull=cj,j.isNumber=xR,j.isObject=wn,j.isObjectLike=Cn,j.isPlainObject=Wu,j.isRegExp=Ub,j.isSafeInteger=dj,j.isSet=wR,j.isString=lp,j.isSymbol=Gr,j.isTypedArray=ec,j.isUndefined=fj,j.isWeakMap=hj,j.isWeakSet=pj,j.join=v4,j.kebabCase=rz,j.last=Co,j.lastIndexOf=b4,j.lowerCase=oz,j.lowerFirst=iz,j.lt=gj,j.lte=mj,j.max=Zz,j.maxBy=eB,j.mean=tB,j.meanBy=nB,j.min=rB,j.minBy=oB,j.stubArray=Zb,j.stubFalse=e0,j.stubObject=Hz,j.stubString=Wz,j.stubTrue=Uz,j.multiply=iB,j.nth=y4,j.noConflict=Iz,j.noop=Jb,j.now=op,j.pad=sz,j.padEnd=az,j.padStart=lz,j.parseInt=cz,j.random=Jj,j.reduce=_8,j.reduceRight=S8,j.repeat=uz,j.replace=dz,j.result=Vj,j.round=sB,j.runInContext=se,j.sample=E8,j.size=O8,j.snakeCase=fz,j.some=$8,j.sortedIndex=R4,j.sortedIndexBy=P4,j.sortedIndexOf=O4,j.sortedLastIndex=$4,j.sortedLastIndexBy=T4,j.sortedLastIndexOf=D4,j.startCase=pz,j.startsWith=gz,j.subtract=aB,j.sum=lB,j.sumBy=cB,j.template=mz,j.times=Gz,j.toFinite=Gi,j.toInteger=pt,j.toLength=SR,j.toLower=vz,j.toNumber=Eo,j.toSafeInteger=vj,j.toString=Gt,j.toUpper=bz,j.trim=yz,j.trimEnd=xz,j.trimStart=wz,j.truncate=_z,j.unescape=Sz,j.uniqueId=Yz,j.upperCase=Cz,j.upperFirst=Yb,j.each=cR,j.eachRight=uR,j.first=iR,Qb(j,function(){var d={};return ai(j,function(g,x){Jt.call(j.prototype,x)||(d[x]=g)}),d}(),{chain:!1}),j.VERSION=r,yo(["bind","bindKey","curry","curryRight","partial","partialRight"],function(d){j[d].placeholder=j}),yo(["drop","take"],function(d,g){Mt.prototype[d]=function(x){x=x===n?1:Ln(pt(x),0);var P=this.__filtered__&&!g?new Mt(this):this.clone();return P.__filtered__?P.__takeCount__=or(x,P.__takeCount__):P.__views__.push({size:or(x,H),type:d+(P.__dir__<0?"Right":"")}),P},Mt.prototype[d+"Right"]=function(x){return this.reverse()[d](x).reverse()}}),yo(["filter","map","takeWhile"],function(d,g){var x=g+1,P=x==q||x==ee;Mt.prototype[d]=function(k){var V=this.clone();return V.__iteratees__.push({iteratee:Je(k,3),type:x}),V.__filtered__=V.__filtered__||P,V}}),yo(["head","last"],function(d,g){var x="take"+(g?"Right":"");Mt.prototype[d]=function(){return this[x](1).value()[0]}}),yo(["initial","tail"],function(d,g){var x="drop"+(g?"":"Right");Mt.prototype[d]=function(){return this.__filtered__?new Mt(this):this[x](1)}}),Mt.prototype.compact=function(){return this.filter($r)},Mt.prototype.find=function(d){return this.filter(d).head()},Mt.prototype.findLast=function(d){return this.reverse().find(d)},Mt.prototype.invokeMap=Ct(function(d,g){return typeof d=="function"?new Mt(this):this.map(function(x){return Fu(x,d,g)})}),Mt.prototype.reject=function(d){return this.filter(sp(Je(d)))},Mt.prototype.slice=function(d,g){d=pt(d);var x=this;return x.__filtered__&&(d>0||g<0)?new Mt(x):(d<0?x=x.takeRight(-d):d&&(x=x.drop(d)),g!==n&&(g=pt(g),x=g<0?x.dropRight(-g):x.take(g-d)),x)},Mt.prototype.takeRightWhile=function(d){return this.reverse().takeWhile(d).reverse()},Mt.prototype.toArray=function(){return this.take(H)},ai(Mt.prototype,function(d,g){var x=/^(?:filter|find|map|reject)|While$/.test(g),P=/^(?:head|last)$/.test(g),k=j[P?"take"+(g=="last"?"Right":""):g],V=P||/^find/.test(g);k&&(j.prototype[g]=function(){var Y=this.__wrapped__,ne=P?[1]:arguments,le=Y instanceof Mt,we=ne[0],_e=le||ut(Y),Pe=function($t){var It=k.apply(j,Rs([$t],ne));return P&&je?It[0]:It};_e&&x&&typeof we=="function"&&we.length!=1&&(le=_e=!1);var je=this.__chain__,Ye=!!this.__actions__.length,et=V&&!je,xt=le&&!Ye;if(!V&&_e){Y=xt?Y:new Mt(this);var tt=d.apply(Y,ne);return tt.__actions__.push({func:np,args:[Pe],thisArg:n}),new wo(tt,je)}return et&&xt?d.apply(this,ne):(tt=this.thru(Pe),et?P?tt.value()[0]:tt.value():tt)})}),yo(["pop","push","shift","sort","splice","unshift"],function(d){var g=Oh[d],x=/^(?:push|sort|unshift)$/.test(d)?"tap":"thru",P=/^(?:pop|shift)$/.test(d);j.prototype[d]=function(){var k=arguments;if(P&&!this.__chain__){var V=this.value();return g.apply(ut(V)?V:[],k)}return this[x](function(Y){return g.apply(ut(Y)?Y:[],k)})}}),ai(Mt.prototype,function(d,g){var x=j[g];if(x){var P=x.name+"";Jt.call(Kl,P)||(Kl[P]=[]),Kl[P].push({name:g,func:x})}}),Kl[Kh(n,y).name]=[{name:"wrapper",func:n}],Mt.prototype.clone=S6,Mt.prototype.reverse=C6,Mt.prototype.value=E6,j.prototype.at=e8,j.prototype.chain=t8,j.prototype.commit=n8,j.prototype.next=r8,j.prototype.plant=i8,j.prototype.reverse=s8,j.prototype.toJSON=j.prototype.valueOf=j.prototype.value=a8,j.prototype.first=j.prototype.head,Du&&(j.prototype[Du]=o8),j},Gl=n6();Sa?((Sa.exports=Gl)._=Gl,Xv._=Gl):qn._=Gl}).call(Gs)})(jg,jg.exports);var xc=jg.exports;const ll=Pl(xc);function eP({id:e,layouts:t,initialHeight:n,y:r,x:o,w:i,minH:s}){const a={i:e,x:o??0,y:r??1/0,w:i||20,h:n||35,minW:6,minH:s||10};return t||(t={}),fw.forEach(l=>{t!=null&&t[l]||(t={...t,[l]:[]});const c=t[l].reduce((u,f)=>Math.max(u,f.y+f.h),0);a.y=a.y===0?0:c,t[l].push(a)}),t}function tP(e,t){t&&fw.forEach(n=>{t!=null&&t[n]&&(t[n]=t[n].filter(r=>r.i!==e))})}const Ee=cD()(mD((e,t)=>({isSessionExpired:!1,currentBreakpoint:"lg",dashboard:{id:"",style:Lg},showContext:!1,selectedSheetId:null,selectedCardId:null,selectedFrameId:null,selectedCard:null,showFilters:!1,isDashboardEditing:!1,isVisualEditing:!1,showDashboardJSON:!1,filteringCards:[],actions:{setInitStore:()=>{e(n=>{n.isSessionExpired=!1,n.currentBreakpoint="lg",n.dashboard={id:"",style:Lg},n.showContext=!1,n.selectedSheetId=null,n.selectedCardId=null,n.selectedFrameId=null,n.selectedCard=null,n.showFilters=!1,n.isDashboardEditing=!1,n.isVisualEditing=!1,n.showDashboardJSON=!1,n.filteringCards=[],n.selectedLensId=void 0})},setLenses:n=>{e(r=>{r.lenses=n})},setSelectedLensId:n=>{e(r=>{r.selectedLensId=n})},deleteSheet:n=>{e(r=>{var i,s,a,l;const o=(i=r.dashboard.sheets)==null?void 0:i.findIndex(c=>c.id===n);o!==void 0&&o>-1&&((s=r.dashboard.sheets)==null||s.splice(o,1),r.selectedSheetId=(l=(a=r.dashboard.sheets)==null?void 0:a[0])==null?void 0:l.id)})},addSheet:n=>{e(r=>{r.dashboard.sheets||(r.dashboard.sheets=[]);const o=r.dashboard.filters;let i={};o==null||o.forEach(a=>{fw.forEach(l=>{i!=null&&i[l]||(i={...i,[l]:[]});const c={i:a.id,x:0,y:0,w:10,h:8};i[l].push(c)})});const s={...n,layouts:i};r.dashboard.sheets.push(s)})},setGlobalStyle:n=>{e(r=>{r.dashboard.globalStyle=n})},setAIScopeTables:n=>{e(r=>{r.dashboard.aiScopeTables=n})},setIsSessionExpired:n=>{e(()=>({isSessionExpired:n}))},setCardPython:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===o.selectedSheetId);i&&xc.forEach(i.frames,l=>{var u;const c=(u=l.cards)==null?void 0:u.find(f=>f.id===n);c&&(c.python=r)})})},addBaseQuery:n=>{e(r=>{var o;r.dashboard.baseQueries||(r.dashboard.baseQueries=[]),(o=r.dashboard.baseQueries)==null||o.push(n)})},removeBaseQuery:n=>{e(r=>{var i,s;const o=(i=r.dashboard.baseQueries)==null?void 0:i.findIndex(a=>a.id===n);o!=null&&o>-1&&((s=r.dashboard.baseQueries)==null||s.splice(o,1))})},setBaseQueries:n=>{e(r=>{r.dashboard.baseQueries=n})},setCurrentBreakpoint:n=>{e(()=>({currentBreakpoint:n}))},setFilteringCards:n=>{e(()=>({filteringCards:n}))},addFilteringCard:n=>{e(r=>{var o;(o=r.filteringCards)==null||o.push(n)})},removeFilteringCard:n=>{e(r=>{var i,s;const o=(i=r.filteringCards)==null?void 0:i.findIndex(a=>a.id===n.id);o!==void 0&&o>-1&&((s=r.filteringCards)==null||s.splice(o,1))})},setCustomCards:n=>{e(r=>{r.dashboard.customCards=n})},setAuthToken:n=>{e(()=>({authToken:n}))},setThemeStyle:n=>{e(()=>({themeStyle:n}))},setDashboard:n=>e({dashboard:n}),setDashboardWithFilterValues:(n,r)=>{e(o=>{o.dashboard=n,o.filterValues=r})},setDashboardTheme:n=>{e(r=>{r.theme=n})},setSheets:n=>{e(r=>{r.dashboard&&(r.dashboard.sheets=n)})},setSheetTitle:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.title=r)})},setCardTitle:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&xc.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(h=>h.id===r);u&&(u.title=o)})})},setCardInfo:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===o.selectedSheetId);i&&xc.forEach(i.frames,l=>{var u;const c=(u=l.cards)==null?void 0:u.find(f=>f.id===n);c&&(c.info=r)})})},setCardDescription:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&xc.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(h=>h.id===r);u&&(u.description=o)})})},setCardSql:(n,r,o)=>{e(i=>{var a,l,c,u;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n);if(s){const f=(c=s.cards)==null?void 0:c.find(h=>h.id===r);f&&(f.sql=o,(u=i.onUpdateCard)==null||u.call(i,f,n))}})},setFrameCardData:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&xc.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(h=>h.id===r);u&&(u.data=o)})})},setSheetLayout:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.layout=r)})},setSheetLayouts:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.layouts=r)})},setShowContext:n=>{e(()=>({showContext:n}))},setShowFilters:n=>{e(()=>({showFilters:n}))},setFilterValues:n=>{e(()=>({filterValues:n}))},addOrUpdateFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.findIndex(i=>i.filterId===n.filterId);o>-1?r.filterValues.splice(o,1,n):r.filterValues.push(n)}else r.filterValues=[n]})},addOrUpdateFilterValues:n=>{e(r=>{r.filterValues?n.forEach(o=>{var s,a,l;const i=(s=r==null?void 0:r.filterValues)==null?void 0:s.findIndex(c=>c.filterId===o.filterId);i!==void 0&&i>-1?(a=r.filterValues)==null||a.splice(i,1,o):(l=r.filterValues)==null||l.push(o)}):r.filterValues=n})},removeFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.filter(i=>i.filterId!==n&&!i.filterId.startsWith(n));r.filterValues=o}})},replaceFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.findIndex(i=>i.filterId===n.filterId);o>-1&&r.filterValues.splice(o,1,n)}})},addFilter:n=>{e(r=>{var i,s;r.dashboard.filters?(i=r.dashboard.filters)==null||i.push(n):r.dashboard.filters=[n];const o=(s=r.dashboard.sheets)==null?void 0:s.find(a=>a.id===r.selectedSheetId);eP({id:n.id,layouts:o==null?void 0:o.layouts,y:0,initialHeight:8,minH:7,w:10})})},removeFilter:n=>{e(r=>{var o,i,s;if(r.dashboard.filters){const a=(o=r.dashboard.filters)==null?void 0:o.findIndex(l=>l.id===n);if(a>-1){(i=r.dashboard.filters)==null||i.splice(a,1);const l=(s=r.dashboard.sheets)==null?void 0:s.find(c=>c.id===r.selectedSheetId);tP(n,l==null?void 0:l.layouts)}}})},updateFrameCard:(n,r,o)=>{e(i=>{var l,c,u,f,h;const s=(c=(l=i.dashboard)==null?void 0:l.sheets)==null?void 0:c.find(p=>p.id===n);if(!s)return;const a=(u=s==null?void 0:s.frames)==null?void 0:u.find(p=>p.id===r);if(a){const p=(f=a.cards)==null?void 0:f.findIndex(v=>v.id===o.id);p>-1&&((h=a.cards)==null||h.splice(p,1,o))}})},updateFilter:n=>{e(r=>{var o,i;if(r.dashboard.filters){const s=(o=r.dashboard.filters)==null?void 0:o.findIndex(a=>a.id===n.id);s>-1&&((i=r.dashboard.filters)==null||i.splice(s,1,n))}})},setIsDashboardEditing:n=>{e(()=>({isDashboardEditing:n}))},setShowDashboardJSON:n=>{e(()=>({showDashboardJSON:n}))},setIsVisualEditing:n=>{e(()=>({isVisualEditing:n}))},addFrame:(n,r,o)=>{e(i=>{var a,l,c,u;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n);if(s){s.frames||(s.frames=[]),(c=s.frames)==null||c.push(r);let f=1/0;const h=0;o==="start"&&(f=0),eP({id:r.id,layouts:s.layouts,minH:10,x:h,y:f}),(u=i.onAddFrame)==null||u.call(i,r,n)}})},removeFrame:(n,r)=>{e(o=>{var s,a,l,c,u;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(f=>f.id===n);if(i){const f=(l=i.frames)==null?void 0:l.findIndex(h=>h.id===r);console.log(f),typeof f=="number"&&f>-1&&((c=i.frames)==null||c.splice(f,1),(u=i.layout)==null||u.splice(f,1),tP(r,i.layouts))}})},updateFrame:(n,r)=>{e(o=>{var a,l,c,u,f;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(h=>h.id===n),s=(c=i==null?void 0:i.frames)==null?void 0:c.findIndex(h=>h.id===r.id);i&&((u=i.frames)==null||u.splice(s,1,r)),(f=o.onAcceptChanges)==null||f.call(o,r,o.dashboard)})},updateCard:(n,r)=>{e(o=>{var a,l,c,u,f;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(h=>h.id===n),s=(c=i==null?void 0:i.cards)==null?void 0:c.findIndex(h=>h.id===r.id);i&&((u=i.cards)==null||u.splice(s,1,r),(f=o.onUpdateCard)==null||f.call(o,r,n))})},removeCard:(n,r)=>{e(o=>{var a,l,c,u,f,h;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(p=>p.id===n),s=(c=i==null?void 0:i.cards)==null?void 0:c.findIndex(p=>p.id===r.id);i&&((u=i.cards)==null||u.splice(s,1),(f=i.layout)==null||f.splice(s,1),(h=o.onRemoveCard)==null||h.call(o,r,n))})},setStyle:n=>{e(r=>{r.dashboard&&(r.dashboard.style=n)})},setSelectedCardId:(n,r)=>{e(o=>{var s,a,l;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(c=>c.id===n);i&&(((l=i.cards)==null?void 0:l.find(u=>u.id===r))?o.selectedCardId=r:o.selectedCardId=null)})},setSelectedFrameId:n=>{e(r=>{var i,s;((s=(i=r.dashboard)==null?void 0:i.sheets)==null?void 0:s.find(a=>a.id===r.selectedSheetId))&&(r.selectedFrameId=n)})},setSelectedSheetId:n=>{e(r=>{var i,s;((s=(i=r.dashboard)==null?void 0:i.sheets)==null?void 0:s.find(a=>a.id===n))&&(r.selectedSheetId=n)})},setOnSaveFunction:n=>{e(()=>({onSaveFunction:n}))},setOnAddCard:n=>{e(()=>({onAddCard:n}))},setOnAcceptChanges:n=>{e(()=>({onAcceptChanges:n}))},setOnUpdateCard:n=>{e(()=>({onUpdateCard:n}))},setOnRemoveCard:n=>{e(()=>({onRemoveCard:n}))},setOnEvent:n=>{e(()=>({onEvent:n}))},getDashboard:()=>t().dashboard,getSelectedSheet:()=>{var n,r;return(r=(n=t().dashboard)==null?void 0:n.sheets)==null?void 0:r.find(o=>o.id===t().selectedSheetId)},getCardFrame:n=>{var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a){for(let l=0;l<a.length;l++)if((i=a[l].cards)==null?void 0:i.find(u=>u.id===n))return a[l]}}},getSelectedFrame:()=>{var r,o,i;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(s=>s.id===t().selectedSheetId);return(i=n==null?void 0:n.frames)==null?void 0:i.find(s=>s.id===t().selectedFrameId)},getCard:n=>{var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a)for(let l=0;l<a.length;l++){const c=(i=a[l].cards)==null?void 0:i.find(u=>u.id===n);if(c)return c}}},getSelectedSheetLayout:()=>{var r,o;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(i=>i.id===t().selectedSheetId);return n==null?void 0:n.layout},getSelectedSheetLayouts:()=>{var r,o;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(i=>i.id===t().selectedSheetId);return n==null?void 0:n.layouts},getStyle:()=>{var n;return(n=t().dashboard)==null?void 0:n.style},getCardSheet(n){var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a){for(let l=0;l<a.length;l++)if((i=a[l].cards)==null?void 0:i.find(u=>u.id===n))return r[s]}}},handleDataPointClickAction:(n,r)=>{LV({card:n,dataPoint:r,set:e,get:t})}}}))),ur=()=>Ee(e=>e.actions),FV={theme:"system",setTheme:()=>null},SD=m.createContext(FV);function jV({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const[o,i]=m.useState(()=>localStorage.getItem(n)||t);m.useEffect(()=>{const a=window.document.documentElement;if(a.classList.remove("light","dark"),o==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";a.classList.add(l);return}a.classList.add(o)},[o]);const s={theme:o,setTheme:a=>{localStorage.setItem(n,a),i(a)}};return R.jsx(SD.Provider,{...r,value:s,children:e})}const CD=()=>{const e=m.useContext(SD);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e};var Uf=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},nu=typeof window>"u"||"Deno"in window;function To(){}function zV(e,t){return typeof e=="function"?e(t):e}function ux(e){return typeof e=="number"&&e>=0&&e!==1/0}function ED(e,t){return Math.max(e+(t||0)-Date.now(),0)}function nP(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==gw(s,t.options))return!1}else if(!Yd(t.queryKey,s))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||typeof o<"u"&&o!==t.state.fetchStatus||i&&!i(t))}function rP(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(qd(t.options.mutationKey)!==qd(i))return!1}else if(!Yd(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function gw(e,t){return((t==null?void 0:t.queryKeyHashFn)||qd)(e)}function qd(e){return JSON.stringify(e,(t,n)=>fx(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function Yd(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!Yd(e[n],t[n])):!1}function RD(e,t){if(e===t)return e;const n=oP(e)&&oP(t);if(n||fx(e)&&fx(t)){const r=n?e:Object.keys(e),o=r.length,i=n?t:Object.keys(t),s=i.length,a=n?[]:{};let l=0;for(let c=0;c<s;c++){const u=n?c:i[c];!n&&e[u]===void 0&&t[u]===void 0&&r.includes(u)?(a[u]=void 0,l++):(a[u]=RD(e[u],t[u]),a[u]===e[u]&&e[u]!==void 0&&l++)}return o===s&&l===o?e:a}return t}function dx(e,t){if(e&&!t||t&&!e)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function oP(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function fx(e){if(!iP(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const n=t.prototype;return!(!iP(n)||!n.hasOwnProperty("isPrototypeOf"))}function iP(e){return Object.prototype.toString.call(e)==="[object Object]"}function BV(e){return new Promise(t=>{setTimeout(t,e)})}function hx(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?RD(e,t):t}function VV(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function HV(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var el,qs,Lc,UT,WV=(UT=class extends Uf{constructor(){super();Xe(this,el,void 0);Xe(this,qs,void 0);Xe(this,Lc,void 0);Ve(this,Lc,t=>{if(!nu&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){ae(this,qs)||this.setEventListener(ae(this,Lc))}onUnsubscribe(){var t;this.hasListeners()||((t=ae(this,qs))==null||t.call(this),Ve(this,qs,void 0))}setEventListener(t){var n;Ve(this,Lc,t),(n=ae(this,qs))==null||n.call(this),Ve(this,qs,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){ae(this,el)!==t&&(Ve(this,el,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof ae(this,el)=="boolean"?ae(this,el):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},el=new WeakMap,qs=new WeakMap,Lc=new WeakMap,UT),zg=new WV,Fc,Ys,jc,GT,UV=(GT=class extends Uf{constructor(){super();Xe(this,Fc,!0);Xe(this,Ys,void 0);Xe(this,jc,void 0);Ve(this,jc,t=>{if(!nu&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){ae(this,Ys)||this.setEventListener(ae(this,jc))}onUnsubscribe(){var t;this.hasListeners()||((t=ae(this,Ys))==null||t.call(this),Ve(this,Ys,void 0))}setEventListener(t){var n;Ve(this,jc,t),(n=ae(this,Ys))==null||n.call(this),Ve(this,Ys,t(this.setOnline.bind(this)))}setOnline(t){ae(this,Fc)!==t&&(Ve(this,Fc,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return ae(this,Fc)}},Fc=new WeakMap,Ys=new WeakMap,jc=new WeakMap,GT),Bg=new UV;function GV(e){return Math.min(1e3*2**e,3e4)}function Tm(e){return(e??"online")==="online"?Bg.isOnline():!0}var PD=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function c0(e){return e instanceof PD}function OD(e){let t=!1,n=0,r=!1,o,i,s;const a=new Promise((w,y)=>{i=w,s=y}),l=w=>{var y;r||(p(new PD(w)),(y=e.abort)==null||y.call(e))},c=()=>{t=!0},u=()=>{t=!1},f=()=>!zg.isFocused()||e.networkMode!=="always"&&!Bg.isOnline(),h=w=>{var y;r||(r=!0,(y=e.onSuccess)==null||y.call(e,w),o==null||o(),i(w))},p=w=>{var y;r||(r=!0,(y=e.onError)==null||y.call(e,w),o==null||o(),s(w))},v=()=>new Promise(w=>{var y;o=_=>{const S=r||!f();return S&&w(_),S},(y=e.onPause)==null||y.call(e)}).then(()=>{var w;o=void 0,r||(w=e.onContinue)==null||w.call(e)}),b=()=>{if(r)return;let w;try{w=e.fn()}catch(y){w=Promise.reject(y)}Promise.resolve(w).then(h).catch(y=>{var $;if(r)return;const _=e.retry??(nu?0:3),S=e.retryDelay??GV,E=typeof S=="function"?S(n,y):S,C=_===!0||typeof _=="number"&&n<_||typeof _=="function"&&_(n,y);if(t||!C){p(y);return}n++,($=e.onFail)==null||$.call(e,n,y),BV(E).then(()=>{if(f())return v()}).then(()=>{t?p(y):b()})})};return Tm(e.networkMode)?b():v().then(b),{promise:a,cancel:l,continue:()=>(o==null?void 0:o())?a:Promise.resolve(),cancelRetry:c,continueRetry:u}}function qV(){let e=[],t=0,n=h=>{h()},r=h=>{h()},o=h=>setTimeout(h,0);const i=h=>{o=h},s=h=>{let p;t++;try{p=h()}finally{t--,t||c()}return p},a=h=>{t?e.push(h):o(()=>{n(h)})},l=h=>(...p)=>{a(()=>{h(...p)})},c=()=>{const h=e;e=[],h.length&&o(()=>{r(()=>{h.forEach(p=>{n(p)})})})};return{batch:s,batchCalls:l,schedule:a,setNotifyFunction:h=>{n=h},setBatchNotifyFunction:h=>{r=h},setScheduler:i}}var Qn=qV(),tl,qT,$D=(qT=class{constructor(){Xe(this,tl,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ux(this.gcTime)&&Ve(this,tl,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(nu?1/0:5*60*1e3))}clearGcTimeout(){ae(this,tl)&&(clearTimeout(ae(this,tl)),Ve(this,tl,void 0))}},tl=new WeakMap,qT),zc,Bc,Po,Ks,Oo,Un,kf,nl,Vc,xg,Yo,Qi,YT,YV=(YT=class extends $D{constructor(t){super();Xe(this,Vc);Xe(this,Yo);Xe(this,zc,void 0);Xe(this,Bc,void 0);Xe(this,Po,void 0);Xe(this,Ks,void 0);Xe(this,Oo,void 0);Xe(this,Un,void 0);Xe(this,kf,void 0);Xe(this,nl,void 0);Ve(this,nl,!1),Ve(this,kf,t.defaultOptions),Et(this,Vc,xg).call(this,t.options),Ve(this,Un,[]),Ve(this,Po,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,Ve(this,zc,t.state||KV(this.options)),this.state=ae(this,zc),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!ae(this,Un).length&&this.state.fetchStatus==="idle"&&ae(this,Po).remove(this)}setData(t,n){const r=hx(this.state.data,t,this.options);return Et(this,Yo,Qi).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){Et(this,Yo,Qi).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r;const n=ae(this,Ks);return(r=ae(this,Oo))==null||r.cancel(t),n?n.then(To).catch(To):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(ae(this,zc))}isActive(){return ae(this,Un).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||ae(this,Un).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!ED(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=ae(this,Un).find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=ae(this,Oo))==null||n.continue()}onOnline(){var n;const t=ae(this,Un).find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=ae(this,Oo))==null||n.continue()}addObserver(t){ae(this,Un).includes(t)||(ae(this,Un).push(t),this.clearGcTimeout(),ae(this,Po).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){ae(this,Un).includes(t)&&(Ve(this,Un,ae(this,Un).filter(n=>n!==t)),ae(this,Un).length||(ae(this,Oo)&&(ae(this,nl)?ae(this,Oo).cancel({revert:!0}):ae(this,Oo).cancelRetry()),this.scheduleGc()),ae(this,Po).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return ae(this,Un).length}invalidate(){this.state.isInvalidated||Et(this,Yo,Qi).call(this,{type:"invalidate"})}fetch(t,n){var c,u,f,h;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(ae(this,Ks))return(c=ae(this,Oo))==null||c.continueRetry(),ae(this,Ks)}if(t&&Et(this,Vc,xg).call(this,t),!this.options.queryFn){const p=ae(this,Un).find(v=>v.options.queryFn);p&&Et(this,Vc,xg).call(this,p.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o={queryKey:this.queryKey,meta:this.meta},i=p=>{Object.defineProperty(p,"signal",{enumerable:!0,get:()=>(Ve(this,nl,!0),r.signal)})};i(o);const s=()=>this.options.queryFn?(Ve(this,nl,!1),this.options.persister?this.options.persister(this.options.queryFn,o,this):this.options.queryFn(o)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),a={fetchOptions:n,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:s};i(a),(u=this.options.behavior)==null||u.onFetch(a,this),Ve(this,Bc,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=a.fetchOptions)==null?void 0:f.meta))&&Et(this,Yo,Qi).call(this,{type:"fetch",meta:(h=a.fetchOptions)==null?void 0:h.meta});const l=p=>{var v,b,w,y;c0(p)&&p.silent||Et(this,Yo,Qi).call(this,{type:"error",error:p}),c0(p)||((b=(v=ae(this,Po).config).onError)==null||b.call(v,p,this),(y=(w=ae(this,Po).config).onSettled)==null||y.call(w,this.state.data,p,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return Ve(this,Oo,OD({fn:a.fetchFn,abort:r.abort.bind(r),onSuccess:p=>{var v,b,w,y;if(typeof p>"u"){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),l(new Error(`${this.queryHash} data is undefined`));return}this.setData(p),(b=(v=ae(this,Po).config).onSuccess)==null||b.call(v,p,this),(y=(w=ae(this,Po).config).onSettled)==null||y.call(w,p,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:l,onFail:(p,v)=>{Et(this,Yo,Qi).call(this,{type:"failed",failureCount:p,error:v})},onPause:()=>{Et(this,Yo,Qi).call(this,{type:"pause"})},onContinue:()=>{Et(this,Yo,Qi).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode})),Ve(this,Ks,ae(this,Oo).promise),ae(this,Ks)}},zc=new WeakMap,Bc=new WeakMap,Po=new WeakMap,Ks=new WeakMap,Oo=new WeakMap,Un=new WeakMap,kf=new WeakMap,nl=new WeakMap,Vc=new WeakSet,xg=function(t){this.options={...ae(this,kf),...t},this.updateGcTime(this.options.gcTime)},Yo=new WeakSet,Qi=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:t.meta??null,fetchStatus:Tm(this.options.networkMode)?"fetching":"paused",...!r.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const o=t.error;return c0(o)&&o.revert&&ae(this,Bc)?{...ae(this,Bc),fetchStatus:"idle"}:{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Qn.batch(()=>{ae(this,Un).forEach(r=>{r.onQueryUpdate()}),ae(this,Po).notify({query:this,type:"updated",action:t})})},YT);function KV(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=typeof t<"u",r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var mi,KT,TD=(KT=class extends Uf{constructor(t={}){super();Xe(this,mi,void 0);this.config=t,Ve(this,mi,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??gw(o,n);let s=this.get(i);return s||(s=new YV({cache:this,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(s)),s}add(t){ae(this,mi).has(t.queryHash)||(ae(this,mi).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=ae(this,mi).get(t.queryHash);n&&(t.destroy(),n===t&&ae(this,mi).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Qn.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return ae(this,mi).get(t)}getAll(){return[...ae(this,mi).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>nP(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>nP(t,r)):n}notify(t){Qn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Qn.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Qn.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},mi=new WeakMap,KT),vi,Mf,Zr,Hc,bi,Vs,XT,XV=(XT=class extends $D{constructor(t){super();Xe(this,bi);Xe(this,vi,void 0);Xe(this,Mf,void 0);Xe(this,Zr,void 0);Xe(this,Hc,void 0);this.mutationId=t.mutationId,Ve(this,Mf,t.defaultOptions),Ve(this,Zr,t.mutationCache),Ve(this,vi,[]),this.state=t.state||QV(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...ae(this,Mf),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){ae(this,vi).includes(t)||(ae(this,vi).push(t),this.clearGcTimeout(),ae(this,Zr).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){Ve(this,vi,ae(this,vi).filter(n=>n!==t)),this.scheduleGc(),ae(this,Zr).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){ae(this,vi).length||(this.state.status==="pending"?this.scheduleGc():ae(this,Zr).remove(this))}continue(){var t;return((t=ae(this,Hc))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,s,a,l,c,u,f,h,p,v,b,w,y,_,S,E,C,$,O;const n=()=>(Ve(this,Hc,OD({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(A,I)=>{Et(this,bi,Vs).call(this,{type:"failed",failureCount:A,error:I})},onPause:()=>{Et(this,bi,Vs).call(this,{type:"pause"})},onContinue:()=>{Et(this,bi,Vs).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),ae(this,Hc).promise),r=this.state.status==="pending";try{if(!r){Et(this,bi,Vs).call(this,{type:"pending",variables:t}),await((i=(o=ae(this,Zr).config).onMutate)==null?void 0:i.call(o,t,this));const I=await((a=(s=this.options).onMutate)==null?void 0:a.call(s,t));I!==this.state.context&&Et(this,bi,Vs).call(this,{type:"pending",context:I,variables:t})}const A=await n();return await((c=(l=ae(this,Zr).config).onSuccess)==null?void 0:c.call(l,A,t,this.state.context,this)),await((f=(u=this.options).onSuccess)==null?void 0:f.call(u,A,t,this.state.context)),await((p=(h=ae(this,Zr).config).onSettled)==null?void 0:p.call(h,A,null,this.state.variables,this.state.context,this)),await((b=(v=this.options).onSettled)==null?void 0:b.call(v,A,null,t,this.state.context)),Et(this,bi,Vs).call(this,{type:"success",data:A}),A}catch(A){try{throw await((y=(w=ae(this,Zr).config).onError)==null?void 0:y.call(w,A,t,this.state.context,this)),await((S=(_=this.options).onError)==null?void 0:S.call(_,A,t,this.state.context)),await((C=(E=ae(this,Zr).config).onSettled)==null?void 0:C.call(E,void 0,A,this.state.variables,this.state.context,this)),await((O=($=this.options).onSettled)==null?void 0:O.call($,void 0,A,t,this.state.context)),A}finally{Et(this,bi,Vs).call(this,{type:"error",error:A})}}}},vi=new WeakMap,Mf=new WeakMap,Zr=new WeakMap,Hc=new WeakMap,bi=new WeakSet,Vs=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!Tm(this.options.networkMode),status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Qn.batch(()=>{ae(this,vi).forEach(r=>{r.onMutationUpdate(t)}),ae(this,Zr).notify({mutation:this,type:"updated",action:t})})},XT);function QV(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var $o,If,rl,QT,JV=(QT=class extends Uf{constructor(t={}){super();Xe(this,$o,void 0);Xe(this,If,void 0);Xe(this,rl,void 0);this.config=t,Ve(this,$o,[]),Ve(this,If,0)}build(t,n,r){const o=new XV({mutationCache:this,mutationId:++up(this,If)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){ae(this,$o).push(t),this.notify({type:"added",mutation:t})}remove(t){Ve(this,$o,ae(this,$o).filter(n=>n!==t)),this.notify({type:"removed",mutation:t})}clear(){Qn.batch(()=>{ae(this,$o).forEach(t=>{this.remove(t)})})}getAll(){return ae(this,$o)}find(t){const n={exact:!0,...t};return ae(this,$o).find(r=>rP(n,r))}findAll(t={}){return ae(this,$o).filter(n=>rP(t,n))}notify(t){Qn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){return Ve(this,rl,(ae(this,rl)??Promise.resolve()).then(()=>{const t=ae(this,$o).filter(n=>n.state.isPaused);return Qn.batch(()=>t.reduce((n,r)=>n.then(()=>r.continue().catch(To)),Promise.resolve()))}).then(()=>{Ve(this,rl,void 0)})),ae(this,rl)}},$o=new WeakMap,If=new WeakMap,rl=new WeakMap,QT);function ZV(e){return{onFetch:(t,n)=>{const r=async()=>{var v,b,w,y,_;const o=t.options,i=(w=(b=(v=t.fetchOptions)==null?void 0:v.meta)==null?void 0:b.fetchMore)==null?void 0:w.direction,s=((y=t.state.data)==null?void 0:y.pages)||[],a=((_=t.state.data)==null?void 0:_.pageParams)||[],l={pages:[],pageParams:[]};let c=!1;const u=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(t.signal.aborted?c=!0:t.signal.addEventListener("abort",()=>{c=!0}),t.signal)})},f=t.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${t.options.queryHash}'`))),h=async(S,E,C)=>{if(c)return Promise.reject();if(E==null&&S.pages.length)return Promise.resolve(S);const $={queryKey:t.queryKey,pageParam:E,direction:C?"backward":"forward",meta:t.options.meta};u($);const O=await f($),{maxPages:A}=t.options,I=C?HV:VV;return{pages:I(S.pages,O,A),pageParams:I(S.pageParams,E,A)}};let p;if(i&&s.length){const S=i==="backward",E=S?eH:sP,C={pages:s,pageParams:a},$=E(o,C);p=await h(C,$,S)}else{p=await h(l,a[0]??o.initialPageParam);const S=e??s.length;for(let E=1;E<S;E++){const C=sP(o,p);p=await h(p,C)}}return p};t.options.persister?t.fetchFn=()=>{var o,i;return(i=(o=t.options).persister)==null?void 0:i.call(o,r,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=r}}}function sP(e,{pages:t,pageParams:n}){const r=t.length-1;return e.getNextPageParam(t[r],t,n[r],n)}function eH(e,{pages:t,pageParams:n}){var r;return(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n)}var Fn,Xs,Qs,Wc,Uc,Js,Gc,qc,JT,tH=(JT=class{constructor(e={}){Xe(this,Fn,void 0);Xe(this,Xs,void 0);Xe(this,Qs,void 0);Xe(this,Wc,void 0);Xe(this,Uc,void 0);Xe(this,Js,void 0);Xe(this,Gc,void 0);Xe(this,qc,void 0);Ve(this,Fn,e.queryCache||new TD),Ve(this,Xs,e.mutationCache||new JV),Ve(this,Qs,e.defaultOptions||{}),Ve(this,Wc,new Map),Ve(this,Uc,new Map),Ve(this,Js,0)}mount(){up(this,Js)._++,ae(this,Js)===1&&(Ve(this,Gc,zg.subscribe(()=>{zg.isFocused()&&(this.resumePausedMutations(),ae(this,Fn).onFocus())})),Ve(this,qc,Bg.subscribe(()=>{Bg.isOnline()&&(this.resumePausedMutations(),ae(this,Fn).onOnline())})))}unmount(){var e,t;up(this,Js)._--,ae(this,Js)===0&&((e=ae(this,Gc))==null||e.call(this),Ve(this,Gc,void 0),(t=ae(this,qc))==null||t.call(this),Ve(this,qc,void 0))}isFetching(e){return ae(this,Fn).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return ae(this,Xs).findAll({...e,status:"pending"}).length}getQueryData(e){var t;return(t=ae(this,Fn).find({queryKey:e}))==null?void 0:t.state.data}ensureQueryData(e){const t=this.getQueryData(e.queryKey);return t!==void 0?Promise.resolve(t):this.fetchQuery(e)}getQueriesData(e){return this.getQueryCache().findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=ae(this,Fn).find({queryKey:e}),o=r==null?void 0:r.state.data,i=zV(t,o);if(typeof i>"u")return;const s=this.defaultQueryOptions({queryKey:e});return ae(this,Fn).build(this,s).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Qn.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var t;return(t=ae(this,Fn).find({queryKey:e}))==null?void 0:t.state}removeQueries(e){const t=ae(this,Fn);Qn.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=ae(this,Fn),r={type:"active",...e};return Qn.batch(()=>(n.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries(r,t)))}cancelQueries(e={},t={}){const n={revert:!0,...t},r=Qn.batch(()=>ae(this,Fn).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(To).catch(To)}invalidateQueries(e={},t={}){return Qn.batch(()=>{if(ae(this,Fn).findAll(e).forEach(r=>{r.invalidate()}),e.refetchType==="none")return Promise.resolve();const n={...e,type:e.refetchType??e.type??"active"};return this.refetchQueries(n,t)})}refetchQueries(e={},t){const n={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},r=Qn.batch(()=>ae(this,Fn).findAll(e).filter(o=>!o.isDisabled()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(To)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(To)}fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const n=ae(this,Fn).build(this,t);return n.isStaleByTime(t.staleTime)?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(To).catch(To)}fetchInfiniteQuery(e){return e.behavior=ZV(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(To).catch(To)}resumePausedMutations(){return ae(this,Xs).resumePausedMutations()}getQueryCache(){return ae(this,Fn)}getMutationCache(){return ae(this,Xs)}getDefaultOptions(){return ae(this,Qs)}setDefaultOptions(e){Ve(this,Qs,e)}setQueryDefaults(e,t){ae(this,Wc).set(qd(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...ae(this,Wc).values()];let n={};return t.forEach(r=>{Yd(e,r.queryKey)&&(n={...n,...r.defaultOptions})}),n}setMutationDefaults(e,t){ae(this,Uc).set(qd(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...ae(this,Uc).values()];let n={};return t.forEach(r=>{Yd(e,r.mutationKey)&&(n={...n,...r.defaultOptions})}),n}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...ae(this,Qs).queries,...(e==null?void 0:e.queryKey)&&this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=gw(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.throwOnError>"u"&&(t.throwOnError=!!t.suspense),typeof t.networkMode>"u"&&t.persister&&(t.networkMode="offlineFirst"),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...ae(this,Qs).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){ae(this,Fn).clear(),ae(this,Xs).clear()}},Fn=new WeakMap,Xs=new WeakMap,Qs=new WeakMap,Wc=new WeakMap,Uc=new WeakMap,Js=new WeakMap,Gc=new WeakMap,qc=new WeakMap,JT),Ir,fn,Nf,yr,ol,Yc,yi,Lf,Kc,Xc,il,sl,Zs,Qc,al,vd,Ff,px,jf,gx,zf,mx,Bf,vx,Vf,bx,Hf,yx,Wf,xx,Sm,DD,ZT,nH=(ZT=class extends Uf{constructor(t,n){super();Xe(this,al);Xe(this,Ff);Xe(this,jf);Xe(this,zf);Xe(this,Bf);Xe(this,Vf);Xe(this,Hf);Xe(this,Wf);Xe(this,Sm);Xe(this,Ir,void 0);Xe(this,fn,void 0);Xe(this,Nf,void 0);Xe(this,yr,void 0);Xe(this,ol,void 0);Xe(this,Yc,void 0);Xe(this,yi,void 0);Xe(this,Lf,void 0);Xe(this,Kc,void 0);Xe(this,Xc,void 0);Xe(this,il,void 0);Xe(this,sl,void 0);Xe(this,Zs,void 0);Xe(this,Qc,new Set);this.options=n,Ve(this,Ir,t),Ve(this,yi,null),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(ae(this,fn).addObserver(this),aP(ae(this,fn),this.options)?Et(this,al,vd).call(this):this.updateResult(),Et(this,Bf,vx).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return wx(ae(this,fn),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return wx(ae(this,fn),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Et(this,Vf,bx).call(this),Et(this,Hf,yx).call(this),ae(this,fn).removeObserver(this)}setOptions(t,n){const r=this.options,o=ae(this,fn);if(this.options=ae(this,Ir).defaultQueryOptions(t),dx(r,this.options)||ae(this,Ir).getQueryCache().notify({type:"observerOptionsUpdated",query:ae(this,fn),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=r.queryKey),Et(this,Wf,xx).call(this);const i=this.hasListeners();i&&lP(ae(this,fn),o,this.options,r)&&Et(this,al,vd).call(this),this.updateResult(n),i&&(ae(this,fn)!==o||this.options.enabled!==r.enabled||this.options.staleTime!==r.staleTime)&&Et(this,Ff,px).call(this);const s=Et(this,jf,gx).call(this);i&&(ae(this,fn)!==o||this.options.enabled!==r.enabled||s!==ae(this,Zs))&&Et(this,zf,mx).call(this,s)}getOptimisticResult(t){const n=ae(this,Ir).getQueryCache().build(ae(this,Ir),t),r=this.createResult(n,t);return oH(this,r)&&(Ve(this,yr,r),Ve(this,Yc,this.options),Ve(this,ol,ae(this,fn).state)),r}getCurrentResult(){return ae(this,yr)}trackResult(t){const n={};return Object.keys(t).forEach(r=>{Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:()=>(ae(this,Qc).add(r),t[r])})}),n}getCurrentQuery(){return ae(this,fn)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=ae(this,Ir).defaultQueryOptions(t),r=ae(this,Ir).getQueryCache().build(ae(this,Ir),n);return r.isFetchingOptimistic=!0,r.fetch().then(()=>this.createResult(r,n))}fetch(t){return Et(this,al,vd).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),ae(this,yr)))}createResult(t,n){var $;const r=ae(this,fn),o=this.options,i=ae(this,yr),s=ae(this,ol),a=ae(this,Yc),c=t!==r?t.state:ae(this,Nf),{state:u}=t;let{error:f,errorUpdatedAt:h,fetchStatus:p,status:v}=u,b=!1,w;if(n._optimisticResults){const O=this.hasListeners(),A=!O&&aP(t,n),I=O&&lP(t,r,n,o);(A||I)&&(p=Tm(t.options.networkMode)?"fetching":"paused",u.dataUpdatedAt||(v="pending")),n._optimisticResults==="isRestoring"&&(p="idle")}if(n.select&&typeof u.data<"u")if(i&&u.data===(s==null?void 0:s.data)&&n.select===ae(this,Lf))w=ae(this,Kc);else try{Ve(this,Lf,n.select),w=n.select(u.data),w=hx(i==null?void 0:i.data,w,n),Ve(this,Kc,w),Ve(this,yi,null)}catch(O){Ve(this,yi,O)}else w=u.data;if(typeof n.placeholderData<"u"&&typeof w>"u"&&v==="pending"){let O;if(i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData))O=i.data;else if(O=typeof n.placeholderData=="function"?n.placeholderData(($=ae(this,Xc))==null?void 0:$.state.data,ae(this,Xc)):n.placeholderData,n.select&&typeof O<"u")try{O=n.select(O),Ve(this,yi,null)}catch(A){Ve(this,yi,A)}typeof O<"u"&&(v="success",w=hx(i==null?void 0:i.data,O,n),b=!0)}ae(this,yi)&&(f=ae(this,yi),w=ae(this,Kc),h=Date.now(),v="error");const y=p==="fetching",_=v==="pending",S=v==="error",E=_&&y;return{status:v,fetchStatus:p,isPending:_,isSuccess:v==="success",isError:S,isInitialLoading:E,isLoading:E,data:w,dataUpdatedAt:u.dataUpdatedAt,error:f,errorUpdatedAt:h,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>c.dataUpdateCount||u.errorUpdateCount>c.errorUpdateCount,isFetching:y,isRefetching:y&&!_,isLoadingError:S&&u.dataUpdatedAt===0,isPaused:p==="paused",isPlaceholderData:b,isRefetchError:S&&u.dataUpdatedAt!==0,isStale:mw(t,n),refetch:this.refetch}}updateResult(t){const n=ae(this,yr),r=this.createResult(ae(this,fn),this.options);if(Ve(this,ol,ae(this,fn).state),Ve(this,Yc,this.options),ae(this,ol).data!==void 0&&Ve(this,Xc,ae(this,fn)),dx(r,n))return;Ve(this,yr,r);const o={},i=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!ae(this,Qc).size)return!0;const l=new Set(a??ae(this,Qc));return this.options.throwOnError&&l.add("error"),Object.keys(ae(this,yr)).some(c=>{const u=c;return ae(this,yr)[u]!==n[u]&&l.has(u)})};(t==null?void 0:t.listeners)!==!1&&i()&&(o.listeners=!0),Et(this,Sm,DD).call(this,{...o,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Et(this,Bf,vx).call(this)}},Ir=new WeakMap,fn=new WeakMap,Nf=new WeakMap,yr=new WeakMap,ol=new WeakMap,Yc=new WeakMap,yi=new WeakMap,Lf=new WeakMap,Kc=new WeakMap,Xc=new WeakMap,il=new WeakMap,sl=new WeakMap,Zs=new WeakMap,Qc=new WeakMap,al=new WeakSet,vd=function(t){Et(this,Wf,xx).call(this);let n=ae(this,fn).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(To)),n},Ff=new WeakSet,px=function(){if(Et(this,Vf,bx).call(this),nu||ae(this,yr).isStale||!ux(this.options.staleTime))return;const n=ED(ae(this,yr).dataUpdatedAt,this.options.staleTime)+1;Ve(this,il,setTimeout(()=>{ae(this,yr).isStale||this.updateResult()},n))},jf=new WeakSet,gx=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(ae(this,fn)):this.options.refetchInterval)??!1},zf=new WeakSet,mx=function(t){Et(this,Hf,yx).call(this),Ve(this,Zs,t),!(nu||this.options.enabled===!1||!ux(ae(this,Zs))||ae(this,Zs)===0)&&Ve(this,sl,setInterval(()=>{(this.options.refetchIntervalInBackground||zg.isFocused())&&Et(this,al,vd).call(this)},ae(this,Zs)))},Bf=new WeakSet,vx=function(){Et(this,Ff,px).call(this),Et(this,zf,mx).call(this,Et(this,jf,gx).call(this))},Vf=new WeakSet,bx=function(){ae(this,il)&&(clearTimeout(ae(this,il)),Ve(this,il,void 0))},Hf=new WeakSet,yx=function(){ae(this,sl)&&(clearInterval(ae(this,sl)),Ve(this,sl,void 0))},Wf=new WeakSet,xx=function(){const t=ae(this,Ir).getQueryCache().build(ae(this,Ir),this.options);if(t===ae(this,fn))return;const n=ae(this,fn);Ve(this,fn,t),Ve(this,Nf,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},Sm=new WeakSet,DD=function(t){Qn.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(ae(this,yr))}),ae(this,Ir).getQueryCache().notify({query:ae(this,fn),type:"observerResultsUpdated"})})},ZT);function rH(e,t){return t.enabled!==!1&&!e.state.dataUpdatedAt&&!(e.state.status==="error"&&t.retryOnMount===!1)}function aP(e,t){return rH(e,t)||e.state.dataUpdatedAt>0&&wx(e,t,t.refetchOnMount)}function wx(e,t,n){if(t.enabled!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&mw(e,t)}return!1}function lP(e,t,n,r){return n.enabled!==!1&&(e!==t||r.enabled===!1)&&(!n.suspense||e.state.status!=="error")&&mw(e,n)}function mw(e,t){return e.isStaleByTime(t.staleTime)}function oH(e,t){return!dx(e.getCurrentResult(),t)}var AD=N.createContext(void 0),kD=e=>{const t=N.useContext(AD);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},iH=({client:e,children:t})=>(N.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),N.createElement(AD.Provider,{value:e},t)),MD=N.createContext(!1),sH=()=>N.useContext(MD);MD.Provider;function aH(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var lH=N.createContext(aH()),cH=()=>N.useContext(lH);function uH(e,t){return typeof e=="function"?e(...t):!!e}var dH=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},fH=e=>{N.useEffect(()=>{e.clearReset()},[e])},hH=({result:e,errorResetBoundary:t,throwOnError:n,query:r})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&uH(n,[e.error,r]),pH=e=>{e.suspense&&typeof e.staleTime!="number"&&(e.staleTime=1e3)},gH=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,mH=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function vH(e,t,n){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=kD(n),o=sH(),i=cH(),s=r.defaultQueryOptions(e);s._optimisticResults=o?"isRestoring":"optimistic",pH(s),dH(s,i),fH(i);const[a]=N.useState(()=>new t(r,s)),l=a.getOptimisticResult(s);if(N.useSyncExternalStore(N.useCallback(c=>{const u=o?()=>{}:a.subscribe(Qn.batchCalls(c));return a.updateResult(),u},[a,o]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),N.useEffect(()=>{a.setOptions(s,{listeners:!1})},[s,a]),gH(s,l))throw mH(s,a,i);if(hH({result:l,errorResetBoundary:i,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash)}))throw l.error;return s.notifyOnChangeProps?l:a.trackResult(l)}function Dm(e,t){return vH(e,nH,t)}function ID({children:e}){const{setIsSessionExpired:t}=ur(),n=new tH({queryCache:new TD({onError:r=>{console.error(`Something went wrong: ${r.message}`),r.message==="invalid token"&&t(!0)}}),defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}});return R.jsx(iH,{client:n,children:e})}const Ol=m.forwardRef(({children:e,className:t,...n},r)=>R.jsx("div",{className:xe("semaphor-scope",t),ref:r,...n,children:e})),bH={id:"",authToken:void 0},ND=m.createContext(bH),LD=({children:e,dashboardProps:t})=>R.jsx(ID,{children:R.jsx(ND.Provider,{value:t,children:R.jsx(Ol,{style:{height:"100%"},children:e})})});function ni(){const e=m.useContext(ND);if(e===void 0)throw new Error("useApplicationContext must be used within a ApplicationContextProvider");return e}function yH(){const{authToken:e}=ni(),t=Ee(s=>s.selectedLensId),{data:n,isLoading:r,isFetching:o,isError:i}=Dm({queryKey:["dashboard",t,e==null?void 0:e.accessToken],queryFn:()=>nV(e==null?void 0:e.accessToken,{lensId:t})});return{data:n,isLoading:r,isFetching:o,isError:i}}function FD(e){return e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e}function cP(e,t){const n=FD(e);return n==="dark"?ll.merge({...t==null?void 0:t.default},{...t==null?void 0:t.dark}):t==null?void 0:t.default}function xH({customStyle:e,currentTheme:t,onSave:n,onEvent:r,defaultFilterValues:o}){const{authToken:i}=ni(),s=Ee(L=>L.selectedLensId),{data:a,isLoading:l,isFetching:c,isError:u}=yH(),{theme:f,setTheme:h}=CD(),p=Ee(L=>L.dashboard.globalStyle),{setDashboard:v,setDashboardWithFilterValues:b,setSelectedSheetId:w,setStyle:y,setOnSaveFunction:_,setLenses:S,setSelectedLensId:E,setInitStore:C}=Ee(L=>L.actions);Ee(L=>L.actions.setCustomCards);const $=Ee(L=>L.actions.setFilterValues),O=Ee(L=>L.actions.setThemeStyle),A=Ee(L=>L.actions.setDashboardTheme),I=Ee(L=>L.actions.setOnEvent);m.useEffect(()=>{i&&C()},[i,C]),m.useEffect(()=>{if(f){const L=FD(f);A(L)}},[f,A]),m.useEffect(()=>{t&&h(t)},[t,h]);const F=m.useCallback(()=>{const L=ll.cloneDeep(Lg),B=ll.merge(L,p);if(e){const J=ll.merge(B,e),q=cP(f,J);O(q),y(J)}else{const J=cP(f,B);O(J),y(Lg)}},[f,e,p,O,y]);return m.useEffect(()=>{a&&a.dashboard&&F()},[f,e,p,F,a]),m.useEffect(()=>{var z;if(!a||!a.dashboard)return;const{dashboard:L,filterValues:B,defaultLensId:J,lenses:q}=a;b(L,B||o||[]),J&&E(J),q&&S(q),w((z=L.sheets)==null?void 0:z[0].id)},[a,v,w,$,s,S,b,E]),m.useEffect(()=>{n&&_(n),r&&I(r)},[n,_,r,I]),{isFetching:c,isLoading:l,isError:u}}function Am({className:e,...t}){return R.jsx("div",{className:xe("animate-pulse rounded-md bg-muted",e),...t})}const vw=N.forwardRef(({className:e,...t},n)=>R.jsx("div",{ref:n,className:xe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));vw.displayName="Card";const km=N.forwardRef(({className:e,...t},n)=>R.jsx("div",{ref:n,className:xe("flex flex-col space-y-1.5 p-6",e),...t}));km.displayName="CardHeader";const bu=N.forwardRef(({className:e,...t},n)=>R.jsx("h3",{ref:n,className:xe("text-2xl font-semibold leading-none tracking-tight",e),...t}));bu.displayName="CardTitle";const bw=N.forwardRef(({className:e,...t},n)=>R.jsx("p",{ref:n,className:xe("text-sm text-muted-foreground",e),...t}));bw.displayName="CardDescription";const Mm=N.forwardRef(({className:e,...t},n)=>R.jsx("div",{ref:n,className:xe("px-6 pt-0",e),...t}));Mm.displayName="CardContent";const yw=N.forwardRef(({className:e,...t},n)=>R.jsx("div",{ref:n,className:xe("flex items-center p-6 pt-0",e),...t}));yw.displayName="CardFooter";function jD({className:e,customStyle:t,onSave:n,onEvent:r,LoadingComponent:o,ErrorComponent:i,onChartElementClicked:s,id:a,authToken:l,currentTheme:c,version:u,customCards:f,showAssistant:h,defaultFilterValues:p,...v}){Ee(E=>E.selectedSheetId);const b=Ee(E=>E.themeStyle),w=Ee(E=>E.isSessionExpired),{isLoading:y,isError:_,isFetching:S}=xH({authToken:l,customStyle:t,currentTheme:c,onSave:n,onEvent:r,defaultFilterValues:p});return y||!l?(r==null||r({type:"info",message:"Loading dashboard"}),o?R.jsx(o,{message:"loading"}):R.jsx("div",{className:"flex items-center gap-3",children:R.jsx(Am,{className:"h-1 w-full dark:h-[2px]"})})):_?(r==null||r({type:"error",message:"Error fetching dashboard"}),i?(console.log("Error fetching dashboard"),R.jsx(i,{})):R.jsx("div",{children:"Error"})):w?(r==null||r({type:"error",message:"Session Expired"}),R.jsx("div",{className:"flex h-full items-center justify-center",children:R.jsxs("div",{className:"space-y-4 rounded-md border border-muted p-10",children:[R.jsx(bu,{children:"Session Expired"}),R.jsx("p",{className:"text-muted-foreground",children:"Please refresh your page to continue."})]})})):R.jsx("div",{className:xe("flex h-full flex-col justify-between",b==null?void 0:b.dashboardPanel,e),style:{},role:"dashboard-panel",...v})}function ce(){return ce=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ce.apply(this,arguments)}function Me(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function tr(e,t=[]){let n=[];function r(i,s){const a=m.createContext(s),l=n.length;n=[...n,s];function c(f){const{scope:h,children:p,...v}=f,b=(h==null?void 0:h[e][l])||a,w=m.useMemo(()=>v,Object.values(v));return m.createElement(b.Provider,{value:w},p)}function u(f,h){const p=(h==null?void 0:h[e][l])||a,v=m.useContext(p);if(v)return v;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return c.displayName=i+"Provider",[c,u]}const o=()=>{const i=n.map(s=>m.createContext(s));return function(a){const l=(a==null?void 0:a[e])||i;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,wH(o,...t)]}function wH(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:l,scopeName:c})=>{const f=l(i)[`__scope${c}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function _H(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function ps(...e){return t=>e.forEach(n=>_H(n,t))}function St(...e){return m.useCallback(ps(...e),e)}const _x=m.forwardRef((e,t)=>{const{children:n,...r}=e,o=m.Children.toArray(n),i=o.find(CH);if(i){const s=i.props.children,a=o.map(l=>l===i?m.Children.count(s)>1?m.Children.only(null):m.isValidElement(s)?s.props.children:null:l);return m.createElement(Sx,ce({},r,{ref:t}),m.isValidElement(s)?m.cloneElement(s,void 0,a):null)}return m.createElement(Sx,ce({},r,{ref:t}),n)});_x.displayName="Slot";const Sx=m.forwardRef((e,t)=>{const{children:n,...r}=e;return m.isValidElement(n)?m.cloneElement(n,{...EH(r,n.props),ref:t?ps(t,n.ref):n.ref}):m.Children.count(n)>1?m.Children.only(null):null});Sx.displayName="SlotClone";const SH=({children:e})=>m.createElement(m.Fragment,null,e);function CH(e){return m.isValidElement(e)&&e.type===SH}function EH(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Im(e){const t=e+"CollectionProvider",[n,r]=tr(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=p=>{const{scope:v,children:b}=p,w=m.useRef(null),y=m.useRef(new Map).current;return m.createElement(o,{scope:v,itemMap:y,collectionRef:w},b)},a=e+"CollectionSlot",l=m.forwardRef((p,v)=>{const{scope:b,children:w}=p,y=i(a,b),_=St(v,y.collectionRef);return m.createElement(_x,{ref:_},w)}),c=e+"CollectionItemSlot",u="data-radix-collection-item",f=m.forwardRef((p,v)=>{const{scope:b,children:w,...y}=p,_=m.useRef(null),S=St(v,_),E=i(c,b);return m.useEffect(()=>(E.itemMap.set(_,{ref:_,...y}),()=>void E.itemMap.delete(_))),m.createElement(_x,{[u]:"",ref:S},w)});function h(p){const v=i(e+"CollectionConsumer",p);return m.useCallback(()=>{const w=v.collectionRef.current;if(!w)return[];const y=Array.from(w.querySelectorAll(`[${u}]`));return Array.from(v.itemMap.values()).sort((E,C)=>y.indexOf(E.ref.current)-y.indexOf(C.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:s,Slot:l,ItemSlot:f},h,r]}const dr=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},RH=N.useId||(()=>{});let PH=0;function Zo(e){const[t,n]=N.useState(RH());return dr(()=>{e||n(r=>r??String(PH++))},[e]),e||(t?`radix-${t}`:"")}const zD=m.forwardRef((e,t)=>{const{children:n,...r}=e,o=m.Children.toArray(n),i=o.find($H);if(i){const s=i.props.children,a=o.map(l=>l===i?m.Children.count(s)>1?m.Children.only(null):m.isValidElement(s)?s.props.children:null:l);return m.createElement(Cx,ce({},r,{ref:t}),m.isValidElement(s)?m.cloneElement(s,void 0,a):null)}return m.createElement(Cx,ce({},r,{ref:t}),n)});zD.displayName="Slot";const Cx=m.forwardRef((e,t)=>{const{children:n,...r}=e;return m.isValidElement(n)?m.cloneElement(n,{...TH(r,n.props),ref:t?ps(t,n.ref):n.ref}):m.Children.count(n)>1?m.Children.only(null):null});Cx.displayName="SlotClone";const OH=({children:e})=>m.createElement(m.Fragment,null,e);function $H(e){return m.isValidElement(e)&&e.type===OH}function TH(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}const DH=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Qe=DH.reduce((e,t)=>{const n=m.forwardRef((r,o)=>{const{asChild:i,...s}=r,a=i?zD:t;return m.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),m.createElement(a,ce({},s,{ref:o}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function BD(e,t){e&&fr.flushSync(()=>e.dispatchEvent(t))}function zn(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)===null||r===void 0?void 0:r.call(t,...n)},[])}function Sr({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=AH({defaultProp:t,onChange:n}),i=e!==void 0,s=i?e:r,a=zn(n),l=m.useCallback(c=>{if(i){const f=typeof c=="function"?c(e):c;f!==e&&a(f)}else o(c)},[i,e,o,a]);return[s,l]}function AH({defaultProp:e,onChange:t}){const n=m.useState(e),[r]=n,o=m.useRef(r),i=zn(t);return m.useEffect(()=>{o.current!==r&&(i(r),o.current=r)},[r,o,i]),n}const kH=m.createContext(void 0);function $l(e){const t=m.useContext(kH);return e||t||"ltr"}const u0="rovingFocusGroup.onEntryFocus",MH={bubbles:!1,cancelable:!0},xw="RovingFocusGroup",[Ex,VD,IH]=Im(xw),[NH,yu]=tr(xw,[IH]),[LH,FH]=NH(xw),jH=m.forwardRef((e,t)=>m.createElement(Ex.Provider,{scope:e.__scopeRovingFocusGroup},m.createElement(Ex.Slot,{scope:e.__scopeRovingFocusGroup},m.createElement(zH,ce({},e,{ref:t}))))),zH=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,...u}=e,f=m.useRef(null),h=St(t,f),p=$l(i),[v=null,b]=Sr({prop:s,defaultProp:a,onChange:l}),[w,y]=m.useState(!1),_=zn(c),S=VD(n),E=m.useRef(!1),[C,$]=m.useState(0);return m.useEffect(()=>{const O=f.current;if(O)return O.addEventListener(u0,_),()=>O.removeEventListener(u0,_)},[_]),m.createElement(LH,{scope:n,orientation:r,dir:p,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(O=>b(O),[b]),onItemShiftTab:m.useCallback(()=>y(!0),[]),onFocusableItemAdd:m.useCallback(()=>$(O=>O+1),[]),onFocusableItemRemove:m.useCallback(()=>$(O=>O-1),[])},m.createElement(Qe.div,ce({tabIndex:w||C===0?-1:0,"data-orientation":r},u,{ref:h,style:{outline:"none",...e.style},onMouseDown:Me(e.onMouseDown,()=>{E.current=!0}),onFocus:Me(e.onFocus,O=>{const A=!E.current;if(O.target===O.currentTarget&&A&&!w){const I=new CustomEvent(u0,MH);if(O.currentTarget.dispatchEvent(I),!I.defaultPrevented){const F=S().filter(z=>z.focusable),L=F.find(z=>z.active),B=F.find(z=>z.id===v),q=[L,B,...F].filter(Boolean).map(z=>z.ref.current);HD(q)}}E.current=!1}),onBlur:Me(e.onBlur,()=>y(!1))})))}),BH="RovingFocusGroupItem",VH=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,...s}=e,a=Zo(),l=i||a,c=FH(BH,n),u=c.currentTabStopId===l,f=VD(n),{onFocusableItemAdd:h,onFocusableItemRemove:p}=c;return m.useEffect(()=>{if(r)return h(),()=>p()},[r,h,p]),m.createElement(Ex.ItemSlot,{scope:n,id:l,focusable:r,active:o},m.createElement(Qe.span,ce({tabIndex:u?0:-1,"data-orientation":c.orientation},s,{ref:t,onMouseDown:Me(e.onMouseDown,v=>{r?c.onItemFocus(l):v.preventDefault()}),onFocus:Me(e.onFocus,()=>c.onItemFocus(l)),onKeyDown:Me(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){c.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=UH(v,c.orientation,c.dir);if(b!==void 0){v.preventDefault();let y=f().filter(_=>_.focusable).map(_=>_.ref.current);if(b==="last")y.reverse();else if(b==="prev"||b==="next"){b==="prev"&&y.reverse();const _=y.indexOf(v.currentTarget);y=c.loop?GH(y,_+1):y.slice(_+1)}setTimeout(()=>HD(y))}})})))}),HH={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function WH(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function UH(e,t,n){const r=WH(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return HH[r]}function HD(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function GH(e,t){return e.map((n,r)=>e[(t+r)%e.length])}const ww=jH,_w=VH;function qH(e,t){return m.useReducer((n,r)=>{const o=t[n][r];return o??n},e)}const nr=e=>{const{present:t,children:n}=e,r=YH(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),i=St(r.ref,o.ref);return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:i}):null};nr.displayName="Presence";function YH(e){const[t,n]=m.useState(),r=m.useRef({}),o=m.useRef(e),i=m.useRef("none"),s=e?"mounted":"unmounted",[a,l]=qH(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const c=pp(r.current);i.current=a==="mounted"?c:"none"},[a]),dr(()=>{const c=r.current,u=o.current;if(u!==e){const h=i.current,p=pp(c);e?l("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),dr(()=>{if(t){const c=f=>{const p=pp(r.current).includes(f.animationName);f.target===t&&p&&fr.flushSync(()=>l("ANIMATION_END"))},u=f=>{f.target===t&&(i.current=pp(r.current))};return t.addEventListener("animationstart",u),t.addEventListener("animationcancel",c),t.addEventListener("animationend",c),()=>{t.removeEventListener("animationstart",u),t.removeEventListener("animationcancel",c),t.removeEventListener("animationend",c)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function pp(e){return(e==null?void 0:e.animationName)||"none"}const WD="Tabs",[KH,$1e]=tr(WD,[yu]),UD=yu(),[XH,Sw]=KH(WD),QH=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:l="automatic",...c}=e,u=$l(a),[f,h]=Sr({prop:r,onChange:o,defaultProp:i});return m.createElement(XH,{scope:n,baseId:Zo(),value:f,onValueChange:h,orientation:s,dir:u,activationMode:l},m.createElement(Qe.div,ce({dir:u,"data-orientation":s},c,{ref:t})))}),JH="TabsList",ZH=m.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=Sw(JH,n),s=UD(n);return m.createElement(ww,ce({asChild:!0},s,{orientation:i.orientation,dir:i.dir,loop:r}),m.createElement(Qe.div,ce({role:"tablist","aria-orientation":i.orientation},o,{ref:t})))}),eW="TabsTrigger",tW=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,s=Sw(eW,n),a=UD(n),l=GD(s.baseId,r),c=qD(s.baseId,r),u=r===s.value;return m.createElement(_w,ce({asChild:!0},a,{focusable:!o,active:u}),m.createElement(Qe.button,ce({type:"button",role:"tab","aria-selected":u,"aria-controls":c,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l},i,{ref:t,onMouseDown:Me(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?s.onValueChange(r):f.preventDefault()}),onKeyDown:Me(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&s.onValueChange(r)}),onFocus:Me(e.onFocus,()=>{const f=s.activationMode!=="manual";!u&&!o&&f&&s.onValueChange(r)})})))}),nW="TabsContent",rW=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=e,a=Sw(nW,n),l=GD(a.baseId,r),c=qD(a.baseId,r),u=r===a.value,f=m.useRef(u);return m.useEffect(()=>{const h=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(h)},[]),m.createElement(nr,{present:o||u},({present:h})=>m.createElement(Qe.div,ce({"data-state":u?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!h,id:c,tabIndex:0},s,{ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0}}),h&&i))});function GD(e,t){return`${e}-trigger-${t}`}function qD(e,t){return`${e}-content-${t}`}const oW=QH,YD=ZH,KD=tW,XD=rW,Cw=oW,Nm=N.forwardRef(({className:e,...t},n)=>R.jsx(YD,{ref:n,className:xe("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));Nm.displayName=YD.displayName;const Lm=N.forwardRef(({className:e,...t},n)=>R.jsx(KD,{ref:n,className:xe("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));Lm.displayName=KD.displayName;const Ew=N.forwardRef(({className:e,...t},n)=>R.jsx(XD,{ref:n,className:xe("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Ew.displayName=XD.displayName;var QD={exports:{}},Gf={},Rx={exports:{}};(function(e,t){(function(n,r){r(t)})(Gs,function(n){function r(Z){return function(ie,me,X,be,Se,$e,Te){return Z(ie,me,Te)}}function o(Z){return function(ie,me,X,be){if(!ie||!me||typeof ie!="object"||typeof me!="object")return Z(ie,me,X,be);var Se=be.get(ie),$e=be.get(me);if(Se&&$e)return Se===me&&$e===ie;be.set(ie,me),be.set(me,ie);var Te=Z(ie,me,X,be);return be.delete(ie),be.delete(me),Te}}function i(Z,te){var ie={};for(var me in Z)ie[me]=Z[me];for(var me in te)ie[me]=te[me];return ie}function s(Z){return Z.constructor===Object||Z.constructor==null}function a(Z){return typeof Z.then=="function"}function l(Z,te){return Z===te||Z!==Z&&te!==te}var c="[object Arguments]",u="[object Boolean]",f="[object Date]",h="[object RegExp]",p="[object Map]",v="[object Number]",b="[object Object]",w="[object Set]",y="[object String]",_=Object.prototype.toString;function S(Z){var te=Z.areArraysEqual,ie=Z.areDatesEqual,me=Z.areMapsEqual,X=Z.areObjectsEqual,be=Z.areRegExpsEqual,Se=Z.areSetsEqual,$e=Z.createIsNestedEqual,Te=$e(Ue);function Ue(Be,Ie,Ke){if(Be===Ie)return!0;if(!Be||!Ie||typeof Be!="object"||typeof Ie!="object")return Be!==Be&&Ie!==Ie;if(s(Be)&&s(Ie))return X(Be,Ie,Te,Ke);var lt=Array.isArray(Be),Nt=Array.isArray(Ie);if(lt||Nt)return lt===Nt&&te(Be,Ie,Te,Ke);var At=_.call(Be);return At!==_.call(Ie)?!1:At===f?ie(Be,Ie,Te,Ke):At===h?be(Be,Ie,Te,Ke):At===p?me(Be,Ie,Te,Ke):At===w?Se(Be,Ie,Te,Ke):At===b||At===c?a(Be)||a(Ie)?!1:X(Be,Ie,Te,Ke):At===u||At===v||At===y?l(Be.valueOf(),Ie.valueOf()):!1}return Ue}function E(Z,te,ie,me){var X=Z.length;if(te.length!==X)return!1;for(;X-- >0;)if(!ie(Z[X],te[X],X,X,Z,te,me))return!1;return!0}var C=o(E);function $(Z,te){return l(Z.valueOf(),te.valueOf())}function O(Z,te,ie,me){var X=Z.size===te.size;if(!X)return!1;if(!Z.size)return!0;var be={},Se=0;return Z.forEach(function($e,Te){if(X){var Ue=!1,Be=0;te.forEach(function(Ie,Ke){!Ue&&!be[Be]&&(Ue=ie(Te,Ke,Se,Be,Z,te,me)&&ie($e,Ie,Te,Ke,Z,te,me))&&(be[Be]=!0),Be++}),Se++,X=Ue}}),X}var A=o(O),I="_owner",F=Object.prototype.hasOwnProperty;function L(Z,te,ie,me){var X=Object.keys(Z),be=X.length;if(Object.keys(te).length!==be)return!1;for(var Se;be-- >0;){if(Se=X[be],Se===I){var $e=!!Z.$$typeof,Te=!!te.$$typeof;if(($e||Te)&&$e!==Te)return!1}if(!F.call(te,Se)||!ie(Z[Se],te[Se],Se,Se,Z,te,me))return!1}return!0}var B=o(L);function J(Z,te){return Z.source===te.source&&Z.flags===te.flags}function q(Z,te,ie,me){var X=Z.size===te.size;if(!X)return!1;if(!Z.size)return!0;var be={};return Z.forEach(function(Se,$e){if(X){var Te=!1,Ue=0;te.forEach(function(Be,Ie){!Te&&!be[Ue]&&(Te=ie(Se,Be,$e,Ie,Z,te,me))&&(be[Ue]=!0),Ue++}),X=Te}}),X}var z=o(q),ee=Object.freeze({areArraysEqual:E,areDatesEqual:$,areMapsEqual:O,areObjectsEqual:L,areRegExpsEqual:J,areSetsEqual:q,createIsNestedEqual:r}),G=Object.freeze({areArraysEqual:C,areDatesEqual:$,areMapsEqual:A,areObjectsEqual:B,areRegExpsEqual:J,areSetsEqual:z,createIsNestedEqual:r}),Q=S(ee);function W(Z,te){return Q(Z,te,void 0)}var T=S(i(ee,{createIsNestedEqual:function(){return l}}));function H(Z,te){return T(Z,te,void 0)}var U=S(G);function M(Z,te){return U(Z,te,new WeakMap)}var re=S(i(G,{createIsNestedEqual:function(){return l}}));function ue(Z,te){return re(Z,te,new WeakMap)}function de(Z){return S(i(ee,Z(ee)))}function pe(Z){var te=S(i(G,Z(G)));return function(ie,me,X){return X===void 0&&(X=new WeakMap),te(ie,me,X)}}n.circularDeepEqual=M,n.circularShallowEqual=ue,n.createCustomCircularEqual=pe,n.createCustomEqual=de,n.deepEqual=W,n.sameValueZeroEqual=l,n.shallowEqual=H,Object.defineProperty(n,"__esModule",{value:!0})})})(Rx,Rx.exports);var Rw=Rx.exports;const Pw=sw(pB);var Ot={},iW=function(t,n,r){return t===n?!0:t.className===n.className&&r(t.style,n.style)&&t.width===n.width&&t.autoSize===n.autoSize&&t.cols===n.cols&&t.draggableCancel===n.draggableCancel&&t.draggableHandle===n.draggableHandle&&r(t.verticalCompact,n.verticalCompact)&&r(t.compactType,n.compactType)&&r(t.layout,n.layout)&&r(t.margin,n.margin)&&r(t.containerPadding,n.containerPadding)&&t.rowHeight===n.rowHeight&&t.maxRows===n.maxRows&&t.isBounded===n.isBounded&&t.isDraggable===n.isDraggable&&t.isResizable===n.isResizable&&t.allowOverlap===n.allowOverlap&&t.preventCollision===n.preventCollision&&t.useCSSTransforms===n.useCSSTransforms&&t.transformScale===n.transformScale&&t.isDroppable===n.isDroppable&&r(t.resizeHandles,n.resizeHandles)&&r(t.resizeHandle,n.resizeHandle)&&t.onLayoutChange===n.onLayoutChange&&t.onDragStart===n.onDragStart&&t.onDrag===n.onDrag&&t.onDragStop===n.onDragStop&&t.onResizeStart===n.onResizeStart&&t.onResize===n.onResize&&t.onResizeStop===n.onResizeStop&&t.onDrop===n.onDrop&&r(t.droppingItem,n.droppingItem)&&r(t.innerRef,n.innerRef)};Object.defineProperty(Ot,"__esModule",{value:!0});Ot.bottom=Ow;Ot.childrenEqual=cW;Ot.cloneLayout=JD;Ot.cloneLayoutItem=cl;Ot.collides=Fm;Ot.compact=eA;Ot.compactItem=tA;Ot.compactType=SW;Ot.correctBounds=nA;Ot.fastPositionEqual=dW;Ot.fastRGLPropsEqual=void 0;Ot.getAllCollisions=rA;Ot.getFirstCollision=Xa;Ot.getLayoutItem=$w;Ot.getStatics=Tw;Ot.modifyLayout=ZD;Ot.moveElement=yd;Ot.moveElementAwayFromCollision=Ox;Ot.noop=void 0;Ot.perc=hW;Ot.resizeItemInDirection=yW;Ot.setTopLeft=wW;Ot.setTransform=xW;Ot.sortLayoutItems=Nw;Ot.sortLayoutItemsByColRow=lA;Ot.sortLayoutItemsByRowCol=aA;Ot.synchronizeLayoutWithChildren=_W;Ot.validateLayout=cA;Ot.withLayoutItem=lW;var uP=Rw,bd=sW(m);function sW(e){return e&&e.__esModule?e:{default:e}}const aW=process.env.NODE_ENV==="production";function Ow(e){let t=0,n;for(let r=0,o=e.length;r<o;r++)n=e[r].y+e[r].h,n>t&&(t=n);return t}function JD(e){const t=Array(e.length);for(let n=0,r=e.length;n<r;n++)t[n]=cl(e[n]);return t}function ZD(e,t){const n=Array(e.length);for(let r=0,o=e.length;r<o;r++)t.i===e[r].i?n[r]=t:n[r]=e[r];return n}function lW(e,t,n){let r=$w(e,t);return r?(r=n(cl(r)),e=ZD(e,r),[e,r]):[e,null]}function cl(e){return{w:e.w,h:e.h,x:e.x,y:e.y,i:e.i,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}}function cW(e,t){return(0,uP.deepEqual)(bd.default.Children.map(e,n=>n==null?void 0:n.key),bd.default.Children.map(t,n=>n==null?void 0:n.key))&&(0,uP.deepEqual)(bd.default.Children.map(e,n=>n==null?void 0:n.props["data-grid"]),bd.default.Children.map(t,n=>n==null?void 0:n.props["data-grid"]))}const uW=iW;Ot.fastRGLPropsEqual=uW;function dW(e,t){return e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function Fm(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function eA(e,t,n,r){const o=Tw(e),i=Nw(e,t),s=Array(e.length);for(let a=0,l=i.length;a<l;a++){let c=cl(i[a]);c.static||(c=tA(o,c,t,n,i,r),o.push(c)),s[e.indexOf(i[a])]=c,c.moved=!1}return s}const fW={x:"w",y:"h"};function Px(e,t,n,r){const o=fW[r];t[r]+=1;const i=e.map(s=>s.i).indexOf(t.i);for(let s=i+1;s<e.length;s++){const a=e[s];if(!a.static){if(a.y>t.y+t.h)break;Fm(t,a)&&Px(e,a,n+t[o],r)}}t[r]=n}function tA(e,t,n,r,o,i){const s=n==="vertical",a=n==="horizontal";if(s)for(t.y=Math.min(Ow(e),t.y);t.y>0&&!Xa(e,t);)t.y--;else if(a)for(;t.x>0&&!Xa(e,t);)t.x--;let l;for(;(l=Xa(e,t))&&!(n===null&&i);)if(a?Px(o,t,l.x+l.w,"x"):Px(o,t,l.y+l.h,"y"),a&&t.x+t.w>r)for(t.x=r-t.w,t.y++;t.x>0&&!Xa(e,t);)t.x--;return t.y=Math.max(t.y,0),t.x=Math.max(t.x,0),t}function nA(e,t){const n=Tw(e);for(let r=0,o=e.length;r<o;r++){const i=e[r];if(i.x+i.w>t.cols&&(i.x=t.cols-i.w),i.x<0&&(i.x=0,i.w=t.cols),!i.static)n.push(i);else for(;Xa(n,i);)i.y++}return e}function $w(e,t){for(let n=0,r=e.length;n<r;n++)if(e[n].i===t)return e[n]}function Xa(e,t){for(let n=0,r=e.length;n<r;n++)if(Fm(e[n],t))return e[n]}function rA(e,t){return e.filter(n=>Fm(n,t))}function Tw(e){return e.filter(t=>t.static)}function yd(e,t,n,r,o,i,s,a,l){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return e;"Moving element ".concat(t.i," to [").concat(String(n),",").concat(String(r),"] from [").concat(t.x,",").concat(t.y,"]");const c=t.x,u=t.y;typeof n=="number"&&(t.x=n),typeof r=="number"&&(t.y=r),t.moved=!0;let f=Nw(e,s);(s==="vertical"&&typeof r=="number"?u>=r:s==="horizontal"&&typeof n=="number"?c>=n:!1)&&(f=f.reverse());const p=rA(f,t),v=p.length>0;if(v&&l)return JD(e);if(v&&i)return"Collision prevented on ".concat(t.i,", reverting."),t.x=c,t.y=u,t.moved=!1,e;for(let b=0,w=p.length;b<w;b++){const y=p[b];"Resolving collision between ".concat(t.i," at [").concat(t.x,",").concat(t.y,"] and ").concat(y.i," at [").concat(y.x,",").concat(y.y,"]"),!y.moved&&(y.static?e=Ox(e,y,t,o,s):e=Ox(e,t,y,o,s))}return e}function Ox(e,t,n,r,o,i){const s=o==="horizontal",a=o==="vertical",l=t.static;if(r){r=!1;const f={x:s?Math.max(t.x-n.w,0):n.x,y:a?Math.max(t.y-n.h,0):n.y,w:n.w,h:n.h,i:"-1"},h=Xa(e,f),p=h&&h.y+h.h>t.y,v=h&&t.x+t.w>h.x;if(h){if(p&&a)return yd(e,n,void 0,t.y+1,r,l,o);if(p&&o==null)return t.y=n.y,n.y=n.y+n.h,e;if(v&&s)return yd(e,t,n.x,void 0,r,l,o)}else return"Doing reverse collision on ".concat(n.i," up to [").concat(f.x,",").concat(f.y,"]."),yd(e,n,s?f.x:void 0,a?f.y:void 0,r,l,o)}const c=s?n.x+1:void 0,u=a?n.y+1:void 0;return c==null&&u==null?e:yd(e,n,s?n.x+1:void 0,a?n.y+1:void 0,r,l,o)}function hW(e){return e*100+"%"}const oA=(e,t,n,r)=>e+n>r?t:n,iA=(e,t,n)=>e<0?t:n,sA=e=>Math.max(0,e),Dw=e=>Math.max(0,e),Aw=(e,t,n)=>{let{left:r,height:o,width:i}=t;const s=e.top-(o-e.height);return{left:r,width:i,height:iA(s,e.height,o),top:Dw(s)}},kw=(e,t,n)=>{let{top:r,left:o,height:i,width:s}=t;return{top:r,height:i,width:oA(e.left,e.width,s,n),left:sA(o)}},Mw=(e,t,n)=>{let{top:r,height:o,width:i}=t;const s=e.left-(i-e.width);return{height:o,width:s<0?e.width:oA(e.left,e.width,i,n),top:Dw(r),left:sA(s)}},Iw=(e,t,n)=>{let{top:r,left:o,height:i,width:s}=t;return{width:s,left:o,height:iA(r,e.height,i),top:Dw(r)}},pW=function(){return Aw(arguments.length<=0?void 0:arguments[0],kw(...arguments))},gW=function(){return Aw(arguments.length<=0?void 0:arguments[0],Mw(...arguments))},mW=function(){return Iw(arguments.length<=0?void 0:arguments[0],kw(...arguments))},vW=function(){return Iw(arguments.length<=0?void 0:arguments[0],Mw(...arguments))},bW={n:Aw,ne:pW,e:kw,se:mW,s:Iw,sw:vW,w:Mw,nw:gW};function yW(e,t,n,r){const o=bW[e];return o?o(t,{...t,...n},r):n}function xW(e){let{top:t,left:n,width:r,height:o}=e;const i="translate(".concat(n,"px,").concat(t,"px)");return{transform:i,WebkitTransform:i,MozTransform:i,msTransform:i,OTransform:i,width:"".concat(r,"px"),height:"".concat(o,"px"),position:"absolute"}}function wW(e){let{top:t,left:n,width:r,height:o}=e;return{top:"".concat(t,"px"),left:"".concat(n,"px"),width:"".concat(r,"px"),height:"".concat(o,"px"),position:"absolute"}}function Nw(e,t){return t==="horizontal"?lA(e):t==="vertical"?aA(e):e}function aA(e){return e.slice(0).sort(function(t,n){return t.y>n.y||t.y===n.y&&t.x>n.x?1:t.y===n.y&&t.x===n.x?0:-1})}function lA(e){return e.slice(0).sort(function(t,n){return t.x>n.x||t.x===n.x&&t.y>n.y?1:-1})}function _W(e,t,n,r,o){e=e||[];const i=[];bd.default.Children.forEach(t,a=>{if((a==null?void 0:a.key)==null)return;const l=$w(e,String(a.key)),c=a.props["data-grid"];l&&c==null?i.push(cl(l)):c?(aW||cA([c],"ReactGridLayout.children"),i.push(cl({...c,i:a.key}))):i.push(cl({w:1,h:1,x:0,y:Ow(i),i:String(a.key)}))});const s=nA(i,{cols:n});return o?s:eA(s,r,n)}function cA(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Layout";const n=["x","y","w","h"];if(!Array.isArray(e))throw new Error(t+" must be an array!");for(let r=0,o=e.length;r<o;r++){const i=e[r];for(let s=0;s<n.length;s++)if(typeof i[n[s]]!="number")throw new Error("ReactGridLayout: "+t+"["+r+"]."+n[s]+" must be a number!")}}function SW(e){const{verticalCompact:t,compactType:n}=e||{};return t===!1?null:n}const CW=()=>{};Ot.noop=CW;var Di={};Object.defineProperty(Di,"__esModule",{value:!0});Di.calcGridColWidth=jm;Di.calcGridItemPosition=EW;Di.calcGridItemWHPx=$x;Di.calcWH=PW;Di.calcXY=RW;Di.clamp=Qa;function jm(e){const{margin:t,containerPadding:n,containerWidth:r,cols:o}=e;return(r-t[0]*(o-1)-n[0]*2)/o}function $x(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function EW(e,t,n,r,o,i){const{margin:s,containerPadding:a,rowHeight:l}=e,c=jm(e),u={};return i&&i.resizing?(u.width=Math.round(i.resizing.width),u.height=Math.round(i.resizing.height)):(u.width=$x(r,c,s[0]),u.height=$x(o,l,s[1])),i&&i.dragging?(u.top=Math.round(i.dragging.top),u.left=Math.round(i.dragging.left)):i&&i.resizing&&typeof i.resizing.top=="number"&&typeof i.resizing.left=="number"?(u.top=Math.round(i.resizing.top),u.left=Math.round(i.resizing.left)):(u.top=Math.round((l+s[1])*n+a[1]),u.left=Math.round((c+s[0])*t+a[0])),u}function RW(e,t,n,r,o){const{margin:i,cols:s,rowHeight:a,maxRows:l}=e,c=jm(e);let u=Math.round((n-i[0])/(c+i[0])),f=Math.round((t-i[1])/(a+i[1]));return u=Qa(u,0,s-r),f=Qa(f,0,l-o),{x:u,y:f}}function PW(e,t,n,r,o,i){const{margin:s,maxRows:a,cols:l,rowHeight:c}=e,u=jm(e);let f=Math.round((t+s[0])/(u+s[0])),h=Math.round((n+s[1])/(c+s[1])),p=Qa(f,0,l-r),v=Qa(h,0,a-o);return["sw","w","nw"].indexOf(i)!==-1&&(p=Qa(f,0,l)),["nw","n","ne"].indexOf(i)!==-1&&(v=Qa(h,0,a)),{w:p,h:v}}function Qa(e,t,n){return Math.max(Math.min(e,n),t)}var zm={},Tx={exports:{}},d0,dP;function Lw(){if(dP)return d0;dP=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return d0=e,d0}var f0,fP;function OW(){if(fP)return f0;fP=1;var e=Lw();function t(){}function n(){}return n.resetWarningCache=t,f0=function(){function r(s,a,l,c,u,f){if(f!==e){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}r.isRequired=r;function o(){return r}var i={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return i.PropTypes=i,i},f0}var gp={exports:{}},qt={};/** @license React v16.13.1
|
|
88
|
+
}`;var xt=kR(function(){return zt(V,Ye+"return "+Pe).apply(n,Y)});if(xt.source=Pe,Wb(xt))throw xt;return xt}function vz(d){return Gt(d).toLowerCase()}function bz(d){return Gt(d).toUpperCase()}function yz(d,g,x){if(d=Gt(d),d&&(x||g===n))return VC(d);if(!d||!(g=Ur(g)))return d;var P=zo(d),k=zo(g),V=HC(P,k),Y=WC(P,k)+1;return As(P,V,Y).join("")}function xz(d,g,x){if(d=Gt(d),d&&(x||g===n))return d.slice(0,GC(d)+1);if(!d||!(g=Ur(g)))return d;var P=zo(d),k=WC(P,zo(g))+1;return As(P,0,k).join("")}function wz(d,g,x){if(d=Gt(d),d&&(x||g===n))return d.replace(Vn,"");if(!d||!(g=Ur(g)))return d;var P=zo(d),k=HC(P,zo(g));return As(P,k).join("")}function _z(d,g){var x=F,P=L;if(wn(g)){var k="separator"in g?g.separator:k;x="length"in g?pt(g.length):x,P="omission"in g?Ur(g.omission):P}d=Gt(d);var V=d.length;if(Wl(d)){var Y=zo(d);V=Y.length}if(x>=V)return d;var ne=x-Ul(P);if(ne<1)return P;var le=Y?As(Y,0,ne).join(""):d.slice(0,ne);if(k===n)return le+P;if(Y&&(ne+=le.length-ne),Ub(k)){if(d.slice(ne).search(k)){var we,_e=le;for(k.global||(k=ab(k.source,Gt(Ge.exec(k))+"g")),k.lastIndex=0;we=k.exec(_e);)var Pe=we.index;le=le.slice(0,Pe===n?ne:Pe)}}else if(d.indexOf(Ur(k),ne)!=ne){var je=le.lastIndexOf(k);je>-1&&(le=le.slice(0,je))}return le+P}function Sz(d){return d=Gt(d),d&&$n.test(d)?d.replace(Qt,J7):d}var Cz=Jl(function(d,g,x){return d+(x?" ":"")+g.toUpperCase()}),Yb=ME("toUpperCase");function AR(d,g,x){return d=Gt(d),g=x?n:g,g===n?q7(d)?t6(d):F7(d):d.match(g)||[]}var kR=Ct(function(d,g){try{return Hr(d,n,g)}catch(x){return Wb(x)?x:new ct(x)}}),Ez=Hi(function(d,g){return yo(g,function(x){x=ci(x),Bi(d,x,Vb(d[x],d))}),d});function Rz(d){var g=d==null?0:d.length,x=Je();return d=g?yn(d,function(P){if(typeof P[1]!="function")throw new xo(s);return[x(P[0]),P[1]]}):[],Ct(function(P){for(var k=-1;++k<g;){var V=d[k];if(Hr(V[0],this,P))return Hr(V[1],this,P)}})}function Pz(d){return J6(_o(d,f))}function Kb(d){return function(){return d}}function Oz(d,g){return d==null||d!==d?g:d}var $z=NE(),Tz=NE(!0);function $r(d){return d}function Xb(d){return fE(typeof d=="function"?d:_o(d,f))}function Dz(d){return pE(_o(d,f))}function Az(d,g){return gE(d,_o(g,f))}var kz=Ct(function(d,g){return function(x){return Fu(x,d,g)}}),Mz=Ct(function(d,g){return function(x){return Fu(d,x,g)}});function Qb(d,g,x){var P=Wn(g),k=Wh(g,P);x==null&&!(wn(g)&&(k.length||!P.length))&&(x=g,g=d,d=this,k=Wh(g,Wn(g)));var V=!(wn(x)&&"chain"in x)||!!x.chain,Y=Ui(d);return yo(k,function(ne){var le=g[ne];d[ne]=le,Y&&(d.prototype[ne]=function(){var we=this.__chain__;if(V||we){var _e=d(this.__wrapped__),Pe=_e.__actions__=Rr(this.__actions__);return Pe.push({func:le,args:arguments,thisArg:d}),_e.__chain__=we,_e}return le.apply(d,Rs([this.value()],arguments))})}),d}function Iz(){return qn._===this&&(qn._=a6),this}function Jb(){}function Nz(d){return d=pt(d),Ct(function(g){return mE(g,d)})}var Lz=$b(yn),Fz=$b(LC),jz=$b(eb);function MR(d){return Nb(d)?tb(ci(d)):g9(d)}function zz(d){return function(g){return d==null?n:Oa(d,g)}}var Bz=FE(),Vz=FE(!0);function Zb(){return[]}function e0(){return!1}function Hz(){return{}}function Wz(){return""}function Uz(){return!0}function Gz(d,g){if(d=pt(d),d<1||d>Q)return[];var x=H,P=or(d,H);g=Je(g),d-=H;for(var k=ob(P,g);++x<d;)g(x);return k}function qz(d){return ut(d)?yn(d,ci):Gr(d)?[d]:Rr(eR(Gt(d)))}function Yz(d){var g=++i6;return Gt(d)+g}var Kz=Xh(function(d,g){return d+g},0),Xz=Tb("ceil"),Qz=Xh(function(d,g){return d/g},1),Jz=Tb("floor");function Zz(d){return d&&d.length?Hh(d,$r,gb):n}function eB(d,g){return d&&d.length?Hh(d,Je(g,2),gb):n}function tB(d){return zC(d,$r)}function nB(d,g){return zC(d,Je(g,2))}function rB(d){return d&&d.length?Hh(d,$r,yb):n}function oB(d,g){return d&&d.length?Hh(d,Je(g,2),yb):n}var iB=Xh(function(d,g){return d*g},1),sB=Tb("round"),aB=Xh(function(d,g){return d-g},0);function lB(d){return d&&d.length?rb(d,$r):0}function cB(d,g){return d&&d.length?rb(d,Je(g,2)):0}return j.after=D8,j.ary=dR,j.assign=bj,j.assignIn=ER,j.assignInWith=cp,j.assignWith=yj,j.at=xj,j.before=fR,j.bind=Vb,j.bindAll=Ez,j.bindKey=hR,j.castArray=H8,j.chain=lR,j.chunk=J9,j.compact=Z9,j.concat=e4,j.cond=Rz,j.conforms=Pz,j.constant=Kb,j.countBy=l8,j.create=wj,j.curry=pR,j.curryRight=gR,j.debounce=mR,j.defaults=_j,j.defaultsDeep=Sj,j.defer=A8,j.delay=k8,j.difference=t4,j.differenceBy=n4,j.differenceWith=r4,j.drop=o4,j.dropRight=i4,j.dropRightWhile=s4,j.dropWhile=a4,j.fill=l4,j.filter=u8,j.flatMap=h8,j.flatMapDeep=p8,j.flatMapDepth=g8,j.flatten=oR,j.flattenDeep=c4,j.flattenDepth=u4,j.flip=M8,j.flow=$z,j.flowRight=Tz,j.fromPairs=d4,j.functions=Tj,j.functionsIn=Dj,j.groupBy=m8,j.initial=h4,j.intersection=p4,j.intersectionBy=g4,j.intersectionWith=m4,j.invert=kj,j.invertBy=Mj,j.invokeMap=b8,j.iteratee=Xb,j.keyBy=y8,j.keys=Wn,j.keysIn=Or,j.map=rp,j.mapKeys=Nj,j.mapValues=Lj,j.matches=Dz,j.matchesProperty=Az,j.memoize=ip,j.merge=Fj,j.mergeWith=RR,j.method=kz,j.methodOf=Mz,j.mixin=Qb,j.negate=sp,j.nthArg=Nz,j.omit=jj,j.omitBy=zj,j.once=I8,j.orderBy=x8,j.over=Lz,j.overArgs=N8,j.overEvery=Fz,j.overSome=jz,j.partial=Hb,j.partialRight=vR,j.partition=w8,j.pick=Bj,j.pickBy=PR,j.property=MR,j.propertyOf=zz,j.pull=x4,j.pullAll=sR,j.pullAllBy=w4,j.pullAllWith=_4,j.pullAt=S4,j.range=Bz,j.rangeRight=Vz,j.rearg=L8,j.reject=C8,j.remove=C4,j.rest=F8,j.reverse=zb,j.sampleSize=R8,j.set=Hj,j.setWith=Wj,j.shuffle=P8,j.slice=E4,j.sortBy=T8,j.sortedUniq=A4,j.sortedUniqBy=k4,j.split=hz,j.spread=j8,j.tail=M4,j.take=I4,j.takeRight=N4,j.takeRightWhile=L4,j.takeWhile=F4,j.tap=Z4,j.throttle=z8,j.thru=np,j.toArray=_R,j.toPairs=OR,j.toPairsIn=$R,j.toPath=qz,j.toPlainObject=CR,j.transform=Uj,j.unary=B8,j.union=j4,j.unionBy=z4,j.unionWith=B4,j.uniq=V4,j.uniqBy=H4,j.uniqWith=W4,j.unset=Gj,j.unzip=Bb,j.unzipWith=aR,j.update=qj,j.updateWith=Yj,j.values=tc,j.valuesIn=Kj,j.without=U4,j.words=AR,j.wrap=V8,j.xor=G4,j.xorBy=q4,j.xorWith=Y4,j.zip=K4,j.zipObject=X4,j.zipObjectDeep=Q4,j.zipWith=J4,j.entries=OR,j.entriesIn=$R,j.extend=ER,j.extendWith=cp,Qb(j,j),j.add=Kz,j.attempt=kR,j.camelCase=Zj,j.capitalize=TR,j.ceil=Xz,j.clamp=Xj,j.clone=W8,j.cloneDeep=G8,j.cloneDeepWith=q8,j.cloneWith=U8,j.conformsTo=Y8,j.deburr=DR,j.defaultTo=Oz,j.divide=Qz,j.endsWith=ez,j.eq=Vo,j.escape=tz,j.escapeRegExp=nz,j.every=c8,j.find=d8,j.findIndex=nR,j.findKey=Cj,j.findLast=f8,j.findLastIndex=rR,j.findLastKey=Ej,j.floor=Jz,j.forEach=cR,j.forEachRight=uR,j.forIn=Rj,j.forInRight=Pj,j.forOwn=Oj,j.forOwnRight=$j,j.get=Gb,j.gt=K8,j.gte=X8,j.has=Aj,j.hasIn=qb,j.head=iR,j.identity=$r,j.includes=v8,j.indexOf=f4,j.inRange=Qj,j.invoke=Ij,j.isArguments=Da,j.isArray=ut,j.isArrayBuffer=Q8,j.isArrayLike=Pr,j.isArrayLikeObject=Tn,j.isBoolean=J8,j.isBuffer=ks,j.isDate=Z8,j.isElement=ej,j.isEmpty=tj,j.isEqual=nj,j.isEqualWith=rj,j.isError=Wb,j.isFinite=oj,j.isFunction=Ui,j.isInteger=bR,j.isLength=ap,j.isMap=yR,j.isMatch=ij,j.isMatchWith=sj,j.isNaN=aj,j.isNative=lj,j.isNil=uj,j.isNull=cj,j.isNumber=xR,j.isObject=wn,j.isObjectLike=Cn,j.isPlainObject=Wu,j.isRegExp=Ub,j.isSafeInteger=dj,j.isSet=wR,j.isString=lp,j.isSymbol=Gr,j.isTypedArray=ec,j.isUndefined=fj,j.isWeakMap=hj,j.isWeakSet=pj,j.join=v4,j.kebabCase=rz,j.last=Co,j.lastIndexOf=b4,j.lowerCase=oz,j.lowerFirst=iz,j.lt=gj,j.lte=mj,j.max=Zz,j.maxBy=eB,j.mean=tB,j.meanBy=nB,j.min=rB,j.minBy=oB,j.stubArray=Zb,j.stubFalse=e0,j.stubObject=Hz,j.stubString=Wz,j.stubTrue=Uz,j.multiply=iB,j.nth=y4,j.noConflict=Iz,j.noop=Jb,j.now=op,j.pad=sz,j.padEnd=az,j.padStart=lz,j.parseInt=cz,j.random=Jj,j.reduce=_8,j.reduceRight=S8,j.repeat=uz,j.replace=dz,j.result=Vj,j.round=sB,j.runInContext=se,j.sample=E8,j.size=O8,j.snakeCase=fz,j.some=$8,j.sortedIndex=R4,j.sortedIndexBy=P4,j.sortedIndexOf=O4,j.sortedLastIndex=$4,j.sortedLastIndexBy=T4,j.sortedLastIndexOf=D4,j.startCase=pz,j.startsWith=gz,j.subtract=aB,j.sum=lB,j.sumBy=cB,j.template=mz,j.times=Gz,j.toFinite=Gi,j.toInteger=pt,j.toLength=SR,j.toLower=vz,j.toNumber=Eo,j.toSafeInteger=vj,j.toString=Gt,j.toUpper=bz,j.trim=yz,j.trimEnd=xz,j.trimStart=wz,j.truncate=_z,j.unescape=Sz,j.uniqueId=Yz,j.upperCase=Cz,j.upperFirst=Yb,j.each=cR,j.eachRight=uR,j.first=iR,Qb(j,function(){var d={};return ai(j,function(g,x){Jt.call(j.prototype,x)||(d[x]=g)}),d}(),{chain:!1}),j.VERSION=r,yo(["bind","bindKey","curry","curryRight","partial","partialRight"],function(d){j[d].placeholder=j}),yo(["drop","take"],function(d,g){Mt.prototype[d]=function(x){x=x===n?1:Ln(pt(x),0);var P=this.__filtered__&&!g?new Mt(this):this.clone();return P.__filtered__?P.__takeCount__=or(x,P.__takeCount__):P.__views__.push({size:or(x,H),type:d+(P.__dir__<0?"Right":"")}),P},Mt.prototype[d+"Right"]=function(x){return this.reverse()[d](x).reverse()}}),yo(["filter","map","takeWhile"],function(d,g){var x=g+1,P=x==q||x==ee;Mt.prototype[d]=function(k){var V=this.clone();return V.__iteratees__.push({iteratee:Je(k,3),type:x}),V.__filtered__=V.__filtered__||P,V}}),yo(["head","last"],function(d,g){var x="take"+(g?"Right":"");Mt.prototype[d]=function(){return this[x](1).value()[0]}}),yo(["initial","tail"],function(d,g){var x="drop"+(g?"":"Right");Mt.prototype[d]=function(){return this.__filtered__?new Mt(this):this[x](1)}}),Mt.prototype.compact=function(){return this.filter($r)},Mt.prototype.find=function(d){return this.filter(d).head()},Mt.prototype.findLast=function(d){return this.reverse().find(d)},Mt.prototype.invokeMap=Ct(function(d,g){return typeof d=="function"?new Mt(this):this.map(function(x){return Fu(x,d,g)})}),Mt.prototype.reject=function(d){return this.filter(sp(Je(d)))},Mt.prototype.slice=function(d,g){d=pt(d);var x=this;return x.__filtered__&&(d>0||g<0)?new Mt(x):(d<0?x=x.takeRight(-d):d&&(x=x.drop(d)),g!==n&&(g=pt(g),x=g<0?x.dropRight(-g):x.take(g-d)),x)},Mt.prototype.takeRightWhile=function(d){return this.reverse().takeWhile(d).reverse()},Mt.prototype.toArray=function(){return this.take(H)},ai(Mt.prototype,function(d,g){var x=/^(?:filter|find|map|reject)|While$/.test(g),P=/^(?:head|last)$/.test(g),k=j[P?"take"+(g=="last"?"Right":""):g],V=P||/^find/.test(g);k&&(j.prototype[g]=function(){var Y=this.__wrapped__,ne=P?[1]:arguments,le=Y instanceof Mt,we=ne[0],_e=le||ut(Y),Pe=function($t){var It=k.apply(j,Rs([$t],ne));return P&&je?It[0]:It};_e&&x&&typeof we=="function"&&we.length!=1&&(le=_e=!1);var je=this.__chain__,Ye=!!this.__actions__.length,et=V&&!je,xt=le&&!Ye;if(!V&&_e){Y=xt?Y:new Mt(this);var tt=d.apply(Y,ne);return tt.__actions__.push({func:np,args:[Pe],thisArg:n}),new wo(tt,je)}return et&&xt?d.apply(this,ne):(tt=this.thru(Pe),et?P?tt.value()[0]:tt.value():tt)})}),yo(["pop","push","shift","sort","splice","unshift"],function(d){var g=Oh[d],x=/^(?:push|sort|unshift)$/.test(d)?"tap":"thru",P=/^(?:pop|shift)$/.test(d);j.prototype[d]=function(){var k=arguments;if(P&&!this.__chain__){var V=this.value();return g.apply(ut(V)?V:[],k)}return this[x](function(Y){return g.apply(ut(Y)?Y:[],k)})}}),ai(Mt.prototype,function(d,g){var x=j[g];if(x){var P=x.name+"";Jt.call(Kl,P)||(Kl[P]=[]),Kl[P].push({name:g,func:x})}}),Kl[Kh(n,y).name]=[{name:"wrapper",func:n}],Mt.prototype.clone=S6,Mt.prototype.reverse=C6,Mt.prototype.value=E6,j.prototype.at=e8,j.prototype.chain=t8,j.prototype.commit=n8,j.prototype.next=r8,j.prototype.plant=i8,j.prototype.reverse=s8,j.prototype.toJSON=j.prototype.valueOf=j.prototype.value=a8,j.prototype.first=j.prototype.head,Du&&(j.prototype[Du]=o8),j},Gl=n6();Sa?((Sa.exports=Gl)._=Gl,Xv._=Gl):qn._=Gl}).call(Gs)})(jg,jg.exports);var xc=jg.exports;const ll=Pl(xc);function eP({id:e,layouts:t,initialHeight:n,y:r,x:o,w:i,minH:s}){const a={i:e,x:o??0,y:r??1/0,w:i||20,h:n||35,minW:6,minH:s||10};return t||(t={}),fw.forEach(l=>{t!=null&&t[l]||(t={...t,[l]:[]});const c=t[l].reduce((u,f)=>Math.max(u,f.y+f.h),0);a.y=a.y===0?0:c,t[l].push(a)}),t}function tP(e,t){t&&fw.forEach(n=>{t!=null&&t[n]&&(t[n]=t[n].filter(r=>r.i!==e))})}const Ee=cD()(mD((e,t)=>({isSessionExpired:!1,currentBreakpoint:"lg",dashboard:{id:"",style:Lg},showContext:!1,selectedSheetId:null,selectedCardId:null,selectedFrameId:null,selectedCard:null,showFilters:!1,isDashboardEditing:!1,isVisualEditing:!1,showDashboardJSON:!1,filteringCards:[],actions:{setInitStore:()=>{e(n=>{n.isSessionExpired=!1,n.currentBreakpoint="lg",n.dashboard={id:"",style:Lg},n.showContext=!1,n.selectedSheetId=null,n.selectedCardId=null,n.selectedFrameId=null,n.selectedCard=null,n.showFilters=!1,n.isDashboardEditing=!1,n.isVisualEditing=!1,n.showDashboardJSON=!1,n.filteringCards=[],n.selectedLensId=void 0})},setLenses:n=>{e(r=>{r.lenses=n})},setSelectedLensId:n=>{e(r=>{r.selectedLensId=n})},deleteSheet:n=>{e(r=>{var i,s,a,l;const o=(i=r.dashboard.sheets)==null?void 0:i.findIndex(c=>c.id===n);o!==void 0&&o>-1&&((s=r.dashboard.sheets)==null||s.splice(o,1),r.selectedSheetId=(l=(a=r.dashboard.sheets)==null?void 0:a[0])==null?void 0:l.id)})},addSheet:n=>{e(r=>{r.dashboard.sheets||(r.dashboard.sheets=[]);const o=r.dashboard.filters;let i={};o==null||o.forEach(a=>{fw.forEach(l=>{i!=null&&i[l]||(i={...i,[l]:[]});const c={i:a.id,x:0,y:0,w:10,h:8};i[l].push(c)})});const s={...n,layouts:i};r.dashboard.sheets.push(s)})},setGlobalStyle:n=>{e(r=>{r.dashboard.globalStyle=n})},setAIScopeTables:n=>{e(r=>{r.dashboard.aiScopeTables=n})},setIsSessionExpired:n=>{e(()=>({isSessionExpired:n}))},setCardPython:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===o.selectedSheetId);i&&xc.forEach(i.frames,l=>{var u;const c=(u=l.cards)==null?void 0:u.find(f=>f.id===n);c&&(c.python=r)})})},addBaseQuery:n=>{e(r=>{var o;r.dashboard.baseQueries||(r.dashboard.baseQueries=[]),(o=r.dashboard.baseQueries)==null||o.push(n)})},removeBaseQuery:n=>{e(r=>{var i,s;const o=(i=r.dashboard.baseQueries)==null?void 0:i.findIndex(a=>a.id===n);o!=null&&o>-1&&((s=r.dashboard.baseQueries)==null||s.splice(o,1))})},setBaseQueries:n=>{e(r=>{r.dashboard.baseQueries=n})},setCurrentBreakpoint:n=>{e(()=>({currentBreakpoint:n}))},setFilteringCards:n=>{e(()=>({filteringCards:n}))},addFilteringCard:n=>{e(r=>{var o;(o=r.filteringCards)==null||o.push(n)})},removeFilteringCard:n=>{e(r=>{var i,s;const o=(i=r.filteringCards)==null?void 0:i.findIndex(a=>a.id===n.id);o!==void 0&&o>-1&&((s=r.filteringCards)==null||s.splice(o,1))})},setCustomCards:n=>{e(r=>{r.dashboard.customCards=n})},setAuthToken:n=>{e(()=>({authToken:n}))},setThemeStyle:n=>{e(()=>({themeStyle:n}))},setDashboard:n=>e({dashboard:n}),setDashboardWithFilterValues:(n,r)=>{e(o=>{o.dashboard=n,o.filterValues=r})},setDashboardTheme:n=>{e(r=>{r.theme=n})},setSheets:n=>{e(r=>{r.dashboard&&(r.dashboard.sheets=n)})},setSheetTitle:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.title=r)})},setCardTitle:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&xc.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(h=>h.id===r);u&&(u.title=o)})})},setCardInfo:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===o.selectedSheetId);i&&xc.forEach(i.frames,l=>{var u;const c=(u=l.cards)==null?void 0:u.find(f=>f.id===n);c&&(c.info=r)})})},setCardDescription:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&xc.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(h=>h.id===r);u&&(u.description=o)})})},setCardSql:(n,r,o)=>{e(i=>{var a,l,c,u;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n);if(s){const f=(c=s.cards)==null?void 0:c.find(h=>h.id===r);f&&(f.sql=o,(u=i.onUpdateCard)==null||u.call(i,f,n))}})},setFrameCardData:(n,r,o)=>{e(i=>{var a,l;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(c=>c.id===n);s&&xc.forEach(s.frames,c=>{var f;const u=(f=c.cards)==null?void 0:f.find(h=>h.id===r);u&&(u.data=o)})})},setSheetLayout:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.layout=r)})},setSheetLayouts:(n,r)=>{e(o=>{var s,a;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);i&&(i.layouts=r)})},setShowContext:n=>{e(()=>({showContext:n}))},setShowFilters:n=>{e(()=>({showFilters:n}))},setFilterValues:n=>{e(()=>({filterValues:n}))},addOrUpdateFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.findIndex(i=>i.filterId===n.filterId);o>-1?r.filterValues.splice(o,1,n):r.filterValues.push(n)}else r.filterValues=[n]})},addOrUpdateFilterValues:n=>{e(r=>{r.filterValues?n.forEach(o=>{var s,a,l;const i=(s=r==null?void 0:r.filterValues)==null?void 0:s.findIndex(c=>c.filterId===o.filterId);i!==void 0&&i>-1?(a=r.filterValues)==null||a.splice(i,1,o):(l=r.filterValues)==null||l.push(o)}):r.filterValues=n})},removeFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.filter(i=>i.filterId!==n&&!i.filterId.startsWith(n));r.filterValues=o}})},replaceFilterValue:n=>{e(r=>{if(r.filterValues){const o=r.filterValues.findIndex(i=>i.filterId===n.filterId);o>-1&&r.filterValues.splice(o,1,n)}})},addFilter:n=>{e(r=>{var i,s;r.dashboard.filters?(i=r.dashboard.filters)==null||i.push(n):r.dashboard.filters=[n];const o=(s=r.dashboard.sheets)==null?void 0:s.find(a=>a.id===r.selectedSheetId);eP({id:n.id,layouts:o==null?void 0:o.layouts,y:0,initialHeight:8,minH:7,w:10})})},removeFilter:n=>{e(r=>{var o,i,s;if(r.dashboard.filters){const a=(o=r.dashboard.filters)==null?void 0:o.findIndex(l=>l.id===n);if(a>-1){(i=r.dashboard.filters)==null||i.splice(a,1);const l=(s=r.dashboard.sheets)==null?void 0:s.find(c=>c.id===r.selectedSheetId);tP(n,l==null?void 0:l.layouts)}}})},updateFrameCard:(n,r,o)=>{e(i=>{var l,c,u,f,h;const s=(c=(l=i.dashboard)==null?void 0:l.sheets)==null?void 0:c.find(p=>p.id===n);if(!s)return;const a=(u=s==null?void 0:s.frames)==null?void 0:u.find(p=>p.id===r);if(a){const p=(f=a.cards)==null?void 0:f.findIndex(v=>v.id===o.id);p>-1&&((h=a.cards)==null||h.splice(p,1,o))}})},updateFilter:n=>{e(r=>{var o,i;if(r.dashboard.filters){const s=(o=r.dashboard.filters)==null?void 0:o.findIndex(a=>a.id===n.id);s>-1&&((i=r.dashboard.filters)==null||i.splice(s,1,n))}})},setIsDashboardEditing:n=>{e(()=>({isDashboardEditing:n}))},setShowDashboardJSON:n=>{e(()=>({showDashboardJSON:n}))},setIsVisualEditing:n=>{e(()=>({isVisualEditing:n}))},addFrame:(n,r,o)=>{e(i=>{var a,l,c,u;const s=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(f=>f.id===n);if(s){s.frames||(s.frames=[]),(c=s.frames)==null||c.push(r);let f=1/0;const h=0;o==="start"&&(f=0),eP({id:r.id,layouts:s.layouts,minH:10,x:h,y:f}),(u=i.onAddFrame)==null||u.call(i,r,n)}})},removeFrame:(n,r)=>{e(o=>{var s,a,l,c,u;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(f=>f.id===n);if(i){const f=(l=i.frames)==null?void 0:l.findIndex(h=>h.id===r);console.log(f),typeof f=="number"&&f>-1&&((c=i.frames)==null||c.splice(f,1),(u=i.layout)==null||u.splice(f,1),tP(r,i.layouts))}})},updateFrame:(n,r)=>{e(o=>{var a,l,c,u,f;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(h=>h.id===n),s=(c=i==null?void 0:i.frames)==null?void 0:c.findIndex(h=>h.id===r.id);i&&((u=i.frames)==null||u.splice(s,1,r)),(f=o.onAcceptChanges)==null||f.call(o,r,o.dashboard)})},updateCard:(n,r)=>{e(o=>{var a,l,c,u,f;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(h=>h.id===n),s=(c=i==null?void 0:i.cards)==null?void 0:c.findIndex(h=>h.id===r.id);i&&((u=i.cards)==null||u.splice(s,1,r),(f=o.onUpdateCard)==null||f.call(o,r,n))})},removeCard:(n,r)=>{e(o=>{var a,l,c,u,f,h;const i=(l=(a=o.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(p=>p.id===n),s=(c=i==null?void 0:i.cards)==null?void 0:c.findIndex(p=>p.id===r.id);i&&((u=i.cards)==null||u.splice(s,1),(f=i.layout)==null||f.splice(s,1),(h=o.onRemoveCard)==null||h.call(o,r,n))})},setStyle:n=>{e(r=>{r.dashboard&&(r.dashboard.style=n)})},setSelectedCardId:(n,r)=>{e(o=>{var s,a,l;const i=(a=(s=o.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(c=>c.id===n);i&&(((l=i.cards)==null?void 0:l.find(u=>u.id===r))?o.selectedCardId=r:o.selectedCardId=null)})},setSelectedFrameId:n=>{e(r=>{var i,s;((s=(i=r.dashboard)==null?void 0:i.sheets)==null?void 0:s.find(a=>a.id===r.selectedSheetId))&&(r.selectedFrameId=n)})},setSelectedSheetId:n=>{e(r=>{var i,s;((s=(i=r.dashboard)==null?void 0:i.sheets)==null?void 0:s.find(a=>a.id===n))&&(r.selectedSheetId=n)})},setOnSaveFunction:n=>{e(()=>({onSaveFunction:n}))},setOnAddCard:n=>{e(()=>({onAddCard:n}))},setOnAcceptChanges:n=>{e(()=>({onAcceptChanges:n}))},setOnUpdateCard:n=>{e(()=>({onUpdateCard:n}))},setOnRemoveCard:n=>{e(()=>({onRemoveCard:n}))},setOnEvent:n=>{e(()=>({onEvent:n}))},getDashboard:()=>t().dashboard,getSelectedSheet:()=>{var n,r;return(r=(n=t().dashboard)==null?void 0:n.sheets)==null?void 0:r.find(o=>o.id===t().selectedSheetId)},getCardFrame:n=>{var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a){for(let l=0;l<a.length;l++)if((i=a[l].cards)==null?void 0:i.find(u=>u.id===n))return a[l]}}},getSelectedFrame:()=>{var r,o,i;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(s=>s.id===t().selectedSheetId);return(i=n==null?void 0:n.frames)==null?void 0:i.find(s=>s.id===t().selectedFrameId)},getCard:n=>{var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a)for(let l=0;l<a.length;l++){const c=(i=a[l].cards)==null?void 0:i.find(u=>u.id===n);if(c)return c}}},getSelectedSheetLayout:()=>{var r,o;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(i=>i.id===t().selectedSheetId);return n==null?void 0:n.layout},getSelectedSheetLayouts:()=>{var r,o;const n=(o=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:o.find(i=>i.id===t().selectedSheetId);return n==null?void 0:n.layouts},getStyle:()=>{var n;return(n=t().dashboard)==null?void 0:n.style},getCardSheet(n){var o,i;const r=(o=t().dashboard)==null?void 0:o.sheets;if(r)for(let s=0;s<r.length;s++){const a=r[s].frames;if(a){for(let l=0;l<a.length;l++)if((i=a[l].cards)==null?void 0:i.find(u=>u.id===n))return r[s]}}},handleDataPointClickAction:(n,r)=>{LV({card:n,dataPoint:r,set:e,get:t})}}}))),ur=()=>Ee(e=>e.actions),FV={theme:"system",setTheme:()=>null},SD=m.createContext(FV);function jV({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const[o,i]=m.useState(()=>localStorage.getItem(n)||t);m.useEffect(()=>{const a=window.document.documentElement;if(a.classList.remove("light","dark"),o==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";a.classList.add(l);return}a.classList.add(o)},[o]);const s={theme:o,setTheme:a=>{localStorage.setItem(n,a),i(a)}};return R.jsx(SD.Provider,{...r,value:s,children:e})}const CD=()=>{const e=m.useContext(SD);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e};var Uf=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},nu=typeof window>"u"||"Deno"in window;function To(){}function zV(e,t){return typeof e=="function"?e(t):e}function ux(e){return typeof e=="number"&&e>=0&&e!==1/0}function ED(e,t){return Math.max(e+(t||0)-Date.now(),0)}function nP(e,t){const{type:n="all",exact:r,fetchStatus:o,predicate:i,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==gw(s,t.options))return!1}else if(!Yd(t.queryKey,s))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||typeof o<"u"&&o!==t.state.fetchStatus||i&&!i(t))}function rP(e,t){const{exact:n,status:r,predicate:o,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(qd(t.options.mutationKey)!==qd(i))return!1}else if(!Yd(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||o&&!o(t))}function gw(e,t){return((t==null?void 0:t.queryKeyHashFn)||qd)(e)}function qd(e){return JSON.stringify(e,(t,n)=>fx(n)?Object.keys(n).sort().reduce((r,o)=>(r[o]=n[o],r),{}):n)}function Yd(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!Yd(e[n],t[n])):!1}function RD(e,t){if(e===t)return e;const n=oP(e)&&oP(t);if(n||fx(e)&&fx(t)){const r=n?e:Object.keys(e),o=r.length,i=n?t:Object.keys(t),s=i.length,a=n?[]:{};let l=0;for(let c=0;c<s;c++){const u=n?c:i[c];!n&&e[u]===void 0&&t[u]===void 0&&r.includes(u)?(a[u]=void 0,l++):(a[u]=RD(e[u],t[u]),a[u]===e[u]&&e[u]!==void 0&&l++)}return o===s&&l===o?e:a}return t}function dx(e,t){if(e&&!t||t&&!e)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function oP(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function fx(e){if(!iP(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const n=t.prototype;return!(!iP(n)||!n.hasOwnProperty("isPrototypeOf"))}function iP(e){return Object.prototype.toString.call(e)==="[object Object]"}function BV(e){return new Promise(t=>{setTimeout(t,e)})}function hx(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?RD(e,t):t}function VV(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function HV(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var el,qs,Lc,UT,WV=(UT=class extends Uf{constructor(){super();Xe(this,el,void 0);Xe(this,qs,void 0);Xe(this,Lc,void 0);Ve(this,Lc,t=>{if(!nu&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){ae(this,qs)||this.setEventListener(ae(this,Lc))}onUnsubscribe(){var t;this.hasListeners()||((t=ae(this,qs))==null||t.call(this),Ve(this,qs,void 0))}setEventListener(t){var n;Ve(this,Lc,t),(n=ae(this,qs))==null||n.call(this),Ve(this,qs,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){ae(this,el)!==t&&(Ve(this,el,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof ae(this,el)=="boolean"?ae(this,el):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},el=new WeakMap,qs=new WeakMap,Lc=new WeakMap,UT),zg=new WV,Fc,Ys,jc,GT,UV=(GT=class extends Uf{constructor(){super();Xe(this,Fc,!0);Xe(this,Ys,void 0);Xe(this,jc,void 0);Ve(this,jc,t=>{if(!nu&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){ae(this,Ys)||this.setEventListener(ae(this,jc))}onUnsubscribe(){var t;this.hasListeners()||((t=ae(this,Ys))==null||t.call(this),Ve(this,Ys,void 0))}setEventListener(t){var n;Ve(this,jc,t),(n=ae(this,Ys))==null||n.call(this),Ve(this,Ys,t(this.setOnline.bind(this)))}setOnline(t){ae(this,Fc)!==t&&(Ve(this,Fc,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return ae(this,Fc)}},Fc=new WeakMap,Ys=new WeakMap,jc=new WeakMap,GT),Bg=new UV;function GV(e){return Math.min(1e3*2**e,3e4)}function Tm(e){return(e??"online")==="online"?Bg.isOnline():!0}var PD=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function c0(e){return e instanceof PD}function OD(e){let t=!1,n=0,r=!1,o,i,s;const a=new Promise((w,y)=>{i=w,s=y}),l=w=>{var y;r||(p(new PD(w)),(y=e.abort)==null||y.call(e))},c=()=>{t=!0},u=()=>{t=!1},f=()=>!zg.isFocused()||e.networkMode!=="always"&&!Bg.isOnline(),h=w=>{var y;r||(r=!0,(y=e.onSuccess)==null||y.call(e,w),o==null||o(),i(w))},p=w=>{var y;r||(r=!0,(y=e.onError)==null||y.call(e,w),o==null||o(),s(w))},v=()=>new Promise(w=>{var y;o=_=>{const S=r||!f();return S&&w(_),S},(y=e.onPause)==null||y.call(e)}).then(()=>{var w;o=void 0,r||(w=e.onContinue)==null||w.call(e)}),b=()=>{if(r)return;let w;try{w=e.fn()}catch(y){w=Promise.reject(y)}Promise.resolve(w).then(h).catch(y=>{var $;if(r)return;const _=e.retry??(nu?0:3),S=e.retryDelay??GV,E=typeof S=="function"?S(n,y):S,C=_===!0||typeof _=="number"&&n<_||typeof _=="function"&&_(n,y);if(t||!C){p(y);return}n++,($=e.onFail)==null||$.call(e,n,y),BV(E).then(()=>{if(f())return v()}).then(()=>{t?p(y):b()})})};return Tm(e.networkMode)?b():v().then(b),{promise:a,cancel:l,continue:()=>(o==null?void 0:o())?a:Promise.resolve(),cancelRetry:c,continueRetry:u}}function qV(){let e=[],t=0,n=h=>{h()},r=h=>{h()},o=h=>setTimeout(h,0);const i=h=>{o=h},s=h=>{let p;t++;try{p=h()}finally{t--,t||c()}return p},a=h=>{t?e.push(h):o(()=>{n(h)})},l=h=>(...p)=>{a(()=>{h(...p)})},c=()=>{const h=e;e=[],h.length&&o(()=>{r(()=>{h.forEach(p=>{n(p)})})})};return{batch:s,batchCalls:l,schedule:a,setNotifyFunction:h=>{n=h},setBatchNotifyFunction:h=>{r=h},setScheduler:i}}var Qn=qV(),tl,qT,$D=(qT=class{constructor(){Xe(this,tl,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ux(this.gcTime)&&Ve(this,tl,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(nu?1/0:5*60*1e3))}clearGcTimeout(){ae(this,tl)&&(clearTimeout(ae(this,tl)),Ve(this,tl,void 0))}},tl=new WeakMap,qT),zc,Bc,Po,Ks,Oo,Un,kf,nl,Vc,xg,Yo,Qi,YT,YV=(YT=class extends $D{constructor(t){super();Xe(this,Vc);Xe(this,Yo);Xe(this,zc,void 0);Xe(this,Bc,void 0);Xe(this,Po,void 0);Xe(this,Ks,void 0);Xe(this,Oo,void 0);Xe(this,Un,void 0);Xe(this,kf,void 0);Xe(this,nl,void 0);Ve(this,nl,!1),Ve(this,kf,t.defaultOptions),Et(this,Vc,xg).call(this,t.options),Ve(this,Un,[]),Ve(this,Po,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,Ve(this,zc,t.state||KV(this.options)),this.state=ae(this,zc),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!ae(this,Un).length&&this.state.fetchStatus==="idle"&&ae(this,Po).remove(this)}setData(t,n){const r=hx(this.state.data,t,this.options);return Et(this,Yo,Qi).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){Et(this,Yo,Qi).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r;const n=ae(this,Ks);return(r=ae(this,Oo))==null||r.cancel(t),n?n.then(To).catch(To):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(ae(this,zc))}isActive(){return ae(this,Un).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||ae(this,Un).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!ED(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=ae(this,Un).find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=ae(this,Oo))==null||n.continue()}onOnline(){var n;const t=ae(this,Un).find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=ae(this,Oo))==null||n.continue()}addObserver(t){ae(this,Un).includes(t)||(ae(this,Un).push(t),this.clearGcTimeout(),ae(this,Po).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){ae(this,Un).includes(t)&&(Ve(this,Un,ae(this,Un).filter(n=>n!==t)),ae(this,Un).length||(ae(this,Oo)&&(ae(this,nl)?ae(this,Oo).cancel({revert:!0}):ae(this,Oo).cancelRetry()),this.scheduleGc()),ae(this,Po).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return ae(this,Un).length}invalidate(){this.state.isInvalidated||Et(this,Yo,Qi).call(this,{type:"invalidate"})}fetch(t,n){var c,u,f,h;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(ae(this,Ks))return(c=ae(this,Oo))==null||c.continueRetry(),ae(this,Ks)}if(t&&Et(this,Vc,xg).call(this,t),!this.options.queryFn){const p=ae(this,Un).find(v=>v.options.queryFn);p&&Et(this,Vc,xg).call(this,p.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o={queryKey:this.queryKey,meta:this.meta},i=p=>{Object.defineProperty(p,"signal",{enumerable:!0,get:()=>(Ve(this,nl,!0),r.signal)})};i(o);const s=()=>this.options.queryFn?(Ve(this,nl,!1),this.options.persister?this.options.persister(this.options.queryFn,o,this):this.options.queryFn(o)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),a={fetchOptions:n,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:s};i(a),(u=this.options.behavior)==null||u.onFetch(a,this),Ve(this,Bc,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=a.fetchOptions)==null?void 0:f.meta))&&Et(this,Yo,Qi).call(this,{type:"fetch",meta:(h=a.fetchOptions)==null?void 0:h.meta});const l=p=>{var v,b,w,y;c0(p)&&p.silent||Et(this,Yo,Qi).call(this,{type:"error",error:p}),c0(p)||((b=(v=ae(this,Po).config).onError)==null||b.call(v,p,this),(y=(w=ae(this,Po).config).onSettled)==null||y.call(w,this.state.data,p,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return Ve(this,Oo,OD({fn:a.fetchFn,abort:r.abort.bind(r),onSuccess:p=>{var v,b,w,y;if(typeof p>"u"){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),l(new Error(`${this.queryHash} data is undefined`));return}this.setData(p),(b=(v=ae(this,Po).config).onSuccess)==null||b.call(v,p,this),(y=(w=ae(this,Po).config).onSettled)==null||y.call(w,p,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:l,onFail:(p,v)=>{Et(this,Yo,Qi).call(this,{type:"failed",failureCount:p,error:v})},onPause:()=>{Et(this,Yo,Qi).call(this,{type:"pause"})},onContinue:()=>{Et(this,Yo,Qi).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode})),Ve(this,Ks,ae(this,Oo).promise),ae(this,Ks)}},zc=new WeakMap,Bc=new WeakMap,Po=new WeakMap,Ks=new WeakMap,Oo=new WeakMap,Un=new WeakMap,kf=new WeakMap,nl=new WeakMap,Vc=new WeakSet,xg=function(t){this.options={...ae(this,kf),...t},this.updateGcTime(this.options.gcTime)},Yo=new WeakSet,Qi=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:t.meta??null,fetchStatus:Tm(this.options.networkMode)?"fetching":"paused",...!r.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...r,data:t.data,dataUpdateCount:r.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const o=t.error;return c0(o)&&o.revert&&ae(this,Bc)?{...ae(this,Bc),fetchStatus:"idle"}:{...r,error:o,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:o,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Qn.batch(()=>{ae(this,Un).forEach(r=>{r.onQueryUpdate()}),ae(this,Po).notify({query:this,type:"updated",action:t})})},YT);function KV(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=typeof t<"u",r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var mi,KT,TD=(KT=class extends Uf{constructor(t={}){super();Xe(this,mi,void 0);this.config=t,Ve(this,mi,new Map)}build(t,n,r){const o=n.queryKey,i=n.queryHash??gw(o,n);let s=this.get(i);return s||(s=new YV({cache:this,queryKey:o,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(o)}),this.add(s)),s}add(t){ae(this,mi).has(t.queryHash)||(ae(this,mi).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=ae(this,mi).get(t.queryHash);n&&(t.destroy(),n===t&&ae(this,mi).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Qn.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return ae(this,mi).get(t)}getAll(){return[...ae(this,mi).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>nP(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>nP(t,r)):n}notify(t){Qn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Qn.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Qn.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},mi=new WeakMap,KT),vi,Mf,Zr,Hc,bi,Vs,XT,XV=(XT=class extends $D{constructor(t){super();Xe(this,bi);Xe(this,vi,void 0);Xe(this,Mf,void 0);Xe(this,Zr,void 0);Xe(this,Hc,void 0);this.mutationId=t.mutationId,Ve(this,Mf,t.defaultOptions),Ve(this,Zr,t.mutationCache),Ve(this,vi,[]),this.state=t.state||QV(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...ae(this,Mf),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){ae(this,vi).includes(t)||(ae(this,vi).push(t),this.clearGcTimeout(),ae(this,Zr).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){Ve(this,vi,ae(this,vi).filter(n=>n!==t)),this.scheduleGc(),ae(this,Zr).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){ae(this,vi).length||(this.state.status==="pending"?this.scheduleGc():ae(this,Zr).remove(this))}continue(){var t;return((t=ae(this,Hc))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,s,a,l,c,u,f,h,p,v,b,w,y,_,S,E,C,$,O;const n=()=>(Ve(this,Hc,OD({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(A,I)=>{Et(this,bi,Vs).call(this,{type:"failed",failureCount:A,error:I})},onPause:()=>{Et(this,bi,Vs).call(this,{type:"pause"})},onContinue:()=>{Et(this,bi,Vs).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),ae(this,Hc).promise),r=this.state.status==="pending";try{if(!r){Et(this,bi,Vs).call(this,{type:"pending",variables:t}),await((i=(o=ae(this,Zr).config).onMutate)==null?void 0:i.call(o,t,this));const I=await((a=(s=this.options).onMutate)==null?void 0:a.call(s,t));I!==this.state.context&&Et(this,bi,Vs).call(this,{type:"pending",context:I,variables:t})}const A=await n();return await((c=(l=ae(this,Zr).config).onSuccess)==null?void 0:c.call(l,A,t,this.state.context,this)),await((f=(u=this.options).onSuccess)==null?void 0:f.call(u,A,t,this.state.context)),await((p=(h=ae(this,Zr).config).onSettled)==null?void 0:p.call(h,A,null,this.state.variables,this.state.context,this)),await((b=(v=this.options).onSettled)==null?void 0:b.call(v,A,null,t,this.state.context)),Et(this,bi,Vs).call(this,{type:"success",data:A}),A}catch(A){try{throw await((y=(w=ae(this,Zr).config).onError)==null?void 0:y.call(w,A,t,this.state.context,this)),await((S=(_=this.options).onError)==null?void 0:S.call(_,A,t,this.state.context)),await((C=(E=ae(this,Zr).config).onSettled)==null?void 0:C.call(E,void 0,A,this.state.variables,this.state.context,this)),await((O=($=this.options).onSettled)==null?void 0:O.call($,void 0,A,t,this.state.context)),A}finally{Et(this,bi,Vs).call(this,{type:"error",error:A})}}}},vi=new WeakMap,Mf=new WeakMap,Zr=new WeakMap,Hc=new WeakMap,bi=new WeakSet,Vs=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!Tm(this.options.networkMode),status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Qn.batch(()=>{ae(this,vi).forEach(r=>{r.onMutationUpdate(t)}),ae(this,Zr).notify({mutation:this,type:"updated",action:t})})},XT);function QV(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var $o,If,rl,QT,JV=(QT=class extends Uf{constructor(t={}){super();Xe(this,$o,void 0);Xe(this,If,void 0);Xe(this,rl,void 0);this.config=t,Ve(this,$o,[]),Ve(this,If,0)}build(t,n,r){const o=new XV({mutationCache:this,mutationId:++up(this,If)._,options:t.defaultMutationOptions(n),state:r});return this.add(o),o}add(t){ae(this,$o).push(t),this.notify({type:"added",mutation:t})}remove(t){Ve(this,$o,ae(this,$o).filter(n=>n!==t)),this.notify({type:"removed",mutation:t})}clear(){Qn.batch(()=>{ae(this,$o).forEach(t=>{this.remove(t)})})}getAll(){return ae(this,$o)}find(t){const n={exact:!0,...t};return ae(this,$o).find(r=>rP(n,r))}findAll(t={}){return ae(this,$o).filter(n=>rP(t,n))}notify(t){Qn.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){return Ve(this,rl,(ae(this,rl)??Promise.resolve()).then(()=>{const t=ae(this,$o).filter(n=>n.state.isPaused);return Qn.batch(()=>t.reduce((n,r)=>n.then(()=>r.continue().catch(To)),Promise.resolve()))}).then(()=>{Ve(this,rl,void 0)})),ae(this,rl)}},$o=new WeakMap,If=new WeakMap,rl=new WeakMap,QT);function ZV(e){return{onFetch:(t,n)=>{const r=async()=>{var v,b,w,y,_;const o=t.options,i=(w=(b=(v=t.fetchOptions)==null?void 0:v.meta)==null?void 0:b.fetchMore)==null?void 0:w.direction,s=((y=t.state.data)==null?void 0:y.pages)||[],a=((_=t.state.data)==null?void 0:_.pageParams)||[],l={pages:[],pageParams:[]};let c=!1;const u=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(t.signal.aborted?c=!0:t.signal.addEventListener("abort",()=>{c=!0}),t.signal)})},f=t.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${t.options.queryHash}'`))),h=async(S,E,C)=>{if(c)return Promise.reject();if(E==null&&S.pages.length)return Promise.resolve(S);const $={queryKey:t.queryKey,pageParam:E,direction:C?"backward":"forward",meta:t.options.meta};u($);const O=await f($),{maxPages:A}=t.options,I=C?HV:VV;return{pages:I(S.pages,O,A),pageParams:I(S.pageParams,E,A)}};let p;if(i&&s.length){const S=i==="backward",E=S?eH:sP,C={pages:s,pageParams:a},$=E(o,C);p=await h(C,$,S)}else{p=await h(l,a[0]??o.initialPageParam);const S=e??s.length;for(let E=1;E<S;E++){const C=sP(o,p);p=await h(p,C)}}return p};t.options.persister?t.fetchFn=()=>{var o,i;return(i=(o=t.options).persister)==null?void 0:i.call(o,r,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=r}}}function sP(e,{pages:t,pageParams:n}){const r=t.length-1;return e.getNextPageParam(t[r],t,n[r],n)}function eH(e,{pages:t,pageParams:n}){var r;return(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n)}var Fn,Xs,Qs,Wc,Uc,Js,Gc,qc,JT,tH=(JT=class{constructor(e={}){Xe(this,Fn,void 0);Xe(this,Xs,void 0);Xe(this,Qs,void 0);Xe(this,Wc,void 0);Xe(this,Uc,void 0);Xe(this,Js,void 0);Xe(this,Gc,void 0);Xe(this,qc,void 0);Ve(this,Fn,e.queryCache||new TD),Ve(this,Xs,e.mutationCache||new JV),Ve(this,Qs,e.defaultOptions||{}),Ve(this,Wc,new Map),Ve(this,Uc,new Map),Ve(this,Js,0)}mount(){up(this,Js)._++,ae(this,Js)===1&&(Ve(this,Gc,zg.subscribe(()=>{zg.isFocused()&&(this.resumePausedMutations(),ae(this,Fn).onFocus())})),Ve(this,qc,Bg.subscribe(()=>{Bg.isOnline()&&(this.resumePausedMutations(),ae(this,Fn).onOnline())})))}unmount(){var e,t;up(this,Js)._--,ae(this,Js)===0&&((e=ae(this,Gc))==null||e.call(this),Ve(this,Gc,void 0),(t=ae(this,qc))==null||t.call(this),Ve(this,qc,void 0))}isFetching(e){return ae(this,Fn).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return ae(this,Xs).findAll({...e,status:"pending"}).length}getQueryData(e){var t;return(t=ae(this,Fn).find({queryKey:e}))==null?void 0:t.state.data}ensureQueryData(e){const t=this.getQueryData(e.queryKey);return t!==void 0?Promise.resolve(t):this.fetchQuery(e)}getQueriesData(e){return this.getQueryCache().findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=ae(this,Fn).find({queryKey:e}),o=r==null?void 0:r.state.data,i=zV(t,o);if(typeof i>"u")return;const s=this.defaultQueryOptions({queryKey:e});return ae(this,Fn).build(this,s).setData(i,{...n,manual:!0})}setQueriesData(e,t,n){return Qn.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var t;return(t=ae(this,Fn).find({queryKey:e}))==null?void 0:t.state}removeQueries(e){const t=ae(this,Fn);Qn.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=ae(this,Fn),r={type:"active",...e};return Qn.batch(()=>(n.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries(r,t)))}cancelQueries(e={},t={}){const n={revert:!0,...t},r=Qn.batch(()=>ae(this,Fn).findAll(e).map(o=>o.cancel(n)));return Promise.all(r).then(To).catch(To)}invalidateQueries(e={},t={}){return Qn.batch(()=>{if(ae(this,Fn).findAll(e).forEach(r=>{r.invalidate()}),e.refetchType==="none")return Promise.resolve();const n={...e,type:e.refetchType??e.type??"active"};return this.refetchQueries(n,t)})}refetchQueries(e={},t){const n={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},r=Qn.batch(()=>ae(this,Fn).findAll(e).filter(o=>!o.isDisabled()).map(o=>{let i=o.fetch(void 0,n);return n.throwOnError||(i=i.catch(To)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(To)}fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const n=ae(this,Fn).build(this,t);return n.isStaleByTime(t.staleTime)?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(To).catch(To)}fetchInfiniteQuery(e){return e.behavior=ZV(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(To).catch(To)}resumePausedMutations(){return ae(this,Xs).resumePausedMutations()}getQueryCache(){return ae(this,Fn)}getMutationCache(){return ae(this,Xs)}getDefaultOptions(){return ae(this,Qs)}setDefaultOptions(e){Ve(this,Qs,e)}setQueryDefaults(e,t){ae(this,Wc).set(qd(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...ae(this,Wc).values()];let n={};return t.forEach(r=>{Yd(e,r.queryKey)&&(n={...n,...r.defaultOptions})}),n}setMutationDefaults(e,t){ae(this,Uc).set(qd(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...ae(this,Uc).values()];let n={};return t.forEach(r=>{Yd(e,r.mutationKey)&&(n={...n,...r.defaultOptions})}),n}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...ae(this,Qs).queries,...(e==null?void 0:e.queryKey)&&this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=gw(t.queryKey,t)),typeof t.refetchOnReconnect>"u"&&(t.refetchOnReconnect=t.networkMode!=="always"),typeof t.throwOnError>"u"&&(t.throwOnError=!!t.suspense),typeof t.networkMode>"u"&&t.persister&&(t.networkMode="offlineFirst"),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...ae(this,Qs).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){ae(this,Fn).clear(),ae(this,Xs).clear()}},Fn=new WeakMap,Xs=new WeakMap,Qs=new WeakMap,Wc=new WeakMap,Uc=new WeakMap,Js=new WeakMap,Gc=new WeakMap,qc=new WeakMap,JT),Ir,fn,Nf,yr,ol,Yc,yi,Lf,Kc,Xc,il,sl,Zs,Qc,al,vd,Ff,px,jf,gx,zf,mx,Bf,vx,Vf,bx,Hf,yx,Wf,xx,Sm,DD,ZT,nH=(ZT=class extends Uf{constructor(t,n){super();Xe(this,al);Xe(this,Ff);Xe(this,jf);Xe(this,zf);Xe(this,Bf);Xe(this,Vf);Xe(this,Hf);Xe(this,Wf);Xe(this,Sm);Xe(this,Ir,void 0);Xe(this,fn,void 0);Xe(this,Nf,void 0);Xe(this,yr,void 0);Xe(this,ol,void 0);Xe(this,Yc,void 0);Xe(this,yi,void 0);Xe(this,Lf,void 0);Xe(this,Kc,void 0);Xe(this,Xc,void 0);Xe(this,il,void 0);Xe(this,sl,void 0);Xe(this,Zs,void 0);Xe(this,Qc,new Set);this.options=n,Ve(this,Ir,t),Ve(this,yi,null),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(ae(this,fn).addObserver(this),aP(ae(this,fn),this.options)?Et(this,al,vd).call(this):this.updateResult(),Et(this,Bf,vx).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return wx(ae(this,fn),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return wx(ae(this,fn),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Et(this,Vf,bx).call(this),Et(this,Hf,yx).call(this),ae(this,fn).removeObserver(this)}setOptions(t,n){const r=this.options,o=ae(this,fn);if(this.options=ae(this,Ir).defaultQueryOptions(t),dx(r,this.options)||ae(this,Ir).getQueryCache().notify({type:"observerOptionsUpdated",query:ae(this,fn),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=r.queryKey),Et(this,Wf,xx).call(this);const i=this.hasListeners();i&&lP(ae(this,fn),o,this.options,r)&&Et(this,al,vd).call(this),this.updateResult(n),i&&(ae(this,fn)!==o||this.options.enabled!==r.enabled||this.options.staleTime!==r.staleTime)&&Et(this,Ff,px).call(this);const s=Et(this,jf,gx).call(this);i&&(ae(this,fn)!==o||this.options.enabled!==r.enabled||s!==ae(this,Zs))&&Et(this,zf,mx).call(this,s)}getOptimisticResult(t){const n=ae(this,Ir).getQueryCache().build(ae(this,Ir),t),r=this.createResult(n,t);return oH(this,r)&&(Ve(this,yr,r),Ve(this,Yc,this.options),Ve(this,ol,ae(this,fn).state)),r}getCurrentResult(){return ae(this,yr)}trackResult(t){const n={};return Object.keys(t).forEach(r=>{Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:()=>(ae(this,Qc).add(r),t[r])})}),n}getCurrentQuery(){return ae(this,fn)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=ae(this,Ir).defaultQueryOptions(t),r=ae(this,Ir).getQueryCache().build(ae(this,Ir),n);return r.isFetchingOptimistic=!0,r.fetch().then(()=>this.createResult(r,n))}fetch(t){return Et(this,al,vd).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),ae(this,yr)))}createResult(t,n){var $;const r=ae(this,fn),o=this.options,i=ae(this,yr),s=ae(this,ol),a=ae(this,Yc),c=t!==r?t.state:ae(this,Nf),{state:u}=t;let{error:f,errorUpdatedAt:h,fetchStatus:p,status:v}=u,b=!1,w;if(n._optimisticResults){const O=this.hasListeners(),A=!O&&aP(t,n),I=O&&lP(t,r,n,o);(A||I)&&(p=Tm(t.options.networkMode)?"fetching":"paused",u.dataUpdatedAt||(v="pending")),n._optimisticResults==="isRestoring"&&(p="idle")}if(n.select&&typeof u.data<"u")if(i&&u.data===(s==null?void 0:s.data)&&n.select===ae(this,Lf))w=ae(this,Kc);else try{Ve(this,Lf,n.select),w=n.select(u.data),w=hx(i==null?void 0:i.data,w,n),Ve(this,Kc,w),Ve(this,yi,null)}catch(O){Ve(this,yi,O)}else w=u.data;if(typeof n.placeholderData<"u"&&typeof w>"u"&&v==="pending"){let O;if(i!=null&&i.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData))O=i.data;else if(O=typeof n.placeholderData=="function"?n.placeholderData(($=ae(this,Xc))==null?void 0:$.state.data,ae(this,Xc)):n.placeholderData,n.select&&typeof O<"u")try{O=n.select(O),Ve(this,yi,null)}catch(A){Ve(this,yi,A)}typeof O<"u"&&(v="success",w=hx(i==null?void 0:i.data,O,n),b=!0)}ae(this,yi)&&(f=ae(this,yi),w=ae(this,Kc),h=Date.now(),v="error");const y=p==="fetching",_=v==="pending",S=v==="error",E=_&&y;return{status:v,fetchStatus:p,isPending:_,isSuccess:v==="success",isError:S,isInitialLoading:E,isLoading:E,data:w,dataUpdatedAt:u.dataUpdatedAt,error:f,errorUpdatedAt:h,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>c.dataUpdateCount||u.errorUpdateCount>c.errorUpdateCount,isFetching:y,isRefetching:y&&!_,isLoadingError:S&&u.dataUpdatedAt===0,isPaused:p==="paused",isPlaceholderData:b,isRefetchError:S&&u.dataUpdatedAt!==0,isStale:mw(t,n),refetch:this.refetch}}updateResult(t){const n=ae(this,yr),r=this.createResult(ae(this,fn),this.options);if(Ve(this,ol,ae(this,fn).state),Ve(this,Yc,this.options),ae(this,ol).data!==void 0&&Ve(this,Xc,ae(this,fn)),dx(r,n))return;Ve(this,yr,r);const o={},i=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!ae(this,Qc).size)return!0;const l=new Set(a??ae(this,Qc));return this.options.throwOnError&&l.add("error"),Object.keys(ae(this,yr)).some(c=>{const u=c;return ae(this,yr)[u]!==n[u]&&l.has(u)})};(t==null?void 0:t.listeners)!==!1&&i()&&(o.listeners=!0),Et(this,Sm,DD).call(this,{...o,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Et(this,Bf,vx).call(this)}},Ir=new WeakMap,fn=new WeakMap,Nf=new WeakMap,yr=new WeakMap,ol=new WeakMap,Yc=new WeakMap,yi=new WeakMap,Lf=new WeakMap,Kc=new WeakMap,Xc=new WeakMap,il=new WeakMap,sl=new WeakMap,Zs=new WeakMap,Qc=new WeakMap,al=new WeakSet,vd=function(t){Et(this,Wf,xx).call(this);let n=ae(this,fn).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(To)),n},Ff=new WeakSet,px=function(){if(Et(this,Vf,bx).call(this),nu||ae(this,yr).isStale||!ux(this.options.staleTime))return;const n=ED(ae(this,yr).dataUpdatedAt,this.options.staleTime)+1;Ve(this,il,setTimeout(()=>{ae(this,yr).isStale||this.updateResult()},n))},jf=new WeakSet,gx=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(ae(this,fn)):this.options.refetchInterval)??!1},zf=new WeakSet,mx=function(t){Et(this,Hf,yx).call(this),Ve(this,Zs,t),!(nu||this.options.enabled===!1||!ux(ae(this,Zs))||ae(this,Zs)===0)&&Ve(this,sl,setInterval(()=>{(this.options.refetchIntervalInBackground||zg.isFocused())&&Et(this,al,vd).call(this)},ae(this,Zs)))},Bf=new WeakSet,vx=function(){Et(this,Ff,px).call(this),Et(this,zf,mx).call(this,Et(this,jf,gx).call(this))},Vf=new WeakSet,bx=function(){ae(this,il)&&(clearTimeout(ae(this,il)),Ve(this,il,void 0))},Hf=new WeakSet,yx=function(){ae(this,sl)&&(clearInterval(ae(this,sl)),Ve(this,sl,void 0))},Wf=new WeakSet,xx=function(){const t=ae(this,Ir).getQueryCache().build(ae(this,Ir),this.options);if(t===ae(this,fn))return;const n=ae(this,fn);Ve(this,fn,t),Ve(this,Nf,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},Sm=new WeakSet,DD=function(t){Qn.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(ae(this,yr))}),ae(this,Ir).getQueryCache().notify({query:ae(this,fn),type:"observerResultsUpdated"})})},ZT);function rH(e,t){return t.enabled!==!1&&!e.state.dataUpdatedAt&&!(e.state.status==="error"&&t.retryOnMount===!1)}function aP(e,t){return rH(e,t)||e.state.dataUpdatedAt>0&&wx(e,t,t.refetchOnMount)}function wx(e,t,n){if(t.enabled!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&mw(e,t)}return!1}function lP(e,t,n,r){return n.enabled!==!1&&(e!==t||r.enabled===!1)&&(!n.suspense||e.state.status!=="error")&&mw(e,n)}function mw(e,t){return e.isStaleByTime(t.staleTime)}function oH(e,t){return!dx(e.getCurrentResult(),t)}var AD=N.createContext(void 0),kD=e=>{const t=N.useContext(AD);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},iH=({client:e,children:t})=>(N.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),N.createElement(AD.Provider,{value:e},t)),MD=N.createContext(!1),sH=()=>N.useContext(MD);MD.Provider;function aH(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var lH=N.createContext(aH()),cH=()=>N.useContext(lH);function uH(e,t){return typeof e=="function"?e(...t):!!e}var dH=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},fH=e=>{N.useEffect(()=>{e.clearReset()},[e])},hH=({result:e,errorResetBoundary:t,throwOnError:n,query:r})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&uH(n,[e.error,r]),pH=e=>{e.suspense&&typeof e.staleTime!="number"&&(e.staleTime=1e3)},gH=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,mH=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function vH(e,t,n){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const r=kD(n),o=sH(),i=cH(),s=r.defaultQueryOptions(e);s._optimisticResults=o?"isRestoring":"optimistic",pH(s),dH(s,i),fH(i);const[a]=N.useState(()=>new t(r,s)),l=a.getOptimisticResult(s);if(N.useSyncExternalStore(N.useCallback(c=>{const u=o?()=>{}:a.subscribe(Qn.batchCalls(c));return a.updateResult(),u},[a,o]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),N.useEffect(()=>{a.setOptions(s,{listeners:!1})},[s,a]),gH(s,l))throw mH(s,a,i);if(hH({result:l,errorResetBoundary:i,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash)}))throw l.error;return s.notifyOnChangeProps?l:a.trackResult(l)}function Dm(e,t){return vH(e,nH,t)}function ID({children:e}){const{setIsSessionExpired:t}=ur(),n=new tH({queryCache:new TD({onError:r=>{console.error(`Something went wrong: ${r.message}`),r.message==="invalid token"&&t(!0)}}),defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}});return R.jsx(iH,{client:n,children:e})}const Ol=m.forwardRef(({children:e,className:t,...n},r)=>R.jsx("div",{className:xe("semaphor-scope",t),ref:r,...n,children:e})),bH={id:"",authToken:void 0},ND=m.createContext(bH),LD=({children:e,dashboardProps:t})=>R.jsx(ID,{children:R.jsx(ND.Provider,{value:t,children:R.jsx(Ol,{style:{height:"100%"},children:e})})});function ni(){const e=m.useContext(ND);if(e===void 0)throw new Error("useApplicationContext must be used within a ApplicationContextProvider");return e}function yH(){const{authToken:e,version:t}=ni(),n=Ee(a=>a.selectedLensId),{data:r,isLoading:o,isFetching:i,isError:s}=Dm({queryKey:["dashboard",n,e==null?void 0:e.accessToken],queryFn:()=>nV(e==null?void 0:e.accessToken,{lensId:n,version:t})});return{data:r,isLoading:o,isFetching:i,isError:s}}function FD(e){return e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e}function cP(e,t){const n=FD(e);return n==="dark"?ll.merge({...t==null?void 0:t.default},{...t==null?void 0:t.dark}):t==null?void 0:t.default}function xH({customStyle:e,currentTheme:t,onSave:n,onEvent:r,defaultFilterValues:o}){const{authToken:i}=ni(),s=Ee(L=>L.selectedLensId),{data:a,isLoading:l,isFetching:c,isError:u}=yH(),{theme:f,setTheme:h}=CD(),p=Ee(L=>L.dashboard.globalStyle),{setDashboard:v,setDashboardWithFilterValues:b,setSelectedSheetId:w,setStyle:y,setOnSaveFunction:_,setLenses:S,setSelectedLensId:E,setInitStore:C}=Ee(L=>L.actions);Ee(L=>L.actions.setCustomCards);const $=Ee(L=>L.actions.setFilterValues),O=Ee(L=>L.actions.setThemeStyle),A=Ee(L=>L.actions.setDashboardTheme),I=Ee(L=>L.actions.setOnEvent);m.useEffect(()=>{i&&C()},[i,C]),m.useEffect(()=>{if(f){const L=FD(f);A(L)}},[f,A]),m.useEffect(()=>{t&&h(t)},[t,h]);const F=m.useCallback(()=>{const L=ll.cloneDeep(Lg),B=ll.merge(L,p);if(e){const J=ll.merge(B,e),q=cP(f,J);O(q),y(J)}else{const J=cP(f,B);O(J),y(Lg)}},[f,e,p,O,y]);return m.useEffect(()=>{a&&a.dashboard&&F()},[f,e,p,F,a]),m.useEffect(()=>{var z;if(!a||!a.dashboard)return;const{dashboard:L,filterValues:B,defaultLensId:J,lenses:q}=a;b(L,B||o||[]),J&&E(J),q&&S(q),w((z=L.sheets)==null?void 0:z[0].id)},[a,v,w,$,s,S,b,E]),m.useEffect(()=>{n&&_(n),r&&I(r)},[n,_,r,I]),{isFetching:c,isLoading:l,isError:u}}function Am({className:e,...t}){return R.jsx("div",{className:xe("animate-pulse rounded-md bg-muted",e),...t})}const vw=N.forwardRef(({className:e,...t},n)=>R.jsx("div",{ref:n,className:xe("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));vw.displayName="Card";const km=N.forwardRef(({className:e,...t},n)=>R.jsx("div",{ref:n,className:xe("flex flex-col space-y-1.5 p-6",e),...t}));km.displayName="CardHeader";const bu=N.forwardRef(({className:e,...t},n)=>R.jsx("h3",{ref:n,className:xe("text-2xl font-semibold leading-none tracking-tight",e),...t}));bu.displayName="CardTitle";const bw=N.forwardRef(({className:e,...t},n)=>R.jsx("p",{ref:n,className:xe("text-sm text-muted-foreground",e),...t}));bw.displayName="CardDescription";const Mm=N.forwardRef(({className:e,...t},n)=>R.jsx("div",{ref:n,className:xe("px-6 pt-0",e),...t}));Mm.displayName="CardContent";const yw=N.forwardRef(({className:e,...t},n)=>R.jsx("div",{ref:n,className:xe("flex items-center p-6 pt-0",e),...t}));yw.displayName="CardFooter";function jD({className:e,customStyle:t,onSave:n,onEvent:r,LoadingComponent:o,ErrorComponent:i,onChartElementClicked:s,id:a,authToken:l,currentTheme:c,version:u,customCards:f,showAssistant:h,defaultFilterValues:p,...v}){Ee(E=>E.selectedSheetId);const b=Ee(E=>E.themeStyle),w=Ee(E=>E.isSessionExpired),{isLoading:y,isError:_,isFetching:S}=xH({authToken:l,customStyle:t,currentTheme:c,onSave:n,onEvent:r,defaultFilterValues:p});return y||!l?(r==null||r({type:"info",message:"Loading dashboard"}),o?R.jsx(o,{message:"loading"}):R.jsx("div",{className:"flex items-center gap-3",children:R.jsx(Am,{className:"h-1 w-full dark:h-[2px]"})})):_?(r==null||r({type:"error",message:"Error fetching dashboard"}),i?(console.log("Error fetching dashboard"),R.jsx(i,{})):R.jsx("div",{children:"Error"})):w?(r==null||r({type:"error",message:"Session Expired"}),R.jsx("div",{className:"flex h-full items-center justify-center",children:R.jsxs("div",{className:"space-y-4 rounded-md border border-muted p-10",children:[R.jsx(bu,{children:"Session Expired"}),R.jsx("p",{className:"text-muted-foreground",children:"Please refresh your page to continue."})]})})):R.jsx("div",{className:xe("flex h-full flex-col justify-between",b==null?void 0:b.dashboardPanel,e),style:{},role:"dashboard-panel",...v})}function ce(){return ce=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ce.apply(this,arguments)}function Me(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function tr(e,t=[]){let n=[];function r(i,s){const a=m.createContext(s),l=n.length;n=[...n,s];function c(f){const{scope:h,children:p,...v}=f,b=(h==null?void 0:h[e][l])||a,w=m.useMemo(()=>v,Object.values(v));return m.createElement(b.Provider,{value:w},p)}function u(f,h){const p=(h==null?void 0:h[e][l])||a,v=m.useContext(p);if(v)return v;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return c.displayName=i+"Provider",[c,u]}const o=()=>{const i=n.map(s=>m.createContext(s));return function(a){const l=(a==null?void 0:a[e])||i;return m.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return o.scopeName=e,[r,wH(o,...t)]}function wH(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const s=r.reduce((a,{useScope:l,scopeName:c})=>{const f=l(i)[`__scope${c}`];return{...a,...f}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:s}),[s])}};return n.scopeName=t.scopeName,n}function _H(e,t){typeof e=="function"?e(t):e!=null&&(e.current=t)}function ps(...e){return t=>e.forEach(n=>_H(n,t))}function St(...e){return m.useCallback(ps(...e),e)}const _x=m.forwardRef((e,t)=>{const{children:n,...r}=e,o=m.Children.toArray(n),i=o.find(CH);if(i){const s=i.props.children,a=o.map(l=>l===i?m.Children.count(s)>1?m.Children.only(null):m.isValidElement(s)?s.props.children:null:l);return m.createElement(Sx,ce({},r,{ref:t}),m.isValidElement(s)?m.cloneElement(s,void 0,a):null)}return m.createElement(Sx,ce({},r,{ref:t}),n)});_x.displayName="Slot";const Sx=m.forwardRef((e,t)=>{const{children:n,...r}=e;return m.isValidElement(n)?m.cloneElement(n,{...EH(r,n.props),ref:t?ps(t,n.ref):n.ref}):m.Children.count(n)>1?m.Children.only(null):null});Sx.displayName="SlotClone";const SH=({children:e})=>m.createElement(m.Fragment,null,e);function CH(e){return m.isValidElement(e)&&e.type===SH}function EH(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function Im(e){const t=e+"CollectionProvider",[n,r]=tr(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=p=>{const{scope:v,children:b}=p,w=m.useRef(null),y=m.useRef(new Map).current;return m.createElement(o,{scope:v,itemMap:y,collectionRef:w},b)},a=e+"CollectionSlot",l=m.forwardRef((p,v)=>{const{scope:b,children:w}=p,y=i(a,b),_=St(v,y.collectionRef);return m.createElement(_x,{ref:_},w)}),c=e+"CollectionItemSlot",u="data-radix-collection-item",f=m.forwardRef((p,v)=>{const{scope:b,children:w,...y}=p,_=m.useRef(null),S=St(v,_),E=i(c,b);return m.useEffect(()=>(E.itemMap.set(_,{ref:_,...y}),()=>void E.itemMap.delete(_))),m.createElement(_x,{[u]:"",ref:S},w)});function h(p){const v=i(e+"CollectionConsumer",p);return m.useCallback(()=>{const w=v.collectionRef.current;if(!w)return[];const y=Array.from(w.querySelectorAll(`[${u}]`));return Array.from(v.itemMap.values()).sort((E,C)=>y.indexOf(E.ref.current)-y.indexOf(C.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:s,Slot:l,ItemSlot:f},h,r]}const dr=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},RH=N.useId||(()=>{});let PH=0;function Zo(e){const[t,n]=N.useState(RH());return dr(()=>{e||n(r=>r??String(PH++))},[e]),e||(t?`radix-${t}`:"")}const zD=m.forwardRef((e,t)=>{const{children:n,...r}=e,o=m.Children.toArray(n),i=o.find($H);if(i){const s=i.props.children,a=o.map(l=>l===i?m.Children.count(s)>1?m.Children.only(null):m.isValidElement(s)?s.props.children:null:l);return m.createElement(Cx,ce({},r,{ref:t}),m.isValidElement(s)?m.cloneElement(s,void 0,a):null)}return m.createElement(Cx,ce({},r,{ref:t}),n)});zD.displayName="Slot";const Cx=m.forwardRef((e,t)=>{const{children:n,...r}=e;return m.isValidElement(n)?m.cloneElement(n,{...TH(r,n.props),ref:t?ps(t,n.ref):n.ref}):m.Children.count(n)>1?m.Children.only(null):null});Cx.displayName="SlotClone";const OH=({children:e})=>m.createElement(m.Fragment,null,e);function $H(e){return m.isValidElement(e)&&e.type===OH}function TH(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...a)=>{i(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}const DH=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Qe=DH.reduce((e,t)=>{const n=m.forwardRef((r,o)=>{const{asChild:i,...s}=r,a=i?zD:t;return m.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),m.createElement(a,ce({},s,{ref:o}))});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function BD(e,t){e&&fr.flushSync(()=>e.dispatchEvent(t))}function zn(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var r;return(r=t.current)===null||r===void 0?void 0:r.call(t,...n)},[])}function Sr({prop:e,defaultProp:t,onChange:n=()=>{}}){const[r,o]=AH({defaultProp:t,onChange:n}),i=e!==void 0,s=i?e:r,a=zn(n),l=m.useCallback(c=>{if(i){const f=typeof c=="function"?c(e):c;f!==e&&a(f)}else o(c)},[i,e,o,a]);return[s,l]}function AH({defaultProp:e,onChange:t}){const n=m.useState(e),[r]=n,o=m.useRef(r),i=zn(t);return m.useEffect(()=>{o.current!==r&&(i(r),o.current=r)},[r,o,i]),n}const kH=m.createContext(void 0);function $l(e){const t=m.useContext(kH);return e||t||"ltr"}const u0="rovingFocusGroup.onEntryFocus",MH={bubbles:!1,cancelable:!0},xw="RovingFocusGroup",[Ex,VD,IH]=Im(xw),[NH,yu]=tr(xw,[IH]),[LH,FH]=NH(xw),jH=m.forwardRef((e,t)=>m.createElement(Ex.Provider,{scope:e.__scopeRovingFocusGroup},m.createElement(Ex.Slot,{scope:e.__scopeRovingFocusGroup},m.createElement(zH,ce({},e,{ref:t}))))),zH=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,...u}=e,f=m.useRef(null),h=St(t,f),p=$l(i),[v=null,b]=Sr({prop:s,defaultProp:a,onChange:l}),[w,y]=m.useState(!1),_=zn(c),S=VD(n),E=m.useRef(!1),[C,$]=m.useState(0);return m.useEffect(()=>{const O=f.current;if(O)return O.addEventListener(u0,_),()=>O.removeEventListener(u0,_)},[_]),m.createElement(LH,{scope:n,orientation:r,dir:p,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(O=>b(O),[b]),onItemShiftTab:m.useCallback(()=>y(!0),[]),onFocusableItemAdd:m.useCallback(()=>$(O=>O+1),[]),onFocusableItemRemove:m.useCallback(()=>$(O=>O-1),[])},m.createElement(Qe.div,ce({tabIndex:w||C===0?-1:0,"data-orientation":r},u,{ref:h,style:{outline:"none",...e.style},onMouseDown:Me(e.onMouseDown,()=>{E.current=!0}),onFocus:Me(e.onFocus,O=>{const A=!E.current;if(O.target===O.currentTarget&&A&&!w){const I=new CustomEvent(u0,MH);if(O.currentTarget.dispatchEvent(I),!I.defaultPrevented){const F=S().filter(z=>z.focusable),L=F.find(z=>z.active),B=F.find(z=>z.id===v),q=[L,B,...F].filter(Boolean).map(z=>z.ref.current);HD(q)}}E.current=!1}),onBlur:Me(e.onBlur,()=>y(!1))})))}),BH="RovingFocusGroupItem",VH=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,...s}=e,a=Zo(),l=i||a,c=FH(BH,n),u=c.currentTabStopId===l,f=VD(n),{onFocusableItemAdd:h,onFocusableItemRemove:p}=c;return m.useEffect(()=>{if(r)return h(),()=>p()},[r,h,p]),m.createElement(Ex.ItemSlot,{scope:n,id:l,focusable:r,active:o},m.createElement(Qe.span,ce({tabIndex:u?0:-1,"data-orientation":c.orientation},s,{ref:t,onMouseDown:Me(e.onMouseDown,v=>{r?c.onItemFocus(l):v.preventDefault()}),onFocus:Me(e.onFocus,()=>c.onItemFocus(l)),onKeyDown:Me(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){c.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const b=UH(v,c.orientation,c.dir);if(b!==void 0){v.preventDefault();let y=f().filter(_=>_.focusable).map(_=>_.ref.current);if(b==="last")y.reverse();else if(b==="prev"||b==="next"){b==="prev"&&y.reverse();const _=y.indexOf(v.currentTarget);y=c.loop?GH(y,_+1):y.slice(_+1)}setTimeout(()=>HD(y))}})})))}),HH={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function WH(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function UH(e,t,n){const r=WH(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return HH[r]}function HD(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function GH(e,t){return e.map((n,r)=>e[(t+r)%e.length])}const ww=jH,_w=VH;function qH(e,t){return m.useReducer((n,r)=>{const o=t[n][r];return o??n},e)}const nr=e=>{const{present:t,children:n}=e,r=YH(t),o=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),i=St(r.ref,o.ref);return typeof n=="function"||r.isPresent?m.cloneElement(o,{ref:i}):null};nr.displayName="Presence";function YH(e){const[t,n]=m.useState(),r=m.useRef({}),o=m.useRef(e),i=m.useRef("none"),s=e?"mounted":"unmounted",[a,l]=qH(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const c=pp(r.current);i.current=a==="mounted"?c:"none"},[a]),dr(()=>{const c=r.current,u=o.current;if(u!==e){const h=i.current,p=pp(c);e?l("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,l]),dr(()=>{if(t){const c=f=>{const p=pp(r.current).includes(f.animationName);f.target===t&&p&&fr.flushSync(()=>l("ANIMATION_END"))},u=f=>{f.target===t&&(i.current=pp(r.current))};return t.addEventListener("animationstart",u),t.addEventListener("animationcancel",c),t.addEventListener("animationend",c),()=>{t.removeEventListener("animationstart",u),t.removeEventListener("animationcancel",c),t.removeEventListener("animationend",c)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function pp(e){return(e==null?void 0:e.animationName)||"none"}const WD="Tabs",[KH,$1e]=tr(WD,[yu]),UD=yu(),[XH,Sw]=KH(WD),QH=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:l="automatic",...c}=e,u=$l(a),[f,h]=Sr({prop:r,onChange:o,defaultProp:i});return m.createElement(XH,{scope:n,baseId:Zo(),value:f,onValueChange:h,orientation:s,dir:u,activationMode:l},m.createElement(Qe.div,ce({dir:u,"data-orientation":s},c,{ref:t})))}),JH="TabsList",ZH=m.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=Sw(JH,n),s=UD(n);return m.createElement(ww,ce({asChild:!0},s,{orientation:i.orientation,dir:i.dir,loop:r}),m.createElement(Qe.div,ce({role:"tablist","aria-orientation":i.orientation},o,{ref:t})))}),eW="TabsTrigger",tW=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,s=Sw(eW,n),a=UD(n),l=GD(s.baseId,r),c=qD(s.baseId,r),u=r===s.value;return m.createElement(_w,ce({asChild:!0},a,{focusable:!o,active:u}),m.createElement(Qe.button,ce({type:"button",role:"tab","aria-selected":u,"aria-controls":c,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l},i,{ref:t,onMouseDown:Me(e.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?s.onValueChange(r):f.preventDefault()}),onKeyDown:Me(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&s.onValueChange(r)}),onFocus:Me(e.onFocus,()=>{const f=s.activationMode!=="manual";!u&&!o&&f&&s.onValueChange(r)})})))}),nW="TabsContent",rW=m.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=e,a=Sw(nW,n),l=GD(a.baseId,r),c=qD(a.baseId,r),u=r===a.value,f=m.useRef(u);return m.useEffect(()=>{const h=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(h)},[]),m.createElement(nr,{present:o||u},({present:h})=>m.createElement(Qe.div,ce({"data-state":u?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!h,id:c,tabIndex:0},s,{ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0}}),h&&i))});function GD(e,t){return`${e}-trigger-${t}`}function qD(e,t){return`${e}-content-${t}`}const oW=QH,YD=ZH,KD=tW,XD=rW,Cw=oW,Nm=N.forwardRef(({className:e,...t},n)=>R.jsx(YD,{ref:n,className:xe("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));Nm.displayName=YD.displayName;const Lm=N.forwardRef(({className:e,...t},n)=>R.jsx(KD,{ref:n,className:xe("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));Lm.displayName=KD.displayName;const Ew=N.forwardRef(({className:e,...t},n)=>R.jsx(XD,{ref:n,className:xe("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Ew.displayName=XD.displayName;var QD={exports:{}},Gf={},Rx={exports:{}};(function(e,t){(function(n,r){r(t)})(Gs,function(n){function r(Z){return function(ie,me,X,be,Se,$e,Te){return Z(ie,me,Te)}}function o(Z){return function(ie,me,X,be){if(!ie||!me||typeof ie!="object"||typeof me!="object")return Z(ie,me,X,be);var Se=be.get(ie),$e=be.get(me);if(Se&&$e)return Se===me&&$e===ie;be.set(ie,me),be.set(me,ie);var Te=Z(ie,me,X,be);return be.delete(ie),be.delete(me),Te}}function i(Z,te){var ie={};for(var me in Z)ie[me]=Z[me];for(var me in te)ie[me]=te[me];return ie}function s(Z){return Z.constructor===Object||Z.constructor==null}function a(Z){return typeof Z.then=="function"}function l(Z,te){return Z===te||Z!==Z&&te!==te}var c="[object Arguments]",u="[object Boolean]",f="[object Date]",h="[object RegExp]",p="[object Map]",v="[object Number]",b="[object Object]",w="[object Set]",y="[object String]",_=Object.prototype.toString;function S(Z){var te=Z.areArraysEqual,ie=Z.areDatesEqual,me=Z.areMapsEqual,X=Z.areObjectsEqual,be=Z.areRegExpsEqual,Se=Z.areSetsEqual,$e=Z.createIsNestedEqual,Te=$e(Ue);function Ue(Be,Ie,Ke){if(Be===Ie)return!0;if(!Be||!Ie||typeof Be!="object"||typeof Ie!="object")return Be!==Be&&Ie!==Ie;if(s(Be)&&s(Ie))return X(Be,Ie,Te,Ke);var lt=Array.isArray(Be),Nt=Array.isArray(Ie);if(lt||Nt)return lt===Nt&&te(Be,Ie,Te,Ke);var At=_.call(Be);return At!==_.call(Ie)?!1:At===f?ie(Be,Ie,Te,Ke):At===h?be(Be,Ie,Te,Ke):At===p?me(Be,Ie,Te,Ke):At===w?Se(Be,Ie,Te,Ke):At===b||At===c?a(Be)||a(Ie)?!1:X(Be,Ie,Te,Ke):At===u||At===v||At===y?l(Be.valueOf(),Ie.valueOf()):!1}return Ue}function E(Z,te,ie,me){var X=Z.length;if(te.length!==X)return!1;for(;X-- >0;)if(!ie(Z[X],te[X],X,X,Z,te,me))return!1;return!0}var C=o(E);function $(Z,te){return l(Z.valueOf(),te.valueOf())}function O(Z,te,ie,me){var X=Z.size===te.size;if(!X)return!1;if(!Z.size)return!0;var be={},Se=0;return Z.forEach(function($e,Te){if(X){var Ue=!1,Be=0;te.forEach(function(Ie,Ke){!Ue&&!be[Be]&&(Ue=ie(Te,Ke,Se,Be,Z,te,me)&&ie($e,Ie,Te,Ke,Z,te,me))&&(be[Be]=!0),Be++}),Se++,X=Ue}}),X}var A=o(O),I="_owner",F=Object.prototype.hasOwnProperty;function L(Z,te,ie,me){var X=Object.keys(Z),be=X.length;if(Object.keys(te).length!==be)return!1;for(var Se;be-- >0;){if(Se=X[be],Se===I){var $e=!!Z.$$typeof,Te=!!te.$$typeof;if(($e||Te)&&$e!==Te)return!1}if(!F.call(te,Se)||!ie(Z[Se],te[Se],Se,Se,Z,te,me))return!1}return!0}var B=o(L);function J(Z,te){return Z.source===te.source&&Z.flags===te.flags}function q(Z,te,ie,me){var X=Z.size===te.size;if(!X)return!1;if(!Z.size)return!0;var be={};return Z.forEach(function(Se,$e){if(X){var Te=!1,Ue=0;te.forEach(function(Be,Ie){!Te&&!be[Ue]&&(Te=ie(Se,Be,$e,Ie,Z,te,me))&&(be[Ue]=!0),Ue++}),X=Te}}),X}var z=o(q),ee=Object.freeze({areArraysEqual:E,areDatesEqual:$,areMapsEqual:O,areObjectsEqual:L,areRegExpsEqual:J,areSetsEqual:q,createIsNestedEqual:r}),G=Object.freeze({areArraysEqual:C,areDatesEqual:$,areMapsEqual:A,areObjectsEqual:B,areRegExpsEqual:J,areSetsEqual:z,createIsNestedEqual:r}),Q=S(ee);function W(Z,te){return Q(Z,te,void 0)}var T=S(i(ee,{createIsNestedEqual:function(){return l}}));function H(Z,te){return T(Z,te,void 0)}var U=S(G);function M(Z,te){return U(Z,te,new WeakMap)}var re=S(i(G,{createIsNestedEqual:function(){return l}}));function ue(Z,te){return re(Z,te,new WeakMap)}function de(Z){return S(i(ee,Z(ee)))}function pe(Z){var te=S(i(G,Z(G)));return function(ie,me,X){return X===void 0&&(X=new WeakMap),te(ie,me,X)}}n.circularDeepEqual=M,n.circularShallowEqual=ue,n.createCustomCircularEqual=pe,n.createCustomEqual=de,n.deepEqual=W,n.sameValueZeroEqual=l,n.shallowEqual=H,Object.defineProperty(n,"__esModule",{value:!0})})})(Rx,Rx.exports);var Rw=Rx.exports;const Pw=sw(pB);var Ot={},iW=function(t,n,r){return t===n?!0:t.className===n.className&&r(t.style,n.style)&&t.width===n.width&&t.autoSize===n.autoSize&&t.cols===n.cols&&t.draggableCancel===n.draggableCancel&&t.draggableHandle===n.draggableHandle&&r(t.verticalCompact,n.verticalCompact)&&r(t.compactType,n.compactType)&&r(t.layout,n.layout)&&r(t.margin,n.margin)&&r(t.containerPadding,n.containerPadding)&&t.rowHeight===n.rowHeight&&t.maxRows===n.maxRows&&t.isBounded===n.isBounded&&t.isDraggable===n.isDraggable&&t.isResizable===n.isResizable&&t.allowOverlap===n.allowOverlap&&t.preventCollision===n.preventCollision&&t.useCSSTransforms===n.useCSSTransforms&&t.transformScale===n.transformScale&&t.isDroppable===n.isDroppable&&r(t.resizeHandles,n.resizeHandles)&&r(t.resizeHandle,n.resizeHandle)&&t.onLayoutChange===n.onLayoutChange&&t.onDragStart===n.onDragStart&&t.onDrag===n.onDrag&&t.onDragStop===n.onDragStop&&t.onResizeStart===n.onResizeStart&&t.onResize===n.onResize&&t.onResizeStop===n.onResizeStop&&t.onDrop===n.onDrop&&r(t.droppingItem,n.droppingItem)&&r(t.innerRef,n.innerRef)};Object.defineProperty(Ot,"__esModule",{value:!0});Ot.bottom=Ow;Ot.childrenEqual=cW;Ot.cloneLayout=JD;Ot.cloneLayoutItem=cl;Ot.collides=Fm;Ot.compact=eA;Ot.compactItem=tA;Ot.compactType=SW;Ot.correctBounds=nA;Ot.fastPositionEqual=dW;Ot.fastRGLPropsEqual=void 0;Ot.getAllCollisions=rA;Ot.getFirstCollision=Xa;Ot.getLayoutItem=$w;Ot.getStatics=Tw;Ot.modifyLayout=ZD;Ot.moveElement=yd;Ot.moveElementAwayFromCollision=Ox;Ot.noop=void 0;Ot.perc=hW;Ot.resizeItemInDirection=yW;Ot.setTopLeft=wW;Ot.setTransform=xW;Ot.sortLayoutItems=Nw;Ot.sortLayoutItemsByColRow=lA;Ot.sortLayoutItemsByRowCol=aA;Ot.synchronizeLayoutWithChildren=_W;Ot.validateLayout=cA;Ot.withLayoutItem=lW;var uP=Rw,bd=sW(m);function sW(e){return e&&e.__esModule?e:{default:e}}const aW=process.env.NODE_ENV==="production";function Ow(e){let t=0,n;for(let r=0,o=e.length;r<o;r++)n=e[r].y+e[r].h,n>t&&(t=n);return t}function JD(e){const t=Array(e.length);for(let n=0,r=e.length;n<r;n++)t[n]=cl(e[n]);return t}function ZD(e,t){const n=Array(e.length);for(let r=0,o=e.length;r<o;r++)t.i===e[r].i?n[r]=t:n[r]=e[r];return n}function lW(e,t,n){let r=$w(e,t);return r?(r=n(cl(r)),e=ZD(e,r),[e,r]):[e,null]}function cl(e){return{w:e.w,h:e.h,x:e.x,y:e.y,i:e.i,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}}function cW(e,t){return(0,uP.deepEqual)(bd.default.Children.map(e,n=>n==null?void 0:n.key),bd.default.Children.map(t,n=>n==null?void 0:n.key))&&(0,uP.deepEqual)(bd.default.Children.map(e,n=>n==null?void 0:n.props["data-grid"]),bd.default.Children.map(t,n=>n==null?void 0:n.props["data-grid"]))}const uW=iW;Ot.fastRGLPropsEqual=uW;function dW(e,t){return e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function Fm(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function eA(e,t,n,r){const o=Tw(e),i=Nw(e,t),s=Array(e.length);for(let a=0,l=i.length;a<l;a++){let c=cl(i[a]);c.static||(c=tA(o,c,t,n,i,r),o.push(c)),s[e.indexOf(i[a])]=c,c.moved=!1}return s}const fW={x:"w",y:"h"};function Px(e,t,n,r){const o=fW[r];t[r]+=1;const i=e.map(s=>s.i).indexOf(t.i);for(let s=i+1;s<e.length;s++){const a=e[s];if(!a.static){if(a.y>t.y+t.h)break;Fm(t,a)&&Px(e,a,n+t[o],r)}}t[r]=n}function tA(e,t,n,r,o,i){const s=n==="vertical",a=n==="horizontal";if(s)for(t.y=Math.min(Ow(e),t.y);t.y>0&&!Xa(e,t);)t.y--;else if(a)for(;t.x>0&&!Xa(e,t);)t.x--;let l;for(;(l=Xa(e,t))&&!(n===null&&i);)if(a?Px(o,t,l.x+l.w,"x"):Px(o,t,l.y+l.h,"y"),a&&t.x+t.w>r)for(t.x=r-t.w,t.y++;t.x>0&&!Xa(e,t);)t.x--;return t.y=Math.max(t.y,0),t.x=Math.max(t.x,0),t}function nA(e,t){const n=Tw(e);for(let r=0,o=e.length;r<o;r++){const i=e[r];if(i.x+i.w>t.cols&&(i.x=t.cols-i.w),i.x<0&&(i.x=0,i.w=t.cols),!i.static)n.push(i);else for(;Xa(n,i);)i.y++}return e}function $w(e,t){for(let n=0,r=e.length;n<r;n++)if(e[n].i===t)return e[n]}function Xa(e,t){for(let n=0,r=e.length;n<r;n++)if(Fm(e[n],t))return e[n]}function rA(e,t){return e.filter(n=>Fm(n,t))}function Tw(e){return e.filter(t=>t.static)}function yd(e,t,n,r,o,i,s,a,l){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return e;"Moving element ".concat(t.i," to [").concat(String(n),",").concat(String(r),"] from [").concat(t.x,",").concat(t.y,"]");const c=t.x,u=t.y;typeof n=="number"&&(t.x=n),typeof r=="number"&&(t.y=r),t.moved=!0;let f=Nw(e,s);(s==="vertical"&&typeof r=="number"?u>=r:s==="horizontal"&&typeof n=="number"?c>=n:!1)&&(f=f.reverse());const p=rA(f,t),v=p.length>0;if(v&&l)return JD(e);if(v&&i)return"Collision prevented on ".concat(t.i,", reverting."),t.x=c,t.y=u,t.moved=!1,e;for(let b=0,w=p.length;b<w;b++){const y=p[b];"Resolving collision between ".concat(t.i," at [").concat(t.x,",").concat(t.y,"] and ").concat(y.i," at [").concat(y.x,",").concat(y.y,"]"),!y.moved&&(y.static?e=Ox(e,y,t,o,s):e=Ox(e,t,y,o,s))}return e}function Ox(e,t,n,r,o,i){const s=o==="horizontal",a=o==="vertical",l=t.static;if(r){r=!1;const f={x:s?Math.max(t.x-n.w,0):n.x,y:a?Math.max(t.y-n.h,0):n.y,w:n.w,h:n.h,i:"-1"},h=Xa(e,f),p=h&&h.y+h.h>t.y,v=h&&t.x+t.w>h.x;if(h){if(p&&a)return yd(e,n,void 0,t.y+1,r,l,o);if(p&&o==null)return t.y=n.y,n.y=n.y+n.h,e;if(v&&s)return yd(e,t,n.x,void 0,r,l,o)}else return"Doing reverse collision on ".concat(n.i," up to [").concat(f.x,",").concat(f.y,"]."),yd(e,n,s?f.x:void 0,a?f.y:void 0,r,l,o)}const c=s?n.x+1:void 0,u=a?n.y+1:void 0;return c==null&&u==null?e:yd(e,n,s?n.x+1:void 0,a?n.y+1:void 0,r,l,o)}function hW(e){return e*100+"%"}const oA=(e,t,n,r)=>e+n>r?t:n,iA=(e,t,n)=>e<0?t:n,sA=e=>Math.max(0,e),Dw=e=>Math.max(0,e),Aw=(e,t,n)=>{let{left:r,height:o,width:i}=t;const s=e.top-(o-e.height);return{left:r,width:i,height:iA(s,e.height,o),top:Dw(s)}},kw=(e,t,n)=>{let{top:r,left:o,height:i,width:s}=t;return{top:r,height:i,width:oA(e.left,e.width,s,n),left:sA(o)}},Mw=(e,t,n)=>{let{top:r,height:o,width:i}=t;const s=e.left-(i-e.width);return{height:o,width:s<0?e.width:oA(e.left,e.width,i,n),top:Dw(r),left:sA(s)}},Iw=(e,t,n)=>{let{top:r,left:o,height:i,width:s}=t;return{width:s,left:o,height:iA(r,e.height,i),top:Dw(r)}},pW=function(){return Aw(arguments.length<=0?void 0:arguments[0],kw(...arguments))},gW=function(){return Aw(arguments.length<=0?void 0:arguments[0],Mw(...arguments))},mW=function(){return Iw(arguments.length<=0?void 0:arguments[0],kw(...arguments))},vW=function(){return Iw(arguments.length<=0?void 0:arguments[0],Mw(...arguments))},bW={n:Aw,ne:pW,e:kw,se:mW,s:Iw,sw:vW,w:Mw,nw:gW};function yW(e,t,n,r){const o=bW[e];return o?o(t,{...t,...n},r):n}function xW(e){let{top:t,left:n,width:r,height:o}=e;const i="translate(".concat(n,"px,").concat(t,"px)");return{transform:i,WebkitTransform:i,MozTransform:i,msTransform:i,OTransform:i,width:"".concat(r,"px"),height:"".concat(o,"px"),position:"absolute"}}function wW(e){let{top:t,left:n,width:r,height:o}=e;return{top:"".concat(t,"px"),left:"".concat(n,"px"),width:"".concat(r,"px"),height:"".concat(o,"px"),position:"absolute"}}function Nw(e,t){return t==="horizontal"?lA(e):t==="vertical"?aA(e):e}function aA(e){return e.slice(0).sort(function(t,n){return t.y>n.y||t.y===n.y&&t.x>n.x?1:t.y===n.y&&t.x===n.x?0:-1})}function lA(e){return e.slice(0).sort(function(t,n){return t.x>n.x||t.x===n.x&&t.y>n.y?1:-1})}function _W(e,t,n,r,o){e=e||[];const i=[];bd.default.Children.forEach(t,a=>{if((a==null?void 0:a.key)==null)return;const l=$w(e,String(a.key)),c=a.props["data-grid"];l&&c==null?i.push(cl(l)):c?(aW||cA([c],"ReactGridLayout.children"),i.push(cl({...c,i:a.key}))):i.push(cl({w:1,h:1,x:0,y:Ow(i),i:String(a.key)}))});const s=nA(i,{cols:n});return o?s:eA(s,r,n)}function cA(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Layout";const n=["x","y","w","h"];if(!Array.isArray(e))throw new Error(t+" must be an array!");for(let r=0,o=e.length;r<o;r++){const i=e[r];for(let s=0;s<n.length;s++)if(typeof i[n[s]]!="number")throw new Error("ReactGridLayout: "+t+"["+r+"]."+n[s]+" must be a number!")}}function SW(e){const{verticalCompact:t,compactType:n}=e||{};return t===!1?null:n}const CW=()=>{};Ot.noop=CW;var Di={};Object.defineProperty(Di,"__esModule",{value:!0});Di.calcGridColWidth=jm;Di.calcGridItemPosition=EW;Di.calcGridItemWHPx=$x;Di.calcWH=PW;Di.calcXY=RW;Di.clamp=Qa;function jm(e){const{margin:t,containerPadding:n,containerWidth:r,cols:o}=e;return(r-t[0]*(o-1)-n[0]*2)/o}function $x(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function EW(e,t,n,r,o,i){const{margin:s,containerPadding:a,rowHeight:l}=e,c=jm(e),u={};return i&&i.resizing?(u.width=Math.round(i.resizing.width),u.height=Math.round(i.resizing.height)):(u.width=$x(r,c,s[0]),u.height=$x(o,l,s[1])),i&&i.dragging?(u.top=Math.round(i.dragging.top),u.left=Math.round(i.dragging.left)):i&&i.resizing&&typeof i.resizing.top=="number"&&typeof i.resizing.left=="number"?(u.top=Math.round(i.resizing.top),u.left=Math.round(i.resizing.left)):(u.top=Math.round((l+s[1])*n+a[1]),u.left=Math.round((c+s[0])*t+a[0])),u}function RW(e,t,n,r,o){const{margin:i,cols:s,rowHeight:a,maxRows:l}=e,c=jm(e);let u=Math.round((n-i[0])/(c+i[0])),f=Math.round((t-i[1])/(a+i[1]));return u=Qa(u,0,s-r),f=Qa(f,0,l-o),{x:u,y:f}}function PW(e,t,n,r,o,i){const{margin:s,maxRows:a,cols:l,rowHeight:c}=e,u=jm(e);let f=Math.round((t+s[0])/(u+s[0])),h=Math.round((n+s[1])/(c+s[1])),p=Qa(f,0,l-r),v=Qa(h,0,a-o);return["sw","w","nw"].indexOf(i)!==-1&&(p=Qa(f,0,l)),["nw","n","ne"].indexOf(i)!==-1&&(v=Qa(h,0,a)),{w:p,h:v}}function Qa(e,t,n){return Math.max(Math.min(e,n),t)}var zm={},Tx={exports:{}},d0,dP;function Lw(){if(dP)return d0;dP=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return d0=e,d0}var f0,fP;function OW(){if(fP)return f0;fP=1;var e=Lw();function t(){}function n(){}return n.resetWarningCache=t,f0=function(){function r(s,a,l,c,u,f){if(f!==e){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}r.isRequired=r;function o(){return r}var i={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return i.PropTypes=i,i},f0}var gp={exports:{}},qt={};/** @license React v16.13.1
|
|
89
89
|
* react-is.development.js
|
|
90
90
|
*
|
|
91
91
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { J as a, ao as e, am as t, aF as c, bS as h, bT as d, bU as o, bj as y, bV as i, bW as s, a7 as n, bX as r, bY as k, bZ as p, b_ as l, Q as M, b$ as u, c0 as v, b0 as g, ah as m, c1 as x, c2 as L, be as w } from "./index-
|
|
2
|
-
import { c3 as Pv } from "./index-
|
|
3
|
-
import { B as C, C as f, a as I, b as S, d as q, e as b, f as H, h as A, i as z, j as P, E as V, k as j, l as B, m as F, G as D, H as R, n as T, o as U, K as O, p as Z, q as G, r as W, L as E, M as X, N, P as K, s as J, t as Q, v as Y, w as _, x as $, y as a1, z as e1, T as t1, A as c1, F as h1, U as d1 } from "./dashboard-plus-
|
|
1
|
+
import { J as a, ao as e, am as t, aF as c, bS as h, bT as d, bU as o, bj as y, bV as i, bW as s, a7 as n, bX as r, bY as k, bZ as p, b_ as l, Q as M, b$ as u, c0 as v, b0 as g, ah as m, c1 as x, c2 as L, be as w } from "./index-6kxWR20D.js";
|
|
2
|
+
import { c3 as Pv } from "./index-6kxWR20D.js";
|
|
3
|
+
import { B as C, C as f, a as I, b as S, d as q, e as b, f as H, h as A, i as z, j as P, E as V, k as j, l as B, m as F, G as D, H as R, n as T, o as U, K as O, p as Z, q as G, r as W, L as E, M as X, N, P as K, s as J, t as Q, v as Y, w as _, x as $, y as a1, z as e1, T as t1, A as c1, F as h1, U as d1 } from "./dashboard-plus-5OdRvE8M.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "react-dom";
|
|
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-cwCVAphZ.js"),a=require("./dashboard-plus-gEOVHCeC.js");require("react");require("react-dom");/**
|
|
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-cwCVAphZ.js");require("react");require("react-dom");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-cwCVAphZ.js"),n=require("./chunks/dashboard-plus-gEOVHCeC.js"),_=require("react");require("react-dom");function v({card:t,footer:u,className:h,...m}){var c;const{customCards:o}=e.useSemaphorContext(),p=_.useRef(null),{isError:C,isLoading:i,isFetching:a,cfg:x,visualKey:f,handleDatapointClick:E}=e.useDashboardCard(t),l=e.useDashboardStore(s=>s.themeStyle),d=e.useDashboardStore(s=>s.selectedSheetId),j=e.useDashboardStore(s=>s.selectedCardId),D=e.useDashboardStore(s=>s.isDashboardEditing),g=((c=t.customCardPreferences)==null?void 0:c.showCardHeader)??!0,{setCardTitle:b,setCardDescription:S,setSelectedCardId:T}=e.useDashboardActions();function R(s){s.stopPropagation(),T(d,t.id)}function A(){if(o&&o.length>0){const s=o.find(r=>r.cardId===t.id);if(s&&s.replaceDefault){const r=s.content;if(r)return e.jsxRuntimeExports.jsx(r,{card:t})}}return t.type==="kpi"?t.data&&t.data.length>0&&e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:i||a,card:t}):N}function y(){if(C)return e.jsxRuntimeExports.jsx("p",{className:"text-sm",children:"Oops! It seems like something went wrong. Please review your connection or filters."});if(t.type==="table"&&t.data&&t.data.length>0)return e.jsxRuntimeExports.jsxs(e.ScrollArea,{children:[e.jsxRuntimeExports.jsx(e.TableVisual,{card:t,data:t.data}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]});if(o&&o.length>0){const s=o.find(r=>r.cardId===t.id);if(s&&s.content){const r=s.content;return e.jsxRuntimeExports.jsx(r,{card:t})}}if(x)return e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:x,onDatapointClick:E},f)}function I(){if(o&&o.length>0){const s=o.find(r=>r.cardId===t.id);if(s&&s.footer){const r=s.footer;if(r)return e.jsxRuntimeExports.jsx(r,{card:t})}}return u||null}if(!t.id)return null;const N=e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[g&&e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"pb-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:t.title,onSave:s=>b(d,t.id,s),children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:t.title})}),t.refreshInterval&&e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{className:"pr-1",children:e.jsxRuntimeExports.jsx("div",{className:e.cn("h-2 w-2 rounded-full bg-green-500 transition-opacity",{"opacity-10":i||a})})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:`Realtime (${t==null?void 0:t.refreshInterval})`})})]}),!t.refreshInterval&&(i||a)&&e.jsxRuntimeExports.jsx(n.LoaderCircle,{className:"h-4 w-4 animate-spin text-muted-foreground"})]}),e.jsxRuntimeExports.jsx(e.Editable,{text:(t==null?void 0:t.description)||"",onSave:s=>S(d,t.id,s),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",t.description]})})]}),e.jsxRuntimeExports.jsx(e.CardContent,{className:"relative flex grow flex-col overflow-auto pb-0",children:y()}),e.jsxRuntimeExports.jsx(e.CardFooter,{children:I()})]});return e.jsxRuntimeExports.jsx(e.Card,{tabIndex:-1,ref:p,role:"dashboard-card",onClick:R,className:e.cn("relative flex h-full flex-col rounded-sm",{"border-dashed border-foreground/50":j===t.id&&D},l==null?void 0:l.dashboardCard,h),...m,children:A()})}exports.BOOLEAN_DATA_TYPES=e.BOOLEAN_DATA_TYPES;exports.DATE_DATA_TYPES=e.DATE_DATA_TYPES;exports.Dashboard=e.Dashboard;exports.DashboardWC=e.DashboardWC;exports.NUMBER_DATA_TYPES=e.NUMBER_DATA_TYPES;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.TEXT_DATA_TYPES=e.TEXT_DATA_TYPES;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.isColumnInSqlGen=e.isColumnInSqlGen;exports.resolveDataType=e.resolveDataType;exports.useCard=e.useCard;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardStore=e.useDashboardStore;exports.useEditorActions=e.useEditorActions;exports.useEditorStore=e.useEditorStore;exports.SelectComponent=n.SelectComponent;exports.Surfboard=n.DashboardPlus;exports.cleanCard=n.cleanCard;exports.getDashbaordStateWithoutData=n.getDashbaordStateWithoutData;exports.useEditorAside=n.useEditorAside;exports.DashboardCard=v;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { u as P, a as F, b as o, c as k, j as s, C as R, E as h, d as L, T as q, e as B, f as C, g as H, h as Y, i as G, k as K, l as O, K as V, S as z, m as Q, n as W, o as J } from "./chunks/index-
|
|
2
|
-
import { B as re, s as oe, D as ne, q as ie, N as le, I as de, r as ue, w as ce, t as fe, y as he, x as Ce, A as me, v as xe, z as pe, F as ge, p as je, H as De, G as be } from "./chunks/index-
|
|
3
|
-
import { L as M } from "./chunks/dashboard-plus-
|
|
4
|
-
import { S as Te, D as Ee, c as Ie, g as Ae, u as ve } from "./chunks/dashboard-plus-
|
|
1
|
+
import { u as P, a as F, b as o, c as k, j as s, C as R, E as h, d as L, T as q, e as B, f as C, g as H, h as Y, i as G, k as K, l as O, K as V, S as z, m as Q, n as W, o as J } from "./chunks/index-6kxWR20D.js";
|
|
2
|
+
import { B as re, s as oe, D as ne, q as ie, N as le, I as de, r as ue, w as ce, t as fe, y as he, x as Ce, A as me, v as xe, z as pe, F as ge, p as je, H as De, G as be } from "./chunks/index-6kxWR20D.js";
|
|
3
|
+
import { L as M } from "./chunks/dashboard-plus-5OdRvE8M.js";
|
|
4
|
+
import { S as Te, D as Ee, c as Ie, g as Ae, u as ve } from "./chunks/dashboard-plus-5OdRvE8M.js";
|
|
5
5
|
import U from "react";
|
|
6
6
|
import "react-dom";
|
|
7
7
|
function se({
|
package/dist/surfboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/dashboard-plus-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/dashboard-plus-gEOVHCeC.js");require("../chunks/index-cwCVAphZ.js");require("react");require("react-dom");exports.Surfboard=r.DashboardPlus;
|
package/dist/surfboard/index.js
CHANGED