@dataramen/cli 0.0.69 → 0.0.70

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.
@@ -1,4 +0,0 @@
1
- import{r as l,a as La,S as eo,p as xr,b as Se,s as Jn,c as bn,n as Xn,i as As,d as gr,t as Aa,e as Bn,f as Pa,g as Ia,h as br,j as rs,k as yr,l as Oa,m as Ma,o as vr,q as $a,u as s,v as to,w as K,x as O,A as Us,y as Da,z as Fa,B as P,C as Cn,D as ne,V as Ce,E as qa,F as Ba,R as tt,G as Ua,O as Wa}from"./index-g8K5wnQd.js";var fn={},wr;function Ha(){if(wr)return fn;wr=1,Object.defineProperty(fn,"__esModule",{value:!0}),fn.parse=i,fn.serialize=d;const e=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,t=/^[\u0021-\u003A\u003C-\u007E]*$/,n=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,r=/^[\u0020-\u003A\u003D-\u007E]*$/,o=Object.prototype.toString,a=(()=>{const p=function(){};return p.prototype=Object.create(null),p})();function i(p,b){const x=new a,y=p.length;if(y<2)return x;const v=b?.decode||f;let g=0;do{const m=p.indexOf("=",g);if(m===-1)break;const w=p.indexOf(";",g),C=w===-1?y:w;if(m>C){g=p.lastIndexOf(";",m-1)+1;continue}const S=u(p,g,m),k=c(p,m,S),j=p.slice(S,k);if(x[j]===void 0){let _=u(p,m+1,C),L=c(p,C,_);const F=v(p.slice(_,L));x[j]=F}g=C+1}while(g<y);return x}function u(p,b,x){do{const y=p.charCodeAt(b);if(y!==32&&y!==9)return b}while(++b<x);return x}function c(p,b,x){for(;b>x;){const y=p.charCodeAt(--b);if(y!==32&&y!==9)return b+1}return x}function d(p,b,x){const y=x?.encode||encodeURIComponent;if(!e.test(p))throw new TypeError(`argument name is invalid: ${p}`);const v=y(b);if(!t.test(v))throw new TypeError(`argument val is invalid: ${b}`);let g=p+"="+v;if(!x)return g;if(x.maxAge!==void 0){if(!Number.isInteger(x.maxAge))throw new TypeError(`option maxAge is invalid: ${x.maxAge}`);g+="; Max-Age="+x.maxAge}if(x.domain){if(!n.test(x.domain))throw new TypeError(`option domain is invalid: ${x.domain}`);g+="; Domain="+x.domain}if(x.path){if(!r.test(x.path))throw new TypeError(`option path is invalid: ${x.path}`);g+="; Path="+x.path}if(x.expires){if(!h(x.expires)||!Number.isFinite(x.expires.valueOf()))throw new TypeError(`option expires is invalid: ${x.expires}`);g+="; Expires="+x.expires.toUTCString()}if(x.httpOnly&&(g+="; HttpOnly"),x.secure&&(g+="; Secure"),x.partitioned&&(g+="; Partitioned"),x.priority)switch(typeof x.priority=="string"?x.priority.toLowerCase():void 0){case"low":g+="; Priority=Low";break;case"medium":g+="; Priority=Medium";break;case"high":g+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${x.priority}`)}if(x.sameSite)switch(typeof x.sameSite=="string"?x.sameSite.toLowerCase():x.sameSite){case!0:case"strict":g+="; SameSite=Strict";break;case"lax":g+="; SameSite=Lax";break;case"none":g+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${x.sameSite}`)}return g}function f(p){if(p.indexOf("%")===-1)return p;try{return decodeURIComponent(p)}catch{return p}}function h(p){return o.call(p)==="[object Date]"}return fn}Ha();var Cr="popstate";function za(e={}){function t(r,o){let{pathname:a,search:i,hash:u}=r.location;return Ps("",{pathname:a,search:i,hash:u},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function n(r,o){return typeof o=="string"?o:vn(o)}return Qa(t,n,null,e)}function z(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ee(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Ka(){return Math.random().toString(36).substring(2,10)}function jr(e,t){return{usr:e.state,key:e.key,idx:t}}function Ps(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Vt(t):t,state:n,key:t&&t.key||r||Ka()}}function vn({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Vt(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Qa(e,t,n,r={}){let{window:o=document.defaultView,v5Compat:a=!1}=r,i=o.history,u="POP",c=null,d=f();d==null&&(d=0,i.replaceState({...i.state,idx:d},""));function f(){return(i.state||{idx:null}).idx}function h(){u="POP";let v=f(),g=v==null?null:v-d;d=v,c&&c({action:u,location:y.location,delta:g})}function p(v,g){u="PUSH";let m=Ps(y.location,v,g);d=f()+1;let w=jr(m,d),C=y.createHref(m);try{i.pushState(w,"",C)}catch(S){if(S instanceof DOMException&&S.name==="DataCloneError")throw S;o.location.assign(C)}a&&c&&c({action:u,location:y.location,delta:1})}function b(v,g){u="REPLACE";let m=Ps(y.location,v,g);d=f();let w=jr(m,d),C=y.createHref(m);i.replaceState(w,"",C),a&&c&&c({action:u,location:y.location,delta:0})}function x(v){return Va(v)}let y={get action(){return u},get location(){return e(o,i)},listen(v){if(c)throw new Error("A history only accepts one active listener");return o.addEventListener(Cr,h),c=v,()=>{o.removeEventListener(Cr,h),c=null}},createHref(v){return t(o,v)},createURL:x,encodeLocation(v){let g=x(v);return{pathname:g.pathname,search:g.search,hash:g.hash}},push:p,replace:b,go(v){return i.go(v)}};return y}function Va(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),z(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:vn(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function no(e,t,n="/"){return Ya(e,t,n,!1)}function Ya(e,t,n,r){let o=typeof t=="string"?Vt(t):t,a=Ge(o.pathname||"/",n);if(a==null)return null;let i=so(e);Ga(i);let u=null;for(let c=0;u==null&&c<i.length;++c){let d=ii(a);u=oi(i[c],d,r)}return u}function so(e,t=[],n=[],r=""){let o=(a,i,u)=>{let c={relativePath:u===void 0?a.path||"":u,caseSensitive:a.caseSensitive===!0,childrenIndex:i,route:a};c.relativePath.startsWith("/")&&(z(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length));let d=Qe([r,c.relativePath]),f=n.concat(c);a.children&&a.children.length>0&&(z(a.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${d}".`),so(a.children,t,f,d)),!(a.path==null&&!a.index)&&t.push({path:d,score:si(d,a.index),routesMeta:f})};return e.forEach((a,i)=>{if(a.path===""||!a.path?.includes("?"))o(a,i);else for(let u of ro(a.path))o(a,i,u)}),t}function ro(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,o=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return o?[a,""]:[a];let i=ro(r.join("/")),u=[];return u.push(...i.map(c=>c===""?a:[a,c].join("/"))),o&&u.push(...i),u.map(c=>e.startsWith("/")&&c===""?"/":c)}function Ga(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:ri(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Ja=/^:[\w-]+$/,Xa=3,Za=2,ei=1,ti=10,ni=-2,Nr=e=>e==="*";function si(e,t){let n=e.split("/"),r=n.length;return n.some(Nr)&&(r+=ni),t&&(r+=Za),n.filter(o=>!Nr(o)).reduce((o,a)=>o+(Ja.test(a)?Xa:a===""?ei:ti),r)}function ri(e,t){return e.length===t.length&&e.slice(0,-1).every((r,o)=>r===t[o])?e[e.length-1]-t[t.length-1]:0}function oi(e,t,n=!1){let{routesMeta:r}=e,o={},a="/",i=[];for(let u=0;u<r.length;++u){let c=r[u],d=u===r.length-1,f=a==="/"?t:t.slice(a.length)||"/",h=Wt({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},f),p=c.route;if(!h&&d&&n&&!r[r.length-1].route.index&&(h=Wt({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!h)return null;Object.assign(o,h.params),i.push({params:o,pathname:Qe([a,h.pathname]),pathnameBase:di(Qe([a,h.pathnameBase])),route:p}),h.pathnameBase!=="/"&&(a=Qe([a,h.pathnameBase]))}return i}function Wt(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ai(e.path,e.caseSensitive,e.end),o=t.match(n);if(!o)return null;let a=o[0],i=a.replace(/(.)\/+$/,"$1"),u=o.slice(1);return{params:r.reduce((d,{paramName:f,isOptional:h},p)=>{if(f==="*"){let x=u[p]||"";i=a.slice(0,a.length-x.length).replace(/(.)\/+$/,"$1")}const b=u[p];return h&&!b?d[f]=void 0:d[f]=(b||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:i,pattern:e}}function ai(e,t=!1,n=!0){Ee(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,u,c)=>(r.push({paramName:u,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),o+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?o+="\\/*$":e!==""&&e!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,t?void 0:"i"),r]}function ii(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Ee(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Ge(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function li(e,t="/"){let{pathname:n,search:r="",hash:o=""}=typeof e=="string"?Vt(e):e;return{pathname:n?n.startsWith("/")?n:ci(n,t):t,search:hi(r),hash:fi(o)}}function ci(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(o=>{o===".."?n.length>1&&n.pop():o!=="."&&n.push(o)}),n.length>1?n.join("/"):"/"}function vs(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function ui(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function oo(e){let t=ui(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function ao(e,t,n,r=!1){let o;typeof e=="string"?o=Vt(e):(o={...e},z(!o.pathname||!o.pathname.includes("?"),vs("?","pathname","search",o)),z(!o.pathname||!o.pathname.includes("#"),vs("#","pathname","hash",o)),z(!o.search||!o.search.includes("#"),vs("#","search","hash",o)));let a=e===""||o.pathname==="",i=a?"/":o.pathname,u;if(i==null)u=n;else{let h=t.length-1;if(!r&&i.startsWith("..")){let p=i.split("/");for(;p[0]==="..";)p.shift(),h-=1;o.pathname=p.join("/")}u=h>=0?t[h]:"/"}let c=li(o,u),d=i&&i!=="/"&&i.endsWith("/"),f=(a||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}var Qe=e=>e.join("/").replace(/\/\/+/g,"/"),di=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),hi=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,fi=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function mi(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var io=["POST","PUT","PATCH","DELETE"];new Set(io);var pi=["GET",...io];new Set(pi);var Yt=l.createContext(null);Yt.displayName="DataRouter";var os=l.createContext(null);os.displayName="DataRouterState";var lo=l.createContext({isTransitioning:!1});lo.displayName="ViewTransition";var xi=l.createContext(new Map);xi.displayName="Fetchers";var gi=l.createContext(null);gi.displayName="Await";var Fe=l.createContext(null);Fe.displayName="Navigation";var jn=l.createContext(null);jn.displayName="Location";var qe=l.createContext({outlet:null,matches:[],isDataRoute:!1});qe.displayName="Route";var Ws=l.createContext(null);Ws.displayName="RouteError";function bi(e,{relative:t}={}){z(Nn(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=l.useContext(Fe),{hash:o,pathname:a,search:i}=_n(e,{relative:t}),u=a;return n!=="/"&&(u=a==="/"?n:Qe([n,a])),r.createHref({pathname:u,search:i,hash:o})}function Nn(){return l.useContext(jn)!=null}function le(){return z(Nn(),"useLocation() may be used only in the context of a <Router> component."),l.useContext(jn).location}var co="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function uo(e){l.useContext(Fe).static||l.useLayoutEffect(e)}function V(){let{isDataRoute:e}=l.useContext(qe);return e?Ai():yi()}function yi(){z(Nn(),"useNavigate() may be used only in the context of a <Router> component.");let e=l.useContext(Yt),{basename:t,navigator:n}=l.useContext(Fe),{matches:r}=l.useContext(qe),{pathname:o}=le(),a=JSON.stringify(oo(r)),i=l.useRef(!1);return uo(()=>{i.current=!0}),l.useCallback((c,d={})=>{if(Ee(i.current,co),!i.current)return;if(typeof c=="number"){n.go(c);return}let f=ao(c,JSON.parse(a),o,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Qe([t,f.pathname])),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,a,o,e])}l.createContext(null);function vi(){let{matches:e}=l.useContext(qe),t=e[e.length-1];return t?t.params:{}}function _n(e,{relative:t}={}){let{matches:n}=l.useContext(qe),{pathname:r}=le(),o=JSON.stringify(oo(n));return l.useMemo(()=>ao(e,JSON.parse(o),r,t==="path"),[e,o,r,t])}function wi(e,t){return ho(e,t)}function ho(e,t,n,r){z(Nn(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o,static:a}=l.useContext(Fe),{matches:i}=l.useContext(qe),u=i[i.length-1],c=u?u.params:{},d=u?u.pathname:"/",f=u?u.pathnameBase:"/",h=u&&u.route;{let m=h&&h.path||"";fo(d,!h||m.endsWith("*")||m.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${d}" (under <Route path="${m}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
2
-
3
- Please change the parent <Route path="${m}"> to <Route path="${m==="/"?"*":`${m}/*`}">.`)}let p=le(),b;if(t){let m=typeof t=="string"?Vt(t):t;z(f==="/"||m.pathname?.startsWith(f),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${f}" but pathname "${m.pathname}" was given in the \`location\` prop.`),b=m}else b=p;let x=b.pathname||"/",y=x;if(f!=="/"){let m=f.replace(/^\//,"").split("/");y="/"+x.replace(/^\//,"").split("/").slice(m.length).join("/")}let v=!a&&n&&n.matches&&n.matches.length>0?n.matches:no(e,{pathname:y});Ee(h||v!=null,`No routes matched location "${b.pathname}${b.search}${b.hash}" `),Ee(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${b.pathname}${b.search}${b.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let g=Si(v&&v.map(m=>Object.assign({},m,{params:Object.assign({},c,m.params),pathname:Qe([f,o.encodeLocation?o.encodeLocation(m.pathname).pathname:m.pathname]),pathnameBase:m.pathnameBase==="/"?f:Qe([f,o.encodeLocation?o.encodeLocation(m.pathnameBase).pathname:m.pathnameBase])})),i,n,r);return t&&g?l.createElement(jn.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...b},navigationType:"POP"}},g):g}function Ci(){let e=Li(),t=mi(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=l.createElement(l.Fragment,null,l.createElement("p",null,"💿 Hey developer 👋"),l.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",l.createElement("code",{style:a},"ErrorBoundary")," or"," ",l.createElement("code",{style:a},"errorElement")," prop on your route.")),l.createElement(l.Fragment,null,l.createElement("h2",null,"Unexpected Application Error!"),l.createElement("h3",{style:{fontStyle:"italic"}},t),n?l.createElement("pre",{style:o},n):null,i)}var ji=l.createElement(Ci,null),Ni=class extends l.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){console.error("React Router caught the following error during render",e,t)}render(){return this.state.error!==void 0?l.createElement(qe.Provider,{value:this.props.routeContext},l.createElement(Ws.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function _i({routeContext:e,match:t,children:n}){let r=l.useContext(Yt);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),l.createElement(qe.Provider,{value:e},n)}function Si(e,t=[],n=null,r=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let o=e,a=n?.errors;if(a!=null){let c=o.findIndex(d=>d.route.id&&a?.[d.route.id]!==void 0);z(c>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(",")}`),o=o.slice(0,Math.min(o.length,c+1))}let i=!1,u=-1;if(n)for(let c=0;c<o.length;c++){let d=o[c];if((d.route.HydrateFallback||d.route.hydrateFallbackElement)&&(u=c),d.route.id){let{loaderData:f,errors:h}=n,p=d.route.loader&&!f.hasOwnProperty(d.route.id)&&(!h||h[d.route.id]===void 0);if(d.route.lazy||p){i=!0,u>=0?o=o.slice(0,u+1):o=[o[0]];break}}}return o.reduceRight((c,d,f)=>{let h,p=!1,b=null,x=null;n&&(h=a&&d.route.id?a[d.route.id]:void 0,b=d.route.errorElement||ji,i&&(u<0&&f===0?(fo("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),p=!0,x=null):u===f&&(p=!0,x=d.route.hydrateFallbackElement||null)));let y=t.concat(o.slice(0,f+1)),v=()=>{let g;return h?g=b:p?g=x:d.route.Component?g=l.createElement(d.route.Component,null):d.route.element?g=d.route.element:g=c,l.createElement(_i,{match:d,routeContext:{outlet:c,matches:y,isDataRoute:n!=null},children:g})};return n&&(d.route.ErrorBoundary||d.route.errorElement||f===0)?l.createElement(Ni,{location:n.location,revalidation:n.revalidation,component:b,error:h,children:v(),routeContext:{outlet:null,matches:y,isDataRoute:!0}}):v()},null)}function Hs(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ki(e){let t=l.useContext(Yt);return z(t,Hs(e)),t}function Ei(e){let t=l.useContext(os);return z(t,Hs(e)),t}function Ri(e){let t=l.useContext(qe);return z(t,Hs(e)),t}function zs(e){let t=Ri(e),n=t.matches[t.matches.length-1];return z(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Ti(){return zs("useRouteId")}function Li(){let e=l.useContext(Ws),t=Ei("useRouteError"),n=zs("useRouteError");return e!==void 0?e:t.errors?.[n]}function Ai(){let{router:e}=ki("useNavigate"),t=zs("useNavigate"),n=l.useRef(!1);return uo(()=>{n.current=!0}),l.useCallback(async(o,a={})=>{Ee(n.current,co),n.current&&(typeof o=="number"?e.navigate(o):await e.navigate(o,{fromRouteId:t,...a}))},[e,t])}var _r={};function fo(e,t,n){!t&&!_r[e]&&(_r[e]=!0,Ee(!1,n))}l.memo(Pi);function Pi({routes:e,future:t,state:n}){return ho(e,void 0,n,t)}function yt(e){z(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Ii({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:o,static:a=!1}){z(!Nn(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let i=e.replace(/^\/*/,"/"),u=l.useMemo(()=>({basename:i,navigator:o,static:a,future:{}}),[i,o,a]);typeof n=="string"&&(n=Vt(n));let{pathname:c="/",search:d="",hash:f="",state:h=null,key:p="default"}=n,b=l.useMemo(()=>{let x=Ge(c,i);return x==null?null:{location:{pathname:x,search:d,hash:f,state:h,key:p},navigationType:r}},[i,c,d,f,h,p,r]);return Ee(b!=null,`<Router basename="${i}"> is not able to match the URL "${c}${d}${f}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:l.createElement(Fe.Provider,{value:u},l.createElement(jn.Provider,{children:t,value:b}))}function Oi({children:e,location:t}){return wi(Is(e),t)}function Is(e,t=[]){let n=[];return l.Children.forEach(e,(r,o)=>{if(!l.isValidElement(r))return;let a=[...t,o];if(r.type===l.Fragment){n.push.apply(n,Is(r.props.children,a));return}z(r.type===yt,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),z(!r.props.index||!r.props.children,"An index route cannot have child routes.");let i={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(i.children=Is(r.props.children,a)),n.push(i)}),n}var Kn="get",Qn="application/x-www-form-urlencoded";function as(e){return e!=null&&typeof e.tagName=="string"}function Mi(e){return as(e)&&e.tagName.toLowerCase()==="button"}function $i(e){return as(e)&&e.tagName.toLowerCase()==="form"}function Di(e){return as(e)&&e.tagName.toLowerCase()==="input"}function Fi(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function qi(e,t){return e.button===0&&(!t||t==="_self")&&!Fi(e)}function Os(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(o=>[n,o]):[[n,r]])},[]))}function Bi(e,t){let n=Os(e);return t&&t.forEach((r,o)=>{n.has(o)||t.getAll(o).forEach(a=>{n.append(o,a)})}),n}var Un=null;function Ui(){if(Un===null)try{new FormData(document.createElement("form"),0),Un=!1}catch{Un=!0}return Un}var Wi=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ws(e){return e!=null&&!Wi.has(e)?(Ee(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Qn}"`),null):e}function Hi(e,t){let n,r,o,a,i;if($i(e)){let u=e.getAttribute("action");r=u?Ge(u,t):null,n=e.getAttribute("method")||Kn,o=ws(e.getAttribute("enctype"))||Qn,a=new FormData(e)}else if(Mi(e)||Di(e)&&(e.type==="submit"||e.type==="image")){let u=e.form;if(u==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||u.getAttribute("action");if(r=c?Ge(c,t):null,n=e.getAttribute("formmethod")||u.getAttribute("method")||Kn,o=ws(e.getAttribute("formenctype"))||ws(u.getAttribute("enctype"))||Qn,a=new FormData(u,e),!Ui()){let{name:d,type:f,value:h}=e;if(f==="image"){let p=d?`${d}.`:"";a.append(`${p}x`,"0"),a.append(`${p}y`,"0")}else d&&a.append(d,h)}}else{if(as(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Kn,r=null,o=Qn,i=e}return a&&o==="text/plain"&&(i=a,a=void 0),{action:r,method:n.toLowerCase(),encType:o,formData:a,body:i}}function Ks(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}async function zi(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Ki(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function Qi(e,t,n){let r=await Promise.all(e.map(async o=>{let a=t.routes[o.route.id];if(a){let i=await zi(a,n);return i.links?i.links():[]}return[]}));return Ji(r.flat(1).filter(Ki).filter(o=>o.rel==="stylesheet"||o.rel==="preload").map(o=>o.rel==="stylesheet"?{...o,rel:"prefetch",as:"style"}:{...o,rel:"prefetch"}))}function Sr(e,t,n,r,o,a){let i=(c,d)=>n[d]?c.route.id!==n[d].route.id:!0,u=(c,d)=>n[d].pathname!==c.pathname||n[d].route.path?.endsWith("*")&&n[d].params["*"]!==c.params["*"];return a==="assets"?t.filter((c,d)=>i(c,d)||u(c,d)):a==="data"?t.filter((c,d)=>{let f=r.routes[c.route.id];if(!f||!f.hasLoader)return!1;if(i(c,d)||u(c,d))return!0;if(c.route.shouldRevalidate){let h=c.route.shouldRevalidate({currentUrl:new URL(o.pathname+o.search+o.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function Vi(e,t,{includeHydrateFallback:n}={}){return Yi(e.map(r=>{let o=t.routes[r.route.id];if(!o)return[];let a=[o.module];return o.clientActionModule&&(a=a.concat(o.clientActionModule)),o.clientLoaderModule&&(a=a.concat(o.clientLoaderModule)),n&&o.hydrateFallbackModule&&(a=a.concat(o.hydrateFallbackModule)),o.imports&&(a=a.concat(o.imports)),a}).flat(1))}function Yi(e){return[...new Set(e)]}function Gi(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Ji(e,t){let n=new Set;return new Set(t),e.reduce((r,o)=>{let a=JSON.stringify(Gi(o));return n.has(a)||(n.add(a),r.push({key:a,link:o})),r},[])}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Xi=new Set([100,101,204,205]);function Zi(e,t){let n=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n.pathname==="/"?n.pathname="_root.data":t&&Ge(n.pathname,t)==="/"?n.pathname=`${t.replace(/\/$/,"")}/_root.data`:n.pathname=`${n.pathname.replace(/\/$/,"")}.data`,n}function mo(){let e=l.useContext(Yt);return Ks(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function el(){let e=l.useContext(os);return Ks(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Qs=l.createContext(void 0);Qs.displayName="FrameworkContext";function po(){let e=l.useContext(Qs);return Ks(e,"You must render this element inside a <HydratedRouter> element"),e}function tl(e,t){let n=l.useContext(Qs),[r,o]=l.useState(!1),[a,i]=l.useState(!1),{onFocus:u,onBlur:c,onMouseEnter:d,onMouseLeave:f,onTouchStart:h}=t,p=l.useRef(null);l.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let y=g=>{g.forEach(m=>{i(m.isIntersecting)})},v=new IntersectionObserver(y,{threshold:.5});return p.current&&v.observe(p.current),()=>{v.disconnect()}}},[e]),l.useEffect(()=>{if(r){let y=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(y)}}},[r]);let b=()=>{o(!0)},x=()=>{o(!1),i(!1)};return n?e!=="intent"?[a,p,{}]:[a,p,{onFocus:mn(u,b),onBlur:mn(c,x),onMouseEnter:mn(d,b),onMouseLeave:mn(f,x),onTouchStart:mn(h,b)}]:[!1,p,{}]}function mn(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function nl({page:e,...t}){let{router:n}=mo(),r=l.useMemo(()=>no(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?l.createElement(rl,{page:e,matches:r,...t}):null}function sl(e){let{manifest:t,routeModules:n}=po(),[r,o]=l.useState([]);return l.useEffect(()=>{let a=!1;return Qi(e,t,n).then(i=>{a||o(i)}),()=>{a=!0}},[e,t,n]),r}function rl({page:e,matches:t,...n}){let r=le(),{manifest:o,routeModules:a}=po(),{basename:i}=mo(),{loaderData:u,matches:c}=el(),d=l.useMemo(()=>Sr(e,t,c,o,r,"data"),[e,t,c,o,r]),f=l.useMemo(()=>Sr(e,t,c,o,r,"assets"),[e,t,c,o,r]),h=l.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let x=new Set,y=!1;if(t.forEach(g=>{let m=o.routes[g.route.id];!m||!m.hasLoader||(!d.some(w=>w.route.id===g.route.id)&&g.route.id in u&&a[g.route.id]?.shouldRevalidate||m.hasClientLoader?y=!0:x.add(g.route.id))}),x.size===0)return[];let v=Zi(e,i);return y&&x.size>0&&v.searchParams.set("_routes",t.filter(g=>x.has(g.route.id)).map(g=>g.route.id).join(",")),[v.pathname+v.search]},[i,u,r,o,d,t,e,a]),p=l.useMemo(()=>Vi(f,o),[f,o]),b=sl(f);return l.createElement(l.Fragment,null,h.map(x=>l.createElement("link",{key:x,rel:"prefetch",as:"fetch",href:x,...n})),p.map(x=>l.createElement("link",{key:x,rel:"modulepreload",href:x,...n})),b.map(({key:x,link:y})=>l.createElement("link",{key:x,...y})))}function ol(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var xo=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{xo&&(window.__reactRouterVersion="7.6.0")}catch{}function al({basename:e,children:t,window:n}){let r=l.useRef();r.current==null&&(r.current=za({window:n,v5Compat:!0}));let o=r.current,[a,i]=l.useState({action:o.action,location:o.location}),u=l.useCallback(c=>{l.startTransition(()=>i(c))},[i]);return l.useLayoutEffect(()=>o.listen(u),[o,u]),l.createElement(Ii,{basename:e,children:t,location:a.location,navigationType:a.action,navigator:o})}var go=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,bo=l.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:o,reloadDocument:a,replace:i,state:u,target:c,to:d,preventScrollReset:f,viewTransition:h,...p},b){let{basename:x}=l.useContext(Fe),y=typeof d=="string"&&go.test(d),v,g=!1;if(typeof d=="string"&&y&&(v=d,xo))try{let L=new URL(window.location.href),F=d.startsWith("//")?new URL(L.protocol+d):new URL(d),Z=Ge(F.pathname,x);F.origin===L.origin&&Z!=null?d=Z+F.search+F.hash:g=!0}catch{Ee(!1,`<Link to="${d}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let m=bi(d,{relative:o}),[w,C,S]=tl(r,p),k=ul(d,{replace:i,state:u,target:c,preventScrollReset:f,relative:o,viewTransition:h});function j(L){t&&t(L),L.defaultPrevented||k(L)}let _=l.createElement("a",{...p,...S,href:v||m,onClick:g||a?t:j,ref:ol(b,C),target:c,"data-discover":!y&&n==="render"?"true":void 0});return w&&!y?l.createElement(l.Fragment,null,_,l.createElement(nl,{page:m})):_});bo.displayName="Link";var il=l.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:o=!1,style:a,to:i,viewTransition:u,children:c,...d},f){let h=_n(i,{relative:d.relative}),p=le(),b=l.useContext(os),{navigator:x,basename:y}=l.useContext(Fe),v=b!=null&&xl(h)&&u===!0,g=x.encodeLocation?x.encodeLocation(h).pathname:h.pathname,m=p.pathname,w=b&&b.navigation&&b.navigation.location?b.navigation.location.pathname:null;n||(m=m.toLowerCase(),w=w?w.toLowerCase():null,g=g.toLowerCase()),w&&y&&(w=Ge(w,y)||w);const C=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let S=m===g||!o&&m.startsWith(g)&&m.charAt(C)==="/",k=w!=null&&(w===g||!o&&w.startsWith(g)&&w.charAt(g.length)==="/"),j={isActive:S,isPending:k,isTransitioning:v},_=S?t:void 0,L;typeof r=="function"?L=r(j):L=[r,S?"active":null,k?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let F=typeof a=="function"?a(j):a;return l.createElement(bo,{...d,"aria-current":_,className:L,ref:f,style:F,to:i,viewTransition:u},typeof c=="function"?c(j):c)});il.displayName="NavLink";var ll=l.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:o,state:a,method:i=Kn,action:u,onSubmit:c,relative:d,preventScrollReset:f,viewTransition:h,...p},b)=>{let x=ml(),y=pl(u,{relative:d}),v=i.toLowerCase()==="get"?"get":"post",g=typeof u=="string"&&go.test(u),m=w=>{if(c&&c(w),w.defaultPrevented)return;w.preventDefault();let C=w.nativeEvent.submitter,S=C?.getAttribute("formmethod")||i;x(C||w.currentTarget,{fetcherKey:t,method:S,navigate:n,replace:o,state:a,relative:d,preventScrollReset:f,viewTransition:h})};return l.createElement("form",{ref:b,method:v,action:y,onSubmit:r?c:m,...p,"data-discover":!g&&e==="render"?"true":void 0})});ll.displayName="Form";function cl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function yo(e){let t=l.useContext(Yt);return z(t,cl(e)),t}function ul(e,{target:t,replace:n,state:r,preventScrollReset:o,relative:a,viewTransition:i}={}){let u=V(),c=le(),d=_n(e,{relative:a});return l.useCallback(f=>{if(qi(f,t)){f.preventDefault();let h=n!==void 0?n:vn(c)===vn(d);u(e,{replace:h,state:r,preventScrollReset:o,relative:a,viewTransition:i})}},[c,u,d,n,r,t,e,o,a,i])}function dl(e){Ee(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=l.useRef(Os(e)),n=l.useRef(!1),r=le(),o=l.useMemo(()=>Bi(r.search,n.current?null:t.current),[r.search]),a=V(),i=l.useCallback((u,c)=>{const d=Os(typeof u=="function"?u(o):u);n.current=!0,a("?"+d,c)},[a,o]);return[o,i]}var hl=0,fl=()=>`__${String(++hl)}__`;function ml(){let{router:e}=yo("useSubmit"),{basename:t}=l.useContext(Fe),n=Ti();return l.useCallback(async(r,o={})=>{let{action:a,method:i,encType:u,formData:c,body:d}=Hi(r,t);if(o.navigate===!1){let f=o.fetcherKey||fl();await e.fetch(f,n,o.action||a,{preventScrollReset:o.preventScrollReset,formData:c,body:d,formMethod:o.method||i,formEncType:o.encType||u,flushSync:o.flushSync})}else await e.navigate(o.action||a,{preventScrollReset:o.preventScrollReset,formData:c,body:d,formMethod:o.method||i,formEncType:o.encType||u,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[e,t,n])}function pl(e,{relative:t}={}){let{basename:n}=l.useContext(Fe),r=l.useContext(qe);z(r,"useFormAction must be used inside a RouteContext");let[o]=r.matches.slice(-1),a={..._n(e||".",{relative:t})},i=le();if(e==null){a.search=i.search;let u=new URLSearchParams(a.search),c=u.getAll("index");if(c.some(f=>f==="")){u.delete("index"),c.filter(h=>h).forEach(h=>u.append("index",h));let f=u.toString();a.search=f?`?${f}`:""}}return(!e||e===".")&&o.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Qe([n,a.pathname])),vn(a)}function xl(e,t={}){let n=l.useContext(lo);z(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=yo("useViewTransitionState"),o=_n(e,{relative:t.relative});if(!n.isTransitioning)return!1;let a=Ge(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=Ge(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Wt(o.pathname,i)!=null||Wt(o.pathname,a)!=null}[...Xi];var vo=La(),wo=class extends eo{constructor(e,t){super(),this.options=t,this.#n=e,this.#i=null,this.#a=xr(),this.bindMethods(),this.setOptions(t)}#n;#e=void 0;#s=void 0;#t=void 0;#r;#o;#a;#i;#p;#h;#f;#c;#u;#l;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),kr(this.#e,this.options)?this.#d():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ms(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ms(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#w(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,n=this.#e;if(this.options=this.#n.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Se(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#C(),this.#e.setOptions(this.options),t._defaulted&&!Jn(this.options,t)&&this.#n.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&Er(this.#e,n,this.options,t)&&this.#d(),this.updateResult(),r&&(this.#e!==n||Se(this.options.enabled,this.#e)!==Se(t.enabled,this.#e)||bn(this.options.staleTime,this.#e)!==bn(t.staleTime,this.#e))&&this.#x();const o=this.#g();r&&(this.#e!==n||Se(this.options.enabled,this.#e)!==Se(t.enabled,this.#e)||o!==this.#l)&&this.#b(o)}getOptimisticResult(e){const t=this.#n.getQueryCache().build(this.#n,e),n=this.createResult(t,e);return bl(this,n)&&(this.#t=n,this.#o=this.options,this.#r=this.#e.state),n}getCurrentResult(){return this.#t}trackResult(e,t){return new Proxy(e,{get:(n,r)=>(this.trackProp(r),t?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#a.status==="pending"&&this.#a.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#n.defaultQueryOptions(e),n=this.#n.getQueryCache().build(this.#n,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#t))}#d(e){this.#C();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Xn)),t}#x(){this.#v();const e=bn(this.options.staleTime,this.#e);if(As||this.#t.isStale||!gr(e))return;const n=Aa(this.#t.dataUpdatedAt,e)+1;this.#c=Bn.setTimeout(()=>{this.#t.isStale||this.updateResult()},n)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(e){this.#w(),this.#l=e,!(As||Se(this.options.enabled,this.#e)===!1||!gr(this.#l)||this.#l===0)&&(this.#u=Bn.setInterval(()=>{(this.options.refetchIntervalInBackground||Pa.isFocused())&&this.#d()},this.#l))}#y(){this.#x(),this.#b(this.#g())}#v(){this.#c&&(Bn.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(Bn.clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const n=this.#e,r=this.options,o=this.#t,a=this.#r,i=this.#o,c=e!==n?e.state:this.#s,{state:d}=e;let f={...d},h=!1,p;if(t._optimisticResults){const _=this.hasListeners(),L=!_&&kr(e,t),F=_&&Er(e,n,t,r);(L||F)&&(f={...f,...Ia(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:b,errorUpdatedAt:x,status:y}=f;p=f.data;let v=!1;if(t.placeholderData!==void 0&&p===void 0&&y==="pending"){let _;o?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(_=o.data,v=!0):_=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,_!==void 0&&(y="success",p=br(o?.data,_,t),h=!0)}if(t.select&&p!==void 0&&!v)if(o&&p===a?.data&&t.select===this.#p)p=this.#h;else try{this.#p=t.select,p=t.select(p),p=br(o?.data,p,t),this.#h=p,this.#i=null}catch(_){this.#i=_}this.#i&&(b=this.#i,p=this.#h,x=Date.now(),y="error");const g=f.fetchStatus==="fetching",m=y==="pending",w=y==="error",C=m&&g,S=p!==void 0,j={status:y,fetchStatus:f.fetchStatus,isPending:m,isSuccess:y==="success",isError:w,isInitialLoading:C,isLoading:C,data:p,dataUpdatedAt:f.dataUpdatedAt,error:b,errorUpdatedAt:x,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>c.dataUpdateCount||f.errorUpdateCount>c.errorUpdateCount,isFetching:g,isRefetching:g&&!m,isLoadingError:w&&!S,isPaused:f.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:w&&S,isStale:Vs(e,t),refetch:this.refetch,promise:this.#a,isEnabled:Se(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const _=Z=>{j.status==="error"?Z.reject(j.error):j.data!==void 0&&Z.resolve(j.data)},L=()=>{const Z=this.#a=j.promise=xr();_(Z)},F=this.#a;switch(F.status){case"pending":e.queryHash===n.queryHash&&_(F);break;case"fulfilled":(j.status==="error"||j.data!==F.value)&&L();break;case"rejected":(j.status!=="error"||j.error!==F.reason)&&L();break}}return j}updateResult(){const e=this.#t,t=this.createResult(this.#e,this.options);if(this.#r=this.#e.state,this.#o=this.options,this.#r.data!==void 0&&(this.#f=this.#e),Jn(t,e))return;this.#t=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,o=typeof r=="function"?r():r;if(o==="all"||!o&&!this.#m.size)return!0;const a=new Set(o??this.#m);return this.options.throwOnError&&a.add("error"),Object.keys(this.#t).some(i=>{const u=i;return this.#t[u]!==e[u]&&a.has(u)})};this.#j({listeners:n()})}#C(){const e=this.#n.getQueryCache().build(this.#n,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#s=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#j(e){rs.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#t)}),this.#n.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function gl(e,t){return Se(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function kr(e,t){return gl(e,t)||e.state.data!==void 0&&Ms(e,t,t.refetchOnMount)}function Ms(e,t,n){if(Se(t.enabled,e)!==!1&&bn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Vs(e,t)}return!1}function Er(e,t,n,r){return(e!==t||Se(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Vs(e,n)}function Vs(e,t){return Se(t.enabled,e)!==!1&&e.isStaleByTime(bn(t.staleTime,e))}function bl(e,t){return!Jn(e.getCurrentResult(),t)}var yl=class extends wo{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:yr()})}getOptimisticResult(e){return e.behavior=yr(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:n}=e,r=super.createResult(e,t),{isFetching:o,isRefetching:a,isError:i,isRefetchError:u}=r,c=n.fetchMeta?.fetchMore?.direction,d=i&&c==="forward",f=o&&c==="forward",h=i&&c==="backward",p=o&&c==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Ma(t,n.data),hasPreviousPage:Oa(t,n.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:h,isFetchingPreviousPage:p,isRefetchError:u&&!d&&!h,isRefetching:a&&!f&&!p}}},vl=class extends eo{#n;#e=void 0;#s;#t;constructor(t,n){super(),this.#n=t,this.setOptions(n),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const n=this.options;this.options=this.#n.defaultMutationOptions(t),Jn(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),n?.mutationKey&&this.options.mutationKey&&vr(n.mutationKey)!==vr(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(t){this.#r(),this.#o(t)}getCurrentResult(){return this.#e}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#r(),this.#o()}mutate(t,n){return this.#t=n,this.#s?.removeObserver(this),this.#s=this.#n.getMutationCache().build(this.#n,this.options),this.#s.addObserver(this),this.#s.execute(t)}#r(){const t=this.#s?.state??$a();this.#e={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#o(t){rs.batch(()=>{if(this.#t&&this.hasListeners()){const n=this.#e.variables,r=this.#e.context,o={client:this.#n,meta:this.options.meta,mutationKey:this.options.mutationKey};t?.type==="success"?(this.#t.onSuccess?.(t.data,n,r,o),this.#t.onSettled?.(t.data,null,n,r,o)):t?.type==="error"&&(this.#t.onError?.(t.error,n,r,o),this.#t.onSettled?.(void 0,t.error,n,r,o))}this.listeners.forEach(n=>{n(this.#e)})})}},Co=l.createContext(void 0),jo=e=>{const t=l.useContext(Co);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},wl=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(Co.Provider,{value:e,children:t})),No=l.createContext(!1),Cl=()=>l.useContext(No);No.Provider;function jl(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Nl=l.createContext(jl()),_l=()=>l.useContext(Nl),Sl=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},kl=e=>{l.useEffect(()=>{e.clearReset()},[e])},El=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||to(n,[e.error,r])),Rl=e=>{if(e.suspense){const n=o=>o==="static"?o:Math.max(o??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...o)=>n(r(...o)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Tl=(e,t)=>e.isLoading&&e.isFetching&&!t,Ll=(e,t)=>e?.suspense&&t.isPending,Rr=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function _o(e,t,n){const r=Cl(),o=_l(),a=jo(),i=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(i),i._optimisticResults=r?"isRestoring":"optimistic",Rl(i),Sl(i,o),kl(o);const u=!a.getQueryCache().get(i.queryHash),[c]=l.useState(()=>new t(a,i)),d=c.getOptimisticResult(i),f=!r&&e.subscribed!==!1;if(l.useSyncExternalStore(l.useCallback(h=>{const p=f?c.subscribe(rs.batchCalls(h)):Xn;return c.updateResult(),p},[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),l.useEffect(()=>{c.setOptions(i)},[i,c]),Ll(i,d))throw Rr(i,c,o);if(El({result:d,errorResetBoundary:o,throwOnError:i.throwOnError,query:a.getQueryCache().get(i.queryHash),suspense:i.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(i,d),i.experimental_prefetchInRender&&!As&&Tl(d,r)&&(u?Rr(i,c,o):a.getQueryCache().get(i.queryHash)?.promise)?.catch(Xn).finally(()=>{c.updateResult()}),i.notifyOnChangeProps?d:c.trackResult(d)}function ce(e,t){return _o(e,wo)}function X(e,t){const n=jo(),[r]=l.useState(()=>new vl(n,e));l.useEffect(()=>{r.setOptions(e)},[r,e]);const o=l.useSyncExternalStore(l.useCallback(i=>r.subscribe(rs.batchCalls(i)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=l.useCallback((i,u)=>{r.mutate(i,u).catch(Xn)},[r]);if(o.error&&to(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:a,mutateAsync:o.mutate}}function So(e,t){return _o(e,yl)}const it="data-sources",ko="auth-user",Al=e=>ce({queryKey:["project","datasources",e],queryFn:async()=>{const{data:t}=await O.get(`/project/team/${e}/datasources`);return t.data},enabled:!!e}),Gt=e=>{const t=["project","datasources"],n=["project","saved-queries"];return Promise.all([K.invalidateQueries({queryKey:t}),K.invalidateQueries({queryKey:n})])},Pl=e=>{const t=["trash","team"];return K.invalidateQueries({queryKey:t})},Il=(e,t)=>ce({queryKey:["project",t.teamId,"tables",e,t.selectedDataSources],queryFn:async()=>{const{data:n}=await O.get(`/project/team/${t.teamId}/query`,{params:{size:30,search:e,selectedDataSources:t.selectedDataSources}});return n.data},enabled:!!t.teamId,staleTime:0}),Ol=(e,t=30,n)=>So({queryKey:["project","tabs-history",e,t,n],queryFn:async({pageParam:r})=>{const o="",{data:a}=await O.get(`/project/team/${e}/tabs-history?page=${r}&size=${t}${o}`);return a},select:({pages:r})=>r.flatMap(o=>o.data),enabled:!!e,initialPageParam:0,getNextPageParam:(r,o)=>{if(r.hasMore)return o.length},staleTime:0}),Ml=(e,t="",n=20)=>So({queryKey:["project","saved-queries",e,t,n],queryFn:async({pageParam:r})=>{const o=new URLSearchParams;o.set("nameFilter",t),o.set("size",n.toString()),o.set("page",r.toString());const{data:a}=await O.get(`/project/team/${e}/queries?${o.toString()}`);return a},enabled:!!e,initialPageParam:0,select:({pages:r})=>r.flatMap(o=>o.data),getNextPageParam:(r,o)=>{if(r.hasMore)return o.length}}),$l=(e,t=10,n=!1)=>ce({queryKey:["project","recent-tabs",e,t,n],queryFn:async()=>{const{data:r}=await O.get(`/project/team/${e}/tabs-history?page=0&size=${t}&archived=${n}`);return r.data},enabled:!!e,staleTime:0}),Dl=e=>X({mutationFn:async()=>{const{data:t}=await O.get(`/project/team/${e}/tabs-history?page=0&size=1&archived=false`);return t.data?.length?t.data[0]:void 0}}),Fl=e=>ce({queryKey:["project","count-saved-queries",e],queryFn:async()=>{const{data:t}=await O.get(`/project/team/${e}/count-saved-queries`);return t.data}}),ql=()=>Promise.all([K.invalidateQueries({queryKey:["project","tabs-history"]}),K.invalidateQueries({queryKey:["project","recent-tabs"]})]),Eo=()=>K.invalidateQueries({queryKey:["project","count-saved-queries"]}),Bl=(e,t)=>{},Ul=()=>{},Wl={event:Bl,pageView:Ul},is=e=>ce({queryKey:[it,e],queryFn:async()=>{const{data:t}=await O.get("/data-sources/"+e);return t.data},enabled:!!e}),Ys=e=>ce({queryKey:[it,e.teamId],queryFn:async()=>{const{data:t}=await O.get("/data-sources",{params:e});return t.data},enabled:e.teamId!==void 0}),Sn=e=>ce({queryKey:[it,e,"inspections"],queryFn:async()=>{const{data:t}=await O.get(`/data-sources/${e}/inspections`);return t.data},enabled:!!e}),Hl=()=>X({mutationFn:async e=>{const{data:t}=await O.post("/data-sources",e);return t.data},onSuccess:()=>{K.invalidateQueries({queryKey:[it]}),Gt()},onError:()=>{}}),zl=()=>X({mutationFn:async({dataSource:e,id:t})=>{const{data:n}=await O.put(`/data-sources/${t}`,e);return n.data},onSuccess:()=>{K.invalidateQueries({queryKey:[it]}),Gt()}}),Ro=()=>X({mutationFn:async e=>{await O.post(`/data-sources/${e}/inspect`)},onSuccess:()=>{K.invalidateQueries({queryKey:[it]})}}),Kl=()=>X({mutationFn:async e=>{await O.delete(`/data-sources/${e}`)},onSuccess:()=>{K.invalidateQueries({queryKey:[it]}),Gt()}}),To=()=>ce({queryKey:["accessToken"],queryFn:Us.get}),ue=()=>{const{data:e}=To();return ce({queryKey:[ko],queryFn:async()=>{const{data:t}=await O.get("/users");return t.data},enabled:!!e,retry:(t,n)=>Da(n)&&n.code==="ERR_NETWORK"?!1:t<3})},Ql=()=>X({mutationFn:async e=>{const{data:t}=await O.patch("/users",e);return t.data},onSuccess:async e=>{K.setQueryData([ko],e)}}),Vl=()=>X({mutationFn:async e=>(await O.post("/users",e),!0),onSuccess:()=>{K.invalidateQueries({queryKey:["team-users"]})}}),je=e=>{const t=new Set;let n=e;const r=u=>(t.add(u),()=>t.delete(u)),o=u=>(t.forEach(c=>c(u)),!0),a=u=>{n=typeof u=="function"?u(n):u,o(n)},i=u=>()=>u?u(n):n;return[u=>l.useSyncExternalStore(r,i(u),i(u)),a,{get:()=>n,subscribe:u=>(u(n),r(u))}]};function Yl(e){const t=[];for(const n of e)for(const r of n.columns)r.ref&&(t.push({id:`${n.tableName}->${r.ref.table}.${r.ref.field}`,name:`${n.tableName} in ${r.ref.table}`,where:`${n.tableName}.${r.name} = ${r.ref.table}.${r.ref.field}`,on:{fromTable:r.ref.table,toTable:n.tableName,fromColumn:r.ref.field,toColumn:r.name}}),t.push({id:`${r.ref.table}->${n.tableName}.${r.name}`,name:`${r.ref.table} in ${n.tableName}`,where:`${r.ref.table}.${r.ref.field} = ${n.tableName}.${r.name}`,on:{fromTable:n.tableName,toTable:r.ref.table,fromColumn:r.name,toColumn:r.ref.field}}));return t}const Gl=e=>ce({queryKey:["hooks",e],queryFn:async()=>{const t=await K.fetchQuery({queryKey:[it,e,"inspections"],queryFn:async()=>{const{data:n}=await O.get(`/data-sources/${e}/inspections`);return n.data}});return Yl(t)},enabled:!!e}),Lo=[{value:"=",label:"equals"},{value:"<>",label:"not equal"},{value:">",label:"greater than"},{value:">=",label:"greater than or equal"},{value:"<",label:"less than"},{value:"<=",label:"less than or equal"},{value:"LIKE",label:"contains"},{value:"NOT LIKE",label:"not contains"},{value:"IN",label:"in list"},{value:"NOT IN",label:"not in list"},{value:"IS NULL",label:"is null"},{value:"IS NOT NULL",label:"is not null"}],Jl=Lo.reduce((e,t)=>(e[t.value]=t.label,e),{});Lo.reduce((e,t)=>(e[t.label]=t.value,e),{});const Jt=e=>e.map(t=>({label:Jl[t],value:t}));Jt(["=","<>",">",">=","<","<=","IN","NOT IN","IS NULL","IS NOT NULL"]);Jt(["=","<>","LIKE","NOT LIKE","IN","NOT IN","IS NULL","IS NOT NULL"]);Jt(["=","<>","IS NULL","IS NOT NULL"]);Jt(["=","<>",">",">=","<","<=","IS NULL","IS NOT NULL"]);Jt(["IS NULL","IS NOT NULL"]);Jt(["IN","NOT IN"]);const Xl=["char","varchar","binary","varbinary","blob","text","enum","set","character","character varying","text","citext","uuid","xml","json","jsonb"],Zl=new Set(Xl),ec=e=>Zl.has(e),tc=["integer","smallint","decimal","numeric","float","real","double precision","int","smallint","integer","bigint","decimal","numeric","real","double precision","serial","bigserial","money"],nc=new Set(tc),sc=e=>nc.has(e),rc=["date","datetime","timestamp","timestamptz"].reduce((e,t)=>(e[t]=!0,e),{}),Ao=e=>e.fn?e.distinct===!0?`${e.fn} distinct ${e.value}`:`${e.fn} ${e.value}`:e.value;var he=(e=>(e.OWNER="owner",e.ADMIN="admin",e.EDITOR="editor",e.READ_ONLY="read_only",e))(he||{});const Tr={[he.READ_ONLY]:10,[he.EDITOR]:20,[he.ADMIN]:30,[he.OWNER]:40},Je=e=>e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e,oc={operator:"LIKE",parse:e=>{const t=e.match(/^LIKE\s*["'](.*)["']$/i);if(t)return[{value:Je(t[1])}]},stringify:(e,t)=>ec(t)?`${e.value?.[0].value}`:`LIKE "%${e.value?.[0].value}%"`},ac={operator:"NOT LIKE",parse:e=>{const t=e.match(/^NOT LIKE\s*["'](.*)["']$/i);if(t)return[{value:Je(t[1])}]},stringify:e=>`NOT LIKE "%${e.value?.[0].value}%"`};function Po(e){return e===""?[]:ic(e).map(lc)}function ic(e){const t=[];let n=0,r="",o=!1,a=!1;for(;n<e.length;){const i=e[n];if((o||a)&&i==="\\"){r+=e[n+1],n+=2;continue}if(i==="'"&&!a){o=!o,r+=i,n++;continue}if(i==='"'&&!o){a=!a,r+=i,n++;continue}if(i===","&&!o&&!a){t.push(r.trim()),r="",n++;continue}r+=i,n++}if(r.trim()!==""&&t.push(r.trim()),o||a)throw new Error("Unterminated string literal");return t}function lc(e){if(e.startsWith("'")&&e.endsWith("'"))return{value:Lr(e.slice(1,-1),"'")};if(e.startsWith('"')&&e.endsWith('"'))return{value:Lr(e.slice(1,-1),'"')};const t=Number(e);if(!Number.isNaN(t))return{value:t};throw new Error(`Invalid literal: ${e}`)}function Lr(e,t){return e.replace(/\\(.)/g,(n,r)=>r)}const cc={operator:"IN",parse:e=>{const t=e.match(/^in\s*\((.*)\)$/i);if(t)return Po(t[1])},stringify:e=>`IN (${e.value?.map(t=>`"${t.value}"`).join(", ")})`},uc={operator:"NOT IN",parse:e=>{const t=e.match(/^not\s+in\s*\((.*)\)$/i);if(t)return Po(t[1])},stringify:e=>`NOT IN (${e.value?.map(t=>`"${t.value}"`).join(", ")})`},dc={operator:"=",parse:e=>{const t=e.match(/^=\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:(e,t)=>sc(t)?`${e.value?.[0].value}`:`= ${e.value?.[0].value}`},hc={operator:"!=",parse:e=>{const t=e.match(/^!=\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`!= ${e.value?.[0].value}`},fc={operator:"<>",parse:e=>{const t=e.match(/^<>\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`<> ${e.value?.[0].value}`},mc={operator:">",parse:e=>{const t=e.match(/^>\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`> ${e.value?.[0].value}`},pc={operator:">=",parse:e=>{const t=e.match(/^>=\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`>= ${e.value?.[0].value}`},xc={operator:"<",parse:e=>{const t=e.match(/^<\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`< ${e.value?.[0].value}`},gc={operator:"<=",parse:e=>{const t=e.match(/^<=\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`<= ${e.value?.[0].value}`},bc={operator:"IS NULL",parse:e=>{if(/^is\s+null$/i.test(e))return[]},stringify:()=>"IS NULL"},yc={operator:"IS NOT NULL",parse:e=>{if(/^is\s+not\s+null$/i.test(e))return[]},stringify:()=>"IS NOT NULL"},vc=[oc,ac,cc,uc,dc,hc,fc,pc,mc,gc,xc,bc,yc];vc.reduce((e,t)=>(e[t.operator]=t,e),{});function wc(e,t){if(!e||!t)return{};const n=new Set;for(const o of t)o.table&&n.add(o.table);const r={};for(const o of n){const a=e.find(i=>i.tableName===o);if(a){r[o]=[];const i=a.columns.filter(u=>u.isPrimary);for(const u of i)if(t.find(d=>d.table===o&&d.column===u.name))r[o].push(u.name);else{delete r[o];break}}}return r}function Cc(e,t,n,r){const{data:o}=Gl(t),{data:a}=Sn(t);return l.useMemo(()=>{const i=wc(a,e?.result.columns);return{name:n,tabId:r,hooks:(()=>{const u=[];if(!o||!e||!e.result.columns)return u;for(const c of o)(e.result.tables.includes(c.on.toTable)||e.result.tables.includes(c.on.fromTable))&&u.push(c);return u})(),availableJoins:(()=>{const u=[];if(!o||!e||!e.result.columns)return u;for(const c of o)!e.result.tables.includes(c.on.toTable)&&e.result.tables.includes(c.on.fromTable)&&u.push(c);return u})(),allColumns:e?.result.allColumns||[],dataSourceId:t,entities:Object.keys(i),getValue:(u,c)=>{const d=Ao(c),f=e?.result.columns?.findIndex(h=>h.full===d);if(f!=null&&f>-1)return u[f]},getEntityKey:(u,c)=>i[u].reduce((d,f)=>{const h=e?.result.columns?.findIndex(p=>p.column===f&&p.table===u);return h!=null&&h>-1&&d.push([f,c[h]]),d},[]),getEntityKeyByRowIndex:(u,c)=>i[u].reduce((d,f)=>{const h=e?.result.columns?.findIndex(p=>p.column===f&&p.table===u);return h!=null&&h>-1&&d.push([f,e?.result.rows[c][h]]),d},[]),getColumnType:u=>{const c=e?.result.allColumns.find(d=>d.full===u);if(c)return c.type}}},[e,t,o,a,n])}function jc(e,t){return l.useMemo(()=>({state:e,setState:t}),[e,t])}function Xt(e){return{dataSourceId:e.dataSourceId||"",page:e?.page||0,size:e?.size||50,table:e.table||"",filters:e?.filters||[],joins:e?.joins??[],orderBy:e?.orderBy??[],columns:e?.columns??[],groupBy:e?.groupBy??[],aggregations:e?.aggregations??[]}}function Nc(e,t){return{name:e,path:t,build:o=>{if(typeof o=="object"){let a=t;for(const[i,u]of Object.entries(o))a=a.replace(":"+i,u);return a}return t},check:o=>!!Wt({path:t,end:!0},o)}}function kn(e,t){return{name:e,path:t,build:()=>t,check:n=>n===t}}const _c=kn("Home","/"),Sc=kn("Workbench","/workbench"),kc=kn("Share query","/share"),Ec=kn("Login","/login"),Rc=kn("Saved queries","/saved-queries"),Tc=Nc("Workbench tab","/workbench/tab/:id"),I={home:_c,workbench:Sc,share:kc,login:Ec,savedQueries:Rc,workbenchTab:Tc},Gs=e=>{K.setQueryData(["workbench-tabs"],t=>e(t||[]))},Lc=(e,t)=>{K.setQueryData(["workbench-tabs",e],n=>n&&t(n))},ls=()=>ce({queryKey:["workbench-tabs"],queryFn:async()=>{const{data:e}=await O.get("/workbench-tabs");return e.data}}),Ac=e=>ce({queryKey:["workbench-tabs",e],queryFn:async()=>{const{data:t}=await O.get(`/workbench-tabs/${e}`);return t.data}}),Zt=()=>X({mutationFn:async e=>{const{data:t}=await O.post("/workbench-tabs",e);return t.data},onSuccess:async e=>{Gs(t=>[...t,e])}}),Pc=()=>X({mutationFn:async e=>(await O.patch(`/workbench-tabs/${e}`,{archived:!0}),e),onMutate:e=>{Gs(t=>t.filter(n=>n.id!==e))}}),Io=()=>X({mutationFn:async e=>(await O.patch(`/workbench-tabs/${e}`,{archived:!1}),e),onSuccess:()=>Mo()}),Ic=()=>X({mutationFn:async({id:e,payload:t})=>(await O.patch(`/workbench-tabs/${e}`,t),!0),onMutate:({id:e,payload:t})=>{Lc(e,n=>({...n,...t})),Gs(n=>n.map(r=>r.id!==e?r:{...r,name:t.name||r.name}))}}),Oc=(e,t)=>{const{dataSourceId:n,searchAll:r,table:o,filters:a,joins:i,orderBy:u,groupBy:c,columns:d,aggregations:f,page:h=0,size:p=20}=t;return ce({queryKey:["workbench-tab-runner",e,n,o,h,p,a,f,i,u,c,d,r],queryFn:async()=>{const{data:b}=await O.post(`/workbench-tabs/${e}/run`,t);return b.data},retry:1,enabled:!!o&&!!n,placeholderData:Fa})},Mc=()=>X({mutationFn:async e=>{await O.delete(`/workbench-tabs/${e}`)},onSuccess:()=>{Mo(),ql()}}),Oo=e=>K.invalidateQueries({queryKey:["workbench-tab-runner",e]}),Mo=()=>K.invalidateQueries({queryKey:["workbench-tabs"]}),[$c,Cs,Dc]=je(void 0),Fc=async()=>new Promise(e=>{Cs({onCancel:()=>{Cs(void 0),e(void 0)},onConfirm:(t,n,r)=>{Cs(void 0),e({dsId:r,id:n,type:t})}})}),En=e=>{const t=V(),n=Zt(),r=Io();return l.useEffect(()=>{n?.data?.id&&t(I.workbenchTab.build({id:n.data.id})),r?.data&&t(I.workbenchTab.build({id:r.data}))},[n.data,r.data]),l.useCallback(()=>{Dc.get()||Fc().then(a=>{a?.type==="table"?n.mutate({name:a.id,opts:Xt({table:a.id,dataSourceId:a.dsId})}):a?.type==="query"?n.mutate({queryId:a.id}):a?.type==="tab"&&r.mutate(a.id)})},[t,e])},Rn=e=>{const{data:t}=ue();return l.useMemo(()=>t?Tr[t.teamRole]>=Tr[e]:!1,[t,e])},qc="_input_19aly_2",Bc="_label_19aly_2",Uc="_content_19aly_2",Wc="_form_19aly_2",Hc="_mode-select_19aly_2",vt={input:qc,label:Bc,content:Uc,form:Wc,switch:"_switch_19aly_2",modeSelect:Hc},zc="_modal_1v20w_2",Kc="_modal-visible_1v20w_2",Qc="_modal-invisible_1v20w_2",Vc="_backdrop_1v20w_2",Yc="_modal-container_1v20w_2",Gc="_close-button_1v20w_2",Bt={modal:zc,modalVisible:Kc,modalInvisible:Qc,backdrop:Vc,modalContainer:Yc,closeButton:Gc},jt=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M368 368L144 144M368 144L144 368"})),ge=({children:e,backdropClose:t,isVisible:n,onClose:r,onClosed:o,noPadding:a=!1,portal:i=!1})=>{const[u,c]=l.useState(!1),d=()=>{t&&r()},f=p=>{n||getComputedStyle(p.currentTarget).opacity==="0"&&(c(!1),o&&o())};l.useEffect(()=>{n&&c(!0)},[n]);const h=s.jsxs("div",{onTransitionEnd:f,className:P(Bt.modal,n?Bt.modalVisible:Bt.modalInvisible),children:[s.jsx("div",{onClick:d,className:Bt.backdrop}),s.jsx("div",{className:P(Bt.modalContainer,a!==!0&&"p-4"),children:u&&e})]});return i?vo.createPortal(h,document.body):h},lt=({onClick:e})=>{const t=l.useRef(e);return t.current=e,l.useEffect(()=>{const n=r=>{r.key==="Escape"&&t.current?.()};return window.addEventListener("keyup",n),()=>{window.removeEventListener("keyup",n)}},[]),s.jsx("button",{className:Bt.closeButton,onClick:e,children:s.jsx(jt,{width:20,height:20})})},$o=({children:e})=>s.jsx("h2",{className:"text-xl font-semibold",children:e}),Jc=({form:e,change:t,shape:n})=>s.jsx("div",{className:vt.form,children:n.fields.map(r=>s.jsxs("label",{className:vt.input,children:[s.jsx("p",{className:vt.label,children:r.label}),s.jsx("input",{value:e[r.name],onChange:t(r.name),type:r.type})]},r.name))}),$t=[{label:"PostgreSQL",tag:"postgres"},{label:"MySQL",tag:"mysql"}],Xc={fields:[{label:"Database URL",name:"dbUrl",type:"text"},{label:"Database port",name:"dbPort",type:"number"},{label:"Username",name:"dbUser",type:"text"},{label:"Password",name:"dbPassword",type:"password"},{label:"Database",name:"dbDatabase",type:"text"}]},Zc={fields:[{label:"Database URL",name:"dbUrl",type:"text"},{label:"Database port",name:"dbPort",type:"number"},{label:"Username",name:"dbUser",type:"text"},{label:"Password",name:"dbPassword",type:"password"},{label:"Database",name:"dbDatabase",type:"text"},{label:"Schema",name:"dbSchema",type:"text"}]},eu=({show:e,onClose:t,dbType:n="postgres"})=>{const r=Hl(),o=Ro(),{data:a}=ue(),[i,{change:u,set:c}]=Cn({name:"",dbType:n,dbUrl:"",dbUser:"",dbPassword:"",dbDatabase:"",dbSchema:"",dbPort:5432,teamId:"",ownerId:"",description:"",allowInsert:!1,allowUpdate:!1}),d=async()=>{const x=await r.mutateAsync({...i,dbPort:Number(i.dbPort),teamId:a.teamId,ownerId:a.id});await o.mutateAsync(x.id),t(),Wl.event("Create Datasource",{dbType:i.dbType})},f=x=>{c("allowInsert",!x),c("allowUpdate",!x)},h=()=>{t()},p=r.isPending||o.isPending,b=!i.allowInsert&&!i.allowUpdate;return s.jsxs(ge,{isVisible:e,onClose:h,portal:!0,children:[s.jsxs("div",{className:"max-w-xl mx-auto overflow-y-auto",children:[r.isError&&s.jsx(ne,{variant:"danger",className:"mb-2",children:s.jsx("span",{children:"Failed to connect to the database. Please check if the data are correct and retry."})}),r.isPending&&s.jsx(ne,{className:"mb-2",variant:"info",children:"Creating connection"}),o.isPending&&s.jsx(ne,{className:"mb-2",variant:"info",children:"Inspecting connection"}),s.jsxs("div",{className:vt.switch,children:[s.jsxs("label",{className:"button tertiary",children:[s.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:i.dbType===$t[0].tag,onChange:()=>c("dbType",$t[0].tag)}),s.jsx("span",{children:$t[0].label})]}),s.jsxs("label",{className:"button tertiary",children:[s.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:i.dbType===$t[1].tag,onChange:()=>c("dbType",$t[1].tag)}),s.jsx("span",{children:$t[1].label})]})]}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("div",{className:vt.content,children:[s.jsx(Jc,{form:i,change:u,shape:i.dbType==="mysql"?Xc:Zc}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("label",{className:"text-sm font-semibold",children:"Name"}),s.jsx("input",{value:i.name,onChange:u("name"),className:"input"})]})]}),s.jsxs("div",{className:"mt-4",children:[s.jsxs("label",{className:vt.modeSelect,children:[s.jsxs("div",{children:[s.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:b,onChange:()=>f(!0)}),s.jsx("span",{className:"text-sm font-semibold",children:"Production mode"})]}),s.jsxs("p",{className:"text-xs mt-1 text-gray-600",children:["Mutation operations (such as INSERT or UPDATE) are ",s.jsx("strong",{children:"forbidden"}),". You won't be able to insert new rows or edit existing data. Tables in this data source are read-only."]})]}),s.jsxs("label",{className:vt.modeSelect,children:[s.jsxs("div",{children:[s.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:!b,onChange:()=>f(!1)}),s.jsx("span",{className:"text-sm font-semibold",children:"Dev mode"})]}),s.jsxs("p",{className:"text-xs mt-1 text-gray-600",children:["Mutation operations (such as INSERT or UPDATE) are ",s.jsx("strong",{children:"allowed"}),". You will be able to insert new rows and edit existing data."]})]})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-1 mt-2",children:[s.jsx("button",{onClick:h,className:"button tertiary",disabled:p,children:"Cancel"}),s.jsx("button",{onClick:d,className:"button primary",disabled:p,children:"Create"})]})]})},tu="_data-source-entry_24p01_2",nu="_action-title_24p01_2",su="_action-subtext_24p01_2",ru="_dev-tag_24p01_2",ou="_prod-tag_24p01_2",au="_recent-tabs-container_24p01_2",iu="_recent-tabs-entry_24p01_2",lu="_home-action-button_24p01_2",cu="_home-gray-card_24p01_2",uu="_home-card-title_24p01_2",du="_home-card-grid-content_24p01_2",$={dataSourceEntry:tu,actionTitle:nu,actionSubtext:su,devTag:ru,prodTag:ou,recentTabsContainer:au,recentTabsEntry:iu,homeActionButton:lu,homeGrayCard:cu,homeCardTitle:uu,homeCardGridContent:du},hu=e=>l.createElement("svg",{fill:"#000000",width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"m24.129 23.412-.508-.484c-.251-.331-.518-.624-.809-.891l-.005-.004q-.448-.407-.931-.774-.387-.266-1.064-.641c-.371-.167-.661-.46-.818-.824l-.004-.01-.048-.024c.212-.021.406-.06.592-.115l-.023.006.57-.157c.236-.074.509-.122.792-.133h.006c.298-.012.579-.06.847-.139l-.025.006q.194-.048.399-.109t.351-.109v-.169q-.145-.217-.351-.496c-.131-.178-.278-.333-.443-.468l-.005-.004q-.629-.556-1.303-1.076c-.396-.309-.845-.624-1.311-.916l-.068-.04c-.246-.162-.528-.312-.825-.435l-.034-.012q-.448-.182-.883-.399c-.097-.048-.21-.09-.327-.119l-.011-.002c-.117-.024-.217-.084-.29-.169l-.001-.001c-.138-.182-.259-.389-.355-.609l-.008-.02q-.145-.339-.314-.651-.363-.702-.702-1.427t-.651-1.452q-.217-.484-.399-.967c-.134-.354-.285-.657-.461-.942l.013.023c-.432-.736-.863-1.364-1.331-1.961l.028.038c-.463-.584-.943-1.106-1.459-1.59l-.008-.007c-.509-.478-1.057-.934-1.632-1.356l-.049-.035q-.896-.651-1.96-1.282c-.285-.168-.616-.305-.965-.393l-.026-.006-1.113-.278-.629-.048q-.314-.024-.629-.024c-.148-.078-.275-.171-.387-.279-.11-.105-.229-.204-.353-.295l-.01-.007c-.605-.353-1.308-.676-2.043-.93l-.085-.026c-.193-.113-.425-.179-.672-.179-.176 0-.345.034-.499.095l.009-.003c-.38.151-.67.458-.795.84l-.003.01c-.073.172-.115.371-.115.581 0 .368.13.705.347.968l-.002-.003q.544.725.834 1.14.217.291.448.605c.141.188.266.403.367.63l.008.021c.056.119.105.261.141.407l.003.016q.048.206.121.448.217.556.411 1.14c.141.425.297.785.478 1.128l-.019-.04q.145.266.291.52t.314.496c.065.098.147.179.241.242l.003.002c.099.072.164.185.169.313v.001c-.114.168-.191.369-.217.586l-.001.006c-.035.253-.085.478-.153.695l.008-.03c-.223.666-.351 1.434-.351 2.231 0 .258.013.512.04.763l-.003-.031c.06.958.349 1.838.812 2.6l-.014-.025c.197.295.408.552.641.787.168.188.412.306.684.306.152 0 .296-.037.422-.103l-.005.002c.35-.126.599-.446.617-.827v-.002c.048-.474.12-.898.219-1.312l-.013.067c.024-.063.038-.135.038-.211 0-.015-.001-.03-.002-.045v.002q-.012-.109.133-.206v.048q.145.339.302.677t.326.677c.295.449.608.841.952 1.202l-.003-.003c.345.372.721.706 1.127 1.001l.022.015c.212.162.398.337.566.528l.004.004c.158.186.347.339.56.454l.01.005v-.024h.048c-.039-.087-.102-.157-.18-.205l-.002-.001c-.079-.044-.147-.088-.211-.136l.005.003q-.217-.217-.448-.484t-.423-.508q-.508-.702-.969-1.467t-.871-1.555q-.194-.387-.375-.798t-.351-.798c-.049-.099-.083-.213-.096-.334v-.005c-.006-.115-.072-.214-.168-.265l-.002-.001c-.121.206-.255.384-.408.545l.001-.001c-.159.167-.289.364-.382.58l-.005.013c-.141.342-.244.739-.289 1.154l-.002.019q-.072.641-.145 1.318l-.048.024-.024.024c-.26-.053-.474-.219-.59-.443l-.002-.005q-.182-.351-.326-.69c-.248-.637-.402-1.374-.423-2.144v-.009c-.009-.122-.013-.265-.013-.408 0-.666.105-1.308.299-1.91l-.012.044q.072-.266.314-.896t.097-.871c-.05-.165-.143-.304-.265-.41l-.001-.001c-.122-.106-.233-.217-.335-.335l-.003-.004q-.169-.244-.326-.52t-.278-.544c-.165-.382-.334-.861-.474-1.353l-.022-.089c-.159-.565-.336-1.043-.546-1.503l.026.064c-.111-.252-.24-.47-.39-.669l.006.008q-.244-.326-.436-.617-.244-.314-.484-.605c-.163-.197-.308-.419-.426-.657l-.009-.02c-.048-.097-.09-.21-.119-.327l-.002-.011c-.011-.035-.017-.076-.017-.117 0-.082.024-.159.066-.223l-.001.002c.011-.056.037-.105.073-.145.039-.035.089-.061.143-.072h.002c.085-.055.188-.088.3-.088.084 0 .165.019.236.053l-.003-.001c.219.062.396.124.569.195l-.036-.013q.459.194.847.375c.298.142.552.292.792.459l-.018-.012q.194.121.387.266t.411.291h.339q.387 0 .822.037c.293.023.564.078.822.164l-.024-.007c.481.143.894.312 1.286.515l-.041-.019q.593.302 1.125.641c.589.367 1.098.743 1.577 1.154l-.017-.014c.5.428.954.867 1.38 1.331l.01.012c.416.454.813.947 1.176 1.464l.031.047c.334.472.671 1.018.974 1.584l.042.085c.081.154.163.343.234.536l.011.033q.097.278.217.57.266.605.57 1.221t.57 1.198l.532 1.161c.187.406.396.756.639 1.079l-.011-.015c.203.217.474.369.778.422l.008.001c.368.092.678.196.978.319l-.047-.017c.143.065.327.134.516.195l.04.011c.212.065.396.151.565.259l-.009-.005c.327.183.604.363.868.559l-.021-.015q.411.302.822.57.194.145.651.423t.484.52c-.114-.004-.249-.007-.384-.007-.492 0-.976.032-1.45.094l.056-.006c-.536.072-1.022.203-1.479.39l.04-.014c-.113.049-.248.094-.388.129l-.019.004c-.142.021-.252.135-.266.277v.001c.061.076.11.164.143.26l.002.006c.034.102.075.19.125.272l-.003-.006c.119.211.247.393.391.561l-.004-.005c.141.174.3.325.476.454l.007.005q.244.194.508.399c.161.126.343.25.532.362l.024.013c.284.174.614.34.958.479l.046.016c.374.15.695.324.993.531l-.016-.011q.291.169.58.375t.556.399c.073.072.137.152.191.239l.003.005c.091.104.217.175.36.193h.003v-.048c-.088-.067-.153-.16-.184-.267l-.001-.004c-.025-.102-.062-.191-.112-.273l.002.004zm-18.576-19.205q-.194 0-.363.012c-.115.008-.222.029-.323.063l.009-.003v.024h.048q.097.145.244.326t.266.351l.387.798.048-.024c.113-.082.2-.192.252-.321l.002-.005c.052-.139.082-.301.082-.469 0-.018 0-.036-.001-.054v.003c-.045-.044-.082-.096-.108-.154l-.001-.003-.081-.182c-.053-.084-.127-.15-.214-.192l-.003-.001c-.094-.045-.174-.102-.244-.169z"})),fu=e=>l.createElement("svg",{width:"800px",height:"800px",viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("title",null,"file_type_pgsql"),l.createElement("path",{d:"M29.507,18.773a1.378,1.378,0,0,0-1.144-.921,2.619,2.619,0,0,0-.913.051,8.2,8.2,0,0,1-1.406.185,27.125,27.125,0,0,0,2.872-6.83c.953-3.689.444-5.369-.151-6.13A8.239,8.239,0,0,0,22.121,2a11.773,11.773,0,0,0-3.453.484A12.858,12.858,0,0,0,16.648,2.3a6.565,6.565,0,0,0-3.518.867,16.039,16.039,0,0,0-2.484-.624,7.694,7.694,0,0,0-5.819.924C3.093,4.691,2.289,6.819,2.438,9.792A36.351,36.351,0,0,0,3.844,16.33a22.579,22.579,0,0,0,1.514,3.863A4.786,4.786,0,0,0,7.8,22.742a2.4,2.4,0,0,0,2.379-.516,2.08,2.08,0,0,0,.5.43,3.328,3.328,0,0,0,.944.4,5.069,5.069,0,0,0,3.3-.2c.006.171.011.335.014.477.006.229.013.454.021.665a11.641,11.641,0,0,0,.441,3.3c.016.043.037.107.059.176a3.975,3.975,0,0,0,.991,1.745,2.955,2.955,0,0,0,2.09.777,4.7,4.7,0,0,0,.977-.109A4.592,4.592,0,0,0,22.607,28.1c.811-1.155,1.206-2.894,1.277-5.635.009-.078.018-.152.026-.222l.017-.145.191.017.049,0a7.562,7.562,0,0,0,3.163-.548c.631-.293,2.654-1.361,2.177-2.8"}),l.createElement("path",{d:"M27.689,19.053c-3.163.652-3.38-.418-3.38-.418C27.648,13.68,29.044,7.39,27.839,5.851c-3.286-4.2-8.975-2.213-9.07-2.162l-.031.006a11.28,11.28,0,0,0-2.11-.22,5.212,5.212,0,0,0-3.34,1S3.14.294,3.612,9.733c.1,2.008,2.878,15.194,6.191,11.211,1.211-1.456,2.381-2.688,2.381-2.688a3.071,3.071,0,0,0,2.006.512l.057-.048a2.21,2.21,0,0,0,.023.567c-.854.954-.6,1.121-2.309,1.472-1.726.356-.712.989-.05,1.155a3.508,3.508,0,0,0,3.915-1.272l-.05.2c.334.268.569,1.742.53,3.079a8.481,8.481,0,0,0,.2,2.971c.264.717.526,2.329,2.769,1.849a3.307,3.307,0,0,0,2.98-3.179c.1-1.234.313-1.052.326-2.155l.174-.522c.2-1.673.032-2.213,1.186-1.962l.281.025a6.4,6.4,0,0,0,2.615-.44c1.406-.652,2.239-1.742.853-1.455h0",style:{fill:"#336791"}}),l.createElement("path",{d:"M13.882,10.631a.981.981,0,0,0-.674.1.247.247,0,0,0-.1.164.48.48,0,0,0,.117.314.881.881,0,0,0,.559.349.637.637,0,0,0,.09.006.725.725,0,0,0,.687-.467c.035-.248-.326-.414-.676-.463m9.442.008c-.027-.195-.374-.25-.7-.2s-.647.194-.62.389a.667.667,0,0,0,.62.411.592.592,0,0,0,.083-.006.8.8,0,0,0,.451-.247.5.5,0,0,0,.169-.343",style:{fill:"#fff"}}),l.createElement("path",{d:"M28.741,18.979c-.121-.365-.509-.482-1.154-.349-1.915.4-2.6.121-2.826-.044a26.327,26.327,0,0,0,3.373-7.565,14.374,14.374,0,0,0,.5-3.253,3.513,3.513,0,0,0-.509-2.2,7.482,7.482,0,0,0-6.049-2.825,10.363,10.363,0,0,0-3.5.551,8.717,8.717,0,0,0-1.968-.253,5.684,5.684,0,0,0-3.372.929,15.051,15.051,0,0,0-2.74-.718,6.978,6.978,0,0,0-5.242.805c-1.5,1.064-2.2,2.966-2.061,5.653a35.489,35.489,0,0,0,1.373,6.348c1.07,3.505,2.233,5.49,3.457,5.9a1.548,1.548,0,0,0,.491.081,2.049,2.049,0,0,0,1.563-.886q1.042-1.25,2.155-2.438a3.472,3.472,0,0,0,1.55.417l0,.042q-.14.166-.273.338c-.375.475-.452.574-1.658.823-.343.071-1.254.259-1.267.9-.014.7,1.077.991,1.2,1.022a5.144,5.144,0,0,0,1.249.162,3.634,3.634,0,0,0,2.5-.934,23.674,23.674,0,0,0,.381,5.684,2.854,2.854,0,0,0,2.729,2.1,4.378,4.378,0,0,0,.917-.1,3.462,3.462,0,0,0,3.156-3.212c.177-1.026.481-3.475.624-4.789a3.859,3.859,0,0,0,1.11.137,6.6,6.6,0,0,0,2.519-.48c.712-.331,2-1.141,1.763-1.846ZM24.051,10.1a7.968,7.968,0,0,1-.116,1.107,10.229,10.229,0,0,0-.14,1.3,9.859,9.859,0,0,0,.1,1.47,5.236,5.236,0,0,1-.229,2.986,3.882,3.882,0,0,1-.207-.426c-.058-.141-.185-.368-.359-.681-.68-1.22-2.274-4.078-1.458-5.244.243-.347.86-.7,2.408-.512ZM22.174,3.531a6.617,6.617,0,0,1,5.334,2.522c.975,1.245-.1,6.912-3.205,11.8l-.094-.119-.039-.049a5.524,5.524,0,0,0,.506-3.8,9.114,9.114,0,0,1-.1-1.352,9.572,9.572,0,0,1,.131-1.206,7.614,7.614,0,0,0,.123-1.493.619.619,0,0,0,.013-.21,8.381,8.381,0,0,0-1.912-3.6,8.61,8.61,0,0,0-3.039-2.284,10.246,10.246,0,0,1,2.28-.214ZM9.479,20.654c-.627.754-1.061.61-1.2.562-.928-.31-2.006-2.272-2.955-5.384a35.167,35.167,0,0,1-1.34-6.159c-.12-2.4.462-4.074,1.73-4.974,2.063-1.463,5.456-.587,6.819-.143-.02.019-.04.037-.059.057-2.237,2.259-2.184,6.119-2.178,6.355,0,.091.007.22.018.4a15.969,15.969,0,0,1-.081,3.226A4.08,4.08,0,0,0,11.3,18.007q.133.138.278.262c-.383.41-1.216,1.318-2.1,2.385Zm2.39-3.19a3.3,3.3,0,0,1-.865-2.764,16.7,16.7,0,0,0,.087-3.381c-.006-.095-.011-.178-.014-.243A4.3,4.3,0,0,1,14,10.223a1.188,1.188,0,0,1,.918,1.026c.646,2.989.085,4.234-.365,5.235-.093.206-.181.4-.255.6l-.058.156a10.218,10.218,0,0,0-.368,1.109,2.788,2.788,0,0,1-2-.887Zm.113,4.03a1.733,1.733,0,0,1-.523-.225,2.553,2.553,0,0,1,.557-.166c1.418-.292,1.637-.5,2.116-1.105.11-.139.234-.3.406-.489h0c.256-.287.374-.238.586-.15a.829.829,0,0,1,.408.525.585.585,0,0,1-.05.491A3.1,3.1,0,0,1,11.983,21.495ZM19.406,28.4a2.113,2.113,0,0,1-2.754-1.526,31.129,31.129,0,0,1-.3-6.853.392.392,0,0,0-.017-.124,1.643,1.643,0,0,0-.048-.23,1.589,1.589,0,0,0-.862-1.034,1.216,1.216,0,0,0-.793-.1,9.586,9.586,0,0,1,.342-1.022l.058-.157c.066-.177.148-.36.235-.554.471-1.047,1.117-2.482.416-5.722a2.044,2.044,0,0,0-2.468-1.669A5.694,5.694,0,0,0,11.328,10c-.078.04-.15.078-.216.115A8.244,8.244,0,0,1,13.03,5.163,4.711,4.711,0,0,1,16.6,3.827,7.567,7.567,0,0,1,22.381,6.59,8.774,8.774,0,0,1,23.963,9.3c-1.463-.149-2.458.14-2.962.861-1.1,1.568.6,4.612,1.416,6.075.15.268.279.5.319.6a5.432,5.432,0,0,0,.861,1.387c.077.1.152.189.208.271-.443.128-1.239.423-1.166,1.9-.058.74-.474,4.205-.686,5.43-.279,1.617-.874,2.22-2.548,2.579Zm7.242-8.288a5.714,5.714,0,0,1-1.931.4,2.422,2.422,0,0,1-1.3-.167c-.045-.919.3-1.015.66-1.117.057-.016.112-.032.166-.05a1.353,1.353,0,0,0,.11.08c.639.422,1.78.467,3.39.135l.018,0a4.334,4.334,0,0,1-1.116.72Z",style:{fill:"#fff"}})),ct=({size:e,type:t})=>t==="mysql"?s.jsx(hu,{width:e,height:e}):s.jsx(fu,{width:e,height:e}),[mu,Ht]=je(void 0),[pu,zt]=je({show:!1}),xu=()=>{const e=En("Home");return s.jsx("div",{className:$.homeActionButton,onClick:e,children:s.jsxs("h2",{className:$.actionTitle,children:[s.jsx("span",{className:"truncate",children:"🔎 Start new query"}),s.jsx("span",{className:"hotkey",children:"N"})]})})},gu=()=>{const e=V();return s.jsx("div",{className:$.homeActionButton,onClick:()=>e(I.savedQueries.build()),children:s.jsx("h2",{className:$.actionTitle,children:s.jsx("span",{className:"truncate",children:"💾 Saved queries"})})})},bu=()=>{const[e,t]=l.useState(void 0),n=Rn(he.EDITOR),r=o=>{n?t(o):Ce.error("You don't have permission to connect new data sources in this team")};return s.jsxs("div",{children:[e&&s.jsx(eu,{show:!0,dbType:e,onClose:()=>t(void 0)}),s.jsx("div",{className:$.homeActionButton,onClick:()=>r("postgres"),children:s.jsx("p",{className:$.actionTitle,children:"🧙‍♂️ Connection wizard"})})]})},yu=()=>{const e=V(),{data:t}=ls(),n=En("Home"),r=()=>{t&&t.length>0?e(I.workbenchTab.build({id:t[0].id})):n()};return s.jsx("div",{className:$.homeActionButton,onClick:r,children:s.jsxs("h2",{className:$.actionTitle,children:[s.jsx("span",{children:"🛠️ Workbench"}),s.jsx("span",{className:"hotkey",children:"W"})]})})},vu=()=>{const{data:e}=ue(),{data:t}=Ys({teamId:e?.teamId}),n=r=>{Ht(r)};return!t||t.length===0?null:s.jsxs("div",{className:$.homeGrayCard,children:[s.jsx("h2",{className:$.homeCardTitle,children:"Data sources"}),s.jsx("div",{className:$.homeCardGridContent,children:t?.map(r=>s.jsxs("div",{className:$.dataSourceEntry,onClick:()=>n(r.id),tabIndex:0,children:[s.jsx(ct,{size:32,type:r.dbType}),s.jsxs("div",{className:"overflow-hidden",children:[s.jsx("p",{className:$.actionTitle,children:r.name}),r.allowInsert?s.jsx("span",{className:$.devTag,children:"dev"}):s.jsx("span",{className:$.prodTag,children:"prod"})]})]},r.id))})]})},wu=()=>s.jsxs("div",{className:$.homeGrayCard,children:[s.jsx("h2",{className:$.homeCardTitle,children:"Useful links"}),s.jsxs("div",{className:$.homeCardGridContent,children:[s.jsxs("a",{className:$.homeActionButton,href:"https://dataramen.xyz/",target:"_blank",children:[s.jsx("h2",{className:$.actionTitle,children:"↗️ Documentation"}),s.jsx("p",{className:$.actionSubtext,children:"Learn how to use DataRamen"})]}),s.jsxs("a",{className:$.homeActionButton,href:"https://github.com/OleksandrDemian/dataramen",target:"_blank",children:[s.jsx("h2",{className:$.actionTitle,children:"↗️ Github"}),s.jsx("p",{className:$.actionSubtext,children:"Codebase is open source"})]}),s.jsxs("a",{className:$.homeActionButton,href:"#",onClick:()=>zt({show:!0}),children:[s.jsxs("h2",{className:$.actionTitle,children:[s.jsx("span",{children:"⌛ Recent tabs"}),s.jsx("span",{className:"hotkey",children:"H"})]}),s.jsx("p",{className:$.actionSubtext,children:"Manage recent tabs"})]})]})]}),Cu=()=>{const{data:e}=ue(),{data:t,isLoading:n}=$l(e?.teamId),r=V();if(n||!t?.length)return null;const o=a=>{r(I.workbenchTab.build({id:a}))};return s.jsxs("div",{className:$.recentTabsContainer,children:[s.jsx("h2",{className:$.homeCardTitle+" px-4 mb-4",children:"Recent tabs"}),t.map(a=>s.jsxs("div",{className:$.recentTabsEntry,onClick:()=>o(a.id),children:[s.jsx("p",{className:"text-(--text-color-primary) truncate",children:a.name}),s.jsxs("p",{className:"flex items-center gap-2",children:[s.jsx(ct,{size:20,type:a.dataSourceType}),s.jsx("span",{className:"text-sm text-(--text-color-secondary) truncate",children:a.dataSourceName})]})]},a.id))]})},ju=()=>{const{data:e}=ue(),{data:t}=Ys({teamId:e?.teamId}),n=!!t&&t.length>0,r=!!e;return s.jsx("div",{className:"page-container h-screen max-h-screen overflow-y-auto no-scrollbar",children:s.jsxs("div",{className:"page-content",children:[s.jsx("div",{className:"py-10 text-center w-full sticky top-0 z-0",children:s.jsx("h1",{className:"comfortaa text-3xl font-semibold text-(--text-color-primary)",children:"DataRamen"})}),s.jsxs("div",{className:"flex flex-col gap-8 mt-8 bg-(--bg) z-1",children:[r&&!n&&s.jsx(ne,{variant:"warning",className:"font-semibold",children:"Connect at least one data source to start using DataRamen"}),s.jsxs("div",{className:$.homeGrayCard,children:[s.jsx("h2",{className:$.homeCardTitle,children:"Quick actions"}),s.jsxs("div",{className:$.homeCardGridContent,children:[s.jsx(xu,{}),s.jsx(bu,{}),r&&s.jsx(yu,{}),s.jsx(gu,{})]})]}),r&&s.jsx(vu,{}),s.jsx(Cu,{}),s.jsx(wu,{})]})]})})},[Nu,Js]=je(void 0),_u=()=>Js(void 0);function wt(e,t){if(e==null)return"";switch(t){case"json":case"jsonb":return JSON.stringify(e,null,2)}if(e===0||e===!1)return e.toString();switch(typeof e){case"string":return e;case"number":case"boolean":return e.toString();default:return JSON.stringify(e)}}const Vn=e=>e.distinct?[e.fn,"DISTINCT",e.value].join(" "):[e.fn,e.value].join(" "),nt=e=>{let t=e.replace(/[_-]+/g," ");return t=t.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),t=t.toLowerCase().replace(/\b\w/g,n=>n.toUpperCase()),t},Su="_container_1wftp_2",ku="_header_1wftp_2",Eu="_fields-container_1wftp_2",Ru="_field-label_1wftp_2",Tu="_actions_1wftp_2",pn={container:Su,header:ku,fieldsContainer:Eu,fieldLabel:Ru,actions:Tu},Lu=(e,t,n)=>ce({queryKey:["entity",e,t,n],queryFn:async()=>{const{data:r}=await O.get(`/runner/${e}/entity/${t}`,{params:n?.reduce((o,a)=>(o[a[0]]=a[1],o),{})});return r.data},retry:1,enabled:!!t&&!!e&&!!n,staleTime:0}),Au=()=>X({mutationFn:async e=>{const{data:t}=await O.post(`/runner/${e.datasourceId}/update`,e);return t.data}}),Pu=()=>X({mutationFn:async e=>{const{data:t}=await O.post(`/runner/${e.datasourceId}/insert`,e);return t.data}}),Xs=e=>l.useMemo(()=>{if(e)return e instanceof qa?e.response?.data.error?e.response.data.error:e.response?.data?.message?e.response.data.message:e.message:e instanceof Error?e.message:"Undefined error"},[e]),Zs=()=>{const{pathname:e}=le();return l.useMemo(()=>Wt({path:I.workbenchTab.path,end:!1},e)?.params.id,[e])},Iu=({data:e})=>{const[t,{change:n,touched:r}]=Cn({}),o=Zs(),{mutateAsync:a,error:i}=Pu(),u=Xs(i),{data:c}=Sn(e.dataSourceId),[d,f]=l.useState(""),h=l.useMemo(()=>c?.find(x=>x.tableName===e.table),[c,e.table]),p=l.useMemo(()=>{if(!h)return[];if(!d)return h.columns.map(y=>({...y,label:nt(y.name)}));const x=d.toLowerCase();return h.columns.filter(y=>y.name.toLowerCase().includes(x)).map(y=>({...y,label:nt(y.name)}))},[d,h]),b=()=>{const x=[];for(const y of r)x.push({value:t[y],column:y});a({datasourceId:e.dataSourceId,table:e.table,values:x}).then(()=>{_u(),o&&Oo(o)})};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:pn.header,children:[s.jsxs("p",{className:"text-lg font-semibold",children:["Insert new row in ",s.jsx("span",{className:"underline",children:e.table})]}),u&&s.jsx(ne,{variant:"danger",children:s.jsx("p",{children:u})})]}),s.jsx("div",{className:"bg-gray-50 py-1 px-4 border-y border-gray-200",children:s.jsx("p",{className:"text-xs text-gray-800",children:"Tip: use = to write raw SQL. Ex: =NULL or =NOW()"})}),s.jsx("div",{className:pn.container,children:s.jsx("div",{className:pn.fieldsContainer,children:p.map(x=>s.jsxs("label",{className:pn.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsxs("p",{children:[x.isPrimary?"🔐":"🏷️"," ",x.label]}),s.jsxs("p",{className:"text-blue-800 text-sm",children:["[",x.name,": ",x.type,"]"]})]}),s.jsx("input",{className:"input w-full",value:wt(t[x.name]),onChange:n(x.name),placeholder:x.name})]},x.name))})}),s.jsxs("div",{className:pn.actions,children:[s.jsxs("label",{children:[s.jsx("span",{className:"mr-2",children:"🔎"}),s.jsx("input",{className:"input bg-white!",value:d,onChange:x=>f(x.target.value),placeholder:"Filter columns"})]}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{disabled:!r.length,className:"button primary",onClick:b,children:"Run insert"})]})]})},Ou=()=>{const e=Nu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const r=()=>Js(void 0);return s.jsxs(ge,{isVisible:e!=null,onClose:r,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(lt,{onClick:r}),t&&s.jsx(Iu,{data:t})]})},[Mu,cs]=je(void 0),$u=()=>cs(void 0),Du="_container_qodpr_2",Fu="_header_qodpr_2",qu="_key_qodpr_2",Bu="_fields-container_qodpr_2",Uu="_field-label_qodpr_2",Wu="_actions_qodpr_2",Dt={container:Du,header:Fu,key:qu,fieldsContainer:Bu,fieldLabel:Uu,actions:Wu},ot=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),Hu=({data:e})=>{const[t,{change:n,set:r,reset:o,touched:a}]=Cn({}),i=Zs(),[u,c]=l.useState(""),{data:d,isLoading:f}=Lu(e.dataSourceId,e.tableName,e.entityId),{mutateAsync:h,error:p}=Au(),b=Xs(p),x=Rn(he.EDITOR),{data:y}=Sn(e.dataSourceId),{data:v}=is(e.dataSourceId),g=l.useMemo(()=>y?.find(k=>k.tableName===e.tableName),[e.tableName,y]),m=l.useMemo(()=>{if(!g)return[];if(!u)return g.columns.map(j=>({...j,label:nt(j.name)}));const k=u.toLowerCase();return g.columns.filter(j=>j.name.toLowerCase().includes(k)).map(j=>({...j,label:nt(j.name)}))},[u,g]);l.useEffect(()=>{const k=d?.entity;if(o(),k&&d?.columns)for(let j=0;j<d.columns.length;j++){const _=d.columns[j];r(_.column,wt(k[j]))}},[d,r,o]);const w=()=>{const k=[];for(const j of a)k.push({value:t[j],column:j});h({datasourceId:e.dataSourceId,table:e.tableName,filters:e.entityId.map(j=>({id:ot(),value:[{value:j[1]}],column:j[0],connector:"AND",operator:"="})),values:k}).then(()=>{$u(),i&&Oo(i)})},C=e.entityId.map(([k,j])=>`${k} = ${j}`).join(", ")||"",S=!v?.allowUpdate||!x;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:Dt.header,children:[s.jsxs("p",{className:"text-lg font-semibold",children:[S?"View":"Edit"," row in ",s.jsx("span",{className:"underline",children:e?.tableName})]}),s.jsx("span",{className:Dt.key,children:C}),b&&s.jsx(ne,{variant:"danger",children:s.jsx("p",{children:b})})]}),!S&&s.jsx("div",{className:"bg-gray-50 py-1 px-4 border-y border-gray-200",children:s.jsx("p",{className:"text-xs text-gray-800",children:"Tip: use = to write raw SQL. Ex: =NULL or =NOW()"})}),s.jsx("div",{className:Dt.container,children:s.jsx("div",{className:Dt.fieldsContainer,children:m.map(k=>s.jsxs("label",{className:Dt.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsxs("p",{children:[k.isPrimary?"🔐":"🏷️"," ",k.label]}),s.jsxs("p",{className:"text-blue-800 text-sm",children:["[",k.name,": ",k.type,"]"]})]}),s.jsx("input",{disabled:k.isPrimary||f||S,className:"input w-full",value:wt(t[k.name]),onChange:n(k.name),placeholder:k.name})]},k.name))})}),s.jsxs("div",{className:Dt.actions,children:[s.jsxs("label",{children:[s.jsx("span",{className:"mr-2",children:"🔎"}),s.jsx("input",{className:"input bg-white!",value:u,onChange:k=>c(k.target.value),placeholder:"Filter columns"})]}),s.jsx("span",{className:"flex-1"}),!S&&s.jsx("button",{disabled:!a.length,className:"button primary",onClick:w,children:"Run update"})]})]})},zu=()=>{const e=Mu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const r=()=>cs(void 0);return s.jsxs(ge,{isVisible:e!=null,onClose:r,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(lt,{onClick:r}),t&&s.jsx(Hu,{data:t})]})},[Ku,js]=je(void 0),Do=async e=>new Promise(t=>{js({message:e,onCancel:()=>{t(!1),js(void 0)},onConfirm:()=>{t(!0),js(void 0)}})}),Qu=({confirm:e})=>s.jsxs("div",{children:[s.jsx("p",{children:e.message}),s.jsxs("div",{className:"flex gap-2 justify-end mt-4",children:[s.jsx("button",{className:"button tertiary",onClick:e.onCancel,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:e.onConfirm,children:"Confirm"})]})]}),Vu=()=>{const e=Ku(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(ge,{isVisible:!!e,onClose:()=>e?.onCancel(),onClosed:()=>n(void 0),children:t&&s.jsx(Qu,{confirm:t})})},[Yu,Yn]=je(void 0),Tn=async(e,t,n)=>new Promise(r=>{Yn({message:e,defaultValue:t,alert:n,onCancel:()=>{Yn(void 0),r(void 0)},onConfirm:o=>{Yn(void 0),r(o)}})}),Gu="_root_ng9lp_1",Ju={root:Gu},Xu=({data:e})=>{const[t,n]=l.useState("");l.useEffect(()=>{e.defaultValue&&n(e.defaultValue)},[e]);const r=a=>{n(a.target.value)},o=a=>{a.key==="Enter"&&(a.preventDefault(),e.onConfirm(t)),a.key==="Escape"&&(a.preventDefault(),e.onCancel())};return s.jsxs("div",{className:Ju.root,children:[s.jsx("h2",{className:"text-xl font-semibold",children:e.message}),e.alert&&s.jsx(ne,{variant:e.alert.type,className:"mt-2",children:e.alert.message}),s.jsx("input",{autoFocus:!0,className:"w-full input my-2",value:t,onChange:r,onKeyDown:o}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{className:"button tertiary",onClick:e.onCancel,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:()=>e.onConfirm(t),children:"Confirm"})]})]})},Zu=()=>{const e=Yu(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(ge,{isVisible:!!e,onClose:()=>Yn(void 0),onClosed:()=>n(void 0),children:t&&s.jsx(Xu,{data:t})})},[ed,td]=je(void 0),Fo=e=>{td(e)},nd="_textarea_khbcz_2",sd={textarea:nd},rd=()=>{const e=ed(),t=()=>{e&&(navigator.clipboard.writeText(e.toString()),Ce.success("Copied!"))},n=()=>Fo(void 0);return s.jsxs(ge,{isVisible:!!e,onClose:n,backdropClose:!0,children:[s.jsx("textarea",{className:sd.textarea,readOnly:!0,defaultValue:e?.toString()}),s.jsxs("div",{className:"mt-2 flex gap-1 justify-end",children:[s.jsx("button",{className:"button primary",onClick:t,children:"Copy"}),s.jsx("button",{className:"button tertiary",onClick:n,children:"Close"})]})]})},od="_tabs_1lmgk_2",ad="_mobile_1lmgk_2",id="_tab_1lmgk_2",ld="_active_1lmgk_2",cd="_close-button_1lmgk_2",xn={tabs:od,mobile:ad,tab:id,active:ld,closeButton:cd},Ar=e=>window.matchMedia(e).matches;function qo(e,{defaultValue:t=!1,initializeWithValue:n=!0}={}){const[r,o]=l.useState(()=>n?Ar(e):t);return l.useLayoutEffect(()=>{const a=window.matchMedia(e);function i(){o(()=>Ar(e))}return i(),a.addListener?a.addListener(i):a.addEventListener("change",i),()=>{a.removeListener?a.removeListener(i):a.removeEventListener("change",i)}},[e]),r}const er={laptop:"(min-width: 1024px)"},Bo=()=>window.matchMedia(er.laptop).matches,ud="_table_w2011_2",dd="_row-index-btn_w2011_2",hd="_semi-transparent_w2011_2",fd="_table-loading_w2011_2",md="_table-empty_w2011_2",pd="_table-row-cells_w2011_2",xd="_header-cell_w2011_2",gd="_header-actions_w2011_2",bd="_cell_w2011_2",yd="_value_w2011_2",vd="_table-config_w2011_2",wd="_table-action_w2011_2",Cd="_green-fixed_w2011_2",jd="_gray_w2011_2",Nd="_modal_w2011_2",_d="_selected-size_w2011_2",Sd="_pagination-indicator_w2011_2",E={table:ud,rowIndexBtn:dd,semiTransparent:hd,tableLoading:fd,tableEmpty:md,tableRowCells:pd,headerCell:xd,headerActions:gd,cell:bd,value:yd,tableConfig:vd,tableAction:wd,greenFixed:Cd,gray:jd,modal:Nd,selectedSize:_d,paginationIndicator:Sd},Be=l.createContext({name:"No name",hooks:[],availableJoins:[],allColumns:[],dataSourceId:"",entities:[],getValue:()=>{},getColumnType:()=>{},getEntityKey:()=>[],getEntityKeyByRowIndex:()=>[]}),fe=l.createContext({state:Xt({}),setState:()=>{}}),Le=l.createContext({}),Uo={ON_ANIMATION_END:Symbol("ON_TRANSITION_END")},Wo=()=>{const[e,t]=l.useState(),[n,r]=l.useState("hidden");return l.useMemo(()=>{const o=u=>{u.preventDefault(),r("in"),t({x:u.clientX-1,y:u.clientY-1})},a=()=>{r("out")},i=()=>{n==="in"?r("visible"):n==="out"&&(t(void 0),r("hidden"))};return{show:!!e,position:e,state:n,open:o,close:a,[Uo.ON_ANIMATION_END]:i}},[e,n])},kd=e=>{if(e==="ASC")return"DESC";if(e!=="DESC")return"ASC"},Ed=()=>{const{state:e,setState:t}=l.useContext(fe),n=l.useCallback(r=>{t(o=>{const a=o.orderBy[0];if(a&&a.column===r){const i=kd(a.direction);return i?{...o,orderBy:[{column:r,direction:i}]}:{...o,orderBy:[]}}return{...o,orderBy:[{column:r,direction:"ASC"}]}})},[t]);return{orderBy:e.orderBy,updateOrderBy:n}},Rd="_options-container_snswe_2",Td="_filter-input_snswe_2",Ld="_option-item_snswe_2",Ad="_list_snswe_2",Pd="_empty-text_snswe_2",Ve={optionsContainer:Rd,filterInput:Td,optionItem:Ld,list:Ad,emptyText:Pd},Id="_container_112a6_2",Od="_animate-show_112a6_2",Md="_animate-hide_112a6_2",$d="_content_112a6_2",Dd="_backdrop_112a6_2",pt={container:Id,animateShow:Od,animateHide:Md,content:$d,backdrop:Dd},Ho=({children:e,handler:t})=>{const n=l.useRef(t.close);n.current=t.close;const r=l.useMemo(()=>{if(!t.position)return;const o={};if(typeof window<"u"){const a=t.position.y>window.innerHeight/2,i=t.position.x>window.innerWidth/2;a?o.bottom=window.innerHeight-t.position.y:o.top=t.position.y,Bo()?i?o.right=window.innerWidth-t.position.x:o.left=t.position.x:(o.right=36,o.left=36)}return o},[t.position]);return l.useEffect(()=>{const o=a=>{a.code==="Escape"&&n.current()};return window.addEventListener("keyup",o),()=>{window.removeEventListener("keyup",o)}},[]),r?s.jsxs("div",{className:P(pt.container,t.state==="out"&&pt.animateHide,t.state==="in"&&pt.animateShow),onAnimationEnd:t[Uo.ON_ANIMATION_END],children:[s.jsx("div",{className:pt.backdrop,onClick:o=>{o.stopPropagation(),o.preventDefault(),t.close()}}),s.jsx("div",{className:P(pt.content,t.state==="out"&&pt.animateHide,t.state==="in"&&pt.animateShow),style:r,children:e})]}):null},$e=(e,t)=>e!=null&&e>t,Fd=(e,t)=>e!=null&&e<t,qd="_root_4e99l_2",Bd="_content_4e99l_2",Ud="_table-name_4e99l_2",Wd="_sub_4e99l_2",Wn={root:qd,content:Bd,tableName:Ud,sub:Wd},zo=({hook:e,onClick:t})=>s.jsxs("button",{className:Wn.root,onClick:t,children:[s.jsx("span",{children:"📄"}),s.jsxs("div",{className:Wn.content,children:[s.jsx("span",{className:Wn.tableName,children:e.on.toTable}),s.jsxs("span",{className:Wn.sub,children:[e.on.toColumn," = ",e.on.fromTable,".",e.on.fromColumn]})]})]},e.where),Hd=P("input",Ve.filterInput);function zd(e,t,n){return{name:`${e.on.toTable} ${e.on.toColumn} equals ${n}`,opts:Xt({table:e.on.toTable,dataSourceId:t,filters:[{id:ot(),column:`${e.on.toTable}.${e.on.toColumn}`,value:n==null?"IS NULL":`${n}`,isEnabled:!0}]})}}const Ko=({rowIndex:e,onClose:t,className:n})=>{const[r,o]=l.useState(""),{hooks:a,dataSourceId:i,getValue:u}=l.useContext(Be),{state:c}=l.useContext(fe),{data:d}=l.useContext(Le),f=l.useMemo(()=>d?.result.rows[e],[d,e]),h=Zt(),p=V(),b=l.useMemo(()=>{if(!d)return[];const g=r.toLowerCase();return a.filter(m=>d.result.columns.some(C=>C.column===m.on.fromColumn&&C.table===m.on.fromTable)?m.on.toTable.toLowerCase().includes(g):!1)},[r,a,d]),x=g=>{f&&h.mutateAsync(zd(g,i,u(f,{value:`${g.on.fromTable}.${g.on.fromColumn}`}))).then(m=>{p(I.workbenchTab.build({id:m.id})),t?.()})},y=()=>{!f||!c||h.mutateAsync({name:`${c.table} > [${c.joins.map(g=>g.table).join()}]`,opts:Xt({joins:c.joins,table:c.table,dataSourceId:c.dataSourceId,filters:[...c.filters.filter(g=>g.isEnabled),...c.groupBy.map(g=>({id:ot(),column:g.value,value:`${u(f,g)}`,isEnabled:!0}))]})}).then(g=>{p(I.workbenchTab.build({id:g.id})),t?.()})},v=c.groupBy.length>0;return s.jsxs("div",{className:n,children:[s.jsx("input",{className:Hd,placeholder:"Filter",value:r,onChange:g=>o(g.target.value)}),s.jsxs("div",{className:Ve.list,children:[v&&s.jsx("button",{onClick:y,className:Ve.optionItem,children:"🎯 Underlying rows"}),$e(b.length,0)?b.map(g=>s.jsx(zo,{hook:g,onClick:()=>x(g)},g.where)):s.jsx("p",{className:Ve.emptyText,children:"Empty"})]})]})},Kd=({handler:e,rowIndex:t})=>s.jsx(Ho,{handler:e,children:s.jsx("div",{className:Ve.optionsContainer,children:s.jsx(Ko,{rowIndex:t,className:"p-2",onClose:()=>{e.close()}})})}),tr=()=>{const{state:e,setState:t}=l.useContext(fe),n=l.useCallback((o,a=!1)=>{t(i=>({...i,page:a?0:i.page,filters:o}))},[t]),r=l.useCallback(o=>{t(a=>({...a,filters:a.filters.filter(i=>i.id!==o)}))},[t]);return{filters:e.filters,removeFilter:r,setFilters:n}},Qd=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:48,d:"M112 244l144-144 144 144M256 120v292"})),Ye=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:48,d:"M184 112l144 144-144 144"})),Vd=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M464 208L352 96 240 208M352 113.13V416M48 304l112 112 112-112M160 398V96"})),Qo=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("title",null,"Search"),l.createElement("path",{d:"M221.09 64a157.09 157.09 0 10157.09 157.09A157.1 157.1 0 00221.09 64z",fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32,d:"M338.29 338.29L448 448"})),Yd="_container_whojd_2",Gd="_animate-show_whojd_2",Jd="_animate-hide_whojd_2",Xd="_backdrop_whojd_2",Zd="_content_whojd_2",xt={container:Yd,animateShow:Gd,animateHide:Jd,backdrop:Xd,content:Zd},Vo=({children:e,ref:t,onClosed:n})=>{const[r,o]=l.useState(void 0),[a,i]=l.useState("hidden"),u=l.useRef(null);if(l.useImperativeHandle(t,()=>({open:(f,h=!0)=>{h||(f.preventDefault(),f.stopPropagation());const p={},b=f.clientY>window.innerHeight/2,x=f.clientX>window.innerWidth/2;b?p.bottom=window.innerHeight-f.clientY:p.top=f.clientY,Bo()?x?p.right=window.innerWidth-f.clientX:p.left=f.clientX:(p.right=36,p.left=36),o(p),i("in")},close:()=>{i("out")}}),[]),!r)return null;const c=()=>{a==="in"?i("visible"):a==="out"&&(o(void 0),i("hidden"),n?.())},d=s.jsxs("div",{className:P(xt.container,a==="out"&&xt.animateHide,a==="in"&&xt.animateShow),onAnimationEnd:c,children:[s.jsx("div",{className:xt.backdrop,onClick:()=>i("out")}),s.jsx("div",{ref:u,style:r,className:P(xt.content,a==="out"&&xt.animateHide,a==="in"&&xt.animateShow),children:e})]});return vo.createPortal(d,document.body)};function Ns(e,t,n){const r=e?.rows?.[t]?.[n],o=e?.columns?.[n];return{value:r,column:o}}const eh=({ref:e})=>{const{data:t}=l.useContext(Le),{getColumnType:n}=l.useContext(Be),{setState:r}=l.useContext(fe);return{copyValue:(u,c)=>{const{value:d,column:f}=Ns(t?.result,u,c);if(f){const h=wt(d,n(f.full));navigator.clipboard.writeText(h),Ce.success("Copied!"),e.current?.close()}},showValue:(u,c)=>{const{value:d,column:f}=Ns(t?.result,u,c);if(f){const h=wt(d,n(f.full));Fo(h),e.current?.close()}},filterValue:(u,c)=>{const{value:d,column:f}=Ns(t?.result,u,c),h=f?.full||"";if(f?.table===""){Ce.error("Filtering on aggregated column is not supported yet");return}if(h){let p;if(d==null)p={id:ot(),isEnabled:!0,column:h,value:"IS NULL"};else{const b=wt(d,n(h));p={id:ot(),isEnabled:!0,column:h,value:b}}r(b=>({...b,filters:[...b.filters,p]})),Ce.success(`Added new filter on column ${f?.alias}`),e.current?.close()}}}},Yo=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("rect",{x:128,y:128,width:336,height:336,rx:57,ry:57,fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M383.5 128l.5-24a56.16 56.16 0 00-56-56H112a64.19 64.19 0 00-64 64v216a56.16 56.16 0 0056 56h24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),th=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M255.66 112c-77.94 0-157.89 45.11-220.83 135.33a16 16 0 00-.27 17.77C82.92 340.8 161.8 400 255.66 400c92.84 0 173.34-59.38 221.79-135.25a16.14 16.14 0 000-17.47C428.89 172.28 347.8 112 255.66 112z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("circle",{cx:256,cy:256,r:80,fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32})),nh="_section-name_coeic_2",sh="_item_coeic_2",gt={sectionName:nh,item:sh},rh=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M136 208l120-104 120 104M136 304l120 104 120-104",stroke:"currentColor",fill:"none",strokeWidth:32,strokeLinecap:"round",strokeLinejoin:"round"})),oh=P("input",Ve.filterInput),ah=({onClose:e,rowIndex:t,className:n})=>{const[r,o]=l.useState(""),{entities:a,dataSourceId:i,getEntityKey:u}=l.useContext(Be),{data:c}=l.useContext(Le),d=l.useMemo(()=>c?.result.rows[t],[c,t]),f=l.useMemo(()=>r?a.filter(p=>p.includes(r)):a,[a,r]),h=p=>{if(!d)return;const b=u(p,d);cs({tableName:p,dataSourceId:i,entityId:b}),e?.()};return s.jsxs("div",{className:n,children:[s.jsx("input",{className:oh,placeholder:"Filter",value:r,onChange:p=>o(p.target.value)}),s.jsx("div",{className:Ve.list,children:$e(f.length,0)?f.map(p=>s.jsx("button",{className:Ve.optionItem,onClick:()=>h(p),children:s.jsxs("span",{children:["📄 ",p]})},p)):s.jsx("p",{className:Ve.emptyText,children:"Empty"})})]})},ih=({ref:e,row:t,col:n,onClosed:r})=>{const o=eh({ref:e}),[a,i]=l.useState("cell"),{entities:u,dataSourceId:c,getEntityKeyByRowIndex:d}=l.useContext(Be),f=()=>o.copyValue(t,n),h=()=>o.showValue(t,n),p=()=>o.filterValue(t,n),b=()=>{if(u.length===1){const y=d(u[0],t);cs({tableName:u[0],dataSourceId:c,entityId:y}),e.current?.close()}else i("expand")},x=()=>{r?.(),i("cell")};return s.jsx(Vo,{ref:e,onClosed:x,children:s.jsxs("div",{className:"w-full lg:w-sm",children:[a==="cell"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:gt.sectionName,children:"Cell actions"}),s.jsxs("button",{className:gt.item,onClick:f,children:[s.jsx(Yo,{width:14,height:14}),"Copy"]}),s.jsxs("button",{className:gt.item,onClick:h,children:[s.jsx(th,{width:14,height:14}),"View"]}),s.jsxs("button",{className:gt.item,onClick:p,children:[s.jsx(Qo,{width:14,height:14}),"Filter"]}),s.jsx("p",{className:gt.sectionName,children:"Row actions"}),s.jsxs("button",{className:gt.item,onClick:()=>i("drill"),children:[s.jsx(Ye,{width:14,height:14}),"Drill down"]}),u?.length>0&&s.jsxs("button",{className:gt.item,onClick:b,children:[s.jsx(rh,{width:14,height:14}),"Expand row"]})]}),a==="drill"&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"flex gap-1 items-center cursor-pointer px-2 py-1 text-sm rounded-lg bg-gray-50 hover:bg-gray-100 mb-2",onClick:()=>i("cell"),children:[s.jsx(Ye,{className:"rotate-180",width:16,height:16}),"Drill down"]}),s.jsx(Ko,{rowIndex:t,onClose:()=>e.current?.close()})]}),a==="expand"&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"flex gap-1 items-center cursor-pointer px-2 py-1 text-sm rounded-lg bg-gray-50 hover:bg-gray-100 mb-2",onClick:()=>i("cell"),children:[s.jsx(Ye,{className:"rotate-180",width:16,height:16}),"Expand row"]}),s.jsx(ah,{rowIndex:t,onClose:()=>e.current?.close()})]})]})})},lh={DESC:"",ASC:"rotate-180"},ch=(e,{column:t,value:n})=>{const r=e.map(o=>({...o,isEnabled:o.column===t?!1:o.isEnabled}));return r.push({id:ot(),column:t,isEnabled:!0,value:n,isAdvanced:!1}),r},uh=()=>{const{data:e}=l.useContext(Le),{orderBy:t,updateOrderBy:n}=Ed(),{setFilters:r,filters:o}=tr(),a=e?.result.columns||[],i=t[0],u=$e(e?.result.tables.length,1),c=d=>{Tn("Filter value","").then(f=>{f&&r(ch(o,{column:d,value:f}))})};return s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("td",{children:"🥢"}),a.map(d=>s.jsxs("td",{className:E.headerCell,children:[s.jsxs("div",{className:"overflow-hidden",children:[u&&s.jsx("p",{className:"text-xs truncate italic",children:d.table||"-"}),s.jsx("p",{className:"text-sm font-semibold truncate",children:d.column})]}),s.jsxs("div",{className:E.headerActions,children:[s.jsx("button",{onClick:()=>n(d.full),children:i?.column===d.full?s.jsx(Qd,{className:lh[i.direction],width:16,height:16}):s.jsx(Vd,{width:16,height:16})}),d.table&&s.jsx("button",{onClick:()=>c(d.full),children:s.jsx(Qo,{width:16,height:16})})]})]},d.full))]})})};function dh({value:e}){if(e==="")return s.jsx("span",{className:"pointer-events-none text-black/30 truncate",children:"<EMPTY STRING>"});if(e==null)return s.jsx("span",{className:"pointer-events-none text-black/30",children:"<NULL>"});const t=wt(e);return s.jsx("span",{className:E.value,children:t})}const hh=l.memo(({row:e,isLastRow:t,index:n,offset:r})=>s.jsxs("tr",{className:P(E.tableRowCells,t&&"rounded-b-lg"),children:[s.jsx("td",{children:s.jsxs("button",{"data-row-action":n,className:E.rowIndexBtn,children:[s.jsx(Ye,{className:"pointer-events-none",width:16,height:16}),n+1+r]})}),e.map((o,a)=>s.jsx("td",{className:E.cell,"data-row":n,"data-col":a,children:s.jsx(dh,{value:o})},a))]})),fh=()=>{const{data:e,error:t,isLoading:n,isFetching:r}=l.useContext(Le),{state:{page:o,size:a}}=l.useContext(fe),i=l.useRef(null),u=Xs(t),c=Wo(),[d,f]=l.useState(void 0),[h,p]=l.useState(void 0),b=v=>{const m=v.target?.dataset?.rowAction;m!=null&&(f(parseInt(m)),c.open(v))},x=v=>{const g=v.target?.dataset,m=g?.row,w=g?.col;m!=null&&w!=null&&(f(parseInt(m)),p(parseInt(w)),i.current?.open(v),v.preventDefault(),v.stopPropagation())},y=o*a;return s.jsxs(s.Fragment,{children:[d!=null&&c.show&&s.jsx(Kd,{handler:c,rowIndex:d}),s.jsx(ih,{ref:i,col:h,row:d,onClosed:()=>{f(void 0),p(void 0)}}),u&&s.jsx(ne,{variant:"danger",children:u}),n&&s.jsx("div",{className:E.tableLoading,children:"Loading data"}),e&&s.jsxs("table",{className:P(E.table,r&&E.semiTransparent),onClick:b,onContextMenu:x,children:[s.jsx(uh,{}),s.jsxs("tbody",{children:[e.result.rows?.length<1&&s.jsx("tr",{className:E.tableEmpty,children:s.jsx("td",{colSpan:e.result.columns.length+1,children:"No data"})}),e.result.rows?.map((v,g)=>s.jsx(hh,{index:g,offset:y,row:v,isLastRow:g===e.result.rows.length-1},g))]})]})]})},Go=()=>{const{state:e,setState:t}=l.useContext(fe),n=l.useCallback(o=>{t(a=>({...a,page:o}))},[t]),r=l.useCallback((o,a=!1)=>{t(i=>({...i,size:o,page:a?0:i.page}))},[t]);return{page:e.page,size:e.size,setSize:r,setPage:n}},mh=()=>X({mutationFn:async e=>{const{data:t}=await O.post("/saved-queries",e);return t.data},onSuccess:()=>{K.invalidateQueries({queryKey:["queries"]}),Gt(),Eo()}}),ph=()=>X({mutationFn:async e=>O.delete("/saved-queries/"+e),onSuccess:()=>{Gt(),Eo()}}),xh=()=>X({mutationFn:async({id:e,payload:t})=>{const{data:n}=await O.patch("/saved-queries/"+e,t);return n.data},onSuccess:()=>{Gt(),Pl()}}),[us,nr]=je({filters:!1,joins:!1,columns:!1,groupBy:!1,aggregate:!1}),Oe=e=>nr(t=>({...t,[e]:!0})),ds=e=>nr(t=>({...t,[e]:!1})),Zn=e=>nr(t=>({...t,[e]:!t[e]})),Kt=Math.min,Ct=Math.max,es=Math.round,Hn=Math.floor,Me=e=>({x:e,y:e}),gh={left:"right",right:"left",bottom:"top",top:"bottom"},bh={start:"end",end:"start"};function $s(e,t,n){return Ct(e,Kt(t,n))}function Ln(e,t){return typeof e=="function"?e(t):e}function Nt(e){return e.split("-")[0]}function An(e){return e.split("-")[1]}function Jo(e){return e==="x"?"y":"x"}function sr(e){return e==="y"?"height":"width"}function st(e){return["top","bottom"].includes(Nt(e))?"y":"x"}function rr(e){return Jo(st(e))}function yh(e,t,n){n===void 0&&(n=!1);const r=An(e),o=rr(e),a=sr(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=ts(i)),[i,ts(i)]}function vh(e){const t=ts(e);return[Ds(e),t,Ds(t)]}function Ds(e){return e.replace(/start|end/g,t=>bh[t])}function wh(e,t,n){const r=["left","right"],o=["right","left"],a=["top","bottom"],i=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?a:i;default:return[]}}function Ch(e,t,n,r){const o=An(e);let a=wh(Nt(e),n==="start",r);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(Ds)))),a}function ts(e){return e.replace(/left|right|bottom|top/g,t=>gh[t])}function jh(e){return{top:0,right:0,bottom:0,left:0,...e}}function Xo(e){return typeof e!="number"?jh(e):{top:e,right:e,bottom:e,left:e}}function ns(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Pr(e,t,n){let{reference:r,floating:o}=e;const a=st(t),i=rr(t),u=sr(i),c=Nt(t),d=a==="y",f=r.x+r.width/2-o.width/2,h=r.y+r.height/2-o.height/2,p=r[u]/2-o[u]/2;let b;switch(c){case"top":b={x:f,y:r.y-o.height};break;case"bottom":b={x:f,y:r.y+r.height};break;case"right":b={x:r.x+r.width,y:h};break;case"left":b={x:r.x-o.width,y:h};break;default:b={x:r.x,y:r.y}}switch(An(t)){case"start":b[i]-=p*(n&&d?-1:1);break;case"end":b[i]+=p*(n&&d?-1:1);break}return b}const Nh=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:i}=n,u=a.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(t));let d=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:h}=Pr(d,r,c),p=r,b={},x=0;for(let y=0;y<u.length;y++){const{name:v,fn:g}=u[y],{x:m,y:w,data:C,reset:S}=await g({x:f,y:h,initialPlacement:r,placement:p,strategy:o,middlewareData:b,rects:d,platform:i,elements:{reference:e,floating:t}});f=m??f,h=w??h,b={...b,[v]:{...b[v],...C}},S&&x<=50&&(x++,typeof S=="object"&&(S.placement&&(p=S.placement),S.rects&&(d=S.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):S.rects),{x:f,y:h}=Pr(d,p,c)),y=-1)}return{x:f,y:h,placement:p,strategy:o,middlewareData:b}};async function Zo(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:a,rects:i,elements:u,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:h="floating",altBoundary:p=!1,padding:b=0}=Ln(t,e),x=Xo(b),v=u[p?h==="floating"?"reference":"floating":h],g=ns(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(v)))==null||n?v:v.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(u.floating)),boundary:d,rootBoundary:f,strategy:c})),m=h==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u.floating)),C=await(a.isElement==null?void 0:a.isElement(w))?await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1}:{x:1,y:1},S=ns(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:m,offsetParent:w,strategy:c}):m);return{top:(g.top-S.top+x.top)/C.y,bottom:(S.bottom-g.bottom+x.bottom)/C.y,left:(g.left-S.left+x.left)/C.x,right:(S.right-g.right+x.right)/C.x}}const _h=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:a,platform:i,elements:u,middlewareData:c}=t,{element:d,padding:f=0}=Ln(e,t)||{};if(d==null)return{};const h=Xo(f),p={x:n,y:r},b=rr(o),x=sr(b),y=await i.getDimensions(d),v=b==="y",g=v?"top":"left",m=v?"bottom":"right",w=v?"clientHeight":"clientWidth",C=a.reference[x]+a.reference[b]-p[b]-a.floating[x],S=p[b]-a.reference[b],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d));let j=k?k[w]:0;(!j||!await(i.isElement==null?void 0:i.isElement(k)))&&(j=u.floating[w]||a.floating[x]);const _=C/2-S/2,L=j/2-y[x]/2-1,F=Kt(h[g],L),Z=Kt(h[m],L),be=F,Ae=j-y[x]-Z,B=j/2-y[x]/2+_,de=$s(be,B,Ae),re=!c.arrow&&An(o)!=null&&B!==de&&a.reference[x]/2-(B<be?F:Z)-y[x]/2<0,Y=re?B<be?B-be:B-Ae:0;return{[b]:p[b]+Y,data:{[b]:de,centerOffset:B-de-Y,...re&&{alignmentOffset:Y}},reset:re}}}),Sh=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:a,rects:i,initialPlacement:u,platform:c,elements:d}=t,{mainAxis:f=!0,crossAxis:h=!0,fallbackPlacements:p,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:y=!0,...v}=Ln(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const g=Nt(o),m=st(u),w=Nt(u)===u,C=await(c.isRTL==null?void 0:c.isRTL(d.floating)),S=p||(w||!y?[ts(u)]:vh(u)),k=x!=="none";!p&&k&&S.push(...Ch(u,y,x,C));const j=[u,...S],_=await Zo(t,v),L=[];let F=((r=a.flip)==null?void 0:r.overflows)||[];if(f&&L.push(_[g]),h){const B=yh(o,i,C);L.push(_[B[0]],_[B[1]])}if(F=[...F,{placement:o,overflows:L}],!L.every(B=>B<=0)){var Z,be;const B=(((Z=a.flip)==null?void 0:Z.index)||0)+1,de=j[B];if(de&&(!(h==="alignment"?m!==st(de):!1)||F.every(W=>W.overflows[0]>0&&st(W.placement)===m)))return{data:{index:B,overflows:F},reset:{placement:de}};let re=(be=F.filter(Y=>Y.overflows[0]<=0).sort((Y,W)=>Y.overflows[1]-W.overflows[1])[0])==null?void 0:be.placement;if(!re)switch(b){case"bestFit":{var Ae;const Y=(Ae=F.filter(W=>{if(k){const oe=st(W.placement);return oe===m||oe==="y"}return!0}).map(W=>[W.placement,W.overflows.filter(oe=>oe>0).reduce((oe,We)=>oe+We,0)]).sort((W,oe)=>W[1]-oe[1])[0])==null?void 0:Ae[0];Y&&(re=Y);break}case"initialPlacement":re=u;break}if(o!==re)return{reset:{placement:re}}}return{}}}};async function kh(e,t){const{placement:n,platform:r,elements:o}=e,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Nt(n),u=An(n),c=st(n)==="y",d=["left","top"].includes(i)?-1:1,f=a&&c?-1:1,h=Ln(t,e);let{mainAxis:p,crossAxis:b,alignmentAxis:x}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return u&&typeof x=="number"&&(b=u==="end"?x*-1:x),c?{x:b*f,y:p*d}:{x:p*d,y:b*f}}const Eh=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:a,placement:i,middlewareData:u}=t,c=await kh(t,e);return i===((n=u.offset)==null?void 0:n.placement)&&(r=u.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:a+c.y,data:{...c,placement:i}}}}},Rh=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:u={fn:v=>{let{x:g,y:m}=v;return{x:g,y:m}}},...c}=Ln(e,t),d={x:n,y:r},f=await Zo(t,c),h=st(Nt(o)),p=Jo(h);let b=d[p],x=d[h];if(a){const v=p==="y"?"top":"left",g=p==="y"?"bottom":"right",m=b+f[v],w=b-f[g];b=$s(m,b,w)}if(i){const v=h==="y"?"top":"left",g=h==="y"?"bottom":"right",m=x+f[v],w=x-f[g];x=$s(m,x,w)}const y=u.fn({...t,[p]:b,[h]:x});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[p]:a,[h]:i}}}}}};function hs(){return typeof window<"u"}function en(e){return ea(e)?(e.nodeName||"").toLowerCase():"#document"}function xe(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ue(e){var t;return(t=(ea(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ea(e){return hs()?e instanceof Node||e instanceof xe(e).Node:!1}function Re(e){return hs()?e instanceof Element||e instanceof xe(e).Element:!1}function De(e){return hs()?e instanceof HTMLElement||e instanceof xe(e).HTMLElement:!1}function Ir(e){return!hs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof xe(e).ShadowRoot}function Pn(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Te(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function Th(e){return["table","td","th"].includes(en(e))}function fs(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function or(e){const t=ar(),n=Re(e)?Te(e):e;return["transform","translate","scale","rotate","perspective"].some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function Lh(e){let t=at(e);for(;De(t)&&!Qt(t);){if(or(t))return t;if(fs(t))return null;t=at(t)}return null}function ar(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Qt(e){return["html","body","#document"].includes(en(e))}function Te(e){return xe(e).getComputedStyle(e)}function ms(e){return Re(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function at(e){if(en(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ir(e)&&e.host||Ue(e);return Ir(t)?t.host:t}function ta(e){const t=at(e);return Qt(t)?e.ownerDocument?e.ownerDocument.body:e.body:De(t)&&Pn(t)?t:ta(t)}function wn(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=ta(e),a=o===((r=e.ownerDocument)==null?void 0:r.body),i=xe(o);if(a){const u=Fs(i);return t.concat(i,i.visualViewport||[],Pn(o)?o:[],u&&n?wn(u):[])}return t.concat(o,wn(o,[],n))}function Fs(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function na(e){const t=Te(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=De(e),a=o?e.offsetWidth:n,i=o?e.offsetHeight:r,u=es(n)!==a||es(r)!==i;return u&&(n=a,r=i),{width:n,height:r,$:u}}function ir(e){return Re(e)?e:e.contextElement}function Ut(e){const t=ir(e);if(!De(t))return Me(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:a}=na(t);let i=(a?es(n.width):n.width)/r,u=(a?es(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!u||!Number.isFinite(u))&&(u=1),{x:i,y:u}}const Ah=Me(0);function sa(e){const t=xe(e);return!ar()||!t.visualViewport?Ah:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ph(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==xe(e)?!1:t}function _t(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=ir(e);let i=Me(1);t&&(r?Re(r)&&(i=Ut(r)):i=Ut(e));const u=Ph(a,n,r)?sa(a):Me(0);let c=(o.left+u.x)/i.x,d=(o.top+u.y)/i.y,f=o.width/i.x,h=o.height/i.y;if(a){const p=xe(a),b=r&&Re(r)?xe(r):r;let x=p,y=Fs(x);for(;y&&r&&b!==x;){const v=Ut(y),g=y.getBoundingClientRect(),m=Te(y),w=g.left+(y.clientLeft+parseFloat(m.paddingLeft))*v.x,C=g.top+(y.clientTop+parseFloat(m.paddingTop))*v.y;c*=v.x,d*=v.y,f*=v.x,h*=v.y,c+=w,d+=C,x=xe(y),y=Fs(x)}}return ns({width:f,height:h,x:c,y:d})}function lr(e,t){const n=ms(e).scrollLeft;return t?t.left+n:_t(Ue(e)).left+n}function ra(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:lr(e,r)),a=r.top+t.scrollTop;return{x:o,y:a}}function Ih(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const a=o==="fixed",i=Ue(r),u=t?fs(t.floating):!1;if(r===i||u&&a)return n;let c={scrollLeft:0,scrollTop:0},d=Me(1);const f=Me(0),h=De(r);if((h||!h&&!a)&&((en(r)!=="body"||Pn(i))&&(c=ms(r)),De(r))){const b=_t(r);d=Ut(r),f.x=b.x+r.clientLeft,f.y=b.y+r.clientTop}const p=i&&!h&&!a?ra(i,c,!0):Me(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+f.x+p.x,y:n.y*d.y-c.scrollTop*d.y+f.y+p.y}}function Oh(e){return Array.from(e.getClientRects())}function Mh(e){const t=Ue(e),n=ms(e),r=e.ownerDocument.body,o=Ct(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Ct(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+lr(e);const u=-n.scrollTop;return Te(r).direction==="rtl"&&(i+=Ct(t.clientWidth,r.clientWidth)-o),{width:o,height:a,x:i,y:u}}function $h(e,t){const n=xe(e),r=Ue(e),o=n.visualViewport;let a=r.clientWidth,i=r.clientHeight,u=0,c=0;if(o){a=o.width,i=o.height;const d=ar();(!d||d&&t==="fixed")&&(u=o.offsetLeft,c=o.offsetTop)}return{width:a,height:i,x:u,y:c}}function Dh(e,t){const n=_t(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,a=De(e)?Ut(e):Me(1),i=e.clientWidth*a.x,u=e.clientHeight*a.y,c=o*a.x,d=r*a.y;return{width:i,height:u,x:c,y:d}}function Or(e,t,n){let r;if(t==="viewport")r=$h(e,n);else if(t==="document")r=Mh(Ue(e));else if(Re(t))r=Dh(t,n);else{const o=sa(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ns(r)}function oa(e,t){const n=at(e);return n===t||!Re(n)||Qt(n)?!1:Te(n).position==="fixed"||oa(n,t)}function Fh(e,t){const n=t.get(e);if(n)return n;let r=wn(e,[],!1).filter(u=>Re(u)&&en(u)!=="body"),o=null;const a=Te(e).position==="fixed";let i=a?at(e):e;for(;Re(i)&&!Qt(i);){const u=Te(i),c=or(i);!c&&u.position==="fixed"&&(o=null),(a?!c&&!o:!c&&u.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Pn(i)&&!c&&oa(e,i))?r=r.filter(f=>f!==i):o=u,i=at(i)}return t.set(e,r),r}function qh(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?fs(t)?[]:Fh(t,this._c):[].concat(n),r],u=i[0],c=i.reduce((d,f)=>{const h=Or(t,f,o);return d.top=Ct(h.top,d.top),d.right=Kt(h.right,d.right),d.bottom=Kt(h.bottom,d.bottom),d.left=Ct(h.left,d.left),d},Or(t,u,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Bh(e){const{width:t,height:n}=na(e);return{width:t,height:n}}function Uh(e,t,n){const r=De(t),o=Ue(t),a=n==="fixed",i=_t(e,!0,a,t);let u={scrollLeft:0,scrollTop:0};const c=Me(0);function d(){c.x=lr(o)}if(r||!r&&!a)if((en(t)!=="body"||Pn(o))&&(u=ms(t)),r){const b=_t(t,!0,a,t);c.x=b.x+t.clientLeft,c.y=b.y+t.clientTop}else o&&d();a&&!r&&o&&d();const f=o&&!r&&!a?ra(o,u):Me(0),h=i.left+u.scrollLeft-c.x-f.x,p=i.top+u.scrollTop-c.y-f.y;return{x:h,y:p,width:i.width,height:i.height}}function _s(e){return Te(e).position==="static"}function Mr(e,t){if(!De(e)||Te(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ue(e)===n&&(n=n.ownerDocument.body),n}function aa(e,t){const n=xe(e);if(fs(e))return n;if(!De(e)){let o=at(e);for(;o&&!Qt(o);){if(Re(o)&&!_s(o))return o;o=at(o)}return n}let r=Mr(e,t);for(;r&&Th(r)&&_s(r);)r=Mr(r,t);return r&&Qt(r)&&_s(r)&&!or(r)?n:r||Lh(e)||n}const Wh=async function(e){const t=this.getOffsetParent||aa,n=this.getDimensions,r=await n(e.floating);return{reference:Uh(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Hh(e){return Te(e).direction==="rtl"}const zh={convertOffsetParentRelativeRectToViewportRelativeRect:Ih,getDocumentElement:Ue,getClippingRect:qh,getOffsetParent:aa,getElementRects:Wh,getClientRects:Oh,getDimensions:Bh,getScale:Ut,isElement:Re,isRTL:Hh};function ia(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Kh(e,t){let n=null,r;const o=Ue(e);function a(){var u;clearTimeout(r),(u=n)==null||u.disconnect(),n=null}function i(u,c){u===void 0&&(u=!1),c===void 0&&(c=1),a();const d=e.getBoundingClientRect(),{left:f,top:h,width:p,height:b}=d;if(u||t(),!p||!b)return;const x=Hn(h),y=Hn(o.clientWidth-(f+p)),v=Hn(o.clientHeight-(h+b)),g=Hn(f),w={rootMargin:-x+"px "+-y+"px "+-v+"px "+-g+"px",threshold:Ct(0,Kt(1,c))||1};let C=!0;function S(k){const j=k[0].intersectionRatio;if(j!==c){if(!C)return i();j?i(!1,j):r=setTimeout(()=>{i(!1,1e-7)},1e3)}j===1&&!ia(d,e.getBoundingClientRect())&&i(),C=!1}try{n=new IntersectionObserver(S,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,w)}n.observe(e)}return i(!0),a}function Qh(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:u=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=ir(e),f=o||a?[...d?wn(d):[],...wn(t)]:[];f.forEach(g=>{o&&g.addEventListener("scroll",n,{passive:!0}),a&&g.addEventListener("resize",n)});const h=d&&u?Kh(d,n):null;let p=-1,b=null;i&&(b=new ResizeObserver(g=>{let[m]=g;m&&m.target===d&&b&&(b.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var w;(w=b)==null||w.observe(t)})),n()}),d&&!c&&b.observe(d),b.observe(t));let x,y=c?_t(e):null;c&&v();function v(){const g=_t(e);y&&!ia(y,g)&&n(),y=g,x=requestAnimationFrame(v)}return n(),()=>{var g;f.forEach(m=>{o&&m.removeEventListener("scroll",n),a&&m.removeEventListener("resize",n)}),h?.(),(g=b)==null||g.disconnect(),b=null,c&&cancelAnimationFrame(x)}}const Vh=Eh,Yh=Rh,Gh=Sh,Jh=_h,$r=(e,t,n)=>{const r=new Map,o={platform:zh,...n},a={...o.platform,_c:r};return Nh(e,t,{...o,platform:a})};var Ss={exports:{}};var Dr;function Xh(){return Dr||(Dr=1,function(e){(function(){var t={}.hasOwnProperty;function n(){for(var a="",i=0;i<arguments.length;i++){var u=arguments[i];u&&(a=o(a,r(u)))}return a}function r(a){if(typeof a=="string"||typeof a=="number")return a;if(typeof a!="object")return"";if(Array.isArray(a))return n.apply(null,a);if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]"))return a.toString();var i="";for(var u in a)t.call(a,u)&&a[u]&&(i=o(i,u));return i}function o(a,i){return i?a?a+" "+i:a+i:a}e.exports?(n.default=n,e.exports=n):window.classNames=n})()}(Ss)),Ss.exports}var Zh=Xh();const qs=Ba(Zh);var Fr={};const ef="react-tooltip-core-styles",tf="react-tooltip-base-styles",qr={core:!1,base:!1};function Br({css:e,id:t=tf,type:n="base",ref:r}){var o,a;if(!e||typeof document>"u"||qr[n]||n==="core"&&typeof process<"u"&&(!((o=process==null?void 0:Fr)===null||o===void 0)&&o.REACT_TOOLTIP_DISABLE_CORE_STYLES)||n!=="base"&&typeof process<"u"&&(!((a=process==null?void 0:Fr)===null||a===void 0)&&a.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;n==="core"&&(t=ef),r||(r={});const{insertAt:i}=r;if(document.getElementById(t))return;const u=document.head||document.getElementsByTagName("head")[0],c=document.createElement("style");c.id=t,c.type="text/css",i==="top"&&u.firstChild?u.insertBefore(c,u.firstChild):u.appendChild(c),c.styleSheet?c.styleSheet.cssText=e:c.appendChild(document.createTextNode(e)),qr[n]=!0}const Ur=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:r="top",offset:o=10,strategy:a="absolute",middlewares:i=[Vh(Number(o)),Gh({fallbackAxisSideDirection:"start"}),Yh({padding:5})],border:u,arrowSize:c=8})=>{if(!e)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};if(t===null)return{tooltipStyles:{},tooltipArrowStyles:{},place:r};const d=i;return n?(d.push(Jh({element:n,padding:5})),$r(e,t,{placement:r,strategy:a,middleware:d}).then(({x:f,y:h,placement:p,middlewareData:b})=>{var x,y;const v={left:`${f}px`,top:`${h}px`,border:u},{x:g,y:m}=(x=b.arrow)!==null&&x!==void 0?x:{x:0,y:0},w=(y={top:"bottom",right:"left",bottom:"top",left:"right"}[p.split("-")[0]])!==null&&y!==void 0?y:"bottom",C=u&&{borderBottom:u,borderRight:u};let S=0;if(u){const k=`${u}`.match(/(\d+)px/);S=k?.[1]?Number(k[1]):1}return{tooltipStyles:v,tooltipArrowStyles:{left:g!=null?`${g}px`:"",top:m!=null?`${m}px`:"",right:"",bottom:"",...C,[w]:`-${c/2+S}px`},place:p}})):$r(e,t,{placement:"bottom",strategy:a,middleware:d}).then(({x:f,y:h,placement:p})=>({tooltipStyles:{left:`${f}px`,top:`${h}px`},tooltipArrowStyles:{},place:p}))},Wr=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),Hr=(e,t,n)=>{let r=null;const o=function(...a){const i=()=>{r=null};!r&&(e.apply(this,a),r=setTimeout(i,t))};return o.cancel=()=>{r&&(clearTimeout(r),r=null)},o},zr=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",Bs=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((o,a)=>Bs(o,t[a]));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!zr(e)||!zr(t))return e===t;const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(o=>Bs(e[o],t[o]))},nf=e=>{if(!(e instanceof HTMLElement||e instanceof SVGElement))return!1;const t=getComputedStyle(e);return["overflow","overflow-x","overflow-y"].some(n=>{const r=t.getPropertyValue(n);return r==="auto"||r==="scroll"})},Kr=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(nf(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},sf=typeof window<"u"?l.useLayoutEffect:l.useEffect,we=e=>{e.current&&(clearTimeout(e.current),e.current=null)},rf="DEFAULT_TOOLTIP_ID",of={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},af=l.createContext({getTooltipData:()=>of});function la(e=rf){return l.useContext(af).getTooltipData(e)}var Ft={tooltip:"core-styles-module_tooltip__3vRRp",fixed:"core-styles-module_fixed__pcSol",arrow:"core-styles-module_arrow__cvMwQ",noArrow:"core-styles-module_noArrow__xock6",clickable:"core-styles-module_clickable__ZuTTB",show:"core-styles-module_show__Nt9eE",closing:"core-styles-module_closing__sGnxF"},ks={tooltip:"styles-module_tooltip__mnnfp",arrow:"styles-module_arrow__K0L3T",dark:"styles-module_dark__xNqje",light:"styles-module_light__Z6W-X",success:"styles-module_success__A2AKt",warning:"styles-module_warning__SCK0X",error:"styles-module_error__JvumD",info:"styles-module_info__BWdHW"};const lf=({forwardRef:e,id:t,className:n,classNameArrow:r,variant:o="dark",anchorId:a,anchorSelect:i,place:u="top",offset:c=10,events:d=["hover"],openOnClick:f=!1,positionStrategy:h="absolute",middlewares:p,wrapper:b,delayShow:x=0,delayHide:y=0,float:v=!1,hidden:g=!1,noArrow:m=!1,clickable:w=!1,closeOnEsc:C=!1,closeOnScroll:S=!1,closeOnResize:k=!1,openEvents:j,closeEvents:_,globalCloseEvents:L,imperativeModeOnly:F,style:Z,position:be,afterShow:Ae,afterHide:B,disableTooltip:de,content:re,contentWrapperRef:Y,isOpen:W,defaultIsOpen:oe=!1,setIsOpen:We,activeAnchor:G,setActiveAnchor:St,border:In,opacity:On,arrowColor:Mn,arrowSize:kt=8,role:ps="tooltip"})=>{var tn;const ae=l.useRef(null),Et=l.useRef(null),Ne=l.useRef(null),Xe=l.useRef(null),nn=l.useRef(null),[Ze,xs]=l.useState({tooltipStyles:{},tooltipArrowStyles:{},place:u}),[me,$n]=l.useState(!1),[ut,dt]=l.useState(!1),[H,sn]=l.useState(null),rn=l.useRef(!1),on=l.useRef(null),{anchorRefs:an,setActiveAnchor:Dn}=la(t),Rt=l.useRef(!1),[et,ln]=l.useState([]),ht=l.useRef(!1),Tt=f||d.includes("click"),gs=Tt||j?.click||j?.dblclick||j?.mousedown,Lt=j?{...j}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!j&&Tt&&Object.assign(Lt,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const ft=_?{..._}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!_&&Tt&&Object.assign(ft,{mouseleave:!1,blur:!1,mouseout:!1});const _e=L?{...L}:{escape:C||!1,scroll:S||!1,resize:k||!1,clickOutsideAnchor:gs||!1};F&&(Object.assign(Lt,{mouseover:!1,focus:!1,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(ft,{mouseout:!1,blur:!1,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(_e,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),sf(()=>(ht.current=!0,()=>{ht.current=!1}),[]);const Q=N=>{ht.current&&(N&&dt(!0),setTimeout(()=>{ht.current&&(We?.(N),W===void 0&&$n(N))},10))};l.useEffect(()=>{if(W===void 0)return()=>null;W&&dt(!0);const N=setTimeout(()=>{$n(W)},10);return()=>{clearTimeout(N)}},[W]),l.useEffect(()=>{if(me!==rn.current)if(we(nn),rn.current=me,me)Ae?.();else{const N=(T=>{const A=T.match(/^([\d.]+)(ms|s)$/);if(!A)return 0;const[,J,se]=A;return Number(J)*(se==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));nn.current=setTimeout(()=>{dt(!1),sn(null),B?.()},N+25)}},[me]);const Fn=N=>{xs(T=>Bs(T,N)?T:N)},cn=(N=x)=>{we(Ne),ut?Q(!0):Ne.current=setTimeout(()=>{Q(!0)},N)},At=(N=y)=>{we(Xe),Xe.current=setTimeout(()=>{Rt.current||Q(!1)},N)},un=N=>{var T;if(!N)return;const A=(T=N.currentTarget)!==null&&T!==void 0?T:N.target;if(!A?.isConnected)return St(null),void Dn({current:null});x?cn():Q(!0),St(A),Dn({current:A}),we(Xe)},Pt=()=>{w?At(y||100):y?At():Q(!1),we(Ne)},It=({x:N,y:T})=>{var A;const J={getBoundingClientRect:()=>({x:N,y:T,width:0,height:0,top:T,left:N,right:N,bottom:T})};Ur({place:(A=H?.place)!==null&&A!==void 0?A:u,offset:c,elementReference:J,tooltipReference:ae.current,tooltipArrowReference:Et.current,strategy:h,middlewares:p,border:In,arrowSize:kt}).then(se=>{Fn(se)})},Ot=N=>{if(!N)return;const T=N,A={x:T.clientX,y:T.clientY};It(A),on.current=A},dn=N=>{var T;if(!me)return;const A=N.target;A.isConnected&&(!((T=ae.current)===null||T===void 0)&&T.contains(A)||[document.querySelector(`[id='${a}']`),...et].some(J=>J?.contains(A))||(Q(!1),we(Ne)))},qn=Hr(un,50),ee=Hr(Pt,50),ye=N=>{ee.cancel(),qn(N)},R=()=>{qn.cancel(),ee()},M=l.useCallback(()=>{var N,T;const A=(N=H?.position)!==null&&N!==void 0?N:be;A?It(A):v?on.current&&It(on.current):G?.isConnected&&Ur({place:(T=H?.place)!==null&&T!==void 0?T:u,offset:c,elementReference:G,tooltipReference:ae.current,tooltipArrowReference:Et.current,strategy:h,middlewares:p,border:In,arrowSize:kt}).then(J=>{ht.current&&Fn(J)})},[me,G,re,Z,u,H?.place,c,h,be,H?.position,v,kt]);l.useEffect(()=>{var N,T;const A=new Set(an);et.forEach(q=>{de?.(q)||A.add({current:q})});const J=document.querySelector(`[id='${a}']`);J&&!de?.(J)&&A.add({current:J});const se=()=>{Q(!1)},Pe=Kr(G),Ie=Kr(ae.current);_e.scroll&&(window.addEventListener("scroll",se),Pe?.addEventListener("scroll",se),Ie?.addEventListener("scroll",se));let ie=null;_e.resize?window.addEventListener("resize",se):G&&ae.current&&(ie=Qh(G,ae.current,M,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const ve=q=>{q.key==="Escape"&&Q(!1)};_e.escape&&window.addEventListener("keydown",ve),_e.clickOutsideAnchor&&window.addEventListener("click",dn);const U=[],Mt=q=>!!(q?.target&&G?.contains(q.target)),Ea=q=>{me&&Mt(q)||un(q)},Ra=q=>{me&&Mt(q)&&Pt()},dr=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],hr=["click","dblclick","mousedown","mouseup"];Object.entries(Lt).forEach(([q,He])=>{He&&(dr.includes(q)?U.push({event:q,listener:ye}):hr.includes(q)&&U.push({event:q,listener:Ea}))}),Object.entries(ft).forEach(([q,He])=>{He&&(dr.includes(q)?U.push({event:q,listener:R}):hr.includes(q)&&U.push({event:q,listener:Ra}))}),v&&U.push({event:"pointermove",listener:Ot});const fr=()=>{Rt.current=!0},mr=()=>{Rt.current=!1,Pt()},pr=w&&(ft.mouseout||ft.mouseleave);return pr&&((N=ae.current)===null||N===void 0||N.addEventListener("mouseover",fr),(T=ae.current)===null||T===void 0||T.addEventListener("mouseout",mr)),U.forEach(({event:q,listener:He})=>{A.forEach(bs=>{var hn;(hn=bs.current)===null||hn===void 0||hn.addEventListener(q,He)})}),()=>{var q,He;_e.scroll&&(window.removeEventListener("scroll",se),Pe?.removeEventListener("scroll",se),Ie?.removeEventListener("scroll",se)),_e.resize?window.removeEventListener("resize",se):ie?.(),_e.clickOutsideAnchor&&window.removeEventListener("click",dn),_e.escape&&window.removeEventListener("keydown",ve),pr&&((q=ae.current)===null||q===void 0||q.removeEventListener("mouseover",fr),(He=ae.current)===null||He===void 0||He.removeEventListener("mouseout",mr)),U.forEach(({event:bs,listener:hn})=>{A.forEach(Ta=>{var ys;(ys=Ta.current)===null||ys===void 0||ys.removeEventListener(bs,hn)})})}},[G,M,ut,an,et,j,_,L,Tt,x,y]),l.useEffect(()=>{var N,T;let A=(T=(N=H?.anchorSelect)!==null&&N!==void 0?N:i)!==null&&T!==void 0?T:"";!A&&t&&(A=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const J=new MutationObserver(se=>{const Pe=[],Ie=[];se.forEach(ie=>{if(ie.type==="attributes"&&ie.attributeName==="data-tooltip-id"&&(ie.target.getAttribute("data-tooltip-id")===t?Pe.push(ie.target):ie.oldValue===t&&Ie.push(ie.target)),ie.type==="childList"){if(G){const ve=[...ie.removedNodes].filter(U=>U.nodeType===1);if(A)try{Ie.push(...ve.filter(U=>U.matches(A))),Ie.push(...ve.flatMap(U=>[...U.querySelectorAll(A)]))}catch{}ve.some(U=>{var Mt;return!!(!((Mt=U?.contains)===null||Mt===void 0)&&Mt.call(U,G))&&(dt(!1),Q(!1),St(null),we(Ne),we(Xe),!0)})}if(A)try{const ve=[...ie.addedNodes].filter(U=>U.nodeType===1);Pe.push(...ve.filter(U=>U.matches(A))),Pe.push(...ve.flatMap(U=>[...U.querySelectorAll(A)]))}catch{}}}),(Pe.length||Ie.length)&&ln(ie=>[...ie.filter(ve=>!Ie.includes(ve)),...Pe])});return J.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{J.disconnect()}},[t,i,H?.anchorSelect,G]),l.useEffect(()=>{M()},[M]),l.useEffect(()=>{if(!Y?.current)return()=>null;const N=new ResizeObserver(()=>{setTimeout(()=>M())});return N.observe(Y.current),()=>{N.disconnect()}},[re,Y?.current]),l.useEffect(()=>{var N;const T=document.querySelector(`[id='${a}']`),A=[...et,T];G&&A.includes(G)||St((N=et[0])!==null&&N!==void 0?N:T)},[a,et,G]),l.useEffect(()=>(oe&&Q(!0),()=>{we(Ne),we(Xe)}),[]),l.useEffect(()=>{var N;let T=(N=H?.anchorSelect)!==null&&N!==void 0?N:i;if(!T&&t&&(T=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),T)try{const A=Array.from(document.querySelectorAll(T));ln(A)}catch{ln([])}},[t,i,H?.anchorSelect]),l.useEffect(()=>{Ne.current&&(we(Ne),cn(x))},[x]);const pe=(tn=H?.content)!==null&&tn!==void 0?tn:re,mt=me&&Object.keys(Ze.tooltipStyles).length>0;return l.useImperativeHandle(e,()=>({open:N=>{if(N?.anchorSelect)try{document.querySelector(N.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${N.anchorSelect}" is not a valid CSS selector`)}sn(N??null),N?.delay?cn(N.delay):Q(!0)},close:N=>{N?.delay?At(N.delay):Q(!1)},activeAnchor:G,place:Ze.place,isOpen:!!(ut&&!g&&pe&&mt)})),ut&&!g&&pe?tt.createElement(b,{id:t,role:ps,className:qs("react-tooltip",Ft.tooltip,ks.tooltip,ks[o],n,`react-tooltip__place-${Ze.place}`,Ft[mt?"show":"closing"],mt?"react-tooltip__show":"react-tooltip__closing",h==="fixed"&&Ft.fixed,w&&Ft.clickable),onTransitionEnd:N=>{we(nn),me||N.propertyName!=="opacity"||(dt(!1),sn(null),B?.())},style:{...Z,...Ze.tooltipStyles,opacity:On!==void 0&&mt?On:void 0},ref:ae},pe,tt.createElement(b,{className:qs("react-tooltip-arrow",Ft.arrow,ks.arrow,r,m&&Ft.noArrow),style:{...Ze.tooltipArrowStyles,background:Mn?`linear-gradient(to right bottom, transparent 50%, ${Mn} 50%)`:void 0,"--rt-arrow-size":`${kt}px`},ref:Et})):null},cf=({content:e})=>tt.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),ss=tt.forwardRef(({id:e,anchorId:t,anchorSelect:n,content:r,html:o,render:a,className:i,classNameArrow:u,variant:c="dark",place:d="top",offset:f=10,wrapper:h="div",children:p=null,events:b=["hover"],openOnClick:x=!1,positionStrategy:y="absolute",middlewares:v,delayShow:g=0,delayHide:m=0,float:w=!1,hidden:C=!1,noArrow:S=!1,clickable:k=!1,closeOnEsc:j=!1,closeOnScroll:_=!1,closeOnResize:L=!1,openEvents:F,closeEvents:Z,globalCloseEvents:be,imperativeModeOnly:Ae=!1,style:B,position:de,isOpen:re,defaultIsOpen:Y=!1,disableStyleInjection:W=!1,border:oe,opacity:We,arrowColor:G,arrowSize:St,setIsOpen:In,afterShow:On,afterHide:Mn,disableTooltip:kt,role:ps="tooltip"},tn)=>{const[ae,Et]=l.useState(r),[Ne,Xe]=l.useState(o),[nn,Ze]=l.useState(d),[xs,me]=l.useState(c),[$n,ut]=l.useState(f),[dt,H]=l.useState(g),[sn,rn]=l.useState(m),[on,an]=l.useState(w),[Dn,Rt]=l.useState(C),[et,ln]=l.useState(h),[ht,Tt]=l.useState(b),[gs,Lt]=l.useState(y),[ft,_e]=l.useState(null),[Q,Fn]=l.useState(null),cn=l.useRef(W),{anchorRefs:At,activeAnchor:un}=la(e),Pt=ee=>ee?.getAttributeNames().reduce((ye,R)=>{var M;return R.startsWith("data-tooltip-")&&(ye[R.replace(/^data-tooltip-/,"")]=(M=ee?.getAttribute(R))!==null&&M!==void 0?M:null),ye},{}),It=ee=>{const ye={place:R=>{var M;Ze((M=R)!==null&&M!==void 0?M:d)},content:R=>{Et(R??r)},html:R=>{Xe(R??o)},variant:R=>{var M;me((M=R)!==null&&M!==void 0?M:c)},offset:R=>{ut(R===null?f:Number(R))},wrapper:R=>{var M;ln((M=R)!==null&&M!==void 0?M:h)},events:R=>{const M=R?.split(" ");Tt(M??b)},"position-strategy":R=>{var M;Lt((M=R)!==null&&M!==void 0?M:y)},"delay-show":R=>{H(R===null?g:Number(R))},"delay-hide":R=>{rn(R===null?m:Number(R))},float:R=>{an(R===null?w:R==="true")},hidden:R=>{Rt(R===null?C:R==="true")},"class-name":R=>{_e(R)}};Object.values(ye).forEach(R=>R(null)),Object.entries(ee).forEach(([R,M])=>{var pe;(pe=ye[R])===null||pe===void 0||pe.call(ye,M)})};l.useEffect(()=>{Et(r)},[r]),l.useEffect(()=>{Xe(o)},[o]),l.useEffect(()=>{Ze(d)},[d]),l.useEffect(()=>{me(c)},[c]),l.useEffect(()=>{ut(f)},[f]),l.useEffect(()=>{H(g)},[g]),l.useEffect(()=>{rn(m)},[m]),l.useEffect(()=>{an(w)},[w]),l.useEffect(()=>{Rt(C)},[C]),l.useEffect(()=>{Lt(y)},[y]),l.useEffect(()=>{cn.current!==W&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")},[W]),l.useEffect(()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:W==="core",disableBase:W}}))},[]),l.useEffect(()=>{var ee;const ye=new Set(At);let R=n;if(!R&&e&&(R=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),R)try{document.querySelectorAll(R).forEach(T=>{ye.add({current:T})})}catch{console.warn(`[react-tooltip] "${R}" is not a valid CSS selector`)}const M=document.querySelector(`[id='${t}']`);if(M&&ye.add({current:M}),!ye.size)return()=>null;const pe=(ee=Q??M)!==null&&ee!==void 0?ee:un.current,mt=new MutationObserver(T=>{T.forEach(A=>{var J;if(!pe||A.type!=="attributes"||!(!((J=A.attributeName)===null||J===void 0)&&J.startsWith("data-tooltip-")))return;const se=Pt(pe);It(se)})}),N={attributes:!0,childList:!1,subtree:!1};if(pe){const T=Pt(pe);It(T),mt.observe(pe,N)}return()=>{mt.disconnect()}},[At,un,Q,t,n]),l.useEffect(()=>{B?.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),oe&&!Wr("border",`${oe}`)&&console.warn(`[react-tooltip] "${oe}" is not a valid \`border\`.`),B?.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),We&&!Wr("opacity",`${We}`)&&console.warn(`[react-tooltip] "${We}" is not a valid \`opacity\`.`)},[]);let Ot=p;const dn=l.useRef(null);if(a){const ee=a({content:Q?.getAttribute("data-tooltip-content")||ae||null,activeAnchor:Q});Ot=ee?tt.createElement("div",{ref:dn,className:"react-tooltip-content-wrapper"},ee):null}else ae&&(Ot=ae);Ne&&(Ot=tt.createElement(cf,{content:Ne}));const qn={forwardRef:tn,id:e,anchorId:t,anchorSelect:n,className:qs(i,ft),classNameArrow:u,content:Ot,contentWrapperRef:dn,place:nn,variant:xs,offset:$n,wrapper:et,events:ht,openOnClick:x,positionStrategy:gs,middlewares:v,delayShow:dt,delayHide:sn,float:on,hidden:Dn,noArrow:S,clickable:k,closeOnEsc:j,closeOnScroll:_,closeOnResize:L,openEvents:F,closeEvents:Z,globalCloseEvents:be,imperativeModeOnly:Ae,style:B,position:de,isOpen:re,defaultIsOpen:Y,border:oe,opacity:We,arrowColor:G,arrowSize:St,setIsOpen:In,afterShow:On,afterHide:Mn,disableTooltip:kt,activeAnchor:Q,setActiveAnchor:ee=>Fn(ee),role:ps};return tt.createElement(lf,{...qn})});typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",e=>{e.detail.disableCore||Br({css:":root{--rt-color-white:#fff;--rt-color-dark:#222;--rt-color-success:#8dc572;--rt-color-error:#be6464;--rt-color-warning:#f0ad4e;--rt-color-info:#337ab7;--rt-opacity:0.9;--rt-transition-show-delay:0.15s;--rt-transition-closing-delay:0.15s;--rt-arrow-size:8px}.core-styles-module_tooltip__3vRRp{position:absolute;top:0;left:0;pointer-events:none;opacity:0;will-change:opacity}.core-styles-module_fixed__pcSol{position:fixed}.core-styles-module_arrow__cvMwQ{position:absolute;background:inherit;z-index:-1}.core-styles-module_noArrow__xock6{display:none}.core-styles-module_clickable__ZuTTB{pointer-events:auto}.core-styles-module_show__Nt9eE{opacity:var(--rt-opacity);transition:opacity var(--rt-transition-show-delay)ease-out}.core-styles-module_closing__sGnxF{opacity:0;transition:opacity var(--rt-transition-closing-delay)ease-in}",type:"core"}),e.detail.disableBase||Br({css:`
4
- .styles-module_tooltip__mnnfp{padding:8px 16px;border-radius:3px;font-size:90%;width:max-content}.styles-module_arrow__K0L3T{width:var(--rt-arrow-size);height:var(--rt-arrow-size)}[class*='react-tooltip__place-top']>.styles-module_arrow__K0L3T{transform:rotate(45deg)}[class*='react-tooltip__place-right']>.styles-module_arrow__K0L3T{transform:rotate(135deg)}[class*='react-tooltip__place-bottom']>.styles-module_arrow__K0L3T{transform:rotate(225deg)}[class*='react-tooltip__place-left']>.styles-module_arrow__K0L3T{transform:rotate(315deg)}.styles-module_dark__xNqje{background:var(--rt-color-dark);color:var(--rt-color-white)}.styles-module_light__Z6W-X{background-color:var(--rt-color-white);color:var(--rt-color-dark)}.styles-module_success__A2AKt{background-color:var(--rt-color-success);color:var(--rt-color-white)}.styles-module_warning__SCK0X{background-color:var(--rt-color-warning);color:var(--rt-color-white)}.styles-module_error__JvumD{background-color:var(--rt-color-error);color:var(--rt-color-white)}.styles-module_info__BWdHW{background-color:var(--rt-color-info);color:var(--rt-color-white)}`,type:"base"})});const uf=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("circle",{cx:256,cy:256,r:32,fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32}),l.createElement("circle",{cx:256,cy:416,r:32,fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32}),l.createElement("circle",{cx:256,cy:96,r:32,fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32})),ca=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M320 146s24.36-12-64-12a160 160 0 10160 160",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M256 58l80 80-80 80"})),df=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("rect",{x:128,y:128,width:336,height:336,rx:57,ry:57,fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M383.5 128l.5-24a56.16 56.16 0 00-56-56H112a64.19 64.19 0 00-64 64v216a56.16 56.16 0 0056 56h24M296 216v160M376 296H216",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),hf=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("circle",{cx:128,cy:256,r:48,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("circle",{cx:384,cy:112,r:48,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("circle",{cx:384,cy:400,r:48,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M169.83 279.53l172.34 96.94M342.17 135.53l-172.34 96.94"})),ua=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M32 144h448M112 256h288M208 368h96"})),da=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M256 112v288M400 256H112"})),ff=()=>{const e=Zs(),t=Ic();return{rename:async r=>{if(e){const o=await Tn("New tab name",r);o&&await t.mutateAsync({id:e,payload:{name:o}})}return Promise.resolve()}}},ha=["shift","alt","meta","mod","ctrl","control"],mf={esc:"escape",return:"enter",left:"arrowleft",right:"arrowright",up:"arrowup",down:"arrowdown",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function rt(e){return(mf[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function fa(e){return ha.includes(e)}function Es(e,t=","){return e.toLowerCase().split(t)}function Rs(e,t="+",n=">",r=!1,o){let a=[],i=!1;e=e.trim(),e.includes(n)?(i=!0,a=e.toLocaleLowerCase().split(n).map(d=>rt(d))):a=e.toLocaleLowerCase().split(t).map(d=>rt(d));const u={alt:a.includes("alt"),ctrl:a.includes("ctrl")||a.includes("control"),shift:a.includes("shift"),meta:a.includes("meta"),mod:a.includes("mod"),useKey:r},c=a.filter(d=>!ha.includes(d));return{...u,keys:c,description:o,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&ma([rt(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&pa([rt(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Ke.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Ke.clear()},0)}));const Ke=new Set;function cr(e){return Array.isArray(e)}function pf(e,t=","){return(cr(e)?e:e.split(t)).every(n=>Ke.has(n.trim().toLowerCase()))}function ma(e){const t=Array.isArray(e)?e:[e];Ke.has("meta")&&Ke.forEach(n=>!fa(n)&&Ke.delete(n.toLowerCase())),t.forEach(n=>Ke.add(n.toLowerCase()))}function pa(e){const t=Array.isArray(e)?e:[e];e==="meta"?Ke.clear():t.forEach(n=>Ke.delete(n.toLowerCase()))}function xf(e,t,n){(typeof n=="function"&&n(e,t)||n===!0)&&e.preventDefault()}function gf(e,t,n){return typeof n=="function"?n(e,t):n===!0||n===void 0}const bf=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function yf(e){return xa(e,bf)}function xa(e,t=!1){const{target:n,composed:r}=e;let o,a;return vf(n)&&r?(o=e.composedPath()[0]&&e.composedPath()[0].tagName,a=e.composedPath()[0]&&e.composedPath()[0].role):(o=n&&n.tagName,a=n&&n.role),cr(t)?!!(o&&t&&t.some(i=>i.toLowerCase()===o.toLowerCase()||i===a)):!!(o&&t&&t)}function vf(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function wf(e,t){return e.length===0&&t?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),!0):t?e.some(n=>t.includes(n))||e.includes("*"):!0}const Cf=(e,t,n=!1)=>{const{alt:r,meta:o,mod:a,shift:i,ctrl:u,keys:c,useKey:d}=t,{code:f,key:h,ctrlKey:p,metaKey:b,shiftKey:x,altKey:y}=e,v=rt(f);if(d&&c?.length===1&&c.includes(h))return!0;if(!c?.includes(v)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(v))return!1;if(!n){if(r!==y&&v!=="alt"||i!==x&&v!=="shift")return!1;if(a){if(!b&&!p)return!1}else if(o!==b&&v!=="meta"&&v!=="os"||u!==p&&v!=="ctrl"&&v!=="control")return!1}return c&&c.length===1&&c.includes(v)?!0:c?pf(c):!c},jf=l.createContext(void 0),Nf=()=>l.useContext(jf);function ga(e,t){return e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(e).length===Object.keys(t).length&&Object.keys(e).reduce((n,r)=>n&&ga(e[r],t[r]),!0):e===t}const _f=l.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),Sf=()=>l.useContext(_f);function kf(e){const t=l.useRef(void 0);return ga(t.current,e)||(t.current=e),t.current}const Qr=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},Ef=typeof window<"u"?l.useLayoutEffect:l.useEffect;function ke(e,t,n,r){const o=l.useRef(null),a=l.useRef(!1),i=Array.isArray(n)?Array.isArray(r)?void 0:r:n,u=cr(e)?e.join(i?.delimiter):e,c=Array.isArray(n)?n:Array.isArray(r)?r:void 0,d=l.useCallback(t,c??[]),f=l.useRef(d);c?f.current=d:f.current=t;const h=kf(i),{activeScopes:p}=Sf(),b=Nf();return Ef(()=>{if(h?.enabled===!1||!wf(p,h?.scopes))return;let x=[],y;const v=(C,S=!1)=>{if(!(yf(C)&&!xa(C,h?.enableOnFormTags))){if(o.current!==null){const k=o.current.getRootNode();if((k instanceof Document||k instanceof ShadowRoot)&&k.activeElement!==o.current&&!o.current.contains(k.activeElement)){Qr(C);return}}C.target?.isContentEditable&&!h?.enableOnContentEditable||Es(u,h?.delimiter).forEach(k=>{if(k.includes(h?.splitKey??"+")&&k.includes(h?.sequenceSplitKey??">")){console.warn(`Hotkey ${k} contains both ${h?.splitKey??"+"} and ${h?.sequenceSplitKey??">"} which is not supported.`);return}const j=Rs(k,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description);if(j.isSequence){y=setTimeout(()=>{x=[]},h?.sequenceTimeoutMs??1e3);const _=j.useKey?C.key:rt(C.code);if(fa(_.toLowerCase()))return;x.push(_);const L=j.keys?.[x.length-1];if(_!==L){x=[],y&&clearTimeout(y);return}x.length===j.keys?.length&&(f.current(C,j),y&&clearTimeout(y),x=[])}else if(Cf(C,j,h?.ignoreModifiers)||j.keys?.includes("*")){if(h?.ignoreEventWhen?.(C)||S&&a.current)return;if(xf(C,j,h?.preventDefault),!gf(C,j,h?.enabled)){Qr(C);return}f.current(C,j),S||(a.current=!0)}})}},g=C=>{C.code!==void 0&&(ma(rt(C.code)),(h?.keydown===void 0&&h?.keyup!==!0||h?.keydown)&&v(C))},m=C=>{C.code!==void 0&&(pa(rt(C.code)),a.current=!1,h?.keyup&&v(C,!0))},w=o.current||i?.document||document;return w.addEventListener("keyup",m,i?.eventListenerOptions),w.addEventListener("keydown",g,i?.eventListenerOptions),b&&Es(u,h?.delimiter).forEach(C=>b.addHotkey(Rs(C,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description))),()=>{w.removeEventListener("keyup",m,i?.eventListenerOptions),w.removeEventListener("keydown",g,i?.eventListenerOptions),b&&Es(u,h?.delimiter).forEach(C=>b.removeHotkey(Rs(C,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description))),x=[],y&&clearTimeout(y)}},[u,h,p]),o}function Rf(){return s.jsxs("div",{className:"flex md:grid md:grid-cols-3 items-center bg-white overflow-auto no-scrollbar",children:[s.jsx(Tf,{}),s.jsx(Lf,{}),s.jsx(If,{})]})}function Tf(){const{dataSourceId:e}=l.useContext(Be),{data:t}=is(e),{state:{table:n}}=l.useContext(fe);return s.jsx("div",{className:E.tableConfig,children:t&&s.jsxs("div",{className:P(E.tableAction,E.greenFixed),"data-tooltip-id":"default","data-tooltip-content":n,children:[s.jsx(ct,{size:18,type:t.dbType}),s.jsx("p",{className:"text-sm",children:t.name}),s.jsx(Ye,{width:12,height:12}),s.jsx("p",{className:"text-sm",children:n})]})})}function Lf(){const{page:e,size:t,setPage:n}=Go(),{data:r,isFetching:o}=l.useContext(Le),a=e*t,i=!o&&!!r?.result.hasMore,u=r?.result.rows.length||0,c=()=>{e>0&&n(e-1)},d=()=>{i&&n(e+1)};return s.jsxs("div",{className:P(E.tableConfig,"justify-self-center"),children:[s.jsx("span",{"data-tooltip-content":"Previous page","data-tooltip-id":"default",className:P(E.tableAction,E.gray,e<1&&"opacity-30"),onClick:c,role:"button",children:s.jsx(Ye,{width:16,height:16,className:"rotate-180"})}),s.jsxs("span",{"data-tooltip-id":"rows-num",className:E.paginationIndicator,children:[a+1," - ",a+u,i&&"+"]}),s.jsx("span",{"data-tooltip-content":"Next page","data-tooltip-id":"default",className:P(E.tableAction,i?E.gray:"opacity-30"),onClick:d,role:"button",children:s.jsx(Ye,{width:16,height:16})})]})}const Af=[5,10,20,50,100,200],Pf=!__CLIENT_CONFIG__.skipAuth;function If(){const{dataSourceId:e,name:t}=l.useContext(Be),{data:n}=is(e),{data:r,refetch:o}=l.useContext(Le),a=Rn(he.EDITOR),i=mh(),{rename:u}=ff(),{size:c,setSize:d}=Go(),{state:f}=l.useContext(fe),h=Zt(),p=V(),b=()=>{h.mutateAsync({name:t,opts:f}).then(m=>{p(I.workbenchTab.build({id:m.id}))})},x=()=>{if(r?.result.queryHistoryId){const m=new URL(window.location.href);m.pathname=I.share.build(),m.searchParams.set("shareId",r.result.queryHistoryId),navigator.clipboard.writeText(m.toString()),Ce.success("Share link copied to clipboard")}},y=()=>{r?.result.columns?.[0].table&&Js({table:r?.result.columns?.[0].table,dataSourceId:e})},v=async()=>{const m=await Tn("Query name",t);!m||!r?.result.queryHistoryId||i.mutate({name:m,queryId:r.result.queryHistoryId})},g=()=>u(t);return ke("s",v),ke("r",g),ke("d",b),s.jsxs("div",{className:"flex justify-self-end",children:[s.jsx("span",{"data-tooltip-content":"Show filters","data-tooltip-id":"default",className:P(E.tableAction,E.gray),onClick:()=>Oe("filters"),role:"button",children:s.jsx(ua,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Join table","data-tooltip-id":"default",className:P(E.tableAction,E.gray),onClick:()=>Oe("joins"),role:"button",children:s.jsx(da,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Refresh data","data-tooltip-id":"default",className:P(E.tableAction,E.gray),onClick:()=>o(),role:"button",children:s.jsx(ca,{width:16,height:16})}),Pf&&s.jsx("span",{"data-tooltip-content":"Share query","data-tooltip-id":"default",className:P(E.tableAction,E.gray),onClick:x,role:"button",children:s.jsx(hf,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Duplicate tab","data-tooltip-id":"default",className:P(E.tableAction,E.gray),onClick:b,role:"button",children:s.jsx(df,{width:16,height:16})}),s.jsx(ss,{id:"rows-num",className:"z-10 shadow-md flex gap-1",clickable:!0,variant:"light",opacity:1,children:Af.map(m=>s.jsx("button",{onClick:()=>d(m,!0),className:P(E.tableAction,E.gray,m===c&&E.selectedSize),children:s.jsx("span",{children:m})},m))}),s.jsx("button",{"data-tooltip-id":"explorer-more-actions",className:P(E.tableAction,E.gray),children:s.jsx(uf,{width:16,height:16})}),s.jsxs(ss,{id:"explorer-more-actions",className:"z-10 shadow-md flex flex-col",clickable:!0,variant:"light",opacity:1,children:[s.jsxs("button",{onClick:()=>Oe("columns"),className:P(E.tableAction,E.modal,E.gray,"justify-between"),children:[s.jsx("span",{children:"Columns"}),s.jsx("span",{className:"hotkey",children:"C"})]}),s.jsxs("button",{onClick:()=>Oe("groupBy"),className:P(E.tableAction,E.modal,E.gray,"justify-between"),children:[s.jsx("span",{children:"Group by"}),s.jsx("span",{className:"hotkey",children:"G"})]}),s.jsxs("button",{onClick:()=>Oe("aggregate"),className:P(E.tableAction,E.modal,E.gray,"justify-between"),children:[s.jsx("span",{children:"Aggregate"}),s.jsx("span",{className:"hotkey",children:"A"})]}),s.jsx("div",{className:"h-0.5 my-2 bg-gray-100"}),s.jsxs("button",{onClick:g,className:P(E.tableAction,E.modal,E.gray,"justify-between"),children:[s.jsx("span",{children:"Rename tab"}),s.jsx("span",{className:"hotkey",children:"R"})]}),a&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:v,className:P(E.tableAction,E.modal,E.gray),children:[s.jsx("span",{children:"Save query"}),s.jsx("span",{className:"hotkey",children:"S"})]}),n?.allowInsert===!0&&s.jsx("button",{onClick:y,className:P(E.tableAction,E.modal,E.gray),children:"Insert new row"})]})]})]})}const Of="_drop-container_162ll_2",Mf="_item_162ll_2",Vr={dropContainer:Of,item:Mf},ba=({dataSourceId:e,inputClassName:t,focusId:n,placeholder:r="Column",onChange:o,value:a,autoFocus:i,allowTables:u})=>{const{data:c}=Sn(e),d=l.useRef(null),f=l.useMemo(()=>{if(!c)return[];let m=c;return u&&(m=c.filter(w=>u.includes(w.tableName))),m.flatMap(w=>w.columns.map(C=>({value:w.tableName+"."+C.name,label:C.name,table:w.tableName,searchValue:C.name.toLowerCase()})))},[c,u]),h=l.useMemo(()=>{const m=a.toLowerCase()||"",w=[];for(let C=0;C<f.length&&w.length<10;C++)f[C].searchValue.includes(m)&&w.push(f[C]);return w},[f,a]),[p,b]=l.useState(!1),[x,y]=l.useState(0),v=m=>{if(m.key==="ArrowDown")m.preventDefault(),y(w=>(w+1)%h.length);else if(m.key==="ArrowUp")m.preventDefault(),y(w=>(w-1+h.length)%h.length);else if(m.key==="Enter"&&x>=0&&x<h.length){m.preventDefault();const w=h[x].value;b(!1);const C=f.findIndex(S=>S.value===w)>-1;o(h[x]?.value||w,C,!0)}};l.useEffect(()=>{const m=d.current?.querySelector('[data-is-active="true"]');m&&m.scrollIntoView({behavior:"smooth",block:"nearest"})},[x]);const g=m=>{const w=m.currentTarget.value,C=f.findIndex(S=>S.value===w)>-1;o(w,C,!1)};return s.jsxs("div",{className:"relative",onFocus:()=>b(!0),onBlur:()=>b(!1),children:[s.jsx("input",{autoFocus:i,onKeyDown:v,value:a,onChange:g,className:t,placeholder:r,"data-focus":n}),p&&h.length>0&&s.jsx("div",{className:Vr.dropContainer,ref:d,tabIndex:-1,children:h.map((m,w)=>s.jsxs("div",{className:Vr.item,"data-is-active":x===w,onMouseDownCapture:C=>{C.preventDefault(),b(!1),o(m.value,!0,!0)},children:[s.jsx("span",{className:"text-xs font-semibold truncate",children:m.table}),s.jsx("p",{className:"truncate text-sm",children:m.label})]},w))})]})},$f="_actions_1mi2a_2",Df="_filter-actions_1mi2a_2",Ff="_advanced-filter-icon_1mi2a_2",qf="_filters-container_1mi2a_2",Bf="_filter-container_1mi2a_2",yn={actions:$f,filterActions:Df,advancedFilterIcon:Ff,filtersContainer:qf,filterContainer:Bf},Uf=({filter:e,dataSourceId:t,allowedTables:n,autoFocus:r,onChangeColumn:o,onChangeValue:a,onRemoveFilter:i,onChangeAdvancedFilter:u,triggerIsEnabled:c,onSubmit:d})=>{const f=p=>{const b=p.target.value;b.charAt(0)===":"?u(e.id,!0):(!e.isAdvanced&&["=","<",">"].includes(b.charAt(0))&&u(e.id,!0),a(e.id,p.currentTarget.value))},h=p=>{p.key==="Backspace"?(e.value.length===0||p.currentTarget.selectionEnd===0)&&u(e.id,!1):p.key==="Enter"&&d()};return s.jsxs("div",{className:yn.filterContainer,children:[s.jsx("input",{type:"checkbox",checked:e.isEnabled!==!1,onClick:()=>c(e.id)}),s.jsx(ba,{dataSourceId:t,onChange:p=>o(e.id,p),value:e.column,allowTables:n,focusId:"column",inputClassName:"input w-full",autoFocus:r}),s.jsxs("div",{className:"flex items-center",children:[e.isAdvanced&&s.jsx("span",{className:yn.advancedFilterIcon,children:s.jsx(ua,{width:14,height:14})}),s.jsx("input",{placeholder:"Filter value",value:e.value,onChange:f,onKeyDown:h,"data-focus":"value",className:"input flex-1"},e.id)]}),s.jsx("div",{className:yn.filterActions,children:s.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove filter",className:"p-0.5 text-sm cursor-pointer rounded-md",onClick:()=>i(e.id),children:s.jsx(jt,{width:20,height:20,className:"text-red-600"})})})]})},Wf=()=>{const{state:e}=l.useContext(fe),{refetch:t}=l.useContext(Le),{setFilters:n}=tr(),r=us(y=>y.filters),o=l.useMemo(()=>[e.table,...e.joins.map(y=>y.table)],[e.table,e.joins]),[a,i]=l.useState([]),u=(y,v)=>{i(g=>[...g.map(m=>m.id===y?{...m,column:v}:m)])},c=(y,v)=>{i(g=>[...g.map(m=>m.id===y?{...m,value:v}:m)])},d=()=>{i(y=>[...y,{id:ot(),value:"",column:"",isEnabled:!0}])},f=y=>{i(v=>v.filter(g=>g.id!==y))},h=(y,v)=>{i(g=>g.map(m=>m.id===y?{...m,isAdvanced:v}:m))},p=()=>ds("filters"),b=()=>{try{n(a.filter(y=>y.value.length>0&&y.column.length>0)),setTimeout(t,1),p()}catch(y){y instanceof Error?Ce.error(y.message):Ce.error("Error during parsing, check you filters")}},x=y=>{i(v=>v.map(g=>g.id===y?{...g,isEnabled:!g.isEnabled}:g))};return l.useEffect(()=>{r&&i(()=>[...e.filters,{id:ot(),value:"",column:"",isEnabled:!0}])},[r]),ke("f",()=>{Zn("filters")}),s.jsxs(ge,{isVisible:r,onClose:p,portal:!0,onClosed:()=>i([]),noPadding:!0,children:[s.jsx(lt,{onClick:p}),s.jsx("h2",{className:"text-lg font-semibold m-2",children:"Filters"}),s.jsxs("div",{className:yn.filtersContainer,children:[a.length<1&&s.jsx("p",{className:"p-1 text-center rounded-lg bg-gray-50 border border-gray-200",children:"No filters"}),a.map((y,v)=>s.jsx(Uf,{filter:y,dataSourceId:e.dataSourceId,allowedTables:o,onChangeColumn:u,onChangeValue:c,onRemoveFilter:f,onChangeAdvancedFilter:h,triggerIsEnabled:x,onSubmit:b,autoFocus:v===a.length-1},y.id))]}),s.jsxs("div",{className:yn.actions,children:[s.jsxs("button",{className:"button tertiary flex items-center gap-1 text-sm",onClick:d,children:[s.jsx(da,{width:20,height:20}),s.jsx("span",{children:"Add filter"})]}),s.jsx("button",{className:"button primary text-sm",onClick:b,children:"Apply filters"})]})]})},Hf="_join-modal_1y0cc_2",zf={joinModal:Hf},Kf=(e,t)=>e.type!==t.type||e.on!==t.on||e.table!==t.table,Qf=(e,t)=>e.type===t.type&&e.on===t.on&&e.table===t.table,ya=()=>{const{state:e,setState:t}=l.useContext(fe),n=l.useCallback(r=>{t(o=>{const a=o.joins;if(a.some(u=>Qf(u,r))){const u=r.table+".";return{...o,joins:a.filter(c=>Kf(c,r)),columns:o.columns.filter(c=>!c.value.startsWith(u)),groupBy:o.groupBy.filter(c=>!c.value.startsWith(u)),orderBy:o.orderBy.filter(c=>!c.column.startsWith(u)),aggregations:o.aggregations.filter(c=>!c.value.startsWith(u)),filters:o.filters.filter(c=>!c.column.startsWith(u))}}return{...o,joins:[...a,r]}})},[t]);return{joins:e.joins,toggle:n}},Vf=()=>{const{isFetching:e}=l.useContext(Le),t=us(c=>c.joins),{toggle:n}=ya(),{availableJoins:r}=l.useContext(Be),[o,a]=l.useState(""),i=l.useMemo(()=>{const c=o.toLowerCase();return r.filter(d=>d.on.toTable.toLowerCase().includes(c))},[r,o]),u=()=>ds("joins");return ke("j",()=>{r.length>0?Oe("joins"):Ce.error("No available tables to join")}),s.jsxs(ge,{isVisible:t,onClose:u,portal:!0,children:[s.jsx(lt,{onClick:u}),s.jsxs("div",{className:zf.joinModal,children:[s.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Join table"}),r.length>0?s.jsx("input",{className:"input w-full",placeholder:"Filter",autoFocus:!0,onChange:c=>a(c.target.value),value:o,disabled:e}):s.jsx(ne,{variant:"warning",children:s.jsx("p",{className:"text-sm truncate",children:"There is nothing else to join"})}),s.jsx("div",{className:`flex flex-col mt-2 overflow-y-auto ${e?"opacity-40":""}`,children:i.map(c=>s.jsx(zo,{hook:c,onClick:()=>{e||(n({table:c.on.toTable,type:"LEFT",on:c.where}),a(""),u())}},c.where))})]})]})};function Yf(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}function Yr(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}const Gf="_container_iegon_2",Jf="_column-label_iegon_2",Xf="_not-active_iegon_2",Gn={container:Gf,columnLabel:Jf,notActive:Xf};function Zf(e){if(!e)return[];const t={};return e.forEach(n=>{t[n.table]?t[n.table].push({value:n.full,ogColumn:n.column,label:nt(n.column),type:n.type}):t[n.table]=[{value:n.full,ogColumn:n.column,label:nt(n.column),type:n.type}],rc[n.type]&&["YEAR","MONTH","DAY"].forEach(r=>{t[n.table].push({value:r+" "+n.full,ogColumn:n.column,label:r+" "+nt(n.column),type:"number",nested:!0})})}),Object.entries(t).reduce((n,[r,o])=>(n.push({name:nt(r),columns:o}),n),[])}function em(e,t){const n=t.toLowerCase();return e.map(r=>{const o=r.columns.filter(a=>a.label.toLowerCase().includes(n)||a.ogColumn.toLowerCase().includes(n));return{...r,columns:o}}).filter(r=>r.columns.length>0)}const tm=({column:e,selected:t,onCheck:n})=>s.jsxs("label",{className:P(Gn.columnLabel,t?Gn.active:Gn.notActive,e.nested&&"pl-5!"),children:[s.jsx("input",{type:"checkbox",checked:t[e.value],name:e.value,onChange:n}),s.jsxs("p",{className:"flex justify-between w-full",children:[s.jsx("span",{"data-tooltip-content":e.value,"data-tooltip-id":"default",children:e.label}),s.jsx("span",{className:"text-blue-600",children:e.type})]})]},e.value),nm={columns:"c",groupBy:"g"},Gr=({mode:e})=>{const t=us(m=>m[e]),{allColumns:n}=l.useContext(Be),{state:r,setState:o}=l.useContext(fe),[a,i]=l.useState({}),[u,c]=l.useState(""),d=l.useMemo(()=>Zf(n),[n]),f=r.aggregations.length>0||r.groupBy.length>0,h=l.useMemo(()=>u?em(d,u):d,[u,d]),p=m=>{i(w=>({...w,[m.target.name]:m.target.checked}))},b=m=>{const w=m.target.checked;i(C=>{for(const S of n)C[S.full]=w;return{...C}})},x=()=>{ds(e)},y=()=>{const m=[];for(const[w,C]of Object.entries(a))if(C){const[S,k]=w.split(" ");m.push({value:k||S,fn:k?S:void 0})}o(w=>({...w,[e]:m})),x()},v=l.useMemo(()=>{for(const m of n)if(!a[m.full])return!1;return!0},[a,n]);ke(nm[e],()=>{e==="columns"?f?Ce.error("Columns are ignored when there is at least one aggregation or group by"):Zn("columns"):Zn("groupBy")}),l.useEffect(()=>{t&&i(()=>Yf(r[e].map(m=>m.fn?m.fn+" "+m.value:m.value)))},[t,i]);const g=()=>{c(""),i({})};return s.jsxs(ge,{isVisible:t,onClose:x,portal:!0,onClosed:g,children:[s.jsx(lt,{onClick:x}),s.jsxs("div",{className:Gn.container,children:[s.jsx("h2",{className:"text-lg font-semibold",children:e==="groupBy"?"Group by":"Show columns"}),s.jsx("input",{autoFocus:!0,className:"input my-2",placeholder:"Filter",value:u,onChange:m=>c(m.target.value)}),s.jsx("div",{className:"overflow-y-auto",children:h.map(m=>s.jsxs("div",{className:"my-2",children:[s.jsxs("p",{className:"font-semibold sticky top-0 bg-white p-1 z-1",children:["📄 ",m.name]}),m.columns.map(w=>s.jsx(tm,{column:w,selected:a,onCheck:p},w.value))]},m.name))}),s.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[s.jsxs("label",{className:"button tertiary flex gap-2 items-center",children:[s.jsx("input",{type:"checkbox",checked:v,onChange:b}),s.jsx("span",{children:"Select all"})]}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{className:"button tertiary",onClick:x,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:y,children:"Apply"})]})]})]})},sm="_options-container_1v6u6_2",rm={optionsContainer:sm},Ts="COUNT all",om=()=>{const e=us(x=>x.aggregate),{dataSourceId:t}=l.useContext(Be),{setState:n,state:r}=l.useContext(fe),{data:o}=l.useContext(Le),[a,i]=l.useState({fn:"",col:""}),u=x=>i({...a,fn:x.currentTarget.value}),c=x=>i({...a,col:x}),d=()=>ds("aggregate"),f=()=>{const x=a.fn===Ts?{value:"*",fn:"COUNT"}:{fn:a.fn,value:a.col,distinct:a.fn==="COUNT"};n(y=>({...y,aggregations:[...y.aggregations,x]}))},h=a.fn===Ts,p=h?!1:!a.col||!a.fn,b=x=>{const y=Ao(x);n(v=>({...v,aggregations:v.aggregations.filter(g=>g.fn!==x.fn||g.value!==x.value),orderBy:v.orderBy.filter(g=>g.column!==y)}))};return ke("a",()=>{Zn("aggregate")}),s.jsxs(ge,{isVisible:e,onClose:d,backdropClose:!0,portal:!0,children:[s.jsx(lt,{onClick:d}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold",children:"Aggregate"}),$e(r.aggregations.length,0)&&s.jsx("div",{className:"flex flex-col gap-1 mt-4",children:r.aggregations.map((x,y)=>s.jsxs("p",{className:"p-2 rounded-md bg-gray-50 flex items-center justify-between",children:[s.jsx("span",{children:Vn(x)}),s.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove aggregation",className:"p-0.5 text-sm cursor-pointer",onClick:()=>b(x),children:s.jsx(jt,{width:20,height:20,className:"text-red-600"})})]},y))}),s.jsxs("div",{className:rm.optionsContainer,children:[s.jsxs("label",{className:P(h&&"col-span-2"),children:[s.jsx("p",{className:"font-semibold text-xs",children:"Function"}),s.jsxs("select",{className:"input w-full",value:a.fn,onChange:u,autoFocus:!0,children:[s.jsx("option",{value:"",disabled:!0,children:"Select function"}),s.jsx("option",{value:Ts,children:"Count all rows"}),s.jsx("option",{value:"COUNT",children:"Count"}),s.jsx("option",{value:"SUM",children:"Sum"}),s.jsx("option",{value:"MAX",children:"Max"}),s.jsx("option",{value:"MIN",children:"Min"}),s.jsx("option",{value:"AVG",children:"Avg"})]})]}),!h&&s.jsxs("label",{children:[s.jsx("p",{className:"font-semibold text-xs",children:"Column"}),s.jsx(ba,{inputClassName:"input w-full",dataSourceId:t,allowTables:o?.result.tables||[],onChange:c,value:a.col})]}),s.jsx("button",{className:"button primary",disabled:p,onClick:f,children:"Add"})]})]})]})},am="_container_96y8i_2",im="_yellow-pill_96y8i_2 _pill_96y8i_2",lm="_blue-pill_96y8i_2 _pill_96y8i_2",cm="_purple-pill_96y8i_2 _pill_96y8i_2",um="_red-pill_96y8i_2 _pill_96y8i_2",dm="_black-pill_96y8i_2 _pill_96y8i_2",hm="_disabled-pill_96y8i_2",bt={container:am,yellowPill:im,bluePill:lm,purplePill:cm,redPill:um,blackPill:dm,disabledPill:hm};function va(e,t=500,n){const[r,o]=l.useState(e),a=l.useRef(n);return a.current=n,l.useEffect(()=>{const i=setTimeout(()=>{o(e),a.current&&a.current(e)},t);return()=>clearTimeout(i)},[e,t]),r}function fm(e){return!(e===!0||e===void 0)}const mm=()=>{const{state:{aggregations:e,columns:t,groupBy:n}}=l.useContext(fe),{toggle:r,joins:o}=ya(),{filters:a,setFilters:i,removeFilter:u}=tr(),c=()=>Oe("joins"),d=()=>Oe("aggregate"),f=()=>Oe("columns"),h=()=>Oe("groupBy"),p=y=>{y.preventDefault(),y.stopPropagation(),r(o[o.length-1])},b=y=>{i(a.map(v=>({...v,isEnabled:y===v.id?fm(v.isEnabled):v.isEnabled})),!0)},x=y=>v=>{v.preventDefault(),v.stopPropagation(),u(y)};return a.length>0||o.length>0||n.length>0||t.length>0||e.length>0?s.jsxs("div",{className:bt.container,children:[o.map((y,v)=>s.jsxs("button",{onClick:c,className:bt.yellowPill,"data-tooltip-id":"default","data-tooltip-content":`Joins ${y.table} on ${y.on}`,children:[s.jsx("p",{className:"text-sm",children:y.table}),v===o.length-1&&s.jsx(jt,{onClick:p,width:18,height:18})]},y.table)),a.map(y=>s.jsxs("button",{onClick:()=>b(y.id),onAuxClick:()=>u(y.id),className:P(bt.bluePill,y.isEnabled===!1&&bt.disabledPill),"data-tooltip-id":"default","data-tooltip-content":`${y.column} ${y.value}`,children:[s.jsx("p",{className:"text-sm",children:y.column}),s.jsx("p",{className:"text-sm",children:y.value}),s.jsx(jt,{onClick:x(y.id),width:18,height:18})]},y.id)),e.map(y=>s.jsx("button",{onClick:d,className:P(bt.purplePill),"data-tooltip-id":"default","data-tooltip-content":Vn(y),children:s.jsx("p",{className:"text-sm",children:Vn(y)})},Vn(y))),t.length>0&&s.jsx("button",{onClick:f,className:P(bt.redPill),"data-tooltip-id":"default","data-tooltip-content":"Has hidden columns",children:s.jsx("p",{className:"text-sm",children:"Hidden columns"})}),n.length>0&&s.jsx("button",{onClick:h,className:P(bt.blackPill),"data-tooltip-id":"default","data-tooltip-content":"Has GROUP BY",children:s.jsx("p",{className:"text-sm",children:"Grouped columns"})}),!1]}):null},pm=({options:e,updater:t,name:n,tabId:r})=>{const o=jc(e,t),a=Oc(r,o.state),i=Cc(a.data,o.state.dataSourceId,n,r);return s.jsx(Be,{value:i,children:s.jsx(fe,{value:o,children:s.jsxs(Le,{value:a,children:[s.jsx(Rf,{}),s.jsx(mm,{}),s.jsxs("div",{className:"flex-1 flex overflow-hidden border-t border-t-gray-200",children:[s.jsx("div",{className:"flex-1 overflow-auto pb-24 lg:pb-12 no-scrollbar",children:s.jsx(fh,{})}),s.jsx(Wf,{}),s.jsx(Vf,{}),s.jsx(Gr,{mode:"columns"}),s.jsx(Gr,{mode:"groupBy"}),s.jsx(om,{})]})]})})})},ur=()=>s.jsxs("div",{role:"status",children:[s.jsxs("svg",{"aria-hidden":"true",className:"w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),s.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]}),s.jsx("span",{className:"sr-only",children:"Loading..."})]}),xm=({id:e})=>{const{data:t}=Ac(e),n=l.useCallback(r=>{if(!t)return;const o=r(Xt(t.opts));K.setQueryData(["workbench-tabs",t.id],{...t,opts:{...t.opts,...o}})},[t]);return t?s.jsx(pm,{updater:n,options:t.opts,name:t.name,tabId:t.id}):s.jsx("div",{className:"flex-1 flex justify-center items-center",children:s.jsx(ur,{})})},gm=e=>{setTimeout(t=>{const n=document.querySelector(`[data-tab-id="${t}"]`);n&&n.scrollIntoView({behavior:"smooth"})},50,e)},bm=()=>{const{id:e}=vi(),t=V(),{data:n}=ls(),r=Pc(),o=qo(er.laptop),a=c=>{if(c===e&&n){if(n.length===1)return t(I.home.build());if(n.length>1){const d=n.find(f=>f.id!==c);if(d)return t(`/workbench/tab/${d.id}`)}}},i=c=>{c.stopPropagation(),c.preventDefault();const d=c.currentTarget.getAttribute("data-tab-id");d&&(r.mutate(d),a(d))},u=c=>{r.mutate(c),a(c)};return l.useEffect(()=>{e&&gm(e)},[e,n]),s.jsxs("div",{className:"h-screen max-h-screen bg-(--bg) flex flex-col",children:[e?s.jsx(xm,{id:e}):s.jsx("div",{className:"flex-1"}),s.jsx("div",{className:P(xn.tabs,"no-scrollbar",!o&&xn.mobile),children:n?.map(c=>s.jsxs("div",{onClick:()=>t(I.workbenchTab.build({id:c.id})),className:P(xn.tab,c.id===e&&xn.active),"data-tooltip-id":"default","data-tab-id":c.id,"data-tooltip-content":c.name,onAuxClick:()=>u(c.id),children:[s.jsxs("span",{className:"truncate w-full",children:["🛠️ ",c.name]}),s.jsx("button",{"data-tab-id":c.id,className:xn.closeButton,onClick:i,children:s.jsx(jt,{width:20,height:20})})]},c.id))})]})},ym="_root_fdxwq_2",vm="_up_fdxwq_2",wm="_down_fdxwq_2",Cm="_chevron_fdxwq_2",jm="_table-name-container_fdxwq_2",Nm="_link_fdxwq_2",_m="_table-name_fdxwq_2",Sm="_ul_fdxwq_2",km="_column-type_fdxwq_2",Em="_action-blue_fdxwq_2 _action_fdxwq_2",Rm="_action-red_fdxwq_2 _action_fdxwq_2",Tm="_db-header-container_fdxwq_2",Lm="_db-header_fdxwq_2",Am="_db-subheader_fdxwq_2 _db-header_fdxwq_2",te={root:ym,up:vm,down:wm,chevron:Cm,tableNameContainer:jm,link:Nm,tableName:_m,ul:Sm,columnType:km,actionBlue:Em,actionRed:Rm,dbHeaderContainer:Tm,dbHeader:Lm,dbSubheader:Am},Pm="_sidebar_80lj1_2",Im="_sidebar-visible_80lj1_2",Om="_sidebar-container_80lj1_2",Mm="_sidebar-invisible_80lj1_2",$m="_backdrop_80lj1_2",gn={sidebar:Pm,sidebarVisible:Im,sidebarContainer:Om,sidebarInvisible:Mm,backdrop:$m},wa=({children:e,backdropClose:t,isVisible:n,onClose:r,onClosed:o,contentClassName:a})=>{const[i,u]=l.useState(!1),c=l.useRef(r);c.current=r;const d=()=>{t&&r()},f=h=>{n||getComputedStyle(h.currentTarget).opacity==="0"&&(u(!1),o&&o())};return l.useEffect(()=>{n&&u(!0)},[n]),l.useEffect(()=>{const h=p=>{n&&p.key==="Escape"&&c.current()};return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h)}},[n]),s.jsxs("div",{onTransitionEnd:f,className:P(gn.sidebar,n?gn.sidebarVisible:gn.sidebarInvisible),children:[s.jsx("div",{onClick:d,className:gn.backdrop}),s.jsx("div",{className:P(gn.sidebarContainer,a),children:i&&e})]})},Dm=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M384 224v184a40 40 0 01-40 40H104a40 40 0 01-40-40V168a40 40 0 0140-40h167.48M336 64h112v112M224 288L440 72",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),Fm=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M364.13 125.25L87 403l-23 45 44.99-23 277.76-277.13-22.62-22.62zM420.69 68.69l-22.62 22.62 22.62 22.63 22.62-22.63a16 16 0 000-22.62h0a16 16 0 00-22.62 0z"})),qm=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M432 144l-28.67 275.74A32 32 0 01371.55 448H140.46a32 32 0 01-31.78-28.26L80 144",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("rect",{x:32,y:64,width:448,height:80,rx:16,ry:16,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M312 240L200 352M312 352L200 240"})),Ca=(e,t=!0)=>{const n=navigator.clipboard.writeText(e);t&&n.then(()=>{Ce.success(`Copied "${e}"`)})},Bm=new Intl.DateTimeFormat("en",{dateStyle:"full",timeStyle:"long"}),zn=18;function Um(e,t){return t&&e.toLowerCase().includes(t)?"bg-yellow-200 cursor-pointer":"cursor-pointer"}const Wm=({insp:e,filter:t,expanded:n})=>{const r=l.useMemo(()=>n?e.columns:t.length<1?[]:e.columns.filter(o=>o.name.toLowerCase().includes(t)),[e,t,n]);return s.jsx("ul",{className:te.ul,children:r.map(o=>s.jsx(s.Fragment,{children:s.jsxs("li",{children:[o.isPrimary?"🔐":"🏷️"," ",s.jsx("span",{onClick:()=>Ca(o.name),className:Um(o.name,t),children:o.name})," ",s.jsxs("span",{className:te.columnType,children:["[",o.type,"]"]}),o.ref&&s.jsxs("span",{children:[" ➡️ ",s.jsx("span",{className:te.columnType,children:o.ref.table}),".",o.ref.field]})]},o.name+o.type)}))},e.id)};function Hm({id:e}){const{data:t}=is(e),{data:n}=Sn(e),r=V(),o=zl(),a=Ro(),i=Kl(),u=Zt(),c=l.useMemo(()=>t?.lastInspected?Bm.format(new Date(t.lastInspected)):"--",[t]),[d,f]=l.useState({}),[h,p]=l.useState(""),[b,x]=l.useState("table"),y=Rn(he.EDITOR),v=h.toLowerCase(),g=l.useMemo(()=>{if(!v||!n)return n||[];const _=[];for(const L of n){if(L.tableName.toLowerCase().includes(v)){_.push(L);continue}b!=="table"&&L.columns.findIndex(F=>F.name.toLowerCase().includes(v))>=0&&_.push(L)}return _},[v,n,b]),m=_=>{f(L=>({...L,[_]:!L[_]}))},w=_=>{u.mutateAsync({name:_,opts:Xt({table:_,dataSourceId:e})}).then(L=>{Ht(void 0),r(I.workbenchTab.build({id:L.id}))})},C=()=>{a.mutate(e)},S=async()=>{const _=await Tn("Enter name",t?.name);_&&o.mutate({id:e,dataSource:{name:_}})},k=async()=>{await Do("Are you sure you want to delete this data source?")&&(i.mutate(e),Ht(void 0))},j=b==="column";return s.jsxs("div",{className:te.root,children:[s.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-4 py-2 z-1",children:[s.jsxs("div",{className:te.dbHeaderContainer,children:[s.jsxs("div",{className:te.dbHeader,children:[t&&s.jsx(ct,{size:24,type:t.dbType}),s.jsx("p",{className:"truncate text-(--text-color-primary) text-lg",children:t?.name})]}),s.jsxs("div",{className:te.dbSubheader,children:[s.jsx("p",{className:"text-xs text-(--text-color-secondary) truncate",children:c}),y&&s.jsxs("div",{className:"flex justify-end",children:[s.jsx("button",{disabled:a.isPending,onClick:C,className:te.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Refresh schema",children:s.jsx(ca,{width:16,height:16})}),s.jsx("button",{disabled:a.isPending,onClick:S,className:te.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Update name",children:s.jsx(Fm,{width:16,height:16})}),s.jsx("button",{disabled:a.isPending,onClick:k,className:te.actionRed,"data-tooltip-id":"default-xs","data-tooltip-content":"Delete data source",children:s.jsx(qm,{width:16,height:16})})]})]})]}),s.jsxs("div",{className:"flex gap-2 items-center mt-2",children:[s.jsxs("select",{className:"input",value:b,onChange:_=>x(_.currentTarget.value),children:[s.jsx("option",{value:"table",children:"Table"}),s.jsx("option",{value:"column",children:"Column"})]}),s.jsx("input",{className:"input flex-1 bg-gray-50",placeholder:j?"Search column":"Search table",value:h,onChange:_=>p(_.target.value),autoFocus:!0})]})]}),s.jsx("div",{className:"overflow-y-auto p-4",children:g?.map(_=>s.jsxs("div",{children:[s.jsxs("div",{className:te.tableNameContainer,children:[s.jsx("button",{className:P(te.chevron,d[_.id]?te.down:te.up),onClick:()=>m(_.id),children:s.jsx(Ye,{width:16,height:16})}),s.jsx("button",{className:P(te.tableName,"flex-1"),onClick:()=>m(_.id),children:_.tableName}),s.jsx("button",{className:te.link,onClick:()=>w(_.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Explore table data",children:s.jsx(Dm,{width:zn,height:zn})}),s.jsx("button",{className:te.link,onClick:()=>Ca(_.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Copy table name",children:s.jsx(Yo,{width:zn,height:zn})})]}),(d[_.id]||h.length>0)&&s.jsx(Wm,{insp:_,filter:j?v:"",expanded:d[_.id]})]},_.id))})]})}const zm=()=>{const e=mu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const r=()=>Ht(void 0);return s.jsx(wa,{isVisible:e!=null,onClose:r,onClosed:()=>n(void 0),backdropClose:!0,children:t&&s.jsx(Hm,{id:t})})},Km="_search_1uhe2_2",Qm="_entry_1uhe2_2",Vm="_ds_1uhe2_2",Ym="_ds-container_1uhe2_2",Gm="_ds-entry_1uhe2_2",Jm="_enabled_1uhe2_2",qt={search:Km,entry:Qm,ds:Vm,dsContainer:Ym,dsEntry:Gm,enabled:Jm};function Xm(e,t,n){try{const r=n.getItem(e);if(r)return JSON.parse(r)}catch(r){console.warn("Failed to restore tabs",r)}return t}const Zm=({storage:e=localStorage,localStorageKey:t,initialData:n})=>{const r=je(Xm(t,n,e));return r[2].subscribe(o=>{e.setItem(t,JSON.stringify(o))}),r},[ep,tp]=Zm({initialData:[],localStorageKey:"selected-data-sources-v1"}),np=e=>tp(t=>{const n=t.indexOf(e);return n>-1?(t.splice(n,1),[...t]):[...t,e]}),sp={table:"📄",query:"📖",tab:"🛠️"},rp=({onTable:e,onQuery:t,onWorkbenchTab:n,autoFocus:r})=>{const[o,a]=l.useState(""),[i,u]=l.useState(-1),c=va(o,200),d=ep(),{data:f}=ue(),{data:h}=Ys({teamId:f?.teamId}),p=l.useMemo(()=>{const m=[],w=Yr(d);if(!h||h.length===0)return[];for(const C of h)w[C.id]&&m.push(C.id);return m},[d,h]),{data:b}=Il(c,{teamId:f?.teamId,selectedDataSources:p}),x=m=>{m.type==="table"?e(m.name,m.dataSourceId):m.type==="query"?t(m.id,m.dataSourceId):m.type==="tab"&&n(m.id,m.dataSourceId)},y=m=>{b&&(m.key==="ArrowDown"?(m.preventDefault(),u(w=>(w+1)%b.length)):m.key==="ArrowUp"?(m.preventDefault(),u(w=>(w-1+b.length)%b.length)):m.key==="Enter"&&i>=0&&b[i]?.name&&(m.preventDefault(),x(b[i])))},v=m=>{const w=m.currentTarget.dataset.tableId,C=b?.find(S=>S.id===w);C&&x(C)},g=l.useMemo(()=>Yr(d),[d]);return s.jsxs("div",{className:"overflow-hidden flex flex-col w-full lg:w-lg",children:[$e(h?.length,0)?s.jsx("div",{className:qt.dsContainer+" no-scrollbar",children:h.map(m=>s.jsxs("button",{className:P(qt.dsEntry,g[m.id]&&qt.enabled),onClick:()=>np(m.id),children:[s.jsx(ct,{size:24,type:m.dbType}),s.jsx("span",{children:m.name})]},m.id))}):s.jsx(ne,{variant:"warning",className:"mb-4",children:"Connect at least one data source to start using DataRamen"}),s.jsx("input",{className:qt.search,placeholder:"Search table or saved query to start from",value:o,onChange:m=>a(m.target.value),onKeyDown:y,autoFocus:r}),$e(b?.length,0)&&s.jsx("div",{className:"overflow-y-auto max-h-full mt-2",children:b.map((m,w)=>s.jsxs("button",{className:qt.entry,"data-is-active":i===w,"data-table-id":m.id,onClick:v,children:[s.jsxs("p",{className:"font-semibold truncate",children:[sp[m.type]," ",m.name]}),s.jsxs("p",{className:qt.ds,children:["📦 ",m.dataSourceName]})]},m.id))})]})},op=()=>{const e=$c(),t=(a,i)=>{e?.onConfirm("table",a,i)},n=(a,i)=>{e?.onConfirm("query",a,i)},r=(a,i)=>{e?.onConfirm("tab",a,i)},o=()=>{e?.onCancel()};return s.jsx(ge,{isVisible:!!e,onClose:o,backdropClose:!0,children:s.jsx(rp,{autoFocus:!0,onTable:t,onQuery:n,onWorkbenchTab:r})})},ap=()=>{const e=En("Hotkey"),t=V(),{pathname:n}=le(),{data:r}=ue(),{data:o}=ls(),a=I.home.check(n);ke("n",()=>{r&&e()}),ke("w",()=>{r&&(o&&o.length>0?t(I.workbenchTab.build({id:o[0].id})):e())},{enabled:a}),ke("h",()=>{zt({show:!0})})},ip=()=>{const e=le();l.useEffect(()=>{},[e.pathname])},[lp,ja]=je(!1),Ls=()=>ja(!1),Na=()=>ja(!0),cp=({repeatPassword:e,password:t})=>t.length<1?null:t.length<8?s.jsx(ne,{variant:"warning",children:"New password should be at least 8 characters long"}):t!==e?s.jsx(ne,{variant:"warning",children:"Repeat password should match new password"}):null,up=()=>{const e=lp(),{data:t}=ue(),{mutateAsync:n,isPending:r}=Ql(),o=V(),[{password:a,repeatPassword:i},{change:u,touched:c,reset:d}]=Cn({password:"",repeatPassword:""}),f=()=>{o("/"),Us.logout().then(()=>{Ls()})},h=()=>{n({password:a}).then(()=>{d(),Ce.success("Password successfully updated!")})},p=a.length<8||a!==i||r,b=c.includes("password");return s.jsxs(ge,{isVisible:e,onClose:Ls,children:[s.jsx(lt,{onClick:Ls}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[s.jsx($o,{children:"Account settings"}),s.jsxs("label",{children:[s.jsx("p",{className:"text-xs font-semibold mb-1",children:"Username"}),s.jsx("input",{className:"input w-full",readOnly:!0,disabled:!0,value:t?.username})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("label",{children:[s.jsx("p",{className:"text-xs font-semibold mb-1",children:"Change password"}),s.jsx("input",{className:"input w-full",type:"password",name:"newPassword",autoComplete:"new-password",value:a,onChange:u("password")})]}),s.jsxs("label",{children:[s.jsx("p",{className:"text-xs font-semibold mb-1",children:"Repeat password"}),s.jsx("input",{className:"input w-full",type:"password",value:i,onChange:u("repeatPassword")})]})]}),b&&s.jsx(cp,{password:a,repeatPassword:i}),s.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[s.jsx("button",{className:"button tertiary",disabled:p,onClick:h,children:"Update password"}),s.jsx("button",{className:"button danger",onClick:f,children:"Log out"})]})]})]})},[dp,_a]=je(!1),Sa=()=>_a(!0),Jr=()=>_a(!1),hp=e=>ce({queryKey:["team-users"],queryFn:async()=>{const{data:t}=await O.get("/teams/"+e+"/users");return t.data},enabled:!!e}),fp=()=>X({mutationFn:async({role:e,teamId:t,userId:n})=>(await O.patch("/teams/"+t+"/user-role",{role:e,userId:n}),!0),onSuccess:()=>{K.invalidateQueries({queryKey:["team-users"]})}}),mp=()=>X({mutationFn:async({teamId:e,userId:t})=>(await O.delete("/teams/"+e,{params:{userId:t}}),!0),onSuccess:()=>{K.invalidateQueries({queryKey:["team-users"]})}}),pp="_user-entry_p8yd5_2",xp="_select-container_p8yd5_2",Xr={userEntry:pp,selectContainer:xp},gp=()=>{const e=dp(),{data:t}=ue(),{data:n}=hp(t?.teamId),{mutate:r,isPending:o}=Vl(),{mutate:a,isPending:i}=fp(),{mutate:u,isPending:c}=mp(),[d,{change:f,reset:h}]=Cn({password:"",username:""}),p=()=>{r({username:d.username,password:d.password,teamId:t?.teamId||""}),h()},b=(g,m)=>{a({teamId:t.teamId,role:m,userId:g})},x=g=>{Do("Are you sure you want to remove this user?").then(m=>{m&&u({userId:g,teamId:t.teamId})})},y=Rn(he.ADMIN),v=o||i||c;return s.jsxs(ge,{isVisible:e,onClose:Jr,backdropClose:!0,children:[s.jsx(lt,{onClick:Jr}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[s.jsx($o,{children:"Manage users"}),$e(n?.length,0)&&s.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:n.map(g=>s.jsxs("div",{className:Xr.userEntry,children:[s.jsx("div",{className:Xr.selectContainer,children:s.jsxs("select",{value:g.role,disabled:!y||v,onChange:m=>b(g.id,m.currentTarget.value),children:[s.jsx("option",{value:he.OWNER,children:"Owner"}),s.jsx("option",{value:he.ADMIN,children:"Admin"}),s.jsx("option",{value:he.EDITOR,children:"Editor"}),s.jsx("option",{value:he.READ_ONLY,children:"Reader"})]})}),s.jsx("p",{className:"flex-1 mx-2",children:g.name}),y&&s.jsx("button",{className:"p-1 cursor-pointer text-red-500 text-sm",onClick:()=>x(g.id),children:"❌"})]},g.id))}),y&&s.jsxs("div",{className:"mt-4",children:[s.jsx("p",{className:"font-semibold",children:"Create new user"}),s.jsxs("div",{className:"flex flex-col lg:flex-row gap-2 lg:items-center mt-2",children:[s.jsx("input",{className:"input flex-1",onChange:f("username"),value:d.username,placeholder:"Username",disabled:v}),s.jsx("input",{className:"input",onChange:f("password"),value:d.password,type:"password",name:"newPassword",autoComplete:"new-password",placeholder:"Password",disabled:v}),s.jsx("button",{className:"button primary",onClick:p,disabled:v,children:"Create user"})]}),s.jsx("p",{className:"text-xs mt-1 text-gray-600",children:"You should create default password for the new account. The user should change it after the first login."})]})]})]})},bp=()=>{const[e,t]=l.useState(""),[n,r]=l.useState(""),[o,a]=l.useState(),[i,u]=l.useState(!1),c=V(),d=f=>{f.preventDefault(),a(void 0),Us.login({password:n,username:e}).then(()=>{c("/",{replace:!0})}).catch(a)};return s.jsx("div",{className:"page-container bg-(--bg) h-screen",children:s.jsx("div",{className:"page-content items-center",children:s.jsxs("form",{className:"flex flex-col gap-2 w-full lg:w-lg",onSubmit:d,children:[s.jsx("p",{className:"font-semibold text-xl min-w-md",children:"Login"}),o&&s.jsx(ne,{variant:"danger",children:"Failed to login. Please verify your credentials"}),s.jsx("input",{value:e,onChange:f=>t(f.currentTarget.value),className:"input",placeholder:"User name"}),s.jsx("input",{value:n,onChange:f=>r(f.currentTarget.value),className:"input",type:"password",placeholder:"Password"}),s.jsx("button",{type:"submit",className:"button primary",children:"Login"}),i?s.jsxs(ne,{className:"w-full border border-blue-500",children:[s.jsx("p",{children:"If this is your first login, the default credentials are:"}),s.jsxs("ul",{className:"mt-2",children:[s.jsxs("li",{children:["Username: ",s.jsx("strong",{children:"admin"})]}),s.jsxs("li",{children:["Password: ",s.jsx("strong",{children:"admin"})]})]}),s.jsx("p",{className:"mt-2",children:"Please make sure to change the default password to a secure one."})]}):s.jsx("button",{className:"button tertiary",onClick:()=>u(!0),children:"First login?"})]})})})},yp=()=>{const e=V(),{pathname:t}=le(),{data:n,isLoading:r}=To();l.useEffect(()=>{!n&&!r&&!I.login.check(t)&&e(I.login.build())},[n,r,e,t])},vp=()=>{},wp=__CLIENT_CONFIG__.skipAuth?vp:yp,Cp=()=>{const[e]=dl(),t=V(),n=Zt(),r=e.get("shareId");return l.useEffect(()=>{r&&n.mutateAsync({queryId:r}).then(o=>{t(I.workbenchTab.build({id:o.id}),{replace:!0})})},[r]),s.jsxs("div",{className:"page-container flex items-center justify-center h-screen",children:[n.isPending&&s.jsxs("div",{className:"flex items-center flex-col gap-2",children:[s.jsx(ur,{}),s.jsx("p",{children:"Fetching query information"})]}),n.isError&&s.jsx(ne,{variant:"danger",children:"Failed to load query information"})]})},jp="_container_16iip_2",Np="_header_16iip_2",_p="_close-button_16iip_2",Sp="_tab-container_16iip_2",kp="_tab-name_16iip_2",Ep="_archived-badge_16iip_2 _badge_16iip_2",Rp="_active-badge_16iip_2 _badge_16iip_2",Tp="_delete-action_16iip_2",Lp="_load-more-btn_16iip_2",ze={container:jp,header:Np,closeButton:_p,tabContainer:Sp,tabName:kp,archivedBadge:Ep,activeBadge:Rp,deleteAction:Tp,loadMoreBtn:Lp},Ap=new Intl.DateTimeFormat,Pp=()=>{const{data:e}=ue(),{data:t,fetchNextPage:n,hasNextPage:r,isFetching:o}=Ol(e?.teamId,25),a=V(),i=Io(),u=Mc(),c=l.useRef(null),d=l.useRef(null),f=b=>{i.mutate(b),zt({show:!1}),a(I.workbenchTab.build({id:b}))},h=()=>{c.current?.close(),u.mutate(d.current)},p=t&&t?.length>0;return s.jsxs("div",{className:ze.container,children:[s.jsxs("div",{className:ze.header,children:[s.jsx("h3",{className:"text-lg",children:"Recent tabs"}),s.jsx("button",{className:ze.closeButton,onClick:()=>zt({show:!1}),children:s.jsx(jt,{width:24,height:24})})]}),!p&&s.jsx(ne,{variant:"warning",children:"History is empty."}),t?.map(b=>s.jsxs("div",{className:ze.tabContainer,onClick:()=>f(b.id),onContextMenu:x=>{d.current=b.id,c.current?.open(x,!1)},children:[s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("p",{className:ze.tabName,children:b.name}),b.dataSourceType&&s.jsx(ct,{size:16,type:b.dataSourceType}),s.jsx("p",{className:"text-xs text-(--text-color-secondary)",children:b.dataSourceName})]}),s.jsxs("div",{className:"flex gap-2 items-center mt-1",children:[s.jsx("p",{className:"text-xs text-(--text-color-secondary) italic",children:Ap.format(new Date(b.updatedAt))}),b.archived?s.jsx("span",{className:ze.archivedBadge,children:"Archived"}):s.jsx("span",{className:ze.activeBadge,children:"Active"})]})]},b.id)),s.jsx(Vo,{ref:c,children:s.jsx("button",{onClick:h,className:ze.deleteAction,children:"🗑 Delete"})}),r&&!o&&s.jsx("div",{className:"flex justify-center my-2",children:s.jsx("button",{className:ze.loadMoreBtn,onClick:()=>n(),children:"Load more"})})]})},Ip=()=>{const e=pu(t=>t.show);return s.jsx(wa,{isVisible:e,onClose:()=>zt({show:!1}),backdropClose:!0,children:s.jsx(Pp,{})})},Op="_queries-container_159g7_2",Mp="_query-entry_159g7_2",Zr={queriesContainer:Op,queryEntry:Mp},$p=()=>{const{data:e}=ue(),[t,n]=l.useState(""),r=va(t),{data:o,isLoading:a,fetchNextPage:i,hasNextPage:u}=Ml(e?.teamId,r),c=l.useRef(void 0),d=V(),f=xh(),h=Zt(),p=ph(),b=Wo(),x=g=>{h.mutateAsync({queryId:g}).then(m=>{d(I.workbenchTab.build({id:m.id}))})},y=async g=>{const m=o?.find(C=>C.id===g);if(!m)return;const w=await Tn("New name?",m?.name);w&&f.mutate({id:m.savedQueryId,payload:{name:w}})},v=g=>{const m=o?.find(w=>w.id===g)?.savedQueryId;m&&p.mutate(m)};return s.jsxs("div",{className:Zr.queriesContainer,children:[s.jsx("div",{className:"sticky top-0 p-4 bg-(--bg)",children:s.jsx("input",{className:"input w-full",placeholder:"Filter",value:t,onChange:g=>n(g.target.value)})}),$e(o?.length,0)&&o.map(g=>s.jsxs("button",{className:Zr.queryEntry,onClick:()=>x(g.id),onContextMenu:m=>{c.current=g.id,b.open(m)},children:[s.jsxs("p",{className:"text-left",children:["📖 ",g.name]}),s.jsxs("p",{className:"flex gap-2 items-center",children:[s.jsx(ct,{size:20,type:g.datasourceType}),s.jsx("span",{className:"truncate text-sm text-(--text-color-secondary)",children:g.datasourceName})]})]},g.savedQueryId)),u&&s.jsx("button",{className:"button primary mx-auto mt-4",onClick:()=>i(),children:"Load more"}),!a&&Fd(o?.length,1)&&s.jsx("p",{className:"text-center text-sm text-(--text-color-secondary)",children:"Empty"}),s.jsx(Ho,{handler:b,children:s.jsxs("div",{className:"context-menu-container",children:[s.jsx("button",{onClick:g=>{g.preventDefault(),g.stopPropagation(),b.close(),y(c.current)},className:"context-menu-item",children:"✏️ Rename"}),s.jsx("button",{onClick:g=>{g.preventDefault(),g.stopPropagation(),b.close(),v(c.current)},className:"context-menu-item",children:"🗑️ Delete"})]})})]})},Dp=()=>{const{data:e}=ue(),{data:t,isLoading:n}=Fl(e?.teamId);return s.jsx("div",{className:"page-container h-screen max-h-screen",children:s.jsxs("div",{className:"page-content max-h-full",children:[s.jsx("div",{className:"py-10 text-center w-full",children:s.jsx("h1",{className:"comfortaa text-3xl font-semibold text-(--text-color-primary)",children:I.savedQueries.name})}),t?s.jsx($p,{}):s.jsx(s.Fragment,{children:n?s.jsx(ur,{}):s.jsx(ne,{variant:"warning",children:"You don't have saved queries."})})]})})},Fp=()=>{const{data:e}=ue(),t=Dl(e?.teamId),n=V();return l.useEffect(()=>{t.mutateAsync().then(r=>{r?n(I.workbenchTab.build({id:r.id}),{replace:!0}):n(I.home.build(),{replace:!0})})},[]),null};function qp(){return ap(),ip(),wp(),s.jsxs(s.Fragment,{children:[s.jsxs(Oi,{children:[s.jsx(yt,{path:I.home.path,element:s.jsx(ju,{})}),s.jsx(yt,{path:I.workbench.path,element:s.jsx(Fp,{})}),s.jsx(yt,{path:I.workbenchTab.path,element:s.jsx(bm,{})}),s.jsx(yt,{path:I.login.path,element:s.jsx(bp,{})}),s.jsx(yt,{path:I.share.path,element:s.jsx(Cp,{})}),s.jsx(yt,{path:I.savedQueries.path,element:s.jsx(Dp,{})})]}),s.jsx(Ou,{}),s.jsx(zu,{}),s.jsx(rd,{}),s.jsx(zm,{}),s.jsx(op,{}),s.jsx(up,{}),s.jsx(gp,{}),s.jsx(Ip,{}),s.jsx(Zu,{}),s.jsx(Vu,{})]})}const Bp="_hidden_17f9n_2",Up="_desktop-layout_17f9n_2",Wp="_mobile-layout_17f9n_2",Hp="_nav_17f9n_2",zp="_shown_17f9n_2",Kp="_main_17f9n_2",Qp="_header_17f9n_2",Vp="_expand_17f9n_2",Yp="_show_17f9n_2",Gp="_hide_17f9n_2",Jp="_icon_17f9n_2",Xp="_nav-item_17f9n_2",Zp="_project-wrapper_17f9n_2",D={hidden:Bp,desktopLayout:Up,mobileLayout:Wp,nav:Hp,shown:zp,main:Kp,header:Qp,expand:Vp,show:Yp,hide:Gp,icon:Jp,navItem:Xp,projectWrapper:Zp},e0="_container_1r3s6_2",t0={container:e0},n0=({dataSource:e,index:t})=>{const n=()=>{Ht(e.id)};return ke(t.toString(),()=>{Ht(r=>{if(r!==e.id)return e.id})}),s.jsxs("button",{className:D.navItem,onClick:n,children:[s.jsx("span",{className:D.icon,children:s.jsx(ct,{size:20,type:e.dbType})}),s.jsx("span",{className:"truncate",children:e.name}),s.jsx("span",{className:"hotkey secondary",children:t})]})},s0=()=>{const{data:e}=ue(),{data:t}=Al(e?.teamId);return s.jsx("div",{className:t0.container,children:$e(t?.length,0)&&s.jsxs("div",{className:"mt-4 flex flex-col",children:[s.jsx("p",{className:"font-semibold truncate text-(--text-color-secondary) mb-2",children:"Data sources"}),t.map((n,r)=>s.jsx(n0,{dataSource:n,index:r+1},n.id))]})})},r0=!__CLIENT_CONFIG__.skipAuth,o0=()=>{const e=V(),{pathname:t}=le(),{data:n}=ue(),r=En("Desktop nav"),[o,a]=l.useState(!1),{data:i}=ls(),u=()=>{I.home.check(t)||e(I.home.build())},c=p=>{I.workbenchTab.check(t)||e(I.workbenchTab.build({id:p}))},d=()=>{I.savedQueries.check(t)||e(I.savedQueries.build())},f=()=>zt({show:!0}),h=o?void 0:"default";return s.jsxs("nav",{className:P(D.nav,o?D.shown:D.hidden),children:[n&&s.jsxs("div",{className:D.header,children:[s.jsxs("button",{onClick:u,className:D.navItem,"data-tooltip-id":h,"data-tooltip-content":"Home",children:[s.jsx("span",{className:D.icon,children:"🏠"}),s.jsx("span",{className:"truncate",children:"Home"})]}),s.jsxs("button",{onClick:r,className:D.navItem,"data-tooltip-id":h,"data-tooltip-content":"New query",children:[s.jsx("span",{className:D.icon,children:"🔎"}),s.jsx("span",{className:"truncate",children:"New query"}),s.jsx("span",{className:"hotkey secondary",children:"N"})]}),s.jsxs("button",{onClick:f,className:D.navItem,"data-tooltip-id":h,"data-tooltip-content":"Recent tabs",children:[s.jsx("span",{className:D.icon,children:"⌛"}),s.jsx("span",{className:"truncate",children:"Recent tabs"}),s.jsx("span",{className:"hotkey secondary",children:"H"})]}),s.jsxs("button",{onClick:d,className:D.navItem,"data-tooltip-id":h,"data-tooltip-content":"Saved queries",children:[s.jsx("span",{className:D.icon,children:"💾"}),s.jsx("span",{className:"truncate",children:"Saved queries"})]}),$e(i?.length,0)&&s.jsxs("button",{onClick:()=>c(i[0].id),className:D.navItem,"data-tooltip-id":h,"data-tooltip-content":"Workbench",children:[s.jsx("span",{className:D.icon,children:"🛠️"}),s.jsx("span",{className:"truncate",children:"Workbench"})]}),r0&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:Na,className:D.navItem,"data-tooltip-id":h,"data-tooltip-content":"User settings",children:[s.jsx("span",{className:D.icon,children:"🪪"}),s.jsx("span",{className:"truncate",children:n.username})]}),s.jsxs("button",{onClick:Sa,className:D.navItem,"data-tooltip-id":h,"data-tooltip-content":"Manage users",children:[s.jsx("span",{className:D.icon,children:"👥"}),s.jsx("span",{className:"truncate",children:"Manage users"})]})]})]}),s.jsx("div",{className:P(D.projectWrapper,o?D.show:D.hide),children:s.jsx(s0,{})}),s.jsx("button",{onClick:()=>a(!o),className:`${D.navItem} m-2`,children:s.jsx("span",{className:P(D.icon,D.expand,o?D.show:D.hide),children:s.jsx(Ye,{width:20,height:20})})})]})},a0="_root_1c4id_2",i0={root:a0},ka=!__CLIENT_CONFIG__.skipAuth,l0=`${i0.root} ${ka?"grid-cols-4":"grid-cols-2"}`,c0=()=>{const{pathname:e}=le(),t=V(),n=En("Mobile nav"),r=()=>{I.home.check(e)||t(I.home.build())};return s.jsxs("div",{className:l0,children:[s.jsxs("button",{onClick:r,children:[s.jsx("p",{children:"🏠"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Home"})]}),s.jsxs("button",{onClick:n,children:[s.jsx("p",{children:"🔎"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"New query"})]}),ka&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:Na,children:[s.jsx("p",{children:"🪪"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Account"})]}),s.jsxs("button",{onClick:Sa,children:[s.jsx("p",{children:"👥"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Users"})]})]})]})},u0=({children:e,isLogin:t})=>s.jsxs("div",{className:D.desktopLayout,children:[s.jsx(ss,{id:"default",className:"z-100"}),s.jsx(ss,{id:"default-xs",className:"z-100 text-xs!"}),!t&&s.jsx(o0,{}),s.jsx("main",{className:D.main,children:e})]}),d0=({children:e,isLogin:t})=>s.jsxs("div",{className:D.mobileLayout,children:[s.jsx("main",{className:D.main,children:e}),!t&&s.jsx(c0,{})]}),h0=({children:e})=>{const t=qo(er.laptop),{pathname:n}=le(),r=I.login.check(n);return t?s.jsx(u0,{isLogin:r,children:e}):s.jsx(d0,{isLogin:r,children:e})};Ua.createRoot(document.getElementById("root")).render(s.jsxs(tt.StrictMode,{children:[s.jsx(Wa,{}),s.jsx(wl,{client:K,children:s.jsx(al,{children:s.jsx(h0,{children:s.jsx(qp,{})})})})]}));