@dataramen/cli 0.0.85-beta.1 → 0.0.85-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as l,a as _i,S as zr,p as Uo,b as Ae,s as as,c as jn,n as is,i as Qs,d as Ho,t as ki,e as Jn,f as Ei,g as Ri,h as Vo,j as ms,k as Ko,l as Li,m as Ti,o as Qo,q as Ai,u as s,v as ro,w as X,x as B,y as qr,A as fs,z as Ii,B as A,C as En,D as ve,E as ue,F as Mi,G as Pi,R as lt,H as Oi,I as Di}from"./index-B8uj6NzK.js";var Go="popstate";function $i(e={}){function t(o,r){let{pathname:a,search:i,hash:c}=o.location;return Gs("",{pathname:a,search:i,hash:c},r.state&&r.state.usr||null,r.state&&r.state.key||"default")}function n(o,r){return typeof r=="string"?r:Nn(r)}return Bi(t,n,null,e)}function Y(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 Fi(){return Math.random().toString(36).substring(2,10)}function Yo(e,t){return{usr:e.state,key:e.key,idx:t}}function Gs(e,t,n=null,o){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?tn(t):t,state:n,key:t&&t.key||o||Fi()}}function Nn({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 tn(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let o=e.indexOf("?");o>=0&&(t.search=e.substring(o),e=e.substring(0,o)),e&&(t.pathname=e)}return t}function Bi(e,t,n,o={}){let{window:r=document.defaultView,v5Compat:a=!1}=o,i=r.history,c="POP",d=null,h=m();h==null&&(h=0,i.replaceState({...i.state,idx:h},""));function m(){return(i.state||{idx:null}).idx}function u(){c="POP";let g=m(),w=g==null?null:g-h;h=g,d&&d({action:c,location:b.location,delta:w})}function x(g,w){c="PUSH";let v=Gs(b.location,g,w);h=m()+1;let y=Yo(v,h),C=b.createHref(v);try{i.pushState(y,"",C)}catch(_){if(_ instanceof DOMException&&_.name==="DataCloneError")throw _;r.location.assign(C)}a&&d&&d({action:c,location:b.location,delta:1})}function f(g,w){c="REPLACE";let v=Gs(b.location,g,w);h=m();let y=Yo(v,h),C=b.createHref(v);i.replaceState(y,"",C),a&&d&&d({action:c,location:b.location,delta:0})}function p(g){return zi(g)}let b={get action(){return c},get location(){return e(r,i)},listen(g){if(d)throw new Error("A history only accepts one active listener");return r.addEventListener(Go,u),d=g,()=>{r.removeEventListener(Go,u),d=null}},createHref(g){return t(r,g)},createURL:p,encodeLocation(g){let w=p(g);return{pathname:w.pathname,search:w.search,hash:w.hash}},push:x,replace:f,go(g){return i.go(g)}};return b}function zi(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Y(n,"No window.location.(origin|href) available to create URL");let o=typeof e=="string"?e:Nn(e);return o=o.replace(/ $/,"%20"),!t&&o.startsWith("//")&&(o=n+o),new URL(o,n)}function Wr(e,t,n="/"){return qi(e,t,n,!1)}function qi(e,t,n,o){let r=typeof t=="string"?tn(t):t,a=et(r.pathname||"/",n);if(a==null)return null;let i=Ur(e);Wi(i);let c=null;for(let d=0;c==null&&d<i.length;++d){let h=el(a);c=Xi(i[d],h,o)}return c}function Ur(e,t=[],n=[],o="",r=!1){let a=(i,c,d=r,h)=>{let m={relativePath:h===void 0?i.path||"":h,caseSensitive:i.caseSensitive===!0,childrenIndex:c,route:i};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(o)&&d)return;Y(m.relativePath.startsWith(o),`Absolute route path "${m.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),m.relativePath=m.relativePath.slice(o.length)}let u=Ze([o,m.relativePath]),x=n.concat(m);i.children&&i.children.length>0&&(Y(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${u}".`),Ur(i.children,t,x,u,d)),!(i.path==null&&!i.index)&&t.push({path:u,score:Yi(u,i.index),routesMeta:x})};return e.forEach((i,c)=>{if(i.path===""||!i.path?.includes("?"))a(i,c);else for(let d of Hr(i.path))a(i,c,!0,d)}),t}function Hr(e){let t=e.split("/");if(t.length===0)return[];let[n,...o]=t,r=n.endsWith("?"),a=n.replace(/\?$/,"");if(o.length===0)return r?[a,""]:[a];let i=Hr(o.join("/")),c=[];return c.push(...i.map(d=>d===""?a:[a,d].join("/"))),r&&c.push(...i),c.map(d=>e.startsWith("/")&&d===""?"/":d)}function Wi(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ji(t.routesMeta.map(o=>o.childrenIndex),n.routesMeta.map(o=>o.childrenIndex)))}var Ui=/^:[\w-]+$/,Hi=3,Vi=2,Ki=1,Qi=10,Gi=-2,Jo=e=>e==="*";function Yi(e,t){let n=e.split("/"),o=n.length;return n.some(Jo)&&(o+=Gi),t&&(o+=Vi),n.filter(r=>!Jo(r)).reduce((r,a)=>r+(Ui.test(a)?Hi:a===""?Ki:Qi),o)}function Ji(e,t){return e.length===t.length&&e.slice(0,-1).every((o,r)=>o===t[r])?e[e.length-1]-t[t.length-1]:0}function Xi(e,t,n=!1){let{routesMeta:o}=e,r={},a="/",i=[];for(let c=0;c<o.length;++c){let d=o[c],h=c===o.length-1,m=a==="/"?t:t.slice(a.length)||"/",u=Yt({path:d.relativePath,caseSensitive:d.caseSensitive,end:h},m),x=d.route;if(!u&&h&&n&&!o[o.length-1].route.index&&(u=Yt({path:d.relativePath,caseSensitive:d.caseSensitive,end:!1},m)),!u)return null;Object.assign(r,u.params),i.push({params:r,pathname:Ze([a,u.pathname]),pathnameBase:ol(Ze([a,u.pathnameBase])),route:x}),u.pathnameBase!=="/"&&(a=Ze([a,u.pathnameBase]))}return i}function Yt(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,o]=Zi(e.path,e.caseSensitive,e.end),r=t.match(n);if(!r)return null;let a=r[0],i=a.replace(/(.)\/+$/,"$1"),c=r.slice(1);return{params:o.reduce((h,{paramName:m,isOptional:u},x)=>{if(m==="*"){let p=c[x]||"";i=a.slice(0,a.length-p.length).replace(/(.)\/+$/,"$1")}const f=c[x];return u&&!f?h[m]=void 0:h[m]=(f||"").replace(/%2F/g,"/"),h},{}),pathname:a,pathnameBase:i,pattern:e}}function Zi(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 o=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,c,d)=>(o.push({paramName:c,isOptional:d!=null}),d?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(o.push({paramName:"*"}),r+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?r+="\\/*$":e!==""&&e!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,t?void 0:"i"),o]}function el(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 et(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,o=e.charAt(n);return o&&o!=="/"?null:e.slice(n)||"/"}var Vr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,tl=e=>Vr.test(e);function nl(e,t="/"){let{pathname:n,search:o="",hash:r=""}=typeof e=="string"?tn(e):e,a;if(n)if(tl(n))a=n;else{if(n.includes("//")){let i=n;n=n.replace(/\/\/+/g,"/"),Ee(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${n}`)}n.startsWith("/")?a=Xo(n.substring(1),"/"):a=Xo(n,t)}else a=t;return{pathname:a,search:rl(o),hash:al(r)}}function Xo(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(r=>{r===".."?n.length>1&&n.pop():r!=="."&&n.push(r)}),n.length>1?n.join("/"):"/"}function Os(e,t,n,o){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(o)}]. 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 sl(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Kr(e){let t=sl(e);return t.map((n,o)=>o===t.length-1?n.pathname:n.pathnameBase)}function Qr(e,t,n,o=!1){let r;typeof e=="string"?r=tn(e):(r={...e},Y(!r.pathname||!r.pathname.includes("?"),Os("?","pathname","search",r)),Y(!r.pathname||!r.pathname.includes("#"),Os("#","pathname","hash",r)),Y(!r.search||!r.search.includes("#"),Os("#","search","hash",r)));let a=e===""||r.pathname==="",i=a?"/":r.pathname,c;if(i==null)c=n;else{let u=t.length-1;if(!o&&i.startsWith("..")){let x=i.split("/");for(;x[0]==="..";)x.shift(),u-=1;r.pathname=x.join("/")}c=u>=0?t[u]:"/"}let d=nl(r,c),h=i&&i!=="/"&&i.endsWith("/"),m=(a||i===".")&&n.endsWith("/");return!d.pathname.endsWith("/")&&(h||m)&&(d.pathname+="/"),d}var Ze=e=>e.join("/").replace(/\/\/+/g,"/"),ol=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),rl=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,al=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,il=class{constructor(e,t,n,o=!1){this.status=e,this.statusText=t||"",this.internal=o,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function ll(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function cl(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Gr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Yr(e,t){let n=e;if(typeof n!="string"||!Vr.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let o=n,r=!1;if(Gr)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),c=et(i.pathname,t);i.origin===a.origin&&c!=null?n=c+i.search+i.hash:r=!0}catch{Ee(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:r,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Jr=["POST","PUT","PATCH","DELETE"];new Set(Jr);var ul=["GET",...Jr];new Set(ul);var nn=l.createContext(null);nn.displayName="DataRouter";var ps=l.createContext(null);ps.displayName="DataRouterState";var dl=l.createContext(!1),Xr=l.createContext({isTransitioning:!1});Xr.displayName="ViewTransition";var hl=l.createContext(new Map);hl.displayName="Fetchers";var ml=l.createContext(null);ml.displayName="Await";var Re=l.createContext(null);Re.displayName="Navigation";var Rn=l.createContext(null);Rn.displayName="Location";var Ue=l.createContext({outlet:null,matches:[],isDataRoute:!1});Ue.displayName="Route";var ao=l.createContext(null);ao.displayName="RouteError";var Zr="REACT_ROUTER_ERROR",fl="REDIRECT",pl="ROUTE_ERROR_RESPONSE";function xl(e){if(e.startsWith(`${Zr}:${fl}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function gl(e){if(e.startsWith(`${Zr}:${pl}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new il(t.status,t.statusText,t.data)}catch{}}function vl(e,{relative:t}={}){Y(Ln(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:o}=l.useContext(Re),{hash:r,pathname:a,search:i}=Tn(e,{relative:t}),c=a;return n!=="/"&&(c=a==="/"?n:Ze([n,a])),o.createHref({pathname:c,search:i,hash:r})}function Ln(){return l.useContext(Rn)!=null}function pe(){return Y(Ln(),"useLocation() may be used only in the context of a <Router> component."),l.useContext(Rn).location}var ea="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function ta(e){l.useContext(Re).static||l.useLayoutEffect(e)}function te(){let{isDataRoute:e}=l.useContext(Ue);return e?Al():bl()}function bl(){Y(Ln(),"useNavigate() may be used only in the context of a <Router> component.");let e=l.useContext(nn),{basename:t,navigator:n}=l.useContext(Re),{matches:o}=l.useContext(Ue),{pathname:r}=pe(),a=JSON.stringify(Kr(o)),i=l.useRef(!1);return ta(()=>{i.current=!0}),l.useCallback((d,h={})=>{if(Ee(i.current,ea),!i.current)return;if(typeof d=="number"){n.go(d);return}let m=Qr(d,JSON.parse(a),r,h.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Ze([t,m.pathname])),(h.replace?n.replace:n.push)(m,h.state,h)},[t,n,a,r,e])}l.createContext(null);function yl(){let{matches:e}=l.useContext(Ue),t=e[e.length-1];return t?t.params:{}}function Tn(e,{relative:t}={}){let{matches:n}=l.useContext(Ue),{pathname:o}=pe(),r=JSON.stringify(Kr(n));return l.useMemo(()=>Qr(e,JSON.parse(r),o,t==="path"),[e,r,o,t])}function wl(e,t){return na(e,t)}function na(e,t,n,o,r){Y(Ln(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=l.useContext(Re),{matches:i}=l.useContext(Ue),c=i[i.length-1],d=c?c.params:{},h=c?c.pathname:"/",m=c?c.pathnameBase:"/",u=c&&c.route;{let v=u&&u.path||"";oa(h,!u||v.endsWith("*")||v.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${v}">) 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="${v}"> to <Route path="${v==="/"?"*":`${v}/*`}">.`)}let x=pe(),f;if(t){let v=typeof t=="string"?tn(t):t;Y(m==="/"||v.pathname?.startsWith(m),`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 "${m}" but pathname "${v.pathname}" was given in the \`location\` prop.`),f=v}else f=x;let p=f.pathname||"/",b=p;if(m!=="/"){let v=m.replace(/^\//,"").split("/");b="/"+p.replace(/^\//,"").split("/").slice(v.length).join("/")}let g=Wr(e,{pathname:b});Ee(u||g!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),Ee(g==null||g[g.length-1].route.element!==void 0||g[g.length-1].route.Component!==void 0||g[g.length-1].route.lazy!==void 0,`Matched leaf route at location "${f.pathname}${f.search}${f.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 w=_l(g&&g.map(v=>Object.assign({},v,{params:Object.assign({},d,v.params),pathname:Ze([m,a.encodeLocation?a.encodeLocation(v.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?m:Ze([m,a.encodeLocation?a.encodeLocation(v.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:v.pathnameBase])})),i,n,o,r);return t&&w?l.createElement(Rn.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...f},navigationType:"POP"}},w):w}function Cl(){let e=Tl(),t=ll(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,o="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:o},a={padding:"2px 4px",backgroundColor:o},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:r},n):null,i)}var jl=l.createElement(Cl,null),sa=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){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=gl(e.digest);n&&(e=n)}let t=e!==void 0?l.createElement(Ue.Provider,{value:this.props.routeContext},l.createElement(ao.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?l.createElement(Nl,{error:e},t):t}};sa.contextType=dl;var Ds=new WeakMap;function Nl({children:e,error:t}){let{basename:n}=l.useContext(Re);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let o=xl(t.digest);if(o){let r=Ds.get(t);if(r)throw r;let a=Yr(o.location,n);if(Gr&&!Ds.get(t))if(a.isExternal||o.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:o.replace}));throw Ds.set(t,i),i}return l.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function Sl({routeContext:e,match:t,children:n}){let o=l.useContext(nn);return o&&o.static&&o.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=t.route.id),l.createElement(Ue.Provider,{value:e},n)}function _l(e,t=[],n=null,o=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 a=e,i=n?.errors;if(i!=null){let m=a.findIndex(u=>u.route.id&&i?.[u.route.id]!==void 0);Y(m>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),a=a.slice(0,Math.min(a.length,m+1))}let c=!1,d=-1;if(n)for(let m=0;m<a.length;m++){let u=a[m];if((u.route.HydrateFallback||u.route.hydrateFallbackElement)&&(d=m),u.route.id){let{loaderData:x,errors:f}=n,p=u.route.loader&&!x.hasOwnProperty(u.route.id)&&(!f||f[u.route.id]===void 0);if(u.route.lazy||p){c=!0,d>=0?a=a.slice(0,d+1):a=[a[0]];break}}}let h=n&&o?(m,u)=>{o(m,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:cl(n.matches),errorInfo:u})}:void 0;return a.reduceRight((m,u,x)=>{let f,p=!1,b=null,g=null;n&&(f=i&&u.route.id?i[u.route.id]:void 0,b=u.route.errorElement||jl,c&&(d<0&&x===0?(oa("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),p=!0,g=null):d===x&&(p=!0,g=u.route.hydrateFallbackElement||null)));let w=t.concat(a.slice(0,x+1)),v=()=>{let y;return f?y=b:p?y=g:u.route.Component?y=l.createElement(u.route.Component,null):u.route.element?y=u.route.element:y=m,l.createElement(Sl,{match:u,routeContext:{outlet:m,matches:w,isDataRoute:n!=null},children:y})};return n&&(u.route.ErrorBoundary||u.route.errorElement||x===0)?l.createElement(sa,{location:n.location,revalidation:n.revalidation,component:b,error:f,children:v(),routeContext:{outlet:null,matches:w,isDataRoute:!0},onError:h}):v()},null)}function io(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function kl(e){let t=l.useContext(nn);return Y(t,io(e)),t}function El(e){let t=l.useContext(ps);return Y(t,io(e)),t}function Rl(e){let t=l.useContext(Ue);return Y(t,io(e)),t}function lo(e){let t=Rl(e),n=t.matches[t.matches.length-1];return Y(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Ll(){return lo("useRouteId")}function Tl(){let e=l.useContext(ao),t=El("useRouteError"),n=lo("useRouteError");return e!==void 0?e:t.errors?.[n]}function Al(){let{router:e}=kl("useNavigate"),t=lo("useNavigate"),n=l.useRef(!1);return ta(()=>{n.current=!0}),l.useCallback(async(r,a={})=>{Ee(n.current,ea),n.current&&(typeof r=="number"?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...a}))},[e,t])}var Zo={};function oa(e,t,n){!t&&!Zo[e]&&(Zo[e]=!0,Ee(!1,n))}l.memo(Il);function Il({routes:e,future:t,state:n,onError:o}){return na(e,void 0,n,o,t)}function Kt(e){Y(!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 Ml({basename:e="/",children:t=null,location:n,navigationType:o="POP",navigator:r,static:a=!1,unstable_useTransitions:i}){Y(!Ln(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),d=l.useMemo(()=>({basename:c,navigator:r,static:a,unstable_useTransitions:i,future:{}}),[c,r,a,i]);typeof n=="string"&&(n=tn(n));let{pathname:h="/",search:m="",hash:u="",state:x=null,key:f="default"}=n,p=l.useMemo(()=>{let b=et(h,c);return b==null?null:{location:{pathname:b,search:m,hash:u,state:x,key:f},navigationType:o}},[c,h,m,u,x,f,o]);return Ee(p!=null,`<Router basename="${c}"> is not able to match the URL "${h}${m}${u}" because it does not start with the basename, so the <Router> won't render anything.`),p==null?null:l.createElement(Re.Provider,{value:d},l.createElement(Rn.Provider,{children:t,value:p}))}function Pl({children:e,location:t}){return wl(Ys(e),t)}function Ys(e,t=[]){let n=[];return l.Children.forEach(e,(o,r)=>{if(!l.isValidElement(o))return;let a=[...t,r];if(o.type===l.Fragment){n.push.apply(n,Ys(o.props.children,a));return}Y(o.type===Kt,`[${typeof o.type=="string"?o.type:o.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Y(!o.props.index||!o.props.children,"An index route cannot have child routes.");let i={id:o.props.id||a.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(i.children=Ys(o.props.children,a)),n.push(i)}),n}var ns="get",ss="application/x-www-form-urlencoded";function xs(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Ol(e){return xs(e)&&e.tagName.toLowerCase()==="button"}function Dl(e){return xs(e)&&e.tagName.toLowerCase()==="form"}function $l(e){return xs(e)&&e.tagName.toLowerCase()==="input"}function Fl(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Bl(e,t){return e.button===0&&(!t||t==="_self")&&!Fl(e)}function Js(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let o=e[n];return t.concat(Array.isArray(o)?o.map(r=>[n,r]):[[n,o]])},[]))}function zl(e,t){let n=Js(e);return t&&t.forEach((o,r)=>{n.has(r)||t.getAll(r).forEach(a=>{n.append(r,a)})}),n}var Xn=null;function ql(){if(Xn===null)try{new FormData(document.createElement("form"),0),Xn=!1}catch{Xn=!0}return Xn}var Wl=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function $s(e){return e!=null&&!Wl.has(e)?(Ee(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ss}"`),null):e}function Ul(e,t){let n,o,r,a,i;if(Dl(e)){let c=e.getAttribute("action");o=c?et(c,t):null,n=e.getAttribute("method")||ns,r=$s(e.getAttribute("enctype"))||ss,a=new FormData(e)}else if(Ol(e)||$l(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let d=e.getAttribute("formaction")||c.getAttribute("action");if(o=d?et(d,t):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||ns,r=$s(e.getAttribute("formenctype"))||$s(c.getAttribute("enctype"))||ss,a=new FormData(c,e),!ql()){let{name:h,type:m,value:u}=e;if(m==="image"){let x=h?`${h}.`:"";a.append(`${x}x`,"0"),a.append(`${x}y`,"0")}else h&&a.append(h,u)}}else{if(xs(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=ns,o=null,r=ss,i=e}return a&&r==="text/plain"&&(i=a,a=void 0),{action:o,method:n.toLowerCase(),encType:r,formData:a,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function co(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Hl(e,t,n,o){let r=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?r.pathname.endsWith("/")?r.pathname=`${r.pathname}_.${o}`:r.pathname=`${r.pathname}.${o}`:r.pathname==="/"?r.pathname=`_root.${o}`:t&&et(r.pathname,t)==="/"?r.pathname=`${t.replace(/\/$/,"")}/_root.${o}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${o}`,r}async function Vl(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 Kl(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 Ql(e,t,n){let o=await Promise.all(e.map(async r=>{let a=t.routes[r.route.id];if(a){let i=await Vl(a,n);return i.links?i.links():[]}return[]}));return Xl(o.flat(1).filter(Kl).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function er(e,t,n,o,r,a){let i=(d,h)=>n[h]?d.route.id!==n[h].route.id:!0,c=(d,h)=>n[h].pathname!==d.pathname||n[h].route.path?.endsWith("*")&&n[h].params["*"]!==d.params["*"];return a==="assets"?t.filter((d,h)=>i(d,h)||c(d,h)):a==="data"?t.filter((d,h)=>{let m=o.routes[d.route.id];if(!m||!m.hasLoader)return!1;if(i(d,h)||c(d,h))return!0;if(d.route.shouldRevalidate){let u=d.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:d.params,defaultShouldRevalidate:!0});if(typeof u=="boolean")return u}return!0}):[]}function Gl(e,t,{includeHydrateFallback:n}={}){return Yl(e.map(o=>{let r=t.routes[o.route.id];if(!r)return[];let a=[r.module];return r.clientActionModule&&(a=a.concat(r.clientActionModule)),r.clientLoaderModule&&(a=a.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(a=a.concat(r.hydrateFallbackModule)),r.imports&&(a=a.concat(r.imports)),a}).flat(1))}function Yl(e){return[...new Set(e)]}function Jl(e){let t={},n=Object.keys(e).sort();for(let o of n)t[o]=e[o];return t}function Xl(e,t){let n=new Set;return new Set(t),e.reduce((o,r)=>{let a=JSON.stringify(Jl(r));return n.has(a)||(n.add(a),o.push({key:a,link:r})),o},[])}function ra(){let e=l.useContext(nn);return co(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Zl(){let e=l.useContext(ps);return co(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var uo=l.createContext(void 0);uo.displayName="FrameworkContext";function aa(){let e=l.useContext(uo);return co(e,"You must render this element inside a <HydratedRouter> element"),e}function ec(e,t){let n=l.useContext(uo),[o,r]=l.useState(!1),[a,i]=l.useState(!1),{onFocus:c,onBlur:d,onMouseEnter:h,onMouseLeave:m,onTouchStart:u}=t,x=l.useRef(null);l.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let b=w=>{w.forEach(v=>{i(v.isIntersecting)})},g=new IntersectionObserver(b,{threshold:.5});return x.current&&g.observe(x.current),()=>{g.disconnect()}}},[e]),l.useEffect(()=>{if(o){let b=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(b)}}},[o]);let f=()=>{r(!0)},p=()=>{r(!1),i(!1)};return n?e!=="intent"?[a,x,{}]:[a,x,{onFocus:yn(c,f),onBlur:yn(d,p),onMouseEnter:yn(h,f),onMouseLeave:yn(m,p),onTouchStart:yn(u,f)}]:[!1,x,{}]}function yn(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function tc({page:e,...t}){let{router:n}=ra(),o=l.useMemo(()=>Wr(n.routes,e,n.basename),[n.routes,e,n.basename]);return o?l.createElement(sc,{page:e,matches:o,...t}):null}function nc(e){let{manifest:t,routeModules:n}=aa(),[o,r]=l.useState([]);return l.useEffect(()=>{let a=!1;return Ql(e,t,n).then(i=>{a||r(i)}),()=>{a=!0}},[e,t,n]),o}function sc({page:e,matches:t,...n}){let o=pe(),{future:r,manifest:a,routeModules:i}=aa(),{basename:c}=ra(),{loaderData:d,matches:h}=Zl(),m=l.useMemo(()=>er(e,t,h,a,o,"data"),[e,t,h,a,o]),u=l.useMemo(()=>er(e,t,h,a,o,"assets"),[e,t,h,a,o]),x=l.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let b=new Set,g=!1;if(t.forEach(v=>{let y=a.routes[v.route.id];!y||!y.hasLoader||(!m.some(C=>C.route.id===v.route.id)&&v.route.id in d&&i[v.route.id]?.shouldRevalidate||y.hasClientLoader?g=!0:b.add(v.route.id))}),b.size===0)return[];let w=Hl(e,c,r.unstable_trailingSlashAwareDataRequests,"data");return g&&b.size>0&&w.searchParams.set("_routes",t.filter(v=>b.has(v.route.id)).map(v=>v.route.id).join(",")),[w.pathname+w.search]},[c,r.unstable_trailingSlashAwareDataRequests,d,o,a,m,t,e,i]),f=l.useMemo(()=>Gl(u,a),[u,a]),p=nc(u);return l.createElement(l.Fragment,null,x.map(b=>l.createElement("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),f.map(b=>l.createElement("link",{key:b,rel:"modulepreload",href:b,...n})),p.map(({key:b,link:g})=>l.createElement("link",{key:b,nonce:n.nonce,...g})))}function oc(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var rc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{rc&&(window.__reactRouterVersion="7.12.0")}catch{}function ac({basename:e,children:t,unstable_useTransitions:n,window:o}){let r=l.useRef();r.current==null&&(r.current=$i({window:o,v5Compat:!0}));let a=r.current,[i,c]=l.useState({action:a.action,location:a.location}),d=l.useCallback(h=>{n===!1?c(h):l.startTransition(()=>c(h))},[n]);return l.useLayoutEffect(()=>a.listen(d),[a,d]),l.createElement(Ml,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a,unstable_useTransitions:n})}var ia=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,la=l.forwardRef(function({onClick:t,discover:n="render",prefetch:o="none",relative:r,reloadDocument:a,replace:i,state:c,target:d,to:h,preventScrollReset:m,viewTransition:u,unstable_defaultShouldRevalidate:x,...f},p){let{basename:b,unstable_useTransitions:g}=l.useContext(Re),w=typeof h=="string"&&ia.test(h),v=Yr(h,b);h=v.to;let y=vl(h,{relative:r}),[C,_,I]=ec(o,f),j=uc(h,{replace:i,state:c,target:d,preventScrollReset:m,relative:r,viewTransition:u,unstable_defaultShouldRevalidate:x,unstable_useTransitions:g});function N(O){t&&t(O),O.defaultPrevented||j(O)}let k=l.createElement("a",{...f,...I,href:v.absoluteURL||y,onClick:v.isExternal||a?t:N,ref:oc(p,_),target:d,"data-discover":!w&&n==="render"?"true":void 0});return C&&!w?l.createElement(l.Fragment,null,k,l.createElement(tc,{page:y})):k});la.displayName="Link";var ic=l.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:o="",end:r=!1,style:a,to:i,viewTransition:c,children:d,...h},m){let u=Tn(i,{relative:h.relative}),x=pe(),f=l.useContext(ps),{navigator:p,basename:b}=l.useContext(Re),g=f!=null&&xc(u)&&c===!0,w=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,v=x.pathname,y=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;n||(v=v.toLowerCase(),y=y?y.toLowerCase():null,w=w.toLowerCase()),y&&b&&(y=et(y,b)||y);const C=w!=="/"&&w.endsWith("/")?w.length-1:w.length;let _=v===w||!r&&v.startsWith(w)&&v.charAt(C)==="/",I=y!=null&&(y===w||!r&&y.startsWith(w)&&y.charAt(w.length)==="/"),j={isActive:_,isPending:I,isTransitioning:g},N=_?t:void 0,k;typeof o=="function"?k=o(j):k=[o,_?"active":null,I?"pending":null,g?"transitioning":null].filter(Boolean).join(" ");let O=typeof a=="function"?a(j):a;return l.createElement(la,{...h,"aria-current":N,className:k,ref:m,style:O,to:i,viewTransition:c},typeof d=="function"?d(j):d)});ic.displayName="NavLink";var lc=l.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:o,replace:r,state:a,method:i=ns,action:c,onSubmit:d,relative:h,preventScrollReset:m,viewTransition:u,unstable_defaultShouldRevalidate:x,...f},p)=>{let{unstable_useTransitions:b}=l.useContext(Re),g=fc(),w=pc(c,{relative:h}),v=i.toLowerCase()==="get"?"get":"post",y=typeof c=="string"&&ia.test(c),C=_=>{if(d&&d(_),_.defaultPrevented)return;_.preventDefault();let I=_.nativeEvent.submitter,j=I?.getAttribute("formmethod")||i,N=()=>g(I||_.currentTarget,{fetcherKey:t,method:j,navigate:n,replace:r,state:a,relative:h,preventScrollReset:m,viewTransition:u,unstable_defaultShouldRevalidate:x});b&&n!==!1?l.startTransition(()=>N()):N()};return l.createElement("form",{ref:p,method:v,action:w,onSubmit:o?d:C,...f,"data-discover":!y&&e==="render"?"true":void 0})});lc.displayName="Form";function cc(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ca(e){let t=l.useContext(nn);return Y(t,cc(e)),t}function uc(e,{target:t,replace:n,state:o,preventScrollReset:r,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:c,unstable_useTransitions:d}={}){let h=te(),m=pe(),u=Tn(e,{relative:a});return l.useCallback(x=>{if(Bl(x,t)){x.preventDefault();let f=n!==void 0?n:Nn(m)===Nn(u),p=()=>h(e,{replace:f,state:o,preventScrollReset:r,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:c});d?l.startTransition(()=>p()):p()}},[m,h,u,n,o,t,e,r,a,i,c,d])}function dc(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(Js(e)),n=l.useRef(!1),o=pe(),r=l.useMemo(()=>zl(o.search,n.current?null:t.current),[o.search]),a=te(),i=l.useCallback((c,d)=>{const h=Js(typeof c=="function"?c(new URLSearchParams(r)):c);n.current=!0,a("?"+h,d)},[a,r]);return[r,i]}var hc=0,mc=()=>`__${String(++hc)}__`;function fc(){let{router:e}=ca("useSubmit"),{basename:t}=l.useContext(Re),n=Ll(),o=e.fetch,r=e.navigate;return l.useCallback(async(a,i={})=>{let{action:c,method:d,encType:h,formData:m,body:u}=Ul(a,t);if(i.navigate===!1){let x=i.fetcherKey||mc();await o(x,n,i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:m,body:u,formMethod:i.method||d,formEncType:i.encType||h,flushSync:i.flushSync})}else await r(i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:m,body:u,formMethod:i.method||d,formEncType:i.encType||h,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[o,r,t,n])}function pc(e,{relative:t}={}){let{basename:n}=l.useContext(Re),o=l.useContext(Ue);Y(o,"useFormAction must be used inside a RouteContext");let[r]=o.matches.slice(-1),a={...Tn(e||".",{relative:t})},i=pe();if(e==null){a.search=i.search;let c=new URLSearchParams(a.search),d=c.getAll("index");if(d.some(m=>m==="")){c.delete("index"),d.filter(u=>u).forEach(u=>c.append("index",u));let m=c.toString();a.search=m?`?${m}`:""}}return(!e||e===".")&&r.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Ze([n,a.pathname])),Nn(a)}function xc(e,{relative:t}={}){let n=l.useContext(Xr);Y(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=ca("useViewTransitionState"),r=Tn(e,{relative:t});if(!n.isTransitioning)return!1;let a=et(n.currentLocation.pathname,o)||n.currentLocation.pathname,i=et(n.nextLocation.pathname,o)||n.nextLocation.pathname;return Yt(r.pathname,i)!=null||Yt(r.pathname,a)!=null}var ho=_i(),ua=class extends zr{constructor(e,t){super(),this.options=t,this.#n=e,this.#i=null,this.#a=Uo(),this.bindMethods(),this.setOptions(t)}#n;#e=void 0;#s=void 0;#t=void 0;#o;#r;#a;#i;#p;#h;#m;#c;#u;#l;#f=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),tr(this.#e,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Xs(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Xs(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#y(),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 Ae(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&&!as(this.options,t)&&this.#n.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const o=this.hasListeners();o&&nr(this.#e,n,this.options,t)&&this.#d(),this.updateResult(),o&&(this.#e!==n||Ae(this.options.enabled,this.#e)!==Ae(t.enabled,this.#e)||jn(this.options.staleTime,this.#e)!==jn(t.staleTime,this.#e))&&this.#x();const r=this.#g();o&&(this.#e!==n||Ae(this.options.enabled,this.#e)!==Ae(t.enabled,this.#e)||r!==this.#l)&&this.#v(r)}getOptimisticResult(e){const t=this.#n.getQueryCache().build(this.#n,e),n=this.createResult(t,e);return vc(this,n)&&(this.#t=n,this.#r=this.options,this.#o=this.#e.state),n}getCurrentResult(){return this.#t}trackResult(e,t){return new Proxy(e,{get:(n,o)=>(this.trackProp(o),t?.(o),o==="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,o))})}trackProp(e){this.#f.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(is)),t}#x(){this.#y();const e=jn(this.options.staleTime,this.#e);if(Qs||this.#t.isStale||!Ho(e))return;const n=ki(this.#t.dataUpdatedAt,e)+1;this.#c=Jn.setTimeout(()=>{this.#t.isStale||this.updateResult()},n)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#v(e){this.#w(),this.#l=e,!(Qs||Ae(this.options.enabled,this.#e)===!1||!Ho(this.#l)||this.#l===0)&&(this.#u=Jn.setInterval(()=>{(this.options.refetchIntervalInBackground||Ei.isFocused())&&this.#d()},this.#l))}#b(){this.#x(),this.#v(this.#g())}#y(){this.#c&&(Jn.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(Jn.clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const n=this.#e,o=this.options,r=this.#t,a=this.#o,i=this.#r,d=e!==n?e.state:this.#s,{state:h}=e;let m={...h},u=!1,x;if(t._optimisticResults){const N=this.hasListeners(),k=!N&&tr(e,t),O=N&&nr(e,n,t,o);(k||O)&&(m={...m,...Ri(h.data,e.options)}),t._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:f,errorUpdatedAt:p,status:b}=m;x=m.data;let g=!1;if(t.placeholderData!==void 0&&x===void 0&&b==="pending"){let N;r?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(N=r.data,g=!0):N=typeof t.placeholderData=="function"?t.placeholderData(this.#m?.state.data,this.#m):t.placeholderData,N!==void 0&&(b="success",x=Vo(r?.data,N,t),u=!0)}if(t.select&&x!==void 0&&!g)if(r&&x===a?.data&&t.select===this.#p)x=this.#h;else try{this.#p=t.select,x=t.select(x),x=Vo(r?.data,x,t),this.#h=x,this.#i=null}catch(N){this.#i=N}this.#i&&(f=this.#i,x=this.#h,p=Date.now(),b="error");const w=m.fetchStatus==="fetching",v=b==="pending",y=b==="error",C=v&&w,_=x!==void 0,j={status:b,fetchStatus:m.fetchStatus,isPending:v,isSuccess:b==="success",isError:y,isInitialLoading:C,isLoading:C,data:x,dataUpdatedAt:m.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:m.dataUpdateCount>0||m.errorUpdateCount>0,isFetchedAfterMount:m.dataUpdateCount>d.dataUpdateCount||m.errorUpdateCount>d.errorUpdateCount,isFetching:w,isRefetching:w&&!v,isLoadingError:y&&!_,isPaused:m.fetchStatus==="paused",isPlaceholderData:u,isRefetchError:y&&_,isStale:mo(e,t),refetch:this.refetch,promise:this.#a,isEnabled:Ae(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const N=G=>{j.status==="error"?G.reject(j.error):j.data!==void 0&&G.resolve(j.data)},k=()=>{const G=this.#a=j.promise=Uo();N(G)},O=this.#a;switch(O.status){case"pending":e.queryHash===n.queryHash&&N(O);break;case"fulfilled":(j.status==="error"||j.data!==O.value)&&k();break;case"rejected":(j.status!=="error"||j.error!==O.reason)&&k();break}}return j}updateResult(){const e=this.#t,t=this.createResult(this.#e,this.options);if(this.#o=this.#e.state,this.#r=this.options,this.#o.data!==void 0&&(this.#m=this.#e),as(t,e))return;this.#t=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:o}=this.options,r=typeof o=="function"?o():o;if(r==="all"||!r&&!this.#f.size)return!0;const a=new Set(r??this.#f);return this.options.throwOnError&&a.add("error"),Object.keys(this.#t).some(i=>{const c=i;return this.#t[c]!==e[c]&&a.has(c)})};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.#b()}#j(e){ms.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#t)}),this.#n.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function gc(e,t){return Ae(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function tr(e,t){return gc(e,t)||e.state.data!==void 0&&Xs(e,t,t.refetchOnMount)}function Xs(e,t,n){if(Ae(t.enabled,e)!==!1&&jn(t.staleTime,e)!=="static"){const o=typeof n=="function"?n(e):n;return o==="always"||o!==!1&&mo(e,t)}return!1}function nr(e,t,n,o){return(e!==t||Ae(o.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&mo(e,n)}function mo(e,t){return Ae(t.enabled,e)!==!1&&e.isStaleByTime(jn(t.staleTime,e))}function vc(e,t){return!as(e.getCurrentResult(),t)}var bc=class extends ua{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:Ko()})}getOptimisticResult(e){return e.behavior=Ko(),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,o=super.createResult(e,t),{isFetching:r,isRefetching:a,isError:i,isRefetchError:c}=o,d=n.fetchMeta?.fetchMore?.direction,h=i&&d==="forward",m=r&&d==="forward",u=i&&d==="backward",x=r&&d==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Ti(t,n.data),hasPreviousPage:Li(t,n.data),isFetchNextPageError:h,isFetchingNextPage:m,isFetchPreviousPageError:u,isFetchingPreviousPage:x,isRefetchError:c&&!h&&!u,isRefetching:a&&!m&&!x}}},yc=class extends zr{#n;#e=void 0;#s;#t;constructor(t,n){super(),this.#n=t,this.setOptions(n),this.bindMethods(),this.#o()}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),as(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),n?.mutationKey&&this.options.mutationKey&&Qo(n.mutationKey)!==Qo(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.#o(),this.#r(t)}getCurrentResult(){return this.#e}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#o(),this.#r()}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)}#o(){const t=this.#s?.state??Ai();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}}#r(t){ms.batch(()=>{if(this.#t&&this.hasListeners()){const n=this.#e.variables,o=this.#e.context,r={client:this.#n,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#t.onSuccess?.(t.data,n,o,r)}catch(a){Promise.reject(a)}try{this.#t.onSettled?.(t.data,null,n,o,r)}catch(a){Promise.reject(a)}}else if(t?.type==="error"){try{this.#t.onError?.(t.error,n,o,r)}catch(a){Promise.reject(a)}try{this.#t.onSettled?.(void 0,t.error,n,o,r)}catch(a){Promise.reject(a)}}}this.listeners.forEach(n=>{n(this.#e)})})}},da=l.createContext(void 0),ha=e=>{const t=l.useContext(da);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},wc=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(da.Provider,{value:e,children:t})),ma=l.createContext(!1),Cc=()=>l.useContext(ma);ma.Provider;function jc(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Nc=l.createContext(jc()),Sc=()=>l.useContext(Nc),_c=(e,t,n)=>{const o=n?.state.error&&typeof e.throwOnError=="function"?ro(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=!1))},kc=e=>{l.useEffect(()=>{e.clearReset()},[e])},Ec=({result:e,errorResetBoundary:t,throwOnError:n,query:o,suspense:r})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(r&&e.data===void 0||ro(n,[e.error,o])),Rc=e=>{if(e.suspense){const n=r=>r==="static"?r:Math.max(r??1e3,1e3),o=e.staleTime;e.staleTime=typeof o=="function"?(...r)=>n(o(...r)):n(o),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Lc=(e,t)=>e.isLoading&&e.isFetching&&!t,Tc=(e,t)=>e?.suspense&&t.isPending,sr=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function fa(e,t,n){const o=Cc(),r=Sc(),a=ha(),i=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(i);const c=a.getQueryCache().get(i.queryHash);i._optimisticResults=o?"isRestoring":"optimistic",Rc(i),_c(i,r,c),kc(r);const d=!a.getQueryCache().get(i.queryHash),[h]=l.useState(()=>new t(a,i)),m=h.getOptimisticResult(i),u=!o&&e.subscribed!==!1;if(l.useSyncExternalStore(l.useCallback(x=>{const f=u?h.subscribe(ms.batchCalls(x)):is;return h.updateResult(),f},[h,u]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),l.useEffect(()=>{h.setOptions(i)},[i,h]),Tc(i,m))throw sr(i,h,r);if(Ec({result:m,errorResetBoundary:r,throwOnError:i.throwOnError,query:c,suspense:i.suspense}))throw m.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(i,m),i.experimental_prefetchInRender&&!Qs&&Lc(m,o)&&(d?sr(i,h,r):c?.promise)?.catch(is).finally(()=>{h.updateResult()}),i.notifyOnChangeProps?m:h.trackResult(m)}function we(e,t){return fa(e,ua)}function ne(e,t){const n=ha(),[o]=l.useState(()=>new yc(n,e));l.useEffect(()=>{o.setOptions(e)},[o,e]);const r=l.useSyncExternalStore(l.useCallback(i=>o.subscribe(ms.batchCalls(i)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),a=l.useCallback((i,c)=>{o.mutate(i,c).catch(is)},[o]);if(r.error&&ro(o.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:a,mutateAsync:r.mutate}}function pa(e,t){return fa(e,bc)}const mt="data-sources",xa="auth-user",Ac=e=>we({queryKey:["project","datasources",e],queryFn:async()=>{const{data:t}=await B.get(`/project/team/${e}/datasources`);return t.data},enabled:!!e}),sn=e=>{const t=["project","datasources"],n=["project","saved-queries"];return Promise.all([X.invalidateQueries({queryKey:t}),X.invalidateQueries({queryKey:n})])},Ic=e=>{const t=["trash","team"];return X.invalidateQueries({queryKey:t})},Mc=(e,t)=>we({queryKey:["project","tables",t.teamId,e,t.selectedDataSources],queryFn:async()=>{const{data:n}=await B.get(`/project/team/${t.teamId}/query`,{params:{size:30,search:e,selectedDataSources:t.selectedDataSources}});return n.data},enabled:!!t.teamId,placeholderData:qr}),gs=()=>X.invalidateQueries({queryKey:["project","tables"]}),Pc=(e,t="",n=30,o)=>pa({queryKey:["project","tabs-history",e,n,o,t],queryFn:async({pageParam:r})=>{const a=new URLSearchParams;a.set("nameFilter",t),a.set("size",n.toString()),a.set("page",r.toString());const{data:i}=await B.get(`/project/team/${e}/tabs-history?${a.toString()}`);return i},select:({pages:r})=>r.flatMap(a=>a.data),enabled:!!e,initialPageParam:0,getNextPageParam:(r,a)=>{if(r.hasMore)return a.length},staleTime:0}),Oc=(e,t="",n=20)=>pa({queryKey:["project","saved-queries",e,t,n],queryFn:async({pageParam:o})=>{const r=new URLSearchParams;r.set("nameFilter",t),r.set("size",n.toString()),r.set("page",o.toString());const{data:a}=await B.get(`/project/team/${e}/queries?${r.toString()}`);return a},enabled:!!e,initialPageParam:0,select:({pages:o})=>o.flatMap(r=>r.data),getNextPageParam:(o,r)=>{if(o.hasMore)return r.length}}),Dc=(e,t=10,n=!1)=>we({queryKey:["project","recent-tabs",e,t,n],queryFn:async()=>{const{data:o}=await B.get(`/project/team/${e}/tabs-history?page=0&size=${t}&archived=${n}`);return o.data},enabled:!!e,staleTime:0}),$c=e=>ne({mutationFn:async()=>{const{data:t}=await B.get(`/project/team/${e}/tabs-history?page=0&size=1&archived=false`);return t.data?.length?t.data[0]:void 0}}),Fc=()=>Promise.all([X.invalidateQueries({queryKey:["project","tabs-history"]}),X.invalidateQueries({queryKey:["project","recent-tabs"]})]),Bc=4e3,vs=e=>we({queryKey:[mt,e],queryFn:async()=>{const{data:t}=await B.get("/data-sources/"+e);return t.data},enabled:!!e,refetchInterval:t=>t.state?.data?.status==="INSPECTING"?Bc:!1}),fo=e=>we({queryKey:[mt,e.teamId],queryFn:async()=>{const{data:t}=await B.get("/data-sources",{params:e});return t.data},enabled:e.teamId!==void 0}),bs=e=>we({queryKey:[mt,e,"inspections"],queryFn:async()=>{const{data:t}=await B.get(`/data-sources/${e}/inspections`);return t.data},enabled:!!e}),zc=e=>X.invalidateQueries({queryKey:[mt,e,"inspections"]}),qc=()=>ne({mutationFn:async e=>{const{data:t}=await B.post("/data-sources",e);return t.data},onSuccess:()=>{X.invalidateQueries({queryKey:[mt]}),sn(),gs()}}),Wc=()=>ne({mutationFn:async({dataSource:e,id:t})=>{const{data:n}=await B.put(`/data-sources/${t}`,e);return n.data},onSuccess:()=>{X.invalidateQueries({queryKey:[mt]}),sn(),gs()}}),ga=()=>ne({mutationFn:async e=>{await B.post(`/data-sources/${e}/inspect`)},onSuccess:(e,t)=>{X.invalidateQueries({queryKey:[mt,t]}),gs()}}),Uc=()=>ne({mutationFn:async e=>{await B.delete(`/data-sources/${e}`)},onSuccess:()=>{X.invalidateQueries({queryKey:[mt]}),sn(),gs()}}),va=()=>we({queryKey:["accessToken"],queryFn:fs.get}),Ce=()=>{const{data:e}=va();return we({queryKey:[xa],queryFn:async()=>{const{data:t}=await B.get("/users");return t.data},enabled:!!e,retry:(t,n)=>Ii(n)&&n.code==="ERR_NETWORK"?!1:t<3})},Hc=()=>ne({mutationFn:async e=>{const{data:t}=await B.patch("/users",e);return t.data},onSuccess:async e=>{X.setQueryData([xa],e)}}),Vc=()=>ne({mutationFn:async e=>(await B.post("/users",e),!0),onSuccess:()=>{X.invalidateQueries({queryKey:["team-users"]})}}),xe=e=>{const t=new Set;let n=e;const o=c=>(t.add(c),()=>t.delete(c)),r=c=>(t.forEach(d=>d(c)),!0),a=c=>{n=typeof c=="function"?c(n):c,r(n)},i=c=>()=>c?c(n):n;return[c=>l.useSyncExternalStore(o,i(c),i(c)),a,{get:()=>n,subscribe:c=>(c(n),o(c))}]};function Kc(e,t,n,o){return l.useMemo(()=>({name:n,tabId:o,hooks:e?.result.availableHooks||[],availableJoins:e?.result?.availableJoins||[],allColumns:e?.result.allColumns||[],dataSourceId:t,entities:e?.result.availableEntities||[],getValue:(r,a,i)=>{const c=e?.result.columns?.findIndex(d=>d.table===a&&d.column===i);if(c!=null&&c>-1)return e?.result?.rows[r][c]},getColumnByIndex:r=>e?.result?.columns?.[r],getValueByIndex:(r,a)=>e?.result?.rows[r]?.[a],getEntityKey:(r,a)=>{const i=e?.result?.rows[a],c=e?.result.columns;if(!i||!c)throw new Error("Cannot find entity key");const d={};for(let h=0;h<c.length;h++){const m=c[h];m.table===r&&m.isPrimary&&(d[m.column]=i[h])}return d},getColumnType:r=>{const a=e?.result.allColumns.find(i=>i.full===r);if(a)return a.type}}),[e,t,n,o])}function Qc(e,t){return l.useMemo(()=>({state:e,setState:t}),[e,t])}function Et(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??[],hiddenColumns:e?.hiddenColumns??[],groupBy:e?.groupBy??[],aggregations:e?.aggregations??[]}}function Gc(e,t){return{name:e,path:t,build:r=>{if(typeof r=="object"){let a=t;for(const[i,c]of Object.entries(r))a=a.replace(":"+i,c);return a}return t},check:r=>!!Yt({path:t,end:!0},r)}}function ys(e,t){return{name:e,path:t,build:()=>t,check:n=>n===t}}const Yc=ys("Home","/"),Jc=ys("Workbench","/workbench"),Xc=ys("Share query","/share"),Zc=ys("Login","/login"),eu=Gc("Workbench tab","/workbench/tab/:id"),D={home:Yc,workbench:Jc,share:Xc,login:Zc,workbenchTab:eu},ws=e=>{X.setQueryData(["workbench-tabs"],t=>e(t||[]))},tu=(e,t)=>{X.setQueryData(["workbench-tabs",e],n=>n&&t(n))},Cs=()=>we({queryKey:["workbench-tabs"],queryFn:async()=>{const{data:e}=await B.get("/workbench-tabs");return e.data}}),nu=e=>we({queryKey:["workbench-tabs",e],queryFn:async()=>{const{data:t}=await B.get(`/workbench-tabs/${e}`);return t.data}}),Tt=()=>ne({mutationFn:async e=>{const{data:t}=await B.post("/workbench-tabs",e);return t.data},onSuccess:async e=>{ws(t=>[...t,{id:e.id,name:e.name,orderIndex:e.orderIndex}])}}),su=()=>ne({mutationFn:async({tabId:e,...t})=>(await B.patch(`/workbench-tabs/${e}/archive`,t)).data.data,onSuccess:async e=>{ws(()=>e)}}),ba=()=>ne({mutationFn:async e=>(await B.patch(`/workbench-tabs/${e}/restore`),e),onSuccess:()=>wa()}),ya=()=>ne({mutationFn:async({id:e,payload:t})=>(await B.patch(`/workbench-tabs/${e}`,t),!0),onMutate:({id:e,payload:t})=>{tu(e,n=>({...n,...t})),ws(n=>n.map(o=>o.id!==e?o:{...o,name:t.name||o.name}))}}),ou=(e,t)=>{const{dataSourceId:n,searchAll:o,table:r,filters:a,joins:i,orderBy:c,groupBy:d,hiddenColumns:h,aggregations:m,page:u=0,size:x=20}=t;return we({queryKey:["workbench-tab-runner",e,n,r,u,x,a,m,i,c,d,h,o],queryFn:async()=>{const{data:f}=await B.post(`/workbench-tabs/${e}/run`,t);return f.data},retry:1,enabled:!!r&&!!n,placeholderData:qr})},ru=()=>ne({mutationFn:async e=>{await B.delete(`/workbench-tabs/${e}`)},onSuccess:()=>{wa(),Fc()}}),po=e=>X.invalidateQueries({queryKey:["workbench-tab-runner",e]}),wa=()=>X.invalidateQueries({queryKey:["workbench-tabs"]}),[au,Fs,iu]=xe(void 0),lu=async()=>new Promise(e=>{Fs({onCancel:()=>{Fs(void 0),e(void 0)},onConfirm:(t,n,o)=>{Fs(void 0),e({dsId:o,id:n,type:t})}})}),An=()=>{const e=te(),t=Tt(),n=ba();return l.useCallback(()=>{iu.get()||lu().then(r=>{r?.type==="table"?t.mutateAsync({name:r.id,opts:Et({table:r.id,dataSourceId:r.dsId})}).then(a=>{e(D.workbenchTab.build({id:a.id}))}):r?.type==="query"?t.mutateAsync({queryId:r.id}).then(a=>{e(D.workbenchTab.build({id:a.id}))}):r?.type==="tab"&&(n.mutate(r.id),e(D.workbenchTab.build({id:r.id})))})},[])},Ca=[{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:"like"},{value:"NOT LIKE",label:"not like"},{value:"CONTAINS",label:"contains"},{value:"NOT CONTAINS",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"}],cu=Ca.reduce((e,t)=>(e[t.value]=t.label,e),{});Ca.reduce((e,t)=>(e[t.label]=t.value,e),{});const on=e=>e.map(t=>({label:cu[t],value:t}));on(["=","<>",">",">=","<","<=","IN","NOT IN","IS NULL","IS NOT NULL"]);on(["=","<>","LIKE","NOT LIKE","IN","NOT IN","IS NULL","IS NOT NULL","CONTAINS","NOT CONTAINS"]);on(["=","<>","IS NULL","IS NOT NULL"]);on(["=","<>",">",">=","<","<=","IS NULL","IS NOT NULL"]);on(["IS NULL","IS NOT NULL"]);on(["IN","NOT IN"]);const uu=["char","varchar","binary","varbinary","blob","text","enum","set","character","character varying","text","citext","uuid","xml","json","jsonb"];new Set(uu);const du=["integer","smallint","decimal","numeric","float","real","double precision","int","smallint","integer","bigint","decimal","numeric","real","double precision","serial","bigserial","money"];new Set(du);const hu=["date","datetime","timestamp","timestamptz"].reduce((e,t)=>(e[t]=!0,e),{}),mu=e=>e.fn?e.distinct===!0?`${e.fn} distinct ${e.value}`:`${e.fn} ${e.value}`:e.value;var fe=(e=>(e.OWNER="owner",e.ADMIN="admin",e.EDITOR="editor",e.READ_ONLY="read_only",e))(fe||{});const or={[fe.READ_ONLY]:10,[fe.EDITOR]:20,[fe.ADMIN]:30,[fe.OWNER]:40},fu=e=>`${e.fromTable}.${e.fromColumn} = ${e.toTable}.${e.toColumn}`,In=e=>{const{data:t}=Ce();return l.useMemo(()=>t?or[t.teamRole]>=or[e]:!1,[t,e])},pu="_input_oj0zm_2",xu="_label_oj0zm_2",gu="_content_oj0zm_2",vu="_form_oj0zm_2",bu="_header_oj0zm_2",yu="_mode-select_oj0zm_2",wu="_selected_oj0zm_2",Cu="_mode-container_oj0zm_2",Fe={input:pu,label:xu,content:gu,form:vu,header:bu,modeSelect:yu,selected:wu,modeContainer:Cu},ju="_modal_jsvt5_2",Nu="_modal-visible_jsvt5_2",Su="_modal-invisible_jsvt5_2",_u="_backdrop_jsvt5_2",ku="_modal-container_jsvt5_2",Eu="_close-button_jsvt5_2",Qt={modal:ju,modalVisible:Nu,modalInvisible:Su,backdrop:_u,modalContainer:ku,closeButton:Eu},tt=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"}));let os=[];const Ru=e=>{const t=Symbol();return os.push({id:t,listener:e}),()=>{os=os.filter(n=>n.id!==t)}};window.addEventListener("keydown",e=>{if(e.key!=="Escape")return;const t=os.pop();t&&(e.preventDefault(),e.stopPropagation(),t.listener())});const js=e=>{const t=l.useRef(e.onClose);t.current=e.onClose,l.useEffect(()=>{if(e.enabled)return Ru(()=>{t.current()})},[e.enabled])},Le=({children:e,backdropClose:t,isVisible:n,onClose:o,onClosed:r,noPadding:a=!1,portal:i=!0})=>{const[c,d]=l.useState(!1),h=()=>{t&&o()},m=x=>{n||getComputedStyle(x.currentTarget).opacity==="0"&&(d(!1),r&&r())};l.useEffect(()=>{n&&d(!0)},[n]),js({onClose:h,enabled:n&&t===!0});const u=s.jsxs("div",{onTransitionEnd:m,className:A(Qt.modal,n?Qt.modalVisible:Qt.modalInvisible),children:[s.jsx("div",{onClick:h,className:Qt.backdrop}),s.jsx("div",{className:A(Qt.modalContainer,a!==!0&&"p-4"),children:c&&e})]});return i?ho.createPortal(u,document.body):u},rn=({onClick:e})=>{const t=l.useRef(e);return t.current=e,s.jsx("button",{className:Qt.closeButton,onClick:e,children:s.jsx(tt,{width:20,height:20})})},ja=({children:e})=>s.jsx("h2",{className:"text-xl font-semibold",children:e}),Lu=({form:e,change:t,shape:n})=>s.jsx("div",{className:Fe.form,children:n.fields.map(o=>s.jsxs("label",{className:Fe.input,children:[s.jsx("p",{className:Fe.label,children:o.label}),s.jsx("input",{value:e[o.name],onChange:t(o.name),type:o.type})]},o.name))}),Tu=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"})),Au=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"}})),He=({size:e,type:t})=>t==="mysql"?s.jsx(Tu,{width:e,height:e}):s.jsx(Au,{width:e,height:e}),Iu={mysql:"MySQL",postgres:"PostgreSQL"},Mu={fields:[{label:"Database URL",name:"dbUrl",type:"text"},{label:"Database port",name:"dbPort",type:"number"},{label:"Username",name:"dbUser",type:"text"},{label:"Password",name:"dbPassword",type:"password"},{label:"Database",name:"dbDatabase",type:"text"}]},Pu={fields:[{label:"Database URL",name:"dbUrl",type:"text"},{label:"Database port",name:"dbPort",type:"number"},{label:"Username",name:"dbUser",type:"text"},{label:"Password",name:"dbPassword",type:"password"},{label:"Database",name:"dbDatabase",type:"text"},{label:"Schema",name:"dbSchema",type:"text"}]},Ou=({show:e,onClose:t,dbType:n="postgres"})=>{const o=qc(),r=ga(),{data:a}=Ce(),[i,{change:c,set:d}]=En({name:"",dbType:n,dbUrl:"",dbUser:"",dbPassword:"",dbDatabase:"",dbSchema:"",dbPort:n==="mysql"?3306:5432,teamId:"",ownerId:"",description:"",allowInsert:!1,allowUpdate:!1}),h=async()=>{const f=await o.mutateAsync({...i,dbPort:Number(i.dbPort),teamId:a.teamId,ownerId:a.id});await r.mutateAsync(f.id),t()},m=f=>{d("allowInsert",!f),d("allowUpdate",!f)},u=o.isPending||r.isPending,x=!i.allowInsert&&!i.allowUpdate;return s.jsxs(Le,{isVisible:e,onClose:t,portal:!0,children:[s.jsxs("div",{className:"max-w-xl mx-auto overflow-y-auto",children:[s.jsxs("div",{className:Fe.header,children:[s.jsx(He,{size:24,type:n}),s.jsx("p",{className:"text-(--text-color-primary) font-semibold",children:Iu[n]})]}),o.isError&&s.jsx(ve,{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."})}),o.isPending&&s.jsx(ve,{className:"mb-2",variant:"info",children:"Creating connection"}),r.isPending&&s.jsx(ve,{className:"mb-2",variant:"info",children:"Inspecting connection"}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("div",{className:Fe.content,children:[s.jsxs("div",{className:"flex flex-col",children:[s.jsx("label",{className:"text-sm font-semibold mb-2",htmlFor:"datasource-name",children:"Name"}),s.jsx("input",{value:i.name,onChange:c("name"),id:"datasource-name",className:"input",placeholder:"Data source name",disabled:u})]}),s.jsx("p",{className:"text-sm font-semibold mt-2",children:"Configuration"}),s.jsx(Lu,{form:i,change:c,shape:i.dbType==="mysql"?Mu:Pu})]}),s.jsx("p",{className:"text-sm font-semibold mt-4",children:"Connection mode"}),s.jsxs("div",{className:Fe.modeContainer,children:[s.jsxs("label",{onClick:()=>m(!0),className:A(Fe.modeSelect,x&&Fe.selected),children:[s.jsxs("span",{className:"text-sm font-semibold text-(--text-color-primary)",children:[s.jsx("input",{type:"radio",disabled:u,checked:x,className:"mr-2"}),"Read-only mode"]}),s.jsxs("p",{className:"text-sm mt-1 text-(--text-color-primary)",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",{onClick:()=>m(!1),className:A(Fe.modeSelect,!x&&Fe.selected),children:[s.jsxs("span",{className:"text-sm font-semibold text-(--text-color-primary)",children:[s.jsx("input",{type:"radio",disabled:u,checked:!x,className:"mr-2"}),"Read/Write mode"]}),s.jsxs("p",{className:"text-sm mt-1 text-(--text-color-primary)",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:t,className:"button tertiary",disabled:u,children:"Cancel"}),s.jsx("button",{onClick:h,className:"button primary",disabled:u,children:"Create"})]})]})},Du="_data-source-entry_11ryl_2",$u="_action-title_11ryl_2",Fu="_recent-tabs-container_11ryl_2",Bu="_recent-tabs-entry_11ryl_2",zu="_home-action-button_11ryl_2",qu="_home-gray-card_11ryl_2",Wu="_home-card-title_11ryl_2",Uu="_home-card-grid-content_11ryl_2",Hu="_useful-links_11ryl_2",Q={dataSourceEntry:Du,actionTitle:$u,recentTabsContainer:Fu,recentTabsEntry:Bu,homeActionButton:zu,homeGrayCard:qu,homeCardTitle:Wu,homeCardGridContent:Uu,usefulLinks:Hu},[Vu,Mn]=xe({show:!1}),[Ku,Jt]=xe({show:!1}),[Qu,Sn]=xe(void 0),Gu=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M256 32C132.3 32 32 134.9 32 261.7c0 101.5 64.2 187.5 153.2 217.9a17.56 17.56 0 003.8.4c8.3 0 11.5-6.1 11.5-11.4 0-5.5-.2-19.9-.3-39.1a102.4 102.4 0 01-22.6 2.7c-43.1 0-52.9-33.5-52.9-33.5-10.2-26.5-24.9-33.6-24.9-33.6-19.5-13.7-.1-14.1 1.4-14.1h.1c22.5 2 34.3 23.8 34.3 23.8 11.2 19.6 26.2 25.1 39.6 25.1a63 63 0 0025.6-6c2-14.8 7.8-24.9 14.2-30.7-49.7-5.8-102-25.5-102-113.5 0-25.1 8.7-45.6 23-61.6-2.3-5.8-10-29.2 2.2-60.8a18.64 18.64 0 015-.5c8.1 0 26.4 3.1 56.6 24.1a208.21 208.21 0 01112.2 0c30.2-21 48.5-24.1 56.6-24.1a18.64 18.64 0 015 .5c12.2 31.6 4.5 55 2.2 60.8 14.3 16.1 23 36.6 23 61.6 0 88.2-52.4 107.6-102.3 113.3 8 7.1 15.2 21.1 15.2 42.5 0 30.7-.3 55.5-.3 63 0 5.4 3.1 11.5 11.4 11.5a19.35 19.35 0 004-.4C415.9 449.2 480 363.1 480 261.7 480 134.9 379.7 32 256 32z"})),Yu=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M227.6 213.1H256v57.1h-28.4z"}),l.createElement("path",{d:"M0 156v171.4h142.2V356H256v-28.6h256V156zm142.2 142.9h-28.4v-85.7H85.3v85.7H28.4V184.6h113.8zm142.2 0h-56.9v28.6h-56.9V184.6h113.8zm199.2 0h-28.4v-85.7h-28.4v85.7h-28.4v-85.7H370v85.7h-56.9V184.6h170.7v114.3z"})),Ju=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M416 221.25V416a48 48 0 01-48 48H144a48 48 0 01-48-48V96a48 48 0 0148-48h98.75a32 32 0 0122.62 9.37l141.26 141.26a32 32 0 019.37 22.62z",fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M256 56v120a32 32 0 0032 32h120M176 288h160M176 368h160",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),Xu=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M336 208v-95a80 80 0 00-160 0v95",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("rect",{x:96,y:208,width:320,height:272,rx:48,ry:48,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),Pn=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"})),Ns=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M380.93 57.37A32 32 0 00358.3 48H94.22A46.21 46.21 0 0048 94.22v323.56A46.21 46.21 0 0094.22 464h323.56A46.36 46.36 0 00464 417.78V153.7a32 32 0 00-9.37-22.63zM256 416a64 64 0 1164-64 63.92 63.92 0 01-64 64zm48-224H112a16 16 0 01-16-16v-64a16 16 0 0116-16h192a16 16 0 0116 16v64a16 16 0 01-16 16z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),Na=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M145.61 464h220.78c19.8 0 35.55-16.29 33.42-35.06C386.06 308 304 310 304 256s83.11-51 95.8-172.94c2-18.78-13.61-35.06-33.41-35.06H145.61c-19.8 0-35.37 16.28-33.41 35.06C124.89 205 208 201 208 256s-82.06 52-95.8 172.94c-2.14 18.77 13.61 35.06 33.41 35.06z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M343.3 432H169.13c-15.6 0-20-18-9.06-29.16C186.55 376 240 356.78 240 326V224c0-19.85-38-35-61.51-67.2-3.88-5.31-3.49-12.8 6.37-12.8h142.73c8.41 0 10.23 7.43 6.4 12.75C310.82 189 272 204.05 272 224v102c0 30.53 55.71 47 80.4 76.87 9.95 12.04 6.47 29.13-9.1 29.13z",fill:"currentColor"})),Sa=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M436.67 184.11a27.17 27.17 0 01-38.3 0l-22.48-22.49a27.15 27.15 0 010-38.29l50.89-50.89a.85.85 0 00-.26-1.38C393.68 57 351.09 64.15 324.05 91c-25.88 25.69-27.35 64.27-17.87 98a27 27 0 01-7.67 27.14l-173 160.76a40.76 40.76 0 1057.57 57.54l162.15-173.3a27 27 0 0126.77-7.7c33.46 8.94 71.49 7.26 97.07-17.94 27.49-27.08 33.42-74.94 20.1-102.33a.85.85 0 00-1.36-.22z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32}),l.createElement("path",{d:"M224 284c-17.48-17-25.49-24.91-31-30.29a18.24 18.24 0 01-3.33-21.35 20.76 20.76 0 013.5-4.62l15.68-15.29a18.66 18.66 0 015.63-3.87 18.11 18.11 0 0120 3.62c5.45 5.29 15.43 15 33.41 32.52M317.07 291.3c40.95 38.1 90.62 83.27 110 99.41a13.46 13.46 0 01.94 19.92L394.63 444a14 14 0 01-20.29-.76c-16.53-19.18-61.09-67.11-99.27-107",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M17.34 193.5l29.41-28.74a4.71 4.71 0 013.41-1.35 4.85 4.85 0 013.41 1.35h0a9.86 9.86 0 008.19 2.77c3.83-.42 7.92-1.6 10.57-4.12 6-5.8-.94-17.23 4.34-24.54a207 207 0 0119.78-22.6c6-5.88 29.84-28.32 69.9-44.45A107.31 107.31 0 01206.67 64c22.59 0 40 10 46.26 15.67a89.54 89.54 0 0110.28 11.64 78.92 78.92 0 00-9.21-2.77 68.82 68.82 0 00-20-1.26c-13.33 1.09-29.41 7.26-38 14-13.9 11-19.87 25.72-20.81 44.71-.68 14.12 2.72 22.1 36.1 55.49a6.6 6.6 0 01-.34 9.16l-18.22 18a6.88 6.88 0 01-9.54.09c-21.94-21.94-36.65-33.09-45-38.16s-15.07-6.5-18.3-6.85a30.85 30.85 0 00-18.27 3.87 11.39 11.39 0 00-2.64 2 14.14 14.14 0 00.42 20.08l1.71 1.6a4.63 4.63 0 010 6.64L71.73 246.6a4.71 4.71 0 01-3.41 1.4 4.86 4.86 0 01-3.41-1.35l-47.57-46.43a4.88 4.88 0 010-6.72z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),rr=20,Ss="text-(--text-color-primary)",Zu=A(Q.homeActionButton,"md:col-span-3"),ed=()=>{const e=An();return s.jsxs("div",{className:Zu,onClick:e,children:[s.jsx(Pn,{width:rr,height:rr,className:Ss}),s.jsx("h2",{className:Q.actionTitle,children:"Start new query"})]})},td=()=>s.jsxs("div",{className:Q.homeActionButton,onClick:()=>Mn({show:!0}),children:[s.jsx(Ns,{width:20,height:20,className:Ss}),s.jsx("h2",{className:Q.actionTitle,children:"Saved queries"})]}),nd=()=>s.jsxs("div",{className:Q.homeActionButton,onClick:()=>Jt({show:!0}),children:[s.jsx(Na,{width:20,height:20,className:Ss}),s.jsx("h2",{className:Q.actionTitle,children:"Recent tabs"})]}),sd={mysql:"MySQL",postgres:"PostgreSQL"},ar=({dbType:e})=>{const[t,n]=l.useState(void 0),o=In(fe.EDITOR),r=a=>{o?n(a):ue.error("You don't have permission to connect new data sources in this team")};return s.jsxs("div",{children:[t&&s.jsx(Ou,{show:!0,dbType:t,onClose:()=>n(void 0)}),s.jsxs("div",{className:Q.homeActionButton,onClick:()=>r(e),children:[s.jsx(He,{size:24,type:e}),s.jsx("p",{className:Q.actionTitle,children:sd[e]})]})]})},od=()=>s.jsxs("div",{className:Q.homeGrayCard,children:[s.jsx("h2",{className:Q.homeCardTitle,children:"Connect new data source"}),s.jsxs("div",{className:Q.homeCardGridContent,children:[s.jsx(ar,{dbType:"mysql"}),s.jsx(ar,{dbType:"postgres"})]})]}),rd=()=>{const e=te(),{data:t}=Cs(),n=An(),o=()=>{t&&t.length>0?e(D.workbenchTab.build({id:t[0].id})):n()};return s.jsxs("div",{className:Q.homeActionButton,onClick:o,children:[s.jsx(Sa,{width:20,height:20,className:Ss}),s.jsx("h2",{className:Q.actionTitle,children:"Workbench"})]})},ad=()=>{const{data:e}=Ce(),{data:t}=fo({teamId:e?.teamId});return!t||t.length===0?null:s.jsxs("div",{className:Q.homeGrayCard,children:[s.jsx("h2",{className:Q.homeCardTitle,children:"Data sources"}),s.jsx("div",{className:Q.homeCardGridContent,children:t?.map(n=>s.jsxs("div",{className:Q.dataSourceEntry,onClick:()=>Sn(n.id),tabIndex:0,children:[!n.allowInsert&&s.jsx(Xu,{"data-tooltip-id":"default","data-tooltip-content":"This datasource is read-only",width:18,height:18,className:"absolute top-2 right-2"}),s.jsx(He,{size:32,type:n.dbType}),s.jsxs("div",{className:"overflow-hidden",children:[s.jsx("p",{className:"text-(--text-color-primary) font-semibold truncate",children:n.name}),s.jsxs("p",{className:"text-sm text-(--text-color-secondary) truncate",children:[n.dbUrl,":",n.dbPort]})]})]},n.id))})]})},Ht=24,_a=()=>s.jsxs("div",{className:Q.usefulLinks,children:[s.jsxs("a",{href:"https://dataramen.xyz/",target:"_blank",children:[s.jsx(Ju,{width:Ht,height:Ht}),s.jsx("span",{children:"Docs"})]}),s.jsxs("a",{href:"https://github.com/OleksandrDemian/dataramen",target:"_blank",children:[s.jsx(Gu,{width:Ht,height:Ht}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:"https://www.npmjs.com/package/@dataramen/cli",target:"_blank",children:[s.jsx(Yu,{width:Ht,height:Ht}),s.jsx("span",{children:"NPM"})]})]}),id=()=>{const{data:e}=Ce(),{data:t,isLoading:n}=Dc(e?.teamId),o=te();if(n||!t?.length)return null;const r=a=>{o(D.workbenchTab.build({id:a}))};return s.jsxs("div",{className:Q.recentTabsContainer,children:[s.jsx("h2",{className:Q.homeCardTitle+" px-4 mb-4",children:"Active tabs"}),t.map(a=>s.jsxs("div",{className:Q.recentTabsEntry,onClick:()=>r(a.id),children:[s.jsx("p",{className:"text-(--text-color-primary) truncate",children:a.name}),s.jsxs("p",{className:"flex items-center gap-2",children:[s.jsx(He,{size:20,type:a.dataSourceType}),s.jsx("span",{className:"text-sm text-(--text-color-secondary) truncate",children:a.dataSourceName})]})]},a.id))]})},ye=(e,t)=>e!=null&&e>t,xo=(e,t)=>e!=null&&e<t,ld=()=>{const{data:e}=Ce(),{data:t,isLoading:n}=fo({teamId:e?.teamId}),o=!n&&xo(t?.length,1),r=!!e;return s.jsx("div",{className:"page-container h-screen max-h-screen overflow-y-auto no-scrollbar",children:s.jsxs("div",{className:"page-content",children:[s.jsxs("div",{className:"py-10 text-center w-full sticky top-0 z-0",children:[s.jsx("h1",{className:"comfortaa text-3xl font-semibold text-(--text-color-primary) mb-4",children:"DataRamen"}),s.jsx(_a,{})]}),s.jsxs("div",{className:"flex flex-col gap-8 mt-8 bg-(--bg) z-1",children:[o&&s.jsx(ve,{variant:"warning",className:"font-semibold",children:"Connect at least one data source to start using DataRamen"}),s.jsxs("div",{className:Q.homeGrayCard,children:[s.jsx("h2",{className:Q.homeCardTitle,children:"Quick actions"}),s.jsxs("div",{className:Q.homeCardGridContent,children:[s.jsx(ed,{}),s.jsx(td,{}),s.jsx(nd,{}),r&&s.jsx(rd,{})]})]}),r&&s.jsx(ad,{}),s.jsx(od,{}),s.jsx(id,{})]})]})})},[cd,Bs]=xe(void 0),go=async e=>new Promise(t=>{Bs({message:e,onCancel:()=>{t(!1),Bs(void 0)},onConfirm:()=>{t(!0),Bs(void 0)}})}),ud=({confirm:e})=>s.jsxs("div",{className:"max-w-sm",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"})]})]}),dd=()=>{const e=cd(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(Le,{isVisible:!!e,onClose:()=>e?.onCancel(),onClosed:()=>n(void 0),children:t&&s.jsx(ud,{confirm:t})})},[hd,St]=xe(void 0),On=async(e,t)=>new Promise(n=>{St({message:e,defaultValue:t,onCancel:()=>{St(void 0),n(void 0)},onConfirm:o=>{St(void 0),n(o)},type:"string"})}),md=async(e,t)=>new Promise(n=>{St({message:e,defaultValue:t,onCancel:()=>{St(void 0),n(void 0)},onConfirm:o=>{St(void 0),n(o)},type:"query-expression"})}),fd="_root_ng9lp_1",ka={root:fd},pd="_root_3rkw5_2",xd="_input_3rkw5_2",ir={root:pd,input:xd},gd=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M315.27 33L96 304h128l-31.51 173.23a2.36 2.36 0 002.33 2.77h0a2.36 2.36 0 001.89-.95L416 208H288l31.66-173.25a2.45 2.45 0 00-2.44-2.75h0a2.42 2.42 0 00-1.95 1z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),vd=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:26,fill:"currentColor"}),l.createElement("circle",{cx:346,cy:256,r:26,fill:"currentColor"}),l.createElement("circle",{cx:166,cy:256,r:26,fill:"currentColor"}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M160 368L32 256l128-112M352 368l128-112-128-112"})),Ea=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M448 341.37V170.61A32 32 0 00432.11 143l-152-88.46a47.94 47.94 0 00-48.24 0L79.89 143A32 32 0 0064 170.61v170.76A32 32 0 0079.89 369l152 88.46a48 48 0 0048.24 0l152-88.46A32 32 0 00448 341.37z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M69 153.99l187 110 187-110M256 463.99v-200"})),lr=(e,t)=>{const n=t.indexOf(e);return n>=t.length?t[0]:t[n+1]},bd=(e,t)=>{const n=t.indexOf(e);return n<=0?t[t.length-1]:t[n-1]},yd=({mode:e,onNextMode:t})=>s.jsxs("span",{tabIndex:-1,className:"pr-2 cursor-pointer text-(--text-color-primary)",onClick:t,"data-mode":e,"data-tooltip-id":"default","data-tooltip-content":`Current mode: ${e}. Use up/down arrows to change input mode.`,children:[e==="advanced"&&s.jsx(gd,{className:"pointer-events-none",width:20,height:20}),e==="raw"&&s.jsx(vd,{className:"pointer-events-none",width:20,height:20}),e==="default"&&s.jsx(Ea,{className:"pointer-events-none",width:20,height:20})]}),Dn=({prefix:e,mode:t="default",allowedModes:n,className:o,inputClass:r,onExpressionChange:a,...i})=>{const c=h=>{a({mode:t,value:h.currentTarget.value})},d=h=>{h.key==="ArrowDown"||h.key==="ArrowUp"?(h.preventDefault(),h.stopPropagation(),a({mode:h.key==="ArrowUp"?lr(t,n):bd(t,n),value:i.value})):i.onKeyDown?.(h)};return s.jsxs("label",{className:A(ir.root,o),"data-input-mode":t,children:[t==="raw"&&!!e&&s.jsx("span",{className:"inline-block pl-1",children:e}),s.jsx("input",{...i,onKeyDown:d,onChange:c,className:A(ir.input,r)}),s.jsx(yd,{mode:t,onNextMode:()=>a({mode:lr(t,n),value:i.value})})]})},$n=["default","raw"],wd=({data:e})=>{const[t,n]=l.useState("");l.useEffect(()=>{e.defaultValue&&n(e.defaultValue)},[e]);const o=a=>{n(a.target.value)},r=a=>{a.key==="Enter"&&(a.preventDefault(),e.onConfirm(t)),a.key==="Escape"&&(a.preventDefault(),e.onCancel())};return s.jsxs("div",{className:ka.root,children:[s.jsx("h2",{className:"text-xl font-semibold",children:e.message}),s.jsx("input",{autoFocus:!0,className:"w-full input my-2",value:t,onChange:o,onKeyDown:r}),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"})]})]})},Cd=({data:e})=>{const[t,n]=l.useState({mode:"default",value:e.defaultValue||""}),o=r=>{r.key==="Enter"&&(r.preventDefault(),e.onConfirm(t)),r.key==="Escape"&&(r.preventDefault(),e.onCancel())};return s.jsxs("div",{className:ka.root,children:[s.jsx("h2",{className:"text-xl font-semibold",children:e.message}),s.jsx(Dn,{prefix:"_",autoFocus:!0,className:"w-full my-2 h-8",value:t.value,mode:t.mode,onExpressionChange:n,allowedModes:$n,onKeyDown:o,placeholder:"Filter value"}),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"})]})]})},jd=()=>{const e=hd(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsxs(Le,{isVisible:!!e,onClose:()=>St(void 0),onClosed:()=>n(void 0),children:[t?.type==="string"&&s.jsx(wd,{data:t}),t?.type==="query-expression"&&s.jsx(Cd,{data:t})]})},[Nd,Ra]=xe(void 0),Sd=e=>{Ra(e)},cr=()=>{Ra(void 0)},_d="_textarea_13uys_2",kd={textarea:_d},Ed=()=>{const e=Nd(),t=()=>{e&&(navigator.clipboard.writeText(e.toString()),ue.success("Copied!"))};return s.jsxs(Le,{isVisible:!!e,onClose:cr,backdropClose:!0,children:[s.jsx("textarea",{className:kd.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:cr,children:"Close"})]})]})},Rd="_tabs_73i7z_2",Ld="_mobile_73i7z_2",Td="_menu_73i7z_2",Ad="_item_73i7z_2",Id="_tab_73i7z_2",Md="_active_73i7z_2",Pd="_close-button_73i7z_2",$e={tabs:Rd,mobile:Ld,menu:Td,item:Ad,tab:Id,active:Md,closeButton:Pd},ur=e=>window.matchMedia(e).matches;function La(e,{defaultValue:t=!1,initializeWithValue:n=!0}={}){const[o,r]=l.useState(()=>n?ur(e):t);return l.useLayoutEffect(()=>{const a=window.matchMedia(e);function i(){r(()=>ur(e))}return i(),a.addListener?a.addListener(i):a.addEventListener("change",i),()=>{a.removeListener?a.removeListener(i):a.removeEventListener("change",i)}},[e]),o}const vo={laptop:"(min-width: 1024px)"},Ta=()=>window.matchMedia(vo.laptop).matches,bo=e=>l.useMemo(()=>{if(e)return e instanceof Mi?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]);function ct(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 rs=e=>e.distinct?[e.fn,"DISTINCT",e.value].join(" "):[e.fn,e.value].join(" "),Od="_table_zkla1_2",Dd="_row-index-btn_zkla1_2",$d="_semi-transparent_zkla1_2",Fd="_table-loading_zkla1_2",Bd="_table-empty_zkla1_2",zd="_table-row-cells_zkla1_2",qd="_header-cell_zkla1_2",Wd="_header-actions_zkla1_2",Ud="_cell_zkla1_2",Hd="_value_zkla1_2",Vd="_table-config_zkla1_2",Kd="_table-action_zkla1_2",Qd="_data-source_zkla1_2",Gd="_gray_zkla1_2",Yd="_modal_zkla1_2",Jd="_selected-size_zkla1_2",Xd="_pagination-indicator_zkla1_2",L={table:Od,rowIndexBtn:Dd,semiTransparent:$d,tableLoading:Fd,tableEmpty:Bd,tableRowCells:zd,headerCell:qd,headerActions:Wd,cell:Ud,value:Hd,tableConfig:Vd,tableAction:Kd,dataSource:Qd,gray:Gd,modal:Yd,selectedSize:Jd,paginationIndicator:Xd},Pe=l.createContext({name:"No name",hooks:[],availableJoins:[],allColumns:[],dataSourceId:"",entities:[],getValue:()=>{},getValueByIndex:()=>{},getColumnByIndex:()=>{},getEntityKey:()=>{},getColumnType:()=>{}}),je=l.createContext({state:Et({}),setState:()=>{}}),nt=l.createContext({}),Aa={ON_ANIMATION_END:Symbol("ON_TRANSITION_END")},Ia=()=>{const[e,t]=l.useState(),[n,o]=l.useState("hidden");return l.useMemo(()=>{const r=c=>{c.preventDefault(),o("in"),t({x:c.clientX-1,y:c.clientY-1})},a=()=>{o("out")},i=()=>{n==="in"?o("visible"):n==="out"&&(t(void 0),o("hidden"))};return{show:!!e,position:e,state:n,open:r,close:a,[Aa.ON_ANIMATION_END]:i}},[e,n])},Zd=e=>{if(e!=="ASC")return e==="DESC"?"ASC":"DESC"},eh=()=>{const{state:e,setState:t}=l.useContext(je),n=l.useCallback(o=>{t(r=>{const a=r.orderBy[0];if(a&&a.column===o){const i=Zd(a.direction);return i?{...r,orderBy:[{column:o,direction:i}]}:{...r,orderBy:[]}}return{...r,orderBy:[{column:o,direction:"DESC"}]}})},[t]);return{orderBy:e.orderBy,updateOrderBy:n}},th="_options-container_11mcd_2",nh="_filter-input_11mcd_2",sh="_list_11mcd_2",oh="_empty-text_11mcd_2",_t={optionsContainer:th,filterInput:nh,list:sh,emptyText:oh},rh="_container_h6raj_2",ah="_animate-show_h6raj_2",ih="_animate-hide_h6raj_2",lh="_content_h6raj_2",ch="_backdrop_h6raj_2",yt={container:rh,animateShow:ah,animateHide:ih,content:lh,backdrop:ch},Ma=({children:e,handler:t})=>{const n=l.useRef(t.close);n.current=t.close;const o=l.useMemo(()=>{if(!t.position)return;const a={};if(typeof window<"u"){const i=t.position.y>window.innerHeight/2,c=t.position.x>window.innerWidth/2;i?a.bottom=window.innerHeight-t.position.y:a.top=t.position.y,Ta()?c?a.right=window.innerWidth-t.position.x:a.left=t.position.x:(a.right=36,a.left=36)}return a},[t.position]);if(js({enabled:!!o,onClose:t.close}),!o)return null;const r=s.jsxs("div",{className:A(yt.container,t.state==="out"&&yt.animateHide,t.state==="in"&&yt.animateShow),onAnimationEnd:t[Aa.ON_ANIMATION_END],children:[s.jsx("div",{className:yt.backdrop,onClick:a=>{a.stopPropagation(),a.preventDefault(),t.close()}}),s.jsx("div",{className:A(yt.content,t.state==="out"&&yt.animateHide,t.state==="in"&&yt.animateShow),style:o,children:e})]});return ho.createPortal(r,document.body)},qe=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),uh="_container_eel9a_2",dh={container:uh},an=({containerClassName:e,className:t,...n})=>s.jsxs("label",{className:A(dh.container,e),children:[s.jsx(Pn,{width:16,height:16}),s.jsx("input",{className:A("flex-1 outline-none",t),...n})]}),hh="_root_1g07i_2",mh="_content_1g07i_2",fh="_table-name_1g07i_2",ph="_sub_1g07i_2",rt={root:hh,content:mh,tableName:fh,sub:ph},yo=({hook:e,onClick:t})=>e.direction==="out"?s.jsx("button",{className:rt.root,onClick:t,children:s.jsxs("div",{className:rt.content,children:[s.jsx("p",{className:rt.tableName,children:e.toTable}),s.jsxs("p",{className:rt.sub,children:[e.toColumn," = ",e.fromTable,".",e.fromColumn]})]})},e.id):s.jsx("button",{className:rt.root,onClick:t,children:s.jsxs("div",{className:rt.content,children:[s.jsx("p",{className:rt.tableName,children:e.fromTable}),s.jsxs("p",{className:rt.sub,children:[e.fromColumn," = ",e.toTable,".",e.toColumn]})]})},e.id);function xh(e,t,n,o){if(e.direction==="out"){const a=o(n,e.fromTable,e.fromColumn);return{name:`${e.toTable} ${e.toColumn} equals ${a}`,opts:Et({table:e.toTable,dataSourceId:t,filters:[{id:qe(),column:`${e.toTable}.${e.toColumn}`,value:a==null?"IS NULL":`${a}`,isEnabled:!0}]})}}const r=o(n,e.toTable,e.toColumn);return{name:`${e.fromTable} ${e.fromColumn} equals ${r}`,opts:Et({table:e.fromTable,dataSourceId:t,filters:[{id:qe(),column:`${e.fromTable}.${e.fromColumn}`,value:r==null?"IS NULL":`${r}`,isEnabled:!0}]})}}const Pa=({rowIndex:e,colIndex:t,onClose:n,className:o})=>{const[r,a]=l.useState(""),{dataSourceId:i,hooks:c,getColumnByIndex:d,getValue:h}=l.useContext(Pe),m=l.useMemo(()=>{if(t===void 0)return c;const g=d(t);return g?c.filter(w=>w.toColumn===g.column&&w.toTable===g.table):[]},[t,c,d]),u=Tt(),x=te(),f=l.useMemo(()=>{const g=r.toLowerCase();return m.filter(w=>w.fromTable.toLowerCase().includes(g))},[r,m]),p=g=>{u.mutateAsync(xh(g,i,e,h)).then(w=>{x(D.workbenchTab.build({id:w.id})),n?.()})},b=ye(f.length,0);return s.jsxs("div",{className:o,children:[s.jsx(an,{autoFocus:!0,className:_t.filterInput,placeholder:"Filter",value:r,onChange:g=>a(g.target.value)}),s.jsxs("div",{className:_t.list,children:[b&&f.map(g=>s.jsx(yo,{hook:g,onClick:()=>p(g)},g.id)),!b&&s.jsx("p",{className:_t.emptyText,children:"Empty"})]})]})},gh=({handler:e,rowIndex:t,colIndex:n})=>s.jsx(Ma,{handler:e,children:s.jsx("div",{className:_t.optionsContainer,children:s.jsx(Pa,{rowIndex:t,colIndex:n,className:"p-2",onClose:()=>{e.close()}})})}),wo=()=>{const{state:e,setState:t}=l.useContext(je),n=l.useCallback((r,a=!1)=>{t(i=>({...i,page:a?0:i.page,filters:r}))},[t]),o=l.useCallback(r=>{t(a=>({...a,filters:a.filters.filter(i=>i.id!==r)}))},[t]);return{filters:e.filters,removeFilter:o,setFilters:n}},vh=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"})),bh=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"})),yh="_container_g2woz_2",wh="_animate-show_g2woz_2",Ch="_animate-hide_g2woz_2",jh="_backdrop_g2woz_2",Nh="_content_g2woz_2",wt={container:yh,animateShow:wh,animateHide:Ch,backdrop:jh,content:Nh},Co=({children:e,ref:t,onClosed:n})=>{const[o,r]=l.useState(void 0),[a,i]=l.useState("hidden"),c=l.useRef(null);if(l.useImperativeHandle(t,()=>({open:(m,u=!0)=>{u||(m.preventDefault(),m.stopPropagation());const x={},f=m.clientY>window.innerHeight/2,p=m.clientX>window.innerWidth/2;f?x.bottom=window.innerHeight-m.clientY:x.top=m.clientY,Ta()?p?x.right=window.innerWidth-m.clientX:x.left=m.clientX:(x.right=36,x.left=36),r(x),i("in")},close:()=>{i("out")}}),[]),js({enabled:a==="in"||a==="visible",onClose:()=>{i("out")}}),!o)return null;const d=()=>{a==="in"?i("visible"):a==="out"&&(r(void 0),i("hidden"),n?.())},h=s.jsxs("div",{className:A(wt.container,a==="out"&&wt.animateHide,a==="in"&&wt.animateShow),onAnimationEnd:d,children:[s.jsx("div",{className:wt.backdrop,onClick:()=>i("out")}),s.jsx("div",{ref:c,style:o,className:A(wt.content,a==="out"&&wt.animateHide,a==="in"&&wt.animateShow),children:e})]});return ho.createPortal(h,document.body)},[Sh,Oa]=xe(void 0),_h=Oa,dr=()=>{Oa(void 0)};function Zn(e,t,n){const o=e?.rows?.[t]?.[n],r=e?.columns?.[n];return{value:o,column:r}}const kh=({ref:e})=>{const{data:t}=l.useContext(nt),{getColumnType:n,getEntityKey:o,dataSourceId:r}=l.useContext(Pe),{setState:a}=l.useContext(je);return{copyValue:(m,u)=>{const{value:x,column:f}=Zn(t?.result,m,u);if(f){const p=ct(x,n(f.full));navigator.clipboard.writeText(p),ue.success("Copied!"),e.current?.close()}},showValue:(m,u)=>{const{value:x,column:f}=Zn(t?.result,m,u);if(f){const p=ct(x,n(f.full));Sd(p),e.current?.close()}},filterValue:(m,u)=>{const{value:x,column:f}=Zn(t?.result,m,u),p=f?.full||"";if(p){let b;if(x==null)b={id:qe(),isEnabled:!0,mode:"raw",column:p,value:"IS NULL"};else{const g=ct(x,n(p));b={id:qe(),isEnabled:!0,column:p,value:g,fn:f?.fn,mode:"default"}}a(g=>({...g,filters:[...g.filters,b]})),ue.success(`Added new filter on column ${f?.alias}`),e.current?.close()}},editValue:(m,u)=>{const{value:x,column:f}=Zn(t?.result,m,u);if(f&&f.table){const p=o(f.table,m),b=ct(x,n(f.full));_h({entity:f.table,current:b,entityId:p,prop:f.column,dataSourceId:r}),e.current?.close()}else ue.error("Unable to edit cell")}}},Da=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})),jo=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})),$a=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"})),Eh="_section-name_18eoz_2",Rh="_item_18eoz_2",at={sectionName:Eh,item:Rh},Nt=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M414 321.94L274.22 158.82a24 24 0 00-36.44 0L98 321.94c-13.34 15.57-2.28 39.62 18.22 39.62h279.6c20.5 0 31.56-24.05 18.18-39.62z",fill:"currentColor"})),[Fa,No]=xe(void 0),Lh=e=>{_o(void 0),No(e)},Ba=()=>No(void 0);function Th(e,t,n){try{const o=n.getItem(e);if(o)return JSON.parse(o)}catch(o){console.warn("Failed to restore tabs",o)}return t}const So=({storage:e=localStorage,localStorageKey:t,initialData:n})=>{const o=xe(Th(t,n,e));return o[2].subscribe(r=>{e.setItem(t,JSON.stringify(r))}),o},[za,_o]=xe(void 0),[Ah,Ih]=So({initialData:{history:[]},localStorageKey:"useEntityEditorHistory_v1"}),ko=(e,t=!0)=>{const n={...e,key:`${e.dataSourceId}-${e.tableName}-${e.entityId.map(o=>o[0]+o[1]).join("")}`};No(void 0),t&&Ih(o=>o.history.some(r=>r.key===n.key)?o:o.history.length<20?{history:[...o.history,n]}:{history:[...o.history.slice(1),n]}),_o(n)},Eo=()=>_o(void 0),Mh=({onClose:e,rowIndex:t,className:n})=>{const[o,r]=l.useState(""),{entities:a,dataSourceId:i,getValue:c}=l.useContext(Pe),d=l.useMemo(()=>{if(!o)return a;const m=o.toLowerCase();return a.filter(u=>u.toTable.toLowerCase().includes(m))},[a,o]),h=m=>{const u=c(t,m.fromTable,m.fromColumn);u?ko({tableName:m.toTable,dataSourceId:i,entityId:[[m.toColumn,""+u]]}):ue.error(`Cannot open ${m.toTable} record. ${m.fromTable}.${m.fromColumn} is NULL`),e?.()};return s.jsxs("div",{className:n,children:[s.jsx(an,{autoFocus:!0,className:_t.filterInput,placeholder:"Filter",value:o,onChange:m=>r(m.target.value)}),s.jsx("div",{className:_t.list,children:ye(d.length,0)?d.map(m=>s.jsx(yo,{hook:m,onClick:()=>h(m)},m.id)):s.jsx("p",{className:_t.emptyText,children:"Empty"})})]})},Ph=({ref:e,row:t,col:n,onClosed:o})=>{const r=kh({ref:e}),[a,i]=l.useState("cell"),{hooks:c,entities:d}=l.useContext(Pe),h=()=>r.copyValue(t,n),m=()=>r.showValue(t,n),u=()=>r.filterValue(t,n),x=()=>r.editValue(t,n),f=()=>{i("show-record")},p=()=>{o?.(),i("cell")},b=ye(c?.length,0),g=ye(d?.length,0);return s.jsx(Co,{ref:e,onClosed:p,children:s.jsxs("div",{className:"w-full lg:w-sm",children:[a==="cell"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:at.sectionName,children:"Cell actions"}),s.jsxs("button",{className:at.item,onClick:h,children:[s.jsx(Da,{width:14,height:14}),"Copy"]}),s.jsxs("button",{className:at.item,onClick:m,children:[s.jsx(jo,{width:14,height:14}),"View"]}),s.jsxs("button",{className:at.item,onClick:u,children:[s.jsx(Pn,{width:14,height:14}),"Filter"]}),s.jsxs("button",{className:at.item,onClick:x,children:[s.jsx($a,{width:14,height:14}),"Edit"]}),(g||b)&&s.jsx("p",{className:at.sectionName,children:"Row actions"}),g&&s.jsxs("button",{className:at.item,onClick:f,children:[s.jsx(Nt,{className:"text-(--text-color-tertiary)",width:14,height:14}),"Show record"]}),b&&s.jsxs("button",{className:at.item,onClick:()=>i("drill"),children:[s.jsx(Nt,{className:"text-(--text-color-tertiary) rotate-180",width:14,height:14}),"Drill down"]})]}),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(Nt,{className:"text-(--text-color-secondary) rotate-270",width:16,height:16}),"Drill down"]}),s.jsx(Pa,{rowIndex:t,onClose:()=>e.current?.close()})]}),a==="show-record"&&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(Nt,{className:"text-(--text-color-secondary) rotate-270",width:16,height:16}),"Show record"]}),s.jsx(Mh,{rowIndex:t,onClose:()=>e.current?.close()})]})]})})},Oh={DESC:"",ASC:"rotate-180"},Dh=(e,{column:t,value:n,fn:o,mode:r})=>{const a=e.map(i=>({...i,isEnabled:i.column===t?!1:i.isEnabled}));return a.push({id:qe(),column:t,isEnabled:!0,value:n,fn:o,mode:r}),a},$h=({visibleCols:e})=>{const{data:t}=l.useContext(nt),{orderBy:n,updateOrderBy:o}=eh(),{setFilters:r,filters:a}=wo(),i=t?.result.columns||[],c=n[0],d=ye(t?.result.tables.length,1),h=(u,x)=>{md("Filter value","").then(f=>{f&&r(Dh(a,{column:u,value:f.value,fn:x,mode:f.mode}))})},m=e.map(u=>i[u]);return s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("td",{children:"🥢"}),m.map(u=>s.jsxs("td",{className:L.headerCell,children:[s.jsxs("div",{className:"overflow-hidden",children:[d&&s.jsx("p",{className:"text-xs truncate italic text-(--text-color-primary)",children:u.table||"-"}),s.jsx("p",{className:"text-sm font-semibold truncate text-(--text-color-primary)",children:u.column})]}),s.jsxs("div",{className:L.headerActions,children:[s.jsx("button",{onClick:()=>o(u.alias),children:c?.column===u.alias?s.jsx(vh,{className:Oh[c.direction],width:16,height:16}):s.jsx(bh,{width:16,height:16})}),s.jsx("button",{onClick:()=>h(u.full,u.fn),children:s.jsx(Pn,{width:16,height:16})})]})]},u.full))]})})};function Fh({value:e,actions:t}){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 n=ct(e);return t?.hasRecord||t?.hasDrill?s.jsxs("div",{className:"flex gap-1 items-center justify-between pointer-events-none",children:[s.jsx("span",{className:L.value,children:n}),s.jsxs("div",{className:"flex",children:[t.hasRecord&&s.jsx("span",{className:"text-gray-300 hover:text-green-600 hover:bg-gray-100 rounded p-0.5 cursor-pointer pointer-events-auto","data-cell-action":"ref","data-tooltip-id":"default-xs","data-tooltip-content":"Show record",children:s.jsx(Nt,{className:"pointer-events-none",width:16,height:16})}),t.hasDrill&&s.jsx("span",{className:"text-gray-300 hover:text-blue-600 hover:bg-gray-100 rounded p-0.5 cursor-pointer pointer-events-auto","data-cell-action":"drill","data-tooltip-id":"default-xs","data-tooltip-content":"Show related rows",children:s.jsx(Nt,{className:"pointer-events-none rotate-180",width:16,height:16})})]})]}):s.jsx("span",{className:L.value,children:n})}const Bh=l.memo(({row:e,isLastRow:t,index:n,offset:o,colMeta:r,visibleCols:a})=>{const i=a.map(c=>[e[c],c]);return s.jsxs("tr",{className:A(L.tableRowCells,t&&"rounded-b-lg"),children:[s.jsx("td",{"data-row":n,children:s.jsxs("button",{"data-cell-action":"drill-all",className:L.rowIndexBtn,children:[s.jsx(Nt,{className:"rotate-180 pointer-events-none",width:16,height:16}),s.jsx("span",{children:n+1+o})]})}),i.map(([c,d])=>s.jsx("td",{className:L.cell,"data-row":n,"data-col":d,children:s.jsx(Fh,{value:c,actions:r.get(d)})},d))]})}),zh=e=>{if(e.tagName==="TD")return e;let t=e.parentElement,n=5;for(;t&&n>=0;){if(t.tagName==="TD")return t;t=t.parentElement,n--}},hr=e=>{const t=zh(e);if(!t)return;const n=parseInt(t.dataset.row,10),o=parseInt(t.dataset.col,10);return{row:n,col:Number.isNaN(o)?void 0:o}},qh=()=>{const{data:e,error:t,isLoading:n,isFetching:o}=l.useContext(nt),{dataSourceId:r,getColumnByIndex:a,getValueByIndex:i}=l.useContext(Pe),{state:{page:c,size:d}}=l.useContext(je),h=l.useRef(null),m=bo(t),u=Ia(),[x,f]=l.useState(),p=y=>{const C=y.target,_=C.dataset?.cellAction,I=hr(C);if(_==="ref"&&ye(I?.col,-1)){const j=i(I.row,I.col),N=a(I.col);N&&ko({tableName:N.ref.table,dataSourceId:r,entityId:[[N.ref.field,j]]})}else(_==="drill"||_==="drill-all")&&(f(I),u.open(y))},b=y=>{const C=hr(y.target);C&&(f(C),h.current?.open(y),y.preventDefault(),y.stopPropagation())},g=c*d,w=l.useMemo(()=>{const y=new Map;return e&&e.result.columns.forEach((C,_)=>{y.set(_,{hasRecord:!!C.ref,hasDrill:!!C.referencedBy})}),y},[e]),v=l.useMemo(()=>{const y=[],C=e?.result.columns;if(C)for(let _=0;_<C.length;_++)C[_].hidden!==!0&&y.push(_);return y},[e]);return s.jsxs(s.Fragment,{children:[x&&u.show&&s.jsx(gh,{handler:u,rowIndex:x.row,colIndex:x.col}),s.jsx(Ph,{ref:h,col:x?.col,row:x?.row,onClosed:()=>{f(void 0)}}),m&&s.jsx(ve,{variant:"danger",children:m}),n&&s.jsx("div",{className:L.tableLoading,children:"Loading data"}),e&&s.jsxs("table",{className:A(L.table,o&&L.semiTransparent),onClick:p,onContextMenu:b,children:[s.jsx($h,{visibleCols:v}),s.jsxs("tbody",{children:[e.result.rows?.length<1&&s.jsx("tr",{className:L.tableEmpty,children:s.jsx("td",{colSpan:e.result.columns.length+1,children:"No data"})}),e.result.rows?.map((y,C)=>s.jsx(Bh,{index:C,offset:g,row:y,colMeta:w,visibleCols:v,isLastRow:C===e.result.rows.length-1},C))]})]})]})},qa=()=>{const{state:e,setState:t}=l.useContext(je),n=l.useCallback(r=>{t(a=>({...a,page:r}))},[t]),o=l.useCallback((r,a=!1)=>{t(i=>({...i,size:r,page:a?0:i.page}))},[t]);return{page:e.page,size:e.size,setSize:o,setPage:n}},Wh=()=>ne({mutationFn:async e=>{const{data:t}=await B.post("/saved-queries",e);return t.data},onSuccess:()=>{X.invalidateQueries({queryKey:["queries"]}),sn()}}),Uh=()=>ne({mutationFn:async e=>B.delete("/saved-queries/"+e),onSuccess:()=>{sn()}}),Hh=()=>ne({mutationFn:async({id:e,payload:t})=>{const{data:n}=await B.patch("/saved-queries/"+e,t);return n.data},onSuccess:()=>{sn(),Ic()}}),[_s,Ro]=xe({filters:!1,joins:!1,hiddenColumns:!1,groupBy:!1,aggregate:!1}),Ye=e=>Ro(t=>({...t,[e]:!0})),ks=e=>Ro(t=>({...t,[e]:!1})),ls=e=>Ro(t=>({...t,[e]:!t[e]})),Xt=Math.min,kt=Math.max,cs=Math.round,es=Math.floor,Be=e=>({x:e,y:e}),Vh={left:"right",right:"left",bottom:"top",top:"bottom"},Kh={start:"end",end:"start"};function Zs(e,t,n){return kt(e,Xt(t,n))}function Fn(e,t){return typeof e=="function"?e(t):e}function Rt(e){return e.split("-")[0]}function Bn(e){return e.split("-")[1]}function Wa(e){return e==="x"?"y":"x"}function Lo(e){return e==="y"?"height":"width"}const Qh=new Set(["top","bottom"]);function ut(e){return Qh.has(Rt(e))?"y":"x"}function To(e){return Wa(ut(e))}function Gh(e,t,n){n===void 0&&(n=!1);const o=Bn(e),r=To(e),a=Lo(r);let i=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=us(i)),[i,us(i)]}function Yh(e){const t=us(e);return[eo(e),t,eo(t)]}function eo(e){return e.replace(/start|end/g,t=>Kh[t])}const mr=["left","right"],fr=["right","left"],Jh=["top","bottom"],Xh=["bottom","top"];function Zh(e,t,n){switch(e){case"top":case"bottom":return n?t?fr:mr:t?mr:fr;case"left":case"right":return t?Jh:Xh;default:return[]}}function em(e,t,n,o){const r=Bn(e);let a=Zh(Rt(e),n==="start",o);return r&&(a=a.map(i=>i+"-"+r),t&&(a=a.concat(a.map(eo)))),a}function us(e){return e.replace(/left|right|bottom|top/g,t=>Vh[t])}function tm(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ua(e){return typeof e!="number"?tm(e):{top:e,right:e,bottom:e,left:e}}function ds(e){const{x:t,y:n,width:o,height:r}=e;return{width:o,height:r,top:n,left:t,right:t+o,bottom:n+r,x:t,y:n}}function pr(e,t,n){let{reference:o,floating:r}=e;const a=ut(t),i=To(t),c=Lo(i),d=Rt(t),h=a==="y",m=o.x+o.width/2-r.width/2,u=o.y+o.height/2-r.height/2,x=o[c]/2-r[c]/2;let f;switch(d){case"top":f={x:m,y:o.y-r.height};break;case"bottom":f={x:m,y:o.y+o.height};break;case"right":f={x:o.x+o.width,y:u};break;case"left":f={x:o.x-r.width,y:u};break;default:f={x:o.x,y:o.y}}switch(Bn(t)){case"start":f[i]-=x*(n&&h?-1:1);break;case"end":f[i]+=x*(n&&h?-1:1);break}return f}const nm=async(e,t,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:a=[],platform:i}=n,c=a.filter(Boolean),d=await(i.isRTL==null?void 0:i.isRTL(t));let h=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:m,y:u}=pr(h,o,d),x=o,f={},p=0;for(let b=0;b<c.length;b++){const{name:g,fn:w}=c[b],{x:v,y,data:C,reset:_}=await w({x:m,y:u,initialPlacement:o,placement:x,strategy:r,middlewareData:f,rects:h,platform:i,elements:{reference:e,floating:t}});m=v??m,u=y??u,f={...f,[g]:{...f[g],...C}},_&&p<=50&&(p++,typeof _=="object"&&(_.placement&&(x=_.placement),_.rects&&(h=_.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):_.rects),{x:m,y:u}=pr(h,x,d)),b=-1)}return{x:m,y:u,placement:x,strategy:r,middlewareData:f}};async function Ha(e,t){var n;t===void 0&&(t={});const{x:o,y:r,platform:a,rects:i,elements:c,strategy:d}=e,{boundary:h="clippingAncestors",rootBoundary:m="viewport",elementContext:u="floating",altBoundary:x=!1,padding:f=0}=Fn(t,e),p=Ua(f),g=c[x?u==="floating"?"reference":"floating":u],w=ds(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(g)))==null||n?g:g.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:h,rootBoundary:m,strategy:d})),v=u==="floating"?{x:o,y:r,width:i.floating.width,height:i.floating.height}:i.reference,y=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),C=await(a.isElement==null?void 0:a.isElement(y))?await(a.getScale==null?void 0:a.getScale(y))||{x:1,y:1}:{x:1,y:1},_=ds(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:v,offsetParent:y,strategy:d}):v);return{top:(w.top-_.top+p.top)/C.y,bottom:(_.bottom-w.bottom+p.bottom)/C.y,left:(w.left-_.left+p.left)/C.x,right:(_.right-w.right+p.right)/C.x}}const sm=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:o,placement:r,rects:a,platform:i,elements:c,middlewareData:d}=t,{element:h,padding:m=0}=Fn(e,t)||{};if(h==null)return{};const u=Ua(m),x={x:n,y:o},f=To(r),p=Lo(f),b=await i.getDimensions(h),g=f==="y",w=g?"top":"left",v=g?"bottom":"right",y=g?"clientHeight":"clientWidth",C=a.reference[p]+a.reference[f]-x[f]-a.floating[p],_=x[f]-a.reference[f],I=await(i.getOffsetParent==null?void 0:i.getOffsetParent(h));let j=I?I[y]:0;(!j||!await(i.isElement==null?void 0:i.isElement(I)))&&(j=c.floating[y]||a.floating[p]);const N=C/2-_/2,k=j/2-b[p]/2-1,O=Xt(u[w],k),G=Xt(u[v],k),ae=O,Ne=j-b[p]-G,z=j/2-b[p]/2+N,E=Zs(ae,z,Ne),P=!d.arrow&&Bn(r)!=null&&z!==E&&a.reference[p]/2-(z<ae?O:G)-b[p]/2<0,U=P?z<ae?z-ae:z-Ne:0;return{[f]:x[f]+U,data:{[f]:E,centerOffset:z-E-U,...P&&{alignmentOffset:U}},reset:P}}}),om=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:r,middlewareData:a,rects:i,initialPlacement:c,platform:d,elements:h}=t,{mainAxis:m=!0,crossAxis:u=!0,fallbackPlacements:x,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:b=!0,...g}=Fn(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const w=Rt(r),v=ut(c),y=Rt(c)===c,C=await(d.isRTL==null?void 0:d.isRTL(h.floating)),_=x||(y||!b?[us(c)]:Yh(c)),I=p!=="none";!x&&I&&_.push(...em(c,b,p,C));const j=[c,..._],N=await Ha(t,g),k=[];let O=((o=a.flip)==null?void 0:o.overflows)||[];if(m&&k.push(N[w]),u){const z=Gh(r,i,C);k.push(N[z[0]],N[z[1]])}if(O=[...O,{placement:r,overflows:k}],!k.every(z=>z<=0)){var G,ae;const z=(((G=a.flip)==null?void 0:G.index)||0)+1,E=j[z];if(E&&(!(u==="alignment"?v!==ut(E):!1)||O.every(H=>ut(H.placement)===v?H.overflows[0]>0:!0)))return{data:{index:z,overflows:O},reset:{placement:E}};let P=(ae=O.filter(U=>U.overflows[0]<=0).sort((U,H)=>U.overflows[1]-H.overflows[1])[0])==null?void 0:ae.placement;if(!P)switch(f){case"bestFit":{var Ne;const U=(Ne=O.filter(H=>{if(I){const ie=ut(H.placement);return ie===v||ie==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(ie=>ie>0).reduce((ie,Ke)=>ie+Ke,0)]).sort((H,ie)=>H[1]-ie[1])[0])==null?void 0:Ne[0];U&&(P=U);break}case"initialPlacement":P=c;break}if(r!==P)return{reset:{placement:P}}}return{}}}},rm=new Set(["left","top"]);async function am(e,t){const{placement:n,platform:o,elements:r}=e,a=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=Rt(n),c=Bn(n),d=ut(n)==="y",h=rm.has(i)?-1:1,m=a&&d?-1:1,u=Fn(t,e);let{mainAxis:x,crossAxis:f,alignmentAxis:p}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return c&&typeof p=="number"&&(f=c==="end"?p*-1:p),d?{x:f*m,y:x*h}:{x:x*h,y:f*m}}const im=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:r,y:a,placement:i,middlewareData:c}=t,d=await am(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:r+d.x,y:a+d.y,data:{...d,placement:i}}}}},lm=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:r}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:c={fn:g=>{let{x:w,y:v}=g;return{x:w,y:v}}},...d}=Fn(e,t),h={x:n,y:o},m=await Ha(t,d),u=ut(Rt(r)),x=Wa(u);let f=h[x],p=h[u];if(a){const g=x==="y"?"top":"left",w=x==="y"?"bottom":"right",v=f+m[g],y=f-m[w];f=Zs(v,f,y)}if(i){const g=u==="y"?"top":"left",w=u==="y"?"bottom":"right",v=p+m[g],y=p-m[w];p=Zs(v,p,y)}const b=c.fn({...t,[x]:f,[u]:p});return{...b,data:{x:b.x-n,y:b.y-o,enabled:{[x]:a,[u]:i}}}}}};function Es(){return typeof window<"u"}function ln(e){return Va(e)?(e.nodeName||"").toLowerCase():"#document"}function be(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ve(e){var t;return(t=(Va(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Va(e){return Es()?e instanceof Node||e instanceof be(e).Node:!1}function Ie(e){return Es()?e instanceof Element||e instanceof be(e).Element:!1}function We(e){return Es()?e instanceof HTMLElement||e instanceof be(e).HTMLElement:!1}function xr(e){return!Es()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof be(e).ShadowRoot}const cm=new Set(["inline","contents"]);function zn(e){const{overflow:t,overflowX:n,overflowY:o,display:r}=Me(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!cm.has(r)}const um=new Set(["table","td","th"]);function dm(e){return um.has(ln(e))}const hm=[":popover-open",":modal"];function Rs(e){return hm.some(t=>{try{return e.matches(t)}catch{return!1}})}const mm=["transform","translate","scale","rotate","perspective"],fm=["transform","translate","scale","rotate","perspective","filter"],pm=["paint","layout","strict","content"];function Ao(e){const t=Io(),n=Ie(e)?Me(e):e;return mm.some(o=>n[o]?n[o]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||fm.some(o=>(n.willChange||"").includes(o))||pm.some(o=>(n.contain||"").includes(o))}function xm(e){let t=ht(e);for(;We(t)&&!Zt(t);){if(Ao(t))return t;if(Rs(t))return null;t=ht(t)}return null}function Io(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const gm=new Set(["html","body","#document"]);function Zt(e){return gm.has(ln(e))}function Me(e){return be(e).getComputedStyle(e)}function Ls(e){return Ie(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ht(e){if(ln(e)==="html")return e;const t=e.assignedSlot||e.parentNode||xr(e)&&e.host||Ve(e);return xr(t)?t.host:t}function Ka(e){const t=ht(e);return Zt(t)?e.ownerDocument?e.ownerDocument.body:e.body:We(t)&&zn(t)?t:Ka(t)}function _n(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=Ka(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=be(r);if(a){const c=to(i);return t.concat(i,i.visualViewport||[],zn(r)?r:[],c&&n?_n(c):[])}return t.concat(r,_n(r,[],n))}function to(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Qa(e){const t=Me(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=We(e),a=r?e.offsetWidth:n,i=r?e.offsetHeight:o,c=cs(n)!==a||cs(o)!==i;return c&&(n=a,o=i),{width:n,height:o,$:c}}function Mo(e){return Ie(e)?e:e.contextElement}function Gt(e){const t=Mo(e);if(!We(t))return Be(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:a}=Qa(t);let i=(a?cs(n.width):n.width)/o,c=(a?cs(n.height):n.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const vm=Be(0);function Ga(e){const t=be(e);return!Io()||!t.visualViewport?vm:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function bm(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==be(e)?!1:t}function Lt(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),a=Mo(e);let i=Be(1);t&&(o?Ie(o)&&(i=Gt(o)):i=Gt(e));const c=bm(a,n,o)?Ga(a):Be(0);let d=(r.left+c.x)/i.x,h=(r.top+c.y)/i.y,m=r.width/i.x,u=r.height/i.y;if(a){const x=be(a),f=o&&Ie(o)?be(o):o;let p=x,b=to(p);for(;b&&o&&f!==p;){const g=Gt(b),w=b.getBoundingClientRect(),v=Me(b),y=w.left+(b.clientLeft+parseFloat(v.paddingLeft))*g.x,C=w.top+(b.clientTop+parseFloat(v.paddingTop))*g.y;d*=g.x,h*=g.y,m*=g.x,u*=g.y,d+=y,h+=C,p=be(b),b=to(p)}}return ds({width:m,height:u,x:d,y:h})}function Ts(e,t){const n=Ls(e).scrollLeft;return t?t.left+n:Lt(Ve(e)).left+n}function Ya(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-Ts(e,n),r=n.top+t.scrollTop;return{x:o,y:r}}function ym(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=Ve(o),c=t?Rs(t.floating):!1;if(o===i||c&&a)return n;let d={scrollLeft:0,scrollTop:0},h=Be(1);const m=Be(0),u=We(o);if((u||!u&&!a)&&((ln(o)!=="body"||zn(i))&&(d=Ls(o)),We(o))){const f=Lt(o);h=Gt(o),m.x=f.x+o.clientLeft,m.y=f.y+o.clientTop}const x=i&&!u&&!a?Ya(i,d):Be(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-d.scrollLeft*h.x+m.x+x.x,y:n.y*h.y-d.scrollTop*h.y+m.y+x.y}}function wm(e){return Array.from(e.getClientRects())}function Cm(e){const t=Ve(e),n=Ls(e),o=e.ownerDocument.body,r=kt(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),a=kt(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-n.scrollLeft+Ts(e);const c=-n.scrollTop;return Me(o).direction==="rtl"&&(i+=kt(t.clientWidth,o.clientWidth)-r),{width:r,height:a,x:i,y:c}}const gr=25;function jm(e,t){const n=be(e),o=Ve(e),r=n.visualViewport;let a=o.clientWidth,i=o.clientHeight,c=0,d=0;if(r){a=r.width,i=r.height;const m=Io();(!m||m&&t==="fixed")&&(c=r.offsetLeft,d=r.offsetTop)}const h=Ts(o);if(h<=0){const m=o.ownerDocument,u=m.body,x=getComputedStyle(u),f=m.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,p=Math.abs(o.clientWidth-u.clientWidth-f);p<=gr&&(a-=p)}else h<=gr&&(a+=h);return{width:a,height:i,x:c,y:d}}const Nm=new Set(["absolute","fixed"]);function Sm(e,t){const n=Lt(e,!0,t==="fixed"),o=n.top+e.clientTop,r=n.left+e.clientLeft,a=We(e)?Gt(e):Be(1),i=e.clientWidth*a.x,c=e.clientHeight*a.y,d=r*a.x,h=o*a.y;return{width:i,height:c,x:d,y:h}}function vr(e,t,n){let o;if(t==="viewport")o=jm(e,n);else if(t==="document")o=Cm(Ve(e));else if(Ie(t))o=Sm(t,n);else{const r=Ga(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return ds(o)}function Ja(e,t){const n=ht(e);return n===t||!Ie(n)||Zt(n)?!1:Me(n).position==="fixed"||Ja(n,t)}function _m(e,t){const n=t.get(e);if(n)return n;let o=_n(e,[],!1).filter(c=>Ie(c)&&ln(c)!=="body"),r=null;const a=Me(e).position==="fixed";let i=a?ht(e):e;for(;Ie(i)&&!Zt(i);){const c=Me(i),d=Ao(i);!d&&c.position==="fixed"&&(r=null),(a?!d&&!r:!d&&c.position==="static"&&!!r&&Nm.has(r.position)||zn(i)&&!d&&Ja(e,i))?o=o.filter(m=>m!==i):r=c,i=ht(i)}return t.set(e,o),o}function km(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const i=[...n==="clippingAncestors"?Rs(t)?[]:_m(t,this._c):[].concat(n),o],c=i[0],d=i.reduce((h,m)=>{const u=vr(t,m,r);return h.top=kt(u.top,h.top),h.right=Xt(u.right,h.right),h.bottom=Xt(u.bottom,h.bottom),h.left=kt(u.left,h.left),h},vr(t,c,r));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function Em(e){const{width:t,height:n}=Qa(e);return{width:t,height:n}}function Rm(e,t,n){const o=We(t),r=Ve(t),a=n==="fixed",i=Lt(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const d=Be(0);function h(){d.x=Ts(r)}if(o||!o&&!a)if((ln(t)!=="body"||zn(r))&&(c=Ls(t)),o){const f=Lt(t,!0,a,t);d.x=f.x+t.clientLeft,d.y=f.y+t.clientTop}else r&&h();a&&!o&&r&&h();const m=r&&!o&&!a?Ya(r,c):Be(0),u=i.left+c.scrollLeft-d.x-m.x,x=i.top+c.scrollTop-d.y-m.y;return{x:u,y:x,width:i.width,height:i.height}}function zs(e){return Me(e).position==="static"}function br(e,t){if(!We(e)||Me(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ve(e)===n&&(n=n.ownerDocument.body),n}function Xa(e,t){const n=be(e);if(Rs(e))return n;if(!We(e)){let r=ht(e);for(;r&&!Zt(r);){if(Ie(r)&&!zs(r))return r;r=ht(r)}return n}let o=br(e,t);for(;o&&dm(o)&&zs(o);)o=br(o,t);return o&&Zt(o)&&zs(o)&&!Ao(o)?n:o||xm(e)||n}const Lm=async function(e){const t=this.getOffsetParent||Xa,n=this.getDimensions,o=await n(e.floating);return{reference:Rm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Tm(e){return Me(e).direction==="rtl"}const Am={convertOffsetParentRelativeRectToViewportRelativeRect:ym,getDocumentElement:Ve,getClippingRect:km,getOffsetParent:Xa,getElementRects:Lm,getClientRects:wm,getDimensions:Em,getScale:Gt,isElement:Ie,isRTL:Tm};function Za(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Im(e,t){let n=null,o;const r=Ve(e);function a(){var c;clearTimeout(o),(c=n)==null||c.disconnect(),n=null}function i(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),a();const h=e.getBoundingClientRect(),{left:m,top:u,width:x,height:f}=h;if(c||t(),!x||!f)return;const p=es(u),b=es(r.clientWidth-(m+x)),g=es(r.clientHeight-(u+f)),w=es(m),y={rootMargin:-p+"px "+-b+"px "+-g+"px "+-w+"px",threshold:kt(0,Xt(1,d))||1};let C=!0;function _(I){const j=I[0].intersectionRatio;if(j!==d){if(!C)return i();j?i(!1,j):o=setTimeout(()=>{i(!1,1e-7)},1e3)}j===1&&!Za(h,e.getBoundingClientRect())&&i(),C=!1}try{n=new IntersectionObserver(_,{...y,root:r.ownerDocument})}catch{n=new IntersectionObserver(_,y)}n.observe(e)}return i(!0),a}function Mm(e,t,n,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=o,h=Mo(e),m=r||a?[...h?_n(h):[],..._n(t)]:[];m.forEach(w=>{r&&w.addEventListener("scroll",n,{passive:!0}),a&&w.addEventListener("resize",n)});const u=h&&c?Im(h,n):null;let x=-1,f=null;i&&(f=new ResizeObserver(w=>{let[v]=w;v&&v.target===h&&f&&(f.unobserve(t),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var y;(y=f)==null||y.observe(t)})),n()}),h&&!d&&f.observe(h),f.observe(t));let p,b=d?Lt(e):null;d&&g();function g(){const w=Lt(e);b&&!Za(b,w)&&n(),b=w,p=requestAnimationFrame(g)}return n(),()=>{var w;m.forEach(v=>{r&&v.removeEventListener("scroll",n),a&&v.removeEventListener("resize",n)}),u?.(),(w=f)==null||w.disconnect(),f=null,d&&cancelAnimationFrame(p)}}const Pm=im,Om=lm,Dm=om,$m=sm,yr=(e,t,n)=>{const o=new Map,r={platform:Am,...n},a={...r.platform,_c:o};return nm(e,t,{...r,platform:a})};var qs={exports:{}};var wr;function Fm(){return wr||(wr=1,(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var a="",i=0;i<arguments.length;i++){var c=arguments[i];c&&(a=r(a,o(c)))}return a}function o(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 c in a)t.call(a,c)&&a[c]&&(i=r(i,c));return i}function r(a,i){return i?a?a+" "+i:a+i:a}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(qs)),qs.exports}var Bm=Fm();const no=Pi(Bm);var Cr={};const zm="react-tooltip-core-styles",qm="react-tooltip-base-styles",jr={core:!1,base:!1};function Nr({css:e,id:t=qm,type:n="base",ref:o}){var r,a;if(!e||typeof document>"u"||jr[n]||n==="core"&&typeof process<"u"&&(!((r=process==null?void 0:Cr)===null||r===void 0)&&r.REACT_TOOLTIP_DISABLE_CORE_STYLES)||n!=="base"&&typeof process<"u"&&(!((a=process==null?void 0:Cr)===null||a===void 0)&&a.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;n==="core"&&(t=zm),o||(o={});const{insertAt:i}=o;if(document.getElementById(t))return;const c=document.head||document.getElementsByTagName("head")[0],d=document.createElement("style");d.id=t,d.type="text/css",i==="top"&&c.firstChild?c.insertBefore(d,c.firstChild):c.appendChild(d),d.styleSheet?d.styleSheet.cssText=e:d.appendChild(document.createTextNode(e)),jr[n]=!0}const Sr=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:o="top",offset:r=10,strategy:a="absolute",middlewares:i=[Pm(Number(r)),Dm({fallbackAxisSideDirection:"start"}),Om({padding:5})],border:c,arrowSize:d=8})=>{if(!e)return{tooltipStyles:{},tooltipArrowStyles:{},place:o};if(t===null)return{tooltipStyles:{},tooltipArrowStyles:{},place:o};const h=i;return n?(h.push($m({element:n,padding:5})),yr(e,t,{placement:o,strategy:a,middleware:h}).then((({x:m,y:u,placement:x,middlewareData:f})=>{var p,b;const g={left:`${m}px`,top:`${u}px`,border:c},{x:w,y:v}=(p=f.arrow)!==null&&p!==void 0?p:{x:0,y:0},y=(b={top:"bottom",right:"left",bottom:"top",left:"right"}[x.split("-")[0]])!==null&&b!==void 0?b:"bottom",C=c&&{borderBottom:c,borderRight:c};let _=0;if(c){const I=`${c}`.match(/(\d+)px/);_=I?.[1]?Number(I[1]):1}return{tooltipStyles:g,tooltipArrowStyles:{left:w!=null?`${w}px`:"",top:v!=null?`${v}px`:"",right:"",bottom:"",...C,[y]:`-${d/2+_}px`},place:x}}))):yr(e,t,{placement:"bottom",strategy:a,middleware:h}).then((({x:m,y:u,placement:x})=>({tooltipStyles:{left:`${m}px`,top:`${u}px`},tooltipArrowStyles:{},place:x})))},_r=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),kr=(e,t,n)=>{let o=null;const r=function(...a){const i=()=>{o=null};!o&&(e.apply(this,a),o=setTimeout(i,t))};return r.cancel=()=>{o&&(clearTimeout(o),o=null)},r},Er=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",so=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((r,a)=>so(r,t[a])));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!Er(e)||!Er(t))return e===t;const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((r=>so(e[r],t[r])))},Wm=e=>{if(!(e instanceof HTMLElement||e instanceof SVGElement))return!1;const t=getComputedStyle(e);return["overflow","overflow-x","overflow-y"].some((n=>{const o=t.getPropertyValue(n);return o==="auto"||o==="scroll"}))},Rr=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(Wm(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},Um=typeof window<"u"?l.useLayoutEffect:l.useEffect,_e=e=>{e.current&&(clearTimeout(e.current),e.current=null)},Hm="DEFAULT_TOOLTIP_ID",Vm={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},Km=l.createContext({getTooltipData:()=>Vm});function ei(e=Hm){return l.useContext(Km).getTooltipData(e)}var Vt={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"},Ws={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 Qm=({forwardRef:e,id:t,className:n,classNameArrow:o,variant:r="dark",anchorId:a,anchorSelect:i,place:c="top",offset:d=10,events:h=["hover"],openOnClick:m=!1,positionStrategy:u="absolute",middlewares:x,wrapper:f,delayShow:p=0,delayHide:b=0,float:g=!1,hidden:w=!1,noArrow:v=!1,clickable:y=!1,closeOnEsc:C=!1,closeOnScroll:_=!1,closeOnResize:I=!1,openEvents:j,closeEvents:N,globalCloseEvents:k,imperativeModeOnly:O,style:G,position:ae,afterShow:Ne,afterHide:z,disableTooltip:E,content:P,contentWrapperRef:U,isOpen:H,defaultIsOpen:ie=!1,setIsOpen:Ke,previousActiveAnchor:cn,activeAnchor:V,setActiveAnchor:At,border:Wn,opacity:Un,arrowColor:Hn,arrowSize:It=8,role:Is="tooltip"})=>{var ft;const de=l.useRef(null),Mt=l.useRef(null),Te=l.useRef(null),pt=l.useRef(null),Pt=l.useRef(null),[xt,Vn]=l.useState({tooltipStyles:{},tooltipArrowStyles:{},place:c}),[he,un]=l.useState(!1),[Ot,st]=l.useState(!1),[J,Dt]=l.useState(null),Kn=l.useRef(!1),$t=l.useRef(null),{anchorRefs:Qn,setActiveAnchor:dn}=ei(t),hn=l.useRef(!1),[ot,mn]=l.useState([]),gt=l.useRef(!1),Ft=m||h.includes("click"),Gn=Ft||j?.click||j?.dblclick||j?.mousedown,fn=j?{...j}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!j&&Ft&&Object.assign(fn,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const vt=N?{...N}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!N&&Ft&&Object.assign(vt,{mouseleave:!1,blur:!1,mouseout:!1});const oe=k?{...k}:{escape:C||!1,scroll:_||!1,resize:I||!1,clickOutsideAnchor:Gn||!1};O&&(Object.assign(fn,{mouseover:!1,focus:!1,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(vt,{mouseout:!1,blur:!1,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(oe,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),Um((()=>(gt.current=!0,()=>{gt.current=!1})),[]);const me=S=>{gt.current&&(S&&st(!0),setTimeout((()=>{gt.current&&(Ke?.(S),H===void 0&&un(S))}),10))};l.useEffect((()=>{if(t){if(he){T(cn);const R=S(V),W=[...new Set([...R,t])].filter(Boolean).join(" ");V?.setAttribute("aria-describedby",W)}else T(V);return()=>{T(V),T(cn)}}function S(R){var W;return((W=R?.getAttribute("aria-describedby"))===null||W===void 0?void 0:W.split(" "))||[]}function T(R){const W=S(R).filter((se=>se!==t));W.length?R?.setAttribute("aria-describedby",W.join(" ")):R?.removeAttribute("aria-describedby")}}),[V,he,t,cn]),l.useEffect((()=>{if(H===void 0)return()=>null;H&&st(!0);const S=setTimeout((()=>{un(H)}),10);return()=>{clearTimeout(S)}}),[H]),l.useEffect((()=>{if(he!==Kn.current)if(_e(Pt),Kn.current=he,he)Ne?.();else{const S=(T=>{const R=T.match(/^([\d.]+)(ms|s)$/);if(!R)return 0;const[,W,se]=R;return Number(W)*(se==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));Pt.current=setTimeout((()=>{st(!1),Dt(null),z?.()}),S+25)}}),[he]);const pn=S=>{Vn((T=>so(T,S)?T:S))},xn=(S=p)=>{_e(Te),Ot?me(!0):Te.current=setTimeout((()=>{me(!0)}),S)},Bt=(S=b)=>{_e(pt),pt.current=setTimeout((()=>{hn.current||me(!1)}),S)},gn=S=>{var T;if(!S)return;const R=(T=S.currentTarget)!==null&&T!==void 0?T:S.target;if(!R?.isConnected)return At(null),void dn({current:null});p?xn():me(!0),At(R),dn({current:R}),_e(pt)},zt=()=>{y?Bt(b||100):b?Bt():me(!1),_e(Te)},qt=({x:S,y:T})=>{var R;const W={getBoundingClientRect:()=>({x:S,y:T,width:0,height:0,top:T,left:S,right:S,bottom:T})};Sr({place:(R=J?.place)!==null&&R!==void 0?R:c,offset:d,elementReference:W,tooltipReference:de.current,tooltipArrowReference:Mt.current,strategy:u,middlewares:x,border:Wn,arrowSize:It}).then((se=>{pn(se)}))},Wt=S=>{if(!S)return;const T=S,R={x:T.clientX,y:T.clientY};qt(R),$t.current=R},vn=S=>{var T;if(!he)return;const R=S.target;R.isConnected&&(!((T=de.current)===null||T===void 0)&&T.contains(R)||[document.querySelector(`[id='${a}']`),...ot].some((W=>W?.contains(R)))||(me(!1),_e(Te)))},Yn=kr(gn,50),Z=kr(zt,50),le=S=>{Z.cancel(),Yn(S)},M=()=>{Yn.cancel(),Z()},$=l.useCallback((()=>{var S,T;const R=(S=J?.position)!==null&&S!==void 0?S:ae;R?qt(R):g?$t.current&&qt($t.current):V?.isConnected&&Sr({place:(T=J?.place)!==null&&T!==void 0?T:c,offset:d,elementReference:V,tooltipReference:de.current,tooltipArrowReference:Mt.current,strategy:u,middlewares:x,border:Wn,arrowSize:It}).then((W=>{gt.current&&pn(W)}))}),[he,V,P,G,c,J?.place,d,u,ae,J?.position,g,It]);l.useEffect((()=>{var S,T;const R=new Set(Qn);ot.forEach((q=>{E?.(q)||R.add({current:q})}));const W=document.querySelector(`[id='${a}']`);W&&!E?.(W)&&R.add({current:W});const se=()=>{me(!1)},Oe=Rr(V),De=Rr(de.current);oe.scroll&&(window.addEventListener("scroll",se),Oe?.addEventListener("scroll",se),De?.addEventListener("scroll",se));let ce=null;oe.resize?window.addEventListener("resize",se):V&&de.current&&(ce=Mm(V,de.current,$,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const Se=q=>{q.key==="Escape"&&me(!1)};oe.escape&&window.addEventListener("keydown",Se),oe.clickOutsideAnchor&&window.addEventListener("click",vn);const K=[],Ut=q=>!!(q?.target&&V?.contains(q.target)),ji=q=>{he&&Ut(q)||gn(q)},Ni=q=>{he&&Ut(q)&&zt()},Fo=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],Bo=["click","dblclick","mousedown","mouseup"];Object.entries(fn).forEach((([q,Qe])=>{Qe&&(Fo.includes(q)?K.push({event:q,listener:le}):Bo.includes(q)&&K.push({event:q,listener:ji}))})),Object.entries(vt).forEach((([q,Qe])=>{Qe&&(Fo.includes(q)?K.push({event:q,listener:M}):Bo.includes(q)&&K.push({event:q,listener:Ni}))})),g&&K.push({event:"pointermove",listener:Wt});const zo=()=>{hn.current=!0},qo=()=>{hn.current=!1,zt()},Wo=y&&(vt.mouseout||vt.mouseleave);return Wo&&((S=de.current)===null||S===void 0||S.addEventListener("mouseover",zo),(T=de.current)===null||T===void 0||T.addEventListener("mouseout",qo)),K.forEach((({event:q,listener:Qe})=>{R.forEach((Ms=>{var bn;(bn=Ms.current)===null||bn===void 0||bn.addEventListener(q,Qe)}))})),()=>{var q,Qe;oe.scroll&&(window.removeEventListener("scroll",se),Oe?.removeEventListener("scroll",se),De?.removeEventListener("scroll",se)),oe.resize?window.removeEventListener("resize",se):ce?.(),oe.clickOutsideAnchor&&window.removeEventListener("click",vn),oe.escape&&window.removeEventListener("keydown",Se),Wo&&((q=de.current)===null||q===void 0||q.removeEventListener("mouseover",zo),(Qe=de.current)===null||Qe===void 0||Qe.removeEventListener("mouseout",qo)),K.forEach((({event:Ms,listener:bn})=>{R.forEach((Si=>{var Ps;(Ps=Si.current)===null||Ps===void 0||Ps.removeEventListener(Ms,bn)}))}))}}),[V,$,Ot,Qn,ot,j,N,k,Ft,p,b]),l.useEffect((()=>{var S,T;let R=(T=(S=J?.anchorSelect)!==null&&S!==void 0?S:i)!==null&&T!==void 0?T:"";!R&&t&&(R=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const W=new MutationObserver((se=>{const Oe=[],De=[];se.forEach((ce=>{if(ce.type==="attributes"&&ce.attributeName==="data-tooltip-id"&&(ce.target.getAttribute("data-tooltip-id")===t?Oe.push(ce.target):ce.oldValue===t&&De.push(ce.target)),ce.type==="childList"){if(V){const Se=[...ce.removedNodes].filter((K=>K.nodeType===1));if(R)try{De.push(...Se.filter((K=>K.matches(R)))),De.push(...Se.flatMap((K=>[...K.querySelectorAll(R)])))}catch{}Se.some((K=>{var Ut;return!!(!((Ut=K?.contains)===null||Ut===void 0)&&Ut.call(K,V))&&(st(!1),me(!1),At(null),_e(Te),_e(pt),!0)}))}if(R)try{const Se=[...ce.addedNodes].filter((K=>K.nodeType===1));Oe.push(...Se.filter((K=>K.matches(R)))),Oe.push(...Se.flatMap((K=>[...K.querySelectorAll(R)])))}catch{}}})),(Oe.length||De.length)&&mn((ce=>[...ce.filter((Se=>!De.includes(Se))),...Oe]))}));return W.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{W.disconnect()}}),[t,i,J?.anchorSelect,V]),l.useEffect((()=>{$()}),[$]),l.useEffect((()=>{if(!U?.current)return()=>null;const S=new ResizeObserver((()=>{setTimeout((()=>$()))}));return S.observe(U.current),()=>{S.disconnect()}}),[P,U?.current]),l.useEffect((()=>{var S;const T=document.querySelector(`[id='${a}']`),R=[...ot,T];V&&R.includes(V)||At((S=ot[0])!==null&&S!==void 0?S:T)}),[a,ot,V]),l.useEffect((()=>(ie&&me(!0),()=>{_e(Te),_e(pt)})),[]),l.useEffect((()=>{var S;let T=(S=J?.anchorSelect)!==null&&S!==void 0?S:i;if(!T&&t&&(T=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),T)try{const R=Array.from(document.querySelectorAll(T));mn(R)}catch{mn([])}}),[t,i,J?.anchorSelect]),l.useEffect((()=>{Te.current&&(_e(Te),xn(p))}),[p]);const ge=(ft=J?.content)!==null&&ft!==void 0?ft:P,bt=he&&Object.keys(xt.tooltipStyles).length>0;return l.useImperativeHandle(e,(()=>({open:S=>{if(S?.anchorSelect)try{document.querySelector(S.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${S.anchorSelect}" is not a valid CSS selector`)}Dt(S??null),S?.delay?xn(S.delay):me(!0)},close:S=>{S?.delay?Bt(S.delay):me(!1)},activeAnchor:V,place:xt.place,isOpen:!!(Ot&&!w&&ge&&bt)}))),Ot&&!w&&ge?lt.createElement(f,{id:t,role:Is,className:no("react-tooltip",Vt.tooltip,Ws.tooltip,Ws[r],n,`react-tooltip__place-${xt.place}`,Vt[bt?"show":"closing"],bt?"react-tooltip__show":"react-tooltip__closing",u==="fixed"&&Vt.fixed,y&&Vt.clickable),onTransitionEnd:S=>{_e(Pt),he||S.propertyName!=="opacity"||(st(!1),Dt(null),z?.())},style:{...G,...xt.tooltipStyles,opacity:Un!==void 0&&bt?Un:void 0},ref:de},ge,lt.createElement(f,{className:no("react-tooltip-arrow",Vt.arrow,Ws.arrow,o,v&&Vt.noArrow),style:{...xt.tooltipArrowStyles,background:Hn?`linear-gradient(to right bottom, transparent 50%, ${Hn} 50%)`:void 0,"--rt-arrow-size":`${It}px`},ref:Mt})):null},Gm=({content:e})=>lt.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),kn=lt.forwardRef((({id:e,anchorId:t,anchorSelect:n,content:o,html:r,render:a,className:i,classNameArrow:c,variant:d="dark",place:h="top",offset:m=10,wrapper:u="div",children:x=null,events:f=["hover"],openOnClick:p=!1,positionStrategy:b="absolute",middlewares:g,delayShow:w=0,delayHide:v=0,float:y=!1,hidden:C=!1,noArrow:_=!1,clickable:I=!1,closeOnEsc:j=!1,closeOnScroll:N=!1,closeOnResize:k=!1,openEvents:O,closeEvents:G,globalCloseEvents:ae,imperativeModeOnly:Ne=!1,style:z,position:E,isOpen:P,defaultIsOpen:U=!1,disableStyleInjection:H=!1,border:ie,opacity:Ke,arrowColor:cn,arrowSize:V,setIsOpen:At,afterShow:Wn,afterHide:Un,disableTooltip:Hn,role:It="tooltip"},Is)=>{const[ft,de]=l.useState(o),[Mt,Te]=l.useState(r),[pt,Pt]=l.useState(h),[xt,Vn]=l.useState(d),[he,un]=l.useState(m),[Ot,st]=l.useState(w),[J,Dt]=l.useState(v),[Kn,$t]=l.useState(y),[Qn,dn]=l.useState(C),[hn,ot]=l.useState(u),[mn,gt]=l.useState(f),[Ft,Gn]=l.useState(b),[fn,vt]=l.useState(null),[oe,me]=l.useState(null),pn=l.useRef(null),xn=l.useRef(H),{anchorRefs:Bt,activeAnchor:gn}=ei(e),zt=Z=>Z?.getAttributeNames().reduce(((le,M)=>{var $;return M.startsWith("data-tooltip-")&&(le[M.replace(/^data-tooltip-/,"")]=($=Z?.getAttribute(M))!==null&&$!==void 0?$:null),le}),{}),qt=Z=>{const le={place:M=>{var $;Pt(($=M)!==null&&$!==void 0?$:h)},content:M=>{de(M??o)},html:M=>{Te(M??r)},variant:M=>{var $;Vn(($=M)!==null&&$!==void 0?$:d)},offset:M=>{un(M===null?m:Number(M))},wrapper:M=>{var $;ot(($=M)!==null&&$!==void 0?$:u)},events:M=>{const $=M?.split(" ");gt($??f)},"position-strategy":M=>{var $;Gn(($=M)!==null&&$!==void 0?$:b)},"delay-show":M=>{st(M===null?w:Number(M))},"delay-hide":M=>{Dt(M===null?v:Number(M))},float:M=>{$t(M===null?y:M==="true")},hidden:M=>{dn(M===null?C:M==="true")},"class-name":M=>{vt(M)}};Object.values(le).forEach((M=>M(null))),Object.entries(Z).forEach((([M,$])=>{var ge;(ge=le[M])===null||ge===void 0||ge.call(le,$)}))};l.useEffect((()=>{de(o)}),[o]),l.useEffect((()=>{Te(r)}),[r]),l.useEffect((()=>{Pt(h)}),[h]),l.useEffect((()=>{Vn(d)}),[d]),l.useEffect((()=>{un(m)}),[m]),l.useEffect((()=>{st(w)}),[w]),l.useEffect((()=>{Dt(v)}),[v]),l.useEffect((()=>{$t(y)}),[y]),l.useEffect((()=>{dn(C)}),[C]),l.useEffect((()=>{Gn(b)}),[b]),l.useEffect((()=>{xn.current!==H&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")}),[H]),l.useEffect((()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:H==="core",disableBase:H}}))}),[]),l.useEffect((()=>{var Z;const le=new Set(Bt);let M=n;if(!M&&e&&(M=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),M)try{document.querySelectorAll(M).forEach((T=>{le.add({current:T})}))}catch{console.warn(`[react-tooltip] "${M}" is not a valid CSS selector`)}const $=document.querySelector(`[id='${t}']`);if($&&le.add({current:$}),!le.size)return()=>null;const ge=(Z=oe??$)!==null&&Z!==void 0?Z:gn.current,bt=new MutationObserver((T=>{T.forEach((R=>{var W;if(!ge||R.type!=="attributes"||!(!((W=R.attributeName)===null||W===void 0)&&W.startsWith("data-tooltip-")))return;const se=zt(ge);qt(se)}))})),S={attributes:!0,childList:!1,subtree:!1};if(ge){const T=zt(ge);qt(T),bt.observe(ge,S)}return()=>{bt.disconnect()}}),[Bt,gn,oe,t,n]),l.useEffect((()=>{z?.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),ie&&!_r("border",`${ie}`)&&console.warn(`[react-tooltip] "${ie}" is not a valid \`border\`.`),z?.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),Ke&&!_r("opacity",`${Ke}`)&&console.warn(`[react-tooltip] "${Ke}" is not a valid \`opacity\`.`)}),[]);let Wt=x;const vn=l.useRef(null);if(a){const Z=a({content:oe?.getAttribute("data-tooltip-content")||ft||null,activeAnchor:oe});Wt=Z?lt.createElement("div",{ref:vn,className:"react-tooltip-content-wrapper"},Z):null}else ft&&(Wt=ft);Mt&&(Wt=lt.createElement(Gm,{content:Mt}));const Yn={forwardRef:Is,id:e,anchorId:t,anchorSelect:n,className:no(i,fn),classNameArrow:c,content:Wt,contentWrapperRef:vn,place:pt,variant:xt,offset:he,wrapper:hn,events:mn,openOnClick:p,positionStrategy:Ft,middlewares:g,delayShow:Ot,delayHide:J,float:Kn,hidden:Qn,noArrow:_,clickable:I,closeOnEsc:j,closeOnScroll:N,closeOnResize:k,openEvents:O,closeEvents:G,globalCloseEvents:ae,imperativeModeOnly:Ne,style:z,position:E,isOpen:P,defaultIsOpen:U,border:ie,opacity:Ke,arrowColor:cn,arrowSize:V,setIsOpen:At,afterShow:Wn,afterHide:Un,disableTooltip:Hn,activeAnchor:oe,previousActiveAnchor:pn.current,setActiveAnchor:Z=>{me((le=>(Z?.isSameNode(le)||(pn.current=le),Z)))},role:It};return lt.createElement(Qm,{...Yn})}));typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",(e=>{e.detail.disableCore||Nr({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||Nr({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 en=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"})),ti=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})),Po=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"})),Ym=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})),Jm=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"})),Xm=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"})),ni=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"})),Zm=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M208 352h-64a96 96 0 010-192h64M304 160h64a96 96 0 010 192h-64M163.29 256h187.42",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:36})),As=()=>{const{pathname:e}=pe();return l.useMemo(()=>Yt({path:D.workbenchTab.path,end:!1},e)?.params.id,[e])},ef=()=>{const e=As(),t=ya();return{rename:async o=>{if(e){const r=await On("New tab name",o);r&&await t.mutateAsync({id:e,payload:{name:r}})}return Promise.resolve()}}},si=["shift","alt","meta","mod","ctrl","control"],tf={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 dt(e){return(tf[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function oi(e){return si.includes(e)}function Us(e,t=","){return e.toLowerCase().split(t)}function Hs(e,t="+",n=">",o=!1,r){let a=[],i=!1;e=e.trim(),e.includes(n)?(i=!0,a=e.toLocaleLowerCase().split(n).map(h=>dt(h))):a=e.toLocaleLowerCase().split(t).map(h=>dt(h));const c={alt:a.includes("alt"),ctrl:a.includes("ctrl")||a.includes("control"),shift:a.includes("shift"),meta:a.includes("meta"),mod:a.includes("mod"),useKey:o},d=a.filter(h=>!si.includes(h));return{...c,keys:d,description:r,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&ri([dt(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&ai([dt(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Je.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Je.clear()},0)}));const Je=new Set;function Oo(e){return Array.isArray(e)}function nf(e,t=","){return(Oo(e)?e:e.split(t)).every(n=>Je.has(n.trim().toLowerCase()))}function ri(e){const t=Array.isArray(e)?e:[e];Je.has("meta")&&Je.forEach(n=>!oi(n)&&Je.delete(n.toLowerCase())),t.forEach(n=>Je.add(n.toLowerCase()))}function ai(e){const t=Array.isArray(e)?e:[e];e==="meta"?Je.clear():t.forEach(n=>Je.delete(n.toLowerCase()))}function sf(e,t,n){(typeof n=="function"&&n(e,t)||n===!0)&&e.preventDefault()}function of(e,t,n){return typeof n=="function"?n(e,t):n===!0||n===void 0}const rf=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function af(e){return ii(e,rf)}function ii(e,t=!1){const{target:n,composed:o}=e;let r,a;return lf(n)&&o?(r=e.composedPath()[0]&&e.composedPath()[0].tagName,a=e.composedPath()[0]&&e.composedPath()[0].role):(r=n&&n.tagName,a=n&&n.role),Oo(t)?!!(r&&t&&t.some(i=>i.toLowerCase()===r.toLowerCase()||i===a)):!!(r&&t&&t)}function lf(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function cf(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 uf=(e,t,n=!1)=>{const{alt:o,meta:r,mod:a,shift:i,ctrl:c,keys:d,useKey:h}=t,{code:m,key:u,ctrlKey:x,metaKey:f,shiftKey:p,altKey:b}=e,g=dt(m);if(h&&d?.length===1&&d.includes(u))return!0;if(!d?.includes(g)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(g))return!1;if(!n){if(o!==b&&g!=="alt"||i!==p&&g!=="shift")return!1;if(a){if(!f&&!x)return!1}else if(r!==f&&g!=="meta"&&g!=="os"||c!==x&&g!=="ctrl"&&g!=="control")return!1}return d&&d.length===1&&d.includes(g)?!0:d?nf(d):!d},df=l.createContext(void 0),hf=()=>l.useContext(df);function li(e,t){return e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(e).length===Object.keys(t).length&&Object.keys(e).reduce((n,o)=>n&&li(e[o],t[o]),!0):e===t}const mf=l.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),ff=()=>l.useContext(mf);function pf(e){const t=l.useRef(void 0);return li(t.current,e)||(t.current=e),t.current}const Lr=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},xf=typeof window<"u"?l.useLayoutEffect:l.useEffect;function ze(e,t,n,o){const r=l.useRef(null),a=l.useRef(!1),i=Array.isArray(n)?Array.isArray(o)?void 0:o:n,c=Oo(e)?e.join(i?.delimiter):e,d=Array.isArray(n)?n:Array.isArray(o)?o:void 0,h=l.useCallback(t,d??[]),m=l.useRef(h);d?m.current=h:m.current=t;const u=pf(i),{activeScopes:x}=ff(),f=hf();return xf(()=>{if(u?.enabled===!1||!cf(x,u?.scopes))return;let p=[],b;const g=(C,_=!1)=>{if(!(af(C)&&!ii(C,u?.enableOnFormTags))){if(r.current!==null){const I=r.current.getRootNode();if((I instanceof Document||I instanceof ShadowRoot)&&I.activeElement!==r.current&&!r.current.contains(I.activeElement)){Lr(C);return}}C.target?.isContentEditable&&!u?.enableOnContentEditable||Us(c,u?.delimiter).forEach(I=>{if(I.includes(u?.splitKey??"+")&&I.includes(u?.sequenceSplitKey??">")){console.warn(`Hotkey ${I} contains both ${u?.splitKey??"+"} and ${u?.sequenceSplitKey??">"} which is not supported.`);return}const j=Hs(I,u?.splitKey,u?.sequenceSplitKey,u?.useKey,u?.description);if(j.isSequence){b=setTimeout(()=>{p=[]},u?.sequenceTimeoutMs??1e3);const N=j.useKey?C.key:dt(C.code);if(oi(N.toLowerCase()))return;p.push(N);const k=j.keys?.[p.length-1];if(N!==k){p=[],b&&clearTimeout(b);return}p.length===j.keys?.length&&(m.current(C,j),b&&clearTimeout(b),p=[])}else if(uf(C,j,u?.ignoreModifiers)||j.keys?.includes("*")){if(u?.ignoreEventWhen?.(C)||_&&a.current)return;if(sf(C,j,u?.preventDefault),!of(C,j,u?.enabled)){Lr(C);return}m.current(C,j),_||(a.current=!0)}})}},w=C=>{C.code!==void 0&&(ri(dt(C.code)),(u?.keydown===void 0&&u?.keyup!==!0||u?.keydown)&&g(C))},v=C=>{C.code!==void 0&&(ai(dt(C.code)),a.current=!1,u?.keyup&&g(C,!0))},y=r.current||i?.document||document;return y.addEventListener("keyup",v,i?.eventListenerOptions),y.addEventListener("keydown",w,i?.eventListenerOptions),f&&Us(c,u?.delimiter).forEach(C=>f.addHotkey(Hs(C,u?.splitKey,u?.sequenceSplitKey,u?.useKey,u?.description))),()=>{y.removeEventListener("keyup",v,i?.eventListenerOptions),y.removeEventListener("keydown",w,i?.eventListenerOptions),f&&Us(c,u?.delimiter).forEach(C=>f.removeHotkey(Hs(C,u?.splitKey,u?.sequenceSplitKey,u?.useKey,u?.description))),p=[],b&&clearTimeout(b)}},[c,u,x]),r}const[ci,gf]=So({storage:localStorage,localStorageKey:"useShowQueryInfo",initialData:!0});function vf(){return s.jsxs("div",{className:"flex md:grid md:grid-cols-3 items-center bg-white overflow-auto no-scrollbar",children:[s.jsx(bf,{}),s.jsx(yf,{}),s.jsx(jf,{})]})}function bf(){const{dataSourceId:e}=l.useContext(Pe),{data:t}=vs(e),{state:{table:n}}=l.useContext(je);return s.jsx("div",{className:L.tableConfig,children:t&&s.jsxs("div",{className:A(L.tableAction,L.dataSource),"data-tooltip-id":"default","data-tooltip-content":n,children:[s.jsx(He,{size:18,type:t.dbType}),s.jsx("p",{className:"text-sm",children:t.name}),s.jsx(en,{width:12,height:12}),s.jsx("p",{className:"text-sm",children:n})]})})}function yf(){const{page:e,size:t,setPage:n}=qa(),{data:o,isFetching:r}=l.useContext(nt),a=e*t,i=!r&&!!o?.result.hasMore,c=o?.result.rows.length||0,d=()=>{e>0&&n(e-1)},h=()=>{i&&n(e+1)};return s.jsxs("div",{className:A(L.tableConfig,"justify-self-center"),children:[s.jsx("span",{"data-tooltip-content":"Previous page","data-tooltip-id":"default",className:A(L.tableAction,L.gray,e<1&&"opacity-30"),onClick:d,role:"button",children:s.jsx(en,{width:16,height:16,className:"rotate-180"})}),s.jsxs("span",{"data-tooltip-id":"rows-num",className:L.paginationIndicator,children:[a+1," - ",a+c,i&&"+"]}),s.jsx("span",{"data-tooltip-content":"Next page","data-tooltip-id":"default",className:A(L.tableAction,i?L.gray:"opacity-30"),onClick:h,role:"button",children:s.jsx(en,{width:16,height:16})})]})}const wf=[5,10,20,50,100,200],Cf=!__CLIENT_CONFIG__.skipAuth;function jf(){const{dataSourceId:e,name:t}=l.useContext(Pe),{data:n}=vs(e),{data:o,refetch:r}=l.useContext(nt),a=In(fe.EDITOR),i=Wh(),{rename:c}=ef(),{size:d,setSize:h}=qa(),{state:m}=l.useContext(je),u=ci(),x=Tt(),f=te(),p=()=>{x.mutateAsync({name:t,opts:m}).then(y=>{f(D.workbenchTab.build({id:y.id}))})},b=()=>{if(o?.result.queryHistoryId){const y=new URL(window.location.href);y.pathname=D.share.build(),y.searchParams.set("shareId",o.result.queryHistoryId),navigator.clipboard.writeText(y.toString()),ue.success("Share link copied to clipboard")}},g=()=>{m.table&&Lh({table:m.table,dataSourceId:e})},w=async()=>{const y=await On("Query name",t);!y||!o?.result.queryHistoryId||i.mutate({name:y,queryId:o.result.queryHistoryId})},v=()=>c(t);return ze("s",w),ze("r",v),ze("d",p),s.jsxs("div",{className:"flex justify-self-end",children:[s.jsx("span",{"data-tooltip-content":"Show query info row","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:()=>gf(!u),role:"button",children:s.jsx(en,{width:16,height:16,className:u?"rotate-270":"rotate-90"})}),s.jsx("span",{"data-tooltip-content":"Show filters","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:()=>Ye("filters"),role:"button",children:s.jsx(Xm,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Join table","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:()=>Ye("joins"),role:"button",children:s.jsx(Zm,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Refresh data","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:()=>r(),role:"button",children:s.jsx(Po,{width:16,height:16})}),Cf&&s.jsx("span",{"data-tooltip-content":"Share query","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:b,role:"button",children:s.jsx(Jm,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Duplicate tab","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:p,role:"button",children:s.jsx(Ym,{width:16,height:16})}),n?.allowInsert===!0&&s.jsx("span",{"data-tooltip-content":"Insert new record","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:g,role:"button",children:s.jsx(ni,{width:16,height:16})}),s.jsx(kn,{id:"rows-num",className:"z-10 shadow-md flex gap-1",clickable:!0,variant:"light",opacity:1,children:wf.map(y=>s.jsx("button",{onClick:()=>h(y,!0),className:A(L.tableAction,L.gray,y===d&&L.selectedSize),children:s.jsx("span",{children:y})},y))}),s.jsx("button",{"data-tooltip-id":"explorer-more-actions",className:A(L.tableAction,L.gray),children:s.jsx(ti,{width:16,height:16})}),s.jsxs(kn,{id:"explorer-more-actions",className:"z-10 shadow-md flex flex-col",clickable:!0,variant:"light",opacity:1,children:[s.jsxs("button",{onClick:()=>Ye("hiddenColumns"),className:A(L.tableAction,L.modal,L.gray,"justify-between"),children:[s.jsx("span",{children:"Columns"}),s.jsx("span",{className:"hotkey",children:"C"})]}),s.jsxs("button",{onClick:()=>Ye("groupBy"),className:A(L.tableAction,L.modal,L.gray,"justify-between"),children:[s.jsx("span",{children:"Group by"}),s.jsx("span",{className:"hotkey",children:"G"})]}),s.jsxs("button",{onClick:()=>Ye("aggregate"),className:A(L.tableAction,L.modal,L.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:v,className:A(L.tableAction,L.modal,L.gray,"justify-between"),children:[s.jsx("span",{children:"Rename tab"}),s.jsx("span",{className:"hotkey",children:"R"})]}),a&&s.jsx(s.Fragment,{children:s.jsxs("button",{onClick:w,className:A(L.tableAction,L.modal,L.gray),children:[s.jsx("span",{children:"Save query"}),s.jsx("span",{className:"hotkey",children:"S"})]})})]})]})}const Nf="_drop-container_oxx3w_2",Sf="_item_oxx3w_2",Tr={dropContainer:Nf,item:Sf},ui=({dataSourceId:e,inputClassName:t,focusId:n,placeholder:o="Column",onChange:r,value:a,autoFocus:i,allowTables:c})=>{const{data:d}=bs(e),h=l.useRef(null),m=l.useMemo(()=>{if(!d)return[];let v=d;return c&&(v=d.filter(y=>c.includes(y.tableName))),v.flatMap(y=>y.columns.map(C=>({value:y.tableName+"."+C.name,label:C.name,table:y.tableName,searchValue:C.name.toLowerCase()})))},[d,c]),u=l.useMemo(()=>{const v=a.toLowerCase()||"",y=[];for(let C=0;C<m.length&&y.length<10;C++)m[C].searchValue.includes(v)&&y.push(m[C]);return y},[m,a]),[x,f]=l.useState(!1),[p,b]=l.useState(0),g=v=>{if(v.key==="ArrowDown")v.preventDefault(),b(y=>(y+1)%u.length);else if(v.key==="ArrowUp")v.preventDefault(),b(y=>(y-1+u.length)%u.length);else if(v.key==="Enter"&&p>=0&&p<u.length){v.preventDefault();const y=u[p].value;f(!1);const C=m.findIndex(_=>_.value===y)>-1;r(u[p]?.value||y,C,!0)}};l.useEffect(()=>{const v=h.current?.querySelector('[data-is-active="true"]');v&&v.scrollIntoView({behavior:"smooth",block:"nearest"})},[p]);const w=v=>{const y=v.currentTarget.value,C=m.findIndex(_=>_.value===y)>-1;r(y,C,!1)};return s.jsxs("div",{className:"relative",onFocus:()=>f(!0),onBlur:()=>f(!1),children:[s.jsx("input",{autoFocus:i,onKeyDown:g,value:a,onChange:w,className:t,placeholder:o,"data-focus":n}),x&&u.length>0&&s.jsx("div",{className:Tr.dropContainer,ref:h,tabIndex:-1,children:u.map((v,y)=>s.jsxs("div",{className:Tr.item,"data-is-active":p===y,onMouseDownCapture:C=>{C.preventDefault(),f(!1),r(v.value,!0,!0)},children:[s.jsx("span",{className:"text-xs font-semibold truncate",children:v.table}),s.jsx("p",{className:"truncate text-sm",children:v.label})]},y))})]})},_f="_actions_1hgps_2",kf="_filter-actions_1hgps_2",Ef="_filters-container_1hgps_2",Rf="_filter-container_1hgps_2",hs={actions:_f,filterActions:kf,filtersContainer:Ef,filterContainer:Rf},Lf=({filter:e,dataSourceId:t,allowedTables:n,autoFocus:o,onChangeColumn:r,onChangeValue:a,onRemoveFilter:i,triggerIsEnabled:c,onSubmit:d})=>{const h=m=>{m.key==="Enter"&&d()};return s.jsxs("div",{className:hs.filterContainer,children:[s.jsx("input",{className:"mr-1",type:"checkbox",checked:e.isEnabled!==!1,onClick:()=>c(e.id)}),s.jsx(ui,{dataSourceId:t,onChange:m=>r(e.id,m),value:e.column,allowTables:n,focusId:"column",inputClassName:"input w-full",autoFocus:o}),s.jsx(Dn,{prefix:"_",allowedModes:$n,onExpressionChange:m=>a(e.id,m),onKeyDown:h,placeholder:"Filter value",value:e.value,mode:e.mode,className:"h-8"}),s.jsx("div",{className:hs.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 ml-1",onClick:()=>i(e.id),children:s.jsx(tt,{width:20,height:20,className:"text-red-600"})})})]})},Tf=()=>{const{state:e}=l.useContext(je),{refetch:t}=l.useContext(nt),{setFilters:n}=wo(),o=_s(p=>p.filters),r=l.useMemo(()=>[e.table,...e.joins.map(p=>p.table)],[e.table,e.joins]),[a,i]=l.useState([]),c=(p,b)=>{i(g=>[...g.map(w=>w.id===p?{...w,column:b}:w)])},d=(p,b)=>{i(g=>[...g.map(w=>w.id===p?{...w,value:b.value,mode:b.mode}:w)])},h=()=>{i(p=>[...p,{id:qe(),value:"",column:"",isEnabled:!0,mode:"default"}])},m=p=>{i(b=>b.filter(g=>g.id!==p))},u=()=>ks("filters"),x=()=>{try{n(a.filter(p=>p.value.length>0&&p.column.length>0)),setTimeout(t,1),u()}catch(p){p instanceof Error?ue.error(p.message):ue.error("Error during parsing, check you filters")}},f=p=>{i(b=>b.map(g=>g.id===p?{...g,isEnabled:!g.isEnabled}:g))};return l.useEffect(()=>{o&&i(()=>[...e.filters,{id:qe(),value:"",column:"",isEnabled:!0,mode:"default"}])},[o]),ze("f",()=>{ls("filters")}),s.jsxs(Le,{isVisible:o,onClose:u,portal:!0,onClosed:()=>i([]),noPadding:!0,backdropClose:!0,children:[s.jsx(rn,{onClick:u}),s.jsx("h2",{className:"text-lg font-semibold m-2",children:"Filters"}),s.jsxs("div",{className:hs.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((p,b)=>s.jsx(Lf,{filter:p,dataSourceId:e.dataSourceId,allowedTables:r,onChangeColumn:c,onChangeValue:d,onRemoveFilter:m,triggerIsEnabled:f,onSubmit:x,autoFocus:b===a.length-1},p.id))]}),s.jsxs("div",{className:hs.actions,children:[s.jsxs("button",{className:"button tertiary flex items-center gap-1 text-sm",onClick:h,children:[s.jsx(ni,{width:20,height:20}),s.jsx("span",{children:"Add filter"})]}),s.jsx("button",{className:"button primary text-sm",onClick:x,children:"Apply filters"})]})]})},Af="_join-modal_13jxy_2",If={joinModal:Af},Mf=(e,t)=>e.type!==t.type||e.on!==t.on||e.table!==t.table,Pf=(e,t)=>e.type===t.type&&e.on===t.on&&e.table===t.table,di=()=>{const{state:e,setState:t}=l.useContext(je),n=l.useCallback(o=>{t(r=>{const a=r.joins;if(a.some(c=>Pf(c,o))){const c=o.table+".";return{...r,joins:a.filter(d=>Mf(d,o)),hiddenColumns:r.hiddenColumns.filter(d=>!d.value.startsWith(c)),groupBy:r.groupBy.filter(d=>!d.value.startsWith(c)),orderBy:r.orderBy.filter(d=>!d.column.startsWith(c)),aggregations:r.aggregations.filter(d=>!d.value.startsWith(c)),filters:r.filters.filter(d=>!d.column.startsWith(c))}}return{...r,joins:[...a,o]}})},[t]);return{joins:e.joins,toggle:n}},Of=()=>{const{isFetching:e}=l.useContext(nt),t=_s(d=>d.joins),{toggle:n}=di(),{availableJoins:o}=l.useContext(Pe),[r,a]=l.useState(""),i=l.useMemo(()=>{const d=r.toLowerCase();return o.filter(h=>h.fromTable.toLowerCase().includes(d))},[o,r]),c=()=>ks("joins");return ze("j",()=>{o.length>0?Ye("joins"):ue.error("No available tables to join")}),s.jsxs(Le,{isVisible:t,onClose:c,portal:!0,backdropClose:!0,children:[s.jsx(rn,{onClick:c}),s.jsxs("div",{className:If.joinModal,children:[s.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Join table"}),o.length>0?s.jsx("input",{className:"input w-full",placeholder:"Filter",autoFocus:!0,onChange:d=>a(d.target.value),value:r,disabled:e}):s.jsx(ve,{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(d=>s.jsx(yo,{hook:d,onClick:()=>{e||(n({table:d.direction==="in"?d.fromTable:d.toTable,type:"LEFT",on:fu(d)}),a(""),c())}},d.id))})]})]})},Df="_container_akfxd_2",$f="_not-active_akfxd_2",Ff="_group-by-label_akfxd_2",Bf="_active_akfxd_2",zf="_highlighted_akfxd_2",Xe={container:Df,notActive:$f,groupByLabel:Ff,active:Bf,highlighted:zf},hi=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M432 448a15.92 15.92 0 01-11.31-4.69l-352-352a16 16 0 0122.62-22.62l352 352A16 16 0 01432 448zM255.66 384c-41.49 0-81.5-12.28-118.92-36.5-34.07-22-64.74-53.51-88.7-91v-.08c19.94-28.57 41.78-52.73 65.24-72.21a2 2 0 00.14-2.94L93.5 161.38a2 2 0 00-2.71-.12c-24.92 21-48.05 46.76-69.08 76.92a31.92 31.92 0 00-.64 35.54c26.41 41.33 60.4 76.14 98.28 100.65C162 402 207.9 416 255.66 416a239.13 239.13 0 0075.8-12.58 2 2 0 00.77-3.31l-21.58-21.58a4 4 0 00-3.83-1 204.8 204.8 0 01-51.16 6.47zM490.84 238.6c-26.46-40.92-60.79-75.68-99.27-100.53C349 110.55 302 96 255.66 96a227.34 227.34 0 00-74.89 12.83 2 2 0 00-.75 3.31l21.55 21.55a4 4 0 003.88 1 192.82 192.82 0 0150.21-6.69c40.69 0 80.58 12.43 118.55 37 34.71 22.4 65.74 53.88 89.76 91a.13.13 0 010 .16 310.72 310.72 0 01-64.12 72.73 2 2 0 00-.15 2.95l19.9 19.89a2 2 0 002.7.13 343.49 343.49 0 0068.64-78.48 32.2 32.2 0 00-.1-34.78z"}),l.createElement("path",{d:"M256 160a95.88 95.88 0 00-21.37 2.4 2 2 0 00-1 3.38l112.59 112.56a2 2 0 003.38-1A96 96 0 00256 160zM165.78 233.66a2 2 0 00-3.38 1 96 96 0 00115 115 2 2 0 001-3.38z"}));function qf(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}function Ar(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}function Wf(e){if(!e)return[];const t={};return e.forEach(n=>{t[n.table]?t[n.table].push({value:n.full,columnName:n.column,type:n.type}):t[n.table]=[{value:n.full,columnName:n.column,type:n.type}],hu[n.type]&&["YEAR","MONTH","DAY"].forEach(o=>{t[n.table].push({value:o+" "+n.full,columnName:o+" "+n.column,type:"number",nested:!0})})}),Object.entries(t).reduce((n,[o,r])=>(n.push({name:o,columns:r}),n),[])}function Uf(e,t){const n=t.toLowerCase();let o=0;return e.map(r=>{const a=r.columns.filter(i=>i.columnName.toLowerCase().includes(n));return{...r,columns:a.map(i=>({...i,colIndex:o++}))}}).filter(r=>r.columns.length>0)}function Ir(e){document.querySelector(`[data-col-idx="${e}"]`)?.scrollIntoView({block:"nearest"})}function Hf(e,t){for(const n of e)for(const o of n.columns)if(o.colIndex===t)return o}const Vf=({column:e,selected:t,highlighted:n,onToggle:o})=>s.jsxs("div",{"data-col-idx":e.colIndex,className:A(Xe.groupByLabel,t?Xe.notActive:Xe.active,n&&Xe.highlighted),onClick:()=>o(e.value,!t),children:[t?s.jsx(hi,{width:16,height:16}):s.jsx(jo,{width:16,height:16}),s.jsxs("p",{className:"flex justify-between w-full",children:[s.jsx("span",{"data-tooltip-content":e.value,"data-tooltip-id":"default",children:e.columnName}),s.jsx("span",{className:"text-blue-600",children:e.type})]})]},e.value),Kf=({column:e,selected:t,highlighted:n,onToggle:o})=>s.jsxs("div",{"data-col-idx":e.colIndex,className:A(Xe.groupByLabel,t?Xe.notActive:Xe.active,n&&Xe.highlighted),onClick:()=>o(e.value,!t),children:[t?s.jsx(jo,{width:16,height:16}):s.jsx(hi,{width:16,height:16}),s.jsxs("p",{className:"flex justify-between w-full",children:[s.jsx("span",{"data-tooltip-content":e.value,"data-tooltip-id":"default",children:e.columnName}),s.jsx("span",{className:"text-blue-600",children:e.type})]})]},e.value),Qf={hiddenColumns:"c",groupBy:"g"},Mr=({mode:e})=>{const t=_s(j=>j[e]),{allColumns:n}=l.useContext(Pe),{state:o,setState:r}=l.useContext(je),[a,i]=l.useState({}),[c,d]=l.useState(""),[h,m]=l.useState(-1),u=l.useRef(null),x=l.useMemo(()=>Wf(n),[n]),f=o.aggregations.length>0||o.groupBy.length>0,{filtered:p,size:b}=l.useMemo(()=>{const j=Uf(x,c);return{filtered:j,size:j.reduce((N,k)=>N+k.columns.length,0)}},[c,x]),g=(j,N)=>{i(k=>({...k,[j]:N})),u.current?.focus()},w=()=>{i({})},v=()=>{ks(e)},y=()=>{const j=[];for(const N of x)for(const k of N.columns)if(a[k.value]===!0){const[O,G]=k.value.split(" ");j.push({value:G||O,fn:G?O:void 0})}r(N=>({...N,[e]:j})),v()},C=Object.values(a).some(j=>j);ze(Qf[e],()=>{e==="hiddenColumns"?f?ue.error("Columns are ignored when there is at least one aggregation or group by"):ls("hiddenColumns"):ls("groupBy")});const _=j=>{if(j.key==="ArrowDown"){const N=Math.min(h+1,b-1);j.preventDefault(),m(N),Ir(N)}else if(j.key==="ArrowUp"){const N=Math.max(h-1,-1);j.preventDefault(),m(N),Ir(N)}else if(j.key===" "){if(h>=0&&h<b){j.preventDefault();const N=Hf(p,h);N&&g(N.value,!a[N.value])}}else j.key==="Enter"&&(j.preventDefault(),y())};l.useEffect(()=>{t&&i(()=>qf(o[e].map(j=>j.fn?j.fn+" "+j.value:j.value)))},[t,i]);const I=()=>{d(""),i({}),m(-1)};return s.jsxs(Le,{isVisible:t,onClose:v,portal:!0,onClosed:I,backdropClose:!0,children:[s.jsx(rn,{onClick:v}),s.jsxs("div",{className:Xe.container,children:[s.jsx("h2",{className:"text-lg font-semibold",children:e==="groupBy"?"Group by":"Show columns"}),s.jsx("input",{ref:u,autoFocus:!0,className:"input my-2",placeholder:"Filter",value:c,onChange:j=>{m(-1),d(j.target.value)},onKeyDown:_}),s.jsx("div",{className:"overflow-y-auto",children:p.map(j=>s.jsxs("div",{className:"my-2",children:[s.jsxs("p",{className:"font-semibold sticky top-0 bg-white p-1 z-1",children:["📄 ",j.name]}),e==="hiddenColumns"&&j.columns.map(N=>s.jsx(Vf,{column:N,selected:a[N.value]===!0,highlighted:h===N.colIndex,onToggle:g},N.value)),e==="groupBy"&&j.columns.map(N=>s.jsx(Kf,{column:N,selected:a[N.value]===!0,highlighted:h===N.colIndex,onToggle:g},N.value))]},j.name))}),s.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[C&&s.jsx("button",{className:"button tertiary flex gap-2 items-center",onClick:w,children:s.jsx("span",{children:"Remove all"})}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{className:"button tertiary",onClick:v,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:y,children:"Apply"})]})]})]})},Gf="_options-container_1sxgn_2",Yf={optionsContainer:Gf},Vs="COUNT all",Jf=()=>{const e=_s(p=>p.aggregate),{dataSourceId:t}=l.useContext(Pe),{setState:n,state:o}=l.useContext(je),{data:r}=l.useContext(nt),[a,i]=l.useState({fn:"",col:""}),c=p=>i({...a,fn:p.currentTarget.value}),d=p=>i({...a,col:p}),h=()=>ks("aggregate"),m=()=>{const p=a.fn===Vs?{value:"*",fn:"COUNT"}:{fn:a.fn,value:a.col,distinct:a.fn==="COUNT"};n(b=>({...b,aggregations:[...b.aggregations,p]}))},u=a.fn===Vs,x=u?!1:!a.col||!a.fn,f=p=>{const b=mu(p);n(g=>({...g,aggregations:g.aggregations.filter(w=>w.fn!==p.fn||w.value!==p.value),orderBy:g.orderBy.filter(w=>w.column!==b)}))};return ze("a",()=>{ls("aggregate")}),s.jsxs(Le,{isVisible:e,onClose:h,backdropClose:!0,portal:!0,children:[s.jsx(rn,{onClick:h}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold",children:"Aggregate"}),ye(o.aggregations.length,0)&&s.jsx("div",{className:"flex flex-col gap-1 mt-4",children:o.aggregations.map((p,b)=>s.jsxs("p",{className:"p-2 rounded-md bg-gray-50 flex items-center justify-between",children:[s.jsx("span",{children:rs(p)}),s.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove aggregation",className:"p-0.5 text-sm cursor-pointer",onClick:()=>f(p),children:s.jsx(tt,{width:20,height:20,className:"text-red-600"})})]},b))}),s.jsxs("div",{className:Yf.optionsContainer,children:[s.jsxs("label",{className:A(u&&"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:c,autoFocus:!0,children:[s.jsx("option",{value:"",disabled:!0,children:"Select function"}),s.jsx("option",{value:Vs,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"})]})]}),!u&&s.jsxs("label",{children:[s.jsx("p",{className:"font-semibold text-xs",children:"Column"}),s.jsx(ui,{inputClassName:"input w-full",dataSourceId:t,allowTables:r?.result.tables||[],onChange:d,value:a.col})]}),s.jsx("button",{className:"button primary",disabled:x,onClick:m,children:"Add"})]})]})]})},Xf="_container_qojni_2",Zf="_yellow-pill_qojni_2 _pill_qojni_2",e0="_blue-pill_qojni_2 _pill_qojni_2",t0="_purple-pill_qojni_2 _pill_qojni_2",n0="_black-pill_qojni_2 _pill_qojni_2",s0="_disabled-pill_qojni_2",Ct={container:Xf,yellowPill:Zf,bluePill:e0,purplePill:t0,blackPill:n0,disabledPill:s0};function o0(e){return!(e===!0||e===void 0)}const r0=()=>{const{state:{aggregations:e,groupBy:t}}=l.useContext(je),{toggle:n,joins:o}=di(),{filters:r,setFilters:a,removeFilter:i}=wo(),c=()=>Ye("joins"),d=()=>Ye("aggregate"),h=()=>Ye("groupBy"),m=f=>{f.preventDefault(),f.stopPropagation(),n(o[o.length-1])},u=f=>{a(r.map(p=>({...p,isEnabled:f===p.id?o0(p.isEnabled):p.isEnabled})),!0)},x=f=>p=>{p.preventDefault(),p.stopPropagation(),i(f)};return r.length>0||o.length>0||t.length>0||e.length>0?s.jsxs("div",{className:Ct.container,children:[o.map((f,p)=>s.jsxs("button",{onClick:c,className:Ct.yellowPill,"data-tooltip-id":"default","data-tooltip-content":`Joins ${f.table} on ${f.on}`,children:[s.jsx("p",{className:"text-sm",children:f.table}),p===o.length-1&&s.jsx(tt,{onClick:m,width:18,height:18})]},f.table)),r.map(f=>s.jsxs("button",{onClick:()=>u(f.id),onAuxClick:()=>i(f.id),className:A(Ct.bluePill,f.isEnabled===!1&&Ct.disabledPill),"data-tooltip-id":"default","data-tooltip-content":`${f.column} ${f.value}`,children:[s.jsx("p",{className:"text-sm",children:f.column}),s.jsx("p",{className:"text-sm",children:f.value}),s.jsx(tt,{onClick:x(f.id),width:18,height:18})]},f.id)),e.map(f=>s.jsx("button",{onClick:d,className:A(Ct.purplePill),"data-tooltip-id":"default","data-tooltip-content":rs(f),children:s.jsx("p",{className:"text-sm",children:rs(f)})},rs(f))),t.length>0&&s.jsx("button",{onClick:h,className:A(Ct.blackPill),"data-tooltip-id":"default","data-tooltip-content":"Has GROUP BY",children:s.jsx("p",{className:"text-sm",children:"Grouped columns"})})]}):s.jsx("div",{className:A(Ct.container,"bg-(--bg-sec)! justify-center!"),children:s.jsx("p",{className:"text-gray-500 text-sm",children:"Empty"})})},a0=({options:e,updater:t,name:n,tabId:o})=>{const r=Qc(e,t),a=ou(o,r.state),i=Kc(a.data,r.state.dataSourceId,n,o),c=ci();return s.jsx(Pe,{value:i,children:s.jsx(je,{value:r,children:s.jsxs(nt,{value:a,children:[s.jsx(vf,{}),c&&s.jsx(r0,{}),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(qh,{})}),s.jsx(Tf,{}),s.jsx(Of,{}),s.jsx(Mr,{mode:"hiddenColumns"}),s.jsx(Mr,{mode:"groupBy"}),s.jsx(Jf,{})]})]})})})},Do=({size:e=32})=>s.jsxs("div",{role:"status",children:[s.jsxs("svg",{"aria-hidden":"true",width:e,height:e,className:"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..."})]}),i0=({id:e})=>{const{data:t}=nu(e),n=l.useCallback(o=>{if(!t)return;const r=o(Et(t.opts));X.setQueryData(["workbench-tabs",t.id],{...t,opts:{...t.opts,...r}})},[t]);return t?s.jsx(a0,{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(Do,{})})},Pr=e=>{setTimeout(t=>{const n=document.querySelector(`[data-tab-id="${t}"]`);n&&n.scrollIntoView({behavior:"smooth"})},50,e)},l0=()=>{const{data:e}=Cs(),t=su();return{workbenchTabs:e,archive:(o,r,a={})=>{t.mutate({tabId:o,...a});const i=e?.find(h=>h.id===r),c=e?.find(h=>h.id===o);let d;if(e&&i&&c){let h;if(a.all)h=[];else if(a.others)h=e.filter(m=>m.id===o),r!==o&&(d=o);else{const m=e.findIndex(u=>u.id===r);h=e.filter(u=>u.id!==o),h.length>m?d=h[m]?.id:h.length>0&&(d=h[h.length-1].id)}ws(()=>h),h.length===0&&(d="home")}return d}}},c0=()=>{const e=ya();return{rename:async(n,o)=>{if(o){const r=await On("New tab name",n);r&&await e.mutateAsync({id:o,payload:{name:r}})}return Promise.resolve()}}},u0=()=>{const{id:e}=yl(),t=te(),{workbenchTabs:n,archive:o}=l0(),{rename:r}=c0(),[a,i]=l.useState(void 0),c=l.useRef(null),d=La(vo.laptop),h=(f,p={})=>{c.current?.close();const b=o(f,e||"",p);b&&(b==="home"?t(D.home.build(),{replace:!0}):(Pr(b),t(D.workbenchTab.build({id:b}),{replace:!0})))},m=f=>{f.stopPropagation(),f.preventDefault();const p=f.currentTarget.getAttribute("data-tab-id");p&&h(p)},u=f=>{const p=f.currentTarget.getAttribute("data-tab-id");p&&c.current&&(f.preventDefault(),f.stopPropagation(),i(p),c.current.open(f))},x=f=>{const p=n?.find(b=>b.id===f);p&&(c.current?.close(),r(p.name,f))};return l.useEffect(()=>{e&&Pr(e)},[e,n]),s.jsxs("div",{className:"h-screen max-h-screen bg-(--bg) flex flex-col",children:[e?s.jsx(i0,{id:e}):s.jsx("div",{className:"flex-1"}),ye(n?.length,0)&&s.jsxs("div",{className:A($e.tabs,"no-scrollbar",!d&&$e.mobile),children:[s.jsx(Co,{ref:c,onClosed:()=>i(void 0),children:a&&s.jsxs("div",{className:$e.menu,children:[s.jsx("button",{className:$e.item,onClick:()=>x(a),children:"Rename"}),s.jsx("button",{className:$e.item,onClick:()=>h(a),children:"Close"}),s.jsx("div",{className:"border-t border-gray-200 my-1"}),s.jsx("button",{className:$e.item,onClick:()=>h(a,{others:!0}),children:"Close other tabs"}),s.jsx("button",{className:$e.item,onClick:()=>h(a,{all:!0}),children:"Close all tabs"})]})}),n?.map(f=>s.jsxs("div",{onClick:()=>t(D.workbenchTab.build({id:f.id})),className:A($e.tab,f.id===e&&$e.active),"data-tooltip-id":"default","data-tab-id":f.id,"data-tooltip-content":f.name,onAuxClick:()=>h(f.id),onContextMenu:u,children:[s.jsx("span",{className:"truncate w-full",children:f.name}),s.jsx("button",{"data-tab-id":f.id,className:$e.closeButton,onClick:m,children:s.jsx(tt,{width:20,height:20})})]},f.id))]})]})},d0="_root_6ljmn_2",h0="_up_6ljmn_2",m0="_down_6ljmn_2",f0="_chevron_6ljmn_2",p0="_table-name-container_6ljmn_2",x0="_link_6ljmn_2",g0="_table-name_6ljmn_2",v0="_ul_6ljmn_2",b0="_column-type_6ljmn_2",y0="_action-blue_6ljmn_2 _action_6ljmn_2",w0="_action-red_6ljmn_2 _action_6ljmn_2",C0="_db-header-container_6ljmn_2",j0="_db-header_6ljmn_2",N0="_db-subheader_6ljmn_2 _db-header_6ljmn_2",re={root:d0,up:h0,down:m0,chevron:f0,tableNameContainer:p0,link:x0,tableName:g0,ul:v0,columnType:b0,actionBlue:y0,actionRed:w0,dbHeaderContainer:C0,dbHeader:j0,dbSubheader:N0},S0="_sidebar_jbumn_2",_0="_sidebar-visible_jbumn_2",k0="_sidebar-container_jbumn_2",E0="_sidebar-invisible_jbumn_2",R0="_backdrop_jbumn_2",wn={sidebar:S0,sidebarVisible:_0,sidebarContainer:k0,sidebarInvisible:E0,backdrop:R0},qn=({children:e,backdropClose:t,isVisible:n,onClose:o,onClosed:r,contentClassName:a})=>{const[i,c]=l.useState(!1),d=()=>{t&&o()},h=m=>{n||getComputedStyle(m.currentTarget).opacity==="0"&&(c(!1),r&&r())};return l.useEffect(()=>{n&&c(!0)},[n]),js({onClose:d,enabled:n&&t===!0}),s.jsxs("div",{onTransitionEnd:h,className:A(wn.sidebar,n?wn.sidebarVisible:wn.sidebarInvisible),children:[s.jsx("div",{onClick:d,className:wn.backdrop}),s.jsx("div",{className:A(wn.sidebarContainer,a),children:i&&e})]})},oo=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})),L0=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"})),mi=(e,t=!0)=>{const n=navigator.clipboard.writeText(e);t&&n.then(()=>{ue.success(`Copied "${e}"`)})},T0=e=>{const t=l.useRef(!1);l.useEffect(()=>{e&&(e.status==="INSPECTING"?t.current=!0:e.status==="READY"&&t.current&&(zc(e.id),t.current=!1))},[e])},A0=new Intl.DateTimeFormat("en",{dateStyle:"full",timeStyle:"long"}),ts=18;function I0(e,t){return t&&e.toLowerCase().includes(t)?"bg-yellow-200 cursor-pointer":"cursor-pointer"}const M0=({insp:e,filter:t,expanded:n})=>{const o=l.useMemo(()=>n?e.columns:t.length<1?[]:e.columns.filter(r=>r.name.toLowerCase().includes(t)),[e,t,n]);return s.jsx("ul",{className:re.ul,children:o.map(r=>s.jsxs("li",{children:[r.isPrimary?"🔐":"🏷️"," ",s.jsx("span",{onClick:()=>mi(r.name),className:I0(r.name,t),children:r.name})," ",s.jsxs("span",{className:re.columnType,children:["[",r.type,"]"]}),r.ref&&s.jsxs("span",{children:[" ➡️ ",s.jsx("span",{className:re.columnType,children:r.ref.table}),".",r.ref.field]})]},r.name+r.type))},e.id)};function P0({id:e}){const{data:t}=vs(e),{data:n}=bs(e),o=te(),r=Wc(),a=ga(),i=Uc(),c=Tt(),d=l.useMemo(()=>t?.lastInspected?A0.format(new Date(t.lastInspected)):"--",[t]),[h,m]=l.useState({}),[u,x]=l.useState(""),[f,p]=l.useState("table"),b=In(fe.EDITOR),g=u.toLowerCase(),w=l.useMemo(()=>{if(!g||!n)return n||[];const k=[];for(const O of n){if(O.tableName.toLowerCase().includes(g)){k.push(O);continue}f!=="table"&&O.columns.findIndex(G=>G.name.toLowerCase().includes(g))>=0&&k.push(O)}return k},[g,n,f]),v=k=>{m(O=>({...O,[k]:!O[k]}))},y=k=>{c.mutateAsync({name:k,opts:Et({table:k,dataSourceId:e})}).then(O=>{Sn(void 0),o(D.workbenchTab.build({id:O.id}))})},C=()=>{a.mutate(e)},_=async()=>{const k=await On("Enter name",t?.name);k&&r.mutate({id:e,dataSource:{name:k}})},I=async()=>{await go("Are you sure you want to delete this data source and all related data (ex: saved queries)?")&&(i.mutate(e),Sn(void 0))};T0(t);const j=f==="column",N=t?.status==="INSPECTING";return s.jsxs("div",{className:re.root,children:[s.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-4 py-2 z-1",children:[s.jsxs("div",{className:re.dbHeaderContainer,children:[s.jsxs("div",{className:re.dbHeader,children:[t&&s.jsx(He,{size:24,type:t.dbType}),s.jsx("p",{className:"truncate text-(--text-color-primary) text-lg",children:t?.name})]}),s.jsxs("div",{className:re.dbSubheader,children:[s.jsx("p",{className:"text-xs text-(--text-color-secondary) truncate",children:d}),b&&s.jsxs("div",{className:"flex justify-end",children:[s.jsx("button",{disabled:a.isPending||N,onClick:C,className:re.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Refresh schema",children:s.jsx(Po,{width:16,height:16})}),s.jsx("button",{disabled:a.isPending,onClick:_,className:re.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Update name",children:s.jsx($a,{width:16,height:16})}),s.jsx("button",{disabled:a.isPending,onClick:I,className:re.actionRed,"data-tooltip-id":"default-xs","data-tooltip-content":"Delete data source",children:s.jsx(L0,{width:16,height:16})})]})]})]}),s.jsxs("div",{className:"flex gap-2 items-center mt-2",children:[s.jsxs("select",{className:"input text-sm",value:f,onChange:k=>p(k.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 text-sm",placeholder:j?"Search column":"Search table",value:u,onChange:k=>x(k.target.value),autoFocus:!0})]})]}),N&&s.jsxs("div",{className:"flex justify-center gap-2 items-center bg-blue-50 p-4 rounded",children:[s.jsx(Do,{size:16}),s.jsx("p",{className:"text-xs text-blue-800",children:"Inspecting schema"})]}),t?.status==="FAILED"&&s.jsx("div",{className:"flex justify-center gap-2 items-center bg-red-50 p-4 rounded",children:s.jsx("p",{className:"text-xs text-red-800",children:"Latest inspection failed"})}),s.jsx("div",{className:A("overflow-y-auto p-4",N&&"opacity-30"),children:w?.map(k=>s.jsxs("div",{children:[s.jsxs("div",{className:re.tableNameContainer,children:[s.jsx("button",{className:A(re.chevron,h[k.id]?re.down:re.up),onClick:()=>v(k.id),children:s.jsx(en,{width:16,height:16})}),s.jsx("button",{className:A(re.tableName,"flex-1"),onClick:()=>v(k.id),children:k.tableName}),s.jsx("button",{className:re.link,onClick:()=>y(k.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Explore table data",children:s.jsx(oo,{width:ts,height:ts})}),s.jsx("button",{className:re.link,onClick:()=>mi(k.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Copy table name",children:s.jsx(Da,{width:ts,height:ts})})]}),(h[k.id]||u.length>0)&&s.jsx(M0,{insp:k,filter:j?g:"",expanded:h[k.id]})]},k.id))})]})}const O0=()=>{const e=Qu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>Sn(void 0);return s.jsx(qn,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),backdropClose:!0,children:t&&s.jsx(P0,{id:t})})};function $o(e,t=500,n){const[o,r]=l.useState(e),a=l.useRef(n);return a.current=n,l.useEffect(()=>{const i=setTimeout(()=>{r(e),a.current&&a.current(e)},t);return()=>clearTimeout(i)},[e,t]),o}const D0="_search-container_16iuc_2",$0="_search_16iuc_2",F0="_entry_16iuc_2",B0="_ds_16iuc_2",z0="_ds-tooltip_16iuc_2",q0="_ds-entry_16iuc_2",W0="_ds-name_16iuc_2",it={searchContainer:D0,search:$0,entry:F0,ds:B0,dsTooltip:z0,dsEntry:q0,dsName:W0},[U0,H0]=So({initialData:[],localStorageKey:"selected-data-sources-v1"}),V0=e=>H0(t=>{const n=t.indexOf(e);return n>-1?(t.splice(n,1),[...t]):[...t,e]}),K0={table:"📄",query:"📖",tab:"🛠️"},Q0=({onTable:e,onQuery:t,onWorkbenchTab:n,autoFocus:o})=>{const[r,a]=l.useState(""),[i,c]=l.useState(-1),d=$o(r,200),h=U0(),{data:m}=Ce(),{data:u}=fo({teamId:m?.teamId}),x=l.useMemo(()=>{const v=[],y=Ar(h);if(!u||u.length===0)return[];for(const C of u)y[C.id]&&v.push(C.id);return v},[h,u]),{data:f}=Mc(d,{teamId:m?.teamId,selectedDataSources:x}),p=v=>{v.type==="table"?e(v.name,v.dataSourceId):v.type==="query"?t(v.id,v.dataSourceId):v.type==="tab"&&n(v.id,v.dataSourceId)},b=v=>{f&&(v.key==="ArrowDown"?(v.preventDefault(),c(y=>(y+1)%f.length)):v.key==="ArrowUp"?(v.preventDefault(),c(y=>(y-1+f.length)%f.length)):v.key==="Enter"&&i>=0&&f[i]?.name&&(v.preventDefault(),p(f[i])))},g=v=>{const y=v.currentTarget.dataset.tableId,C=f?.find(_=>_.id===y);C&&p(C)},w=l.useMemo(()=>Ar(h),[h]);return s.jsxs("div",{className:"overflow-hidden flex flex-col w-full lg:w-lg",children:[s.jsx(kn,{id:"datasources",clickable:!0,className:it.dsTooltip,variant:"light",place:"left-start",positionStrategy:"fixed",noArrow:!0,opacity:1,children:u?.map(v=>s.jsxs("button",{className:A(it.dsEntry,w[v.id]&&it.enabled),onClick:()=>V0(v.id),children:[s.jsx("input",{type:"checkbox",checked:!!w[v.id],readOnly:!0}),s.jsx("p",{className:it.dsName,children:v.name}),s.jsx("div",{children:s.jsx(He,{size:16,type:v.dbType})})]},v.id))}),xo(u?.length,1)&&s.jsx(ve,{variant:"warning",className:"mb-4",children:"Connect at least one data source to start using DataRamen"}),s.jsxs("div",{className:it.searchContainer,children:[s.jsx(an,{containerClassName:it.search,placeholder:"Search table or saved query to start from",value:r,onChange:v=>a(v.target.value),onKeyDown:b,autoFocus:o}),ye(u?.length,0)&&s.jsx("span",{"data-tooltip-id":"datasources",children:s.jsx(ti,{width:16,height:16})})]}),s.jsx("div",{className:"overflow-y-auto max-h-full mt-2",children:f?.map((v,y)=>s.jsxs("button",{className:it.entry,"data-is-active":i===y,"data-table-id":v.id,onClick:g,children:[s.jsxs("p",{className:"truncate",children:[K0[v.type]," ",v.name]}),s.jsxs("p",{className:it.ds,children:["📦 ",v.dataSourceName]})]},v.id))})]})},G0=()=>{const e=au(),t=(a,i)=>{e?.onConfirm("table",a,i)},n=(a,i)=>{e?.onConfirm("query",a,i)},o=(a,i)=>{e?.onConfirm("tab",a,i)},r=()=>{e?.onCancel()};return s.jsx(Le,{isVisible:!!e,onClose:r,backdropClose:!0,children:s.jsx(Q0,{autoFocus:!0,onTable:t,onQuery:n,onWorkbenchTab:o})})},Y0=()=>{const e=An(),t=te(),{pathname:n}=pe(),{data:o}=Ce(),{data:r}=Cs(),a=D.home.check(n);ze("n",()=>{o&&e()}),ze("w",()=>{o&&(r&&r.length>0?t(D.workbenchTab.build({id:r[0].id})):e())},{enabled:a}),ze("h",()=>{Jt({show:!0})})},[J0,fi]=xe(!1),Ks=()=>fi(!1),pi=()=>fi(!0),X0=({repeatPassword:e,password:t})=>t.length<1?null:t.length<8?s.jsx(ve,{variant:"warning",children:"New password should be at least 8 characters long"}):t!==e?s.jsx(ve,{variant:"warning",children:"Repeat password should match new password"}):null,Z0=()=>{const e=J0(),{data:t}=Ce(),{mutateAsync:n,isPending:o}=Hc(),r=te(),[{password:a,repeatPassword:i},{change:c,touched:d,reset:h}]=En({password:"",repeatPassword:""}),m=()=>{r("/"),fs.logout().then(()=>{Ks()})},u=()=>{n({password:a}).then(()=>{h(),ue.success("Password successfully updated!")})},x=a.length<8||a!==i||o,f=d.includes("password");return s.jsxs(Le,{isVisible:e,onClose:Ks,children:[s.jsx(rn,{onClick:Ks}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[s.jsx(ja,{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:c("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:c("repeatPassword")})]})]}),f&&s.jsx(X0,{password:a,repeatPassword:i}),s.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[s.jsx("button",{className:"button tertiary",disabled:x,onClick:u,children:"Update password"}),s.jsx("button",{className:"button danger",onClick:m,children:"Log out"})]})]})]})},[ep,xi]=xe(!1),gi=()=>xi(!0),Or=()=>xi(!1),tp=e=>we({queryKey:["team-users"],queryFn:async()=>{const{data:t}=await B.get("/teams/"+e+"/users");return t.data},enabled:!!e}),np=()=>ne({mutationFn:async({role:e,teamId:t,userId:n})=>(await B.patch("/teams/"+t+"/user-role",{role:e,userId:n}),!0),onSuccess:()=>{X.invalidateQueries({queryKey:["team-users"]})}}),sp=()=>ne({mutationFn:async({teamId:e,userId:t})=>(await B.delete("/teams/"+e,{params:{userId:t}}),!0),onSuccess:()=>{X.invalidateQueries({queryKey:["team-users"]})}}),op="_user-entry_159md_2",rp="_select-container_159md_2",Dr={userEntry:op,selectContainer:rp},ap=()=>{const e=ep(),{data:t}=Ce(),{data:n}=tp(t?.teamId),{mutate:o,isPending:r}=Vc(),{mutate:a,isPending:i}=np(),{mutate:c,isPending:d}=sp(),[h,{change:m,reset:u}]=En({password:"",username:""}),x=()=>{o({username:h.username,password:h.password,teamId:t?.teamId||""}),u()},f=(w,v)=>{a({teamId:t.teamId,role:v,userId:w})},p=w=>{go("Are you sure you want to remove this user?").then(v=>{v&&c({userId:w,teamId:t.teamId})})},b=In(fe.ADMIN),g=r||i||d;return s.jsxs(Le,{isVisible:e,onClose:Or,backdropClose:!0,children:[s.jsx(rn,{onClick:Or}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[s.jsx(ja,{children:"Manage users"}),ye(n?.length,0)&&s.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:n.map(w=>s.jsxs("div",{className:Dr.userEntry,children:[s.jsx("div",{className:Dr.selectContainer,children:s.jsxs("select",{value:w.role,disabled:!b||g,onChange:v=>f(w.id,v.currentTarget.value),children:[s.jsx("option",{value:fe.OWNER,children:"Owner"}),s.jsx("option",{value:fe.ADMIN,children:"Admin"}),s.jsx("option",{value:fe.EDITOR,children:"Editor"}),s.jsx("option",{value:fe.READ_ONLY,children:"Reader"})]})}),s.jsx("p",{className:"flex-1 mx-2",children:w.name}),b&&s.jsx("button",{className:"p-1 cursor-pointer text-red-500 text-sm",onClick:()=>p(w.id),children:"❌"})]},w.id))}),b&&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:m("username"),value:h.username,placeholder:"Username",disabled:g}),s.jsx("input",{className:"input",onChange:m("password"),value:h.password,type:"password",name:"newPassword",autoComplete:"new-password",placeholder:"Password",disabled:g}),s.jsx("button",{className:"button primary",onClick:x,disabled:g,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."})]})]})]})},ip="_gray-card_2pavo_2",lp="_login-label_2pavo_2",$r={grayCard:ip,loginLabel:lp},cp=()=>{const[e,t]=l.useState(""),[n,o]=l.useState(""),[r,a]=l.useState(),i=te(),c=d=>{d.preventDefault(),a(void 0),fs.login({password:n,username:e}).then(()=>{i("/",{replace:!0})}).catch(a)};return s.jsx("div",{className:"page-container bg-(--bg) h-screen",children:s.jsxs("div",{className:"page-content items-center",children:[s.jsxs("div",{className:"py-10 text-center w-full sticky top-0 z-0",children:[s.jsx("h1",{className:"comfortaa text-3xl font-semibold text-(--text-color-primary) mb-4",children:"Welcome to DataRamen!"}),s.jsx(_a,{})]}),s.jsxs("form",{className:$r.grayCard,onSubmit:c,children:[s.jsx("h2",{className:$r.loginLabel,children:"Login"}),r&&s.jsx(ve,{className:"border border-red-600",variant:"danger",children:"Failed to login. Please verify your credentials"}),s.jsx("input",{value:e,onChange:d=>t(d.currentTarget.value),className:"input secondary",placeholder:"User name"}),s.jsx("input",{value:n,onChange:d=>o(d.currentTarget.value),className:"input secondary",type:"password",placeholder:"Password"}),s.jsx("div",{className:"flex justify-end",children:s.jsx("button",{type:"submit",className:"button primary",children:"Login"})})]})]})})},up=()=>{const e=te(),{pathname:t}=pe(),{data:n,isLoading:o}=va();l.useEffect(()=>{!n&&!o&&!D.login.check(t)&&e(D.login.build())},[n,o,e,t])},dp=()=>{},hp=__CLIENT_CONFIG__.skipAuth?dp:up,mp=()=>{const[e]=dc(),t=te(),n=Tt(),o=e.get("shareId");return l.useEffect(()=>{o&&n.mutateAsync({queryId:o}).then(r=>{t(D.workbenchTab.build({id:r.id}),{replace:!0})})},[o]),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(Do,{}),s.jsx("p",{children:"Fetching query information"})]}),n.isError&&s.jsx(ve,{variant:"danger",children:"Failed to load query information"})]})},fp="_tab-container_wni5e_2",pp="_tab-name_wni5e_2",xp="_archived-badge_wni5e_2 _badge_wni5e_2",gp="_active-badge_wni5e_2 _badge_wni5e_2",vp="_delete-action_wni5e_2",Cn={tabContainer:fp,tabName:pp,archivedBadge:xp,activeBadge:gp,deleteAction:vp},vi=({title:e,onLoadMore:t,children:n,onClose:o,hasMore:r,onSearchValue:a,searchValue:i})=>s.jsxs("aside",{className:"max-w-full w-md no-scrollbar",children:[s.jsxs("div",{className:"sticky top-0 px-4 py-2 border-b border-gray-200 bg-white",children:[s.jsxs("h3",{className:"text-lg flex justify-between items-center",children:[s.jsx("span",{children:e}),o&&s.jsx("button",{className:"cursor-pointer hover:bg-(--bg-ter) rounded-full p-1",onClick:o,children:s.jsx(tt,{width:24,height:24})})]}),s.jsx(an,{containerClassName:"mt-2",className:"text-sm",placeholder:"Filter",value:i,autoFocus:!0,onChange:c=>a(c.target.value)})]}),n,r&&s.jsx("div",{className:"flex justify-center my-2",children:s.jsx("button",{className:"text-blue-800 text-sm p-2 cursor-pointer",onClick:t,children:"Load more"})})]}),bp=new Intl.DateTimeFormat,yp=()=>{const[e,t]=l.useState(""),n=$o(e),{data:o}=Ce(),{data:r,fetchNextPage:a,hasNextPage:i}=Pc(o?.teamId,n,25),c=te(),d=ba(),h=ru(),m=l.useRef(null),u=l.useRef(null),x=p=>{r?.find(g=>g.id===p)?.archived&&d.mutate(p),Jt({show:!1}),c(D.workbenchTab.build({id:p}))},f=()=>{m.current?.close(),h.mutate(u.current)};return s.jsxs(vi,{hasMore:i,onLoadMore:a,onClose:()=>Jt({show:!1}),searchValue:e,onSearchValue:t,title:"Recent tabs",children:[r?.map(p=>s.jsxs("div",{className:Cn.tabContainer,onClick:()=>x(p.id),onContextMenu:b=>{u.current=p.id,m.current?.open(b,!1)},children:[s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("p",{className:Cn.tabName,children:p.name}),p.dataSourceType&&s.jsx(He,{size:16,type:p.dataSourceType}),s.jsx("p",{className:"text-xs text-(--text-color-secondary)",children:p.dataSourceName})]}),s.jsxs("div",{className:"flex gap-2 items-center mt-1",children:[s.jsx("p",{className:"text-xs text-(--text-color-secondary) italic",children:bp.format(new Date(p.updatedAt))}),p.archived?s.jsx("span",{className:Cn.archivedBadge,children:"Archived"}):s.jsx("span",{className:Cn.activeBadge,children:"Active"})]})]},p.id)),s.jsx(Co,{ref:m,children:s.jsx("button",{onClick:f,className:Cn.deleteAction,children:"🗑 Delete"})})]})},wp=()=>{const e=Ku(t=>t.show);return s.jsx(qn,{isVisible:e,onClose:()=>Jt({show:!1}),backdropClose:!0,children:s.jsx(yp,{})})},Cp=()=>{const{data:e}=Ce(),t=$c(e?.teamId),n=te();return l.useEffect(()=>{t.mutateAsync().then(o=>{o?n(D.workbenchTab.build({id:o.id}),{replace:!0}):n(D.home.build(),{replace:!0})})},[]),null},jp="_query-entry_b47pm_2",Np={queryEntry:jp},Sp=new Intl.DateTimeFormat,_p=({projectQueries:e,isLoading:t})=>{const n=l.useRef(void 0),o=te(),r=Hh(),a=Tt(),i=Uh(),c=Ia(),d=u=>{a.isPending||a.mutateAsync({queryId:u}).then(x=>{Mn({show:!1}),o(D.workbenchTab.build({id:x.id}))})},h=async u=>{const x=e?.find(p=>p.id===u);if(!x)return;const f=await On("New name?",x?.name);f&&r.mutate({id:x.savedQueryId,payload:{name:f}})},m=u=>{const x=e?.find(f=>f.id===u)?.savedQueryId;x&&i.mutate(x)};return s.jsxs("div",{className:"flex flex-col px-2",children:[ye(e?.length,0)&&e.map(u=>s.jsxs("button",{className:Np.queryEntry,onClick:()=>d(u.id),onContextMenu:x=>{n.current=u.id,c.open(x)},children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-left text-sm font-semibold text-(--text-color-primary)",children:u.name}),s.jsx("p",{className:"text-left text-xs text-(--text-color-secondary) italic",children:Sp.format(new Date(u.updatedAt))})]}),s.jsxs("p",{className:"flex gap-2 items-center",children:[s.jsx(He,{size:16,type:u.datasourceType}),s.jsx("span",{className:"truncate text-xs text-(--text-color-secondary)",children:u.datasourceName})]})]},u.savedQueryId)),!t&&xo(e?.length,1)&&s.jsx("p",{className:"text-center text-sm text-(--text-color-secondary) mt-2",children:"Empty"}),s.jsx(Ma,{handler:c,children:s.jsxs("div",{className:"context-menu-container",children:[s.jsx("button",{onClick:u=>{u.preventDefault(),u.stopPropagation(),c.close(),h(n.current)},className:"context-menu-item",children:"✏️ Rename"}),s.jsx("button",{onClick:u=>{u.preventDefault(),u.stopPropagation(),c.close(),m(n.current)},className:"context-menu-item",children:"🗑️ Delete"})]})})]})},kp=()=>{const{data:e}=Ce(),[t,n]=l.useState(""),o=$o(t),{data:r,isLoading:a,fetchNextPage:i,hasNextPage:c}=Oc(e?.teamId,o);return s.jsx(vi,{hasMore:c,onClose:()=>Mn({show:!1}),onLoadMore:i,searchValue:t,onSearchValue:n,title:"Saved queries",children:s.jsx(_p,{isLoading:a,projectQueries:r||[]})})},Ep=()=>{const e=Vu(t=>t.show);return s.jsx(qn,{isVisible:e,onClose:()=>Mn({show:!1}),backdropClose:!0,children:s.jsx(kp,{})})},Rp=(e,t,n)=>we({queryKey:["entity",e,t,n],queryFn:async()=>{const{data:o}=await B.get(`/runner/${e}/entity/${t}`,{params:n?.reduce((r,a)=>(r[a[0]]=a[1],r),{})});return o.data},retry:1,enabled:!!t&&!!e&&!!n,staleTime:0}),bi=()=>ne({mutationFn:async e=>{const{data:t}=await B.post(`/runner/${e.datasourceId}/update`,e);return t.data}}),Lp=()=>ne({mutationFn:async e=>{const{data:t}=await B.post(`/runner/${e.datasourceId}/insert`,e);return t.data}}),Tp=({prop:e,entity:t,entityId:n,current:o,dataSourceId:r})=>{const[a,i]=l.useState({mode:"default",value:o?.toString()||""}),c=bi(),d=As(),h=()=>{const u=Object.entries(n).map(([x,f])=>({value:f.toString(),column:x,id:qe(),isEnabled:!0}));c.mutateAsync({datasourceId:r,table:t,values:{[e]:a},filters:u}).then(()=>{dr(),d&&po(d)})},m=u=>{u.key==="Enter"&&h()};return s.jsxs("div",{className:"w-full lg:w-lg",children:[s.jsxs("div",{className:"rounded-t-md bg-gray-50 border-b border-gray-100 px-4 py-2",children:[s.jsx("p",{className:"font-semibold text-sm",children:t}),s.jsx("p",{className:"text-xs",children:Object.entries(n).map(([u,x])=>`${u} = "${x}"`).join()})]}),s.jsxs("div",{className:"px-4 py-2",children:[s.jsx("p",{className:"font-semibold text-sm",children:e}),s.jsx(Dn,{prefix:"=",onExpressionChange:i,allowedModes:$n,value:a.value,mode:a.mode,className:"h-8",autoFocus:!0,onKeyUp:m,disabled:c.isPending}),s.jsxs("div",{className:"mt-2 flex gap-1 justify-end",children:[s.jsx("button",{disabled:c.isPending,className:"button primary",onClick:h,children:"Commit"}),s.jsx("button",{disabled:c.isPending,className:"button tertiary",onClick:dr,children:"Close"})]})]})]})},Ap=()=>{const e=Sh(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(Le,{backdropClose:!0,isVisible:!!e,onClose:Eo,onClosed:()=>n(void 0),noPadding:!0,children:t&&s.jsx(Tp,{prop:t.prop,entityId:t.entityId,current:t.current,entity:t.entity,dataSourceId:t.dataSourceId})})};function Ip(){return Y0(),hp(),s.jsxs(s.Fragment,{children:[s.jsxs(Pl,{children:[s.jsx(Kt,{path:D.home.path,element:s.jsx(ld,{})}),s.jsx(Kt,{path:D.workbench.path,element:s.jsx(Cp,{})}),s.jsx(Kt,{path:D.workbenchTab.path,element:s.jsx(u0,{})}),s.jsx(Kt,{path:D.login.path,element:s.jsx(cp,{})}),s.jsx(Kt,{path:D.share.path,element:s.jsx(mp,{})})]}),s.jsx(Ed,{}),s.jsx(Ap,{}),s.jsx(O0,{}),s.jsx(G0,{}),s.jsx(Z0,{}),s.jsx(ap,{}),s.jsx(wp,{}),s.jsx(Ep,{}),s.jsx(jd,{}),s.jsx(dd,{})]})}const Mp="_hidden_21709_2",Pp="_desktop-layout_21709_2",Op="_mobile-layout_21709_2",Dp="_nav_21709_2",$p="_shown_21709_2",Fp="_main_21709_2",Bp="_header_21709_2",zp="_expand_21709_2",qp="_show_21709_2",Wp="_hide_21709_2",Up="_icon_21709_2",Hp="_nav-item_21709_2",Vp="_project-wrapper_21709_2",F={hidden:Mp,desktopLayout:Pp,mobileLayout:Op,nav:Dp,shown:$p,main:Fp,header:Bp,expand:zp,show:qp,hide:Wp,icon:Up,navItem:Hp,projectWrapper:Vp},Kp=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"currentColor",d:"M507 211.16c-1.42-1.19-14.25-10.94-41.79-10.94a132.55 132.55 0 00-21.61 1.9c-5.22-36.4-35.38-54-36.57-55l-7.36-4.28-4.75 6.9a101.65 101.65 0 00-13.06 30.45c-5 20.7-1.9 40.2 8.55 56.85-12.59 7.14-33 8.8-37.28 9H15.94A15.93 15.93 0 000 262.07a241.25 241.25 0 0014.75 86.83C26.39 379.35 43.72 402 66 415.74 91.22 431.2 132.3 440 178.6 440a344.23 344.23 0 0062.45-5.71 257.44 257.44 0 0081.69-29.73 223.55 223.55 0 0055.57-45.67c26.83-30.21 42.74-64 54.38-94h4.75c29.21 0 47.26-11.66 57.23-21.65a63.31 63.31 0 0015.2-22.36l2.14-6.18z"}),l.createElement("path",{fill:"currentColor",d:"M47.29 236.37H92.4a4 4 0 004-4v-40.48a4 4 0 00-4-4H47.29a4 4 0 00-4 4v40.44a4.16 4.16 0 004 4M109.5 236.37h45.12a4 4 0 004-4v-40.48a4 4 0 00-4-4H109.5a4 4 0 00-4 4v40.44a4.16 4.16 0 004 4M172.9 236.37H218a4 4 0 004-4v-40.48a4 4 0 00-4-4h-45.1a4 4 0 00-4 4v40.44a3.87 3.87 0 004 4M235.36 236.37h45.12a4 4 0 004-4v-40.48a4 4 0 00-4-4h-45.12a4 4 0 00-4 4v40.44a4 4 0 004 4M109.5 178.57h45.12a4.16 4.16 0 004-4v-40.48a4 4 0 00-4-4H109.5a4 4 0 00-4 4v40.44a4.34 4.34 0 004 4M172.9 178.57H218a4.16 4.16 0 004-4v-40.48a4 4 0 00-4-4h-45.1a4 4 0 00-4 4v40.44a4 4 0 004 4M235.36 178.57h45.12a4.16 4.16 0 004-4v-40.48a4.16 4.16 0 00-4-4h-45.12a4 4 0 00-4 4v40.44a4.16 4.16 0 004 4M235.36 120.53h45.12a4 4 0 004-4V76a4.16 4.16 0 00-4-4h-45.12a4 4 0 00-4 4v40.44a4.17 4.17 0 004 4M298.28 236.37h45.12a4 4 0 004-4v-40.48a4 4 0 00-4-4h-45.12a4 4 0 00-4 4v40.44a4.16 4.16 0 004 4"})),Qp=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("rect",{x:32,y:48,width:448,height:416,rx:48,ry:48,fill:"none",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M96 112l80 64-80 64M192 240h64"})),Gp=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M304 336v40a40 40 0 01-40 40H104a40 40 0 01-40-40V136a40 40 0 0140-40h152c22.09 0 48 17.91 48 40v40M368 336l80-80-80-80M176 256h256",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),Yp=e=>l.createElement("svg",{className:"ionicon",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",...e},l.createElement("path",{d:"m 266.89,52 c -5,-5.28 -16.69,-5.34 -21.78,0 L 80,212 v 236 c 0,8.83656 7.163444,16 16,16 h 96 V 328 c 0,-13.25483 10.74517,-24 24,-24 h 80 c 13.25483,0 24,10.74517 24,24 v 136 h 96 c 8.83656,0 16,-7.16344 16,-16 l -0.16428,-236.06357 z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),Jp=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M344 144c-3.92 52.87-44 96-88 96s-84.15-43.12-88-96c-4-55 35-96 88-96s92 42 88 96z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M256 304c-87 0-175.3 48-191.64 138.6C62.39 453.52 68.57 464 80 464h352c11.44 0 17.62-10.48 15.65-21.4C431.3 352 343 304 256 304z",fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32})),Xp=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M402 168c-2.93 40.67-33.1 72-66 72s-63.12-31.32-66-72c-3-42.31 26.37-72 66-72s69 30.46 66 72z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M336 304c-65.17 0-127.84 32.37-143.54 95.41-2.08 8.34 3.15 16.59 11.72 16.59h263.65c8.57 0 13.77-8.25 11.72-16.59C463.85 335.36 401.18 304 336 304z",fill:"none",stroke:"currentColor",strokeMiterlimit:10,strokeWidth:32}),l.createElement("path",{d:"M200 185.94c-2.34 32.48-26.72 58.06-53 58.06s-50.7-25.57-53-58.06C91.61 152.15 115.34 128 147 128s55.39 24.77 53 57.94z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32}),l.createElement("path",{d:"M206 306c-18.05-8.27-37.93-11.45-59-11.45-52 0-102.1 25.85-114.65 76.2-1.65 6.66 2.53 13.25 9.37 13.25H154",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:10,strokeWidth:32})),Fr=!__CLIENT_CONFIG__.skipAuth,Br=(()=>{const e=__CLIENT_CONFIG__.serverVersion||"--";switch(__CLIENT_CONFIG__.modeName){case"docker":return`v${e} | Docker`;case"cli":return`v${e} | CLI`;case"dev":return`v${e} | DEV`;default:return`v${e} | Custom`}})(),ee=20,ke="text-(--text-color-primary)";function Zp(){switch(__CLIENT_CONFIG__.modeName){case"docker":return s.jsx(Kp,{className:ke,width:ee,height:ee});case"cli":return s.jsx(Qp,{className:ke,width:ee,height:ee});default:return s.jsx(Ea,{className:ke,width:ee,height:ee})}}const e1=({dataSource:e})=>s.jsxs("button",{className:F.navItem,onClick:()=>Sn(e.id),"data-tooltip-id":"default","data-tooltip-content":e.name,"data-tooltip-place":"right",children:[s.jsx("span",{className:F.icon,children:s.jsx(He,{size:20,type:e.dbType})}),s.jsx("span",{className:"truncate",children:e.name})]}),t1=()=>{const e=te(),{pathname:t}=pe(),{data:n}=Ce(),o=An(),[r,a]=l.useState(!1),{data:i}=Cs(),{data:c}=Ac(n?.teamId),d=()=>{D.home.check(t)||e(D.home.build())},h=p=>{D.workbenchTab.check(t)||e(D.workbenchTab.build({id:p}))},m=()=>{Mn({show:!0})},u=()=>{go("Are you sure you want to logout?").then(p=>{p&&(e("/"),fs.logout())})},x=()=>Jt({show:!0}),f=r?void 0:"default";return s.jsxs("nav",{className:A(F.nav,r?F.shown:F.hidden),children:[n&&s.jsxs("div",{className:F.header,children:[s.jsxs("button",{onClick:d,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"Home",children:[s.jsx("span",{className:F.icon,children:s.jsx(Yp,{className:ke,width:ee,height:ee})}),s.jsx("span",{className:"truncate",children:"Home"})]}),s.jsxs("button",{onClick:o,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"New query",children:[s.jsx("span",{className:F.icon,children:s.jsx(Pn,{className:ke,width:ee,height:ee})}),s.jsx("span",{className:"truncate",children:"New query"}),s.jsx("span",{className:"hotkey secondary",children:"N"})]}),s.jsxs("button",{onClick:x,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"Recent tabs",children:[s.jsx("span",{className:F.icon,children:s.jsx(Na,{className:ke,width:ee,height:ee})}),s.jsx("span",{className:"truncate",children:"Recent tabs"}),s.jsx("span",{className:"hotkey secondary",children:"H"})]}),s.jsxs("button",{onClick:m,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"Saved queries",children:[s.jsx("span",{className:F.icon,children:s.jsx(Ns,{className:ke,width:ee,height:ee})}),s.jsx("span",{className:"truncate",children:"Saved queries"})]}),ye(i?.length,0)&&s.jsxs("button",{onClick:()=>h(i[0].id),className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"Workbench",children:[s.jsx("span",{className:F.icon,children:s.jsx(Sa,{className:ke,width:ee,height:ee})}),s.jsx("span",{className:"truncate",children:"Workbench"}),s.jsx("span",{className:"hotkey secondary",children:"W"})]}),Fr&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:pi,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"User settings",children:[s.jsx("span",{className:F.icon,children:s.jsx(Jp,{className:ke,width:ee,height:ee})}),s.jsx("span",{className:"truncate",children:n.username})]}),s.jsxs("button",{onClick:gi,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"Manage users",children:[s.jsx("span",{className:F.icon,children:s.jsx(Xp,{className:ke,width:ee,height:ee})}),s.jsx("span",{className:"truncate",children:"Manage users"})]})]})]}),s.jsx("div",{className:A(F.projectWrapper),children:ye(c?.length,0)&&s.jsx("div",{className:"mt-4 flex flex-col",children:c.map(p=>s.jsx(e1,{dataSource:p},p.id))})}),Fr&&s.jsxs("button",{onClick:u,"data-tooltip-id":f,"data-tooltip-content":"Logout",className:`${F.navItem} mx-1`,children:[s.jsx("span",{className:F.icon,children:s.jsx(Gp,{className:ke,width:20,height:20})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:"Logout"})]}),s.jsxs("div",{className:`${F.navItem} mx-1 cursor-auto!`,"data-tooltip-id":f,"data-tooltip-content":Br,children:[s.jsx("span",{className:F.icon,children:s.jsx(Zp,{})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:Br})]}),s.jsxs("button",{onClick:()=>a(!r),"data-tooltip-id":"default","data-tooltip-content":"Expand sidebar","data-tooltip-hidden":r,"data-tooltip-place":"right",className:`${F.navItem} mx-1`,children:[s.jsx("span",{className:A(F.icon,F.expand,r?F.show:F.hide),children:s.jsx(en,{className:ke,width:20,height:20})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:"Collapse menu"})]})]})},n1="_root_1qcxm_2",s1={root:n1},yi=!__CLIENT_CONFIG__.skipAuth,o1=`${s1.root} ${yi?"grid-cols-4":"grid-cols-2"}`,r1=()=>{const{pathname:e}=pe(),t=te(),n=An(),o=()=>{D.home.check(e)||t(D.home.build())};return s.jsxs("div",{className:o1,children:[s.jsxs("button",{onClick:o,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"})]}),yi&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:pi,children:[s.jsx("p",{children:"🪪"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Account"})]}),s.jsxs("button",{onClick:gi,children:[s.jsx("p",{children:"👥"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Users"})]})]})]})},a1="_root_z3uno_2",i1="_container_z3uno_2",l1="_header_z3uno_2",c1="_fields-container_z3uno_2",u1="_field-label_z3uno_2",d1="_changed-marker_z3uno_2",h1="_action-icon_z3uno_2",Ge={root:a1,container:i1,header:l1,fieldsContainer:c1,fieldLabel:u1,changedMarker:d1,actionIcon:h1},m1=e=>{if(e==null)return"<NULL>";if(e==="")return"<EMPTY STRING>"},f1=e=>e.isPrimary?"🔐 "+e.name:e.ref?"🔑 "+e.name:e.name,wi=({data:e})=>{const t=Ah(E=>E.history),[n,{set:o,reset:r,touched:a,untouch:i}]=En({}),c=As(),d=te(),[h,m]=l.useState(0),[u,x]=l.useState(""),{data:f,isLoading:p,refetch:b}=Rp(e.dataSourceId,e.tableName,e.entityId),{mutateAsync:g,error:w,isPending:v}=bi(),y=Tt(),C=bo(w),_=In(fe.EDITOR),{data:I}=bs(e.dataSourceId),{data:j}=vs(e.dataSourceId),N=l.useMemo(()=>I?.find(E=>E.tableName===e.tableName),[e.tableName,I]),k=l.useMemo(()=>{if(!N)return[];if(!u)return N.columns;const E=u.toLowerCase();return N.columns.filter(P=>P.name.toLowerCase().includes(E))},[u,N]),O=l.useMemo(()=>{const E={};if(!f?.entity)return E;for(let P=0;P<f.columns.length;P++)E[f.columns[P]?.column]=m1(f.entity[P]);return E},[f]);l.useEffect(()=>{const E=f?.entity;if(r(),E&&f?.columns)for(let P=0;P<f.columns.length;P++){const U=f.columns[P];o(U.column,{value:ct(E[P]),mode:"default"})}},[f,o,r,h,e]);const G=()=>{const E={};for(const P of a)E[P]=n[P];g({datasourceId:e.dataSourceId,table:e.tableName,filters:e.entityId.map(P=>({id:qe(),value:""+P[1],column:P[0],isEnabled:!0})),values:E}).then(()=>{i(),ue.success("Record successfully updated."),b(),c&&po(c)})},ae=(E,P,U)=>{y.isPending||y.mutateAsync({name:`${E} ${P} = ${U}`,opts:Et({dataSourceId:e.dataSourceId,table:E,filters:[{value:`${U}`,column:`${E}.${P}`,id:qe(),isEnabled:!0}]})}).then(({id:H})=>{d(D.workbenchTab.build({id:H}))})},Ne=E=>{const P=t.find(U=>U.key===E);P&&ko(P,!1)},z=!j?.allowUpdate||!_||v;return s.jsxs("div",{className:Ge.root,children:[s.jsxs("div",{className:Ge.header,children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("select",{className:"input rounded-md! w-full",value:e?.key,onChange:E=>Ne(E.currentTarget.value),children:t.map(E=>s.jsxs("option",{value:E.key,children:[E.tableName," - ",E.entityId.map(P=>`${P[0]} = ${P[1]}`)]},E.key))}),!z&&s.jsx("button",{"data-tooltip-id":"default","data-tooltip-content":"Reset values",className:Ge.actionIcon,disabled:!a.length,onClick:()=>m(E=>++E),children:s.jsx(Po,{width:16,height:16})}),!z&&s.jsx("button",{"data-tooltip-id":"default","data-tooltip-content":"Commit changes",disabled:!a.length,onClick:G,className:Ge.actionIcon,children:s.jsx(Ns,{width:16,height:16})}),s.jsx("button",{className:Ge.actionIcon,onClick:Eo,children:s.jsx(tt,{width:20,height:20})})]}),C&&s.jsx(ve,{variant:"danger",children:s.jsx("p",{children:C})}),s.jsx(an,{containerClassName:"mt-2",className:"text-sm",value:u,onChange:E=>x(E.target.value),placeholder:"Filter columns"})]}),s.jsx("div",{className:Ge.container,children:s.jsx("div",{className:Ge.fieldsContainer,children:k.map(E=>s.jsxs("label",{className:Ge.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsxs("p",{children:[a.includes(E.name)&&s.jsx("span",{className:Ge.changedMarker}),f1(E)]}),s.jsx("p",{className:"text-blue-800 text-xs",children:E.type})]}),s.jsxs("div",{className:"flex items-center",children:[s.jsx(Dn,{prefix:"=",allowedModes:$n,disabled:E.isPrimary||p||z,value:ct(n[E.name]?.value),mode:n[E.name]?.mode,onExpressionChange:P=>o(E.name,P,!0),placeholder:O[E.name]}),E.ref&&s.jsx("button",{className:"cursor-pointer pl-2",onClick:()=>ae(E.ref.table,E.ref.field,n[E.name]?.value),children:s.jsx(oo,{width:16,height:16})}),E.isPrimary&&s.jsx("button",{className:"cursor-pointer pl-2",onClick:()=>ae(e.tableName,E.name,n[E.name]?.value),children:s.jsx(oo,{width:16,height:16})})]})]},E.name))})})]})},p1=()=>{const e=za();return e?s.jsx(wi,{data:e}):null},x1=()=>{const e=za(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(qn,{backdropClose:!0,isVisible:!!e,onClose:Eo,onClosed:()=>n(void 0),children:t&&s.jsx(wi,{data:t})})},g1="_root_mn1s4_2",v1="_container_mn1s4_2",b1="_header_mn1s4_2",y1="_fields-container_mn1s4_2",w1="_field-label_mn1s4_2",C1="_icon-action_mn1s4_2",jt={root:g1,container:v1,header:b1,fieldsContainer:y1,fieldLabel:w1,iconAction:C1},j1=e=>e.isPrimary?"🔐 "+e.name:e.ref?"🔑 "+e.name:e.name,Ci=({data:e})=>{const[t,{set:n,touched:o,reset:r}]=En({}),a=As(),{mutateAsync:i,error:c,isPending:d}=Lp(),h=bo(c),{data:m}=bs(e.dataSourceId),[u,x]=l.useState(""),f=l.useMemo(()=>m?.find(g=>g.tableName===e.table),[m,e.table]),p=l.useMemo(()=>{if(!f)return[];if(!u)return f.columns;const g=u.toLowerCase();return f.columns.filter(w=>w.name.toLowerCase().includes(g))},[u,f]),b=()=>{const g={};for(const w of o)g[w]=t[w];i({datasourceId:e.dataSourceId,table:e.table,values:g}).then(()=>{ue.success("Record successfully created."),a&&po(a)})};return l.useEffect(()=>{r()},[e]),s.jsxs("div",{className:jt.root,children:[s.jsxs("div",{className:jt.header,children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("p",{className:"text-lg flex-1 font-semibold underline",children:["New ",e.table]}),s.jsx("button",{"data-tooltip-id":"default","data-tooltip-content":"Commit changes",disabled:!o.length||d,className:jt.iconAction,onClick:b,children:s.jsx(Ns,{width:16,height:16})}),s.jsx("button",{className:jt.iconAction,onClick:Ba,children:s.jsx(tt,{width:20,height:20})})]}),h&&s.jsx(ve,{variant:"danger",children:s.jsx("p",{children:h})}),s.jsx(an,{containerClassName:"mt-2",className:"text-sm",value:u,onChange:g=>x(g.target.value),placeholder:"Filter columns"})]}),s.jsx("div",{className:jt.container,children:s.jsx("div",{className:jt.fieldsContainer,children:p.map(g=>s.jsxs("label",{className:jt.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsx("p",{children:j1(g)}),s.jsx("p",{className:"text-blue-800 text-xs",children:g.type})]}),s.jsx(Dn,{disabled:d,prefix:"=",allowedModes:$n,mode:t[g.name]?.mode,value:ct(t[g.name]?.value),onExpressionChange:w=>n(g.name,w,!0)})]},g.name))})})]})},N1=()=>{const e=Fa();return e?s.jsx(Ci,{data:e}):null},S1=()=>{const e=Fa(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(qn,{backdropClose:!0,isVisible:!!e,onClose:Ba,onClosed:()=>n(void 0),children:t&&s.jsx(Ci,{data:t})})},_1=({children:e,isLogin:t})=>s.jsxs("div",{className:F.desktopLayout,children:[s.jsx(kn,{id:"default",className:"z-500"}),s.jsx(kn,{id:"default-xs",className:"z-500 text-xs!"}),!t&&s.jsx(t1,{}),s.jsx("main",{className:F.main,children:e}),s.jsx(p1,{}),s.jsx(N1,{})]}),k1=({children:e,isLogin:t})=>s.jsxs("div",{className:F.mobileLayout,children:[s.jsx("main",{className:F.main,children:e}),s.jsx(x1,{}),s.jsx(S1,{}),!t&&s.jsx(r1,{})]}),E1=({children:e})=>{const t=La(vo.laptop),{pathname:n}=pe(),o=D.login.check(n);return t?s.jsx(_1,{isLogin:o,children:e}):s.jsx(k1,{isLogin:o,children:e})};Oi.createRoot(document.getElementById("root")).render(s.jsxs(lt.StrictMode,{children:[s.jsx(Di,{}),s.jsx(wc,{client:X,children:s.jsx(ac,{children:s.jsx(E1,{children:s.jsx(Ip,{})})})})]}));
|