@dataramen/cli 0.0.80 → 0.0.82
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 +12 -8
- package/dist/code/web/assets/{index-BH-53aoF.js → index-4_2vea0v.js} +10 -10
- package/dist/code/web/assets/index-CYeuDa9l.css +1 -0
- package/dist/code/web/assets/main-CqSmXK5U.css +1 -0
- package/dist/code/web/assets/main-DL3NOO1d.js +4 -0
- package/dist/code/web/assets/{setup-BQlPp9ci.js → setup-CXjgdMcg.js} +1 -1
- package/dist/code/web/index.html +4 -4
- package/dist/code/web/setup.html +3 -3
- package/dist/package.json +1 -1
- package/package.json +1 -1
- package/dist/code/web/assets/index-B7w_CUoE.css +0 -1
- package/dist/code/web/assets/main-BI7zNByW.js +0 -4
- package/dist/code/web/assets/main-DmtcqnKx.css +0 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{r as l,a as vi,S as Pr,p as Wo,b as Te,s as os,c as wn,n as rs,i as Qs,d as qo,t as bi,e as Qn,f as yi,g as wi,h as Uo,j as ds,k as Ho,l as Ci,m as ji,o as zo,q as Ni,u as s,v as ro,w as J,x as B,y as Or,A as hs,z as _i,B as A,C as kn,D as ge,E as fe,F as Si,G as ki,R as at,H as Ei,I as Ri}from"./index-4_2vea0v.js";var Vo="popstate";function Li(e={}){function t(o,r){let{pathname:a,search:i,hash:c}=o.location;return Gs("",{pathname:a,search:i,hash:c},r.state&&r.state.usr||null,r.state&&r.state.key||"default")}function n(o,r){return typeof r=="string"?r:Cn(r)}return Ai(t,n,null,e)}function G(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 Ti(){return Math.random().toString(36).substring(2,10)}function Ko(e,t){return{usr:e.state,key:e.key,idx:t}}function Gs(e,t,n=null,o){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Zt(t):t,state:n,key:t&&t.key||o||Ti()}}function Cn({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 Zt(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 Ai(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 b=m(),w=b==null?null:b-h;h=b,u&&u({action:c,location:v.location,delta:w})}function g(b,w){c="PUSH";let p=Gs(v.location,b,w);h=m()+1;let y=Ko(p,h),C=v.createHref(p);try{i.pushState(y,"",C)}catch(N){if(N instanceof DOMException&&N.name==="DataCloneError")throw N;r.location.assign(C)}a&&u&&u({action:c,location:v.location,delta:1})}function f(b,w){c="REPLACE";let p=Gs(v.location,b,w);h=m();let y=Ko(p,h),C=v.createHref(p);i.replaceState(y,"",C),a&&u&&u({action:c,location:v.location,delta:0})}function x(b){return Ii(b)}let v={get action(){return c},get location(){return e(r,i)},listen(b){if(u)throw new Error("A history only accepts one active listener");return r.addEventListener(Vo,d),u=b,()=>{r.removeEventListener(Vo,d),u=null}},createHref(b){return t(r,b)},createURL:x,encodeLocation(b){let w=x(b);return{pathname:w.pathname,search:w.search,hash:w.hash}},push:g,replace:f,go(b){return i.go(b)}};return v}function Ii(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),G(n,"No window.location.(origin|href) available to create URL");let o=typeof e=="string"?e:Cn(e);return o=o.replace(/ $/,"%20"),!t&&o.startsWith("//")&&(o=n+o),new URL(o,n)}function Dr(e,t,n="/"){return Mi(e,t,n,!1)}function Mi(e,t,n,o){let r=typeof t=="string"?Zt(t):t,a=Xe(r.pathname||"/",n);if(a==null)return null;let i=$r(e);Pi(i);let c=null;for(let u=0;c==null&&u<i.length;++u){let h=Vi(a);c=Hi(i[u],h,o)}return c}function $r(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;G(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=Je([o,m.relativePath]),g=n.concat(m);i.children&&i.children.length>0&&(G(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${d}".`),$r(i.children,t,g,d,u)),!(i.path==null&&!i.index)&&t.push({path:d,score:qi(d,i.index),routesMeta:g})};return e.forEach((i,c)=>{if(i.path===""||!i.path?.includes("?"))a(i,c);else for(let u of Fr(i.path))a(i,c,!0,u)}),t}function Fr(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=Fr(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 Pi(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ui(t.routesMeta.map(o=>o.childrenIndex),n.routesMeta.map(o=>o.childrenIndex)))}var Oi=/^:[\w-]+$/,Di=3,$i=2,Fi=1,Bi=10,Wi=-2,Qo=e=>e==="*";function qi(e,t){let n=e.split("/"),o=n.length;return n.some(Qo)&&(o+=Wi),t&&(o+=$i),n.filter(r=>!Qo(r)).reduce((r,a)=>r+(Oi.test(a)?Di:a===""?Fi:Bi),o)}function Ui(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 Hi(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:Je([a,d.pathname]),pathnameBase:Yi(Je([a,d.pathnameBase])),route:g}),d.pathnameBase!=="/"&&(a=Je([a,d.pathnameBase]))}return i}function Gt(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,o]=zi(e.path,e.caseSensitive,e.end),r=t.match(n);if(!r)return null;let a=r[0],i=a.replace(/(.)\/+$/,"$1"),c=r.slice(1);return{params:o.reduce((h,{paramName:m,isOptional:d},g)=>{if(m==="*"){let x=c[g]||"";i=a.slice(0,a.length-x.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 zi(e,t=!1,n=!0){Ee(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let o=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,c,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 Vi(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 Xe(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 Br=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ki=e=>Br.test(e);function Qi(e,t="/"){let{pathname:n,search:o="",hash:r=""}=typeof e=="string"?Zt(e):e,a;if(n)if(Ki(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=Go(n.substring(1),"/"):a=Go(n,t)}else a=t;return{pathname:a,search:Ji(o),hash:Xi(r)}}function Go(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 Ps(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 Gi(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Wr(e){let t=Gi(e);return t.map((n,o)=>o===t.length-1?n.pathname:n.pathnameBase)}function qr(e,t,n,o=!1){let r;typeof e=="string"?r=Zt(e):(r={...e},G(!r.pathname||!r.pathname.includes("?"),Ps("?","pathname","search",r)),G(!r.pathname||!r.pathname.includes("#"),Ps("#","pathname","hash",r)),G(!r.search||!r.search.includes("#"),Ps("#","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=Qi(r,c),h=i&&i!=="/"&&i.endsWith("/"),m=(a||i===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||m)&&(u.pathname+="/"),u}var Je=e=>e.join("/").replace(/\/\/+/g,"/"),Yi=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Ji=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Xi=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 el(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function tl(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Ur=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Hr(e,t){let n=e;if(typeof n!="string"||!Br.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let o=n,r=!1;if(Ur)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),c=Xe(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 zr=["POST","PUT","PATCH","DELETE"];new Set(zr);var nl=["GET",...zr];new Set(nl);var en=l.createContext(null);en.displayName="DataRouter";var ms=l.createContext(null);ms.displayName="DataRouterState";var sl=l.createContext(!1),Vr=l.createContext({isTransitioning:!1});Vr.displayName="ViewTransition";var ol=l.createContext(new Map);ol.displayName="Fetchers";var rl=l.createContext(null);rl.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 ao=l.createContext(null);ao.displayName="RouteError";var Kr="REACT_ROUTER_ERROR",al="REDIRECT",il="ROUTE_ERROR_RESPONSE";function ll(e){if(e.startsWith(`${Kr}:${al}:{`))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 cl(e){if(e.startsWith(`${Kr}:${il}:{`))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 ul(e,{relative:t}={}){G(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:Je([n,a])),o.createHref({pathname:c,search:i,hash:r})}function Rn(){return l.useContext(En)!=null}function pe(){return G(Rn(),"useLocation() may be used only in the context of a <Router> component."),l.useContext(En).location}var Qr="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Gr(e){l.useContext(Re).static||l.useLayoutEffect(e)}function ee(){let{isDataRoute:e}=l.useContext(He);return e?Nl():dl()}function dl(){G(Rn(),"useNavigate() may be used only in the context of a <Router> component.");let e=l.useContext(en),{basename:t,navigator:n}=l.useContext(Re),{matches:o}=l.useContext(He),{pathname:r}=pe(),a=JSON.stringify(Wr(o)),i=l.useRef(!1);return Gr(()=>{i.current=!0}),l.useCallback((u,h={})=>{if(Ee(i.current,Qr),!i.current)return;if(typeof u=="number"){n.go(u);return}let m=qr(u,JSON.parse(a),r,h.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Je([t,m.pathname])),(h.replace?n.replace:n.push)(m,h.state,h)},[t,n,a,r,e])}l.createContext(null);function hl(){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(Wr(n));return l.useMemo(()=>qr(e,JSON.parse(r),o,t==="path"),[e,r,o,t])}function ml(e,t){return Yr(e,t)}function Yr(e,t,n,o,r){G(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 p=d&&d.path||"";Xr(h,!d||p.endsWith("*")||p.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${p}">) 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="${p}"> to <Route path="${p==="/"?"*":`${p}/*`}">.`)}let g=pe(),f;if(t){let p=typeof t=="string"?Zt(t):t;G(m==="/"||p.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 "${p.pathname}" was given in the \`location\` prop.`),f=p}else f=g;let x=f.pathname||"/",v=x;if(m!=="/"){let p=m.replace(/^\//,"").split("/");v="/"+x.replace(/^\//,"").split("/").slice(p.length).join("/")}let b=Dr(e,{pathname:v});Ee(d||b!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),Ee(b==null||b[b.length-1].route.element!==void 0||b[b.length-1].route.Component!==void 0||b[b.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=vl(b&&b.map(p=>Object.assign({},p,{params:Object.assign({},u,p.params),pathname:Je([m,a.encodeLocation?a.encodeLocation(p.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:p.pathname]),pathnameBase:p.pathnameBase==="/"?m:Je([m,a.encodeLocation?a.encodeLocation(p.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:p.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 fl(){let e=jl(),t=el(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 pl=l.createElement(fl,null),Jr=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=cl(e.digest);n&&(e=n)}let t=e!==void 0?l.createElement(He.Provider,{value:this.props.routeContext},l.createElement(ao.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?l.createElement(xl,{error:e},t):t}};Jr.contextType=sl;var Os=new WeakMap;function xl({children:e,error:t}){let{basename:n}=l.useContext(Re);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let o=ll(t.digest);if(o){let r=Os.get(t);if(r)throw r;let a=Hr(o.location,n);if(Ur&&!Os.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 Os.set(t,i),i}return l.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function gl({routeContext:e,match:t,children:n}){let o=l.useContext(en);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 vl(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);G(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,x=d.route.loader&&!g.hasOwnProperty(d.route.id)&&(!f||f[d.route.id]===void 0);if(d.route.lazy||x){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:tl(n.matches),errorInfo:d})}:void 0;return a.reduceRight((m,d,g)=>{let f,x=!1,v=null,b=null;n&&(f=i&&d.route.id?i[d.route.id]:void 0,v=d.route.errorElement||pl,c&&(u<0&&g===0?(Xr("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,b=null):u===g&&(x=!0,b=d.route.hydrateFallbackElement||null)));let w=t.concat(a.slice(0,g+1)),p=()=>{let y;return f?y=v:x?y=b:d.route.Component?y=l.createElement(d.route.Component,null):d.route.element?y=d.route.element:y=m,l.createElement(gl,{match:d,routeContext:{outlet:m,matches:w,isDataRoute:n!=null},children:y})};return n&&(d.route.ErrorBoundary||d.route.errorElement||g===0)?l.createElement(Jr,{location:n.location,revalidation:n.revalidation,component:v,error:f,children:p(),routeContext:{outlet:null,matches:w,isDataRoute:!0},onError:h}):p()},null)}function io(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function bl(e){let t=l.useContext(en);return G(t,io(e)),t}function yl(e){let t=l.useContext(ms);return G(t,io(e)),t}function wl(e){let t=l.useContext(He);return G(t,io(e)),t}function lo(e){let t=wl(e),n=t.matches[t.matches.length-1];return G(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Cl(){return lo("useRouteId")}function jl(){let e=l.useContext(ao),t=yl("useRouteError"),n=lo("useRouteError");return e!==void 0?e:t.errors?.[n]}function Nl(){let{router:e}=bl("useNavigate"),t=lo("useNavigate"),n=l.useRef(!1);return Gr(()=>{n.current=!0}),l.useCallback(async(r,a={})=>{Ee(n.current,Qr),n.current&&(typeof r=="number"?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...a}))},[e,t])}var Yo={};function Xr(e,t,n){!t&&!Yo[e]&&(Yo[e]=!0,Ee(!1,n))}l.memo(_l);function _l({routes:e,future:t,state:n,onError:o}){return Yr(e,void 0,n,o,t)}function Vt(e){G(!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 Sl({basename:e="/",children:t=null,location:n,navigationType:o="POP",navigator:r,static:a=!1,unstable_useTransitions:i}){G(!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=Zt(n));let{pathname:h="/",search:m="",hash:d="",state:g=null,key:f="default"}=n,x=l.useMemo(()=>{let v=Xe(h,c);return v==null?null:{location:{pathname:v,search:m,hash:d,state:g,key:f},navigationType:o}},[c,h,m,d,g,f,o]);return Ee(x!=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.`),x==null?null:l.createElement(Re.Provider,{value:u},l.createElement(En.Provider,{children:t,value:x}))}function kl({children:e,location:t}){return ml(Ys(e),t)}function Ys(e,t=[]){let n=[];return l.Children.forEach(e,(o,r)=>{if(!l.isValidElement(o))return;let a=[...t,r];if(o.type===l.Fragment){n.push.apply(n,Ys(o.props.children,a));return}G(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>`),G(!o.props.index||!o.props.children,"An index route cannot have child routes.");let i={id:o.props.id||a.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(i.children=Ys(o.props.children,a)),n.push(i)}),n}var Zn="get",es="application/x-www-form-urlencoded";function fs(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function El(e){return fs(e)&&e.tagName.toLowerCase()==="button"}function Rl(e){return fs(e)&&e.tagName.toLowerCase()==="form"}function Ll(e){return fs(e)&&e.tagName.toLowerCase()==="input"}function Tl(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Al(e,t){return e.button===0&&(!t||t==="_self")&&!Tl(e)}function Js(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let o=e[n];return t.concat(Array.isArray(o)?o.map(r=>[n,r]):[[n,o]])},[]))}function Il(e,t){let n=Js(e);return t&&t.forEach((o,r)=>{n.has(r)||t.getAll(r).forEach(a=>{n.append(r,a)})}),n}var Gn=null;function Ml(){if(Gn===null)try{new FormData(document.createElement("form"),0),Gn=!1}catch{Gn=!0}return Gn}var Pl=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ds(e){return e!=null&&!Pl.has(e)?(Ee(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${es}"`),null):e}function Ol(e,t){let n,o,r,a,i;if(Rl(e)){let c=e.getAttribute("action");o=c?Xe(c,t):null,n=e.getAttribute("method")||Zn,r=Ds(e.getAttribute("enctype"))||es,a=new FormData(e)}else if(El(e)||Ll(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?Xe(u,t):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||Zn,r=Ds(e.getAttribute("formenctype"))||Ds(c.getAttribute("enctype"))||es,a=new FormData(c,e),!Ml()){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(fs(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Zn,o=null,r=es,i=e}return a&&r==="text/plain"&&(i=a,a=void 0),{action:o,method:n.toLowerCase(),encType:r,formData:a,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function co(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Dl(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&&Xe(r.pathname,t)==="/"?r.pathname=`${t.replace(/\/$/,"")}/_root.${o}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${o}`,r}async function $l(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 Fl(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 Bl(e,t,n){let o=await Promise.all(e.map(async r=>{let a=t.routes[r.route.id];if(a){let i=await $l(a,n);return i.links?i.links():[]}return[]}));return Hl(o.flat(1).filter(Fl).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function Jo(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 Wl(e,t,{includeHydrateFallback:n}={}){return ql(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 ql(e){return[...new Set(e)]}function Ul(e){let t={},n=Object.keys(e).sort();for(let o of n)t[o]=e[o];return t}function Hl(e,t){let n=new Set;return new Set(t),e.reduce((o,r)=>{let a=JSON.stringify(Ul(r));return n.has(a)||(n.add(a),o.push({key:a,link:r})),o},[])}function Zr(){let e=l.useContext(en);return co(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function zl(){let e=l.useContext(ms);return co(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var uo=l.createContext(void 0);uo.displayName="FrameworkContext";function ea(){let e=l.useContext(uo);return co(e,"You must render this element inside a <HydratedRouter> element"),e}function Vl(e,t){let n=l.useContext(uo),[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 v=w=>{w.forEach(p=>{i(p.isIntersecting)})},b=new IntersectionObserver(v,{threshold:.5});return g.current&&b.observe(g.current),()=>{b.disconnect()}}},[e]),l.useEffect(()=>{if(o){let v=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(v)}}},[o]);let f=()=>{r(!0)},x=()=>{r(!1),i(!1)};return n?e!=="intent"?[a,g,{}]:[a,g,{onFocus:vn(c,f),onBlur:vn(u,x),onMouseEnter:vn(h,f),onMouseLeave:vn(m,x),onTouchStart:vn(d,f)}]:[!1,g,{}]}function vn(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Kl({page:e,...t}){let{router:n}=Zr(),o=l.useMemo(()=>Dr(n.routes,e,n.basename),[n.routes,e,n.basename]);return o?l.createElement(Gl,{page:e,matches:o,...t}):null}function Ql(e){let{manifest:t,routeModules:n}=ea(),[o,r]=l.useState([]);return l.useEffect(()=>{let a=!1;return Bl(e,t,n).then(i=>{a||r(i)}),()=>{a=!0}},[e,t,n]),o}function Gl({page:e,matches:t,...n}){let o=pe(),{future:r,manifest:a,routeModules:i}=ea(),{basename:c}=Zr(),{loaderData:u,matches:h}=zl(),m=l.useMemo(()=>Jo(e,t,h,a,o,"data"),[e,t,h,a,o]),d=l.useMemo(()=>Jo(e,t,h,a,o,"assets"),[e,t,h,a,o]),g=l.useMemo(()=>{if(e===o.pathname+o.search+o.hash)return[];let v=new Set,b=!1;if(t.forEach(p=>{let y=a.routes[p.route.id];!y||!y.hasLoader||(!m.some(C=>C.route.id===p.route.id)&&p.route.id in u&&i[p.route.id]?.shouldRevalidate||y.hasClientLoader?b=!0:v.add(p.route.id))}),v.size===0)return[];let w=Dl(e,c,r.unstable_trailingSlashAwareDataRequests,"data");return b&&v.size>0&&w.searchParams.set("_routes",t.filter(p=>v.has(p.route.id)).map(p=>p.route.id).join(",")),[w.pathname+w.search]},[c,r.unstable_trailingSlashAwareDataRequests,u,o,a,m,t,e,i]),f=l.useMemo(()=>Wl(d,a),[d,a]),x=Ql(d);return l.createElement(l.Fragment,null,g.map(v=>l.createElement("link",{key:v,rel:"prefetch",as:"fetch",href:v,...n})),f.map(v=>l.createElement("link",{key:v,rel:"modulepreload",href:v,...n})),x.map(({key:v,link:b})=>l.createElement("link",{key:v,nonce:n.nonce,...b})))}function Yl(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Jl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Jl&&(window.__reactRouterVersion="7.12.0")}catch{}function Xl({basename:e,children:t,unstable_useTransitions:n,window:o}){let r=l.useRef();r.current==null&&(r.current=Li({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(Sl,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a,unstable_useTransitions:n})}var ta=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,na=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},x){let{basename:v,unstable_useTransitions:b}=l.useContext(Re),w=typeof h=="string"&&ta.test(h),p=Hr(h,v);h=p.to;let y=ul(h,{relative:r}),[C,N,I]=Vl(o,f),_=nc(h,{replace:i,state:c,target:u,preventScrollReset:m,relative:r,viewTransition:d,unstable_defaultShouldRevalidate:g,unstable_useTransitions:b});function M(O){t&&t(O),O.defaultPrevented||_(O)}let k=l.createElement("a",{...f,...I,href:p.absoluteURL||y,onClick:p.isExternal||a?t:M,ref:Yl(x,N),target:u,"data-discover":!w&&n==="render"?"true":void 0});return C&&!w?l.createElement(l.Fragment,null,k,l.createElement(Kl,{page:y})):k});na.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(ms),{navigator:x,basename:v}=l.useContext(Re),b=f!=null&&lc(d)&&c===!0,w=x.encodeLocation?x.encodeLocation(d).pathname:d.pathname,p=g.pathname,y=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;n||(p=p.toLowerCase(),y=y?y.toLowerCase():null,w=w.toLowerCase()),y&&v&&(y=Xe(y,v)||y);const C=w!=="/"&&w.endsWith("/")?w.length-1:w.length;let N=p===w||!r&&p.startsWith(w)&&p.charAt(C)==="/",I=y!=null&&(y===w||!r&&y.startsWith(w)&&y.charAt(w.length)==="/"),_={isActive:N,isPending:I,isTransitioning:b},M=N?t:void 0,k;typeof o=="function"?k=o(_):k=[o,N?"active":null,I?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let O=typeof a=="function"?a(_):a;return l.createElement(na,{...h,"aria-current":M,className:k,ref:m,style:O,to:i,viewTransition:c},typeof u=="function"?u(_):u)});Zl.displayName="NavLink";var ec=l.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:o,replace:r,state:a,method:i=Zn,action:c,onSubmit:u,relative:h,preventScrollReset:m,viewTransition:d,unstable_defaultShouldRevalidate:g,...f},x)=>{let{unstable_useTransitions:v}=l.useContext(Re),b=ac(),w=ic(c,{relative:h}),p=i.toLowerCase()==="get"?"get":"post",y=typeof c=="string"&&ta.test(c),C=N=>{if(u&&u(N),N.defaultPrevented)return;N.preventDefault();let I=N.nativeEvent.submitter,_=I?.getAttribute("formmethod")||i,M=()=>b(I||N.currentTarget,{fetcherKey:t,method:_,navigate:n,replace:r,state:a,relative:h,preventScrollReset:m,viewTransition:d,unstable_defaultShouldRevalidate:g});v&&n!==!1?l.startTransition(()=>M()):M()};return l.createElement("form",{ref:x,method:p,action:w,onSubmit:o?u:C,...f,"data-discover":!y&&e==="render"?"true":void 0})});ec.displayName="Form";function tc(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function sa(e){let t=l.useContext(en);return G(t,tc(e)),t}function nc(e,{target:t,replace:n,state:o,preventScrollReset:r,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:c,unstable_useTransitions:u}={}){let h=ee(),m=pe(),d=Ln(e,{relative:a});return l.useCallback(g=>{if(Al(g,t)){g.preventDefault();let f=n!==void 0?n:Cn(m)===Cn(d),x=()=>h(e,{replace:f,state:o,preventScrollReset:r,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:c});u?l.startTransition(()=>x()):x()}},[m,h,d,n,o,t,e,r,a,i,c,u])}function sc(e){Ee(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=l.useRef(Js(e)),n=l.useRef(!1),o=pe(),r=l.useMemo(()=>Il(o.search,n.current?null:t.current),[o.search]),a=ee(),i=l.useCallback((c,u)=>{const h=Js(typeof c=="function"?c(new URLSearchParams(r)):c);n.current=!0,a("?"+h,u)},[a,r]);return[r,i]}var oc=0,rc=()=>`__${String(++oc)}__`;function ac(){let{router:e}=sa("useSubmit"),{basename:t}=l.useContext(Re),n=Cl(),o=e.fetch,r=e.navigate;return l.useCallback(async(a,i={})=>{let{action:c,method:u,encType:h,formData:m,body:d}=Ol(a,t);if(i.navigate===!1){let g=i.fetcherKey||rc();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 ic(e,{relative:t}={}){let{basename:n}=l.useContext(Re),o=l.useContext(He);G(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:Je([n,a.pathname])),Cn(a)}function lc(e,{relative:t}={}){let n=l.useContext(Vr);G(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=sa("useViewTransitionState"),r=Ln(e,{relative:t});if(!n.isTransitioning)return!1;let a=Xe(n.currentLocation.pathname,o)||n.currentLocation.pathname,i=Xe(n.nextLocation.pathname,o)||n.nextLocation.pathname;return Gt(r.pathname,i)!=null||Gt(r.pathname,a)!=null}var ho=vi(),oa=class extends Pr{constructor(e,t){super(),this.options=t,this.#n=e,this.#i=null,this.#a=Wo(),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),Xo(this.#e,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Xs(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Xs(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#y(),this.#w(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,n=this.#e;if(this.options=this.#n.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof 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&&!os(this.options,t)&&this.#n.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const o=this.hasListeners();o&&Zo(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)||wn(this.options.staleTime,this.#e)!==wn(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.#v(r)}getOptimisticResult(e){const t=this.#n.getQueryCache().build(this.#n,e),n=this.createResult(t,e);return uc(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(rs)),t}#x(){this.#y();const e=wn(this.options.staleTime,this.#e);if(Qs||this.#t.isStale||!qo(e))return;const n=bi(this.#t.dataUpdatedAt,e)+1;this.#c=Qn.setTimeout(()=>{this.#t.isStale||this.updateResult()},n)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#v(e){this.#w(),this.#l=e,!(Qs||Te(this.options.enabled,this.#e)===!1||!qo(this.#l)||this.#l===0)&&(this.#u=Qn.setInterval(()=>{(this.options.refetchIntervalInBackground||yi.isFocused())&&this.#d()},this.#l))}#b(){this.#x(),this.#v(this.#g())}#y(){this.#c&&(Qn.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(Qn.clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const n=this.#e,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 M=this.hasListeners(),k=!M&&Xo(e,t),O=M&&Zo(e,n,t,o);(k||O)&&(m={...m,...wi(h.data,e.options)}),t._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:f,errorUpdatedAt:x,status:v}=m;g=m.data;let b=!1;if(t.placeholderData!==void 0&&g===void 0&&v==="pending"){let M;r?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(M=r.data,b=!0):M=typeof t.placeholderData=="function"?t.placeholderData(this.#m?.state.data,this.#m):t.placeholderData,M!==void 0&&(v="success",g=Uo(r?.data,M,t),d=!0)}if(t.select&&g!==void 0&&!b)if(r&&g===a?.data&&t.select===this.#p)g=this.#h;else try{this.#p=t.select,g=t.select(g),g=Uo(r?.data,g,t),this.#h=g,this.#i=null}catch(M){this.#i=M}this.#i&&(f=this.#i,g=this.#h,x=Date.now(),v="error");const w=m.fetchStatus==="fetching",p=v==="pending",y=v==="error",C=p&&w,N=g!==void 0,_={status:v,fetchStatus:m.fetchStatus,isPending:p,isSuccess:v==="success",isError:y,isInitialLoading:C,isLoading:C,data:g,dataUpdatedAt:m.dataUpdatedAt,error:f,errorUpdatedAt:x,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&&!p,isLoadingError:y&&!N,isPaused:m.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:y&&N,isStale:mo(e,t),refetch:this.refetch,promise:this.#a,isEnabled:Te(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const M=te=>{_.status==="error"?te.reject(_.error):_.data!==void 0&&te.resolve(_.data)},k=()=>{const te=this.#a=_.promise=Wo();M(te)},O=this.#a;switch(O.status){case"pending":e.queryHash===n.queryHash&&M(O);break;case"fulfilled":(_.status==="error"||_.data!==O.value)&&k();break;case"rejected":(_.status!=="error"||_.error!==O.reason)&&k();break}}return _}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),os(t,e))return;this.#t=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:o}=this.options,r=typeof o=="function"?o():o;if(r==="all"||!r&&!this.#f.size)return!0;const a=new Set(r??this.#f);return this.options.throwOnError&&a.add("error"),Object.keys(this.#t).some(i=>{const c=i;return this.#t[c]!==e[c]&&a.has(c)})};this.#j({listeners:n()})}#C(){const e=this.#n.getQueryCache().build(this.#n,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#s=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#j(e){ds.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#t)}),this.#n.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function cc(e,t){return Te(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Xo(e,t){return cc(e,t)||e.state.data!==void 0&&Xs(e,t,t.refetchOnMount)}function Xs(e,t,n){if(Te(t.enabled,e)!==!1&&wn(t.staleTime,e)!=="static"){const o=typeof n=="function"?n(e):n;return o==="always"||o!==!1&&mo(e,t)}return!1}function Zo(e,t,n,o){return(e!==t||Te(o.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&mo(e,n)}function mo(e,t){return Te(t.enabled,e)!==!1&&e.isStaleByTime(wn(t.staleTime,e))}function uc(e,t){return!os(e.getCurrentResult(),t)}var dc=class extends oa{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:Ho()})}getOptimisticResult(e){return e.behavior=Ho(),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:ji(t,n.data),hasPreviousPage:Ci(t,n.data),isFetchNextPageError:h,isFetchingNextPage:m,isFetchPreviousPageError:d,isFetchingPreviousPage:g,isRefetchError:c&&!h&&!d,isRefetching:a&&!m&&!g}}},hc=class extends Pr{#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),os(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),n?.mutationKey&&this.options.mutationKey&&zo(n.mutationKey)!==zo(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??Ni();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){ds.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)})})}},ra=l.createContext(void 0),aa=e=>{const t=l.useContext(ra);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},mc=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),s.jsx(ra.Provider,{value:e,children:t})),ia=l.createContext(!1),fc=()=>l.useContext(ia);ia.Provider;function pc(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var xc=l.createContext(pc()),gc=()=>l.useContext(xc),vc=(e,t,n)=>{const o=n?.state.error&&typeof e.throwOnError=="function"?ro(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=!1))},bc=e=>{l.useEffect(()=>{e.clearReset()},[e])},yc=({result:e,errorResetBoundary:t,throwOnError:n,query:o,suspense:r})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(r&&e.data===void 0||ro(n,[e.error,o])),wc=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))}},Cc=(e,t)=>e.isLoading&&e.isFetching&&!t,jc=(e,t)=>e?.suspense&&t.isPending,er=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function la(e,t,n){const o=fc(),r=gc(),a=aa(),i=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(i);const c=a.getQueryCache().get(i.queryHash);i._optimisticResults=o?"isRestoring":"optimistic",wc(i),vc(i,r,c),bc(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(ds.batchCalls(g)):rs;return h.updateResult(),f},[h,d]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),l.useEffect(()=>{h.setOptions(i)},[i,h]),jc(i,m))throw er(i,h,r);if(yc({result:m,errorResetBoundary:r,throwOnError:i.throwOnError,query:c,suspense:i.suspense}))throw m.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(i,m),i.experimental_prefetchInRender&&!Qs&&Cc(m,o)&&(u?er(i,h,r):c?.promise)?.catch(rs).finally(()=>{h.updateResult()}),i.notifyOnChangeProps?m:h.trackResult(m)}function ye(e,t){return la(e,oa)}function ne(e,t){const n=aa(),[o]=l.useState(()=>new hc(n,e));l.useEffect(()=>{o.setOptions(e)},[o,e]);const r=l.useSyncExternalStore(l.useCallback(i=>o.subscribe(ds.batchCalls(i)),[o]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),a=l.useCallback((i,c)=>{o.mutate(i,c).catch(rs)},[o]);if(r.error&&ro(o.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:a,mutateAsync:r.mutate}}function ca(e,t){return la(e,dc)}const ut="data-sources",ua="auth-user",Nc=e=>ye({queryKey:["project","datasources",e],queryFn:async()=>{const{data:t}=await B.get(`/project/team/${e}/datasources`);return t.data},enabled:!!e}),tn=e=>{const t=["project","datasources"],n=["project","saved-queries"];return Promise.all([J.invalidateQueries({queryKey:t}),J.invalidateQueries({queryKey:n})])},_c=e=>{const t=["trash","team"];return J.invalidateQueries({queryKey:t})},Sc=(e,t)=>ye({queryKey:["project","tables",t.teamId,e,t.selectedDataSources],queryFn:async()=>{const{data:n}=await B.get(`/project/team/${t.teamId}/query`,{params:{size:30,search:e,selectedDataSources:t.selectedDataSources}});return n.data},enabled:!!t.teamId,placeholderData:Or}),ps=()=>J.invalidateQueries({queryKey:["project","tables"]}),kc=(e,t="",n=30,o)=>ca({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}),Ec=(e,t="",n=20)=>ca({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}}),Rc=(e,t=10,n=!1)=>ye({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}),Lc=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}}),Tc=()=>Promise.all([J.invalidateQueries({queryKey:["project","tabs-history"]}),J.invalidateQueries({queryKey:["project","recent-tabs"]})]),Ac=4e3,xs=e=>ye({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"?Ac:!1}),fo=e=>ye({queryKey:[ut,e.teamId],queryFn:async()=>{const{data:t}=await B.get("/data-sources",{params:e});return t.data},enabled:e.teamId!==void 0}),gs=e=>ye({queryKey:[ut,e,"inspections"],queryFn:async()=>{const{data:t}=await B.get(`/data-sources/${e}/inspections`);return t.data},enabled:!!e}),Ic=e=>J.invalidateQueries({queryKey:[ut,e,"inspections"]}),Mc=()=>ne({mutationFn:async e=>{const{data:t}=await B.post("/data-sources",e);return t.data},onSuccess:()=>{J.invalidateQueries({queryKey:[ut]}),tn(),ps()}}),Pc=()=>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]}),tn(),ps()}}),da=()=>ne({mutationFn:async e=>{await B.post(`/data-sources/${e}/inspect`)},onSuccess:(e,t)=>{J.invalidateQueries({queryKey:[ut,t]}),ps()}}),Oc=()=>ne({mutationFn:async e=>{await B.delete(`/data-sources/${e}`)},onSuccess:()=>{J.invalidateQueries({queryKey:[ut]}),tn(),ps()}}),ha=()=>ye({queryKey:["accessToken"],queryFn:hs.get}),we=()=>{const{data:e}=ha();return ye({queryKey:[ua],queryFn:async()=>{const{data:t}=await B.get("/users");return t.data},enabled:!!e,retry:(t,n)=>_i(n)&&n.code==="ERR_NETWORK"?!1:t<3})},Dc=()=>ne({mutationFn:async e=>{const{data:t}=await B.patch("/users",e);return t.data},onSuccess:async e=>{J.setQueryData([ua],e)}}),$c=()=>ne({mutationFn:async e=>(await B.post("/users",e),!0),onSuccess:()=>{J.invalidateQueries({queryKey:["team-users"]})}}),Ce=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 Fc(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 Bc(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 Wc(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 vs(e,t){return{name:e,path:t,build:()=>t,check:n=>n===t}}const qc=vs("Home","/"),Uc=vs("Workbench","/workbench"),Hc=vs("Share query","/share"),zc=vs("Login","/login"),Vc=Wc("Workbench tab","/workbench/tab/:id"),D={home:qc,workbench:Uc,share:Hc,login:zc,workbenchTab:Vc},bs=e=>{J.setQueryData(["workbench-tabs"],t=>e(t||[]))},Kc=(e,t)=>{J.setQueryData(["workbench-tabs",e],n=>n&&t(n))},ys=()=>ye({queryKey:["workbench-tabs"],queryFn:async()=>{const{data:e}=await B.get("/workbench-tabs");return e.data}}),Qc=e=>ye({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=>{bs(t=>[...t,{id:e.id,name:e.name,orderIndex:e.orderIndex}])}}),Gc=()=>ne({mutationFn:async({tabId:e,...t})=>(await B.patch(`/workbench-tabs/${e}/archive`,t)).data.data,onSuccess:async e=>{bs(()=>e)}}),ma=()=>ne({mutationFn:async e=>(await B.patch(`/workbench-tabs/${e}/restore`),e),onSuccess:()=>xa()}),fa=()=>ne({mutationFn:async({id:e,payload:t})=>(await B.patch(`/workbench-tabs/${e}`,t),!0),onMutate:({id:e,payload:t})=>{Kc(e,n=>({...n,...t})),bs(n=>n.map(o=>o.id!==e?o:{...o,name:t.name||o.name}))}}),Yc=(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 ye({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:Or})},Jc=()=>ne({mutationFn:async e=>{await B.delete(`/workbench-tabs/${e}`)},onSuccess:()=>{xa(),Tc()}}),pa=e=>J.invalidateQueries({queryKey:["workbench-tab-runner",e]}),xa=()=>J.invalidateQueries({queryKey:["workbench-tabs"]}),[Xc,$s,Zc]=Ce(void 0),eu=async()=>new Promise(e=>{$s({onCancel:()=>{$s(void 0),e(void 0)},onConfirm:(t,n,o)=>{$s(void 0),e({dsId:o,id:n,type:t})}})}),Tn=()=>{const e=ee(),t=Lt(),n=ma();return l.useCallback(()=>{Zc.get()||eu().then(r=>{r?.type==="table"?t.mutateAsync({name:r.id,opts:kt({table:r.id,dataSourceId:r.dsId})}).then(a=>{e(D.workbenchTab.build({id:a.id}))}):r?.type==="query"?t.mutateAsync({queryId:r.id}).then(a=>{e(D.workbenchTab.build({id:a.id}))}):r?.type==="tab"&&(n.mutate(r.id),e(D.workbenchTab.build({id:r.id})))})},[])},ga=[{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"}],tu=ga.reduce((e,t)=>(e[t.value]=t.label,e),{});ga.reduce((e,t)=>(e[t.label]=t.value,e),{});const nn=e=>e.map(t=>({label:tu[t],value:t}));nn(["=","<>",">",">=","<","<=","IN","NOT IN","IS NULL","IS NOT NULL"]);nn(["=","<>","LIKE","NOT LIKE","IN","NOT IN","IS NULL","IS NOT NULL","CONTAINS","NOT CONTAINS"]);nn(["=","<>","IS NULL","IS NOT NULL"]);nn(["=","<>",">",">=","<","<=","IS NULL","IS NOT NULL"]);nn(["IS NULL","IS NOT NULL"]);nn(["IN","NOT IN"]);const nu=["char","varchar","binary","varbinary","blob","text","enum","set","character","character varying","text","citext","uuid","xml","json","jsonb"];new Set(nu);const su=["integer","smallint","decimal","numeric","float","real","double precision","int","smallint","integer","bigint","decimal","numeric","real","double precision","serial","bigserial","money"];new Set(su);const ou=["date","datetime","timestamp","timestamptz"].reduce((e,t)=>(e[t]=!0,e),{}),ru=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 tr={[me.READ_ONLY]:10,[me.EDITOR]:20,[me.ADMIN]:30,[me.OWNER]:40},au=e=>`${e.fromTable}.${e.fromColumn} = ${e.toTable}.${e.toColumn}`,An=e=>{const{data:t}=we();return l.useMemo(()=>t?tr[t.teamRole]>=tr[e]:!1,[t,e])},iu="_input_10dly_2",lu="_label_10dly_2",cu="_content_10dly_2",uu="_form_10dly_2",du="_header_10dly_2",hu="_mode-select_10dly_2",mu="_selected_10dly_2",fu="_mode-container_10dly_2",Fe={input:iu,label:lu,content:cu,form:uu,header:du,modeSelect:hu,selected:mu,modeContainer:fu},pu="_modal_1yx4c_2",xu="_modal-visible_1yx4c_2",gu="_modal-invisible_1yx4c_2",vu="_backdrop_1yx4c_2",bu="_modal-container_1yx4c_2",yu="_close-button_1yx4c_2",Kt={modal:pu,modalVisible:xu,modalInvisible:gu,backdrop:vu,modalContainer:bu,closeButton:yu},Ze=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 ts=[];const wu=e=>{const t=Symbol();return ts.push({id:t,listener:e}),()=>{ts=ts.filter(n=>n.id!==t)}};window.addEventListener("keydown",e=>{if(e.key!=="Escape")return;const t=ts.pop();t&&(e.preventDefault(),e.stopPropagation(),t.listener())});const ws=e=>{const t=l.useRef(e.onClose);t.current=e.onClose,l.useEffect(()=>{if(e.enabled)return wu(()=>{t.current()})},[e.enabled])},Me=({children:e,backdropClose:t,isVisible:n,onClose:o,onClosed:r,noPadding:a=!1,portal:i=!0})=>{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]),ws({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?ho.createPortal(d,document.body):d},sn=({onClick:e})=>{const t=l.useRef(e);return t.current=e,s.jsx("button",{className:Kt.closeButton,onClick:e,children:s.jsx(Ze,{width:20,height:20})})},va=({children:e})=>s.jsx("h2",{className:"text-xl font-semibold",children:e}),Cu=({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))}),ju=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"})),Nu=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(ju,{width:e,height:e}):s.jsx(Nu,{width:e,height:e}),_u={mysql:"MySQL",postgres:"PostgreSQL"},Su={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"}]},ku={fields:[{label:"Database URL",name:"dbUrl",type:"text"},{label:"Database port",name:"dbPort",type:"number"},{label:"Username",name:"dbUser",type:"text"},{label:"Password",name:"dbPassword",type:"password"},{label:"Database",name:"dbDatabase",type:"text"},{label:"Schema",name:"dbSchema",type:"text"}]},Eu=({show:e,onClose:t,dbType:n="postgres"})=>{const o=Mc(),r=da(),{data:a}=we(),[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:_u[n]})]}),o.isError&&s.jsx(ge,{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(ge,{className:"mb-2",variant:"info",children:"Creating connection"}),r.isPending&&s.jsx(ge,{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(Cu,{form:i,change:c,shape:i.dbType==="mysql"?Su:ku})]}),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"})]})]})},Ru="_data-source-entry_euw6m_2",Lu="_action-title_euw6m_2",Tu="_recent-tabs-container_euw6m_2",Au="_recent-tabs-entry_euw6m_2",Iu="_home-action-button_euw6m_2",Mu="_home-gray-card_euw6m_2",Pu="_home-card-title_euw6m_2",Ou="_home-card-grid-content_euw6m_2",Du="_useful-links_euw6m_2",Q={dataSourceEntry:Ru,actionTitle:Lu,recentTabsContainer:Tu,recentTabsEntry:Au,homeActionButton:Iu,homeGrayCard:Mu,homeCardTitle:Pu,homeCardGridContent:Ou,usefulLinks:Du},[$u,In]=Ce({show:!1}),[Fu,Yt]=Ce({show:!1}),[Bu,jn]=Ce(void 0),Wu=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"})),qu=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"})),Uu=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})),Hu=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"})),Cs=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})),ba=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"})),ya=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})),nr=20,js="text-(--text-color-primary)",zu=A(Q.homeActionButton,"md:col-span-3"),Vu=()=>{const e=Tn();return s.jsxs("div",{className:zu,onClick:e,children:[s.jsx(Mn,{width:nr,height:nr,className:js}),s.jsx("h2",{className:Q.actionTitle,children:"Start new query"})]})},Ku=()=>s.jsxs("div",{className:Q.homeActionButton,onClick:()=>In({show:!0}),children:[s.jsx(Cs,{width:20,height:20,className:js}),s.jsx("h2",{className:Q.actionTitle,children:"Saved queries"})]}),Qu=()=>s.jsxs("div",{className:Q.homeActionButton,onClick:()=>Yt({show:!0}),children:[s.jsx(ba,{width:20,height:20,className:js}),s.jsx("h2",{className:Q.actionTitle,children:"Recent tabs"})]}),Gu={mysql:"MySQL",postgres:"PostgreSQL"},sr=({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(Eu,{show:!0,dbType:t,onClose:()=>n(void 0)}),s.jsxs("div",{className:Q.homeActionButton,onClick:()=>r(e),children:[s.jsx(ze,{size:24,type:e}),s.jsx("p",{className:Q.actionTitle,children:Gu[e]})]})]})},Yu=()=>s.jsxs("div",{className:Q.homeGrayCard,children:[s.jsx("h2",{className:Q.homeCardTitle,children:"Connect new data source"}),s.jsxs("div",{className:Q.homeCardGridContent,children:[s.jsx(sr,{dbType:"mysql"}),s.jsx(sr,{dbType:"postgres"})]})]}),Ju=()=>{const e=ee(),{data:t}=ys(),n=Tn(),o=()=>{t&&t.length>0?e(D.workbenchTab.build({id:t[0].id})):n()};return s.jsxs("div",{className:Q.homeActionButton,onClick:o,children:[s.jsx(ya,{width:20,height:20,className:js}),s.jsx("h2",{className:Q.actionTitle,children:"Workbench"})]})},Xu=()=>{const{data:e}=we(),{data:t}=fo({teamId:e?.teamId});return!t||t.length===0?null:s.jsxs("div",{className:Q.homeGrayCard,children:[s.jsx("h2",{className:Q.homeCardTitle,children:"Data sources"}),s.jsx("div",{className:Q.homeCardGridContent,children:t?.map(n=>s.jsxs("div",{className:Q.dataSourceEntry,onClick:()=>jn(n.id),tabIndex:0,children:[!n.allowInsert&&s.jsx(Hu,{"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,wa=()=>s.jsxs("div",{className:Q.usefulLinks,children:[s.jsxs("a",{href:"https://dataramen.xyz/",target:"_blank",children:[s.jsx(Uu,{width:Ht,height:Ht}),s.jsx("span",{children:"Docs"})]}),s.jsxs("a",{href:"https://github.com/OleksandrDemian/dataramen",target:"_blank",children:[s.jsx(Wu,{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(qu,{width:Ht,height:Ht}),s.jsx("span",{children:"NPM"})]})]}),Zu=()=>{const{data:e}=we(),{data:t,isLoading:n}=Rc(e?.teamId),o=ee();if(n||!t?.length)return null;const r=a=>{o(D.workbenchTab.build({id:a}))};return s.jsxs("div",{className:Q.recentTabsContainer,children:[s.jsx("h2",{className:Q.homeCardTitle+" px-4 mb-4",children:"Active tabs"}),t.map(a=>s.jsxs("div",{className:Q.recentTabsEntry,onClick:()=>r(a.id),children:[s.jsx("p",{className:"text-(--text-color-primary) truncate",children:a.name}),s.jsxs("p",{className:"flex items-center gap-2",children:[s.jsx(ze,{size:20,type:a.dataSourceType}),s.jsx("span",{className:"text-sm text-(--text-color-secondary) truncate",children:a.dataSourceName})]})]},a.id))]})},be=(e,t)=>e!=null&&e>t,po=(e,t)=>e!=null&&e<t,ed=()=>{const{data:e}=we(),{data:t,isLoading:n}=fo({teamId:e?.teamId}),o=!n&&po(t?.length,1),r=!!e;return s.jsx("div",{className:"page-container h-screen max-h-screen overflow-y-auto no-scrollbar",children:s.jsxs("div",{className:"page-content",children:[s.jsxs("div",{className:"py-10 text-center w-full sticky top-0 z-0",children:[s.jsx("h1",{className:"comfortaa text-3xl font-semibold text-(--text-color-primary) mb-4",children:"DataRamen"}),s.jsx(wa,{})]}),s.jsxs("div",{className:"flex flex-col gap-8 mt-8 bg-(--bg) z-1",children:[o&&s.jsx(ge,{variant:"warning",className:"font-semibold",children:"Connect at least one data source to start using DataRamen"}),s.jsxs("div",{className:Q.homeGrayCard,children:[s.jsx("h2",{className:Q.homeCardTitle,children:"Quick actions"}),s.jsxs("div",{className:Q.homeCardGridContent,children:[s.jsx(Vu,{}),s.jsx(Ku,{}),s.jsx(Qu,{}),r&&s.jsx(Ju,{})]})]}),r&&s.jsx(Xu,{}),s.jsx(Yu,{}),s.jsx(Zu,{})]})]})})},[td,Fs]=Ce(void 0),xo=async e=>new Promise(t=>{Fs({message:e,onCancel:()=>{t(!1),Fs(void 0)},onConfirm:()=>{t(!0),Fs(void 0)}})}),nd=({confirm:e})=>s.jsxs("div",{className:"max-w-sm",children:[s.jsx("p",{children:e.message}),s.jsxs("div",{className:"flex gap-2 justify-end mt-4",children:[s.jsx("button",{className:"button tertiary",onClick:e.onCancel,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:e.onConfirm,children:"Confirm"})]})]}),sd=()=>{const e=td(),[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(nd,{confirm:t})})},[od,jt]=Ce(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"})}),rd=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"})}),ad="_root_ng9lp_1",Ca={root:ad},id="_root_992zz_2",ld="_input_992zz_2",or={root:id,input:ld},cd=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})),ud=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"})),ja=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"})),rr=(e,t)=>{const n=t.indexOf(e);return n>=t.length?t[0]:t[n+1]},dd=(e,t)=>{const n=t.indexOf(e);return n<=0?t[t.length-1]:t[n-1]},hd=({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(cd,{className:"pointer-events-none",width:20,height:20}),e==="raw"&&s.jsx(ud,{className:"pointer-events-none",width:20,height:20}),e==="default"&&s.jsx(ja,{className:"pointer-events-none",width:20,height:20})]}),Ns=({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"?rr(t,n):dd(t,n),value:i.value})):i.onKeyDown?.(h)};return s.jsxs("label",{className:A(or.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(or.input,r)}),s.jsx(hd,{mode:t,onNextMode:()=>a({mode:rr(t,n),value:i.value})})]})},_s=["default","raw"],md=({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:Ca.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"})]})]})},fd=({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:Ca.root,children:[s.jsx("h2",{className:"text-xl font-semibold",children:e.message}),s.jsx(Ns,{prefix:"_",autoFocus:!0,className:"w-full my-2 h-8",value:t.value,mode:t.mode,onExpressionChange:n,allowedModes:_s,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"})]})]})},pd=()=>{const e=od(),[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(md,{data:t}),t?.type==="query-expression"&&s.jsx(fd,{data:t})]})},[xd,gd]=Ce(void 0),Na=e=>{gd(e)},vd="_textarea_1yvfn_2",bd={textarea:vd},yd=()=>{const e=xd(),t=()=>{e&&(navigator.clipboard.writeText(e.toString()),fe.success("Copied!"))},n=()=>Na(void 0);return s.jsxs(Me,{isVisible:!!e,onClose:n,backdropClose:!0,children:[s.jsx("textarea",{className:bd.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"})]})]})},wd="_tabs_17t7r_2",Cd="_mobile_17t7r_2",jd="_menu_17t7r_2",Nd="_item_17t7r_2",_d="_tab_17t7r_2",Sd="_active_17t7r_2",kd="_close-button_17t7r_2",$e={tabs:wd,mobile:Cd,menu:jd,item:Nd,tab:_d,active:Sd,closeButton:kd},ar=e=>window.matchMedia(e).matches;function _a(e,{defaultValue:t=!1,initializeWithValue:n=!0}={}){const[o,r]=l.useState(()=>n?ar(e):t);return l.useLayoutEffect(()=>{const a=window.matchMedia(e);function i(){r(()=>ar(e))}return i(),a.addListener?a.addListener(i):a.addEventListener("change",i),()=>{a.removeListener?a.removeListener(i):a.removeEventListener("change",i)}},[e]),o}const go={laptop:"(min-width: 1024px)"},Sa=()=>window.matchMedia(go.laptop).matches,vo=e=>l.useMemo(()=>{if(e)return e instanceof Si?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 ns=e=>e.distinct?[e.fn,"DISTINCT",e.value].join(" "):[e.fn,e.value].join(" "),Yn=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},Ed="_table_10ka2_2",Rd="_row-index-btn_10ka2_2",Ld="_semi-transparent_10ka2_2",Td="_table-loading_10ka2_2",Ad="_table-empty_10ka2_2",Id="_table-row-cells_10ka2_2",Md="_header-cell_10ka2_2",Pd="_header-actions_10ka2_2",Od="_cell_10ka2_2",Dd="_value_10ka2_2",$d="_table-config_10ka2_2",Fd="_table-action_10ka2_2",Bd="_data-source_10ka2_2",Wd="_gray_10ka2_2",qd="_modal_10ka2_2",Ud="_selected-size_10ka2_2",Hd="_pagination-indicator_10ka2_2",L={table:Ed,rowIndexBtn:Rd,semiTransparent:Ld,tableLoading:Td,tableEmpty:Ad,tableRowCells:Id,headerCell:Md,headerActions:Pd,cell:Od,value:Dd,tableConfig:$d,tableAction:Fd,dataSource:Bd,gray:Wd,modal:qd,selectedSize:Ud,paginationIndicator:Hd},Pe=l.createContext({name:"No name",hooks:[],availableJoins:[],allColumns:[],dataSourceId:"",entities:[],getValue:()=>{},getValueByIndex:()=>{},getColumnByIndex:()=>{},getColumnType:()=>{}}),je=l.createContext({state:kt({}),setState:()=>{}}),tt=l.createContext({}),ka={ON_ANIMATION_END:Symbol("ON_TRANSITION_END")},Ea=()=>{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,[ka.ON_ANIMATION_END]:i}},[e,n])},zd=e=>{if(e!=="ASC")return e==="DESC"?"ASC":"DESC"},Vd=()=>{const{state:e,setState:t}=l.useContext(je),n=l.useCallback(o=>{t(r=>{const a=r.orderBy[0];if(a&&a.column===o){const i=zd(a.direction);return i?{...r,orderBy:[{column:o,direction:i}]}:{...r,orderBy:[]}}return{...r,orderBy:[{column:o,direction:"DESC"}]}})},[t]);return{orderBy:e.orderBy,updateOrderBy:n}},Kd="_options-container_1wv9o_2",Qd="_filter-input_1wv9o_2",Gd="_list_1wv9o_2",Yd="_empty-text_1wv9o_2",_t={optionsContainer:Kd,filterInput:Qd,list:Gd,emptyText:Yd},Jd="_container_tazcc_2",Xd="_animate-show_tazcc_2",Zd="_animate-hide_tazcc_2",eh="_content_tazcc_2",th="_backdrop_tazcc_2",gt={container:Jd,animateShow:Xd,animateHide:Zd,content:eh,backdrop:th},Ra=({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,Sa()?c?a.right=window.innerWidth-t.position.x:a.left=t.position.x:(a.right=36,a.left=36)}return a},[t.position]);if(ws({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[ka.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 ho.createPortal(r,document.body)},et=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),nh="_container_z9urg_2",sh={container:nh},on=({containerClassName:e,className:t,...n})=>s.jsxs("label",{className:A(sh.container,e),children:[s.jsx(Mn,{width:16,height:16}),s.jsx("input",{className:A("flex-1 outline-none",t),...n})]}),oh="_root_1v204_2",rh="_content_1v204_2",ah="_table-name_1v204_2",ih="_sub_1v204_2",ot={root:oh,content:rh,tableName:ah,sub:ih},bo=({hook:e,onClick:t})=>e.direction==="out"?s.jsx("button",{className:ot.root,onClick:t,children:s.jsxs("div",{className:ot.content,children:[s.jsx("p",{className:ot.tableName,children:e.toTable}),s.jsxs("p",{className:ot.sub,children:[e.toColumn," = ",e.fromTable,".",e.fromColumn]})]})},e.id):s.jsx("button",{className:ot.root,onClick:t,children:s.jsxs("div",{className:ot.content,children:[s.jsx("p",{className:ot.tableName,children:e.fromTable}),s.jsxs("p",{className:ot.sub,children:[e.fromColumn," = ",e.toTable,".",e.toColumn]})]})},e.id);function lh(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:et(),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:et(),column:`${e.fromTable}.${e.fromColumn}`,value:r==null?"IS NULL":`${r}`,isEnabled:!0}]})}}const La=({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 b=u(t);return b?c.filter(w=>w.toColumn===b.column&&w.toTable===b.table):[]},[t,c,u]),d=Lt(),g=ee(),f=l.useMemo(()=>{const b=r.toLowerCase();return m.filter(w=>w.fromTable.toLowerCase().includes(b))},[r,m]),x=b=>{d.mutateAsync(lh(b,i,e,h)).then(w=>{g(D.workbenchTab.build({id:w.id})),n?.()})},v=be(f.length,0);return s.jsxs("div",{className:o,children:[s.jsx(on,{autoFocus:!0,className:_t.filterInput,placeholder:"Filter",value:r,onChange:b=>a(b.target.value)}),s.jsxs("div",{className:_t.list,children:[v&&f.map(b=>s.jsx(bo,{hook:b,onClick:()=>x(b)},b.id)),!v&&s.jsx("p",{className:_t.emptyText,children:"Empty"})]})]})},ch=({handler:e,rowIndex:t,colIndex:n})=>s.jsx(Ra,{handler:e,children:s.jsx("div",{className:_t.optionsContainer,children:s.jsx(La,{rowIndex:t,colIndex:n,className:"p-2",onClose:()=>{e.close()}})})}),yo=()=>{const{state:e,setState:t}=l.useContext(je),n=l.useCallback((r,a=!1)=>{t(i=>({...i,page:a?0:i.page,filters:r}))},[t]),o=l.useCallback(r=>{t(a=>({...a,filters:a.filters.filter(i=>i.id!==r)}))},[t]);return{filters:e.filters,removeFilter:o,setFilters:n}},uh=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"})),dh=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"})),hh="_container_1l1kx_2",mh="_animate-show_1l1kx_2",fh="_animate-hide_1l1kx_2",ph="_backdrop_1l1kx_2",xh="_content_1l1kx_2",vt={container:hh,animateShow:mh,animateHide:fh,backdrop:ph,content:xh},wo=({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,x=m.clientX>window.innerWidth/2;f?g.bottom=window.innerHeight-m.clientY:g.top=m.clientY,Sa()?x?g.right=window.innerWidth-m.clientX:g.left=m.clientX:(g.right=36,g.left=36),r(g),i("in")},close:()=>{i("out")}}),[]),ws({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(vt.container,a==="out"&&vt.animateHide,a==="in"&&vt.animateShow),onAnimationEnd:u,children:[s.jsx("div",{className:vt.backdrop,onClick:()=>i("out")}),s.jsx("div",{ref:c,style:o,className:A(vt.content,a==="out"&&vt.animateHide,a==="in"&&vt.animateShow),children:e})]});return ho.createPortal(h,document.body)};function Bs(e,t,n){const o=e?.rows?.[t]?.[n],r=e?.columns?.[n];return{value:o,column:r}}const gh=({ref:e})=>{const{data:t}=l.useContext(tt),{getColumnType:n}=l.useContext(Pe),{setState:o}=l.useContext(je);return{copyValue:(c,u)=>{const{value:h,column:m}=Bs(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}=Bs(t?.result,c,u);if(m){const d=Nt(h,n(m.full));Na(d),e.current?.close()}},filterValue:(c,u)=>{const{value:h,column:m}=Bs(t?.result,c,u),d=m?.full||"";if(d){let g;if(h==null)g={id:et(),isEnabled:!0,mode:"raw",column:d,value:"IS NULL"};else{const f=Nt(h,n(d));g={id:et(),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()}}}},Ta=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})),vh=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})),bh="_section-name_okgyy_2",yh="_item_okgyy_2",bt={sectionName:bh,item:yh},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"})),[Aa,Co]=Ce(void 0),wh=e=>{jo(void 0),Co(e)},Ia=()=>Co(void 0);function Ch(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 Ma=({storage:e=localStorage,localStorageKey:t,initialData:n})=>{const o=Ce(Ch(t,n,e));return o[2].subscribe(r=>{e.setItem(t,JSON.stringify(r))}),o},[Pa,jo]=Ce(void 0),[jh,Nh]=Ma({initialData:{history:[]},localStorageKey:"useEntityEditorHistory_v1"}),No=(e,t=!0)=>{const n={...e,key:`${e.dataSourceId}-${e.tableName}-${e.entityId.map(o=>o[0]+o[1]).join("")}`};Co(void 0),t&&Nh(o=>o.history.some(r=>r.key===n.key)?o:o.history.length<20?{history:[...o.history,n]}:{history:[...o.history.slice(1),n]}),jo(n)},Oa=()=>jo(void 0),_h=({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?No({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(on,{autoFocus:!0,className:_t.filterInput,placeholder:"Filter",value:o,onChange:m=>r(m.target.value)}),s.jsx("div",{className:_t.list,children:be(u.length,0)?u.map(m=>s.jsx(bo,{hook:m,onClick:()=>h(m)},m.id)):s.jsx("p",{className:_t.emptyText,children:"Empty"})})]})},Sh=({ref:e,row:t,col:n,onClosed:o})=>{const r=gh({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")},x=be(c?.length,0),v=be(u?.length,0);return s.jsx(wo,{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:bt.sectionName,children:"Cell actions"}),s.jsxs("button",{className:bt.item,onClick:h,children:[s.jsx(Ta,{width:14,height:14}),"Copy"]}),s.jsxs("button",{className:bt.item,onClick:m,children:[s.jsx(vh,{width:14,height:14}),"View"]}),s.jsxs("button",{className:bt.item,onClick:d,children:[s.jsx(Mn,{width:14,height:14}),"Filter"]}),(v||x)&&s.jsx("p",{className:bt.sectionName,children:"Row actions"}),v&&s.jsxs("button",{className:bt.item,onClick:g,children:[s.jsx(Ct,{className:"text-(--text-color-tertiary)",width:14,height:14}),"Show record"]}),x&&s.jsxs("button",{className:bt.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(La,{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(_h,{rowIndex:t,onClose:()=>e.current?.close()})]})]})})},kh={DESC:"",ASC:"rotate-180"},Eh=(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:et(),column:t,isEnabled:!0,value:n,fn:o,mode:r}),a},Rh=()=>{const{data:e}=l.useContext(tt),{orderBy:t,updateOrderBy:n}=Vd(),{setFilters:o,filters:r}=yo(),a=e?.result.columns||[],i=t[0],c=be(e?.result.tables.length,1),u=(h,m)=>{rd("Filter value","").then(d=>{d&&o(Eh(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(uh,{className:kh[i.direction],width:16,height:16}):s.jsx(dh,{width:16,height:16})}),s.jsx("button",{onClick:()=>u(h.full,h.fn),children:s.jsx(Mn,{width:16,height:16})})]})]},h.full))]})})};function Lh({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 Th=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(Lh,{value:a,actions:r.get(i)})},i))]})),Ah=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--}},ir=e=>{const t=Ah(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}},Ih=()=>{const{data:e,error:t,isLoading:n,isFetching:o}=l.useContext(tt),{dataSourceId:r,getColumnByIndex:a,getValueByIndex:i}=l.useContext(Pe),{state:{page:c,size:u}}=l.useContext(je),h=l.useRef(null),m=vo(t),d=Ea(),[g,f]=l.useState(),x=p=>{const y=p.target,C=y.dataset?.cellAction,N=ir(y);if(C==="ref"&&be(N?.col,-1)){const I=i(N.row,N.col),_=a(N.col);_&&No({tableName:_.ref.table,dataSourceId:r,entityId:[[_.ref.field,I]]})}else(C==="drill"||C==="drill-all")&&(f(N),d.open(p))},v=p=>{const y=ir(p.target);y&&(f(y),h.current?.open(p),p.preventDefault(),p.stopPropagation())},b=c*u,w=l.useMemo(()=>{const p=new Map;return e&&e.result.columns.forEach((y,C)=>{p.set(C,{hasRecord:!!y.ref,hasDrill:!!y.referencedBy})}),p},[e]);return s.jsxs(s.Fragment,{children:[g&&d.show&&s.jsx(ch,{handler:d,rowIndex:g.row,colIndex:g.col}),s.jsx(Sh,{ref:h,col:g?.col,row:g?.row,onClosed:()=>{f(void 0)}}),m&&s.jsx(ge,{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:x,onContextMenu:v,children:[s.jsx(Rh,{}),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((p,y)=>s.jsx(Th,{index:y,offset:b,row:p,colMeta:w,isLastRow:y===e.result.rows.length-1},y))]})]})]})},Da=()=>{const{state:e,setState:t}=l.useContext(je),n=l.useCallback(r=>{t(a=>({...a,page:r}))},[t]),o=l.useCallback((r,a=!1)=>{t(i=>({...i,size:r,page:a?0:i.page}))},[t]);return{page:e.page,size:e.size,setSize:o,setPage:n}},Mh=()=>ne({mutationFn:async e=>{const{data:t}=await B.post("/saved-queries",e);return t.data},onSuccess:()=>{J.invalidateQueries({queryKey:["queries"]}),tn()}}),Ph=()=>ne({mutationFn:async e=>B.delete("/saved-queries/"+e),onSuccess:()=>{tn()}}),Oh=()=>ne({mutationFn:async({id:e,payload:t})=>{const{data:n}=await B.patch("/saved-queries/"+e,t);return n.data},onSuccess:()=>{tn(),_c()}}),[Ss,_o]=Ce({filters:!1,joins:!1,columns:!1,groupBy:!1,aggregate:!1}),Be=e=>_o(t=>({...t,[e]:!0})),ks=e=>_o(t=>({...t,[e]:!1})),as=e=>_o(t=>({...t,[e]:!t[e]})),Jt=Math.min,St=Math.max,is=Math.round,Jn=Math.floor,We=e=>({x:e,y:e}),Dh={left:"right",right:"left",bottom:"top",top:"bottom"},$h={start:"end",end:"start"};function Zs(e,t,n){return St(e,Jt(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 $a(e){return e==="x"?"y":"x"}function So(e){return e==="y"?"height":"width"}const Fh=new Set(["top","bottom"]);function it(e){return Fh.has(Et(e))?"y":"x"}function ko(e){return $a(it(e))}function Bh(e,t,n){n===void 0&&(n=!1);const o=Dn(e),r=ko(e),a=So(r);let i=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=ls(i)),[i,ls(i)]}function Wh(e){const t=ls(e);return[eo(e),t,eo(t)]}function eo(e){return e.replace(/start|end/g,t=>$h[t])}const lr=["left","right"],cr=["right","left"],qh=["top","bottom"],Uh=["bottom","top"];function Hh(e,t,n){switch(e){case"top":case"bottom":return n?t?cr:lr:t?lr:cr;case"left":case"right":return t?qh:Uh;default:return[]}}function zh(e,t,n,o){const r=Dn(e);let a=Hh(Et(e),n==="start",o);return r&&(a=a.map(i=>i+"-"+r),t&&(a=a.concat(a.map(eo)))),a}function ls(e){return e.replace(/left|right|bottom|top/g,t=>Dh[t])}function Vh(e){return{top:0,right:0,bottom:0,left:0,...e}}function Fa(e){return typeof e!="number"?Vh(e):{top:e,right:e,bottom:e,left:e}}function cs(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 ur(e,t,n){let{reference:o,floating:r}=e;const a=it(t),i=ko(t),c=So(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 Kh=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}=ur(h,o,u),g=o,f={},x=0;for(let v=0;v<c.length;v++){const{name:b,fn:w}=c[v],{x:p,y,data:C,reset:N}=await w({x:m,y:d,initialPlacement:o,placement:g,strategy:r,middlewareData:f,rects:h,platform:i,elements:{reference:e,floating:t}});m=p??m,d=y??d,f={...f,[b]:{...f[b],...C}},N&&x<=50&&(x++,typeof N=="object"&&(N.placement&&(g=N.placement),N.rects&&(h=N.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):N.rects),{x:m,y:d}=ur(h,g,u)),v=-1)}return{x:m,y:d,placement:g,strategy:r,middlewareData:f}};async function Ba(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),x=Fa(f),b=c[g?d==="floating"?"reference":"floating":d],w=cs(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(b)))==null||n?b:b.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:h,rootBoundary:m,strategy:u})),p=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},N=cs(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:p,offsetParent:y,strategy:u}):p);return{top:(w.top-N.top+x.top)/C.y,bottom:(N.bottom-w.bottom+x.bottom)/C.y,left:(w.left-N.left+x.left)/C.x,right:(N.right-w.right+x.right)/C.x}}const Qh=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=Fa(m),g={x:n,y:o},f=ko(r),x=So(f),v=await i.getDimensions(h),b=f==="y",w=b?"top":"left",p=b?"bottom":"right",y=b?"clientHeight":"clientWidth",C=a.reference[x]+a.reference[f]-g[f]-a.floating[x],N=g[f]-a.reference[f],I=await(i.getOffsetParent==null?void 0:i.getOffsetParent(h));let _=I?I[y]:0;(!_||!await(i.isElement==null?void 0:i.isElement(I)))&&(_=c.floating[y]||a.floating[x]);const M=C/2-N/2,k=_/2-v[x]/2-1,O=Jt(d[w],k),te=Jt(d[p],k),ae=O,Ne=_-v[x]-te,W=_/2-v[x]/2+M,S=Zs(ae,W,Ne),P=!u.arrow&&Dn(r)!=null&&W!==S&&a.reference[x]/2-(W<ae?O:te)-v[x]/2<0,H=P?W<ae?W-ae:W-Ne:0;return{[f]:g[f]+H,data:{[f]:S,centerOffset:W-S-H,...P&&{alignmentOffset:H}},reset:P}}}),Gh=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:x="none",flipAlignment:v=!0,...b}=On(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const w=Et(r),p=it(c),y=Et(c)===c,C=await(u.isRTL==null?void 0:u.isRTL(h.floating)),N=g||(y||!v?[ls(c)]:Wh(c)),I=x!=="none";!g&&I&&N.push(...zh(c,v,x,C));const _=[c,...N],M=await Ba(t,b),k=[];let O=((o=a.flip)==null?void 0:o.overflows)||[];if(m&&k.push(M[w]),d){const W=Bh(r,i,C);k.push(M[W[0]],M[W[1]])}if(O=[...O,{placement:r,overflows:k}],!k.every(W=>W<=0)){var te,ae;const W=(((te=a.flip)==null?void 0:te.index)||0)+1,S=_[W];if(S&&(!(d==="alignment"?p!==it(S):!1)||O.every(z=>it(z.placement)===p?z.overflows[0]>0:!0)))return{data:{index:W,overflows:O},reset:{placement:S}};let P=(ae=O.filter(H=>H.overflows[0]<=0).sort((H,z)=>H.overflows[1]-z.overflows[1])[0])==null?void 0:ae.placement;if(!P)switch(f){case"bestFit":{var Ne;const H=(Ne=O.filter(z=>{if(I){const ie=it(z.placement);return ie===p||ie==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(ie=>ie>0).reduce((ie,Ke)=>ie+Ke,0)]).sort((z,ie)=>z[1]-ie[1])[0])==null?void 0:Ne[0];H&&(P=H);break}case"initialPlacement":P=c;break}if(r!==P)return{reset:{placement:P}}}return{}}}},Yh=new Set(["left","top"]);async function Jh(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=Yh.has(i)?-1:1,m=a&&u?-1:1,d=On(t,e);let{mainAxis:g,crossAxis:f,alignmentAxis:x}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return c&&typeof x=="number"&&(f=c==="end"?x*-1:x),u?{x:f*m,y:g*h}:{x:g*h,y:f*m}}const Xh=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 Jh(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}}}}},Zh=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:b=>{let{x:w,y:p}=b;return{x:w,y:p}}},...u}=On(e,t),h={x:n,y:o},m=await Ba(t,u),d=it(Et(r)),g=$a(d);let f=h[g],x=h[d];if(a){const b=g==="y"?"top":"left",w=g==="y"?"bottom":"right",p=f+m[b],y=f-m[w];f=Zs(p,f,y)}if(i){const b=d==="y"?"top":"left",w=d==="y"?"bottom":"right",p=x+m[b],y=x-m[w];x=Zs(p,x,y)}const v=c.fn({...t,[g]:f,[d]:x});return{...v,data:{x:v.x-n,y:v.y-o,enabled:{[g]:a,[d]:i}}}}}};function Es(){return typeof window<"u"}function rn(e){return Wa(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=(Wa(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Wa(e){return Es()?e instanceof Node||e instanceof ve(e).Node:!1}function Ae(e){return Es()?e instanceof Element||e instanceof ve(e).Element:!1}function Ue(e){return Es()?e instanceof HTMLElement||e instanceof ve(e).HTMLElement:!1}function dr(e){return!Es()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ve(e).ShadowRoot}const em=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)&&!em.has(r)}const tm=new Set(["table","td","th"]);function nm(e){return tm.has(rn(e))}const sm=[":popover-open",":modal"];function Rs(e){return sm.some(t=>{try{return e.matches(t)}catch{return!1}})}const om=["transform","translate","scale","rotate","perspective"],rm=["transform","translate","scale","rotate","perspective","filter"],am=["paint","layout","strict","content"];function Eo(e){const t=Ro(),n=Ae(e)?Ie(e):e;return om.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)||rm.some(o=>(n.willChange||"").includes(o))||am.some(o=>(n.contain||"").includes(o))}function im(e){let t=ct(e);for(;Ue(t)&&!Xt(t);){if(Eo(t))return t;if(Rs(t))return null;t=ct(t)}return null}function Ro(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const lm=new Set(["html","body","#document"]);function Xt(e){return lm.has(rn(e))}function Ie(e){return ve(e).getComputedStyle(e)}function Ls(e){return Ae(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ct(e){if(rn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||dr(e)&&e.host||Ve(e);return dr(t)?t.host:t}function qa(e){const t=ct(e);return Xt(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ue(t)&&$n(t)?t:qa(t)}function Nn(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=qa(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=ve(r);if(a){const c=to(i);return t.concat(i,i.visualViewport||[],$n(r)?r:[],c&&n?Nn(c):[])}return t.concat(r,Nn(r,[],n))}function to(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ua(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=is(n)!==a||is(o)!==i;return c&&(n=a,o=i),{width:n,height:o,$:c}}function Lo(e){return Ae(e)?e:e.contextElement}function Qt(e){const t=Lo(e);if(!Ue(t))return We(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:a}=Ua(t);let i=(a?is(n.width):n.width)/o,c=(a?is(n.height):n.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const cm=We(0);function Ha(e){const t=ve(e);return!Ro()||!t.visualViewport?cm:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function um(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=Lo(e);let i=We(1);t&&(o?Ae(o)&&(i=Qt(o)):i=Qt(e));const c=um(a,n,o)?Ha(a):We(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 x=g,v=to(x);for(;v&&o&&f!==x;){const b=Qt(v),w=v.getBoundingClientRect(),p=Ie(v),y=w.left+(v.clientLeft+parseFloat(p.paddingLeft))*b.x,C=w.top+(v.clientTop+parseFloat(p.paddingTop))*b.y;u*=b.x,h*=b.y,m*=b.x,d*=b.y,u+=y,h+=C,x=ve(v),v=to(x)}}return cs({width:m,height:d,x:u,y:h})}function Ts(e,t){const n=Ls(e).scrollLeft;return t?t.left+n:Rt(Ve(e)).left+n}function za(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-Ts(e,n),r=n.top+t.scrollTop;return{x:o,y:r}}function dm(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=Ve(o),c=t?Rs(t.floating):!1;if(o===i||c&&a)return n;let u={scrollLeft:0,scrollTop:0},h=We(1);const m=We(0),d=Ue(o);if((d||!d&&!a)&&((rn(o)!=="body"||$n(i))&&(u=Ls(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?za(i,u):We(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 hm(e){return Array.from(e.getClientRects())}function mm(e){const t=Ve(e),n=Ls(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+Ts(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 hr=25;function fm(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=Ro();(!m||m&&t==="fixed")&&(c=r.offsetLeft,u=r.offsetTop)}const h=Ts(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,x=Math.abs(o.clientWidth-d.clientWidth-f);x<=hr&&(a-=x)}else h<=hr&&(a+=h);return{width:a,height:i,x:c,y:u}}const pm=new Set(["absolute","fixed"]);function xm(e,t){const n=Rt(e,!0,t==="fixed"),o=n.top+e.clientTop,r=n.left+e.clientLeft,a=Ue(e)?Qt(e):We(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 mr(e,t,n){let o;if(t==="viewport")o=fm(e,n);else if(t==="document")o=mm(Ve(e));else if(Ae(t))o=xm(t,n);else{const r=Ha(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return cs(o)}function Va(e,t){const n=ct(e);return n===t||!Ae(n)||Xt(n)?!1:Ie(n).position==="fixed"||Va(n,t)}function gm(e,t){const n=t.get(e);if(n)return n;let o=Nn(e,[],!1).filter(c=>Ae(c)&&rn(c)!=="body"),r=null;const a=Ie(e).position==="fixed";let i=a?ct(e):e;for(;Ae(i)&&!Xt(i);){const c=Ie(i),u=Eo(i);!u&&c.position==="fixed"&&(r=null),(a?!u&&!r:!u&&c.position==="static"&&!!r&&pm.has(r.position)||$n(i)&&!u&&Va(e,i))?o=o.filter(m=>m!==i):r=c,i=ct(i)}return t.set(e,o),o}function vm(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const i=[...n==="clippingAncestors"?Rs(t)?[]:gm(t,this._c):[].concat(n),o],c=i[0],u=i.reduce((h,m)=>{const d=mr(t,m,r);return h.top=St(d.top,h.top),h.right=Jt(d.right,h.right),h.bottom=Jt(d.bottom,h.bottom),h.left=St(d.left,h.left),h},mr(t,c,r));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function bm(e){const{width:t,height:n}=Ua(e);return{width:t,height:n}}function ym(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=We(0);function h(){u.x=Ts(r)}if(o||!o&&!a)if((rn(t)!=="body"||$n(r))&&(c=Ls(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?za(r,c):We(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 Ws(e){return Ie(e).position==="static"}function fr(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 Ka(e,t){const n=ve(e);if(Rs(e))return n;if(!Ue(e)){let r=ct(e);for(;r&&!Xt(r);){if(Ae(r)&&!Ws(r))return r;r=ct(r)}return n}let o=fr(e,t);for(;o&&nm(o)&&Ws(o);)o=fr(o,t);return o&&Xt(o)&&Ws(o)&&!Eo(o)?n:o||im(e)||n}const wm=async function(e){const t=this.getOffsetParent||Ka,n=this.getDimensions,o=await n(e.floating);return{reference:ym(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Cm(e){return Ie(e).direction==="rtl"}const jm={convertOffsetParentRelativeRectToViewportRelativeRect:dm,getDocumentElement:Ve,getClippingRect:vm,getOffsetParent:Ka,getElementRects:wm,getClientRects:hm,getDimensions:bm,getScale:Qt,isElement:Ae,isRTL:Cm};function Qa(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Nm(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 x=Jn(d),v=Jn(r.clientWidth-(m+g)),b=Jn(r.clientHeight-(d+f)),w=Jn(m),y={rootMargin:-x+"px "+-v+"px "+-b+"px "+-w+"px",threshold:St(0,Jt(1,u))||1};let C=!0;function N(I){const _=I[0].intersectionRatio;if(_!==u){if(!C)return i();_?i(!1,_):o=setTimeout(()=>{i(!1,1e-7)},1e3)}_===1&&!Qa(h,e.getBoundingClientRect())&&i(),C=!1}try{n=new IntersectionObserver(N,{...y,root:r.ownerDocument})}catch{n=new IntersectionObserver(N,y)}n.observe(e)}return i(!0),a}function _m(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=Lo(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?Nm(h,n):null;let g=-1,f=null;i&&(f=new ResizeObserver(w=>{let[p]=w;p&&p.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 x,v=u?Rt(e):null;u&&b();function b(){const w=Rt(e);v&&!Qa(v,w)&&n(),v=w,x=requestAnimationFrame(b)}return n(),()=>{var w;m.forEach(p=>{r&&p.removeEventListener("scroll",n),a&&p.removeEventListener("resize",n)}),d?.(),(w=f)==null||w.disconnect(),f=null,u&&cancelAnimationFrame(x)}}const Sm=Xh,km=Zh,Em=Gh,Rm=Qh,pr=(e,t,n)=>{const o=new Map,r={platform:jm,...n},a={...r.platform,_c:o};return Kh(e,t,{...r,platform:a})};var qs={exports:{}};var xr;function Lm(){return xr||(xr=1,(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var a="",i=0;i<arguments.length;i++){var c=arguments[i];c&&(a=r(a,o(c)))}return a}function o(a){if(typeof a=="string"||typeof a=="number")return a;if(typeof a!="object")return"";if(Array.isArray(a))return n.apply(null,a);if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]"))return a.toString();var i="";for(var c in a)t.call(a,c)&&a[c]&&(i=r(i,c));return i}function r(a,i){return i?a?a+" "+i:a+i:a}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(qs)),qs.exports}var Tm=Lm();const no=ki(Tm);var gr={};const Am="react-tooltip-core-styles",Im="react-tooltip-base-styles",vr={core:!1,base:!1};function br({css:e,id:t=Im,type:n="base",ref:o}){var r,a;if(!e||typeof document>"u"||vr[n]||n==="core"&&typeof process<"u"&&(!((r=process==null?void 0:gr)===null||r===void 0)&&r.REACT_TOOLTIP_DISABLE_CORE_STYLES)||n!=="base"&&typeof process<"u"&&(!((a=process==null?void 0:gr)===null||a===void 0)&&a.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;n==="core"&&(t=Am),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)),vr[n]=!0}const yr=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:o="top",offset:r=10,strategy:a="absolute",middlewares:i=[Sm(Number(r)),Em({fallbackAxisSideDirection:"start"}),km({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(Rm({element:n,padding:5})),pr(e,t,{placement:o,strategy:a,middleware:h}).then((({x:m,y:d,placement:g,middlewareData:f})=>{var x,v;const b={left:`${m}px`,top:`${d}px`,border:c},{x:w,y:p}=(x=f.arrow)!==null&&x!==void 0?x:{x:0,y:0},y=(v={top:"bottom",right:"left",bottom:"top",left:"right"}[g.split("-")[0]])!==null&&v!==void 0?v:"bottom",C=c&&{borderBottom:c,borderRight:c};let N=0;if(c){const I=`${c}`.match(/(\d+)px/);N=I?.[1]?Number(I[1]):1}return{tooltipStyles:b,tooltipArrowStyles:{left:w!=null?`${w}px`:"",top:p!=null?`${p}px`:"",right:"",bottom:"",...C,[y]:`-${u/2+N}px`},place:g}}))):pr(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})))},wr=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),Cr=(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},jr=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",so=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((r,a)=>so(r,t[a])));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!jr(e)||!jr(t))return e===t;const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((r=>so(e[r],t[r])))},Mm=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"}))},Nr=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(Mm(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},Pm=typeof window<"u"?l.useLayoutEffect:l.useEffect,Se=e=>{e.current&&(clearTimeout(e.current),e.current=null)},Om="DEFAULT_TOOLTIP_ID",Dm={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},$m=l.createContext({getTooltipData:()=>Dm});function Ga(e=Om){return l.useContext($m).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"},Us={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 Fm=({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:x=0,delayHide:v=0,float:b=!1,hidden:w=!1,noArrow:p=!1,clickable:y=!1,closeOnEsc:C=!1,closeOnScroll:N=!1,closeOnResize:I=!1,openEvents:_,closeEvents:M,globalCloseEvents:k,imperativeModeOnly:O,style:te,position:ae,afterShow:Ne,afterHide:W,disableTooltip:S,content:P,contentWrapperRef:H,isOpen:z,defaultIsOpen:ie=!1,setIsOpen:Ke,previousActiveAnchor:an,activeAnchor:V,setActiveAnchor:Tt,border:Bn,opacity:Wn,arrowColor:qn,arrowSize:At=8,role:As="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,Un]=l.useState({tooltipStyles:{},tooltipArrowStyles:{},place:c}),[de,ln]=l.useState(!1),[Pt,nt]=l.useState(!1),[Y,Ot]=l.useState(null),Hn=l.useRef(!1),Dt=l.useRef(null),{anchorRefs:zn,setActiveAnchor:cn}=Ga(t),un=l.useRef(!1),[st,dn]=l.useState([]),ft=l.useRef(!1),$t=m||h.includes("click"),Vn=$t||_?.click||_?.dblclick||_?.mousedown,hn=_?{..._}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!_&&$t&&Object.assign(hn,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const pt=M?{...M}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!M&&$t&&Object.assign(pt,{mouseleave:!1,blur:!1,mouseout:!1});const oe=k?{...k}:{escape:C||!1,scroll:N||!1,resize:I||!1,clickOutsideAnchor:Vn||!1};O&&(Object.assign(hn,{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})),Pm((()=>(ft.current=!0,()=>{ft.current=!1})),[]);const he=j=>{ft.current&&(j&&nt(!0),setTimeout((()=>{ft.current&&(Ke?.(j),z===void 0&&ln(j))}),10))};l.useEffect((()=>{if(t){if(de){R(an);const E=j(V),U=[...new Set([...E,t])].filter(Boolean).join(" ");V?.setAttribute("aria-describedby",U)}else R(V);return()=>{R(V),R(an)}}function j(E){var U;return((U=E?.getAttribute("aria-describedby"))===null||U===void 0?void 0:U.split(" "))||[]}function R(E){const U=j(E).filter((se=>se!==t));U.length?E?.setAttribute("aria-describedby",U.join(" ")):E?.removeAttribute("aria-describedby")}}),[V,de,t,an]),l.useEffect((()=>{if(z===void 0)return()=>null;z&&nt(!0);const j=setTimeout((()=>{ln(z)}),10);return()=>{clearTimeout(j)}}),[z]),l.useEffect((()=>{if(de!==Hn.current)if(Se(Mt),Hn.current=de,de)Ne?.();else{const j=(R=>{const E=R.match(/^([\d.]+)(ms|s)$/);if(!E)return 0;const[,U,se]=E;return Number(U)*(se==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));Mt.current=setTimeout((()=>{nt(!1),Ot(null),W?.()}),j+25)}}),[de]);const mn=j=>{Un((R=>so(R,j)?R:j))},fn=(j=x)=>{Se(Le),Pt?he(!0):Le.current=setTimeout((()=>{he(!0)}),j)},Ft=(j=v)=>{Se(ht),ht.current=setTimeout((()=>{un.current||he(!1)}),j)},pn=j=>{var R;if(!j)return;const E=(R=j.currentTarget)!==null&&R!==void 0?R:j.target;if(!E?.isConnected)return Tt(null),void cn({current:null});x?fn():he(!0),Tt(E),cn({current:E}),Se(ht)},Bt=()=>{y?Ft(v||100):v?Ft():he(!1),Se(Le)},Wt=({x:j,y:R})=>{var E;const U={getBoundingClientRect:()=>({x:j,y:R,width:0,height:0,top:R,left:j,right:j,bottom:R})};yr({place:(E=Y?.place)!==null&&E!==void 0?E:c,offset:u,elementReference:U,tooltipReference:ue.current,tooltipArrowReference:It.current,strategy:d,middlewares:g,border:Bn,arrowSize:At}).then((se=>{mn(se)}))},qt=j=>{if(!j)return;const R=j,E={x:R.clientX,y:R.clientY};Wt(E),Dt.current=E},xn=j=>{var R;if(!de)return;const E=j.target;E.isConnected&&(!((R=ue.current)===null||R===void 0)&&R.contains(E)||[document.querySelector(`[id='${a}']`),...st].some((U=>U?.contains(E)))||(he(!1),Se(Le)))},Kn=Cr(pn,50),X=Cr(Bt,50),le=j=>{X.cancel(),Kn(j)},T=()=>{Kn.cancel(),X()},$=l.useCallback((()=>{var j,R;const E=(j=Y?.position)!==null&&j!==void 0?j:ae;E?Wt(E):b?Dt.current&&Wt(Dt.current):V?.isConnected&&yr({place:(R=Y?.place)!==null&&R!==void 0?R:c,offset:u,elementReference:V,tooltipReference:ue.current,tooltipArrowReference:It.current,strategy:d,middlewares:g,border:Bn,arrowSize:At}).then((U=>{ft.current&&mn(U)}))}),[de,V,P,te,c,Y?.place,u,d,ae,Y?.position,b,At]);l.useEffect((()=>{var j,R;const E=new Set(zn);st.forEach((q=>{S?.(q)||E.add({current:q})}));const U=document.querySelector(`[id='${a}']`);U&&!S?.(U)&&E.add({current:U});const se=()=>{he(!1)},Oe=Nr(V),De=Nr(ue.current);oe.scroll&&(window.addEventListener("scroll",se),Oe?.addEventListener("scroll",se),De?.addEventListener("scroll",se));let ce=null;oe.resize?window.addEventListener("resize",se):V&&ue.current&&(ce=_m(V,ue.current,$,{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",xn);const K=[],Ut=q=>!!(q?.target&&V?.contains(q.target)),pi=q=>{de&&Ut(q)||pn(q)},xi=q=>{de&&Ut(q)&&Bt()},Oo=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],Do=["click","dblclick","mousedown","mouseup"];Object.entries(hn).forEach((([q,Qe])=>{Qe&&(Oo.includes(q)?K.push({event:q,listener:le}):Do.includes(q)&&K.push({event:q,listener:pi}))})),Object.entries(pt).forEach((([q,Qe])=>{Qe&&(Oo.includes(q)?K.push({event:q,listener:T}):Do.includes(q)&&K.push({event:q,listener:xi}))})),b&&K.push({event:"pointermove",listener:qt});const $o=()=>{un.current=!0},Fo=()=>{un.current=!1,Bt()},Bo=y&&(pt.mouseout||pt.mouseleave);return Bo&&((j=ue.current)===null||j===void 0||j.addEventListener("mouseover",$o),(R=ue.current)===null||R===void 0||R.addEventListener("mouseout",Fo)),K.forEach((({event:q,listener:Qe})=>{E.forEach((Is=>{var gn;(gn=Is.current)===null||gn===void 0||gn.addEventListener(q,Qe)}))})),()=>{var q,Qe;oe.scroll&&(window.removeEventListener("scroll",se),Oe?.removeEventListener("scroll",se),De?.removeEventListener("scroll",se)),oe.resize?window.removeEventListener("resize",se):ce?.(),oe.clickOutsideAnchor&&window.removeEventListener("click",xn),oe.escape&&window.removeEventListener("keydown",_e),Bo&&((q=ue.current)===null||q===void 0||q.removeEventListener("mouseover",$o),(Qe=ue.current)===null||Qe===void 0||Qe.removeEventListener("mouseout",Fo)),K.forEach((({event:Is,listener:gn})=>{E.forEach((gi=>{var Ms;(Ms=gi.current)===null||Ms===void 0||Ms.removeEventListener(Is,gn)}))}))}}),[V,$,Pt,zn,st,_,M,k,$t,x,v]),l.useEffect((()=>{var j,R;let E=(R=(j=Y?.anchorSelect)!==null&&j!==void 0?j:i)!==null&&R!==void 0?R:"";!E&&t&&(E=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const U=new MutationObserver((se=>{const Oe=[],De=[];se.forEach((ce=>{if(ce.type==="attributes"&&ce.attributeName==="data-tooltip-id"&&(ce.target.getAttribute("data-tooltip-id")===t?Oe.push(ce.target):ce.oldValue===t&&De.push(ce.target)),ce.type==="childList"){if(V){const _e=[...ce.removedNodes].filter((K=>K.nodeType===1));if(E)try{De.push(..._e.filter((K=>K.matches(E)))),De.push(..._e.flatMap((K=>[...K.querySelectorAll(E)])))}catch{}_e.some((K=>{var Ut;return!!(!((Ut=K?.contains)===null||Ut===void 0)&&Ut.call(K,V))&&(nt(!1),he(!1),Tt(null),Se(Le),Se(ht),!0)}))}if(E)try{const _e=[...ce.addedNodes].filter((K=>K.nodeType===1));Oe.push(..._e.filter((K=>K.matches(E)))),Oe.push(..._e.flatMap((K=>[...K.querySelectorAll(E)])))}catch{}}})),(Oe.length||De.length)&&dn((ce=>[...ce.filter((_e=>!De.includes(_e))),...Oe]))}));return U.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{U.disconnect()}}),[t,i,Y?.anchorSelect,V]),l.useEffect((()=>{$()}),[$]),l.useEffect((()=>{if(!H?.current)return()=>null;const j=new ResizeObserver((()=>{setTimeout((()=>$()))}));return j.observe(H.current),()=>{j.disconnect()}}),[P,H?.current]),l.useEffect((()=>{var j;const R=document.querySelector(`[id='${a}']`),E=[...st,R];V&&E.includes(V)||Tt((j=st[0])!==null&&j!==void 0?j:R)}),[a,st,V]),l.useEffect((()=>(ie&&he(!0),()=>{Se(Le),Se(ht)})),[]),l.useEffect((()=>{var j;let R=(j=Y?.anchorSelect)!==null&&j!==void 0?j:i;if(!R&&t&&(R=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),R)try{const E=Array.from(document.querySelectorAll(R));dn(E)}catch{dn([])}}),[t,i,Y?.anchorSelect]),l.useEffect((()=>{Le.current&&(Se(Le),fn(x))}),[x]);const xe=(dt=Y?.content)!==null&&dt!==void 0?dt:P,xt=de&&Object.keys(mt.tooltipStyles).length>0;return l.useImperativeHandle(e,(()=>({open:j=>{if(j?.anchorSelect)try{document.querySelector(j.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${j.anchorSelect}" is not a valid CSS selector`)}Ot(j??null),j?.delay?fn(j.delay):he(!0)},close:j=>{j?.delay?Ft(j.delay):he(!1)},activeAnchor:V,place:mt.place,isOpen:!!(Pt&&!w&&xe&&xt)}))),Pt&&!w&&xe?at.createElement(f,{id:t,role:As,className:no("react-tooltip",zt.tooltip,Us.tooltip,Us[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:j=>{Se(Mt),de||j.propertyName!=="opacity"||(nt(!1),Ot(null),W?.())},style:{...te,...mt.tooltipStyles,opacity:Wn!==void 0&&xt?Wn:void 0},ref:ue},xe,at.createElement(f,{className:no("react-tooltip-arrow",zt.arrow,Us.arrow,o,p&&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},Bm=({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:x=!1,positionStrategy:v="absolute",middlewares:b,delayShow:w=0,delayHide:p=0,float:y=!1,hidden:C=!1,noArrow:N=!1,clickable:I=!1,closeOnEsc:_=!1,closeOnScroll:M=!1,closeOnResize:k=!1,openEvents:O,closeEvents:te,globalCloseEvents:ae,imperativeModeOnly:Ne=!1,style:W,position:S,isOpen:P,defaultIsOpen:H=!1,disableStyleInjection:z=!1,border:ie,opacity:Ke,arrowColor:an,arrowSize:V,setIsOpen:Tt,afterShow:Bn,afterHide:Wn,disableTooltip:qn,role:At="tooltip"},As)=>{const[dt,ue]=l.useState(o),[It,Le]=l.useState(r),[ht,Mt]=l.useState(h),[mt,Un]=l.useState(u),[de,ln]=l.useState(m),[Pt,nt]=l.useState(w),[Y,Ot]=l.useState(p),[Hn,Dt]=l.useState(y),[zn,cn]=l.useState(C),[un,st]=l.useState(d),[dn,ft]=l.useState(f),[$t,Vn]=l.useState(v),[hn,pt]=l.useState(null),[oe,he]=l.useState(null),mn=l.useRef(null),fn=l.useRef(z),{anchorRefs:Ft,activeAnchor:pn}=Ga(e),Bt=X=>X?.getAttributeNames().reduce(((le,T)=>{var $;return T.startsWith("data-tooltip-")&&(le[T.replace(/^data-tooltip-/,"")]=($=X?.getAttribute(T))!==null&&$!==void 0?$:null),le}),{}),Wt=X=>{const le={place:T=>{var $;Mt(($=T)!==null&&$!==void 0?$:h)},content:T=>{ue(T??o)},html:T=>{Le(T??r)},variant:T=>{var $;Un(($=T)!==null&&$!==void 0?$:u)},offset:T=>{ln(T===null?m:Number(T))},wrapper:T=>{var $;st(($=T)!==null&&$!==void 0?$:d)},events:T=>{const $=T?.split(" ");ft($??f)},"position-strategy":T=>{var $;Vn(($=T)!==null&&$!==void 0?$:v)},"delay-show":T=>{nt(T===null?w:Number(T))},"delay-hide":T=>{Ot(T===null?p:Number(T))},float:T=>{Dt(T===null?y:T==="true")},hidden:T=>{cn(T===null?C:T==="true")},"class-name":T=>{pt(T)}};Object.values(le).forEach((T=>T(null))),Object.entries(X).forEach((([T,$])=>{var xe;(xe=le[T])===null||xe===void 0||xe.call(le,$)}))};l.useEffect((()=>{ue(o)}),[o]),l.useEffect((()=>{Le(r)}),[r]),l.useEffect((()=>{Mt(h)}),[h]),l.useEffect((()=>{Un(u)}),[u]),l.useEffect((()=>{ln(m)}),[m]),l.useEffect((()=>{nt(w)}),[w]),l.useEffect((()=>{Ot(p)}),[p]),l.useEffect((()=>{Dt(y)}),[y]),l.useEffect((()=>{cn(C)}),[C]),l.useEffect((()=>{Vn(v)}),[v]),l.useEffect((()=>{fn.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 X;const le=new Set(Ft);let T=n;if(!T&&e&&(T=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),T)try{document.querySelectorAll(T).forEach((R=>{le.add({current:R})}))}catch{console.warn(`[react-tooltip] "${T}" is not a valid CSS selector`)}const $=document.querySelector(`[id='${t}']`);if($&&le.add({current:$}),!le.size)return()=>null;const xe=(X=oe??$)!==null&&X!==void 0?X:pn.current,xt=new MutationObserver((R=>{R.forEach((E=>{var U;if(!xe||E.type!=="attributes"||!(!((U=E.attributeName)===null||U===void 0)&&U.startsWith("data-tooltip-")))return;const se=Bt(xe);Wt(se)}))})),j={attributes:!0,childList:!1,subtree:!1};if(xe){const R=Bt(xe);Wt(R),xt.observe(xe,j)}return()=>{xt.disconnect()}}),[Ft,pn,oe,t,n]),l.useEffect((()=>{W?.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),ie&&!wr("border",`${ie}`)&&console.warn(`[react-tooltip] "${ie}" is not a valid \`border\`.`),W?.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),Ke&&!wr("opacity",`${Ke}`)&&console.warn(`[react-tooltip] "${Ke}" is not a valid \`opacity\`.`)}),[]);let qt=g;const xn=l.useRef(null);if(a){const X=a({content:oe?.getAttribute("data-tooltip-content")||dt||null,activeAnchor:oe});qt=X?at.createElement("div",{ref:xn,className:"react-tooltip-content-wrapper"},X):null}else dt&&(qt=dt);It&&(qt=at.createElement(Bm,{content:It}));const Kn={forwardRef:As,id:e,anchorId:t,anchorSelect:n,className:no(i,hn),classNameArrow:c,content:qt,contentWrapperRef:xn,place:ht,variant:mt,offset:de,wrapper:un,events:dn,openOnClick:x,positionStrategy:$t,middlewares:b,delayShow:Pt,delayHide:Y,float:Hn,hidden:zn,noArrow:N,clickable:I,closeOnEsc:_,closeOnScroll:M,closeOnResize:k,openEvents:O,closeEvents:te,globalCloseEvents:ae,imperativeModeOnly:Ne,style:W,position:S,isOpen:P,defaultIsOpen:H,border:ie,opacity:Ke,arrowColor:an,arrowSize:V,setIsOpen:Tt,afterShow:Bn,afterHide:Wn,disableTooltip:qn,activeAnchor:oe,previousActiveAnchor:mn.current,setActiveAnchor:X=>{he((le=>(X?.isSameNode(le)||(mn.current=le),X)))},role:At};return at.createElement(Fm,{...Kn})}));typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",(e=>{e.detail.disableCore||br({css:":root{--rt-color-white:#fff;--rt-color-dark:#222;--rt-color-success:#8dc572;--rt-color-error:#be6464;--rt-color-warning:#f0ad4e;--rt-color-info:#337ab7;--rt-opacity:0.9;--rt-transition-show-delay:0.15s;--rt-transition-closing-delay:0.15s;--rt-arrow-size:8px}.core-styles-module_tooltip__3vRRp{position:absolute;top:0;left:0;pointer-events:none;opacity:0;will-change:opacity}.core-styles-module_fixed__pcSol{position:fixed}.core-styles-module_arrow__cvMwQ{position:absolute;background:inherit;z-index:-1}.core-styles-module_noArrow__xock6{display:none}.core-styles-module_clickable__ZuTTB{pointer-events:auto}.core-styles-module_show__Nt9eE{opacity:var(--rt-opacity);transition:opacity var(--rt-transition-show-delay)ease-out}.core-styles-module_closing__sGnxF{opacity:0;transition:opacity var(--rt-transition-closing-delay)ease-in}",type:"core"}),e.detail.disableBase||br({css:`
|
|
4
|
+
.styles-module_tooltip__mnnfp{padding:8px 16px;border-radius:3px;font-size:90%;width:max-content}.styles-module_arrow__K0L3T{width:var(--rt-arrow-size);height:var(--rt-arrow-size)}[class*='react-tooltip__place-top']>.styles-module_arrow__K0L3T{transform:rotate(45deg)}[class*='react-tooltip__place-right']>.styles-module_arrow__K0L3T{transform:rotate(135deg)}[class*='react-tooltip__place-bottom']>.styles-module_arrow__K0L3T{transform:rotate(225deg)}[class*='react-tooltip__place-left']>.styles-module_arrow__K0L3T{transform:rotate(315deg)}.styles-module_dark__xNqje{background:var(--rt-color-dark);color:var(--rt-color-white)}.styles-module_light__Z6W-X{background-color:var(--rt-color-white);color:var(--rt-color-dark)}.styles-module_success__A2AKt{background-color:var(--rt-color-success);color:var(--rt-color-white)}.styles-module_warning__SCK0X{background-color:var(--rt-color-warning);color:var(--rt-color-white)}.styles-module_error__JvumD{background-color:var(--rt-color-error);color:var(--rt-color-white)}.styles-module_info__BWdHW{background-color:var(--rt-color-info);color:var(--rt-color-white)}`,type:"base"})}));const 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"})),Ya=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})),To=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"})),Wm=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})),qm=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"})),Um=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"})),Ja=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"})),Hm=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})),Ao=()=>{const{pathname:e}=pe();return l.useMemo(()=>Gt({path:D.workbenchTab.path,end:!1},e)?.params.id,[e])},zm=()=>{const e=Ao(),t=fa();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()}}},Xa=["shift","alt","meta","mod","ctrl","control"],Vm={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(Vm[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function Za(e){return Xa.includes(e)}function Hs(e,t=","){return e.toLowerCase().split(t)}function zs(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=>!Xa.includes(h));return{...c,keys:u,description:r,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&ei([lt(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&ti([lt(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Ye.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Ye.clear()},0)}));const Ye=new Set;function Io(e){return Array.isArray(e)}function Km(e,t=","){return(Io(e)?e:e.split(t)).every(n=>Ye.has(n.trim().toLowerCase()))}function ei(e){const t=Array.isArray(e)?e:[e];Ye.has("meta")&&Ye.forEach(n=>!Za(n)&&Ye.delete(n.toLowerCase())),t.forEach(n=>Ye.add(n.toLowerCase()))}function ti(e){const t=Array.isArray(e)?e:[e];e==="meta"?Ye.clear():t.forEach(n=>Ye.delete(n.toLowerCase()))}function Qm(e,t,n){(typeof n=="function"&&n(e,t)||n===!0)&&e.preventDefault()}function Gm(e,t,n){return typeof n=="function"?n(e,t):n===!0||n===void 0}const Ym=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Jm(e){return ni(e,Ym)}function ni(e,t=!1){const{target:n,composed:o}=e;let r,a;return Xm(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),Io(t)?!!(r&&t&&t.some(i=>i.toLowerCase()===r.toLowerCase()||i===a)):!!(r&&t&&t)}function Xm(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Zm(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 ef=(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:x,altKey:v}=e,b=lt(m);if(h&&u?.length===1&&u.includes(d))return!0;if(!u?.includes(b)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(b))return!1;if(!n){if(o!==v&&b!=="alt"||i!==x&&b!=="shift")return!1;if(a){if(!f&&!g)return!1}else if(r!==f&&b!=="meta"&&b!=="os"||c!==g&&b!=="ctrl"&&b!=="control")return!1}return u&&u.length===1&&u.includes(b)?!0:u?Km(u):!u},tf=l.createContext(void 0),nf=()=>l.useContext(tf);function si(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&&si(e[o],t[o]),!0):e===t}const sf=l.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),of=()=>l.useContext(sf);function rf(e){const t=l.useRef(void 0);return si(t.current,e)||(t.current=e),t.current}const _r=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},af=typeof window<"u"?l.useLayoutEffect:l.useEffect;function qe(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=Io(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=rf(i),{activeScopes:g}=of(),f=nf();return af(()=>{if(d?.enabled===!1||!Zm(g,d?.scopes))return;let x=[],v;const b=(C,N=!1)=>{if(!(Jm(C)&&!ni(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)){_r(C);return}}C.target?.isContentEditable&&!d?.enableOnContentEditable||Hs(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 _=zs(I,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description);if(_.isSequence){v=setTimeout(()=>{x=[]},d?.sequenceTimeoutMs??1e3);const M=_.useKey?C.key:lt(C.code);if(Za(M.toLowerCase()))return;x.push(M);const k=_.keys?.[x.length-1];if(M!==k){x=[],v&&clearTimeout(v);return}x.length===_.keys?.length&&(m.current(C,_),v&&clearTimeout(v),x=[])}else if(ef(C,_,d?.ignoreModifiers)||_.keys?.includes("*")){if(d?.ignoreEventWhen?.(C)||N&&a.current)return;if(Qm(C,_,d?.preventDefault),!Gm(C,_,d?.enabled)){_r(C);return}m.current(C,_),N||(a.current=!0)}})}},w=C=>{C.code!==void 0&&(ei(lt(C.code)),(d?.keydown===void 0&&d?.keyup!==!0||d?.keydown)&&b(C))},p=C=>{C.code!==void 0&&(ti(lt(C.code)),a.current=!1,d?.keyup&&b(C,!0))},y=r.current||i?.document||document;return y.addEventListener("keyup",p,i?.eventListenerOptions),y.addEventListener("keydown",w,i?.eventListenerOptions),f&&Hs(c,d?.delimiter).forEach(C=>f.addHotkey(zs(C,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description))),()=>{y.removeEventListener("keyup",p,i?.eventListenerOptions),y.removeEventListener("keydown",w,i?.eventListenerOptions),f&&Hs(c,d?.delimiter).forEach(C=>f.removeHotkey(zs(C,d?.splitKey,d?.sequenceSplitKey,d?.useKey,d?.description))),x=[],v&&clearTimeout(v)}},[c,d,g]),r}function lf(){return s.jsxs("div",{className:"flex md:grid md:grid-cols-3 items-center bg-white overflow-auto no-scrollbar",children:[s.jsx(cf,{}),s.jsx(uf,{}),s.jsx(mf,{})]})}function cf(){const{dataSourceId:e}=l.useContext(Pe),{data:t}=xs(e),{state:{table:n}}=l.useContext(je);return s.jsx("div",{className:L.tableConfig,children:t&&s.jsxs("div",{className:A(L.tableAction,L.dataSource),"data-tooltip-id":"default","data-tooltip-content":n,children:[s.jsx(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 uf(){const{page:e,size:t,setPage:n}=Da(),{data:o,isFetching:r}=l.useContext(tt),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 df=[5,10,20,50,100,200],hf=!__CLIENT_CONFIG__.skipAuth;function mf(){const{dataSourceId:e,name:t}=l.useContext(Pe),{data:n}=xs(e),{data:o,refetch:r}=l.useContext(tt),a=An(me.EDITOR),i=Mh(),{rename:c}=zm(),{size:u,setSize:h}=Da(),{state:m}=l.useContext(je),d=Lt(),g=ee(),f=()=>{d.mutateAsync({name:t,opts:m}).then(p=>{g(D.workbenchTab.build({id:p.id}))})},x=()=>{if(o?.result.queryHistoryId){const p=new URL(window.location.href);p.pathname=D.share.build(),p.searchParams.set("shareId",o.result.queryHistoryId),navigator.clipboard.writeText(p.toString()),fe.success("Share link copied to clipboard")}},v=()=>{m.table&&wh({table:m.table,dataSourceId:e})},b=async()=>{const p=await Pn("Query name",t);!p||!o?.result.queryHistoryId||i.mutate({name:p,queryId:o.result.queryHistoryId})},w=()=>c(t);return qe("s",b),qe("r",w),qe("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(Um,{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(Hm,{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(To,{width:16,height:16})}),hf&&s.jsx("span",{"data-tooltip-content":"Share query","data-tooltip-id":"default",className:A(L.tableAction,L.gray),onClick:x,role:"button",children:s.jsx(qm,{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(Wm,{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:v,role:"button",children:s.jsx(Ja,{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:df.map(p=>s.jsx("button",{onClick:()=>h(p,!0),className:A(L.tableAction,L.gray,p===u&&L.selectedSize),children:s.jsx("span",{children:p})},p))}),s.jsx("button",{"data-tooltip-id":"explorer-more-actions",className:A(L.tableAction,L.gray),children:s.jsx(Ya,{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:b,className:A(L.tableAction,L.modal,L.gray),children:[s.jsx("span",{children:"Save query"}),s.jsx("span",{className:"hotkey",children:"S"})]})})]})]})}const ff="_drop-container_1xd52_2",pf="_item_1xd52_2",Sr={dropContainer:ff,item:pf},oi=({dataSourceId:e,inputClassName:t,focusId:n,placeholder:o="Column",onChange:r,value:a,autoFocus:i,allowTables:c})=>{const{data:u}=gs(e),h=l.useRef(null),m=l.useMemo(()=>{if(!u)return[];let p=u;return c&&(p=u.filter(y=>c.includes(y.tableName))),p.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 p=a.toLowerCase()||"",y=[];for(let C=0;C<m.length&&y.length<10;C++)m[C].searchValue.includes(p)&&y.push(m[C]);return y},[m,a]),[g,f]=l.useState(!1),[x,v]=l.useState(0),b=p=>{if(p.key==="ArrowDown")p.preventDefault(),v(y=>(y+1)%d.length);else if(p.key==="ArrowUp")p.preventDefault(),v(y=>(y-1+d.length)%d.length);else if(p.key==="Enter"&&x>=0&&x<d.length){p.preventDefault();const y=d[x].value;f(!1);const C=m.findIndex(N=>N.value===y)>-1;r(d[x]?.value||y,C,!0)}};l.useEffect(()=>{const p=h.current?.querySelector('[data-is-active="true"]');p&&p.scrollIntoView({behavior:"smooth",block:"nearest"})},[x]);const w=p=>{const y=p.currentTarget.value,C=m.findIndex(N=>N.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:b,value:a,onChange:w,className:t,placeholder:o,"data-focus":n}),g&&d.length>0&&s.jsx("div",{className:Sr.dropContainer,ref:h,tabIndex:-1,children:d.map((p,y)=>s.jsxs("div",{className:Sr.item,"data-is-active":x===y,onMouseDownCapture:C=>{C.preventDefault(),f(!1),r(p.value,!0,!0)},children:[s.jsx("span",{className:"text-xs font-semibold truncate",children:p.table}),s.jsx("p",{className:"truncate text-sm",children:p.label})]},y))})]})},xf="_actions_1ewl3_2",gf="_filter-actions_1ewl3_2",vf="_filters-container_1ewl3_2",bf="_filter-container_1ewl3_2",us={actions:xf,filterActions:gf,filtersContainer:vf,filterContainer:bf},yf=({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:us.filterContainer,children:[s.jsx("input",{className:"mr-1",type:"checkbox",checked:e.isEnabled!==!1,onClick:()=>c(e.id)}),s.jsx(oi,{dataSourceId:t,onChange:m=>r(e.id,m),value:e.column,allowTables:n,focusId:"column",inputClassName:"input w-full",autoFocus:o}),s.jsx(Ns,{prefix:"_",allowedModes:_s,onExpressionChange:m=>a(e.id,m),onKeyDown:h,placeholder:"Filter value",value:e.value,mode:e.mode,className:"h-8"}),s.jsx("div",{className:us.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(Ze,{width:20,height:20,className:"text-red-600"})})})]})},wf=()=>{const{state:e}=l.useContext(je),{refetch:t}=l.useContext(tt),{setFilters:n}=yo(),o=Ss(x=>x.filters),r=l.useMemo(()=>[e.table,...e.joins.map(x=>x.table)],[e.table,e.joins]),[a,i]=l.useState([]),c=(x,v)=>{i(b=>[...b.map(w=>w.id===x?{...w,column:v}:w)])},u=(x,v)=>{i(b=>[...b.map(w=>w.id===x?{...w,value:v.value,mode:v.mode}:w)])},h=()=>{i(x=>[...x,{id:et(),value:"",column:"",isEnabled:!0,mode:"default"}])},m=x=>{i(v=>v.filter(b=>b.id!==x))},d=()=>ks("filters"),g=()=>{try{n(a.filter(x=>x.value.length>0&&x.column.length>0)),setTimeout(t,1),d()}catch(x){x instanceof Error?fe.error(x.message):fe.error("Error during parsing, check you filters")}},f=x=>{i(v=>v.map(b=>b.id===x?{...b,isEnabled:!b.isEnabled}:b))};return l.useEffect(()=>{o&&i(()=>[...e.filters,{id:et(),value:"",column:"",isEnabled:!0,mode:"default"}])},[o]),qe("f",()=>{as("filters")}),s.jsxs(Me,{isVisible:o,onClose:d,portal:!0,onClosed:()=>i([]),noPadding:!0,backdropClose:!0,children:[s.jsx(sn,{onClick:d}),s.jsx("h2",{className:"text-lg font-semibold m-2",children:"Filters"}),s.jsxs("div",{className:us.filtersContainer,children:[a.length<1&&s.jsx("p",{className:"p-1 text-center rounded-lg bg-gray-50 border border-gray-200",children:"No filters"}),a.map((x,v)=>s.jsx(yf,{filter:x,dataSourceId:e.dataSourceId,allowedTables:r,onChangeColumn:c,onChangeValue:u,onRemoveFilter:m,triggerIsEnabled:f,onSubmit:g,autoFocus:v===a.length-1},x.id))]}),s.jsxs("div",{className:us.actions,children:[s.jsxs("button",{className:"button tertiary flex items-center gap-1 text-sm",onClick:h,children:[s.jsx(Ja,{width:20,height:20}),s.jsx("span",{children:"Add filter"})]}),s.jsx("button",{className:"button primary text-sm",onClick:g,children:"Apply filters"})]})]})},Cf="_join-modal_1qgvq_2",jf={joinModal:Cf},Nf=(e,t)=>e.type!==t.type||e.on!==t.on||e.table!==t.table,_f=(e,t)=>e.type===t.type&&e.on===t.on&&e.table===t.table,ri=()=>{const{state:e,setState:t}=l.useContext(je),n=l.useCallback(o=>{t(r=>{const a=r.joins;if(a.some(c=>_f(c,o))){const c=o.table+".";return{...r,joins:a.filter(u=>Nf(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}},Sf=()=>{const{isFetching:e}=l.useContext(tt),t=Ss(u=>u.joins),{toggle:n}=ri(),{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=()=>ks("joins");return qe("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(sn,{onClick:c}),s.jsxs("div",{className:jf.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(ge,{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(bo,{hook:u,onClick:()=>{e||(n({table:u.direction==="in"?u.fromTable:u.toTable,type:"LEFT",on:au(u)}),a(""),c())}},u.id))})]})]})};function kf(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}function kr(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}const Ef="_container_mo9ee_2",Rf="_column-label_mo9ee_2",Lf="_not-active_mo9ee_2",ss={container:Ef,columnLabel:Rf,notActive:Lf};function Tf(e){if(!e)return[];const t={};return e.forEach(n=>{t[n.table]?t[n.table].push({value:n.full,ogColumn:n.column,label:Yn(n.column),type:n.type}):t[n.table]=[{value:n.full,ogColumn:n.column,label:Yn(n.column),type:n.type}],ou[n.type]&&["YEAR","MONTH","DAY"].forEach(o=>{t[n.table].push({value:o+" "+n.full,ogColumn:n.column,label:o+" "+Yn(n.column),type:"number",nested:!0})})}),Object.entries(t).reduce((n,[o,r])=>(n.push({name:Yn(o),columns:r}),n),[])}function Af(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 If=({column:e,selected:t,onCheck:n})=>s.jsxs("label",{className:A(ss.columnLabel,t?ss.active:ss.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),Mf={columns:"c",groupBy:"g"},Er=({mode:e})=>{const t=Ss(p=>p[e]),{allColumns:n}=l.useContext(Pe),{state:o,setState:r}=l.useContext(je),[a,i]=l.useState({}),[c,u]=l.useState(""),h=l.useMemo(()=>Tf(n),[n]),m=o.aggregations.length>0||o.groupBy.length>0,d=l.useMemo(()=>c?Af(h,c):h,[c,h]),g=p=>{i(y=>({...y,[p.target.name]:p.target.checked}))},f=p=>{const y=p.target.checked;i(C=>{for(const N of n)C[N.full]=y;return{...C}})},x=()=>{ks(e)},v=()=>{const p=[];for(const[y,C]of Object.entries(a))if(C){const[N,I]=y.split(" ");p.push({value:I||N,fn:I?N:void 0})}r(y=>({...y,[e]:p})),x()},b=l.useMemo(()=>{for(const p of n)if(!a[p.full])return!1;return!0},[a,n]);qe(Mf[e],()=>{e==="columns"?m?fe.error("Columns are ignored when there is at least one aggregation or group by"):as("columns"):as("groupBy")}),l.useEffect(()=>{t&&i(()=>kf(o[e].map(p=>p.fn?p.fn+" "+p.value:p.value)))},[t,i]);const w=()=>{u(""),i({})};return s.jsxs(Me,{isVisible:t,onClose:x,portal:!0,onClosed:w,backdropClose:!0,children:[s.jsx(sn,{onClick:x}),s.jsxs("div",{className:ss.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:p=>u(p.target.value)}),s.jsx("div",{className:"overflow-y-auto",children:d.map(p=>s.jsxs("div",{className:"my-2",children:[s.jsxs("p",{className:"font-semibold sticky top-0 bg-white p-1 z-1",children:["📄 ",p.name]}),p.columns.map(y=>s.jsx(If,{column:y,selected:a,onCheck:g},y.value))]},p.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:b,onChange:f}),s.jsx("span",{children:"Select all"})]}),s.jsx("span",{className:"flex-1"}),s.jsx("button",{className:"button tertiary",onClick:x,children:"Cancel"}),s.jsx("button",{className:"button primary",onClick:v,children:"Apply"})]})]})]})},Pf="_options-container_vjk9x_2",Of={optionsContainer:Pf},Vs="COUNT all",Df=()=>{const e=Ss(x=>x.aggregate),{dataSourceId:t}=l.useContext(Pe),{setState:n,state:o}=l.useContext(je),{data:r}=l.useContext(tt),[a,i]=l.useState({fn:"",col:""}),c=x=>i({...a,fn:x.currentTarget.value}),u=x=>i({...a,col:x}),h=()=>ks("aggregate"),m=()=>{const x=a.fn===Vs?{value:"*",fn:"COUNT"}:{fn:a.fn,value:a.col,distinct:a.fn==="COUNT"};n(v=>({...v,aggregations:[...v.aggregations,x]}))},d=a.fn===Vs,g=d?!1:!a.col||!a.fn,f=x=>{const v=ru(x);n(b=>({...b,aggregations:b.aggregations.filter(w=>w.fn!==x.fn||w.value!==x.value),orderBy:b.orderBy.filter(w=>w.column!==v)}))};return qe("a",()=>{as("aggregate")}),s.jsxs(Me,{isVisible:e,onClose:h,backdropClose:!0,portal:!0,children:[s.jsx(sn,{onClick:h}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold",children:"Aggregate"}),be(o.aggregations.length,0)&&s.jsx("div",{className:"flex flex-col gap-1 mt-4",children:o.aggregations.map((x,v)=>s.jsxs("p",{className:"p-2 rounded-md bg-gray-50 flex items-center justify-between",children:[s.jsx("span",{children:ns(x)}),s.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove aggregation",className:"p-0.5 text-sm cursor-pointer",onClick:()=>f(x),children:s.jsx(Ze,{width:20,height:20,className:"text-red-600"})})]},v))}),s.jsxs("div",{className:Of.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:Vs,children:"Count all rows"}),s.jsx("option",{value:"COUNT",children:"Count"}),s.jsx("option",{value:"SUM",children:"Sum"}),s.jsx("option",{value:"MAX",children:"Max"}),s.jsx("option",{value:"MIN",children:"Min"}),s.jsx("option",{value:"AVG",children:"Avg"})]})]}),!d&&s.jsxs("label",{children:[s.jsx("p",{className:"font-semibold text-xs",children:"Column"}),s.jsx(oi,{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"})]})]})]})},$f="_container_c6f9o_2",Ff="_yellow-pill_c6f9o_2 _pill_c6f9o_2",Bf="_blue-pill_c6f9o_2 _pill_c6f9o_2",Wf="_purple-pill_c6f9o_2 _pill_c6f9o_2",qf="_red-pill_c6f9o_2 _pill_c6f9o_2",Uf="_black-pill_c6f9o_2 _pill_c6f9o_2",Hf="_disabled-pill_c6f9o_2",yt={container:$f,yellowPill:Ff,bluePill:Bf,purplePill:Wf,redPill:qf,blackPill:Uf,disabledPill:Hf};function zf(e){return!(e===!0||e===void 0)}const Vf=()=>{const{state:{aggregations:e,columns:t,groupBy:n}}=l.useContext(je),{toggle:o,joins:r}=ri(),{filters:a,setFilters:i,removeFilter:c}=yo(),u=()=>Be("joins"),h=()=>Be("aggregate"),m=()=>Be("columns"),d=()=>Be("groupBy"),g=v=>{v.preventDefault(),v.stopPropagation(),o(r[r.length-1])},f=v=>{i(a.map(b=>({...b,isEnabled:v===b.id?zf(b.isEnabled):b.isEnabled})),!0)},x=v=>b=>{b.preventDefault(),b.stopPropagation(),c(v)};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((v,b)=>s.jsxs("button",{onClick:u,className:yt.yellowPill,"data-tooltip-id":"default","data-tooltip-content":`Joins ${v.table} on ${v.on}`,children:[s.jsx("p",{className:"text-sm",children:v.table}),b===r.length-1&&s.jsx(Ze,{onClick:g,width:18,height:18})]},v.table)),a.map(v=>s.jsxs("button",{onClick:()=>f(v.id),onAuxClick:()=>c(v.id),className:A(yt.bluePill,v.isEnabled===!1&&yt.disabledPill),"data-tooltip-id":"default","data-tooltip-content":`${v.column} ${v.value}`,children:[s.jsx("p",{className:"text-sm",children:v.column}),s.jsx("p",{className:"text-sm",children:v.value}),s.jsx(Ze,{onClick:x(v.id),width:18,height:18})]},v.id)),e.map(v=>s.jsx("button",{onClick:h,className:A(yt.purplePill),"data-tooltip-id":"default","data-tooltip-content":ns(v),children:s.jsx("p",{className:"text-sm",children:ns(v)})},ns(v))),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},Kf=({options:e,updater:t,name:n,tabId:o})=>{const r=Bc(e,t),a=Yc(o,r.state),i=Fc(a.data,r.state.dataSourceId,n,o);return s.jsx(Pe,{value:i,children:s.jsx(je,{value:r,children:s.jsxs(tt,{value:a,children:[s.jsx(lf,{}),s.jsx(Vf,{}),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(Ih,{})}),s.jsx(wf,{}),s.jsx(Sf,{}),s.jsx(Er,{mode:"columns"}),s.jsx(Er,{mode:"groupBy"}),s.jsx(Df,{})]})]})})})},Mo=({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..."})]}),Qf=({id:e})=>{const{data:t}=Qc(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(Kf,{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(Mo,{})})},Rr=e=>{setTimeout(t=>{const n=document.querySelector(`[data-tab-id="${t}"]`);n&&n.scrollIntoView({behavior:"smooth"})},50,e)},Gf=()=>{const{data:e}=ys(),t=Gc();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)}bs(()=>h),h.length===0&&(u="home")}return u}}},Yf=()=>{const e=fa();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()}}},Jf=()=>{const{id:e}=hl(),t=ee(),{workbenchTabs:n,archive:o}=Gf(),{rename:r}=Yf(),[a,i]=l.useState(void 0),c=l.useRef(null),u=_a(go.laptop),h=(f,x={})=>{c.current?.close();const v=o(f,e||"",x);v&&(v==="home"?t(D.home.build(),{replace:!0}):(Rr(v),t(D.workbenchTab.build({id:v}),{replace:!0})))},m=f=>{f.stopPropagation(),f.preventDefault();const x=f.currentTarget.getAttribute("data-tab-id");x&&h(x)},d=f=>{const x=f.currentTarget.getAttribute("data-tab-id");x&&c.current&&(f.preventDefault(),f.stopPropagation(),i(x),c.current.open(f))},g=f=>{const x=n?.find(v=>v.id===f);x&&(c.current?.close(),r(x.name,f))};return l.useEffect(()=>{e&&Rr(e)},[e,n]),s.jsxs("div",{className:"h-screen max-h-screen bg-(--bg) flex flex-col",children:[e?s.jsx(Qf,{id:e}):s.jsx("div",{className:"flex-1"}),be(n?.length,0)&&s.jsxs("div",{className:A($e.tabs,"no-scrollbar",!u&&$e.mobile),children:[s.jsx(wo,{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(D.workbenchTab.build({id:f.id})),className:A($e.tab,f.id===e&&$e.active),"data-tooltip-id":"default","data-tab-id":f.id,"data-tooltip-content":f.name,onAuxClick:()=>h(f.id),onContextMenu: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(Ze,{width:20,height:20})})]},f.id))]})]})},Xf="_root_1ujbd_2",Zf="_up_1ujbd_2",e0="_down_1ujbd_2",t0="_chevron_1ujbd_2",n0="_table-name-container_1ujbd_2",s0="_link_1ujbd_2",o0="_table-name_1ujbd_2",r0="_ul_1ujbd_2",a0="_column-type_1ujbd_2",i0="_action-blue_1ujbd_2 _action_1ujbd_2",l0="_action-red_1ujbd_2 _action_1ujbd_2",c0="_db-header-container_1ujbd_2",u0="_db-header_1ujbd_2",d0="_db-subheader_1ujbd_2 _db-header_1ujbd_2",re={root:Xf,up:Zf,down:e0,chevron:t0,tableNameContainer:n0,link:s0,tableName:o0,ul:r0,columnType:a0,actionBlue:i0,actionRed:l0,dbHeaderContainer:c0,dbHeader:u0,dbSubheader:d0},h0="_sidebar_6yd9v_2",m0="_sidebar-visible_6yd9v_2",f0="_sidebar-container_6yd9v_2",p0="_sidebar-invisible_6yd9v_2",x0="_backdrop_6yd9v_2",bn={sidebar:h0,sidebarVisible:m0,sidebarContainer:f0,sidebarInvisible:p0,backdrop:x0},Fn=({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]),ws({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})]})},oo=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{d:"M384 224v184a40 40 0 01-40 40H104a40 40 0 01-40-40V168a40 40 0 0140-40h167.48M336 64h112v112M224 288L440 72",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32})),g0=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"})),v0=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"})),ai=(e,t=!0)=>{const n=navigator.clipboard.writeText(e);t&&n.then(()=>{fe.success(`Copied "${e}"`)})},b0=e=>{const t=l.useRef(!1);l.useEffect(()=>{e&&(e.status==="INSPECTING"?t.current=!0:e.status==="READY"&&t.current&&(Ic(e.id),t.current=!1))},[e])},y0=new Intl.DateTimeFormat("en",{dateStyle:"full",timeStyle:"long"}),Xn=18;function w0(e,t){return t&&e.toLowerCase().includes(t)?"bg-yellow-200 cursor-pointer":"cursor-pointer"}const C0=({insp:e,filter:t,expanded:n})=>{const o=l.useMemo(()=>n?e.columns:t.length<1?[]:e.columns.filter(r=>r.name.toLowerCase().includes(t)),[e,t,n]);return s.jsx("ul",{className:re.ul,children:o.map(r=>s.jsxs("li",{children:[r.isPrimary?"🔐":"🏷️"," ",s.jsx("span",{onClick:()=>ai(r.name),className:w0(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 j0({id:e}){const{data:t}=xs(e),{data:n}=gs(e),o=ee(),r=Pc(),a=da(),i=Oc(),c=Lt(),u=l.useMemo(()=>t?.lastInspected?y0.format(new Date(t.lastInspected)):"--",[t]),[h,m]=l.useState({}),[d,g]=l.useState(""),[f,x]=l.useState("table"),v=An(me.EDITOR),b=d.toLowerCase(),w=l.useMemo(()=>{if(!b||!n)return n||[];const k=[];for(const O of n){if(O.tableName.toLowerCase().includes(b)){k.push(O);continue}f!=="table"&&O.columns.findIndex(te=>te.name.toLowerCase().includes(b))>=0&&k.push(O)}return k},[b,n,f]),p=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(D.workbenchTab.build({id:O.id}))})},C=()=>{a.mutate(e)},N=async()=>{const k=await Pn("Enter name",t?.name);k&&r.mutate({id:e,dataSource:{name:k}})},I=async()=>{await xo("Are you sure you want to delete this data source and all related data (ex: saved queries)?")&&(i.mutate(e),jn(void 0))};b0(t);const _=f==="column",M=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}),v&&s.jsxs("div",{className:"flex justify-end",children:[s.jsx("button",{disabled:a.isPending||M,onClick:C,className:re.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Refresh schema",children:s.jsx(To,{width:16,height:16})}),s.jsx("button",{disabled:a.isPending,onClick:N,className:re.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Update name",children:s.jsx(g0,{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(v0,{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=>x(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:_?"Search column":"Search table",value:d,onChange:k=>g(k.target.value),autoFocus:!0})]})]}),M&&s.jsxs("div",{className:"flex justify-center gap-2 items-center bg-blue-50 p-4 rounded",children:[s.jsx(Mo,{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",M&&"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:()=>p(k.id),children:s.jsx(Sn,{width:16,height:16})}),s.jsx("button",{className:A(re.tableName,"flex-1"),onClick:()=>p(k.id),children:k.tableName}),s.jsx("button",{className:re.link,onClick:()=>y(k.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Explore table data",children:s.jsx(oo,{width:Xn,height:Xn})}),s.jsx("button",{className:re.link,onClick:()=>ai(k.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Copy table name",children:s.jsx(Ta,{width:Xn,height:Xn})})]}),(h[k.id]||d.length>0)&&s.jsx(C0,{insp:k,filter:_?b:"",expanded:h[k.id]})]},k.id))})]})}const N0=()=>{const e=Bu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const o=()=>jn(void 0);return s.jsx(Fn,{isVisible:e!=null,onClose:o,onClosed:()=>n(void 0),backdropClose:!0,children:t&&s.jsx(j0,{id:t})})};function Po(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 _0="_search-container_6s3xd_2",S0="_search_6s3xd_2",k0="_entry_6s3xd_2",E0="_ds_6s3xd_2",R0="_ds-tooltip_6s3xd_2",L0="_ds-entry_6s3xd_2",T0="_ds-name_6s3xd_2",rt={searchContainer:_0,search:S0,entry:k0,ds:E0,dsTooltip:R0,dsEntry:L0,dsName:T0},[A0,I0]=Ma({initialData:[],localStorageKey:"selected-data-sources-v1"}),M0=e=>I0(t=>{const n=t.indexOf(e);return n>-1?(t.splice(n,1),[...t]):[...t,e]}),P0={table:"📄",query:"📖",tab:"🛠️"},O0=({onTable:e,onQuery:t,onWorkbenchTab:n,autoFocus:o})=>{const[r,a]=l.useState(""),[i,c]=l.useState(-1),u=Po(r,200),h=A0(),{data:m}=we(),{data:d}=fo({teamId:m?.teamId}),g=l.useMemo(()=>{const p=[],y=kr(h);if(!d||d.length===0)return[];for(const C of d)y[C.id]&&p.push(C.id);return p},[h,d]),{data:f}=Sc(u,{teamId:m?.teamId,selectedDataSources:g}),x=p=>{p.type==="table"?e(p.name,p.dataSourceId):p.type==="query"?t(p.id,p.dataSourceId):p.type==="tab"&&n(p.id,p.dataSourceId)},v=p=>{f&&(p.key==="ArrowDown"?(p.preventDefault(),c(y=>(y+1)%f.length)):p.key==="ArrowUp"?(p.preventDefault(),c(y=>(y-1+f.length)%f.length)):p.key==="Enter"&&i>=0&&f[i]?.name&&(p.preventDefault(),x(f[i])))},b=p=>{const y=p.currentTarget.dataset.tableId,C=f?.find(N=>N.id===y);C&&x(C)},w=l.useMemo(()=>kr(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:rt.dsTooltip,variant:"light",place:"left-start",positionStrategy:"fixed",noArrow:!0,opacity:1,children:d?.map(p=>s.jsxs("button",{className:A(rt.dsEntry,w[p.id]&&rt.enabled),onClick:()=>M0(p.id),children:[s.jsx("input",{type:"checkbox",checked:!!w[p.id],readOnly:!0}),s.jsx("p",{className:rt.dsName,children:p.name}),s.jsx("div",{children:s.jsx(ze,{size:16,type:p.dbType})})]},p.id))}),po(d?.length,1)&&s.jsx(ge,{variant:"warning",className:"mb-4",children:"Connect at least one data source to start using DataRamen"}),s.jsxs("div",{className:rt.searchContainer,children:[s.jsx(on,{containerClassName:rt.search,placeholder:"Search table or saved query to start from",value:r,onChange:p=>a(p.target.value),onKeyDown:v,autoFocus:o}),be(d?.length,0)&&s.jsx("span",{"data-tooltip-id":"datasources",children:s.jsx(Ya,{width:16,height:16})})]}),s.jsx("div",{className:"overflow-y-auto max-h-full mt-2",children:f?.map((p,y)=>s.jsxs("button",{className:rt.entry,"data-is-active":i===y,"data-table-id":p.id,onClick:b,children:[s.jsxs("p",{className:"truncate",children:[P0[p.type]," ",p.name]}),s.jsxs("p",{className:rt.ds,children:["📦 ",p.dataSourceName]})]},p.id))})]})},D0=()=>{const e=Xc(),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(O0,{autoFocus:!0,onTable:t,onQuery:n,onWorkbenchTab:o})})},$0=()=>{const e=Tn(),t=ee(),{pathname:n}=pe(),{data:o}=we(),{data:r}=ys(),a=D.home.check(n);qe("n",()=>{o&&e()}),qe("w",()=>{o&&(r&&r.length>0?t(D.workbenchTab.build({id:r[0].id})):e())},{enabled:a}),qe("h",()=>{Yt({show:!0})})},[F0,ii]=Ce(!1),Ks=()=>ii(!1),li=()=>ii(!0),B0=({repeatPassword:e,password:t})=>t.length<1?null:t.length<8?s.jsx(ge,{variant:"warning",children:"New password should be at least 8 characters long"}):t!==e?s.jsx(ge,{variant:"warning",children:"Repeat password should match new password"}):null,W0=()=>{const e=F0(),{data:t}=we(),{mutateAsync:n,isPending:o}=Dc(),r=ee(),[{password:a,repeatPassword:i},{change:c,touched:u,reset:h}]=kn({password:"",repeatPassword:""}),m=()=>{r("/"),hs.logout().then(()=>{Ks()})},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:Ks,children:[s.jsx(sn,{onClick:Ks}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[s.jsx(va,{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(B0,{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"})]})]})]})},[q0,ci]=Ce(!1),ui=()=>ci(!0),Lr=()=>ci(!1),U0=e=>ye({queryKey:["team-users"],queryFn:async()=>{const{data:t}=await B.get("/teams/"+e+"/users");return t.data},enabled:!!e}),H0=()=>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"]})}}),z0=()=>ne({mutationFn:async({teamId:e,userId:t})=>(await B.delete("/teams/"+e,{params:{userId:t}}),!0),onSuccess:()=>{J.invalidateQueries({queryKey:["team-users"]})}}),V0="_user-entry_1qomo_2",K0="_select-container_1qomo_2",Tr={userEntry:V0,selectContainer:K0},Q0=()=>{const e=q0(),{data:t}=we(),{data:n}=U0(t?.teamId),{mutate:o,isPending:r}=$c(),{mutate:a,isPending:i}=H0(),{mutate:c,isPending:u}=z0(),[h,{change:m,reset:d}]=kn({password:"",username:""}),g=()=>{o({username:h.username,password:h.password,teamId:t?.teamId||""}),d()},f=(w,p)=>{a({teamId:t.teamId,role:p,userId:w})},x=w=>{xo("Are you sure you want to remove this user?").then(p=>{p&&c({userId:w,teamId:t.teamId})})},v=An(me.ADMIN),b=r||i||u;return s.jsxs(Me,{isVisible:e,onClose:Lr,backdropClose:!0,children:[s.jsx(sn,{onClick:Lr}),s.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[s.jsx(va,{children:"Manage users"}),be(n?.length,0)&&s.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:n.map(w=>s.jsxs("div",{className:Tr.userEntry,children:[s.jsx("div",{className:Tr.selectContainer,children:s.jsxs("select",{value:w.role,disabled:!v||b,onChange:p=>f(w.id,p.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}),v&&s.jsx("button",{className:"p-1 cursor-pointer text-red-500 text-sm",onClick:()=>x(w.id),children:"❌"})]},w.id))}),v&&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:b}),s.jsx("input",{className:"input",onChange:m("password"),value:h.password,type:"password",name:"newPassword",autoComplete:"new-password",placeholder:"Password",disabled:b}),s.jsx("button",{className:"button primary",onClick:g,disabled:b,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."})]})]})]})},G0="_gray-card_1i0q8_2",Y0="_login-label_1i0q8_2",Ar={grayCard:G0,loginLabel:Y0},J0=()=>{const[e,t]=l.useState(""),[n,o]=l.useState(""),[r,a]=l.useState(),i=ee(),c=u=>{u.preventDefault(),a(void 0),hs.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(wa,{})]}),s.jsxs("form",{className:Ar.grayCard,onSubmit:c,children:[s.jsx("h2",{className:Ar.loginLabel,children:"Login"}),r&&s.jsx(ge,{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"})})]})]})})},X0=()=>{const e=ee(),{pathname:t}=pe(),{data:n,isLoading:o}=ha();l.useEffect(()=>{!n&&!o&&!D.login.check(t)&&e(D.login.build())},[n,o,e,t])},Z0=()=>{},ep=__CLIENT_CONFIG__.skipAuth?Z0:X0,tp=()=>{const[e]=sc(),t=ee(),n=Lt(),o=e.get("shareId");return l.useEffect(()=>{o&&n.mutateAsync({queryId:o}).then(r=>{t(D.workbenchTab.build({id:r.id}),{replace:!0})})},[o]),s.jsxs("div",{className:"page-container flex items-center justify-center h-screen",children:[n.isPending&&s.jsxs("div",{className:"flex items-center flex-col gap-2",children:[s.jsx(Mo,{}),s.jsx("p",{children:"Fetching query information"})]}),n.isError&&s.jsx(ge,{variant:"danger",children:"Failed to load query information"})]})},np="_tab-container_1vdih_2",sp="_tab-name_1vdih_2",op="_archived-badge_1vdih_2 _badge_1vdih_2",rp="_active-badge_1vdih_2 _badge_1vdih_2",ap="_delete-action_1vdih_2",yn={tabContainer:np,tabName:sp,archivedBadge:op,activeBadge:rp,deleteAction:ap},di=({title:e,onLoadMore:t,children:n,onClose:o,hasMore:r,onSearchValue:a,searchValue:i})=>s.jsxs("aside",{className:"max-w-full w-md no-scrollbar",children:[s.jsxs("div",{className:"sticky top-0 px-4 py-2 border-b border-gray-200 bg-white",children:[s.jsxs("h3",{className:"text-lg flex justify-between items-center",children:[s.jsx("span",{children:e}),o&&s.jsx("button",{className:"cursor-pointer hover:bg-(--bg-ter) rounded-full p-1",onClick:o,children:s.jsx(Ze,{width:24,height:24})})]}),s.jsx(on,{containerClassName:"mt-2",className:"text-sm",placeholder:"Filter",value:i,autoFocus:!0,onChange:c=>a(c.target.value)})]}),n,r&&s.jsx("div",{className:"flex justify-center my-2",children:s.jsx("button",{className:"text-blue-800 text-sm p-2 cursor-pointer",onClick:t,children:"Load more"})})]}),ip=new Intl.DateTimeFormat,lp=()=>{const[e,t]=l.useState(""),n=Po(e),{data:o}=we(),{data:r,fetchNextPage:a,hasNextPage:i}=kc(o?.teamId,n,25),c=ee(),u=ma(),h=Jc(),m=l.useRef(null),d=l.useRef(null),g=x=>{r?.find(b=>b.id===x)?.archived&&u.mutate(x),Yt({show:!1}),c(D.workbenchTab.build({id:x}))},f=()=>{m.current?.close(),h.mutate(d.current)};return s.jsxs(di,{hasMore:i,onLoadMore:a,onClose:()=>Yt({show:!1}),searchValue:e,onSearchValue:t,title:"Recent tabs",children:[r?.map(x=>s.jsxs("div",{className:yn.tabContainer,onClick:()=>g(x.id),onContextMenu:v=>{d.current=x.id,m.current?.open(v,!1)},children:[s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("p",{className:yn.tabName,children:x.name}),x.dataSourceType&&s.jsx(ze,{size:16,type:x.dataSourceType}),s.jsx("p",{className:"text-xs text-(--text-color-secondary)",children:x.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:ip.format(new Date(x.updatedAt))}),x.archived?s.jsx("span",{className:yn.archivedBadge,children:"Archived"}):s.jsx("span",{className:yn.activeBadge,children:"Active"})]})]},x.id)),s.jsx(wo,{ref:m,children:s.jsx("button",{onClick:f,className:yn.deleteAction,children:"🗑 Delete"})})]})},cp=()=>{const e=Fu(t=>t.show);return s.jsx(Fn,{isVisible:e,onClose:()=>Yt({show:!1}),backdropClose:!0,children:s.jsx(lp,{})})},up=()=>{const{data:e}=we(),t=Lc(e?.teamId),n=ee();return l.useEffect(()=>{t.mutateAsync().then(o=>{o?n(D.workbenchTab.build({id:o.id}),{replace:!0}):n(D.home.build(),{replace:!0})})},[]),null},dp="_query-entry_1c7h7_2",hp={queryEntry:dp},mp=new Intl.DateTimeFormat,fp=({projectQueries:e,isLoading:t})=>{const n=l.useRef(void 0),o=ee(),r=Oh(),a=Lt(),i=Ph(),c=Ea(),u=d=>{a.isPending||a.mutateAsync({queryId:d}).then(g=>{In({show:!1}),o(D.workbenchTab.build({id:g.id}))})},h=async d=>{const g=e?.find(x=>x.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:[be(e?.length,0)&&e.map(d=>s.jsxs("button",{className:hp.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:mp.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&&po(e?.length,1)&&s.jsx("p",{className:"text-center text-sm text-(--text-color-secondary) mt-2",children:"Empty"}),s.jsx(Ra,{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"})]})})]})},pp=()=>{const{data:e}=we(),[t,n]=l.useState(""),o=Po(t),{data:r,isLoading:a,fetchNextPage:i,hasNextPage:c}=Ec(e?.teamId,o);return s.jsx(di,{hasMore:c,onClose:()=>In({show:!1}),onLoadMore:i,searchValue:t,onSearchValue:n,title:"Saved queries",children:s.jsx(fp,{isLoading:a,projectQueries:r||[]})})},xp=()=>{const e=$u(t=>t.show);return s.jsx(Fn,{isVisible:e,onClose:()=>In({show:!1}),backdropClose:!0,children:s.jsx(pp,{})})};function gp(){return $0(),ep(),s.jsxs(s.Fragment,{children:[s.jsxs(kl,{children:[s.jsx(Vt,{path:D.home.path,element:s.jsx(ed,{})}),s.jsx(Vt,{path:D.workbench.path,element:s.jsx(up,{})}),s.jsx(Vt,{path:D.workbenchTab.path,element:s.jsx(Jf,{})}),s.jsx(Vt,{path:D.login.path,element:s.jsx(J0,{})}),s.jsx(Vt,{path:D.share.path,element:s.jsx(tp,{})})]}),s.jsx(yd,{}),s.jsx(N0,{}),s.jsx(D0,{}),s.jsx(W0,{}),s.jsx(Q0,{}),s.jsx(cp,{}),s.jsx(xp,{}),s.jsx(pd,{}),s.jsx(sd,{})]})}const vp="_hidden_tu6bi_2",bp="_desktop-layout_tu6bi_2",yp="_mobile-layout_tu6bi_2",wp="_nav_tu6bi_2",Cp="_shown_tu6bi_2",jp="_main_tu6bi_2",Np="_header_tu6bi_2",_p="_expand_tu6bi_2",Sp="_show_tu6bi_2",kp="_hide_tu6bi_2",Ep="_icon_tu6bi_2",Rp="_nav-item_tu6bi_2",Lp="_project-wrapper_tu6bi_2",F={hidden:vp,desktopLayout:bp,mobileLayout:yp,nav:wp,shown:Cp,main:jp,header:Np,expand:_p,show:Sp,hide:kp,icon:Ep,navItem:Rp,projectWrapper:Lp},Tp=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"})),Ap=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"})),Ip=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})),Mp=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})),Pp=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})),Op=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})),Ir=!__CLIENT_CONFIG__.skipAuth,Mr=(()=>{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`}})(),Z=20,ke="text-(--text-color-primary)";function Dp(){switch(__CLIENT_CONFIG__.modeName){case"docker":return s.jsx(Tp,{className:ke,width:Z,height:Z});case"cli":return s.jsx(Ap,{className:ke,width:Z,height:Z});default:return s.jsx(ja,{className:ke,width:Z,height:Z})}}const $p=({dataSource:e})=>s.jsxs("button",{className:F.navItem,onClick:()=>jn(e.id),"data-tooltip-id":"default","data-tooltip-content":e.name,"data-tooltip-place":"right",children:[s.jsx("span",{className:F.icon,children:s.jsx(ze,{size:20,type:e.dbType})}),s.jsx("span",{className:"truncate",children:e.name})]}),Fp=()=>{const e=ee(),{pathname:t}=pe(),{data:n}=we(),o=Tn(),[r,a]=l.useState(!1),{data:i}=ys(),{data:c}=Nc(n?.teamId),u=()=>{D.home.check(t)||e(D.home.build())},h=x=>{D.workbenchTab.check(t)||e(D.workbenchTab.build({id:x}))},m=()=>{In({show:!0})},d=()=>{xo("Are you sure you want to logout?").then(x=>{x&&(e("/"),hs.logout())})},g=()=>Yt({show:!0}),f=r?void 0:"default";return s.jsxs("nav",{className:A(F.nav,r?F.shown:F.hidden),children:[n&&s.jsxs("div",{className:F.header,children:[s.jsxs("button",{onClick:u,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"Home",children:[s.jsx("span",{className:F.icon,children:s.jsx(Mp,{className:ke,width:Z,height:Z})}),s.jsx("span",{className:"truncate",children:"Home"})]}),s.jsxs("button",{onClick:o,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"New query",children:[s.jsx("span",{className:F.icon,children:s.jsx(Mn,{className:ke,width:Z,height:Z})}),s.jsx("span",{className:"truncate",children:"New query"}),s.jsx("span",{className:"hotkey secondary",children:"N"})]}),s.jsxs("button",{onClick:g,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"Recent tabs",children:[s.jsx("span",{className:F.icon,children:s.jsx(ba,{className:ke,width:Z,height:Z})}),s.jsx("span",{className:"truncate",children:"Recent tabs"}),s.jsx("span",{className:"hotkey secondary",children:"H"})]}),s.jsxs("button",{onClick:m,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"Saved queries",children:[s.jsx("span",{className:F.icon,children:s.jsx(Cs,{className:ke,width:Z,height:Z})}),s.jsx("span",{className:"truncate",children:"Saved queries"})]}),be(i?.length,0)&&s.jsxs("button",{onClick:()=>h(i[0].id),className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"Workbench",children:[s.jsx("span",{className:F.icon,children:s.jsx(ya,{className:ke,width:Z,height:Z})}),s.jsx("span",{className:"truncate",children:"Workbench"}),s.jsx("span",{className:"hotkey secondary",children:"W"})]}),Ir&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:li,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"User settings",children:[s.jsx("span",{className:F.icon,children:s.jsx(Pp,{className:ke,width:Z,height:Z})}),s.jsx("span",{className:"truncate",children:n.username})]}),s.jsxs("button",{onClick:ui,className:F.navItem,"data-tooltip-id":f,"data-tooltip-content":"Manage users",children:[s.jsx("span",{className:F.icon,children:s.jsx(Op,{className:ke,width:Z,height:Z})}),s.jsx("span",{className:"truncate",children:"Manage users"})]})]})]}),s.jsx("div",{className:A(F.projectWrapper),children:be(c?.length,0)&&s.jsx("div",{className:"mt-4 flex flex-col",children:c.map(x=>s.jsx($p,{dataSource:x},x.id))})}),Ir&&s.jsxs("button",{onClick:d,"data-tooltip-id":f,"data-tooltip-content":"Logout",className:`${F.navItem} mx-1`,children:[s.jsx("span",{className:F.icon,children:s.jsx(Ip,{className:ke,width:20,height:20})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:"Logout"})]}),s.jsxs("div",{className:`${F.navItem} mx-1 cursor-auto!`,"data-tooltip-id":f,"data-tooltip-content":Mr,children:[s.jsx("span",{className:F.icon,children:s.jsx(Dp,{})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:Mr})]}),s.jsxs("button",{onClick:()=>a(!r),"data-tooltip-id":"default","data-tooltip-content":"Expand sidebar","data-tooltip-hidden":r,"data-tooltip-place":"right",className:`${F.navItem} mx-1`,children:[s.jsx("span",{className:A(F.icon,F.expand,r?F.show:F.hide),children:s.jsx(Sn,{className:ke,width:20,height:20})}),s.jsx("span",{className:"truncate text-sm text-(--text-color-primary)",children:"Collapse menu"})]})]})},Bp="_root_gx008_2",Wp={root:Bp},hi=!__CLIENT_CONFIG__.skipAuth,qp=`${Wp.root} ${hi?"grid-cols-4":"grid-cols-2"}`,Up=()=>{const{pathname:e}=pe(),t=ee(),n=Tn(),o=()=>{D.home.check(e)||t(D.home.build())};return s.jsxs("div",{className:qp,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"})]}),hi&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:li,children:[s.jsx("p",{children:"🪪"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Account"})]}),s.jsxs("button",{onClick:ui,children:[s.jsx("p",{children:"👥"}),s.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Users"})]})]})]})},Hp=(e,t,n)=>ye({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}),zp=()=>ne({mutationFn:async e=>{const{data:t}=await B.post(`/runner/${e.datasourceId}/update`,e);return t.data}}),Vp=()=>ne({mutationFn:async e=>{const{data:t}=await B.post(`/runner/${e.datasourceId}/insert`,e);return t.data}}),Kp="_root_1ld5s_2",Qp="_container_1ld5s_2",Gp="_header_1ld5s_2",Yp="_fields-container_1ld5s_2",Jp="_field-label_1ld5s_2",Xp="_changed-marker_1ld5s_2",Zp="_action-icon_1ld5s_2",Ge={root:Kp,container:Qp,header:Gp,fieldsContainer:Yp,fieldLabel:Jp,changedMarker:Xp,actionIcon:Zp},e1=e=>{if(e==null)return"<NULL>";if(e==="")return"<EMPTY STRING>"},t1=e=>e.isPrimary?"🔐 "+e.name:e.ref?"🔑 "+e.name:e.name,mi=({data:e})=>{const t=jh(S=>S.history),[n,{set:o,reset:r,touched:a,untouch:i}]=kn({}),c=Ao(),u=ee(),[h,m]=l.useState(0),[d,g]=l.useState(""),{data:f,isLoading:x,refetch:v}=Hp(e.dataSourceId,e.tableName,e.entityId),{mutateAsync:b,error:w,isPending:p}=zp(),y=Lt(),C=vo(w),N=An(me.EDITOR),{data:I}=gs(e.dataSourceId),{data:_}=xs(e.dataSourceId),M=l.useMemo(()=>I?.find(S=>S.tableName===e.tableName),[e.tableName,I]),k=l.useMemo(()=>{if(!M)return[];if(!d)return M.columns;const S=d.toLowerCase();return M.columns.filter(P=>P.name.toLowerCase().includes(S))},[d,M]),O=l.useMemo(()=>{const S={};if(!f?.entity)return S;for(let P=0;P<f.columns.length;P++)S[f.columns[P]?.column]=e1(f.entity[P]);return S},[f]);l.useEffect(()=>{const S=f?.entity;if(r(),S&&f?.columns)for(let P=0;P<f.columns.length;P++){const H=f.columns[P];o(H.column,{value:Nt(S[P]),mode:"default"})}},[f,o,r,h]);const te=()=>{const S={};for(const P of a)S[P]=n[P];b({datasourceId:e.dataSourceId,table:e.tableName,filters:e.entityId.map(P=>({id:et(),value:""+P[1],column:P[0],isEnabled:!0})),values:S}).then(()=>{i(),fe.success("Record successfully updated."),v(),c&&pa(c)})},ae=(S,P,H)=>{y.isPending||y.mutateAsync({name:`${S} ${P} = ${H}`,opts:kt({dataSourceId:e.dataSourceId,table:S,filters:[{value:`${H}`,column:`${S}.${P}`,id:et(),isEnabled:!0}]})}).then(({id:z})=>{u(D.workbenchTab.build({id:z}))})},Ne=S=>{const P=t.find(H=>H.key===S);P&&No(P,!1)},W=!_?.allowUpdate||!N||p;return s.jsxs("div",{className:Ge.root,children:[s.jsxs("div",{className:Ge.header,children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("select",{className:"input rounded-md! w-full",value:e?.key,onChange:S=>Ne(S.currentTarget.value),children:t.map(S=>s.jsxs("option",{value:S.key,children:[S.tableName," - ",S.entityId.map(P=>`${P[0]} = ${P[1]}`)]},S.key))}),!W&&a.length>0&&s.jsx("button",{"data-tooltip-id":"default","data-tooltip-content":"Reset values",className:Ge.actionIcon,onClick:()=>m(S=>++S),children:s.jsx(To,{width:16,height:16})}),!W&&s.jsx("button",{"data-tooltip-id":"default","data-tooltip-content":"Commit changes",disabled:!a.length,onClick:te,className:Ge.actionIcon,children:s.jsx(Cs,{width:16,height:16})}),s.jsx("button",{className:Ge.actionIcon,onClick:Oa,children:s.jsx(Ze,{width:20,height:20})})]}),C&&s.jsx(ge,{variant:"danger",children:s.jsx("p",{children:C})}),s.jsx(on,{containerClassName:"mt-2",className:"text-sm",value:d,onChange:S=>g(S.target.value),placeholder:"Filter columns"})]}),s.jsx("div",{className:Ge.container,children:s.jsx("div",{className:Ge.fieldsContainer,children:k.map(S=>s.jsxs("label",{className:Ge.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsxs("p",{children:[a.includes(S.name)&&s.jsx("span",{className:Ge.changedMarker}),t1(S)]}),s.jsx("p",{className:"text-blue-800 text-xs",children:S.type})]}),s.jsxs("div",{className:"flex items-center",children:[s.jsx(Ns,{prefix:"=",allowedModes:_s,disabled:S.isPrimary||x||W,value:Nt(n[S.name]?.value),mode:n[S.name]?.mode,onExpressionChange:P=>o(S.name,P,!0),placeholder:O[S.name]}),S.ref&&s.jsx("button",{className:"cursor-pointer pl-2",onClick:()=>ae(S.ref.table,S.ref.field,n[S.name]?.value),children:s.jsx(oo,{width:16,height:16})}),S.isPrimary&&s.jsx("button",{className:"cursor-pointer pl-2",onClick:()=>ae(e.tableName,S.name,n[S.name]?.value),children:s.jsx(oo,{width:16,height:16})})]})]},S.name))})})]})},n1=()=>{const e=Pa();return e?s.jsx(mi,{data:e}):null},s1=()=>{const e=Pa(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(Fn,{backdropClose:!0,isVisible:!!e,onClose:Oa,onClosed:()=>n(void 0),children:t&&s.jsx(mi,{data:t})})},o1="_root_11g25_2",r1="_container_11g25_2",a1="_header_11g25_2",i1="_fields-container_11g25_2",l1="_field-label_11g25_2",c1="_icon-action_11g25_2",wt={root:o1,container:r1,header:a1,fieldsContainer:i1,fieldLabel:l1,iconAction:c1},u1=e=>e.isPrimary?"🔐 "+e.name:e.ref?"🔑 "+e.name:e.name,fi=({data:e})=>{const[t,{set:n,touched:o}]=kn({}),r=Ao(),{mutateAsync:a,error:i,isPending:c}=Vp(),u=vo(i),{data:h}=gs(e.dataSourceId),[m,d]=l.useState(""),g=l.useMemo(()=>h?.find(v=>v.tableName===e.table),[h,e.table]),f=l.useMemo(()=>{if(!g)return[];if(!m)return g.columns;const v=m.toLowerCase();return g.columns.filter(b=>b.name.toLowerCase().includes(v))},[m,g]),x=()=>{const v={};for(const b of o)v[b]=t[b];a({datasourceId:e.dataSourceId,table:e.table,values:v}).then(()=>{fe.success("Record successfully created."),r&&pa(r)})};return s.jsxs("div",{className:wt.root,children:[s.jsxs("div",{className:wt.header,children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("p",{className:"text-lg flex-1 font-semibold underline",children:["New ",e.table]}),s.jsx("button",{"data-tooltip-id":"default","data-tooltip-content":"Commit changes",disabled:!o.length||c,className:wt.iconAction,onClick:x,children:s.jsx(Cs,{width:16,height:16})}),s.jsx("button",{className:wt.iconAction,onClick:Ia,children:s.jsx(Ze,{width:20,height:20})})]}),u&&s.jsx(ge,{variant:"danger",children:s.jsx("p",{children:u})}),s.jsx(on,{containerClassName:"mt-2",className:"text-sm",value:m,onChange:v=>d(v.target.value),placeholder:"Filter columns"})]}),s.jsx("div",{className:wt.container,children:s.jsx("div",{className:wt.fieldsContainer,children:f.map(v=>s.jsxs("label",{className:wt.fieldLabel,children:[s.jsxs("div",{className:"flex justify-between mb-0.5",children:[s.jsx("p",{children:u1(v)}),s.jsx("p",{className:"text-blue-800 text-xs",children:v.type})]}),s.jsx(Ns,{disabled:c,prefix:"=",allowedModes:_s,mode:t[v.name]?.mode,value:Nt(t[v.name]?.value),onExpressionChange:b=>n(v.name,b,!0)})]},v.name))})})]})},d1=()=>{const e=Aa();return e?s.jsx(fi,{data:e}):null},h1=()=>{const e=Aa(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),s.jsx(Fn,{backdropClose:!0,isVisible:!!e,onClose:Ia,onClosed:()=>n(void 0),children:t&&s.jsx(fi,{data:t})})},m1=({children:e,isLogin:t})=>s.jsxs("div",{className:F.desktopLayout,children:[s.jsx(_n,{id:"default",className:"z-500"}),s.jsx(_n,{id:"default-xs",className:"z-500 text-xs!"}),!t&&s.jsx(Fp,{}),s.jsx("main",{className:F.main,children:e}),s.jsx(n1,{}),s.jsx(d1,{})]}),f1=({children:e,isLogin:t})=>s.jsxs("div",{className:F.mobileLayout,children:[s.jsx("main",{className:F.main,children:e}),s.jsx(s1,{}),s.jsx(h1,{}),!t&&s.jsx(Up,{})]}),p1=({children:e})=>{const t=_a(go.laptop),{pathname:n}=pe(),o=D.login.check(n);return t?s.jsx(m1,{isLogin:o,children:e}):s.jsx(f1,{isLogin:o,children:e})};Ei.createRoot(document.getElementById("root")).render(s.jsxs(at.StrictMode,{children:[s.jsx(Ri,{}),s.jsx(mc,{client:J,children:s.jsx(Xl,{children:s.jsx(p1,{children:s.jsx(gp,{})})})})]}));
|