@dataramen/cli 0.0.67 → 0.0.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/code/server.js +8 -8
- package/dist/code/web/assets/index-D_yzt1XG.css +1 -0
- package/dist/code/web/assets/{index-DRdCzPJM.js → index-g8K5wnQd.js} +1 -1
- package/dist/code/web/assets/main-BbebNQDt.js +4 -0
- package/dist/code/web/assets/main-DQXEBF5j.css +1 -0
- package/dist/code/web/assets/{setup-DK7Bw_GF.js → setup-CbifUuH4.js} +1 -1
- package/dist/code/web/index.html +4 -4
- package/dist/code/web/setup.html +3 -3
- package/dist/package.json +1 -1
- package/package.json +1 -1
- package/dist/code/web/assets/index-BXGMoOT9.css +0 -1
- package/dist/code/web/assets/main-Q3MkN8u5.css +0 -1
- package/dist/code/web/assets/main-hQGXcnxF.js +0 -4
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as l,a as Sa,S as Xr,p as pr,b as Se,s as Jn,c as xn,n as Gn,i as Ts,d as gr,t as _a,e as qn,f as Ea,g as ka,h as xr,j as ss,k as br,l as Ra,m as Ta,o as yr,q as La,u as s,v as Zr,w as K,x as O,A as qs,y as Aa,z as Pa,B as k,C as Cn,D as Z,V as Ce,E as Ia,F as Oa,R as tt,G as $a,O as Ma}from"./index-DRdCzPJM.js";var dn={},vr;function Da(){if(vr)return dn;vr=1,Object.defineProperty(dn,"__esModule",{value:!0}),dn.parse=i,dn.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 g=new a,x=p.length;if(x<2)return g;const v=b?.decode||f;let y=0;do{const m=p.indexOf("=",y);if(m===-1)break;const w=p.indexOf(";",y),C=w===-1?x:w;if(m>C){y=p.lastIndexOf(";",m-1)+1;continue}const _=u(p,y,m),E=c(p,m,_),j=p.slice(_,E);if(g[j]===void 0){let S=u(p,m+1,C),A=c(p,C,S);const $=v(p.slice(S,A));g[j]=$}y=C+1}while(y<x);return g}function u(p,b,g){do{const x=p.charCodeAt(b);if(x!==32&&x!==9)return b}while(++b<g);return g}function c(p,b,g){for(;b>g;){const x=p.charCodeAt(--b);if(x!==32&&x!==9)return b+1}return g}function d(p,b,g){const x=g?.encode||encodeURIComponent;if(!e.test(p))throw new TypeError(`argument name is invalid: ${p}`);const v=x(b);if(!t.test(v))throw new TypeError(`argument val is invalid: ${b}`);let y=p+"="+v;if(!g)return y;if(g.maxAge!==void 0){if(!Number.isInteger(g.maxAge))throw new TypeError(`option maxAge is invalid: ${g.maxAge}`);y+="; Max-Age="+g.maxAge}if(g.domain){if(!n.test(g.domain))throw new TypeError(`option domain is invalid: ${g.domain}`);y+="; Domain="+g.domain}if(g.path){if(!r.test(g.path))throw new TypeError(`option path is invalid: ${g.path}`);y+="; Path="+g.path}if(g.expires){if(!h(g.expires)||!Number.isFinite(g.expires.valueOf()))throw new TypeError(`option expires is invalid: ${g.expires}`);y+="; Expires="+g.expires.toUTCString()}if(g.httpOnly&&(y+="; HttpOnly"),g.secure&&(y+="; Secure"),g.partitioned&&(y+="; Partitioned"),g.priority)switch(typeof g.priority=="string"?g.priority.toLowerCase():void 0){case"low":y+="; Priority=Low";break;case"medium":y+="; Priority=Medium";break;case"high":y+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${g.priority}`)}if(g.sameSite)switch(typeof g.sameSite=="string"?g.sameSite.toLowerCase():g.sameSite){case!0:case"strict":y+="; SameSite=Strict";break;case"lax":y+="; SameSite=Lax";break;case"none":y+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${g.sameSite}`)}return y}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 dn}Da();var wr="popstate";function Fa(e={}){function t(r,o){let{pathname:a,search:i,hash:u}=r.location;return Ls("",{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:yn(o)}return Ba(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 qa(){return Math.random().toString(36).substring(2,10)}function Cr(e,t){return{usr:e.state,key:e.key,idx:t}}function Ls(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Ht(t):t,state:n,key:t&&t.key||r||qa()}}function yn({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 Ht(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 Ba(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(),y=v==null?null:v-d;d=v,c&&c({action:u,location:x.location,delta:y})}function p(v,y){u="PUSH";let m=Ls(x.location,v,y);d=f()+1;let w=Cr(m,d),C=x.createHref(m);try{i.pushState(w,"",C)}catch(_){if(_ instanceof DOMException&&_.name==="DataCloneError")throw _;o.location.assign(C)}a&&c&&c({action:u,location:x.location,delta:1})}function b(v,y){u="REPLACE";let m=Ls(x.location,v,y);d=f();let w=Cr(m,d),C=x.createHref(m);i.replaceState(w,"",C),a&&c&&c({action:u,location:x.location,delta:0})}function g(v){return Ua(v)}let x={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(wr,h),c=v,()=>{o.removeEventListener(wr,h),c=null}},createHref(v){return t(o,v)},createURL:g,encodeLocation(v){let y=g(v);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:p,replace:b,go(v){return i.go(v)}};return x}function Ua(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:yn(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function eo(e,t,n="/"){return Wa(e,t,n,!1)}function Wa(e,t,n,r){let o=typeof t=="string"?Ht(t):t,a=Qe(o.pathname||"/",n);if(a==null)return null;let i=to(e);za(i);let u=null;for(let c=0;u==null&&c<i.length;++c){let d=ti(a);u=Za(i[c],d,r)}return u}function to(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=Ke([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}".`),to(a.children,t,f,d)),!(a.path==null&&!a.index)&&t.push({path:d,score:Ga(d,a.index),routesMeta:f})};return e.forEach((a,i)=>{if(a.path===""||!a.path?.includes("?"))o(a,i);else for(let u of no(a.path))o(a,i,u)}),t}function no(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=no(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 za(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Xa(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Ha=/^:[\w-]+$/,Ka=3,Va=2,Qa=1,Ya=10,Ja=-2,jr=e=>e==="*";function Ga(e,t){let n=e.split("/"),r=n.length;return n.some(jr)&&(r+=Ja),t&&(r+=Va),n.filter(o=>!jr(o)).reduce((o,a)=>o+(Ha.test(a)?Ka:a===""?Qa:Ya),r)}function Xa(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 Za(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=vn({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},f),p=c.route;if(!h&&d&&n&&!r[r.length-1].route.index&&(h=vn({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},f)),!h)return null;Object.assign(o,h.params),i.push({params:o,pathname:Ke([a,h.pathname]),pathnameBase:oi(Ke([a,h.pathnameBase])),route:p}),h.pathnameBase!=="/"&&(a=Ke([a,h.pathnameBase]))}return i}function vn(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ei(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 g=u[p]||"";i=a.slice(0,a.length-g.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 ei(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 ti(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 Qe(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 ni(e,t="/"){let{pathname:n,search:r="",hash:o=""}=typeof e=="string"?Ht(e):e;return{pathname:n?n.startsWith("/")?n:si(n,t):t,search:ai(r),hash:ii(o)}}function si(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 bs(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 ri(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function so(e){let t=ri(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function ro(e,t,n,r=!1){let o;typeof e=="string"?o=Ht(e):(o={...e},z(!o.pathname||!o.pathname.includes("?"),bs("?","pathname","search",o)),z(!o.pathname||!o.pathname.includes("#"),bs("#","pathname","hash",o)),z(!o.search||!o.search.includes("#"),bs("#","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=ni(o,u),d=i&&i!=="/"&&i.endsWith("/"),f=(a||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}var Ke=e=>e.join("/").replace(/\/\/+/g,"/"),oi=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),ai=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,ii=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function li(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var oo=["POST","PUT","PATCH","DELETE"];new Set(oo);var ci=["GET",...oo];new Set(ci);var Kt=l.createContext(null);Kt.displayName="DataRouter";var rs=l.createContext(null);rs.displayName="DataRouterState";var ao=l.createContext({isTransitioning:!1});ao.displayName="ViewTransition";var ui=l.createContext(new Map);ui.displayName="Fetchers";var di=l.createContext(null);di.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 Bs=l.createContext(null);Bs.displayName="RouteError";function hi(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}=Sn(e,{relative:t}),u=a;return n!=="/"&&(u=a==="/"?n:Ke([n,a])),r.createHref({pathname:u,search:i,hash:o})}function Nn(){return l.useContext(jn)!=null}function ie(){return z(Nn(),"useLocation() may be used only in the context of a <Router> component."),l.useContext(jn).location}var io="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function lo(e){l.useContext(Fe).static||l.useLayoutEffect(e)}function ee(){let{isDataRoute:e}=l.useContext(qe);return e?_i():fi()}function fi(){z(Nn(),"useNavigate() may be used only in the context of a <Router> component.");let e=l.useContext(Kt),{basename:t,navigator:n}=l.useContext(Fe),{matches:r}=l.useContext(qe),{pathname:o}=ie(),a=JSON.stringify(so(r)),i=l.useRef(!1);return lo(()=>{i.current=!0}),l.useCallback((c,d={})=>{if(Ee(i.current,io),!i.current)return;if(typeof c=="number"){n.go(c);return}let f=ro(c,JSON.parse(a),o,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Ke([t,f.pathname])),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,a,o,e])}l.createContext(null);function mi(){let{matches:e}=l.useContext(qe),t=e[e.length-1];return t?t.params:{}}function Sn(e,{relative:t}={}){let{matches:n}=l.useContext(qe),{pathname:r}=ie(),o=JSON.stringify(so(n));return l.useMemo(()=>ro(e,JSON.parse(o),r,t==="path"),[e,o,r,t])}function pi(e,t){return co(e,t)}function co(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||"";uo(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=ie(),b;if(t){let m=typeof t=="string"?Ht(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 g=b.pathname||"/",x=g;if(f!=="/"){let m=f.replace(/^\//,"").split("/");x="/"+g.replace(/^\//,"").split("/").slice(m.length).join("/")}let v=!a&&n&&n.matches&&n.matches.length>0?n.matches:eo(e,{pathname:x});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 y=vi(v&&v.map(m=>Object.assign({},m,{params:Object.assign({},c,m.params),pathname:Ke([f,o.encodeLocation?o.encodeLocation(m.pathname).pathname:m.pathname]),pathnameBase:m.pathnameBase==="/"?f:Ke([f,o.encodeLocation?o.encodeLocation(m.pathnameBase).pathname:m.pathnameBase])})),i,n,r);return t&&y?l.createElement(jn.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...b},navigationType:"POP"}},y):y}function gi(){let e=Si(),t=li(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 xi=l.createElement(gi,null),bi=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(Bs.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function yi({routeContext:e,match:t,children:n}){let r=l.useContext(Kt);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 vi(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,g=null;n&&(h=a&&d.route.id?a[d.route.id]:void 0,b=d.route.errorElement||xi,i&&(u<0&&f===0?(uo("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),p=!0,g=null):u===f&&(p=!0,g=d.route.hydrateFallbackElement||null)));let x=t.concat(o.slice(0,f+1)),v=()=>{let y;return h?y=b:p?y=g:d.route.Component?y=l.createElement(d.route.Component,null):d.route.element?y=d.route.element:y=c,l.createElement(yi,{match:d,routeContext:{outlet:c,matches:x,isDataRoute:n!=null},children:y})};return n&&(d.route.ErrorBoundary||d.route.errorElement||f===0)?l.createElement(bi,{location:n.location,revalidation:n.revalidation,component:b,error:h,children:v(),routeContext:{outlet:null,matches:x,isDataRoute:!0}}):v()},null)}function Us(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function wi(e){let t=l.useContext(Kt);return z(t,Us(e)),t}function Ci(e){let t=l.useContext(rs);return z(t,Us(e)),t}function ji(e){let t=l.useContext(qe);return z(t,Us(e)),t}function Ws(e){let t=ji(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 Ni(){return Ws("useRouteId")}function Si(){let e=l.useContext(Bs),t=Ci("useRouteError"),n=Ws("useRouteError");return e!==void 0?e:t.errors?.[n]}function _i(){let{router:e}=wi("useNavigate"),t=Ws("useNavigate"),n=l.useRef(!1);return lo(()=>{n.current=!0}),l.useCallback(async(o,a={})=>{Ee(n.current,io),n.current&&(typeof o=="number"?e.navigate(o):await e.navigate(o,{fromRouteId:t,...a}))},[e,t])}var Nr={};function uo(e,t,n){!t&&!Nr[e]&&(Nr[e]=!0,Ee(!1,n))}l.memo(Ei);function Ei({routes:e,future:t,state:n}){return co(e,void 0,n,t)}function gn(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 ki({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=Ht(n));let{pathname:c="/",search:d="",hash:f="",state:h=null,key:p="default"}=n,b=l.useMemo(()=>{let g=Qe(c,i);return g==null?null:{location:{pathname:g,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 Ri({children:e,location:t}){return pi(As(e),t)}function As(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,As(r.props.children,a));return}z(r.type===gn,`[${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=As(r.props.children,a)),n.push(i)}),n}var Hn="get",Kn="application/x-www-form-urlencoded";function os(e){return e!=null&&typeof e.tagName=="string"}function Ti(e){return os(e)&&e.tagName.toLowerCase()==="button"}function Li(e){return os(e)&&e.tagName.toLowerCase()==="form"}function Ai(e){return os(e)&&e.tagName.toLowerCase()==="input"}function Pi(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Ii(e,t){return e.button===0&&(!t||t==="_self")&&!Pi(e)}function Ps(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 Oi(e,t){let n=Ps(e);return t&&t.forEach((r,o)=>{n.has(o)||t.getAll(o).forEach(a=>{n.append(o,a)})}),n}var Bn=null;function $i(){if(Bn===null)try{new FormData(document.createElement("form"),0),Bn=!1}catch{Bn=!0}return Bn}var Mi=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ys(e){return e!=null&&!Mi.has(e)?(Ee(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Kn}"`),null):e}function Di(e,t){let n,r,o,a,i;if(Li(e)){let u=e.getAttribute("action");r=u?Qe(u,t):null,n=e.getAttribute("method")||Hn,o=ys(e.getAttribute("enctype"))||Kn,a=new FormData(e)}else if(Ti(e)||Ai(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?Qe(c,t):null,n=e.getAttribute("formmethod")||u.getAttribute("method")||Hn,o=ys(e.getAttribute("formenctype"))||ys(u.getAttribute("enctype"))||Kn,a=new FormData(u,e),!$i()){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(os(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Hn,r=null,o=Kn,i=e}return a&&o==="text/plain"&&(i=a,a=void 0),{action:r,method:n.toLowerCase(),encType:o,formData:a,body:i}}function zs(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}async function Fi(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 qi(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 Bi(e,t,n){let r=await Promise.all(e.map(async o=>{let a=t.routes[o.route.id];if(a){let i=await Fi(a,n);return i.links?i.links():[]}return[]}));return Hi(r.flat(1).filter(qi).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 Ui(e,t,{includeHydrateFallback:n}={}){return Wi(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 Wi(e){return[...new Set(e)]}function zi(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Hi(e,t){let n=new Set;return new Set(t),e.reduce((r,o)=>{let a=JSON.stringify(zi(o));return n.has(a)||(n.add(a),r.push({key:a,link:o})),r},[])}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Ki=new Set([100,101,204,205]);function Vi(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&&Qe(n.pathname,t)==="/"?n.pathname=`${t.replace(/\/$/,"")}/_root.data`:n.pathname=`${n.pathname.replace(/\/$/,"")}.data`,n}function ho(){let e=l.useContext(Kt);return zs(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Qi(){let e=l.useContext(rs);return zs(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Hs=l.createContext(void 0);Hs.displayName="FrameworkContext";function fo(){let e=l.useContext(Hs);return zs(e,"You must render this element inside a <HydratedRouter> element"),e}function Yi(e,t){let n=l.useContext(Hs),[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 x=y=>{y.forEach(m=>{i(m.isIntersecting)})},v=new IntersectionObserver(x,{threshold:.5});return p.current&&v.observe(p.current),()=>{v.disconnect()}}},[e]),l.useEffect(()=>{if(r){let x=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(x)}}},[r]);let b=()=>{o(!0)},g=()=>{o(!1),i(!1)};return n?e!=="intent"?[a,p,{}]:[a,p,{onFocus:hn(u,b),onBlur:hn(c,g),onMouseEnter:hn(d,b),onMouseLeave:hn(f,g),onTouchStart:hn(h,b)}]:[!1,p,{}]}function hn(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Ji({page:e,...t}){let{router:n}=ho(),r=l.useMemo(()=>eo(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?l.createElement(Xi,{page:e,matches:r,...t}):null}function Gi(e){let{manifest:t,routeModules:n}=fo(),[r,o]=l.useState([]);return l.useEffect(()=>{let a=!1;return Bi(e,t,n).then(i=>{a||o(i)}),()=>{a=!0}},[e,t,n]),r}function Xi({page:e,matches:t,...n}){let r=ie(),{manifest:o,routeModules:a}=fo(),{basename:i}=ho(),{loaderData:u,matches:c}=Qi(),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 g=new Set,x=!1;if(t.forEach(y=>{let m=o.routes[y.route.id];!m||!m.hasLoader||(!d.some(w=>w.route.id===y.route.id)&&y.route.id in u&&a[y.route.id]?.shouldRevalidate||m.hasClientLoader?x=!0:g.add(y.route.id))}),g.size===0)return[];let v=Vi(e,i);return x&&g.size>0&&v.searchParams.set("_routes",t.filter(y=>g.has(y.route.id)).map(y=>y.route.id).join(",")),[v.pathname+v.search]},[i,u,r,o,d,t,e,a]),p=l.useMemo(()=>Ui(f,o),[f,o]),b=Gi(f);return l.createElement(l.Fragment,null,h.map(g=>l.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...n})),p.map(g=>l.createElement("link",{key:g,rel:"modulepreload",href:g,...n})),b.map(({key:g,link:x})=>l.createElement("link",{key:g,...x})))}function Zi(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var mo=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{mo&&(window.__reactRouterVersion="7.6.0")}catch{}function el({basename:e,children:t,window:n}){let r=l.useRef();r.current==null&&(r.current=Fa({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(ki,{basename:e,children:t,location:a.location,navigationType:a.action,navigator:o})}var po=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,go=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:g}=l.useContext(Fe),x=typeof d=="string"&&po.test(d),v,y=!1;if(typeof d=="string"&&x&&(v=d,mo))try{let A=new URL(window.location.href),$=d.startsWith("//")?new URL(A.protocol+d):new URL(d),J=Qe($.pathname,g);$.origin===A.origin&&J!=null?d=J+$.search+$.hash:y=!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=hi(d,{relative:o}),[w,C,_]=Yi(r,p),E=rl(d,{replace:i,state:u,target:c,preventScrollReset:f,relative:o,viewTransition:h});function j(A){t&&t(A),A.defaultPrevented||E(A)}let S=l.createElement("a",{...p,..._,href:v||m,onClick:y||a?t:j,ref:Zi(b,C),target:c,"data-discover":!x&&n==="render"?"true":void 0});return w&&!x?l.createElement(l.Fragment,null,S,l.createElement(Ji,{page:m})):S});go.displayName="Link";var tl=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=Sn(i,{relative:d.relative}),p=ie(),b=l.useContext(rs),{navigator:g,basename:x}=l.useContext(Fe),v=b!=null&&ul(h)&&u===!0,y=g.encodeLocation?g.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,y=y.toLowerCase()),w&&x&&(w=Qe(w,x)||w);const C=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let _=m===y||!o&&m.startsWith(y)&&m.charAt(C)==="/",E=w!=null&&(w===y||!o&&w.startsWith(y)&&w.charAt(y.length)==="/"),j={isActive:_,isPending:E,isTransitioning:v},S=_?t:void 0,A;typeof r=="function"?A=r(j):A=[r,_?"active":null,E?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let $=typeof a=="function"?a(j):a;return l.createElement(go,{...d,"aria-current":S,className:A,ref:f,style:$,to:i,viewTransition:u},typeof c=="function"?c(j):c)});tl.displayName="NavLink";var nl=l.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:o,state:a,method:i=Hn,action:u,onSubmit:c,relative:d,preventScrollReset:f,viewTransition:h,...p},b)=>{let g=ll(),x=cl(u,{relative:d}),v=i.toLowerCase()==="get"?"get":"post",y=typeof u=="string"&&po.test(u),m=w=>{if(c&&c(w),w.defaultPrevented)return;w.preventDefault();let C=w.nativeEvent.submitter,_=C?.getAttribute("formmethod")||i;g(C||w.currentTarget,{fetcherKey:t,method:_,navigate:n,replace:o,state:a,relative:d,preventScrollReset:f,viewTransition:h})};return l.createElement("form",{ref:b,method:v,action:x,onSubmit:r?c:m,...p,"data-discover":!y&&e==="render"?"true":void 0})});nl.displayName="Form";function sl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function xo(e){let t=l.useContext(Kt);return z(t,sl(e)),t}function rl(e,{target:t,replace:n,state:r,preventScrollReset:o,relative:a,viewTransition:i}={}){let u=ee(),c=ie(),d=Sn(e,{relative:a});return l.useCallback(f=>{if(Ii(f,t)){f.preventDefault();let h=n!==void 0?n:yn(c)===yn(d);u(e,{replace:h,state:r,preventScrollReset:o,relative:a,viewTransition:i})}},[c,u,d,n,r,t,e,o,a,i])}function ol(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(Ps(e)),n=l.useRef(!1),r=ie(),o=l.useMemo(()=>Oi(r.search,n.current?null:t.current),[r.search]),a=ee(),i=l.useCallback((u,c)=>{const d=Ps(typeof u=="function"?u(o):u);n.current=!0,a("?"+d,c)},[a,o]);return[o,i]}var al=0,il=()=>`__${String(++al)}__`;function ll(){let{router:e}=xo("useSubmit"),{basename:t}=l.useContext(Fe),n=Ni();return l.useCallback(async(r,o={})=>{let{action:a,method:i,encType:u,formData:c,body:d}=Di(r,t);if(o.navigate===!1){let f=o.fetcherKey||il();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 cl(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={...Sn(e||".",{relative:t})},i=ie();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:Ke([n,a.pathname])),yn(a)}function ul(e,t={}){let n=l.useContext(ao);z(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=xo("useViewTransitionState"),o=Sn(e,{relative:t.relative});if(!n.isTransitioning)return!1;let a=Qe(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=Qe(n.nextLocation.pathname,r)||n.nextLocation.pathname;return vn(o.pathname,i)!=null||vn(o.pathname,a)!=null}[...Ki];var dl=Sa(),bo=class extends Xr{constructor(e,t){super(),this.options=t,this.#n=e,this.#i=null,this.#a=pr(),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),_r(this.#e,this.options)?this.#d():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Is(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Is(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)||xn(this.options.staleTime,this.#e)!==xn(t.staleTime,this.#e))&&this.#g();const o=this.#x();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 fl(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(Gn)),t}#g(){this.#v();const e=xn(this.options.staleTime,this.#e);if(Ts||this.#t.isStale||!gr(e))return;const n=_a(this.#t.dataUpdatedAt,e)+1;this.#c=qn.setTimeout(()=>{this.#t.isStale||this.updateResult()},n)}#x(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(e){this.#w(),this.#l=e,!(Ts||Se(this.options.enabled,this.#e)===!1||!gr(this.#l)||this.#l===0)&&(this.#u=qn.setInterval(()=>{(this.options.refetchIntervalInBackground||Ea.isFocused())&&this.#d()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(qn.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(qn.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 S=this.hasListeners(),A=!S&&_r(e,t),$=S&&Er(e,n,t,r);(A||$)&&(f={...f,...ka(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:b,errorUpdatedAt:g,status:x}=f;p=f.data;let v=!1;if(t.placeholderData!==void 0&&p===void 0&&x==="pending"){let S;o?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(S=o.data,v=!0):S=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,S!==void 0&&(x="success",p=xr(o?.data,S,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=xr(o?.data,p,t),this.#h=p,this.#i=null}catch(S){this.#i=S}this.#i&&(b=this.#i,p=this.#h,g=Date.now(),x="error");const y=f.fetchStatus==="fetching",m=x==="pending",w=x==="error",C=m&&y,_=p!==void 0,j={status:x,fetchStatus:f.fetchStatus,isPending:m,isSuccess:x==="success",isError:w,isInitialLoading:C,isLoading:C,data:p,dataUpdatedAt:f.dataUpdatedAt,error:b,errorUpdatedAt:g,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:y,isRefetching:y&&!m,isLoadingError:w&&!_,isPaused:f.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:w&&_,isStale:Ks(e,t),refetch:this.refetch,promise:this.#a,isEnabled:Se(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const S=J=>{j.status==="error"?J.reject(j.error):j.data!==void 0&&J.resolve(j.data)},A=()=>{const J=this.#a=j.promise=pr();S(J)},$=this.#a;switch($.status){case"pending":e.queryHash===n.queryHash&&S($);break;case"fulfilled":(j.status==="error"||j.data!==$.value)&&A();break;case"rejected":(j.status!=="error"||j.error!==$.reason)&&A();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){ss.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#t)}),this.#n.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function hl(e,t){return Se(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function _r(e,t){return hl(e,t)||e.state.data!==void 0&&Is(e,t,t.refetchOnMount)}function Is(e,t,n){if(Se(t.enabled,e)!==!1&&xn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Ks(e,t)}return!1}function Er(e,t,n,r){return(e!==t||Se(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Ks(e,n)}function Ks(e,t){return Se(t.enabled,e)!==!1&&e.isStaleByTime(xn(t.staleTime,e))}function fl(e,t){return!Jn(e.getCurrentResult(),t)}var ml=class extends bo{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:br()})}getOptimisticResult(e){return e.behavior=br(),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:Ta(t,n.data),hasPreviousPage:Ra(t,n.data),isFetchNextPageError:d,isFetchingNextPage:f,isFetchPreviousPageError:h,isFetchingPreviousPage:p,isRefetchError:u&&!d&&!h,isRefetching:a&&!f&&!p}}},pl=class extends Xr{#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&&yr(n.mutationKey)!==yr(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??La();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){ss.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)})})}},yo=l.createContext(void 0),vo=e=>{const t=l.useContext(yo);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},gl=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(yo.Provider,{value:e,children:t})),wo=l.createContext(!1),xl=()=>l.useContext(wo);wo.Provider;function bl(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var yl=l.createContext(bl()),vl=()=>l.useContext(yl),wl=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Cl=e=>{l.useEffect(()=>{e.clearReset()},[e])},jl=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(o&&e.data===void 0||Zr(n,[e.error,r])),Nl=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))}},Sl=(e,t)=>e.isLoading&&e.isFetching&&!t,_l=(e,t)=>e?.suspense&&t.isPending,kr=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Co(e,t,n){const r=xl(),o=vl(),a=vo(),i=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(i),i._optimisticResults=r?"isRestoring":"optimistic",Nl(i),wl(i,o),Cl(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(ss.batchCalls(h)):Gn;return c.updateResult(),p},[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),l.useEffect(()=>{c.setOptions(i)},[i,c]),_l(i,d))throw kr(i,c,o);if(jl({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&&!Ts&&Sl(d,r)&&(u?kr(i,c,o):a.getQueryCache().get(i.queryHash)?.promise)?.catch(Gn).finally(()=>{c.updateResult()}),i.notifyOnChangeProps?d:c.trackResult(d)}function de(e,t){return Co(e,bo)}function X(e,t){const n=vo(),[r]=l.useState(()=>new pl(n,e));l.useEffect(()=>{r.setOptions(e)},[r,e]);const o=l.useSyncExternalStore(l.useCallback(i=>r.subscribe(ss.batchCalls(i)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=l.useCallback((i,u)=>{r.mutate(i,u).catch(Gn)},[r]);if(o.error&&Zr(r.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:a,mutateAsync:o.mutate}}function El(e,t){return Co(e,ml)}const lt="data-sources",jo="auth-user",kl=e=>de({queryKey:["project","datasources",e],queryFn:async()=>{const{data:t}=await O.get(`/project/team/${e}/datasources`);return t.data},enabled:!!e}),Rl=e=>de({queryKey:["project","saved-queries",e],queryFn:async()=>{const{data:t}=await O.get(`/project/team/${e}/queries`);return t.data},enabled:!!e}),Vt=e=>{const t=["project","datasources"],n=["project","saved-queries"];return Promise.all([K.invalidateQueries({queryKey:t}),K.invalidateQueries({queryKey:n})])},Tl=e=>{const t=["trash","team"];return K.invalidateQueries({queryKey:t})},Ll=(e,t)=>de({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}),Al=(e,t=30)=>El({queryKey:["project","tabs-history",e,t],queryFn:async({pageParam:n})=>{const{data:r}=await O.get(`/project/team/${e}/tabs-history?page=${n}&size=${t}`);return r},select:({pages:n})=>n.flatMap(r=>r.data),enabled:!!e,initialPageParam:0,getNextPageParam:(n,r)=>{if(n.hasMore)return r.length},staleTime:0}),Pl=()=>K.invalidateQueries({queryKey:["project","tabs-history"]}),Il=(e,t)=>{},Ol=()=>{},$l={event:Il,pageView:Ol},as=e=>de({queryKey:[lt,e],queryFn:async()=>{const{data:t}=await O.get("/data-sources/"+e);return t.data},enabled:!!e}),Vs=e=>de({queryKey:[lt,e.teamId],queryFn:async()=>{const{data:t}=await O.get("/data-sources",{params:e});return t.data},enabled:e.teamId!==void 0}),_n=e=>de({queryKey:[lt,e,"inspections"],queryFn:async()=>{const{data:t}=await O.get(`/data-sources/${e}/inspections`);return t.data},enabled:!!e}),Ml=()=>X({mutationFn:async e=>{const{data:t}=await O.post("/data-sources",e);return t.data},onSuccess:()=>{K.invalidateQueries({queryKey:[lt]}),Vt()},onError:()=>{}}),Dl=()=>X({mutationFn:async({dataSource:e,id:t})=>{const{data:n}=await O.put(`/data-sources/${t}`,e);return n.data},onSuccess:()=>{K.invalidateQueries({queryKey:[lt]}),Vt()}}),No=()=>X({mutationFn:async e=>{await O.post(`/data-sources/${e}/inspect`)},onSuccess:()=>{K.invalidateQueries({queryKey:[lt]})}}),Fl=()=>X({mutationFn:async e=>{await O.delete(`/data-sources/${e}`)},onSuccess:()=>{K.invalidateQueries({queryKey:[lt]}),Vt()}}),So=()=>de({queryKey:["accessToken"],queryFn:qs.get}),Te=()=>{const{data:e}=So();return de({queryKey:[jo],queryFn:async()=>{const{data:t}=await O.get("/users");return t.data},enabled:!!e,retry:(t,n)=>Aa(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([jo],e)}}),Bl=()=>X({mutationFn:async e=>(await O.post("/users",e),!0),onSuccess:()=>{K.invalidateQueries({queryKey:["team-users"]})}}),ge=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 Ul(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 Wl=e=>de({queryKey:["hooks",e],queryFn:async()=>{const t=await K.fetchQuery({queryKey:[lt,e,"inspections"],queryFn:async()=>{const{data:n}=await O.get(`/data-sources/${e}/inspections`);return n.data}});return Ul(t)},enabled:!!e}),_o=[{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"}],zl=_o.reduce((e,t)=>(e[t.value]=t.label,e),{});_o.reduce((e,t)=>(e[t.label]=t.value,e),{});const Qt=e=>e.map(t=>({label:zl[t],value:t}));Qt(["=","<>",">",">=","<","<=","IN","NOT IN","IS NULL","IS NOT NULL"]);Qt(["=","<>","LIKE","NOT LIKE","IN","NOT IN","IS NULL","IS NOT NULL"]);Qt(["=","<>","IS NULL","IS NOT NULL"]);Qt(["=","<>",">",">=","<","<=","IS NULL","IS NOT NULL"]);Qt(["IS NULL","IS NOT NULL"]);Qt(["IN","NOT IN"]);const Hl=["char","varchar","binary","varbinary","blob","text","enum","set","character","character varying","text","citext","uuid","xml","json","jsonb"],Kl=new Set(Hl),Vl=e=>Kl.has(e),Ql=["integer","smallint","decimal","numeric","float","real","double precision","int","smallint","integer","bigint","decimal","numeric","real","double precision","serial","bigserial","money"],Yl=new Set(Ql),Jl=e=>Yl.has(e),Gl=["date","datetime","timestamp","timestamptz"].reduce((e,t)=>(e[t]=!0,e),{}),Eo=e=>e.fn?e.distinct===!0?`${e.fn} distinct ${e.value}`:`${e.fn} ${e.value}`:e.value;var ue=(e=>(e.OWNER="owner",e.ADMIN="admin",e.EDITOR="editor",e.READ_ONLY="read_only",e))(ue||{});const Rr={[ue.READ_ONLY]:10,[ue.EDITOR]:20,[ue.ADMIN]:30,[ue.OWNER]:40},Je=e=>e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e,Xl={operator:"LIKE",parse:e=>{const t=e.match(/^LIKE\s*["'](.*)["']$/i);if(t)return[{value:Je(t[1])}]},stringify:(e,t)=>Vl(t)?`${e.value?.[0].value}`:`LIKE "%${e.value?.[0].value}%"`},Zl={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 ko(e){return e===""?[]:ec(e).map(tc)}function ec(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 tc(e){if(e.startsWith("'")&&e.endsWith("'"))return{value:Tr(e.slice(1,-1),"'")};if(e.startsWith('"')&&e.endsWith('"'))return{value:Tr(e.slice(1,-1),'"')};const t=Number(e);if(!Number.isNaN(t))return{value:t};throw new Error(`Invalid literal: ${e}`)}function Tr(e,t){return e.replace(/\\(.)/g,(n,r)=>r)}const nc={operator:"IN",parse:e=>{const t=e.match(/^in\s*\((.*)\)$/i);if(t)return ko(t[1])},stringify:e=>`IN (${e.value?.map(t=>`"${t.value}"`).join(", ")})`},sc={operator:"NOT IN",parse:e=>{const t=e.match(/^not\s+in\s*\((.*)\)$/i);if(t)return ko(t[1])},stringify:e=>`NOT IN (${e.value?.map(t=>`"${t.value}"`).join(", ")})`},rc={operator:"=",parse:e=>{const t=e.match(/^=\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:(e,t)=>Jl(t)?`${e.value?.[0].value}`:`= ${e.value?.[0].value}`},oc={operator:"!=",parse:e=>{const t=e.match(/^!=\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`!= ${e.value?.[0].value}`},ac={operator:"<>",parse:e=>{const t=e.match(/^<>\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`<> ${e.value?.[0].value}`},ic={operator:">",parse:e=>{const t=e.match(/^>\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`> ${e.value?.[0].value}`},lc={operator:">=",parse:e=>{const t=e.match(/^>=\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`>= ${e.value?.[0].value}`},cc={operator:"<",parse:e=>{const t=e.match(/^<\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`< ${e.value?.[0].value}`},uc={operator:"<=",parse:e=>{const t=e.match(/^<=\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`<= ${e.value?.[0].value}`},dc={operator:"IS NULL",parse:e=>{if(/^is\s+null$/i.test(e))return[]},stringify:()=>"IS NULL"},hc={operator:"IS NOT NULL",parse:e=>{if(/^is\s+not\s+null$/i.test(e))return[]},stringify:()=>"IS NOT NULL"},fc=[Xl,Zl,nc,sc,rc,oc,ac,lc,ic,uc,cc,dc,hc];fc.reduce((e,t)=>(e[t.operator]=t,e),{});function mc(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 pc(e,t,n,r){const{data:o}=Wl(t),{data:a}=_n(t);return l.useMemo(()=>{const i=mc(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=Eo(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 gc(e,t){return l.useMemo(()=>({state:e,setState:t}),[e,t])}function Yt(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??[]}}const F={home:{path:"/"},workbench:{path:"/workbench"},share:{path:"/share"},login:{path:"/login"}},Qs=e=>{K.setQueryData(["workbench-tabs"],t=>e(t||[]))},xc=(e,t)=>{K.setQueryData(["workbench-tabs",e],n=>n&&t(n))},Ys=()=>de({queryKey:["workbench-tabs"],queryFn:async()=>{const{data:e}=await O.get("/workbench-tabs");return e.data}}),bc=e=>de({queryKey:["workbench-tabs",e],queryFn:async()=>{const{data:t}=await O.get(`/workbench-tabs/${e}`);return t.data}}),Jt=()=>X({mutationFn:async e=>{const{data:t}=await O.post("/workbench-tabs",e);return t.data},onSuccess:async e=>{Qs(t=>[...t,e])}}),yc=()=>X({mutationFn:async e=>(await O.patch(`/workbench-tabs/${e}`,{archived:!0}),e),onMutate:e=>{Qs(t=>t.filter(n=>n.id!==e))}}),Ro=()=>X({mutationFn:async e=>(await O.patch(`/workbench-tabs/${e}`,{archived:!1}),e),onSuccess:()=>Lo()}),vc=()=>X({mutationFn:async({id:e,payload:t})=>(await O.patch(`/workbench-tabs/${e}`,t),!0),onMutate:({id:e,payload:t})=>{xc(e,n=>({...n,...t})),Qs(n=>n.map(r=>r.id!==e?r:{...r,name:t.name||r.name}))}}),wc=(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 de({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:Pa})},Cc=()=>X({mutationFn:async e=>{await O.delete(`/workbench-tabs/${e}`)},onSuccess:()=>{Lo(),Pl()}}),To=e=>K.invalidateQueries({queryKey:["workbench-tab-runner",e]}),Lo=()=>K.invalidateQueries({queryKey:["workbench-tabs"]}),[jc,vs,Nc]=ge(void 0),Sc=async()=>new Promise(e=>{vs({onCancel:()=>{vs(void 0),e(void 0)},onConfirm:(t,n,r)=>{vs(void 0),e({dsId:r,id:n,type:t})}})}),En=e=>{const t=ee(),n=Jt(),r=Ro();return l.useEffect(()=>{n?.data?.id&&t(`${F.workbench.path}/tab/${n.data.id}`),r?.data&&t(`${F.workbench.path}/tab/${r?.data}`)},[n.data,r.data]),l.useCallback(()=>{Nc.get()||Sc().then(a=>{a?.type==="table"?n.mutate({name:a.id,opts:Yt({table:a.id,dataSourceId:a.dsId})}):a?.type==="query"?n.mutate({queryId:a.id}):a?.type==="tab"&&r.mutate(a.id)})},[t,e])},kn=e=>{const{data:t}=Te();return l.useMemo(()=>t?Rr[t.teamRole]>=Rr[e]:!1,[t,e])},_c="_input_4lyb8_2",Ec="_small_4lyb8_2",kc="_content_4lyb8_2",Rc="_form_4lyb8_2",Tc="_mode-select_4lyb8_2",D={input:_c,small:Ec,content:kc,form:Rc,switch:"_switch_4lyb8_2",modeSelect:Tc},Lc="_modal_15glu_2",Ac="_modal-visible_15glu_2",Pc="_modal-invisible_15glu_2",Ic="_backdrop_15glu_2",Oc="_modal-container_15glu_2",$c="_close-button_15glu_2",Dt={modal:Lc,modalVisible:Ac,modalInvisible:Pc,backdrop:Ic,modalContainer:Oc,closeButton:$c},vt=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"})),xe=({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:k(Dt.modal,n?Dt.modalVisible:Dt.modalInvisible),children:[s.jsx("div",{onClick:d,className:Dt.backdrop}),s.jsx("div",{className:k(Dt.modalContainer,a!==!0&&"p-4"),children:u&&e})]});return i?dl.createPortal(h,document.body):h},Ge=({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:Dt.closeButton,onClick:e,children:s.jsx(vt,{width:20,height:20})})},Ao=({children:e})=>s.jsx("h2",{className:"text-xl font-semibold",children:e}),Mc=({form:e,change:t})=>s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:k(D.input,D.small),children:[s.jsx("label",{children:"Database URL"}),s.jsx("input",{value:e.dbUrl,onChange:t("dbUrl"),className:"input"})]}),s.jsxs("div",{className:k(D.input,D.small),children:[s.jsx("label",{children:"Database port"}),s.jsx("input",{value:e.dbPort,onChange:t("dbPort"),type:"number",className:"input"})]}),s.jsxs("div",{className:k(D.input,D.small),children:[s.jsx("label",{children:"User"}),s.jsx("input",{value:e.dbUser,onChange:t("dbUser"),className:"input"})]}),s.jsxs("div",{className:k(D.input,D.small),children:[s.jsx("label",{children:"Password"}),s.jsx("input",{type:"password",value:e.dbPassword,onChange:t("dbPassword"),className:"input"})]}),s.jsxs("div",{className:k(D.input,D.small),children:[s.jsx("label",{children:"Database"}),s.jsx("input",{value:e.dbDatabase,onChange:t("dbDatabase"),className:"input"})]})]}),Dc=({form:e,change:t})=>s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:k(D.input,D.small),children:[s.jsx("label",{children:"Database URL"}),s.jsx("input",{value:e.dbUrl,onChange:t("dbUrl"),className:"input"})]}),s.jsxs("div",{className:k(D.input,D.small),children:[s.jsx("label",{children:"Database port"}),s.jsx("input",{value:e.dbPort,onChange:t("dbPort"),type:"number",className:"input"})]}),s.jsxs("div",{className:k(D.input,D.small),children:[s.jsx("label",{children:"User"}),s.jsx("input",{value:e.dbUser,onChange:t("dbUser"),className:"input"})]}),s.jsxs("div",{className:k(D.input,D.small),children:[s.jsx("label",{children:"Password"}),s.jsx("input",{type:"password",value:e.dbPassword,onChange:t("dbPassword"),className:"input"})]}),s.jsxs("div",{className:k(D.input,D.small),children:[s.jsx("label",{children:"Database"}),s.jsx("input",{value:e.dbDatabase,onChange:t("dbDatabase"),className:"input"})]}),s.jsxs("div",{className:k(D.input,D.small),children:[s.jsx("label",{children:"Schema"}),s.jsx("input",{value:e.dbSchema,onChange:t("dbSchema"),className:"input"})]})]}),It=[{label:"PostgreSQL",tag:"postgres"},{label:"MySQL",tag:"mysql"}],Fc=({show:e,onClose:t,dbType:n="postgres"})=>{const r=Ml(),o=No(),{data:a}=Te(),[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 g=await r.mutateAsync({...i,dbPort:Number(i.dbPort),teamId:a.teamId,ownerId:a.id});await o.mutateAsync(g.id),t(),$l.event("Create Datasource",{dbType:i.dbType})},f=g=>{c("allowInsert",!g),c("allowUpdate",!g)},h=()=>{t()},p=r.isPending||o.isPending,b=!i.allowInsert&&!i.allowUpdate;return s.jsxs(xe,{isVisible:e,onClose:h,children:[s.jsxs("div",{className:"max-w-xl mx-auto overflow-y-auto",children:[s.jsxs(Z,{variant:"warning",className:"text-sm mb-2 max-w-xl",children:["DataRamen is currently under active development. In production-like environments, ",s.jsx("span",{className:"font-semibold underline",children:"it’s recommended to use read-only database credentials"}),"."]}),r.isError&&s.jsx(Z,{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(Z,{className:"mb-2",variant:"info",children:"Creating connection"}),o.isPending&&s.jsx(Z,{className:"mb-2",variant:"info",children:"Inspecting connection"}),s.jsxs("div",{className:D.switch,children:[s.jsxs("label",{className:"button tertiary",children:[s.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:i.dbType===It[0].tag,onChange:()=>c("dbType",It[0].tag)}),s.jsx("span",{children:It[0].label})]}),s.jsxs("label",{className:"button tertiary",children:[s.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:i.dbType===It[1].tag,onChange:()=>c("dbType",It[1].tag)}),s.jsx("span",{children:It[1].label})]})]}),s.jsxs("div",{className:"overflow-y-auto mt-2",children:[s.jsx("div",{className:D.content,children:s.jsxs("div",{className:D.form,children:[s.jsxs("div",{className:k(D.input,"col-span-2"),children:[s.jsx("label",{children:"Name"}),s.jsx("input",{value:i.name,onChange:u("name"),className:"input"})]}),s.jsxs("div",{className:k(D.input,"col-span-2"),children:[s.jsx("label",{children:"Description"}),s.jsx("textarea",{value:i.description,onChange:u("description"),className:"input"})]}),i.dbType==="mysql"&&s.jsx(Mc,{form:i,change:u}),i.dbType==="postgres"&&s.jsx(Dc,{form:i,change:u})]})}),s.jsxs("div",{className:"mt-4",children:[s.jsxs("label",{className:D.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:D.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"})]})]})},qc="_data-source-entry_shdht_2",Bc="_action-title_shdht_2",Uc="_action-subtext_shdht_2",Wc="_dev-tag_shdht_2",zc="_prod-tag_shdht_2",ae={dataSourceEntry:qc,actionTitle:Bc,actionSubtext:Uc,devTag:Wc,prodTag:zc},Hc=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"})),Kc=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"}})),Gt=({size:e,type:t})=>t==="mysql"?s.jsx(Hc,{width:e,height:e}):s.jsx(Kc,{width:e,height:e}),[Vc,qt]=ge(void 0),[Qc,Bt]=ge({show:!1}),Yc=()=>{const e=En("Home");return s.jsxs("div",{className:"card-white hover:bg-gray-50! cursor-pointer",onClick:e,children:[s.jsxs("h2",{className:ae.actionTitle,children:[s.jsx("span",{className:"truncate",children:"🔎 Start new query"}),s.jsx("span",{className:"hotkey",children:"N"})]}),s.jsx("p",{className:ae.actionSubtext,children:"Select table to start new query."})]})},Jc=()=>{const[e,t]=l.useState(void 0),n=kn(ue.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(Fc,{show:!0,dbType:e,onClose:()=>t(void 0)}),s.jsxs("div",{className:"card-white hover:bg-gray-50! cursor-pointer",onClick:()=>r("postgres"),children:[s.jsx("p",{className:ae.actionTitle,children:"🧙♂️ Connection wizard"}),s.jsx("p",{className:ae.actionSubtext,children:"Configure new database connection."})]})]})},Gc=()=>{const e=ee(),{data:t}=Ys(),n=En("Home"),r=()=>{t&&t.length>0?e(`${F.workbench.path}/tab/${t[0].id}`):n()};return s.jsxs("div",{className:"card-white hover:bg-gray-50! cursor-pointer",onClick:r,children:[s.jsxs("h2",{className:ae.actionTitle,children:[s.jsx("span",{children:"🛠️ Workbench"}),s.jsx("span",{className:"hotkey",children:"W"})]}),s.jsx("p",{className:ae.actionSubtext,children:"Continue your work from where you left."})]})},Xc=()=>{const{data:e}=Te(),{data:t}=Vs({teamId:e?.teamId}),n=r=>{qt(r)};return!t||t.length===0?null:s.jsxs("div",{className:"mt-8",children:[s.jsx("h2",{className:"font-semibold text-gray-700",children:"Data sources"}),s.jsx("div",{className:"grid lg:grid-cols-3 gap-2 mt-4",children:t?.map(r=>s.jsxs("div",{className:ae.dataSourceEntry,onClick:()=>n(r.id),tabIndex:0,children:[s.jsx(Gt,{size:32,type:r.dbType}),s.jsxs("div",{className:"overflow-hidden",children:[s.jsx("p",{className:"font-semibold truncate text-gray-800 flex-1",children:r.name}),r.allowInsert?s.jsx("span",{className:ae.devTag,children:"dev"}):s.jsx("span",{className:ae.prodTag,children:"prod"})]})]},r.id))})]})},Zc=()=>s.jsxs("div",{className:"mt-8",children:[s.jsx("h2",{className:"font-semibold text-gray-700",children:"Useful links"}),s.jsxs("div",{className:"grid lg:grid-cols-3 gap-2 mt-4",children:[s.jsxs("a",{className:"card-white hover:bg-gray-50!",href:"https://dataramen.xyz/",children:[s.jsx("h2",{className:ae.actionTitle,children:"↗️ Documentation"}),s.jsx("p",{className:ae.actionSubtext,children:"Learn how to use DataRamen"})]}),s.jsxs("a",{className:"card-white hover:bg-gray-50!",href:"https://github.com/OleksandrDemian/dataramen",children:[s.jsx("h2",{className:ae.actionTitle,children:"↗️ Github"}),s.jsx("p",{className:ae.actionSubtext,children:"Codebase is open source"})]}),s.jsxs("a",{className:"card-white hover:bg-gray-50!",href:"#",onClick:()=>Bt({show:!0}),children:[s.jsxs("h2",{className:ae.actionTitle,children:[s.jsx("span",{children:"⌛ Recent tabs"}),s.jsx("span",{className:"hotkey",children:"H"})]}),s.jsx("p",{className:ae.actionSubtext,children:"Manage recent tabs"})]})]})]}),eu=()=>{const{data:e}=Te(),{data:t}=Vs({teamId:e?.teamId}),n=!!t&&t.length>0,r=!!e;return s.jsx("div",{className:"page-container h-screen max-h-screen",children:s.jsxs("div",{className:"max-w-6xl h-full pb-12 overflow-y-auto",children:[s.jsx("div",{className:"py-10 text-center w-full",children:s.jsx("h1",{className:"comfortaa text-3xl font-semibold",children:"DataRamen"})}),r&&!n&&s.jsx(Z,{variant:"warning",className:"font-semibold",children:"Connect at least one data source to start using DataRamen"}),s.jsx("h2",{className:"font-semibold text-gray-700 mt-4 hidden lg:block",children:"Quick actions"}),s.jsxs("div",{className:"grid lg:grid-cols-3 gap-2 mt-4",children:[s.jsx(Yc,{}),s.jsx(Jc,{}),r&&s.jsx(Gc,{})]}),r&&s.jsx(Xc,{}),s.jsx(Zc,{})]})})},[tu,Js]=ge(void 0),nu=()=>Js(void 0);function bt(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_1d91y_2",ru="_header_1d91y_2",ou="_fields-container_1d91y_2",au="_field-label_1d91y_2",iu="_actions_1d91y_2",fn={container:su,header:ru,fieldsContainer:ou,fieldLabel:au,actions:iu},lu=(e,t,n)=>de({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}),cu=()=>X({mutationFn:async e=>{const{data:t}=await O.post(`/runner/${e.datasourceId}/update`,e);return t.data}}),uu=()=>X({mutationFn:async e=>{const{data:t}=await O.post(`/runner/${e.datasourceId}/insert`,e);return t.data}}),Gs=e=>l.useMemo(()=>{if(e)return e instanceof Ia?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]),Xs=()=>{const{pathname:e}=ie();return l.useMemo(()=>vn({path:`${F.workbench.path}/tab/:id`,end:!1},e)?.params.id,[e])},du=({data:e})=>{const[t,{change:n,touched:r}]=Cn({}),o=Xs(),{mutateAsync:a,error:i}=uu(),u=Gs(i),{data:c}=_n(e.dataSourceId),[d,f]=l.useState(""),h=l.useMemo(()=>c?.find(g=>g.tableName===e.table),[c,e.table]),p=l.useMemo(()=>{if(!h)return[];if(!d)return h.columns.map(x=>({...x,label:nt(x.name)}));const g=d.toLowerCase();return h.columns.filter(x=>x.name.toLowerCase().includes(g)).map(x=>({...x,label:nt(x.name)}))},[d,h]),b=()=>{const g=[];for(const x of r)g.push({value:t[x],column:x});a({datasourceId:e.dataSourceId,table:e.table,values:g}).then(()=>{nu(),o&&To(o)})};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:fn.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(Z,{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:fn.container,children:s.jsx("div",{className:fn.fieldsContainer,children:p.map(g=>s.jsxs("label",{className:fn.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsxs("p",{children:[g.isPrimary?"🔐":"🏷️"," ",g.label]}),s.jsxs("p",{className:"text-blue-800 text-sm",children:["[",g.name,": ",g.type,"]"]})]}),s.jsx("input",{className:"input w-full",value:bt(t[g.name]),onChange:n(g.name),placeholder:g.name})]},g.name))})}),s.jsxs("div",{className:fn.actions,children:[s.jsxs("label",{children:[s.jsx("span",{className:"mr-2",children:"🔎"}),s.jsx("input",{className:"input bg-white!",value:d,onChange:g=>f(g.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"})]})]})},hu=()=>{const e=tu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const r=()=>Js(void 0);return s.jsxs(xe,{isVisible:e!=null,onClose:r,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(Ge,{onClick:r}),t&&s.jsx(du,{data:t})]})},[fu,is]=ge(void 0),mu=()=>is(void 0),pu="_container_12xzb_2",gu="_header_12xzb_2",xu="_key_12xzb_2",bu="_fields-container_12xzb_2",yu="_field-label_12xzb_2",vu="_actions_12xzb_2",Ot={container:pu,header:gu,key:xu,fieldsContainer:bu,fieldLabel:yu,actions:vu},at=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),wu=({data:e})=>{const[t,{change:n,set:r,reset:o,touched:a}]=Cn({}),i=Xs(),[u,c]=l.useState(""),{data:d,isLoading:f}=lu(e.dataSourceId,e.tableName,e.entityId),{mutateAsync:h,error:p}=cu(),b=Gs(p),g=kn(ue.EDITOR),{data:x}=_n(e.dataSourceId),{data:v}=as(e.dataSourceId),y=l.useMemo(()=>x?.find(E=>E.tableName===e.tableName),[e.tableName,x]),m=l.useMemo(()=>{if(!y)return[];if(!u)return y.columns.map(j=>({...j,label:nt(j.name)}));const E=u.toLowerCase();return y.columns.filter(j=>j.name.toLowerCase().includes(E)).map(j=>({...j,label:nt(j.name)}))},[u,y]);l.useEffect(()=>{const E=d?.entity;if(o(),E&&d?.columns)for(let j=0;j<d.columns.length;j++){const S=d.columns[j];r(S.column,bt(E[j]))}},[d,r,o]);const w=()=>{const E=[];for(const j of a)E.push({value:t[j],column:j});h({datasourceId:e.dataSourceId,table:e.tableName,filters:e.entityId.map(j=>({id:at(),value:[{value:j[1]}],column:j[0],connector:"AND",operator:"="})),values:E}).then(()=>{mu(),i&&To(i)})},C=e.entityId.map(([E,j])=>`${E} = ${j}`).join(", ")||"",_=!v?.allowUpdate||!g;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:Ot.header,children:[s.jsxs("p",{className:"text-lg font-semibold",children:[_?"View":"Edit"," row in ",s.jsx("span",{className:"underline",children:e?.tableName})]}),s.jsx("span",{className:Ot.key,children:C}),b&&s.jsx(Z,{variant:"danger",children:s.jsx("p",{children:b})})]}),!_&&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:Ot.container,children:s.jsx("div",{className:Ot.fieldsContainer,children:m.map(E=>s.jsxs("label",{className:Ot.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsxs("p",{children:[E.isPrimary?"🔐":"🏷️"," ",E.label]}),s.jsxs("p",{className:"text-blue-800 text-sm",children:["[",E.name,": ",E.type,"]"]})]}),s.jsx("input",{disabled:E.isPrimary||f||_,className:"input w-full",value:bt(t[E.name]),onChange:n(E.name),placeholder:E.name})]},E.name))})}),s.jsxs("div",{className:Ot.actions,children:[s.jsxs("label",{children:[s.jsx("span",{className:"mr-2",children:"🔎"}),s.jsx("input",{className:"input bg-white!",value:u,onChange:E=>c(E.target.value),placeholder:"Filter columns"})]}),s.jsx("span",{className:"flex-1"}),!_&&s.jsx("button",{disabled:!a.length,className:"button primary",onClick:w,children:"Run update"})]})]})},Cu=()=>{const e=fu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const r=()=>is(void 0);return s.jsxs(xe,{isVisible:e!=null,onClose:r,onClosed:()=>n(void 0),noPadding:!0,children:[s.jsx(Ge,{onClick:r}),t&&s.jsx(wu,{data:t})]})},[ju,ws]=ge(void 0),Po=async e=>new Promise(t=>{ws({message:e,onCancel:()=>{t(!1),ws(void 0)},onConfirm:()=>{t(!0),ws(void 0)}})}),Nu=({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"})]})]}),Su=()=>{const e=ju(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(xe,{isVisible:!!e,onClose:()=>e?.onCancel(),onClosed:()=>n(void 0),children:t&&s.jsx(Nu,{confirm:t})})},[_u,Qn]=ge(void 0),Rn=async(e,t,n)=>new Promise(r=>{Qn({message:e,defaultValue:t,alert:n,onCancel:()=>{Qn(void 0),r(void 0)},onConfirm:o=>{Qn(void 0),r(o)}})}),Eu="_root_ng9lp_1",ku={root:Eu},Ru=({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:ku.root,children:[s.jsx("h2",{className:"text-xl font-semibold",children:e.message}),e.alert&&s.jsx(Z,{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"})]})]})},Tu=()=>{const e=_u(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(xe,{isVisible:!!e,onClose:()=>Qn(void 0),onClosed:()=>n(void 0),children:t&&s.jsx(Ru,{data:t})})},[Lu,Au]=ge(void 0),Io=e=>{Au(e)},Pu="_textarea_xjmxk_2",Iu={textarea:Pu},Ou=()=>{const e=Lu(),t=()=>{e&&(navigator.clipboard.writeText(e.toString()),Ce.success("Copied!"))},n=()=>Io(void 0);return s.jsxs(xe,{isVisible:!!e,onClose:n,backdropClose:!0,children:[s.jsx("textarea",{className:Iu.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"})]})]})},$u="_tabs_ud43z_2",Mu="_mobile_ud43z_2",Du="_tab_ud43z_2",Fu="_active_ud43z_2",qu="_close-button_ud43z_2",mn={tabs:$u,mobile:Mu,tab:Du,active:Fu,closeButton:qu},Lr=e=>window.matchMedia(e).matches;function Oo(e,{defaultValue:t=!1,initializeWithValue:n=!0}={}){const[r,o]=l.useState(()=>n?Lr(e):t);return l.useLayoutEffect(()=>{const a=window.matchMedia(e);function i(){o(()=>Lr(e))}return i(),a.addListener?a.addListener(i):a.addEventListener("change",i),()=>{a.removeListener?a.removeListener(i):a.removeEventListener("change",i)}},[e]),r}const Zs={laptop:"(min-width: 1024px)"},$o=()=>window.matchMedia(Zs.laptop).matches,Bu="_table_1owsc_2",Uu="_row-index-btn_1owsc_2",Wu="_semi-transparent_1owsc_2",zu="_table-loading_1owsc_2",Hu="_table-empty_1owsc_2",Ku="_table-row-cells_1owsc_2",Vu="_header-cell_1owsc_2",Qu="_header-actions_1owsc_2",Yu="_cell_1owsc_2",Ju="_value_1owsc_2",Gu="_table-config_1owsc_2",Xu="_table-action_1owsc_2",Zu="_green-fixed_1owsc_2",ed="_gray_1owsc_2",td="_modal_1owsc_2",nd="_selected-size_1owsc_2",sd="_pagination-indicator_1owsc_2",R={table:Bu,rowIndexBtn:Uu,semiTransparent:Wu,tableLoading:zu,tableEmpty:Hu,tableRowCells:Ku,headerCell:Vu,headerActions:Qu,cell:Yu,value:Ju,tableConfig:Gu,tableAction:Xu,greenFixed:Zu,gray:ed,modal:td,selectedSize:nd,paginationIndicator:sd},Be=l.createContext({name:"No name",hooks:[],availableJoins:[],allColumns:[],dataSourceId:"",entities:[],getValue:()=>{},getColumnType:()=>{},getEntityKey:()=>[],getEntityKeyByRowIndex:()=>[]}),he=l.createContext({state:Yt({}),setState:()=>{}}),Le=l.createContext({}),Mo={ON_ANIMATION_END:Symbol("ON_TRANSITION_END")},Do=()=>{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,[Mo.ON_ANIMATION_END]:i}},[e,n])},rd=e=>{if(e==="ASC")return"DESC";if(e!=="DESC")return"ASC"},od=()=>{const{state:e,setState:t}=l.useContext(he),n=l.useCallback(r=>{t(o=>{const a=o.orderBy[0];if(a&&a.column===r){const i=rd(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}},ad="_options-container_hrngm_2",id="_filter-input_hrngm_2",ld="_option-item_hrngm_2",cd="_list_hrngm_2",ud="_empty-text_hrngm_2",Ve={optionsContainer:ad,filterInput:id,optionItem:ld,list:cd,emptyText:ud},dd="_container_1a9rl_2",hd="_animate-show_1a9rl_2",fd="_animate-hide_1a9rl_2",md="_content_1a9rl_2",pd="_backdrop_1a9rl_2",mt={container:dd,animateShow:hd,animateHide:fd,content:md,backdrop:pd},Fo=({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,$o()?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:k(mt.container,t.state==="out"&&mt.animateHide,t.state==="in"&&mt.animateShow),onAnimationEnd:t[Mo.ON_ANIMATION_END],children:[s.jsx("div",{className:mt.backdrop,onClick:o=>{o.stopPropagation(),o.preventDefault(),t.close()}}),s.jsx("div",{className:k(mt.content,t.state==="out"&&mt.animateHide,t.state==="in"&&mt.animateShow),style:r,children:e})]}):null},Ye=(e,t)=>e!=null&&e>t,gd="_root_v5920_2",xd="_content_v5920_2",bd="_table-name_v5920_2",yd="_sub_v5920_2",Un={root:gd,content:xd,tableName:bd,sub:yd},qo=({hook:e,onClick:t})=>s.jsxs("button",{className:Un.root,onClick:t,children:[s.jsx("span",{children:"📄"}),s.jsxs("div",{className:Un.content,children:[s.jsx("span",{className:Un.tableName,children:e.on.toTable}),s.jsxs("span",{className:Un.sub,children:[e.on.toColumn," = ",e.on.fromTable,".",e.on.fromColumn]})]})]},e.where),vd=k("input",Ve.filterInput);function wd(e,t,n){return{name:`${e.on.toTable} ${e.on.toColumn} equals ${n}`,opts:Yt({table:e.on.toTable,dataSourceId:t,filters:[{id:at(),column:`${e.on.toTable}.${e.on.toColumn}`,value:n==null?"IS NULL":`${n}`,isEnabled:!0}]})}}const Bo=({rowIndex:e,onClose:t,className:n})=>{const[r,o]=l.useState(""),{hooks:a,dataSourceId:i,getValue:u}=l.useContext(Be),{state:c}=l.useContext(he),{data:d}=l.useContext(Le),f=l.useMemo(()=>d?.result.rows[e],[d,e]),h=Jt(),p=ee(),b=l.useMemo(()=>{if(!d)return[];const y=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(y):!1)},[r,a,d]),g=y=>{f&&h.mutateAsync(wd(y,i,u(f,{value:`${y.on.fromTable}.${y.on.fromColumn}`}))).then(m=>{p(`${F.workbench.path}/tab/${m.id}`),t?.()})},x=()=>{!f||!c||h.mutateAsync({name:`${c.table} > [${c.joins.map(y=>y.table).join()}]`,opts:Yt({joins:c.joins,table:c.table,dataSourceId:c.dataSourceId,filters:[...c.filters.filter(y=>y.isEnabled),...c.groupBy.map(y=>({id:at(),column:y.value,value:`${u(f,y)}`,isEnabled:!0}))]})}).then(y=>{p(`${F.workbench.path}/tab/${y.id}`),t?.()})},v=c.groupBy.length>0;return s.jsxs("div",{className:n,children:[s.jsx("input",{className:vd,placeholder:"Filter",value:r,onChange:y=>o(y.target.value)}),s.jsxs("div",{className:Ve.list,children:[v&&s.jsx("button",{onClick:x,className:Ve.optionItem,children:"🎯 Underlying rows"}),Ye(b.length,0)?b.map(y=>s.jsx(qo,{hook:y,onClick:()=>g(y)},y.where)):s.jsx("p",{className:Ve.emptyText,children:"Empty"})]})]})},Cd=({handler:e,rowIndex:t})=>s.jsx(Fo,{handler:e,children:s.jsx("div",{className:Ve.optionsContainer,children:s.jsx(Bo,{rowIndex:t,className:"p-2",onClose:()=>{e.close()}})})}),er=()=>{const{state:e,setState:t}=l.useContext(he),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}},jd=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"})),rt=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"})),Nd=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"})),Uo=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"})),Sd="_container_jbrp0_2",_d="_animate-show_jbrp0_2",Ed="_animate-hide_jbrp0_2",kd="_backdrop_jbrp0_2",Rd="_content_jbrp0_2",pt={container:Sd,animateShow:_d,animateHide:Ed,backdrop:kd,content:Rd},Td=({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:d=>{const f={},h=d.clientY>window.innerHeight/2,p=d.clientX>window.innerWidth/2;h?f.bottom=window.innerHeight-d.clientY:f.top=d.clientY,$o()?p?f.right=window.innerWidth-d.clientX:f.left=d.clientX:(f.right=36,f.left=36),o(f),i("in")},close:()=>{i("out")}}),[]),!r)return null;const c=()=>{a==="in"?i("visible"):a==="out"&&(o(void 0),i("hidden"),n?.())};return s.jsxs("div",{className:k(pt.container,a==="out"&&pt.animateHide,a==="in"&&pt.animateShow),onAnimationEnd:c,children:[s.jsx("div",{className:pt.backdrop,onClick:()=>i("out")}),s.jsx("div",{ref:u,style:r,className:k(pt.content,a==="out"&&pt.animateHide,a==="in"&&pt.animateShow),children:e})]})};function Cs(e,t,n){const r=e?.rows?.[t]?.[n],o=e?.columns?.[n];return{value:r,column:o}}const Ld=({ref:e})=>{const{data:t}=l.useContext(Le),{getColumnType:n}=l.useContext(Be),{setState:r}=l.useContext(he);return{copyValue:(u,c)=>{const{value:d,column:f}=Cs(t?.result,u,c);if(f){const h=bt(d,n(f.full));navigator.clipboard.writeText(h),Ce.success("Copied!"),e.current?.close()}},showValue:(u,c)=>{const{value:d,column:f}=Cs(t?.result,u,c);if(f){const h=bt(d,n(f.full));Io(h),e.current?.close()}},filterValue:(u,c)=>{const{value:d,column:f}=Cs(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:at(),isEnabled:!0,column:h,value:"IS NULL"};else{const b=bt(d,n(h));p={id:at(),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()}}}},Wo=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})),Ad=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})),Pd="_section-name_up5ey_2",Id="_item_up5ey_2",gt={sectionName:Pd,item:Id},Od=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"})),$d=k("input",Ve.filterInput),Md=({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);is({tableName:p,dataSourceId:i,entityId:b}),e?.()};return s.jsxs("div",{className:n,children:[s.jsx("input",{className:$d,placeholder:"Filter",value:r,onChange:p=>o(p.target.value)}),s.jsx("div",{className:Ve.list,children:Ye(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"})})]})},Dd=({ref:e,row:t,col:n,onClosed:r})=>{const o=Ld({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 x=d(u[0],t);is({tableName:u[0],dataSourceId:c,entityId:x}),e.current?.close()}else i("expand")},g=()=>{r?.(),i("cell")};return s.jsx(Td,{ref:e,onClosed:g,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(Wo,{width:14,height:14}),"Copy"]}),s.jsxs("button",{className:gt.item,onClick:h,children:[s.jsx(Ad,{width:14,height:14}),"View"]}),s.jsxs("button",{className:gt.item,onClick:p,children:[s.jsx(Uo,{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(rt,{width:14,height:14}),"Drill down"]}),u?.length>0&&s.jsxs("button",{className:gt.item,onClick:b,children:[s.jsx(Od,{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(rt,{className:"rotate-180",width:16,height:16}),"Drill down"]}),s.jsx(Bo,{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(rt,{className:"rotate-180",width:16,height:16}),"Expand row"]}),s.jsx(Md,{rowIndex:t,onClose:()=>e.current?.close()})]})]})})},Fd={DESC:"",ASC:"rotate-180"},qd=(e,{column:t,value:n})=>{const r=e.map(o=>({...o,isEnabled:o.column===t?!1:o.isEnabled}));return r.push({id:at(),column:t,isEnabled:!0,value:n,isAdvanced:!1}),r},Bd=()=>{const{data:e}=l.useContext(Le),{orderBy:t,updateOrderBy:n}=od(),{setFilters:r,filters:o}=er(),a=e?.result.columns||[],i=t[0],u=Ye(e?.result.tables.length,1),c=d=>{Rn("Filter value","").then(f=>{f&&r(qd(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:R.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:R.headerActions,children:[s.jsx("button",{onClick:()=>n(d.full),children:i?.column===d.full?s.jsx(jd,{className:Fd[i.direction],width:16,height:16}):s.jsx(Nd,{width:16,height:16})}),d.table&&s.jsx("button",{onClick:()=>c(d.full),children:s.jsx(Uo,{width:16,height:16})})]})]},d.full))]})})};function Ud({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=bt(e);return s.jsx("span",{className:R.value,children:t})}const Wd=l.memo(({row:e,isLastRow:t,index:n,offset:r})=>s.jsxs("tr",{className:k(R.tableRowCells,t&&"rounded-b-lg"),children:[s.jsx("td",{children:s.jsxs("button",{"data-row-action":n,className:R.rowIndexBtn,children:[s.jsx(rt,{className:"pointer-events-none",width:16,height:16}),n+1+r]})}),e.map((o,a)=>s.jsx("td",{className:R.cell,"data-row":n,"data-col":a,children:s.jsx(Ud,{value:o})},a))]})),zd=()=>{const{data:e,error:t,isLoading:n,isFetching:r}=l.useContext(Le),{state:{page:o,size:a}}=l.useContext(he),i=l.useRef(null),u=Gs(t),c=Do(),[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))},g=v=>{const y=v.target?.dataset,m=y?.row,w=y?.col;m!=null&&w!=null&&(f(parseInt(m)),p(parseInt(w)),i.current?.open(v),v.preventDefault(),v.stopPropagation())},x=o*a;return s.jsxs(s.Fragment,{children:[d!=null&&c.show&&s.jsx(Cd,{handler:c,rowIndex:d}),s.jsx(Dd,{ref:i,col:h,row:d,onClosed:()=>{f(void 0),p(void 0)}}),u&&s.jsx(Z,{variant:"danger",children:u}),n&&s.jsx("div",{className:R.tableLoading,children:"Loading data"}),e&&s.jsxs("table",{className:k(R.table,r&&R.semiTransparent),onClick:b,onContextMenu:g,children:[s.jsx(Bd,{}),s.jsxs("tbody",{children:[e.result.rows?.length<1&&s.jsx("tr",{className:R.tableEmpty,children:s.jsx("td",{colSpan:e.result.columns.length+1,children:"No data"})}),e.result.rows?.map((v,y)=>s.jsx(Wd,{index:y,offset:x,row:v,isLastRow:y===e.result.rows.length-1},y))]})]})]})},zo=()=>{const{state:e,setState:t}=l.useContext(he),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}},Hd=()=>X({mutationFn:async e=>{const{data:t}=await O.post("/saved-queries",e);return t.data},onSuccess:()=>{K.invalidateQueries({queryKey:["queries"]}),Vt()}}),Kd=()=>X({mutationFn:async e=>O.delete("/saved-queries/"+e),onSuccess:()=>{Vt()}}),Vd=()=>X({mutationFn:async({id:e,payload:t})=>{const{data:n}=await O.patch("/saved-queries/"+e,t);return n.data},onSuccess:()=>{Vt(),Tl()}}),[ls,tr]=ge({filters:!1,joins:!1,columns:!1,groupBy:!1,aggregate:!1}),$e=e=>tr(t=>({...t,[e]:!0})),cs=e=>tr(t=>({...t,[e]:!1})),Xn=e=>tr(t=>({...t,[e]:!t[e]})),Ut=Math.min,yt=Math.max,Zn=Math.round,Wn=Math.floor,Me=e=>({x:e,y:e}),Qd={left:"right",right:"left",bottom:"top",top:"bottom"},Yd={start:"end",end:"start"};function Os(e,t,n){return yt(e,Ut(t,n))}function Tn(e,t){return typeof e=="function"?e(t):e}function wt(e){return e.split("-")[0]}function Ln(e){return e.split("-")[1]}function Ho(e){return e==="x"?"y":"x"}function nr(e){return e==="y"?"height":"width"}function st(e){return["top","bottom"].includes(wt(e))?"y":"x"}function sr(e){return Ho(st(e))}function Jd(e,t,n){n===void 0&&(n=!1);const r=Ln(e),o=sr(e),a=nr(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=es(i)),[i,es(i)]}function Gd(e){const t=es(e);return[$s(e),t,$s(t)]}function $s(e){return e.replace(/start|end/g,t=>Yd[t])}function Xd(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 Zd(e,t,n,r){const o=Ln(e);let a=Xd(wt(e),n==="start",r);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map($s)))),a}function es(e){return e.replace(/left|right|bottom|top/g,t=>Qd[t])}function eh(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ko(e){return typeof e!="number"?eh(e):{top:e,right:e,bottom:e,left:e}}function ts(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 Ar(e,t,n){let{reference:r,floating:o}=e;const a=st(t),i=sr(t),u=nr(i),c=wt(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(Ln(t)){case"start":b[i]-=p*(n&&d?-1:1);break;case"end":b[i]+=p*(n&&d?-1:1);break}return b}const th=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}=Ar(d,r,c),p=r,b={},g=0;for(let x=0;x<u.length;x++){const{name:v,fn:y}=u[x],{x:m,y:w,data:C,reset:_}=await y({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}},_&&g<=50&&(g++,typeof _=="object"&&(_.placement&&(p=_.placement),_.rects&&(d=_.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):_.rects),{x:f,y:h}=Ar(d,p,c)),x=-1)}return{x:f,y:h,placement:p,strategy:o,middlewareData:b}};async function Vo(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}=Tn(t,e),g=Ko(b),v=u[p?h==="floating"?"reference":"floating":h],y=ts(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},_=ts(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:u,rect:m,offsetParent:w,strategy:c}):m);return{top:(y.top-_.top+g.top)/C.y,bottom:(_.bottom-y.bottom+g.bottom)/C.y,left:(y.left-_.left+g.left)/C.x,right:(_.right-y.right+g.right)/C.x}}const nh=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}=Tn(e,t)||{};if(d==null)return{};const h=Ko(f),p={x:n,y:r},b=sr(o),g=nr(b),x=await i.getDimensions(d),v=b==="y",y=v?"top":"left",m=v?"bottom":"right",w=v?"clientHeight":"clientWidth",C=a.reference[g]+a.reference[b]-p[b]-a.floating[g],_=p[b]-a.reference[b],E=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d));let j=E?E[w]:0;(!j||!await(i.isElement==null?void 0:i.isElement(E)))&&(j=u.floating[w]||a.floating[g]);const S=C/2-_/2,A=j/2-x[g]/2-1,$=Ut(h[y],A),J=Ut(h[m],A),be=$,Ae=j-x[g]-J,q=j/2-x[g]/2+S,le=Os(be,q,Ae),ne=!c.arrow&&Ln(o)!=null&&q!==le&&a.reference[g]/2-(q<be?$:J)-x[g]/2<0,V=ne?q<be?q-be:q-Ae:0;return{[b]:p[b]+V,data:{[b]:le,centerOffset:q-le-V,...ne&&{alignmentOffset:V}},reset:ne}}}),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:g="none",flipAlignment:x=!0,...v}=Tn(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const y=wt(o),m=st(u),w=wt(u)===u,C=await(c.isRTL==null?void 0:c.isRTL(d.floating)),_=p||(w||!x?[es(u)]:Gd(u)),E=g!=="none";!p&&E&&_.push(...Zd(u,x,g,C));const j=[u,..._],S=await Vo(t,v),A=[];let $=((r=a.flip)==null?void 0:r.overflows)||[];if(f&&A.push(S[y]),h){const q=Jd(o,i,C);A.push(S[q[0]],S[q[1]])}if($=[...$,{placement:o,overflows:A}],!A.every(q=>q<=0)){var J,be;const q=(((J=a.flip)==null?void 0:J.index)||0)+1,le=j[q];if(le&&(!(h==="alignment"?m!==st(le):!1)||$.every(U=>U.overflows[0]>0&&st(U.placement)===m)))return{data:{index:q,overflows:$},reset:{placement:le}};let ne=(be=$.filter(V=>V.overflows[0]<=0).sort((V,U)=>V.overflows[1]-U.overflows[1])[0])==null?void 0:be.placement;if(!ne)switch(b){case"bestFit":{var Ae;const V=(Ae=$.filter(U=>{if(E){const se=st(U.placement);return se===m||se==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(se=>se>0).reduce((se,We)=>se+We,0)]).sort((U,se)=>U[1]-se[1])[0])==null?void 0:Ae[0];V&&(ne=V);break}case"initialPlacement":ne=u;break}if(o!==ne)return{reset:{placement:ne}}}return{}}}};async function rh(e,t){const{placement:n,platform:r,elements:o}=e,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=wt(n),u=Ln(n),c=st(n)==="y",d=["left","top"].includes(i)?-1:1,f=a&&c?-1:1,h=Tn(t,e);let{mainAxis:p,crossAxis:b,alignmentAxis:g}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return u&&typeof g=="number"&&(b=u==="end"?g*-1:g),c?{x:b*f,y:p*d}:{x:p*d,y:b*f}}const oh=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 rh(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}}}}},ah=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:y,y:m}=v;return{x:y,y:m}}},...c}=Tn(e,t),d={x:n,y:r},f=await Vo(t,c),h=st(wt(o)),p=Ho(h);let b=d[p],g=d[h];if(a){const v=p==="y"?"top":"left",y=p==="y"?"bottom":"right",m=b+f[v],w=b-f[y];b=Os(m,b,w)}if(i){const v=h==="y"?"top":"left",y=h==="y"?"bottom":"right",m=g+f[v],w=g-f[y];g=Os(m,g,w)}const x=u.fn({...t,[p]:b,[h]:g});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[p]:a,[h]:i}}}}}};function us(){return typeof window<"u"}function Xt(e){return Qo(e)?(e.nodeName||"").toLowerCase():"#document"}function pe(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ue(e){var t;return(t=(Qo(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Qo(e){return us()?e instanceof Node||e instanceof pe(e).Node:!1}function ke(e){return us()?e instanceof Element||e instanceof pe(e).Element:!1}function De(e){return us()?e instanceof HTMLElement||e instanceof pe(e).HTMLElement:!1}function Pr(e){return!us()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof pe(e).ShadowRoot}function An(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=Re(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function ih(e){return["table","td","th"].includes(Xt(e))}function ds(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function rr(e){const t=or(),n=ke(e)?Re(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=it(e);for(;De(t)&&!Wt(t);){if(rr(t))return t;if(ds(t))return null;t=it(t)}return null}function or(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Wt(e){return["html","body","#document"].includes(Xt(e))}function Re(e){return pe(e).getComputedStyle(e)}function hs(e){return ke(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function it(e){if(Xt(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Pr(e)&&e.host||Ue(e);return Pr(t)?t.host:t}function Yo(e){const t=it(e);return Wt(t)?e.ownerDocument?e.ownerDocument.body:e.body:De(t)&&An(t)?t:Yo(t)}function wn(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Yo(e),a=o===((r=e.ownerDocument)==null?void 0:r.body),i=pe(o);if(a){const u=Ms(i);return t.concat(i,i.visualViewport||[],An(o)?o:[],u&&n?wn(u):[])}return t.concat(o,wn(o,[],n))}function Ms(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Jo(e){const t=Re(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=Zn(n)!==a||Zn(r)!==i;return u&&(n=a,r=i),{width:n,height:r,$:u}}function ar(e){return ke(e)?e:e.contextElement}function Ft(e){const t=ar(e);if(!De(t))return Me(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:a}=Jo(t);let i=(a?Zn(n.width):n.width)/r,u=(a?Zn(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!u||!Number.isFinite(u))&&(u=1),{x:i,y:u}}const ch=Me(0);function Go(e){const t=pe(e);return!or()||!t.visualViewport?ch:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function uh(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==pe(e)?!1:t}function Ct(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=ar(e);let i=Me(1);t&&(r?ke(r)&&(i=Ft(r)):i=Ft(e));const u=uh(a,n,r)?Go(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=pe(a),b=r&&ke(r)?pe(r):r;let g=p,x=Ms(g);for(;x&&r&&b!==g;){const v=Ft(x),y=x.getBoundingClientRect(),m=Re(x),w=y.left+(x.clientLeft+parseFloat(m.paddingLeft))*v.x,C=y.top+(x.clientTop+parseFloat(m.paddingTop))*v.y;c*=v.x,d*=v.y,f*=v.x,h*=v.y,c+=w,d+=C,g=pe(x),x=Ms(g)}}return ts({width:f,height:h,x:c,y:d})}function ir(e,t){const n=hs(e).scrollLeft;return t?t.left+n:Ct(Ue(e)).left+n}function Xo(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:ir(e,r)),a=r.top+t.scrollTop;return{x:o,y:a}}function dh(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const a=o==="fixed",i=Ue(r),u=t?ds(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)&&((Xt(r)!=="body"||An(i))&&(c=hs(r)),De(r))){const b=Ct(r);d=Ft(r),f.x=b.x+r.clientLeft,f.y=b.y+r.clientTop}const p=i&&!h&&!a?Xo(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 hh(e){return Array.from(e.getClientRects())}function fh(e){const t=Ue(e),n=hs(e),r=e.ownerDocument.body,o=yt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=yt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ir(e);const u=-n.scrollTop;return Re(r).direction==="rtl"&&(i+=yt(t.clientWidth,r.clientWidth)-o),{width:o,height:a,x:i,y:u}}function mh(e,t){const n=pe(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=or();(!d||d&&t==="fixed")&&(u=o.offsetLeft,c=o.offsetTop)}return{width:a,height:i,x:u,y:c}}function ph(e,t){const n=Ct(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,a=De(e)?Ft(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 Ir(e,t,n){let r;if(t==="viewport")r=mh(e,n);else if(t==="document")r=fh(Ue(e));else if(ke(t))r=ph(t,n);else{const o=Go(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return ts(r)}function Zo(e,t){const n=it(e);return n===t||!ke(n)||Wt(n)?!1:Re(n).position==="fixed"||Zo(n,t)}function gh(e,t){const n=t.get(e);if(n)return n;let r=wn(e,[],!1).filter(u=>ke(u)&&Xt(u)!=="body"),o=null;const a=Re(e).position==="fixed";let i=a?it(e):e;for(;ke(i)&&!Wt(i);){const u=Re(i),c=rr(i);!c&&u.position==="fixed"&&(o=null),(a?!c&&!o:!c&&u.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||An(i)&&!c&&Zo(e,i))?r=r.filter(f=>f!==i):o=u,i=it(i)}return t.set(e,r),r}function xh(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ds(t)?[]:gh(t,this._c):[].concat(n),r],u=i[0],c=i.reduce((d,f)=>{const h=Ir(t,f,o);return d.top=yt(h.top,d.top),d.right=Ut(h.right,d.right),d.bottom=Ut(h.bottom,d.bottom),d.left=yt(h.left,d.left),d},Ir(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}=Jo(e);return{width:t,height:n}}function yh(e,t,n){const r=De(t),o=Ue(t),a=n==="fixed",i=Ct(e,!0,a,t);let u={scrollLeft:0,scrollTop:0};const c=Me(0);function d(){c.x=ir(o)}if(r||!r&&!a)if((Xt(t)!=="body"||An(o))&&(u=hs(t)),r){const b=Ct(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?Xo(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 js(e){return Re(e).position==="static"}function Or(e,t){if(!De(e)||Re(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ue(e)===n&&(n=n.ownerDocument.body),n}function ea(e,t){const n=pe(e);if(ds(e))return n;if(!De(e)){let o=it(e);for(;o&&!Wt(o);){if(ke(o)&&!js(o))return o;o=it(o)}return n}let r=Or(e,t);for(;r&&ih(r)&&js(r);)r=Or(r,t);return r&&Wt(r)&&js(r)&&!rr(r)?n:r||lh(e)||n}const vh=async function(e){const t=this.getOffsetParent||ea,n=this.getDimensions,r=await n(e.floating);return{reference:yh(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function wh(e){return Re(e).direction==="rtl"}const Ch={convertOffsetParentRelativeRectToViewportRelativeRect:dh,getDocumentElement:Ue,getClippingRect:xh,getOffsetParent:ea,getElementRects:vh,getClientRects:hh,getDimensions:bh,getScale:Ft,isElement:ke,isRTL:wh};function ta(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function jh(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 g=Wn(h),x=Wn(o.clientWidth-(f+p)),v=Wn(o.clientHeight-(h+b)),y=Wn(f),w={rootMargin:-g+"px "+-x+"px "+-v+"px "+-y+"px",threshold:yt(0,Ut(1,c))||1};let C=!0;function _(E){const j=E[0].intersectionRatio;if(j!==c){if(!C)return i();j?i(!1,j):r=setTimeout(()=>{i(!1,1e-7)},1e3)}j===1&&!ta(d,e.getBoundingClientRect())&&i(),C=!1}try{n=new IntersectionObserver(_,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(_,w)}n.observe(e)}return i(!0),a}function Nh(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=ar(e),f=o||a?[...d?wn(d):[],...wn(t)]:[];f.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),a&&y.addEventListener("resize",n)});const h=d&&u?jh(d,n):null;let p=-1,b=null;i&&(b=new ResizeObserver(y=>{let[m]=y;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 g,x=c?Ct(e):null;c&&v();function v(){const y=Ct(e);x&&!ta(x,y)&&n(),x=y,g=requestAnimationFrame(v)}return n(),()=>{var y;f.forEach(m=>{o&&m.removeEventListener("scroll",n),a&&m.removeEventListener("resize",n)}),h?.(),(y=b)==null||y.disconnect(),b=null,c&&cancelAnimationFrame(g)}}const Sh=oh,_h=ah,Eh=sh,kh=nh,$r=(e,t,n)=>{const r=new Map,o={platform:Ch,...n},a={...o.platform,_c:r};return th(e,t,{...o,platform:a})};var Ns={exports:{}};var Mr;function Rh(){return Mr||(Mr=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})()}(Ns)),Ns.exports}var Th=Rh();const Ds=Oa(Th);var Dr={};const Lh="react-tooltip-core-styles",Ah="react-tooltip-base-styles",Fr={core:!1,base:!1};function qr({css:e,id:t=Ah,type:n="base",ref:r}){var o,a;if(!e||typeof document>"u"||Fr[n]||n==="core"&&typeof process<"u"&&(!((o=process==null?void 0:Dr)===null||o===void 0)&&o.REACT_TOOLTIP_DISABLE_CORE_STYLES)||n!=="base"&&typeof process<"u"&&(!((a=process==null?void 0:Dr)===null||a===void 0)&&a.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;n==="core"&&(t=Lh),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)),Fr[n]=!0}const Br=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:r="top",offset:o=10,strategy:a="absolute",middlewares:i=[Sh(Number(o)),Eh({fallbackAxisSideDirection:"start"}),_h({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(kh({element:n,padding:5})),$r(e,t,{placement:r,strategy:a,middleware:d}).then(({x:f,y:h,placement:p,middlewareData:b})=>{var g,x;const v={left:`${f}px`,top:`${h}px`,border:u},{x:y,y:m}=(g=b.arrow)!==null&&g!==void 0?g:{x:0,y:0},w=(x={top:"bottom",right:"left",bottom:"top",left:"right"}[p.split("-")[0]])!==null&&x!==void 0?x:"bottom",C=u&&{borderBottom:u,borderRight:u};let _=0;if(u){const E=`${u}`.match(/(\d+)px/);_=E?.[1]?Number(E[1]):1}return{tooltipStyles:v,tooltipArrowStyles:{left:y!=null?`${y}px`:"",top:m!=null?`${m}px`:"",right:"",bottom:"",...C,[w]:`-${c/2+_}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}))},Ur=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),Wr=(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",Fs=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((o,a)=>Fs(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=>Fs(e[o],t[o]))},Ph=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"})},Hr=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(Ph(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},Ih=typeof window<"u"?l.useLayoutEffect:l.useEffect,we=e=>{e.current&&(clearTimeout(e.current),e.current=null)},Oh="DEFAULT_TOOLTIP_ID",$h={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},Mh=l.createContext({getTooltipData:()=>$h});function na(e=Oh){return l.useContext(Mh).getTooltipData(e)}var $t={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"},Ss={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 Dh=({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:g=0,delayHide:x=0,float:v=!1,hidden:y=!1,noArrow:m=!1,clickable:w=!1,closeOnEsc:C=!1,closeOnScroll:_=!1,closeOnResize:E=!1,openEvents:j,closeEvents:S,globalCloseEvents:A,imperativeModeOnly:$,style:J,position:be,afterShow:Ae,afterHide:q,disableTooltip:le,content:ne,contentWrapperRef:V,isOpen:U,defaultIsOpen:se=!1,setIsOpen:We,activeAnchor:Q,setActiveAnchor:jt,border:Pn,opacity:In,arrowColor:On,arrowSize:Nt=8,role:fs="tooltip"})=>{var Zt;const re=l.useRef(null),St=l.useRef(null),je=l.useRef(null),Xe=l.useRef(null),en=l.useRef(null),[Ze,ms]=l.useState({tooltipStyles:{},tooltipArrowStyles:{},place:u}),[fe,$n]=l.useState(!1),[ct,ut]=l.useState(!1),[W,tn]=l.useState(null),nn=l.useRef(!1),sn=l.useRef(null),{anchorRefs:rn,setActiveAnchor:Mn}=na(t),_t=l.useRef(!1),[et,on]=l.useState([]),dt=l.useRef(!1),Et=f||d.includes("click"),ps=Et||j?.click||j?.dblclick||j?.mousedown,kt=j?{...j}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!j&&Et&&Object.assign(kt,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const ht=S?{...S}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!S&&Et&&Object.assign(ht,{mouseleave:!1,blur:!1,mouseout:!1});const Ne=A?{...A}:{escape:C||!1,scroll:_||!1,resize:E||!1,clickOutsideAnchor:ps||!1};$&&(Object.assign(kt,{mouseover:!1,focus:!1,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(ht,{mouseout:!1,blur:!1,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(Ne,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),Ih(()=>(dt.current=!0,()=>{dt.current=!1}),[]);const H=N=>{dt.current&&(N&&ut(!0),setTimeout(()=>{dt.current&&(We?.(N),U===void 0&&$n(N))},10))};l.useEffect(()=>{if(U===void 0)return()=>null;U&&ut(!0);const N=setTimeout(()=>{$n(U)},10);return()=>{clearTimeout(N)}},[U]),l.useEffect(()=>{if(fe!==nn.current)if(we(en),nn.current=fe,fe)Ae?.();else{const N=(L=>{const P=L.match(/^([\d.]+)(ms|s)$/);if(!P)return 0;const[,Y,te]=P;return Number(Y)*(te==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));en.current=setTimeout(()=>{ut(!1),tn(null),q?.()},N+25)}},[fe]);const Dn=N=>{ms(L=>Fs(L,N)?L:N)},an=(N=g)=>{we(je),ct?H(!0):je.current=setTimeout(()=>{H(!0)},N)},Rt=(N=x)=>{we(Xe),Xe.current=setTimeout(()=>{_t.current||H(!1)},N)},ln=N=>{var L;if(!N)return;const P=(L=N.currentTarget)!==null&&L!==void 0?L:N.target;if(!P?.isConnected)return jt(null),void Mn({current:null});g?an():H(!0),jt(P),Mn({current:P}),we(Xe)},Tt=()=>{w?Rt(x||100):x?Rt():H(!1),we(je)},Lt=({x:N,y:L})=>{var P;const Y={getBoundingClientRect:()=>({x:N,y:L,width:0,height:0,top:L,left:N,right:N,bottom:L})};Br({place:(P=W?.place)!==null&&P!==void 0?P:u,offset:c,elementReference:Y,tooltipReference:re.current,tooltipArrowReference:St.current,strategy:h,middlewares:p,border:Pn,arrowSize:Nt}).then(te=>{Dn(te)})},At=N=>{if(!N)return;const L=N,P={x:L.clientX,y:L.clientY};Lt(P),sn.current=P},cn=N=>{var L;if(!fe)return;const P=N.target;P.isConnected&&(!((L=re.current)===null||L===void 0)&&L.contains(P)||[document.querySelector(`[id='${a}']`),...et].some(Y=>Y?.contains(P))||(H(!1),we(je)))},Fn=Wr(ln,50),G=Wr(Tt,50),ye=N=>{G.cancel(),Fn(N)},T=()=>{Fn.cancel(),G()},I=l.useCallback(()=>{var N,L;const P=(N=W?.position)!==null&&N!==void 0?N:be;P?Lt(P):v?sn.current&&Lt(sn.current):Q?.isConnected&&Br({place:(L=W?.place)!==null&&L!==void 0?L:u,offset:c,elementReference:Q,tooltipReference:re.current,tooltipArrowReference:St.current,strategy:h,middlewares:p,border:Pn,arrowSize:Nt}).then(Y=>{dt.current&&Dn(Y)})},[fe,Q,ne,J,u,W?.place,c,h,be,W?.position,v,Nt]);l.useEffect(()=>{var N,L;const P=new Set(rn);et.forEach(M=>{le?.(M)||P.add({current:M})});const Y=document.querySelector(`[id='${a}']`);Y&&!le?.(Y)&&P.add({current:Y});const te=()=>{H(!1)},Pe=Hr(Q),Ie=Hr(re.current);Ne.scroll&&(window.addEventListener("scroll",te),Pe?.addEventListener("scroll",te),Ie?.addEventListener("scroll",te));let oe=null;Ne.resize?window.addEventListener("resize",te):Q&&re.current&&(oe=Nh(Q,re.current,I,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const ve=M=>{M.key==="Escape"&&H(!1)};Ne.escape&&window.addEventListener("keydown",ve),Ne.clickOutsideAnchor&&window.addEventListener("click",cn);const B=[],Pt=M=>!!(M?.target&&Q?.contains(M.target)),Ca=M=>{fe&&Pt(M)||ln(M)},ja=M=>{fe&&Pt(M)&&Tt()},ur=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],dr=["click","dblclick","mousedown","mouseup"];Object.entries(kt).forEach(([M,ze])=>{ze&&(ur.includes(M)?B.push({event:M,listener:ye}):dr.includes(M)&&B.push({event:M,listener:Ca}))}),Object.entries(ht).forEach(([M,ze])=>{ze&&(ur.includes(M)?B.push({event:M,listener:T}):dr.includes(M)&&B.push({event:M,listener:ja}))}),v&&B.push({event:"pointermove",listener:At});const hr=()=>{_t.current=!0},fr=()=>{_t.current=!1,Tt()},mr=w&&(ht.mouseout||ht.mouseleave);return mr&&((N=re.current)===null||N===void 0||N.addEventListener("mouseover",hr),(L=re.current)===null||L===void 0||L.addEventListener("mouseout",fr)),B.forEach(({event:M,listener:ze})=>{P.forEach(gs=>{var un;(un=gs.current)===null||un===void 0||un.addEventListener(M,ze)})}),()=>{var M,ze;Ne.scroll&&(window.removeEventListener("scroll",te),Pe?.removeEventListener("scroll",te),Ie?.removeEventListener("scroll",te)),Ne.resize?window.removeEventListener("resize",te):oe?.(),Ne.clickOutsideAnchor&&window.removeEventListener("click",cn),Ne.escape&&window.removeEventListener("keydown",ve),mr&&((M=re.current)===null||M===void 0||M.removeEventListener("mouseover",hr),(ze=re.current)===null||ze===void 0||ze.removeEventListener("mouseout",fr)),B.forEach(({event:gs,listener:un})=>{P.forEach(Na=>{var xs;(xs=Na.current)===null||xs===void 0||xs.removeEventListener(gs,un)})})}},[Q,I,ct,rn,et,j,S,A,Et,g,x]),l.useEffect(()=>{var N,L;let P=(L=(N=W?.anchorSelect)!==null&&N!==void 0?N:i)!==null&&L!==void 0?L:"";!P&&t&&(P=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const Y=new MutationObserver(te=>{const Pe=[],Ie=[];te.forEach(oe=>{if(oe.type==="attributes"&&oe.attributeName==="data-tooltip-id"&&(oe.target.getAttribute("data-tooltip-id")===t?Pe.push(oe.target):oe.oldValue===t&&Ie.push(oe.target)),oe.type==="childList"){if(Q){const ve=[...oe.removedNodes].filter(B=>B.nodeType===1);if(P)try{Ie.push(...ve.filter(B=>B.matches(P))),Ie.push(...ve.flatMap(B=>[...B.querySelectorAll(P)]))}catch{}ve.some(B=>{var Pt;return!!(!((Pt=B?.contains)===null||Pt===void 0)&&Pt.call(B,Q))&&(ut(!1),H(!1),jt(null),we(je),we(Xe),!0)})}if(P)try{const ve=[...oe.addedNodes].filter(B=>B.nodeType===1);Pe.push(...ve.filter(B=>B.matches(P))),Pe.push(...ve.flatMap(B=>[...B.querySelectorAll(P)]))}catch{}}}),(Pe.length||Ie.length)&&on(oe=>[...oe.filter(ve=>!Ie.includes(ve)),...Pe])});return Y.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{Y.disconnect()}},[t,i,W?.anchorSelect,Q]),l.useEffect(()=>{I()},[I]),l.useEffect(()=>{if(!V?.current)return()=>null;const N=new ResizeObserver(()=>{setTimeout(()=>I())});return N.observe(V.current),()=>{N.disconnect()}},[ne,V?.current]),l.useEffect(()=>{var N;const L=document.querySelector(`[id='${a}']`),P=[...et,L];Q&&P.includes(Q)||jt((N=et[0])!==null&&N!==void 0?N:L)},[a,et,Q]),l.useEffect(()=>(se&&H(!0),()=>{we(je),we(Xe)}),[]),l.useEffect(()=>{var N;let L=(N=W?.anchorSelect)!==null&&N!==void 0?N:i;if(!L&&t&&(L=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),L)try{const P=Array.from(document.querySelectorAll(L));on(P)}catch{on([])}},[t,i,W?.anchorSelect]),l.useEffect(()=>{je.current&&(we(je),an(g))},[g]);const me=(Zt=W?.content)!==null&&Zt!==void 0?Zt:ne,ft=fe&&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`)}tn(N??null),N?.delay?an(N.delay):H(!0)},close:N=>{N?.delay?Rt(N.delay):H(!1)},activeAnchor:Q,place:Ze.place,isOpen:!!(ct&&!y&&me&&ft)})),ct&&!y&&me?tt.createElement(b,{id:t,role:fs,className:Ds("react-tooltip",$t.tooltip,Ss.tooltip,Ss[o],n,`react-tooltip__place-${Ze.place}`,$t[ft?"show":"closing"],ft?"react-tooltip__show":"react-tooltip__closing",h==="fixed"&&$t.fixed,w&&$t.clickable),onTransitionEnd:N=>{we(en),fe||N.propertyName!=="opacity"||(ut(!1),tn(null),q?.())},style:{...J,...Ze.tooltipStyles,opacity:In!==void 0&&ft?In:void 0},ref:re},me,tt.createElement(b,{className:Ds("react-tooltip-arrow",$t.arrow,Ss.arrow,r,m&&$t.noArrow),style:{...Ze.tooltipArrowStyles,background:On?`linear-gradient(to right bottom, transparent 50%, ${On} 50%)`:void 0,"--rt-arrow-size":`${Nt}px`},ref:St})):null},Fh=({content:e})=>tt.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),ns=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:g=!1,positionStrategy:x="absolute",middlewares:v,delayShow:y=0,delayHide:m=0,float:w=!1,hidden:C=!1,noArrow:_=!1,clickable:E=!1,closeOnEsc:j=!1,closeOnScroll:S=!1,closeOnResize:A=!1,openEvents:$,closeEvents:J,globalCloseEvents:be,imperativeModeOnly:Ae=!1,style:q,position:le,isOpen:ne,defaultIsOpen:V=!1,disableStyleInjection:U=!1,border:se,opacity:We,arrowColor:Q,arrowSize:jt,setIsOpen:Pn,afterShow:In,afterHide:On,disableTooltip:Nt,role:fs="tooltip"},Zt)=>{const[re,St]=l.useState(r),[je,Xe]=l.useState(o),[en,Ze]=l.useState(d),[ms,fe]=l.useState(c),[$n,ct]=l.useState(f),[ut,W]=l.useState(y),[tn,nn]=l.useState(m),[sn,rn]=l.useState(w),[Mn,_t]=l.useState(C),[et,on]=l.useState(h),[dt,Et]=l.useState(b),[ps,kt]=l.useState(x),[ht,Ne]=l.useState(null),[H,Dn]=l.useState(null),an=l.useRef(U),{anchorRefs:Rt,activeAnchor:ln}=na(e),Tt=G=>G?.getAttributeNames().reduce((ye,T)=>{var I;return T.startsWith("data-tooltip-")&&(ye[T.replace(/^data-tooltip-/,"")]=(I=G?.getAttribute(T))!==null&&I!==void 0?I:null),ye},{}),Lt=G=>{const ye={place:T=>{var I;Ze((I=T)!==null&&I!==void 0?I:d)},content:T=>{St(T??r)},html:T=>{Xe(T??o)},variant:T=>{var I;fe((I=T)!==null&&I!==void 0?I:c)},offset:T=>{ct(T===null?f:Number(T))},wrapper:T=>{var I;on((I=T)!==null&&I!==void 0?I:h)},events:T=>{const I=T?.split(" ");Et(I??b)},"position-strategy":T=>{var I;kt((I=T)!==null&&I!==void 0?I:x)},"delay-show":T=>{W(T===null?y:Number(T))},"delay-hide":T=>{nn(T===null?m:Number(T))},float:T=>{rn(T===null?w:T==="true")},hidden:T=>{_t(T===null?C:T==="true")},"class-name":T=>{Ne(T)}};Object.values(ye).forEach(T=>T(null)),Object.entries(G).forEach(([T,I])=>{var me;(me=ye[T])===null||me===void 0||me.call(ye,I)})};l.useEffect(()=>{St(r)},[r]),l.useEffect(()=>{Xe(o)},[o]),l.useEffect(()=>{Ze(d)},[d]),l.useEffect(()=>{fe(c)},[c]),l.useEffect(()=>{ct(f)},[f]),l.useEffect(()=>{W(y)},[y]),l.useEffect(()=>{nn(m)},[m]),l.useEffect(()=>{rn(w)},[w]),l.useEffect(()=>{_t(C)},[C]),l.useEffect(()=>{kt(x)},[x]),l.useEffect(()=>{an.current!==U&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")},[U]),l.useEffect(()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:U==="core",disableBase:U}}))},[]),l.useEffect(()=>{var G;const ye=new Set(Rt);let T=n;if(!T&&e&&(T=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),T)try{document.querySelectorAll(T).forEach(L=>{ye.add({current:L})})}catch{console.warn(`[react-tooltip] "${T}" is not a valid CSS selector`)}const I=document.querySelector(`[id='${t}']`);if(I&&ye.add({current:I}),!ye.size)return()=>null;const me=(G=H??I)!==null&&G!==void 0?G:ln.current,ft=new MutationObserver(L=>{L.forEach(P=>{var Y;if(!me||P.type!=="attributes"||!(!((Y=P.attributeName)===null||Y===void 0)&&Y.startsWith("data-tooltip-")))return;const te=Tt(me);Lt(te)})}),N={attributes:!0,childList:!1,subtree:!1};if(me){const L=Tt(me);Lt(L),ft.observe(me,N)}return()=>{ft.disconnect()}},[Rt,ln,H,t,n]),l.useEffect(()=>{q?.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),se&&!Ur("border",`${se}`)&&console.warn(`[react-tooltip] "${se}" is not a valid \`border\`.`),q?.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),We&&!Ur("opacity",`${We}`)&&console.warn(`[react-tooltip] "${We}" is not a valid \`opacity\`.`)},[]);let At=p;const cn=l.useRef(null);if(a){const G=a({content:H?.getAttribute("data-tooltip-content")||re||null,activeAnchor:H});At=G?tt.createElement("div",{ref:cn,className:"react-tooltip-content-wrapper"},G):null}else re&&(At=re);je&&(At=tt.createElement(Fh,{content:je}));const Fn={forwardRef:Zt,id:e,anchorId:t,anchorSelect:n,className:Ds(i,ht),classNameArrow:u,content:At,contentWrapperRef:cn,place:en,variant:ms,offset:$n,wrapper:et,events:dt,openOnClick:g,positionStrategy:ps,middlewares:v,delayShow:ut,delayHide:tn,float:sn,hidden:Mn,noArrow:_,clickable:E,closeOnEsc:j,closeOnScroll:S,closeOnResize:A,openEvents:$,closeEvents:J,globalCloseEvents:be,imperativeModeOnly:Ae,style:q,position:le,isOpen:ne,defaultIsOpen:V,border:se,opacity:We,arrowColor:Q,arrowSize:jt,setIsOpen:Pn,afterShow:In,afterHide:On,disableTooltip:Nt,activeAnchor:H,setActiveAnchor:G=>Dn(G),role:fs};return tt.createElement(Dh,{...Fn})});typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",e=>{e.detail.disableCore||qr({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||qr({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 qh=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})),sa=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"})),Bh=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})),Uh=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"})),ra=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"})),oa=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"})),Wh=()=>{const e=Xs(),t=vc();return{rename:async r=>{if(e){const o=await Rn("New tab name",r);o&&await t.mutateAsync({id:e,payload:{name:o}})}return Promise.resolve()}}},aa=["shift","alt","meta","mod","ctrl","control"],zh={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 ot(e){return(zh[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function ia(e){return aa.includes(e)}function _s(e,t=","){return e.toLowerCase().split(t)}function Es(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=>ot(d))):a=e.toLocaleLowerCase().split(t).map(d=>ot(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=>!aa.includes(d));return{...u,keys:c,description:o,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&la([ot(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&ca([ot(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{He.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{He.clear()},0)}));const He=new Set;function lr(e){return Array.isArray(e)}function Hh(e,t=","){return(lr(e)?e:e.split(t)).every(n=>He.has(n.trim().toLowerCase()))}function la(e){const t=Array.isArray(e)?e:[e];He.has("meta")&&He.forEach(n=>!ia(n)&&He.delete(n.toLowerCase())),t.forEach(n=>He.add(n.toLowerCase()))}function ca(e){const t=Array.isArray(e)?e:[e];e==="meta"?He.clear():t.forEach(n=>He.delete(n.toLowerCase()))}function Kh(e,t,n){(typeof n=="function"&&n(e,t)||n===!0)&&e.preventDefault()}function Vh(e,t,n){return typeof n=="function"?n(e,t):n===!0||n===void 0}const Qh=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Yh(e){return ua(e,Qh)}function ua(e,t=!1){const{target:n,composed:r}=e;let o,a;return Jh(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),lr(t)?!!(o&&t&&t.some(i=>i.toLowerCase()===o.toLowerCase()||i===a)):!!(o&&t&&t)}function Jh(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Gh(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 Xh=(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:g,altKey:x}=e,v=ot(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!==x&&v!=="alt"||i!==g&&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?Hh(c):!c},Zh=l.createContext(void 0),ef=()=>l.useContext(Zh);function da(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&&da(e[r],t[r]),!0):e===t}const tf=l.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),nf=()=>l.useContext(tf);function sf(e){const t=l.useRef(void 0);return da(t.current,e)||(t.current=e),t.current}const Kr=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},rf=typeof window<"u"?l.useLayoutEffect:l.useEffect;function _e(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=lr(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=sf(i),{activeScopes:p}=nf(),b=ef();return rf(()=>{if(h?.enabled===!1||!Gh(p,h?.scopes))return;let g=[],x;const v=(C,_=!1)=>{if(!(Yh(C)&&!ua(C,h?.enableOnFormTags))){if(o.current!==null){const E=o.current.getRootNode();if((E instanceof Document||E instanceof ShadowRoot)&&E.activeElement!==o.current&&!o.current.contains(E.activeElement)){Kr(C);return}}C.target?.isContentEditable&&!h?.enableOnContentEditable||_s(u,h?.delimiter).forEach(E=>{if(E.includes(h?.splitKey??"+")&&E.includes(h?.sequenceSplitKey??">")){console.warn(`Hotkey ${E} contains both ${h?.splitKey??"+"} and ${h?.sequenceSplitKey??">"} which is not supported.`);return}const j=Es(E,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description);if(j.isSequence){x=setTimeout(()=>{g=[]},h?.sequenceTimeoutMs??1e3);const S=j.useKey?C.key:ot(C.code);if(ia(S.toLowerCase()))return;g.push(S);const A=j.keys?.[g.length-1];if(S!==A){g=[],x&&clearTimeout(x);return}g.length===j.keys?.length&&(f.current(C,j),x&&clearTimeout(x),g=[])}else if(Xh(C,j,h?.ignoreModifiers)||j.keys?.includes("*")){if(h?.ignoreEventWhen?.(C)||_&&a.current)return;if(Kh(C,j,h?.preventDefault),!Vh(C,j,h?.enabled)){Kr(C);return}f.current(C,j),_||(a.current=!0)}})}},y=C=>{C.code!==void 0&&(la(ot(C.code)),(h?.keydown===void 0&&h?.keyup!==!0||h?.keydown)&&v(C))},m=C=>{C.code!==void 0&&(ca(ot(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",y,i?.eventListenerOptions),b&&_s(u,h?.delimiter).forEach(C=>b.addHotkey(Es(C,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description))),()=>{w.removeEventListener("keyup",m,i?.eventListenerOptions),w.removeEventListener("keydown",y,i?.eventListenerOptions),b&&_s(u,h?.delimiter).forEach(C=>b.removeHotkey(Es(C,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description))),g=[],x&&clearTimeout(x)}},[u,h,p]),o}function of(){return s.jsxs("div",{className:"flex md:grid md:grid-cols-3 items-center bg-white overflow-auto no-scrollbar mb-2 shadow",children:[s.jsx(af,{}),s.jsx(lf,{}),s.jsx(df,{})]})}function af(){const{dataSourceId:e}=l.useContext(Be),{data:t}=as(e),{state:{table:n}}=l.useContext(he);return s.jsx("div",{className:R.tableConfig,children:t&&s.jsxs("div",{className:k(R.tableAction,R.greenFixed),"data-tooltip-id":"default","data-tooltip-content":n,children:[s.jsx(Gt,{size:18,type:t.dbType}),s.jsx("p",{className:"text-sm",children:t.name}),s.jsx(rt,{width:12,height:12}),s.jsx("p",{className:"text-sm",children:n})]})})}function lf(){const{page:e,size:t,setPage:n}=zo(),{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:k(R.tableConfig,"justify-self-center"),children:[s.jsx("span",{"data-tooltip-content":"Previous page","data-tooltip-id":"default",className:k(R.tableAction,R.gray,e<1&&"opacity-30"),onClick:c,role:"button",children:s.jsx(rt,{width:16,height:16,className:"rotate-180"})}),s.jsxs("span",{"data-tooltip-id":"rows-num",className:R.paginationIndicator,children:[a+1," - ",a+u,i&&"+"]}),s.jsx("span",{"data-tooltip-content":"Next page","data-tooltip-id":"default",className:k(R.tableAction,i?R.gray:"opacity-30"),onClick:d,role:"button",children:s.jsx(rt,{width:16,height:16})})]})}const cf=[5,10,20,50,100,200],uf=!__CLIENT_CONFIG__.skipAuth;function df(){const{dataSourceId:e,name:t}=l.useContext(Be),{data:n}=as(e),{data:r,refetch:o}=l.useContext(Le),a=kn(ue.EDITOR),i=Hd(),{rename:u}=Wh(),{size:c,setSize:d}=zo(),{state:f}=l.useContext(he),h=Jt(),p=ee(),b=()=>{h.mutateAsync({name:t,opts:f}).then(m=>{p(`${F.workbench.path}/tab/${m.id}`)})},g=()=>{if(r?.result.queryHistoryId){const m=new URL(window.location.href);m.pathname=F.share.path,m.searchParams.set("shareId",r.result.queryHistoryId),navigator.clipboard.writeText(m.toString()),Ce.success("Share link copied to clipboard")}},x=()=>{r?.result.columns?.[0].table&&Js({table:r?.result.columns?.[0].table,dataSourceId:e})},v=async()=>{const m=await Rn("Query name",t);!m||!r?.result.queryHistoryId||i.mutate({name:m,queryId:r.result.queryHistoryId})},y=()=>u(t);return _e("s",v),_e("r",y),_e("d",b),s.jsxs("div",{className:"flex justify-self-end",children:[s.jsx("span",{"data-tooltip-content":"Show filters","data-tooltip-id":"default",className:k(R.tableAction,R.gray),onClick:()=>$e("filters"),role:"button",children:s.jsx(ra,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Join table","data-tooltip-id":"default",className:k(R.tableAction,R.gray),onClick:()=>$e("joins"),role:"button",children:s.jsx(oa,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Refresh data","data-tooltip-id":"default",className:k(R.tableAction,R.gray),onClick:()=>o(),role:"button",children:s.jsx(sa,{width:16,height:16})}),uf&&s.jsx("span",{"data-tooltip-content":"Share query","data-tooltip-id":"default",className:k(R.tableAction,R.gray),onClick:g,role:"button",children:s.jsx(Uh,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Duplicate tab","data-tooltip-id":"default",className:k(R.tableAction,R.gray),onClick:b,role:"button",children:s.jsx(Bh,{width:16,height:16})}),s.jsx(ns,{id:"rows-num",className:"z-10 shadow-md flex gap-1",clickable:!0,variant:"light",opacity:1,children:cf.map(m=>s.jsx("button",{onClick:()=>d(m,!0),className:k(R.tableAction,R.gray,m===c&&R.selectedSize),children:s.jsx("span",{children:m})},m))}),s.jsx("button",{"data-tooltip-id":"explorer-more-actions",className:k(R.tableAction,R.gray),children:s.jsx(qh,{width:16,height:16})}),s.jsxs(ns,{id:"explorer-more-actions",className:"z-10 shadow-md flex flex-col",clickable:!0,variant:"light",opacity:1,children:[s.jsxs("button",{onClick:()=>$e("columns"),className:k(R.tableAction,R.modal,R.gray,"justify-between"),children:[s.jsx("span",{children:"Columns"}),s.jsx("span",{className:"hotkey",children:"C"})]}),s.jsxs("button",{onClick:()=>$e("groupBy"),className:k(R.tableAction,R.modal,R.gray,"justify-between"),children:[s.jsx("span",{children:"Group by"}),s.jsx("span",{className:"hotkey",children:"G"})]}),s.jsxs("button",{onClick:()=>$e("aggregate"),className:k(R.tableAction,R.modal,R.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:y,className:k(R.tableAction,R.modal,R.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:k(R.tableAction,R.modal,R.gray),children:[s.jsx("span",{children:"Save query"}),s.jsx("span",{className:"hotkey",children:"S"})]}),n?.allowInsert===!0&&s.jsx("button",{onClick:x,className:k(R.tableAction,R.modal,R.gray),children:"Insert new row"})]})]})]})}const hf="_drop-container_147os_2",ff="_item_147os_2",Vr={dropContainer:hf,item:ff},ha=({dataSourceId:e,inputClassName:t,focusId:n,placeholder:r="Column",onChange:o,value:a,autoFocus:i,allowTables:u})=>{const{data:c}=_n(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),[g,x]=l.useState(0),v=m=>{if(m.key==="ArrowDown")m.preventDefault(),x(w=>(w+1)%h.length);else if(m.key==="ArrowUp")m.preventDefault(),x(w=>(w-1+h.length)%h.length);else if(m.key==="Enter"&&g>=0&&g<h.length){m.preventDefault();const w=h[g].value;b(!1);const C=f.findIndex(_=>_.value===w)>-1;o(h[g]?.value||w,C,!0)}};l.useEffect(()=>{const m=d.current?.querySelector('[data-is-active="true"]');m&&m.scrollIntoView({behavior:"smooth",block:"nearest"})},[g]);const y=m=>{const w=m.currentTarget.value,C=f.findIndex(_=>_.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:y,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":g===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))})]})},mf="_actions_x2nyt_2",pf="_filter-actions_x2nyt_2",gf="_advanced-filter-icon_x2nyt_2",xf="_filters-container_x2nyt_2",bf="_filter-container_x2nyt_2",bn={actions:mf,filterActions:pf,advancedFilterIcon:gf,filtersContainer:xf,filterContainer:bf},yf=({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:bn.filterContainer,children:[s.jsx("input",{type:"checkbox",checked:e.isEnabled!==!1,onClick:()=>c(e.id)}),s.jsx(ha,{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:bn.advancedFilterIcon,children:s.jsx(ra,{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:bn.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(vt,{width:20,height:20,className:"text-red-600"})})})]})},vf=()=>{const{state:e}=l.useContext(he),{refetch:t}=l.useContext(Le),{setFilters:n}=er(),r=ls(x=>x.filters),o=l.useMemo(()=>[e.table,...e.joins.map(x=>x.table)],[e.table,e.joins]),[a,i]=l.useState([]),u=(x,v)=>{i(y=>[...y.map(m=>m.id===x?{...m,column:v}:m)])},c=(x,v)=>{i(y=>[...y.map(m=>m.id===x?{...m,value:v}:m)])},d=()=>{i(x=>[...x,{id:at(),value:"",column:"",isEnabled:!0}])},f=x=>{i(v=>v.filter(y=>y.id!==x))},h=(x,v)=>{i(y=>y.map(m=>m.id===x?{...m,isAdvanced:v}:m))},p=()=>cs("filters"),b=()=>{try{n(a.filter(x=>x.value.length>0&&x.column.length>0)),setTimeout(t,1),p()}catch(x){x instanceof Error?Ce.error(x.message):Ce.error("Error during parsing, check you filters")}},g=x=>{i(v=>v.map(y=>y.id===x?{...y,isEnabled:!y.isEnabled}:y))};return l.useEffect(()=>{r&&i(()=>[...e.filters,{id:at(),value:"",column:"",isEnabled:!0}])},[r]),_e("f",()=>{Xn("filters")}),s.jsxs(xe,{isVisible:r,onClose:p,portal:!0,onClosed:()=>i([]),noPadding:!0,children:[s.jsx(Ge,{onClick:p}),s.jsx("h2",{className:"text-lg font-semibold m-2",children:"Filters"}),s.jsxs("div",{className:bn.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((x,v)=>s.jsx(yf,{filter:x,dataSourceId:e.dataSourceId,allowedTables:o,onChangeColumn:u,onChangeValue:c,onRemoveFilter:f,onChangeAdvancedFilter:h,triggerIsEnabled:g,onSubmit:b,autoFocus:v===a.length-1},x.id))]}),s.jsxs("div",{className:bn.actions,children:[s.jsxs("button",{className:"button tertiary flex items-center gap-1 text-sm",onClick:d,children:[s.jsx(oa,{width:20,height:20}),s.jsx("span",{children:"Add filter"})]}),s.jsx("button",{className:"button primary text-sm",onClick:b,children:"Apply filters"})]})]})},wf="_join-modal_8vd6j_2",Cf={joinModal:wf},jf=(e,t)=>e.type!==t.type||e.on!==t.on||e.table!==t.table,Nf=(e,t)=>e.type===t.type&&e.on===t.on&&e.table===t.table,fa=()=>{const{state:e,setState:t}=l.useContext(he),n=l.useCallback(r=>{t(o=>{const a=o.joins;if(a.some(u=>Nf(u,r))){const u=r.table+".";return{...o,joins:a.filter(c=>jf(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}},Sf=()=>{const{isFetching:e}=l.useContext(Le),t=ls(c=>c.joins),{toggle:n}=fa(),{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=()=>cs("joins");return _e("j",()=>{r.length>0?$e("joins"):Ce.error("No available tables to join")}),s.jsxs(xe,{isVisible:t,onClose:u,portal:!0,children:[s.jsx(Ge,{onClick:u}),s.jsxs("div",{className:Cf.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(Z,{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(qo,{hook:c,onClick:()=>{e||(n({table:c.on.toTable,type:"LEFT",on:c.where}),a(""),u())}},c.where))})]})]})};function _f(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}function Qr(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}const Ef="_container_shd1g_2",kf="_column-label_shd1g_2",Rf="_not-active_shd1g_2",Yn={container:Ef,columnLabel:kf,notActive:Rf};function Tf(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}],Gl[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 Lf(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 Af=({column:e,selected:t,onCheck:n})=>s.jsxs("label",{className:k(Yn.columnLabel,t?Yn.active:Yn.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),Pf={columns:"c",groupBy:"g"},Yr=({mode:e})=>{const t=ls(m=>m[e]),{allColumns:n}=l.useContext(Be),{state:r,setState:o}=l.useContext(he),[a,i]=l.useState({}),[u,c]=l.useState(""),d=l.useMemo(()=>Tf(n),[n]),f=r.aggregations.length>0||r.groupBy.length>0,h=l.useMemo(()=>u?Lf(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 _ of n)C[_.full]=w;return{...C}})},g=()=>{cs(e)},x=()=>{const m=[];for(const[w,C]of Object.entries(a))if(C){const[_,E]=w.split(" ");m.push({value:E||_,fn:E?_:void 0})}o(w=>({...w,[e]:m})),g()},v=l.useMemo(()=>{for(const m of n)if(!a[m.full])return!1;return!0},[a,n]);_e(Pf[e],()=>{e==="columns"?f?Ce.error("Columns are ignored when there is at least one aggregation or group by"):Xn("columns"):Xn("groupBy")}),l.useEffect(()=>{t&&i(()=>_f(r[e].map(m=>m.fn?m.fn+" "+m.value:m.value)))},[t,i]);const y=()=>{c(""),i({})};return s.jsxs(xe,{isVisible:t,onClose:g,portal:!0,onClosed:y,children:[s.jsx(Ge,{onClick:g}),s.jsxs("div",{className:Yn.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(Af,{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:g,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:x,children:"Apply"})]})]})]})},If="_options-container_uddr2_2",Of={optionsContainer:If},ks="COUNT all",$f=()=>{const e=ls(g=>g.aggregate),{dataSourceId:t}=l.useContext(Be),{setState:n,state:r}=l.useContext(he),{data:o}=l.useContext(Le),[a,i]=l.useState({fn:"",col:""}),u=g=>i({...a,fn:g.currentTarget.value}),c=g=>i({...a,col:g}),d=()=>cs("aggregate"),f=()=>{const g=a.fn===ks?{value:"*",fn:"COUNT"}:{fn:a.fn,value:a.col,distinct:a.fn==="COUNT"};n(x=>({...x,aggregations:[...x.aggregations,g]}))},h=a.fn===ks,p=h?!1:!a.col||!a.fn,b=g=>{const x=Eo(g);n(v=>({...v,aggregations:v.aggregations.filter(y=>y.fn!==g.fn||y.value!==g.value),orderBy:v.orderBy.filter(y=>y.column!==x)}))};return _e("a",()=>{Xn("aggregate")}),s.jsxs(xe,{isVisible:e,onClose:d,backdropClose:!0,portal:!0,children:[s.jsx(Ge,{onClick:d}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold",children:"Aggregate"}),Ye(r.aggregations.length,0)&&s.jsx("div",{className:"flex flex-col gap-1 mt-4",children:r.aggregations.map((g,x)=>s.jsxs("p",{className:"p-2 rounded-md bg-gray-50 flex items-center justify-between",children:[s.jsx("span",{children:Vn(g)}),s.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove aggregation",className:"p-0.5 text-sm cursor-pointer",onClick:()=>b(g),children:s.jsx(vt,{width:20,height:20,className:"text-red-600"})})]},x))}),s.jsxs("div",{className:Of.optionsContainer,children:[s.jsxs("label",{className:k(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:ks,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(ha,{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"})]})]})]})},Mf="_container_gkq25_2",Df="_yellow-pill_gkq25_2 _pill_gkq25_2",Ff="_blue-pill_gkq25_2 _pill_gkq25_2",qf="_purple-pill_gkq25_2 _pill_gkq25_2",Bf="_red-pill_gkq25_2 _pill_gkq25_2",Uf="_black-pill_gkq25_2 _pill_gkq25_2",Wf="_disabled-pill_gkq25_2",xt={container:Mf,yellowPill:Df,bluePill:Ff,purplePill:qf,redPill:Bf,blackPill:Uf,disabledPill:Wf};function zf(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 Hf(e){return!(e===!0||e===void 0)}const Kf=()=>{const{state:{aggregations:e,columns:t,groupBy:n}}=l.useContext(he),{toggle:r,joins:o}=fa(),{filters:a,setFilters:i,removeFilter:u}=er(),c=()=>$e("joins"),d=()=>$e("aggregate"),f=()=>$e("columns"),h=()=>$e("groupBy"),p=x=>{x.preventDefault(),x.stopPropagation(),r(o[o.length-1])},b=x=>{i(a.map(v=>({...v,isEnabled:x===v.id?Hf(v.isEnabled):v.isEnabled})),!0)},g=x=>v=>{v.preventDefault(),v.stopPropagation(),u(x)};return a.length>0||o.length>0||n.length>0||t.length>0||e.length>0?s.jsxs("div",{className:xt.container,children:[o.map((x,v)=>s.jsxs("button",{onClick:c,className:xt.yellowPill,"data-tooltip-id":"default","data-tooltip-content":`Joins ${x.table} on ${x.on}`,children:[s.jsx("p",{className:"text-sm",children:x.table}),v===o.length-1&&s.jsx(vt,{onClick:p,width:18,height:18})]},x.table)),a.map(x=>s.jsxs("button",{onClick:()=>b(x.id),onAuxClick:()=>u(x.id),className:k(xt.bluePill,x.isEnabled===!1&&xt.disabledPill),"data-tooltip-id":"default","data-tooltip-content":`${x.column} ${x.value}`,children:[s.jsx("p",{className:"text-sm",children:x.column}),s.jsx("p",{className:"text-sm",children:x.value}),s.jsx(vt,{onClick:g(x.id),width:18,height:18})]},x.id)),e.map(x=>s.jsx("button",{onClick:d,className:k(xt.purplePill),"data-tooltip-id":"default","data-tooltip-content":Vn(x),children:s.jsx("p",{className:"text-sm",children:Vn(x)})},Vn(x))),t.length>0&&s.jsx("button",{onClick:f,className:k(xt.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:k(xt.blackPill),"data-tooltip-id":"default","data-tooltip-content":"Has GROUP BY",children:s.jsx("p",{className:"text-sm",children:"Grouped columns"})}),!1]}):null},Vf=({options:e,updater:t,name:n,tabId:r})=>{const o=gc(e,t),a=wc(r,o.state),i=pc(a.data,o.state.dataSourceId,n,r);return s.jsx(Be,{value:i,children:s.jsx(he,{value:o,children:s.jsxs(Le,{value:a,children:[s.jsx(of,{}),s.jsx(Kf,{}),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(zd,{})}),s.jsx(vf,{}),s.jsx(Sf,{}),s.jsx(Yr,{mode:"columns"}),s.jsx(Yr,{mode:"groupBy"}),s.jsx($f,{})]})]})})})},ma=()=>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..."})]}),Qf=({id:e})=>{const{data:t}=bc(e),n=l.useCallback(r=>{if(!t)return;const o=r(Yt(t.opts));K.setQueryData(["workbench-tabs",t.id],{...t,opts:{...t.opts,...o}})},[t]);return t?s.jsx(Vf,{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(ma,{})})},Yf=e=>{setTimeout(t=>{const n=document.querySelector(`[data-tab-id="${t}"]`);n&&n.scrollIntoView({behavior:"smooth"})},50,e)},Jf=()=>{const{id:e}=mi(),t=ee(),{data:n}=Ys(),r=yc(),o=Oo(Zs.laptop),a=c=>{if(c===e&&n){if(n.length===1)return t(F.home.path);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&&Yf(e)},[e]),s.jsxs("div",{className:"h-screen max-h-screen bg-(--bg) flex flex-col",children:[e&&s.jsx(Qf,{id:e}),s.jsx("div",{className:k(mn.tabs,"no-scrollbar",!o&&mn.mobile),children:n?.map(c=>s.jsxs("div",{onClick:()=>t(`${F.workbench.path}/tab/${c.id}`),className:k(mn.tab,c.id===e&&mn.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:mn.closeButton,onClick:i,children:s.jsx(vt,{width:20,height:20})})]},c.id))})]})},Gf="_root_qslmq_2",Xf="_up_qslmq_2",Zf="_down_qslmq_2",em="_chevron_qslmq_2",tm="_table-name-container_qslmq_2",nm="_link_qslmq_2",sm="_table-name_qslmq_2",rm="_ul_qslmq_2",om="_column-type_qslmq_2",am="_action-blue_qslmq_2 _action_qslmq_2",im="_action-red_qslmq_2 _action_qslmq_2",ce={root:Gf,up:Xf,down:Zf,chevron:em,tableNameContainer:tm,link:nm,tableName:sm,ul:rm,columnType:om,actionBlue:am,actionRed:im},[Pp,lm]=ge(!1),pa=()=>lm(!1),cm="_sidebar_5zpiv_2",um="_sidebar-visible_5zpiv_2",dm="_sidebar-container_5zpiv_2",hm="_sidebar-invisible_5zpiv_2",fm="_backdrop_5zpiv_2",pn={sidebar:cm,sidebarVisible:um,sidebarContainer:dm,sidebarInvisible:hm,backdrop:fm},ga=({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:k(pn.sidebar,n?pn.sidebarVisible:pn.sidebarInvisible),children:[s.jsx("div",{onClick:d,className:pn.backdrop}),s.jsx("div",{className:k(pn.sidebarContainer,a),children:i&&e})]})},mm=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})),pm=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"})),gm=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"})),xa=(e,t=!0)=>{const n=navigator.clipboard.writeText(e);t&&n.then(()=>{Ce.success(`Copied "${e}"`)})},xm=new Intl.DateTimeFormat("en",{dateStyle:"full",timeStyle:"long"}),zn=18;function bm(e,t){return t&&e.toLowerCase().includes(t)?"bg-yellow-200 cursor-pointer":"cursor-pointer"}const ym=({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:ce.ul,children:r.map(o=>s.jsx(s.Fragment,{children:s.jsxs("li",{children:[o.isPrimary?"🔐":"🏷️"," ",s.jsx("span",{onClick:()=>xa(o.name),className:bm(o.name,t),children:o.name})," ",s.jsxs("span",{className:ce.columnType,children:["[",o.type,"]"]}),o.ref&&s.jsxs("span",{children:[" ➡️ ",s.jsx("span",{className:ce.columnType,children:o.ref.table}),".",o.ref.field]})]},o.name+o.type)}))},e.id)};function vm({id:e}){const{data:t}=as(e),{data:n}=_n(e),r=ee(),o=Dl(),a=No(),i=Fl(),u=Jt(),c=l.useMemo(()=>t?.lastInspected?xm.format(new Date(t.lastInspected)):"--",[t]),[d,f]=l.useState({}),[h,p]=l.useState(""),[b,g]=l.useState("table"),x=kn(ue.EDITOR),v=h.toLowerCase(),y=l.useMemo(()=>{if(!v||!n)return n||[];const S=[];for(const A of n){if(A.tableName.toLowerCase().includes(v)){S.push(A);continue}b!=="table"&&A.columns.findIndex($=>$.name.toLowerCase().includes(v))>=0&&S.push(A)}return S},[v,n,b]),m=S=>{f(A=>({...A,[S]:!A[S]}))},w=S=>{u.mutateAsync({name:S,opts:Yt({table:S,dataSourceId:e})}).then(A=>{qt(void 0),pa(),r(`${F.workbench.path}/tab/${A.id}`)})},C=()=>{a.mutate(e)},_=async()=>{const S=await Rn("Enter name",t?.name);S&&o.mutate({id:e,dataSource:{name:S}})},E=async()=>{await Po("Are you sure you want to delete this data source?")&&(i.mutate(e),qt(void 0))},j=b==="column";return s.jsxs("div",{className:ce.root,children:[s.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 p-4 z-1",children:[s.jsxs("h3",{className:"page-head flex gap-2",children:[t&&s.jsx(Gt,{size:32,type:t.dbType}),s.jsx("span",{className:"truncate",children:t?.name})]}),s.jsx("p",{className:"mt-2 text-xs text-gray-800",children:"Last DB inspection"}),s.jsx("p",{className:"text-sm font-semibold",children:c}),x&&s.jsxs("div",{className:"mt-2 flex gap-2",children:[s.jsxs("button",{disabled:a.isPending,onClick:C,className:ce.actionBlue,children:[s.jsx(sa,{width:16,height:16}),"INSPECT"]}),s.jsxs("button",{disabled:a.isPending,onClick:_,className:ce.actionBlue,children:[s.jsx(pm,{width:16,height:16}),"RENAME"]}),s.jsxs("button",{disabled:a.isPending,onClick:E,className:ce.actionRed,children:[s.jsx(gm,{width:16,height:16}),"DELETE"]})]}),s.jsxs("div",{className:"flex gap-2 items-center mb-2 mt-4",children:[s.jsxs("select",{className:"input",value:b,onChange:S=>g(S.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:S=>p(S.target.value),autoFocus:!0})]})]}),s.jsx("div",{className:"overflow-y-auto p-4",children:y?.map(S=>s.jsxs("div",{children:[s.jsxs("div",{className:ce.tableNameContainer,children:[s.jsx("button",{className:k(ce.chevron,d[S.id]?ce.down:ce.up),onClick:()=>m(S.id),children:s.jsx(rt,{width:16,height:16})}),s.jsx("button",{className:k(ce.tableName,"flex-1"),onClick:()=>m(S.id),children:S.tableName}),s.jsx("button",{className:ce.link,onClick:()=>w(S.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Explore table data",children:s.jsx(mm,{width:zn,height:zn})}),s.jsx("button",{className:ce.link,onClick:()=>xa(S.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Copy table name",children:s.jsx(Wo,{width:zn,height:zn})})]}),(d[S.id]||h.length>0)&&s.jsx(ym,{insp:S,filter:j?v:"",expanded:d[S.id]})]},S.id))})]})}const wm=()=>{const e=Vc(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const r=()=>qt(void 0);return s.jsx(ga,{isVisible:e!=null,onClose:r,onClosed:()=>n(void 0),backdropClose:!0,children:t&&s.jsx(vm,{id:t})})},Cm="_search_1t7by_2",jm="_entry_1t7by_2",Nm="_ds_1t7by_2",Sm="_ds-container_1t7by_2",_m="_ds-entry_1t7by_2",Em="_enabled_1t7by_2",Mt={search:Cm,entry:jm,ds:Nm,dsContainer:Sm,dsEntry:_m,enabled:Em};function km(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 Rm=({storage:e=localStorage,localStorageKey:t,initialData:n})=>{const r=ge(km(t,n,e));return r[2].subscribe(o=>{e.setItem(t,JSON.stringify(o))}),r},[Tm,Lm]=Rm({initialData:[],localStorageKey:"selected-data-sources-v1"}),Am=e=>Lm(t=>{const n=t.indexOf(e);return n>-1?(t.splice(n,1),[...t]):[...t,e]}),Pm={table:"📄",query:"📖",tab:"🛠️"},Im=({onTable:e,onQuery:t,onWorkbenchTab:n,autoFocus:r})=>{const[o,a]=l.useState(""),[i,u]=l.useState(-1),c=zf(o,200),d=Tm(),{data:f}=Te(),{data:h}=Vs({teamId:f?.teamId}),p=l.useMemo(()=>{const m=[],w=Qr(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}=Ll(c,{teamId:f?.teamId,selectedDataSources:p}),g=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)},x=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(),g(b[i])))},v=m=>{const w=m.currentTarget.dataset.tableId,C=b?.find(_=>_.id===w);C&&g(C)},y=l.useMemo(()=>Qr(d),[d]);return s.jsxs("div",{className:"overflow-hidden flex flex-col w-full lg:w-lg",children:[Ye(h?.length,0)?s.jsx("div",{className:Mt.dsContainer+" no-scrollbar",children:h.map(m=>s.jsxs("button",{className:k(Mt.dsEntry,y[m.id]&&Mt.enabled),onClick:()=>Am(m.id),children:[s.jsx(Gt,{size:24,type:m.dbType}),s.jsx("span",{children:m.name})]},m.id))}):s.jsx(Z,{variant:"warning",className:"mb-4",children:"Connect at least one data source to start using DataRamen"}),s.jsx("input",{className:Mt.search,placeholder:"Search table or saved query to start from",value:o,onChange:m=>a(m.target.value),onKeyDown:x,autoFocus:r}),Ye(b?.length,0)&&s.jsx("div",{className:"overflow-y-auto max-h-full mt-2",children:b.map((m,w)=>s.jsxs("button",{className:Mt.entry,"data-is-active":i===w,"data-table-id":m.id,onClick:v,children:[s.jsxs("p",{className:"font-semibold truncate",children:[Pm[m.type]," ",m.name]}),s.jsxs("p",{className:Mt.ds,children:["📦 ",m.dataSourceName]})]},m.id))})]})},Om=()=>{const e=jc(),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.jsxs(xe,{isVisible:!!e,onClose:o,children:[s.jsx(Ge,{onClick:o}),s.jsx(Im,{autoFocus:!0,onTable:t,onQuery:n,onWorkbenchTab:r})]})},$m=()=>{const e=En("Hotkey"),t=ee(),{pathname:n}=ie(),{data:r}=Te(),{data:o}=Ys(),a=n===F.home.path;_e("n",()=>{r&&e()}),_e("w",()=>{r&&(o&&o.length>0?t(`${F.workbench.path}/tab/${o[0].id}`):e())},{enabled:a}),_e("h",()=>{Bt({show:!0})})},Mm=()=>{const e=ie();l.useEffect(()=>{},[e.pathname])},[Dm,ba]=ge(!1),Rs=()=>ba(!1),ya=()=>ba(!0),Fm=({repeatPassword:e,password:t})=>t.length<1?null:t.length<8?s.jsx(Z,{variant:"warning",children:"New password should be at least 8 characters long"}):t!==e?s.jsx(Z,{variant:"warning",children:"Repeat password should match new password"}):null,qm=()=>{const e=Dm(),{data:t}=Te(),{mutateAsync:n,isPending:r}=ql(),o=ee(),[{password:a,repeatPassword:i},{change:u,touched:c,reset:d}]=Cn({password:"",repeatPassword:""}),f=()=>{o("/"),qs.logout().then(()=>{Rs()})},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(xe,{isVisible:e,onClose:Rs,children:[s.jsx(Ge,{onClick:Rs}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[s.jsx(Ao,{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(Fm,{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"})]})]})]})},[Bm,va]=ge(!1),wa=()=>va(!0),Jr=()=>va(!1),Um=e=>de({queryKey:["team-users"],queryFn:async()=>{const{data:t}=await O.get("/teams/"+e+"/users");return t.data},enabled:!!e}),Wm=()=>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"]})}}),zm=()=>X({mutationFn:async({teamId:e,userId:t})=>(await O.delete("/teams/"+e,{params:{userId:t}}),!0),onSuccess:()=>{K.invalidateQueries({queryKey:["team-users"]})}}),Hm="_user-entry_14n50_2",Km="_select-container_14n50_2",Gr={userEntry:Hm,selectContainer:Km},Vm=()=>{const e=Bm(),{data:t}=Te(),{data:n}=Um(t?.teamId),{mutate:r,isPending:o}=Bl(),{mutate:a,isPending:i}=Wm(),{mutate:u,isPending:c}=zm(),[d,{change:f,reset:h}]=Cn({password:"",username:""}),p=()=>{r({username:d.username,password:d.password,teamId:t?.teamId||""}),h()},b=(y,m)=>{a({teamId:t.teamId,role:m,userId:y})},g=y=>{Po("Are you sure you want to remove this user?").then(m=>{m&&u({userId:y,teamId:t.teamId})})},x=kn(ue.ADMIN),v=o||i||c;return s.jsxs(xe,{isVisible:e,onClose:Jr,backdropClose:!0,children:[s.jsx(Ge,{onClick:Jr}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[s.jsx(Ao,{children:"Manage users"}),Ye(n?.length,0)&&s.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:n.map(y=>s.jsxs("div",{className:Gr.userEntry,children:[s.jsx("div",{className:Gr.selectContainer,children:s.jsxs("select",{value:y.role,disabled:!x||v,onChange:m=>b(y.id,m.currentTarget.value),children:[s.jsx("option",{value:ue.OWNER,children:"Owner"}),s.jsx("option",{value:ue.ADMIN,children:"Admin"}),s.jsx("option",{value:ue.EDITOR,children:"Editor"}),s.jsx("option",{value:ue.READ_ONLY,children:"Reader"})]})}),s.jsx("p",{className:"flex-1 mx-2",children:y.name}),x&&s.jsx("button",{className:"p-1 cursor-pointer text-red-500 text-sm",onClick:()=>g(y.id),children:"❌"})]},y.id))}),x&&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."})]})]})]})},Qm=()=>{const[e,t]=l.useState(""),[n,r]=l.useState(""),[o,a]=l.useState(),[i,u]=l.useState(!1),c=ee(),d=f=>{f.preventDefault(),a(void 0),qs.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(Z,{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(Z,{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?"})]})})})},Ym=()=>{const e=ee(),{pathname:t}=ie(),{data:n,isLoading:r}=So();l.useEffect(()=>{!n&&!r&&t!==F.login.path&&e(F.login.path)},[n,r,e,t])},Jm=()=>{},Gm=__CLIENT_CONFIG__.skipAuth?Jm:Ym,Xm=()=>{const[e]=ol(),t=ee(),n=Jt(),r=e.get("shareId");return l.useEffect(()=>{r&&n.mutateAsync({queryId:r}).then(o=>{t(`${F.workbench.path}/tab/${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(ma,{}),s.jsx("p",{children:"Fetching query information"})]}),n.isError&&s.jsx(Z,{variant:"danger",children:"Failed to load query information"})]})},Zm="_container_1in1n_2",ep="_header_1in1n_2",tp="_close-button_1in1n_2",np="_tab-container_1in1n_2",sp="_tab-name_1in1n_2",rp="_archived-badge_1in1n_2 _badge_1in1n_2",op="_active-badge_1in1n_2 _badge_1in1n_2",ap="_action-blue_1in1n_2 _action_1in1n_2",ip="_action-red_1in1n_2 _action_1in1n_2",lp="_load-more-btn_1in1n_2",Oe={container:Zm,header:ep,closeButton:tp,tabContainer:np,tabName:sp,archivedBadge:rp,activeBadge:op,actionBlue:ap,actionRed:ip,loadMoreBtn:lp},cp=new Intl.DateTimeFormat,up=()=>{const{data:e}=Te(),{data:t,fetchNextPage:n,hasNextPage:r,isFetching:o}=Al(e?.teamId,25),a=ee(),i=Ro(),u=Cc(),c=h=>{i.mutate(h),Bt({show:!1}),a(`${F.workbench.path}/tab/${h}`)},d=h=>{u.mutate(h)},f=t&&t?.length>0;return s.jsxs("div",{className:Oe.container,children:[s.jsxs("div",{className:Oe.header,children:[s.jsx("h3",{className:"text-lg",children:"Tabs history"}),s.jsx("button",{className:Oe.closeButton,onClick:()=>Bt({show:!1}),children:s.jsx(vt,{width:24,height:24})})]}),!f&&s.jsx(Z,{variant:"warning",children:"History is empty."}),t?.map(h=>s.jsxs("div",{className:Oe.tabContainer,children:[s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("p",{className:Oe.tabName,children:h.name}),h.dataSourceType&&s.jsx(Gt,{size:16,type:h.dataSourceType}),s.jsx("p",{className:"text-sm",children:h.dataSourceName})]}),s.jsxs("div",{className:"flex gap-2 items-center mt-1",children:[s.jsx("p",{className:"text-sm italic",children:cp.format(new Date(h.updatedAt))}),h.archived?s.jsx("span",{className:Oe.archivedBadge,children:"Archived"}):s.jsx("span",{className:Oe.activeBadge,children:"Active"}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{onClick:()=>c(h.id),className:Oe.actionBlue,children:"Open"}),s.jsx("button",{onClick:()=>d(h.id),className:Oe.actionRed,children:"Delete"})]})]},h.id)),r&&!o&&s.jsx("div",{className:"flex justify-center my-2",children:s.jsx("button",{className:Oe.loadMoreBtn,onClick:()=>n(),children:"Load more"})})]})},dp=()=>{const e=Qc(t=>t.show);return s.jsx(ga,{isVisible:e,onClose:()=>Bt({show:!1}),backdropClose:!0,children:s.jsx(up,{})})};function hp(){return $m(),Mm(),Gm(),s.jsxs(s.Fragment,{children:[s.jsxs(Ri,{children:[s.jsx(gn,{path:F.home.path,element:s.jsx(eu,{})}),s.jsx(gn,{path:`${F.workbench.path}/tab/:id`,element:s.jsx(Jf,{})}),s.jsx(gn,{path:F.login.path,element:s.jsx(Qm,{})}),s.jsx(gn,{path:F.share.path,element:s.jsx(Xm,{})})]}),s.jsx(hu,{}),s.jsx(Cu,{}),s.jsx(Ou,{}),s.jsx(wm,{}),s.jsx(Om,{}),s.jsx(qm,{}),s.jsx(Vm,{}),s.jsx(dp,{}),s.jsx(Tu,{}),s.jsx(Su,{})]})}const fp="_desktop-layout_11msc_2",mp="_mobile-layout_11msc_2",pp="_nav_11msc_2",gp="_main_11msc_2",xp="_header_11msc_2",zt={desktopLayout:fp,mobileLayout:mp,nav:pp,main:gp,header:xp},bp="_container_1sgl4_2",yp="_menu_1sgl4_2",cr={container:bp,menu:yp},vp=({name:e,id:t,onRename:n,onDelete:r,onOpen:o})=>{const a=Do();return s.jsxs("button",{className:cr.menu,onContextMenu:a.open,onClick:()=>o(t),children:[s.jsx(Fo,{handler:a,children:s.jsxs("div",{className:"context-menu-container",children:[s.jsx("button",{onClick:i=>{i.preventDefault(),i.stopPropagation(),a.close(),n(t)},className:"context-menu-item",children:"✏️ Rename"}),s.jsx("button",{onClick:i=>{i.preventDefault(),i.stopPropagation(),a.close(),r(t)},className:"context-menu-item",children:"🗑️ Delete"})]})}),s.jsxs("span",{children:["📖 ",e]})]})},wp=({dataSource:e,index:t})=>{const n=()=>{qt(e.id)};return _e(t.toString(),()=>{qt(r=>{if(r!==e.id)return e.id})}),s.jsxs("button",{className:cr.menu,onClick:n,children:[s.jsx(Gt,{size:20,type:e.dbType}),s.jsx("p",{className:"truncate flex-1 text-left mx-1.5",children:e.name}),s.jsx("span",{className:"hotkey",children:t})]})},Cp=()=>{const e=ee(),{data:t}=Te(),{data:n}=kl(t?.teamId),{data:r}=Rl(t?.teamId),o=Jt(),a=Vd(),i=Kd(),u=f=>{o.mutateAsync({queryId:f}).then(h=>{e(`${F.workbench.path}/tab/${h.id}`)})},c=async f=>{const h=r?.find(b=>b.id===f);if(!h)return;const p=await Rn("New name?",h?.name);p&&a.mutate({id:h.savedQueryId,payload:{name:p}})},d=f=>{const h=r?.find(p=>p.id===f)?.savedQueryId;h&&i.mutate(h)};return s.jsx("div",{className:cr.container,children:s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[Ye(n?.length,0)&&s.jsxs("div",{className:"mt-4",children:[s.jsx("p",{className:"font-semibold text-sm text-gray-600 mb-2",children:"DATA SOURCES"}),n.map((f,h)=>s.jsx(wp,{dataSource:f,index:h+1},f.id))]}),Ye(r?.length,0)&&s.jsxs("div",{className:"mt-4",children:[s.jsx("p",{className:"font-semibold text-sm text-gray-600 mb-2",children:"SAVED QUERIES"}),r.map(f=>s.jsx(vp,{onDelete:d,onRename:c,onOpen:u,name:f.name,id:f.id},f.savedQueryId))]})]})})},jp=!__CLIENT_CONFIG__.skipAuth,Np=()=>{const e=ee(),{pathname:t}=ie(),{data:n}=Te(),r=En("Desktop nav"),o=()=>{pa(),t!==F.home.path&&e(F.home.path)},a=()=>Bt({show:!0});return s.jsxs("nav",{className:zt.nav,children:[n&&s.jsxs("div",{className:zt.header,children:[s.jsx("button",{onClick:o,className:"flex justify-between items-center",children:s.jsx("span",{children:"🏠 Home"})}),s.jsxs("button",{onClick:r,className:"flex justify-between items-center",children:[s.jsx("span",{children:"🔎 New query"}),s.jsx("span",{className:"hotkey",children:"N"})]}),s.jsxs("button",{onClick:a,className:"flex justify-between items-center",children:[s.jsx("span",{children:"⌛ Recent tabs"}),s.jsx("span",{className:"hotkey",children:"H"})]}),jp&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:ya,children:["🪪 ",n.username]}),s.jsx("button",{onClick:wa,children:"👥 Manage users"})]})]}),s.jsx(Cp,{})]})},Sp="_root_1yx8n_2",_p={root:Sp},Ep=()=>{const{pathname:e}=ie(),t=ee(),n=En("Mobile nav"),r=()=>{e!==F.home.path&&t(F.home.path)};return s.jsxs("div",{className:_p.root,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"})]}),s.jsxs("button",{onClick:ya,children:[s.jsx("p",{children:"🪪"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Account"})]}),s.jsxs("button",{onClick:wa,children:[s.jsx("p",{children:"👥"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Users"})]})]})},kp=({children:e,isLogin:t})=>s.jsxs("div",{className:zt.desktopLayout,children:[s.jsx(ns,{id:"default",className:"z-100"}),s.jsx(ns,{id:"default-xs",className:"z-100 text-xs!"}),!t&&s.jsx(Np,{}),s.jsx("main",{className:zt.main,children:e})]}),Rp=({children:e,isLogin:t})=>s.jsxs("div",{className:zt.mobileLayout,children:[s.jsx("main",{className:zt.main,children:e}),!t&&s.jsx(Ep,{})]}),Tp=({children:e})=>{const t=Oo(Zs.laptop),{pathname:n}=ie(),r=n===F.login.path;return t?s.jsx(kp,{isLogin:r,children:e}):s.jsx(Rp,{isLogin:r,children:e})};$a.createRoot(document.getElementById("root")).render(s.jsxs(tt.StrictMode,{children:[s.jsx(Ma,{}),s.jsx(gl,{client:K,children:s.jsx(el,{children:s.jsx(Tp,{children:s.jsx(hp,{})})})})]}));
|