@dataramen/cli 0.0.79 → 0.0.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/code/server.js +8 -8
- package/dist/code/web/assets/main-BI7zNByW.js +4 -0
- package/dist/code/web/assets/{main-CVXGxYiB.css → main-DmtcqnKx.css} +1 -1
- package/dist/code/web/index.html +2 -2
- package/dist/package.json +1 -1
- package/package.json +1 -1
- package/dist/code/web/assets/main--tJBQGt-.js +0 -4
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{r as l,a as ui,S as Tr,p as Do,b as Te,s as ss,c as yn,n as os,i as Hs,d as $o,t as di,e as Kn,f as hi,g as mi,h as Fo,j as us,k as Bo,l as fi,m as pi,o as qo,q as xi,u as s,v as to,w as J,x as B,y as Ar,A as ds,z as gi,B as A,C as kn,D as be,E as fe,F as bi,G as vi,R as at,H as yi,I as wi}from"./index-BH-53aoF.js";var Wo="popstate";function Ci(e={}){function t(o,r){let{pathname:a,search:i,hash:c}=o.location;return zs("",{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:wn(r)}return Ni(t,n,null,e)}function V(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 ji(){return Math.random().toString(36).substring(2,10)}function Uo(e,t){return{usr:e.state,key:e.key,idx:t}}function zs(e,t,n=null,o){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Xt(t):t,state:n,key:t&&t.key||o||ji()}}function wn({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 Xt(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 Ni(e,t,n,o={}){let{window:r=document.defaultView,v5Compat:a=!1}=o,i=r.history,c="POP",u=null,h=m();h==null&&(h=0,i.replaceState({...i.state,idx:h},""));function m(){return(i.state||{idx:null}).idx}function d(){c="POP";let v=m(),w=v==null?null:v-h;h=v,u&&u({action:c,location:b.location,delta:w})}function g(v,w){c="PUSH";let x=zs(b.location,v,w);h=m()+1;let y=Uo(x,h),C=b.createHref(x);try{i.pushState(y,"",C)}catch(_){if(_ instanceof DOMException&&_.name==="DataCloneError")throw _;r.location.assign(C)}a&&u&&u({action:c,location:b.location,delta:1})}function f(v,w){c="REPLACE";let x=zs(b.location,v,w);h=m();let y=Uo(x,h),C=b.createHref(x);i.replaceState(y,"",C),a&&u&&u({action:c,location:b.location,delta:0})}function p(v){return _i(v)}let b={get action(){return c},get location(){return e(r,i)},listen(v){if(u)throw new Error("A history only accepts one active listener");return r.addEventListener(Wo,d),u=v,()=>{r.removeEventListener(Wo,d),u=null}},createHref(v){return t(r,v)},createURL:p,encodeLocation(v){let w=p(v);return{pathname:w.pathname,search:w.search,hash:w.hash}},push:g,replace:f,go(v){return i.go(v)}};return b}function _i(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),V(n,"No window.location.(origin|href) available to create URL");let o=typeof e=="string"?e:wn(e);return o=o.replace(/ $/,"%20"),!t&&o.startsWith("//")&&(o=n+o),new URL(o,n)}function Ir(e,t,n="/"){return Si(e,t,n,!1)}function Si(e,t,n,o){let r=typeof t=="string"?Xt(t):t,a=Je(r.pathname||"/",n);if(a==null)return null;let i=Mr(e);ki(i);let c=null;for(let u=0;c==null&&u<i.length;++u){let h=$i(a);c=Oi(i[u],h,o)}return c}function Mr(e,t=[],n=[],o="",r=!1){let a=(i,c,u=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)&&u)return;V(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 d=Ye([o,m.relativePath]),g=n.concat(m);i.children&&i.children.length>0&&(V(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${d}".`),Mr(i.children,t,g,d,u)),!(i.path==null&&!i.index)&&t.push({path:d,score:Mi(d,i.index),routesMeta:g})};return e.forEach((i,c)=>{if(i.path===""||!i.path?.includes("?"))a(i,c);else for(let u of Pr(i.path))a(i,c,!0,u)}),t}function Pr(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=Pr(o.join("/")),c=[];return c.push(...i.map(u=>u===""?a:[a,u].join("/"))),r&&c.push(...i),c.map(u=>e.startsWith("/")&&u===""?"/":u)}function ki(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Pi(t.routesMeta.map(o=>o.childrenIndex),n.routesMeta.map(o=>o.childrenIndex)))}var Ei=/^:[\w-]+$/,Ri=3,Li=2,Ti=1,Ai=10,Ii=-2,Ho=e=>e==="*";function Mi(e,t){let n=e.split("/"),o=n.length;return n.some(Ho)&&(o+=Ii),t&&(o+=Li),n.filter(r=>!Ho(r)).reduce((r,a)=>r+(Ei.test(a)?Ri:a===""?Ti:Ai),o)}function Pi(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 Oi(e,t,n=!1){let{routesMeta:o}=e,r={},a="/",i=[];for(let c=0;c<o.length;++c){let u=o[c],h=c===o.length-1,m=a==="/"?t:t.slice(a.length)||"/",d=Gt({path:u.relativePath,caseSensitive:u.caseSensitive,end:h},m),g=u.route;if(!d&&h&&n&&!o[o.length-1].route.index&&(d=Gt({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},m)),!d)return null;Object.assign(r,d.params),i.push({params:r,pathname:Ye([a,d.pathname]),pathnameBase:Wi(Ye([a,d.pathnameBase])),route:g}),d.pathnameBase!=="/"&&(a=Ye([a,d.pathnameBase]))}return i}function Gt(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,o]=Di(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:d},g)=>{if(m==="*"){let p=c[g]||"";i=a.slice(0,a.length-p.length).replace(/(.)\/+$/,"$1")}const f=c[g];return d&&!f?h[m]=void 0:h[m]=(f||"").replace(/%2F/g,"/"),h},{}),pathname:a,pathnameBase:i,pattern:e}}function Di(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,u)=>(o.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)")).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 $i(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 Je(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 Or=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Fi=e=>Or.test(e);function Bi(e,t="/"){let{pathname:n,search:o="",hash:r=""}=typeof e=="string"?Xt(e):e,a;if(n)if(Fi(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=zo(n.substring(1),"/"):a=zo(n,t)}else a=t;return{pathname:a,search:Ui(o),hash:Hi(r)}}function zo(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 Ts(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 qi(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Dr(e){let t=qi(e);return t.map((n,o)=>o===t.length-1?n.pathname:n.pathnameBase)}function $r(e,t,n,o=!1){let r;typeof e=="string"?r=Xt(e):(r={...e},V(!r.pathname||!r.pathname.includes("?"),Ts("?","pathname","search",r)),V(!r.pathname||!r.pathname.includes("#"),Ts("#","pathname","hash",r)),V(!r.search||!r.search.includes("#"),Ts("#","search","hash",r)));let a=e===""||r.pathname==="",i=a?"/":r.pathname,c;if(i==null)c=n;else{let d=t.length-1;if(!o&&i.startsWith("..")){let g=i.split("/");for(;g[0]==="..";)g.shift(),d-=1;r.pathname=g.join("/")}c=d>=0?t[d]:"/"}let u=Bi(r,c),h=i&&i!=="/"&&i.endsWith("/"),m=(a||i===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||m)&&(u.pathname+="/"),u}var Ye=e=>e.join("/").replace(/\/\/+/g,"/"),Wi=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Ui=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Hi=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,zi=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 Vi(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Ki(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Fr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Br(e,t){let n=e;if(typeof n!="string"||!Or.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let o=n,r=!1;if(Fr)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),c=Je(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 qr=["POST","PUT","PATCH","DELETE"];new Set(qr);var Qi=["GET",...qr];new Set(Qi);var Zt=l.createContext(null);Zt.displayName="DataRouter";var hs=l.createContext(null);hs.displayName="DataRouterState";var Gi=l.createContext(!1),Wr=l.createContext({isTransitioning:!1});Wr.displayName="ViewTransition";var Yi=l.createContext(new Map);Yi.displayName="Fetchers";var Ji=l.createContext(null);Ji.displayName="Await";var Re=l.createContext(null);Re.displayName="Navigation";var En=l.createContext(null);En.displayName="Location";var He=l.createContext({outlet:null,matches:[],isDataRoute:!1});He.displayName="Route";var no=l.createContext(null);no.displayName="RouteError";var Ur="REACT_ROUTER_ERROR",Xi="REDIRECT",Zi="ROUTE_ERROR_RESPONSE";function el(e){if(e.startsWith(`${Ur}:${Xi}:{`))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 tl(e){if(e.startsWith(`${Ur}:${Zi}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new zi(t.status,t.statusText,t.data)}catch{}}function nl(e,{relative:t}={}){V(Rn(),"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}=Ln(e,{relative:t}),c=a;return n!=="/"&&(c=a==="/"?n:Ye([n,a])),o.createHref({pathname:c,search:i,hash:r})}function Rn(){return l.useContext(En)!=null}function pe(){return V(Rn(),"useLocation() may be used only in the context of a <Router> component."),l.useContext(En).location}var Hr="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function zr(e){l.useContext(Re).static||l.useLayoutEffect(e)}function te(){let{isDataRoute:e}=l.useContext(He);return e?xl():sl()}function sl(){V(Rn(),"useNavigate() may be used only in the context of a <Router> component.");let e=l.useContext(Zt),{basename:t,navigator:n}=l.useContext(Re),{matches:o}=l.useContext(He),{pathname:r}=pe(),a=JSON.stringify(Dr(o)),i=l.useRef(!1);return zr(()=>{i.current=!0}),l.useCallback((u,h={})=>{if(Ee(i.current,Hr),!i.current)return;if(typeof u=="number"){n.go(u);return}let m=$r(u,JSON.parse(a),r,h.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Ye([t,m.pathname])),(h.replace?n.replace:n.push)(m,h.state,h)},[t,n,a,r,e])}l.createContext(null);function ol(){let{matches:e}=l.useContext(He),t=e[e.length-1];return t?t.params:{}}function Ln(e,{relative:t}={}){let{matches:n}=l.useContext(He),{pathname:o}=pe(),r=JSON.stringify(Dr(n));return l.useMemo(()=>$r(e,JSON.parse(r),o,t==="path"),[e,r,o,t])}function rl(e,t){return Vr(e,t)}function Vr(e,t,n,o,r){V(Rn(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=l.useContext(Re),{matches:i}=l.useContext(He),c=i[i.length-1],u=c?c.params:{},h=c?c.pathname:"/",m=c?c.pathnameBase:"/",d=c&&c.route;{let x=d&&d.path||"";Qr(h,!d||x.endsWith("*")||x.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${x}">) 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="${x}"> to <Route path="${x==="/"?"*":`${x}/*`}">.`)}let g=pe(),f;if(t){let x=typeof t=="string"?Xt(t):t;V(m==="/"||x.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 "${x.pathname}" was given in the \`location\` prop.`),f=x}else f=g;let p=f.pathname||"/",b=p;if(m!=="/"){let x=m.replace(/^\//,"").split("/");b="/"+p.replace(/^\//,"").split("/").slice(x.length).join("/")}let v=Ir(e,{pathname:b});Ee(d||v!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),Ee(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${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=ul(v&&v.map(x=>Object.assign({},x,{params:Object.assign({},u,x.params),pathname:Ye([m,a.encodeLocation?a.encodeLocation(x.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?m:Ye([m,a.encodeLocation?a.encodeLocation(x.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:x.pathnameBase])})),i,n,o,r);return t&&w?l.createElement(En.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...f},navigationType:"POP"}},w):w}function al(){let e=pl(),t=Vi(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 il=l.createElement(al,null),Kr=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=tl(e.digest);n&&(e=n)}let t=e!==void 0?l.createElement(He.Provider,{value:this.props.routeContext},l.createElement(no.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?l.createElement(ll,{error:e},t):t}};Kr.contextType=Gi;var As=new WeakMap;function ll({children:e,error:t}){let{basename:n}=l.useContext(Re);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let o=el(t.digest);if(o){let r=As.get(t);if(r)throw r;let a=Br(o.location,n);if(Fr&&!As.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 As.set(t,i),i}return l.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function cl({routeContext:e,match:t,children:n}){let o=l.useContext(Zt);return o&&o.static&&o.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=t.route.id),l.createElement(He.Provider,{value:e},n)}function ul(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(d=>d.route.id&&i?.[d.route.id]!==void 0);V(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,u=-1;if(n)for(let m=0;m<a.length;m++){let d=a[m];if((d.route.HydrateFallback||d.route.hydrateFallbackElement)&&(u=m),d.route.id){let{loaderData:g,errors:f}=n,p=d.route.loader&&!g.hasOwnProperty(d.route.id)&&(!f||f[d.route.id]===void 0);if(d.route.lazy||p){c=!0,u>=0?a=a.slice(0,u+1):a=[a[0]];break}}}let h=n&&o?(m,d)=>{o(m,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:Ki(n.matches),errorInfo:d})}:void 0;return a.reduceRight((m,d,g)=>{let f,p=!1,b=null,v=null;n&&(f=i&&d.route.id?i[d.route.id]:void 0,b=d.route.errorElement||il,c&&(u<0&&g===0?(Qr("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),p=!0,v=null):u===g&&(p=!0,v=d.route.hydrateFallbackElement||null)));let w=t.concat(a.slice(0,g+1)),x=()=>{let y;return f?y=b:p?y=v:d.route.Component?y=l.createElement(d.route.Component,null):d.route.element?y=d.route.element:y=m,l.createElement(cl,{match:d,routeContext:{outlet:m,matches:w,isDataRoute:n!=null},children:y})};return n&&(d.route.ErrorBoundary||d.route.errorElement||g===0)?l.createElement(Kr,{location:n.location,revalidation:n.revalidation,component:b,error:f,children:x(),routeContext:{outlet:null,matches:w,isDataRoute:!0},onError:h}):x()},null)}function so(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function dl(e){let t=l.useContext(Zt);return V(t,so(e)),t}function hl(e){let t=l.useContext(hs);return V(t,so(e)),t}function ml(e){let t=l.useContext(He);return V(t,so(e)),t}function oo(e){let t=ml(e),n=t.matches[t.matches.length-1];return V(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function fl(){return oo("useRouteId")}function pl(){let e=l.useContext(no),t=hl("useRouteError"),n=oo("useRouteError");return e!==void 0?e:t.errors?.[n]}function xl(){let{router:e}=dl("useNavigate"),t=oo("useNavigate"),n=l.useRef(!1);return zr(()=>{n.current=!0}),l.useCallback(async(r,a={})=>{Ee(n.current,Hr),n.current&&(typeof r=="number"?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...a}))},[e,t])}var Vo={};function Qr(e,t,n){!t&&!Vo[e]&&(Vo[e]=!0,Ee(!1,n))}l.memo(gl);function gl({routes:e,future:t,state:n,onError:o}){return Vr(e,void 0,n,o,t)}function Vt(e){V(!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 bl({basename:e="/",children:t=null,location:n,navigationType:o="POP",navigator:r,static:a=!1,unstable_useTransitions:i}){V(!Rn(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),u=l.useMemo(()=>({basename:c,navigator:r,static:a,unstable_useTransitions:i,future:{}}),[c,r,a,i]);typeof n=="string"&&(n=Xt(n));let{pathname:h="/",search:m="",hash:d="",state:g=null,key:f="default"}=n,p=l.useMemo(()=>{let b=Je(h,c);return b==null?null:{location:{pathname:b,search:m,hash:d,state:g,key:f},navigationType:o}},[c,h,m,d,g,f,o]);return Ee(p!=null,`<Router basename="${c}"> is not able to match the URL "${h}${m}${d}" because it does not start with the basename, so the <Router> won't render anything.`),p==null?null:l.createElement(Re.Provider,{value:u},l.createElement(En.Provider,{children:t,value:p}))}function vl({children:e,location:t}){return rl(Vs(e),t)}function Vs(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,Vs(o.props.children,a));return}V(o.type===Vt,`[${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>`),V(!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=Vs(o.props.children,a)),n.push(i)}),n}var Xn="get",Zn="application/x-www-form-urlencoded";function ms(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function yl(e){return ms(e)&&e.tagName.toLowerCase()==="button"}function wl(e){return ms(e)&&e.tagName.toLowerCase()==="form"}function Cl(e){return ms(e)&&e.tagName.toLowerCase()==="input"}function jl(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Nl(e,t){return e.button===0&&(!t||t==="_self")&&!jl(e)}function Ks(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 _l(e,t){let n=Ks(e);return t&&t.forEach((o,r)=>{n.has(r)||t.getAll(r).forEach(a=>{n.append(r,a)})}),n}var Qn=null;function Sl(){if(Qn===null)try{new FormData(document.createElement("form"),0),Qn=!1}catch{Qn=!0}return Qn}var kl=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Is(e){return e!=null&&!kl.has(e)?(Ee(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Zn}"`),null):e}function El(e,t){let n,o,r,a,i;if(wl(e)){let c=e.getAttribute("action");o=c?Je(c,t):null,n=e.getAttribute("method")||Xn,r=Is(e.getAttribute("enctype"))||Zn,a=new FormData(e)}else if(yl(e)||Cl(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 u=e.getAttribute("formaction")||c.getAttribute("action");if(o=u?Je(u,t):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||Xn,r=Is(e.getAttribute("formenctype"))||Is(c.getAttribute("enctype"))||Zn,a=new FormData(c,e),!Sl()){let{name:h,type:m,value:d}=e;if(m==="image"){let g=h?`${h}.`:"";a.append(`${g}x`,"0"),a.append(`${g}y`,"0")}else h&&a.append(h,d)}}else{if(ms(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Xn,o=null,r=Zn,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 ro(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Rl(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&&Je(r.pathname,t)==="/"?r.pathname=`${t.replace(/\/$/,"")}/_root.${o}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${o}`,r}async function Ll(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 Tl(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 Al(e,t,n){let o=await Promise.all(e.map(async r=>{let a=t.routes[r.route.id];if(a){let i=await Ll(a,n);return i.links?i.links():[]}return[]}));return Ol(o.flat(1).filter(Tl).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function Ko(e,t,n,o,r,a){let i=(u,h)=>n[h]?u.route.id!==n[h].route.id:!0,c=(u,h)=>n[h].pathname!==u.pathname||n[h].route.path?.endsWith("*")&&n[h].params["*"]!==u.params["*"];return a==="assets"?t.filter((u,h)=>i(u,h)||c(u,h)):a==="data"?t.filter((u,h)=>{let m=o.routes[u.route.id];if(!m||!m.hasLoader)return!1;if(i(u,h)||c(u,h))return!0;if(u.route.shouldRevalidate){let d=u.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:u.params,defaultShouldRevalidate:!0});if(typeof d=="boolean")return d}return!0}):[]}function Il(e,t,{includeHydrateFallback:n}={}){return Ml(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 Ml(e){return[...new Set(e)]}function Pl(e){let t={},n=Object.keys(e).sort();for(let o of n)t[o]=e[o];return t}function Ol(e,t){let n=new Set;return new Set(t),e.reduce((o,r)=>{let a=JSON.stringify(Pl(r));return n.has(a)||(n.add(a),o.push({key:a,link:r})),o},[])}function Gr(){let e=l.useContext(Zt);return ro(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Dl(){let e=l.useContext(hs);return ro(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var ao=l.createContext(void 0);ao.displayName="FrameworkContext";function Yr(){let e=l.useContext(ao);return ro(e,"You must render this element inside a <HydratedRouter> element"),e}function $l(e,t){let n=l.useContext(ao),[o,r]=l.useState(!1),[a,i]=l.useState(!1),{onFocus:c,onBlur:u,onMouseEnter:h,onMouseLeave:m,onTouchStart:d}=t,g=l.useRef(null);l.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let b=w=>{w.forEach(x=>{i(x.isIntersecting)})},v=new IntersectionObserver(b,{threshold:.5});return g.current&&v.observe(g.current),()=>{v.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,g,{}]:[a,g,{onFocus:gn(c,f),onBlur:gn(u,p),onMouseEnter:gn(h,f),onMouseLeave:gn(m,p),onTouchStart:gn(d,f)}]:[!1,g,{}]}function gn(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Fl({page:e,...t}){let{router:n}=Gr(),o=l.useMemo(()=>Ir(n.routes,e,n.basename),[n.routes,e,n.basename]);return o?l.createElement(ql,{page:e,matches:o,...t}):null}function Bl(e){let{manifest:t,routeModules:n}=Yr(),[o,r]=l.useState([]);return l.useEffect(()=>{let a=!1;return Al(e,t,n).then(i=>{a||r(i)}),()=>{a=!0}},[e,t,n]),o}function ql({page:e,matches:t,...n}){let o=pe(),{future:r,manifest:a,routeModules:i}=Yr(),{basename:c}=Gr(),{loaderData:u,matches:h}=Dl(),m=l.useMemo(()=>Ko(e,t,h,a,o,"data"),[e,t,h,a,o]),d=l.useMemo(()=>Ko(e,t,h,a,o,"assets"),[e,t,h,a,o]),g=l.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let b=new Set,v=!1;if(t.forEach(x=>{let y=a.routes[x.route.id];!y||!y.hasLoader||(!m.some(C=>C.route.id===x.route.id)&&x.route.id in u&&i[x.route.id]?.shouldRevalidate||y.hasClientLoader?v=!0:b.add(x.route.id))}),b.size===0)return[];let w=Rl(e,c,r.unstable_trailingSlashAwareDataRequests,"data");return v&&b.size>0&&w.searchParams.set("_routes",t.filter(x=>b.has(x.route.id)).map(x=>x.route.id).join(",")),[w.pathname+w.search]},[c,r.unstable_trailingSlashAwareDataRequests,u,o,a,m,t,e,i]),f=l.useMemo(()=>Il(d,a),[d,a]),p=Bl(d);return l.createElement(l.Fragment,null,g.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:v})=>l.createElement("link",{key:b,nonce:n.nonce,...v})))}function Wl(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Ul=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Ul&&(window.__reactRouterVersion="7.12.0")}catch{}function Hl({basename:e,children:t,unstable_useTransitions:n,window:o}){let r=l.useRef();r.current==null&&(r.current=Ci({window:o,v5Compat:!0}));let a=r.current,[i,c]=l.useState({action:a.action,location:a.location}),u=l.useCallback(h=>{n===!1?c(h):l.startTransition(()=>c(h))},[n]);return l.useLayoutEffect(()=>a.listen(u),[a,u]),l.createElement(bl,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a,unstable_useTransitions:n})}var Jr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Xr=l.forwardRef(function({onClick:t,discover:n="render",prefetch:o="none",relative:r,reloadDocument:a,replace:i,state:c,target:u,to:h,preventScrollReset:m,viewTransition:d,unstable_defaultShouldRevalidate:g,...f},p){let{basename:b,unstable_useTransitions:v}=l.useContext(Re),w=typeof h=="string"&&Jr.test(h),x=Br(h,b);h=x.to;let y=nl(h,{relative:r}),[C,_,I]=$l(o,f),S=Ql(h,{replace:i,state:c,target:u,preventScrollReset:m,relative:r,viewTransition:d,unstable_defaultShouldRevalidate:g,unstable_useTransitions:v});function P(O){t&&t(O),O.defaultPrevented||S(O)}let k=l.createElement("a",{...f,...I,href:x.absoluteURL||y,onClick:x.isExternal||a?t:P,ref:Wl(p,_),target:u,"data-discover":!w&&n==="render"?"true":void 0});return C&&!w?l.createElement(l.Fragment,null,k,l.createElement(Fl,{page:y})):k});Xr.displayName="Link";var zl=l.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:o="",end:r=!1,style:a,to:i,viewTransition:c,children:u,...h},m){let d=Ln(i,{relative:h.relative}),g=pe(),f=l.useContext(hs),{navigator:p,basename:b}=l.useContext(Re),v=f!=null&&ec(d)&&c===!0,w=p.encodeLocation?p.encodeLocation(d).pathname:d.pathname,x=g.pathname,y=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;n||(x=x.toLowerCase(),y=y?y.toLowerCase():null,w=w.toLowerCase()),y&&b&&(y=Je(y,b)||y);const C=w!=="/"&&w.endsWith("/")?w.length-1:w.length;let _=x===w||!r&&x.startsWith(w)&&x.charAt(C)==="/",I=y!=null&&(y===w||!r&&y.startsWith(w)&&y.charAt(w.length)==="/"),S={isActive:_,isPending:I,isTransitioning:v},P=_?t:void 0,k;typeof o=="function"?k=o(S):k=[o,_?"active":null,I?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let O=typeof a=="function"?a(S):a;return l.createElement(Xr,{...h,"aria-current":P,className:k,ref:m,style:O,to:i,viewTransition:c},typeof u=="function"?u(S):u)});zl.displayName="NavLink";var Vl=l.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:o,replace:r,state:a,method:i=Xn,action:c,onSubmit:u,relative:h,preventScrollReset:m,viewTransition:d,unstable_defaultShouldRevalidate:g,...f},p)=>{let{unstable_useTransitions:b}=l.useContext(Re),v=Xl(),w=Zl(c,{relative:h}),x=i.toLowerCase()==="get"?"get":"post",y=typeof c=="string"&&Jr.test(c),C=_=>{if(u&&u(_),_.defaultPrevented)return;_.preventDefault();let I=_.nativeEvent.submitter,S=I?.getAttribute("formmethod")||i,P=()=>v(I||_.currentTarget,{fetcherKey:t,method:S,navigate:n,replace:r,state:a,relative:h,preventScrollReset:m,viewTransition:d,unstable_defaultShouldRevalidate:g});b&&n!==!1?l.startTransition(()=>P()):P()};return l.createElement("form",{ref:p,method:x,action:w,onSubmit:o?u:C,...f,"data-discover":!y&&e==="render"?"true":void 0})});Vl.displayName="Form";function Kl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Zr(e){let t=l.useContext(Zt);return V(t,Kl(e)),t}function Ql(e,{target:t,replace:n,state:o,preventScrollReset:r,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:c,unstable_useTransitions:u}={}){let h=te(),m=pe(),d=Ln(e,{relative:a});return l.useCallback(g=>{if(Nl(g,t)){g.preventDefault();let f=n!==void 0?n:wn(m)===wn(d),p=()=>h(e,{replace:f,state:o,preventScrollReset:r,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:c});u?l.startTransition(()=>p()):p()}},[m,h,d,n,o,t,e,r,a,i,c,u])}function Gl(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(Ks(e)),n=l.useRef(!1),o=pe(),r=l.useMemo(()=>_l(o.search,n.current?null:t.current),[o.search]),a=te(),i=l.useCallback((c,u)=>{const h=Ks(typeof c=="function"?c(new URLSearchParams(r)):c);n.current=!0,a("?"+h,u)},[a,r]);return[r,i]}var Yl=0,Jl=()=>`__${String(++Yl)}__`;function Xl(){let{router:e}=Zr("useSubmit"),{basename:t}=l.useContext(Re),n=fl(),o=e.fetch,r=e.navigate;return l.useCallback(async(a,i={})=>{let{action:c,method:u,encType:h,formData:m,body:d}=El(a,t);if(i.navigate===!1){let g=i.fetcherKey||Jl();await o(g,n,i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:m,body:d,formMethod:i.method||u,formEncType:i.encType||h,flushSync:i.flushSync})}else await r(i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:m,body:d,formMethod:i.method||u,formEncType:i.encType||h,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[o,r,t,n])}function Zl(e,{relative:t}={}){let{basename:n}=l.useContext(Re),o=l.useContext(He);V(o,"useFormAction must be used inside a RouteContext");let[r]=o.matches.slice(-1),a={...Ln(e||".",{relative:t})},i=pe();if(e==null){a.search=i.search;let c=new URLSearchParams(a.search),u=c.getAll("index");if(u.some(m=>m==="")){c.delete("index"),u.filter(d=>d).forEach(d=>c.append("index",d));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:Ye([n,a.pathname])),wn(a)}function ec(e,{relative:t}={}){let n=l.useContext(Wr);V(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Zr("useViewTransitionState"),r=Ln(e,{relative:t});if(!n.isTransitioning)return!1;let a=Je(n.currentLocation.pathname,o)||n.currentLocation.pathname,i=Je(n.nextLocation.pathname,o)||n.nextLocation.pathname;return Gt(r.pathname,i)!=null||Gt(r.pathname,a)!=null}var io=ui(),ea=class extends Tr{constructor(e,t){super(),this.options=t,this.#n=e,this.#i=null,this.#a=Do(),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),Qo(this.#e,this.options)?this.#d():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Qs(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Qs(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 Te(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&&!ss(this.options,t)&&this.#n.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const o=this.hasListeners();o&&Go(this.#e,n,this.options,t)&&this.#d(),this.updateResult(),o&&(this.#e!==n||Te(this.options.enabled,this.#e)!==Te(t.enabled,this.#e)||yn(this.options.staleTime,this.#e)!==yn(t.staleTime,this.#e))&&this.#x();const r=this.#g();o&&(this.#e!==n||Te(this.options.enabled,this.#e)!==Te(t.enabled,this.#e)||r!==this.#l)&&this.#b(r)}getOptimisticResult(e){const t=this.#n.getQueryCache().build(this.#n,e),n=this.createResult(t,e);return nc(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(os)),t}#x(){this.#y();const e=yn(this.options.staleTime,this.#e);if(Hs||this.#t.isStale||!$o(e))return;const n=di(this.#t.dataUpdatedAt,e)+1;this.#c=Kn.setTimeout(()=>{this.#t.isStale||this.updateResult()},n)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(e){this.#w(),this.#l=e,!(Hs||Te(this.options.enabled,this.#e)===!1||!$o(this.#l)||this.#l===0)&&(this.#u=Kn.setInterval(()=>{(this.options.refetchIntervalInBackground||hi.isFocused())&&this.#d()},this.#l))}#v(){this.#x(),this.#b(this.#g())}#y(){this.#c&&(Kn.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(Kn.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,u=e!==n?e.state:this.#s,{state:h}=e;let m={...h},d=!1,g;if(t._optimisticResults){const P=this.hasListeners(),k=!P&&Qo(e,t),O=P&&Go(e,n,t,o);(k||O)&&(m={...m,...mi(h.data,e.options)}),t._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:f,errorUpdatedAt:p,status:b}=m;g=m.data;let v=!1;if(t.placeholderData!==void 0&&g===void 0&&b==="pending"){let P;r?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(P=r.data,v=!0):P=typeof t.placeholderData=="function"?t.placeholderData(this.#m?.state.data,this.#m):t.placeholderData,P!==void 0&&(b="success",g=Fo(r?.data,P,t),d=!0)}if(t.select&&g!==void 0&&!v)if(r&&g===a?.data&&t.select===this.#p)g=this.#h;else try{this.#p=t.select,g=t.select(g),g=Fo(r?.data,g,t),this.#h=g,this.#i=null}catch(P){this.#i=P}this.#i&&(f=this.#i,g=this.#h,p=Date.now(),b="error");const w=m.fetchStatus==="fetching",x=b==="pending",y=b==="error",C=x&&w,_=g!==void 0,S={status:b,fetchStatus:m.fetchStatus,isPending:x,isSuccess:b==="success",isError:y,isInitialLoading:C,isLoading:C,data:g,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>u.dataUpdateCount||m.errorUpdateCount>u.errorUpdateCount,isFetching:w,isRefetching:w&&!x,isLoadingError:y&&!_,isPaused:m.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:y&&_,isStale:lo(e,t),refetch:this.refetch,promise:this.#a,isEnabled:Te(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const P=X=>{S.status==="error"?X.reject(S.error):S.data!==void 0&&X.resolve(S.data)},k=()=>{const X=this.#a=S.promise=Do();P(X)},O=this.#a;switch(O.status){case"pending":e.queryHash===n.queryHash&&P(O);break;case"fulfilled":(S.status==="error"||S.data!==O.value)&&k();break;case"rejected":(S.status!=="error"||S.error!==O.reason)&&k();break}}return S}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),ss(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.#v()}#j(e){us.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#t)}),this.#n.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function tc(e,t){return Te(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Qo(e,t){return tc(e,t)||e.state.data!==void 0&&Qs(e,t,t.refetchOnMount)}function Qs(e,t,n){if(Te(t.enabled,e)!==!1&&yn(t.staleTime,e)!=="static"){const o=typeof n=="function"?n(e):n;return o==="always"||o!==!1&&lo(e,t)}return!1}function Go(e,t,n,o){return(e!==t||Te(o.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&lo(e,n)}function lo(e,t){return Te(t.enabled,e)!==!1&&e.isStaleByTime(yn(t.staleTime,e))}function nc(e,t){return!ss(e.getCurrentResult(),t)}var sc=class extends ea{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:Bo()})}getOptimisticResult(e){return e.behavior=Bo(),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,u=n.fetchMeta?.fetchMore?.direction,h=i&&u==="forward",m=r&&u==="forward",d=i&&u==="backward",g=r&&u==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:pi(t,n.data),hasPreviousPage:fi(t,n.data),isFetchNextPageError:h,isFetchingNextPage:m,isFetchPreviousPageError:d,isFetchingPreviousPage:g,isRefetchError:c&&!h&&!d,isRefetching:a&&!m&&!g}}},oc=class extends Tr{#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),ss(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??xi();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){us.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)})})}},ta=l.createContext(void 0),na=e=>{const t=l.useContext(ta);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},rc=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(ta.Provider,{value:e,children:t})),sa=l.createContext(!1),ac=()=>l.useContext(sa);sa.Provider;function ic(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var lc=l.createContext(ic()),cc=()=>l.useContext(lc),uc=(e,t,n)=>{const o=n?.state.error&&typeof e.throwOnError=="function"?to(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=!1))},dc=e=>{l.useEffect(()=>{e.clearReset()},[e])},hc=({result:e,errorResetBoundary:t,throwOnError:n,query:o,suspense:r})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(r&&e.data===void 0||to(n,[e.error,o])),mc=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))}},fc=(e,t)=>e.isLoading&&e.isFetching&&!t,pc=(e,t)=>e?.suspense&&t.isPending,Yo=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function oa(e,t,n){const o=ac(),r=cc(),a=na(),i=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(i);const c=a.getQueryCache().get(i.queryHash);i._optimisticResults=o?"isRestoring":"optimistic",mc(i),uc(i,r,c),dc(r);const u=!a.getQueryCache().get(i.queryHash),[h]=l.useState(()=>new t(a,i)),m=h.getOptimisticResult(i),d=!o&&e.subscribed!==!1;if(l.useSyncExternalStore(l.useCallback(g=>{const f=d?h.subscribe(us.batchCalls(g)):os;return h.updateResult(),f},[h,d]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),l.useEffect(()=>{h.setOptions(i)},[i,h]),pc(i,m))throw Yo(i,h,r);if(hc({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&&!Hs&&fc(m,o)&&(u?Yo(i,h,r):c?.promise)?.catch(os).finally(()=>{h.updateResult()}),i.notifyOnChangeProps?m:h.trackResult(m)}function we(e,t){return oa(e,ea)}function ne(e,t){const n=na(),[o]=l.useState(()=>new oc(n,e));l.useEffect(()=>{o.setOptions(e)},[o,e]);const r=l.useSyncExternalStore(l.useCallback(i=>o.subscribe(us.batchCalls(i)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),a=l.useCallback((i,c)=>{o.mutate(i,c).catch(os)},[o]);if(r.error&&to(o.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:a,mutateAsync:r.mutate}}function ra(e,t){return oa(e,sc)}const ut="data-sources",aa="auth-user",xc=e=>we({queryKey:["project","datasources",e],queryFn:async()=>{const{data:t}=await B.get(`/project/team/${e}/datasources`);return t.data},enabled:!!e}),en=e=>{const t=["project","datasources"],n=["project","saved-queries"];return Promise.all([J.invalidateQueries({queryKey:t}),J.invalidateQueries({queryKey:n})])},gc=e=>{const t=["trash","team"];return J.invalidateQueries({queryKey:t})},bc=(e,t)=>we({queryKey:["project",t.teamId,"tables",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:Ar}),vc=(e,t="",n=30,o)=>ra({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}),yc=(e,t="",n=20)=>ra({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}}),wc=(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}),Cc=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}}),jc=()=>Promise.all([J.invalidateQueries({queryKey:["project","tabs-history"]}),J.invalidateQueries({queryKey:["project","recent-tabs"]})]),Nc=4e3,fs=e=>we({queryKey:[ut,e],queryFn:async()=>{const{data:t}=await B.get("/data-sources/"+e);return t.data},enabled:!!e,refetchInterval:t=>t.state?.data?.status==="INSPECTING"?Nc:!1}),co=e=>we({queryKey:[ut,e.teamId],queryFn:async()=>{const{data:t}=await B.get("/data-sources",{params:e});return t.data},enabled:e.teamId!==void 0}),ps=e=>we({queryKey:[ut,e,"inspections"],queryFn:async()=>{const{data:t}=await B.get(`/data-sources/${e}/inspections`);return t.data},enabled:!!e}),_c=e=>J.invalidateQueries({queryKey:[ut,e,"inspections"]}),Sc=()=>ne({mutationFn:async e=>{const{data:t}=await B.post("/data-sources",e);return t.data},onSuccess:()=>{J.invalidateQueries({queryKey:[ut]}),en()}}),kc=()=>ne({mutationFn:async({dataSource:e,id:t})=>{const{data:n}=await B.put(`/data-sources/${t}`,e);return n.data},onSuccess:()=>{J.invalidateQueries({queryKey:[ut]}),en()}}),ia=()=>ne({mutationFn:async e=>{await B.post(`/data-sources/${e}/inspect`)},onSuccess:(e,t)=>{J.invalidateQueries({queryKey:[ut,t]})}}),Ec=()=>ne({mutationFn:async e=>{await B.delete(`/data-sources/${e}`)},onSuccess:()=>{J.invalidateQueries({queryKey:[ut]}),en()}}),la=()=>we({queryKey:["accessToken"],queryFn:ds.get}),Ce=()=>{const{data:e}=la();return we({queryKey:[aa],queryFn:async()=>{const{data:t}=await B.get("/users");return t.data},enabled:!!e,retry:(t,n)=>gi(n)&&n.code==="ERR_NETWORK"?!1:t<3})},Rc=()=>ne({mutationFn:async e=>{const{data:t}=await B.patch("/users",e);return t.data},onSuccess:async e=>{J.setQueryData([aa],e)}}),Lc=()=>ne({mutationFn:async e=>(await B.post("/users",e),!0),onSuccess:()=>{J.invalidateQueries({queryKey:["team-users"]})}}),je=e=>{const t=new Set;let n=e;const o=c=>(t.add(c),()=>t.delete(c)),r=c=>(t.forEach(u=>u(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 Tc(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(u=>u.table===a&&u.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],getColumnType:r=>{const a=e?.result.allColumns.find(i=>i.full===r);if(a)return a.type}}),[e,t,n,o])}function Ac(e,t){return l.useMemo(()=>({state:e,setState:t}),[e,t])}function kt(e){return{dataSourceId:e.dataSourceId||"",page:e?.page||0,size:e?.size||50,table:e.table||"",filters:e?.filters||[],joins:e?.joins??[],orderBy:e?.orderBy??[],columns:e?.columns??[],groupBy:e?.groupBy??[],aggregations:e?.aggregations??[]}}function Ic(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=>!!Gt({path:t,end:!0},r)}}function xs(e,t){return{name:e,path:t,build:()=>t,check:n=>n===t}}const Mc=xs("Home","/"),Pc=xs("Workbench","/workbench"),Oc=xs("Share query","/share"),Dc=xs("Login","/login"),$c=Ic("Workbench tab","/workbench/tab/:id"),F={home:Mc,workbench:Pc,share:Oc,login:Dc,workbenchTab:$c},gs=e=>{J.setQueryData(["workbench-tabs"],t=>e(t||[]))},Fc=(e,t)=>{J.setQueryData(["workbench-tabs",e],n=>n&&t(n))},bs=()=>we({queryKey:["workbench-tabs"],queryFn:async()=>{const{data:e}=await B.get("/workbench-tabs");return e.data}}),Bc=e=>we({queryKey:["workbench-tabs",e],queryFn:async()=>{const{data:t}=await B.get(`/workbench-tabs/${e}`);return t.data}}),Lt=()=>ne({mutationFn:async e=>{const{data:t}=await B.post("/workbench-tabs",e);return t.data},onSuccess:async e=>{gs(t=>[...t,{id:e.id,name:e.name,orderIndex:e.orderIndex}])}}),qc=()=>ne({mutationFn:async({tabId:e,...t})=>(await B.patch(`/workbench-tabs/${e}/archive`,t)).data.data,onSuccess:async e=>{gs(()=>e)}}),ca=()=>ne({mutationFn:async e=>(await B.patch(`/workbench-tabs/${e}/restore`),e),onSuccess:()=>ha()}),ua=()=>ne({mutationFn:async({id:e,payload:t})=>(await B.patch(`/workbench-tabs/${e}`,t),!0),onMutate:({id:e,payload:t})=>{Fc(e,n=>({...n,...t})),gs(n=>n.map(o=>o.id!==e?o:{...o,name:t.name||o.name}))}}),Wc=(e,t)=>{const{dataSourceId:n,searchAll:o,table:r,filters:a,joins:i,orderBy:c,groupBy:u,columns:h,aggregations:m,page:d=0,size:g=20}=t;return we({queryKey:["workbench-tab-runner",e,n,r,d,g,a,m,i,c,u,h,o],queryFn:async()=>{const{data:f}=await B.post(`/workbench-tabs/${e}/run`,t);return f.data},retry:1,enabled:!!r&&!!n,placeholderData:Ar})},Uc=()=>ne({mutationFn:async e=>{await B.delete(`/workbench-tabs/${e}`)},onSuccess:()=>{ha(),jc()}}),da=e=>J.invalidateQueries({queryKey:["workbench-tab-runner",e]}),ha=()=>J.invalidateQueries({queryKey:["workbench-tabs"]}),[Hc,Ms,zc]=je(void 0),Vc=async()=>new Promise(e=>{Ms({onCancel:()=>{Ms(void 0),e(void 0)},onConfirm:(t,n,o)=>{Ms(void 0),e({dsId:o,id:n,type:t})}})}),Tn=e=>{const t=te(),n=Lt(),o=ca();return l.useEffect(()=>{n?.data?.id&&t(F.workbenchTab.build({id:n.data.id})),o?.data&&t(F.workbenchTab.build({id:o.data}))},[n.data,o.data]),l.useCallback(()=>{zc.get()||Vc().then(a=>{a?.type==="table"?n.mutate({name:a.id,opts:kt({table:a.id,dataSourceId:a.dsId})}):a?.type==="query"?n.mutate({queryId:a.id}):a?.type==="tab"&&o.mutate(a.id)})},[t,e])},ma=[{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"}],Kc=ma.reduce((e,t)=>(e[t.value]=t.label,e),{});ma.reduce((e,t)=>(e[t.label]=t.value,e),{});const tn=e=>e.map(t=>({label:Kc[t],value:t}));tn(["=","<>",">",">=","<","<=","IN","NOT IN","IS NULL","IS NOT NULL"]);tn(["=","<>","LIKE","NOT LIKE","IN","NOT IN","IS NULL","IS NOT NULL","CONTAINS","NOT CONTAINS"]);tn(["=","<>","IS NULL","IS NOT NULL"]);tn(["=","<>",">",">=","<","<=","IS NULL","IS NOT NULL"]);tn(["IS NULL","IS NOT NULL"]);tn(["IN","NOT IN"]);const Qc=["char","varchar","binary","varbinary","blob","text","enum","set","character","character varying","text","citext","uuid","xml","json","jsonb"];new Set(Qc);const Gc=["integer","smallint","decimal","numeric","float","real","double precision","int","smallint","integer","bigint","decimal","numeric","real","double precision","serial","bigserial","money"];new Set(Gc);const Yc=["date","datetime","timestamp","timestamptz"].reduce((e,t)=>(e[t]=!0,e),{}),Jc=e=>e.fn?e.distinct===!0?`${e.fn} distinct ${e.value}`:`${e.fn} ${e.value}`:e.value;var me=(e=>(e.OWNER="owner",e.ADMIN="admin",e.EDITOR="editor",e.READ_ONLY="read_only",e))(me||{});const Jo={[me.READ_ONLY]:10,[me.EDITOR]:20,[me.ADMIN]:30,[me.OWNER]:40},Xc=e=>`${e.fromTable}.${e.fromColumn} = ${e.toTable}.${e.toColumn}`,An=e=>{const{data:t}=Ce();return l.useMemo(()=>t?Jo[t.teamRole]>=Jo[e]:!1,[t,e])},Zc="_input_n98qv_2",eu="_label_n98qv_2",tu="_content_n98qv_2",nu="_form_n98qv_2",su="_header_n98qv_2",ou="_mode-select_n98qv_2",ru="_selected_n98qv_2",au="_mode-container_n98qv_2",Fe={input:Zc,label:eu,content:tu,form:nu,header:su,modeSelect:ou,selected:ru,modeContainer:au},iu="_modal_112c0_2",lu="_modal-visible_112c0_2",cu="_modal-invisible_112c0_2",uu="_backdrop_112c0_2",du="_modal-container_112c0_2",hu="_close-button_112c0_2",Kt={modal:iu,modalVisible:lu,modalInvisible:cu,backdrop:uu,modalContainer:du,closeButton:hu},Xe=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 es=[];const mu=e=>{const t=Symbol();return es.push({id:t,listener:e}),()=>{es=es.filter(n=>n.id!==t)}};window.addEventListener("keydown",e=>{if(e.key!=="Escape")return;const t=es.pop();t&&(e.preventDefault(),e.stopPropagation(),t.listener())});const vs=e=>{const t=l.useRef(e.onClose);t.current=e.onClose,l.useEffect(()=>{if(e.enabled)return mu(()=>{t.current()})},[e.enabled])},Me=({children:e,backdropClose:t,isVisible:n,onClose:o,onClosed:r,noPadding:a=!1,portal:i=!1})=>{const[c,u]=l.useState(!1),h=()=>{t&&o()},m=g=>{n||getComputedStyle(g.currentTarget).opacity==="0"&&(u(!1),r&&r())};l.useEffect(()=>{n&&u(!0)},[n]),vs({onClose:h,enabled:n&&t===!0});const d=s.jsxs("div",{onTransitionEnd:m,className:A(Kt.modal,n?Kt.modalVisible:Kt.modalInvisible),children:[s.jsx("div",{onClick:h,className:Kt.backdrop}),s.jsx("div",{className:A(Kt.modalContainer,a!==!0&&"p-4"),children:c&&e})]});return i?io.createPortal(d,document.body):d},nn=({onClick:e})=>{const t=l.useRef(e);return t.current=e,s.jsx("button",{className:Kt.closeButton,onClick:e,children:s.jsx(Xe,{width:20,height:20})})},fa=({children:e})=>s.jsx("h2",{className:"text-xl font-semibold",children:e}),fu=({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))}),pu=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"})),xu=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"}})),ze=({size:e,type:t})=>t==="mysql"?s.jsx(pu,{width:e,height:e}):s.jsx(xu,{width:e,height:e}),gu={mysql:"MySQL",postgres:"PostgreSQL"},bu={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"}]},vu={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"}]},yu=({show:e,onClose:t,dbType:n="postgres"})=>{const o=Sc(),r=ia(),{data:a}=Ce(),[i,{change:c,set:u}]=kn({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=>{u("allowInsert",!f),u("allowUpdate",!f)},d=o.isPending||r.isPending,g=!i.allowInsert&&!i.allowUpdate;return s.jsxs(Me,{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(ze,{size:24,type:n}),s.jsx("p",{className:"text-(--text-color-primary) font-semibold",children:gu[n]})]}),o.isError&&s.jsx(be,{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(be,{className:"mb-2",variant:"info",children:"Creating connection"}),r.isPending&&s.jsx(be,{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:d})]}),s.jsx("p",{className:"text-sm font-semibold mt-2",children:"Configuration"}),s.jsx(fu,{form:i,change:c,shape:i.dbType==="mysql"?bu:vu})]}),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,g&&Fe.selected),children:[s.jsxs("span",{className:"text-sm font-semibold text-(--text-color-primary)",children:[s.jsx("input",{type:"radio",disabled:d,checked:g,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,!g&&Fe.selected),children:[s.jsxs("span",{className:"text-sm font-semibold text-(--text-color-primary)",children:[s.jsx("input",{type:"radio",disabled:d,checked:!g,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:d,children:"Cancel"}),s.jsx("button",{onClick:h,className:"button primary",disabled:d,children:"Create"})]})]})},wu="_data-source-entry_vcqrj_2",Cu="_action-title_vcqrj_2",ju="_recent-tabs-container_vcqrj_2",Nu="_recent-tabs-entry_vcqrj_2",_u="_home-action-button_vcqrj_2",Su="_home-gray-card_vcqrj_2",ku="_home-card-title_vcqrj_2",Eu="_home-card-grid-content_vcqrj_2",Ru="_useful-links_vcqrj_2",G={dataSourceEntry:wu,actionTitle:Cu,recentTabsContainer:ju,recentTabsEntry:Nu,homeActionButton:_u,homeGrayCard:Su,homeCardTitle:ku,homeCardGridContent:Eu,usefulLinks:Ru},[Lu,In]=je({show:!1}),[Tu,Cn]=je({show:!1}),[Au,jn]=je(void 0),Iu=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"})),Mu=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"})),Pu=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})),Ou=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})),Mn=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"})),pa=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"})),xa=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})),Xo=20,uo="text-(--text-color-primary)",Du=()=>{const e=Tn("Home");return s.jsxs("div",{className:G.homeActionButton,onClick:e,children:[s.jsx(Mn,{width:Xo,height:Xo,className:uo}),s.jsx("h2",{className:G.actionTitle,children:"Start new query"})]})},$u=()=>s.jsxs("div",{className:G.homeActionButton,onClick:()=>In({show:!0}),children:[s.jsx(pa,{width:20,height:20,className:uo}),s.jsx("h2",{className:G.actionTitle,children:"Saved queries"})]}),Fu={mysql:"MySQL",postgres:"PostgreSQL"},Zo=({dbType:e})=>{const[t,n]=l.useState(void 0),o=An(me.EDITOR),r=a=>{o?n(a):fe.error("You don't have permission to connect new data sources in this team")};return s.jsxs("div",{children:[t&&s.jsx(yu,{show:!0,dbType:t,onClose:()=>n(void 0)}),s.jsxs("div",{className:G.homeActionButton,onClick:()=>r(e),children:[s.jsx(ze,{size:24,type:e}),s.jsx("p",{className:G.actionTitle,children:Fu[e]})]})]})},Bu=()=>s.jsxs("div",{className:G.homeGrayCard,children:[s.jsx("h2",{className:G.homeCardTitle,children:"Connect new data source"}),s.jsxs("div",{className:G.homeCardGridContent,children:[s.jsx(Zo,{dbType:"mysql"}),s.jsx(Zo,{dbType:"postgres"})]})]}),qu=()=>{const e=te(),{data:t}=bs(),n=Tn("Home"),o=()=>{t&&t.length>0?e(F.workbenchTab.build({id:t[0].id})):n()};return s.jsxs("div",{className:G.homeActionButton,onClick:o,children:[s.jsx(xa,{width:20,height:20,className:uo}),s.jsx("h2",{className:G.actionTitle,children:"Workbench"})]})},Wu=()=>{const{data:e}=Ce(),{data:t}=co({teamId:e?.teamId});return!t||t.length===0?null:s.jsxs("div",{className:G.homeGrayCard,children:[s.jsx("h2",{className:G.homeCardTitle,children:"Data sources"}),s.jsx("div",{className:G.homeCardGridContent,children:t?.map(n=>s.jsxs("div",{className:G.dataSourceEntry,onClick:()=>jn(n.id),tabIndex:0,children:[!n.allowInsert&&s.jsx(Ou,{"data-tooltip-id":"default","data-tooltip-content":"This datasource is read-only",width:18,height:18,className:"absolute top-2 right-2"}),s.jsx(ze,{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,ga=()=>s.jsxs("div",{className:G.usefulLinks,children:[s.jsxs("a",{href:"https://dataramen.xyz/",target:"_blank",children:[s.jsx(Pu,{width:Ht,height:Ht}),s.jsx("span",{children:"Docs"})]}),s.jsxs("a",{href:"https://github.com/OleksandrDemian/dataramen",target:"_blank",children:[s.jsx(Iu,{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(Mu,{width:Ht,height:Ht}),s.jsx("span",{children:"NPM"})]})]}),Uu=()=>{const{data:e}=Ce(),{data:t,isLoading:n}=wc(e?.teamId),o=te();if(n||!t?.length)return null;const r=a=>{o(F.workbenchTab.build({id:a}))};return s.jsxs("div",{className:G.recentTabsContainer,children:[s.jsx("h2",{className:G.homeCardTitle+" px-4 mb-4",children:"Recent tabs"}),t.map(a=>s.jsxs("div",{className:G.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(ze,{size:20,type:a.dataSourceType}),s.jsx("span",{className:"text-sm text-(--text-color-secondary) truncate",children:a.dataSourceName})]})]},a.id))]})},Hu=()=>{const{data:e}=Ce(),{data:t}=co({teamId:e?.teamId}),n=!!t&&t.length>0,o=!!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(ga,{})]}),s.jsxs("div",{className:"flex flex-col gap-8 mt-8 bg-(--bg) z-1",children:[o&&!n&&s.jsx(be,{variant:"warning",className:"font-semibold",children:"Connect at least one data source to start using DataRamen"}),s.jsxs("div",{className:G.homeGrayCard,children:[s.jsx("h2",{className:G.homeCardTitle,children:"Quick actions"}),s.jsxs("div",{className:G.homeCardGridContent,children:[s.jsx(Du,{}),o&&s.jsx(qu,{}),s.jsx($u,{})]})]}),o&&s.jsx(Wu,{}),s.jsx(Bu,{}),s.jsx(Uu,{})]})]})})},[zu,Ps]=je(void 0),ho=async e=>new Promise(t=>{Ps({message:e,onCancel:()=>{t(!1),Ps(void 0)},onConfirm:()=>{t(!0),Ps(void 0)}})}),Vu=({confirm:e})=>s.jsxs("div",{children:[s.jsx("p",{children:e.message}),s.jsxs("div",{className:"flex gap-2 justify-end mt-4",children:[s.jsx("button",{className:"button tertiary",onClick:e.onCancel,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:e.onConfirm,children:"Confirm"})]})]}),Ku=()=>{const e=zu(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(Me,{isVisible:!!e,onClose:()=>e?.onCancel(),onClosed:()=>n(void 0),children:t&&s.jsx(Vu,{confirm:t})})},[Qu,jt]=je(void 0),Pn=async(e,t)=>new Promise(n=>{jt({message:e,defaultValue:t,onCancel:()=>{jt(void 0),n(void 0)},onConfirm:o=>{jt(void 0),n(o)},type:"string"})}),Gu=async(e,t)=>new Promise(n=>{jt({message:e,defaultValue:t,onCancel:()=>{jt(void 0),n(void 0)},onConfirm:o=>{jt(void 0),n(o)},type:"query-expression"})}),Yu="_root_ng9lp_1",ba={root:Yu},Ju="_root_u7zys_2",Xu="_input_u7zys_2",er={root:Ju,input:Xu},Zu=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})),ed=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"})),va=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"})),tr=(e,t)=>{const n=t.indexOf(e);return n>=t.length?t[0]:t[n+1]},td=(e,t)=>{const n=t.indexOf(e);return n<=0?t[t.length-1]:t[n-1]},nd=({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(Zu,{className:"pointer-events-none",width:20,height:20}),e==="raw"&&s.jsx(ed,{className:"pointer-events-none",width:20,height:20}),e==="default"&&s.jsx(va,{className:"pointer-events-none",width:20,height:20})]}),ys=({prefix:e,mode:t="default",allowedModes:n,className:o,inputClass:r,onExpressionChange:a,...i})=>{const c=h=>{a({mode:t,value:h.currentTarget.value})},u=h=>{h.key==="ArrowDown"||h.key==="ArrowUp"?(h.preventDefault(),h.stopPropagation(),a({mode:h.key==="ArrowUp"?tr(t,n):td(t,n),value:i.value})):i.onKeyDown?.(h)};return s.jsxs("label",{className:A(er.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:u,onChange:c,className:A(er.input,r)}),s.jsx(nd,{mode:t,onNextMode:()=>a({mode:tr(t,n),value:i.value})})]})},ws=["default","raw"],sd=({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:ba.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"})]})]})},od=({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:ba.root,children:[s.jsx("h2",{className:"text-xl font-semibold",children:e.message}),s.jsx(ys,{prefix:"_",autoFocus:!0,className:"w-full my-2 h-8",value:t.value,mode:t.mode,onExpressionChange:n,allowedModes:ws,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"})]})]})},rd=()=>{const e=Qu(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsxs(Me,{isVisible:!!e,onClose:()=>jt(void 0),onClosed:()=>n(void 0),children:[t?.type==="string"&&s.jsx(sd,{data:t}),t?.type==="query-expression"&&s.jsx(od,{data:t})]})},[ad,id]=je(void 0),ya=e=>{id(e)},ld="_textarea_1q672_2",cd={textarea:ld},ud=()=>{const e=ad(),t=()=>{e&&(navigator.clipboard.writeText(e.toString()),fe.success("Copied!"))},n=()=>ya(void 0);return s.jsxs(Me,{isVisible:!!e,onClose:n,backdropClose:!0,children:[s.jsx("textarea",{className:cd.textarea,readOnly:!0,defaultValue:e?.toString()}),s.jsxs("div",{className:"mt-2 flex gap-1 justify-end",children:[s.jsx("button",{className:"button primary",onClick:t,children:"Copy"}),s.jsx("button",{className:"button tertiary",onClick:n,children:"Close"})]})]})},dd="_tabs_k8xhz_2",hd="_mobile_k8xhz_2",md="_menu_k8xhz_2",fd="_item_k8xhz_2",pd="_tab_k8xhz_2",xd="_active_k8xhz_2",gd="_close-button_k8xhz_2",$e={tabs:dd,mobile:hd,menu:md,item:fd,tab:pd,active:xd,closeButton:gd},nr=e=>window.matchMedia(e).matches;function wa(e,{defaultValue:t=!1,initializeWithValue:n=!0}={}){const[o,r]=l.useState(()=>n?nr(e):t);return l.useLayoutEffect(()=>{const a=window.matchMedia(e);function i(){r(()=>nr(e))}return i(),a.addListener?a.addListener(i):a.addEventListener("change",i),()=>{a.removeListener?a.removeListener(i):a.removeEventListener("change",i)}},[e]),o}const mo={laptop:"(min-width: 1024px)"},Ca=()=>window.matchMedia(mo.laptop).matches,fo=e=>l.useMemo(()=>{if(e)return e instanceof bi?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 Nt(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 ts=e=>e.distinct?[e.fn,"DISTINCT",e.value].join(" "):[e.fn,e.value].join(" "),Gn=e=>{let t=e.replace(/[_-]+/g," ");return t=t.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),t=t.toLowerCase().replace(/\b\w/g,n=>n.toUpperCase()),t},bd="_table_al97d_2",vd="_row-index-btn_al97d_2",yd="_semi-transparent_al97d_2",wd="_table-loading_al97d_2",Cd="_table-empty_al97d_2",jd="_table-row-cells_al97d_2",Nd="_header-cell_al97d_2",_d="_header-actions_al97d_2",Sd="_cell_al97d_2",kd="_value_al97d_2",Ed="_table-config_al97d_2",Rd="_table-action_al97d_2",Ld="_data-source_al97d_2",Td="_gray_al97d_2",Ad="_modal_al97d_2",Id="_selected-size_al97d_2",Md="_pagination-indicator_al97d_2",L={table:bd,rowIndexBtn:vd,semiTransparent:yd,tableLoading:wd,tableEmpty:Cd,tableRowCells:jd,headerCell:Nd,headerActions:_d,cell:Sd,value:kd,tableConfig:Ed,tableAction:Rd,dataSource:Ld,gray:Td,modal:Ad,selectedSize:Id,paginationIndicator:Md},Pe=l.createContext({name:"No name",hooks:[],availableJoins:[],allColumns:[],dataSourceId:"",entities:[],getValue:()=>{},getValueByIndex:()=>{},getColumnByIndex:()=>{},getColumnType:()=>{}}),Ne=l.createContext({state:kt({}),setState:()=>{}}),et=l.createContext({}),ja={ON_ANIMATION_END:Symbol("ON_TRANSITION_END")},Na=()=>{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,[ja.ON_ANIMATION_END]:i}},[e,n])},Pd=e=>{if(e!=="ASC")return e==="DESC"?"ASC":"DESC"},Od=()=>{const{state:e,setState:t}=l.useContext(Ne),n=l.useCallback(o=>{t(r=>{const a=r.orderBy[0];if(a&&a.column===o){const i=Pd(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}},Dd="_options-container_pmdxk_2",$d="_filter-input_pmdxk_2",Fd="_list_pmdxk_2",Bd="_empty-text_pmdxk_2",_t={optionsContainer:Dd,filterInput:$d,list:Fd,emptyText:Bd},qd="_container_zy41j_2",Wd="_animate-show_zy41j_2",Ud="_animate-hide_zy41j_2",Hd="_content_zy41j_2",zd="_backdrop_zy41j_2",gt={container:qd,animateShow:Wd,animateHide:Ud,content:Hd,backdrop:zd},_a=({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,Ca()?c?a.right=window.innerWidth-t.position.x:a.left=t.position.x:(a.right=36,a.left=36)}return a},[t.position]);if(vs({enabled:!!o,onClose:t.close}),!o)return null;const r=s.jsxs("div",{className:A(gt.container,t.state==="out"&>.animateHide,t.state==="in"&>.animateShow),onAnimationEnd:t[ja.ON_ANIMATION_END],children:[s.jsx("div",{className:gt.backdrop,onClick:a=>{a.stopPropagation(),a.preventDefault(),t.close()}}),s.jsx("div",{className:A(gt.content,t.state==="out"&>.animateHide,t.state==="in"&>.animateShow),style:o,children:e})]});return io.createPortal(r,document.body)},Ze=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),ye=(e,t)=>e!=null&&e>t,Sa=(e,t)=>e!=null&&e<t,Vd="_container_2r6fb_2",Kd={container:Vd},sn=({containerClassName:e,className:t,...n})=>s.jsxs("label",{className:A(Kd.container,e),children:[s.jsx(Mn,{width:16,height:16}),s.jsx("input",{className:A("flex-1 outline-none",t),...n})]}),Qd="_root_10642_2",Gd="_content_10642_2",Yd="_table-name_10642_2",Jd="_sub_10642_2",st={root:Qd,content:Gd,tableName:Yd,sub:Jd},po=({hook:e,onClick:t})=>e.direction==="out"?s.jsx("button",{className:st.root,onClick:t,children:s.jsxs("div",{className:st.content,children:[s.jsx("p",{className:st.tableName,children:e.toTable}),s.jsxs("p",{className:st.sub,children:[e.toColumn," = ",e.fromTable,".",e.fromColumn]})]})},e.id):s.jsx("button",{className:st.root,onClick:t,children:s.jsxs("div",{className:st.content,children:[s.jsx("p",{className:st.tableName,children:e.fromTable}),s.jsxs("p",{className:st.sub,children:[e.fromColumn," = ",e.toTable,".",e.toColumn]})]})},e.id);function Xd(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:kt({table:e.toTable,dataSourceId:t,filters:[{id:Ze(),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:kt({table:e.fromTable,dataSourceId:t,filters:[{id:Ze(),column:`${e.fromTable}.${e.fromColumn}`,value:r==null?"IS NULL":`${r}`,isEnabled:!0}]})}}const ka=({rowIndex:e,colIndex:t,onClose:n,className:o})=>{const[r,a]=l.useState(""),{dataSourceId:i,hooks:c,getColumnByIndex:u,getValue:h}=l.useContext(Pe),m=l.useMemo(()=>{if(t===void 0)return c;const v=u(t);return v?c.filter(w=>w.toColumn===v.column&&w.toTable===v.table):[]},[t,c,u]),d=Lt(),g=te(),f=l.useMemo(()=>{const v=r.toLowerCase();return m.filter(w=>w.fromTable.toLowerCase().includes(v))},[r,m]),p=v=>{d.mutateAsync(Xd(v,i,e,h)).then(w=>{g(F.workbenchTab.build({id:w.id})),n?.()})},b=ye(f.length,0);return s.jsxs("div",{className:o,children:[s.jsx(sn,{autoFocus:!0,className:_t.filterInput,placeholder:"Filter",value:r,onChange:v=>a(v.target.value)}),s.jsxs("div",{className:_t.list,children:[b&&f.map(v=>s.jsx(po,{hook:v,onClick:()=>p(v)},v.id)),!b&&s.jsx("p",{className:_t.emptyText,children:"Empty"})]})]})},Zd=({handler:e,rowIndex:t,colIndex:n})=>s.jsx(_a,{handler:e,children:s.jsx("div",{className:_t.optionsContainer,children:s.jsx(ka,{rowIndex:t,colIndex:n,className:"p-2",onClose:()=>{e.close()}})})}),xo=()=>{const{state:e,setState:t}=l.useContext(Ne),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}},eh=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"})),th=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"})),nh="_container_ioqub_2",sh="_animate-show_ioqub_2",oh="_animate-hide_ioqub_2",rh="_backdrop_ioqub_2",ah="_content_ioqub_2",bt={container:nh,animateShow:sh,animateHide:oh,backdrop:rh,content:ah},go=({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,d=!0)=>{d||(m.preventDefault(),m.stopPropagation());const g={},f=m.clientY>window.innerHeight/2,p=m.clientX>window.innerWidth/2;f?g.bottom=window.innerHeight-m.clientY:g.top=m.clientY,Ca()?p?g.right=window.innerWidth-m.clientX:g.left=m.clientX:(g.right=36,g.left=36),r(g),i("in")},close:()=>{i("out")}}),[]),vs({enabled:a==="in"||a==="visible",onClose:()=>{i("out")}}),!o)return null;const u=()=>{a==="in"?i("visible"):a==="out"&&(r(void 0),i("hidden"),n?.())},h=s.jsxs("div",{className:A(bt.container,a==="out"&&bt.animateHide,a==="in"&&bt.animateShow),onAnimationEnd:u,children:[s.jsx("div",{className:bt.backdrop,onClick:()=>i("out")}),s.jsx("div",{ref:c,style:o,className:A(bt.content,a==="out"&&bt.animateHide,a==="in"&&bt.animateShow),children:e})]});return io.createPortal(h,document.body)};function Os(e,t,n){const o=e?.rows?.[t]?.[n],r=e?.columns?.[n];return{value:o,column:r}}const ih=({ref:e})=>{const{data:t}=l.useContext(et),{getColumnType:n}=l.useContext(Pe),{setState:o}=l.useContext(Ne);return{copyValue:(c,u)=>{const{value:h,column:m}=Os(t?.result,c,u);if(m){const d=Nt(h,n(m.full));navigator.clipboard.writeText(d),fe.success("Copied!"),e.current?.close()}},showValue:(c,u)=>{const{value:h,column:m}=Os(t?.result,c,u);if(m){const d=Nt(h,n(m.full));ya(d),e.current?.close()}},filterValue:(c,u)=>{const{value:h,column:m}=Os(t?.result,c,u),d=m?.full||"";if(d){let g;if(h==null)g={id:Ze(),isEnabled:!0,mode:"raw",column:d,value:"IS NULL"};else{const f=Nt(h,n(d));g={id:Ze(),isEnabled:!0,column:d,value:f,fn:m?.fn,mode:"default"}}o(f=>({...f,filters:[...f.filters,g]})),fe.success(`Added new filter on column ${m?.alias}`),e.current?.close()}}}},Ea=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})),lh=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})),ch="_section-name_189yd_2",uh="_item_189yd_2",vt={sectionName:ch,item:uh},Ct=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"})),[dh,bo]=je(void 0),hh=e=>{vo(void 0),bo(e)},mh=()=>bo(void 0);function fh(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 Ra=({storage:e=localStorage,localStorageKey:t,initialData:n})=>{const o=je(fh(t,n,e));return o[2].subscribe(r=>{e.setItem(t,JSON.stringify(r))}),o},[ph,vo]=je(void 0),[xh,gh]=Ra({initialData:{history:[]},localStorageKey:"useEntityEditorHistory_v1"}),yo=(e,t=!0)=>{const n={...e,key:`${e.dataSourceId}-${e.tableName}-${e.entityId.map(o=>o[0]+o[1]).join("")}`};bo(void 0),t&&gh(o=>o.history.some(r=>r.key===n.key)?o:o.history.length<20?{history:[...o.history,n]}:{history:[...o.history.slice(1),n]}),vo(n)},bh=()=>vo(void 0),vh=({onClose:e,rowIndex:t,className:n})=>{const[o,r]=l.useState(""),{entities:a,dataSourceId:i,getValue:c}=l.useContext(Pe),u=l.useMemo(()=>{if(!o)return a;const m=o.toLowerCase();return a.filter(d=>d.toTable.toLowerCase().includes(m))},[a,o]),h=m=>{const d=c(t,m.fromTable,m.fromColumn);d?yo({tableName:m.toTable,dataSourceId:i,entityId:[[m.toColumn,""+d]]}):fe.error(`Cannot open ${m.toTable} record. ${m.fromTable}.${m.fromColumn} is NULL`),e?.()};return s.jsxs("div",{className:n,children:[s.jsx(sn,{autoFocus:!0,className:_t.filterInput,placeholder:"Filter",value:o,onChange:m=>r(m.target.value)}),s.jsx("div",{className:_t.list,children:ye(u.length,0)?u.map(m=>s.jsx(po,{hook:m,onClick:()=>h(m)},m.id)):s.jsx("p",{className:_t.emptyText,children:"Empty"})})]})},yh=({ref:e,row:t,col:n,onClosed:o})=>{const r=ih({ref:e}),[a,i]=l.useState("cell"),{hooks:c,entities:u}=l.useContext(Pe),h=()=>r.copyValue(t,n),m=()=>r.showValue(t,n),d=()=>r.filterValue(t,n),g=()=>{i("show-record")},f=()=>{o?.(),i("cell")},p=ye(c?.length,0),b=ye(u?.length,0);return s.jsx(go,{ref:e,onClosed:f,children:s.jsxs("div",{className:"w-full lg:w-sm",children:[a==="cell"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:vt.sectionName,children:"Cell actions"}),s.jsxs("button",{className:vt.item,onClick:h,children:[s.jsx(Ea,{width:14,height:14}),"Copy"]}),s.jsxs("button",{className:vt.item,onClick:m,children:[s.jsx(lh,{width:14,height:14}),"View"]}),s.jsxs("button",{className:vt.item,onClick:d,children:[s.jsx(Mn,{width:14,height:14}),"Filter"]}),(b||p)&&s.jsx("p",{className:vt.sectionName,children:"Row actions"}),b&&s.jsxs("button",{className:vt.item,onClick:g,children:[s.jsx(Ct,{className:"text-(--text-color-tertiary)",width:14,height:14}),"Show record"]}),p&&s.jsxs("button",{className:vt.item,onClick:()=>i("drill"),children:[s.jsx(Ct,{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(Ct,{className:"text-(--text-color-secondary) rotate-270",width:16,height:16}),"Drill down"]}),s.jsx(ka,{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(Ct,{className:"text-(--text-color-secondary) rotate-270",width:16,height:16}),"Show record"]}),s.jsx(vh,{rowIndex:t,onClose:()=>e.current?.close()})]})]})})},wh={DESC:"",ASC:"rotate-180"},Ch=(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:Ze(),column:t,isEnabled:!0,value:n,fn:o,mode:r}),a},jh=()=>{const{data:e}=l.useContext(et),{orderBy:t,updateOrderBy:n}=Od(),{setFilters:o,filters:r}=xo(),a=e?.result.columns||[],i=t[0],c=ye(e?.result.tables.length,1),u=(h,m)=>{Gu("Filter value","").then(d=>{d&&o(Ch(r,{column:h,value:d.value,fn:m,mode:d.mode}))})};return s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("td",{children:"🥢"}),a.map(h=>s.jsxs("td",{className:L.headerCell,children:[s.jsxs("div",{className:"overflow-hidden",children:[c&&s.jsx("p",{className:"text-xs truncate italic text-(--text-color-primary)",children:h.table||"-"}),s.jsx("p",{className:"text-sm font-semibold truncate text-(--text-color-primary)",children:h.column})]}),s.jsxs("div",{className:L.headerActions,children:[s.jsx("button",{onClick:()=>n(h.alias),children:i?.column===h.alias?s.jsx(eh,{className:wh[i.direction],width:16,height:16}):s.jsx(th,{width:16,height:16})}),s.jsx("button",{onClick:()=>u(h.full,h.fn),children:s.jsx(Mn,{width:16,height:16})})]})]},h.full))]})})};function Nh({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=Nt(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(Ct,{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(Ct,{className:"pointer-events-none rotate-180",width:16,height:16})})]})]}):s.jsx("span",{className:L.value,children:n})}const _h=l.memo(({row:e,isLastRow:t,index:n,offset:o,colMeta:r})=>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(Ct,{className:"rotate-180 pointer-events-none",width:16,height:16}),s.jsx("span",{children:n+1+o})]})}),e.map((a,i)=>s.jsx("td",{className:L.cell,"data-row":n,"data-col":i,children:s.jsx(Nh,{value:a,actions:r.get(i)})},i))]})),Sh=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--}},sr=e=>{const t=Sh(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}},kh=()=>{const{data:e,error:t,isLoading:n,isFetching:o}=l.useContext(et),{dataSourceId:r,getColumnByIndex:a,getValueByIndex:i}=l.useContext(Pe),{state:{page:c,size:u}}=l.useContext(Ne),h=l.useRef(null),m=fo(t),d=Na(),[g,f]=l.useState(),p=x=>{const y=x.target,C=y.dataset?.cellAction,_=sr(y);if(C==="ref"&&ye(_?.col,-1)){const I=i(_.row,_.col),S=a(_.col);S&&yo({tableName:S.ref.table,dataSourceId:r,entityId:[[S.ref.field,I]]})}else(C==="drill"||C==="drill-all")&&(f(_),d.open(x))},b=x=>{const y=sr(x.target);y&&(f(y),h.current?.open(x),x.preventDefault(),x.stopPropagation())},v=c*u,w=l.useMemo(()=>{const x=new Map;return e&&e.result.columns.forEach((y,C)=>{x.set(C,{hasRecord:!!y.ref,hasDrill:!!y.referencedBy})}),x},[e]);return s.jsxs(s.Fragment,{children:[g&&d.show&&s.jsx(Zd,{handler:d,rowIndex:g.row,colIndex:g.col}),s.jsx(yh,{ref:h,col:g?.col,row:g?.row,onClosed:()=>{f(void 0)}}),m&&s.jsx(be,{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(jh,{}),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((x,y)=>s.jsx(_h,{index:y,offset:v,row:x,colMeta:w,isLastRow:y===e.result.rows.length-1},y))]})]})]})},La=()=>{const{state:e,setState:t}=l.useContext(Ne),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}},Eh=()=>ne({mutationFn:async e=>{const{data:t}=await B.post("/saved-queries",e);return t.data},onSuccess:()=>{J.invalidateQueries({queryKey:["queries"]}),en()}}),Rh=()=>ne({mutationFn:async e=>B.delete("/saved-queries/"+e),onSuccess:()=>{en()}}),Lh=()=>ne({mutationFn:async({id:e,payload:t})=>{const{data:n}=await B.patch("/saved-queries/"+e,t);return n.data},onSuccess:()=>{en(),gc()}}),[Cs,wo]=je({filters:!1,joins:!1,columns:!1,groupBy:!1,aggregate:!1}),Be=e=>wo(t=>({...t,[e]:!0})),js=e=>wo(t=>({...t,[e]:!1})),rs=e=>wo(t=>({...t,[e]:!t[e]})),Yt=Math.min,St=Math.max,as=Math.round,Yn=Math.floor,qe=e=>({x:e,y:e}),Th={left:"right",right:"left",bottom:"top",top:"bottom"},Ah={start:"end",end:"start"};function Gs(e,t,n){return St(e,Yt(t,n))}function On(e,t){return typeof e=="function"?e(t):e}function Et(e){return e.split("-")[0]}function Dn(e){return e.split("-")[1]}function Ta(e){return e==="x"?"y":"x"}function Co(e){return e==="y"?"height":"width"}const Ih=new Set(["top","bottom"]);function it(e){return Ih.has(Et(e))?"y":"x"}function jo(e){return Ta(it(e))}function Mh(e,t,n){n===void 0&&(n=!1);const o=Dn(e),r=jo(e),a=Co(r);let i=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=is(i)),[i,is(i)]}function Ph(e){const t=is(e);return[Ys(e),t,Ys(t)]}function Ys(e){return e.replace(/start|end/g,t=>Ah[t])}const or=["left","right"],rr=["right","left"],Oh=["top","bottom"],Dh=["bottom","top"];function $h(e,t,n){switch(e){case"top":case"bottom":return n?t?rr:or:t?or:rr;case"left":case"right":return t?Oh:Dh;default:return[]}}function Fh(e,t,n,o){const r=Dn(e);let a=$h(Et(e),n==="start",o);return r&&(a=a.map(i=>i+"-"+r),t&&(a=a.concat(a.map(Ys)))),a}function is(e){return e.replace(/left|right|bottom|top/g,t=>Th[t])}function Bh(e){return{top:0,right:0,bottom:0,left:0,...e}}function Aa(e){return typeof e!="number"?Bh(e):{top:e,right:e,bottom:e,left:e}}function ls(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 ar(e,t,n){let{reference:o,floating:r}=e;const a=it(t),i=jo(t),c=Co(i),u=Et(t),h=a==="y",m=o.x+o.width/2-r.width/2,d=o.y+o.height/2-r.height/2,g=o[c]/2-r[c]/2;let f;switch(u){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:d};break;case"left":f={x:o.x-r.width,y:d};break;default:f={x:o.x,y:o.y}}switch(Dn(t)){case"start":f[i]-=g*(n&&h?-1:1);break;case"end":f[i]+=g*(n&&h?-1:1);break}return f}const qh=async(e,t,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:a=[],platform:i}=n,c=a.filter(Boolean),u=await(i.isRTL==null?void 0:i.isRTL(t));let h=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:m,y:d}=ar(h,o,u),g=o,f={},p=0;for(let b=0;b<c.length;b++){const{name:v,fn:w}=c[b],{x,y,data:C,reset:_}=await w({x:m,y:d,initialPlacement:o,placement:g,strategy:r,middlewareData:f,rects:h,platform:i,elements:{reference:e,floating:t}});m=x??m,d=y??d,f={...f,[v]:{...f[v],...C}},_&&p<=50&&(p++,typeof _=="object"&&(_.placement&&(g=_.placement),_.rects&&(h=_.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):_.rects),{x:m,y:d}=ar(h,g,u)),b=-1)}return{x:m,y:d,placement:g,strategy:r,middlewareData:f}};async function Ia(e,t){var n;t===void 0&&(t={});const{x:o,y:r,platform:a,rects:i,elements:c,strategy:u}=e,{boundary:h="clippingAncestors",rootBoundary:m="viewport",elementContext:d="floating",altBoundary:g=!1,padding:f=0}=On(t,e),p=Aa(f),v=c[g?d==="floating"?"reference":"floating":d],w=ls(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(v)))==null||n?v:v.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:h,rootBoundary:m,strategy:u})),x=d==="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},_=ls(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:x,offsetParent:y,strategy:u}):x);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 Wh=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:o,placement:r,rects:a,platform:i,elements:c,middlewareData:u}=t,{element:h,padding:m=0}=On(e,t)||{};if(h==null)return{};const d=Aa(m),g={x:n,y:o},f=jo(r),p=Co(f),b=await i.getDimensions(h),v=f==="y",w=v?"top":"left",x=v?"bottom":"right",y=v?"clientHeight":"clientWidth",C=a.reference[p]+a.reference[f]-g[f]-a.floating[p],_=g[f]-a.reference[f],I=await(i.getOffsetParent==null?void 0:i.getOffsetParent(h));let S=I?I[y]:0;(!S||!await(i.isElement==null?void 0:i.isElement(I)))&&(S=c.floating[y]||a.floating[p]);const P=C/2-_/2,k=S/2-b[p]/2-1,O=Yt(d[w],k),X=Yt(d[x],k),ce=O,xe=S-b[p]-X,j=S/2-b[p]/2+P,M=Gs(ce,j,xe),K=!u.arrow&&Dn(r)!=null&&j!==M&&a.reference[p]/2-(j<ce?O:X)-b[p]/2<0,Y=K?j<ce?j-ce:j-xe:0;return{[f]:g[f]+Y,data:{[f]:M,centerOffset:j-M-Y,...K&&{alignmentOffset:Y}},reset:K}}}),Uh=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:u,elements:h}=t,{mainAxis:m=!0,crossAxis:d=!0,fallbackPlacements:g,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:b=!0,...v}=On(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const w=Et(r),x=it(c),y=Et(c)===c,C=await(u.isRTL==null?void 0:u.isRTL(h.floating)),_=g||(y||!b?[is(c)]:Ph(c)),I=p!=="none";!g&&I&&_.push(...Fh(c,b,p,C));const S=[c,..._],P=await Ia(t,v),k=[];let O=((o=a.flip)==null?void 0:o.overflows)||[];if(m&&k.push(P[w]),d){const j=Mh(r,i,C);k.push(P[j[0]],P[j[1]])}if(O=[...O,{placement:r,overflows:k}],!k.every(j=>j<=0)){var X,ce;const j=(((X=a.flip)==null?void 0:X.index)||0)+1,M=S[j];if(M&&(!(d==="alignment"?x!==it(M):!1)||O.every(z=>it(z.placement)===x?z.overflows[0]>0:!0)))return{data:{index:j,overflows:O},reset:{placement:M}};let K=(ce=O.filter(Y=>Y.overflows[0]<=0).sort((Y,z)=>Y.overflows[1]-z.overflows[1])[0])==null?void 0:ce.placement;if(!K)switch(f){case"bestFit":{var xe;const Y=(xe=O.filter(z=>{if(I){const ae=it(z.placement);return ae===x||ae==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(ae=>ae>0).reduce((ae,Ke)=>ae+Ke,0)]).sort((z,ae)=>z[1]-ae[1])[0])==null?void 0:xe[0];Y&&(K=Y);break}case"initialPlacement":K=c;break}if(r!==K)return{reset:{placement:K}}}return{}}}},Hh=new Set(["left","top"]);async function zh(e,t){const{placement:n,platform:o,elements:r}=e,a=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=Et(n),c=Dn(n),u=it(n)==="y",h=Hh.has(i)?-1:1,m=a&&u?-1:1,d=On(t,e);let{mainAxis:g,crossAxis:f,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return c&&typeof p=="number"&&(f=c==="end"?p*-1:p),u?{x:f*m,y:g*h}:{x:g*h,y:f*m}}const Vh=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,u=await zh(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:r+u.x,y:a+u.y,data:{...u,placement:i}}}}},Kh=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:v=>{let{x:w,y:x}=v;return{x:w,y:x}}},...u}=On(e,t),h={x:n,y:o},m=await Ia(t,u),d=it(Et(r)),g=Ta(d);let f=h[g],p=h[d];if(a){const v=g==="y"?"top":"left",w=g==="y"?"bottom":"right",x=f+m[v],y=f-m[w];f=Gs(x,f,y)}if(i){const v=d==="y"?"top":"left",w=d==="y"?"bottom":"right",x=p+m[v],y=p-m[w];p=Gs(x,p,y)}const b=c.fn({...t,[g]:f,[d]:p});return{...b,data:{x:b.x-n,y:b.y-o,enabled:{[g]:a,[d]:i}}}}}};function Ns(){return typeof window<"u"}function on(e){return Ma(e)?(e.nodeName||"").toLowerCase():"#document"}function ve(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ve(e){var t;return(t=(Ma(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ma(e){return Ns()?e instanceof Node||e instanceof ve(e).Node:!1}function Ae(e){return Ns()?e instanceof Element||e instanceof ve(e).Element:!1}function Ue(e){return Ns()?e instanceof HTMLElement||e instanceof ve(e).HTMLElement:!1}function ir(e){return!Ns()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ve(e).ShadowRoot}const Qh=new Set(["inline","contents"]);function $n(e){const{overflow:t,overflowX:n,overflowY:o,display:r}=Ie(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&!Qh.has(r)}const Gh=new Set(["table","td","th"]);function Yh(e){return Gh.has(on(e))}const Jh=[":popover-open",":modal"];function _s(e){return Jh.some(t=>{try{return e.matches(t)}catch{return!1}})}const Xh=["transform","translate","scale","rotate","perspective"],Zh=["transform","translate","scale","rotate","perspective","filter"],em=["paint","layout","strict","content"];function No(e){const t=_o(),n=Ae(e)?Ie(e):e;return Xh.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)||Zh.some(o=>(n.willChange||"").includes(o))||em.some(o=>(n.contain||"").includes(o))}function tm(e){let t=ct(e);for(;Ue(t)&&!Jt(t);){if(No(t))return t;if(_s(t))return null;t=ct(t)}return null}function _o(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const nm=new Set(["html","body","#document"]);function Jt(e){return nm.has(on(e))}function Ie(e){return ve(e).getComputedStyle(e)}function Ss(e){return Ae(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ct(e){if(on(e)==="html")return e;const t=e.assignedSlot||e.parentNode||ir(e)&&e.host||Ve(e);return ir(t)?t.host:t}function Pa(e){const t=ct(e);return Jt(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ue(t)&&$n(t)?t:Pa(t)}function Nn(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=Pa(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=ve(r);if(a){const c=Js(i);return t.concat(i,i.visualViewport||[],$n(r)?r:[],c&&n?Nn(c):[])}return t.concat(r,Nn(r,[],n))}function Js(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Oa(e){const t=Ie(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=Ue(e),a=r?e.offsetWidth:n,i=r?e.offsetHeight:o,c=as(n)!==a||as(o)!==i;return c&&(n=a,o=i),{width:n,height:o,$:c}}function So(e){return Ae(e)?e:e.contextElement}function Qt(e){const t=So(e);if(!Ue(t))return qe(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:a}=Oa(t);let i=(a?as(n.width):n.width)/o,c=(a?as(n.height):n.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const sm=qe(0);function Da(e){const t=ve(e);return!_o()||!t.visualViewport?sm:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function om(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ve(e)?!1:t}function Rt(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),a=So(e);let i=qe(1);t&&(o?Ae(o)&&(i=Qt(o)):i=Qt(e));const c=om(a,n,o)?Da(a):qe(0);let u=(r.left+c.x)/i.x,h=(r.top+c.y)/i.y,m=r.width/i.x,d=r.height/i.y;if(a){const g=ve(a),f=o&&Ae(o)?ve(o):o;let p=g,b=Js(p);for(;b&&o&&f!==p;){const v=Qt(b),w=b.getBoundingClientRect(),x=Ie(b),y=w.left+(b.clientLeft+parseFloat(x.paddingLeft))*v.x,C=w.top+(b.clientTop+parseFloat(x.paddingTop))*v.y;u*=v.x,h*=v.y,m*=v.x,d*=v.y,u+=y,h+=C,p=ve(b),b=Js(p)}}return ls({width:m,height:d,x:u,y:h})}function ks(e,t){const n=Ss(e).scrollLeft;return t?t.left+n:Rt(Ve(e)).left+n}function $a(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-ks(e,n),r=n.top+t.scrollTop;return{x:o,y:r}}function rm(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=Ve(o),c=t?_s(t.floating):!1;if(o===i||c&&a)return n;let u={scrollLeft:0,scrollTop:0},h=qe(1);const m=qe(0),d=Ue(o);if((d||!d&&!a)&&((on(o)!=="body"||$n(i))&&(u=Ss(o)),Ue(o))){const f=Rt(o);h=Qt(o),m.x=f.x+o.clientLeft,m.y=f.y+o.clientTop}const g=i&&!d&&!a?$a(i,u):qe(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-u.scrollLeft*h.x+m.x+g.x,y:n.y*h.y-u.scrollTop*h.y+m.y+g.y}}function am(e){return Array.from(e.getClientRects())}function im(e){const t=Ve(e),n=Ss(e),o=e.ownerDocument.body,r=St(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),a=St(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-n.scrollLeft+ks(e);const c=-n.scrollTop;return Ie(o).direction==="rtl"&&(i+=St(t.clientWidth,o.clientWidth)-r),{width:r,height:a,x:i,y:c}}const lr=25;function lm(e,t){const n=ve(e),o=Ve(e),r=n.visualViewport;let a=o.clientWidth,i=o.clientHeight,c=0,u=0;if(r){a=r.width,i=r.height;const m=_o();(!m||m&&t==="fixed")&&(c=r.offsetLeft,u=r.offsetTop)}const h=ks(o);if(h<=0){const m=o.ownerDocument,d=m.body,g=getComputedStyle(d),f=m.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,p=Math.abs(o.clientWidth-d.clientWidth-f);p<=lr&&(a-=p)}else h<=lr&&(a+=h);return{width:a,height:i,x:c,y:u}}const cm=new Set(["absolute","fixed"]);function um(e,t){const n=Rt(e,!0,t==="fixed"),o=n.top+e.clientTop,r=n.left+e.clientLeft,a=Ue(e)?Qt(e):qe(1),i=e.clientWidth*a.x,c=e.clientHeight*a.y,u=r*a.x,h=o*a.y;return{width:i,height:c,x:u,y:h}}function cr(e,t,n){let o;if(t==="viewport")o=lm(e,n);else if(t==="document")o=im(Ve(e));else if(Ae(t))o=um(t,n);else{const r=Da(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return ls(o)}function Fa(e,t){const n=ct(e);return n===t||!Ae(n)||Jt(n)?!1:Ie(n).position==="fixed"||Fa(n,t)}function dm(e,t){const n=t.get(e);if(n)return n;let o=Nn(e,[],!1).filter(c=>Ae(c)&&on(c)!=="body"),r=null;const a=Ie(e).position==="fixed";let i=a?ct(e):e;for(;Ae(i)&&!Jt(i);){const c=Ie(i),u=No(i);!u&&c.position==="fixed"&&(r=null),(a?!u&&!r:!u&&c.position==="static"&&!!r&&cm.has(r.position)||$n(i)&&!u&&Fa(e,i))?o=o.filter(m=>m!==i):r=c,i=ct(i)}return t.set(e,o),o}function hm(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const i=[...n==="clippingAncestors"?_s(t)?[]:dm(t,this._c):[].concat(n),o],c=i[0],u=i.reduce((h,m)=>{const d=cr(t,m,r);return h.top=St(d.top,h.top),h.right=Yt(d.right,h.right),h.bottom=Yt(d.bottom,h.bottom),h.left=St(d.left,h.left),h},cr(t,c,r));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function mm(e){const{width:t,height:n}=Oa(e);return{width:t,height:n}}function fm(e,t,n){const o=Ue(t),r=Ve(t),a=n==="fixed",i=Rt(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const u=qe(0);function h(){u.x=ks(r)}if(o||!o&&!a)if((on(t)!=="body"||$n(r))&&(c=Ss(t)),o){const f=Rt(t,!0,a,t);u.x=f.x+t.clientLeft,u.y=f.y+t.clientTop}else r&&h();a&&!o&&r&&h();const m=r&&!o&&!a?$a(r,c):qe(0),d=i.left+c.scrollLeft-u.x-m.x,g=i.top+c.scrollTop-u.y-m.y;return{x:d,y:g,width:i.width,height:i.height}}function Ds(e){return Ie(e).position==="static"}function ur(e,t){if(!Ue(e)||Ie(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ve(e)===n&&(n=n.ownerDocument.body),n}function Ba(e,t){const n=ve(e);if(_s(e))return n;if(!Ue(e)){let r=ct(e);for(;r&&!Jt(r);){if(Ae(r)&&!Ds(r))return r;r=ct(r)}return n}let o=ur(e,t);for(;o&&Yh(o)&&Ds(o);)o=ur(o,t);return o&&Jt(o)&&Ds(o)&&!No(o)?n:o||tm(e)||n}const pm=async function(e){const t=this.getOffsetParent||Ba,n=this.getDimensions,o=await n(e.floating);return{reference:fm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function xm(e){return Ie(e).direction==="rtl"}const gm={convertOffsetParentRelativeRectToViewportRelativeRect:rm,getDocumentElement:Ve,getClippingRect:hm,getOffsetParent:Ba,getElementRects:pm,getClientRects:am,getDimensions:mm,getScale:Qt,isElement:Ae,isRTL:xm};function qa(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function bm(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,u){c===void 0&&(c=!1),u===void 0&&(u=1),a();const h=e.getBoundingClientRect(),{left:m,top:d,width:g,height:f}=h;if(c||t(),!g||!f)return;const p=Yn(d),b=Yn(r.clientWidth-(m+g)),v=Yn(r.clientHeight-(d+f)),w=Yn(m),y={rootMargin:-p+"px "+-b+"px "+-v+"px "+-w+"px",threshold:St(0,Yt(1,u))||1};let C=!0;function _(I){const S=I[0].intersectionRatio;if(S!==u){if(!C)return i();S?i(!1,S):o=setTimeout(()=>{i(!1,1e-7)},1e3)}S===1&&!qa(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 vm(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:u=!1}=o,h=So(e),m=r||a?[...h?Nn(h):[],...Nn(t)]:[];m.forEach(w=>{r&&w.addEventListener("scroll",n,{passive:!0}),a&&w.addEventListener("resize",n)});const d=h&&c?bm(h,n):null;let g=-1,f=null;i&&(f=new ResizeObserver(w=>{let[x]=w;x&&x.target===h&&f&&(f.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var y;(y=f)==null||y.observe(t)})),n()}),h&&!u&&f.observe(h),f.observe(t));let p,b=u?Rt(e):null;u&&v();function v(){const w=Rt(e);b&&!qa(b,w)&&n(),b=w,p=requestAnimationFrame(v)}return n(),()=>{var w;m.forEach(x=>{r&&x.removeEventListener("scroll",n),a&&x.removeEventListener("resize",n)}),d?.(),(w=f)==null||w.disconnect(),f=null,u&&cancelAnimationFrame(p)}}const ym=Vh,wm=Kh,Cm=Uh,jm=Wh,dr=(e,t,n)=>{const o=new Map,r={platform:gm,...n},a={...r.platform,_c:o};return qh(e,t,{...r,platform:a})};var $s={exports:{}};var hr;function Nm(){return hr||(hr=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})()})($s)),$s.exports}var _m=Nm();const Xs=vi(_m);var mr={};const Sm="react-tooltip-core-styles",km="react-tooltip-base-styles",fr={core:!1,base:!1};function pr({css:e,id:t=km,type:n="base",ref:o}){var r,a;if(!e||typeof document>"u"||fr[n]||n==="core"&&typeof process<"u"&&(!((r=process==null?void 0:mr)===null||r===void 0)&&r.REACT_TOOLTIP_DISABLE_CORE_STYLES)||n!=="base"&&typeof process<"u"&&(!((a=process==null?void 0:mr)===null||a===void 0)&&a.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;n==="core"&&(t=Sm),o||(o={});const{insertAt:i}=o;if(document.getElementById(t))return;const c=document.head||document.getElementsByTagName("head")[0],u=document.createElement("style");u.id=t,u.type="text/css",i==="top"&&c.firstChild?c.insertBefore(u,c.firstChild):c.appendChild(u),u.styleSheet?u.styleSheet.cssText=e:u.appendChild(document.createTextNode(e)),fr[n]=!0}const xr=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:o="top",offset:r=10,strategy:a="absolute",middlewares:i=[ym(Number(r)),Cm({fallbackAxisSideDirection:"start"}),wm({padding:5})],border:c,arrowSize:u=8})=>{if(!e)return{tooltipStyles:{},tooltipArrowStyles:{},place:o};if(t===null)return{tooltipStyles:{},tooltipArrowStyles:{},place:o};const h=i;return n?(h.push(jm({element:n,padding:5})),dr(e,t,{placement:o,strategy:a,middleware:h}).then((({x:m,y:d,placement:g,middlewareData:f})=>{var p,b;const v={left:`${m}px`,top:`${d}px`,border:c},{x:w,y:x}=(p=f.arrow)!==null&&p!==void 0?p:{x:0,y:0},y=(b={top:"bottom",right:"left",bottom:"top",left:"right"}[g.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:v,tooltipArrowStyles:{left:w!=null?`${w}px`:"",top:x!=null?`${x}px`:"",right:"",bottom:"",...C,[y]:`-${u/2+_}px`},place:g}}))):dr(e,t,{placement:"bottom",strategy:a,middleware:h}).then((({x:m,y:d,placement:g})=>({tooltipStyles:{left:`${m}px`,top:`${d}px`},tooltipArrowStyles:{},place:g})))},gr=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),br=(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},vr=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",Zs=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((r,a)=>Zs(r,t[a])));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!vr(e)||!vr(t))return e===t;const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((r=>Zs(e[r],t[r])))},Em=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"}))},yr=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(Em(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},Rm=typeof window<"u"?l.useLayoutEffect:l.useEffect,Se=e=>{e.current&&(clearTimeout(e.current),e.current=null)},Lm="DEFAULT_TOOLTIP_ID",Tm={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},Am=l.createContext({getTooltipData:()=>Tm});function Wa(e=Lm){return l.useContext(Am).getTooltipData(e)}var zt={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"},Fs={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 Im=({forwardRef:e,id:t,className:n,classNameArrow:o,variant:r="dark",anchorId:a,anchorSelect:i,place:c="top",offset:u=10,events:h=["hover"],openOnClick:m=!1,positionStrategy:d="absolute",middlewares:g,wrapper:f,delayShow:p=0,delayHide:b=0,float:v=!1,hidden:w=!1,noArrow:x=!1,clickable:y=!1,closeOnEsc:C=!1,closeOnScroll:_=!1,closeOnResize:I=!1,openEvents:S,closeEvents:P,globalCloseEvents:k,imperativeModeOnly:O,style:X,position:ce,afterShow:xe,afterHide:j,disableTooltip:M,content:K,contentWrapperRef:Y,isOpen:z,defaultIsOpen:ae=!1,setIsOpen:Ke,previousActiveAnchor:rn,activeAnchor:U,setActiveAnchor:Tt,border:Fn,opacity:Bn,arrowColor:qn,arrowSize:At=8,role:Es="tooltip"})=>{var dt;const ue=l.useRef(null),It=l.useRef(null),Le=l.useRef(null),ht=l.useRef(null),Mt=l.useRef(null),[mt,Wn]=l.useState({tooltipStyles:{},tooltipArrowStyles:{},place:c}),[de,an]=l.useState(!1),[Pt,tt]=l.useState(!1),[Q,Ot]=l.useState(null),Un=l.useRef(!1),Dt=l.useRef(null),{anchorRefs:Hn,setActiveAnchor:ln}=Wa(t),cn=l.useRef(!1),[nt,un]=l.useState([]),ft=l.useRef(!1),$t=m||h.includes("click"),zn=$t||S?.click||S?.dblclick||S?.mousedown,dn=S?{...S}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!S&&$t&&Object.assign(dn,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const pt=P?{...P}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!P&&$t&&Object.assign(pt,{mouseleave:!1,blur:!1,mouseout:!1});const oe=k?{...k}:{escape:C||!1,scroll:_||!1,resize:I||!1,clickOutsideAnchor:zn||!1};O&&(Object.assign(dn,{mouseover:!1,focus:!1,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(pt,{mouseout:!1,blur:!1,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(oe,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),Rm((()=>(ft.current=!0,()=>{ft.current=!1})),[]);const he=N=>{ft.current&&(N&&tt(!0),setTimeout((()=>{ft.current&&(Ke?.(N),z===void 0&&an(N))}),10))};l.useEffect((()=>{if(t){if(de){R(rn);const E=N(U),W=[...new Set([...E,t])].filter(Boolean).join(" ");U?.setAttribute("aria-describedby",W)}else R(U);return()=>{R(U),R(rn)}}function N(E){var W;return((W=E?.getAttribute("aria-describedby"))===null||W===void 0?void 0:W.split(" "))||[]}function R(E){const W=N(E).filter((se=>se!==t));W.length?E?.setAttribute("aria-describedby",W.join(" ")):E?.removeAttribute("aria-describedby")}}),[U,de,t,rn]),l.useEffect((()=>{if(z===void 0)return()=>null;z&&tt(!0);const N=setTimeout((()=>{an(z)}),10);return()=>{clearTimeout(N)}}),[z]),l.useEffect((()=>{if(de!==Un.current)if(Se(Mt),Un.current=de,de)xe?.();else{const N=(R=>{const E=R.match(/^([\d.]+)(ms|s)$/);if(!E)return 0;const[,W,se]=E;return Number(W)*(se==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));Mt.current=setTimeout((()=>{tt(!1),Ot(null),j?.()}),N+25)}}),[de]);const hn=N=>{Wn((R=>Zs(R,N)?R:N))},mn=(N=p)=>{Se(Le),Pt?he(!0):Le.current=setTimeout((()=>{he(!0)}),N)},Ft=(N=b)=>{Se(ht),ht.current=setTimeout((()=>{cn.current||he(!1)}),N)},fn=N=>{var R;if(!N)return;const E=(R=N.currentTarget)!==null&&R!==void 0?R:N.target;if(!E?.isConnected)return Tt(null),void ln({current:null});p?mn():he(!0),Tt(E),ln({current:E}),Se(ht)},Bt=()=>{y?Ft(b||100):b?Ft():he(!1),Se(Le)},qt=({x:N,y:R})=>{var E;const W={getBoundingClientRect:()=>({x:N,y:R,width:0,height:0,top:R,left:N,right:N,bottom:R})};xr({place:(E=Q?.place)!==null&&E!==void 0?E:c,offset:u,elementReference:W,tooltipReference:ue.current,tooltipArrowReference:It.current,strategy:d,middlewares:g,border:Fn,arrowSize:At}).then((se=>{hn(se)}))},Wt=N=>{if(!N)return;const R=N,E={x:R.clientX,y:R.clientY};qt(E),Dt.current=E},pn=N=>{var R;if(!de)return;const E=N.target;E.isConnected&&(!((R=ue.current)===null||R===void 0)&&R.contains(E)||[document.querySelector(`[id='${a}']`),...nt].some((W=>W?.contains(E)))||(he(!1),Se(Le)))},Vn=br(fn,50),Z=br(Bt,50),ie=N=>{Z.cancel(),Vn(N)},T=()=>{Vn.cancel(),Z()},D=l.useCallback((()=>{var N,R;const E=(N=Q?.position)!==null&&N!==void 0?N:ce;E?qt(E):v?Dt.current&&qt(Dt.current):U?.isConnected&&xr({place:(R=Q?.place)!==null&&R!==void 0?R:c,offset:u,elementReference:U,tooltipReference:ue.current,tooltipArrowReference:It.current,strategy:d,middlewares:g,border:Fn,arrowSize:At}).then((W=>{ft.current&&hn(W)}))}),[de,U,K,X,c,Q?.place,u,d,ce,Q?.position,v,At]);l.useEffect((()=>{var N,R;const E=new Set(Hn);nt.forEach((q=>{M?.(q)||E.add({current:q})}));const W=document.querySelector(`[id='${a}']`);W&&!M?.(W)&&E.add({current:W});const se=()=>{he(!1)},Oe=yr(U),De=yr(ue.current);oe.scroll&&(window.addEventListener("scroll",se),Oe?.addEventListener("scroll",se),De?.addEventListener("scroll",se));let le=null;oe.resize?window.addEventListener("resize",se):U&&ue.current&&(le=vm(U,ue.current,D,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const _e=q=>{q.key==="Escape"&&he(!1)};oe.escape&&window.addEventListener("keydown",_e),oe.clickOutsideAnchor&&window.addEventListener("click",pn);const H=[],Ut=q=>!!(q?.target&&U?.contains(q.target)),ii=q=>{de&&Ut(q)||fn(q)},li=q=>{de&&Ut(q)&&Bt()},Ao=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],Io=["click","dblclick","mousedown","mouseup"];Object.entries(dn).forEach((([q,Qe])=>{Qe&&(Ao.includes(q)?H.push({event:q,listener:ie}):Io.includes(q)&&H.push({event:q,listener:ii}))})),Object.entries(pt).forEach((([q,Qe])=>{Qe&&(Ao.includes(q)?H.push({event:q,listener:T}):Io.includes(q)&&H.push({event:q,listener:li}))})),v&&H.push({event:"pointermove",listener:Wt});const Mo=()=>{cn.current=!0},Po=()=>{cn.current=!1,Bt()},Oo=y&&(pt.mouseout||pt.mouseleave);return Oo&&((N=ue.current)===null||N===void 0||N.addEventListener("mouseover",Mo),(R=ue.current)===null||R===void 0||R.addEventListener("mouseout",Po)),H.forEach((({event:q,listener:Qe})=>{E.forEach((Rs=>{var xn;(xn=Rs.current)===null||xn===void 0||xn.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):le?.(),oe.clickOutsideAnchor&&window.removeEventListener("click",pn),oe.escape&&window.removeEventListener("keydown",_e),Oo&&((q=ue.current)===null||q===void 0||q.removeEventListener("mouseover",Mo),(Qe=ue.current)===null||Qe===void 0||Qe.removeEventListener("mouseout",Po)),H.forEach((({event:Rs,listener:xn})=>{E.forEach((ci=>{var Ls;(Ls=ci.current)===null||Ls===void 0||Ls.removeEventListener(Rs,xn)}))}))}}),[U,D,Pt,Hn,nt,S,P,k,$t,p,b]),l.useEffect((()=>{var N,R;let E=(R=(N=Q?.anchorSelect)!==null&&N!==void 0?N:i)!==null&&R!==void 0?R:"";!E&&t&&(E=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const W=new MutationObserver((se=>{const Oe=[],De=[];se.forEach((le=>{if(le.type==="attributes"&&le.attributeName==="data-tooltip-id"&&(le.target.getAttribute("data-tooltip-id")===t?Oe.push(le.target):le.oldValue===t&&De.push(le.target)),le.type==="childList"){if(U){const _e=[...le.removedNodes].filter((H=>H.nodeType===1));if(E)try{De.push(..._e.filter((H=>H.matches(E)))),De.push(..._e.flatMap((H=>[...H.querySelectorAll(E)])))}catch{}_e.some((H=>{var Ut;return!!(!((Ut=H?.contains)===null||Ut===void 0)&&Ut.call(H,U))&&(tt(!1),he(!1),Tt(null),Se(Le),Se(ht),!0)}))}if(E)try{const _e=[...le.addedNodes].filter((H=>H.nodeType===1));Oe.push(..._e.filter((H=>H.matches(E)))),Oe.push(..._e.flatMap((H=>[...H.querySelectorAll(E)])))}catch{}}})),(Oe.length||De.length)&&un((le=>[...le.filter((_e=>!De.includes(_e))),...Oe]))}));return W.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{W.disconnect()}}),[t,i,Q?.anchorSelect,U]),l.useEffect((()=>{D()}),[D]),l.useEffect((()=>{if(!Y?.current)return()=>null;const N=new ResizeObserver((()=>{setTimeout((()=>D()))}));return N.observe(Y.current),()=>{N.disconnect()}}),[K,Y?.current]),l.useEffect((()=>{var N;const R=document.querySelector(`[id='${a}']`),E=[...nt,R];U&&E.includes(U)||Tt((N=nt[0])!==null&&N!==void 0?N:R)}),[a,nt,U]),l.useEffect((()=>(ae&&he(!0),()=>{Se(Le),Se(ht)})),[]),l.useEffect((()=>{var N;let R=(N=Q?.anchorSelect)!==null&&N!==void 0?N:i;if(!R&&t&&(R=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),R)try{const E=Array.from(document.querySelectorAll(R));un(E)}catch{un([])}}),[t,i,Q?.anchorSelect]),l.useEffect((()=>{Le.current&&(Se(Le),mn(p))}),[p]);const ge=(dt=Q?.content)!==null&&dt!==void 0?dt:K,xt=de&&Object.keys(mt.tooltipStyles).length>0;return l.useImperativeHandle(e,(()=>({open:N=>{if(N?.anchorSelect)try{document.querySelector(N.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${N.anchorSelect}" is not a valid CSS selector`)}Ot(N??null),N?.delay?mn(N.delay):he(!0)},close:N=>{N?.delay?Ft(N.delay):he(!1)},activeAnchor:U,place:mt.place,isOpen:!!(Pt&&!w&&ge&&xt)}))),Pt&&!w&&ge?at.createElement(f,{id:t,role:Es,className:Xs("react-tooltip",zt.tooltip,Fs.tooltip,Fs[r],n,`react-tooltip__place-${mt.place}`,zt[xt?"show":"closing"],xt?"react-tooltip__show":"react-tooltip__closing",d==="fixed"&&zt.fixed,y&&zt.clickable),onTransitionEnd:N=>{Se(Mt),de||N.propertyName!=="opacity"||(tt(!1),Ot(null),j?.())},style:{...X,...mt.tooltipStyles,opacity:Bn!==void 0&&xt?Bn:void 0},ref:ue},ge,at.createElement(f,{className:Xs("react-tooltip-arrow",zt.arrow,Fs.arrow,o,x&&zt.noArrow),style:{...mt.tooltipArrowStyles,background:qn?`linear-gradient(to right bottom, transparent 50%, ${qn} 50%)`:void 0,"--rt-arrow-size":`${At}px`},ref:It})):null},Mm=({content:e})=>at.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),_n=at.forwardRef((({id:e,anchorId:t,anchorSelect:n,content:o,html:r,render:a,className:i,classNameArrow:c,variant:u="dark",place:h="top",offset:m=10,wrapper:d="div",children:g=null,events:f=["hover"],openOnClick:p=!1,positionStrategy:b="absolute",middlewares:v,delayShow:w=0,delayHide:x=0,float:y=!1,hidden:C=!1,noArrow:_=!1,clickable:I=!1,closeOnEsc:S=!1,closeOnScroll:P=!1,closeOnResize:k=!1,openEvents:O,closeEvents:X,globalCloseEvents:ce,imperativeModeOnly:xe=!1,style:j,position:M,isOpen:K,defaultIsOpen:Y=!1,disableStyleInjection:z=!1,border:ae,opacity:Ke,arrowColor:rn,arrowSize:U,setIsOpen:Tt,afterShow:Fn,afterHide:Bn,disableTooltip:qn,role:At="tooltip"},Es)=>{const[dt,ue]=l.useState(o),[It,Le]=l.useState(r),[ht,Mt]=l.useState(h),[mt,Wn]=l.useState(u),[de,an]=l.useState(m),[Pt,tt]=l.useState(w),[Q,Ot]=l.useState(x),[Un,Dt]=l.useState(y),[Hn,ln]=l.useState(C),[cn,nt]=l.useState(d),[un,ft]=l.useState(f),[$t,zn]=l.useState(b),[dn,pt]=l.useState(null),[oe,he]=l.useState(null),hn=l.useRef(null),mn=l.useRef(z),{anchorRefs:Ft,activeAnchor:fn}=Wa(e),Bt=Z=>Z?.getAttributeNames().reduce(((ie,T)=>{var D;return T.startsWith("data-tooltip-")&&(ie[T.replace(/^data-tooltip-/,"")]=(D=Z?.getAttribute(T))!==null&&D!==void 0?D:null),ie}),{}),qt=Z=>{const ie={place:T=>{var D;Mt((D=T)!==null&&D!==void 0?D:h)},content:T=>{ue(T??o)},html:T=>{Le(T??r)},variant:T=>{var D;Wn((D=T)!==null&&D!==void 0?D:u)},offset:T=>{an(T===null?m:Number(T))},wrapper:T=>{var D;nt((D=T)!==null&&D!==void 0?D:d)},events:T=>{const D=T?.split(" ");ft(D??f)},"position-strategy":T=>{var D;zn((D=T)!==null&&D!==void 0?D:b)},"delay-show":T=>{tt(T===null?w:Number(T))},"delay-hide":T=>{Ot(T===null?x:Number(T))},float:T=>{Dt(T===null?y:T==="true")},hidden:T=>{ln(T===null?C:T==="true")},"class-name":T=>{pt(T)}};Object.values(ie).forEach((T=>T(null))),Object.entries(Z).forEach((([T,D])=>{var ge;(ge=ie[T])===null||ge===void 0||ge.call(ie,D)}))};l.useEffect((()=>{ue(o)}),[o]),l.useEffect((()=>{Le(r)}),[r]),l.useEffect((()=>{Mt(h)}),[h]),l.useEffect((()=>{Wn(u)}),[u]),l.useEffect((()=>{an(m)}),[m]),l.useEffect((()=>{tt(w)}),[w]),l.useEffect((()=>{Ot(x)}),[x]),l.useEffect((()=>{Dt(y)}),[y]),l.useEffect((()=>{ln(C)}),[C]),l.useEffect((()=>{zn(b)}),[b]),l.useEffect((()=>{mn.current!==z&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")}),[z]),l.useEffect((()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:z==="core",disableBase:z}}))}),[]),l.useEffect((()=>{var Z;const ie=new Set(Ft);let T=n;if(!T&&e&&(T=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),T)try{document.querySelectorAll(T).forEach((R=>{ie.add({current:R})}))}catch{console.warn(`[react-tooltip] "${T}" is not a valid CSS selector`)}const D=document.querySelector(`[id='${t}']`);if(D&&ie.add({current:D}),!ie.size)return()=>null;const ge=(Z=oe??D)!==null&&Z!==void 0?Z:fn.current,xt=new MutationObserver((R=>{R.forEach((E=>{var W;if(!ge||E.type!=="attributes"||!(!((W=E.attributeName)===null||W===void 0)&&W.startsWith("data-tooltip-")))return;const se=Bt(ge);qt(se)}))})),N={attributes:!0,childList:!1,subtree:!1};if(ge){const R=Bt(ge);qt(R),xt.observe(ge,N)}return()=>{xt.disconnect()}}),[Ft,fn,oe,t,n]),l.useEffect((()=>{j?.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),ae&&!gr("border",`${ae}`)&&console.warn(`[react-tooltip] "${ae}" is not a valid \`border\`.`),j?.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),Ke&&!gr("opacity",`${Ke}`)&&console.warn(`[react-tooltip] "${Ke}" is not a valid \`opacity\`.`)}),[]);let Wt=g;const pn=l.useRef(null);if(a){const Z=a({content:oe?.getAttribute("data-tooltip-content")||dt||null,activeAnchor:oe});Wt=Z?at.createElement("div",{ref:pn,className:"react-tooltip-content-wrapper"},Z):null}else dt&&(Wt=dt);It&&(Wt=at.createElement(Mm,{content:It}));const Vn={forwardRef:Es,id:e,anchorId:t,anchorSelect:n,className:Xs(i,dn),classNameArrow:c,content:Wt,contentWrapperRef:pn,place:ht,variant:mt,offset:de,wrapper:cn,events:un,openOnClick:p,positionStrategy:$t,middlewares:v,delayShow:Pt,delayHide:Q,float:Un,hidden:Hn,noArrow:_,clickable:I,closeOnEsc:S,closeOnScroll:P,closeOnResize:k,openEvents:O,closeEvents:X,globalCloseEvents:ce,imperativeModeOnly:xe,style:j,position:M,isOpen:K,defaultIsOpen:Y,border:ae,opacity:Ke,arrowColor:rn,arrowSize:U,setIsOpen:Tt,afterShow:Fn,afterHide:Bn,disableTooltip:qn,activeAnchor:oe,previousActiveAnchor:hn.current,setActiveAnchor:Z=>{he((ie=>(Z?.isSameNode(ie)||(hn.current=ie),Z)))},role:At};return at.createElement(Im,{...Vn})}));typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",(e=>{e.detail.disableCore||pr({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||pr({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 Sn=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"})),Ua=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})),Ha=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"})),Pm=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})),Om=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"})),Dm=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"})),za=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"})),$m=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})),ko=()=>{const{pathname:e}=pe();return l.useMemo(()=>Gt({path:F.workbenchTab.path,end:!1},e)?.params.id,[e])},Fm=()=>{const e=ko(),t=ua();return{rename:async o=>{if(e){const r=await Pn("New tab name",o);r&&await t.mutateAsync({id:e,payload:{name:r}})}return Promise.resolve()}}},Va=["shift","alt","meta","mod","ctrl","control"],Bm={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 lt(e){return(Bm[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function Ka(e){return Va.includes(e)}function Bs(e,t=","){return e.toLowerCase().split(t)}function qs(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=>lt(h))):a=e.toLocaleLowerCase().split(t).map(h=>lt(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},u=a.filter(h=>!Va.includes(h));return{...c,keys:u,description:r,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&Qa([lt(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&Ga([lt(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Ge.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Ge.clear()},0)}));const Ge=new Set;function Eo(e){return Array.isArray(e)}function qm(e,t=","){return(Eo(e)?e:e.split(t)).every(n=>Ge.has(n.trim().toLowerCase()))}function Qa(e){const t=Array.isArray(e)?e:[e];Ge.has("meta")&&Ge.forEach(n=>!Ka(n)&&Ge.delete(n.toLowerCase())),t.forEach(n=>Ge.add(n.toLowerCase()))}function Ga(e){const t=Array.isArray(e)?e:[e];e==="meta"?Ge.clear():t.forEach(n=>Ge.delete(n.toLowerCase()))}function Wm(e,t,n){(typeof n=="function"&&n(e,t)||n===!0)&&e.preventDefault()}function Um(e,t,n){return typeof n=="function"?n(e,t):n===!0||n===void 0}const Hm=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function zm(e){return Ya(e,Hm)}function Ya(e,t=!1){const{target:n,composed:o}=e;let r,a;return Vm(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),Eo(t)?!!(r&&t&&t.some(i=>i.toLowerCase()===r.toLowerCase()||i===a)):!!(r&&t&&t)}function Vm(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Km(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 Qm=(e,t,n=!1)=>{const{alt:o,meta:r,mod:a,shift:i,ctrl:c,keys:u,useKey:h}=t,{code:m,key:d,ctrlKey:g,metaKey:f,shiftKey:p,altKey:b}=e,v=lt(m);if(h&&u?.length===1&&u.includes(d))return!0;if(!u?.includes(v)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(v))return!1;if(!n){if(o!==b&&v!=="alt"||i!==p&&v!=="shift")return!1;if(a){if(!f&&!g)return!1}else if(r!==f&&v!=="meta"&&v!=="os"||c!==g&&v!=="ctrl"&&v!=="control")return!1}return u&&u.length===1&&u.includes(v)?!0:u?qm(u):!u},Gm=l.createContext(void 0),Ym=()=>l.useContext(Gm);function Ja(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&&Ja(e[o],t[o]),!0):e===t}const Jm=l.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),Xm=()=>l.useContext(Jm);function Zm(e){const t=l.useRef(void 0);return Ja(t.current,e)||(t.current=e),t.current}const wr=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},ef=typeof window<"u"?l.useLayoutEffect:l.useEffect;function We(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=Eo(e)?e.join(i?.delimiter):e,u=Array.isArray(n)?n:Array.isArray(o)?o:void 0,h=l.useCallback(t,u??[]),m=l.useRef(h);u?m.current=h:m.current=t;const d=Zm(i),{activeScopes:g}=Xm(),f=Ym();return ef(()=>{if(d?.enabled===!1||!Km(g,d?.scopes))return;let p=[],b;const v=(C,_=!1)=>{if(!(zm(C)&&!Ya(C,d?.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)){wr(C);return}}C.target?.isContentEditable&&!d?.enableOnContentEditable||Bs(c,d?.delimiter).forEach(I=>{if(I.includes(d?.splitKey??"+")&&I.includes(d?.sequenceSplitKey??">")){console.warn(`Hotkey ${I} contains both ${d?.splitKey??"+"} and ${d?.sequenceSplitKey??">"} which is not supported.`);return}const S=qs(I,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description);if(S.isSequence){b=setTimeout(()=>{p=[]},d?.sequenceTimeoutMs??1e3);const P=S.useKey?C.key:lt(C.code);if(Ka(P.toLowerCase()))return;p.push(P);const k=S.keys?.[p.length-1];if(P!==k){p=[],b&&clearTimeout(b);return}p.length===S.keys?.length&&(m.current(C,S),b&&clearTimeout(b),p=[])}else if(Qm(C,S,d?.ignoreModifiers)||S.keys?.includes("*")){if(d?.ignoreEventWhen?.(C)||_&&a.current)return;if(Wm(C,S,d?.preventDefault),!Um(C,S,d?.enabled)){wr(C);return}m.current(C,S),_||(a.current=!0)}})}},w=C=>{C.code!==void 0&&(Qa(lt(C.code)),(d?.keydown===void 0&&d?.keyup!==!0||d?.keydown)&&v(C))},x=C=>{C.code!==void 0&&(Ga(lt(C.code)),a.current=!1,d?.keyup&&v(C,!0))},y=r.current||i?.document||document;return y.addEventListener("keyup",x,i?.eventListenerOptions),y.addEventListener("keydown",w,i?.eventListenerOptions),f&&Bs(c,d?.delimiter).forEach(C=>f.addHotkey(qs(C,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description))),()=>{y.removeEventListener("keyup",x,i?.eventListenerOptions),y.removeEventListener("keydown",w,i?.eventListenerOptions),f&&Bs(c,d?.delimiter).forEach(C=>f.removeHotkey(qs(C,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description))),p=[],b&&clearTimeout(b)}},[c,d,g]),r}function tf(){return s.jsxs("div",{className:"flex md:grid md:grid-cols-3 items-center bg-white overflow-auto no-scrollbar",children:[s.jsx(nf,{}),s.jsx(sf,{}),s.jsx(af,{})]})}function nf(){const{dataSourceId:e}=l.useContext(Pe),{data:t}=fs(e),{state:{table:n}}=l.useContext(Ne);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(ze,{size:18,type:t.dbType}),s.jsx("p",{className:"text-sm",children:t.name}),s.jsx(Sn,{width:12,height:12}),s.jsx("p",{className:"text-sm",children:n})]})})}function sf(){const{page:e,size:t,setPage:n}=La(),{data:o,isFetching:r}=l.useContext(et),a=e*t,i=!r&&!!o?.result.hasMore,c=o?.result.rows.length||0,u=()=>{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:u,role:"button",children:s.jsx(Sn,{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(Sn,{width:16,height:16})})]})}const of=[5,10,20,50,100,200],rf=!__CLIENT_CONFIG__.skipAuth;function af(){const{dataSourceId:e,name:t}=l.useContext(Pe),{data:n}=fs(e),{data:o,refetch:r}=l.useContext(et),a=An(me.EDITOR),i=Eh(),{rename:c}=Fm(),{size:u,setSize:h}=La(),{state:m}=l.useContext(Ne),d=Lt(),g=te(),f=()=>{d.mutateAsync({name:t,opts:m}).then(x=>{g(F.workbenchTab.build({id:x.id}))})},p=()=>{if(o?.result.queryHistoryId){const x=new URL(window.location.href);x.pathname=F.share.build(),x.searchParams.set("shareId",o.result.queryHistoryId),navigator.clipboard.writeText(x.toString()),fe.success("Share link copied to clipboard")}},b=()=>{m.table&&hh({table:m.table,dataSourceId:e})},v=async()=>{const x=await Pn("Query name",t);!x||!o?.result.queryHistoryId||i.mutate({name:x,queryId:o.result.queryHistoryId})},w=()=>c(t);return We("s",v),We("r",w),We("d",f),s.jsxs("div",{className:"flex justify-self-end",children:[s.jsx("span",{"data-tooltip-content":"Show filters","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:()=>Be("filters"),role:"button",children:s.jsx(Dm,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Join table","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:()=>Be("joins"),role:"button",children:s.jsx($m,{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(Ha,{width:16,height:16})}),rf&&s.jsx("span",{"data-tooltip-content":"Share query","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:p,role:"button",children:s.jsx(Om,{width:16,height:16})}),s.jsx("span",{"data-tooltip-content":"Duplicate tab","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:f,role:"button",children:s.jsx(Pm,{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:b,role:"button",children:s.jsx(za,{width:16,height:16})}),s.jsx(_n,{id:"rows-num",className:"z-10 shadow-md flex gap-1",clickable:!0,variant:"light",opacity:1,children:of.map(x=>s.jsx("button",{onClick:()=>h(x,!0),className:A(L.tableAction,L.gray,x===u&&L.selectedSize),children:s.jsx("span",{children:x})},x))}),s.jsx("button",{"data-tooltip-id":"explorer-more-actions",className:A(L.tableAction,L.gray),children:s.jsx(Ua,{width:16,height:16})}),s.jsxs(_n,{id:"explorer-more-actions",className:"z-10 shadow-md flex flex-col",clickable:!0,variant:"light",opacity:1,children:[s.jsxs("button",{onClick:()=>Be("columns"),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:()=>Be("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:()=>Be("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:w,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:v,className:A(L.tableAction,L.modal,L.gray),children:[s.jsx("span",{children:"Save query"}),s.jsx("span",{className:"hotkey",children:"S"})]})})]})]})}const lf="_drop-container_enkea_2",cf="_item_enkea_2",Cr={dropContainer:lf,item:cf},Xa=({dataSourceId:e,inputClassName:t,focusId:n,placeholder:o="Column",onChange:r,value:a,autoFocus:i,allowTables:c})=>{const{data:u}=ps(e),h=l.useRef(null),m=l.useMemo(()=>{if(!u)return[];let x=u;return c&&(x=u.filter(y=>c.includes(y.tableName))),x.flatMap(y=>y.columns.map(C=>({value:y.tableName+"."+C.name,label:C.name,table:y.tableName,searchValue:C.name.toLowerCase()})))},[u,c]),d=l.useMemo(()=>{const x=a.toLowerCase()||"",y=[];for(let C=0;C<m.length&&y.length<10;C++)m[C].searchValue.includes(x)&&y.push(m[C]);return y},[m,a]),[g,f]=l.useState(!1),[p,b]=l.useState(0),v=x=>{if(x.key==="ArrowDown")x.preventDefault(),b(y=>(y+1)%d.length);else if(x.key==="ArrowUp")x.preventDefault(),b(y=>(y-1+d.length)%d.length);else if(x.key==="Enter"&&p>=0&&p<d.length){x.preventDefault();const y=d[p].value;f(!1);const C=m.findIndex(_=>_.value===y)>-1;r(d[p]?.value||y,C,!0)}};l.useEffect(()=>{const x=h.current?.querySelector('[data-is-active="true"]');x&&x.scrollIntoView({behavior:"smooth",block:"nearest"})},[p]);const w=x=>{const y=x.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:v,value:a,onChange:w,className:t,placeholder:o,"data-focus":n}),g&&d.length>0&&s.jsx("div",{className:Cr.dropContainer,ref:h,tabIndex:-1,children:d.map((x,y)=>s.jsxs("div",{className:Cr.item,"data-is-active":p===y,onMouseDownCapture:C=>{C.preventDefault(),f(!1),r(x.value,!0,!0)},children:[s.jsx("span",{className:"text-xs font-semibold truncate",children:x.table}),s.jsx("p",{className:"truncate text-sm",children:x.label})]},y))})]})},uf="_actions_152yu_2",df="_filter-actions_152yu_2",hf="_filters-container_152yu_2",mf="_filter-container_152yu_2",cs={actions:uf,filterActions:df,filtersContainer:hf,filterContainer:mf},ff=({filter:e,dataSourceId:t,allowedTables:n,autoFocus:o,onChangeColumn:r,onChangeValue:a,onRemoveFilter:i,triggerIsEnabled:c,onSubmit:u})=>{const h=m=>{m.key==="Enter"&&u()};return s.jsxs("div",{className:cs.filterContainer,children:[s.jsx("input",{className:"mr-1",type:"checkbox",checked:e.isEnabled!==!1,onClick:()=>c(e.id)}),s.jsx(Xa,{dataSourceId:t,onChange:m=>r(e.id,m),value:e.column,allowTables:n,focusId:"column",inputClassName:"input w-full",autoFocus:o}),s.jsx(ys,{prefix:"_",allowedModes:ws,onExpressionChange:m=>a(e.id,m),onKeyDown:h,placeholder:"Filter value",value:e.value,mode:e.mode,className:"h-8"}),s.jsx("div",{className:cs.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(Xe,{width:20,height:20,className:"text-red-600"})})})]})},pf=()=>{const{state:e}=l.useContext(Ne),{refetch:t}=l.useContext(et),{setFilters:n}=xo(),o=Cs(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(v=>[...v.map(w=>w.id===p?{...w,column:b}:w)])},u=(p,b)=>{i(v=>[...v.map(w=>w.id===p?{...w,value:b.value,mode:b.mode}:w)])},h=()=>{i(p=>[...p,{id:Ze(),value:"",column:"",isEnabled:!0,mode:"default"}])},m=p=>{i(b=>b.filter(v=>v.id!==p))},d=()=>js("filters"),g=()=>{try{n(a.filter(p=>p.value.length>0&&p.column.length>0)),setTimeout(t,1),d()}catch(p){p instanceof Error?fe.error(p.message):fe.error("Error during parsing, check you filters")}},f=p=>{i(b=>b.map(v=>v.id===p?{...v,isEnabled:!v.isEnabled}:v))};return l.useEffect(()=>{o&&i(()=>[...e.filters,{id:Ze(),value:"",column:"",isEnabled:!0,mode:"default"}])},[o]),We("f",()=>{rs("filters")}),s.jsxs(Me,{isVisible:o,onClose:d,portal:!0,onClosed:()=>i([]),noPadding:!0,backdropClose:!0,children:[s.jsx(nn,{onClick:d}),s.jsx("h2",{className:"text-lg font-semibold m-2",children:"Filters"}),s.jsxs("div",{className:cs.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(ff,{filter:p,dataSourceId:e.dataSourceId,allowedTables:r,onChangeColumn:c,onChangeValue:u,onRemoveFilter:m,triggerIsEnabled:f,onSubmit:g,autoFocus:b===a.length-1},p.id))]}),s.jsxs("div",{className:cs.actions,children:[s.jsxs("button",{className:"button tertiary flex items-center gap-1 text-sm",onClick:h,children:[s.jsx(za,{width:20,height:20}),s.jsx("span",{children:"Add filter"})]}),s.jsx("button",{className:"button primary text-sm",onClick:g,children:"Apply filters"})]})]})},xf="_join-modal_ux7d0_2",gf={joinModal:xf},bf=(e,t)=>e.type!==t.type||e.on!==t.on||e.table!==t.table,vf=(e,t)=>e.type===t.type&&e.on===t.on&&e.table===t.table,Za=()=>{const{state:e,setState:t}=l.useContext(Ne),n=l.useCallback(o=>{t(r=>{const a=r.joins;if(a.some(c=>vf(c,o))){const c=o.table+".";return{...r,joins:a.filter(u=>bf(u,o)),columns:r.columns.filter(u=>!u.value.startsWith(c)),groupBy:r.groupBy.filter(u=>!u.value.startsWith(c)),orderBy:r.orderBy.filter(u=>!u.column.startsWith(c)),aggregations:r.aggregations.filter(u=>!u.value.startsWith(c)),filters:r.filters.filter(u=>!u.column.startsWith(c))}}return{...r,joins:[...a,o]}})},[t]);return{joins:e.joins,toggle:n}},yf=()=>{const{isFetching:e}=l.useContext(et),t=Cs(u=>u.joins),{toggle:n}=Za(),{availableJoins:o}=l.useContext(Pe),[r,a]=l.useState(""),i=l.useMemo(()=>{const u=r.toLowerCase();return o.filter(h=>h.fromTable.toLowerCase().includes(u))},[o,r]),c=()=>js("joins");return We("j",()=>{o.length>0?Be("joins"):fe.error("No available tables to join")}),s.jsxs(Me,{isVisible:t,onClose:c,portal:!0,backdropClose:!0,children:[s.jsx(nn,{onClick:c}),s.jsxs("div",{className:gf.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:u=>a(u.target.value),value:r,disabled:e}):s.jsx(be,{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(u=>s.jsx(po,{hook:u,onClick:()=>{e||(n({table:u.direction==="in"?u.fromTable:u.toTable,type:"LEFT",on:Xc(u)}),a(""),c())}},u.id))})]})]})};function wf(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}function jr(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}const Cf="_container_sluxh_2",jf="_column-label_sluxh_2",Nf="_not-active_sluxh_2",ns={container:Cf,columnLabel:jf,notActive:Nf};function _f(e){if(!e)return[];const t={};return e.forEach(n=>{t[n.table]?t[n.table].push({value:n.full,ogColumn:n.column,label:Gn(n.column),type:n.type}):t[n.table]=[{value:n.full,ogColumn:n.column,label:Gn(n.column),type:n.type}],Yc[n.type]&&["YEAR","MONTH","DAY"].forEach(o=>{t[n.table].push({value:o+" "+n.full,ogColumn:n.column,label:o+" "+Gn(n.column),type:"number",nested:!0})})}),Object.entries(t).reduce((n,[o,r])=>(n.push({name:Gn(o),columns:r}),n),[])}function Sf(e,t){const n=t.toLowerCase();return e.map(o=>{const r=o.columns.filter(a=>a.label.toLowerCase().includes(n)||a.ogColumn.toLowerCase().includes(n));return{...o,columns:r}}).filter(o=>o.columns.length>0)}const kf=({column:e,selected:t,onCheck:n})=>s.jsxs("label",{className:A(ns.columnLabel,t?ns.active:ns.notActive,e.nested&&"pl-5!"),children:[s.jsx("input",{type:"checkbox",checked:t[e.value],name:e.value,onChange:n}),s.jsxs("p",{className:"flex justify-between w-full",children:[s.jsx("span",{"data-tooltip-content":e.value,"data-tooltip-id":"default",children:e.label}),s.jsx("span",{className:"text-blue-600",children:e.type})]})]},e.value),Ef={columns:"c",groupBy:"g"},Nr=({mode:e})=>{const t=Cs(x=>x[e]),{allColumns:n}=l.useContext(Pe),{state:o,setState:r}=l.useContext(Ne),[a,i]=l.useState({}),[c,u]=l.useState(""),h=l.useMemo(()=>_f(n),[n]),m=o.aggregations.length>0||o.groupBy.length>0,d=l.useMemo(()=>c?Sf(h,c):h,[c,h]),g=x=>{i(y=>({...y,[x.target.name]:x.target.checked}))},f=x=>{const y=x.target.checked;i(C=>{for(const _ of n)C[_.full]=y;return{...C}})},p=()=>{js(e)},b=()=>{const x=[];for(const[y,C]of Object.entries(a))if(C){const[_,I]=y.split(" ");x.push({value:I||_,fn:I?_:void 0})}r(y=>({...y,[e]:x})),p()},v=l.useMemo(()=>{for(const x of n)if(!a[x.full])return!1;return!0},[a,n]);We(Ef[e],()=>{e==="columns"?m?fe.error("Columns are ignored when there is at least one aggregation or group by"):rs("columns"):rs("groupBy")}),l.useEffect(()=>{t&&i(()=>wf(o[e].map(x=>x.fn?x.fn+" "+x.value:x.value)))},[t,i]);const w=()=>{u(""),i({})};return s.jsxs(Me,{isVisible:t,onClose:p,portal:!0,onClosed:w,backdropClose:!0,children:[s.jsx(nn,{onClick:p}),s.jsxs("div",{className:ns.container,children:[s.jsx("h2",{className:"text-lg font-semibold",children:e==="groupBy"?"Group by":"Show columns"}),s.jsx("input",{autoFocus:!0,className:"input my-2",placeholder:"Filter",value:c,onChange:x=>u(x.target.value)}),s.jsx("div",{className:"overflow-y-auto",children:d.map(x=>s.jsxs("div",{className:"my-2",children:[s.jsxs("p",{className:"font-semibold sticky top-0 bg-white p-1 z-1",children:["📄 ",x.name]}),x.columns.map(y=>s.jsx(kf,{column:y,selected:a,onCheck:g},y.value))]},x.name))}),s.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[s.jsxs("label",{className:"button tertiary flex gap-2 items-center",children:[s.jsx("input",{type:"checkbox",checked:v,onChange:f}),s.jsx("span",{children:"Select all"})]}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{className:"button tertiary",onClick:p,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:b,children:"Apply"})]})]})]})},Rf="_options-container_vmmph_2",Lf={optionsContainer:Rf},Ws="COUNT all",Tf=()=>{const e=Cs(p=>p.aggregate),{dataSourceId:t}=l.useContext(Pe),{setState:n,state:o}=l.useContext(Ne),{data:r}=l.useContext(et),[a,i]=l.useState({fn:"",col:""}),c=p=>i({...a,fn:p.currentTarget.value}),u=p=>i({...a,col:p}),h=()=>js("aggregate"),m=()=>{const p=a.fn===Ws?{value:"*",fn:"COUNT"}:{fn:a.fn,value:a.col,distinct:a.fn==="COUNT"};n(b=>({...b,aggregations:[...b.aggregations,p]}))},d=a.fn===Ws,g=d?!1:!a.col||!a.fn,f=p=>{const b=Jc(p);n(v=>({...v,aggregations:v.aggregations.filter(w=>w.fn!==p.fn||w.value!==p.value),orderBy:v.orderBy.filter(w=>w.column!==b)}))};return We("a",()=>{rs("aggregate")}),s.jsxs(Me,{isVisible:e,onClose:h,backdropClose:!0,portal:!0,children:[s.jsx(nn,{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:ts(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(Xe,{width:20,height:20,className:"text-red-600"})})]},b))}),s.jsxs("div",{className:Lf.optionsContainer,children:[s.jsxs("label",{className:A(d&&"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:Ws,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"})]})]}),!d&&s.jsxs("label",{children:[s.jsx("p",{className:"font-semibold text-xs",children:"Column"}),s.jsx(Xa,{inputClassName:"input w-full",dataSourceId:t,allowTables:r?.result.tables||[],onChange:u,value:a.col})]}),s.jsx("button",{className:"button primary",disabled:g,onClick:m,children:"Add"})]})]})]})},Af="_container_hjlb6_2",If="_yellow-pill_hjlb6_2 _pill_hjlb6_2",Mf="_blue-pill_hjlb6_2 _pill_hjlb6_2",Pf="_purple-pill_hjlb6_2 _pill_hjlb6_2",Of="_red-pill_hjlb6_2 _pill_hjlb6_2",Df="_black-pill_hjlb6_2 _pill_hjlb6_2",$f="_disabled-pill_hjlb6_2",yt={container:Af,yellowPill:If,bluePill:Mf,purplePill:Pf,redPill:Of,blackPill:Df,disabledPill:$f};function Ff(e){return!(e===!0||e===void 0)}const Bf=()=>{const{state:{aggregations:e,columns:t,groupBy:n}}=l.useContext(Ne),{toggle:o,joins:r}=Za(),{filters:a,setFilters:i,removeFilter:c}=xo(),u=()=>Be("joins"),h=()=>Be("aggregate"),m=()=>Be("columns"),d=()=>Be("groupBy"),g=b=>{b.preventDefault(),b.stopPropagation(),o(r[r.length-1])},f=b=>{i(a.map(v=>({...v,isEnabled:b===v.id?Ff(v.isEnabled):v.isEnabled})),!0)},p=b=>v=>{v.preventDefault(),v.stopPropagation(),c(b)};return a.length>0||r.length>0||n.length>0||t.length>0||e.length>0?s.jsxs("div",{className:yt.container,children:[r.map((b,v)=>s.jsxs("button",{onClick:u,className:yt.yellowPill,"data-tooltip-id":"default","data-tooltip-content":`Joins ${b.table} on ${b.on}`,children:[s.jsx("p",{className:"text-sm",children:b.table}),v===r.length-1&&s.jsx(Xe,{onClick:g,width:18,height:18})]},b.table)),a.map(b=>s.jsxs("button",{onClick:()=>f(b.id),onAuxClick:()=>c(b.id),className:A(yt.bluePill,b.isEnabled===!1&&yt.disabledPill),"data-tooltip-id":"default","data-tooltip-content":`${b.column} ${b.value}`,children:[s.jsx("p",{className:"text-sm",children:b.column}),s.jsx("p",{className:"text-sm",children:b.value}),s.jsx(Xe,{onClick:p(b.id),width:18,height:18})]},b.id)),e.map(b=>s.jsx("button",{onClick:h,className:A(yt.purplePill),"data-tooltip-id":"default","data-tooltip-content":ts(b),children:s.jsx("p",{className:"text-sm",children:ts(b)})},ts(b))),t.length>0&&s.jsx("button",{onClick:m,className:A(yt.redPill),"data-tooltip-id":"default","data-tooltip-content":"Has hidden columns",children:s.jsx("p",{className:"text-sm",children:"Hidden columns"})}),n.length>0&&s.jsx("button",{onClick:d,className:A(yt.blackPill),"data-tooltip-id":"default","data-tooltip-content":"Has GROUP BY",children:s.jsx("p",{className:"text-sm",children:"Grouped columns"})})]}):null},qf=({options:e,updater:t,name:n,tabId:o})=>{const r=Ac(e,t),a=Wc(o,r.state),i=Tc(a.data,r.state.dataSourceId,n,o);return s.jsx(Pe,{value:i,children:s.jsx(Ne,{value:r,children:s.jsxs(et,{value:a,children:[s.jsx(tf,{}),s.jsx(Bf,{}),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(kh,{})}),s.jsx(pf,{}),s.jsx(yf,{}),s.jsx(Nr,{mode:"columns"}),s.jsx(Nr,{mode:"groupBy"}),s.jsx(Tf,{})]})]})})})},Ro=({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..."})]}),Wf=({id:e})=>{const{data:t}=Bc(e),n=l.useCallback(o=>{if(!t)return;const r=o(kt(t.opts));J.setQueryData(["workbench-tabs",t.id],{...t,opts:{...t.opts,...r}})},[t]);return t?s.jsx(qf,{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(Ro,{})})},_r=e=>{setTimeout(t=>{const n=document.querySelector(`[data-tab-id="${t}"]`);n&&n.scrollIntoView({behavior:"smooth"})},50,e)},Uf=()=>{const{data:e}=bs(),t=qc();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 u;if(e&&i&&c){let h;if(a.all)h=[];else if(a.others)h=e.filter(m=>m.id===o),r!==o&&(u=o);else{const m=e.findIndex(d=>d.id===r);h=e.filter(d=>d.id!==o),h.length>m?u=h[m]?.id:h.length>0&&(u=h[h.length-1].id)}gs(()=>h),h.length===0&&(u="home")}return u}}},Hf=()=>{const e=ua();return{rename:async(n,o)=>{if(o){const r=await Pn("New tab name",n);r&&await e.mutateAsync({id:o,payload:{name:r}})}return Promise.resolve()}}},zf=()=>{const{id:e}=ol(),t=te(),{workbenchTabs:n,archive:o}=Uf(),{rename:r}=Hf(),[a,i]=l.useState(void 0),c=l.useRef(null),u=wa(mo.laptop),h=(f,p={})=>{c.current?.close();const b=o(f,e||"",p);b&&(b==="home"?t(F.home.build(),{replace:!0}):(_r(b),t(F.workbenchTab.build({id:b}),{replace:!0})))},m=f=>{f.stopPropagation(),f.preventDefault();const p=f.currentTarget.getAttribute("data-tab-id");p&&h(p)},d=f=>{const p=f.currentTarget.getAttribute("data-tab-id");p&&c.current&&(f.preventDefault(),f.stopPropagation(),i(p),c.current.open(f))},g=f=>{const p=n?.find(b=>b.id===f);p&&(c.current?.close(),r(p.name,f))};return l.useEffect(()=>{e&&_r(e)},[e,n]),s.jsxs("div",{className:"h-screen max-h-screen bg-(--bg) flex flex-col",children:[e?s.jsx(Wf,{id:e}):s.jsx("div",{className:"flex-1"}),ye(n?.length,0)&&s.jsxs("div",{className:A($e.tabs,"no-scrollbar",!u&&$e.mobile),children:[s.jsx(go,{ref:c,onClosed:()=>i(void 0),children:a&&s.jsxs("div",{className:$e.menu,children:[s.jsx("button",{className:$e.item,onClick:()=>g(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(F.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:d,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(Xe,{width:20,height:20})})]},f.id))]})]})},Vf="_root_1bsgo_2",Kf="_up_1bsgo_2",Qf="_down_1bsgo_2",Gf="_chevron_1bsgo_2",Yf="_table-name-container_1bsgo_2",Jf="_link_1bsgo_2",Xf="_table-name_1bsgo_2",Zf="_ul_1bsgo_2",e0="_column-type_1bsgo_2",t0="_action-blue_1bsgo_2 _action_1bsgo_2",n0="_action-red_1bsgo_2 _action_1bsgo_2",s0="_db-header-container_1bsgo_2",o0="_db-header_1bsgo_2",r0="_db-subheader_1bsgo_2 _db-header_1bsgo_2",re={root:Vf,up:Kf,down:Qf,chevron:Gf,tableNameContainer:Yf,link:Jf,tableName:Xf,ul:Zf,columnType:e0,actionBlue:t0,actionRed:n0,dbHeaderContainer:s0,dbHeader:o0,dbSubheader:r0},a0="_sidebar_1yd55_2",i0="_sidebar-visible_1yd55_2",l0="_sidebar-container_1yd55_2",c0="_sidebar-invisible_1yd55_2",u0="_backdrop_1yd55_2",bn={sidebar:a0,sidebarVisible:i0,sidebarContainer:l0,sidebarInvisible:c0,backdrop:u0},Lo=({children:e,backdropClose:t,isVisible:n,onClose:o,onClosed:r,contentClassName:a})=>{const[i,c]=l.useState(!1),u=()=>{t&&o()},h=m=>{n||getComputedStyle(m.currentTarget).opacity==="0"&&(c(!1),r&&r())};return l.useEffect(()=>{n&&c(!0)},[n]),vs({onClose:u,enabled:n&&t===!0}),s.jsxs("div",{onTransitionEnd:h,className:A(bn.sidebar,n?bn.sidebarVisible:bn.sidebarInvisible),children:[s.jsx("div",{onClick:u,className:bn.backdrop}),s.jsx("div",{className:A(bn.sidebarContainer,a),children:i&&e})]})},eo=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})),d0=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"})),h0=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"})),ei=(e,t=!0)=>{const n=navigator.clipboard.writeText(e);t&&n.then(()=>{fe.success(`Copied "${e}"`)})},m0=e=>{const t=l.useRef(!1);l.useEffect(()=>{e&&(e.status==="INSPECTING"?t.current=!0:e.status==="READY"&&t.current&&(_c(e.id),t.current=!1))},[e])},f0=new Intl.DateTimeFormat("en",{dateStyle:"full",timeStyle:"long"}),Jn=18;function p0(e,t){return t&&e.toLowerCase().includes(t)?"bg-yellow-200 cursor-pointer":"cursor-pointer"}const x0=({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.jsx(s.Fragment,{children:s.jsxs("li",{children:[r.isPrimary?"🔐":"🏷️"," ",s.jsx("span",{onClick:()=>ei(r.name),className:p0(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 g0({id:e}){const{data:t}=fs(e),{data:n}=ps(e),o=te(),r=kc(),a=ia(),i=Ec(),c=Lt(),u=l.useMemo(()=>t?.lastInspected?f0.format(new Date(t.lastInspected)):"--",[t]),[h,m]=l.useState({}),[d,g]=l.useState(""),[f,p]=l.useState("table"),b=An(me.EDITOR),v=d.toLowerCase(),w=l.useMemo(()=>{if(!v||!n)return n||[];const k=[];for(const O of n){if(O.tableName.toLowerCase().includes(v)){k.push(O);continue}f!=="table"&&O.columns.findIndex(X=>X.name.toLowerCase().includes(v))>=0&&k.push(O)}return k},[v,n,f]),x=k=>{m(O=>({...O,[k]:!O[k]}))},y=k=>{c.mutateAsync({name:k,opts:kt({table:k,dataSourceId:e})}).then(O=>{jn(void 0),o(F.workbenchTab.build({id:O.id}))})},C=()=>{a.mutate(e)},_=async()=>{const k=await Pn("Enter name",t?.name);k&&r.mutate({id:e,dataSource:{name:k}})},I=async()=>{await ho("Are you sure you want to delete this data source?")&&(i.mutate(e),jn(void 0))};m0(t);const S=f==="column",P=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(ze,{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:u}),b&&s.jsxs("div",{className:"flex justify-end",children:[s.jsx("button",{disabled:a.isPending||P,onClick:C,className:re.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Refresh schema",children:s.jsx(Ha,{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(d0,{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(h0,{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:S?"Search column":"Search table",value:d,onChange:k=>g(k.target.value),autoFocus:!0})]})]}),P&&s.jsxs("div",{className:"flex justify-center gap-2 items-center bg-blue-50 p-4 rounded",children:[s.jsx(Ro,{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",P&&"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:()=>x(k.id),children:s.jsx(Sn,{width:16,height:16})}),s.jsx("button",{className:A(re.tableName,"flex-1"),onClick:()=>x(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(eo,{width:Jn,height:Jn})}),s.jsx("button",{className:re.link,onClick:()=>ei(k.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Copy table name",children:s.jsx(Ea,{width:Jn,height:Jn})})]}),(h[k.id]||d.length>0)&&s.jsx(x0,{insp:k,filter:S?v:"",expanded:h[k.id]})]},k.id))})]})}const b0=()=>{const e=Au(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>jn(void 0);return s.jsx(Lo,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),backdropClose:!0,children:t&&s.jsx(g0,{id:t})})};function To(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 v0="_search-container_1izag_2",y0="_search_1izag_2",w0="_entry_1izag_2",C0="_ds_1izag_2",j0="_ds-tooltip_1izag_2",N0="_ds-entry_1izag_2",_0="_ds-name_1izag_2",ot={searchContainer:v0,search:y0,entry:w0,ds:C0,dsTooltip:j0,dsEntry:N0,dsName:_0},[S0,k0]=Ra({initialData:[],localStorageKey:"selected-data-sources-v1"}),E0=e=>k0(t=>{const n=t.indexOf(e);return n>-1?(t.splice(n,1),[...t]):[...t,e]}),R0={table:"📄",query:"📖",tab:"🛠️"},L0=({onTable:e,onQuery:t,onWorkbenchTab:n,autoFocus:o})=>{const[r,a]=l.useState(""),[i,c]=l.useState(-1),u=To(r,200),h=S0(),{data:m}=Ce(),{data:d}=co({teamId:m?.teamId}),g=l.useMemo(()=>{const x=[],y=jr(h);if(!d||d.length===0)return[];for(const C of d)y[C.id]&&x.push(C.id);return x},[h,d]),{data:f}=bc(u,{teamId:m?.teamId,selectedDataSources:g}),p=x=>{x.type==="table"?e(x.name,x.dataSourceId):x.type==="query"?t(x.id,x.dataSourceId):x.type==="tab"&&n(x.id,x.dataSourceId)},b=x=>{f&&(x.key==="ArrowDown"?(x.preventDefault(),c(y=>(y+1)%f.length)):x.key==="ArrowUp"?(x.preventDefault(),c(y=>(y-1+f.length)%f.length)):x.key==="Enter"&&i>=0&&f[i]?.name&&(x.preventDefault(),p(f[i])))},v=x=>{const y=x.currentTarget.dataset.tableId,C=f?.find(_=>_.id===y);C&&p(C)},w=l.useMemo(()=>jr(h),[h]);return s.jsxs("div",{className:"overflow-hidden flex flex-col w-full lg:w-lg",children:[s.jsx(_n,{id:"datasources",clickable:!0,className:ot.dsTooltip,variant:"light",place:"left-start",positionStrategy:"fixed",noArrow:!0,opacity:1,children:d?.map(x=>s.jsxs("button",{className:A(ot.dsEntry,w[x.id]&&ot.enabled),onClick:()=>E0(x.id),children:[s.jsx("input",{type:"checkbox",checked:!!w[x.id],readOnly:!0}),s.jsx("p",{className:ot.dsName,children:x.name}),s.jsx("div",{children:s.jsx(ze,{size:16,type:x.dbType})})]},x.id))}),Sa(d?.length,1)&&s.jsx(be,{variant:"warning",className:"mb-4",children:"Connect at least one data source to start using DataRamen"}),s.jsxs("div",{className:ot.searchContainer,children:[s.jsx(sn,{containerClassName:ot.search,placeholder:"Search table or saved query to start from",value:r,onChange:x=>a(x.target.value),onKeyDown:b,autoFocus:o}),ye(d?.length,0)&&s.jsx("span",{"data-tooltip-id":"datasources",children:s.jsx(Ua,{width:16,height:16})})]}),s.jsx("div",{className:"overflow-y-auto max-h-full mt-2",children:f?.map((x,y)=>s.jsxs("button",{className:ot.entry,"data-is-active":i===y,"data-table-id":x.id,onClick:v,children:[s.jsxs("p",{className:"truncate",children:[R0[x.type]," ",x.name]}),s.jsxs("p",{className:ot.ds,children:["📦 ",x.dataSourceName]})]},x.id))})]})},T0=()=>{const e=Hc(),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(Me,{isVisible:!!e,onClose:r,backdropClose:!0,children:s.jsx(L0,{autoFocus:!0,onTable:t,onQuery:n,onWorkbenchTab:o})})},A0=()=>{const e=Tn("Hotkey"),t=te(),{pathname:n}=pe(),{data:o}=Ce(),{data:r}=bs(),a=F.home.check(n);We("n",()=>{o&&e()}),We("w",()=>{o&&(r&&r.length>0?t(F.workbenchTab.build({id:r[0].id})):e())},{enabled:a}),We("h",()=>{Cn({show:!0})})},[I0,ti]=je(!1),Us=()=>ti(!1),ni=()=>ti(!0),M0=({repeatPassword:e,password:t})=>t.length<1?null:t.length<8?s.jsx(be,{variant:"warning",children:"New password should be at least 8 characters long"}):t!==e?s.jsx(be,{variant:"warning",children:"Repeat password should match new password"}):null,P0=()=>{const e=I0(),{data:t}=Ce(),{mutateAsync:n,isPending:o}=Rc(),r=te(),[{password:a,repeatPassword:i},{change:c,touched:u,reset:h}]=kn({password:"",repeatPassword:""}),m=()=>{r("/"),ds.logout().then(()=>{Us()})},d=()=>{n({password:a}).then(()=>{h(),fe.success("Password successfully updated!")})},g=a.length<8||a!==i||o,f=u.includes("password");return s.jsxs(Me,{isVisible:e,onClose:Us,children:[s.jsx(nn,{onClick:Us}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[s.jsx(fa,{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(M0,{password:a,repeatPassword:i}),s.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[s.jsx("button",{className:"button tertiary",disabled:g,onClick:d,children:"Update password"}),s.jsx("button",{className:"button danger",onClick:m,children:"Log out"})]})]})]})},[O0,si]=je(!1),oi=()=>si(!0),Sr=()=>si(!1),D0=e=>we({queryKey:["team-users"],queryFn:async()=>{const{data:t}=await B.get("/teams/"+e+"/users");return t.data},enabled:!!e}),$0=()=>ne({mutationFn:async({role:e,teamId:t,userId:n})=>(await B.patch("/teams/"+t+"/user-role",{role:e,userId:n}),!0),onSuccess:()=>{J.invalidateQueries({queryKey:["team-users"]})}}),F0=()=>ne({mutationFn:async({teamId:e,userId:t})=>(await B.delete("/teams/"+e,{params:{userId:t}}),!0),onSuccess:()=>{J.invalidateQueries({queryKey:["team-users"]})}}),B0="_user-entry_1e8p7_2",q0="_select-container_1e8p7_2",kr={userEntry:B0,selectContainer:q0},W0=()=>{const e=O0(),{data:t}=Ce(),{data:n}=D0(t?.teamId),{mutate:o,isPending:r}=Lc(),{mutate:a,isPending:i}=$0(),{mutate:c,isPending:u}=F0(),[h,{change:m,reset:d}]=kn({password:"",username:""}),g=()=>{o({username:h.username,password:h.password,teamId:t?.teamId||""}),d()},f=(w,x)=>{a({teamId:t.teamId,role:x,userId:w})},p=w=>{ho("Are you sure you want to remove this user?").then(x=>{x&&c({userId:w,teamId:t.teamId})})},b=An(me.ADMIN),v=r||i||u;return s.jsxs(Me,{isVisible:e,onClose:Sr,backdropClose:!0,children:[s.jsx(nn,{onClick:Sr}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[s.jsx(fa,{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:kr.userEntry,children:[s.jsx("div",{className:kr.selectContainer,children:s.jsxs("select",{value:w.role,disabled:!b||v,onChange:x=>f(w.id,x.currentTarget.value),children:[s.jsx("option",{value:me.OWNER,children:"Owner"}),s.jsx("option",{value:me.ADMIN,children:"Admin"}),s.jsx("option",{value:me.EDITOR,children:"Editor"}),s.jsx("option",{value:me.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:v}),s.jsx("input",{className:"input",onChange:m("password"),value:h.password,type:"password",name:"newPassword",autoComplete:"new-password",placeholder:"Password",disabled:v}),s.jsx("button",{className:"button primary",onClick:g,disabled:v,children:"Create user"})]}),s.jsx("p",{className:"text-xs mt-1 text-gray-600",children:"You should create default password for the new account. The user should change it after the first login."})]})]})]})},U0="_gray-card_1rp1c_2",H0="_login-label_1rp1c_2",Er={grayCard:U0,loginLabel:H0},z0=()=>{const[e,t]=l.useState(""),[n,o]=l.useState(""),[r,a]=l.useState(),i=te(),c=u=>{u.preventDefault(),a(void 0),ds.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(ga,{})]}),s.jsxs("form",{className:Er.grayCard,onSubmit:c,children:[s.jsx("h2",{className:Er.loginLabel,children:"Login"}),r&&s.jsx(be,{className:"border border-red-600",variant:"danger",children:"Failed to login. Please verify your credentials"}),s.jsx("input",{value:e,onChange:u=>t(u.currentTarget.value),className:"input secondary",placeholder:"User name"}),s.jsx("input",{value:n,onChange:u=>o(u.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"})})]})]})})},V0=()=>{const e=te(),{pathname:t}=pe(),{data:n,isLoading:o}=la();l.useEffect(()=>{!n&&!o&&!F.login.check(t)&&e(F.login.build())},[n,o,e,t])},K0=()=>{},Q0=__CLIENT_CONFIG__.skipAuth?K0:V0,G0=()=>{const[e]=Gl(),t=te(),n=Lt(),o=e.get("shareId");return l.useEffect(()=>{o&&n.mutateAsync({queryId:o}).then(r=>{t(F.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(Ro,{}),s.jsx("p",{children:"Fetching query information"})]}),n.isError&&s.jsx(be,{variant:"danger",children:"Failed to load query information"})]})},Y0="_tab-container_skud1_2",J0="_tab-name_skud1_2",X0="_archived-badge_skud1_2 _badge_skud1_2",Z0="_active-badge_skud1_2 _badge_skud1_2",ep="_delete-action_skud1_2",vn={tabContainer:Y0,tabName:J0,archivedBadge:X0,activeBadge:Z0,deleteAction:ep},ri=({onLoadMore:e,children:t,onClose:n,hasMore:o,onSearchValue:r,searchValue:a})=>s.jsxs("aside",{className:"w-full lg: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:["Recent tabs",n&&s.jsx("button",{className:"cursor-pointer hover:bg-(--bg-ter) rounded-full p-1",onClick:n,children:s.jsx(Xe,{width:24,height:24})})]}),s.jsx(sn,{containerClassName:"mt-2",className:"text-sm",placeholder:"Filter",value:a,autoFocus:!0,onChange:i=>r(i.target.value)})]}),t,o&&s.jsx("div",{className:"flex justify-center my-2",children:s.jsx("button",{className:"text-blue-800 text-sm p-2 cursor-pointer",onClick:e,children:"Load more"})})]}),tp=new Intl.DateTimeFormat,np=()=>{const[e,t]=l.useState(""),n=To(e),{data:o}=Ce(),{data:r,fetchNextPage:a,hasNextPage:i}=vc(o?.teamId,n,25),c=te(),u=ca(),h=Uc(),m=l.useRef(null),d=l.useRef(null),g=p=>{r?.find(v=>v.id===p)?.archived&&u.mutate(p),Cn({show:!1}),c(F.workbenchTab.build({id:p}))},f=()=>{m.current?.close(),h.mutate(d.current)};return s.jsxs(ri,{hasMore:i,onLoadMore:a,onClose:()=>Cn({show:!1}),searchValue:e,onSearchValue:t,children:[r?.map(p=>s.jsxs("div",{className:vn.tabContainer,onClick:()=>g(p.id),onContextMenu:b=>{d.current=p.id,m.current?.open(b,!1)},children:[s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("p",{className:vn.tabName,children:p.name}),p.dataSourceType&&s.jsx(ze,{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:tp.format(new Date(p.updatedAt))}),p.archived?s.jsx("span",{className:vn.archivedBadge,children:"Archived"}):s.jsx("span",{className:vn.activeBadge,children:"Active"})]})]},p.id)),s.jsx(go,{ref:m,children:s.jsx("button",{onClick:f,className:vn.deleteAction,children:"🗑 Delete"})})]})},sp=()=>{const e=Tu(t=>t.show);return s.jsx(Lo,{isVisible:e,onClose:()=>Cn({show:!1}),backdropClose:!0,children:s.jsx(np,{})})},op=()=>{const{data:e}=Ce(),t=Cc(e?.teamId),n=te();return l.useEffect(()=>{t.mutateAsync().then(o=>{o?n(F.workbenchTab.build({id:o.id}),{replace:!0}):n(F.home.build(),{replace:!0})})},[]),null},rp="_query-entry_166yi_2",ap={queryEntry:rp},ip=new Intl.DateTimeFormat,lp=({projectQueries:e,isLoading:t})=>{const n=l.useRef(void 0),o=te(),r=Lh(),a=Lt(),i=Rh(),c=Na(),u=d=>{a.mutateAsync({queryId:d}).then(g=>{In({show:!1}),o(F.workbenchTab.build({id:g.id}))})},h=async d=>{const g=e?.find(p=>p.id===d);if(!g)return;const f=await Pn("New name?",g?.name);f&&r.mutate({id:g.savedQueryId,payload:{name:f}})},m=d=>{const g=e?.find(f=>f.id===d)?.savedQueryId;g&&i.mutate(g)};return s.jsxs("div",{className:"flex flex-col px-2",children:[ye(e?.length,0)&&e.map(d=>s.jsxs("button",{className:ap.queryEntry,onClick:()=>u(d.id),onContextMenu:g=>{n.current=d.id,c.open(g)},children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-left text-sm font-semibold text-(--text-color-primary)",children:d.name}),s.jsx("p",{className:"text-left text-xs text-(--text-color-secondary) italic",children:ip.format(new Date(d.updatedAt))})]}),s.jsxs("p",{className:"flex gap-2 items-center",children:[s.jsx(ze,{size:16,type:d.datasourceType}),s.jsx("span",{className:"truncate text-xs text-(--text-color-secondary)",children:d.datasourceName})]})]},d.savedQueryId)),!t&&Sa(e?.length,1)&&s.jsx("p",{className:"text-center text-sm text-(--text-color-secondary) mt-2",children:"Empty"}),s.jsx(_a,{handler:c,children:s.jsxs("div",{className:"context-menu-container",children:[s.jsx("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),c.close(),h(n.current)},className:"context-menu-item",children:"✏️ Rename"}),s.jsx("button",{onClick:d=>{d.preventDefault(),d.stopPropagation(),c.close(),m(n.current)},className:"context-menu-item",children:"🗑️ Delete"})]})})]})},cp=()=>{const{data:e}=Ce(),[t,n]=l.useState(""),o=To(t),{data:r,isLoading:a,fetchNextPage:i,hasNextPage:c}=yc(e?.teamId,o);return s.jsx(ri,{hasMore:c,onClose:()=>In({show:!1}),onLoadMore:i,searchValue:t,onSearchValue:n,children:s.jsx(lp,{isLoading:a,projectQueries:r||[]})})},up=()=>{const e=Lu(t=>t.show);return s.jsx(Lo,{isVisible:e,onClose:()=>In({show:!1}),backdropClose:!0,children:s.jsx(cp,{})})};function dp(){return A0(),Q0(),s.jsxs(s.Fragment,{children:[s.jsxs(vl,{children:[s.jsx(Vt,{path:F.home.path,element:s.jsx(Hu,{})}),s.jsx(Vt,{path:F.workbench.path,element:s.jsx(op,{})}),s.jsx(Vt,{path:F.workbenchTab.path,element:s.jsx(zf,{})}),s.jsx(Vt,{path:F.login.path,element:s.jsx(z0,{})}),s.jsx(Vt,{path:F.share.path,element:s.jsx(G0,{})})]}),s.jsx(ud,{}),s.jsx(b0,{}),s.jsx(T0,{}),s.jsx(P0,{}),s.jsx(W0,{}),s.jsx(sp,{}),s.jsx(up,{}),s.jsx(rd,{}),s.jsx(Ku,{})]})}const hp="_hidden_11443_2",mp="_desktop-layout_11443_2",fp="_mobile-layout_11443_2",pp="_nav_11443_2",xp="_shown_11443_2",gp="_main_11443_2",bp="_header_11443_2",vp="_expand_11443_2",yp="_show_11443_2",wp="_hide_11443_2",Cp="_icon_11443_2",jp="_nav-item_11443_2",Np="_project-wrapper_11443_2",$={hidden:hp,desktopLayout:mp,mobileLayout:fp,nav:pp,shown:xp,main:gp,header:bp,expand:vp,show:yp,hide:wp,icon:Cp,navItem:jp,projectWrapper:Np},_p=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"})),Sp=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"})),kp=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})),Ep=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})),Rp=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})),Lp=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})),Tp=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})),Rr=!__CLIENT_CONFIG__.skipAuth,Lr=(()=>{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 Ap(){switch(__CLIENT_CONFIG__.modeName){case"docker":return s.jsx(_p,{className:ke,width:ee,height:ee});case"cli":return s.jsx(Sp,{className:ke,width:ee,height:ee});default:return s.jsx(va,{className:ke,width:ee,height:ee})}}const Ip=({dataSource:e})=>s.jsxs("button",{className:$.navItem,onClick:()=>jn(e.id),"data-tooltip-id":"default","data-tooltip-content":e.name,"data-tooltip-place":"right",children:[s.jsx("span",{className:$.icon,children:s.jsx(ze,{size:20,type:e.dbType})}),s.jsx("span",{className:"truncate",children:e.name})]}),Mp=()=>{const e=te(),{pathname:t}=pe(),{data:n}=Ce(),o=Tn("Desktop nav"),[r,a]=l.useState(!1),{data:i}=bs(),{data:c}=xc(n?.teamId),u=()=>{F.home.check(t)||e(F.home.build())},h=p=>{F.workbenchTab.check(t)||e(F.workbenchTab.build({id:p}))},m=()=>{In({show:!0})},d=()=>{ho("Are you sure you want to logout?").then(p=>{p&&(e("/"),ds.logout())})},g=()=>Cn({show:!0}),f=r?void 0:"default";return s.jsxs("nav",{className:A($.nav,r?$.shown:$.hidden),children:[n&&s.jsxs("div",{className:$.header,children:[s.jsxs("button",{onClick:u,className:$.navItem,"data-tooltip-id":f,"data-tooltip-content":"Home",children:[s.jsx("span",{className:$.icon,children:s.jsx(Ep,{className:ke,width:ee,height:ee})}),s.jsx("span",{className:"truncate",children:"Home"})]}),s.jsxs("button",{onClick:o,className:$.navItem,"data-tooltip-id":f,"data-tooltip-content":"New query",children:[s.jsx("span",{className:$.icon,children:s.jsx(Mn,{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:g,className:$.navItem,"data-tooltip-id":f,"data-tooltip-content":"Recent tabs",children:[s.jsx("span",{className:$.icon,children:s.jsx(pa,{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:$.navItem,"data-tooltip-id":f,"data-tooltip-content":"Saved queries",children:[s.jsx("span",{className:$.icon,children:s.jsx(Tp,{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:$.navItem,"data-tooltip-id":f,"data-tooltip-content":"Workbench",children:[s.jsx("span",{className:$.icon,children:s.jsx(xa,{className:ke,width:ee,height:ee})}),s.jsx("span",{className:"truncate",children:"Workbench"}),s.jsx("span",{className:"hotkey secondary",children:"W"})]}),Rr&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:ni,className:$.navItem,"data-tooltip-id":f,"data-tooltip-content":"User settings",children:[s.jsx("span",{className:$.icon,children:s.jsx(Rp,{className:ke,width:ee,height:ee})}),s.jsx("span",{className:"truncate",children:n.username})]}),s.jsxs("button",{onClick:oi,className:$.navItem,"data-tooltip-id":f,"data-tooltip-content":"Manage users",children:[s.jsx("span",{className:$.icon,children:s.jsx(Lp,{className:ke,width:ee,height:ee})}),s.jsx("span",{className:"truncate",children:"Manage users"})]})]})]}),s.jsx("div",{className:A($.projectWrapper),children:ye(c?.length,0)&&s.jsx("div",{className:"mt-4 flex flex-col",children:c.map(p=>s.jsx(Ip,{dataSource:p},p.id))})}),Rr&&s.jsxs("button",{onClick:d,"data-tooltip-id":f,"data-tooltip-content":"Logout",className:`${$.navItem} mx-1`,children:[s.jsx("span",{className:$.icon,children:s.jsx(kp,{className:ke,width:20,height:20})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:"Logout"})]}),s.jsxs("div",{className:`${$.navItem} mx-1 cursor-auto!`,"data-tooltip-id":f,"data-tooltip-content":Lr,children:[s.jsx("span",{className:$.icon,children:s.jsx(Ap,{})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:Lr})]}),s.jsxs("button",{onClick:()=>a(!r),"data-tooltip-id":"default","data-tooltip-content":"Expand sidebar","data-tooltip-hidden":r,"data-tooltip-place":"right",className:`${$.navItem} mx-1`,children:[s.jsx("span",{className:A($.icon,$.expand,r?$.show:$.hide),children:s.jsx(Sn,{className:ke,width:20,height:20})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:"Collapse menu"})]})]})},Pp="_root_15fjr_2",Op={root:Pp},ai=!__CLIENT_CONFIG__.skipAuth,Dp=`${Op.root} ${ai?"grid-cols-4":"grid-cols-2"}`,$p=()=>{const{pathname:e}=pe(),t=te(),n=Tn("Mobile nav"),o=()=>{F.home.check(e)||t(F.home.build())};return s.jsxs("div",{className:Dp,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"})]}),ai&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:ni,children:[s.jsx("p",{children:"🪪"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Account"})]}),s.jsxs("button",{onClick:oi,children:[s.jsx("p",{children:"👥"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Users"})]})]})]})},Fp=(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}),Bp=()=>ne({mutationFn:async e=>{const{data:t}=await B.post(`/runner/${e.datasourceId}/update`,e);return t.data}}),qp=()=>ne({mutationFn:async e=>{const{data:t}=await B.post(`/runner/${e.datasourceId}/insert`,e);return t.data}}),Wp="_root_rf3m2_2",Up="_container_rf3m2_2",Hp="_header_rf3m2_2",zp="_fields-container_rf3m2_2",Vp="_field-label_rf3m2_2",Kp="_changed-marker_rf3m2_2",Qp="_actions_rf3m2_2",Gp="_close_rf3m2_2",rt={root:Wp,container:Up,header:Hp,fieldsContainer:zp,fieldLabel:Vp,changedMarker:Kp,actions:Qp,close:Gp},Yp=e=>{if(e==null)return"<NULL>";if(e==="")return"<EMPTY STRING>"},Jp=e=>e.isPrimary?"🔐 "+e.name:e.ref?"🔑 "+e.name:e.name,Xp=({data:e})=>{const t=xh(j=>j.history),[n,{set:o,reset:r,touched:a,untouch:i}]=kn({}),c=ko(),u=te(),[h,m]=l.useState(0),[d,g]=l.useState(""),{data:f,isLoading:p,refetch:b}=Fp(e.dataSourceId,e.tableName,e.entityId),{mutateAsync:v,error:w}=Bp(),{mutateAsync:x}=Lt(),y=fo(w),C=An(me.EDITOR),{data:_}=ps(e.dataSourceId),{data:I}=fs(e.dataSourceId),S=l.useMemo(()=>_?.find(j=>j.tableName===e.tableName),[e.tableName,_]),P=l.useMemo(()=>{if(!S)return[];if(!d)return S.columns;const j=d.toLowerCase();return S.columns.filter(M=>M.name.toLowerCase().includes(j))},[d,S]),k=l.useMemo(()=>{const j={};if(!f?.entity)return j;for(let M=0;M<f.columns.length;M++)j[f.columns[M]?.column]=Yp(f.entity[M]);return j},[f]);l.useEffect(()=>{const j=f?.entity;if(r(),j&&f?.columns)for(let M=0;M<f.columns.length;M++){const K=f.columns[M];o(K.column,{value:Nt(j[M]),mode:"default"})}},[f,o,r,h]);const O=()=>{const j={};for(const M of a)j[M]=n[M];v({datasourceId:e.dataSourceId,table:e.tableName,filters:e.entityId.map(M=>({id:Ze(),value:""+M[1],column:M[0],isEnabled:!0})),values:j}).then(()=>{i(),fe.success("Record successfully updated."),b(),c&&da(c)})},X=(j,M,K)=>{x({name:`${j} ${M} = ${K}`,opts:kt({dataSourceId:e.dataSourceId,table:j,filters:[{value:`${K}`,column:`${j}.${M}`,id:Ze(),isEnabled:!0}]})}).then(({id:Y})=>{u(F.workbenchTab.build({id:Y}))})},ce=j=>{const M=t.find(K=>K.key===j);M&&yo(M,!1)},xe=!I?.allowUpdate||!C;return s.jsxs("div",{className:rt.root,children:[s.jsxs("div",{className:rt.header,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("select",{className:"input rounded-md! w-full",value:e?.key,onChange:j=>ce(j.currentTarget.value),children:t.map(j=>s.jsxs("option",{value:j.key,children:[j.tableName," - ",j.entityId.map(M=>`${M[0]} = ${M[1]}`)]},j.key))}),s.jsx("button",{className:rt.close,onClick:bh,children:s.jsx(Xe,{width:20,height:20})})]}),y&&s.jsx(be,{variant:"danger",children:s.jsx("p",{children:y})}),s.jsx(sn,{containerClassName:"mt-2",className:"text-sm",value:d,onChange:j=>g(j.target.value),placeholder:"Filter columns"})]}),s.jsx("div",{className:rt.container,children:s.jsx("div",{className:rt.fieldsContainer,children:P.map(j=>s.jsxs("label",{className:rt.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsxs("p",{children:[a.includes(j.name)&&s.jsx("span",{className:rt.changedMarker}),Jp(j)]}),s.jsx("p",{className:"text-blue-800 text-xs",children:j.type})]}),s.jsxs("div",{className:"flex items-center",children:[s.jsx(ys,{prefix:"=",allowedModes:ws,disabled:j.isPrimary||p||xe,value:Nt(n[j.name]?.value),mode:n[j.name]?.mode,onExpressionChange:M=>o(j.name,M,!0),placeholder:k[j.name]}),j.ref&&s.jsx("button",{className:"cursor-pointer pl-2",onClick:()=>X(j.ref.table,j.ref.field,n[j.name]?.value),children:s.jsx(eo,{width:16,height:16})}),j.isPrimary&&s.jsx("button",{className:"cursor-pointer pl-2",onClick:()=>X(e.tableName,j.name,n[j.name]?.value),children:s.jsx(eo,{width:16,height:16})})]})]},j.name))})}),s.jsxs("div",{className:rt.actions,children:[s.jsx("span",{className:"flex-1"}),a.length>0&&s.jsx("button",{className:"button tertiary",onClick:()=>m(j=>++j),children:"Reset"}),!xe&&s.jsx("button",{disabled:!a.length,className:"button primary",onClick:O,children:"Commit"})]})]})},Zp=()=>{const e=ph();return e?s.jsx(Xp,{data:e}):null},e1="_root_173up_2",t1="_container_173up_2",n1="_header_173up_2",s1="_fields-container_173up_2",o1="_field-label_173up_2",r1="_actions_173up_2",a1="_close_173up_2",wt={root:e1,container:t1,header:n1,fieldsContainer:s1,fieldLabel:o1,actions:r1,close:a1},i1=e=>e.isPrimary?"🔐 "+e.name:e.ref?"🔑 "+e.name:e.name,l1=({data:e})=>{const[t,{set:n,touched:o}]=kn({}),r=ko(),{mutateAsync:a,error:i}=qp(),c=fo(i),{data:u}=ps(e.dataSourceId),[h,m]=l.useState(""),d=l.useMemo(()=>u?.find(p=>p.tableName===e.table),[u,e.table]),g=l.useMemo(()=>{if(!d)return[];if(!h)return d.columns;const p=h.toLowerCase();return d.columns.filter(b=>b.name.toLowerCase().includes(p))},[h,d]),f=()=>{const p={};for(const b of o)p[b]=t[b];a({datasourceId:e.dataSourceId,table:e.table,values:p}).then(()=>{fe.success("Record successfully created."),r&&da(r)})};return s.jsxs("div",{className:wt.root,children:[s.jsxs("div",{className:wt.header,children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("p",{className:"text-lg font-semibold underline",children:["New ",e.table]}),s.jsx("button",{className:wt.close,onClick:mh,children:s.jsx(Xe,{width:20,height:20})})]}),c&&s.jsx(be,{variant:"danger",children:s.jsx("p",{children:c})}),s.jsx(sn,{containerClassName:"mt-2",className:"text-sm",value:h,onChange:p=>m(p.target.value),placeholder:"Filter columns"})]}),s.jsx("div",{className:wt.container,children:s.jsx("div",{className:wt.fieldsContainer,children:g.map(p=>s.jsxs("label",{className:wt.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsx("p",{children:i1(p)}),s.jsx("p",{className:"text-blue-800 text-xs",children:p.type})]}),s.jsx(ys,{prefix:"=",allowedModes:ws,mode:t[p.name]?.mode,value:Nt(t[p.name]?.value),onExpressionChange:b=>n(p.name,b,!0)})]},p.name))})}),s.jsxs("div",{className:wt.actions,children:[s.jsx("span",{className:"flex-1"}),s.jsx("button",{disabled:!o.length,className:"button primary",onClick:f,children:"Insert"})]})]})},c1=()=>{const e=dh();return e?s.jsx(l1,{data:e}):null},u1=({children:e,isLogin:t})=>s.jsxs("div",{className:$.desktopLayout,children:[s.jsx(_n,{id:"default",className:"z-100"}),s.jsx(_n,{id:"default-xs",className:"z-100 text-xs!"}),!t&&s.jsx(Mp,{}),s.jsx("main",{className:$.main,children:e}),s.jsx(Zp,{}),s.jsx(c1,{})]}),d1=({children:e,isLogin:t})=>s.jsxs("div",{className:$.mobileLayout,children:[s.jsx("main",{className:$.main,children:e}),!t&&s.jsx($p,{})]}),h1=({children:e})=>{const t=wa(mo.laptop),{pathname:n}=pe(),o=F.login.check(n);return t?s.jsx(u1,{isLogin:o,children:e}):s.jsx(d1,{isLogin:o,children:e})};yi.createRoot(document.getElementById("root")).render(s.jsxs(at.StrictMode,{children:[s.jsx(wi,{}),s.jsx(rc,{client:J,children:s.jsx(Hl,{children:s.jsx(h1,{children:s.jsx(dp,{})})})})]}));
|