react-semaphor 0.0.42 → 0.0.45

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.
@@ -56,7 +56,7 @@ Check the top-level render call using <`+ae+">.")}return Y}}function Fa(M,Y){{if
56
56
  *
57
57
  * This source code is licensed under the MIT license found in the
58
58
  * LICENSE file in the root directory of this source tree.
59
- */var uw;function q3(){if(uw)return nm;uw=1;var e=m,t=lw();function n(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,o=e.useRef,s=e.useEffect,a=e.useMemo,l=e.useDebugValue;return nm.useSyncExternalStoreWithSelector=function(c,d,f,g,p){var v=o(null);if(v.current===null){var y={hasValue:!1,value:null};v.current=y}else y=v.current;v=a(function(){function w(k){if(!S){if(S=!0,C=k,k=g(k),p!==void 0&&y.hasValue){var A=y.value;if(p(A,k))return P=A}return P=k}if(A=P,r(C,k))return A;var L=g(k);return p!==void 0&&p(A,L)?A:(C=k,P=L)}var S=!1,C,P,O=f===void 0?null:f;return[function(){return w(d())},O===null?void 0:function(){return w(O())}]},[d,f,g,p]);var x=i(c,v[0],v[1]);return s(function(){y.hasValue=!0,y.value=x},[x]),l(x),x},nm}process.env.NODE_ENV==="production"?Zg.exports=q3():Zg.exports=W3();var U3=Zg.exports;const G3=Pc(U3);var dw={VITE_SEMAPHOR_API:"https://semaphor.cloud/api/v1",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{useDebugValue:Y3}=m,{useSyncExternalStoreWithSelector:K3}=G3;let fw=!1;function X3(e,t=e.getState,n){(dw?"production":void 0)!=="production"&&n&&!fw&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),fw=!0);const r=K3(e.subscribe,e.getState,e.getServerState||e.getState,t,n);return Y3(r),r}const hw=e=>{(dw?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?B3(e):e,n=(r,i)=>X3(t,r,i);return Object.assign(n,t),n},pw=e=>e?hw(e):hw;var gw=Symbol.for("immer-nothing"),mw=Symbol.for("immer-draftable"),wr=Symbol.for("immer-state"),Q3=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function ir(e,...t){if(process.env.NODE_ENV!=="production"){const n=Q3[e],r=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var tl=Object.getPrototypeOf;function nl(e){return!!e&&!!e[wr]}function As(e){var t;return e?vw(e)||Array.isArray(e)||!!e[mw]||!!((t=e.constructor)!=null&&t[mw])||Xd(e)||Qd(e):!1}var Z3=Object.prototype.constructor.toString();function vw(e){if(!e||typeof e!="object")return!1;const t=tl(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===Z3}function Ac(e,t){Kd(e)===0?Object.entries(e).forEach(([n,r])=>{t(n,r,e)}):e.forEach((n,r)=>t(r,n,e))}function Kd(e){const t=e[wr];return t?t.type_:Array.isArray(e)?1:Xd(e)?2:Qd(e)?3:0}function rm(e,t){return Kd(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function bw(e,t,n){const r=Kd(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function J3(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Xd(e){return e instanceof Map}function Qd(e){return e instanceof Set}function Is(e){return e.copy_||e.base_}function im(e,t){if(Xd(e))return new Map(e);if(Qd(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&vw(e))return tl(e)?{...e}:Object.assign(Object.create(null),e);const n=Object.getOwnPropertyDescriptors(e);delete n[wr];let r=Reflect.ownKeys(n);for(let i=0;i<r.length;i++){const o=r[i],s=n[o];s.writable===!1&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(n[o]={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[o]})}return Object.create(tl(e),n)}function om(e,t=!1){return Zd(e)||nl(e)||!As(e)||(Kd(e)>1&&(e.set=e.add=e.clear=e.delete=eN),Object.freeze(e),t&&Ac(e,(n,r)=>om(r,!0))),e}function eN(){ir(2)}function Zd(e){return Object.isFrozen(e)}var tN={};function Ns(e){const t=tN[e];return t||ir(0,e),t}var Ic;function yw(){return Ic}function nN(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function xw(e,t){t&&(Ns("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function sm(e){am(e),e.drafts_.forEach(rN),e.drafts_=null}function am(e){e===Ic&&(Ic=e.parent_)}function ww(e){return Ic=nN(Ic,e)}function rN(e){const t=e[wr];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function _w(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[wr].modified_&&(sm(t),ir(4)),As(e)&&(e=Jd(t,e),t.parent_||ef(t,e)),t.patches_&&Ns("Patches").generateReplacementPatches_(n[wr].base_,e,t.patches_,t.inversePatches_)):e=Jd(t,n,[]),sm(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==gw?e:void 0}function Jd(e,t,n){if(Zd(t))return t;const r=t[wr];if(!r)return Ac(t,(i,o)=>Sw(e,r,t,i,o,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return ef(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const i=r.copy_;let o=i,s=!1;r.type_===3&&(o=new Set(i),i.clear(),s=!0),Ac(o,(a,l)=>Sw(e,r,i,a,l,n,s)),ef(e,i,!1),n&&e.patches_&&Ns("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function Sw(e,t,n,r,i,o,s){if(process.env.NODE_ENV!=="production"&&i===n&&ir(5),nl(i)){const a=o&&t&&t.type_!==3&&!rm(t.assigned_,r)?o.concat(r):void 0,l=Jd(e,i,a);if(bw(n,r,l),nl(l))e.canAutoFreeze_=!1;else return}else s&&n.add(i);if(As(i)&&!Zd(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Jd(e,i),(!t||!t.scope_.parent_)&&ef(e,i)}}function ef(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&om(t,n)}function iN(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:yw(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,o=lm;n&&(i=[r],o=Nc);const{revoke:s,proxy:a}=Proxy.revocable(i,o);return r.draft_=a,r.revoke_=s,a}var lm={get(e,t){if(t===wr)return e;const n=Is(e);if(!rm(n,t))return oN(e,n,t);const r=n[t];return e.finalized_||!As(r)?r:r===cm(e.base_,t)?(dm(e),e.copy_[t]=fm(r,e)):r},has(e,t){return t in Is(e)},ownKeys(e){return Reflect.ownKeys(Is(e))},set(e,t,n){const r=Cw(Is(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=cm(Is(e),t),o=i==null?void 0:i[wr];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(J3(n,i)&&(n!==void 0||rm(e.base_,t)))return!0;dm(e),um(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return cm(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,dm(e),um(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Is(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){ir(11)},getPrototypeOf(e){return tl(e.base_)},setPrototypeOf(){ir(12)}},Nc={};Ac(lm,(e,t)=>{Nc[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),Nc.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&ir(13),Nc.set.call(this,e,t,void 0)},Nc.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&ir(14),lm.set.call(this,e[0],t,n,e[0])};function cm(e,t){const n=e[wr];return(n?Is(n):e)[t]}function oN(e,t,n){var i;const r=Cw(t,n);return r?"value"in r?r.value:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function Cw(e,t){if(!(t in e))return;let n=tl(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=tl(n)}}function um(e){e.modified_||(e.modified_=!0,e.parent_&&um(e.parent_))}function dm(e){e.copy_||(e.copy_=im(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var sN=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const o=n;n=t;const s=this;return function(l=o,...c){return s.produce(l,d=>n.call(this,d,...c))}}typeof n!="function"&&ir(6),r!==void 0&&typeof r!="function"&&ir(7);let i;if(As(t)){const o=ww(this),s=fm(t,void 0);let a=!0;try{i=n(s),a=!1}finally{a?sm(o):am(o)}return xw(o,r),_w(i,o)}else if(!t||typeof t!="object"){if(i=n(t),i===void 0&&(i=t),i===gw&&(i=void 0),this.autoFreeze_&&om(i,!0),r){const o=[],s=[];Ns("Patches").generateReplacementPatches_(t,i,o,s),r(o,s)}return i}else ir(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...a)=>this.produceWithPatches(s,l=>t(l,...a));let r,i;return[this.produce(t,n,(s,a)=>{r=s,i=a}),r,i]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){As(e)||ir(8),nl(e)&&(e=aN(e));const t=ww(this),n=fm(e,void 0);return n[wr].isManual_=!0,am(t),n}finishDraft(e,t){const n=e&&e[wr];(!n||!n.isManual_)&&ir(9);const{scope_:r}=n;return xw(r,t),_w(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=Ns("Patches").applyPatches_;return nl(e)?r(e,t):this.produce(e,i=>r(i,t))}};function fm(e,t){const n=Xd(e)?Ns("MapSet").proxyMap_(e,t):Qd(e)?Ns("MapSet").proxySet_(e,t):iN(e,t);return(t?t.scope_:yw()).drafts_.push(n),n}function aN(e){return nl(e)||ir(10,e),Ew(e)}function Ew(e){if(!As(e)||Zd(e))return e;const t=e[wr];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=im(e,t.scope_.immer_.useStrictShallowCopy_)}else n=im(e,!0);return Ac(n,(r,i)=>{bw(n,r,Ew(i))}),t&&(t.finalized_=!1),n}var _r=new sN,lN=_r.produce;_r.produceWithPatches.bind(_r),_r.setAutoFreeze.bind(_r),_r.setUseStrictShallowCopy.bind(_r),_r.applyPatches.bind(_r),_r.createDraft.bind(_r),_r.finishDraft.bind(_r);const Ow=e=>(t,n,r)=>(r.setState=(i,o,...s)=>{const a=typeof i=="function"?lN(i):i;return t(a,o,...s)},e(r.setState,n,r));var tf,nf=kt;if(process.env.NODE_ENV==="production")tf=nf.createRoot,nf.hydrateRoot;else{var Pw=nf.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;tf=function(e,t){Pw.usingClientEntryPoint=!0;try{return nf.createRoot(e,t)}finally{Pw.usingClientEntryPoint=!1}}}function kw(e,t,n){const r={count:0},i=a=>{const l=m.useRef(r.count);return m.useEffect(()=>{l.current+=1,l.current===r.count+1&&(l.current-=1,t.setState(a))}),null};if(i.displayName=`((${e})) devtool`,typeof document>"u")return;if(!n){let a=document.getElementById(`simple-zustand-devtools-${e}`);a||(a=document.createElement("div"),a.id=`simple-zustand-devtools-${e}`),document.body.appendChild(a),n=a}const o=tf(n),s=a=>{a&&(o.render(m.createElement(i,Object.assign({},a))),r.count+=1)};s(t.getState()),t.subscribe(s)}var Mw={},Dw={},hm={exports:{}},Gt=String,Tw=function(){return{isColorSupported:!1,reset:Gt,bold:Gt,dim:Gt,italic:Gt,underline:Gt,inverse:Gt,hidden:Gt,strikethrough:Gt,black:Gt,red:Gt,green:Gt,yellow:Gt,blue:Gt,magenta:Gt,cyan:Gt,white:Gt,gray:Gt,bgBlack:Gt,bgRed:Gt,bgGreen:Gt,bgYellow:Gt,bgBlue:Gt,bgMagenta:Gt,bgCyan:Gt,bgWhite:Gt}};hm.exports=Tw(),hm.exports.createColors=Tw;var cN=hm.exports;(function(e){Object.defineProperty(e,"__esModule",{value:!0});function t(l,c){for(var d in c)Object.defineProperty(l,d,{enumerable:!0,get:c[d]})}t(e,{dim:function(){return s},default:function(){return a}});const n=r(cN);function r(l){return l&&l.__esModule?l:{default:l}}let i=new Set;function o(l,c,d){typeof process<"u"&&process.env.JEST_WORKER_ID||d&&i.has(d)||(d&&i.add(d),console.warn(""),c.forEach(f=>console.warn(l,"-",f)))}function s(l){return n.default.dim(l)}const a={info(l,c){o(n.default.bold(n.default.cyan("info")),...Array.isArray(l)?[l]:[c,l])},warn(l,c){o(n.default.bold(n.default.yellow("warn")),...Array.isArray(l)?[l]:[c,l])},risk(l,c){o(n.default.bold(n.default.magenta("risk")),...Array.isArray(l)?[l]:[c,l])}}})(Dw),function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const t=n(Dw);function n(o){return o&&o.__esModule?o:{default:o}}function r({version:o,from:s,to:a}){t.default.warn(`${s}-color-renamed`,[`As of Tailwind CSS ${o}, \`${s}\` has been renamed to \`${a}\`.`,"Update your configuration file to silence this warning."])}const i={inherit:"inherit",current:"currentColor",transparent:"transparent",black:"#000",white:"#fff",slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"},get lightBlue(){return r({version:"v2.2",from:"lightBlue",to:"sky"}),this.sky},get warmGray(){return r({version:"v3.0",from:"warmGray",to:"stone"}),this.stone},get trueGray(){return r({version:"v3.0",from:"trueGray",to:"neutral"}),this.neutral},get coolGray(){return r({version:"v3.0",from:"coolGray",to:"gray"}),this.gray},get blueGray(){return r({version:"v3.0",from:"blueGray",to:"slate"}),this.slate}}}(Mw);let pm=Mw;var uN=(pm.__esModule?pm:{default:pm}).default;const an=Pc(uN),gm={default:{dashboardPanel:"",dashboardTabsContainer:"",gridLayout:{className:""},chart:{font:{family:"Open Sans, sans-serif"},dataset:{backgroundColor:[an.violet[400],an.red[400],an.amber[400],an.orange[400],an.rose[400]],borderColor:[an.violet[400],an.red[400],an.amber[400],an.orange[400],an.rose[400]]},options:{plugins:{datalabels:{display:!1,color:dN},title:{display:!0},tooltip:{backgroundColor:"#fff",bodyColor:"#000",borderWidth:.25,titleColor:"#000",borderColor:"rgb(128,131,139)",cornerRadius:2,boxPadding:4},legend:{position:"top",align:"center",maxHeight:0}},scales:{y:{grid:{display:!0},title:{display:!0,text:""},beginAtZero:!0,ticks:{precision:0}},x:{grid:{display:!0},title:{display:!0}}},layout:{padding:{top:-40}},borderRadius:1,responsive:!0,maintainAspectRatio:!1}}},dark:{chart:{dataset:{backgroundColor:[an.teal[100],an.purple[100],an.amber[100],an.orange[100],an.rose[100]],borderColor:[an.teal[400],an.purple[400],an.amber[400],an.orange[300],an.rose[400]]},options:{plugins:{tooltip:{backgroundColor:"#000",bodyColor:"#fff",borderWidth:.25,titleColor:"#fff",borderColor:"rgb(128,131,139)",cornerRadius:2,boxPadding:4}},datalabels:{display:!1},scales:{x:{grid:{display:!0,color:an.slate[800]}},y:{grid:{display:!0,color:an.slate[800]}}}}}}};function dN(e){var r,i,o,s,a,l;const t=(a=(s=(o=(i=(r=e==null?void 0:e.chart)==null?void 0:r.config)==null?void 0:i._config)==null?void 0:o.options)==null?void 0:s.plugins)==null?void 0:a.datalabels;let n=(l=e==null?void 0:e.dataset)==null?void 0:l.backgroundColor;return(t==null?void 0:t.align)==="end"&&(t==null?void 0:t.anchor)==="end"&&(n=Aw()),(t==null?void 0:t.align)==="start"&&(t==null?void 0:t.anchor)==="start"&&(n=Aw()),fN(n)}function Aw(){return be.getState().theme==="dark"?"#000000":"#FFFFFF"}function fN(e){let t=0,n=0,r=0,i=0;const o=d=>{const f=d.replace("#",""),g=parseInt(f.substring(0,2),16),p=parseInt(f.substring(2,4),16),v=parseInt(f.substring(4,6),16);t+=g,n+=p,r+=v,i++};Array.isArray(e)?e.forEach(d=>{o(d)}):o(e);const s=t/i,a=n/i,l=r/i;return(s*299+a*587+l*114)/1e3>=180?"black":"white"}const be=pw()(Ow((e,t)=>({dashboard:{id:"",style:gm},selectedSheetId:null,selectedCardId:null,selectedCard:null,showFilters:!1,isDashboardEditing:!0,isVisualEditing:!1,showDashboardJSON:!1,isEditorSaveEvent:!1,actions:{setAuthToken:n=>{e(()=>({authToken:n}))},setThemeStyle:n=>{e(()=>({themeStyle:n}))},setIsEditorSaveEvent:n=>{e(()=>({isEditorSaveEvent:n}))},setDashboard:n=>e({dashboard:n}),setBookmarkKey:n=>{e(()=>({bookmarkKey:n}))},setDashboardTheme:n=>{e(r=>{r.theme=n})},setDashboardTitle:n=>{e(r=>{r.dashboard&&(r.dashboard.title=n)})},setDashboardDescription:n=>{e(r=>{r.dashboard&&(r.dashboard.description=n)})},setSheets:n=>{e(r=>{r.dashboard&&(r.dashboard.sheets=n)})},setSheetTitle:(n,r)=>{e(i=>{var s,a;const o=(a=(s=i.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);o&&(o.title=r)})},setSheetDescription:(n,r)=>{e(i=>{var s,a;const o=(a=(s=i.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);o&&(o.description=r)})},setCards:(n,r)=>{e(i=>{var s,a;const o=(a=(s=i.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);o&&(o.cards=r)})},setCardTitle:(n,r,i)=>{e(o=>{var a,l,c,d;const s=(l=(a=o.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(g=>g.id===r);f&&(f.title=i,(d=o.onUpdateCard)==null||d.call(o,f,n))}})},setCardSql:(n,r,i)=>{e(o=>{var a,l,c,d;const s=(l=(a=o.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(g=>g.id===r);f&&(f.sql=i,(d=o.onUpdateCard)==null||d.call(o,f,n))}})},setCardData:(n,r,i)=>{e(o=>{var a,l,c,d;const s=(l=(a=o.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(g=>g.id===r);f&&(f.data=i,(d=o.onUpdateCard)==null||d.call(o,f,n))}})},setCardDescription:(n,r,i)=>{e(o=>{var a,l,c,d;const s=(l=(a=o.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(g=>g.id===r);f&&(f.description=i,(d=o.onUpdateCard)==null||d.call(o,f,n))}})},setSheetLayout:(n,r)=>{e(i=>{var s,a;const o=(a=(s=i.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);o&&(o.layout=r)})},setShowFilters:n=>{e(()=>({showFilters:n}))},addOrUpdateFilterValue:n=>{e(r=>{if(r.filterValues){const i=r.filterValues.findIndex(o=>o.filterId===n.filterId);i>-1?r.filterValues.splice(i,1,n):r.filterValues.push(n)}else r.filterValues=[n]})},removeFilterValue:n=>{e(r=>{if(r.filterValues){const i=r.filterValues.findIndex(o=>o.filterId===n);i>-1&&r.filterValues.splice(i,1)}})},addFilter:n=>{e(r=>{var i;r.dashboard.filters?(i=r.dashboard.filters)==null||i.push(n):r.dashboard.filters=[n]})},removeFilter:n=>{e(r=>{var i,o;if(r.dashboard.filters){const s=(i=r.dashboard.filters)==null?void 0:i.findIndex(a=>a.id===n);console.log("index",s),s>-1&&((o=r.dashboard.filters)==null||o.splice(s,1))}})},updateFilter:n=>{e(r=>{var i,o;if(r.dashboard.filters){const s=(i=r.dashboard.filters)==null?void 0:i.findIndex(a=>a.id===n.id);s>-1&&((o=r.dashboard.filters)==null||o.splice(s,1,n))}})},setIsDashboardEditing:n=>{e(()=>({isDashboardEditing:n}))},setShowDashboardJSON:n=>{e(()=>({showDashboardJSON:n}))},setIsVisualEditing:n=>{e(()=>({isVisualEditing:n}))},addCard:(n,r)=>{e(i=>{var s,a,l,c,d;const o=(a=(s=i.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(f=>f.id===n);if(o){(l=o.cards)==null||l.push(r);const f={i:r.id,x:0,y:1/0,w:20,h:7,minW:10};(c=o.layout)==null||c.push(f),(d=i.onAddCard)==null||d.call(i,r,n)}})},updateCard:(n,r)=>{e(i=>{var a,l,c,d,f;const o=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(g=>g.id===n),s=(c=o==null?void 0:o.cards)==null?void 0:c.findIndex(g=>g.id===r.id);o&&((d=o.cards)==null||d.splice(s,1,r),(f=i.onUpdateCard)==null||f.call(i,r,n))})},removeCard:(n,r)=>{e(i=>{var a,l,c,d,f,g;const o=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(p=>p.id===n),s=(c=o==null?void 0:o.cards)==null?void 0:c.findIndex(p=>p.id===r.id);o&&((d=o.cards)==null||d.splice(s,1),(f=o.layout)==null||f.splice(s,1),(g=i.onRemoveCard)==null||g.call(i,r,n))})},setStyle:n=>{e(r=>{r.dashboard&&(r.dashboard.style=n)})},setSelectedCardId:(n,r)=>{e(i=>{var s,a,l;const o=(a=(s=i.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(c=>c.id===n);o&&(((l=o.cards)==null?void 0:l.find(d=>d.id===r))?i.selectedCardId=r:i.selectedCardId=null)})},setSelectedCard:n=>{e(r=>{r.selectedCard=n})},setSelectedSheetId:n=>{e(r=>{var o,s;((s=(o=r.dashboard)==null?void 0:o.sheets)==null?void 0:s.find(a=>a.id===n))&&(r.selectedSheetId=n)})},setOnSaveFunction:n=>{e(()=>({onSaveFunction:n}))},setOnAddCard:n=>{e(()=>({onAddCard: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(i=>i.id===t().selectedSheetId)},getSelectedCard:()=>{var r,i,o;const n=(i=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:i.find(s=>s.id===t().selectedSheetId);return(o=n==null?void 0:n.cards)==null?void 0:o.find(s=>s.id===t().selectedCardId)},getSelectedSheetCards:()=>{var r,i;const n=(i=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:i.find(o=>o.id===t().selectedSheetId);return n==null?void 0:n.cards},getSelectedSheetLayout:()=>{var r,i;const n=(i=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:i.find(o=>o.id===t().selectedSheetId);return n==null?void 0:n.layout},getStyle:()=>{var n;return(n=t().dashboard)==null?void 0:n.style}}})));process.env.NODE_ENV==="development"&&kw("DashboardStore",be);var Rc=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(){}},rl=typeof window>"u"||"Deno"in window;function Kr(){}function hN(e,t){return typeof e=="function"?e(t):e}function mm(e){return typeof e=="number"&&e>=0&&e!==1/0}function Iw(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Nw(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:o,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==vm(s,t.options))return!1}else if(!$c(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 i<"u"&&i!==t.state.fetchStatus||o&&!o(t))}function Rw(e,t){const{exact:n,status:r,predicate:i,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(Lc(t.options.mutationKey)!==Lc(o))return!1}else if(!$c(t.options.mutationKey,o))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function vm(e,t){return((t==null?void 0:t.queryKeyHashFn)||Lc)(e)}function Lc(e){return JSON.stringify(e,(t,n)=>ym(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function $c(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!$c(e[n],t[n])):!1}function Lw(e,t){if(e===t)return e;const n=$w(e)&&$w(t);if(n||ym(e)&&ym(t)){const r=n?e:Object.keys(e),i=r.length,o=n?t:Object.keys(t),s=o.length,a=n?[]:{};let l=0;for(let c=0;c<s;c++){const d=n?c:o[c];!n&&e[d]===void 0&&t[d]===void 0&&r.includes(d)?(a[d]=void 0,l++):(a[d]=Lw(e[d],t[d]),a[d]===e[d]&&e[d]!==void 0&&l++)}return i===s&&l===i?e:a}return t}function bm(e,t){if(e&&!t||t&&!e)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function $w(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ym(e){if(!Fw(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const n=t.prototype;return!(!Fw(n)||!n.hasOwnProperty("isPrototypeOf"))}function Fw(e){return Object.prototype.toString.call(e)==="[object Object]"}function pN(e){return new Promise(t=>{setTimeout(t,e)})}function xm(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Lw(e,t):t}function gN(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function mN(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var vN=(_A=class extends Rc{constructor(){super();ze(this,Oa,void 0);ze(this,fs,void 0);ze(this,Ql,void 0);Ie(this,Ql,t=>{if(!rl&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){Z(this,fs)||this.setEventListener(Z(this,Ql))}onUnsubscribe(){var t;this.hasListeners()||((t=Z(this,fs))==null||t.call(this),Ie(this,fs,void 0))}setEventListener(t){var n;Ie(this,Ql,t),(n=Z(this,fs))==null||n.call(this),Ie(this,fs,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){Z(this,Oa)!==t&&(Ie(this,Oa,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof Z(this,Oa)=="boolean"?Z(this,Oa):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Oa=new WeakMap,fs=new WeakMap,Ql=new WeakMap,_A),rf=new vN,bN=(SA=class extends Rc{constructor(){super();ze(this,Zl,!0);ze(this,hs,void 0);ze(this,Jl,void 0);Ie(this,Jl,t=>{if(!rl&&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(){Z(this,hs)||this.setEventListener(Z(this,Jl))}onUnsubscribe(){var t;this.hasListeners()||((t=Z(this,hs))==null||t.call(this),Ie(this,hs,void 0))}setEventListener(t){var n;Ie(this,Jl,t),(n=Z(this,hs))==null||n.call(this),Ie(this,hs,t(this.setOnline.bind(this)))}setOnline(t){Z(this,Zl)!==t&&(Ie(this,Zl,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return Z(this,Zl)}},Zl=new WeakMap,hs=new WeakMap,Jl=new WeakMap,SA),of=new bN;function yN(e){return Math.min(1e3*2**e,3e4)}function sf(e){return(e??"online")==="online"?of.isOnline():!0}var jw=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function wm(e){return e instanceof jw}function zw(e){let t=!1,n=0,r=!1,i,o,s;const a=new Promise((x,w)=>{o=x,s=w}),l=x=>{var w;r||(p(new jw(x)),(w=e.abort)==null||w.call(e))},c=()=>{t=!0},d=()=>{t=!1},f=()=>!rf.isFocused()||e.networkMode!=="always"&&!of.isOnline(),g=x=>{var w;r||(r=!0,(w=e.onSuccess)==null||w.call(e,x),i==null||i(),o(x))},p=x=>{var w;r||(r=!0,(w=e.onError)==null||w.call(e,x),i==null||i(),s(x))},v=()=>new Promise(x=>{var w;i=S=>{const C=r||!f();return C&&x(S),C},(w=e.onPause)==null||w.call(e)}).then(()=>{var x;i=void 0,r||(x=e.onContinue)==null||x.call(e)}),y=()=>{if(r)return;let x;try{x=e.fn()}catch(w){x=Promise.reject(w)}Promise.resolve(x).then(g).catch(w=>{var k;if(r)return;const S=e.retry??(rl?0:3),C=e.retryDelay??yN,P=typeof C=="function"?C(n,w):C,O=S===!0||typeof S=="number"&&n<S||typeof S=="function"&&S(n,w);if(t||!O){p(w);return}n++,(k=e.onFail)==null||k.call(e,n,w),pN(P).then(()=>{if(f())return v()}).then(()=>{t?p(w):y()})})};return sf(e.networkMode)?y():v().then(y),{promise:a,cancel:l,continue:()=>(i==null?void 0:i())?a:Promise.resolve(),cancelRetry:c,continueRetry:d}}function xN(){let e=[],t=0,n=g=>{g()},r=g=>{g()},i=g=>setTimeout(g,0);const o=g=>{i=g},s=g=>{let p;t++;try{p=g()}finally{t--,t||c()}return p},a=g=>{t?e.push(g):i(()=>{n(g)})},l=g=>(...p)=>{a(()=>{g(...p)})},c=()=>{const g=e;e=[],g.length&&i(()=>{r(()=>{g.forEach(p=>{n(p)})})})};return{batch:s,batchCalls:l,schedule:a,setNotifyFunction:g=>{n=g},setBatchNotifyFunction:g=>{r=g},setScheduler:o}}var In=xN(),Bw=(CA=class{constructor(){ze(this,Pa,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),mm(this.gcTime)&&Ie(this,Pa,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(rl?1/0:5*60*1e3))}clearGcTimeout(){Z(this,Pa)&&(clearTimeout(Z(this,Pa)),Ie(this,Pa,void 0))}},Pa=new WeakMap,CA),wN=(EA=class extends Bw{constructor(t){super();ze(this,nc);ze(this,Si);ze(this,ec,void 0);ze(this,tc,void 0);ze(this,ri,void 0);ze(this,ps,void 0);ze(this,ii,void 0);ze(this,Mn,void 0);ze(this,fd,void 0);ze(this,ka,void 0);Ie(this,ka,!1),Ie(this,fd,t.defaultOptions),xt(this,nc,Gg).call(this,t.options),Ie(this,Mn,[]),Ie(this,ri,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,Ie(this,ec,t.state||_N(this.options)),this.state=Z(this,ec),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!Z(this,Mn).length&&this.state.fetchStatus==="idle"&&Z(this,ri).remove(this)}setData(t,n){const r=xm(this.state.data,t,this.options);return xt(this,Si,No).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){xt(this,Si,No).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r;const n=Z(this,ps);return(r=Z(this,ii))==null||r.cancel(t),n?n.then(Kr).catch(Kr):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(Z(this,ec))}isActive(){return Z(this,Mn).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||Z(this,Mn).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!Iw(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=Z(this,Mn).find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=Z(this,ii))==null||n.continue()}onOnline(){var n;const t=Z(this,Mn).find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=Z(this,ii))==null||n.continue()}addObserver(t){Z(this,Mn).includes(t)||(Z(this,Mn).push(t),this.clearGcTimeout(),Z(this,ri).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){Z(this,Mn).includes(t)&&(Ie(this,Mn,Z(this,Mn).filter(n=>n!==t)),Z(this,Mn).length||(Z(this,ii)&&(Z(this,ka)?Z(this,ii).cancel({revert:!0}):Z(this,ii).cancelRetry()),this.scheduleGc()),Z(this,ri).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return Z(this,Mn).length}invalidate(){this.state.isInvalidated||xt(this,Si,No).call(this,{type:"invalidate"})}fetch(t,n){var c,d,f,g;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(Z(this,ps))return(c=Z(this,ii))==null||c.continueRetry(),Z(this,ps)}if(t&&xt(this,nc,Gg).call(this,t),!this.options.queryFn){const p=Z(this,Mn).find(v=>v.options.queryFn);p&&xt(this,nc,Gg).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,i={queryKey:this.queryKey,meta:this.meta},o=p=>{Object.defineProperty(p,"signal",{enumerable:!0,get:()=>(Ie(this,ka,!0),r.signal)})};o(i);const s=()=>this.options.queryFn?(Ie(this,ka,!1),this.options.persister?this.options.persister(this.options.queryFn,i,this):this.options.queryFn(i)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),a={fetchOptions:n,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:s};o(a),(d=this.options.behavior)==null||d.onFetch(a,this),Ie(this,tc,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=a.fetchOptions)==null?void 0:f.meta))&&xt(this,Si,No).call(this,{type:"fetch",meta:(g=a.fetchOptions)==null?void 0:g.meta});const l=p=>{var v,y,x,w;wm(p)&&p.silent||xt(this,Si,No).call(this,{type:"error",error:p}),wm(p)||((y=(v=Z(this,ri).config).onError)==null||y.call(v,p,this),(w=(x=Z(this,ri).config).onSettled)==null||w.call(x,this.state.data,p,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return Ie(this,ii,zw({fn:a.fetchFn,abort:r.abort.bind(r),onSuccess:p=>{var v,y,x,w;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),(y=(v=Z(this,ri).config).onSuccess)==null||y.call(v,p,this),(w=(x=Z(this,ri).config).onSettled)==null||w.call(x,p,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:l,onFail:(p,v)=>{xt(this,Si,No).call(this,{type:"failed",failureCount:p,error:v})},onPause:()=>{xt(this,Si,No).call(this,{type:"pause"})},onContinue:()=>{xt(this,Si,No).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode})),Ie(this,ps,Z(this,ii).promise),Z(this,ps)}},ec=new WeakMap,tc=new WeakMap,ri=new WeakMap,ps=new WeakMap,ii=new WeakMap,Mn=new WeakMap,fd=new WeakMap,ka=new WeakMap,nc=new WeakSet,Gg=function(t){this.options={...Z(this,fd),...t},this.updateGcTime(this.options.gcTime)},Si=new WeakSet,No=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:sf(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 i=t.error;return wm(i)&&i.revert&&Z(this,tc)?{...Z(this,tc),fetchStatus:"idle"}:{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),In.batch(()=>{Z(this,Mn).forEach(r=>{r.onQueryUpdate()}),Z(this,ri).notify({query:this,type:"updated",action:t})})},EA);function _N(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 SN=(OA=class extends Rc{constructor(t={}){super();ze(this,Yi,void 0);this.config=t,Ie(this,Yi,new Map)}build(t,n,r){const i=n.queryKey,o=n.queryHash??vm(i,n);let s=this.get(o);return s||(s=new wN({cache:this,queryKey:i,queryHash:o,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(i)}),this.add(s)),s}add(t){Z(this,Yi).has(t.queryHash)||(Z(this,Yi).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=Z(this,Yi).get(t.queryHash);n&&(t.destroy(),n===t&&Z(this,Yi).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){In.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return Z(this,Yi).get(t)}getAll(){return[...Z(this,Yi).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Nw(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>Nw(t,r)):n}notify(t){In.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){In.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){In.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Yi=new WeakMap,OA),CN=(PA=class extends Bw{constructor(t){super();ze(this,Xi);ze(this,Ki,void 0);ze(this,hd,void 0);ze(this,zr,void 0);ze(this,rc,void 0);this.mutationId=t.mutationId,Ie(this,hd,t.defaultOptions),Ie(this,zr,t.mutationCache),Ie(this,Ki,[]),this.state=t.state||EN(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...Z(this,hd),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){Z(this,Ki).includes(t)||(Z(this,Ki).push(t),this.clearGcTimeout(),Z(this,zr).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){Ie(this,Ki,Z(this,Ki).filter(n=>n!==t)),this.scheduleGc(),Z(this,zr).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){Z(this,Ki).length||(this.state.status==="pending"?this.scheduleGc():Z(this,zr).remove(this))}continue(){var t;return((t=Z(this,rc))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var i,o,s,a,l,c,d,f,g,p,v,y,x,w,S,C,P,O,k,A;const n=()=>(Ie(this,rc,zw({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(L,F)=>{xt(this,Xi,ks).call(this,{type:"failed",failureCount:L,error:F})},onPause:()=>{xt(this,Xi,ks).call(this,{type:"pause"})},onContinue:()=>{xt(this,Xi,ks).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),Z(this,rc).promise),r=this.state.status==="pending";try{if(!r){xt(this,Xi,ks).call(this,{type:"pending",variables:t}),await((o=(i=Z(this,zr).config).onMutate)==null?void 0:o.call(i,t,this));const F=await((a=(s=this.options).onMutate)==null?void 0:a.call(s,t));F!==this.state.context&&xt(this,Xi,ks).call(this,{type:"pending",context:F,variables:t})}const L=await n();return await((c=(l=Z(this,zr).config).onSuccess)==null?void 0:c.call(l,L,t,this.state.context,this)),await((f=(d=this.options).onSuccess)==null?void 0:f.call(d,L,t,this.state.context)),await((p=(g=Z(this,zr).config).onSettled)==null?void 0:p.call(g,L,null,this.state.variables,this.state.context,this)),await((y=(v=this.options).onSettled)==null?void 0:y.call(v,L,null,t,this.state.context)),xt(this,Xi,ks).call(this,{type:"success",data:L}),L}catch(L){try{throw await((w=(x=Z(this,zr).config).onError)==null?void 0:w.call(x,L,t,this.state.context,this)),await((C=(S=this.options).onError)==null?void 0:C.call(S,L,t,this.state.context)),await((O=(P=Z(this,zr).config).onSettled)==null?void 0:O.call(P,void 0,L,this.state.variables,this.state.context,this)),await((A=(k=this.options).onSettled)==null?void 0:A.call(k,void 0,L,t,this.state.context)),L}finally{xt(this,Xi,ks).call(this,{type:"error",error:L})}}}},Ki=new WeakMap,hd=new WeakMap,zr=new WeakMap,rc=new WeakMap,Xi=new WeakSet,ks=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:!sf(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),In.batch(()=>{Z(this,Ki).forEach(r=>{r.onMutationUpdate(t)}),Z(this,zr).notify({mutation:this,type:"updated",action:t})})},PA);function EN(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var ON=(kA=class extends Rc{constructor(t={}){super();ze(this,oi,void 0);ze(this,pd,void 0);ze(this,Ma,void 0);this.config=t,Ie(this,oi,[]),Ie(this,pd,0)}build(t,n,r){const i=new CN({mutationCache:this,mutationId:++Ug(this,pd)._,options:t.defaultMutationOptions(n),state:r});return this.add(i),i}add(t){Z(this,oi).push(t),this.notify({type:"added",mutation:t})}remove(t){Ie(this,oi,Z(this,oi).filter(n=>n!==t)),this.notify({type:"removed",mutation:t})}clear(){In.batch(()=>{Z(this,oi).forEach(t=>{this.remove(t)})})}getAll(){return Z(this,oi)}find(t){const n={exact:!0,...t};return Z(this,oi).find(r=>Rw(n,r))}findAll(t={}){return Z(this,oi).filter(n=>Rw(t,n))}notify(t){In.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){return Ie(this,Ma,(Z(this,Ma)??Promise.resolve()).then(()=>{const t=Z(this,oi).filter(n=>n.state.isPaused);return In.batch(()=>t.reduce((n,r)=>n.then(()=>r.continue().catch(Kr)),Promise.resolve()))}).then(()=>{Ie(this,Ma,void 0)})),Z(this,Ma)}},oi=new WeakMap,pd=new WeakMap,Ma=new WeakMap,kA);function PN(e){return{onFetch:(t,n)=>{const r=async()=>{var v,y,x,w,S;const i=t.options,o=(x=(y=(v=t.fetchOptions)==null?void 0:v.meta)==null?void 0:y.fetchMore)==null?void 0:x.direction,s=((w=t.state.data)==null?void 0:w.pages)||[],a=((S=t.state.data)==null?void 0:S.pageParams)||[],l={pages:[],pageParams:[]};let c=!1;const d=C=>{Object.defineProperty(C,"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}'`))),g=async(C,P,O)=>{if(c)return Promise.reject();if(P==null&&C.pages.length)return Promise.resolve(C);const k={queryKey:t.queryKey,pageParam:P,direction:O?"backward":"forward",meta:t.options.meta};d(k);const A=await f(k),{maxPages:L}=t.options,F=O?mN:gN;return{pages:F(C.pages,A,L),pageParams:F(C.pageParams,P,L)}};let p;if(o&&s.length){const C=o==="backward",P=C?kN:Vw,O={pages:s,pageParams:a},k=P(i,O);p=await g(O,k,C)}else{p=await g(l,a[0]??i.initialPageParam);const C=e??s.length;for(let P=1;P<C;P++){const O=Vw(i,p);p=await g(p,O)}}return p};t.options.persister?t.fetchFn=()=>{var i,o;return(o=(i=t.options).persister)==null?void 0:o.call(i,r,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=r}}}function Vw(e,{pages:t,pageParams:n}){const r=t.length-1;return e.getNextPageParam(t[r],t,n[r],n)}function kN(e,{pages:t,pageParams:n}){var r;return(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n)}var MN=(MA=class{constructor(e={}){ze(this,Sn,void 0);ze(this,gs,void 0);ze(this,ms,void 0);ze(this,ic,void 0);ze(this,oc,void 0);ze(this,vs,void 0);ze(this,sc,void 0);ze(this,ac,void 0);Ie(this,Sn,e.queryCache||new SN),Ie(this,gs,e.mutationCache||new ON),Ie(this,ms,e.defaultOptions||{}),Ie(this,ic,new Map),Ie(this,oc,new Map),Ie(this,vs,0)}mount(){Ug(this,vs)._++,Z(this,vs)===1&&(Ie(this,sc,rf.subscribe(()=>{rf.isFocused()&&(this.resumePausedMutations(),Z(this,Sn).onFocus())})),Ie(this,ac,of.subscribe(()=>{of.isOnline()&&(this.resumePausedMutations(),Z(this,Sn).onOnline())})))}unmount(){var e,t;Ug(this,vs)._--,Z(this,vs)===0&&((e=Z(this,sc))==null||e.call(this),Ie(this,sc,void 0),(t=Z(this,ac))==null||t.call(this),Ie(this,ac,void 0))}isFetching(e){return Z(this,Sn).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return Z(this,gs).findAll({...e,status:"pending"}).length}getQueryData(e){var t;return(t=Z(this,Sn).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=Z(this,Sn).find({queryKey:e}),i=r==null?void 0:r.state.data,o=hN(t,i);if(typeof o>"u")return;const s=this.defaultQueryOptions({queryKey:e});return Z(this,Sn).build(this,s).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return In.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var t;return(t=Z(this,Sn).find({queryKey:e}))==null?void 0:t.state}removeQueries(e){const t=Z(this,Sn);In.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=Z(this,Sn),r={type:"active",...e};return In.batch(()=>(n.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries(r,t)))}cancelQueries(e={},t={}){const n={revert:!0,...t},r=In.batch(()=>Z(this,Sn).findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(Kr).catch(Kr)}invalidateQueries(e={},t={}){return In.batch(()=>{if(Z(this,Sn).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=In.batch(()=>Z(this,Sn).findAll(e).filter(i=>!i.isDisabled()).map(i=>{let o=i.fetch(void 0,n);return n.throwOnError||(o=o.catch(Kr)),i.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(r).then(Kr)}fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const n=Z(this,Sn).build(this,t);return n.isStaleByTime(t.staleTime)?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Kr).catch(Kr)}fetchInfiniteQuery(e){return e.behavior=PN(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Kr).catch(Kr)}resumePausedMutations(){return Z(this,gs).resumePausedMutations()}getQueryCache(){return Z(this,Sn)}getMutationCache(){return Z(this,gs)}getDefaultOptions(){return Z(this,ms)}setDefaultOptions(e){Ie(this,ms,e)}setQueryDefaults(e,t){Z(this,ic).set(Lc(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...Z(this,ic).values()];let n={};return t.forEach(r=>{$c(e,r.queryKey)&&(n={...n,...r.defaultOptions})}),n}setMutationDefaults(e,t){Z(this,oc).set(Lc(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...Z(this,oc).values()];let n={};return t.forEach(r=>{$c(e,r.mutationKey)&&(n={...n,...r.defaultOptions})}),n}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...Z(this,ms).queries,...(e==null?void 0:e.queryKey)&&this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=vm(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:{...Z(this,ms).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){Z(this,Sn).clear(),Z(this,gs).clear()}},Sn=new WeakMap,gs=new WeakMap,ms=new WeakMap,ic=new WeakMap,oc=new WeakMap,vs=new WeakMap,sc=new WeakMap,ac=new WeakMap,MA),DN=(DA=class extends Rc{constructor(t,n){super();ze(this,Ia);ze(this,vd);ze(this,bd);ze(this,yd);ze(this,xd);ze(this,wd);ze(this,_d);ze(this,Sd);ze(this,ig);ze(this,gr,void 0);ze(this,Zt,void 0);ze(this,gd,void 0);ze(this,er,void 0);ze(this,Da,void 0);ze(this,lc,void 0);ze(this,Qi,void 0);ze(this,md,void 0);ze(this,cc,void 0);ze(this,uc,void 0);ze(this,Ta,void 0);ze(this,Aa,void 0);ze(this,bs,void 0);ze(this,dc,new Set);this.options=n,Ie(this,gr,t),Ie(this,Qi,null),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(Z(this,Zt).addObserver(this),Hw(Z(this,Zt),this.options)?xt(this,Ia,qd).call(this):this.updateResult(),xt(this,xd,W1).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return _m(Z(this,Zt),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return _m(Z(this,Zt),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,xt(this,wd,q1).call(this),xt(this,_d,U1).call(this),Z(this,Zt).removeObserver(this)}setOptions(t,n){const r=this.options,i=Z(this,Zt);if(this.options=Z(this,gr).defaultQueryOptions(t),bm(r,this.options)||Z(this,gr).getQueryCache().notify({type:"observerOptionsUpdated",query:Z(this,Zt),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),xt(this,Sd,G1).call(this);const o=this.hasListeners();o&&Ww(Z(this,Zt),i,this.options,r)&&xt(this,Ia,qd).call(this),this.updateResult(n),o&&(Z(this,Zt)!==i||this.options.enabled!==r.enabled||this.options.staleTime!==r.staleTime)&&xt(this,vd,B1).call(this);const s=xt(this,bd,V1).call(this);o&&(Z(this,Zt)!==i||this.options.enabled!==r.enabled||s!==Z(this,bs))&&xt(this,yd,H1).call(this,s)}getOptimisticResult(t){const n=Z(this,gr).getQueryCache().build(Z(this,gr),t),r=this.createResult(n,t);return AN(this,r)&&(Ie(this,er,r),Ie(this,lc,this.options),Ie(this,Da,Z(this,Zt).state)),r}getCurrentResult(){return Z(this,er)}trackResult(t){const n={};return Object.keys(t).forEach(r=>{Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:()=>(Z(this,dc).add(r),t[r])})}),n}getCurrentQuery(){return Z(this,Zt)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=Z(this,gr).defaultQueryOptions(t),r=Z(this,gr).getQueryCache().build(Z(this,gr),n);return r.isFetchingOptimistic=!0,r.fetch().then(()=>this.createResult(r,n))}fetch(t){return xt(this,Ia,qd).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),Z(this,er)))}createResult(t,n){var k;const r=Z(this,Zt),i=this.options,o=Z(this,er),s=Z(this,Da),a=Z(this,lc),c=t!==r?t.state:Z(this,gd),{state:d}=t;let{error:f,errorUpdatedAt:g,fetchStatus:p,status:v}=d,y=!1,x;if(n._optimisticResults){const A=this.hasListeners(),L=!A&&Hw(t,n),F=A&&Ww(t,r,n,i);(L||F)&&(p=sf(t.options.networkMode)?"fetching":"paused",d.dataUpdatedAt||(v="pending")),n._optimisticResults==="isRestoring"&&(p="idle")}if(n.select&&typeof d.data<"u")if(o&&d.data===(s==null?void 0:s.data)&&n.select===Z(this,md))x=Z(this,cc);else try{Ie(this,md,n.select),x=n.select(d.data),x=xm(o==null?void 0:o.data,x,n),Ie(this,cc,x),Ie(this,Qi,null)}catch(A){Ie(this,Qi,A)}else x=d.data;if(typeof n.placeholderData<"u"&&typeof x>"u"&&v==="pending"){let A;if(o!=null&&o.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData))A=o.data;else if(A=typeof n.placeholderData=="function"?n.placeholderData((k=Z(this,uc))==null?void 0:k.state.data,Z(this,uc)):n.placeholderData,n.select&&typeof A<"u")try{A=n.select(A),Ie(this,Qi,null)}catch(L){Ie(this,Qi,L)}typeof A<"u"&&(v="success",x=xm(o==null?void 0:o.data,A,n),y=!0)}Z(this,Qi)&&(f=Z(this,Qi),x=Z(this,cc),g=Date.now(),v="error");const w=p==="fetching",S=v==="pending",C=v==="error",P=S&&w;return{status:v,fetchStatus:p,isPending:S,isSuccess:v==="success",isError:C,isInitialLoading:P,isLoading:P,data:x,dataUpdatedAt:d.dataUpdatedAt,error:f,errorUpdatedAt:g,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:w,isRefetching:w&&!S,isLoadingError:C&&d.dataUpdatedAt===0,isPaused:p==="paused",isPlaceholderData:y,isRefetchError:C&&d.dataUpdatedAt!==0,isStale:Sm(t,n),refetch:this.refetch}}updateResult(t){const n=Z(this,er),r=this.createResult(Z(this,Zt),this.options);if(Ie(this,Da,Z(this,Zt).state),Ie(this,lc,this.options),Z(this,Da).data!==void 0&&Ie(this,uc,Z(this,Zt)),bm(r,n))return;Ie(this,er,r);const i={},o=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!Z(this,dc).size)return!0;const l=new Set(a??Z(this,dc));return this.options.throwOnError&&l.add("error"),Object.keys(Z(this,er)).some(c=>{const d=c;return Z(this,er)[d]!==n[d]&&l.has(d)})};(t==null?void 0:t.listeners)!==!1&&o()&&(i.listeners=!0),xt(this,ig,n3).call(this,{...i,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&xt(this,xd,W1).call(this)}},gr=new WeakMap,Zt=new WeakMap,gd=new WeakMap,er=new WeakMap,Da=new WeakMap,lc=new WeakMap,Qi=new WeakMap,md=new WeakMap,cc=new WeakMap,uc=new WeakMap,Ta=new WeakMap,Aa=new WeakMap,bs=new WeakMap,dc=new WeakMap,Ia=new WeakSet,qd=function(t){xt(this,Sd,G1).call(this);let n=Z(this,Zt).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Kr)),n},vd=new WeakSet,B1=function(){if(xt(this,wd,q1).call(this),rl||Z(this,er).isStale||!mm(this.options.staleTime))return;const n=Iw(Z(this,er).dataUpdatedAt,this.options.staleTime)+1;Ie(this,Ta,setTimeout(()=>{Z(this,er).isStale||this.updateResult()},n))},bd=new WeakSet,V1=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(Z(this,Zt)):this.options.refetchInterval)??!1},yd=new WeakSet,H1=function(t){xt(this,_d,U1).call(this),Ie(this,bs,t),!(rl||this.options.enabled===!1||!mm(Z(this,bs))||Z(this,bs)===0)&&Ie(this,Aa,setInterval(()=>{(this.options.refetchIntervalInBackground||rf.isFocused())&&xt(this,Ia,qd).call(this)},Z(this,bs)))},xd=new WeakSet,W1=function(){xt(this,vd,B1).call(this),xt(this,yd,H1).call(this,xt(this,bd,V1).call(this))},wd=new WeakSet,q1=function(){Z(this,Ta)&&(clearTimeout(Z(this,Ta)),Ie(this,Ta,void 0))},_d=new WeakSet,U1=function(){Z(this,Aa)&&(clearInterval(Z(this,Aa)),Ie(this,Aa,void 0))},Sd=new WeakSet,G1=function(){const t=Z(this,gr).getQueryCache().build(Z(this,gr),this.options);if(t===Z(this,Zt))return;const n=Z(this,Zt);Ie(this,Zt,t),Ie(this,gd,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},ig=new WeakSet,n3=function(t){In.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(Z(this,er))}),Z(this,gr).getQueryCache().notify({query:Z(this,Zt),type:"observerResultsUpdated"})})},DA);function TN(e,t){return t.enabled!==!1&&!e.state.dataUpdatedAt&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Hw(e,t){return TN(e,t)||e.state.dataUpdatedAt>0&&_m(e,t,t.refetchOnMount)}function _m(e,t,n){if(t.enabled!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Sm(e,t)}return!1}function Ww(e,t,n,r){return n.enabled!==!1&&(e!==t||r.enabled===!1)&&(!n.suspense||e.state.status!=="error")&&Sm(e,n)}function Sm(e,t){return e.isStaleByTime(t.staleTime)}function AN(e,t){return!bm(e.getCurrentResult(),t)}var qw=ue.createContext(void 0),IN=e=>{const t=ue.useContext(qw);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},NN=({client:e,children:t})=>(ue.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),ue.createElement(qw.Provider,{value:e},t)),Uw=ue.createContext(!1),RN=()=>ue.useContext(Uw);Uw.Provider;function LN(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var $N=ue.createContext(LN()),FN=()=>ue.useContext($N);function jN(e,t){return typeof e=="function"?e(...t):!!e}var zN=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},BN=e=>{ue.useEffect(()=>{e.clearReset()},[e])},VN=({result:e,errorResetBoundary:t,throwOnError:n,query:r})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&jN(n,[e.error,r]),HN=e=>{e.suspense&&typeof e.staleTime!="number"&&(e.staleTime=1e3)},WN=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,qN=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function UN(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=IN(n),i=RN(),o=FN(),s=r.defaultQueryOptions(e);s._optimisticResults=i?"isRestoring":"optimistic",HN(s),zN(s,o),BN(o);const[a]=ue.useState(()=>new t(r,s)),l=a.getOptimisticResult(s);if(ue.useSyncExternalStore(ue.useCallback(c=>{const d=i?()=>{}:a.subscribe(In.batchCalls(c));return a.updateResult(),d},[a,i]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),ue.useEffect(()=>{a.setOptions(s,{listeners:!1})},[s,a]),WN(s,l))throw qN(s,a,o);if(VN({result:l,errorResetBoundary:o,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash)}))throw l.error;return s.notifyOnChangeProps?l:a.trackResult(l)}function Sr(e,t){return UN(e,DN,t)}var af={exports:{}};/**
59
+ */var uw;function q3(){if(uw)return nm;uw=1;var e=m,t=lw();function n(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,o=e.useRef,s=e.useEffect,a=e.useMemo,l=e.useDebugValue;return nm.useSyncExternalStoreWithSelector=function(c,d,f,g,p){var v=o(null);if(v.current===null){var y={hasValue:!1,value:null};v.current=y}else y=v.current;v=a(function(){function w(k){if(!S){if(S=!0,C=k,k=g(k),p!==void 0&&y.hasValue){var A=y.value;if(p(A,k))return P=A}return P=k}if(A=P,r(C,k))return A;var L=g(k);return p!==void 0&&p(A,L)?A:(C=k,P=L)}var S=!1,C,P,O=f===void 0?null:f;return[function(){return w(d())},O===null?void 0:function(){return w(O())}]},[d,f,g,p]);var x=i(c,v[0],v[1]);return s(function(){y.hasValue=!0,y.value=x},[x]),l(x),x},nm}process.env.NODE_ENV==="production"?Zg.exports=q3():Zg.exports=W3();var U3=Zg.exports;const G3=Pc(U3);var dw={VITE_SEMAPHOR_API:"https://semaphor.cloud/api/v1",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const{useDebugValue:Y3}=m,{useSyncExternalStoreWithSelector:K3}=G3;let fw=!1;function X3(e,t=e.getState,n){(dw?"production":void 0)!=="production"&&n&&!fw&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),fw=!0);const r=K3(e.subscribe,e.getState,e.getServerState||e.getState,t,n);return Y3(r),r}const hw=e=>{(dw?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?B3(e):e,n=(r,i)=>X3(t,r,i);return Object.assign(n,t),n},pw=e=>e?hw(e):hw;var gw=Symbol.for("immer-nothing"),mw=Symbol.for("immer-draftable"),wr=Symbol.for("immer-state"),Q3=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function ir(e,...t){if(process.env.NODE_ENV!=="production"){const n=Q3[e],r=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var tl=Object.getPrototypeOf;function nl(e){return!!e&&!!e[wr]}function As(e){var t;return e?vw(e)||Array.isArray(e)||!!e[mw]||!!((t=e.constructor)!=null&&t[mw])||Xd(e)||Qd(e):!1}var Z3=Object.prototype.constructor.toString();function vw(e){if(!e||typeof e!="object")return!1;const t=tl(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===Z3}function Ac(e,t){Kd(e)===0?Object.entries(e).forEach(([n,r])=>{t(n,r,e)}):e.forEach((n,r)=>t(r,n,e))}function Kd(e){const t=e[wr];return t?t.type_:Array.isArray(e)?1:Xd(e)?2:Qd(e)?3:0}function rm(e,t){return Kd(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function bw(e,t,n){const r=Kd(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function J3(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Xd(e){return e instanceof Map}function Qd(e){return e instanceof Set}function Is(e){return e.copy_||e.base_}function im(e,t){if(Xd(e))return new Map(e);if(Qd(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);if(!t&&vw(e))return tl(e)?{...e}:Object.assign(Object.create(null),e);const n=Object.getOwnPropertyDescriptors(e);delete n[wr];let r=Reflect.ownKeys(n);for(let i=0;i<r.length;i++){const o=r[i],s=n[o];s.writable===!1&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(n[o]={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[o]})}return Object.create(tl(e),n)}function om(e,t=!1){return Zd(e)||nl(e)||!As(e)||(Kd(e)>1&&(e.set=e.add=e.clear=e.delete=eN),Object.freeze(e),t&&Ac(e,(n,r)=>om(r,!0))),e}function eN(){ir(2)}function Zd(e){return Object.isFrozen(e)}var tN={};function Ns(e){const t=tN[e];return t||ir(0,e),t}var Ic;function yw(){return Ic}function nN(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function xw(e,t){t&&(Ns("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function sm(e){am(e),e.drafts_.forEach(rN),e.drafts_=null}function am(e){e===Ic&&(Ic=e.parent_)}function ww(e){return Ic=nN(Ic,e)}function rN(e){const t=e[wr];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function _w(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[wr].modified_&&(sm(t),ir(4)),As(e)&&(e=Jd(t,e),t.parent_||ef(t,e)),t.patches_&&Ns("Patches").generateReplacementPatches_(n[wr].base_,e,t.patches_,t.inversePatches_)):e=Jd(t,n,[]),sm(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==gw?e:void 0}function Jd(e,t,n){if(Zd(t))return t;const r=t[wr];if(!r)return Ac(t,(i,o)=>Sw(e,r,t,i,o,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return ef(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const i=r.copy_;let o=i,s=!1;r.type_===3&&(o=new Set(i),i.clear(),s=!0),Ac(o,(a,l)=>Sw(e,r,i,a,l,n,s)),ef(e,i,!1),n&&e.patches_&&Ns("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function Sw(e,t,n,r,i,o,s){if(process.env.NODE_ENV!=="production"&&i===n&&ir(5),nl(i)){const a=o&&t&&t.type_!==3&&!rm(t.assigned_,r)?o.concat(r):void 0,l=Jd(e,i,a);if(bw(n,r,l),nl(l))e.canAutoFreeze_=!1;else return}else s&&n.add(i);if(As(i)&&!Zd(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Jd(e,i),(!t||!t.scope_.parent_)&&ef(e,i)}}function ef(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&om(t,n)}function iN(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:yw(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,o=lm;n&&(i=[r],o=Nc);const{revoke:s,proxy:a}=Proxy.revocable(i,o);return r.draft_=a,r.revoke_=s,a}var lm={get(e,t){if(t===wr)return e;const n=Is(e);if(!rm(n,t))return oN(e,n,t);const r=n[t];return e.finalized_||!As(r)?r:r===cm(e.base_,t)?(dm(e),e.copy_[t]=fm(r,e)):r},has(e,t){return t in Is(e)},ownKeys(e){return Reflect.ownKeys(Is(e))},set(e,t,n){const r=Cw(Is(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const i=cm(Is(e),t),o=i==null?void 0:i[wr];if(o&&o.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(J3(n,i)&&(n!==void 0||rm(e.base_,t)))return!0;dm(e),um(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return cm(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,dm(e),um(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Is(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){ir(11)},getPrototypeOf(e){return tl(e.base_)},setPrototypeOf(){ir(12)}},Nc={};Ac(lm,(e,t)=>{Nc[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),Nc.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&ir(13),Nc.set.call(this,e,t,void 0)},Nc.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&ir(14),lm.set.call(this,e[0],t,n,e[0])};function cm(e,t){const n=e[wr];return(n?Is(n):e)[t]}function oN(e,t,n){var i;const r=Cw(t,n);return r?"value"in r?r.value:(i=r.get)==null?void 0:i.call(e.draft_):void 0}function Cw(e,t){if(!(t in e))return;let n=tl(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=tl(n)}}function um(e){e.modified_||(e.modified_=!0,e.parent_&&um(e.parent_))}function dm(e){e.copy_||(e.copy_=im(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var sN=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const o=n;n=t;const s=this;return function(l=o,...c){return s.produce(l,d=>n.call(this,d,...c))}}typeof n!="function"&&ir(6),r!==void 0&&typeof r!="function"&&ir(7);let i;if(As(t)){const o=ww(this),s=fm(t,void 0);let a=!0;try{i=n(s),a=!1}finally{a?sm(o):am(o)}return xw(o,r),_w(i,o)}else if(!t||typeof t!="object"){if(i=n(t),i===void 0&&(i=t),i===gw&&(i=void 0),this.autoFreeze_&&om(i,!0),r){const o=[],s=[];Ns("Patches").generateReplacementPatches_(t,i,o,s),r(o,s)}return i}else ir(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...a)=>this.produceWithPatches(s,l=>t(l,...a));let r,i;return[this.produce(t,n,(s,a)=>{r=s,i=a}),r,i]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){As(e)||ir(8),nl(e)&&(e=aN(e));const t=ww(this),n=fm(e,void 0);return n[wr].isManual_=!0,am(t),n}finishDraft(e,t){const n=e&&e[wr];(!n||!n.isManual_)&&ir(9);const{scope_:r}=n;return xw(r,t),_w(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const i=t[n];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}n>-1&&(t=t.slice(n+1));const r=Ns("Patches").applyPatches_;return nl(e)?r(e,t):this.produce(e,i=>r(i,t))}};function fm(e,t){const n=Xd(e)?Ns("MapSet").proxyMap_(e,t):Qd(e)?Ns("MapSet").proxySet_(e,t):iN(e,t);return(t?t.scope_:yw()).drafts_.push(n),n}function aN(e){return nl(e)||ir(10,e),Ew(e)}function Ew(e){if(!As(e)||Zd(e))return e;const t=e[wr];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=im(e,t.scope_.immer_.useStrictShallowCopy_)}else n=im(e,!0);return Ac(n,(r,i)=>{bw(n,r,Ew(i))}),t&&(t.finalized_=!1),n}var _r=new sN,lN=_r.produce;_r.produceWithPatches.bind(_r),_r.setAutoFreeze.bind(_r),_r.setUseStrictShallowCopy.bind(_r),_r.applyPatches.bind(_r),_r.createDraft.bind(_r),_r.finishDraft.bind(_r);const Ow=e=>(t,n,r)=>(r.setState=(i,o,...s)=>{const a=typeof i=="function"?lN(i):i;return t(a,o,...s)},e(r.setState,n,r));var tf,nf=kt;if(process.env.NODE_ENV==="production")tf=nf.createRoot,nf.hydrateRoot;else{var Pw=nf.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;tf=function(e,t){Pw.usingClientEntryPoint=!0;try{return nf.createRoot(e,t)}finally{Pw.usingClientEntryPoint=!1}}}function kw(e,t,n){const r={count:0},i=a=>{const l=m.useRef(r.count);return m.useEffect(()=>{l.current+=1,l.current===r.count+1&&(l.current-=1,t.setState(a))}),null};if(i.displayName=`((${e})) devtool`,typeof document>"u")return;if(!n){let a=document.getElementById(`simple-zustand-devtools-${e}`);a||(a=document.createElement("div"),a.id=`simple-zustand-devtools-${e}`),document.body.appendChild(a),n=a}const o=tf(n),s=a=>{a&&(o.render(m.createElement(i,Object.assign({},a))),r.count+=1)};s(t.getState()),t.subscribe(s)}var Mw={},Dw={},hm={exports:{}},Gt=String,Tw=function(){return{isColorSupported:!1,reset:Gt,bold:Gt,dim:Gt,italic:Gt,underline:Gt,inverse:Gt,hidden:Gt,strikethrough:Gt,black:Gt,red:Gt,green:Gt,yellow:Gt,blue:Gt,magenta:Gt,cyan:Gt,white:Gt,gray:Gt,bgBlack:Gt,bgRed:Gt,bgGreen:Gt,bgYellow:Gt,bgBlue:Gt,bgMagenta:Gt,bgCyan:Gt,bgWhite:Gt}};hm.exports=Tw(),hm.exports.createColors=Tw;var cN=hm.exports;(function(e){Object.defineProperty(e,"__esModule",{value:!0});function t(l,c){for(var d in c)Object.defineProperty(l,d,{enumerable:!0,get:c[d]})}t(e,{dim:function(){return s},default:function(){return a}});const n=r(cN);function r(l){return l&&l.__esModule?l:{default:l}}let i=new Set;function o(l,c,d){typeof process<"u"&&process.env.JEST_WORKER_ID||d&&i.has(d)||(d&&i.add(d),console.warn(""),c.forEach(f=>console.warn(l,"-",f)))}function s(l){return n.default.dim(l)}const a={info(l,c){o(n.default.bold(n.default.cyan("info")),...Array.isArray(l)?[l]:[c,l])},warn(l,c){o(n.default.bold(n.default.yellow("warn")),...Array.isArray(l)?[l]:[c,l])},risk(l,c){o(n.default.bold(n.default.magenta("risk")),...Array.isArray(l)?[l]:[c,l])}}})(Dw),function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const t=n(Dw);function n(o){return o&&o.__esModule?o:{default:o}}function r({version:o,from:s,to:a}){t.default.warn(`${s}-color-renamed`,[`As of Tailwind CSS ${o}, \`${s}\` has been renamed to \`${a}\`.`,"Update your configuration file to silence this warning."])}const i={inherit:"inherit",current:"currentColor",transparent:"transparent",black:"#000",white:"#fff",slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"},get lightBlue(){return r({version:"v2.2",from:"lightBlue",to:"sky"}),this.sky},get warmGray(){return r({version:"v3.0",from:"warmGray",to:"stone"}),this.stone},get trueGray(){return r({version:"v3.0",from:"trueGray",to:"neutral"}),this.neutral},get coolGray(){return r({version:"v3.0",from:"coolGray",to:"gray"}),this.gray},get blueGray(){return r({version:"v3.0",from:"blueGray",to:"slate"}),this.slate}}}(Mw);let pm=Mw;var uN=(pm.__esModule?pm:{default:pm}).default;const an=Pc(uN),gm={default:{dashboardPanel:"",dashboardTabsContainer:"",gridLayout:{className:""},chart:{font:{family:"Open Sans, sans-serif"},dataset:{backgroundColor:[an.violet[400],an.red[400],an.amber[400],an.orange[400],an.rose[400]],borderColor:[an.violet[400],an.red[400],an.amber[400],an.orange[400],an.rose[400]]},options:{plugins:{datalabels:{display:!1,color:dN},title:{display:!0},tooltip:{backgroundColor:"#fff",bodyColor:"#000",borderWidth:.25,titleColor:"#000",borderColor:"rgb(128,131,139)",cornerRadius:2,boxPadding:4},legend:{position:"top",align:"center",maxHeight:0}},scales:{y:{grid:{display:!0},title:{display:!0,text:""},beginAtZero:!0,ticks:{precision:0}},x:{grid:{display:!0},title:{display:!0}}},layout:{padding:{top:-40}},borderRadius:1,responsive:!0,maintainAspectRatio:!1}}},dark:{chart:{dataset:{backgroundColor:[an.teal[100],an.purple[100],an.amber[100],an.orange[100],an.rose[100]],borderColor:[an.teal[400],an.purple[400],an.amber[400],an.orange[300],an.rose[400]]},options:{plugins:{tooltip:{backgroundColor:"#000",bodyColor:"#fff",borderWidth:.25,titleColor:"#fff",borderColor:"rgb(128,131,139)",cornerRadius:2,boxPadding:4}},datalabels:{display:!1},scales:{x:{grid:{display:!0,color:an.slate[800]}},y:{grid:{display:!0,color:an.slate[800]}}}}}}};function dN(e){var r,i,o,s,a,l;const t=(a=(s=(o=(i=(r=e==null?void 0:e.chart)==null?void 0:r.config)==null?void 0:i._config)==null?void 0:o.options)==null?void 0:s.plugins)==null?void 0:a.datalabels;let n=(l=e==null?void 0:e.dataset)==null?void 0:l.backgroundColor;return(t==null?void 0:t.align)==="end"&&(t==null?void 0:t.anchor)==="end"&&(n=Aw()),(t==null?void 0:t.align)==="start"&&(t==null?void 0:t.anchor)==="start"&&(n=Aw()),fN(n)}function Aw(){return be.getState().theme==="dark"?"#000000":"#FFFFFF"}function fN(e){let t=0,n=0,r=0,i=0;const o=d=>{const f=d.replace("#",""),g=parseInt(f.substring(0,2),16),p=parseInt(f.substring(2,4),16),v=parseInt(f.substring(4,6),16);t+=g,n+=p,r+=v,i++};Array.isArray(e)?e.forEach(d=>{o(d)}):o(e);const s=t/i,a=n/i,l=r/i;return(s*299+a*587+l*114)/1e3>=180?"black":"white"}const be=pw()(Ow((e,t)=>({dashboard:{id:"",style:gm},selectedSheetId:null,selectedCardId:null,selectedCard:null,showFilters:!1,isDashboardEditing:!1,isVisualEditing:!1,showDashboardJSON:!1,isEditorSaveEvent:!1,actions:{setAuthToken:n=>{e(()=>({authToken:n}))},setThemeStyle:n=>{e(()=>({themeStyle:n}))},setIsEditorSaveEvent:n=>{e(()=>({isEditorSaveEvent:n}))},setDashboard:n=>e({dashboard:n}),setBookmarkKey:n=>{e(()=>({bookmarkKey:n}))},setDashboardTheme:n=>{e(r=>{r.theme=n})},setDashboardTitle:n=>{e(r=>{r.dashboard&&(r.dashboard.title=n)})},setDashboardDescription:n=>{e(r=>{r.dashboard&&(r.dashboard.description=n)})},setSheets:n=>{e(r=>{r.dashboard&&(r.dashboard.sheets=n)})},setSheetTitle:(n,r)=>{e(i=>{var s,a;const o=(a=(s=i.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);o&&(o.title=r)})},setSheetDescription:(n,r)=>{e(i=>{var s,a;const o=(a=(s=i.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);o&&(o.description=r)})},setCards:(n,r)=>{e(i=>{var s,a;const o=(a=(s=i.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);o&&(o.cards=r)})},setCardTitle:(n,r,i)=>{e(o=>{var a,l,c,d;const s=(l=(a=o.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(g=>g.id===r);f&&(f.title=i,(d=o.onUpdateCard)==null||d.call(o,f,n))}})},setCardSql:(n,r,i)=>{e(o=>{var a,l,c,d;const s=(l=(a=o.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(g=>g.id===r);f&&(f.sql=i,(d=o.onUpdateCard)==null||d.call(o,f,n))}})},setCardData:(n,r,i)=>{e(o=>{var a,l,c,d;const s=(l=(a=o.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(g=>g.id===r);f&&(f.data=i,(d=o.onUpdateCard)==null||d.call(o,f,n))}})},setCardDescription:(n,r,i)=>{e(o=>{var a,l,c,d;const s=(l=(a=o.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(g=>g.id===r);f&&(f.description=i,(d=o.onUpdateCard)==null||d.call(o,f,n))}})},setSheetLayout:(n,r)=>{e(i=>{var s,a;const o=(a=(s=i.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(l=>l.id===n);o&&(o.layout=r)})},setShowFilters:n=>{e(()=>({showFilters:n}))},addOrUpdateFilterValue:n=>{e(r=>{if(r.filterValues){const i=r.filterValues.findIndex(o=>o.filterId===n.filterId);i>-1?r.filterValues.splice(i,1,n):r.filterValues.push(n)}else r.filterValues=[n]})},removeFilterValue:n=>{e(r=>{if(r.filterValues){const i=r.filterValues.findIndex(o=>o.filterId===n);i>-1&&r.filterValues.splice(i,1)}})},addFilter:n=>{e(r=>{var i;r.dashboard.filters?(i=r.dashboard.filters)==null||i.push(n):r.dashboard.filters=[n]})},removeFilter:n=>{e(r=>{var i,o;if(r.dashboard.filters){const s=(i=r.dashboard.filters)==null?void 0:i.findIndex(a=>a.id===n);console.log("index",s),s>-1&&((o=r.dashboard.filters)==null||o.splice(s,1))}})},updateFilter:n=>{e(r=>{var i,o;if(r.dashboard.filters){const s=(i=r.dashboard.filters)==null?void 0:i.findIndex(a=>a.id===n.id);s>-1&&((o=r.dashboard.filters)==null||o.splice(s,1,n))}})},setIsDashboardEditing:n=>{e(()=>({isDashboardEditing:n}))},setShowDashboardJSON:n=>{e(()=>({showDashboardJSON:n}))},setIsVisualEditing:n=>{e(()=>({isVisualEditing:n}))},addCard:(n,r)=>{e(i=>{var s,a,l,c,d;const o=(a=(s=i.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(f=>f.id===n);if(o){(l=o.cards)==null||l.push(r);const f={i:r.id,x:0,y:1/0,w:20,h:7,minW:10};(c=o.layout)==null||c.push(f),(d=i.onAddCard)==null||d.call(i,r,n)}})},updateCard:(n,r)=>{e(i=>{var a,l,c,d,f;const o=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(g=>g.id===n),s=(c=o==null?void 0:o.cards)==null?void 0:c.findIndex(g=>g.id===r.id);o&&((d=o.cards)==null||d.splice(s,1,r),(f=i.onUpdateCard)==null||f.call(i,r,n))})},removeCard:(n,r)=>{e(i=>{var a,l,c,d,f,g;const o=(l=(a=i.dashboard)==null?void 0:a.sheets)==null?void 0:l.find(p=>p.id===n),s=(c=o==null?void 0:o.cards)==null?void 0:c.findIndex(p=>p.id===r.id);o&&((d=o.cards)==null||d.splice(s,1),(f=o.layout)==null||f.splice(s,1),(g=i.onRemoveCard)==null||g.call(i,r,n))})},setStyle:n=>{e(r=>{r.dashboard&&(r.dashboard.style=n)})},setSelectedCardId:(n,r)=>{e(i=>{var s,a,l;const o=(a=(s=i.dashboard)==null?void 0:s.sheets)==null?void 0:a.find(c=>c.id===n);o&&(((l=o.cards)==null?void 0:l.find(d=>d.id===r))?i.selectedCardId=r:i.selectedCardId=null)})},setSelectedCard:n=>{e(r=>{r.selectedCard=n})},setSelectedSheetId:n=>{e(r=>{var o,s;((s=(o=r.dashboard)==null?void 0:o.sheets)==null?void 0:s.find(a=>a.id===n))&&(r.selectedSheetId=n)})},setOnSaveFunction:n=>{e(()=>({onSaveFunction:n}))},setOnAddCard:n=>{e(()=>({onAddCard: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(i=>i.id===t().selectedSheetId)},getSelectedCard:()=>{var r,i,o;const n=(i=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:i.find(s=>s.id===t().selectedSheetId);return(o=n==null?void 0:n.cards)==null?void 0:o.find(s=>s.id===t().selectedCardId)},getSelectedSheetCards:()=>{var r,i;const n=(i=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:i.find(o=>o.id===t().selectedSheetId);return n==null?void 0:n.cards},getSelectedSheetLayout:()=>{var r,i;const n=(i=(r=t().dashboard)==null?void 0:r.sheets)==null?void 0:i.find(o=>o.id===t().selectedSheetId);return n==null?void 0:n.layout},getStyle:()=>{var n;return(n=t().dashboard)==null?void 0:n.style}}})));process.env.NODE_ENV==="development"&&kw("DashboardStore",be);var Rc=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(){}},rl=typeof window>"u"||"Deno"in window;function Kr(){}function hN(e,t){return typeof e=="function"?e(t):e}function mm(e){return typeof e=="number"&&e>=0&&e!==1/0}function Iw(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Nw(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:o,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==vm(s,t.options))return!1}else if(!$c(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 i<"u"&&i!==t.state.fetchStatus||o&&!o(t))}function Rw(e,t){const{exact:n,status:r,predicate:i,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(Lc(t.options.mutationKey)!==Lc(o))return!1}else if(!$c(t.options.mutationKey,o))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function vm(e,t){return((t==null?void 0:t.queryKeyHashFn)||Lc)(e)}function Lc(e){return JSON.stringify(e,(t,n)=>ym(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function $c(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?!Object.keys(t).some(n=>!$c(e[n],t[n])):!1}function Lw(e,t){if(e===t)return e;const n=$w(e)&&$w(t);if(n||ym(e)&&ym(t)){const r=n?e:Object.keys(e),i=r.length,o=n?t:Object.keys(t),s=o.length,a=n?[]:{};let l=0;for(let c=0;c<s;c++){const d=n?c:o[c];!n&&e[d]===void 0&&t[d]===void 0&&r.includes(d)?(a[d]=void 0,l++):(a[d]=Lw(e[d],t[d]),a[d]===e[d]&&e[d]!==void 0&&l++)}return i===s&&l===i?e:a}return t}function bm(e,t){if(e&&!t||t&&!e)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function $w(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function ym(e){if(!Fw(e))return!1;const t=e.constructor;if(typeof t>"u")return!0;const n=t.prototype;return!(!Fw(n)||!n.hasOwnProperty("isPrototypeOf"))}function Fw(e){return Object.prototype.toString.call(e)==="[object Object]"}function pN(e){return new Promise(t=>{setTimeout(t,e)})}function xm(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Lw(e,t):t}function gN(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function mN(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var vN=(_A=class extends Rc{constructor(){super();ze(this,Oa,void 0);ze(this,fs,void 0);ze(this,Ql,void 0);Ie(this,Ql,t=>{if(!rl&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){Z(this,fs)||this.setEventListener(Z(this,Ql))}onUnsubscribe(){var t;this.hasListeners()||((t=Z(this,fs))==null||t.call(this),Ie(this,fs,void 0))}setEventListener(t){var n;Ie(this,Ql,t),(n=Z(this,fs))==null||n.call(this),Ie(this,fs,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){Z(this,Oa)!==t&&(Ie(this,Oa,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof Z(this,Oa)=="boolean"?Z(this,Oa):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Oa=new WeakMap,fs=new WeakMap,Ql=new WeakMap,_A),rf=new vN,bN=(SA=class extends Rc{constructor(){super();ze(this,Zl,!0);ze(this,hs,void 0);ze(this,Jl,void 0);Ie(this,Jl,t=>{if(!rl&&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(){Z(this,hs)||this.setEventListener(Z(this,Jl))}onUnsubscribe(){var t;this.hasListeners()||((t=Z(this,hs))==null||t.call(this),Ie(this,hs,void 0))}setEventListener(t){var n;Ie(this,Jl,t),(n=Z(this,hs))==null||n.call(this),Ie(this,hs,t(this.setOnline.bind(this)))}setOnline(t){Z(this,Zl)!==t&&(Ie(this,Zl,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return Z(this,Zl)}},Zl=new WeakMap,hs=new WeakMap,Jl=new WeakMap,SA),of=new bN;function yN(e){return Math.min(1e3*2**e,3e4)}function sf(e){return(e??"online")==="online"?of.isOnline():!0}var jw=class{constructor(e){this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function wm(e){return e instanceof jw}function zw(e){let t=!1,n=0,r=!1,i,o,s;const a=new Promise((x,w)=>{o=x,s=w}),l=x=>{var w;r||(p(new jw(x)),(w=e.abort)==null||w.call(e))},c=()=>{t=!0},d=()=>{t=!1},f=()=>!rf.isFocused()||e.networkMode!=="always"&&!of.isOnline(),g=x=>{var w;r||(r=!0,(w=e.onSuccess)==null||w.call(e,x),i==null||i(),o(x))},p=x=>{var w;r||(r=!0,(w=e.onError)==null||w.call(e,x),i==null||i(),s(x))},v=()=>new Promise(x=>{var w;i=S=>{const C=r||!f();return C&&x(S),C},(w=e.onPause)==null||w.call(e)}).then(()=>{var x;i=void 0,r||(x=e.onContinue)==null||x.call(e)}),y=()=>{if(r)return;let x;try{x=e.fn()}catch(w){x=Promise.reject(w)}Promise.resolve(x).then(g).catch(w=>{var k;if(r)return;const S=e.retry??(rl?0:3),C=e.retryDelay??yN,P=typeof C=="function"?C(n,w):C,O=S===!0||typeof S=="number"&&n<S||typeof S=="function"&&S(n,w);if(t||!O){p(w);return}n++,(k=e.onFail)==null||k.call(e,n,w),pN(P).then(()=>{if(f())return v()}).then(()=>{t?p(w):y()})})};return sf(e.networkMode)?y():v().then(y),{promise:a,cancel:l,continue:()=>(i==null?void 0:i())?a:Promise.resolve(),cancelRetry:c,continueRetry:d}}function xN(){let e=[],t=0,n=g=>{g()},r=g=>{g()},i=g=>setTimeout(g,0);const o=g=>{i=g},s=g=>{let p;t++;try{p=g()}finally{t--,t||c()}return p},a=g=>{t?e.push(g):i(()=>{n(g)})},l=g=>(...p)=>{a(()=>{g(...p)})},c=()=>{const g=e;e=[],g.length&&i(()=>{r(()=>{g.forEach(p=>{n(p)})})})};return{batch:s,batchCalls:l,schedule:a,setNotifyFunction:g=>{n=g},setBatchNotifyFunction:g=>{r=g},setScheduler:o}}var In=xN(),Bw=(CA=class{constructor(){ze(this,Pa,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),mm(this.gcTime)&&Ie(this,Pa,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(rl?1/0:5*60*1e3))}clearGcTimeout(){Z(this,Pa)&&(clearTimeout(Z(this,Pa)),Ie(this,Pa,void 0))}},Pa=new WeakMap,CA),wN=(EA=class extends Bw{constructor(t){super();ze(this,nc);ze(this,Si);ze(this,ec,void 0);ze(this,tc,void 0);ze(this,ri,void 0);ze(this,ps,void 0);ze(this,ii,void 0);ze(this,Mn,void 0);ze(this,fd,void 0);ze(this,ka,void 0);Ie(this,ka,!1),Ie(this,fd,t.defaultOptions),xt(this,nc,Gg).call(this,t.options),Ie(this,Mn,[]),Ie(this,ri,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,Ie(this,ec,t.state||_N(this.options)),this.state=Z(this,ec),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!Z(this,Mn).length&&this.state.fetchStatus==="idle"&&Z(this,ri).remove(this)}setData(t,n){const r=xm(this.state.data,t,this.options);return xt(this,Si,No).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){xt(this,Si,No).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r;const n=Z(this,ps);return(r=Z(this,ii))==null||r.cancel(t),n?n.then(Kr).catch(Kr):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(Z(this,ec))}isActive(){return Z(this,Mn).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||Z(this,Mn).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!Iw(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=Z(this,Mn).find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=Z(this,ii))==null||n.continue()}onOnline(){var n;const t=Z(this,Mn).find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=Z(this,ii))==null||n.continue()}addObserver(t){Z(this,Mn).includes(t)||(Z(this,Mn).push(t),this.clearGcTimeout(),Z(this,ri).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){Z(this,Mn).includes(t)&&(Ie(this,Mn,Z(this,Mn).filter(n=>n!==t)),Z(this,Mn).length||(Z(this,ii)&&(Z(this,ka)?Z(this,ii).cancel({revert:!0}):Z(this,ii).cancelRetry()),this.scheduleGc()),Z(this,ri).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return Z(this,Mn).length}invalidate(){this.state.isInvalidated||xt(this,Si,No).call(this,{type:"invalidate"})}fetch(t,n){var c,d,f,g;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(Z(this,ps))return(c=Z(this,ii))==null||c.continueRetry(),Z(this,ps)}if(t&&xt(this,nc,Gg).call(this,t),!this.options.queryFn){const p=Z(this,Mn).find(v=>v.options.queryFn);p&&xt(this,nc,Gg).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,i={queryKey:this.queryKey,meta:this.meta},o=p=>{Object.defineProperty(p,"signal",{enumerable:!0,get:()=>(Ie(this,ka,!0),r.signal)})};o(i);const s=()=>this.options.queryFn?(Ie(this,ka,!1),this.options.persister?this.options.persister(this.options.queryFn,i,this):this.options.queryFn(i)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),a={fetchOptions:n,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:s};o(a),(d=this.options.behavior)==null||d.onFetch(a,this),Ie(this,tc,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=a.fetchOptions)==null?void 0:f.meta))&&xt(this,Si,No).call(this,{type:"fetch",meta:(g=a.fetchOptions)==null?void 0:g.meta});const l=p=>{var v,y,x,w;wm(p)&&p.silent||xt(this,Si,No).call(this,{type:"error",error:p}),wm(p)||((y=(v=Z(this,ri).config).onError)==null||y.call(v,p,this),(w=(x=Z(this,ri).config).onSettled)==null||w.call(x,this.state.data,p,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return Ie(this,ii,zw({fn:a.fetchFn,abort:r.abort.bind(r),onSuccess:p=>{var v,y,x,w;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),(y=(v=Z(this,ri).config).onSuccess)==null||y.call(v,p,this),(w=(x=Z(this,ri).config).onSettled)==null||w.call(x,p,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:l,onFail:(p,v)=>{xt(this,Si,No).call(this,{type:"failed",failureCount:p,error:v})},onPause:()=>{xt(this,Si,No).call(this,{type:"pause"})},onContinue:()=>{xt(this,Si,No).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode})),Ie(this,ps,Z(this,ii).promise),Z(this,ps)}},ec=new WeakMap,tc=new WeakMap,ri=new WeakMap,ps=new WeakMap,ii=new WeakMap,Mn=new WeakMap,fd=new WeakMap,ka=new WeakMap,nc=new WeakSet,Gg=function(t){this.options={...Z(this,fd),...t},this.updateGcTime(this.options.gcTime)},Si=new WeakSet,No=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:sf(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 i=t.error;return wm(i)&&i.revert&&Z(this,tc)?{...Z(this,tc),fetchStatus:"idle"}:{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),In.batch(()=>{Z(this,Mn).forEach(r=>{r.onQueryUpdate()}),Z(this,ri).notify({query:this,type:"updated",action:t})})},EA);function _N(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 SN=(OA=class extends Rc{constructor(t={}){super();ze(this,Yi,void 0);this.config=t,Ie(this,Yi,new Map)}build(t,n,r){const i=n.queryKey,o=n.queryHash??vm(i,n);let s=this.get(o);return s||(s=new wN({cache:this,queryKey:i,queryHash:o,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(i)}),this.add(s)),s}add(t){Z(this,Yi).has(t.queryHash)||(Z(this,Yi).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=Z(this,Yi).get(t.queryHash);n&&(t.destroy(),n===t&&Z(this,Yi).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){In.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return Z(this,Yi).get(t)}getAll(){return[...Z(this,Yi).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Nw(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>Nw(t,r)):n}notify(t){In.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){In.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){In.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Yi=new WeakMap,OA),CN=(PA=class extends Bw{constructor(t){super();ze(this,Xi);ze(this,Ki,void 0);ze(this,hd,void 0);ze(this,zr,void 0);ze(this,rc,void 0);this.mutationId=t.mutationId,Ie(this,hd,t.defaultOptions),Ie(this,zr,t.mutationCache),Ie(this,Ki,[]),this.state=t.state||EN(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...Z(this,hd),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){Z(this,Ki).includes(t)||(Z(this,Ki).push(t),this.clearGcTimeout(),Z(this,zr).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){Ie(this,Ki,Z(this,Ki).filter(n=>n!==t)),this.scheduleGc(),Z(this,zr).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){Z(this,Ki).length||(this.state.status==="pending"?this.scheduleGc():Z(this,zr).remove(this))}continue(){var t;return((t=Z(this,rc))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var i,o,s,a,l,c,d,f,g,p,v,y,x,w,S,C,P,O,k,A;const n=()=>(Ie(this,rc,zw({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(L,F)=>{xt(this,Xi,ks).call(this,{type:"failed",failureCount:L,error:F})},onPause:()=>{xt(this,Xi,ks).call(this,{type:"pause"})},onContinue:()=>{xt(this,Xi,ks).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),Z(this,rc).promise),r=this.state.status==="pending";try{if(!r){xt(this,Xi,ks).call(this,{type:"pending",variables:t}),await((o=(i=Z(this,zr).config).onMutate)==null?void 0:o.call(i,t,this));const F=await((a=(s=this.options).onMutate)==null?void 0:a.call(s,t));F!==this.state.context&&xt(this,Xi,ks).call(this,{type:"pending",context:F,variables:t})}const L=await n();return await((c=(l=Z(this,zr).config).onSuccess)==null?void 0:c.call(l,L,t,this.state.context,this)),await((f=(d=this.options).onSuccess)==null?void 0:f.call(d,L,t,this.state.context)),await((p=(g=Z(this,zr).config).onSettled)==null?void 0:p.call(g,L,null,this.state.variables,this.state.context,this)),await((y=(v=this.options).onSettled)==null?void 0:y.call(v,L,null,t,this.state.context)),xt(this,Xi,ks).call(this,{type:"success",data:L}),L}catch(L){try{throw await((w=(x=Z(this,zr).config).onError)==null?void 0:w.call(x,L,t,this.state.context,this)),await((C=(S=this.options).onError)==null?void 0:C.call(S,L,t,this.state.context)),await((O=(P=Z(this,zr).config).onSettled)==null?void 0:O.call(P,void 0,L,this.state.variables,this.state.context,this)),await((A=(k=this.options).onSettled)==null?void 0:A.call(k,void 0,L,t,this.state.context)),L}finally{xt(this,Xi,ks).call(this,{type:"error",error:L})}}}},Ki=new WeakMap,hd=new WeakMap,zr=new WeakMap,rc=new WeakMap,Xi=new WeakSet,ks=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:!sf(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),In.batch(()=>{Z(this,Ki).forEach(r=>{r.onMutationUpdate(t)}),Z(this,zr).notify({mutation:this,type:"updated",action:t})})},PA);function EN(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var ON=(kA=class extends Rc{constructor(t={}){super();ze(this,oi,void 0);ze(this,pd,void 0);ze(this,Ma,void 0);this.config=t,Ie(this,oi,[]),Ie(this,pd,0)}build(t,n,r){const i=new CN({mutationCache:this,mutationId:++Ug(this,pd)._,options:t.defaultMutationOptions(n),state:r});return this.add(i),i}add(t){Z(this,oi).push(t),this.notify({type:"added",mutation:t})}remove(t){Ie(this,oi,Z(this,oi).filter(n=>n!==t)),this.notify({type:"removed",mutation:t})}clear(){In.batch(()=>{Z(this,oi).forEach(t=>{this.remove(t)})})}getAll(){return Z(this,oi)}find(t){const n={exact:!0,...t};return Z(this,oi).find(r=>Rw(n,r))}findAll(t={}){return Z(this,oi).filter(n=>Rw(t,n))}notify(t){In.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){return Ie(this,Ma,(Z(this,Ma)??Promise.resolve()).then(()=>{const t=Z(this,oi).filter(n=>n.state.isPaused);return In.batch(()=>t.reduce((n,r)=>n.then(()=>r.continue().catch(Kr)),Promise.resolve()))}).then(()=>{Ie(this,Ma,void 0)})),Z(this,Ma)}},oi=new WeakMap,pd=new WeakMap,Ma=new WeakMap,kA);function PN(e){return{onFetch:(t,n)=>{const r=async()=>{var v,y,x,w,S;const i=t.options,o=(x=(y=(v=t.fetchOptions)==null?void 0:v.meta)==null?void 0:y.fetchMore)==null?void 0:x.direction,s=((w=t.state.data)==null?void 0:w.pages)||[],a=((S=t.state.data)==null?void 0:S.pageParams)||[],l={pages:[],pageParams:[]};let c=!1;const d=C=>{Object.defineProperty(C,"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}'`))),g=async(C,P,O)=>{if(c)return Promise.reject();if(P==null&&C.pages.length)return Promise.resolve(C);const k={queryKey:t.queryKey,pageParam:P,direction:O?"backward":"forward",meta:t.options.meta};d(k);const A=await f(k),{maxPages:L}=t.options,F=O?mN:gN;return{pages:F(C.pages,A,L),pageParams:F(C.pageParams,P,L)}};let p;if(o&&s.length){const C=o==="backward",P=C?kN:Vw,O={pages:s,pageParams:a},k=P(i,O);p=await g(O,k,C)}else{p=await g(l,a[0]??i.initialPageParam);const C=e??s.length;for(let P=1;P<C;P++){const O=Vw(i,p);p=await g(p,O)}}return p};t.options.persister?t.fetchFn=()=>{var i,o;return(o=(i=t.options).persister)==null?void 0:o.call(i,r,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=r}}}function Vw(e,{pages:t,pageParams:n}){const r=t.length-1;return e.getNextPageParam(t[r],t,n[r],n)}function kN(e,{pages:t,pageParams:n}){var r;return(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n)}var MN=(MA=class{constructor(e={}){ze(this,Sn,void 0);ze(this,gs,void 0);ze(this,ms,void 0);ze(this,ic,void 0);ze(this,oc,void 0);ze(this,vs,void 0);ze(this,sc,void 0);ze(this,ac,void 0);Ie(this,Sn,e.queryCache||new SN),Ie(this,gs,e.mutationCache||new ON),Ie(this,ms,e.defaultOptions||{}),Ie(this,ic,new Map),Ie(this,oc,new Map),Ie(this,vs,0)}mount(){Ug(this,vs)._++,Z(this,vs)===1&&(Ie(this,sc,rf.subscribe(()=>{rf.isFocused()&&(this.resumePausedMutations(),Z(this,Sn).onFocus())})),Ie(this,ac,of.subscribe(()=>{of.isOnline()&&(this.resumePausedMutations(),Z(this,Sn).onOnline())})))}unmount(){var e,t;Ug(this,vs)._--,Z(this,vs)===0&&((e=Z(this,sc))==null||e.call(this),Ie(this,sc,void 0),(t=Z(this,ac))==null||t.call(this),Ie(this,ac,void 0))}isFetching(e){return Z(this,Sn).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return Z(this,gs).findAll({...e,status:"pending"}).length}getQueryData(e){var t;return(t=Z(this,Sn).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=Z(this,Sn).find({queryKey:e}),i=r==null?void 0:r.state.data,o=hN(t,i);if(typeof o>"u")return;const s=this.defaultQueryOptions({queryKey:e});return Z(this,Sn).build(this,s).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return In.batch(()=>this.getQueryCache().findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var t;return(t=Z(this,Sn).find({queryKey:e}))==null?void 0:t.state}removeQueries(e){const t=Z(this,Sn);In.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=Z(this,Sn),r={type:"active",...e};return In.batch(()=>(n.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries(r,t)))}cancelQueries(e={},t={}){const n={revert:!0,...t},r=In.batch(()=>Z(this,Sn).findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(Kr).catch(Kr)}invalidateQueries(e={},t={}){return In.batch(()=>{if(Z(this,Sn).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=In.batch(()=>Z(this,Sn).findAll(e).filter(i=>!i.isDisabled()).map(i=>{let o=i.fetch(void 0,n);return n.throwOnError||(o=o.catch(Kr)),i.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(r).then(Kr)}fetchQuery(e){const t=this.defaultQueryOptions(e);typeof t.retry>"u"&&(t.retry=!1);const n=Z(this,Sn).build(this,t);return n.isStaleByTime(t.staleTime)?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Kr).catch(Kr)}fetchInfiniteQuery(e){return e.behavior=PN(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Kr).catch(Kr)}resumePausedMutations(){return Z(this,gs).resumePausedMutations()}getQueryCache(){return Z(this,Sn)}getMutationCache(){return Z(this,gs)}getDefaultOptions(){return Z(this,ms)}setDefaultOptions(e){Ie(this,ms,e)}setQueryDefaults(e,t){Z(this,ic).set(Lc(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...Z(this,ic).values()];let n={};return t.forEach(r=>{$c(e,r.queryKey)&&(n={...n,...r.defaultOptions})}),n}setMutationDefaults(e,t){Z(this,oc).set(Lc(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...Z(this,oc).values()];let n={};return t.forEach(r=>{$c(e,r.mutationKey)&&(n={...n,...r.defaultOptions})}),n}defaultQueryOptions(e){if(e!=null&&e._defaulted)return e;const t={...Z(this,ms).queries,...(e==null?void 0:e.queryKey)&&this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=vm(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:{...Z(this,ms).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){Z(this,Sn).clear(),Z(this,gs).clear()}},Sn=new WeakMap,gs=new WeakMap,ms=new WeakMap,ic=new WeakMap,oc=new WeakMap,vs=new WeakMap,sc=new WeakMap,ac=new WeakMap,MA),DN=(DA=class extends Rc{constructor(t,n){super();ze(this,Ia);ze(this,vd);ze(this,bd);ze(this,yd);ze(this,xd);ze(this,wd);ze(this,_d);ze(this,Sd);ze(this,ig);ze(this,gr,void 0);ze(this,Zt,void 0);ze(this,gd,void 0);ze(this,er,void 0);ze(this,Da,void 0);ze(this,lc,void 0);ze(this,Qi,void 0);ze(this,md,void 0);ze(this,cc,void 0);ze(this,uc,void 0);ze(this,Ta,void 0);ze(this,Aa,void 0);ze(this,bs,void 0);ze(this,dc,new Set);this.options=n,Ie(this,gr,t),Ie(this,Qi,null),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(Z(this,Zt).addObserver(this),Hw(Z(this,Zt),this.options)?xt(this,Ia,qd).call(this):this.updateResult(),xt(this,xd,W1).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return _m(Z(this,Zt),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return _m(Z(this,Zt),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,xt(this,wd,q1).call(this),xt(this,_d,U1).call(this),Z(this,Zt).removeObserver(this)}setOptions(t,n){const r=this.options,i=Z(this,Zt);if(this.options=Z(this,gr).defaultQueryOptions(t),bm(r,this.options)||Z(this,gr).getQueryCache().notify({type:"observerOptionsUpdated",query:Z(this,Zt),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),xt(this,Sd,G1).call(this);const o=this.hasListeners();o&&Ww(Z(this,Zt),i,this.options,r)&&xt(this,Ia,qd).call(this),this.updateResult(n),o&&(Z(this,Zt)!==i||this.options.enabled!==r.enabled||this.options.staleTime!==r.staleTime)&&xt(this,vd,B1).call(this);const s=xt(this,bd,V1).call(this);o&&(Z(this,Zt)!==i||this.options.enabled!==r.enabled||s!==Z(this,bs))&&xt(this,yd,H1).call(this,s)}getOptimisticResult(t){const n=Z(this,gr).getQueryCache().build(Z(this,gr),t),r=this.createResult(n,t);return AN(this,r)&&(Ie(this,er,r),Ie(this,lc,this.options),Ie(this,Da,Z(this,Zt).state)),r}getCurrentResult(){return Z(this,er)}trackResult(t){const n={};return Object.keys(t).forEach(r=>{Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:()=>(Z(this,dc).add(r),t[r])})}),n}getCurrentQuery(){return Z(this,Zt)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=Z(this,gr).defaultQueryOptions(t),r=Z(this,gr).getQueryCache().build(Z(this,gr),n);return r.isFetchingOptimistic=!0,r.fetch().then(()=>this.createResult(r,n))}fetch(t){return xt(this,Ia,qd).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),Z(this,er)))}createResult(t,n){var k;const r=Z(this,Zt),i=this.options,o=Z(this,er),s=Z(this,Da),a=Z(this,lc),c=t!==r?t.state:Z(this,gd),{state:d}=t;let{error:f,errorUpdatedAt:g,fetchStatus:p,status:v}=d,y=!1,x;if(n._optimisticResults){const A=this.hasListeners(),L=!A&&Hw(t,n),F=A&&Ww(t,r,n,i);(L||F)&&(p=sf(t.options.networkMode)?"fetching":"paused",d.dataUpdatedAt||(v="pending")),n._optimisticResults==="isRestoring"&&(p="idle")}if(n.select&&typeof d.data<"u")if(o&&d.data===(s==null?void 0:s.data)&&n.select===Z(this,md))x=Z(this,cc);else try{Ie(this,md,n.select),x=n.select(d.data),x=xm(o==null?void 0:o.data,x,n),Ie(this,cc,x),Ie(this,Qi,null)}catch(A){Ie(this,Qi,A)}else x=d.data;if(typeof n.placeholderData<"u"&&typeof x>"u"&&v==="pending"){let A;if(o!=null&&o.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData))A=o.data;else if(A=typeof n.placeholderData=="function"?n.placeholderData((k=Z(this,uc))==null?void 0:k.state.data,Z(this,uc)):n.placeholderData,n.select&&typeof A<"u")try{A=n.select(A),Ie(this,Qi,null)}catch(L){Ie(this,Qi,L)}typeof A<"u"&&(v="success",x=xm(o==null?void 0:o.data,A,n),y=!0)}Z(this,Qi)&&(f=Z(this,Qi),x=Z(this,cc),g=Date.now(),v="error");const w=p==="fetching",S=v==="pending",C=v==="error",P=S&&w;return{status:v,fetchStatus:p,isPending:S,isSuccess:v==="success",isError:C,isInitialLoading:P,isLoading:P,data:x,dataUpdatedAt:d.dataUpdatedAt,error:f,errorUpdatedAt:g,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:w,isRefetching:w&&!S,isLoadingError:C&&d.dataUpdatedAt===0,isPaused:p==="paused",isPlaceholderData:y,isRefetchError:C&&d.dataUpdatedAt!==0,isStale:Sm(t,n),refetch:this.refetch}}updateResult(t){const n=Z(this,er),r=this.createResult(Z(this,Zt),this.options);if(Ie(this,Da,Z(this,Zt).state),Ie(this,lc,this.options),Z(this,Da).data!==void 0&&Ie(this,uc,Z(this,Zt)),bm(r,n))return;Ie(this,er,r);const i={},o=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!Z(this,dc).size)return!0;const l=new Set(a??Z(this,dc));return this.options.throwOnError&&l.add("error"),Object.keys(Z(this,er)).some(c=>{const d=c;return Z(this,er)[d]!==n[d]&&l.has(d)})};(t==null?void 0:t.listeners)!==!1&&o()&&(i.listeners=!0),xt(this,ig,n3).call(this,{...i,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&xt(this,xd,W1).call(this)}},gr=new WeakMap,Zt=new WeakMap,gd=new WeakMap,er=new WeakMap,Da=new WeakMap,lc=new WeakMap,Qi=new WeakMap,md=new WeakMap,cc=new WeakMap,uc=new WeakMap,Ta=new WeakMap,Aa=new WeakMap,bs=new WeakMap,dc=new WeakMap,Ia=new WeakSet,qd=function(t){xt(this,Sd,G1).call(this);let n=Z(this,Zt).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Kr)),n},vd=new WeakSet,B1=function(){if(xt(this,wd,q1).call(this),rl||Z(this,er).isStale||!mm(this.options.staleTime))return;const n=Iw(Z(this,er).dataUpdatedAt,this.options.staleTime)+1;Ie(this,Ta,setTimeout(()=>{Z(this,er).isStale||this.updateResult()},n))},bd=new WeakSet,V1=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(Z(this,Zt)):this.options.refetchInterval)??!1},yd=new WeakSet,H1=function(t){xt(this,_d,U1).call(this),Ie(this,bs,t),!(rl||this.options.enabled===!1||!mm(Z(this,bs))||Z(this,bs)===0)&&Ie(this,Aa,setInterval(()=>{(this.options.refetchIntervalInBackground||rf.isFocused())&&xt(this,Ia,qd).call(this)},Z(this,bs)))},xd=new WeakSet,W1=function(){xt(this,vd,B1).call(this),xt(this,yd,H1).call(this,xt(this,bd,V1).call(this))},wd=new WeakSet,q1=function(){Z(this,Ta)&&(clearTimeout(Z(this,Ta)),Ie(this,Ta,void 0))},_d=new WeakSet,U1=function(){Z(this,Aa)&&(clearInterval(Z(this,Aa)),Ie(this,Aa,void 0))},Sd=new WeakSet,G1=function(){const t=Z(this,gr).getQueryCache().build(Z(this,gr),this.options);if(t===Z(this,Zt))return;const n=Z(this,Zt);Ie(this,Zt,t),Ie(this,gd,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},ig=new WeakSet,n3=function(t){In.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(Z(this,er))}),Z(this,gr).getQueryCache().notify({query:Z(this,Zt),type:"observerResultsUpdated"})})},DA);function TN(e,t){return t.enabled!==!1&&!e.state.dataUpdatedAt&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Hw(e,t){return TN(e,t)||e.state.dataUpdatedAt>0&&_m(e,t,t.refetchOnMount)}function _m(e,t,n){if(t.enabled!==!1){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Sm(e,t)}return!1}function Ww(e,t,n,r){return n.enabled!==!1&&(e!==t||r.enabled===!1)&&(!n.suspense||e.state.status!=="error")&&Sm(e,n)}function Sm(e,t){return e.isStaleByTime(t.staleTime)}function AN(e,t){return!bm(e.getCurrentResult(),t)}var qw=ue.createContext(void 0),IN=e=>{const t=ue.useContext(qw);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},NN=({client:e,children:t})=>(ue.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),ue.createElement(qw.Provider,{value:e},t)),Uw=ue.createContext(!1),RN=()=>ue.useContext(Uw);Uw.Provider;function LN(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var $N=ue.createContext(LN()),FN=()=>ue.useContext($N);function jN(e,t){return typeof e=="function"?e(...t):!!e}var zN=(e,t)=>{(e.suspense||e.throwOnError)&&(t.isReset()||(e.retryOnMount=!1))},BN=e=>{ue.useEffect(()=>{e.clearReset()},[e])},VN=({result:e,errorResetBoundary:t,throwOnError:n,query:r})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&jN(n,[e.error,r]),HN=e=>{e.suspense&&typeof e.staleTime!="number"&&(e.staleTime=1e3)},WN=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,qN=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function UN(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=IN(n),i=RN(),o=FN(),s=r.defaultQueryOptions(e);s._optimisticResults=i?"isRestoring":"optimistic",HN(s),zN(s,o),BN(o);const[a]=ue.useState(()=>new t(r,s)),l=a.getOptimisticResult(s);if(ue.useSyncExternalStore(ue.useCallback(c=>{const d=i?()=>{}:a.subscribe(In.batchCalls(c));return a.updateResult(),d},[a,i]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),ue.useEffect(()=>{a.setOptions(s,{listeners:!1})},[s,a]),WN(s,l))throw qN(s,a,o);if(VN({result:l,errorResetBoundary:o,throwOnError:s.throwOnError,query:r.getQueryCache().get(s.queryHash)}))throw l.error;return s.notifyOnChangeProps?l:a.trackResult(l)}function Sr(e,t){return UN(e,DN,t)}var af={exports:{}};/**
60
60
  * @license
61
61
  * Lodash <https://lodash.com/>
62
62
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
@@ -425,7 +425,7 @@ Check the top-level render call using <`+ae+">.")}return Y}}function Fa(M,Y){{if
425
425
  .block-interactivity-`.concat(e,` {pointer-events: none;}
426
426
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
427
427
  `)},vG=0,Rl=[];function bG(e){var t=ue.useRef([]),n=ue.useRef([0,0]),r=ue.useRef(),i=ue.useState(vG++)[0],o=ue.useState(function(){return $P()})[0],s=ue.useRef(e);ue.useEffect(function(){s.current=e},[e]),ue.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var y=zU([e.lockRef.current],(e.shards||[]).map(HP),!0).filter(Boolean);return y.forEach(function(x){return x.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),y.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=ue.useCallback(function(y,x){if("touches"in y&&y.touches.length===2)return!s.current.allowPinchZoom;var w=fp(y),S=n.current,C="deltaX"in y?y.deltaX:S[0]-w[0],P="deltaY"in y?y.deltaY:S[1]-w[1],O,k=y.target,A=Math.abs(C)>Math.abs(P)?"h":"v";if("touches"in y&&A==="h"&&k.type==="range")return!1;var L=jP(A,k);if(!L)return!0;if(L?O=A:(O=A==="v"?"h":"v",L=jP(A,k)),!L)return!1;if(!r.current&&"changedTouches"in y&&(C||P)&&(r.current=O),!O)return!0;var F=r.current||O;return pG(F,x,y,F==="h"?C:P,!0)},[]),l=ue.useCallback(function(y){var x=y;if(!(!Rl.length||Rl[Rl.length-1]!==o)){var w="deltaY"in x?VP(x):fp(x),S=t.current.filter(function(O){return O.name===x.type&&O.target===x.target&&gG(O.delta,w)})[0];if(S&&S.should){x.cancelable&&x.preventDefault();return}if(!S){var C=(s.current.shards||[]).map(HP).filter(Boolean).filter(function(O){return O.contains(x.target)}),P=C.length>0?a(x,C[0]):!s.current.noIsolation;P&&x.cancelable&&x.preventDefault()}}},[]),c=ue.useCallback(function(y,x,w,S){var C={name:y,delta:x,target:w,should:S};t.current.push(C),setTimeout(function(){t.current=t.current.filter(function(P){return P!==C})},1)},[]),d=ue.useCallback(function(y){n.current=fp(y),r.current=void 0},[]),f=ue.useCallback(function(y){c(y.type,VP(y),y.target,a(y,e.lockRef.current))},[]),g=ue.useCallback(function(y){c(y.type,fp(y),y.target,a(y,e.lockRef.current))},[]);ue.useEffect(function(){return Rl.push(o),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:g}),document.addEventListener("wheel",l,Nl),document.addEventListener("touchmove",l,Nl),document.addEventListener("touchstart",d,Nl),function(){Rl=Rl.filter(function(y){return y!==o}),document.removeEventListener("wheel",l,Nl),document.removeEventListener("touchmove",l,Nl),document.removeEventListener("touchstart",d,Nl)}},[]);var p=e.removeScrollBar,v=e.inert;return ue.createElement(ue.Fragment,null,v?ue.createElement(o,{styles:mG(i)}):null,p?ue.createElement(aG,{gapMode:"margin"}):null)}const yG=KU(RP,bG);var WP=ue.forwardRef(function(e,t){return ue.createElement(up,Wi({},e,{ref:t,sideCar:yG}))});WP.classNames=up.classNames;const hp=WP,qP="Popover",[UP,efe]=Pn(qP,[Fi]),oy=Fi(),[xG,Ll]=UP(qP),wG=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:s=!1}=e,a=oy(t),l=m.useRef(null),[c,d]=m.useState(!1),[f=!1,g]=Qn({prop:r,defaultProp:i,onChange:o});return m.createElement(Cu,a,m.createElement(xG,{scope:t,contentId:or(),triggerRef:l,open:f,onOpenChange:g,onOpenToggle:m.useCallback(()=>g(p=>!p),[g]),hasCustomAnchor:c,onCustomAnchorAdd:m.useCallback(()=>d(!0),[]),onCustomAnchorRemove:m.useCallback(()=>d(!1),[]),modal:s},n))},_G="PopoverTrigger",SG=m.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=Ll(_G,n),o=oy(n),s=et(t,i.triggerRef),a=m.createElement(Be.button,le({type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":KP(i.open)},r,{ref:s,onClick:Ce(e.onClick,i.onOpenToggle)}));return i.hasCustomAnchor?a:m.createElement(Eu,le({asChild:!0},o),a)}),GP="PopoverPortal",[CG,EG]=UP(GP,{forceMount:void 0}),OG=e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,o=Ll(GP,t);return m.createElement(CG,{scope:t,forceMount:n},m.createElement(vn,{present:n||o.open},m.createElement(Dh,{asChild:!0,container:i},r)))},Hu="PopoverContent",PG=m.forwardRef((e,t)=>{const n=EG(Hu,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,o=Ll(Hu,e.__scopePopover);return m.createElement(vn,{present:r||o.open},o.modal?m.createElement(kG,le({},i,{ref:t})):m.createElement(MG,le({},i,{ref:t})))}),kG=m.forwardRef((e,t)=>{const n=Ll(Hu,e.__scopePopover),r=m.useRef(null),i=et(t,r),o=m.useRef(!1);return m.useEffect(()=>{const s=r.current;if(s)return ap(s)},[]),m.createElement(hp,{as:no,allowPinchZoom:!0},m.createElement(YP,le({},e,{ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ce(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),o.current||(a=n.triggerRef.current)===null||a===void 0||a.focus()}),onPointerDownOutside:Ce(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;o.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:Ce(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})))}),MG=m.forwardRef((e,t)=>{const n=Ll(Hu,e.__scopePopover),r=m.useRef(!1),i=m.useRef(!1);return m.createElement(YP,le({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var s;if((s=e.onCloseAutoFocus)===null||s===void 0||s.call(e,o),!o.defaultPrevented){var a;r.current||(a=n.triggerRef.current)===null||a===void 0||a.focus(),o.preventDefault()}r.current=!1,i.current=!1},onInteractOutside:o=>{var s,a;(s=e.onInteractOutside)===null||s===void 0||s.call(e,o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const l=o.target;((a=n.triggerRef.current)===null||a===void 0?void 0:a.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}}))}),YP=m.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:d,...f}=e,g=Ll(Hu,n),p=oy(n);return rp(),m.createElement(ip,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o},m.createElement(wl,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:d,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>g.onOpenChange(!1)},m.createElement(Ou,le({"data-state":KP(g.open),role:"dialog",id:g.contentId},p,f,{ref:t,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}}))))});function KP(e){return e?"open":"closed"}const DG=wG,TG=SG,AG=OG,XP=PG,pp=DG,gp=TG,Wu=ue.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},i)=>_.jsx(AG,{children:_.jsx(XP,{ref:i,align:t,sideOffset:n,className:Pe("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})}));Wu.displayName=XP.displayName;function IG({filter:e,className:t}){const[n,r]=m.useState(!1),[i,o]=m.useState(),[s,a]=m.useState(),l=be(C=>C.filterValues),c=be(C=>C.authToken),d=be(C=>C.actions.addOrUpdateFilterValue),f=be(C=>C.actions.removeFilterValue),{data:g,isLoading:p,isFetching:v,isError:y,refetch:x}=Sr({queryKey:[e.sql],queryFn:()=>Ts("https://semaphor.cloud/api/v1/query",(c==null?void 0:c.accessToken)||"",{connection_id:e.connectionId,sql:e.sql}),enabled:!!e.sql&&!!e.connectionId&&!!e.database});m.useEffect(()=>{var C;if(((C=g==null?void 0:g.records)==null?void 0:C.length)>0){const P=g.records[0];if(!P.min||!P.max)return;o({from:new Date(P.min),to:new Date(P.max)}),a({from:new Date(P.min),to:new Date(P.max)})}},[g]),m.useEffect(()=>{if(l&&!l.find(P=>P.filterId===e.id)){o(s);return}},[l,e.id,s]);function w(){f(e.id),o(s),r(!1)}function S(){if(!i)return;console.log(i);const C=[i==null?void 0:i.from,i==null?void 0:i.to];console.log(C);const P={filterId:e.id,connectionType:e.database==="NA"?"api":"database",valueType:P0(e),name:e.column,operation:"between",values:C};d(P),r(!1)}return p?_.jsx("div",{children:_.jsx(lf,{className:" bg-foreground/10 h-8 w-[250px]"})}):y?_.jsx("div",{className:"bg-muted h-8 w-[250px] px-2",children:"Error"}):g?_.jsx("div",{className:Pe("grid gap-2",t),children:_.jsxs(pp,{open:n,onOpenChange:r,children:[_.jsx(gp,{asChild:!0,children:_.jsxs(it,{size:"sm",id:"date",variant:"outline",className:Pe("w-[250px] justify-start text-left font-normal rounded-sm h-[34px]",!i&&"text-muted-foreground"),children:[_.jsx(qB,{className:"mr-2 h-4 w-4"}),i!=null&&i.from?i.to?_.jsxs(_.Fragment,{children:[Hi(i.from,"LLL dd, y")," -"," ",Hi(i.to,"LLL dd, y")]}):Hi(i.from,"LLL dd, y"):_.jsx("span",{children:"Pick a date"})]})}),_.jsxs(Wu,{className:"w-auto p-0",align:"start",children:[_.jsx(EP,{initialFocus:!0,mode:"range",defaultMonth:i==null?void 0:i.from,selected:i,onSelect:o,numberOfMonths:2}),_.jsxs("div",{className:"flex justify-end px-4 py-3 gap-2",children:[_.jsx(it,{size:"sm",variant:"outline",onClick:S,children:"Apply"}),_.jsx(it,{size:"sm",variant:"outline",onClick:w,children:"Clear"})]})]})]})}):null}function NG(){const e=be(s=>s.dashboard.filters),t=be(s=>s.isDashboardEditing),n=be(s=>s.actions.removeFilter),r=be(s=>s.actions.updateFilter),i=be(s=>s.actions.removeFilterValue);if(!e)return null;const o=s=>Iu.includes(s.dataType)?_.jsx(IG,{filter:s}):_.jsx(HW,{filter:s});return _.jsx("section",{role:"dashboard-filters",className:" px-[10px] pt-0 grow w-full items-center flex gap-2 flex-wrap ",children:e.map(s=>_.jsxs("div",{children:[_.jsx(qc,{className:" my-1 ",text:s.title||s.column,onSave:a=>r({...s,title:a}),children:_.jsxs("div",{className:"flex items-center justify-between group mb-1",children:[_.jsxs("div",{className:"flex gap-1 items-center ",children:[_.jsx(fa,{className:" inline-block text-sm ",children:s.title}),t&&_.jsx(na,{onClick:()=>{i(s.id),n(s.id)},className:"w-3 h-3 invisible text-muted-foreground group-hover:visible hover:text-foreground cursor-pointer"})]}),_.jsx("div",{onClick:()=>i(s.id),className:" text-xs invisible group-hover:visible group-hover:underline cursor-pointer text-muted-foreground hover:text-foreground",children:"Clear"})]})}),o(s)]},s.id))})}function QP(){const e=be(i=>{var o;return(o=i.dashboard)==null?void 0:o.sheets});be(i=>i.isDashboardEditing);const t=be(i=>i.themeStyle);be(i=>i.isVisualEditing);const n=be(i=>i.selectedSheetId),r=be(i=>i.actions.setSelectedSheetId);return be(i=>i.actions.setSheetTitle),e?_.jsxs(a_,{role:"dashboard-tabs-container",className:Pe(" grow bg-muted dark:bg-foreground/5 p-2 ",t==null?void 0:t.dashboardTabsContainer),onValueChange:i=>{r(i)},value:n||e[0].id,children:[_.jsx(NG,{}),e==null?void 0:e.map(i=>_.jsx(ff,{className:"mt-0",value:i.id,children:_.jsx(uH,{})},i.id))]}):null}function ZP({children:e}){const t=new MN;return _.jsx(KN,{defaultTheme:"dark",storageKey:"vite-ui-theme",children:_.jsx($B,{delayDuration:0,children:_.jsx(NN,{client:t,children:e})})})}function JP(e){return _.jsx(ZP,{children:_.jsx(Kw,{...e,children:_.jsx(QP,{})})})}var RG=Object.defineProperty,LG=(e,t,n)=>t in e?RG(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mp=(e,t,n)=>(LG(e,typeof t!="symbol"?t+"":t,n),n);const $G={stringify:e=>e,parse:e=>e},FG={stringify:e=>`${e}`,parse:e=>parseFloat(e)},jG={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},zG={stringify:e=>e.name,parse:(e,t)=>{const n=(()=>{if(typeof window<"u"&&e in window)return window[e];if(typeof global<"u"&&e in global)return global[e]})();return typeof n=="function"?n.bind(t):void 0}},BG={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)},sy={string:$G,number:FG,boolean:jG,function:zG,json:BG},ay=Symbol.for("r2wc.render"),vp=Symbol.for("r2wc.connected"),ga=Symbol.for("r2wc.context"),is=Symbol.for("r2wc.props");function VG(e,t,n){var r,i,o;t.props||(t.props=e.propTypes?Object.keys(e.propTypes):[]);const s=(Array.isArray(t.props)?t.props.slice():Object.keys(t.props)).filter(f=>f!=="container"),a={},l={},c={};for(const f of s){a[f]=Array.isArray(t.props)?"string":t.props[f];const g=HG(f);l[f]=g,c[g]=f}class d extends HTMLElement{constructor(){super(),mp(this,r,!0),mp(this,i),mp(this,o,{}),mp(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[is].container=this.container;for(const g of s){const p=l[g],v=this.getAttribute(p),y=a[g],x=sy[y];v&&x!=null&&x.parse&&(this[is][g]=x.parse(v,this))}}static get observedAttributes(){return Object.keys(c)}connectedCallback(){this[vp]=!0,this[ay]()}disconnectedCallback(){this[vp]=!1,this[ga]&&n.unmount(this[ga]),delete this[ga]}attributeChangedCallback(g,p,v){const y=c[g],x=a[y],w=sy[x];y in a&&w!=null&&w.parse&&(this[is][y]=w.parse(v,this),this[ay]())}[(r=vp,i=ga,o=is,ay)](){this[vp]&&(this[ga]?n.update(this[ga],this[is]):this[ga]=n.mount(this.container,e,this[is]))}}for(const f of s){const g=l[f],p=a[f];Object.defineProperty(d.prototype,f,{enumerable:!0,configurable:!0,get(){return this[is][f]},set(v){this[is][f]=v;const y=sy[p];if(y!=null&&y.stringify){const x=y.stringify(v);this.getAttribute(g)!==x&&this.setAttribute(g,x)}}})}return d}function HG(e=""){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function WG(e,t,n){const r=tf(e),i=m.createElement(t,n);return r.render(i),{root:r,ReactComponent:t}}function qG({root:e,ReactComponent:t},n){const r=m.createElement(t,n);e.render(r)}function UG({root:e}){e.unmount()}function GG(e,t={}){return VG(e,t,{mount:WG,update:qG,unmount:UG})}const YG=GG(JP,{props:{id:"string",authToken:"json",currentTheme:"string",style:"json",onEvent:"function",onSave:"function",LoadingComponent:"function",ErrorComponent:"function"}}),ly=["Enter"," "],KG=["ArrowDown","PageUp","Home"],ek=["ArrowUp","PageDown","End"],XG=[...KG,...ek],QG={ltr:[...ly,"ArrowRight"],rtl:[...ly,"ArrowLeft"]},ZG={ltr:["ArrowLeft"],rtl:["ArrowRight"]},bp="Menu",[qu,JG,eY]=uf(bp),[ma,tk]=Pn(bp,[eY,Fi,il]),cy=Fi(),nk=il(),[tY,va]=ma(bp),[nY,Uu]=ma(bp),rY=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:o,modal:s=!0}=e,a=cy(t),[l,c]=m.useState(null),d=m.useRef(!1),f=xn(o),g=Ls(i);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),m.createElement(Cu,a,m.createElement(tY,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c},m.createElement(nY,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:g,modal:s},r)))},rk=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=cy(n);return m.createElement(Eu,le({},i,r,{ref:t}))}),ik="MenuPortal",[iY,ok]=ma(ik,{forceMount:void 0}),oY=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,o=va(ik,t);return m.createElement(iY,{scope:t,forceMount:n},m.createElement(vn,{present:n||o.open},m.createElement(Dh,{asChild:!0,container:i},r)))},wi="MenuContent",[sY,uy]=ma(wi),aY=m.forwardRef((e,t)=>{const n=ok(wi,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=va(wi,e.__scopeMenu),s=Uu(wi,e.__scopeMenu);return m.createElement(qu.Provider,{scope:e.__scopeMenu},m.createElement(vn,{present:r||o.open},m.createElement(qu.Slot,{scope:e.__scopeMenu},s.modal?m.createElement(lY,le({},i,{ref:t})):m.createElement(cY,le({},i,{ref:t})))))}),lY=m.forwardRef((e,t)=>{const n=va(wi,e.__scopeMenu),r=m.useRef(null),i=et(t,r);return m.useEffect(()=>{const o=r.current;if(o)return ap(o)},[]),m.createElement(dy,le({},e,{ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ce(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)}))}),cY=m.forwardRef((e,t)=>{const n=va(wi,e.__scopeMenu);return m.createElement(dy,le({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)}))}),dy=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:g,onDismiss:p,disableOutsideScroll:v,...y}=e,x=va(wi,n),w=Uu(wi,n),S=cy(n),C=nk(n),P=JG(n),[O,k]=m.useState(null),A=m.useRef(null),L=et(t,A,x.onContentChange),F=m.useRef(0),z=m.useRef(""),B=m.useRef(0),V=m.useRef(null),X=m.useRef("right"),K=m.useRef(0),$=v?hp:m.Fragment,J=v?{as:no,allowPinchZoom:!0}:void 0,G=se=>{var D,W;const re=z.current+se,N=P().filter(ee=>!ee.disabled),ne=document.activeElement,ge=(D=N.find(ee=>ee.ref.current===ne))===null||D===void 0?void 0:D.textValue,he=N.map(ee=>ee.textValue),de=kY(he,re,ge),ie=(W=N.find(ee=>ee.textValue===de))===null||W===void 0?void 0:W.ref.current;(function ee(H){z.current=H,window.clearTimeout(F.current),H!==""&&(F.current=window.setTimeout(()=>ee(""),1e3))})(re),ie&&setTimeout(()=>ie.focus())};m.useEffect(()=>()=>window.clearTimeout(F.current),[]),rp();const q=m.useCallback(se=>{var D,W;return X.current===((D=V.current)===null||D===void 0?void 0:D.side)&&DY(se,(W=V.current)===null||W===void 0?void 0:W.area)},[]);return m.createElement(sY,{scope:n,searchRef:z,onItemEnter:m.useCallback(se=>{q(se)&&se.preventDefault()},[q]),onItemLeave:m.useCallback(se=>{var D;q(se)||((D=A.current)===null||D===void 0||D.focus(),k(null))},[q]),onTriggerLeave:m.useCallback(se=>{q(se)&&se.preventDefault()},[q]),pointerGraceTimerRef:B,onPointerGraceIntentChange:m.useCallback(se=>{V.current=se},[])},m.createElement($,J,m.createElement(ip,{asChild:!0,trapped:i,onMountAutoFocus:Ce(o,se=>{var D;se.preventDefault(),(D=A.current)===null||D===void 0||D.focus()}),onUnmountAutoFocus:s},m.createElement(wl,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:g,onDismiss:p},m.createElement(Mm,le({asChild:!0},C,{dir:w.dir,orientation:"vertical",loop:r,currentTabStopId:O,onCurrentTabStopIdChange:k,onEntryFocus:Ce(l,se=>{w.isUsingKeyboardRef.current||se.preventDefault()})}),m.createElement(Ou,le({role:"menu","aria-orientation":"vertical","data-state":dk(x.open),"data-radix-menu-content":"",dir:w.dir},S,y,{ref:L,style:{outline:"none",...y.style},onKeyDown:Ce(y.onKeyDown,se=>{const W=se.target.closest("[data-radix-menu-content]")===se.currentTarget,re=se.ctrlKey||se.altKey||se.metaKey,N=se.key.length===1;W&&(se.key==="Tab"&&se.preventDefault(),!re&&N&&G(se.key));const ne=A.current;if(se.target!==ne||!XG.includes(se.key))return;se.preventDefault();const he=P().filter(de=>!de.disabled).map(de=>de.ref.current);ek.includes(se.key)&&he.reverse(),OY(he)}),onBlur:Ce(e.onBlur,se=>{se.currentTarget.contains(se.target)||(window.clearTimeout(F.current),z.current="")}),onPointerMove:Ce(e.onPointerMove,Gu(se=>{const D=se.target,W=K.current!==se.clientX;if(se.currentTarget.contains(D)&&W){const re=se.clientX>K.current?"right":"left";X.current=re,K.current=se.clientX}}))})))))))}),uY=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.createElement(Be.div,le({role:"group"},r,{ref:t}))}),dY=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.createElement(Be.div,le({},r,{ref:t}))}),fy="MenuItem",sk="menu.itemSelect",hy=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,o=m.useRef(null),s=Uu(fy,e.__scopeMenu),a=uy(fy,e.__scopeMenu),l=et(t,o),c=m.useRef(!1),d=()=>{const f=o.current;if(!n&&f){const g=new CustomEvent(sk,{bubbles:!0,cancelable:!0});f.addEventListener(sk,p=>r==null?void 0:r(p),{once:!0}),Qw(f,g),g.defaultPrevented?c.current=!1:s.onClose()}};return m.createElement(ak,le({},i,{ref:l,disabled:n,onClick:Ce(e.onClick,d),onPointerDown:f=>{var g;(g=e.onPointerDown)===null||g===void 0||g.call(e,f),c.current=!0},onPointerUp:Ce(e.onPointerUp,f=>{var g;c.current||(g=f.currentTarget)===null||g===void 0||g.click()}),onKeyDown:Ce(e.onKeyDown,f=>{const g=a.searchRef.current!=="";n||g&&f.key===" "||ly.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})}))}),ak=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...o}=e,s=uy(fy,n),a=nk(n),l=m.useRef(null),c=et(t,l),[d,f]=m.useState(!1),[g,p]=m.useState("");return m.useEffect(()=>{const v=l.current;if(v){var y;p(((y=v.textContent)!==null&&y!==void 0?y:"").trim())}},[o.children]),m.createElement(qu.ItemSlot,{scope:n,disabled:r,textValue:i??g},m.createElement(Dm,le({asChild:!0},a,{focusable:!r}),m.createElement(Be.div,le({role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0},o,{ref:c,onPointerMove:Ce(e.onPointerMove,Gu(v=>{r?s.onItemLeave(v):(s.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus())})),onPointerLeave:Ce(e.onPointerLeave,Gu(v=>s.onItemLeave(v))),onFocus:Ce(e.onFocus,()=>f(!0)),onBlur:Ce(e.onBlur,()=>f(!1))}))))}),fY=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return m.createElement(ck,{scope:e.__scopeMenu,checked:n},m.createElement(hy,le({role:"menuitemcheckbox","aria-checked":xp(n)?"mixed":n},i,{ref:t,"data-state":py(n),onSelect:Ce(i.onSelect,()=>r==null?void 0:r(xp(n)?!0:!n),{checkForDefaultPrevented:!1})})))}),hY="MenuRadioGroup",[pY,gY]=ma(hY,{value:void 0,onValueChange:()=>{}}),mY=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,o=xn(r);return m.createElement(pY,{scope:e.__scopeMenu,value:n,onValueChange:o},m.createElement(uY,le({},i,{ref:t})))}),vY="MenuRadioItem",bY=m.forwardRef((e,t)=>{const{value:n,...r}=e,i=gY(vY,e.__scopeMenu),o=n===i.value;return m.createElement(ck,{scope:e.__scopeMenu,checked:o},m.createElement(hy,le({role:"menuitemradio","aria-checked":o},r,{ref:t,"data-state":py(o),onSelect:Ce(r.onSelect,()=>{var s;return(s=i.onValueChange)===null||s===void 0?void 0:s.call(i,n)},{checkForDefaultPrevented:!1})})))}),lk="MenuItemIndicator",[ck,yY]=ma(lk,{checked:!1}),xY=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,o=yY(lk,n);return m.createElement(vn,{present:r||xp(o.checked)||o.checked===!0},m.createElement(Be.span,le({},i,{ref:t,"data-state":py(o.checked)})))}),wY=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return m.createElement(Be.div,le({role:"separator","aria-orientation":"horizontal"},r,{ref:t}))}),_Y="MenuSub",[nfe,uk]=ma(_Y),yp="MenuSubTrigger",SY=m.forwardRef((e,t)=>{const n=va(yp,e.__scopeMenu),r=Uu(yp,e.__scopeMenu),i=uk(yp,e.__scopeMenu),o=uy(yp,e.__scopeMenu),s=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=o,c={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),m.createElement(rk,le({asChild:!0},c),m.createElement(ak,le({id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":dk(n.open)},e,{ref:cf(t,i.onTriggerChange),onClick:f=>{var g;(g=e.onClick)===null||g===void 0||g.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ce(e.onPointerMove,Gu(f=>{o.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!s.current&&(o.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:Ce(e.onPointerLeave,Gu(f=>{var g;d();const p=(g=n.content)===null||g===void 0?void 0:g.getBoundingClientRect();if(p){var v;const y=(v=n.content)===null||v===void 0?void 0:v.dataset.side,x=y==="right",w=x?-5:5,S=p[x?"left":"right"],C=p[x?"right":"left"];o.onPointerGraceIntentChange({area:[{x:f.clientX+w,y:f.clientY},{x:S,y:p.top},{x:C,y:p.top},{x:C,y:p.bottom},{x:S,y:p.bottom}],side:y}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(f),f.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Ce(e.onKeyDown,f=>{const g=o.searchRef.current!=="";if(!(e.disabled||g&&f.key===" ")&&QG[r.dir].includes(f.key)){var p;n.onOpenChange(!0),(p=n.content)===null||p===void 0||p.focus(),f.preventDefault()}})})))}),CY="MenuSubContent",EY=m.forwardRef((e,t)=>{const n=ok(wi,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=va(wi,e.__scopeMenu),s=Uu(wi,e.__scopeMenu),a=uk(CY,e.__scopeMenu),l=m.useRef(null),c=et(t,l);return m.createElement(qu.Provider,{scope:e.__scopeMenu},m.createElement(vn,{present:r||o.open},m.createElement(qu.Slot,{scope:e.__scopeMenu},m.createElement(dy,le({id:a.contentId,"aria-labelledby":a.triggerId},i,{ref:c,align:"start",side:s.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;s.isUsingKeyboardRef.current&&((f=l.current)===null||f===void 0||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:Ce(e.onFocusOutside,d=>{d.target!==a.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Ce(e.onEscapeKeyDown,d=>{s.onClose(),d.preventDefault()}),onKeyDown:Ce(e.onKeyDown,d=>{const f=d.currentTarget.contains(d.target),g=ZG[s.dir].includes(d.key);if(f&&g){var p;o.onOpenChange(!1),(p=a.trigger)===null||p===void 0||p.focus(),d.preventDefault()}})})))))});function dk(e){return e?"open":"closed"}function xp(e){return e==="indeterminate"}function py(e){return xp(e)?"indeterminate":e?"checked":"unchecked"}function OY(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function PY(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function kY(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let s=PY(e,Math.max(o,0));i.length===1&&(s=s.filter(c=>c!==n));const l=s.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function MY(e,t){const{x:n,y:r}=e;let i=!1;for(let o=0,s=t.length-1;o<t.length;s=o++){const a=t[o].x,l=t[o].y,c=t[s].x,d=t[s].y;l>r!=d>r&&n<(c-a)*(r-l)/(d-l)+a&&(i=!i)}return i}function DY(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return MY(n,t)}function Gu(e){return t=>t.pointerType==="mouse"?e(t):void 0}const TY=rY,AY=rk,IY=oY,NY=aY,RY=dY,LY=hy,$Y=fY,FY=mY,jY=bY,zY=xY,BY=wY,VY=SY,HY=EY,fk="DropdownMenu",[WY,rfe]=Pn(fk,[tk]),Nr=tk(),[qY,hk]=WY(fk),UY=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:o,onOpenChange:s,modal:a=!0}=e,l=Nr(t),c=m.useRef(null),[d=!1,f]=Qn({prop:i,defaultProp:o,onChange:s});return m.createElement(qY,{scope:t,triggerId:or(),triggerRef:c,contentId:or(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(g=>!g),[f]),modal:a},m.createElement(TY,le({},l,{open:d,onOpenChange:f,dir:r,modal:a}),n))},GY="DropdownMenuTrigger",YY=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,o=hk(GY,n),s=Nr(n);return m.createElement(AY,le({asChild:!0},s),m.createElement(Be.button,le({type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,disabled:r},i,{ref:cf(t,o.triggerRef),onPointerDown:Ce(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(o.onOpenToggle(),o.open||a.preventDefault())}),onKeyDown:Ce(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&o.onOpenToggle(),a.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})))}),KY=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Nr(t);return m.createElement(IY,le({},r,n))},XY="DropdownMenuContent",QY=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=hk(XY,n),o=Nr(n),s=m.useRef(!1);return m.createElement(NY,le({id:i.contentId,"aria-labelledby":i.triggerId},o,r,{ref:t,onCloseAutoFocus:Ce(e.onCloseAutoFocus,a=>{var l;s.current||(l=i.triggerRef.current)===null||l===void 0||l.focus(),s.current=!1,a.preventDefault()}),onInteractOutside:Ce(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;(!i.modal||d)&&(s.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))}),ZY=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement(RY,le({},i,r,{ref:t}))}),JY=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement(LY,le({},i,r,{ref:t}))}),eK=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement($Y,le({},i,r,{ref:t}))}),tK=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement(FY,le({},i,r,{ref:t}))}),nK=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement(jY,le({},i,r,{ref:t}))}),rK=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement(zY,le({},i,r,{ref:t}))}),iK=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement(BY,le({},i,r,{ref:t}))}),oK=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement(VY,le({},i,r,{ref:t}))}),sK=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Nr(n);return m.createElement(HY,le({},i,r,{ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))}),aK=UY,lK=YY,cK=KY,pk=QY,gk=ZY,mk=JY,vk=eK,uK=tK,bk=nK,yk=rK,xk=iK,wk=oK,_k=sK,Sk=aK,Ck=lK,dK=uK,fK=ue.forwardRef(({className:e,inset:t,children:n,...r},i)=>_.jsxs(wk,{ref:i,className:Pe("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,_.jsx(V2,{className:"ml-auto h-4 w-4"})]}));fK.displayName=wk.displayName;const hK=ue.forwardRef(({className:e,...t},n)=>_.jsx(_k,{ref:n,className:Pe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));hK.displayName=_k.displayName;const gy=ue.forwardRef(({className:e,sideOffset:t=4,...n},r)=>_.jsx(cK,{children:_.jsx(pk,{ref:r,sideOffset:t,className:Pe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));gy.displayName=pk.displayName;const wp=ue.forwardRef(({className:e,inset:t,...n},r)=>_.jsx(mk,{ref:r,className:Pe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));wp.displayName=mk.displayName;const pK=ue.forwardRef(({className:e,children:t,checked:n,...r},i)=>_.jsxs(vk,{ref:i,className:Pe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[_.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:_.jsx(yk,{children:_.jsx(Rh,{className:"h-4 w-4"})})}),t]}));pK.displayName=vk.displayName;const my=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsxs(bk,{ref:r,className:Pe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[_.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:_.jsx(yk,{children:_.jsx(H2,{className:"h-2 w-2 fill-current"})})}),t]}));my.displayName=bk.displayName;const Ek=ue.forwardRef(({className:e,inset:t,...n},r)=>_.jsx(gk,{ref:r,className:Pe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Ek.displayName=gk.displayName;const Ok=ue.forwardRef(({className:e,...t},n)=>_.jsx(xk,{ref:n,className:Pe("-mx-1 my-1 h-px bg-muted",e),...t}));Ok.displayName=xk.displayName;function gK(){const{setTheme:e}=Cm(),t=be(n=>n.actions.setDashboardTheme);return _.jsxs(Sk,{children:[_.jsx(Ck,{asChild:!0,children:_.jsxs(it,{className:"h-7 p-2",variant:"outline",size:"sm",children:[_.jsx(rV,{strokeWidth:1.5,className:"h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),_.jsx(QB,{strokeWidth:1.5,className:"absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),_.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),_.jsxs(gy,{align:"end",children:[_.jsx(wp,{onClick:()=>{e("light"),t("light")},children:"Light"}),_.jsx(wp,{onClick:()=>{e("dark"),t("dark")},children:"Dark"}),_.jsx(wp,{onClick:()=>{e("system"),t("system")},children:"System"})]})]})}function vy(e){var t;return{...e,sheets:(t=e==null?void 0:e.sheets)==null?void 0:t.map(n=>{var r;return{...n,cards:(r=n==null?void 0:n.cards)==null?void 0:r.map(i=>Pk(i))}})}}function Pk(e){var t,n,r,i;return{...e,cfg:{...e.cfg,data:{...(t=e.cfg)==null?void 0:t.data,labels:[],datasets:(i=(r=(n=e.cfg)==null?void 0:n.data)==null?void 0:r.datasets)==null?void 0:i.map(o=>({...o,data:[]}))}},customCfg:mK(e.customCfg),data:[]}}function mK(e){var t,n;return e?{...e,data:{...e==null?void 0:e.data,labels:[],datasets:(n=(t=e==null?void 0:e.data)==null?void 0:t.datasets)==null?void 0:n.map(r=>({...r,data:[]}))}}:null}function $l(e){return`semaphor:bookmark:${e}`}const kk="Dialog",[Mk,ife]=Pn(kk),[vK,_i]=Mk(kk),bK=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:s=!0}=e,a=m.useRef(null),l=m.useRef(null),[c=!1,d]=Qn({prop:r,defaultProp:i,onChange:o});return m.createElement(vK,{scope:t,triggerRef:a,contentRef:l,contentId:or(),titleId:or(),descriptionId:or(),open:c,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(f=>!f),[d]),modal:s},n)},yK="DialogTrigger",xK=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=_i(yK,n),o=et(t,i.triggerRef);return m.createElement(Be.button,le({type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":yy(i.open)},r,{ref:o,onClick:Ce(e.onClick,i.onOpenToggle)}))}),Dk="DialogPortal",[wK,Tk]=Mk(Dk,{forceMount:void 0}),_K=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,o=_i(Dk,t);return m.createElement(wK,{scope:t,forceMount:n},m.Children.map(r,s=>m.createElement(vn,{present:n||o.open},m.createElement(Dh,{asChild:!0,container:i},s))))},by="DialogOverlay",SK=m.forwardRef((e,t)=>{const n=Tk(by,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=_i(by,e.__scopeDialog);return o.modal?m.createElement(vn,{present:r||o.open},m.createElement(CK,le({},i,{ref:t}))):null}),CK=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=_i(by,n);return m.createElement(hp,{as:no,allowPinchZoom:!0,shards:[i.contentRef]},m.createElement(Be.div,le({"data-state":yy(i.open)},r,{ref:t,style:{pointerEvents:"auto",...r.style}})))}),Yu="DialogContent",EK=m.forwardRef((e,t)=>{const n=Tk(Yu,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=_i(Yu,e.__scopeDialog);return m.createElement(vn,{present:r||o.open},o.modal?m.createElement(OK,le({},i,{ref:t})):m.createElement(PK,le({},i,{ref:t})))}),OK=m.forwardRef((e,t)=>{const n=_i(Yu,e.__scopeDialog),r=m.useRef(null),i=et(t,n.contentRef,r);return m.useEffect(()=>{const o=r.current;if(o)return ap(o)},[]),m.createElement(Ak,le({},e,{ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ce(e.onCloseAutoFocus,o=>{var s;o.preventDefault(),(s=n.triggerRef.current)===null||s===void 0||s.focus()}),onPointerDownOutside:Ce(e.onPointerDownOutside,o=>{const s=o.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&o.preventDefault()}),onFocusOutside:Ce(e.onFocusOutside,o=>o.preventDefault())}))}),PK=m.forwardRef((e,t)=>{const n=_i(Yu,e.__scopeDialog),r=m.useRef(!1),i=m.useRef(!1);return m.createElement(Ak,le({},e,{ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var s;if((s=e.onCloseAutoFocus)===null||s===void 0||s.call(e,o),!o.defaultPrevented){var a;r.current||(a=n.triggerRef.current)===null||a===void 0||a.focus(),o.preventDefault()}r.current=!1,i.current=!1},onInteractOutside:o=>{var s,a;(s=e.onInteractOutside)===null||s===void 0||s.call(e,o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const l=o.target;((a=n.triggerRef.current)===null||a===void 0?void 0:a.contains(l))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}}))}),Ak=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...s}=e,a=_i(Yu,n),l=m.useRef(null),c=et(t,l);return rp(),m.createElement(m.Fragment,null,m.createElement(ip,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o},m.createElement(wl,le({role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":yy(a.open)},s,{ref:c,onDismiss:()=>a.onOpenChange(!1)}))),!1)}),kK="DialogTitle",MK=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=_i(kK,n);return m.createElement(Be.h2,le({id:i.titleId},r,{ref:t}))}),DK="DialogDescription",TK=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=_i(DK,n);return m.createElement(Be.p,le({id:i.descriptionId},r,{ref:t}))}),AK="DialogClose",IK=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=_i(AK,n);return m.createElement(Be.button,le({type:"button"},r,{ref:t,onClick:Ce(e.onClick,()=>i.onOpenChange(!1))}))});function yy(e){return e?"open":"closed"}const NK=bK,RK=xK,LK=_K,Ik=SK,Nk=EK,Rk=MK,Lk=TK,$K=IK,xy=NK,wy=RK,FK=LK,$k=ue.forwardRef(({className:e,...t},n)=>_.jsx(Ik,{ref:n,className:Pe("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));$k.displayName=Ik.displayName;const _p=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsxs(FK,{children:[_.jsx($k,{}),_.jsxs(Nk,{ref:r,className:Pe("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,_.jsxs($K,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[_.jsx(sV,{className:"h-4 w-4"}),_.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));_p.displayName=Nk.displayName;const Sp=({className:e,...t})=>_.jsx("div",{className:Pe("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Sp.displayName="DialogHeader";const _y=({className:e,...t})=>_.jsx("div",{className:Pe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});_y.displayName="DialogFooter";const Cp=ue.forwardRef(({className:e,...t},n)=>_.jsx(Rk,{ref:n,className:Pe("text-lg font-semibold leading-none tracking-tight",e),...t}));Cp.displayName=Rk.displayName;const Ep=ue.forwardRef(({className:e,...t},n)=>_.jsx(Lk,{ref:n,className:Pe("text-sm text-muted-foreground",e),...t}));Ep.displayName=Lk.displayName;const Ku=ue.forwardRef(({className:e,type:t,...n},r)=>_.jsx("input",{type:t,className:Pe("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));Ku.displayName="Input";function jK(){const[e,t]=m.useState(""),[n,r]=m.useState(!1),[i,o]=m.useState(!1),s=be(l=>l.dashboard);function a(){const l=vy(s),c=$l(s.id),d=JSON.parse(localStorage.getItem(c)||"[]");if(d.some(g=>g.name===e)){r(!0);return}d.push({name:e,template:l}),localStorage.setItem(c,JSON.stringify(d)),o(!1)}return _.jsxs(xy,{open:i,onOpenChange:o,children:[_.jsx(wy,{asChild:!0,children:_.jsx(it,{variant:"outline",className:"h-7 p-2",size:"sm",children:_.jsx(WB,{className:"h-4 w-4",strokeWidth:1.5})})}),_.jsxs(_p,{className:"sm:max-w-[425px]",children:[_.jsxs(Sp,{children:[_.jsx(Cp,{children:"Add Bookmark"}),_.jsx(Ep,{children:"Bookmarks are private by default and are only visible to you."})]}),_.jsx("div",{className:"grid gap-4 py-4",children:_.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[_.jsx(fa,{className:"text-right",children:"Name"}),_.jsx(Ku,{value:e,onChange:l=>{n&&r(!1),t(l.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),n&&_.jsx("p",{className:"text-sm",children:"The bookmark name already exists. Use a differnet name."}),_.jsx(_y,{children:_.jsx(it,{type:"submit",disabled:!e,onClick:a,children:"Save"})})]})]})}function zK(){const[e,t]=m.useState(!1),[n,r]=m.useState(""),i=be(f=>f.dashboard),[o,s]=m.useState([]),a=be(f=>f.actions.setDashboard),l=be(f=>f.actions.setBookmarkKey);m.useEffect(()=>{const f=$l(i.id),g=JSON.parse(localStorage.getItem(f)||"[]");s(g)},[e,i]);function c(f){if(f===n)return;const g=o.find(v=>v.name===f),p=g==null?void 0:g.template;p&&(a(p),l(f==="Original"?"":f)),r(f)}function d(f){const g=$l(i.id),v=JSON.parse(localStorage.getItem(g)||"[]").filter(y=>y.name!==f);localStorage.setItem(g,JSON.stringify(v)),s(v)}return _.jsxs(Sk,{open:e,onOpenChange:t,children:[_.jsx(Ck,{asChild:!0,children:_.jsx(it,{variant:"outline",className:"h-7 p-2",children:"Bookmarks"})}),_.jsxs(gy,{className:"w-56",children:[_.jsx(Ek,{children:"Local Bookmarks"}),_.jsx(Ok,{}),_.jsxs(dK,{value:n,onValueChange:c,children:[_.jsx(my,{value:"Original",children:"Original"}),o.filter(f=>f.name!="Original").map((f,g)=>_.jsxs(my,{className:"xbg-red-100 flex justify-between",value:f.name,children:[_.jsx("p",{children:f.name}),_.jsx(na,{onClick:p=>{p.preventDefault(),d(f.name)},className:"h-3 w-3 hover:cursor-pointer",strokeWidth:1.5})]},g))]})]})]})}function BK(){const e=be(C=>C.bookmarkKey),t=be(C=>C.dashboard),n=be(C=>C.selectedSheetId),r=be(C=>C.isDashboardEditing),i=be(C=>C.isVisualEditing),o=be(C=>C.showFilters),s=be(C=>C.showDashboardJSON),a=be(C=>C.actions.setShowDashboardJSON),l=be(C=>C.onSaveFunction),c=be(C=>C.actions.setShowFilters),{addCard:d,getSelectedSheet:f,setIsDashboardEditing:g,setSelectedCardId:p,setSelectedCard:v}=be(C=>C.actions),y=f(),x=()=>{if(!r||!y)return;const C={id:yh(),title:"New Card",description:"New Card Description",preferences:{filterOnClick:!0},type:"bar",sql:"select COUNT(*) from YOUR_TABLE",data:[]};d(y.id,C),p(n,C.id),v(C)},w=()=>{g(!0)};function S(){if(!e||e==="")return;const C=vy(t),P=$l(t.id),O=JSON.parse(localStorage.getItem(P)||"[]"),k=O.findIndex(A=>A.name===e);k!==-1?O[k]={name:e,template:C}:O.push({name:e,template:C}),localStorage.setItem(P,JSON.stringify(O)),l==null||l(C)}return _.jsxs("div",{className:`flex items-center justify-between gap-2 border-b-[3px]
428
- border-b-muted py-2 `,role:"dashboard-controls",children:[_.jsx("div",{children:e}),_.jsxs("div",{className:"flex gap-2",children:[r&&!i&&_.jsx(jK,{}),_.jsx(zK,{}),r&&!i&&_.jsxs(it,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!r,onClick:x,children:[_.jsx(eV,{className:" mr-2 h-4 w-4",strokeWidth:1.5}),"Add Card"]}),!r&&_.jsx(it,{variant:"outline",className:"h-7 p-2",onClick:w,size:"sm",children:_.jsx(ZB,{className:"h-4 w-4",strokeWidth:1.5})}),r&&!i&&_.jsx(it,{variant:"outline",role:"close",className:"h-7 p-2",onClick:()=>g(!1),size:"sm",children:_.jsx(na,{className:"h-4 w-4",strokeWidth:1.5})}),r&&!i&&_.jsx(it,{className:"h-7 p-2",variant:"outline",onClick:S,size:"sm",children:_.jsx(tV,{className:"h-4 w-4",strokeWidth:1.5})}),!o&&!i&&r&&_.jsx(it,{className:"h-7 p-2",variant:"outline",onClick:()=>c(!0),size:"sm",children:_.jsx(W2,{className:"h-4 w-4",strokeWidth:1.5})}),!i&&r&&_.jsx("div",{className:" flex items-center space-x-2",children:_.jsx(it,{className:"h-7 p-2",onClick:()=>a(!s),size:"sm",variant:"outline",children:_.jsx(YB,{className:"h-4 w-4",strokeWidth:1.5})})}),_.jsx(gK,{})]})]})}const Fk=m.forwardRef(({className:e,...t},n)=>_.jsx("div",{role:"editor-panel",ref:n,className:Pe("flex grow min-h-[80vh]",e),...t}));Fk.displayName="EditorPanel";const jk=m.forwardRef(({className:e,...t},n)=>_.jsx("div",{ref:n,className:Pe(" flex flex-col space-y-2 w-[270px]",e),...t}));jk.displayName="EditorAside";const zk=m.forwardRef(({className:e,...t},n)=>_.jsx("div",{ref:n,className:Pe(" grow",e),...t}));zk.displayName="EditorMain";function Op(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}const VK=[" ","Enter","ArrowUp","ArrowDown"],HK=[" ","Enter"],Pp="Select",[kp,Mp,WK]=uf(Pp),[Fl,ofe]=Pn(Pp,[WK,Fi]),Sy=Fi(),[qK,ba]=Fl(Pp),[UK,GK]=Fl(Pp),YK=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:o,value:s,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:f,disabled:g,required:p}=e,v=Sy(t),[y,x]=m.useState(null),[w,S]=m.useState(null),[C,P]=m.useState(!1),O=Ls(c),[k=!1,A]=Qn({prop:r,defaultProp:i,onChange:o}),[L,F]=Qn({prop:s,defaultProp:a,onChange:l}),z=m.useRef(null),B=y?!!y.closest("form"):!0,[V,X]=m.useState(new Set),K=Array.from(V).map($=>$.props.value).join(";");return m.createElement(Cu,v,m.createElement(qK,{required:p,scope:t,trigger:y,onTriggerChange:x,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:C,onValueNodeHasChildrenChange:P,contentId:or(),value:L,onValueChange:F,open:k,onOpenChange:A,dir:O,triggerPointerDownPosRef:z,disabled:g},m.createElement(kp.Provider,{scope:t},m.createElement(UK,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback($=>{X(J=>new Set(J).add($))},[]),onNativeOptionRemove:m.useCallback($=>{X(J=>{const G=new Set(J);return G.delete($),G})},[])},n)),B?m.createElement(Kk,{key:K,"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:L,onChange:$=>F($.target.value),disabled:g},L===void 0?m.createElement("option",{value:""}):null,Array.from(V)):null))},KK="SelectTrigger",XK=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...i}=e,o=Sy(n),s=ba(KK,n),a=s.disabled||r,l=et(t,s.onTriggerChange),c=Mp(n),[d,f,g]=Xk(v=>{const y=c().filter(S=>!S.disabled),x=y.find(S=>S.value===s.value),w=Qk(y,v,x);w!==void 0&&s.onValueChange(w.value)}),p=()=>{a||(s.onOpenChange(!0),g())};return m.createElement(Eu,le({asChild:!0},o),m.createElement(Be.button,le({type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Yk(s.value)?"":void 0},i,{ref:l,onClick:Ce(i.onClick,v=>{v.currentTarget.focus()}),onPointerDown:Ce(i.onPointerDown,v=>{const y=v.target;y.hasPointerCapture(v.pointerId)&&y.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&(p(),s.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)},v.preventDefault())}),onKeyDown:Ce(i.onKeyDown,v=>{const y=d.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&f(v.key),!(y&&v.key===" ")&&VK.includes(v.key)&&(p(),v.preventDefault())})})))}),QK="SelectValue",ZK=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,children:o,placeholder:s="",...a}=e,l=ba(QK,n),{onValueNodeHasChildrenChange:c}=l,d=o!==void 0,f=et(t,l.onValueNodeChange);return Vn(()=>{c(d)},[c,d]),m.createElement(Be.span,le({},a,{ref:f,style:{pointerEvents:"none"}}),Yk(l.value)?m.createElement(m.Fragment,null,s):o)}),JK=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...i}=e;return m.createElement(Be.span,le({"aria-hidden":!0},i,{ref:t}),r||"▼")}),eX=e=>m.createElement(Dh,le({asChild:!0},e)),jl="SelectContent",tX=m.forwardRef((e,t)=>{const n=ba(jl,e.__scopeSelect),[r,i]=m.useState();if(Vn(()=>{i(new DocumentFragment)},[]),!n.open){const o=r;return o?kt.createPortal(m.createElement(Bk,{scope:e.__scopeSelect},m.createElement(kp.Slot,{scope:e.__scopeSelect},m.createElement("div",null,e.children))),o):null}return m.createElement(nX,le({},e,{ref:t}))}),_o=10,[Bk,ya]=Fl(jl),nX=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:o,onPointerDownOutside:s,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:g,collisionPadding:p,sticky:v,hideWhenDetached:y,avoidCollisions:x,...w}=e,S=ba(jl,n),[C,P]=m.useState(null),[O,k]=m.useState(null),A=et(t,de=>P(de)),[L,F]=m.useState(null),[z,B]=m.useState(null),V=Mp(n),[X,K]=m.useState(!1),$=m.useRef(!1);m.useEffect(()=>{if(C)return ap(C)},[C]),rp();const J=m.useCallback(de=>{const[ie,...ee]=V().map(oe=>oe.ref.current),[H]=ee.slice(-1),ye=document.activeElement;for(const oe of de)if(oe===ye||(oe==null||oe.scrollIntoView({block:"nearest"}),oe===ie&&O&&(O.scrollTop=0),oe===H&&O&&(O.scrollTop=O.scrollHeight),oe==null||oe.focus(),document.activeElement!==ye))return},[V,O]),G=m.useCallback(()=>J([L,C]),[J,L,C]);m.useEffect(()=>{X&&G()},[X,G]);const{onOpenChange:q,triggerPointerDownPosRef:se}=S;m.useEffect(()=>{if(C){let de={x:0,y:0};const ie=H=>{var ye,oe,Te,Fe;de={x:Math.abs(Math.round(H.pageX)-((ye=(oe=se.current)===null||oe===void 0?void 0:oe.x)!==null&&ye!==void 0?ye:0)),y:Math.abs(Math.round(H.pageY)-((Te=(Fe=se.current)===null||Fe===void 0?void 0:Fe.y)!==null&&Te!==void 0?Te:0))}},ee=H=>{de.x<=10&&de.y<=10?H.preventDefault():C.contains(H.target)||q(!1),document.removeEventListener("pointermove",ie),se.current=null};return se.current!==null&&(document.addEventListener("pointermove",ie),document.addEventListener("pointerup",ee,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ie),document.removeEventListener("pointerup",ee,{capture:!0})}}},[C,q,se]),m.useEffect(()=>{const de=()=>q(!1);return window.addEventListener("blur",de),window.addEventListener("resize",de),()=>{window.removeEventListener("blur",de),window.removeEventListener("resize",de)}},[q]);const[D,W]=Xk(de=>{const ie=V().filter(ye=>!ye.disabled),ee=ie.find(ye=>ye.ref.current===document.activeElement),H=Qk(ie,de,ee);H&&setTimeout(()=>H.ref.current.focus())}),re=m.useCallback((de,ie,ee)=>{const H=!$.current&&!ee;(S.value!==void 0&&S.value===ie||H)&&(F(de),H&&($.current=!0))},[S.value]),N=m.useCallback(()=>C==null?void 0:C.focus(),[C]),ne=m.useCallback((de,ie,ee)=>{const H=!$.current&&!ee;(S.value!==void 0&&S.value===ie||H)&&B(de)},[S.value]),ge=r==="popper"?Vk:rX,he=ge===Vk?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:g,collisionPadding:p,sticky:v,hideWhenDetached:y,avoidCollisions:x}:{};return m.createElement(Bk,{scope:n,content:C,viewport:O,onViewportChange:k,itemRefCallback:re,selectedItem:L,onItemLeave:N,itemTextRefCallback:ne,focusSelectedItem:G,selectedItemText:z,position:r,isPositioned:X,searchRef:D},m.createElement(hp,{as:no,allowPinchZoom:!0},m.createElement(ip,{asChild:!0,trapped:S.open,onMountAutoFocus:de=>{de.preventDefault()},onUnmountAutoFocus:Ce(i,de=>{var ie;(ie=S.trigger)===null||ie===void 0||ie.focus({preventScroll:!0}),de.preventDefault()})},m.createElement(wl,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:de=>de.preventDefault(),onDismiss:()=>S.onOpenChange(!1)},m.createElement(ge,le({role:"listbox",id:S.contentId,"data-state":S.open?"open":"closed",dir:S.dir,onContextMenu:de=>de.preventDefault()},w,he,{onPlaced:()=>K(!0),ref:A,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:Ce(w.onKeyDown,de=>{const ie=de.ctrlKey||de.altKey||de.metaKey;if(de.key==="Tab"&&de.preventDefault(),!ie&&de.key.length===1&&W(de.key),["ArrowUp","ArrowDown","Home","End"].includes(de.key)){let H=V().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);if(["ArrowUp","End"].includes(de.key)&&(H=H.slice().reverse()),["ArrowUp","ArrowDown"].includes(de.key)){const ye=de.target,oe=H.indexOf(ye);H=H.slice(oe+1)}setTimeout(()=>J(H)),de.preventDefault()}})}))))))}),rX=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...i}=e,o=ba(jl,n),s=ya(jl,n),[a,l]=m.useState(null),[c,d]=m.useState(null),f=et(t,A=>d(A)),g=Mp(n),p=m.useRef(!1),v=m.useRef(!0),{viewport:y,selectedItem:x,selectedItemText:w,focusSelectedItem:S}=s,C=m.useCallback(()=>{if(o.trigger&&o.valueNode&&a&&c&&y&&x&&w){const A=o.trigger.getBoundingClientRect(),L=c.getBoundingClientRect(),F=o.valueNode.getBoundingClientRect(),z=w.getBoundingClientRect();if(o.dir!=="rtl"){const ye=z.left-L.left,oe=F.left-ye,Te=A.left-oe,Fe=A.width+Te,He=Math.max(Fe,L.width),Ke=window.innerWidth-_o,St=a0(oe,[_o,Ke-He]);a.style.minWidth=Fe+"px",a.style.left=St+"px"}else{const ye=L.right-z.right,oe=window.innerWidth-F.right-ye,Te=window.innerWidth-A.right-oe,Fe=A.width+Te,He=Math.max(Fe,L.width),Ke=window.innerWidth-_o,St=a0(oe,[_o,Ke-He]);a.style.minWidth=Fe+"px",a.style.right=St+"px"}const B=g(),V=window.innerHeight-_o*2,X=y.scrollHeight,K=window.getComputedStyle(c),$=parseInt(K.borderTopWidth,10),J=parseInt(K.paddingTop,10),G=parseInt(K.borderBottomWidth,10),q=parseInt(K.paddingBottom,10),se=$+J+X+q+G,D=Math.min(x.offsetHeight*5,se),W=window.getComputedStyle(y),re=parseInt(W.paddingTop,10),N=parseInt(W.paddingBottom,10),ne=A.top+A.height/2-_o,ge=V-ne,he=x.offsetHeight/2,de=x.offsetTop+he,ie=$+J+de,ee=se-ie;if(ie<=ne){const ye=x===B[B.length-1].ref.current;a.style.bottom="0px";const oe=c.clientHeight-y.offsetTop-y.offsetHeight,Te=Math.max(ge,he+(ye?N:0)+oe+G),Fe=ie+Te;a.style.height=Fe+"px"}else{const ye=x===B[0].ref.current;a.style.top="0px";const Te=Math.max(ne,$+y.offsetTop+(ye?re:0)+he)+ee;a.style.height=Te+"px",y.scrollTop=ie-ne+y.offsetTop}a.style.margin=`${_o}px 0`,a.style.minHeight=D+"px",a.style.maxHeight=V+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[g,o.trigger,o.valueNode,a,c,y,x,w,o.dir,r]);Vn(()=>C(),[C]);const[P,O]=m.useState();Vn(()=>{c&&O(window.getComputedStyle(c).zIndex)},[c]);const k=m.useCallback(A=>{A&&v.current===!0&&(C(),S==null||S(),v.current=!1)},[C,S]);return m.createElement(iX,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:k},m.createElement("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:P}},m.createElement(Be.div,le({},i,{ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}}))))}),Vk=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=_o,...o}=e,s=Sy(n);return m.createElement(Ou,le({},s,o,{ref:t,align:r,collisionPadding:i,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}}))}),[iX,Cy]=Fl(jl,{}),Hk="SelectViewport",oX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=ya(Hk,n),o=Cy(Hk,n),s=et(t,i.onViewportChange),a=m.useRef(0);return m.createElement(m.Fragment,null,m.createElement("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"}}),m.createElement(kp.Slot,{scope:n},m.createElement(Be.div,le({"data-radix-select-viewport":"",role:"presentation"},r,{ref:s,style:{position:"relative",flex:1,overflow:"auto",...r.style},onScroll:Ce(r.onScroll,l=>{const c=l.currentTarget,{contentWrapper:d,shouldExpandOnScrollRef:f}=o;if(f!=null&&f.current&&d){const g=Math.abs(a.current-c.scrollTop);if(g>0){const p=window.innerHeight-_o*2,v=parseFloat(d.style.minHeight),y=parseFloat(d.style.height),x=Math.max(v,y);if(x<p){const w=x+g,S=Math.min(p,w),C=w-S;d.style.height=S+"px",d.style.bottom==="0px"&&(c.scrollTop=C>0?C:0,d.style.justifyContent="flex-end")}}}a.current=c.scrollTop})}))))}),sX="SelectGroup",[aX,lX]=Fl(sX),cX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=or();return m.createElement(aX,{scope:n,id:i},m.createElement(Be.div,le({role:"group","aria-labelledby":i},r,{ref:t})))}),uX="SelectLabel",dX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=lX(uX,n);return m.createElement(Be.div,le({id:i.id},r,{ref:t}))}),Ey="SelectItem",[fX,Wk]=Fl(Ey),hX=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:i=!1,textValue:o,...s}=e,a=ba(Ey,n),l=ya(Ey,n),c=a.value===r,[d,f]=m.useState(o??""),[g,p]=m.useState(!1),v=et(t,w=>{var S;return(S=l.itemRefCallback)===null||S===void 0?void 0:S.call(l,w,r,i)}),y=or(),x=()=>{i||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return m.createElement(fX,{scope:n,value:r,disabled:i,textId:y,isSelected:c,onItemTextChange:m.useCallback(w=>{f(S=>{var C;return S||((C=w==null?void 0:w.textContent)!==null&&C!==void 0?C:"").trim()})},[])},m.createElement(kp.ItemSlot,{scope:n,value:r,disabled:i,textValue:d},m.createElement(Be.div,le({role:"option","aria-labelledby":y,"data-highlighted":g?"":void 0,"aria-selected":c&&g,"data-state":c?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1},s,{ref:v,onFocus:Ce(s.onFocus,()=>p(!0)),onBlur:Ce(s.onBlur,()=>p(!1)),onPointerUp:Ce(s.onPointerUp,x),onPointerMove:Ce(s.onPointerMove,w=>{if(i){var S;(S=l.onItemLeave)===null||S===void 0||S.call(l)}else w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ce(s.onPointerLeave,w=>{if(w.currentTarget===document.activeElement){var S;(S=l.onItemLeave)===null||S===void 0||S.call(l)}}),onKeyDown:Ce(s.onKeyDown,w=>{var S;((S=l.searchRef)===null||S===void 0?void 0:S.current)!==""&&w.key===" "||(HK.includes(w.key)&&x(),w.key===" "&&w.preventDefault())})}))))}),Dp="SelectItemText",pX=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,...o}=e,s=ba(Dp,n),a=ya(Dp,n),l=Wk(Dp,n),c=GK(Dp,n),[d,f]=m.useState(null),g=et(t,w=>f(w),l.onItemTextChange,w=>{var S;return(S=a.itemTextRefCallback)===null||S===void 0?void 0:S.call(a,w,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=m.useMemo(()=>m.createElement("option",{key:l.value,value:l.value,disabled:l.disabled},p),[l.disabled,l.value,p]),{onNativeOptionAdd:y,onNativeOptionRemove:x}=c;return Vn(()=>(y(v),()=>x(v)),[y,x,v]),m.createElement(m.Fragment,null,m.createElement(Be.span,le({id:l.textId},o,{ref:g})),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren?kt.createPortal(o.children,s.valueNode):null)}),gX="SelectItemIndicator",mX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Wk(gX,n).isSelected?m.createElement(Be.span,le({"aria-hidden":!0},r,{ref:t})):null}),qk="SelectScrollUpButton",vX=m.forwardRef((e,t)=>{const n=ya(qk,e.__scopeSelect),r=Cy(qk,e.__scopeSelect),[i,o]=m.useState(!1),s=et(t,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const c=a.scrollTop>0;o(c)};const a=n.viewport;return l(),a.addEventListener("scroll",l),()=>a.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?m.createElement(Gk,le({},e,{ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}})):null}),Uk="SelectScrollDownButton",bX=m.forwardRef((e,t)=>{const n=ya(Uk,e.__scopeSelect),r=Cy(Uk,e.__scopeSelect),[i,o]=m.useState(!1),s=et(t,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const c=a.scrollHeight-a.clientHeight,d=Math.ceil(a.scrollTop)<c;o(d)};const a=n.viewport;return l(),a.addEventListener("scroll",l),()=>a.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?m.createElement(Gk,le({},e,{ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}})):null}),Gk=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...i}=e,o=ya("SelectScrollButton",n),s=m.useRef(null),a=Mp(n),l=m.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),Vn(()=>{var c;const d=a().find(f=>f.ref.current===document.activeElement);d==null||(c=d.ref.current)===null||c===void 0||c.scrollIntoView({block:"nearest"})},[a]),m.createElement(Be.div,le({"aria-hidden":!0},i,{ref:t,style:{flexShrink:0,...i.style},onPointerDown:Ce(i.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:Ce(i.onPointerMove,()=>{var c;(c=o.onItemLeave)===null||c===void 0||c.call(o),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:Ce(i.onPointerLeave,()=>{l()})}))}),yX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return m.createElement(Be.div,le({"aria-hidden":!0},r,{ref:t}))});function Yk(e){return e===""||e===void 0}const Kk=m.forwardRef((e,t)=>{const{value:n,...r}=e,i=m.useRef(null),o=et(t,i),s=Op(n);return m.useEffect(()=>{const a=i.current,l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(s!==n&&d){const f=new Event("change",{bubbles:!0});d.call(a,n),a.dispatchEvent(f)}},[s,n]),m.createElement(T2,{asChild:!0},m.createElement("select",le({},r,{ref:o,defaultValue:n})))});Kk.displayName="BubbleSelect";function Xk(e){const t=xn(e),n=m.useRef(""),r=m.useRef(0),i=m.useCallback(s=>{const a=n.current+s;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),o=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,o]}function Qk(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let s=xX(e,Math.max(o,0));i.length===1&&(s=s.filter(c=>c!==n));const l=s.find(c=>c.textValue.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function xX(e,t){return e.map((n,r)=>e[(t+r)%e.length])}const wX=YK,Zk=XK,_X=ZK,SX=JK,CX=eX,Jk=tX,EX=oX,OX=cX,eM=dX,tM=hX,PX=pX,kX=mX,nM=vX,rM=bX,iM=yX,oM=wX,sM=OX,aM=_X,Oy=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsxs(Zk,{ref:r,className:Pe("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,_.jsx(SX,{asChild:!0,children:_.jsx(Hb,{className:"h-4 w-4 opacity-50"})})]}));Oy.displayName=Zk.displayName;const lM=ue.forwardRef(({className:e,...t},n)=>_.jsx(nM,{ref:n,className:Pe("flex cursor-default items-center justify-center py-1",e),...t,children:_.jsx(GB,{className:"h-4 w-4"})}));lM.displayName=nM.displayName;const cM=ue.forwardRef(({className:e,...t},n)=>_.jsx(rM,{ref:n,className:Pe("flex cursor-default items-center justify-center py-1",e),...t,children:_.jsx(Hb,{className:"h-4 w-4"})}));cM.displayName=rM.displayName;const Py=ue.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>_.jsx(CX,{children:_.jsxs(Jk,{ref:i,className:Pe("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[_.jsx(lM,{}),_.jsx(EX,{className:Pe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),_.jsx(cM,{})]})}));Py.displayName=Jk.displayName;const Tp=ue.forwardRef(({className:e,...t},n)=>_.jsx(eM,{ref:n,className:Pe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Tp.displayName=eM.displayName;const xa=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsxs(tM,{ref:r,className:Pe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[_.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:_.jsx(kX,{children:_.jsx(Rh,{className:"h-4 w-4"})})}),_.jsx(PX,{children:t})]}));xa.displayName=tM.displayName;const MX=ue.forwardRef(({className:e,...t},n)=>_.jsx(iM,{ref:n,className:Pe("-mx-1 my-1 h-px bg-muted",e),...t}));MX.displayName=iM.displayName;function Ap({title:e,items:t,value:n,isLoading:r,isError:i,onChange:o}){const s=r?"Loading...":i?"Error":n;function a(){if(e==="Connection")return _.jsx(JB,{className:" rotate-90",strokeWidth:1,size:16});if(e==="Database")return _.jsx(KB,{strokeWidth:1,size:16});if(e==="Schema")return _.jsx(iV,{strokeWidth:1,size:16});if(e==="Table")return _.jsx(Wb,{strokeWidth:1,size:16})}return _.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx("div",{className:" shrink-0",children:a()}),_.jsxs(oM,{value:s,onValueChange:o,children:[_.jsx(Oy,{className:"focus:ring-offset-0 focus:ring-1 h-7 w-[190px] ",children:_.jsx(aM,{placeholder:r?"Loading...":i?"Error":`Select ${e}`})}),_.jsx(Py,{children:_.jsxs(sM,{children:[r?_.jsx(Tp,{children:"Loading..."}):_.jsx(Tp,{children:e}),_.jsx(_.Fragment,{children:t&&t.map(l=>_.jsx(xa,{value:l.id,children:l.name},l.id))}),(r||i)&&_.jsx(xa,{value:s,children:s})]})})]})]})}function DX({column:e}){const[t,n]=m.useState(!1),r=_e(d=>d.selectedTableName),i=_e(d=>d.selectedSchemaName),o=_e(d=>d.sqlGen),s=_e(d=>d.actions.setSqlGen),a=_e(d=>d.actions.setCardSql),l=_e(d=>d.actions.setRunSql);function c(d,f){const g=WO(d,o,f);s(g);const p=HO(g,i||"",r);p&&(a(p),l(!0)),n(!1)}return _.jsxs(pp,{open:t,onOpenChange:n,children:[_.jsx(gp,{asChild:!0,children:_.jsx(Hj,{className:"w-3 h-3 text-foreground/40 cursor-pointer"})}),_.jsx(Wu,{align:"center",className:" p-0 w-18 rounded-none shadow-none border-muted",children:_.jsxs("ul",{className:"text-xs ",children:[_.jsx("li",{onClick:()=>c(e,"COUNT"),className:" px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Count"}),_.jsx("li",{onClick:()=>c(e,"AVG"),className:" px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Avg"}),_.jsx("li",{onClick:()=>c(e,"SUM"),className:"px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Sum"}),_.jsx("li",{onClick:()=>c(e,"MAX"),className:"px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Max"}),_.jsx("li",{onClick:()=>c(e,"MIN"),className:"px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Min"})]})})]})}function uM({column:e}){return _.jsxs(Bb,{children:[_.jsx(I2,{asChild:!0,children:O0.includes(e.data_type.toLowerCase())?_.jsx("span",{className:" font-thin",children:"T"}):Dl.includes(e.data_type.toLowerCase())?_.jsx("span",{className:" font-thin",children:"#"}):Iu.includes(e.data_type.toLowerCase())?_.jsx("span",{className:" font-thin",children:"D"}):VO.includes(e.data_type.toLowerCase())?_.jsx("span",{className:" font-thin",children:"B"}):_.jsx("span",{className:" font-thin",children:"?"})}),_.jsx(Ih,{children:_.jsx("p",{className:"text-xs font-mono",children:e.data_type})})]})}function TX({schemaName:e,tableName:t,columns:n,status:r}){const i=_e(f=>f.sqlGen),o=_e(f=>f.actions.setRunSql),s=_e(f=>f.actions.setSqlGen),a=_e(f=>f.actions.setIsShowingVisual),l=_e(f=>f.actions.setCardSql);function c(f){const g=WO(f,i);s(g);const p=HO(g,e,t);p&&(l(p),o(!0))}function d(){const f=k0(e,t);a(!1),l(`SELECT * FROM ${f} LIMIT 10`),o(!0)}return _.jsxs("div",{className:"px-4",children:[_.jsx("div",{className:" font-medium px-2 pt-2 pb-3",children:_.jsxs(it,{disabled:r!=="Success",onClick:d,variant:"secondary",className:" h-7 flex w-full",children:[r!=="Success"&&_.jsx(ku,{className:" w-4 h-4 animate-spin mr-2 text-foreground/50"}),"Show top 10 rows"]})}),_.jsxs(Pl,{className:`w-full ${t==="api"?"h-[74vh]":"h-[60vh]"}`,children:[n==null?void 0:n.map(f=>_.jsxs("div",{onClick:()=>c(f),className:Pe(" text-sm flex items-center justify-between px-3 py-[6px] transition-colors hover:bg-muted/50 cursor-pointer rounded ",{" bg-muted":BW(f,i)}),children:[_.jsxs("div",{className:"flex items-center space-x-2 ",children:[_.jsx(uM,{column:f}),_.jsx("span",{children:f.column_name})]}),Dl.includes(f.data_type)&&_.jsx("div",{onClick:g=>g.stopPropagation(),className:" flex items-center justify-end ",children:_.jsx(DX,{column:f})})]},f.column_name)),_.jsx(Hh,{orientation:"vertical"}),_.jsx(Hh,{orientation:"horizontal"})]})]})}function dM({ColumnsComponent:e}){const t=_e(K=>K.selectedConnectionId);_e(K=>K.card.sql);const n=_e(K=>K.selectedDatabaseName),r=_e(K=>K.selectedSchemaName),i=_e(K=>K.selectedTableName),o=_e(K=>K.actions.setSelectedConnectionId),s=_e(K=>K.actions.setSelectedDatabaseName),a=_e(K=>K.actions.setSelectedSchemaName),l=_e(K=>K.actions.setSelectedTableName),c=_e(K=>K.actions.setCardSql),{connectionItems:d,schemaItems:f,databaseItems:g,tableItems:p,columns:v,isConnectionsLoading:y,isConnectionsError:x,isDatabasesLoadingOrFetching:w,isDatabaseError:S,isSchemaLoadingOrFetching:C,isSchemaError:P,isColumnsError:O,isColumnsLoadingOrFetching:k,isAPIConnection:A}=iH();m.useEffect(()=>{A&&(s("NA"),a(""),l("api"))},[A,c,l,a,s]);const L=A?"api":i||"",F=A?"":r||"";function z(K){a(K),l("")}function B(K){s(K),a(""),l("")}function V(K){o(K)}function X(){return e?e(F,L,v):_.jsx(TX,{schemaName:F,tableName:L,columns:v,status:k?"Loading...":O?"Error":"Success"})}return _.jsxs("aside",{className:" grow flex flex-col xbg-red-100 ",children:[_.jsxs("section",{className:"space-y-3 pt-4 pb-3 px-6",children:[_.jsx(Ap,{items:d,title:"Connection",value:t||"",onChange:V,isLoading:y,isError:x}),!A&&_.jsxs(_.Fragment,{children:[_.jsx(Ap,{onChange:B,isError:S,isLoading:w,items:g,value:n||"",title:"Database"}),_.jsx(Ap,{onChange:z,isError:P,isLoading:C,items:f,value:r||"",title:"Schema"}),_.jsx(Ap,{onChange:l,isError:S,items:p,isLoading:w,value:i||"",title:"Table"})]})]}),X(),_.jsx("div",{className:" grow justify-end flex flex-col pt-6 "})]})}const{createElement:zl,createContext:AX,createRef:sfe,forwardRef:fM,useCallback:Rr,useContext:hM,useEffect:wa,useImperativeHandle:pM,useLayoutEffect:IX,useMemo:NX,useRef:ei,useState:Ip}=ue,gM=ue.useId,Np=AX(null);Np.displayName="PanelGroupContext";const Xu=IX,RX=typeof gM=="function"?gM:()=>null;let LX=0;function ky(e=null){const t=RX(),n=ei(e||t||null);return n.current===null&&(n.current=""+LX++),e??n.current}function mM({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:o,id:s,maxSize:a,minSize:l,onCollapse:c,onExpand:d,onResize:f,order:g,style:p,tagName:v="div",...y}){const x=hM(Np);if(x===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:w,expandPanel:S,getPanelSize:C,getPanelStyle:P,groupId:O,isPanelCollapsed:k,registerPanel:A,resizePanel:L,unregisterPanel:F}=x,z=ky(s),B=ei({callbacks:{onCollapse:c,onExpand:d,onResize:f},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:a,minSize:l},id:z,idIsFromProps:s!==void 0,order:g});ei({didLogMissingDefaultSizeWarning:!1}),Xu(()=>{const{callbacks:X,constraints:K}=B.current;B.current.id=z,B.current.idIsFromProps=s!==void 0,B.current.order=g,X.onCollapse=c,X.onExpand=d,X.onResize=f,K.collapsedSize=n,K.collapsible=r,K.defaultSize=i,K.maxSize=a,K.minSize=l}),Xu(()=>{const X=B.current;return A(X),()=>{F(X)}},[g,z,A,F]),pM(o,()=>({collapse:()=>{w(B.current)},expand:()=>{S(B.current)},getId(){return z},getSize(){return C(B.current)},isCollapsed(){return k(B.current)},isExpanded(){return!k(B.current)},resize:X=>{L(B.current,X)}}),[w,S,C,k,z,L]);const V=P(B.current,i);return zl(v,{...y,children:e,className:t,style:{...V,...p},"data-panel":"","data-panel-id":z,"data-panel-group-id":O,"data-panel-collapsible":void 0,"data-panel-size":void 0})}const vM=fM((e,t)=>zl(mM,{...e,forwardedRef:t}));mM.displayName="Panel",vM.displayName="forwardRef(Panel)";function st(e,t="Assertion failed!"){if(!e)throw console.error(t),Error(t)}const bM=10;function Qu(e,t,n=bM){e=parseFloat(e.toFixed(n)),t=parseFloat(t.toFixed(n));const r=e-t;return r===0?0:r>0?1:-1}function Lr(e,t,n){return Qu(e,t,n)===0}function Bl({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];st(r!=null);let{collapsedSize:i=0,collapsible:o,maxSize:s=100,minSize:a=0}=r;if(Qu(n,a)<0)if(o){const l=(i+a)/2;Qu(n,l)<0?n=i:n=a}else n=a;return n=Math.min(s,n),n=parseFloat(n.toFixed(bM)),n}function Zu({delta:e,layout:t,panelConstraints:n,pivotIndices:r,trigger:i}){if(Lr(e,0))return t;const o=[...t],[s,a]=r;st(s!=null),st(a!=null);let l=0;if(i==="keyboard"){{const d=e<0?a:s,f=n[d];if(st(f),f.collapsible){const g=t[d];st(g!=null);const p=n[d];st(p);const{collapsedSize:v=0,minSize:y=0}=p;if(Lr(g,v)){const x=y-g;Qu(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const d=e<0?s:a,f=n[d];st(f);const{collapsible:g}=f;if(g){const p=t[d];st(p!=null);const v=n[d];st(v);const{collapsedSize:y=0,minSize:x=0}=v;if(Lr(p,x)){const w=p-y;Qu(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}}{const d=e<0?1:-1;let f=e<0?a:s,g=0;for(;;){const v=t[f];st(v!=null);const x=Bl({panelConstraints:n,panelIndex:f,size:100})-v;if(g+=x,f+=d,f<0||f>=n.length)break}const p=Math.min(Math.abs(e),Math.abs(g));e=e<0?0-p:p}{let f=e<0?s:a;for(;f>=0&&f<n.length;){const g=Math.abs(e)-Math.abs(l),p=t[f];st(p!=null);const v=p-g,y=Bl({panelConstraints:n,panelIndex:f,size:v});if(!Lr(p,y)&&(l+=p-y,o[f]=y,l.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?f--:f++}}if(Lr(l,0))return t;{const d=e<0?a:s,f=t[d];st(f!=null);const g=f+l,p=Bl({panelConstraints:n,panelIndex:d,size:g});if(o[d]=p,!Lr(p,g)){let v=g-p,x=e<0?a:s;for(;x>=0&&x<n.length;){const w=o[x];st(w!=null);const S=w+v,C=Bl({panelConstraints:n,panelIndex:x,size:S});if(Lr(w,C)||(v-=C-w,o[x]=C),Lr(v,0))break;e>0?x--:x++}}}const c=o.reduce((d,f)=>f+d,0);return Lr(c,100)?o:t}function $X({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,o=0,s=0;const a=n[0];st(a!=null),t.forEach((f,g)=>{const{constraints:p}=f,{maxSize:v=100,minSize:y=0}=p;g===a?(r=y,i=v):(o+=y,s+=v)});const l=Math.min(i,100-o),c=Math.max(r,100-s),d=e[a];return{valueMax:l,valueMin:c,valueNow:d}}function Ju(e){return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function yM(e,t){const r=Ju(e).findIndex(i=>i.getAttribute("data-panel-resize-handle-id")===t);return r??null}function xM(e,t){const n=yM(e,t);return n!=null?[n,n+1]:[-1,-1]}function wM(e){const t=document.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return t||null}function Rp(e){const t=document.querySelector(`[data-panel-resize-handle-id="${e}"]`);return t||null}function FX(e,t,n){var r,i,o,s;const a=Rp(t),l=Ju(e),c=a?l.indexOf(a):-1,d=(r=(i=n[c])===null||i===void 0?void 0:i.id)!==null&&r!==void 0?r:null,f=(o=(s=n[c+1])===null||s===void 0?void 0:s.id)!==null&&o!==void 0?o:null;return[d,f]}function jX({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,setLayout:o}){ei({didWarnAboutMissingResizeHandle:!1}),Xu(()=>{const s=Ju(n);for(let a=0;a<i.length-1;a++){const{valueMax:l,valueMin:c,valueNow:d}=$X({layout:r,panelsArray:i,pivotIndices:[a,a+1]}),f=s[a];if(f!=null){const g=i[a];st(g),f.setAttribute("aria-controls",g.id),f.setAttribute("aria-valuemax",""+Math.round(l)),f.setAttribute("aria-valuemin",""+Math.round(c)),f.setAttribute("aria-valuenow",d!=null?""+Math.round(d):"")}}return()=>{s.forEach((a,l)=>{a.removeAttribute("aria-controls"),a.removeAttribute("aria-valuemax"),a.removeAttribute("aria-valuemin"),a.removeAttribute("aria-valuenow")})}},[n,r,i]),wa(()=>{const s=t.current;st(s);const{panelDataArray:a}=s,l=wM(n);st(l!=null,`No group found for id "${n}"`);const c=Ju(n);st(c);const d=c.map(f=>{const g=f.getAttribute("data-panel-resize-handle-id");st(g);const[p,v]=FX(n,g,a);if(p==null||v==null)return()=>{};const y=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const w=a.findIndex(S=>S.id===p);if(w>=0){const S=a[w];st(S);const C=r[w],{collapsedSize:P=0,collapsible:O,minSize:k=0}=S.constraints;if(C!=null&&O){const A=Zu({delta:Lr(C,P)?k-P:P-C,layout:r,panelConstraints:a.map(L=>L.constraints),pivotIndices:xM(n,g),trigger:"keyboard"});r!==A&&o(A)}}break}}};return f.addEventListener("keydown",y),()=>{f.removeEventListener("keydown",y)}});return()=>{d.forEach(f=>f())}},[e,t,n,r,i,o])}function _M(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function SM(e){return e.type==="keydown"}function CM(e){return e.type.startsWith("mouse")}function EM(e){return e.type.startsWith("touch")}function OM(e,t){const n=e==="horizontal";if(CM(t))return n?t.clientX:t.clientY;if(EM(t)){const r=t.touches[0];return st(r),n?r.screenX:r.screenY}else throw Error(`Unsupported event type "${t.type}"`)}function zX(e,t,n,r){const i=n==="horizontal",o=Rp(t);st(o);const s=o.getAttribute("data-panel-group-id");st(s);let{initialCursorPosition:a}=r;const l=OM(n,e),c=wM(s);st(c);const d=c.getBoundingClientRect(),f=i?d.width:d.height;return(l-a)/f*100}function BX(e,t,n,r,i){if(SM(e)){const o=n==="horizontal";let s=0;e.shiftKey?s=100:i!=null?s=i:s=10;let a=0;switch(e.key){case"ArrowDown":a=o?0:s;break;case"ArrowLeft":a=o?-s:0;break;case"ArrowRight":a=o?s:0;break;case"ArrowUp":a=o?0:-s;break;case"End":a=100;break;case"Home":a=-100;break}return a}else return r==null?0:zX(e,t,n,r)}function VX({panelDataArray:e}){const t=Array(e.length),n=e.map(o=>o.constraints);let r=0,i=100;for(let o=0;o<e.length;o++){const s=n[o];st(s);const{defaultSize:a}=s;a!=null&&(r++,t[o]=a,i-=a)}for(let o=0;o<e.length;o++){const s=n[o];st(s);const{defaultSize:a}=s;if(a!=null)continue;const l=e.length-r,c=i/l;r++,t[o]=c,i-=c}return t}function Vl(e,t,n){t.forEach((r,i)=>{const o=e[i];st(o);const{callbacks:s,constraints:a,id:l}=o,{collapsedSize:c=0,collapsible:d}=a,f=n[l];if(f==null||r!==f){n[l]=r;const{onCollapse:g,onExpand:p,onResize:v}=s;v&&v(r,f),d&&(g||p)&&(p&&(f==null||f===c)&&r!==c&&p(),g&&(f==null||f!==c)&&r===c&&g())}})}function Lp(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function HX({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:i,precision:o=3}){const s=n[i];let a;return s==null?a=e??"1":r.length===1?a="1":a=s.toPrecision(o),{flexBasis:0,flexGrow:a,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}let My=null,_a=null;function PM(e){switch(e){case"horizontal":return"ew-resize";case"horizontal-max":return"w-resize";case"horizontal-min":return"e-resize";case"vertical":return"ns-resize";case"vertical-max":return"n-resize";case"vertical-min":return"s-resize"}}function WX(){_a!==null&&(document.head.removeChild(_a),My=null,_a=null)}function Dy(e){if(My===e)return;My=e;const t=PM(e);_a===null&&(_a=document.createElement("style"),document.head.appendChild(_a)),_a.innerHTML=`*{cursor: ${t}!important;}`}function qX(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function kM(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function MM(e){return`react-resizable-panels:${e}`}function DM(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:i,order:o}=t;return i?r:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function TM(e,t){try{const n=MM(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function UX(e,t,n){var r,i;const o=(r=TM(e,n))!==null&&r!==void 0?r:{},s=DM(t);return(i=o[s])!==null&&i!==void 0?i:null}function GX(e,t,n,r,i){var o;const s=MM(e),a=DM(t),l=(o=TM(e,i))!==null&&o!==void 0?o:{};l[a]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(s,JSON.stringify(l))}catch(c){console.error(c)}}function AM({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((o,s)=>o+s,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!Lr(r,100))for(let o=0;o<t.length;o++){const s=n[o];st(s!=null);const a=100/r*s;n[o]=a}let i=0;for(let o=0;o<t.length;o++){const s=n[o];st(s!=null);const a=Bl({panelConstraints:t,panelIndex:o,size:s});s!=a&&(i+=s-a,n[o]=a)}if(!Lr(i,0))for(let o=0;o<t.length;o++){const s=n[o];st(s!=null);const a=s+i,l=Bl({panelConstraints:t,panelIndex:o,size:a});if(s!==l&&(i-=l-s,n[o]=l,Lr(i,0)))break}return n}const YX=100,ed={getItem:e=>(kM(ed),ed.getItem(e)),setItem:(e,t)=>{kM(ed),ed.setItem(e,t)}},IM={};function NM({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:o=null,onLayout:s=null,keyboardResizeBy:a=null,storage:l=ed,style:c,tagName:d="div",...f}){const g=ky(o),[p,v]=Ip(null),[y,x]=Ip([]),w=ei({}),S=ei(new Map),C=ei(0),P=ei({autoSaveId:e,direction:r,dragState:p,id:g,keyboardResizeBy:a,onLayout:s,storage:l}),O=ei({layout:y,panelDataArray:[],panelDataArrayChanged:!1});ei({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),pM(i,()=>({getId:()=>P.current.id,getLayout:()=>{const{layout:D}=O.current;return D},setLayout:D=>{const{onLayout:W}=P.current,{layout:re,panelDataArray:N}=O.current,ne=AM({layout:D,panelConstraints:N.map(ge=>ge.constraints)});_M(re,ne)||(x(ne),O.current.layout=ne,W&&W(ne),Vl(N,ne,w.current))}}),[]),Xu(()=>{P.current.autoSaveId=e,P.current.direction=r,P.current.dragState=p,P.current.id=g,P.current.onLayout=s,P.current.storage=l}),jX({committedValuesRef:P,eagerValuesRef:O,groupId:g,layout:y,panelDataArray:O.current.panelDataArray,setLayout:x}),wa(()=>{const{panelDataArray:D}=O.current;if(e){if(y.length===0||y.length!==D.length)return;let W=IM[e];W==null&&(W=qX(GX,YX),IM[e]=W);const re=[...D],N=new Map(S.current);W(e,re,N,y,l)}},[e,y,l]),wa(()=>{});const k=Rr(D=>{const{onLayout:W}=P.current,{layout:re,panelDataArray:N}=O.current;if(D.constraints.collapsible){const ne=N.map(ie=>ie.constraints),{collapsedSize:ge=0,panelSize:he,pivotIndices:de}=Wl(N,D,re);if(st(he!=null),he!==ge){S.current.set(D.id,he);const ee=Hl(N,D)===N.length-1?he-ge:ge-he,H=Zu({delta:ee,layout:re,panelConstraints:ne,pivotIndices:de,trigger:"imperative-api"});Lp(re,H)||(x(H),O.current.layout=H,W&&W(H),Vl(N,H,w.current))}}},[]),A=Rr(D=>{const{onLayout:W}=P.current,{layout:re,panelDataArray:N}=O.current;if(D.constraints.collapsible){const ne=N.map(ee=>ee.constraints),{collapsedSize:ge=0,panelSize:he,minSize:de=0,pivotIndices:ie}=Wl(N,D,re);if(he===ge){const ee=S.current.get(D.id),H=ee!=null&&ee>=de?ee:de,oe=Hl(N,D)===N.length-1?he-H:H-he,Te=Zu({delta:oe,layout:re,panelConstraints:ne,pivotIndices:ie,trigger:"imperative-api"});Lp(re,Te)||(x(Te),O.current.layout=Te,W&&W(Te),Vl(N,Te,w.current))}}},[]),L=Rr(D=>{const{layout:W,panelDataArray:re}=O.current,{panelSize:N}=Wl(re,D,W);return st(N!=null),N},[]),F=Rr((D,W)=>{const{panelDataArray:re}=O.current,N=Hl(re,D);return HX({defaultSize:W,dragState:p,layout:y,panelData:re,panelIndex:N})},[p,y]),z=Rr(D=>{const{layout:W,panelDataArray:re}=O.current,{collapsedSize:N=0,collapsible:ne,panelSize:ge}=Wl(re,D,W);return ne===!0&&ge===N},[]),B=Rr(D=>{const{layout:W,panelDataArray:re}=O.current,{collapsedSize:N=0,collapsible:ne,panelSize:ge}=Wl(re,D,W);return st(ge!=null),!ne||ge>N},[]),V=Rr(D=>{const{panelDataArray:W}=O.current;W.push(D),W.sort((re,N)=>{const ne=re.order,ge=N.order;return ne==null&&ge==null?0:ne==null?-1:ge==null?1:ne-ge}),O.current.panelDataArrayChanged=!0},[]);Xu(()=>{if(O.current.panelDataArrayChanged){O.current.panelDataArrayChanged=!1;const{autoSaveId:D,onLayout:W,storage:re}=P.current,{layout:N,panelDataArray:ne}=O.current;let ge=null;if(D){const de=UX(D,ne,re);de&&(S.current=new Map(Object.entries(de.expandToSizes)),ge=de.layout)}ge==null&&(ge=VX({panelDataArray:ne}));const he=AM({layout:ge,panelConstraints:ne.map(de=>de.constraints)});_M(N,he)||(x(he),O.current.layout=he,W&&W(he),Vl(ne,he,w.current))}});const X=Rr(D=>function(re){re.preventDefault();const{direction:N,dragState:ne,id:ge,keyboardResizeBy:he,onLayout:de}=P.current,{layout:ie,panelDataArray:ee}=O.current,{initialLayout:H}=ne??{},ye=xM(ge,D);let oe=BX(re,D,N,ne,he);if(oe===0)return;const Te=N==="horizontal";document.dir==="rtl"&&Te&&(oe=-oe);const Fe=ee.map(St=>St.constraints),He=Zu({delta:oe,layout:H??ie,panelConstraints:Fe,pivotIndices:ye,trigger:SM(re)?"keyboard":"mouse-or-touch"}),Ke=!Lp(ie,He);(CM(re)||EM(re))&&C.current!=oe&&(C.current=oe,Dy(Ke?Te?"horizontal":"vertical":Te?oe<0?"horizontal-min":"horizontal-max":oe<0?"vertical-min":"vertical-max")),Ke&&(x(He),O.current.layout=He,de&&de(He),Vl(ee,He,w.current))},[]),K=Rr((D,W)=>{const{onLayout:re}=P.current,{layout:N,panelDataArray:ne}=O.current,ge=ne.map(ye=>ye.constraints),{panelSize:he,pivotIndices:de}=Wl(ne,D,N);st(he!=null);const ee=Hl(ne,D)===ne.length-1?he-W:W-he,H=Zu({delta:ee,layout:N,panelConstraints:ge,pivotIndices:de,trigger:"imperative-api"});Lp(N,H)||(x(H),O.current.layout=H,re&&re(H),Vl(ne,H,w.current))},[]),$=Rr((D,W)=>{const{direction:re}=P.current,{layout:N}=O.current,ne=Rp(D);st(ne);const ge=OM(re,W);v({dragHandleId:D,dragHandleRect:ne.getBoundingClientRect(),initialCursorPosition:ge,initialLayout:N})},[]),J=Rr(()=>{WX(),v(null)},[]),G=Rr(D=>{const{panelDataArray:W}=O.current,re=Hl(W,D);re>=0&&(W.splice(re,1),delete w.current[D.id],O.current.panelDataArrayChanged=!0)},[]),q=NX(()=>({collapsePanel:k,direction:r,dragState:p,expandPanel:A,getPanelSize:L,getPanelStyle:F,groupId:g,isPanelCollapsed:z,isPanelExpanded:B,registerPanel:V,registerResizeHandle:X,resizePanel:K,startDragging:$,stopDragging:J,unregisterPanel:G}),[k,p,r,A,L,F,g,z,B,V,X,K,$,J,G]),se={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return zl(Np.Provider,{value:q},zl(d,{...f,children:t,className:n,style:{...se,...c},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":g}))}const RM=fM((e,t)=>zl(NM,{...e,forwardedRef:t}));NM.displayName="PanelGroup",RM.displayName="forwardRef(PanelGroup)";function Hl(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Wl(e,t,n){const r=e.map(c=>c.constraints),i=Hl(e,t),o=r[i],a=i===e.length-1?[i-1,i]:[i,i+1],l=n[i];return{...o,panelSize:l,pivotIndices:a}}function KX({disabled:e,handleId:t,resizeHandler:n}){wa(()=>{if(e||n==null)return;const r=Rp(t);if(r==null)return;const i=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{o.preventDefault(),n(o);break}case"F6":{o.preventDefault();const s=r.getAttribute("data-panel-group-id");st(s);const a=Ju(s),l=yM(s,t);st(l!==null);const c=o.shiftKey?l>0?l-1:a.length-1:l+1<a.length?l+1:0;a[c].focus();break}}};return r.addEventListener("keydown",i),()=>{r.removeEventListener("keydown",i)}},[e,t,n])}function LM({children:e=null,className:t="",disabled:n=!1,id:r,onDragging:i,style:o={},tabIndex:s=0,tagName:a="div",...l}){const c=ei(null),d=ei({onDragging:i});wa(()=>{d.current.onDragging=i});const f=hM(Np);if(f===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:g,dragState:p,groupId:v,registerResizeHandle:y,startDragging:x,stopDragging:w}=f,S=ky(r),C=(p==null?void 0:p.dragHandleId)===S,[P,O]=Ip(!1),[k,A]=Ip(null),L=Rr(()=>{const z=c.current;st(z),z.blur(),w();const{onDragging:B}=d.current;B&&B(!1)},[w]);wa(()=>{if(n)A(null);else{const z=y(S);A(()=>z)}},[n,S,y]),wa(()=>{if(n||k==null||!C)return;const z=K=>{k(K)},B=K=>{k(K)},V=c.current;st(V);const X=V.ownerDocument;return X.body.addEventListener("contextmenu",L),X.body.addEventListener("mousemove",z),X.body.addEventListener("touchmove",z),X.body.addEventListener("mouseleave",B),window.addEventListener("mouseup",L),window.addEventListener("touchend",L),()=>{X.body.removeEventListener("contextmenu",L),X.body.removeEventListener("mousemove",z),X.body.removeEventListener("touchmove",z),X.body.removeEventListener("mouseleave",B),window.removeEventListener("mouseup",L),window.removeEventListener("touchend",L)}},[g,n,C,k,L]),KX({disabled:n,handleId:S,resizeHandler:k});const F={cursor:PM(g),touchAction:"none",userSelect:"none"};return zl(a,{...l,children:e,className:t,onBlur:()=>O(!1),onFocus:()=>O(!0),onMouseDown:z=>{x(S,z.nativeEvent);const B=d.current;st(B);const{onDragging:V}=B;V&&V(!0)},onMouseUp:L,onTouchCancel:L,onTouchEnd:L,onTouchStart:z=>{x(S,z.nativeEvent);const B=d.current;st(B);const{onDragging:V}=B;V&&V(!0)},ref:c,role:"separator",style:{...F,...o},tabIndex:s,"data-panel-group-direction":g,"data-panel-group-id":v,"data-resize-handle":"","data-resize-handle-active":C?"pointer":P?"keyboard":void 0,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":S})}LM.displayName="PanelResizeHandle";const $M=({className:e,...t})=>_.jsx(RM,{className:Pe("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),$p=vM,FM=({withHandle:e,className:t,...n})=>_.jsx(LM,{className:Pe("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&_.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:_.jsx(XB,{className:"h-2.5 w-2.5"})})});function XX(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function jM(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function zM(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?jM(Object(n),!0).forEach(function(r){XX(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jM(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function QX(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o<r.length;o++)i=r[o],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function ZX(e,t){if(e==null)return{};var n=QX(e,t),r,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function JX(e,t){return eQ(e)||tQ(e,t)||nQ(e,t)||rQ()}function eQ(e){if(Array.isArray(e))return e}function tQ(e,t){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(e)))){var n=[],r=!0,i=!1,o=void 0;try{for(var s=e[Symbol.iterator](),a;!(r=(a=s.next()).done)&&(n.push(a.value),!(t&&n.length===t));r=!0);}catch(l){i=!0,o=l}finally{try{!r&&s.return!=null&&s.return()}finally{if(i)throw o}}return n}}function nQ(e,t){if(e){if(typeof e=="string")return BM(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return BM(e,t)}}function BM(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function rQ(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
428
+ border-b-muted py-2 `,role:"dashboard-controls",children:[_.jsx("div",{children:e}),_.jsxs("div",{className:"flex gap-2",children:[r&&!i&&_.jsx(jK,{}),!i&&_.jsx(zK,{}),r&&!i&&_.jsxs(it,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!r,onClick:x,children:[_.jsx(eV,{className:" mr-2 h-4 w-4",strokeWidth:1.5}),"Add Card"]}),!r&&_.jsx(it,{variant:"outline",className:"h-7 p-2",onClick:w,size:"sm",children:_.jsx(ZB,{className:"h-4 w-4",strokeWidth:1.5})}),r&&!i&&_.jsx(it,{variant:"outline",role:"close",className:"h-7 p-2",onClick:()=>g(!1),size:"sm",children:_.jsx(na,{className:"h-4 w-4",strokeWidth:1.5})}),r&&!i&&_.jsx(it,{className:"h-7 p-2",variant:"outline",onClick:S,size:"sm",children:_.jsx(tV,{className:"h-4 w-4",strokeWidth:1.5})}),!o&&!i&&r&&_.jsx(it,{className:"h-7 p-2",variant:"outline",onClick:()=>c(!0),size:"sm",children:_.jsx(W2,{className:"h-4 w-4",strokeWidth:1.5})}),!i&&r&&_.jsx("div",{className:" flex items-center space-x-2",children:_.jsx(it,{className:"h-7 p-2",onClick:()=>a(!s),size:"sm",variant:"outline",children:_.jsx(YB,{className:"h-4 w-4",strokeWidth:1.5})})}),_.jsx(gK,{})]})]})}const Fk=m.forwardRef(({className:e,...t},n)=>_.jsx("div",{role:"editor-panel",ref:n,className:Pe("flex grow min-h-[80vh]",e),...t}));Fk.displayName="EditorPanel";const jk=m.forwardRef(({className:e,...t},n)=>_.jsx("div",{ref:n,className:Pe(" flex flex-col space-y-2 w-[270px]",e),...t}));jk.displayName="EditorAside";const zk=m.forwardRef(({className:e,...t},n)=>_.jsx("div",{ref:n,className:Pe(" grow",e),...t}));zk.displayName="EditorMain";function Op(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}const VK=[" ","Enter","ArrowUp","ArrowDown"],HK=[" ","Enter"],Pp="Select",[kp,Mp,WK]=uf(Pp),[Fl,ofe]=Pn(Pp,[WK,Fi]),Sy=Fi(),[qK,ba]=Fl(Pp),[UK,GK]=Fl(Pp),YK=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:o,value:s,defaultValue:a,onValueChange:l,dir:c,name:d,autoComplete:f,disabled:g,required:p}=e,v=Sy(t),[y,x]=m.useState(null),[w,S]=m.useState(null),[C,P]=m.useState(!1),O=Ls(c),[k=!1,A]=Qn({prop:r,defaultProp:i,onChange:o}),[L,F]=Qn({prop:s,defaultProp:a,onChange:l}),z=m.useRef(null),B=y?!!y.closest("form"):!0,[V,X]=m.useState(new Set),K=Array.from(V).map($=>$.props.value).join(";");return m.createElement(Cu,v,m.createElement(qK,{required:p,scope:t,trigger:y,onTriggerChange:x,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:C,onValueNodeHasChildrenChange:P,contentId:or(),value:L,onValueChange:F,open:k,onOpenChange:A,dir:O,triggerPointerDownPosRef:z,disabled:g},m.createElement(kp.Provider,{scope:t},m.createElement(UK,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback($=>{X(J=>new Set(J).add($))},[]),onNativeOptionRemove:m.useCallback($=>{X(J=>{const G=new Set(J);return G.delete($),G})},[])},n)),B?m.createElement(Kk,{key:K,"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:L,onChange:$=>F($.target.value),disabled:g},L===void 0?m.createElement("option",{value:""}):null,Array.from(V)):null))},KK="SelectTrigger",XK=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...i}=e,o=Sy(n),s=ba(KK,n),a=s.disabled||r,l=et(t,s.onTriggerChange),c=Mp(n),[d,f,g]=Xk(v=>{const y=c().filter(S=>!S.disabled),x=y.find(S=>S.value===s.value),w=Qk(y,v,x);w!==void 0&&s.onValueChange(w.value)}),p=()=>{a||(s.onOpenChange(!0),g())};return m.createElement(Eu,le({asChild:!0},o),m.createElement(Be.button,le({type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Yk(s.value)?"":void 0},i,{ref:l,onClick:Ce(i.onClick,v=>{v.currentTarget.focus()}),onPointerDown:Ce(i.onPointerDown,v=>{const y=v.target;y.hasPointerCapture(v.pointerId)&&y.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&(p(),s.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)},v.preventDefault())}),onKeyDown:Ce(i.onKeyDown,v=>{const y=d.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&f(v.key),!(y&&v.key===" ")&&VK.includes(v.key)&&(p(),v.preventDefault())})})))}),QK="SelectValue",ZK=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,children:o,placeholder:s="",...a}=e,l=ba(QK,n),{onValueNodeHasChildrenChange:c}=l,d=o!==void 0,f=et(t,l.onValueNodeChange);return Vn(()=>{c(d)},[c,d]),m.createElement(Be.span,le({},a,{ref:f,style:{pointerEvents:"none"}}),Yk(l.value)?m.createElement(m.Fragment,null,s):o)}),JK=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...i}=e;return m.createElement(Be.span,le({"aria-hidden":!0},i,{ref:t}),r||"▼")}),eX=e=>m.createElement(Dh,le({asChild:!0},e)),jl="SelectContent",tX=m.forwardRef((e,t)=>{const n=ba(jl,e.__scopeSelect),[r,i]=m.useState();if(Vn(()=>{i(new DocumentFragment)},[]),!n.open){const o=r;return o?kt.createPortal(m.createElement(Bk,{scope:e.__scopeSelect},m.createElement(kp.Slot,{scope:e.__scopeSelect},m.createElement("div",null,e.children))),o):null}return m.createElement(nX,le({},e,{ref:t}))}),_o=10,[Bk,ya]=Fl(jl),nX=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:o,onPointerDownOutside:s,side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:g,collisionPadding:p,sticky:v,hideWhenDetached:y,avoidCollisions:x,...w}=e,S=ba(jl,n),[C,P]=m.useState(null),[O,k]=m.useState(null),A=et(t,de=>P(de)),[L,F]=m.useState(null),[z,B]=m.useState(null),V=Mp(n),[X,K]=m.useState(!1),$=m.useRef(!1);m.useEffect(()=>{if(C)return ap(C)},[C]),rp();const J=m.useCallback(de=>{const[ie,...ee]=V().map(oe=>oe.ref.current),[H]=ee.slice(-1),ye=document.activeElement;for(const oe of de)if(oe===ye||(oe==null||oe.scrollIntoView({block:"nearest"}),oe===ie&&O&&(O.scrollTop=0),oe===H&&O&&(O.scrollTop=O.scrollHeight),oe==null||oe.focus(),document.activeElement!==ye))return},[V,O]),G=m.useCallback(()=>J([L,C]),[J,L,C]);m.useEffect(()=>{X&&G()},[X,G]);const{onOpenChange:q,triggerPointerDownPosRef:se}=S;m.useEffect(()=>{if(C){let de={x:0,y:0};const ie=H=>{var ye,oe,Te,Fe;de={x:Math.abs(Math.round(H.pageX)-((ye=(oe=se.current)===null||oe===void 0?void 0:oe.x)!==null&&ye!==void 0?ye:0)),y:Math.abs(Math.round(H.pageY)-((Te=(Fe=se.current)===null||Fe===void 0?void 0:Fe.y)!==null&&Te!==void 0?Te:0))}},ee=H=>{de.x<=10&&de.y<=10?H.preventDefault():C.contains(H.target)||q(!1),document.removeEventListener("pointermove",ie),se.current=null};return se.current!==null&&(document.addEventListener("pointermove",ie),document.addEventListener("pointerup",ee,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ie),document.removeEventListener("pointerup",ee,{capture:!0})}}},[C,q,se]),m.useEffect(()=>{const de=()=>q(!1);return window.addEventListener("blur",de),window.addEventListener("resize",de),()=>{window.removeEventListener("blur",de),window.removeEventListener("resize",de)}},[q]);const[D,W]=Xk(de=>{const ie=V().filter(ye=>!ye.disabled),ee=ie.find(ye=>ye.ref.current===document.activeElement),H=Qk(ie,de,ee);H&&setTimeout(()=>H.ref.current.focus())}),re=m.useCallback((de,ie,ee)=>{const H=!$.current&&!ee;(S.value!==void 0&&S.value===ie||H)&&(F(de),H&&($.current=!0))},[S.value]),N=m.useCallback(()=>C==null?void 0:C.focus(),[C]),ne=m.useCallback((de,ie,ee)=>{const H=!$.current&&!ee;(S.value!==void 0&&S.value===ie||H)&&B(de)},[S.value]),ge=r==="popper"?Vk:rX,he=ge===Vk?{side:a,sideOffset:l,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:g,collisionPadding:p,sticky:v,hideWhenDetached:y,avoidCollisions:x}:{};return m.createElement(Bk,{scope:n,content:C,viewport:O,onViewportChange:k,itemRefCallback:re,selectedItem:L,onItemLeave:N,itemTextRefCallback:ne,focusSelectedItem:G,selectedItemText:z,position:r,isPositioned:X,searchRef:D},m.createElement(hp,{as:no,allowPinchZoom:!0},m.createElement(ip,{asChild:!0,trapped:S.open,onMountAutoFocus:de=>{de.preventDefault()},onUnmountAutoFocus:Ce(i,de=>{var ie;(ie=S.trigger)===null||ie===void 0||ie.focus({preventScroll:!0}),de.preventDefault()})},m.createElement(wl,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:de=>de.preventDefault(),onDismiss:()=>S.onOpenChange(!1)},m.createElement(ge,le({role:"listbox",id:S.contentId,"data-state":S.open?"open":"closed",dir:S.dir,onContextMenu:de=>de.preventDefault()},w,he,{onPlaced:()=>K(!0),ref:A,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:Ce(w.onKeyDown,de=>{const ie=de.ctrlKey||de.altKey||de.metaKey;if(de.key==="Tab"&&de.preventDefault(),!ie&&de.key.length===1&&W(de.key),["ArrowUp","ArrowDown","Home","End"].includes(de.key)){let H=V().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);if(["ArrowUp","End"].includes(de.key)&&(H=H.slice().reverse()),["ArrowUp","ArrowDown"].includes(de.key)){const ye=de.target,oe=H.indexOf(ye);H=H.slice(oe+1)}setTimeout(()=>J(H)),de.preventDefault()}})}))))))}),rX=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...i}=e,o=ba(jl,n),s=ya(jl,n),[a,l]=m.useState(null),[c,d]=m.useState(null),f=et(t,A=>d(A)),g=Mp(n),p=m.useRef(!1),v=m.useRef(!0),{viewport:y,selectedItem:x,selectedItemText:w,focusSelectedItem:S}=s,C=m.useCallback(()=>{if(o.trigger&&o.valueNode&&a&&c&&y&&x&&w){const A=o.trigger.getBoundingClientRect(),L=c.getBoundingClientRect(),F=o.valueNode.getBoundingClientRect(),z=w.getBoundingClientRect();if(o.dir!=="rtl"){const ye=z.left-L.left,oe=F.left-ye,Te=A.left-oe,Fe=A.width+Te,He=Math.max(Fe,L.width),Ke=window.innerWidth-_o,St=a0(oe,[_o,Ke-He]);a.style.minWidth=Fe+"px",a.style.left=St+"px"}else{const ye=L.right-z.right,oe=window.innerWidth-F.right-ye,Te=window.innerWidth-A.right-oe,Fe=A.width+Te,He=Math.max(Fe,L.width),Ke=window.innerWidth-_o,St=a0(oe,[_o,Ke-He]);a.style.minWidth=Fe+"px",a.style.right=St+"px"}const B=g(),V=window.innerHeight-_o*2,X=y.scrollHeight,K=window.getComputedStyle(c),$=parseInt(K.borderTopWidth,10),J=parseInt(K.paddingTop,10),G=parseInt(K.borderBottomWidth,10),q=parseInt(K.paddingBottom,10),se=$+J+X+q+G,D=Math.min(x.offsetHeight*5,se),W=window.getComputedStyle(y),re=parseInt(W.paddingTop,10),N=parseInt(W.paddingBottom,10),ne=A.top+A.height/2-_o,ge=V-ne,he=x.offsetHeight/2,de=x.offsetTop+he,ie=$+J+de,ee=se-ie;if(ie<=ne){const ye=x===B[B.length-1].ref.current;a.style.bottom="0px";const oe=c.clientHeight-y.offsetTop-y.offsetHeight,Te=Math.max(ge,he+(ye?N:0)+oe+G),Fe=ie+Te;a.style.height=Fe+"px"}else{const ye=x===B[0].ref.current;a.style.top="0px";const Te=Math.max(ne,$+y.offsetTop+(ye?re:0)+he)+ee;a.style.height=Te+"px",y.scrollTop=ie-ne+y.offsetTop}a.style.margin=`${_o}px 0`,a.style.minHeight=D+"px",a.style.maxHeight=V+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[g,o.trigger,o.valueNode,a,c,y,x,w,o.dir,r]);Vn(()=>C(),[C]);const[P,O]=m.useState();Vn(()=>{c&&O(window.getComputedStyle(c).zIndex)},[c]);const k=m.useCallback(A=>{A&&v.current===!0&&(C(),S==null||S(),v.current=!1)},[C,S]);return m.createElement(iX,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:k},m.createElement("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:P}},m.createElement(Be.div,le({},i,{ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}}))))}),Vk=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=_o,...o}=e,s=Sy(n);return m.createElement(Ou,le({},s,o,{ref:t,align:r,collisionPadding:i,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}}))}),[iX,Cy]=Fl(jl,{}),Hk="SelectViewport",oX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=ya(Hk,n),o=Cy(Hk,n),s=et(t,i.onViewportChange),a=m.useRef(0);return m.createElement(m.Fragment,null,m.createElement("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"}}),m.createElement(kp.Slot,{scope:n},m.createElement(Be.div,le({"data-radix-select-viewport":"",role:"presentation"},r,{ref:s,style:{position:"relative",flex:1,overflow:"auto",...r.style},onScroll:Ce(r.onScroll,l=>{const c=l.currentTarget,{contentWrapper:d,shouldExpandOnScrollRef:f}=o;if(f!=null&&f.current&&d){const g=Math.abs(a.current-c.scrollTop);if(g>0){const p=window.innerHeight-_o*2,v=parseFloat(d.style.minHeight),y=parseFloat(d.style.height),x=Math.max(v,y);if(x<p){const w=x+g,S=Math.min(p,w),C=w-S;d.style.height=S+"px",d.style.bottom==="0px"&&(c.scrollTop=C>0?C:0,d.style.justifyContent="flex-end")}}}a.current=c.scrollTop})}))))}),sX="SelectGroup",[aX,lX]=Fl(sX),cX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=or();return m.createElement(aX,{scope:n,id:i},m.createElement(Be.div,le({role:"group","aria-labelledby":i},r,{ref:t})))}),uX="SelectLabel",dX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=lX(uX,n);return m.createElement(Be.div,le({id:i.id},r,{ref:t}))}),Ey="SelectItem",[fX,Wk]=Fl(Ey),hX=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:i=!1,textValue:o,...s}=e,a=ba(Ey,n),l=ya(Ey,n),c=a.value===r,[d,f]=m.useState(o??""),[g,p]=m.useState(!1),v=et(t,w=>{var S;return(S=l.itemRefCallback)===null||S===void 0?void 0:S.call(l,w,r,i)}),y=or(),x=()=>{i||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return m.createElement(fX,{scope:n,value:r,disabled:i,textId:y,isSelected:c,onItemTextChange:m.useCallback(w=>{f(S=>{var C;return S||((C=w==null?void 0:w.textContent)!==null&&C!==void 0?C:"").trim()})},[])},m.createElement(kp.ItemSlot,{scope:n,value:r,disabled:i,textValue:d},m.createElement(Be.div,le({role:"option","aria-labelledby":y,"data-highlighted":g?"":void 0,"aria-selected":c&&g,"data-state":c?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1},s,{ref:v,onFocus:Ce(s.onFocus,()=>p(!0)),onBlur:Ce(s.onBlur,()=>p(!1)),onPointerUp:Ce(s.onPointerUp,x),onPointerMove:Ce(s.onPointerMove,w=>{if(i){var S;(S=l.onItemLeave)===null||S===void 0||S.call(l)}else w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ce(s.onPointerLeave,w=>{if(w.currentTarget===document.activeElement){var S;(S=l.onItemLeave)===null||S===void 0||S.call(l)}}),onKeyDown:Ce(s.onKeyDown,w=>{var S;((S=l.searchRef)===null||S===void 0?void 0:S.current)!==""&&w.key===" "||(HK.includes(w.key)&&x(),w.key===" "&&w.preventDefault())})}))))}),Dp="SelectItemText",pX=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,...o}=e,s=ba(Dp,n),a=ya(Dp,n),l=Wk(Dp,n),c=GK(Dp,n),[d,f]=m.useState(null),g=et(t,w=>f(w),l.onItemTextChange,w=>{var S;return(S=a.itemTextRefCallback)===null||S===void 0?void 0:S.call(a,w,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=m.useMemo(()=>m.createElement("option",{key:l.value,value:l.value,disabled:l.disabled},p),[l.disabled,l.value,p]),{onNativeOptionAdd:y,onNativeOptionRemove:x}=c;return Vn(()=>(y(v),()=>x(v)),[y,x,v]),m.createElement(m.Fragment,null,m.createElement(Be.span,le({id:l.textId},o,{ref:g})),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren?kt.createPortal(o.children,s.valueNode):null)}),gX="SelectItemIndicator",mX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Wk(gX,n).isSelected?m.createElement(Be.span,le({"aria-hidden":!0},r,{ref:t})):null}),qk="SelectScrollUpButton",vX=m.forwardRef((e,t)=>{const n=ya(qk,e.__scopeSelect),r=Cy(qk,e.__scopeSelect),[i,o]=m.useState(!1),s=et(t,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const c=a.scrollTop>0;o(c)};const a=n.viewport;return l(),a.addEventListener("scroll",l),()=>a.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?m.createElement(Gk,le({},e,{ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}})):null}),Uk="SelectScrollDownButton",bX=m.forwardRef((e,t)=>{const n=ya(Uk,e.__scopeSelect),r=Cy(Uk,e.__scopeSelect),[i,o]=m.useState(!1),s=et(t,r.onScrollButtonChange);return Vn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const c=a.scrollHeight-a.clientHeight,d=Math.ceil(a.scrollTop)<c;o(d)};const a=n.viewport;return l(),a.addEventListener("scroll",l),()=>a.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?m.createElement(Gk,le({},e,{ref:s,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}})):null}),Gk=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...i}=e,o=ya("SelectScrollButton",n),s=m.useRef(null),a=Mp(n),l=m.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),Vn(()=>{var c;const d=a().find(f=>f.ref.current===document.activeElement);d==null||(c=d.ref.current)===null||c===void 0||c.scrollIntoView({block:"nearest"})},[a]),m.createElement(Be.div,le({"aria-hidden":!0},i,{ref:t,style:{flexShrink:0,...i.style},onPointerDown:Ce(i.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:Ce(i.onPointerMove,()=>{var c;(c=o.onItemLeave)===null||c===void 0||c.call(o),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:Ce(i.onPointerLeave,()=>{l()})}))}),yX=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return m.createElement(Be.div,le({"aria-hidden":!0},r,{ref:t}))});function Yk(e){return e===""||e===void 0}const Kk=m.forwardRef((e,t)=>{const{value:n,...r}=e,i=m.useRef(null),o=et(t,i),s=Op(n);return m.useEffect(()=>{const a=i.current,l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(s!==n&&d){const f=new Event("change",{bubbles:!0});d.call(a,n),a.dispatchEvent(f)}},[s,n]),m.createElement(T2,{asChild:!0},m.createElement("select",le({},r,{ref:o,defaultValue:n})))});Kk.displayName="BubbleSelect";function Xk(e){const t=xn(e),n=m.useRef(""),r=m.useRef(0),i=m.useCallback(s=>{const a=n.current+s;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),o=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,o]}function Qk(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let s=xX(e,Math.max(o,0));i.length===1&&(s=s.filter(c=>c!==n));const l=s.find(c=>c.textValue.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function xX(e,t){return e.map((n,r)=>e[(t+r)%e.length])}const wX=YK,Zk=XK,_X=ZK,SX=JK,CX=eX,Jk=tX,EX=oX,OX=cX,eM=dX,tM=hX,PX=pX,kX=mX,nM=vX,rM=bX,iM=yX,oM=wX,sM=OX,aM=_X,Oy=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsxs(Zk,{ref:r,className:Pe("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,_.jsx(SX,{asChild:!0,children:_.jsx(Hb,{className:"h-4 w-4 opacity-50"})})]}));Oy.displayName=Zk.displayName;const lM=ue.forwardRef(({className:e,...t},n)=>_.jsx(nM,{ref:n,className:Pe("flex cursor-default items-center justify-center py-1",e),...t,children:_.jsx(GB,{className:"h-4 w-4"})}));lM.displayName=nM.displayName;const cM=ue.forwardRef(({className:e,...t},n)=>_.jsx(rM,{ref:n,className:Pe("flex cursor-default items-center justify-center py-1",e),...t,children:_.jsx(Hb,{className:"h-4 w-4"})}));cM.displayName=rM.displayName;const Py=ue.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>_.jsx(CX,{children:_.jsxs(Jk,{ref:i,className:Pe("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[_.jsx(lM,{}),_.jsx(EX,{className:Pe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),_.jsx(cM,{})]})}));Py.displayName=Jk.displayName;const Tp=ue.forwardRef(({className:e,...t},n)=>_.jsx(eM,{ref:n,className:Pe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Tp.displayName=eM.displayName;const xa=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsxs(tM,{ref:r,className:Pe("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[_.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:_.jsx(kX,{children:_.jsx(Rh,{className:"h-4 w-4"})})}),_.jsx(PX,{children:t})]}));xa.displayName=tM.displayName;const MX=ue.forwardRef(({className:e,...t},n)=>_.jsx(iM,{ref:n,className:Pe("-mx-1 my-1 h-px bg-muted",e),...t}));MX.displayName=iM.displayName;function Ap({title:e,items:t,value:n,isLoading:r,isError:i,onChange:o}){const s=r?"Loading...":i?"Error":n;function a(){if(e==="Connection")return _.jsx(JB,{className:" rotate-90",strokeWidth:1,size:16});if(e==="Database")return _.jsx(KB,{strokeWidth:1,size:16});if(e==="Schema")return _.jsx(iV,{strokeWidth:1,size:16});if(e==="Table")return _.jsx(Wb,{strokeWidth:1,size:16})}return _.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx("div",{className:" shrink-0",children:a()}),_.jsxs(oM,{value:s,onValueChange:o,children:[_.jsx(Oy,{className:"focus:ring-offset-0 focus:ring-1 h-7 w-[190px] ",children:_.jsx(aM,{placeholder:r?"Loading...":i?"Error":`Select ${e}`})}),_.jsx(Py,{children:_.jsxs(sM,{children:[r?_.jsx(Tp,{children:"Loading..."}):_.jsx(Tp,{children:e}),_.jsx(_.Fragment,{children:t&&t.map(l=>_.jsx(xa,{value:l.id,children:l.name},l.id))}),(r||i)&&_.jsx(xa,{value:s,children:s})]})})]})]})}function DX({column:e}){const[t,n]=m.useState(!1),r=_e(d=>d.selectedTableName),i=_e(d=>d.selectedSchemaName),o=_e(d=>d.sqlGen),s=_e(d=>d.actions.setSqlGen),a=_e(d=>d.actions.setCardSql),l=_e(d=>d.actions.setRunSql);function c(d,f){const g=WO(d,o,f);s(g);const p=HO(g,i||"",r);p&&(a(p),l(!0)),n(!1)}return _.jsxs(pp,{open:t,onOpenChange:n,children:[_.jsx(gp,{asChild:!0,children:_.jsx(Hj,{className:"w-3 h-3 text-foreground/40 cursor-pointer"})}),_.jsx(Wu,{align:"center",className:" p-0 w-18 rounded-none shadow-none border-muted",children:_.jsxs("ul",{className:"text-xs ",children:[_.jsx("li",{onClick:()=>c(e,"COUNT"),className:" px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Count"}),_.jsx("li",{onClick:()=>c(e,"AVG"),className:" px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Avg"}),_.jsx("li",{onClick:()=>c(e,"SUM"),className:"px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Sum"}),_.jsx("li",{onClick:()=>c(e,"MAX"),className:"px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Max"}),_.jsx("li",{onClick:()=>c(e,"MIN"),className:"px-3 p-1 hover:bg-muted transition-colors cursor-pointer",children:"Min"})]})})]})}function uM({column:e}){return _.jsxs(Bb,{children:[_.jsx(I2,{asChild:!0,children:O0.includes(e.data_type.toLowerCase())?_.jsx("span",{className:" font-thin",children:"T"}):Dl.includes(e.data_type.toLowerCase())?_.jsx("span",{className:" font-thin",children:"#"}):Iu.includes(e.data_type.toLowerCase())?_.jsx("span",{className:" font-thin",children:"D"}):VO.includes(e.data_type.toLowerCase())?_.jsx("span",{className:" font-thin",children:"B"}):_.jsx("span",{className:" font-thin",children:"?"})}),_.jsx(Ih,{children:_.jsx("p",{className:"text-xs font-mono",children:e.data_type})})]})}function TX({schemaName:e,tableName:t,columns:n,status:r}){const i=_e(f=>f.sqlGen),o=_e(f=>f.actions.setRunSql),s=_e(f=>f.actions.setSqlGen),a=_e(f=>f.actions.setIsShowingVisual),l=_e(f=>f.actions.setCardSql);function c(f){const g=WO(f,i);s(g);const p=HO(g,e,t);p&&(l(p),o(!0))}function d(){const f=k0(e,t);a(!1),l(`SELECT * FROM ${f} LIMIT 10`),o(!0)}return _.jsxs("div",{className:"px-4",children:[_.jsx("div",{className:" font-medium px-2 pt-2 pb-3",children:_.jsxs(it,{disabled:r!=="Success",onClick:d,variant:"secondary",className:" h-7 flex w-full",children:[r!=="Success"&&_.jsx(ku,{className:" w-4 h-4 animate-spin mr-2 text-foreground/50"}),"Show top 10 rows"]})}),_.jsxs(Pl,{className:`w-full ${t==="api"?"h-[74vh]":"h-[60vh]"}`,children:[n==null?void 0:n.map(f=>_.jsxs("div",{onClick:()=>c(f),className:Pe(" text-sm flex items-center justify-between px-3 py-[6px] transition-colors hover:bg-muted/50 cursor-pointer rounded ",{" bg-muted":BW(f,i)}),children:[_.jsxs("div",{className:"flex items-center space-x-2 ",children:[_.jsx(uM,{column:f}),_.jsx("span",{children:f.column_name})]}),Dl.includes(f.data_type)&&_.jsx("div",{onClick:g=>g.stopPropagation(),className:" flex items-center justify-end ",children:_.jsx(DX,{column:f})})]},f.column_name)),_.jsx(Hh,{orientation:"vertical"}),_.jsx(Hh,{orientation:"horizontal"})]})]})}function dM({ColumnsComponent:e}){const t=_e(K=>K.selectedConnectionId);_e(K=>K.card.sql);const n=_e(K=>K.selectedDatabaseName),r=_e(K=>K.selectedSchemaName),i=_e(K=>K.selectedTableName),o=_e(K=>K.actions.setSelectedConnectionId),s=_e(K=>K.actions.setSelectedDatabaseName),a=_e(K=>K.actions.setSelectedSchemaName),l=_e(K=>K.actions.setSelectedTableName),c=_e(K=>K.actions.setCardSql),{connectionItems:d,schemaItems:f,databaseItems:g,tableItems:p,columns:v,isConnectionsLoading:y,isConnectionsError:x,isDatabasesLoadingOrFetching:w,isDatabaseError:S,isSchemaLoadingOrFetching:C,isSchemaError:P,isColumnsError:O,isColumnsLoadingOrFetching:k,isAPIConnection:A}=iH();m.useEffect(()=>{A&&(s("NA"),a(""),l("api"))},[A,c,l,a,s]);const L=A?"api":i||"",F=A?"":r||"";function z(K){a(K),l("")}function B(K){s(K),a(""),l("")}function V(K){o(K)}function X(){return e?e(F,L,v):_.jsx(TX,{schemaName:F,tableName:L,columns:v,status:k?"Loading...":O?"Error":"Success"})}return _.jsxs("aside",{className:" grow flex flex-col xbg-red-100 ",children:[_.jsxs("section",{className:"space-y-3 pt-4 pb-3 px-6",children:[_.jsx(Ap,{items:d,title:"Connection",value:t||"",onChange:V,isLoading:y,isError:x}),!A&&_.jsxs(_.Fragment,{children:[_.jsx(Ap,{onChange:B,isError:S,isLoading:w,items:g,value:n||"",title:"Database"}),_.jsx(Ap,{onChange:z,isError:P,isLoading:C,items:f,value:r||"",title:"Schema"}),_.jsx(Ap,{onChange:l,isError:S,items:p,isLoading:w,value:i||"",title:"Table"})]})]}),X(),_.jsx("div",{className:" grow justify-end flex flex-col pt-6 "})]})}const{createElement:zl,createContext:AX,createRef:sfe,forwardRef:fM,useCallback:Rr,useContext:hM,useEffect:wa,useImperativeHandle:pM,useLayoutEffect:IX,useMemo:NX,useRef:ei,useState:Ip}=ue,gM=ue.useId,Np=AX(null);Np.displayName="PanelGroupContext";const Xu=IX,RX=typeof gM=="function"?gM:()=>null;let LX=0;function ky(e=null){const t=RX(),n=ei(e||t||null);return n.current===null&&(n.current=""+LX++),e??n.current}function mM({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:i,forwardedRef:o,id:s,maxSize:a,minSize:l,onCollapse:c,onExpand:d,onResize:f,order:g,style:p,tagName:v="div",...y}){const x=hM(Np);if(x===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:w,expandPanel:S,getPanelSize:C,getPanelStyle:P,groupId:O,isPanelCollapsed:k,registerPanel:A,resizePanel:L,unregisterPanel:F}=x,z=ky(s),B=ei({callbacks:{onCollapse:c,onExpand:d,onResize:f},constraints:{collapsedSize:n,collapsible:r,defaultSize:i,maxSize:a,minSize:l},id:z,idIsFromProps:s!==void 0,order:g});ei({didLogMissingDefaultSizeWarning:!1}),Xu(()=>{const{callbacks:X,constraints:K}=B.current;B.current.id=z,B.current.idIsFromProps=s!==void 0,B.current.order=g,X.onCollapse=c,X.onExpand=d,X.onResize=f,K.collapsedSize=n,K.collapsible=r,K.defaultSize=i,K.maxSize=a,K.minSize=l}),Xu(()=>{const X=B.current;return A(X),()=>{F(X)}},[g,z,A,F]),pM(o,()=>({collapse:()=>{w(B.current)},expand:()=>{S(B.current)},getId(){return z},getSize(){return C(B.current)},isCollapsed(){return k(B.current)},isExpanded(){return!k(B.current)},resize:X=>{L(B.current,X)}}),[w,S,C,k,z,L]);const V=P(B.current,i);return zl(v,{...y,children:e,className:t,style:{...V,...p},"data-panel":"","data-panel-id":z,"data-panel-group-id":O,"data-panel-collapsible":void 0,"data-panel-size":void 0})}const vM=fM((e,t)=>zl(mM,{...e,forwardedRef:t}));mM.displayName="Panel",vM.displayName="forwardRef(Panel)";function st(e,t="Assertion failed!"){if(!e)throw console.error(t),Error(t)}const bM=10;function Qu(e,t,n=bM){e=parseFloat(e.toFixed(n)),t=parseFloat(t.toFixed(n));const r=e-t;return r===0?0:r>0?1:-1}function Lr(e,t,n){return Qu(e,t,n)===0}function Bl({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];st(r!=null);let{collapsedSize:i=0,collapsible:o,maxSize:s=100,minSize:a=0}=r;if(Qu(n,a)<0)if(o){const l=(i+a)/2;Qu(n,l)<0?n=i:n=a}else n=a;return n=Math.min(s,n),n=parseFloat(n.toFixed(bM)),n}function Zu({delta:e,layout:t,panelConstraints:n,pivotIndices:r,trigger:i}){if(Lr(e,0))return t;const o=[...t],[s,a]=r;st(s!=null),st(a!=null);let l=0;if(i==="keyboard"){{const d=e<0?a:s,f=n[d];if(st(f),f.collapsible){const g=t[d];st(g!=null);const p=n[d];st(p);const{collapsedSize:v=0,minSize:y=0}=p;if(Lr(g,v)){const x=y-g;Qu(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const d=e<0?s:a,f=n[d];st(f);const{collapsible:g}=f;if(g){const p=t[d];st(p!=null);const v=n[d];st(v);const{collapsedSize:y=0,minSize:x=0}=v;if(Lr(p,x)){const w=p-y;Qu(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}}{const d=e<0?1:-1;let f=e<0?a:s,g=0;for(;;){const v=t[f];st(v!=null);const x=Bl({panelConstraints:n,panelIndex:f,size:100})-v;if(g+=x,f+=d,f<0||f>=n.length)break}const p=Math.min(Math.abs(e),Math.abs(g));e=e<0?0-p:p}{let f=e<0?s:a;for(;f>=0&&f<n.length;){const g=Math.abs(e)-Math.abs(l),p=t[f];st(p!=null);const v=p-g,y=Bl({panelConstraints:n,panelIndex:f,size:v});if(!Lr(p,y)&&(l+=p-y,o[f]=y,l.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?f--:f++}}if(Lr(l,0))return t;{const d=e<0?a:s,f=t[d];st(f!=null);const g=f+l,p=Bl({panelConstraints:n,panelIndex:d,size:g});if(o[d]=p,!Lr(p,g)){let v=g-p,x=e<0?a:s;for(;x>=0&&x<n.length;){const w=o[x];st(w!=null);const S=w+v,C=Bl({panelConstraints:n,panelIndex:x,size:S});if(Lr(w,C)||(v-=C-w,o[x]=C),Lr(v,0))break;e>0?x--:x++}}}const c=o.reduce((d,f)=>f+d,0);return Lr(c,100)?o:t}function $X({layout:e,panelsArray:t,pivotIndices:n}){let r=0,i=100,o=0,s=0;const a=n[0];st(a!=null),t.forEach((f,g)=>{const{constraints:p}=f,{maxSize:v=100,minSize:y=0}=p;g===a?(r=y,i=v):(o+=y,s+=v)});const l=Math.min(i,100-o),c=Math.max(r,100-s),d=e[a];return{valueMax:l,valueMin:c,valueNow:d}}function Ju(e){return Array.from(document.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function yM(e,t){const r=Ju(e).findIndex(i=>i.getAttribute("data-panel-resize-handle-id")===t);return r??null}function xM(e,t){const n=yM(e,t);return n!=null?[n,n+1]:[-1,-1]}function wM(e){const t=document.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return t||null}function Rp(e){const t=document.querySelector(`[data-panel-resize-handle-id="${e}"]`);return t||null}function FX(e,t,n){var r,i,o,s;const a=Rp(t),l=Ju(e),c=a?l.indexOf(a):-1,d=(r=(i=n[c])===null||i===void 0?void 0:i.id)!==null&&r!==void 0?r:null,f=(o=(s=n[c+1])===null||s===void 0?void 0:s.id)!==null&&o!==void 0?o:null;return[d,f]}function jX({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:i,setLayout:o}){ei({didWarnAboutMissingResizeHandle:!1}),Xu(()=>{const s=Ju(n);for(let a=0;a<i.length-1;a++){const{valueMax:l,valueMin:c,valueNow:d}=$X({layout:r,panelsArray:i,pivotIndices:[a,a+1]}),f=s[a];if(f!=null){const g=i[a];st(g),f.setAttribute("aria-controls",g.id),f.setAttribute("aria-valuemax",""+Math.round(l)),f.setAttribute("aria-valuemin",""+Math.round(c)),f.setAttribute("aria-valuenow",d!=null?""+Math.round(d):"")}}return()=>{s.forEach((a,l)=>{a.removeAttribute("aria-controls"),a.removeAttribute("aria-valuemax"),a.removeAttribute("aria-valuemin"),a.removeAttribute("aria-valuenow")})}},[n,r,i]),wa(()=>{const s=t.current;st(s);const{panelDataArray:a}=s,l=wM(n);st(l!=null,`No group found for id "${n}"`);const c=Ju(n);st(c);const d=c.map(f=>{const g=f.getAttribute("data-panel-resize-handle-id");st(g);const[p,v]=FX(n,g,a);if(p==null||v==null)return()=>{};const y=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const w=a.findIndex(S=>S.id===p);if(w>=0){const S=a[w];st(S);const C=r[w],{collapsedSize:P=0,collapsible:O,minSize:k=0}=S.constraints;if(C!=null&&O){const A=Zu({delta:Lr(C,P)?k-P:P-C,layout:r,panelConstraints:a.map(L=>L.constraints),pivotIndices:xM(n,g),trigger:"keyboard"});r!==A&&o(A)}}break}}};return f.addEventListener("keydown",y),()=>{f.removeEventListener("keydown",y)}});return()=>{d.forEach(f=>f())}},[e,t,n,r,i,o])}function _M(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function SM(e){return e.type==="keydown"}function CM(e){return e.type.startsWith("mouse")}function EM(e){return e.type.startsWith("touch")}function OM(e,t){const n=e==="horizontal";if(CM(t))return n?t.clientX:t.clientY;if(EM(t)){const r=t.touches[0];return st(r),n?r.screenX:r.screenY}else throw Error(`Unsupported event type "${t.type}"`)}function zX(e,t,n,r){const i=n==="horizontal",o=Rp(t);st(o);const s=o.getAttribute("data-panel-group-id");st(s);let{initialCursorPosition:a}=r;const l=OM(n,e),c=wM(s);st(c);const d=c.getBoundingClientRect(),f=i?d.width:d.height;return(l-a)/f*100}function BX(e,t,n,r,i){if(SM(e)){const o=n==="horizontal";let s=0;e.shiftKey?s=100:i!=null?s=i:s=10;let a=0;switch(e.key){case"ArrowDown":a=o?0:s;break;case"ArrowLeft":a=o?-s:0;break;case"ArrowRight":a=o?s:0;break;case"ArrowUp":a=o?0:-s;break;case"End":a=100;break;case"Home":a=-100;break}return a}else return r==null?0:zX(e,t,n,r)}function VX({panelDataArray:e}){const t=Array(e.length),n=e.map(o=>o.constraints);let r=0,i=100;for(let o=0;o<e.length;o++){const s=n[o];st(s);const{defaultSize:a}=s;a!=null&&(r++,t[o]=a,i-=a)}for(let o=0;o<e.length;o++){const s=n[o];st(s);const{defaultSize:a}=s;if(a!=null)continue;const l=e.length-r,c=i/l;r++,t[o]=c,i-=c}return t}function Vl(e,t,n){t.forEach((r,i)=>{const o=e[i];st(o);const{callbacks:s,constraints:a,id:l}=o,{collapsedSize:c=0,collapsible:d}=a,f=n[l];if(f==null||r!==f){n[l]=r;const{onCollapse:g,onExpand:p,onResize:v}=s;v&&v(r,f),d&&(g||p)&&(p&&(f==null||f===c)&&r!==c&&p(),g&&(f==null||f!==c)&&r===c&&g())}})}function Lp(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function HX({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:i,precision:o=3}){const s=n[i];let a;return s==null?a=e??"1":r.length===1?a="1":a=s.toPrecision(o),{flexBasis:0,flexGrow:a,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}let My=null,_a=null;function PM(e){switch(e){case"horizontal":return"ew-resize";case"horizontal-max":return"w-resize";case"horizontal-min":return"e-resize";case"vertical":return"ns-resize";case"vertical-max":return"n-resize";case"vertical-min":return"s-resize"}}function WX(){_a!==null&&(document.head.removeChild(_a),My=null,_a=null)}function Dy(e){if(My===e)return;My=e;const t=PM(e);_a===null&&(_a=document.createElement("style"),document.head.appendChild(_a)),_a.innerHTML=`*{cursor: ${t}!important;}`}function qX(e,t=10){let n=null;return(...i)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...i)},t)}}function kM(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function MM(e){return`react-resizable-panels:${e}`}function DM(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:i,order:o}=t;return i?r:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function TM(e,t){try{const n=MM(e),r=t.getItem(n);if(r){const i=JSON.parse(r);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function UX(e,t,n){var r,i;const o=(r=TM(e,n))!==null&&r!==void 0?r:{},s=DM(t);return(i=o[s])!==null&&i!==void 0?i:null}function GX(e,t,n,r,i){var o;const s=MM(e),a=DM(t),l=(o=TM(e,i))!==null&&o!==void 0?o:{};l[a]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(s,JSON.stringify(l))}catch(c){console.error(c)}}function AM({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((o,s)=>o+s,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!Lr(r,100))for(let o=0;o<t.length;o++){const s=n[o];st(s!=null);const a=100/r*s;n[o]=a}let i=0;for(let o=0;o<t.length;o++){const s=n[o];st(s!=null);const a=Bl({panelConstraints:t,panelIndex:o,size:s});s!=a&&(i+=s-a,n[o]=a)}if(!Lr(i,0))for(let o=0;o<t.length;o++){const s=n[o];st(s!=null);const a=s+i,l=Bl({panelConstraints:t,panelIndex:o,size:a});if(s!==l&&(i-=l-s,n[o]=l,Lr(i,0)))break}return n}const YX=100,ed={getItem:e=>(kM(ed),ed.getItem(e)),setItem:(e,t)=>{kM(ed),ed.setItem(e,t)}},IM={};function NM({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:i,id:o=null,onLayout:s=null,keyboardResizeBy:a=null,storage:l=ed,style:c,tagName:d="div",...f}){const g=ky(o),[p,v]=Ip(null),[y,x]=Ip([]),w=ei({}),S=ei(new Map),C=ei(0),P=ei({autoSaveId:e,direction:r,dragState:p,id:g,keyboardResizeBy:a,onLayout:s,storage:l}),O=ei({layout:y,panelDataArray:[],panelDataArrayChanged:!1});ei({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),pM(i,()=>({getId:()=>P.current.id,getLayout:()=>{const{layout:D}=O.current;return D},setLayout:D=>{const{onLayout:W}=P.current,{layout:re,panelDataArray:N}=O.current,ne=AM({layout:D,panelConstraints:N.map(ge=>ge.constraints)});_M(re,ne)||(x(ne),O.current.layout=ne,W&&W(ne),Vl(N,ne,w.current))}}),[]),Xu(()=>{P.current.autoSaveId=e,P.current.direction=r,P.current.dragState=p,P.current.id=g,P.current.onLayout=s,P.current.storage=l}),jX({committedValuesRef:P,eagerValuesRef:O,groupId:g,layout:y,panelDataArray:O.current.panelDataArray,setLayout:x}),wa(()=>{const{panelDataArray:D}=O.current;if(e){if(y.length===0||y.length!==D.length)return;let W=IM[e];W==null&&(W=qX(GX,YX),IM[e]=W);const re=[...D],N=new Map(S.current);W(e,re,N,y,l)}},[e,y,l]),wa(()=>{});const k=Rr(D=>{const{onLayout:W}=P.current,{layout:re,panelDataArray:N}=O.current;if(D.constraints.collapsible){const ne=N.map(ie=>ie.constraints),{collapsedSize:ge=0,panelSize:he,pivotIndices:de}=Wl(N,D,re);if(st(he!=null),he!==ge){S.current.set(D.id,he);const ee=Hl(N,D)===N.length-1?he-ge:ge-he,H=Zu({delta:ee,layout:re,panelConstraints:ne,pivotIndices:de,trigger:"imperative-api"});Lp(re,H)||(x(H),O.current.layout=H,W&&W(H),Vl(N,H,w.current))}}},[]),A=Rr(D=>{const{onLayout:W}=P.current,{layout:re,panelDataArray:N}=O.current;if(D.constraints.collapsible){const ne=N.map(ee=>ee.constraints),{collapsedSize:ge=0,panelSize:he,minSize:de=0,pivotIndices:ie}=Wl(N,D,re);if(he===ge){const ee=S.current.get(D.id),H=ee!=null&&ee>=de?ee:de,oe=Hl(N,D)===N.length-1?he-H:H-he,Te=Zu({delta:oe,layout:re,panelConstraints:ne,pivotIndices:ie,trigger:"imperative-api"});Lp(re,Te)||(x(Te),O.current.layout=Te,W&&W(Te),Vl(N,Te,w.current))}}},[]),L=Rr(D=>{const{layout:W,panelDataArray:re}=O.current,{panelSize:N}=Wl(re,D,W);return st(N!=null),N},[]),F=Rr((D,W)=>{const{panelDataArray:re}=O.current,N=Hl(re,D);return HX({defaultSize:W,dragState:p,layout:y,panelData:re,panelIndex:N})},[p,y]),z=Rr(D=>{const{layout:W,panelDataArray:re}=O.current,{collapsedSize:N=0,collapsible:ne,panelSize:ge}=Wl(re,D,W);return ne===!0&&ge===N},[]),B=Rr(D=>{const{layout:W,panelDataArray:re}=O.current,{collapsedSize:N=0,collapsible:ne,panelSize:ge}=Wl(re,D,W);return st(ge!=null),!ne||ge>N},[]),V=Rr(D=>{const{panelDataArray:W}=O.current;W.push(D),W.sort((re,N)=>{const ne=re.order,ge=N.order;return ne==null&&ge==null?0:ne==null?-1:ge==null?1:ne-ge}),O.current.panelDataArrayChanged=!0},[]);Xu(()=>{if(O.current.panelDataArrayChanged){O.current.panelDataArrayChanged=!1;const{autoSaveId:D,onLayout:W,storage:re}=P.current,{layout:N,panelDataArray:ne}=O.current;let ge=null;if(D){const de=UX(D,ne,re);de&&(S.current=new Map(Object.entries(de.expandToSizes)),ge=de.layout)}ge==null&&(ge=VX({panelDataArray:ne}));const he=AM({layout:ge,panelConstraints:ne.map(de=>de.constraints)});_M(N,he)||(x(he),O.current.layout=he,W&&W(he),Vl(ne,he,w.current))}});const X=Rr(D=>function(re){re.preventDefault();const{direction:N,dragState:ne,id:ge,keyboardResizeBy:he,onLayout:de}=P.current,{layout:ie,panelDataArray:ee}=O.current,{initialLayout:H}=ne??{},ye=xM(ge,D);let oe=BX(re,D,N,ne,he);if(oe===0)return;const Te=N==="horizontal";document.dir==="rtl"&&Te&&(oe=-oe);const Fe=ee.map(St=>St.constraints),He=Zu({delta:oe,layout:H??ie,panelConstraints:Fe,pivotIndices:ye,trigger:SM(re)?"keyboard":"mouse-or-touch"}),Ke=!Lp(ie,He);(CM(re)||EM(re))&&C.current!=oe&&(C.current=oe,Dy(Ke?Te?"horizontal":"vertical":Te?oe<0?"horizontal-min":"horizontal-max":oe<0?"vertical-min":"vertical-max")),Ke&&(x(He),O.current.layout=He,de&&de(He),Vl(ee,He,w.current))},[]),K=Rr((D,W)=>{const{onLayout:re}=P.current,{layout:N,panelDataArray:ne}=O.current,ge=ne.map(ye=>ye.constraints),{panelSize:he,pivotIndices:de}=Wl(ne,D,N);st(he!=null);const ee=Hl(ne,D)===ne.length-1?he-W:W-he,H=Zu({delta:ee,layout:N,panelConstraints:ge,pivotIndices:de,trigger:"imperative-api"});Lp(N,H)||(x(H),O.current.layout=H,re&&re(H),Vl(ne,H,w.current))},[]),$=Rr((D,W)=>{const{direction:re}=P.current,{layout:N}=O.current,ne=Rp(D);st(ne);const ge=OM(re,W);v({dragHandleId:D,dragHandleRect:ne.getBoundingClientRect(),initialCursorPosition:ge,initialLayout:N})},[]),J=Rr(()=>{WX(),v(null)},[]),G=Rr(D=>{const{panelDataArray:W}=O.current,re=Hl(W,D);re>=0&&(W.splice(re,1),delete w.current[D.id],O.current.panelDataArrayChanged=!0)},[]),q=NX(()=>({collapsePanel:k,direction:r,dragState:p,expandPanel:A,getPanelSize:L,getPanelStyle:F,groupId:g,isPanelCollapsed:z,isPanelExpanded:B,registerPanel:V,registerResizeHandle:X,resizePanel:K,startDragging:$,stopDragging:J,unregisterPanel:G}),[k,p,r,A,L,F,g,z,B,V,X,K,$,J,G]),se={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return zl(Np.Provider,{value:q},zl(d,{...f,children:t,className:n,style:{...se,...c},"data-panel-group":"","data-panel-group-direction":r,"data-panel-group-id":g}))}const RM=fM((e,t)=>zl(NM,{...e,forwardedRef:t}));NM.displayName="PanelGroup",RM.displayName="forwardRef(PanelGroup)";function Hl(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Wl(e,t,n){const r=e.map(c=>c.constraints),i=Hl(e,t),o=r[i],a=i===e.length-1?[i-1,i]:[i,i+1],l=n[i];return{...o,panelSize:l,pivotIndices:a}}function KX({disabled:e,handleId:t,resizeHandler:n}){wa(()=>{if(e||n==null)return;const r=Rp(t);if(r==null)return;const i=o=>{if(!o.defaultPrevented)switch(o.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{o.preventDefault(),n(o);break}case"F6":{o.preventDefault();const s=r.getAttribute("data-panel-group-id");st(s);const a=Ju(s),l=yM(s,t);st(l!==null);const c=o.shiftKey?l>0?l-1:a.length-1:l+1<a.length?l+1:0;a[c].focus();break}}};return r.addEventListener("keydown",i),()=>{r.removeEventListener("keydown",i)}},[e,t,n])}function LM({children:e=null,className:t="",disabled:n=!1,id:r,onDragging:i,style:o={},tabIndex:s=0,tagName:a="div",...l}){const c=ei(null),d=ei({onDragging:i});wa(()=>{d.current.onDragging=i});const f=hM(Np);if(f===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:g,dragState:p,groupId:v,registerResizeHandle:y,startDragging:x,stopDragging:w}=f,S=ky(r),C=(p==null?void 0:p.dragHandleId)===S,[P,O]=Ip(!1),[k,A]=Ip(null),L=Rr(()=>{const z=c.current;st(z),z.blur(),w();const{onDragging:B}=d.current;B&&B(!1)},[w]);wa(()=>{if(n)A(null);else{const z=y(S);A(()=>z)}},[n,S,y]),wa(()=>{if(n||k==null||!C)return;const z=K=>{k(K)},B=K=>{k(K)},V=c.current;st(V);const X=V.ownerDocument;return X.body.addEventListener("contextmenu",L),X.body.addEventListener("mousemove",z),X.body.addEventListener("touchmove",z),X.body.addEventListener("mouseleave",B),window.addEventListener("mouseup",L),window.addEventListener("touchend",L),()=>{X.body.removeEventListener("contextmenu",L),X.body.removeEventListener("mousemove",z),X.body.removeEventListener("touchmove",z),X.body.removeEventListener("mouseleave",B),window.removeEventListener("mouseup",L),window.removeEventListener("touchend",L)}},[g,n,C,k,L]),KX({disabled:n,handleId:S,resizeHandler:k});const F={cursor:PM(g),touchAction:"none",userSelect:"none"};return zl(a,{...l,children:e,className:t,onBlur:()=>O(!1),onFocus:()=>O(!0),onMouseDown:z=>{x(S,z.nativeEvent);const B=d.current;st(B);const{onDragging:V}=B;V&&V(!0)},onMouseUp:L,onTouchCancel:L,onTouchEnd:L,onTouchStart:z=>{x(S,z.nativeEvent);const B=d.current;st(B);const{onDragging:V}=B;V&&V(!0)},ref:c,role:"separator",style:{...F,...o},tabIndex:s,"data-panel-group-direction":g,"data-panel-group-id":v,"data-resize-handle":"","data-resize-handle-active":C?"pointer":P?"keyboard":void 0,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":S})}LM.displayName="PanelResizeHandle";const $M=({className:e,...t})=>_.jsx(RM,{className:Pe("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),$p=vM,FM=({withHandle:e,className:t,...n})=>_.jsx(LM,{className:Pe("relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:-translate-y-1/2 data-[panel-group-direction=vertical]:after:translate-x-0 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&_.jsx("div",{className:"z-10 flex h-4 w-3 items-center justify-center rounded-sm border bg-border",children:_.jsx(XB,{className:"h-2.5 w-2.5"})})});function XX(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function jM(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function zM(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?jM(Object(n),!0).forEach(function(r){XX(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jM(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function QX(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o<r.length;o++)i=r[o],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function ZX(e,t){if(e==null)return{};var n=QX(e,t),r,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function JX(e,t){return eQ(e)||tQ(e,t)||nQ(e,t)||rQ()}function eQ(e){if(Array.isArray(e))return e}function tQ(e,t){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(e)))){var n=[],r=!0,i=!1,o=void 0;try{for(var s=e[Symbol.iterator](),a;!(r=(a=s.next()).done)&&(n.push(a.value),!(t&&n.length===t));r=!0);}catch(l){i=!0,o=l}finally{try{!r&&s.return!=null&&s.return()}finally{if(i)throw o}}return n}}function nQ(e,t){if(e){if(typeof e=="string")return BM(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return BM(e,t)}}function BM(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function rQ(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
429
429
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function iQ(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function VM(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function HM(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?VM(Object(n),!0).forEach(function(r){iQ(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):VM(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function oQ(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r){return t.reduceRight(function(i,o){return o(i)},r)}}function td(e){return function t(){for(var n=this,r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return i.length>=e.length?e.apply(this,i):function(){for(var s=arguments.length,a=new Array(s),l=0;l<s;l++)a[l]=arguments[l];return t.apply(n,[].concat(i,a))}}}function Fp(e){return{}.toString.call(e).includes("Object")}function sQ(e){return!Object.keys(e).length}function nd(e){return typeof e=="function"}function aQ(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function lQ(e,t){return Fp(t)||os("changeType"),Object.keys(t).some(function(n){return!aQ(e,n)})&&os("changeField"),t}function cQ(e){nd(e)||os("selectorType")}function uQ(e){nd(e)||Fp(e)||os("handlerType"),Fp(e)&&Object.values(e).some(function(t){return!nd(t)})&&os("handlersType")}function dQ(e){e||os("initialIsRequired"),Fp(e)||os("initialType"),sQ(e)&&os("initialContent")}function fQ(e,t){throw new Error(e[t]||e.default)}var hQ={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},os=td(fQ)(hQ),jp={changes:lQ,selector:cQ,handler:uQ,initial:dQ};function pQ(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};jp.initial(e),jp.handler(t);var n={current:e},r=td(vQ)(n,t),i=td(mQ)(n),o=td(jp.changes)(e),s=td(gQ)(n);function a(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(d){return d};return jp.selector(c),c(n.current)}function l(c){oQ(r,i,o,s)(c)}return[a,l]}function gQ(e,t){return nd(t)?t(e.current):t}function mQ(e,t){return e.current=HM(HM({},e.current),t),t}function vQ(e,t,n){return nd(t)?t(e.current):Object.keys(n).forEach(function(r){var i;return(i=t[r])===null||i===void 0?void 0:i.call(t,e.current[r])}),n}var bQ={create:pQ},yQ={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.43.0/min/vs"}};function xQ(e){return function t(){for(var n=this,r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return i.length>=e.length?e.apply(this,i):function(){for(var s=arguments.length,a=new Array(s),l=0;l<s;l++)a[l]=arguments[l];return t.apply(n,[].concat(i,a))}}}function wQ(e){return{}.toString.call(e).includes("Object")}function _Q(e){return e||qM("configIsRequired"),wQ(e)||qM("configType"),e.urls?(SQ(),{paths:{vs:e.urls.monacoBase}}):e}function SQ(){console.warn(WM.deprecation)}function CQ(e,t){throw new Error(e[t]||e.default)}var WM={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
430
430
  You are using deprecated way of configuration.
431
431
 
@@ -502,4 +502,4 @@ SELECT label, measure FROM table
502
502
  Table Columns: ${g==null?void 0:g.map(X=>`${X.column_name} | ${X.data_type}`).join(", ")}
503
503
  User SQL: ${p}
504
504
  `,x=` When the user asks for a specific chart please use the following query structure to generate the chart query. Do not make up the column names. Use only the table columns provided above for the query. Replace x-axis, y-axis, and lables with the appropriate column names.
505
- Visual Query Syntax: ${Bne}`,{data:w,isLoading:S,isFetching:C,isError:P,refetch:O}=Sr({queryKey:["ai-query"],queryFn:()=>el("https://semaphor.cloud/api/v1/ai",(s==null?void 0:s.accessToken)||"",{user_content:`userContent: ${y} ${a?x:""}`}),enabled:!1});function k(X){if(X.toLowerCase().includes("bar"))f("bar");else if(X.toLowerCase().includes("line"))f("line");else if(X.toLowerCase().includes("bubble"))f("bubble");else if(X.toLowerCase().includes("scatter"))f("scatter");else if(X.toLowerCase().includes("stacked"))f("stackedBar");else if(X.toLowerCase().includes("pie"))f("pie");else if(X.toLowerCase().includes("donut")||X.toLowerCase().includes("doughnut"))f("doughnut");else if(X.toLowerCase().includes("radar"))f("radar");else return f("bar"),!1;return!0}function A(){n&&(k(n)&&l(!0),O())}m.useEffect(()=>{i&&(A(),o(!1))},[i,o]);const L={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"5px",width:"100%"},F={fontFamily:"monospace",fontSize:14,lineHeight:1.6},z={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},B={p:({node:X,...K})=>_.jsx("p",{style:L,...K}),pre:({node:X,...K})=>_.jsxs("pre",{className:" bg-muted/50 space-y-2 p-3 rounded-sm",style:F,children:[_.jsx("code",{className:" whitespace-normal",children:K.children}),_.jsxs("div",{className:" flex justify-start gap-2",children:[_.jsx(it,{onClick:V,size:"sm",variant:"outline",children:_.jsx(JE,{})}),_.jsx(it,{onClick:$=>{const J=V($);J&&(t(!1),c(J),d(!0))},size:"sm",variant:"outline",children:_.jsx(Zj,{})})]})]}),li:({node:X,...K})=>_.jsx("li",{style:z,...K})};function V(X){const K=X.currentTarget.closest("pre");if(!K)return;const $=K.textContent||K.innerText;return navigator.clipboard.writeText($).then(()=>console.log("Text copied to clipboard")).catch(J=>console.error("Error in copying text: ",J)),$}return _.jsxs(xy,{open:e,onOpenChange:t,children:[_.jsx(wy,{asChild:!0,children:_.jsx(it,{size:"sm",className:"",variant:"outline",children:_.jsx(nV,{strokeWidth:1,size:16})})}),_.jsxs(_p,{className:" border-muted sm:max-w-[425px] md:min-w-[625px] md:max-h-[625px] flex flex-col justify-between overflow-auto",children:[_.jsxs(Sp,{children:[_.jsx(Cp,{children:"Ask"}),_.jsx(Ep,{children:"Need assistance with SQL queries? Feel free to ask me any question!"})]}),_.jsx(Pl,{className:"h-[625px] w-full border-t border-t-muted ",children:(!S||!C)&&_.jsx(jne,{className:" pl-1 pr-3 py-1 w-full xbg-red-100 overflow-auto ",components:B,children:w==null?void 0:w.response})}),_.jsxs("div",{children:[_.jsx(lf,{className:Pe(" invisible h-1 w-full animate-pulse",{visible:S||C})}),_.jsxs("div",{className:" border rounded-md flex items-center w-full",children:[_.jsx(By,{onKeyDown:X=>{X.key==="Enter"&&!X.shiftKey&&(X.preventDefault(),r(""),A())},placeholder:"Type something...",onFocus:X=>{const K=X.target,$=K.value.length;K.setSelectionRange($,$)},className:" border-none resize-none min-h-7 max-h-10 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",value:n,onChange:X=>r(X.target.value)})," ",_.jsx(it,{className:"h-8",size:"sm",variant:"ghost",onClick:A,children:!S&&!C?_.jsx(Xj,{}):_.jsx(ku,{className:" w-4 h-4 animate-spin mr-2 text-foreground/50"})})]})]})]})]})}function Hne(){const{theme:e}=Cm(),t=m.useRef(),n=m.useRef(),[r,i]=m.useState(!1),[o,s]=m.useState(!1),[a,l]=m.useState(""),[c,d]=m.useState(!1);m.useState("");const f=be(H=>H.authToken),g=_e(H=>H.card),p=be(H=>H.theme),v=_e(H=>H.selectedConnectionId),y=_e(H=>H.selectedDatabaseName),x=_e(H=>H.selectedSchemaName),w=_e(H=>H.selectedTableName),S=_e(H=>H.actions.setCardSql),C=_e(H=>H.card.sql),P=_e(H=>H.selectedConnectionId),O=_e(H=>H.filterValues),k=_e(H=>H.applyFilters),A=_e(H=>H.actions.setCardCustomCfg),L=_e(H=>H.actions.setFilterValues),F=_e(H=>H.onSave),z=_e(H=>H.actions.setApplyFilters),B=_e(H=>H.onClose),V=_e(H=>H.actions.setCardData),X=_e(H=>H.actions.setSqlGen),K=_e(H=>H.runSql),$=_e(H=>H.actions.setRunSql),J=_e(H=>H.actions.setIsSqlRunning),{data:G,isLoading:q,isFetching:se,isSuccess:D,isError:W,error:re,status:N,refetch:ne}=Sr({queryKey:[C],queryFn:()=>Ts("https://semaphor.cloud/api/v1/query",(f==null?void 0:f.accessToken)||"",{connection_id:P,sql:C,active_filters:k?O:[]}),enabled:!1,retry:!1});m.useEffect(()=>{G&&(console.log("queryData",G),V(G.records))},[G,V]),m.useEffect(()=>{K&&(ne(),$(!1))},[K,ne,$]),m.useEffect(()=>{(q||se)&&J(!0),(W||D)&&J(!1)},[q,se,W,D,J]);function ge(){S(""),V([]),X({}),A("")}const he=H=>{n.current=H};function de(){if(C&&!C.includes("{{")){const H=eZ(C);S(H),F==null||F({...g,sql:H,lastSelectedSchema:x,lastSelectedDatabase:y,lastSelectedTable:w,connectionId:v})}else F==null||F(g)}function ie(){B==null||B()}m.useEffect(()=>{const H=t.current,ye=n.current;if(H){const oe=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",Te=p==="system"?oe:p;H.editor.defineTheme("default",{base:Te==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":Te==="light"?"#ffffff":"#020817"}}),H.editor.setTheme("default")}return ye&&H&&ye.addCommand(H.KeyMod.Shift|H.KeyCode.Enter,function(){return console.log("Executing query..."),ne(),!1}),()=>{}},[e,p,t.current]);function ee(H){t.current=H}return _.jsxs("section",{className:"grow h-full flex flex-col justify-end pt-3 ",children:[_.jsxs("div",{className:" grow flex relative justify-between ",children:[_.jsx("div",{className:`flex ${r?"w-2/3":"w-[95%]"} xbg-red-100 p-1`,children:_.jsx(Ny,{theme:"default",onChange:H=>{S(H),console.log(H)},value:C,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:ee,onMount:he})}),r&&_.jsx("div",{className:" w-1/3 text-xs relative overflow-hidden xbg-yellow-100 p-1 ",children:_.jsxs("div",{className:"min-h-0 ",children:[_.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx(wZ,{checked:k,onCheckedChange:()=>z(!k),text:"Apply Filters"}),_.jsx(_Z,{})]}),_.jsx(Ny,{theme:"default",onChange:H=>{if(H)try{JSON.parse(H),L(JSON.parse(H))}catch{}},defaultLanguage:"json",className:"min-h-[220px] mt-1",value:JSON.stringify(O,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),O&&r&&_.jsx(na,{onClick:()=>i(!1),className:"absolute right-6 top-1 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer"}),O&&!r&&_.jsx(W2,{onClick:()=>i(!0),className:Pe("absolute right-6 top-1 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer",{"text-red-800 font-bold":k})})]}),_.jsxs("div",{className:" flex grow px-6 pt-3 pb-4 gap-2 justify-between item-center",children:[_.jsxs("div",{className:"flex grow gap-2 items-center",children:[_.jsxs(it,{disabled:q||se,onClick:()=>{ne()},className:" shrink-0",size:"sm",variant:"outline",children:[(q||se)&&_.jsx(ku,{className:"w-4 h-4 mr-2 animate-spin text-foreground/50"}),"Run"]}),W&&_.jsx(fZ,{error:re.message}),_.jsx(it,{onClick:ge,className:"",size:"sm",variant:"outline",children:"Clear"}),_.jsx(Ku,{value:a,placeholder:"Type something...",onChange:H=>{l(H.target.value)},onKeyDown:H=>{H.key==="Enter"&&(H.preventDefault(),console.log("enter pressed"),d(!0),s(!0))},className:" bg-muted border-none h-9 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"}),_.jsx(Vne,{open:o,setOpen:s,userInput:a,triggerAIRun:c,setTriggerAIRun:d,setUserInput:H=>l(H)})]}),_.jsxs("div",{className:"flex gap-2 items-end ",children:[_.jsx(it,{onClick:de,size:"sm",variant:"outline",children:_.jsx(Rh,{size:16,strokeWidth:2,className:"text-green-600 font-bold"})}),_.jsx(it,{onClick:ie,className:" w-full",size:"sm",variant:"outline",children:_.jsx(na,{className:" h-3.5 w-3.5"})})]})]})]})}const $T="Switch",[Wne,_fe]=Pn($T),[qne,Une]=Wne($T),Gne=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:o,required:s,disabled:a,value:l="on",onCheckedChange:c,...d}=e,[f,g]=m.useState(null),p=et(t,S=>g(S)),v=m.useRef(!1),y=f?!!f.closest("form"):!0,[x=!1,w]=Qn({prop:i,defaultProp:o,onChange:c});return m.createElement(qne,{scope:n,checked:x,disabled:a},m.createElement(Be.button,le({type:"button",role:"switch","aria-checked":x,"aria-required":s,"data-state":FT(x),"data-disabled":a?"":void 0,disabled:a,value:l},d,{ref:p,onClick:Ce(e.onClick,S=>{w(C=>!C),y&&(v.current=S.isPropagationStopped(),v.current||S.stopPropagation())})})),y&&m.createElement(Xne,{control:f,bubbles:!v.current,name:r,value:l,checked:x,required:s,disabled:a,style:{transform:"translateX(-100%)"}}))}),Yne="SwitchThumb",Kne=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=Une(Yne,n);return m.createElement(Be.span,le({"data-state":FT(i.checked),"data-disabled":i.disabled?"":void 0},r,{ref:t}))}),Xne=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Op(n),a=Mh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const g=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(g)}},[s,n,r]),m.createElement("input",le({type:"checkbox","aria-hidden":!0,defaultChecked:n},i,{tabIndex:-1,ref:o,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function FT(e){return e?"checked":"unchecked"}const jT=Gne,Qne=Kne,zT=ue.forwardRef(({className:e,...t},n)=>_.jsx(jT,{className:Pe("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:_.jsx(Qne,{className:Pe("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));zT.displayName=jT.displayName;function BT({className:e,...t}){const[n,r]=m.useState(0),i=be(l=>l.themeStyle),o=_e(l=>l.card),s=_e(l=>l.actions.setCard);if(m.useEffect(()=>{r(n+1)},[o.data,o.type,o.cfg,o.customCfg,i]),!o.id)return null;let a;return o.data&&o.data.length>0&&(a=Pb({data:o.data,cardType:o.type,cfg:o.cfg,customCfg:o.customCfg})),_.jsxs(kv,{role:"editor-visual-card",className:Pe(" relative h-full flex flex-col rounded-none",e),...t,children:[_.jsxs(Mv,{children:[_.jsx(qc,{text:o.title,onSave:l=>s({...o,title:l}),children:_.jsx(Dv,{className:"text-base",children:o.title})}),_.jsx(qc,{text:o.description||"",onSave:l=>s({...o,description:l}),children:_.jsxs(Tv,{children:[" ",o.description]})})]}),_.jsxs(Av,{className:"flex flex-col pb-3 grow",children:[o.type!=="table"&&a&&_.jsx(QE,{cfg:a},n),o.type==="table"&&o.data&&o.data.length>0&&_.jsx(cO,{children:_.jsx(s0,{data:o==null?void 0:o.data})})]})]})}function Zne(){const[e,t]=m.useState(!1),[n,r]=m.useState(""),[i,o]=m.useState(""),[s,a]=m.useState(""),l=_e(x=>x.card),c=_e(x=>x.card.customCfg),d=_e(x=>x.actions.setCardCustomCfg);function f(x){var C,P;const w={...x,data:{...x==null?void 0:x.data,datasets:(P=(C=x==null?void 0:x.data)==null?void 0:C.datasets)==null?void 0:P.map(O=>({...O,data:[]}))}};return JSON.stringify(w,null,1)}function g(){if(!l.data||l.data.length===0)return;const x=Pb({data:l.data,cardType:l.type,cfg:l.cfg});x&&(r(JSON.stringify(x,null,1)),c&&o(JSON.stringify(c,null,1)))}function p(){if(i)try{const x=JSON.parse(i);return x?(d(x),a(""),o(""),x):void 0}catch(x){console.log(x),a("Invalid JSON")}}function v(){o(""),d(null)}function y(){let x;if(c){const w=Rs.cloneDeep(l.cfg),S=Rs.merge(w,c);return x=f(S),x}return n?(x=f(JSON.parse(n)),x):""}return _.jsxs(xy,{open:e,onOpenChange:t,children:[_.jsx(wy,{asChild:!0,children:_.jsx(it,{onClick:g,className:`h-7 ${c&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:c?"Custom Config":"Customize"})}),_.jsx(_p,{className:" sm:max-w-[425px] md:min-w-[600px] md:min-h-[700px] lg:min-w-[800px] xl:min-w-[1000px]",children:_.jsxs("div",{className:"bg-red-x100 flex flex-col gap-2 justify-between",children:[_.jsxs(Sp,{className:"",children:[_.jsx(Cp,{children:"Customize Chart"}),_.jsxs(Ep,{children:["See the configuration options and documentation",_.jsx("a",{target:"_blank",className:"ml-1 underline text-blue-500 ",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),_.jsxs("div",{className:"grow flex flex-wrap gap-2",children:[_.jsx(BT,{className:"flex-1 rounded shadow-none"}),_.jsxs(a_,{defaultValue:"custom-config",className:" flex flex-col flex-1",children:[_.jsxs(l_,{className:" justify-start border rounded-sm rounded-b-none border-b-0 ",children:[_.jsxs(Am,{value:"custom-config",children:[c&&_.jsx(ZE,{className:"w-5 h-5 mr-1 text-green-600"}),c?"Custom Config":"Default Config"]}),_.jsx(Am,{className:"",value:"output",children:"Output"})]}),_.jsx(ff,{className:" grow mt-0 bg-red-x p-2 border border-t-0 rounded-b ",value:"output",children:_.jsx(By,{disabled:!0,value:n,className:" border-none resize-none font-mono h-full focus-visible:ring-0 focus-visible:ring-offset-0"})}),_.jsx(ff,{className:"grow mt-0 border border-t-0 rounded-b ",value:"custom-config",children:_.jsx(Ny,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"json",value:y(),onChange:x=>o(x)})})]})]}),_.jsxs(_y,{className:"flex items-center",children:[_.jsx(fa,{className:"text-red-500 mr-2",children:s}),_.jsx(it,{disabled:!c,onClick:v,variant:"outline",children:"Reset"}),_.jsx(it,{onClick:p,variant:"outline",children:"Apply"}),_.jsx(it,{onClick:()=>t(!1),variant:"outline",children:"Close"})]})]})})]})}var VT={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},HT=m.createContext&&m.createContext(VT),Jne=["attr","size","title"];function ere(e,t){if(e==null)return{};var n=tre(e,t),r,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function tre(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o<r.length;o++)i=r[o],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function eg(){return eg=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},eg.apply(this,arguments)}function WT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function tg(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?WT(Object(n),!0).forEach(function(r){nre(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):WT(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function nre(e,t,n){return t=rre(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function rre(e){var t=ire(e,"string");return typeof t=="symbol"?t:String(t)}function ire(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function qT(e){return e&&e.map((t,n)=>m.createElement(t.tag,tg({key:n},t.attr),qT(t.child)))}function dd(e){return t=>m.createElement(ore,eg({attr:tg({},e.attr)},t),qT(e.child))}function ore(e){var t=n=>{var{attr:r,size:i,title:o}=e,s=ere(e,Jne),a=i||n.size||"1em",l;return n.className&&(l=n.className),e.className&&(l=(l?l+" ":"")+e.className),m.createElement("svg",eg({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,s,{className:l,style:tg(tg({color:e.color||n.color},n.style),e.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),o&&m.createElement("title",null,o),e.children)};return HT!==void 0?m.createElement(HT.Consumer,null,n=>t(n)):t(VT)}function UT(e){return dd({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M926.8 397.1l-396-288a31.81 31.81 0 0 0-37.6 0l-396 288a31.99 31.99 0 0 0-11.6 35.8l151.3 466a32 32 0 0 0 30.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z"},child:[]}]})(e)}function GT(e){return dd({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm87.63,96H191.48A64.1,64.1,0,0,0,136,64.52V40.37A88.13,88.13,0,0,1,215.63,120ZM120,120H80.68A48.09,48.09,0,0,1,120,80.68Zm0,16v39.32A48.09,48.09,0,0,1,80.68,136Zm16,0h39.32A48.09,48.09,0,0,1,136,175.32Zm0-16V80.68A48.09,48.09,0,0,1,175.32,120ZM120,40.37V64.52A64.1,64.1,0,0,0,64.52,120H40.37A88.13,88.13,0,0,1,120,40.37ZM40.37,136H64.52A64.1,64.1,0,0,0,120,191.48v24.15A88.13,88.13,0,0,1,40.37,136ZM136,215.63V191.48A64.1,64.1,0,0,0,191.48,136h24.15A88.13,88.13,0,0,1,136,215.63Z"},child:[]}]})(e)}function YT(e){return dd({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137,28.05a11.94,11.94,0,0,0-9.12,3.08A12.09,12.09,0,0,0,124,40V80.67a11.88,11.88,0,0,0,9.9,11.81,36,36,0,1,1-41.85,37.4c-.47-9.14,1.47-16.8,5.75-22.79h0a11.89,11.89,0,0,0-1.3-15.35L68.87,63.51a12,12,0,0,0-17.74.83A99.6,99.6,0,0,0,57.79,199.2,99.24,99.24,0,0,0,128,228h1.43A100.29,100.29,0,0,0,228,129.42C228.72,77.21,188.76,32.68,137,28.05ZM57.28,69.46A4,4,0,0,1,60.2,68h.19a3.91,3.91,0,0,1,2.79,1.14L90.81,97.36a3.93,3.93,0,0,1,.48,5.08A40.47,40.47,0,0,0,84.08,124h-48A90.36,90.36,0,0,1,57.28,69.46ZM36.09,132H84.18A44,44,0,0,0,124,171.81V219.9A92,92,0,0,1,36.09,132ZM193,193a91.43,91.43,0,0,1-61,26.92V171.82a43.51,43.51,0,0,0,26-11.63,44,44,0,0,0-22.79-75.6A4,4,0,0,1,132,80.67V40a4,4,0,0,1,1.31-3,3.89,3.89,0,0,1,3-1c47.59,4.26,84.34,45.24,83.67,93.29A91.42,91.42,0,0,1,193,193Z"},child:[]}]})(e)}function KT(e){return dd({tag:"svg",attr:{viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},child:[]},{tag:"path",attr:{d:"M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0"},child:[]}]})(e)}function XT(e){return dd({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M4 9h4v11H4zM4 4h4v4H4zM10 7h4v4h-4zM16 10h4v4h-4zM16 15h4v5h-4zM10 12h4v8h-4z"},child:[]}]})(e)}function sre(){const[e,t]=m.useState(!1),n=_e(s=>s.card.type),r=_e(s=>s.actions.setCardType),i=_e(s=>s.actions.setCardCustomCfg);function o(s){r(s),i(null),t(!1)}return _.jsxs(pp,{open:e,onOpenChange:t,children:[_.jsx(gp,{asChild:!0,children:_.jsx(it,{className:"h-7 px-2",variant:"outline",children:_.jsx(are,{className:"h-4 w-4",chartType:n})})}),_.jsx(Wu,{className:"w-50",children:_.jsxs("div",{className:"grid grid-cols-3 place-items-center ",children:[_.jsx(it,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:_.jsx(B2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("line"),variant:"ghost",children:_.jsx(q2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("stackedBar"),variant:"ghost",children:_.jsx(XT,{className:"h-6 w-6 text-foreground/50 ",strokeWidth:0})}),_.jsx(it,{onClick:()=>o("scatter"),variant:"ghost",children:_.jsx(G2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("bubble"),variant:"ghost",children:_.jsx(KT,{strokeWidth:2})}),_.jsx(it,{onClick:()=>o("pie"),variant:"ghost",children:_.jsx(U2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("doughnut"),variant:"ghost",children:_.jsx(YT,{className:"h-7 w-7",strokeWidth:.5})}),_.jsx(it,{onClick:()=>o("radar"),variant:"ghost",children:_.jsx(UT,{className:"h-6 w-6 text-foreground/50 font-extralight",strokeWidth:.5})}),_.jsx(it,{onClick:()=>o("polarArea"),variant:"ghost",children:_.jsx(GT,{className:"h-6 w-6 text-foreground/50",strokeWidth:1})}),_.jsx(it,{onClick:()=>o("table"),variant:"ghost",children:_.jsx(Wb,{className:"h-6 w-6 text-foreground/90",strokeWidth:1})})]})})]})}function are({chartType:e,className:t}){switch(e){case"bar":return _.jsx(B2,{className:t});case"line":return _.jsx(q2,{className:t});case"pie":return _.jsx(U2,{className:t});case"radar":return _.jsx(UT,{className:t});case"scatter":return _.jsx(G2,{className:t});case"bubble":return _.jsx(KT,{className:t});case"doughnut":return _.jsx(YT,{className:t});case"stackedBar":return _.jsx(XT,{className:"h-5 w-5 text-foreground/50 ",strokeWidth:0});case"polarArea":return _.jsx(GT,{className:t});default:return _.jsx(Wb,{className:t})}}function lre(){const e=_e(n=>n.card.refreshInterval),t=_e(n=>n.actions.setCardRefreshInterval);return _.jsxs(pp,{children:[_.jsx(gp,{asChild:!0,children:_.jsx(it,{className:"h-7",variant:"outline",children:"Realtime"})}),_.jsx(Wu,{className:"w-[200px]",children:_.jsx("div",{className:"grid gap-4",children:_.jsx("div",{className:"grid gap-2",children:_.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[_.jsx(fa,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),_.jsx(Ku,{value:e||"",onChange:n=>t(n.target.value),id:"width",placeholder:"30s",className:"col-span-2 h-7 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0"})]})})})})]})}function QT(){const e=_e(r=>r.card),t=_e(r=>r.isShowingVisual),n=_e(r=>r.isSqlRunning);return _e(r=>r.onSave),_e(r=>r.onClose),_e(r=>r.actions.setCardSql),_e(r=>r.actions.setCardType),_e(r=>r.actions.setSqlGen),_.jsxs("div",{className:" h-full relative flex flex-col",children:[n&&_.jsx(ku,{className:" w-10 h-10 z-10 absolute m-auto left-0 right-0 top-0 bottom-0 animate-spin text-foreground/10 "}),_.jsxs("div",{className:" h-10 px-6 pt-6 bg-red-x100 mb-0 z-10 right-0 flex justify-end items-center gap-2",children:[t&&_.jsxs("div",{className:"bg-red-x00 flex grow gap-2",children:[_.jsx(sre,{}),_.jsx(Zne,{}),_.jsx(lre,{})]}),_.jsx(cre,{})]}),t?_.jsx(BT,{className:"grow border-none shadow-none "}):_.jsx("div",{className:"w-full mt-4 px-6 bg-red-x00 grow border-none shadow-none overflow-y-auto ",children:e.data&&e.data.length>0&&_.jsx(s0,{data:e.data})})]})}function cre(){const e=_e(n=>n.isShowingVisual),t=_e(n=>n.actions.setIsShowingVisual);return _.jsxs("div",{className:" flex items-center space-x-2",children:[_.jsx(fa,{htmlFor:"visualize",children:"Chart"}),_.jsx(zT,{checked:e,onCheckedChange:()=>t(!e),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}const ZT="Collapsible",[ure,JT]=Pn(ZT),[dre,_x]=ure(ZT),fre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:o,onOpenChange:s,...a}=e,[l=!1,c]=Qn({prop:r,defaultProp:i,onChange:s});return m.createElement(dre,{scope:n,disabled:o,contentId:or(),open:l,onOpenToggle:m.useCallback(()=>c(d=>!d),[c])},m.createElement(Be.div,le({"data-state":Sx(l),"data-disabled":o?"":void 0},a,{ref:t})))}),hre="CollapsibleTrigger",pre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=_x(hre,n);return m.createElement(Be.button,le({type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":Sx(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled},r,{ref:t,onClick:Ce(e.onClick,i.onOpenToggle)}))}),eA="CollapsibleContent",gre=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=_x(eA,e.__scopeCollapsible);return m.createElement(vn,{present:n||i.open},({present:o})=>m.createElement(mre,le({},r,{ref:t,present:o})))}),mre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...o}=e,s=_x(eA,n),[a,l]=m.useState(r),c=m.useRef(null),d=et(t,c),f=m.useRef(0),g=f.current,p=m.useRef(0),v=p.current,y=s.open||a,x=m.useRef(y),w=m.useRef();return m.useEffect(()=>{const S=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(S)},[]),Vn(()=>{const S=c.current;if(S){w.current=w.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const C=S.getBoundingClientRect();f.current=C.height,p.current=C.width,x.current||(S.style.transitionDuration=w.current.transitionDuration,S.style.animationName=w.current.animationName),l(r)}},[s.open,r]),m.createElement(Be.div,le({"data-state":Sx(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!y},o,{ref:d,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style}}),y&&i)});function Sx(e){return e?"open":"closed"}const vre=fre,bre=pre,yre=gre,ls="Accordion",xre=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Cx,wre,_re]=uf(ls),[ng,Sfe]=Pn(ls,[_re,JT]),Ex=JT(),tA=m.forwardRef((e,t)=>{const{type:n,...r}=e,i=r,o=r;return m.createElement(Cx.Provider,{scope:e.__scopeAccordion},n==="multiple"?m.createElement(Ore,le({},o,{ref:t})):m.createElement(Ere,le({},i,{ref:t})))});tA.propTypes={type(e){const t=e.value||e.defaultValue;return e.type&&!["single","multiple"].includes(e.type)?new Error("Invalid prop `type` supplied to `Accordion`. Expected one of `single | multiple`."):e.type==="multiple"&&typeof t=="string"?new Error("Invalid prop `type` supplied to `Accordion`. Expected `single` when `defaultValue` or `value` is type `string`."):e.type==="single"&&Array.isArray(t)?new Error("Invalid prop `type` supplied to `Accordion`. Expected `multiple` when `defaultValue` or `value` is type `string[]`."):null}};const[nA,Sre]=ng(ls),[rA,Cre]=ng(ls,{collapsible:!1}),Ere=m.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:i=()=>{},collapsible:o=!1,...s}=e,[a,l]=Qn({prop:n,defaultProp:r,onChange:i});return m.createElement(nA,{scope:e.__scopeAccordion,value:a?[a]:[],onItemOpen:l,onItemClose:m.useCallback(()=>o&&l(""),[o,l])},m.createElement(rA,{scope:e.__scopeAccordion,collapsible:o},m.createElement(iA,le({},s,{ref:t}))))}),Ore=m.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:i=()=>{},...o}=e,[s=[],a]=Qn({prop:n,defaultProp:r,onChange:i}),l=m.useCallback(d=>a((f=[])=>[...f,d]),[a]),c=m.useCallback(d=>a((f=[])=>f.filter(g=>g!==d)),[a]);return m.createElement(nA,{scope:e.__scopeAccordion,value:s,onItemOpen:l,onItemClose:c},m.createElement(rA,{scope:e.__scopeAccordion,collapsible:!0},m.createElement(iA,le({},o,{ref:t}))))}),[Pre,rg]=ng(ls),iA=m.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:i,orientation:o="vertical",...s}=e,a=m.useRef(null),l=et(a,t),c=wre(n),f=Ls(i)==="ltr",g=Ce(e.onKeyDown,p=>{var v;if(!xre.includes(p.key))return;const y=p.target,x=c().filter(F=>{var z;return!((z=F.ref.current)!==null&&z!==void 0&&z.disabled)}),w=x.findIndex(F=>F.ref.current===y),S=x.length;if(w===-1)return;p.preventDefault();let C=w;const P=0,O=S-1,k=()=>{C=w+1,C>O&&(C=P)},A=()=>{C=w-1,C<P&&(C=O)};switch(p.key){case"Home":C=P;break;case"End":C=O;break;case"ArrowRight":o==="horizontal"&&(f?k():A());break;case"ArrowDown":o==="vertical"&&k();break;case"ArrowLeft":o==="horizontal"&&(f?A():k());break;case"ArrowUp":o==="vertical"&&A();break}const L=C%S;(v=x[L].ref.current)===null||v===void 0||v.focus()});return m.createElement(Pre,{scope:n,disabled:r,direction:i,orientation:o},m.createElement(Cx.Slot,{scope:n},m.createElement(Be.div,le({},s,{"data-orientation":o,ref:l,onKeyDown:r?void 0:g}))))}),Ox="AccordionItem",[kre,Px]=ng(Ox),Mre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...i}=e,o=rg(Ox,n),s=Sre(Ox,n),a=Ex(n),l=or(),c=r&&s.value.includes(r)||!1,d=o.disabled||e.disabled;return m.createElement(kre,{scope:n,open:c,disabled:d,triggerId:l},m.createElement(vre,le({"data-orientation":o.orientation,"data-state":sA(c)},a,i,{ref:t,disabled:d,open:c,onOpenChange:f=>{f?s.onItemOpen(r):s.onItemClose(r)}})))}),Dre="AccordionHeader",Tre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=rg(ls,n),o=Px(Dre,n);return m.createElement(Be.h3,le({"data-orientation":i.orientation,"data-state":sA(o.open),"data-disabled":o.disabled?"":void 0},r,{ref:t}))}),oA="AccordionTrigger",Are=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=rg(ls,n),o=Px(oA,n),s=Cre(oA,n),a=Ex(n);return m.createElement(Cx.ItemSlot,{scope:n},m.createElement(bre,le({"aria-disabled":o.open&&!s.collapsible||void 0,"data-orientation":i.orientation,id:o.triggerId},a,r,{ref:t})))}),Ire="AccordionContent",Nre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=rg(ls,n),o=Px(Ire,n),s=Ex(n);return m.createElement(yre,le({role:"region","aria-labelledby":o.triggerId,"data-orientation":i.orientation},s,r,{ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}}))});function sA(e){return e?"open":"closed"}const Rre=tA,Lre=Mre,$re=Tre,aA=Are,lA=Nre,cA=Rre,cs=ue.forwardRef(({className:e,...t},n)=>_.jsx(Lre,{ref:n,className:Pe("border-b",e),...t}));cs.displayName="AccordionItem";const us=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsx($re,{className:"flex",children:_.jsxs(aA,{ref:r,className:Pe("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,_.jsx(Hb,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));us.displayName=aA.displayName;const ds=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsx(lA,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:_.jsx("div",{className:Pe("pb-4 pt-0",e),children:t})}));ds.displayName=lA.displayName;const uA="Radio",[Fre,dA]=Pn(uA),[jre,zre]=Fre(uA),Bre=m.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:i=!1,required:o,disabled:s,value:a="on",onCheck:l,...c}=e,[d,f]=m.useState(null),g=et(t,y=>f(y)),p=m.useRef(!1),v=d?!!d.closest("form"):!0;return m.createElement(jre,{scope:n,checked:i,disabled:s},m.createElement(Be.button,le({type:"button",role:"radio","aria-checked":i,"data-state":fA(i),"data-disabled":s?"":void 0,disabled:s,value:a},c,{ref:g,onClick:Ce(e.onClick,y=>{i||l==null||l(),v&&(p.current=y.isPropagationStopped(),p.current||y.stopPropagation())})})),v&&m.createElement(Wre,{control:d,bubbles:!p.current,name:r,value:a,checked:i,required:o,disabled:s,style:{transform:"translateX(-100%)"}}))}),Vre="RadioIndicator",Hre=m.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...i}=e,o=zre(Vre,n);return m.createElement(vn,{present:r||o.checked},m.createElement(Be.span,le({"data-state":fA(o.checked),"data-disabled":o.disabled?"":void 0},i,{ref:t})))}),Wre=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Op(n),a=Mh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const g=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(g)}},[s,n,r]),m.createElement("input",le({type:"radio","aria-hidden":!0,defaultChecked:n},i,{tabIndex:-1,ref:o,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function fA(e){return e?"checked":"unchecked"}const qre=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],hA="RadioGroup",[Ure,Cfe]=Pn(hA,[il,dA]),pA=il(),gA=dA(),[Gre,Yre]=Ure(hA),Kre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:i,value:o,required:s=!1,disabled:a=!1,orientation:l,dir:c,loop:d=!0,onValueChange:f,...g}=e,p=pA(n),v=Ls(c),[y,x]=Qn({prop:o,defaultProp:i,onChange:f});return m.createElement(Gre,{scope:n,name:r,required:s,disabled:a,value:y,onValueChange:x},m.createElement(Mm,le({asChild:!0},p,{orientation:l,dir:v,loop:d}),m.createElement(Be.div,le({role:"radiogroup","aria-required":s,"aria-orientation":l,"data-disabled":a?"":void 0,dir:v},g,{ref:t}))))}),Xre="RadioGroupItem",Qre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...i}=e,o=Yre(Xre,n),s=o.disabled||r,a=pA(n),l=gA(n),c=m.useRef(null),d=et(t,c),f=o.value===i.value,g=m.useRef(!1);return m.useEffect(()=>{const p=y=>{qre.includes(y.key)&&(g.current=!0)},v=()=>g.current=!1;return document.addEventListener("keydown",p),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",v)}},[]),m.createElement(Dm,le({asChild:!0},a,{focusable:!s,active:f}),m.createElement(Bre,le({disabled:s,required:o.required,checked:f},l,i,{name:o.name,ref:d,onCheck:()=>o.onValueChange(i.value),onKeyDown:Ce(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:Ce(i.onFocus,()=>{var p;g.current&&((p=c.current)===null||p===void 0||p.click())})})))}),Zre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,i=gA(n);return m.createElement(Hre,le({},i,r,{ref:t}))}),mA=Kre,vA=Qre,Jre=Zre,bA=ue.forwardRef(({className:e,...t},n)=>_.jsx(mA,{className:Pe("grid gap-2",e),...t,ref:n}));bA.displayName=mA.displayName;const kx=ue.forwardRef(({className:e,...t},n)=>_.jsx(vA,{ref:n,className:Pe("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:_.jsx(Jre,{className:"flex items-center justify-center",children:_.jsx(H2,{className:"h-2.5 w-2.5 fill-current text-current"})})}));kx.displayName=vA.displayName;function yA(){var i;const e=_e(o=>o.card.cfg),t=_e(o=>o.actions.setCardCfg),n=(i=e==null?void 0:e.options)==null?void 0:i.indexAxis;function r(o){const s={...e,options:{...e==null?void 0:e.options,indexAxis:o}};t(s)}return _.jsxs("div",{children:[_.jsx("p",{className:"font-semibold",children:"Orientation"}),_.jsxs(bA,{value:n,onValueChange:r,className:"flex gap-3 mt-2 ",defaultValue:"x",children:[_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx(kx,{value:"x",id:"r1"}),_.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx(kx,{value:"y",id:"r2"}),_.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})]})}function xA(){var r,i,o;const e=_e(s=>s.card.cfg),t=_e(s=>s.actions.setCardCfg);function n(s){var c;const a={datalabels:{display:s!=="none",align:s,anchor:s,clamp:!0}},l={...e,options:{...e==null?void 0:e.options,plugins:{...(c=e==null?void 0:e.options)==null?void 0:c.plugins,...a}}};t(l),console.log(s)}return _.jsxs(_.Fragment,{children:[_.jsx("label",{className:"font-medium",children:"Data Labels"}),_.jsxs(oM,{value:(o=(i=(r=e==null?void 0:e.options)==null?void 0:r.plugins)==null?void 0:i.datalabels)==null?void 0:o.anchor,onValueChange:n,defaultValue:"none",children:[_.jsx(Oy,{className:"w-[180px] mt-2 focus:ring-1 focus:ring-offset-0 h-7",children:_.jsx(aM,{placeholder:"Select position"})}),_.jsx(Py,{children:_.jsxs(sM,{children:[_.jsx(Tp,{children:"Data Labels"}),_.jsx(xa,{value:"none",children:"None"}),_.jsx(xa,{value:"start",children:"Start"}),_.jsx(xa,{value:"center",children:"Center"}),_.jsx(xa,{value:"end",children:"End"})]})})]})]})}function wA(){const e=_e(i=>i.card.preferences),t=_e(i=>i.actions.setCardPreferences),n=_e(i=>{var o;return(o=i.card.preferences)==null?void 0:o.filterOnClickField}),r=_e(i=>i.actions.setFilterOnClickField);return _.jsxs("div",{children:[_.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[_.jsx(zy,{checked:!!(e!=null&&e.filterOnClick),onCheckedChange:i=>{t({...e,filterOnClick:!!i})}}),_.jsx(fa,{children:"Filter on click"})]}),(e==null?void 0:e.filterOnClick)===!0&&_.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx(Ku,{value:n||"",className:" h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"expression (optional)",onChange:i=>r(i.target.value)}),_.jsxs(Bb,{children:[_.jsx(L2,{children:_.jsx(e2,{className:"h-4 w-4 opacity-70"})}),_.jsx(Ih,{children:_.jsxs("div",{className:"max-w-[200px]",children:["The x-axis expression of your query. Example:",_.jsx("div",{className:" mt-1 text-xs font-mono",children:"TO_CHAR(order_date, 'YYYY-MM')"})]})})]})]})]})}const eie={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},tie={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function nie(){const e=_e(t=>t.card.type);return _.jsxs("div",{className:"p-6 space-y-6",children:[_.jsx(cA,{className:" ",type:"single",collapsible:!0,children:rie(e)}),_.jsx("section",{className:"",children:["line","bar"].includes(e)&&_.jsx(yA,{})}),_.jsx("div",{children:_.jsx(xA,{})}),_.jsx("div",{children:_.jsx(wA,{})})]})}function rie(e){if(["line","bar"].includes(e))return _.jsxs(_.Fragment,{children:[_.jsxs(cs,{className:"border-muted",value:"item-1",children:[_.jsx(us,{className:" font-normal",children:_.jsx("p",{children:"Chart Query"})}),_.jsxs(ds,{className:" ",children:[_.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"X-axis - Category (ex. city)"}),_.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),_.jsxs(cs,{className:"border-muted",value:"item-2",children:[_.jsx(us,{className:" font-normal",children:"Mixed Chart"}),_.jsxs(ds,{className:" text-xs space-y-2",children:[_.jsxs("p",{children:["Click ",_.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),_.jsx("pre",{children:JSON.stringify(eie,null,2)})]})]}),_.jsxs(cs,{className:"border-muted",value:"item-3",children:[_.jsx(us,{className:" font-normal",children:"Area Chart"}),_.jsxs(ds,{className:" text-xs space-y-2",children:[_.jsxs("p",{children:["Click ",_.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",_.jsx("a",{className:"text-blue-500 hover:underline mx-1",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),_.jsx("pre",{children:JSON.stringify(tie,null,2)})]})]})]});if(e==="bubble")return _.jsx(_.Fragment,{children:_.jsxs(cs,{className:"border-muted",value:"item-1",children:[_.jsx(us,{className:" font-normal",children:_.jsxs("p",{children:["How to create a ",_.jsx("span",{children:e})," chart query?"]})}),_.jsxs(ds,{className:" ",children:[_.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis, radius FROM table"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),_.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),_.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),_.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(e==="scatter")return _.jsx(_.Fragment,{children:_.jsxs(cs,{value:"item-1",children:[_.jsx(us,{className:" font-normal",children:_.jsxs("p",{children:["How to create a ",_.jsx("span",{children:e})," chart query?"]})}),_.jsxs(ds,{className:" ",children:[_.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis FROM table"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Group (opt) - Category (ex. state)"}),_.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),_.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(e))return _.jsx(_.Fragment,{children:_.jsxs(cs,{value:"item-1",children:[_.jsx(us,{className:" font-normal",children:_.jsxs("p",{children:["How to create a"," ",_.jsxs("span",{children:[e==="polarArea"?"polar":e," "]})," ","chart query?"]})}),_.jsxs(ds,{className:" ",children:[_.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, measure FROM table"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function iie(){return _.jsxs("div",{className:"px-6 py-2 space-y-6",children:[_.jsx(cA,{className:" ",type:"single",collapsible:!0,children:_.jsxs(cs,{className:"border-muted",value:"item-1",children:[_.jsx(us,{className:" font-normal",children:"Stacked chart query?"}),_.jsxs(ds,{className:" ",children:[_.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"X-axis - Category (ex. country)"}),_.jsx("li",{children:"Stack by - Category (ex. city)"}),_.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]})}),_.jsx("section",{className:"",children:_.jsx(yA,{})}),_.jsx("div",{children:_.jsx(xA,{})}),_.jsx("div",{children:_.jsx(wA,{})})]})}function oie(){const e=_e(t=>t.card.type);return _.jsx(Pl,{className:" text-sm h-full w-full ",children:e==="stackedBar"?_.jsx(iie,{}):_.jsx(nie,{})})}function sie(){const e=_e(t=>t.isShowingVisual);return _.jsxs($M,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[_.jsx($p,{minSize:40,defaultSize:40,children:_.jsx(Hne,{})}),_.jsx(FM,{className:"border-[1.5px] border-muted"}),_.jsx($p,{minSize:60,defaultSize:60,children:e?_.jsxs($M,{direction:"horizontal",children:[_.jsx(_.Fragment,{children:_.jsx($p,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:_.jsx(oie,{})})}),_.jsx(FM,{className:"border-[1.5px] border-muted"}),_.jsx($p,{minSize:40,defaultSize:70,maxSize:100,children:_.jsx(QT,{})})]}):_.jsx(QT,{})})]})}function aie({authToken:e,onSave:t,onClose:n}){_e(s=>s.actions.setCard);const r=_e(s=>s.actions.setOnSave),i=_e(s=>s.actions.setOnClose),o=be(s=>s.actions.setAuthToken);return m.useEffect(()=>{t&&r(t),n&&i(n)},[t,r,n,i]),m.useEffect(()=>{e&&e.accessToken&&o(e)},[e,o]),_.jsxs(Fk,{className:"border-x border-b rounded-none border-muted ",children:[_.jsx(jk,{className:" rounded-none border-r-[3px] border-muted ",children:_.jsx(dM,{})}),_.jsx(zk,{children:_.jsx(sie,{})})]})}function lie(){be(s=>s.selectedCardId);const e=be(s=>s.selectedSheetId),t=be(s=>s.actions.setIsVisualEditing);be(s=>s.actions.setIsEditorSaveEvent);const n=be(s=>s.isVisualEditing);be(s=>s.actions.getSelectedCard());const r=be(s=>s.actions.updateCard);function i(s){e&&(r(e,s),t(!1))}function o(){t(!1)}return _.jsx("div",{className:`grow flex ${n?"block":"hidden"}`,children:_.jsx(aie,{onSave:i,onClose:o})})}function cie({columns:e,tableName:t}){const n=_e(f=>f.selectedConnectionId),r=_e(f=>f.selectedDatabaseName),i=_e(f=>f.selectedSchemaName),o=_e(f=>f.selectedTableName),s=be(f=>f.dashboard.filters)||[],a=be(f=>f.actions.addFilter),l=be(f=>f.actions.removeFilter),c=be(f=>f.actions.removeFilterValue);function d(f){const g=s==null?void 0:s.find(p=>p.column===f.column_name&&p.table===o&&p.database===r);if(g)c(g.id),l(g.id);else{const p=k0(i||"",t),v=`SELECT ${f.column_name}, COUNT(*) FROM ${p} GROUP BY ${f.column_name} ORDER BY ${f.column_name} ASC LIMIT 50`,y=`SELECT min(${f.column_name}) as min, max(${f.column_name}) as max FROM ${p}`;if(t==="api"&&n){a({id:yh(),column:f.column_name,title:f.column_name,dataType:f.data_type,table:"api",database:"NA",connectionId:n,sql:Iu.includes(f.data_type)?y:v});return}if(!n||!r||!o)throw new Error("missing connectionId, database, or table");a({id:yh(),column:f.column_name,title:f.column_name,dataType:f.data_type,table:o,database:r,connectionId:n,sql:Iu.includes(f.data_type)?y:v})}}return _.jsx(Pl,{className:" h-[70vh] mt-2 xbg-red-100 px-3",children:e==null?void 0:e.map(f=>{const g=s==null?void 0:s.find(p=>p.column===f.column_name&&p.table===o&&p.database===r);return _.jsx("div",{onClick:()=>d(f),className:Pe(" group flex text-sm items-center justify-between px-3 py-[6px] transition-colors hover:bg-muted/50 cursor-pointer border border-background border-dashed",{"bg-muted ":g}),children:_.jsxs("div",{className:"flex items-center gap-2 ",children:[_.jsx(uM,{column:f}),_.jsx("span",{children:f.column_name})]})},f.column_name)})})}function uie(){be(t=>t.showFilters);const e=be(t=>t.actions.setShowFilters);return _.jsxs("section",{className:" relative space-y-4 py-0 px-4 border-muted bg-red-x100",children:[_.jsx(it,{onClick:()=>e(!1),className:" p-0 h-7 w-7 absolute top-0 right-4",variant:"outline",children:_.jsx(na,{})}),_.jsx("p",{className:"text-md px-2",children:"Data Columns"}),_.jsx("div",{children:_.jsx(dM,{ColumnsComponent:(t,n,r)=>_.jsx(cie,{schemaName:t,tableName:n,columns:r})})})]})}function die(){const e=be(r=>r.dashboard),t=be(r=>r.showFilters),n=be(r=>r.isVisualEditing);return m.useEffect(()=>{if(e.id==="")return;const r=$l(e.id),i=JSON.parse(localStorage.getItem(r)||"[]"),o=i.find(s=>s.name==="Original");o?o.template=e:i.push({name:"Original",template:e}),localStorage.setItem(r,JSON.stringify(i))},[e.id]),_.jsxs("div",{role:"dashboard-plus-main",className:` flex grow ${n?"hidden":"block"}`,children:[_.jsx(QP,{}),t&&_.jsx("div",{role:"filter-aside-container",className:"",children:_.jsx(uie,{})})]})}function fie(){const e=be(r=>r.dashboard),t=be(r=>r.actions.setDashboard),n=be(r=>r.showDashboardJSON);return be(r=>r.actions.setShowDashboardJSON),_.jsx("div",{className:Pe(" p-2",{hidden:!n}),children:_.jsx(JM,{onChange:r=>{if(r)try{JSON.parse(r),t(JSON.parse(r))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(e,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function hie({showControls:e=!1,showFooter:t=!0,...n}){return be(r=>r.isVisualEditing),_.jsxs(ZP,{children:[_.jsx(fie,{}),_.jsxs(Kw,{...n,children:[e&&_.jsx(BK,{}),_.jsx(lie,{}),_.jsx(die,{})]})]})}function pie(){const e=be(t=>t.actions);return{setDashboardTitle:e.setDashboardTitle,getStyle:e.getStyle,getDashboard:e.getDashboard,setOnSaveFunction:e.setOnSaveFunction,setOnAddCard:e.setOnAddCard,setOnUpateCard:e.setOnUpdateCard,setOnRemoveCard:e.setOnRemoveCard}}ct.Dashboard=JP,ct.DashboardPlus=hie,ct.DashboardWC=YG,ct.cleanCard=Pk,ct.getBookmarkKey=$l,ct.getDashbaordStateWithoutData=vy,ct.useActions=pie,ct.useDashboardStore=be,Object.defineProperty(ct,Symbol.toStringTag,{value:"Module"})});
505
+ Visual Query Syntax: ${Bne}`,{data:w,isLoading:S,isFetching:C,isError:P,refetch:O}=Sr({queryKey:["ai-query"],queryFn:()=>el("https://semaphor.cloud/api/v1/ai",(s==null?void 0:s.accessToken)||"",{user_content:`userContent: ${y} ${a?x:""}`}),enabled:!1});function k(X){if(X.toLowerCase().includes("bar"))f("bar");else if(X.toLowerCase().includes("line"))f("line");else if(X.toLowerCase().includes("bubble"))f("bubble");else if(X.toLowerCase().includes("scatter"))f("scatter");else if(X.toLowerCase().includes("stacked"))f("stackedBar");else if(X.toLowerCase().includes("pie"))f("pie");else if(X.toLowerCase().includes("donut")||X.toLowerCase().includes("doughnut"))f("doughnut");else if(X.toLowerCase().includes("radar"))f("radar");else return f("bar"),!1;return!0}function A(){n&&(k(n)&&l(!0),O())}m.useEffect(()=>{i&&(A(),o(!1))},[i,o]);const L={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"5px",width:"100%"},F={fontFamily:"monospace",fontSize:14,lineHeight:1.6},z={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},B={p:({node:X,...K})=>_.jsx("p",{style:L,...K}),pre:({node:X,...K})=>_.jsxs("pre",{className:" bg-muted/50 space-y-2 p-3 rounded-sm",style:F,children:[_.jsx("code",{className:" whitespace-normal",children:K.children}),_.jsxs("div",{className:" flex justify-start gap-2",children:[_.jsx(it,{onClick:V,size:"sm",variant:"outline",children:_.jsx(JE,{})}),_.jsx(it,{onClick:$=>{const J=V($);J&&(t(!1),c(J),d(!0))},size:"sm",variant:"outline",children:_.jsx(Zj,{})})]})]}),li:({node:X,...K})=>_.jsx("li",{style:z,...K})};function V(X){const K=X.currentTarget.closest("pre");if(!K)return;const $=K.textContent||K.innerText;return navigator.clipboard.writeText($).then(()=>console.log("Text copied to clipboard")).catch(J=>console.error("Error in copying text: ",J)),$}return _.jsxs(xy,{open:e,onOpenChange:t,children:[_.jsx(wy,{asChild:!0,children:_.jsx(it,{size:"sm",className:"",variant:"outline",children:_.jsx(nV,{strokeWidth:1,size:16})})}),_.jsxs(_p,{className:" border-muted sm:max-w-[425px] md:min-w-[625px] md:max-h-[625px] flex flex-col justify-between overflow-auto",children:[_.jsxs(Sp,{children:[_.jsx(Cp,{children:"Ask"}),_.jsx(Ep,{children:"Need assistance with SQL queries? Feel free to ask me any question!"})]}),_.jsx(Pl,{className:"h-[625px] w-full border-t border-t-muted ",children:(!S||!C)&&_.jsx(jne,{className:" pl-1 pr-3 py-1 w-full xbg-red-100 overflow-auto ",components:B,children:w==null?void 0:w.response})}),_.jsxs("div",{children:[_.jsx(lf,{className:Pe(" invisible h-1 w-full animate-pulse",{visible:S||C})}),_.jsxs("div",{className:" border rounded-md flex items-center w-full",children:[_.jsx(By,{onKeyDown:X=>{X.key==="Enter"&&!X.shiftKey&&(X.preventDefault(),r(""),A())},placeholder:"Type something...",onFocus:X=>{const K=X.target,$=K.value.length;K.setSelectionRange($,$)},className:" border-none resize-none min-h-7 max-h-10 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",value:n,onChange:X=>r(X.target.value)})," ",_.jsx(it,{className:"h-8",size:"sm",variant:"ghost",onClick:A,children:!S&&!C?_.jsx(Xj,{}):_.jsx(ku,{className:" w-4 h-4 animate-spin mr-2 text-foreground/50"})})]})]})]})]})}function Hne(){const{theme:e}=Cm(),t=m.useRef(),n=m.useRef(),[r,i]=m.useState(!1),[o,s]=m.useState(!1),[a,l]=m.useState(""),[c,d]=m.useState(!1);m.useState("");const f=be(H=>H.authToken),g=_e(H=>H.card),p=be(H=>H.theme),v=_e(H=>H.selectedConnectionId),y=_e(H=>H.selectedDatabaseName),x=_e(H=>H.selectedSchemaName),w=_e(H=>H.selectedTableName),S=_e(H=>H.actions.setCardSql),C=_e(H=>H.card.sql),P=_e(H=>H.selectedConnectionId),O=_e(H=>H.filterValues),k=_e(H=>H.applyFilters),A=_e(H=>H.actions.setCardCustomCfg),L=_e(H=>H.actions.setFilterValues),F=_e(H=>H.onSave),z=_e(H=>H.actions.setApplyFilters),B=_e(H=>H.onClose),V=_e(H=>H.actions.setCardData),X=_e(H=>H.actions.setSqlGen),K=_e(H=>H.runSql),$=_e(H=>H.actions.setRunSql),J=_e(H=>H.actions.setIsSqlRunning),{data:G,isLoading:q,isFetching:se,isSuccess:D,isError:W,error:re,status:N,refetch:ne}=Sr({queryKey:[C],queryFn:()=>Ts("https://semaphor.cloud/api/v1/query",(f==null?void 0:f.accessToken)||"",{connection_id:P,sql:C,active_filters:k?O:[]}),enabled:!1,retry:!1});m.useEffect(()=>{G&&(console.log("queryData",G),V(G.records))},[G,V]),m.useEffect(()=>{K&&(ne(),$(!1))},[K,ne,$]),m.useEffect(()=>{(q||se)&&J(!0),(W||D)&&J(!1)},[q,se,W,D,J]);function ge(){S(""),V([]),X({}),A("")}const he=H=>{n.current=H};function de(){if(C&&!C.includes("{{")){const H=eZ(C);S(H),F==null||F({...g,sql:H,lastSelectedSchema:x,lastSelectedDatabase:y,lastSelectedTable:w,connectionId:v})}else F==null||F(g)}function ie(){B==null||B()}m.useEffect(()=>{const H=t.current,ye=n.current;if(H){const oe=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",Te=p==="system"?oe:p;H.editor.defineTheme("default",{base:Te==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":Te==="light"?"#ffffff":"#020817"}}),H.editor.setTheme("default")}return ye&&H&&ye.addCommand(H.KeyMod.Shift|H.KeyCode.Enter,function(){return console.log("Executing query..."),ne(),!1}),()=>{}},[e,p,t.current]);function ee(H){t.current=H}return _.jsxs("section",{role:"editor-section",className:"grow flex flex-col justify-end pt-3 p-1 ",children:[_.jsxs("div",{className:" grow flex relative overflow-y-scroll justify-between ",children:[_.jsx("div",{role:"editor-container",className:`flex ${r?"w-2/3":"w-[95%]"} xbg-red-100 p-1`,children:_.jsx(Ny,{theme:"default",onChange:H=>{S(H),console.log(H)},value:C,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:ee,onMount:he})}),r&&_.jsx("div",{className:" w-1/3 text-xs relative overflow-hidden xbg-yellow-100 p-1 ",children:_.jsxs("div",{className:"min-h-0 ",children:[_.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx(wZ,{checked:k,onCheckedChange:()=>z(!k),text:"Apply Filters"}),_.jsx(_Z,{})]}),_.jsx(Ny,{theme:"default",onChange:H=>{if(H)try{JSON.parse(H),L(JSON.parse(H))}catch{}},defaultLanguage:"json",className:"min-h-[220px] mt-1",value:JSON.stringify(O,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),O&&r&&_.jsx(na,{onClick:()=>i(!1),className:"absolute right-6 top-1 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer"}),O&&!r&&_.jsx(W2,{onClick:()=>i(!0),className:Pe("absolute right-6 top-1 w-3 h-3 text-foreground/50 hover:text-foreground hover:cursor-pointer",{"text-red-800 font-bold":k})})]}),_.jsxs("div",{className:" flex grow px-6 pt-3 pb-4 gap-2 justify-between item-center",children:[_.jsxs("div",{className:"flex grow gap-2 items-center",children:[_.jsxs(it,{disabled:q||se,onClick:()=>{ne()},className:" shrink-0",size:"sm",variant:"outline",children:[(q||se)&&_.jsx(ku,{className:"w-4 h-4 mr-2 animate-spin text-foreground/50"}),"Run"]}),W&&_.jsx(fZ,{error:re.message}),_.jsx(it,{onClick:ge,className:"",size:"sm",variant:"outline",children:"Clear"}),_.jsx(Ku,{value:a,placeholder:"Type something...",onChange:H=>{l(H.target.value)},onKeyDown:H=>{H.key==="Enter"&&(H.preventDefault(),console.log("enter pressed"),d(!0),s(!0))},className:" bg-muted border-none h-9 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"}),_.jsx(Vne,{open:o,setOpen:s,userInput:a,triggerAIRun:c,setTriggerAIRun:d,setUserInput:H=>l(H)})]}),_.jsxs("div",{className:"flex gap-2 items-end ",children:[_.jsx(it,{onClick:de,size:"sm",variant:"outline",children:_.jsx(Rh,{size:16,strokeWidth:2,className:"text-green-600 font-bold"})}),_.jsx(it,{onClick:ie,className:" w-full",size:"sm",variant:"outline",children:_.jsx(na,{className:" h-3.5 w-3.5"})})]})]})]})}const $T="Switch",[Wne,_fe]=Pn($T),[qne,Une]=Wne($T),Gne=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:o,required:s,disabled:a,value:l="on",onCheckedChange:c,...d}=e,[f,g]=m.useState(null),p=et(t,S=>g(S)),v=m.useRef(!1),y=f?!!f.closest("form"):!0,[x=!1,w]=Qn({prop:i,defaultProp:o,onChange:c});return m.createElement(qne,{scope:n,checked:x,disabled:a},m.createElement(Be.button,le({type:"button",role:"switch","aria-checked":x,"aria-required":s,"data-state":FT(x),"data-disabled":a?"":void 0,disabled:a,value:l},d,{ref:p,onClick:Ce(e.onClick,S=>{w(C=>!C),y&&(v.current=S.isPropagationStopped(),v.current||S.stopPropagation())})})),y&&m.createElement(Xne,{control:f,bubbles:!v.current,name:r,value:l,checked:x,required:s,disabled:a,style:{transform:"translateX(-100%)"}}))}),Yne="SwitchThumb",Kne=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=Une(Yne,n);return m.createElement(Be.span,le({"data-state":FT(i.checked),"data-disabled":i.disabled?"":void 0},r,{ref:t}))}),Xne=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Op(n),a=Mh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const g=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(g)}},[s,n,r]),m.createElement("input",le({type:"checkbox","aria-hidden":!0,defaultChecked:n},i,{tabIndex:-1,ref:o,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function FT(e){return e?"checked":"unchecked"}const jT=Gne,Qne=Kne,zT=ue.forwardRef(({className:e,...t},n)=>_.jsx(jT,{className:Pe("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:_.jsx(Qne,{className:Pe("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));zT.displayName=jT.displayName;function BT({className:e,...t}){const[n,r]=m.useState(0),i=be(l=>l.themeStyle),o=_e(l=>l.card),s=_e(l=>l.actions.setCard);if(m.useEffect(()=>{r(n+1)},[o.data,o.type,o.cfg,o.customCfg,i]),!o.id)return null;let a;return o.data&&o.data.length>0&&(a=Pb({data:o.data,cardType:o.type,cfg:o.cfg,customCfg:o.customCfg})),_.jsxs(kv,{role:"editor-visual-card",className:Pe(" relative h-full flex flex-col rounded-none",e),...t,children:[_.jsxs(Mv,{children:[_.jsx(qc,{text:o.title,onSave:l=>s({...o,title:l}),children:_.jsx(Dv,{className:"text-base",children:o.title})}),_.jsx(qc,{text:o.description||"",onSave:l=>s({...o,description:l}),children:_.jsxs(Tv,{children:[" ",o.description]})})]}),_.jsxs(Av,{className:"flex flex-col pb-3 grow",children:[o.type!=="table"&&a&&_.jsx(QE,{cfg:a},n),o.type==="table"&&o.data&&o.data.length>0&&_.jsx(cO,{children:_.jsx(s0,{data:o==null?void 0:o.data})})]})]})}function Zne(){const[e,t]=m.useState(!1),[n,r]=m.useState(""),[i,o]=m.useState(""),[s,a]=m.useState(""),l=_e(x=>x.card),c=_e(x=>x.card.customCfg),d=_e(x=>x.actions.setCardCustomCfg);function f(x){var C,P;const w={...x,data:{...x==null?void 0:x.data,datasets:(P=(C=x==null?void 0:x.data)==null?void 0:C.datasets)==null?void 0:P.map(O=>({...O,data:[]}))}};return JSON.stringify(w,null,1)}function g(){if(!l.data||l.data.length===0)return;const x=Pb({data:l.data,cardType:l.type,cfg:l.cfg});x&&(r(JSON.stringify(x,null,1)),c&&o(JSON.stringify(c,null,1)))}function p(){if(i)try{const x=JSON.parse(i);return x?(d(x),a(""),o(""),x):void 0}catch(x){console.log(x),a("Invalid JSON")}}function v(){o(""),d(null)}function y(){let x;if(c){const w=Rs.cloneDeep(l.cfg),S=Rs.merge(w,c);return x=f(S),x}return n?(x=f(JSON.parse(n)),x):""}return _.jsxs(xy,{open:e,onOpenChange:t,children:[_.jsx(wy,{asChild:!0,children:_.jsx(it,{onClick:g,className:`h-7 ${c&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:c?"Custom Config":"Customize"})}),_.jsx(_p,{className:" sm:max-w-[425px] md:min-w-[600px] md:min-h-[700px] lg:min-w-[800px] xl:min-w-[1000px]",children:_.jsxs("div",{className:"bg-red-x100 flex flex-col gap-2 justify-between",children:[_.jsxs(Sp,{className:"",children:[_.jsx(Cp,{children:"Customize Chart"}),_.jsxs(Ep,{children:["See the configuration options and documentation",_.jsx("a",{target:"_blank",className:"ml-1 underline text-blue-500 ",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),_.jsxs("div",{className:"grow flex flex-wrap gap-2",children:[_.jsx(BT,{className:"flex-1 rounded shadow-none"}),_.jsxs(a_,{defaultValue:"custom-config",className:" flex flex-col flex-1",children:[_.jsxs(l_,{className:" justify-start border rounded-sm rounded-b-none border-b-0 ",children:[_.jsxs(Am,{value:"custom-config",children:[c&&_.jsx(ZE,{className:"w-5 h-5 mr-1 text-green-600"}),c?"Custom Config":"Default Config"]}),_.jsx(Am,{className:"",value:"output",children:"Output"})]}),_.jsx(ff,{className:" grow mt-0 bg-red-x p-2 border border-t-0 rounded-b ",value:"output",children:_.jsx(By,{disabled:!0,value:n,className:" border-none resize-none font-mono h-full focus-visible:ring-0 focus-visible:ring-offset-0"})}),_.jsx(ff,{className:"grow mt-0 border border-t-0 rounded-b ",value:"custom-config",children:_.jsx(Ny,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"json",value:y(),onChange:x=>o(x)})})]})]}),_.jsxs(_y,{className:"flex items-center",children:[_.jsx(fa,{className:"text-red-500 mr-2",children:s}),_.jsx(it,{disabled:!c,onClick:v,variant:"outline",children:"Reset"}),_.jsx(it,{onClick:p,variant:"outline",children:"Apply"}),_.jsx(it,{onClick:()=>t(!1),variant:"outline",children:"Close"})]})]})})]})}var VT={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},HT=m.createContext&&m.createContext(VT),Jne=["attr","size","title"];function ere(e,t){if(e==null)return{};var n=tre(e,t),r,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function tre(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o<r.length;o++)i=r[o],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function eg(){return eg=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},eg.apply(this,arguments)}function WT(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function tg(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?WT(Object(n),!0).forEach(function(r){nre(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):WT(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function nre(e,t,n){return t=rre(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function rre(e){var t=ire(e,"string");return typeof t=="symbol"?t:String(t)}function ire(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function qT(e){return e&&e.map((t,n)=>m.createElement(t.tag,tg({key:n},t.attr),qT(t.child)))}function dd(e){return t=>m.createElement(ore,eg({attr:tg({},e.attr)},t),qT(e.child))}function ore(e){var t=n=>{var{attr:r,size:i,title:o}=e,s=ere(e,Jne),a=i||n.size||"1em",l;return n.className&&(l=n.className),e.className&&(l=(l?l+" ":"")+e.className),m.createElement("svg",eg({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,s,{className:l,style:tg(tg({color:e.color||n.color},n.style),e.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),o&&m.createElement("title",null,o),e.children)};return HT!==void 0?m.createElement(HT.Consumer,null,n=>t(n)):t(VT)}function UT(e){return dd({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M926.8 397.1l-396-288a31.81 31.81 0 0 0-37.6 0l-396 288a31.99 31.99 0 0 0-11.6 35.8l151.3 466a32 32 0 0 0 30.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z"},child:[]}]})(e)}function GT(e){return dd({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm87.63,96H191.48A64.1,64.1,0,0,0,136,64.52V40.37A88.13,88.13,0,0,1,215.63,120ZM120,120H80.68A48.09,48.09,0,0,1,120,80.68Zm0,16v39.32A48.09,48.09,0,0,1,80.68,136Zm16,0h39.32A48.09,48.09,0,0,1,136,175.32Zm0-16V80.68A48.09,48.09,0,0,1,175.32,120ZM120,40.37V64.52A64.1,64.1,0,0,0,64.52,120H40.37A88.13,88.13,0,0,1,120,40.37ZM40.37,136H64.52A64.1,64.1,0,0,0,120,191.48v24.15A88.13,88.13,0,0,1,40.37,136ZM136,215.63V191.48A64.1,64.1,0,0,0,191.48,136h24.15A88.13,88.13,0,0,1,136,215.63Z"},child:[]}]})(e)}function YT(e){return dd({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M137,28.05a11.94,11.94,0,0,0-9.12,3.08A12.09,12.09,0,0,0,124,40V80.67a11.88,11.88,0,0,0,9.9,11.81,36,36,0,1,1-41.85,37.4c-.47-9.14,1.47-16.8,5.75-22.79h0a11.89,11.89,0,0,0-1.3-15.35L68.87,63.51a12,12,0,0,0-17.74.83A99.6,99.6,0,0,0,57.79,199.2,99.24,99.24,0,0,0,128,228h1.43A100.29,100.29,0,0,0,228,129.42C228.72,77.21,188.76,32.68,137,28.05ZM57.28,69.46A4,4,0,0,1,60.2,68h.19a3.91,3.91,0,0,1,2.79,1.14L90.81,97.36a3.93,3.93,0,0,1,.48,5.08A40.47,40.47,0,0,0,84.08,124h-48A90.36,90.36,0,0,1,57.28,69.46ZM36.09,132H84.18A44,44,0,0,0,124,171.81V219.9A92,92,0,0,1,36.09,132ZM193,193a91.43,91.43,0,0,1-61,26.92V171.82a43.51,43.51,0,0,0,26-11.63,44,44,0,0,0-22.79-75.6A4,4,0,0,1,132,80.67V40a4,4,0,0,1,1.31-3,3.89,3.89,0,0,1,3-1c47.59,4.26,84.34,45.24,83.67,93.29A91.42,91.42,0,0,1,193,193Z"},child:[]}]})(e)}function KT(e){return dd({tag:"svg",attr:{viewBox:"0 0 24 24",strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},child:[]},{tag:"path",attr:{d:"M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"},child:[]},{tag:"path",attr:{d:"M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},child:[]},{tag:"path",attr:{d:"M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0"},child:[]}]})(e)}function XT(e){return dd({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M4 9h4v11H4zM4 4h4v4H4zM10 7h4v4h-4zM16 10h4v4h-4zM16 15h4v5h-4zM10 12h4v8h-4z"},child:[]}]})(e)}function sre(){const[e,t]=m.useState(!1),n=_e(s=>s.card.type),r=_e(s=>s.actions.setCardType),i=_e(s=>s.actions.setCardCustomCfg);function o(s){r(s),i(null),t(!1)}return _.jsxs(pp,{open:e,onOpenChange:t,children:[_.jsx(gp,{asChild:!0,children:_.jsx(it,{className:"h-7 px-2",variant:"outline",children:_.jsx(are,{className:"h-4 w-4",chartType:n})})}),_.jsx(Wu,{className:"w-50",children:_.jsxs("div",{className:"grid grid-cols-3 place-items-center ",children:[_.jsx(it,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:_.jsx(B2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("line"),variant:"ghost",children:_.jsx(q2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("stackedBar"),variant:"ghost",children:_.jsx(XT,{className:"h-6 w-6 text-foreground/50 ",strokeWidth:0})}),_.jsx(it,{onClick:()=>o("scatter"),variant:"ghost",children:_.jsx(G2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("bubble"),variant:"ghost",children:_.jsx(KT,{strokeWidth:2})}),_.jsx(it,{onClick:()=>o("pie"),variant:"ghost",children:_.jsx(U2,{strokeWidth:1})}),_.jsx(it,{onClick:()=>o("doughnut"),variant:"ghost",children:_.jsx(YT,{className:"h-7 w-7",strokeWidth:.5})}),_.jsx(it,{onClick:()=>o("radar"),variant:"ghost",children:_.jsx(UT,{className:"h-6 w-6 text-foreground/50 font-extralight",strokeWidth:.5})}),_.jsx(it,{onClick:()=>o("polarArea"),variant:"ghost",children:_.jsx(GT,{className:"h-6 w-6 text-foreground/50",strokeWidth:1})}),_.jsx(it,{onClick:()=>o("table"),variant:"ghost",children:_.jsx(Wb,{className:"h-6 w-6 text-foreground/90",strokeWidth:1})})]})})]})}function are({chartType:e,className:t}){switch(e){case"bar":return _.jsx(B2,{className:t});case"line":return _.jsx(q2,{className:t});case"pie":return _.jsx(U2,{className:t});case"radar":return _.jsx(UT,{className:t});case"scatter":return _.jsx(G2,{className:t});case"bubble":return _.jsx(KT,{className:t});case"doughnut":return _.jsx(YT,{className:t});case"stackedBar":return _.jsx(XT,{className:"h-5 w-5 text-foreground/50 ",strokeWidth:0});case"polarArea":return _.jsx(GT,{className:t});default:return _.jsx(Wb,{className:t})}}function lre(){const e=_e(n=>n.card.refreshInterval),t=_e(n=>n.actions.setCardRefreshInterval);return _.jsxs(pp,{children:[_.jsx(gp,{asChild:!0,children:_.jsx(it,{className:"h-7",variant:"outline",children:"Realtime"})}),_.jsx(Wu,{className:"w-[200px]",children:_.jsx("div",{className:"grid gap-4",children:_.jsx("div",{className:"grid gap-2",children:_.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[_.jsx(fa,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),_.jsx(Ku,{value:e||"",onChange:n=>t(n.target.value),id:"width",placeholder:"30s",className:"col-span-2 h-7 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0"})]})})})})]})}function QT(){const e=_e(r=>r.card),t=_e(r=>r.isShowingVisual),n=_e(r=>r.isSqlRunning);return _e(r=>r.onSave),_e(r=>r.onClose),_e(r=>r.actions.setCardSql),_e(r=>r.actions.setCardType),_e(r=>r.actions.setSqlGen),_.jsxs("div",{className:" h-full relative flex flex-col",children:[n&&_.jsx(ku,{className:" w-10 h-10 z-10 absolute m-auto left-0 right-0 top-0 bottom-0 animate-spin text-foreground/10 "}),_.jsxs("div",{className:" h-10 px-6 pt-6 bg-red-x100 mb-0 z-10 right-0 flex justify-end items-center gap-2",children:[t&&_.jsxs("div",{className:"bg-red-x00 flex grow gap-2",children:[_.jsx(sre,{}),_.jsx(Zne,{}),_.jsx(lre,{})]}),_.jsx(cre,{})]}),t?_.jsx(BT,{className:"grow border-none shadow-none "}):_.jsx("div",{className:"w-full mt-4 px-6 bg-red-x00 grow border-none shadow-none overflow-y-auto ",children:e.data&&e.data.length>0&&_.jsx(s0,{data:e.data})})]})}function cre(){const e=_e(n=>n.isShowingVisual),t=_e(n=>n.actions.setIsShowingVisual);return _.jsxs("div",{className:" flex items-center space-x-2",children:[_.jsx(fa,{htmlFor:"visualize",children:"Chart"}),_.jsx(zT,{checked:e,onCheckedChange:()=>t(!e),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}const ZT="Collapsible",[ure,JT]=Pn(ZT),[dre,_x]=ure(ZT),fre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:o,onOpenChange:s,...a}=e,[l=!1,c]=Qn({prop:r,defaultProp:i,onChange:s});return m.createElement(dre,{scope:n,disabled:o,contentId:or(),open:l,onOpenToggle:m.useCallback(()=>c(d=>!d),[c])},m.createElement(Be.div,le({"data-state":Sx(l),"data-disabled":o?"":void 0},a,{ref:t})))}),hre="CollapsibleTrigger",pre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=_x(hre,n);return m.createElement(Be.button,le({type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":Sx(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled},r,{ref:t,onClick:Ce(e.onClick,i.onOpenToggle)}))}),eA="CollapsibleContent",gre=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=_x(eA,e.__scopeCollapsible);return m.createElement(vn,{present:n||i.open},({present:o})=>m.createElement(mre,le({},r,{ref:t,present:o})))}),mre=m.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...o}=e,s=_x(eA,n),[a,l]=m.useState(r),c=m.useRef(null),d=et(t,c),f=m.useRef(0),g=f.current,p=m.useRef(0),v=p.current,y=s.open||a,x=m.useRef(y),w=m.useRef();return m.useEffect(()=>{const S=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(S)},[]),Vn(()=>{const S=c.current;if(S){w.current=w.current||{transitionDuration:S.style.transitionDuration,animationName:S.style.animationName},S.style.transitionDuration="0s",S.style.animationName="none";const C=S.getBoundingClientRect();f.current=C.height,p.current=C.width,x.current||(S.style.transitionDuration=w.current.transitionDuration,S.style.animationName=w.current.animationName),l(r)}},[s.open,r]),m.createElement(Be.div,le({"data-state":Sx(s.open),"data-disabled":s.disabled?"":void 0,id:s.contentId,hidden:!y},o,{ref:d,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style}}),y&&i)});function Sx(e){return e?"open":"closed"}const vre=fre,bre=pre,yre=gre,ls="Accordion",xre=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Cx,wre,_re]=uf(ls),[ng,Sfe]=Pn(ls,[_re,JT]),Ex=JT(),tA=m.forwardRef((e,t)=>{const{type:n,...r}=e,i=r,o=r;return m.createElement(Cx.Provider,{scope:e.__scopeAccordion},n==="multiple"?m.createElement(Ore,le({},o,{ref:t})):m.createElement(Ere,le({},i,{ref:t})))});tA.propTypes={type(e){const t=e.value||e.defaultValue;return e.type&&!["single","multiple"].includes(e.type)?new Error("Invalid prop `type` supplied to `Accordion`. Expected one of `single | multiple`."):e.type==="multiple"&&typeof t=="string"?new Error("Invalid prop `type` supplied to `Accordion`. Expected `single` when `defaultValue` or `value` is type `string`."):e.type==="single"&&Array.isArray(t)?new Error("Invalid prop `type` supplied to `Accordion`. Expected `multiple` when `defaultValue` or `value` is type `string[]`."):null}};const[nA,Sre]=ng(ls),[rA,Cre]=ng(ls,{collapsible:!1}),Ere=m.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:i=()=>{},collapsible:o=!1,...s}=e,[a,l]=Qn({prop:n,defaultProp:r,onChange:i});return m.createElement(nA,{scope:e.__scopeAccordion,value:a?[a]:[],onItemOpen:l,onItemClose:m.useCallback(()=>o&&l(""),[o,l])},m.createElement(rA,{scope:e.__scopeAccordion,collapsible:o},m.createElement(iA,le({},s,{ref:t}))))}),Ore=m.forwardRef((e,t)=>{const{value:n,defaultValue:r,onValueChange:i=()=>{},...o}=e,[s=[],a]=Qn({prop:n,defaultProp:r,onChange:i}),l=m.useCallback(d=>a((f=[])=>[...f,d]),[a]),c=m.useCallback(d=>a((f=[])=>f.filter(g=>g!==d)),[a]);return m.createElement(nA,{scope:e.__scopeAccordion,value:s,onItemOpen:l,onItemClose:c},m.createElement(rA,{scope:e.__scopeAccordion,collapsible:!0},m.createElement(iA,le({},o,{ref:t}))))}),[Pre,rg]=ng(ls),iA=m.forwardRef((e,t)=>{const{__scopeAccordion:n,disabled:r,dir:i,orientation:o="vertical",...s}=e,a=m.useRef(null),l=et(a,t),c=wre(n),f=Ls(i)==="ltr",g=Ce(e.onKeyDown,p=>{var v;if(!xre.includes(p.key))return;const y=p.target,x=c().filter(F=>{var z;return!((z=F.ref.current)!==null&&z!==void 0&&z.disabled)}),w=x.findIndex(F=>F.ref.current===y),S=x.length;if(w===-1)return;p.preventDefault();let C=w;const P=0,O=S-1,k=()=>{C=w+1,C>O&&(C=P)},A=()=>{C=w-1,C<P&&(C=O)};switch(p.key){case"Home":C=P;break;case"End":C=O;break;case"ArrowRight":o==="horizontal"&&(f?k():A());break;case"ArrowDown":o==="vertical"&&k();break;case"ArrowLeft":o==="horizontal"&&(f?A():k());break;case"ArrowUp":o==="vertical"&&A();break}const L=C%S;(v=x[L].ref.current)===null||v===void 0||v.focus()});return m.createElement(Pre,{scope:n,disabled:r,direction:i,orientation:o},m.createElement(Cx.Slot,{scope:n},m.createElement(Be.div,le({},s,{"data-orientation":o,ref:l,onKeyDown:r?void 0:g}))))}),Ox="AccordionItem",[kre,Px]=ng(Ox),Mre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,value:r,...i}=e,o=rg(Ox,n),s=Sre(Ox,n),a=Ex(n),l=or(),c=r&&s.value.includes(r)||!1,d=o.disabled||e.disabled;return m.createElement(kre,{scope:n,open:c,disabled:d,triggerId:l},m.createElement(vre,le({"data-orientation":o.orientation,"data-state":sA(c)},a,i,{ref:t,disabled:d,open:c,onOpenChange:f=>{f?s.onItemOpen(r):s.onItemClose(r)}})))}),Dre="AccordionHeader",Tre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=rg(ls,n),o=Px(Dre,n);return m.createElement(Be.h3,le({"data-orientation":i.orientation,"data-state":sA(o.open),"data-disabled":o.disabled?"":void 0},r,{ref:t}))}),oA="AccordionTrigger",Are=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=rg(ls,n),o=Px(oA,n),s=Cre(oA,n),a=Ex(n);return m.createElement(Cx.ItemSlot,{scope:n},m.createElement(bre,le({"aria-disabled":o.open&&!s.collapsible||void 0,"data-orientation":i.orientation,id:o.triggerId},a,r,{ref:t})))}),Ire="AccordionContent",Nre=m.forwardRef((e,t)=>{const{__scopeAccordion:n,...r}=e,i=rg(ls,n),o=Px(Ire,n),s=Ex(n);return m.createElement(yre,le({role:"region","aria-labelledby":o.triggerId,"data-orientation":i.orientation},s,r,{ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}}))});function sA(e){return e?"open":"closed"}const Rre=tA,Lre=Mre,$re=Tre,aA=Are,lA=Nre,cA=Rre,cs=ue.forwardRef(({className:e,...t},n)=>_.jsx(Lre,{ref:n,className:Pe("border-b",e),...t}));cs.displayName="AccordionItem";const us=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsx($re,{className:"flex",children:_.jsxs(aA,{ref:r,className:Pe("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",e),...n,children:[t,_.jsx(Hb,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));us.displayName=aA.displayName;const ds=ue.forwardRef(({className:e,children:t,...n},r)=>_.jsx(lA,{ref:r,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:_.jsx("div",{className:Pe("pb-4 pt-0",e),children:t})}));ds.displayName=lA.displayName;const uA="Radio",[Fre,dA]=Pn(uA),[jre,zre]=Fre(uA),Bre=m.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:i=!1,required:o,disabled:s,value:a="on",onCheck:l,...c}=e,[d,f]=m.useState(null),g=et(t,y=>f(y)),p=m.useRef(!1),v=d?!!d.closest("form"):!0;return m.createElement(jre,{scope:n,checked:i,disabled:s},m.createElement(Be.button,le({type:"button",role:"radio","aria-checked":i,"data-state":fA(i),"data-disabled":s?"":void 0,disabled:s,value:a},c,{ref:g,onClick:Ce(e.onClick,y=>{i||l==null||l(),v&&(p.current=y.isPropagationStopped(),p.current||y.stopPropagation())})})),v&&m.createElement(Wre,{control:d,bubbles:!p.current,name:r,value:a,checked:i,required:o,disabled:s,style:{transform:"translateX(-100%)"}}))}),Vre="RadioIndicator",Hre=m.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...i}=e,o=zre(Vre,n);return m.createElement(vn,{present:r||o.checked},m.createElement(Be.span,le({"data-state":fA(o.checked),"data-disabled":o.disabled?"":void 0},i,{ref:t})))}),Wre=e=>{const{control:t,checked:n,bubbles:r=!0,...i}=e,o=m.useRef(null),s=Op(n),a=Mh(t);return m.useEffect(()=>{const l=o.current,c=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(c,"checked").set;if(s!==n&&f){const g=new Event("click",{bubbles:r});f.call(l,n),l.dispatchEvent(g)}},[s,n,r]),m.createElement("input",le({type:"radio","aria-hidden":!0,defaultChecked:n},i,{tabIndex:-1,ref:o,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function fA(e){return e?"checked":"unchecked"}const qre=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],hA="RadioGroup",[Ure,Cfe]=Pn(hA,[il,dA]),pA=il(),gA=dA(),[Gre,Yre]=Ure(hA),Kre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:i,value:o,required:s=!1,disabled:a=!1,orientation:l,dir:c,loop:d=!0,onValueChange:f,...g}=e,p=pA(n),v=Ls(c),[y,x]=Qn({prop:o,defaultProp:i,onChange:f});return m.createElement(Gre,{scope:n,name:r,required:s,disabled:a,value:y,onValueChange:x},m.createElement(Mm,le({asChild:!0},p,{orientation:l,dir:v,loop:d}),m.createElement(Be.div,le({role:"radiogroup","aria-required":s,"aria-orientation":l,"data-disabled":a?"":void 0,dir:v},g,{ref:t}))))}),Xre="RadioGroupItem",Qre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...i}=e,o=Yre(Xre,n),s=o.disabled||r,a=pA(n),l=gA(n),c=m.useRef(null),d=et(t,c),f=o.value===i.value,g=m.useRef(!1);return m.useEffect(()=>{const p=y=>{qre.includes(y.key)&&(g.current=!0)},v=()=>g.current=!1;return document.addEventListener("keydown",p),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",v)}},[]),m.createElement(Dm,le({asChild:!0},a,{focusable:!s,active:f}),m.createElement(Bre,le({disabled:s,required:o.required,checked:f},l,i,{name:o.name,ref:d,onCheck:()=>o.onValueChange(i.value),onKeyDown:Ce(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:Ce(i.onFocus,()=>{var p;g.current&&((p=c.current)===null||p===void 0||p.click())})})))}),Zre=m.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,i=gA(n);return m.createElement(Hre,le({},i,r,{ref:t}))}),mA=Kre,vA=Qre,Jre=Zre,bA=ue.forwardRef(({className:e,...t},n)=>_.jsx(mA,{className:Pe("grid gap-2",e),...t,ref:n}));bA.displayName=mA.displayName;const kx=ue.forwardRef(({className:e,...t},n)=>_.jsx(vA,{ref:n,className:Pe("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:_.jsx(Jre,{className:"flex items-center justify-center",children:_.jsx(H2,{className:"h-2.5 w-2.5 fill-current text-current"})})}));kx.displayName=vA.displayName;function yA(){var i;const e=_e(o=>o.card.cfg),t=_e(o=>o.actions.setCardCfg),n=(i=e==null?void 0:e.options)==null?void 0:i.indexAxis;function r(o){const s={...e,options:{...e==null?void 0:e.options,indexAxis:o}};t(s)}return _.jsxs("div",{children:[_.jsx("p",{className:"font-semibold",children:"Orientation"}),_.jsxs(bA,{value:n,onValueChange:r,className:"flex gap-3 mt-2 ",defaultValue:"x",children:[_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx(kx,{value:"x",id:"r1"}),_.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx(kx,{value:"y",id:"r2"}),_.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})]})}function xA(){var r,i,o;const e=_e(s=>s.card.cfg),t=_e(s=>s.actions.setCardCfg);function n(s){var c;const a={datalabels:{display:s!=="none",align:s,anchor:s,clamp:!0}},l={...e,options:{...e==null?void 0:e.options,plugins:{...(c=e==null?void 0:e.options)==null?void 0:c.plugins,...a}}};t(l),console.log(s)}return _.jsxs(_.Fragment,{children:[_.jsx("label",{className:"font-medium",children:"Data Labels"}),_.jsxs(oM,{value:(o=(i=(r=e==null?void 0:e.options)==null?void 0:r.plugins)==null?void 0:i.datalabels)==null?void 0:o.anchor,onValueChange:n,defaultValue:"none",children:[_.jsx(Oy,{className:"w-[180px] mt-2 focus:ring-1 focus:ring-offset-0 h-7",children:_.jsx(aM,{placeholder:"Select position"})}),_.jsx(Py,{children:_.jsxs(sM,{children:[_.jsx(Tp,{children:"Data Labels"}),_.jsx(xa,{value:"none",children:"None"}),_.jsx(xa,{value:"start",children:"Start"}),_.jsx(xa,{value:"center",children:"Center"}),_.jsx(xa,{value:"end",children:"End"})]})})]})]})}function wA(){const e=_e(i=>i.card.preferences),t=_e(i=>i.actions.setCardPreferences),n=_e(i=>{var o;return(o=i.card.preferences)==null?void 0:o.filterOnClickField}),r=_e(i=>i.actions.setFilterOnClickField);return _.jsxs("div",{children:[_.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[_.jsx(zy,{checked:!!(e!=null&&e.filterOnClick),onCheckedChange:i=>{t({...e,filterOnClick:!!i})}}),_.jsx(fa,{children:"Filter on click"})]}),(e==null?void 0:e.filterOnClick)===!0&&_.jsxs("div",{className:"flex gap-2 items-center",children:[_.jsx(Ku,{value:n||"",className:" h-7 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"expression (optional)",onChange:i=>r(i.target.value)}),_.jsxs(Bb,{children:[_.jsx(L2,{children:_.jsx(e2,{className:"h-4 w-4 opacity-70"})}),_.jsx(Ih,{children:_.jsxs("div",{className:"max-w-[200px]",children:["The x-axis expression of your query. Example:",_.jsx("div",{className:" mt-1 text-xs font-mono",children:"TO_CHAR(order_date, 'YYYY-MM')"})]})})]})]})]})}const eie={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},tie={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function nie(){const e=_e(t=>t.card.type);return _.jsxs("div",{className:"p-6 space-y-6",children:[_.jsx(cA,{className:" ",type:"single",collapsible:!0,children:rie(e)}),_.jsx("section",{className:"",children:["line","bar"].includes(e)&&_.jsx(yA,{})}),_.jsx("div",{children:_.jsx(xA,{})}),_.jsx("div",{children:_.jsx(wA,{})})]})}function rie(e){if(["line","bar"].includes(e))return _.jsxs(_.Fragment,{children:[_.jsxs(cs,{className:"border-muted",value:"item-1",children:[_.jsx(us,{className:" font-normal",children:_.jsx("p",{children:"Chart Query"})}),_.jsxs(ds,{className:" ",children:[_.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"X-axis - Category (ex. city)"}),_.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),_.jsxs(cs,{className:"border-muted",value:"item-2",children:[_.jsx(us,{className:" font-normal",children:"Mixed Chart"}),_.jsxs(ds,{className:" text-xs space-y-2",children:[_.jsxs("p",{children:["Click ",_.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),_.jsx("pre",{children:JSON.stringify(eie,null,2)})]})]}),_.jsxs(cs,{className:"border-muted",value:"item-3",children:[_.jsx(us,{className:" font-normal",children:"Area Chart"}),_.jsxs(ds,{className:" text-xs space-y-2",children:[_.jsxs("p",{children:["Click ",_.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",_.jsx("a",{className:"text-blue-500 hover:underline mx-1",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),_.jsx("pre",{children:JSON.stringify(tie,null,2)})]})]})]});if(e==="bubble")return _.jsx(_.Fragment,{children:_.jsxs(cs,{className:"border-muted",value:"item-1",children:[_.jsx(us,{className:" font-normal",children:_.jsxs("p",{children:["How to create a ",_.jsx("span",{children:e})," chart query?"]})}),_.jsxs(ds,{className:" ",children:[_.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis, radius FROM table"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),_.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),_.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),_.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(e==="scatter")return _.jsx(_.Fragment,{children:_.jsxs(cs,{value:"item-1",children:[_.jsx(us,{className:" font-normal",children:_.jsxs("p",{children:["How to create a ",_.jsx("span",{children:e})," chart query?"]})}),_.jsxs(ds,{className:" ",children:[_.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, x-axis, y-axis FROM table"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Group (opt) - Category (ex. state)"}),_.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),_.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(e))return _.jsx(_.Fragment,{children:_.jsxs(cs,{value:"item-1",children:[_.jsx(us,{className:" font-normal",children:_.jsxs("p",{children:["How to create a"," ",_.jsxs("span",{children:[e==="polarArea"?"polar":e," "]})," ","chart query?"]})}),_.jsxs(ds,{className:" ",children:[_.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT label, measure FROM table"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"Label - Category (ex. city)"}),_.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function iie(){return _.jsxs("div",{className:"px-6 py-2 space-y-6",children:[_.jsx(cA,{className:" ",type:"single",collapsible:!0,children:_.jsxs(cs,{className:"border-muted",value:"item-1",children:[_.jsx(us,{className:" font-normal",children:"Stacked chart query?"}),_.jsxs(ds,{className:" ",children:[_.jsx("div",{className:"bg-muted px-2 py-1 rounded font-mono font-semibold text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),_.jsxs("ul",{className:"my-6 ml-6 list-disc [&>li]:mt-2 font-normal text-xs",children:[_.jsx("li",{children:"X-axis - Category (ex. country)"}),_.jsx("li",{children:"Stack by - Category (ex. city)"}),_.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]})}),_.jsx("section",{className:"",children:_.jsx(yA,{})}),_.jsx("div",{children:_.jsx(xA,{})}),_.jsx("div",{children:_.jsx(wA,{})})]})}function oie(){const e=_e(t=>t.card.type);return _.jsx(Pl,{className:" text-sm h-full w-full ",children:e==="stackedBar"?_.jsx(iie,{}):_.jsx(nie,{})})}function sie(){const e=_e(t=>t.isShowingVisual);return _.jsxs($M,{direction:"vertical",className:"min-w-full max-w-lg min-h-[250px]",children:[_.jsx($p,{className:"flex",minSize:40,defaultSize:40,children:_.jsx(Hne,{})}),_.jsx(FM,{className:"border-[1.5px] border-muted"}),_.jsx($p,{minSize:60,defaultSize:60,children:e?_.jsxs($M,{direction:"horizontal",children:[_.jsx(_.Fragment,{children:_.jsx($p,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:_.jsx(oie,{})})}),_.jsx(FM,{className:"border-[1.5px] border-muted"}),_.jsx($p,{minSize:40,defaultSize:70,maxSize:100,children:_.jsx(QT,{})})]}):_.jsx(QT,{})})]})}function aie({authToken:e,onSave:t,onClose:n}){_e(s=>s.actions.setCard);const r=_e(s=>s.actions.setOnSave),i=_e(s=>s.actions.setOnClose),o=be(s=>s.actions.setAuthToken);return m.useEffect(()=>{t&&r(t),n&&i(n)},[t,r,n,i]),m.useEffect(()=>{e&&e.accessToken&&o(e)},[e,o]),_.jsxs(Fk,{className:"border-x border-b rounded-none border-muted ",children:[_.jsx(jk,{className:" rounded-none border-r-[3px] border-muted ",children:_.jsx(dM,{})}),_.jsx(zk,{children:_.jsx(sie,{})})]})}function lie(){be(s=>s.selectedCardId);const e=be(s=>s.selectedSheetId),t=be(s=>s.actions.setIsVisualEditing);be(s=>s.actions.setIsEditorSaveEvent);const n=be(s=>s.isVisualEditing);be(s=>s.actions.getSelectedCard());const r=be(s=>s.actions.updateCard);function i(s){e&&(r(e,s),t(!1))}function o(){t(!1)}return _.jsx("div",{className:`grow flex ${n?"block":"hidden"}`,children:_.jsx(aie,{onSave:i,onClose:o})})}function cie({columns:e,tableName:t}){const n=_e(f=>f.selectedConnectionId),r=_e(f=>f.selectedDatabaseName),i=_e(f=>f.selectedSchemaName),o=_e(f=>f.selectedTableName),s=be(f=>f.dashboard.filters)||[],a=be(f=>f.actions.addFilter),l=be(f=>f.actions.removeFilter),c=be(f=>f.actions.removeFilterValue);function d(f){const g=s==null?void 0:s.find(p=>p.column===f.column_name&&p.table===o&&p.database===r);if(g)c(g.id),l(g.id);else{const p=k0(i||"",t),v=`SELECT ${f.column_name}, COUNT(*) FROM ${p} GROUP BY ${f.column_name} ORDER BY ${f.column_name} ASC LIMIT 50`,y=`SELECT min(${f.column_name}) as min, max(${f.column_name}) as max FROM ${p}`;if(t==="api"&&n){a({id:yh(),column:f.column_name,title:f.column_name,dataType:f.data_type,table:"api",database:"NA",connectionId:n,sql:Iu.includes(f.data_type)?y:v});return}if(!n||!r||!o)throw new Error("missing connectionId, database, or table");a({id:yh(),column:f.column_name,title:f.column_name,dataType:f.data_type,table:o,database:r,connectionId:n,sql:Iu.includes(f.data_type)?y:v})}}return _.jsx(Pl,{className:" h-[70vh] mt-2 xbg-red-100 px-3",children:e==null?void 0:e.map(f=>{const g=s==null?void 0:s.find(p=>p.column===f.column_name&&p.table===o&&p.database===r);return _.jsx("div",{onClick:()=>d(f),className:Pe(" group flex text-sm items-center justify-between px-3 py-[6px] transition-colors hover:bg-muted/50 cursor-pointer border border-background border-dashed",{"bg-muted ":g}),children:_.jsxs("div",{className:"flex items-center gap-2 ",children:[_.jsx(uM,{column:f}),_.jsx("span",{children:f.column_name})]})},f.column_name)})})}function uie(){be(t=>t.showFilters);const e=be(t=>t.actions.setShowFilters);return _.jsxs("section",{className:" relative space-y-4 py-0 px-4 border-muted bg-red-x100",children:[_.jsx(it,{onClick:()=>e(!1),className:" p-0 h-7 w-7 absolute top-0 right-4",variant:"outline",children:_.jsx(na,{})}),_.jsx("p",{className:"text-md px-2",children:"Data Columns"}),_.jsx("div",{children:_.jsx(dM,{ColumnsComponent:(t,n,r)=>_.jsx(cie,{schemaName:t,tableName:n,columns:r})})})]})}function die(){const e=be(r=>r.dashboard),t=be(r=>r.showFilters),n=be(r=>r.isVisualEditing);return m.useEffect(()=>{if(e.id==="")return;const r=$l(e.id),i=JSON.parse(localStorage.getItem(r)||"[]"),o=i.find(s=>s.name==="Original");o?o.template=e:i.push({name:"Original",template:e}),localStorage.setItem(r,JSON.stringify(i))},[e.id]),_.jsxs("div",{role:"dashboard-plus-main",className:` flex grow ${n?"hidden":"block"}`,children:[_.jsx(QP,{}),t&&_.jsx("div",{role:"filter-aside-container",className:"",children:_.jsx(uie,{})})]})}function fie(){const e=be(r=>r.dashboard),t=be(r=>r.actions.setDashboard),n=be(r=>r.showDashboardJSON);return be(r=>r.actions.setShowDashboardJSON),_.jsx("div",{className:Pe(" p-2",{hidden:!n}),children:_.jsx(JM,{onChange:r=>{if(r)try{JSON.parse(r),t(JSON.parse(r))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(e,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function hie({showControls:e=!1,showFooter:t=!0,...n}){return be(r=>r.isVisualEditing),_.jsxs(ZP,{children:[_.jsx(fie,{}),_.jsxs(Kw,{...n,children:[e&&_.jsx(BK,{}),_.jsx(lie,{}),_.jsx(die,{})]})]})}function pie(){const e=be(t=>t.actions);return{setDashboardTitle:e.setDashboardTitle,getStyle:e.getStyle,getDashboard:e.getDashboard,setOnSaveFunction:e.setOnSaveFunction,setOnAddCard:e.setOnAddCard,setOnUpateCard:e.setOnUpdateCard,setOnRemoveCard:e.setOnRemoveCard}}ct.Dashboard=JP,ct.DashboardPlus=hie,ct.DashboardWC=YG,ct.cleanCard=Pk,ct.getBookmarkKey=$l,ct.getDashbaordStateWithoutData=vy,ct.useActions=pie,ct.useDashboardStore=be,Object.defineProperty(ct,Symbol.toStringTag,{value:"Module"})});