@dataramen/cli 0.0.69 → 0.0.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/app.js +1 -1
- package/dist/code/cli.js +1 -1
- package/dist/code/server.js +8 -8
- package/dist/code/web/assets/index-CuM5yTKj.css +1 -0
- package/dist/code/web/assets/index-VGcygI3P.js +190 -0
- package/dist/code/web/assets/main-CKMVXs0c.js +4 -0
- package/dist/code/web/assets/main-D6h5BZfN.css +1 -0
- package/dist/code/web/assets/{setup-CbifUuH4.js → setup-XBuZP5zl.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 +3 -2
- package/dist/code/web/assets/index-D_yzt1XG.css +0 -1
- package/dist/code/web/assets/index-g8K5wnQd.js +0 -190
- package/dist/code/web/assets/main-BbebNQDt.js +0 -4
- package/dist/code/web/assets/main-DQXEBF5j.css +0 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{r as l,a as qa,S as ao,p as br,b as ke,s as Zn,c as vn,n as es,i as Is,d as vr,t as Ua,e as Wn,f as Wa,g as Ha,h as yr,j as as,k as wr,l as za,m as Ka,o as Cr,q as Va,u as r,v as Hs,w as Q,x as O,A as zs,y as Qa,z as Ga,B as A,C as jn,D as ne,E as je,F as Ya,G as Ja,R as et,H as Xa,I as Za}from"./index-VGcygI3P.js";var jr="popstate";function ei(e={}){function t(s,o){let{pathname:a,search:i,hash:c}=s.location;return Os("",{pathname:a,search:i,hash:c},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function n(s,o){return typeof o=="string"?o:wn(o)}return ni(t,n,null,e)}function K(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ne(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 Nr(e,t){return{usr:e.state,key:e.key,idx:t}}function Os(e,t,n=null,s){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Yt(t):t,state:n,key:t&&t.key||s||ti()}}function wn({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Yt(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let s=e.indexOf("?");s>=0&&(t.search=e.substring(s),e=e.substring(0,s)),e&&(t.pathname=e)}return t}function ni(e,t,n,s={}){let{window:o=document.defaultView,v5Compat:a=!1}=s,i=o.history,c="POP",u=null,d=m();d==null&&(d=0,i.replaceState({...i.state,idx:d},""));function m(){return(i.state||{idx:null}).idx}function h(){c="POP";let v=m(),y=v==null?null:v-d;d=v,u&&u({action:c,location:g.location,delta:y})}function p(v,y){c="PUSH";let f=Os(g.location,v,y);d=m()+1;let w=Nr(f,d),C=g.createHref(f);try{i.pushState(w,"",C)}catch(_){if(_ instanceof DOMException&&_.name==="DataCloneError")throw _;o.location.assign(C)}a&&u&&u({action:c,location:g.location,delta:1})}function x(v,y){c="REPLACE";let f=Os(g.location,v,y);d=m();let w=Nr(f,d),C=g.createHref(f);i.replaceState(w,"",C),a&&u&&u({action:c,location:g.location,delta:0})}function b(v){return si(v)}let g={get action(){return c},get location(){return e(o,i)},listen(v){if(u)throw new Error("A history only accepts one active listener");return o.addEventListener(jr,h),u=v,()=>{o.removeEventListener(jr,h),u=null}},createHref(v){return t(o,v)},createURL:b,encodeLocation(v){let y=b(v);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:p,replace:x,go(v){return i.go(v)}};return g}function si(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),K(n,"No window.location.(origin|href) available to create URL");let s=typeof e=="string"?e:wn(e);return s=s.replace(/ $/,"%20"),!t&&s.startsWith("//")&&(s=n+s),new URL(s,n)}function io(e,t,n="/"){return ri(e,t,n,!1)}function ri(e,t,n,s){let o=typeof t=="string"?Yt(t):t,a=Ye(o.pathname||"/",n);if(a==null)return null;let i=lo(e);oi(i);let c=null;for(let u=0;c==null&&u<i.length;++u){let d=xi(a);c=fi(i[u],d,s)}return c}function lo(e,t=[],n=[],s="",o=!1){let a=(i,c,u=o,d)=>{let m={relativePath:d===void 0?i.path||"":d,caseSensitive:i.caseSensitive===!0,childrenIndex:c,route:i};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(s)&&u)return;K(m.relativePath.startsWith(s),`Absolute route path "${m.relativePath}" nested under path "${s}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),m.relativePath=m.relativePath.slice(s.length)}let h=Ve([s,m.relativePath]),p=n.concat(m);i.children&&i.children.length>0&&(K(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),lo(i.children,t,p,h,u)),!(i.path==null&&!i.index)&&t.push({path:h,score:hi(h,i.index),routesMeta:p})};return e.forEach((i,c)=>{if(i.path===""||!i.path?.includes("?"))a(i,c);else for(let u of co(i.path))a(i,c,!0,u)}),t}function co(e){let t=e.split("/");if(t.length===0)return[];let[n,...s]=t,o=n.endsWith("?"),a=n.replace(/\?$/,"");if(s.length===0)return o?[a,""]:[a];let i=co(s.join("/")),c=[];return c.push(...i.map(u=>u===""?a:[a,u].join("/"))),o&&c.push(...i),c.map(u=>e.startsWith("/")&&u===""?"/":u)}function oi(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:mi(t.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}var ai=/^:[\w-]+$/,ii=3,li=2,ci=1,ui=10,di=-2,_r=e=>e==="*";function hi(e,t){let n=e.split("/"),s=n.length;return n.some(_r)&&(s+=di),t&&(s+=li),n.filter(o=>!_r(o)).reduce((o,a)=>o+(ai.test(a)?ii:a===""?ci:ui),s)}function mi(e,t){return e.length===t.length&&e.slice(0,-1).every((s,o)=>s===t[o])?e[e.length-1]-t[t.length-1]:0}function fi(e,t,n=!1){let{routesMeta:s}=e,o={},a="/",i=[];for(let c=0;c<s.length;++c){let u=s[c],d=c===s.length-1,m=a==="/"?t:t.slice(a.length)||"/",h=zt({path:u.relativePath,caseSensitive:u.caseSensitive,end:d},m),p=u.route;if(!h&&d&&n&&!s[s.length-1].route.index&&(h=zt({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},m)),!h)return null;Object.assign(o,h.params),i.push({params:o,pathname:Ve([a,h.pathname]),pathnameBase:yi(Ve([a,h.pathnameBase])),route:p}),h.pathnameBase!=="/"&&(a=Ve([a,h.pathnameBase]))}return i}function zt(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,s]=pi(e.path,e.caseSensitive,e.end),o=t.match(n);if(!o)return null;let a=o[0],i=a.replace(/(.)\/+$/,"$1"),c=o.slice(1);return{params:s.reduce((d,{paramName:m,isOptional:h},p)=>{if(m==="*"){let b=c[p]||"";i=a.slice(0,a.length-b.length).replace(/(.)\/+$/,"$1")}const x=c[p];return h&&!x?d[m]=void 0:d[m]=(x||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:i,pattern:e}}function pi(e,t=!1,n=!0){Ne(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 s=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,c,u)=>(s.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(s.push({paramName:"*"}),o+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?o+="\\/*$":e!==""&&e!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,t?void 0:"i"),s]}function xi(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Ne(!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 Ye(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,s=e.charAt(n);return s&&s!=="/"?null:e.slice(n)||"/"}var uo=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,gi=e=>uo.test(e);function bi(e,t="/"){let{pathname:n,search:s="",hash:o=""}=typeof e=="string"?Yt(e):e,a;if(n)if(gi(n))a=n;else{if(n.includes("//")){let i=n;n=n.replace(/\/\/+/g,"/"),Ne(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${n}`)}n.startsWith("/")?a=Sr(n.substring(1),"/"):a=Sr(n,t)}else a=t;return{pathname:a,search:wi(s),hash:Ci(o)}}function Sr(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(o=>{o===".."?n.length>1&&n.pop():o!=="."&&n.push(o)}),n.length>1?n.join("/"):"/"}function ws(e,t,n,s){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(s)}]. 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 vi(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function ho(e){let t=vi(e);return t.map((n,s)=>s===t.length-1?n.pathname:n.pathnameBase)}function mo(e,t,n,s=!1){let o;typeof e=="string"?o=Yt(e):(o={...e},K(!o.pathname||!o.pathname.includes("?"),ws("?","pathname","search",o)),K(!o.pathname||!o.pathname.includes("#"),ws("#","pathname","hash",o)),K(!o.search||!o.search.includes("#"),ws("#","search","hash",o)));let a=e===""||o.pathname==="",i=a?"/":o.pathname,c;if(i==null)c=n;else{let h=t.length-1;if(!s&&i.startsWith("..")){let p=i.split("/");for(;p[0]==="..";)p.shift(),h-=1;o.pathname=p.join("/")}c=h>=0?t[h]:"/"}let u=bi(o,c),d=i&&i!=="/"&&i.endsWith("/"),m=(a||i===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(d||m)&&(u.pathname+="/"),u}var Ve=e=>e.join("/").replace(/\/\/+/g,"/"),yi=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),wi=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Ci=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,ji=class{constructor(e,t,n,s=!1){this.status=e,this.statusText=t||"",this.internal=s,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Ni(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function _i(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var fo=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function po(e,t){let n=e;if(typeof n!="string"||!uo.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let s=n,o=!1;if(fo)try{let a=new URL(window.location.href),i=n.startsWith("//")?new URL(a.protocol+n):new URL(n),c=Ye(i.pathname,t);i.origin===a.origin&&c!=null?n=c+i.search+i.hash:o=!0}catch{Ne(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:s,isExternal:o,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var xo=["POST","PUT","PATCH","DELETE"];new Set(xo);var Si=["GET",...xo];new Set(Si);var Jt=l.createContext(null);Jt.displayName="DataRouter";var is=l.createContext(null);is.displayName="DataRouterState";var Ei=l.createContext(!1),go=l.createContext({isTransitioning:!1});go.displayName="ViewTransition";var ki=l.createContext(new Map);ki.displayName="Fetchers";var Ri=l.createContext(null);Ri.displayName="Await";var _e=l.createContext(null);_e.displayName="Navigation";var Nn=l.createContext(null);Nn.displayName="Location";var Be=l.createContext({outlet:null,matches:[],isDataRoute:!1});Be.displayName="Route";var Ks=l.createContext(null);Ks.displayName="RouteError";var bo="REACT_ROUTER_ERROR",Ti="REDIRECT",Li="ROUTE_ERROR_RESPONSE";function Ai(e){if(e.startsWith(`${bo}:${Ti}:{`))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 Pi(e){if(e.startsWith(`${bo}:${Li}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new ji(t.status,t.statusText,t.data)}catch{}}function Ii(e,{relative:t}={}){K(_n(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:s}=l.useContext(_e),{hash:o,pathname:a,search:i}=Sn(e,{relative:t}),c=a;return n!=="/"&&(c=a==="/"?n:Ve([n,a])),s.createHref({pathname:c,search:i,hash:o})}function _n(){return l.useContext(Nn)!=null}function le(){return K(_n(),"useLocation() may be used only in the context of a <Router> component."),l.useContext(Nn).location}var vo="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function yo(e){l.useContext(_e).static||l.useLayoutEffect(e)}function Y(){let{isDataRoute:e}=l.useContext(Be);return e?Qi():Oi()}function Oi(){K(_n(),"useNavigate() may be used only in the context of a <Router> component.");let e=l.useContext(Jt),{basename:t,navigator:n}=l.useContext(_e),{matches:s}=l.useContext(Be),{pathname:o}=le(),a=JSON.stringify(ho(s)),i=l.useRef(!1);return yo(()=>{i.current=!0}),l.useCallback((u,d={})=>{if(Ne(i.current,vo),!i.current)return;if(typeof u=="number"){n.go(u);return}let m=mo(u,JSON.parse(a),o,d.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Ve([t,m.pathname])),(d.replace?n.replace:n.push)(m,d.state,d)},[t,n,a,o,e])}l.createContext(null);function Mi(){let{matches:e}=l.useContext(Be),t=e[e.length-1];return t?t.params:{}}function Sn(e,{relative:t}={}){let{matches:n}=l.useContext(Be),{pathname:s}=le(),o=JSON.stringify(ho(n));return l.useMemo(()=>mo(e,JSON.parse(o),s,t==="path"),[e,o,s,t])}function $i(e,t){return wo(e,t)}function wo(e,t,n,s,o){K(_n(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=l.useContext(_e),{matches:i}=l.useContext(Be),c=i[i.length-1],u=c?c.params:{},d=c?c.pathname:"/",m=c?c.pathnameBase:"/",h=c&&c.route;{let f=h&&h.path||"";jo(d,!h||f.endsWith("*")||f.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${d}" (under <Route path="${f}">) 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="${f}"> to <Route path="${f==="/"?"*":`${f}/*`}">.`)}let p=le(),x;if(t){let f=typeof t=="string"?Yt(t):t;K(m==="/"||f.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 "${f.pathname}" was given in the \`location\` prop.`),x=f}else x=p;let b=x.pathname||"/",g=b;if(m!=="/"){let f=m.replace(/^\//,"").split("/");g="/"+b.replace(/^\//,"").split("/").slice(f.length).join("/")}let v=io(e,{pathname:g});Ne(h||v!=null,`No routes matched location "${x.pathname}${x.search}${x.hash}" `),Ne(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${x.pathname}${x.search}${x.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let y=Ui(v&&v.map(f=>Object.assign({},f,{params:Object.assign({},u,f.params),pathname:Ve([m,a.encodeLocation?a.encodeLocation(f.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:f.pathname]),pathnameBase:f.pathnameBase==="/"?m:Ve([m,a.encodeLocation?a.encodeLocation(f.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:f.pathnameBase])})),i,n,s,o);return t&&y?l.createElement(Nn.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...x},navigationType:"POP"}},y):y}function Di(){let e=Vi(),t=Ni(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:s},a={padding:"2px 4px",backgroundColor:s},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=l.createElement(l.Fragment,null,l.createElement("p",null,"💿 Hey developer 👋"),l.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",l.createElement("code",{style:a},"ErrorBoundary")," or"," ",l.createElement("code",{style:a},"errorElement")," prop on your route.")),l.createElement(l.Fragment,null,l.createElement("h2",null,"Unexpected Application Error!"),l.createElement("h3",{style:{fontStyle:"italic"}},t),n?l.createElement("pre",{style:o},n):null,i)}var Fi=l.createElement(Di,null),Co=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=Pi(e.digest);n&&(e=n)}let t=e!==void 0?l.createElement(Be.Provider,{value:this.props.routeContext},l.createElement(Ks.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?l.createElement(Bi,{error:e},t):t}};Co.contextType=Ei;var Cs=new WeakMap;function Bi({children:e,error:t}){let{basename:n}=l.useContext(_e);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let s=Ai(t.digest);if(s){let o=Cs.get(t);if(o)throw o;let a=po(s.location,n);if(fo&&!Cs.get(t))if(a.isExternal||s.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:s.replace}));throw Cs.set(t,i),i}return l.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return e}function qi({routeContext:e,match:t,children:n}){let s=l.useContext(Jt);return s&&s.static&&s.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=t.route.id),l.createElement(Be.Provider,{value:e},n)}function Ui(e,t=[],n=null,s=null,o=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(h=>h.route.id&&i?.[h.route.id]!==void 0);K(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 h=a[m];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(u=m),h.route.id){let{loaderData:p,errors:x}=n,b=h.route.loader&&!p.hasOwnProperty(h.route.id)&&(!x||x[h.route.id]===void 0);if(h.route.lazy||b){c=!0,u>=0?a=a.slice(0,u+1):a=[a[0]];break}}}let d=n&&s?(m,h)=>{s(m,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:_i(n.matches),errorInfo:h})}:void 0;return a.reduceRight((m,h,p)=>{let x,b=!1,g=null,v=null;n&&(x=i&&h.route.id?i[h.route.id]:void 0,g=h.route.errorElement||Fi,c&&(u<0&&p===0?(jo("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),b=!0,v=null):u===p&&(b=!0,v=h.route.hydrateFallbackElement||null)));let y=t.concat(a.slice(0,p+1)),f=()=>{let w;return x?w=g:b?w=v:h.route.Component?w=l.createElement(h.route.Component,null):h.route.element?w=h.route.element:w=m,l.createElement(qi,{match:h,routeContext:{outlet:m,matches:y,isDataRoute:n!=null},children:w})};return n&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?l.createElement(Co,{location:n.location,revalidation:n.revalidation,component:g,error:x,children:f(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:d}):f()},null)}function Vs(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Wi(e){let t=l.useContext(Jt);return K(t,Vs(e)),t}function Hi(e){let t=l.useContext(is);return K(t,Vs(e)),t}function zi(e){let t=l.useContext(Be);return K(t,Vs(e)),t}function Qs(e){let t=zi(e),n=t.matches[t.matches.length-1];return K(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Ki(){return Qs("useRouteId")}function Vi(){let e=l.useContext(Ks),t=Hi("useRouteError"),n=Qs("useRouteError");return e!==void 0?e:t.errors?.[n]}function Qi(){let{router:e}=Wi("useNavigate"),t=Qs("useNavigate"),n=l.useRef(!1);return yo(()=>{n.current=!0}),l.useCallback(async(o,a={})=>{Ne(n.current,vo),n.current&&(typeof o=="number"?await e.navigate(o):await e.navigate(o,{fromRouteId:t,...a}))},[e,t])}var Er={};function jo(e,t,n){!t&&!Er[e]&&(Er[e]=!0,Ne(!1,n))}l.memo(Gi);function Gi({routes:e,future:t,state:n,onError:s}){return wo(e,void 0,n,s,t)}function vt(e){K(!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 Yi({basename:e="/",children:t=null,location:n,navigationType:s="POP",navigator:o,static:a=!1,unstable_useTransitions:i}){K(!_n(),"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:o,static:a,unstable_useTransitions:i,future:{}}),[c,o,a,i]);typeof n=="string"&&(n=Yt(n));let{pathname:d="/",search:m="",hash:h="",state:p=null,key:x="default"}=n,b=l.useMemo(()=>{let g=Ye(d,c);return g==null?null:{location:{pathname:g,search:m,hash:h,state:p,key:x},navigationType:s}},[c,d,m,h,p,x,s]);return Ne(b!=null,`<Router basename="${c}"> is not able to match the URL "${d}${m}${h}" because it does not start with the basename, so the <Router> won't render anything.`),b==null?null:l.createElement(_e.Provider,{value:u},l.createElement(Nn.Provider,{children:t,value:b}))}function Ji({children:e,location:t}){return $i(Ms(e),t)}function Ms(e,t=[]){let n=[];return l.Children.forEach(e,(s,o)=>{if(!l.isValidElement(s))return;let a=[...t,o];if(s.type===l.Fragment){n.push.apply(n,Ms(s.props.children,a));return}K(s.type===vt,`[${typeof s.type=="string"?s.type:s.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),K(!s.props.index||!s.props.children,"An index route cannot have child routes.");let i={id:s.props.id||a.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,middleware:s.props.middleware,loader:s.props.loader,action:s.props.action,hydrateFallbackElement:s.props.hydrateFallbackElement,HydrateFallback:s.props.HydrateFallback,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.hasErrorBoundary===!0||s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(i.children=Ms(s.props.children,a)),n.push(i)}),n}var Qn="get",Gn="application/x-www-form-urlencoded";function ls(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Xi(e){return ls(e)&&e.tagName.toLowerCase()==="button"}function Zi(e){return ls(e)&&e.tagName.toLowerCase()==="form"}function el(e){return ls(e)&&e.tagName.toLowerCase()==="input"}function tl(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function nl(e,t){return e.button===0&&(!t||t==="_self")&&!tl(e)}function $s(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let s=e[n];return t.concat(Array.isArray(s)?s.map(o=>[n,o]):[[n,s]])},[]))}function sl(e,t){let n=$s(e);return t&&t.forEach((s,o)=>{n.has(o)||t.getAll(o).forEach(a=>{n.append(o,a)})}),n}var Hn=null;function rl(){if(Hn===null)try{new FormData(document.createElement("form"),0),Hn=!1}catch{Hn=!0}return Hn}var ol=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function js(e){return e!=null&&!ol.has(e)?(Ne(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Gn}"`),null):e}function al(e,t){let n,s,o,a,i;if(Zi(e)){let c=e.getAttribute("action");s=c?Ye(c,t):null,n=e.getAttribute("method")||Qn,o=js(e.getAttribute("enctype"))||Gn,a=new FormData(e)}else if(Xi(e)||el(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(s=u?Ye(u,t):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||Qn,o=js(e.getAttribute("formenctype"))||js(c.getAttribute("enctype"))||Gn,a=new FormData(c,e),!rl()){let{name:d,type:m,value:h}=e;if(m==="image"){let p=d?`${d}.`:"";a.append(`${p}x`,"0"),a.append(`${p}y`,"0")}else d&&a.append(d,h)}}else{if(ls(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Qn,s=null,o=Gn,i=e}return a&&o==="text/plain"&&(i=a,a=void 0),{action:s,method:n.toLowerCase(),encType:o,formData:a,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Gs(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function il(e,t,n,s){let o=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?o.pathname.endsWith("/")?o.pathname=`${o.pathname}_.${s}`:o.pathname=`${o.pathname}.${s}`:o.pathname==="/"?o.pathname=`_root.${s}`:t&&Ye(o.pathname,t)==="/"?o.pathname=`${t.replace(/\/$/,"")}/_root.${s}`:o.pathname=`${o.pathname.replace(/\/$/,"")}.${s}`,o}async function ll(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function cl(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 ul(e,t,n){let s=await Promise.all(e.map(async o=>{let a=t.routes[o.route.id];if(a){let i=await ll(a,n);return i.links?i.links():[]}return[]}));return fl(s.flat(1).filter(cl).filter(o=>o.rel==="stylesheet"||o.rel==="preload").map(o=>o.rel==="stylesheet"?{...o,rel:"prefetch",as:"style"}:{...o,rel:"prefetch"}))}function kr(e,t,n,s,o,a){let i=(u,d)=>n[d]?u.route.id!==n[d].route.id:!0,c=(u,d)=>n[d].pathname!==u.pathname||n[d].route.path?.endsWith("*")&&n[d].params["*"]!==u.params["*"];return a==="assets"?t.filter((u,d)=>i(u,d)||c(u,d)):a==="data"?t.filter((u,d)=>{let m=s.routes[u.route.id];if(!m||!m.hasLoader)return!1;if(i(u,d)||c(u,d))return!0;if(u.route.shouldRevalidate){let h=u.route.shouldRevalidate({currentUrl:new URL(o.pathname+o.search+o.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:u.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function dl(e,t,{includeHydrateFallback:n}={}){return hl(e.map(s=>{let o=t.routes[s.route.id];if(!o)return[];let a=[o.module];return o.clientActionModule&&(a=a.concat(o.clientActionModule)),o.clientLoaderModule&&(a=a.concat(o.clientLoaderModule)),n&&o.hydrateFallbackModule&&(a=a.concat(o.hydrateFallbackModule)),o.imports&&(a=a.concat(o.imports)),a}).flat(1))}function hl(e){return[...new Set(e)]}function ml(e){let t={},n=Object.keys(e).sort();for(let s of n)t[s]=e[s];return t}function fl(e,t){let n=new Set;return new Set(t),e.reduce((s,o)=>{let a=JSON.stringify(ml(o));return n.has(a)||(n.add(a),s.push({key:a,link:o})),s},[])}function No(){let e=l.useContext(Jt);return Gs(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function pl(){let e=l.useContext(is);return Gs(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var Ys=l.createContext(void 0);Ys.displayName="FrameworkContext";function _o(){let e=l.useContext(Ys);return Gs(e,"You must render this element inside a <HydratedRouter> element"),e}function xl(e,t){let n=l.useContext(Ys),[s,o]=l.useState(!1),[a,i]=l.useState(!1),{onFocus:c,onBlur:u,onMouseEnter:d,onMouseLeave:m,onTouchStart:h}=t,p=l.useRef(null);l.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let g=y=>{y.forEach(f=>{i(f.isIntersecting)})},v=new IntersectionObserver(g,{threshold:.5});return p.current&&v.observe(p.current),()=>{v.disconnect()}}},[e]),l.useEffect(()=>{if(s){let g=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(g)}}},[s]);let x=()=>{o(!0)},b=()=>{o(!1),i(!1)};return n?e!=="intent"?[a,p,{}]:[a,p,{onFocus:pn(c,x),onBlur:pn(u,b),onMouseEnter:pn(d,x),onMouseLeave:pn(m,b),onTouchStart:pn(h,x)}]:[!1,p,{}]}function pn(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function gl({page:e,...t}){let{router:n}=No(),s=l.useMemo(()=>io(n.routes,e,n.basename),[n.routes,e,n.basename]);return s?l.createElement(vl,{page:e,matches:s,...t}):null}function bl(e){let{manifest:t,routeModules:n}=_o(),[s,o]=l.useState([]);return l.useEffect(()=>{let a=!1;return ul(e,t,n).then(i=>{a||o(i)}),()=>{a=!0}},[e,t,n]),s}function vl({page:e,matches:t,...n}){let s=le(),{future:o,manifest:a,routeModules:i}=_o(),{basename:c}=No(),{loaderData:u,matches:d}=pl(),m=l.useMemo(()=>kr(e,t,d,a,s,"data"),[e,t,d,a,s]),h=l.useMemo(()=>kr(e,t,d,a,s,"assets"),[e,t,d,a,s]),p=l.useMemo(()=>{if(e===s.pathname+s.search+s.hash)return[];let g=new Set,v=!1;if(t.forEach(f=>{let w=a.routes[f.route.id];!w||!w.hasLoader||(!m.some(C=>C.route.id===f.route.id)&&f.route.id in u&&i[f.route.id]?.shouldRevalidate||w.hasClientLoader?v=!0:g.add(f.route.id))}),g.size===0)return[];let y=il(e,c,o.unstable_trailingSlashAwareDataRequests,"data");return v&&g.size>0&&y.searchParams.set("_routes",t.filter(f=>g.has(f.route.id)).map(f=>f.route.id).join(",")),[y.pathname+y.search]},[c,o.unstable_trailingSlashAwareDataRequests,u,s,a,m,t,e,i]),x=l.useMemo(()=>dl(h,a),[h,a]),b=bl(h);return l.createElement(l.Fragment,null,p.map(g=>l.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...n})),x.map(g=>l.createElement("link",{key:g,rel:"modulepreload",href:g,...n})),b.map(({key:g,link:v})=>l.createElement("link",{key:g,nonce:n.nonce,...v})))}function yl(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var wl=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{wl&&(window.__reactRouterVersion="7.12.0")}catch{}function Cl({basename:e,children:t,unstable_useTransitions:n,window:s}){let o=l.useRef();o.current==null&&(o.current=ei({window:s,v5Compat:!0}));let a=o.current,[i,c]=l.useState({action:a.action,location:a.location}),u=l.useCallback(d=>{n===!1?c(d):l.startTransition(()=>c(d))},[n]);return l.useLayoutEffect(()=>a.listen(u),[a,u]),l.createElement(Yi,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:a,unstable_useTransitions:n})}var So=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Eo=l.forwardRef(function({onClick:t,discover:n="render",prefetch:s="none",relative:o,reloadDocument:a,replace:i,state:c,target:u,to:d,preventScrollReset:m,viewTransition:h,unstable_defaultShouldRevalidate:p,...x},b){let{basename:g,unstable_useTransitions:v}=l.useContext(_e),y=typeof d=="string"&&So.test(d),f=po(d,g);d=f.to;let w=Ii(d,{relative:o}),[C,_,E]=xl(s,x),j=Sl(d,{replace:i,state:c,target:u,preventScrollReset:m,relative:o,viewTransition:h,unstable_defaultShouldRevalidate:p,unstable_useTransitions:v});function S(B){t&&t(B),B.defaultPrevented||j(B)}let I=l.createElement("a",{...x,...E,href:f.absoluteURL||w,onClick:f.isExternal||a?t:S,ref:yl(b,_),target:u,"data-discover":!y&&n==="render"?"true":void 0});return C&&!y?l.createElement(l.Fragment,null,I,l.createElement(gl,{page:w})):I});Eo.displayName="Link";var jl=l.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:s="",end:o=!1,style:a,to:i,viewTransition:c,children:u,...d},m){let h=Sn(i,{relative:d.relative}),p=le(),x=l.useContext(is),{navigator:b,basename:g}=l.useContext(_e),v=x!=null&&Al(h)&&c===!0,y=b.encodeLocation?b.encodeLocation(h).pathname:h.pathname,f=p.pathname,w=x&&x.navigation&&x.navigation.location?x.navigation.location.pathname:null;n||(f=f.toLowerCase(),w=w?w.toLowerCase():null,y=y.toLowerCase()),w&&g&&(w=Ye(w,g)||w);const C=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let _=f===y||!o&&f.startsWith(y)&&f.charAt(C)==="/",E=w!=null&&(w===y||!o&&w.startsWith(y)&&w.charAt(y.length)==="/"),j={isActive:_,isPending:E,isTransitioning:v},S=_?t:void 0,I;typeof s=="function"?I=s(j):I=[s,_?"active":null,E?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let B=typeof a=="function"?a(j):a;return l.createElement(Eo,{...d,"aria-current":S,className:I,ref:m,style:B,to:i,viewTransition:c},typeof u=="function"?u(j):u)});jl.displayName="NavLink";var Nl=l.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:s,replace:o,state:a,method:i=Qn,action:c,onSubmit:u,relative:d,preventScrollReset:m,viewTransition:h,unstable_defaultShouldRevalidate:p,...x},b)=>{let{unstable_useTransitions:g}=l.useContext(_e),v=Tl(),y=Ll(c,{relative:d}),f=i.toLowerCase()==="get"?"get":"post",w=typeof c=="string"&&So.test(c),C=_=>{if(u&&u(_),_.defaultPrevented)return;_.preventDefault();let E=_.nativeEvent.submitter,j=E?.getAttribute("formmethod")||i,S=()=>v(E||_.currentTarget,{fetcherKey:t,method:j,navigate:n,replace:o,state:a,relative:d,preventScrollReset:m,viewTransition:h,unstable_defaultShouldRevalidate:p});g&&n!==!1?l.startTransition(()=>S()):S()};return l.createElement("form",{ref:b,method:f,action:y,onSubmit:s?u:C,...x,"data-discover":!w&&e==="render"?"true":void 0})});Nl.displayName="Form";function _l(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ko(e){let t=l.useContext(Jt);return K(t,_l(e)),t}function Sl(e,{target:t,replace:n,state:s,preventScrollReset:o,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:c,unstable_useTransitions:u}={}){let d=Y(),m=le(),h=Sn(e,{relative:a});return l.useCallback(p=>{if(nl(p,t)){p.preventDefault();let x=n!==void 0?n:wn(m)===wn(h),b=()=>d(e,{replace:x,state:s,preventScrollReset:o,relative:a,viewTransition:i,unstable_defaultShouldRevalidate:c});u?l.startTransition(()=>b()):b()}},[m,d,h,n,s,t,e,o,a,i,c,u])}function El(e){Ne(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($s(e)),n=l.useRef(!1),s=le(),o=l.useMemo(()=>sl(s.search,n.current?null:t.current),[s.search]),a=Y(),i=l.useCallback((c,u)=>{const d=$s(typeof c=="function"?c(new URLSearchParams(o)):c);n.current=!0,a("?"+d,u)},[a,o]);return[o,i]}var kl=0,Rl=()=>`__${String(++kl)}__`;function Tl(){let{router:e}=ko("useSubmit"),{basename:t}=l.useContext(_e),n=Ki(),s=e.fetch,o=e.navigate;return l.useCallback(async(a,i={})=>{let{action:c,method:u,encType:d,formData:m,body:h}=al(a,t);if(i.navigate===!1){let p=i.fetcherKey||Rl();await s(p,n,i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:m,body:h,formMethod:i.method||u,formEncType:i.encType||d,flushSync:i.flushSync})}else await o(i.action||c,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:m,body:h,formMethod:i.method||u,formEncType:i.encType||d,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[s,o,t,n])}function Ll(e,{relative:t}={}){let{basename:n}=l.useContext(_e),s=l.useContext(Be);K(s,"useFormAction must be used inside a RouteContext");let[o]=s.matches.slice(-1),a={...Sn(e||".",{relative:t})},i=le();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(h=>h).forEach(h=>c.append("index",h));let m=c.toString();a.search=m?`?${m}`:""}}return(!e||e===".")&&o.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Ve([n,a.pathname])),wn(a)}function Al(e,{relative:t}={}){let n=l.useContext(go);K(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:s}=ko("useViewTransitionState"),o=Sn(e,{relative:t});if(!n.isTransitioning)return!1;let a=Ye(n.currentLocation.pathname,s)||n.currentLocation.pathname,i=Ye(n.nextLocation.pathname,s)||n.nextLocation.pathname;return zt(o.pathname,i)!=null||zt(o.pathname,a)!=null}var Ro=qa(),To=class extends ao{constructor(e,t){super(),this.options=t,this.#n=e,this.#i=null,this.#a=br(),this.bindMethods(),this.setOptions(t)}#n;#e=void 0;#s=void 0;#t=void 0;#r;#o;#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),Rr(this.#e,this.options)?this.#d():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ds(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ds(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 ke(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&&!Zn(this.options,t)&&this.#n.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const s=this.hasListeners();s&&Tr(this.#e,n,this.options,t)&&this.#d(),this.updateResult(),s&&(this.#e!==n||ke(this.options.enabled,this.#e)!==ke(t.enabled,this.#e)||vn(this.options.staleTime,this.#e)!==vn(t.staleTime,this.#e))&&this.#x();const o=this.#g();s&&(this.#e!==n||ke(this.options.enabled,this.#e)!==ke(t.enabled,this.#e)||o!==this.#l)&&this.#b(o)}getOptimisticResult(e){const t=this.#n.getQueryCache().build(this.#n,e),n=this.createResult(t,e);return Il(this,n)&&(this.#t=n,this.#o=this.options,this.#r=this.#e.state),n}getCurrentResult(){return this.#t}trackResult(e,t){return new Proxy(e,{get:(n,s)=>(this.trackProp(s),t?.(s),s==="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,s))})}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(es)),t}#x(){this.#y();const e=vn(this.options.staleTime,this.#e);if(Is||this.#t.isStale||!vr(e))return;const n=Ua(this.#t.dataUpdatedAt,e)+1;this.#c=Wn.setTimeout(()=>{this.#t.isStale||this.updateResult()},n)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(e){this.#w(),this.#l=e,!(Is||ke(this.options.enabled,this.#e)===!1||!vr(this.#l)||this.#l===0)&&(this.#u=Wn.setInterval(()=>{(this.options.refetchIntervalInBackground||Wa.isFocused())&&this.#d()},this.#l))}#v(){this.#x(),this.#b(this.#g())}#y(){this.#c&&(Wn.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(Wn.clearInterval(this.#u),this.#u=void 0)}createResult(e,t){const n=this.#e,s=this.options,o=this.#t,a=this.#r,i=this.#o,u=e!==n?e.state:this.#s,{state:d}=e;let m={...d},h=!1,p;if(t._optimisticResults){const S=this.hasListeners(),I=!S&&Rr(e,t),B=S&&Tr(e,n,t,s);(I||B)&&(m={...m,...Ha(d.data,e.options)}),t._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:x,errorUpdatedAt:b,status:g}=m;p=m.data;let v=!1;if(t.placeholderData!==void 0&&p===void 0&&g==="pending"){let S;o?.isPlaceholderData&&t.placeholderData===i?.placeholderData?(S=o.data,v=!0):S=typeof t.placeholderData=="function"?t.placeholderData(this.#m?.state.data,this.#m):t.placeholderData,S!==void 0&&(g="success",p=yr(o?.data,S,t),h=!0)}if(t.select&&p!==void 0&&!v)if(o&&p===a?.data&&t.select===this.#p)p=this.#h;else try{this.#p=t.select,p=t.select(p),p=yr(o?.data,p,t),this.#h=p,this.#i=null}catch(S){this.#i=S}this.#i&&(x=this.#i,p=this.#h,b=Date.now(),g="error");const y=m.fetchStatus==="fetching",f=g==="pending",w=g==="error",C=f&&y,_=p!==void 0,j={status:g,fetchStatus:m.fetchStatus,isPending:f,isSuccess:g==="success",isError:w,isInitialLoading:C,isLoading:C,data:p,dataUpdatedAt:m.dataUpdatedAt,error:x,errorUpdatedAt:b,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:y,isRefetching:y&&!f,isLoadingError:w&&!_,isPaused:m.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:w&&_,isStale:Js(e,t),refetch:this.refetch,promise:this.#a,isEnabled:ke(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const S=se=>{j.status==="error"?se.reject(j.error):j.data!==void 0&&se.resolve(j.data)},I=()=>{const se=this.#a=j.promise=br();S(se)},B=this.#a;switch(B.status){case"pending":e.queryHash===n.queryHash&&S(B);break;case"fulfilled":(j.status==="error"||j.data!==B.value)&&I();break;case"rejected":(j.status!=="error"||j.error!==B.reason)&&I();break}}return j}updateResult(){const e=this.#t,t=this.createResult(this.#e,this.options);if(this.#r=this.#e.state,this.#o=this.options,this.#r.data!==void 0&&(this.#m=this.#e),Zn(t,e))return;this.#t=t;const n=()=>{if(!e)return!0;const{notifyOnChangeProps:s}=this.options,o=typeof s=="function"?s():s;if(o==="all"||!o&&!this.#f.size)return!0;const a=new Set(o??this.#f);return this.options.throwOnError&&a.add("error"),Object.keys(this.#t).some(i=>{const c=i;return this.#t[c]!==e[c]&&a.has(c)})};this.#j({listeners:n()})}#C(){const e=this.#n.getQueryCache().build(this.#n,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#s=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#v()}#j(e){as.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#t)}),this.#n.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Pl(e,t){return ke(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Rr(e,t){return Pl(e,t)||e.state.data!==void 0&&Ds(e,t,t.refetchOnMount)}function Ds(e,t,n){if(ke(t.enabled,e)!==!1&&vn(t.staleTime,e)!=="static"){const s=typeof n=="function"?n(e):n;return s==="always"||s!==!1&&Js(e,t)}return!1}function Tr(e,t,n,s){return(e!==t||ke(s.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Js(e,n)}function Js(e,t){return ke(t.enabled,e)!==!1&&e.isStaleByTime(vn(t.staleTime,e))}function Il(e,t){return!Zn(e.getCurrentResult(),t)}var Ol=class extends To{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:wr()})}getOptimisticResult(e){return e.behavior=wr(),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,s=super.createResult(e,t),{isFetching:o,isRefetching:a,isError:i,isRefetchError:c}=s,u=n.fetchMeta?.fetchMore?.direction,d=i&&u==="forward",m=o&&u==="forward",h=i&&u==="backward",p=o&&u==="backward";return{...s,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Ka(t,n.data),hasPreviousPage:za(t,n.data),isFetchNextPageError:d,isFetchingNextPage:m,isFetchPreviousPageError:h,isFetchingPreviousPage:p,isRefetchError:c&&!d&&!h,isRefetching:a&&!m&&!p}}},Ml=class extends ao{#n;#e=void 0;#s;#t;constructor(t,n){super(),this.#n=t,this.setOptions(n),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const n=this.options;this.options=this.#n.defaultMutationOptions(t),Zn(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),n?.mutationKey&&this.options.mutationKey&&Cr(n.mutationKey)!==Cr(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(t){this.#r(),this.#o(t)}getCurrentResult(){return this.#e}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#r(),this.#o()}mutate(t,n){return this.#t=n,this.#s?.removeObserver(this),this.#s=this.#n.getMutationCache().build(this.#n,this.options),this.#s.addObserver(this),this.#s.execute(t)}#r(){const t=this.#s?.state??Va();this.#e={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#o(t){as.batch(()=>{if(this.#t&&this.hasListeners()){const n=this.#e.variables,s=this.#e.context,o={client:this.#n,meta:this.options.meta,mutationKey:this.options.mutationKey};if(t?.type==="success"){try{this.#t.onSuccess?.(t.data,n,s,o)}catch(a){Promise.reject(a)}try{this.#t.onSettled?.(t.data,null,n,s,o)}catch(a){Promise.reject(a)}}else if(t?.type==="error"){try{this.#t.onError?.(t.error,n,s,o)}catch(a){Promise.reject(a)}try{this.#t.onSettled?.(void 0,t.error,n,s,o)}catch(a){Promise.reject(a)}}}this.listeners.forEach(n=>{n(this.#e)})})}},Lo=l.createContext(void 0),Ao=e=>{const t=l.useContext(Lo);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},$l=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),r.jsx(Lo.Provider,{value:e,children:t})),Po=l.createContext(!1),Dl=()=>l.useContext(Po);Po.Provider;function Fl(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Bl=l.createContext(Fl()),ql=()=>l.useContext(Bl),Ul=(e,t,n)=>{const s=n?.state.error&&typeof e.throwOnError=="function"?Hs(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||s)&&(t.isReset()||(e.retryOnMount=!1))},Wl=e=>{l.useEffect(()=>{e.clearReset()},[e])},Hl=({result:e,errorResetBoundary:t,throwOnError:n,query:s,suspense:o})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(o&&e.data===void 0||Hs(n,[e.error,s])),zl=e=>{if(e.suspense){const n=o=>o==="static"?o:Math.max(o??1e3,1e3),s=e.staleTime;e.staleTime=typeof s=="function"?(...o)=>n(s(...o)):n(s),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Kl=(e,t)=>e.isLoading&&e.isFetching&&!t,Vl=(e,t)=>e?.suspense&&t.isPending,Lr=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Io(e,t,n){const s=Dl(),o=ql(),a=Ao(),i=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(i);const c=a.getQueryCache().get(i.queryHash);i._optimisticResults=s?"isRestoring":"optimistic",zl(i),Ul(i,o,c),Wl(o);const u=!a.getQueryCache().get(i.queryHash),[d]=l.useState(()=>new t(a,i)),m=d.getOptimisticResult(i),h=!s&&e.subscribed!==!1;if(l.useSyncExternalStore(l.useCallback(p=>{const x=h?d.subscribe(as.batchCalls(p)):es;return d.updateResult(),x},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),l.useEffect(()=>{d.setOptions(i)},[i,d]),Vl(i,m))throw Lr(i,d,o);if(Hl({result:m,errorResetBoundary:o,throwOnError:i.throwOnError,query:c,suspense:i.suspense}))throw m.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(i,m),i.experimental_prefetchInRender&&!Is&&Kl(m,s)&&(u?Lr(i,d,o):c?.promise)?.catch(es).finally(()=>{d.updateResult()}),i.notifyOnChangeProps?m:d.trackResult(m)}function ce(e,t){return Io(e,To)}function X(e,t){const n=Ao(),[s]=l.useState(()=>new Ml(n,e));l.useEffect(()=>{s.setOptions(e)},[s,e]);const o=l.useSyncExternalStore(l.useCallback(i=>s.subscribe(as.batchCalls(i)),[s]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),a=l.useCallback((i,c)=>{s.mutate(i,c).catch(es)},[s]);if(o.error&&Hs(s.options.throwOnError,[o.error]))throw o.error;return{...o,mutate:a,mutateAsync:o.mutate}}function Oo(e,t){return Io(e,Ol)}const at="data-sources",Mo="auth-user",Ql=e=>ce({queryKey:["project","datasources",e],queryFn:async()=>{const{data:t}=await O.get(`/project/team/${e}/datasources`);return t.data},enabled:!!e}),Xt=e=>{const t=["project","datasources"],n=["project","saved-queries"];return Promise.all([Q.invalidateQueries({queryKey:t}),Q.invalidateQueries({queryKey:n})])},Gl=e=>{const t=["trash","team"];return Q.invalidateQueries({queryKey:t})},Yl=(e,t)=>ce({queryKey:["project",t.teamId,"tables",e,t.selectedDataSources],queryFn:async()=>{const{data:n}=await O.get(`/project/team/${t.teamId}/query`,{params:{size:30,search:e,selectedDataSources:t.selectedDataSources}});return n.data},enabled:!!t.teamId,staleTime:0}),Jl=(e,t=30,n)=>Oo({queryKey:["project","tabs-history",e,t,n],queryFn:async({pageParam:s})=>{const{data:a}=await O.get(`/project/team/${e}/tabs-history?page=${s}&size=${t}`);return a},select:({pages:s})=>s.flatMap(o=>o.data),enabled:!!e,initialPageParam:0,getNextPageParam:(s,o)=>{if(s.hasMore)return o.length},staleTime:0}),Xl=(e,t="",n=20)=>Oo({queryKey:["project","saved-queries",e,t,n],queryFn:async({pageParam:s})=>{const o=new URLSearchParams;o.set("nameFilter",t),o.set("size",n.toString()),o.set("page",s.toString());const{data:a}=await O.get(`/project/team/${e}/queries?${o.toString()}`);return a},enabled:!!e,initialPageParam:0,select:({pages:s})=>s.flatMap(o=>o.data),getNextPageParam:(s,o)=>{if(s.hasMore)return o.length}}),Zl=(e,t=10,n=!1)=>ce({queryKey:["project","recent-tabs",e,t,n],queryFn:async()=>{const{data:s}=await O.get(`/project/team/${e}/tabs-history?page=0&size=${t}&archived=${n}`);return s.data},enabled:!!e,staleTime:0}),ec=e=>X({mutationFn:async()=>{const{data:t}=await O.get(`/project/team/${e}/tabs-history?page=0&size=1&archived=false`);return t.data?.length?t.data[0]:void 0}}),tc=e=>ce({queryKey:["project","count-saved-queries",e],queryFn:async()=>{const{data:t}=await O.get(`/project/team/${e}/count-saved-queries`);return t.data}}),nc=()=>Promise.all([Q.invalidateQueries({queryKey:["project","tabs-history"]}),Q.invalidateQueries({queryKey:["project","recent-tabs"]})]),$o=()=>Q.invalidateQueries({queryKey:["project","count-saved-queries"]}),sc=(e,t)=>{},rc=()=>{},oc={event:sc,pageView:rc},cs=e=>ce({queryKey:[at,e],queryFn:async()=>{const{data:t}=await O.get("/data-sources/"+e);return t.data},enabled:!!e}),Xs=e=>ce({queryKey:[at,e.teamId],queryFn:async()=>{const{data:t}=await O.get("/data-sources",{params:e});return t.data},enabled:e.teamId!==void 0}),En=e=>ce({queryKey:[at,e,"inspections"],queryFn:async()=>{const{data:t}=await O.get(`/data-sources/${e}/inspections`);return t.data},enabled:!!e}),ac=()=>X({mutationFn:async e=>{const{data:t}=await O.post("/data-sources",e);return t.data},onSuccess:()=>{Q.invalidateQueries({queryKey:[at]}),Xt()},onError:()=>{}}),ic=()=>X({mutationFn:async({dataSource:e,id:t})=>{const{data:n}=await O.put(`/data-sources/${t}`,e);return n.data},onSuccess:()=>{Q.invalidateQueries({queryKey:[at]}),Xt()}}),Do=()=>X({mutationFn:async e=>{await O.post(`/data-sources/${e}/inspect`)},onSuccess:()=>{Q.invalidateQueries({queryKey:[at]})}}),lc=()=>X({mutationFn:async e=>{await O.delete(`/data-sources/${e}`)},onSuccess:()=>{Q.invalidateQueries({queryKey:[at]}),Xt()}}),Fo=()=>ce({queryKey:["accessToken"],queryFn:zs.get}),ue=()=>{const{data:e}=Fo();return ce({queryKey:[Mo],queryFn:async()=>{const{data:t}=await O.get("/users");return t.data},enabled:!!e,retry:(t,n)=>Qa(n)&&n.code==="ERR_NETWORK"?!1:t<3})},cc=()=>X({mutationFn:async e=>{const{data:t}=await O.patch("/users",e);return t.data},onSuccess:async e=>{Q.setQueryData([Mo],e)}}),uc=()=>X({mutationFn:async e=>(await O.post("/users",e),!0),onSuccess:()=>{Q.invalidateQueries({queryKey:["team-users"]})}}),Se=e=>{const t=new Set;let n=e;const s=c=>(t.add(c),()=>t.delete(c)),o=c=>(t.forEach(u=>u(c)),!0),a=c=>{n=typeof c=="function"?c(n):c,o(n)},i=c=>()=>c?c(n):n;return[c=>l.useSyncExternalStore(s,i(c),i(c)),a,{get:()=>n,subscribe:c=>(c(n),s(c))}]};function dc(e){const t=[];for(const n of e)for(const s of n.columns)s.ref&&(t.push({id:`${n.tableName}->${s.ref.table}.${s.ref.field}`,name:`${n.tableName} in ${s.ref.table}`,where:`${n.tableName}.${s.name} = ${s.ref.table}.${s.ref.field}`,on:{fromTable:s.ref.table,toTable:n.tableName,fromColumn:s.ref.field,toColumn:s.name}}),t.push({id:`${s.ref.table}->${n.tableName}.${s.name}`,name:`${s.ref.table} in ${n.tableName}`,where:`${s.ref.table}.${s.ref.field} = ${n.tableName}.${s.name}`,on:{fromTable:n.tableName,toTable:s.ref.table,fromColumn:s.name,toColumn:s.ref.field}}));return t}const hc=e=>ce({queryKey:["hooks",e],queryFn:async()=>{const t=await Q.fetchQuery({queryKey:[at,e,"inspections"],queryFn:async()=>{const{data:n}=await O.get(`/data-sources/${e}/inspections`);return n.data}});return dc(t)},enabled:!!e}),Bo=[{value:"=",label:"equals"},{value:"<>",label:"not equal"},{value:">",label:"greater than"},{value:">=",label:"greater than or equal"},{value:"<",label:"less than"},{value:"<=",label:"less than or equal"},{value:"LIKE",label:"contains"},{value:"NOT LIKE",label:"not contains"},{value:"IN",label:"in list"},{value:"NOT IN",label:"not in list"},{value:"IS NULL",label:"is null"},{value:"IS NOT NULL",label:"is not null"}],mc=Bo.reduce((e,t)=>(e[t.value]=t.label,e),{});Bo.reduce((e,t)=>(e[t.label]=t.value,e),{});const Zt=e=>e.map(t=>({label:mc[t],value:t}));Zt(["=","<>",">",">=","<","<=","IN","NOT IN","IS NULL","IS NOT NULL"]);Zt(["=","<>","LIKE","NOT LIKE","IN","NOT IN","IS NULL","IS NOT NULL"]);Zt(["=","<>","IS NULL","IS NOT NULL"]);Zt(["=","<>",">",">=","<","<=","IS NULL","IS NOT NULL"]);Zt(["IS NULL","IS NOT NULL"]);Zt(["IN","NOT IN"]);const fc=["char","varchar","binary","varbinary","blob","text","enum","set","character","character varying","text","citext","uuid","xml","json","jsonb"],pc=new Set(fc),xc=e=>pc.has(e),gc=["integer","smallint","decimal","numeric","float","real","double precision","int","smallint","integer","bigint","decimal","numeric","real","double precision","serial","bigserial","money"],bc=new Set(gc),vc=e=>bc.has(e),yc=["date","datetime","timestamp","timestamptz"].reduce((e,t)=>(e[t]=!0,e),{}),qo=e=>e.fn?e.distinct===!0?`${e.fn} distinct ${e.value}`:`${e.fn} ${e.value}`:e.value;var pe=(e=>(e.OWNER="owner",e.ADMIN="admin",e.EDITOR="editor",e.READ_ONLY="read_only",e))(pe||{});const Ar={[pe.READ_ONLY]:10,[pe.EDITOR]:20,[pe.ADMIN]:30,[pe.OWNER]:40},Je=e=>e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e,wc={operator:"LIKE",parse:e=>{const t=e.match(/^LIKE\s*["'](.*)["']$/i);if(t)return[{value:Je(t[1])}]},stringify:(e,t)=>xc(t)?`${e.value?.[0].value}`:`LIKE "%${e.value?.[0].value}%"`},Cc={operator:"NOT LIKE",parse:e=>{const t=e.match(/^NOT LIKE\s*["'](.*)["']$/i);if(t)return[{value:Je(t[1])}]},stringify:e=>`NOT LIKE "%${e.value?.[0].value}%"`};function Uo(e){return e===""?[]:jc(e).map(Nc)}function jc(e){const t=[];let n=0,s="",o=!1,a=!1;for(;n<e.length;){const i=e[n];if((o||a)&&i==="\\"){s+=e[n+1],n+=2;continue}if(i==="'"&&!a){o=!o,s+=i,n++;continue}if(i==='"'&&!o){a=!a,s+=i,n++;continue}if(i===","&&!o&&!a){t.push(s.trim()),s="",n++;continue}s+=i,n++}if(s.trim()!==""&&t.push(s.trim()),o||a)throw new Error("Unterminated string literal");return t}function Nc(e){if(e.startsWith("'")&&e.endsWith("'"))return{value:Pr(e.slice(1,-1),"'")};if(e.startsWith('"')&&e.endsWith('"'))return{value:Pr(e.slice(1,-1),'"')};const t=Number(e);if(!Number.isNaN(t))return{value:t};throw new Error(`Invalid literal: ${e}`)}function Pr(e,t){return e.replace(/\\(.)/g,(n,s)=>s)}const _c={operator:"IN",parse:e=>{const t=e.match(/^in\s*\((.*)\)$/i);if(t)return Uo(t[1])},stringify:e=>`IN (${e.value?.map(t=>`"${t.value}"`).join(", ")})`},Sc={operator:"NOT IN",parse:e=>{const t=e.match(/^not\s+in\s*\((.*)\)$/i);if(t)return Uo(t[1])},stringify:e=>`NOT IN (${e.value?.map(t=>`"${t.value}"`).join(", ")})`},Ec={operator:"=",parse:e=>{const t=e.match(/^=\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:(e,t)=>vc(t)?`${e.value?.[0].value}`:`= ${e.value?.[0].value}`},kc={operator:"!=",parse:e=>{const t=e.match(/^!=\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`!= ${e.value?.[0].value}`},Rc={operator:"<>",parse:e=>{const t=e.match(/^<>\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`<> ${e.value?.[0].value}`},Tc={operator:">",parse:e=>{const t=e.match(/^>\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`> ${e.value?.[0].value}`},Lc={operator:">=",parse:e=>{const t=e.match(/^>=\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`>= ${e.value?.[0].value}`},Ac={operator:"<",parse:e=>{const t=e.match(/^<\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`< ${e.value?.[0].value}`},Pc={operator:"<=",parse:e=>{const t=e.match(/^<=\s*(.*)$/);if(t)return[{value:Je(t[1])}]},stringify:e=>`<= ${e.value?.[0].value}`},Ic={operator:"IS NULL",parse:e=>{if(/^is\s+null$/i.test(e))return[]},stringify:()=>"IS NULL"},Oc={operator:"IS NOT NULL",parse:e=>{if(/^is\s+not\s+null$/i.test(e))return[]},stringify:()=>"IS NOT NULL"},Mc=[wc,Cc,_c,Sc,Ec,kc,Rc,Lc,Tc,Pc,Ac,Ic,Oc];Mc.reduce((e,t)=>(e[t.operator]=t,e),{});function $c(e,t){if(!e||!t)return{};const n=new Set;for(const o of t)o.table&&n.add(o.table);const s={};for(const o of n){const a=e.find(i=>i.tableName===o);if(a){s[o]=[];const i=a.columns.filter(c=>c.isPrimary);for(const c of i)if(t.find(d=>d.table===o&&d.column===c.name))s[o].push(c.name);else{delete s[o];break}}}return s}function Dc(e,t,n,s){const{data:o}=hc(t),{data:a}=En(t);return l.useMemo(()=>{const i=$c(a,e?.result.columns);return{name:n,tabId:s,hooks:(()=>{const c=[];if(!o||!e||!e.result.columns)return c;for(const u of o)(e.result.tables.includes(u.on.toTable)||e.result.tables.includes(u.on.fromTable))&&c.push(u);return c})(),availableJoins:(()=>{const c=[];if(!o||!e||!e.result.columns)return c;for(const u of o)!e.result.tables.includes(u.on.toTable)&&e.result.tables.includes(u.on.fromTable)&&c.push(u);return c})(),allColumns:e?.result.allColumns||[],dataSourceId:t,entities:Object.keys(i),getValue:(c,u)=>{const d=qo(u),m=e?.result.columns?.findIndex(h=>h.full===d);if(m!=null&&m>-1)return c[m]},getEntityKey:(c,u)=>i[c].reduce((d,m)=>{const h=e?.result.columns?.findIndex(p=>p.column===m&&p.table===c);return h!=null&&h>-1&&d.push([m,u[h]]),d},[]),getEntityKeyByRowIndex:(c,u)=>i[c].reduce((d,m)=>{const h=e?.result.columns?.findIndex(p=>p.column===m&&p.table===c);return h!=null&&h>-1&&d.push([m,e?.result.rows[u][h]]),d},[]),getColumnType:c=>{const u=e?.result.allColumns.find(d=>d.full===c);if(u)return u.type}}},[e,t,o,a,n])}function Fc(e,t){return l.useMemo(()=>({state:e,setState:t}),[e,t])}function en(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 Bc(e,t){return{name:e,path:t,build:o=>{if(typeof o=="object"){let a=t;for(const[i,c]of Object.entries(o))a=a.replace(":"+i,c);return a}return t},check:o=>!!zt({path:t,end:!0},o)}}function kn(e,t){return{name:e,path:t,build:()=>t,check:n=>n===t}}const qc=kn("Home","/"),Uc=kn("Workbench","/workbench"),Wc=kn("Share query","/share"),Hc=kn("Login","/login"),zc=kn("Saved queries","/saved-queries"),Kc=Bc("Workbench tab","/workbench/tab/:id"),P={home:qc,workbench:Uc,share:Wc,login:Hc,savedQueries:zc,workbenchTab:Kc},Zs=e=>{Q.setQueryData(["workbench-tabs"],t=>e(t||[]))},Vc=(e,t)=>{Q.setQueryData(["workbench-tabs",e],n=>n&&t(n))},us=()=>ce({queryKey:["workbench-tabs"],queryFn:async()=>{const{data:e}=await O.get("/workbench-tabs");return e.data}}),Qc=e=>ce({queryKey:["workbench-tabs",e],queryFn:async()=>{const{data:t}=await O.get(`/workbench-tabs/${e}`);return t.data}}),tn=()=>X({mutationFn:async e=>{const{data:t}=await O.post("/workbench-tabs",e);return t.data},onSuccess:async e=>{Zs(t=>[...t,e])}}),Gc=()=>X({mutationFn:async e=>(await O.patch(`/workbench-tabs/${e}`,{archived:!0}),e),onMutate:e=>{Zs(t=>t.filter(n=>n.id!==e))}}),Wo=()=>X({mutationFn:async e=>(await O.patch(`/workbench-tabs/${e}`,{archived:!1}),e),onSuccess:()=>zo()}),Yc=()=>X({mutationFn:async({id:e,payload:t})=>(await O.patch(`/workbench-tabs/${e}`,t),!0),onMutate:({id:e,payload:t})=>{Vc(e,n=>({...n,...t})),Zs(n=>n.map(s=>s.id!==e?s:{...s,name:t.name||s.name}))}}),Jc=(e,t)=>{const{dataSourceId:n,searchAll:s,table:o,filters:a,joins:i,orderBy:c,groupBy:u,columns:d,aggregations:m,page:h=0,size:p=20}=t;return ce({queryKey:["workbench-tab-runner",e,n,o,h,p,a,m,i,c,u,d,s],queryFn:async()=>{const{data:x}=await O.post(`/workbench-tabs/${e}/run`,t);return x.data},retry:1,enabled:!!o&&!!n,placeholderData:Ga})},Xc=()=>X({mutationFn:async e=>{await O.delete(`/workbench-tabs/${e}`)},onSuccess:()=>{zo(),nc()}}),Ho=e=>Q.invalidateQueries({queryKey:["workbench-tab-runner",e]}),zo=()=>Q.invalidateQueries({queryKey:["workbench-tabs"]}),[Zc,Ns,eu]=Se(void 0),tu=async()=>new Promise(e=>{Ns({onCancel:()=>{Ns(void 0),e(void 0)},onConfirm:(t,n,s)=>{Ns(void 0),e({dsId:s,id:n,type:t})}})}),Rn=e=>{const t=Y(),n=tn(),s=Wo();return l.useEffect(()=>{n?.data?.id&&t(P.workbenchTab.build({id:n.data.id})),s?.data&&t(P.workbenchTab.build({id:s.data}))},[n.data,s.data]),l.useCallback(()=>{eu.get()||tu().then(a=>{a?.type==="table"?n.mutate({name:a.id,opts:en({table:a.id,dataSourceId:a.dsId})}):a?.type==="query"?n.mutate({queryId:a.id}):a?.type==="tab"&&s.mutate(a.id)})},[t,e])},Tn=e=>{const{data:t}=ue();return l.useMemo(()=>t?Ar[t.teamRole]>=Ar[e]:!1,[t,e])},nu="_input_1hufc_2",su="_label_1hufc_2",ru="_content_1hufc_2",ou="_form_1hufc_2",au="_mode-select_1hufc_2",yt={input:nu,label:su,content:ru,form:ou,switch:"_switch_1hufc_2",modeSelect:au},iu="_modal_1t5ps_2",lu="_modal-visible_1t5ps_2",cu="_modal-invisible_1t5ps_2",uu="_backdrop_1t5ps_2",du="_modal-container_1t5ps_2",hu="_close-button_1t5ps_2",Wt={modal:iu,modalVisible:lu,modalInvisible:cu,backdrop:uu,modalContainer:du,closeButton:hu},jt=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"M368 368L144 144M368 144L144 368"})),ve=({children:e,backdropClose:t,isVisible:n,onClose:s,onClosed:o,noPadding:a=!1,portal:i=!1})=>{const[c,u]=l.useState(!1),d=()=>{t&&s()},m=p=>{n||getComputedStyle(p.currentTarget).opacity==="0"&&(u(!1),o&&o())};l.useEffect(()=>{n&&u(!0)},[n]);const h=r.jsxs("div",{onTransitionEnd:m,className:A(Wt.modal,n?Wt.modalVisible:Wt.modalInvisible),children:[r.jsx("div",{onClick:d,className:Wt.backdrop}),r.jsx("div",{className:A(Wt.modalContainer,a!==!0&&"p-4"),children:c&&e})]});return i?Ro.createPortal(h,document.body):h},it=({onClick:e})=>{const t=l.useRef(e);return t.current=e,l.useEffect(()=>{const n=s=>{s.key==="Escape"&&t.current?.()};return window.addEventListener("keyup",n),()=>{window.removeEventListener("keyup",n)}},[]),r.jsx("button",{className:Wt.closeButton,onClick:e,children:r.jsx(jt,{width:20,height:20})})},Ko=({children:e})=>r.jsx("h2",{className:"text-xl font-semibold",children:e}),mu=({form:e,change:t,shape:n})=>r.jsx("div",{className:yt.form,children:n.fields.map(s=>r.jsxs("label",{className:yt.input,children:[r.jsx("p",{className:yt.label,children:s.label}),r.jsx("input",{value:e[s.name],onChange:t(s.name),type:s.type})]},s.name))}),Ft=[{label:"PostgreSQL",tag:"postgres"},{label:"MySQL",tag:"mysql"}],fu={fields:[{label:"Database URL",name:"dbUrl",type:"text"},{label:"Database port",name:"dbPort",type:"number"},{label:"Username",name:"dbUser",type:"text"},{label:"Password",name:"dbPassword",type:"password"},{label:"Database",name:"dbDatabase",type:"text"}]},pu={fields:[{label:"Database URL",name:"dbUrl",type:"text"},{label:"Database port",name:"dbPort",type:"number"},{label:"Username",name:"dbUser",type:"text"},{label:"Password",name:"dbPassword",type:"password"},{label:"Database",name:"dbDatabase",type:"text"},{label:"Schema",name:"dbSchema",type:"text"}]},xu=({show:e,onClose:t,dbType:n="postgres"})=>{const s=ac(),o=Do(),{data:a}=ue(),[i,{change:c,set:u}]=jn({name:"",dbType:n,dbUrl:"",dbUser:"",dbPassword:"",dbDatabase:"",dbSchema:"",dbPort:5432,teamId:"",ownerId:"",description:"",allowInsert:!1,allowUpdate:!1}),d=async()=>{const b=await s.mutateAsync({...i,dbPort:Number(i.dbPort),teamId:a.teamId,ownerId:a.id});await o.mutateAsync(b.id),t(),oc.event("Create Datasource",{dbType:i.dbType})},m=b=>{u("allowInsert",!b),u("allowUpdate",!b)},h=()=>{t()},p=s.isPending||o.isPending,x=!i.allowInsert&&!i.allowUpdate;return r.jsxs(ve,{isVisible:e,onClose:h,portal:!0,children:[r.jsxs("div",{className:"max-w-xl mx-auto overflow-y-auto",children:[s.isError&&r.jsx(ne,{variant:"danger",className:"mb-2",children:r.jsx("span",{children:"Failed to connect to the database. Please check if the data are correct and retry."})}),s.isPending&&r.jsx(ne,{className:"mb-2",variant:"info",children:"Creating connection"}),o.isPending&&r.jsx(ne,{className:"mb-2",variant:"info",children:"Inspecting connection"}),r.jsxs("div",{className:yt.switch,children:[r.jsxs("label",{className:"button tertiary",children:[r.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:i.dbType===Ft[0].tag,onChange:()=>u("dbType",Ft[0].tag)}),r.jsx("span",{children:Ft[0].label})]}),r.jsxs("label",{className:"button tertiary",children:[r.jsx("input",{type:"radio",name:"bdType",className:"mr-2",checked:i.dbType===Ft[1].tag,onChange:()=>u("dbType",Ft[1].tag)}),r.jsx("span",{children:Ft[1].label})]})]}),r.jsxs("div",{className:"mt-2",children:[r.jsxs("div",{className:yt.content,children:[r.jsx(mu,{form:i,change:c,shape:i.dbType==="mysql"?fu:pu}),r.jsxs("div",{className:"flex flex-col",children:[r.jsx("label",{className:"text-sm font-semibold",children:"Name"}),r.jsx("input",{value:i.name,onChange:c("name"),className:"input"})]})]}),r.jsxs("div",{className:"mt-4",children:[r.jsxs("label",{className:yt.modeSelect,children:[r.jsxs("div",{children:[r.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:x,onChange:()=>m(!0)}),r.jsx("span",{className:"text-sm font-semibold",children:"Production mode"})]}),r.jsxs("p",{className:"text-xs mt-1 text-gray-600",children:["Mutation operations (such as INSERT or UPDATE) are ",r.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."]})]}),r.jsxs("label",{className:yt.modeSelect,children:[r.jsxs("div",{children:[r.jsx("input",{type:"radio",name:"production-mode",className:"mr-2",checked:!x,onChange:()=>m(!1)}),r.jsx("span",{className:"text-sm font-semibold",children:"Dev mode"})]}),r.jsxs("p",{className:"text-xs mt-1 text-gray-600",children:["Mutation operations (such as INSERT or UPDATE) are ",r.jsx("strong",{children:"allowed"}),". You will be able to insert new rows and edit existing data."]})]})]})]})]}),r.jsxs("div",{className:"flex justify-end gap-1 mt-2",children:[r.jsx("button",{onClick:h,className:"button tertiary",disabled:p,children:"Cancel"}),r.jsx("button",{onClick:d,className:"button primary",disabled:p,children:"Create"})]})]})},gu="_data-source-entry_14xie_2",bu="_action-title_14xie_2",vu="_action-subtext_14xie_2",yu="_dev-tag_14xie_2",wu="_prod-tag_14xie_2",Cu="_recent-tabs-container_14xie_2",ju="_recent-tabs-entry_14xie_2",Nu="_home-action-button_14xie_2",_u="_home-gray-card_14xie_2",Su="_home-card-title_14xie_2",Eu="_home-card-grid-content_14xie_2",D={dataSourceEntry:gu,actionTitle:bu,actionSubtext:vu,devTag:yu,prodTag:wu,recentTabsContainer:Cu,recentTabsEntry:ju,homeActionButton:Nu,homeGrayCard:_u,homeCardTitle:Su,homeCardGridContent:Eu},ku=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"})),Ru=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"}})),lt=({size:e,type:t})=>t==="mysql"?r.jsx(ku,{width:e,height:e}):r.jsx(Ru,{width:e,height:e}),[Tu,Kt]=Se(void 0),[Lu,Vt]=Se({show:!1}),Au=()=>{const e=Rn("Home");return r.jsx("div",{className:D.homeActionButton,onClick:e,children:r.jsxs("h2",{className:D.actionTitle,children:[r.jsx("span",{className:"truncate",children:"🔎 Start new query"}),r.jsx("span",{className:"hotkey",children:"N"})]})})},Pu=()=>{const e=Y();return r.jsx("div",{className:D.homeActionButton,onClick:()=>e(P.savedQueries.build()),children:r.jsx("h2",{className:D.actionTitle,children:r.jsx("span",{className:"truncate",children:"💾 Saved queries"})})})},Iu=()=>{const[e,t]=l.useState(void 0),n=Tn(pe.EDITOR),s=o=>{n?t(o):je.error("You don't have permission to connect new data sources in this team")};return r.jsxs("div",{children:[e&&r.jsx(xu,{show:!0,dbType:e,onClose:()=>t(void 0)}),r.jsx("div",{className:D.homeActionButton,onClick:()=>s("postgres"),children:r.jsx("p",{className:D.actionTitle,children:"🧙♂️ Connection wizard"})})]})},Ou=()=>{const e=Y(),{data:t}=us(),n=Rn("Home"),s=()=>{t&&t.length>0?e(P.workbenchTab.build({id:t[0].id})):n()};return r.jsx("div",{className:D.homeActionButton,onClick:s,children:r.jsxs("h2",{className:D.actionTitle,children:[r.jsx("span",{children:"🛠️ Workbench"}),r.jsx("span",{className:"hotkey",children:"W"})]})})},Mu=()=>{const{data:e}=ue(),{data:t}=Xs({teamId:e?.teamId}),n=s=>{Kt(s)};return!t||t.length===0?null:r.jsxs("div",{className:D.homeGrayCard,children:[r.jsx("h2",{className:D.homeCardTitle,children:"Data sources"}),r.jsx("div",{className:D.homeCardGridContent,children:t?.map(s=>r.jsxs("div",{className:D.dataSourceEntry,onClick:()=>n(s.id),tabIndex:0,children:[r.jsx(lt,{size:32,type:s.dbType}),r.jsxs("div",{className:"overflow-hidden",children:[r.jsx("p",{className:D.actionTitle,children:s.name}),s.allowInsert?r.jsx("span",{className:D.devTag,children:"dev"}):r.jsx("span",{className:D.prodTag,children:"prod"})]})]},s.id))})]})},$u=()=>r.jsxs("div",{className:D.homeGrayCard,children:[r.jsx("h2",{className:D.homeCardTitle,children:"Useful links"}),r.jsxs("div",{className:D.homeCardGridContent,children:[r.jsxs("a",{className:D.homeActionButton,href:"https://dataramen.xyz/",target:"_blank",children:[r.jsx("h2",{className:D.actionTitle,children:"↗️ Documentation"}),r.jsx("p",{className:D.actionSubtext,children:"Learn how to use DataRamen"})]}),r.jsxs("a",{className:D.homeActionButton,href:"https://github.com/OleksandrDemian/dataramen",target:"_blank",children:[r.jsx("h2",{className:D.actionTitle,children:"↗️ Github"}),r.jsx("p",{className:D.actionSubtext,children:"Codebase is open source"})]}),r.jsxs("a",{className:D.homeActionButton,href:"#",onClick:()=>Vt({show:!0}),children:[r.jsxs("h2",{className:D.actionTitle,children:[r.jsx("span",{children:"⌛ Recent tabs"}),r.jsx("span",{className:"hotkey",children:"H"})]}),r.jsx("p",{className:D.actionSubtext,children:"Manage recent tabs"})]})]})]}),Du=()=>{const{data:e}=ue(),{data:t,isLoading:n}=Zl(e?.teamId),s=Y();if(n||!t?.length)return null;const o=a=>{s(P.workbenchTab.build({id:a}))};return r.jsxs("div",{className:D.recentTabsContainer,children:[r.jsx("h2",{className:D.homeCardTitle+" px-4 mb-4",children:"Recent tabs"}),t.map(a=>r.jsxs("div",{className:D.recentTabsEntry,onClick:()=>o(a.id),children:[r.jsx("p",{className:"text-(--text-color-primary) truncate",children:a.name}),r.jsxs("p",{className:"flex items-center gap-2",children:[r.jsx(lt,{size:20,type:a.dataSourceType}),r.jsx("span",{className:"text-sm text-(--text-color-secondary) truncate",children:a.dataSourceName})]})]},a.id))]})},Fu=()=>{const{data:e}=ue(),{data:t}=Xs({teamId:e?.teamId}),n=!!t&&t.length>0,s=!!e;return r.jsx("div",{className:"page-container h-screen max-h-screen overflow-y-auto no-scrollbar",children:r.jsxs("div",{className:"page-content",children:[r.jsx("div",{className:"py-10 text-center w-full sticky top-0 z-0",children:r.jsx("h1",{className:"comfortaa text-3xl font-semibold text-(--text-color-primary)",children:"DataRamen"})}),r.jsxs("div",{className:"flex flex-col gap-8 mt-8 bg-(--bg) z-1",children:[s&&!n&&r.jsx(ne,{variant:"warning",className:"font-semibold",children:"Connect at least one data source to start using DataRamen"}),r.jsxs("div",{className:D.homeGrayCard,children:[r.jsx("h2",{className:D.homeCardTitle,children:"Quick actions"}),r.jsxs("div",{className:D.homeCardGridContent,children:[r.jsx(Au,{}),r.jsx(Iu,{}),s&&r.jsx(Ou,{}),r.jsx(Pu,{})]})]}),s&&r.jsx(Mu,{}),r.jsx(Du,{}),r.jsx($u,{})]})]})})},[Bu,er]=Se(void 0),qu=()=>er(void 0);function wt(e,t){if(e==null)return"";switch(t){case"json":case"jsonb":return JSON.stringify(e,null,2)}if(e===0||e===!1)return e.toString();switch(typeof e){case"string":return e;case"number":case"boolean":return e.toString();default:return JSON.stringify(e)}}const Yn=e=>e.distinct?[e.fn,"DISTINCT",e.value].join(" "):[e.fn,e.value].join(" "),tt=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},Uu="_container_d92uy_2",Wu="_header_d92uy_2",Hu="_fields-container_d92uy_2",zu="_field-label_d92uy_2",Ku="_actions_d92uy_2",xn={container:Uu,header:Wu,fieldsContainer:Hu,fieldLabel:zu,actions:Ku},Vu=(e,t,n)=>ce({queryKey:["entity",e,t,n],queryFn:async()=>{const{data:s}=await O.get(`/runner/${e}/entity/${t}`,{params:n?.reduce((o,a)=>(o[a[0]]=a[1],o),{})});return s.data},retry:1,enabled:!!t&&!!e&&!!n,staleTime:0}),Qu=()=>X({mutationFn:async e=>{const{data:t}=await O.post(`/runner/${e.datasourceId}/update`,e);return t.data}}),Gu=()=>X({mutationFn:async e=>{const{data:t}=await O.post(`/runner/${e.datasourceId}/insert`,e);return t.data}}),tr=e=>l.useMemo(()=>{if(e)return e instanceof Ya?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]),nr=()=>{const{pathname:e}=le();return l.useMemo(()=>zt({path:P.workbenchTab.path,end:!1},e)?.params.id,[e])},Yu=({data:e})=>{const[t,{change:n,touched:s}]=jn({}),o=nr(),{mutateAsync:a,error:i}=Gu(),c=tr(i),{data:u}=En(e.dataSourceId),[d,m]=l.useState(""),h=l.useMemo(()=>u?.find(b=>b.tableName===e.table),[u,e.table]),p=l.useMemo(()=>{if(!h)return[];if(!d)return h.columns.map(g=>({...g,label:tt(g.name)}));const b=d.toLowerCase();return h.columns.filter(g=>g.name.toLowerCase().includes(b)).map(g=>({...g,label:tt(g.name)}))},[d,h]),x=()=>{const b=[];for(const g of s)b.push({value:t[g],column:g});a({datasourceId:e.dataSourceId,table:e.table,values:b}).then(()=>{qu(),o&&Ho(o)})};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:xn.header,children:[r.jsxs("p",{className:"text-lg font-semibold",children:["Insert new row in ",r.jsx("span",{className:"underline",children:e.table})]}),c&&r.jsx(ne,{variant:"danger",children:r.jsx("p",{children:c})})]}),r.jsx("div",{className:"bg-gray-50 py-1 px-4 border-y border-gray-200",children:r.jsx("p",{className:"text-xs text-gray-800",children:"Tip: use = to write raw SQL. Ex: =NULL or =NOW()"})}),r.jsx("div",{className:xn.container,children:r.jsx("div",{className:xn.fieldsContainer,children:p.map(b=>r.jsxs("label",{className:xn.fieldLabel,children:[r.jsxs("div",{className:"flex justify-between",children:[r.jsxs("p",{children:[b.isPrimary?"🔐":"🏷️"," ",b.label]}),r.jsxs("p",{className:"text-blue-800 text-sm",children:["[",b.name,": ",b.type,"]"]})]}),r.jsx("input",{className:"input w-full",value:wt(t[b.name]),onChange:n(b.name),placeholder:b.name})]},b.name))})}),r.jsxs("div",{className:xn.actions,children:[r.jsxs("label",{children:[r.jsx("span",{className:"mr-2",children:"🔎"}),r.jsx("input",{className:"input bg-white!",value:d,onChange:b=>m(b.target.value),placeholder:"Filter columns"})]}),r.jsx("span",{className:"flex-1"}),r.jsx("button",{disabled:!s.length,className:"button primary",onClick:x,children:"Run insert"})]})]})},Ju=()=>{const e=Bu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const s=()=>er(void 0);return r.jsxs(ve,{isVisible:e!=null,onClose:s,onClosed:()=>n(void 0),noPadding:!0,children:[r.jsx(it,{onClick:s}),t&&r.jsx(Yu,{data:t})]})},[Xu,ds]=Se(void 0),Zu=()=>ds(void 0),ed="_container_vcea9_2",td="_header_vcea9_2",nd="_key_vcea9_2",sd="_fields-container_vcea9_2",rd="_field-label_vcea9_2",od="_actions_vcea9_2",Bt={container:ed,header:td,key:nd,fieldsContainer:sd,fieldLabel:rd,actions:od},rt=()=>Date.now().toString(36)+Math.random().toString(36).substring(2),ad=({data:e})=>{const[t,{change:n,set:s,reset:o,touched:a}]=jn({}),i=nr(),[c,u]=l.useState(""),{data:d,isLoading:m}=Vu(e.dataSourceId,e.tableName,e.entityId),{mutateAsync:h,error:p}=Qu(),x=tr(p),b=Tn(pe.EDITOR),{data:g}=En(e.dataSourceId),{data:v}=cs(e.dataSourceId),y=l.useMemo(()=>g?.find(E=>E.tableName===e.tableName),[e.tableName,g]),f=l.useMemo(()=>{if(!y)return[];if(!c)return y.columns.map(j=>({...j,label:tt(j.name)}));const E=c.toLowerCase();return y.columns.filter(j=>j.name.toLowerCase().includes(E)).map(j=>({...j,label:tt(j.name)}))},[c,y]);l.useEffect(()=>{const E=d?.entity;if(o(),E&&d?.columns)for(let j=0;j<d.columns.length;j++){const S=d.columns[j];s(S.column,wt(E[j]))}},[d,s,o]);const w=()=>{const E=[];for(const j of a)E.push({value:t[j],column:j});h({datasourceId:e.dataSourceId,table:e.tableName,filters:e.entityId.map(j=>({id:rt(),value:[{value:j[1]}],column:j[0],connector:"AND",operator:"="})),values:E}).then(()=>{Zu(),i&&Ho(i)})},C=e.entityId.map(([E,j])=>`${E} = ${j}`).join(", ")||"",_=!v?.allowUpdate||!b;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:Bt.header,children:[r.jsxs("p",{className:"text-lg font-semibold",children:[_?"View":"Edit"," row in ",r.jsx("span",{className:"underline",children:e?.tableName})]}),r.jsx("span",{className:Bt.key,children:C}),x&&r.jsx(ne,{variant:"danger",children:r.jsx("p",{children:x})})]}),!_&&r.jsx("div",{className:"bg-gray-50 py-1 px-4 border-y border-gray-200",children:r.jsx("p",{className:"text-xs text-gray-800",children:"Tip: use = to write raw SQL. Ex: =NULL or =NOW()"})}),r.jsx("div",{className:Bt.container,children:r.jsx("div",{className:Bt.fieldsContainer,children:f.map(E=>r.jsxs("label",{className:Bt.fieldLabel,children:[r.jsxs("div",{className:"flex justify-between",children:[r.jsxs("p",{children:[E.isPrimary?"🔐":"🏷️"," ",E.label]}),r.jsxs("p",{className:"text-blue-800 text-sm",children:["[",E.name,": ",E.type,"]"]})]}),r.jsx("input",{disabled:E.isPrimary||m||_,className:"input w-full",value:wt(t[E.name]),onChange:n(E.name),placeholder:E.name})]},E.name))})}),r.jsxs("div",{className:Bt.actions,children:[r.jsxs("label",{children:[r.jsx("span",{className:"mr-2",children:"🔎"}),r.jsx("input",{className:"input bg-white!",value:c,onChange:E=>u(E.target.value),placeholder:"Filter columns"})]}),r.jsx("span",{className:"flex-1"}),!_&&r.jsx("button",{disabled:!a.length,className:"button primary",onClick:w,children:"Run update"})]})]})},id=()=>{const e=Xu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const s=()=>ds(void 0);return r.jsxs(ve,{isVisible:e!=null,onClose:s,onClosed:()=>n(void 0),noPadding:!0,children:[r.jsx(it,{onClick:s}),t&&r.jsx(ad,{data:t})]})},[ld,_s]=Se(void 0),Vo=async e=>new Promise(t=>{_s({message:e,onCancel:()=>{t(!1),_s(void 0)},onConfirm:()=>{t(!0),_s(void 0)}})}),cd=({confirm:e})=>r.jsxs("div",{children:[r.jsx("p",{children:e.message}),r.jsxs("div",{className:"flex gap-2 justify-end mt-4",children:[r.jsx("button",{className:"button tertiary",onClick:e.onCancel,children:"Cancel"}),r.jsx("button",{className:"button primary",onClick:e.onConfirm,children:"Confirm"})]})]}),ud=()=>{const e=ld(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),r.jsx(ve,{isVisible:!!e,onClose:()=>e?.onCancel(),onClosed:()=>n(void 0),children:t&&r.jsx(cd,{confirm:t})})},[dd,Jn]=Se(void 0),Ln=async(e,t,n)=>new Promise(s=>{Jn({message:e,defaultValue:t,alert:n,onCancel:()=>{Jn(void 0),s(void 0)},onConfirm:o=>{Jn(void 0),s(o)}})}),hd="_root_ng9lp_1",md={root:hd},fd=({data:e})=>{const[t,n]=l.useState("");l.useEffect(()=>{e.defaultValue&&n(e.defaultValue)},[e]);const s=a=>{n(a.target.value)},o=a=>{a.key==="Enter"&&(a.preventDefault(),e.onConfirm(t)),a.key==="Escape"&&(a.preventDefault(),e.onCancel())};return r.jsxs("div",{className:md.root,children:[r.jsx("h2",{className:"text-xl font-semibold",children:e.message}),e.alert&&r.jsx(ne,{variant:e.alert.type,className:"mt-2",children:e.alert.message}),r.jsx("input",{autoFocus:!0,className:"w-full input my-2",value:t,onChange:s,onKeyDown:o}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx("button",{className:"button tertiary",onClick:e.onCancel,children:"Cancel"}),r.jsx("button",{className:"button primary",onClick:()=>e.onConfirm(t),children:"Confirm"})]})]})},pd=()=>{const e=dd(),[t,n]=l.useState(void 0);return l.useEffect(()=>{e&&n(e)},[e]),r.jsx(ve,{isVisible:!!e,onClose:()=>Jn(void 0),onClosed:()=>n(void 0),children:t&&r.jsx(fd,{data:t})})},[xd,gd]=Se(void 0),Qo=e=>{gd(e)},bd="_textarea_68vbf_2",vd={textarea:bd},yd=()=>{const e=xd(),t=()=>{e&&(navigator.clipboard.writeText(e.toString()),je.success("Copied!"))},n=()=>Qo(void 0);return r.jsxs(ve,{isVisible:!!e,onClose:n,backdropClose:!0,children:[r.jsx("textarea",{className:vd.textarea,readOnly:!0,defaultValue:e?.toString()}),r.jsxs("div",{className:"mt-2 flex gap-1 justify-end",children:[r.jsx("button",{className:"button primary",onClick:t,children:"Copy"}),r.jsx("button",{className:"button tertiary",onClick:n,children:"Close"})]})]})},wd="_tabs_i8v6j_2",Cd="_mobile_i8v6j_2",jd="_tab_i8v6j_2",Nd="_active_i8v6j_2",_d="_close-button_i8v6j_2",gn={tabs:wd,mobile:Cd,tab:jd,active:Nd,closeButton:_d},Ir=e=>window.matchMedia(e).matches;function Go(e,{defaultValue:t=!1,initializeWithValue:n=!0}={}){const[s,o]=l.useState(()=>n?Ir(e):t);return l.useLayoutEffect(()=>{const a=window.matchMedia(e);function i(){o(()=>Ir(e))}return i(),a.addListener?a.addListener(i):a.addEventListener("change",i),()=>{a.removeListener?a.removeListener(i):a.removeEventListener("change",i)}},[e]),s}const sr={laptop:"(min-width: 1024px)"},Yo=()=>window.matchMedia(sr.laptop).matches,Sd="_table_56tu0_2",Ed="_row-index-btn_56tu0_2",kd="_semi-transparent_56tu0_2",Rd="_table-loading_56tu0_2",Td="_table-empty_56tu0_2",Ld="_table-row-cells_56tu0_2",Ad="_header-cell_56tu0_2",Pd="_header-actions_56tu0_2",Id="_cell_56tu0_2",Od="_value_56tu0_2",Md="_table-config_56tu0_2",$d="_table-action_56tu0_2",Dd="_green-fixed_56tu0_2",Fd="_gray_56tu0_2",Bd="_modal_56tu0_2",qd="_selected-size_56tu0_2",Ud="_pagination-indicator_56tu0_2",T={table:Sd,rowIndexBtn:Ed,semiTransparent:kd,tableLoading:Rd,tableEmpty:Td,tableRowCells:Ld,headerCell:Ad,headerActions:Pd,cell:Id,value:Od,tableConfig:Md,tableAction:$d,greenFixed:Dd,gray:Fd,modal:Bd,selectedSize:qd,paginationIndicator:Ud},qe=l.createContext({name:"No name",hooks:[],availableJoins:[],allColumns:[],dataSourceId:"",entities:[],getValue:()=>{},getColumnType:()=>{},getEntityKey:()=>[],getEntityKeyByRowIndex:()=>[]}),xe=l.createContext({state:en({}),setState:()=>{}}),Ae=l.createContext({}),Jo={ON_ANIMATION_END:Symbol("ON_TRANSITION_END")},Xo=()=>{const[e,t]=l.useState(),[n,s]=l.useState("hidden");return l.useMemo(()=>{const o=c=>{c.preventDefault(),s("in"),t({x:c.clientX-1,y:c.clientY-1})},a=()=>{s("out")},i=()=>{n==="in"?s("visible"):n==="out"&&(t(void 0),s("hidden"))};return{show:!!e,position:e,state:n,open:o,close:a,[Jo.ON_ANIMATION_END]:i}},[e,n])},Wd=e=>{if(e==="ASC")return"DESC";if(e!=="DESC")return"ASC"},Hd=()=>{const{state:e,setState:t}=l.useContext(xe),n=l.useCallback(s=>{t(o=>{const a=o.orderBy[0];if(a&&a.column===s){const i=Wd(a.direction);return i?{...o,orderBy:[{column:s,direction:i}]}:{...o,orderBy:[]}}return{...o,orderBy:[{column:s,direction:"ASC"}]}})},[t]);return{orderBy:e.orderBy,updateOrderBy:n}},zd="_options-container_fboyw_2",Kd="_filter-input_fboyw_2",Vd="_option-item_fboyw_2",Qd="_list_fboyw_2",Gd="_empty-text_fboyw_2",Qe={optionsContainer:zd,filterInput:Kd,optionItem:Vd,list:Qd,emptyText:Gd},Yd="_container_14l7a_2",Jd="_animate-show_14l7a_2",Xd="_animate-hide_14l7a_2",Zd="_content_14l7a_2",eh="_backdrop_14l7a_2",pt={container:Yd,animateShow:Jd,animateHide:Xd,content:Zd,backdrop:eh},Zo=({children:e,handler:t})=>{const n=l.useRef(t.close);n.current=t.close;const s=l.useMemo(()=>{if(!t.position)return;const o={};if(typeof window<"u"){const a=t.position.y>window.innerHeight/2,i=t.position.x>window.innerWidth/2;a?o.bottom=window.innerHeight-t.position.y:o.top=t.position.y,Yo()?i?o.right=window.innerWidth-t.position.x:o.left=t.position.x:(o.right=36,o.left=36)}return o},[t.position]);return l.useEffect(()=>{const o=a=>{a.code==="Escape"&&n.current()};return window.addEventListener("keyup",o),()=>{window.removeEventListener("keyup",o)}},[]),s?r.jsxs("div",{className:A(pt.container,t.state==="out"&&pt.animateHide,t.state==="in"&&pt.animateShow),onAnimationEnd:t[Jo.ON_ANIMATION_END],children:[r.jsx("div",{className:pt.backdrop,onClick:o=>{o.stopPropagation(),o.preventDefault(),t.close()}}),r.jsx("div",{className:A(pt.content,t.state==="out"&&pt.animateHide,t.state==="in"&&pt.animateShow),style:s,children:e})]}):null},De=(e,t)=>e!=null&&e>t,th=(e,t)=>e!=null&&e<t,nh="_root_ki4vr_2",sh="_content_ki4vr_2",rh="_table-name_ki4vr_2",oh="_sub_ki4vr_2",zn={root:nh,content:sh,tableName:rh,sub:oh},ea=({hook:e,onClick:t})=>r.jsxs("button",{className:zn.root,onClick:t,children:[r.jsx("span",{children:"📄"}),r.jsxs("div",{className:zn.content,children:[r.jsx("span",{className:zn.tableName,children:e.on.toTable}),r.jsxs("span",{className:zn.sub,children:[e.on.toColumn," = ",e.on.fromTable,".",e.on.fromColumn]})]})]},e.where),ah=A("input",Qe.filterInput);function ih(e,t,n){return{name:`${e.on.toTable} ${e.on.toColumn} equals ${n}`,opts:en({table:e.on.toTable,dataSourceId:t,filters:[{id:rt(),column:`${e.on.toTable}.${e.on.toColumn}`,value:n==null?"IS NULL":`${n}`,isEnabled:!0}]})}}const ta=({rowIndex:e,onClose:t,className:n})=>{const[s,o]=l.useState(""),{hooks:a,dataSourceId:i,getValue:c}=l.useContext(qe),{state:u}=l.useContext(xe),{data:d}=l.useContext(Ae),m=l.useMemo(()=>d?.result.rows[e],[d,e]),h=tn(),p=Y(),x=l.useMemo(()=>{if(!d)return[];const f=s.toLowerCase();return a.filter(w=>d.result.columns.some(_=>_.column===w.on.fromColumn&&_.table===w.on.fromTable)?w.on.toTable.toLowerCase().includes(f):!1)},[s,a,d]),b=f=>{m&&h.mutateAsync(ih(f,i,c(m,{value:`${f.on.fromTable}.${f.on.fromColumn}`}))).then(w=>{p(P.workbenchTab.build({id:w.id})),t?.()})},g=()=>{!m||!u||h.mutateAsync({name:`${u.table} > [${u.joins.map(f=>f.table).join()}]`,opts:en({joins:u.joins,table:u.table,dataSourceId:u.dataSourceId,filters:[...u.filters.filter(f=>f.isEnabled),...u.groupBy.map(f=>({id:rt(),column:f.value,value:`${c(m,f)}`,isEnabled:!0}))]})}).then(f=>{p(P.workbenchTab.build({id:f.id})),t?.()})},v=u.groupBy.length>0,y=De(x.length,0);return r.jsxs("div",{className:n,children:[r.jsx("input",{className:ah,placeholder:"Filter",value:s,onChange:f=>o(f.target.value)}),r.jsxs("div",{className:Qe.list,children:[v&&r.jsx("button",{onClick:g,className:Qe.optionItem,children:"🎯 Underlying rows"}),y&&x.map(f=>r.jsx(ea,{hook:f,onClick:()=>b(f)},f.where)),!v&&!y&&r.jsx("p",{className:Qe.emptyText,children:"Empty"})]})]})},lh=({handler:e,rowIndex:t})=>r.jsx(Zo,{handler:e,children:r.jsx("div",{className:Qe.optionsContainer,children:r.jsx(ta,{rowIndex:t,className:"p-2",onClose:()=>{e.close()}})})}),rr=()=>{const{state:e,setState:t}=l.useContext(xe),n=l.useCallback((o,a=!1)=>{t(i=>({...i,page:a?0:i.page,filters:o}))},[t]),s=l.useCallback(o=>{t(a=>({...a,filters:a.filters.filter(i=>i.id!==o)}))},[t]);return{filters:e.filters,removeFilter:s,setFilters:n}},ch=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"})),Ge=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"})),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:32,d:"M464 208L352 96 240 208M352 113.13V416M48 304l112 112 112-112M160 398V96"})),na=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"})),dh="_container_flyao_2",hh="_animate-show_flyao_2",mh="_animate-hide_flyao_2",fh="_backdrop_flyao_2",ph="_content_flyao_2",xt={container:dh,animateShow:hh,animateHide:mh,backdrop:fh,content:ph},sa=({children:e,ref:t,onClosed:n})=>{const[s,o]=l.useState(void 0),[a,i]=l.useState("hidden"),c=l.useRef(null);if(l.useImperativeHandle(t,()=>({open:(m,h=!0)=>{h||(m.preventDefault(),m.stopPropagation());const p={},x=m.clientY>window.innerHeight/2,b=m.clientX>window.innerWidth/2;x?p.bottom=window.innerHeight-m.clientY:p.top=m.clientY,Yo()?b?p.right=window.innerWidth-m.clientX:p.left=m.clientX:(p.right=36,p.left=36),o(p),i("in")},close:()=>{i("out")}}),[]),!s)return null;const u=()=>{a==="in"?i("visible"):a==="out"&&(o(void 0),i("hidden"),n?.())},d=r.jsxs("div",{className:A(xt.container,a==="out"&&xt.animateHide,a==="in"&&xt.animateShow),onAnimationEnd:u,children:[r.jsx("div",{className:xt.backdrop,onClick:()=>i("out")}),r.jsx("div",{ref:c,style:s,className:A(xt.content,a==="out"&&xt.animateHide,a==="in"&&xt.animateShow),children:e})]});return Ro.createPortal(d,document.body)};function Ss(e,t,n){const s=e?.rows?.[t]?.[n],o=e?.columns?.[n];return{value:s,column:o}}const xh=({ref:e})=>{const{data:t}=l.useContext(Ae),{getColumnType:n}=l.useContext(qe),{setState:s}=l.useContext(xe);return{copyValue:(c,u)=>{const{value:d,column:m}=Ss(t?.result,c,u);if(m){const h=wt(d,n(m.full));navigator.clipboard.writeText(h),je.success("Copied!"),e.current?.close()}},showValue:(c,u)=>{const{value:d,column:m}=Ss(t?.result,c,u);if(m){const h=wt(d,n(m.full));Qo(h),e.current?.close()}},filterValue:(c,u)=>{const{value:d,column:m}=Ss(t?.result,c,u),h=m?.full||"";if(m?.table===""){je.error("Filtering on aggregated column is not supported yet");return}if(h){let p;if(d==null)p={id:rt(),isEnabled:!0,column:h,value:"IS NULL"};else{const x=wt(d,n(h));p={id:rt(),isEnabled:!0,column:h,value:x}}s(x=>({...x,filters:[...x.filters,p]})),je.success(`Added new filter on column ${m?.alias}`),e.current?.close()}}}},ra=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})),gh=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_2c7gu_2",vh="_item_2c7gu_2",gt={sectionName:bh,item:vh},oa=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:32,d:"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"})),yh=A("input",Qe.filterInput),wh=({onClose:e,rowIndex:t,className:n})=>{const[s,o]=l.useState(""),{entities:a,dataSourceId:i,getEntityKey:c}=l.useContext(qe),{data:u}=l.useContext(Ae),d=l.useMemo(()=>u?.result.rows[t],[u,t]),m=l.useMemo(()=>s?a.filter(p=>p.includes(s)):a,[a,s]),h=p=>{if(!d)return;const x=c(p,d);ds({tableName:p,dataSourceId:i,entityId:x}),e?.()};return r.jsxs("div",{className:n,children:[r.jsx("input",{className:yh,placeholder:"Filter",value:s,onChange:p=>o(p.target.value)}),r.jsx("div",{className:Qe.list,children:De(m.length,0)?m.map(p=>r.jsx("button",{className:Qe.optionItem,onClick:()=>h(p),children:r.jsxs("span",{children:["📄 ",p]})},p)):r.jsx("p",{className:Qe.emptyText,children:"Empty"})})]})},Ch=({ref:e,row:t,col:n,onClosed:s})=>{const o=xh({ref:e}),[a,i]=l.useState("cell"),{entities:c,dataSourceId:u,getEntityKeyByRowIndex:d}=l.useContext(qe),m=()=>o.copyValue(t,n),h=()=>o.showValue(t,n),p=()=>o.filterValue(t,n),x=()=>{if(c.length===1){const g=d(c[0],t);ds({tableName:c[0],dataSourceId:u,entityId:g}),e.current?.close()}else i("expand")},b=()=>{s?.(),i("cell")};return r.jsx(sa,{ref:e,onClosed:b,children:r.jsxs("div",{className:"w-full lg:w-sm",children:[a==="cell"&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:gt.sectionName,children:"Cell actions"}),r.jsxs("button",{className:gt.item,onClick:m,children:[r.jsx(ra,{width:14,height:14}),"Copy"]}),r.jsxs("button",{className:gt.item,onClick:h,children:[r.jsx(gh,{width:14,height:14}),"View"]}),r.jsxs("button",{className:gt.item,onClick:p,children:[r.jsx(na,{width:14,height:14}),"Filter"]}),r.jsx("p",{className:gt.sectionName,children:"Row actions"}),r.jsxs("button",{className:gt.item,onClick:()=>i("drill"),children:[r.jsx(Ge,{width:14,height:14}),"Drill down"]}),c?.length>0&&r.jsxs("button",{className:gt.item,onClick:x,children:[r.jsx(oa,{width:14,height:14}),"Edit row"]})]}),a==="drill"&&r.jsxs(r.Fragment,{children:[r.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:[r.jsx(Ge,{className:"rotate-180",width:16,height:16}),"Drill down"]}),r.jsx(ta,{rowIndex:t,onClose:()=>e.current?.close()})]}),a==="expand"&&r.jsxs(r.Fragment,{children:[r.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:[r.jsx(Ge,{className:"rotate-180",width:16,height:16}),"Select entity"]}),r.jsx(wh,{rowIndex:t,onClose:()=>e.current?.close()})]})]})})},jh={DESC:"",ASC:"rotate-180"},Nh=(e,{column:t,value:n})=>{const s=e.map(o=>({...o,isEnabled:o.column===t?!1:o.isEnabled}));return s.push({id:rt(),column:t,isEnabled:!0,value:n,isAdvanced:!1}),s},_h=()=>{const{data:e}=l.useContext(Ae),{orderBy:t,updateOrderBy:n}=Hd(),{setFilters:s,filters:o}=rr(),a=e?.result.columns||[],i=t[0],c=De(e?.result.tables.length,1),u=d=>{Ln("Filter value","").then(m=>{m&&s(Nh(o,{column:d,value:m}))})};return r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("td",{children:"🥢"}),a.map(d=>r.jsxs("td",{className:T.headerCell,children:[r.jsxs("div",{className:"overflow-hidden",children:[c&&r.jsx("p",{className:"text-xs truncate italic",children:d.table||"-"}),r.jsx("p",{className:"text-sm font-semibold truncate",children:d.column})]}),r.jsxs("div",{className:T.headerActions,children:[r.jsx("button",{onClick:()=>n(d.full),children:i?.column===d.full?r.jsx(ch,{className:jh[i.direction],width:16,height:16}):r.jsx(uh,{width:16,height:16})}),d.table&&r.jsx("button",{onClick:()=>u(d.full),children:r.jsx(na,{width:16,height:16})})]})]},d.full))]})})};function Sh({value:e}){if(e==="")return r.jsx("span",{className:"pointer-events-none text-black/30 truncate",children:"<EMPTY STRING>"});if(e==null)return r.jsx("span",{className:"pointer-events-none text-black/30",children:"<NULL>"});const t=wt(e);return r.jsx("span",{className:T.value,children:t})}const Eh=l.memo(({row:e,isLastRow:t,index:n,offset:s})=>r.jsxs("tr",{className:A(T.tableRowCells,t&&"rounded-b-lg"),children:[r.jsx("td",{children:r.jsxs("button",{"data-row-action":n,className:T.rowIndexBtn,children:[r.jsx(Ge,{className:"pointer-events-none",width:16,height:16}),n+1+s]})}),e.map((o,a)=>r.jsx("td",{className:T.cell,"data-row":n,"data-col":a,children:r.jsx(Sh,{value:o})},a))]})),kh=()=>{const{data:e,error:t,isLoading:n,isFetching:s}=l.useContext(Ae),{state:{page:o,size:a}}=l.useContext(xe),i=l.useRef(null),c=tr(t),u=Xo(),[d,m]=l.useState(void 0),[h,p]=l.useState(void 0),x=v=>{const f=v.target?.dataset?.rowAction;f!=null&&(m(parseInt(f)),u.open(v))},b=v=>{const y=v.target?.dataset,f=y?.row,w=y?.col;f!=null&&w!=null&&(m(parseInt(f)),p(parseInt(w)),i.current?.open(v),v.preventDefault(),v.stopPropagation())},g=o*a;return r.jsxs(r.Fragment,{children:[d!=null&&u.show&&r.jsx(lh,{handler:u,rowIndex:d}),r.jsx(Ch,{ref:i,col:h,row:d,onClosed:()=>{m(void 0),p(void 0)}}),c&&r.jsx(ne,{variant:"danger",children:c}),n&&r.jsx("div",{className:T.tableLoading,children:"Loading data"}),e&&r.jsxs("table",{className:A(T.table,s&&T.semiTransparent),onClick:x,onContextMenu:b,children:[r.jsx(_h,{}),r.jsxs("tbody",{children:[e.result.rows?.length<1&&r.jsx("tr",{className:T.tableEmpty,children:r.jsx("td",{colSpan:e.result.columns.length+1,children:"No data"})}),e.result.rows?.map((v,y)=>r.jsx(Eh,{index:y,offset:g,row:v,isLastRow:y===e.result.rows.length-1},y))]})]})]})},aa=()=>{const{state:e,setState:t}=l.useContext(xe),n=l.useCallback(o=>{t(a=>({...a,page:o}))},[t]),s=l.useCallback((o,a=!1)=>{t(i=>({...i,size:o,page:a?0:i.page}))},[t]);return{page:e.page,size:e.size,setSize:s,setPage:n}},Rh=()=>X({mutationFn:async e=>{const{data:t}=await O.post("/saved-queries",e);return t.data},onSuccess:()=>{Q.invalidateQueries({queryKey:["queries"]}),Xt(),$o()}}),Th=()=>X({mutationFn:async e=>O.delete("/saved-queries/"+e),onSuccess:()=>{Xt(),$o()}}),Lh=()=>X({mutationFn:async({id:e,payload:t})=>{const{data:n}=await O.patch("/saved-queries/"+e,t);return n.data},onSuccess:()=>{Xt(),Gl()}}),[hs,or]=Se({filters:!1,joins:!1,columns:!1,groupBy:!1,aggregate:!1}),Me=e=>or(t=>({...t,[e]:!0})),ms=e=>or(t=>({...t,[e]:!1})),ts=e=>or(t=>({...t,[e]:!t[e]})),Qt=Math.min,Ct=Math.max,ns=Math.round,Kn=Math.floor,$e=e=>({x:e,y:e}),Ah={left:"right",right:"left",bottom:"top",top:"bottom"},Ph={start:"end",end:"start"};function Fs(e,t,n){return Ct(e,Qt(t,n))}function An(e,t){return typeof e=="function"?e(t):e}function Nt(e){return e.split("-")[0]}function Pn(e){return e.split("-")[1]}function ia(e){return e==="x"?"y":"x"}function ar(e){return e==="y"?"height":"width"}const Ih=new Set(["top","bottom"]);function nt(e){return Ih.has(Nt(e))?"y":"x"}function ir(e){return ia(nt(e))}function Oh(e,t,n){n===void 0&&(n=!1);const s=Pn(e),o=ir(e),a=ar(o);let i=o==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=ss(i)),[i,ss(i)]}function Mh(e){const t=ss(e);return[Bs(e),t,Bs(t)]}function Bs(e){return e.replace(/start|end/g,t=>Ph[t])}const Or=["left","right"],Mr=["right","left"],$h=["top","bottom"],Dh=["bottom","top"];function Fh(e,t,n){switch(e){case"top":case"bottom":return n?t?Mr:Or:t?Or:Mr;case"left":case"right":return t?$h:Dh;default:return[]}}function Bh(e,t,n,s){const o=Pn(e);let a=Fh(Nt(e),n==="start",s);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(Bs)))),a}function ss(e){return e.replace(/left|right|bottom|top/g,t=>Ah[t])}function qh(e){return{top:0,right:0,bottom:0,left:0,...e}}function la(e){return typeof e!="number"?qh(e):{top:e,right:e,bottom:e,left:e}}function rs(e){const{x:t,y:n,width:s,height:o}=e;return{width:s,height:o,top:n,left:t,right:t+s,bottom:n+o,x:t,y:n}}function $r(e,t,n){let{reference:s,floating:o}=e;const a=nt(t),i=ir(t),c=ar(i),u=Nt(t),d=a==="y",m=s.x+s.width/2-o.width/2,h=s.y+s.height/2-o.height/2,p=s[c]/2-o[c]/2;let x;switch(u){case"top":x={x:m,y:s.y-o.height};break;case"bottom":x={x:m,y:s.y+s.height};break;case"right":x={x:s.x+s.width,y:h};break;case"left":x={x:s.x-o.width,y:h};break;default:x={x:s.x,y:s.y}}switch(Pn(t)){case"start":x[i]-=p*(n&&d?-1:1);break;case"end":x[i]+=p*(n&&d?-1:1);break}return x}const Uh=async(e,t,n)=>{const{placement:s="bottom",strategy:o="absolute",middleware:a=[],platform:i}=n,c=a.filter(Boolean),u=await(i.isRTL==null?void 0:i.isRTL(t));let d=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:m,y:h}=$r(d,s,u),p=s,x={},b=0;for(let g=0;g<c.length;g++){const{name:v,fn:y}=c[g],{x:f,y:w,data:C,reset:_}=await y({x:m,y:h,initialPlacement:s,placement:p,strategy:o,middlewareData:x,rects:d,platform:i,elements:{reference:e,floating:t}});m=f??m,h=w??h,x={...x,[v]:{...x[v],...C}},_&&b<=50&&(b++,typeof _=="object"&&(_.placement&&(p=_.placement),_.rects&&(d=_.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):_.rects),{x:m,y:h}=$r(d,p,u)),g=-1)}return{x:m,y:h,placement:p,strategy:o,middlewareData:x}};async function ca(e,t){var n;t===void 0&&(t={});const{x:s,y:o,platform:a,rects:i,elements:c,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:m="viewport",elementContext:h="floating",altBoundary:p=!1,padding:x=0}=An(t,e),b=la(x),v=c[p?h==="floating"?"reference":"floating":h],y=rs(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(v)))==null||n?v:v.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:d,rootBoundary:m,strategy:u})),f=h==="floating"?{x:s,y:o,width:i.floating.width,height:i.floating.height}:i.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),C=await(a.isElement==null?void 0:a.isElement(w))?await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1}:{x:1,y:1},_=rs(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:f,offsetParent:w,strategy:u}):f);return{top:(y.top-_.top+b.top)/C.y,bottom:(_.bottom-y.bottom+b.bottom)/C.y,left:(y.left-_.left+b.left)/C.x,right:(_.right-y.right+b.right)/C.x}}const Wh=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:o,rects:a,platform:i,elements:c,middlewareData:u}=t,{element:d,padding:m=0}=An(e,t)||{};if(d==null)return{};const h=la(m),p={x:n,y:s},x=ir(o),b=ar(x),g=await i.getDimensions(d),v=x==="y",y=v?"top":"left",f=v?"bottom":"right",w=v?"clientHeight":"clientWidth",C=a.reference[b]+a.reference[x]-p[x]-a.floating[b],_=p[x]-a.reference[x],E=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d));let j=E?E[w]:0;(!j||!await(i.isElement==null?void 0:i.isElement(E)))&&(j=c.floating[w]||a.floating[b]);const S=C/2-_/2,I=j/2-g[b]/2-1,B=Qt(h[y],I),se=Qt(h[f],I),ye=B,Pe=j-g[b]-se,U=j/2-g[b]/2+S,de=Fs(ye,U,Pe),re=!u.arrow&&Pn(o)!=null&&U!==de&&a.reference[b]/2-(U<ye?B:se)-g[b]/2<0,J=re?U<ye?U-ye:U-Pe:0;return{[x]:p[x]+J,data:{[x]:de,centerOffset:U-de-J,...re&&{alignmentOffset:J}},reset:re}}}),Hh=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:o,middlewareData:a,rects:i,initialPlacement:c,platform:u,elements:d}=t,{mainAxis:m=!0,crossAxis:h=!0,fallbackPlacements:p,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:g=!0,...v}=An(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const y=Nt(o),f=nt(c),w=Nt(c)===c,C=await(u.isRTL==null?void 0:u.isRTL(d.floating)),_=p||(w||!g?[ss(c)]:Mh(c)),E=b!=="none";!p&&E&&_.push(...Bh(c,g,b,C));const j=[c,..._],S=await ca(t,v),I=[];let B=((s=a.flip)==null?void 0:s.overflows)||[];if(m&&I.push(S[y]),h){const U=Oh(o,i,C);I.push(S[U[0]],S[U[1]])}if(B=[...B,{placement:o,overflows:I}],!I.every(U=>U<=0)){var se,ye;const U=(((se=a.flip)==null?void 0:se.index)||0)+1,de=j[U];if(de&&(!(h==="alignment"?f!==nt(de):!1)||B.every(z=>nt(z.placement)===f?z.overflows[0]>0:!0)))return{data:{index:U,overflows:B},reset:{placement:de}};let re=(ye=B.filter(J=>J.overflows[0]<=0).sort((J,z)=>J.overflows[1]-z.overflows[1])[0])==null?void 0:ye.placement;if(!re)switch(x){case"bestFit":{var Pe;const J=(Pe=B.filter(z=>{if(E){const oe=nt(z.placement);return oe===f||oe==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(oe=>oe>0).reduce((oe,We)=>oe+We,0)]).sort((z,oe)=>z[1]-oe[1])[0])==null?void 0:Pe[0];J&&(re=J);break}case"initialPlacement":re=c;break}if(o!==re)return{reset:{placement:re}}}return{}}}},zh=new Set(["left","top"]);async function Kh(e,t){const{placement:n,platform:s,elements:o}=e,a=await(s.isRTL==null?void 0:s.isRTL(o.floating)),i=Nt(n),c=Pn(n),u=nt(n)==="y",d=zh.has(i)?-1:1,m=a&&u?-1:1,h=An(t,e);let{mainAxis:p,crossAxis:x,alignmentAxis:b}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return c&&typeof b=="number"&&(x=c==="end"?b*-1:b),u?{x:x*m,y:p*d}:{x:p*d,y:x*m}}const Vh=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:o,y:a,placement:i,middlewareData:c}=t,u=await Kh(t,e);return i===((n=c.offset)==null?void 0:n.placement)&&(s=c.arrow)!=null&&s.alignmentOffset?{}:{x:o+u.x,y:a+u.y,data:{...u,placement:i}}}}},Qh=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:o}=t,{mainAxis:a=!0,crossAxis:i=!1,limiter:c={fn:v=>{let{x:y,y:f}=v;return{x:y,y:f}}},...u}=An(e,t),d={x:n,y:s},m=await ca(t,u),h=nt(Nt(o)),p=ia(h);let x=d[p],b=d[h];if(a){const v=p==="y"?"top":"left",y=p==="y"?"bottom":"right",f=x+m[v],w=x-m[y];x=Fs(f,x,w)}if(i){const v=h==="y"?"top":"left",y=h==="y"?"bottom":"right",f=b+m[v],w=b-m[y];b=Fs(f,b,w)}const g=c.fn({...t,[p]:x,[h]:b});return{...g,data:{x:g.x-n,y:g.y-s,enabled:{[p]:a,[h]:i}}}}}};function fs(){return typeof window<"u"}function nn(e){return ua(e)?(e.nodeName||"").toLowerCase():"#document"}function be(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ue(e){var t;return(t=(ua(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ua(e){return fs()?e instanceof Node||e instanceof be(e).Node:!1}function Te(e){return fs()?e instanceof Element||e instanceof be(e).Element:!1}function Fe(e){return fs()?e instanceof HTMLElement||e instanceof be(e).HTMLElement:!1}function Dr(e){return!fs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof be(e).ShadowRoot}const Gh=new Set(["inline","contents"]);function In(e){const{overflow:t,overflowX:n,overflowY:s,display:o}=Le(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!Gh.has(o)}const Yh=new Set(["table","td","th"]);function Jh(e){return Yh.has(nn(e))}const Xh=[":popover-open",":modal"];function ps(e){return Xh.some(t=>{try{return e.matches(t)}catch{return!1}})}const Zh=["transform","translate","scale","rotate","perspective"],em=["transform","translate","scale","rotate","perspective","filter"],tm=["paint","layout","strict","content"];function lr(e){const t=cr(),n=Te(e)?Le(e):e;return Zh.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||em.some(s=>(n.willChange||"").includes(s))||tm.some(s=>(n.contain||"").includes(s))}function nm(e){let t=ot(e);for(;Fe(t)&&!Gt(t);){if(lr(t))return t;if(ps(t))return null;t=ot(t)}return null}function cr(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const sm=new Set(["html","body","#document"]);function Gt(e){return sm.has(nn(e))}function Le(e){return be(e).getComputedStyle(e)}function xs(e){return Te(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ot(e){if(nn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Dr(e)&&e.host||Ue(e);return Dr(t)?t.host:t}function da(e){const t=ot(e);return Gt(t)?e.ownerDocument?e.ownerDocument.body:e.body:Fe(t)&&In(t)?t:da(t)}function Cn(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=da(e),a=o===((s=e.ownerDocument)==null?void 0:s.body),i=be(o);if(a){const c=qs(i);return t.concat(i,i.visualViewport||[],In(o)?o:[],c&&n?Cn(c):[])}return t.concat(o,Cn(o,[],n))}function qs(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ha(e){const t=Le(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const o=Fe(e),a=o?e.offsetWidth:n,i=o?e.offsetHeight:s,c=ns(n)!==a||ns(s)!==i;return c&&(n=a,s=i),{width:n,height:s,$:c}}function ur(e){return Te(e)?e:e.contextElement}function Ht(e){const t=ur(e);if(!Fe(t))return $e(1);const n=t.getBoundingClientRect(),{width:s,height:o,$:a}=ha(t);let i=(a?ns(n.width):n.width)/s,c=(a?ns(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const rm=$e(0);function ma(e){const t=be(e);return!cr()||!t.visualViewport?rm:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function om(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==be(e)?!1:t}function _t(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=ur(e);let i=$e(1);t&&(s?Te(s)&&(i=Ht(s)):i=Ht(e));const c=om(a,n,s)?ma(a):$e(0);let u=(o.left+c.x)/i.x,d=(o.top+c.y)/i.y,m=o.width/i.x,h=o.height/i.y;if(a){const p=be(a),x=s&&Te(s)?be(s):s;let b=p,g=qs(b);for(;g&&s&&x!==b;){const v=Ht(g),y=g.getBoundingClientRect(),f=Le(g),w=y.left+(g.clientLeft+parseFloat(f.paddingLeft))*v.x,C=y.top+(g.clientTop+parseFloat(f.paddingTop))*v.y;u*=v.x,d*=v.y,m*=v.x,h*=v.y,u+=w,d+=C,b=be(g),g=qs(b)}}return rs({width:m,height:h,x:u,y:d})}function gs(e,t){const n=xs(e).scrollLeft;return t?t.left+n:_t(Ue(e)).left+n}function fa(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-gs(e,n),o=n.top+t.scrollTop;return{x:s,y:o}}function am(e){let{elements:t,rect:n,offsetParent:s,strategy:o}=e;const a=o==="fixed",i=Ue(s),c=t?ps(t.floating):!1;if(s===i||c&&a)return n;let u={scrollLeft:0,scrollTop:0},d=$e(1);const m=$e(0),h=Fe(s);if((h||!h&&!a)&&((nn(s)!=="body"||In(i))&&(u=xs(s)),Fe(s))){const x=_t(s);d=Ht(s),m.x=x.x+s.clientLeft,m.y=x.y+s.clientTop}const p=i&&!h&&!a?fa(i,u):$e(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+m.x+p.x,y:n.y*d.y-u.scrollTop*d.y+m.y+p.y}}function im(e){return Array.from(e.getClientRects())}function lm(e){const t=Ue(e),n=xs(e),s=e.ownerDocument.body,o=Ct(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),a=Ct(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let i=-n.scrollLeft+gs(e);const c=-n.scrollTop;return Le(s).direction==="rtl"&&(i+=Ct(t.clientWidth,s.clientWidth)-o),{width:o,height:a,x:i,y:c}}const Fr=25;function cm(e,t){const n=be(e),s=Ue(e),o=n.visualViewport;let a=s.clientWidth,i=s.clientHeight,c=0,u=0;if(o){a=o.width,i=o.height;const m=cr();(!m||m&&t==="fixed")&&(c=o.offsetLeft,u=o.offsetTop)}const d=gs(s);if(d<=0){const m=s.ownerDocument,h=m.body,p=getComputedStyle(h),x=m.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,b=Math.abs(s.clientWidth-h.clientWidth-x);b<=Fr&&(a-=b)}else d<=Fr&&(a+=d);return{width:a,height:i,x:c,y:u}}const um=new Set(["absolute","fixed"]);function dm(e,t){const n=_t(e,!0,t==="fixed"),s=n.top+e.clientTop,o=n.left+e.clientLeft,a=Fe(e)?Ht(e):$e(1),i=e.clientWidth*a.x,c=e.clientHeight*a.y,u=o*a.x,d=s*a.y;return{width:i,height:c,x:u,y:d}}function Br(e,t,n){let s;if(t==="viewport")s=cm(e,n);else if(t==="document")s=lm(Ue(e));else if(Te(t))s=dm(t,n);else{const o=ma(e);s={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return rs(s)}function pa(e,t){const n=ot(e);return n===t||!Te(n)||Gt(n)?!1:Le(n).position==="fixed"||pa(n,t)}function hm(e,t){const n=t.get(e);if(n)return n;let s=Cn(e,[],!1).filter(c=>Te(c)&&nn(c)!=="body"),o=null;const a=Le(e).position==="fixed";let i=a?ot(e):e;for(;Te(i)&&!Gt(i);){const c=Le(i),u=lr(i);!u&&c.position==="fixed"&&(o=null),(a?!u&&!o:!u&&c.position==="static"&&!!o&&um.has(o.position)||In(i)&&!u&&pa(e,i))?s=s.filter(m=>m!==i):o=c,i=ot(i)}return t.set(e,s),s}function mm(e){let{element:t,boundary:n,rootBoundary:s,strategy:o}=e;const i=[...n==="clippingAncestors"?ps(t)?[]:hm(t,this._c):[].concat(n),s],c=i[0],u=i.reduce((d,m)=>{const h=Br(t,m,o);return d.top=Ct(h.top,d.top),d.right=Qt(h.right,d.right),d.bottom=Qt(h.bottom,d.bottom),d.left=Ct(h.left,d.left),d},Br(t,c,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function fm(e){const{width:t,height:n}=ha(e);return{width:t,height:n}}function pm(e,t,n){const s=Fe(t),o=Ue(t),a=n==="fixed",i=_t(e,!0,a,t);let c={scrollLeft:0,scrollTop:0};const u=$e(0);function d(){u.x=gs(o)}if(s||!s&&!a)if((nn(t)!=="body"||In(o))&&(c=xs(t)),s){const x=_t(t,!0,a,t);u.x=x.x+t.clientLeft,u.y=x.y+t.clientTop}else o&&d();a&&!s&&o&&d();const m=o&&!s&&!a?fa(o,c):$e(0),h=i.left+c.scrollLeft-u.x-m.x,p=i.top+c.scrollTop-u.y-m.y;return{x:h,y:p,width:i.width,height:i.height}}function Es(e){return Le(e).position==="static"}function qr(e,t){if(!Fe(e)||Le(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ue(e)===n&&(n=n.ownerDocument.body),n}function xa(e,t){const n=be(e);if(ps(e))return n;if(!Fe(e)){let o=ot(e);for(;o&&!Gt(o);){if(Te(o)&&!Es(o))return o;o=ot(o)}return n}let s=qr(e,t);for(;s&&Jh(s)&&Es(s);)s=qr(s,t);return s&&Gt(s)&&Es(s)&&!lr(s)?n:s||nm(e)||n}const xm=async function(e){const t=this.getOffsetParent||xa,n=this.getDimensions,s=await n(e.floating);return{reference:pm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function gm(e){return Le(e).direction==="rtl"}const bm={convertOffsetParentRelativeRectToViewportRelativeRect:am,getDocumentElement:Ue,getClippingRect:mm,getOffsetParent:xa,getElementRects:xm,getClientRects:im,getDimensions:fm,getScale:Ht,isElement:Te,isRTL:gm};function ga(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function vm(e,t){let n=null,s;const o=Ue(e);function a(){var c;clearTimeout(s),(c=n)==null||c.disconnect(),n=null}function i(c,u){c===void 0&&(c=!1),u===void 0&&(u=1),a();const d=e.getBoundingClientRect(),{left:m,top:h,width:p,height:x}=d;if(c||t(),!p||!x)return;const b=Kn(h),g=Kn(o.clientWidth-(m+p)),v=Kn(o.clientHeight-(h+x)),y=Kn(m),w={rootMargin:-b+"px "+-g+"px "+-v+"px "+-y+"px",threshold:Ct(0,Qt(1,u))||1};let C=!0;function _(E){const j=E[0].intersectionRatio;if(j!==u){if(!C)return i();j?i(!1,j):s=setTimeout(()=>{i(!1,1e-7)},1e3)}j===1&&!ga(d,e.getBoundingClientRect())&&i(),C=!1}try{n=new IntersectionObserver(_,{...w,root:o.ownerDocument})}catch{n=new IntersectionObserver(_,w)}n.observe(e)}return i(!0),a}function ym(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=s,d=ur(e),m=o||a?[...d?Cn(d):[],...Cn(t)]:[];m.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),a&&y.addEventListener("resize",n)});const h=d&&c?vm(d,n):null;let p=-1,x=null;i&&(x=new ResizeObserver(y=>{let[f]=y;f&&f.target===d&&x&&(x.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var w;(w=x)==null||w.observe(t)})),n()}),d&&!u&&x.observe(d),x.observe(t));let b,g=u?_t(e):null;u&&v();function v(){const y=_t(e);g&&!ga(g,y)&&n(),g=y,b=requestAnimationFrame(v)}return n(),()=>{var y;m.forEach(f=>{o&&f.removeEventListener("scroll",n),a&&f.removeEventListener("resize",n)}),h?.(),(y=x)==null||y.disconnect(),x=null,u&&cancelAnimationFrame(b)}}const wm=Vh,Cm=Qh,jm=Hh,Nm=Wh,Ur=(e,t,n)=>{const s=new Map,o={platform:bm,...n},a={...o.platform,_c:s};return Uh(e,t,{...o,platform:a})};var ks={exports:{}};var Wr;function _m(){return Wr||(Wr=1,(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var a="",i=0;i<arguments.length;i++){var c=arguments[i];c&&(a=o(a,s(c)))}return a}function s(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=o(i,c));return i}function o(a,i){return i?a?a+" "+i:a+i:a}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(ks)),ks.exports}var Sm=_m();const Us=Ja(Sm);var Hr={};const Em="react-tooltip-core-styles",km="react-tooltip-base-styles",zr={core:!1,base:!1};function Kr({css:e,id:t=km,type:n="base",ref:s}){var o,a;if(!e||typeof document>"u"||zr[n]||n==="core"&&typeof process<"u"&&(!((o=process==null?void 0:Hr)===null||o===void 0)&&o.REACT_TOOLTIP_DISABLE_CORE_STYLES)||n!=="base"&&typeof process<"u"&&(!((a=process==null?void 0:Hr)===null||a===void 0)&&a.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;n==="core"&&(t=Em),s||(s={});const{insertAt:i}=s;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)),zr[n]=!0}const Vr=async({elementReference:e=null,tooltipReference:t=null,tooltipArrowReference:n=null,place:s="top",offset:o=10,strategy:a="absolute",middlewares:i=[wm(Number(o)),jm({fallbackAxisSideDirection:"start"}),Cm({padding:5})],border:c,arrowSize:u=8})=>{if(!e)return{tooltipStyles:{},tooltipArrowStyles:{},place:s};if(t===null)return{tooltipStyles:{},tooltipArrowStyles:{},place:s};const d=i;return n?(d.push(Nm({element:n,padding:5})),Ur(e,t,{placement:s,strategy:a,middleware:d}).then((({x:m,y:h,placement:p,middlewareData:x})=>{var b,g;const v={left:`${m}px`,top:`${h}px`,border:c},{x:y,y:f}=(b=x.arrow)!==null&&b!==void 0?b:{x:0,y:0},w=(g={top:"bottom",right:"left",bottom:"top",left:"right"}[p.split("-")[0]])!==null&&g!==void 0?g:"bottom",C=c&&{borderBottom:c,borderRight:c};let _=0;if(c){const E=`${c}`.match(/(\d+)px/);_=E?.[1]?Number(E[1]):1}return{tooltipStyles:v,tooltipArrowStyles:{left:y!=null?`${y}px`:"",top:f!=null?`${f}px`:"",right:"",bottom:"",...C,[w]:`-${u/2+_}px`},place:p}}))):Ur(e,t,{placement:"bottom",strategy:a,middleware:d}).then((({x:m,y:h,placement:p})=>({tooltipStyles:{left:`${m}px`,top:`${h}px`},tooltipArrowStyles:{},place:p})))},Qr=(e,t)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,t),Gr=(e,t,n)=>{let s=null;const o=function(...a){const i=()=>{s=null};!s&&(e.apply(this,a),s=setTimeout(i,t))};return o.cancel=()=>{s&&(clearTimeout(s),s=null)},o},Yr=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",Ws=(e,t)=>{if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every(((o,a)=>Ws(o,t[a])));if(Array.isArray(e)!==Array.isArray(t))return!1;if(!Yr(e)||!Yr(t))return e===t;const n=Object.keys(e),s=Object.keys(t);return n.length===s.length&&n.every((o=>Ws(e[o],t[o])))},Rm=e=>{if(!(e instanceof HTMLElement||e instanceof SVGElement))return!1;const t=getComputedStyle(e);return["overflow","overflow-x","overflow-y"].some((n=>{const s=t.getPropertyValue(n);return s==="auto"||s==="scroll"}))},Jr=e=>{if(!e)return null;let t=e.parentElement;for(;t;){if(Rm(t))return t;t=t.parentElement}return document.scrollingElement||document.documentElement},Tm=typeof window<"u"?l.useLayoutEffect:l.useEffect,Ce=e=>{e.current&&(clearTimeout(e.current),e.current=null)},Lm="DEFAULT_TOOLTIP_ID",Am={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},Pm=l.createContext({getTooltipData:()=>Am});function ba(e=Lm){return l.useContext(Pm).getTooltipData(e)}var qt={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"},Rs={tooltip:"styles-module_tooltip__mnnfp",arrow:"styles-module_arrow__K0L3T",dark:"styles-module_dark__xNqje",light:"styles-module_light__Z6W-X",success:"styles-module_success__A2AKt",warning:"styles-module_warning__SCK0X",error:"styles-module_error__JvumD",info:"styles-module_info__BWdHW"};const Im=({forwardRef:e,id:t,className:n,classNameArrow:s,variant:o="dark",anchorId:a,anchorSelect:i,place:c="top",offset:u=10,events:d=["hover"],openOnClick:m=!1,positionStrategy:h="absolute",middlewares:p,wrapper:x,delayShow:b=0,delayHide:g=0,float:v=!1,hidden:y=!1,noArrow:f=!1,clickable:w=!1,closeOnEsc:C=!1,closeOnScroll:_=!1,closeOnResize:E=!1,openEvents:j,closeEvents:S,globalCloseEvents:I,imperativeModeOnly:B,style:se,position:ye,afterShow:Pe,afterHide:U,disableTooltip:de,content:re,contentWrapperRef:J,isOpen:z,defaultIsOpen:oe=!1,setIsOpen:We,previousActiveAnchor:sn,activeAnchor:W,setActiveAnchor:St,border:On,opacity:Mn,arrowColor:$n,arrowSize:Et=8,role:bs="tooltip"})=>{var ct;const he=l.useRef(null),kt=l.useRef(null),Ee=l.useRef(null),ut=l.useRef(null),Rt=l.useRef(null),[dt,Dn]=l.useState({tooltipStyles:{},tooltipArrowStyles:{},place:c}),[me,rn]=l.useState(!1),[Tt,Xe]=l.useState(!1),[V,Lt]=l.useState(null),Fn=l.useRef(!1),At=l.useRef(null),{anchorRefs:Bn,setActiveAnchor:on}=ba(t),an=l.useRef(!1),[Ze,ln]=l.useState([]),ht=l.useRef(!1),Pt=m||d.includes("click"),qn=Pt||j?.click||j?.dblclick||j?.mousedown,cn=j?{...j}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!j&&Pt&&Object.assign(cn,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const mt=S?{...S}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!S&&Pt&&Object.assign(mt,{mouseleave:!1,blur:!1,mouseout:!1});const ee=I?{...I}:{escape:C||!1,scroll:_||!1,resize:E||!1,clickOutsideAnchor:qn||!1};B&&(Object.assign(cn,{mouseover:!1,focus:!1,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(mt,{mouseout:!1,blur:!1,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(ee,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),Tm((()=>(ht.current=!0,()=>{ht.current=!1})),[]);const fe=N=>{ht.current&&(N&&Xe(!0),setTimeout((()=>{ht.current&&(We?.(N),z===void 0&&rn(N))}),10))};l.useEffect((()=>{if(t){if(me){R(sn);const k=N(W),q=[...new Set([...k,t])].filter(Boolean).join(" ");W?.setAttribute("aria-describedby",q)}else R(W);return()=>{R(W),R(sn)}}function N(k){var q;return((q=k?.getAttribute("aria-describedby"))===null||q===void 0?void 0:q.split(" "))||[]}function R(k){const q=N(k).filter((Z=>Z!==t));q.length?k?.setAttribute("aria-describedby",q.join(" ")):k?.removeAttribute("aria-describedby")}}),[W,me,t,sn]),l.useEffect((()=>{if(z===void 0)return()=>null;z&&Xe(!0);const N=setTimeout((()=>{rn(z)}),10);return()=>{clearTimeout(N)}}),[z]),l.useEffect((()=>{if(me!==Fn.current)if(Ce(Rt),Fn.current=me,me)Pe?.();else{const N=(R=>{const k=R.match(/^([\d.]+)(ms|s)$/);if(!k)return 0;const[,q,Z]=k;return Number(q)*(Z==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));Rt.current=setTimeout((()=>{Xe(!1),Lt(null),U?.()}),N+25)}}),[me]);const un=N=>{Dn((R=>Ws(R,N)?R:N))},dn=(N=b)=>{Ce(Ee),Tt?fe(!0):Ee.current=setTimeout((()=>{fe(!0)}),N)},It=(N=g)=>{Ce(ut),ut.current=setTimeout((()=>{an.current||fe(!1)}),N)},hn=N=>{var R;if(!N)return;const k=(R=N.currentTarget)!==null&&R!==void 0?R:N.target;if(!k?.isConnected)return St(null),void on({current:null});b?dn():fe(!0),St(k),on({current:k}),Ce(ut)},Ot=()=>{w?It(g||100):g?It():fe(!1),Ce(Ee)},Mt=({x:N,y:R})=>{var k;const q={getBoundingClientRect:()=>({x:N,y:R,width:0,height:0,top:R,left:N,right:N,bottom:R})};Vr({place:(k=V?.place)!==null&&k!==void 0?k:c,offset:u,elementReference:q,tooltipReference:he.current,tooltipArrowReference:kt.current,strategy:h,middlewares:p,border:On,arrowSize:Et}).then((Z=>{un(Z)}))},$t=N=>{if(!N)return;const R=N,k={x:R.clientX,y:R.clientY};Mt(k),At.current=k},mn=N=>{var R;if(!me)return;const k=N.target;k.isConnected&&(!((R=he.current)===null||R===void 0)&&R.contains(k)||[document.querySelector(`[id='${a}']`),...Ze].some((q=>q?.contains(k)))||(fe(!1),Ce(Ee)))},Un=Gr(hn,50),G=Gr(Ot,50),ae=N=>{G.cancel(),Un(N)},L=()=>{Un.cancel(),G()},M=l.useCallback((()=>{var N,R;const k=(N=V?.position)!==null&&N!==void 0?N:ye;k?Mt(k):v?At.current&&Mt(At.current):W?.isConnected&&Vr({place:(R=V?.place)!==null&&R!==void 0?R:c,offset:u,elementReference:W,tooltipReference:he.current,tooltipArrowReference:kt.current,strategy:h,middlewares:p,border:On,arrowSize:Et}).then((q=>{ht.current&&un(q)}))}),[me,W,re,se,c,V?.place,u,h,ye,V?.position,v,Et]);l.useEffect((()=>{var N,R;const k=new Set(Bn);Ze.forEach((F=>{de?.(F)||k.add({current:F})}));const q=document.querySelector(`[id='${a}']`);q&&!de?.(q)&&k.add({current:q});const Z=()=>{fe(!1)},Ie=Jr(W),Oe=Jr(he.current);ee.scroll&&(window.addEventListener("scroll",Z),Ie?.addEventListener("scroll",Z),Oe?.addEventListener("scroll",Z));let ie=null;ee.resize?window.addEventListener("resize",Z):W&&he.current&&(ie=ym(W,he.current,M,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const we=F=>{F.key==="Escape"&&fe(!1)};ee.escape&&window.addEventListener("keydown",we),ee.clickOutsideAnchor&&window.addEventListener("click",mn);const H=[],Dt=F=>!!(F?.target&&W?.contains(F.target)),Da=F=>{me&&Dt(F)||hn(F)},Fa=F=>{me&&Dt(F)&&Ot()},mr=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],fr=["click","dblclick","mousedown","mouseup"];Object.entries(cn).forEach((([F,He])=>{He&&(mr.includes(F)?H.push({event:F,listener:ae}):fr.includes(F)&&H.push({event:F,listener:Da}))})),Object.entries(mt).forEach((([F,He])=>{He&&(mr.includes(F)?H.push({event:F,listener:L}):fr.includes(F)&&H.push({event:F,listener:Fa}))})),v&&H.push({event:"pointermove",listener:$t});const pr=()=>{an.current=!0},xr=()=>{an.current=!1,Ot()},gr=w&&(mt.mouseout||mt.mouseleave);return gr&&((N=he.current)===null||N===void 0||N.addEventListener("mouseover",pr),(R=he.current)===null||R===void 0||R.addEventListener("mouseout",xr)),H.forEach((({event:F,listener:He})=>{k.forEach((vs=>{var fn;(fn=vs.current)===null||fn===void 0||fn.addEventListener(F,He)}))})),()=>{var F,He;ee.scroll&&(window.removeEventListener("scroll",Z),Ie?.removeEventListener("scroll",Z),Oe?.removeEventListener("scroll",Z)),ee.resize?window.removeEventListener("resize",Z):ie?.(),ee.clickOutsideAnchor&&window.removeEventListener("click",mn),ee.escape&&window.removeEventListener("keydown",we),gr&&((F=he.current)===null||F===void 0||F.removeEventListener("mouseover",pr),(He=he.current)===null||He===void 0||He.removeEventListener("mouseout",xr)),H.forEach((({event:vs,listener:fn})=>{k.forEach((Ba=>{var ys;(ys=Ba.current)===null||ys===void 0||ys.removeEventListener(vs,fn)}))}))}}),[W,M,Tt,Bn,Ze,j,S,I,Pt,b,g]),l.useEffect((()=>{var N,R;let k=(R=(N=V?.anchorSelect)!==null&&N!==void 0?N:i)!==null&&R!==void 0?R:"";!k&&t&&(k=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`);const q=new MutationObserver((Z=>{const Ie=[],Oe=[];Z.forEach((ie=>{if(ie.type==="attributes"&&ie.attributeName==="data-tooltip-id"&&(ie.target.getAttribute("data-tooltip-id")===t?Ie.push(ie.target):ie.oldValue===t&&Oe.push(ie.target)),ie.type==="childList"){if(W){const we=[...ie.removedNodes].filter((H=>H.nodeType===1));if(k)try{Oe.push(...we.filter((H=>H.matches(k)))),Oe.push(...we.flatMap((H=>[...H.querySelectorAll(k)])))}catch{}we.some((H=>{var Dt;return!!(!((Dt=H?.contains)===null||Dt===void 0)&&Dt.call(H,W))&&(Xe(!1),fe(!1),St(null),Ce(Ee),Ce(ut),!0)}))}if(k)try{const we=[...ie.addedNodes].filter((H=>H.nodeType===1));Ie.push(...we.filter((H=>H.matches(k)))),Ie.push(...we.flatMap((H=>[...H.querySelectorAll(k)])))}catch{}}})),(Ie.length||Oe.length)&&ln((ie=>[...ie.filter((we=>!Oe.includes(we))),...Ie]))}));return q.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{q.disconnect()}}),[t,i,V?.anchorSelect,W]),l.useEffect((()=>{M()}),[M]),l.useEffect((()=>{if(!J?.current)return()=>null;const N=new ResizeObserver((()=>{setTimeout((()=>M()))}));return N.observe(J.current),()=>{N.disconnect()}}),[re,J?.current]),l.useEffect((()=>{var N;const R=document.querySelector(`[id='${a}']`),k=[...Ze,R];W&&k.includes(W)||St((N=Ze[0])!==null&&N!==void 0?N:R)}),[a,Ze,W]),l.useEffect((()=>(oe&&fe(!0),()=>{Ce(Ee),Ce(ut)})),[]),l.useEffect((()=>{var N;let R=(N=V?.anchorSelect)!==null&&N!==void 0?N:i;if(!R&&t&&(R=`[data-tooltip-id='${t.replace(/'/g,"\\'")}']`),R)try{const k=Array.from(document.querySelectorAll(R));ln(k)}catch{ln([])}}),[t,i,V?.anchorSelect]),l.useEffect((()=>{Ee.current&&(Ce(Ee),dn(b))}),[b]);const ge=(ct=V?.content)!==null&&ct!==void 0?ct:re,ft=me&&Object.keys(dt.tooltipStyles).length>0;return l.useImperativeHandle(e,(()=>({open:N=>{if(N?.anchorSelect)try{document.querySelector(N.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${N.anchorSelect}" is not a valid CSS selector`)}Lt(N??null),N?.delay?dn(N.delay):fe(!0)},close:N=>{N?.delay?It(N.delay):fe(!1)},activeAnchor:W,place:dt.place,isOpen:!!(Tt&&!y&&ge&&ft)}))),Tt&&!y&&ge?et.createElement(x,{id:t,role:bs,className:Us("react-tooltip",qt.tooltip,Rs.tooltip,Rs[o],n,`react-tooltip__place-${dt.place}`,qt[ft?"show":"closing"],ft?"react-tooltip__show":"react-tooltip__closing",h==="fixed"&&qt.fixed,w&&qt.clickable),onTransitionEnd:N=>{Ce(Rt),me||N.propertyName!=="opacity"||(Xe(!1),Lt(null),U?.())},style:{...se,...dt.tooltipStyles,opacity:Mn!==void 0&&ft?Mn:void 0},ref:he},ge,et.createElement(x,{className:Us("react-tooltip-arrow",qt.arrow,Rs.arrow,s,f&&qt.noArrow),style:{...dt.tooltipArrowStyles,background:$n?`linear-gradient(to right bottom, transparent 50%, ${$n} 50%)`:void 0,"--rt-arrow-size":`${Et}px`},ref:kt})):null},Om=({content:e})=>et.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),os=et.forwardRef((({id:e,anchorId:t,anchorSelect:n,content:s,html:o,render:a,className:i,classNameArrow:c,variant:u="dark",place:d="top",offset:m=10,wrapper:h="div",children:p=null,events:x=["hover"],openOnClick:b=!1,positionStrategy:g="absolute",middlewares:v,delayShow:y=0,delayHide:f=0,float:w=!1,hidden:C=!1,noArrow:_=!1,clickable:E=!1,closeOnEsc:j=!1,closeOnScroll:S=!1,closeOnResize:I=!1,openEvents:B,closeEvents:se,globalCloseEvents:ye,imperativeModeOnly:Pe=!1,style:U,position:de,isOpen:re,defaultIsOpen:J=!1,disableStyleInjection:z=!1,border:oe,opacity:We,arrowColor:sn,arrowSize:W,setIsOpen:St,afterShow:On,afterHide:Mn,disableTooltip:$n,role:Et="tooltip"},bs)=>{const[ct,he]=l.useState(s),[kt,Ee]=l.useState(o),[ut,Rt]=l.useState(d),[dt,Dn]=l.useState(u),[me,rn]=l.useState(m),[Tt,Xe]=l.useState(y),[V,Lt]=l.useState(f),[Fn,At]=l.useState(w),[Bn,on]=l.useState(C),[an,Ze]=l.useState(h),[ln,ht]=l.useState(x),[Pt,qn]=l.useState(g),[cn,mt]=l.useState(null),[ee,fe]=l.useState(null),un=l.useRef(null),dn=l.useRef(z),{anchorRefs:It,activeAnchor:hn}=ba(e),Ot=G=>G?.getAttributeNames().reduce(((ae,L)=>{var M;return L.startsWith("data-tooltip-")&&(ae[L.replace(/^data-tooltip-/,"")]=(M=G?.getAttribute(L))!==null&&M!==void 0?M:null),ae}),{}),Mt=G=>{const ae={place:L=>{var M;Rt((M=L)!==null&&M!==void 0?M:d)},content:L=>{he(L??s)},html:L=>{Ee(L??o)},variant:L=>{var M;Dn((M=L)!==null&&M!==void 0?M:u)},offset:L=>{rn(L===null?m:Number(L))},wrapper:L=>{var M;Ze((M=L)!==null&&M!==void 0?M:h)},events:L=>{const M=L?.split(" ");ht(M??x)},"position-strategy":L=>{var M;qn((M=L)!==null&&M!==void 0?M:g)},"delay-show":L=>{Xe(L===null?y:Number(L))},"delay-hide":L=>{Lt(L===null?f:Number(L))},float:L=>{At(L===null?w:L==="true")},hidden:L=>{on(L===null?C:L==="true")},"class-name":L=>{mt(L)}};Object.values(ae).forEach((L=>L(null))),Object.entries(G).forEach((([L,M])=>{var ge;(ge=ae[L])===null||ge===void 0||ge.call(ae,M)}))};l.useEffect((()=>{he(s)}),[s]),l.useEffect((()=>{Ee(o)}),[o]),l.useEffect((()=>{Rt(d)}),[d]),l.useEffect((()=>{Dn(u)}),[u]),l.useEffect((()=>{rn(m)}),[m]),l.useEffect((()=>{Xe(y)}),[y]),l.useEffect((()=>{Lt(f)}),[f]),l.useEffect((()=>{At(w)}),[w]),l.useEffect((()=>{on(C)}),[C]),l.useEffect((()=>{qn(g)}),[g]),l.useEffect((()=>{dn.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 G;const ae=new Set(It);let L=n;if(!L&&e&&(L=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),L)try{document.querySelectorAll(L).forEach((R=>{ae.add({current:R})}))}catch{console.warn(`[react-tooltip] "${L}" is not a valid CSS selector`)}const M=document.querySelector(`[id='${t}']`);if(M&&ae.add({current:M}),!ae.size)return()=>null;const ge=(G=ee??M)!==null&&G!==void 0?G:hn.current,ft=new MutationObserver((R=>{R.forEach((k=>{var q;if(!ge||k.type!=="attributes"||!(!((q=k.attributeName)===null||q===void 0)&&q.startsWith("data-tooltip-")))return;const Z=Ot(ge);Mt(Z)}))})),N={attributes:!0,childList:!1,subtree:!1};if(ge){const R=Ot(ge);Mt(R),ft.observe(ge,N)}return()=>{ft.disconnect()}}),[It,hn,ee,t,n]),l.useEffect((()=>{U?.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),oe&&!Qr("border",`${oe}`)&&console.warn(`[react-tooltip] "${oe}" is not a valid \`border\`.`),U?.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),We&&!Qr("opacity",`${We}`)&&console.warn(`[react-tooltip] "${We}" is not a valid \`opacity\`.`)}),[]);let $t=p;const mn=l.useRef(null);if(a){const G=a({content:ee?.getAttribute("data-tooltip-content")||ct||null,activeAnchor:ee});$t=G?et.createElement("div",{ref:mn,className:"react-tooltip-content-wrapper"},G):null}else ct&&($t=ct);kt&&($t=et.createElement(Om,{content:kt}));const Un={forwardRef:bs,id:e,anchorId:t,anchorSelect:n,className:Us(i,cn),classNameArrow:c,content:$t,contentWrapperRef:mn,place:ut,variant:dt,offset:me,wrapper:an,events:ln,openOnClick:b,positionStrategy:Pt,middlewares:v,delayShow:Tt,delayHide:V,float:Fn,hidden:Bn,noArrow:_,clickable:E,closeOnEsc:j,closeOnScroll:S,closeOnResize:I,openEvents:B,closeEvents:se,globalCloseEvents:ye,imperativeModeOnly:Pe,style:U,position:de,isOpen:re,defaultIsOpen:J,border:oe,opacity:We,arrowColor:sn,arrowSize:W,setIsOpen:St,afterShow:On,afterHide:Mn,disableTooltip:$n,activeAnchor:ee,previousActiveAnchor:un.current,setActiveAnchor:G=>{fe((ae=>(G?.isSameNode(ae)||(un.current=ae),G)))},role:Et};return et.createElement(Im,{...Un})}));typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",(e=>{e.detail.disableCore||Kr({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||Kr({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 Mm=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})),va=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"})),$m=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})),Dm=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"})),ya=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"})),wa=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"})),Fm=()=>{const e=nr(),t=Yc();return{rename:async s=>{if(e){const o=await Ln("New tab name",s);o&&await t.mutateAsync({id:e,payload:{name:o}})}return Promise.resolve()}}},Ca=["shift","alt","meta","mod","ctrl","control"],Bm={esc:"escape",return:"enter",left:"arrowleft",right:"arrowright",up:"arrowup",down:"arrowdown",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function st(e){return(Bm[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function ja(e){return Ca.includes(e)}function Ts(e,t=","){return e.toLowerCase().split(t)}function Ls(e,t="+",n=">",s=!1,o){let a=[],i=!1;e=e.trim(),e.includes(n)?(i=!0,a=e.toLocaleLowerCase().split(n).map(d=>st(d))):a=e.toLocaleLowerCase().split(t).map(d=>st(d));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:s},u=a.filter(d=>!Ca.includes(d));return{...c,keys:u,description:o,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&Na([st(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&_a([st(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Ke.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Ke.clear()},0)}));const Ke=new Set;function dr(e){return Array.isArray(e)}function qm(e,t=","){return(dr(e)?e:e.split(t)).every(n=>Ke.has(n.trim().toLowerCase()))}function Na(e){const t=Array.isArray(e)?e:[e];Ke.has("meta")&&Ke.forEach(n=>!ja(n)&&Ke.delete(n.toLowerCase())),t.forEach(n=>Ke.add(n.toLowerCase()))}function _a(e){const t=Array.isArray(e)?e:[e];e==="meta"?Ke.clear():t.forEach(n=>Ke.delete(n.toLowerCase()))}function Um(e,t,n){(typeof n=="function"&&n(e,t)||n===!0)&&e.preventDefault()}function Wm(e,t,n){return typeof n=="function"?n(e,t):n===!0||n===void 0}const Hm=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function zm(e){return Sa(e,Hm)}function Sa(e,t=!1){const{target:n,composed:s}=e;let o,a;return Km(n)&&s?(o=e.composedPath()[0]&&e.composedPath()[0].tagName,a=e.composedPath()[0]&&e.composedPath()[0].role):(o=n&&n.tagName,a=n&&n.role),dr(t)?!!(o&&t&&t.some(i=>i.toLowerCase()===o.toLowerCase()||i===a)):!!(o&&t&&t)}function Km(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Vm(e,t){return e.length===0&&t?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),!0):t?e.some(n=>t.includes(n))||e.includes("*"):!0}const Qm=(e,t,n=!1)=>{const{alt:s,meta:o,mod:a,shift:i,ctrl:c,keys:u,useKey:d}=t,{code:m,key:h,ctrlKey:p,metaKey:x,shiftKey:b,altKey:g}=e,v=st(m);if(d&&u?.length===1&&u.includes(h))return!0;if(!u?.includes(v)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(v))return!1;if(!n){if(s!==g&&v!=="alt"||i!==b&&v!=="shift")return!1;if(a){if(!x&&!p)return!1}else if(o!==x&&v!=="meta"&&v!=="os"||c!==p&&v!=="ctrl"&&v!=="control")return!1}return u&&u.length===1&&u.includes(v)?!0:u?qm(u):!u},Gm=l.createContext(void 0),Ym=()=>l.useContext(Gm);function Ea(e,t){return e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(e).length===Object.keys(t).length&&Object.keys(e).reduce((n,s)=>n&&Ea(e[s],t[s]),!0):e===t}const Jm=l.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),Xm=()=>l.useContext(Jm);function Zm(e){const t=l.useRef(void 0);return Ea(t.current,e)||(t.current=e),t.current}const Xr=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},ef=typeof window<"u"?l.useLayoutEffect:l.useEffect;function Re(e,t,n,s){const o=l.useRef(null),a=l.useRef(!1),i=Array.isArray(n)?Array.isArray(s)?void 0:s:n,c=dr(e)?e.join(i?.delimiter):e,u=Array.isArray(n)?n:Array.isArray(s)?s:void 0,d=l.useCallback(t,u??[]),m=l.useRef(d);u?m.current=d:m.current=t;const h=Zm(i),{activeScopes:p}=Xm(),x=Ym();return ef(()=>{if(h?.enabled===!1||!Vm(p,h?.scopes))return;let b=[],g;const v=(C,_=!1)=>{if(!(zm(C)&&!Sa(C,h?.enableOnFormTags))){if(o.current!==null){const E=o.current.getRootNode();if((E instanceof Document||E instanceof ShadowRoot)&&E.activeElement!==o.current&&!o.current.contains(E.activeElement)){Xr(C);return}}C.target?.isContentEditable&&!h?.enableOnContentEditable||Ts(c,h?.delimiter).forEach(E=>{if(E.includes(h?.splitKey??"+")&&E.includes(h?.sequenceSplitKey??">")){console.warn(`Hotkey ${E} contains both ${h?.splitKey??"+"} and ${h?.sequenceSplitKey??">"} which is not supported.`);return}const j=Ls(E,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description);if(j.isSequence){g=setTimeout(()=>{b=[]},h?.sequenceTimeoutMs??1e3);const S=j.useKey?C.key:st(C.code);if(ja(S.toLowerCase()))return;b.push(S);const I=j.keys?.[b.length-1];if(S!==I){b=[],g&&clearTimeout(g);return}b.length===j.keys?.length&&(m.current(C,j),g&&clearTimeout(g),b=[])}else if(Qm(C,j,h?.ignoreModifiers)||j.keys?.includes("*")){if(h?.ignoreEventWhen?.(C)||_&&a.current)return;if(Um(C,j,h?.preventDefault),!Wm(C,j,h?.enabled)){Xr(C);return}m.current(C,j),_||(a.current=!0)}})}},y=C=>{C.code!==void 0&&(Na(st(C.code)),(h?.keydown===void 0&&h?.keyup!==!0||h?.keydown)&&v(C))},f=C=>{C.code!==void 0&&(_a(st(C.code)),a.current=!1,h?.keyup&&v(C,!0))},w=o.current||i?.document||document;return w.addEventListener("keyup",f,i?.eventListenerOptions),w.addEventListener("keydown",y,i?.eventListenerOptions),x&&Ts(c,h?.delimiter).forEach(C=>x.addHotkey(Ls(C,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description))),()=>{w.removeEventListener("keyup",f,i?.eventListenerOptions),w.removeEventListener("keydown",y,i?.eventListenerOptions),x&&Ts(c,h?.delimiter).forEach(C=>x.removeHotkey(Ls(C,h?.splitKey,h?.sequenceSplitKey,h?.useKey,h?.description))),b=[],g&&clearTimeout(g)}},[c,h,p]),o}function tf(){return r.jsxs("div",{className:"flex md:grid md:grid-cols-3 items-center bg-white overflow-auto no-scrollbar",children:[r.jsx(nf,{}),r.jsx(sf,{}),r.jsx(af,{})]})}function nf(){const{dataSourceId:e}=l.useContext(qe),{data:t}=cs(e),{state:{table:n}}=l.useContext(xe);return r.jsx("div",{className:T.tableConfig,children:t&&r.jsxs("div",{className:A(T.tableAction,T.greenFixed),"data-tooltip-id":"default","data-tooltip-content":n,children:[r.jsx(lt,{size:18,type:t.dbType}),r.jsx("p",{className:"text-sm",children:t.name}),r.jsx(Ge,{width:12,height:12}),r.jsx("p",{className:"text-sm",children:n})]})})}function sf(){const{page:e,size:t,setPage:n}=aa(),{data:s,isFetching:o}=l.useContext(Ae),a=e*t,i=!o&&!!s?.result.hasMore,c=s?.result.rows.length||0,u=()=>{e>0&&n(e-1)},d=()=>{i&&n(e+1)};return r.jsxs("div",{className:A(T.tableConfig,"justify-self-center"),children:[r.jsx("span",{"data-tooltip-content":"Previous page","data-tooltip-id":"default",className:A(T.tableAction,T.gray,e<1&&"opacity-30"),onClick:u,role:"button",children:r.jsx(Ge,{width:16,height:16,className:"rotate-180"})}),r.jsxs("span",{"data-tooltip-id":"rows-num",className:T.paginationIndicator,children:[a+1," - ",a+c,i&&"+"]}),r.jsx("span",{"data-tooltip-content":"Next page","data-tooltip-id":"default",className:A(T.tableAction,i?T.gray:"opacity-30"),onClick:d,role:"button",children:r.jsx(Ge,{width:16,height:16})})]})}const rf=[5,10,20,50,100,200],of=!__CLIENT_CONFIG__.skipAuth;function af(){const{dataSourceId:e,name:t}=l.useContext(qe),{data:n}=cs(e),{data:s,refetch:o}=l.useContext(Ae),a=Tn(pe.EDITOR),i=Rh(),{rename:c}=Fm(),{size:u,setSize:d}=aa(),{state:m}=l.useContext(xe),h=tn(),p=Y(),x=()=>{h.mutateAsync({name:t,opts:m}).then(f=>{p(P.workbenchTab.build({id:f.id}))})},b=()=>{if(s?.result.queryHistoryId){const f=new URL(window.location.href);f.pathname=P.share.build(),f.searchParams.set("shareId",s.result.queryHistoryId),navigator.clipboard.writeText(f.toString()),je.success("Share link copied to clipboard")}},g=()=>{s?.result.columns?.[0].table&&er({table:s?.result.columns?.[0].table,dataSourceId:e})},v=async()=>{const f=await Ln("Query name",t);!f||!s?.result.queryHistoryId||i.mutate({name:f,queryId:s.result.queryHistoryId})},y=()=>c(t);return Re("s",v),Re("r",y),Re("d",x),r.jsxs("div",{className:"flex justify-self-end",children:[r.jsx("span",{"data-tooltip-content":"Show filters","data-tooltip-id":"default",className:A(T.tableAction,T.gray),onClick:()=>Me("filters"),role:"button",children:r.jsx(ya,{width:16,height:16})}),r.jsx("span",{"data-tooltip-content":"Join table","data-tooltip-id":"default",className:A(T.tableAction,T.gray),onClick:()=>Me("joins"),role:"button",children:r.jsx(wa,{width:16,height:16})}),r.jsx("span",{"data-tooltip-content":"Refresh data","data-tooltip-id":"default",className:A(T.tableAction,T.gray),onClick:()=>o(),role:"button",children:r.jsx(va,{width:16,height:16})}),of&&r.jsx("span",{"data-tooltip-content":"Share query","data-tooltip-id":"default",className:A(T.tableAction,T.gray),onClick:b,role:"button",children:r.jsx(Dm,{width:16,height:16})}),r.jsx("span",{"data-tooltip-content":"Duplicate tab","data-tooltip-id":"default",className:A(T.tableAction,T.gray),onClick:x,role:"button",children:r.jsx($m,{width:16,height:16})}),r.jsx(os,{id:"rows-num",className:"z-10 shadow-md flex gap-1",clickable:!0,variant:"light",opacity:1,children:rf.map(f=>r.jsx("button",{onClick:()=>d(f,!0),className:A(T.tableAction,T.gray,f===u&&T.selectedSize),children:r.jsx("span",{children:f})},f))}),r.jsx("button",{"data-tooltip-id":"explorer-more-actions",className:A(T.tableAction,T.gray),children:r.jsx(Mm,{width:16,height:16})}),r.jsxs(os,{id:"explorer-more-actions",className:"z-10 shadow-md flex flex-col",clickable:!0,variant:"light",opacity:1,children:[r.jsxs("button",{onClick:()=>Me("columns"),className:A(T.tableAction,T.modal,T.gray,"justify-between"),children:[r.jsx("span",{children:"Columns"}),r.jsx("span",{className:"hotkey",children:"C"})]}),r.jsxs("button",{onClick:()=>Me("groupBy"),className:A(T.tableAction,T.modal,T.gray,"justify-between"),children:[r.jsx("span",{children:"Group by"}),r.jsx("span",{className:"hotkey",children:"G"})]}),r.jsxs("button",{onClick:()=>Me("aggregate"),className:A(T.tableAction,T.modal,T.gray,"justify-between"),children:[r.jsx("span",{children:"Aggregate"}),r.jsx("span",{className:"hotkey",children:"A"})]}),r.jsx("div",{className:"h-0.5 my-2 bg-gray-100"}),r.jsxs("button",{onClick:y,className:A(T.tableAction,T.modal,T.gray,"justify-between"),children:[r.jsx("span",{children:"Rename tab"}),r.jsx("span",{className:"hotkey",children:"R"})]}),a&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{onClick:v,className:A(T.tableAction,T.modal,T.gray),children:[r.jsx("span",{children:"Save query"}),r.jsx("span",{className:"hotkey",children:"S"})]}),n?.allowInsert===!0&&r.jsx("button",{onClick:g,className:A(T.tableAction,T.modal,T.gray),children:"Insert new row"})]})]})]})}const lf="_drop-container_1x8ce_2",cf="_item_1x8ce_2",Zr={dropContainer:lf,item:cf},ka=({dataSourceId:e,inputClassName:t,focusId:n,placeholder:s="Column",onChange:o,value:a,autoFocus:i,allowTables:c})=>{const{data:u}=En(e),d=l.useRef(null),m=l.useMemo(()=>{if(!u)return[];let f=u;return c&&(f=u.filter(w=>c.includes(w.tableName))),f.flatMap(w=>w.columns.map(C=>({value:w.tableName+"."+C.name,label:C.name,table:w.tableName,searchValue:C.name.toLowerCase()})))},[u,c]),h=l.useMemo(()=>{const f=a.toLowerCase()||"",w=[];for(let C=0;C<m.length&&w.length<10;C++)m[C].searchValue.includes(f)&&w.push(m[C]);return w},[m,a]),[p,x]=l.useState(!1),[b,g]=l.useState(0),v=f=>{if(f.key==="ArrowDown")f.preventDefault(),g(w=>(w+1)%h.length);else if(f.key==="ArrowUp")f.preventDefault(),g(w=>(w-1+h.length)%h.length);else if(f.key==="Enter"&&b>=0&&b<h.length){f.preventDefault();const w=h[b].value;x(!1);const C=m.findIndex(_=>_.value===w)>-1;o(h[b]?.value||w,C,!0)}};l.useEffect(()=>{const f=d.current?.querySelector('[data-is-active="true"]');f&&f.scrollIntoView({behavior:"smooth",block:"nearest"})},[b]);const y=f=>{const w=f.currentTarget.value,C=m.findIndex(_=>_.value===w)>-1;o(w,C,!1)};return r.jsxs("div",{className:"relative",onFocus:()=>x(!0),onBlur:()=>x(!1),children:[r.jsx("input",{autoFocus:i,onKeyDown:v,value:a,onChange:y,className:t,placeholder:s,"data-focus":n}),p&&h.length>0&&r.jsx("div",{className:Zr.dropContainer,ref:d,tabIndex:-1,children:h.map((f,w)=>r.jsxs("div",{className:Zr.item,"data-is-active":b===w,onMouseDownCapture:C=>{C.preventDefault(),x(!1),o(f.value,!0,!0)},children:[r.jsx("span",{className:"text-xs font-semibold truncate",children:f.table}),r.jsx("p",{className:"truncate text-sm",children:f.label})]},w))})]})},uf="_actions_1js4i_2",df="_filter-actions_1js4i_2",hf="_advanced-filter-icon_1js4i_2",mf="_filters-container_1js4i_2",ff="_filter-container_1js4i_2",yn={actions:uf,filterActions:df,advancedFilterIcon:hf,filtersContainer:mf,filterContainer:ff},pf=({filter:e,dataSourceId:t,allowedTables:n,autoFocus:s,onChangeColumn:o,onChangeValue:a,onRemoveFilter:i,onChangeAdvancedFilter:c,triggerIsEnabled:u,onSubmit:d})=>{const m=p=>{const x=p.target.value;x.charAt(0)===":"?c(e.id,!0):(!e.isAdvanced&&["=","<",">"].includes(x.charAt(0))&&c(e.id,!0),a(e.id,p.currentTarget.value))},h=p=>{p.key==="Backspace"?(e.value.length===0||p.currentTarget.selectionEnd===0)&&c(e.id,!1):p.key==="Enter"&&d()};return r.jsxs("div",{className:yn.filterContainer,children:[r.jsx("input",{type:"checkbox",checked:e.isEnabled!==!1,onClick:()=>u(e.id)}),r.jsx(ka,{dataSourceId:t,onChange:p=>o(e.id,p),value:e.column,allowTables:n,focusId:"column",inputClassName:"input w-full",autoFocus:s}),r.jsxs("div",{className:"flex items-center",children:[e.isAdvanced&&r.jsx("span",{className:yn.advancedFilterIcon,children:r.jsx(ya,{width:14,height:14})}),r.jsx("input",{placeholder:"Filter value",value:e.value,onChange:m,onKeyDown:h,"data-focus":"value",className:"input flex-1"},e.id)]}),r.jsx("div",{className:yn.filterActions,children:r.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove filter",className:"p-0.5 text-sm cursor-pointer rounded-md",onClick:()=>i(e.id),children:r.jsx(jt,{width:20,height:20,className:"text-red-600"})})})]})},xf=()=>{const{state:e}=l.useContext(xe),{refetch:t}=l.useContext(Ae),{setFilters:n}=rr(),s=hs(g=>g.filters),o=l.useMemo(()=>[e.table,...e.joins.map(g=>g.table)],[e.table,e.joins]),[a,i]=l.useState([]),c=(g,v)=>{i(y=>[...y.map(f=>f.id===g?{...f,column:v}:f)])},u=(g,v)=>{i(y=>[...y.map(f=>f.id===g?{...f,value:v}:f)])},d=()=>{i(g=>[...g,{id:rt(),value:"",column:"",isEnabled:!0}])},m=g=>{i(v=>v.filter(y=>y.id!==g))},h=(g,v)=>{i(y=>y.map(f=>f.id===g?{...f,isAdvanced:v}:f))},p=()=>ms("filters"),x=()=>{try{n(a.filter(g=>g.value.length>0&&g.column.length>0)),setTimeout(t,1),p()}catch(g){g instanceof Error?je.error(g.message):je.error("Error during parsing, check you filters")}},b=g=>{i(v=>v.map(y=>y.id===g?{...y,isEnabled:!y.isEnabled}:y))};return l.useEffect(()=>{s&&i(()=>[...e.filters,{id:rt(),value:"",column:"",isEnabled:!0}])},[s]),Re("f",()=>{ts("filters")}),r.jsxs(ve,{isVisible:s,onClose:p,portal:!0,onClosed:()=>i([]),noPadding:!0,children:[r.jsx(it,{onClick:p}),r.jsx("h2",{className:"text-lg font-semibold m-2",children:"Filters"}),r.jsxs("div",{className:yn.filtersContainer,children:[a.length<1&&r.jsx("p",{className:"p-1 text-center rounded-lg bg-gray-50 border border-gray-200",children:"No filters"}),a.map((g,v)=>r.jsx(pf,{filter:g,dataSourceId:e.dataSourceId,allowedTables:o,onChangeColumn:c,onChangeValue:u,onRemoveFilter:m,onChangeAdvancedFilter:h,triggerIsEnabled:b,onSubmit:x,autoFocus:v===a.length-1},g.id))]}),r.jsxs("div",{className:yn.actions,children:[r.jsxs("button",{className:"button tertiary flex items-center gap-1 text-sm",onClick:d,children:[r.jsx(wa,{width:20,height:20}),r.jsx("span",{children:"Add filter"})]}),r.jsx("button",{className:"button primary text-sm",onClick:x,children:"Apply filters"})]})]})},gf="_join-modal_1pj2b_2",bf={joinModal:gf},vf=(e,t)=>e.type!==t.type||e.on!==t.on||e.table!==t.table,yf=(e,t)=>e.type===t.type&&e.on===t.on&&e.table===t.table,Ra=()=>{const{state:e,setState:t}=l.useContext(xe),n=l.useCallback(s=>{t(o=>{const a=o.joins;if(a.some(c=>yf(c,s))){const c=s.table+".";return{...o,joins:a.filter(u=>vf(u,s)),columns:o.columns.filter(u=>!u.value.startsWith(c)),groupBy:o.groupBy.filter(u=>!u.value.startsWith(c)),orderBy:o.orderBy.filter(u=>!u.column.startsWith(c)),aggregations:o.aggregations.filter(u=>!u.value.startsWith(c)),filters:o.filters.filter(u=>!u.column.startsWith(c))}}return{...o,joins:[...a,s]}})},[t]);return{joins:e.joins,toggle:n}},wf=()=>{const{isFetching:e}=l.useContext(Ae),t=hs(u=>u.joins),{toggle:n}=Ra(),{availableJoins:s}=l.useContext(qe),[o,a]=l.useState(""),i=l.useMemo(()=>{const u=o.toLowerCase();return s.filter(d=>d.on.toTable.toLowerCase().includes(u))},[s,o]),c=()=>ms("joins");return Re("j",()=>{s.length>0?Me("joins"):je.error("No available tables to join")}),r.jsxs(ve,{isVisible:t,onClose:c,portal:!0,children:[r.jsx(it,{onClick:c}),r.jsxs("div",{className:bf.joinModal,children:[r.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Join table"}),s.length>0?r.jsx("input",{className:"input w-full",placeholder:"Filter",autoFocus:!0,onChange:u=>a(u.target.value),value:o,disabled:e}):r.jsx(ne,{variant:"warning",children:r.jsx("p",{className:"text-sm truncate",children:"There is nothing else to join"})}),r.jsx("div",{className:`flex flex-col mt-2 overflow-y-auto ${e?"opacity-40":""}`,children:i.map(u=>r.jsx(ea,{hook:u,onClick:()=>{e||(n({table:u.on.toTable,type:"LEFT",on:u.where}),a(""),c())}},u.where))})]})]})};function Cf(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}function eo(e){return e.reduce((t,n)=>(t[n]=!0,t),{})}const jf="_container_hkce7_2",Nf="_column-label_hkce7_2",_f="_not-active_hkce7_2",Xn={container:jf,columnLabel:Nf,notActive:_f};function Sf(e){if(!e)return[];const t={};return e.forEach(n=>{t[n.table]?t[n.table].push({value:n.full,ogColumn:n.column,label:tt(n.column),type:n.type}):t[n.table]=[{value:n.full,ogColumn:n.column,label:tt(n.column),type:n.type}],yc[n.type]&&["YEAR","MONTH","DAY"].forEach(s=>{t[n.table].push({value:s+" "+n.full,ogColumn:n.column,label:s+" "+tt(n.column),type:"number",nested:!0})})}),Object.entries(t).reduce((n,[s,o])=>(n.push({name:tt(s),columns:o}),n),[])}function Ef(e,t){const n=t.toLowerCase();return e.map(s=>{const o=s.columns.filter(a=>a.label.toLowerCase().includes(n)||a.ogColumn.toLowerCase().includes(n));return{...s,columns:o}}).filter(s=>s.columns.length>0)}const kf=({column:e,selected:t,onCheck:n})=>r.jsxs("label",{className:A(Xn.columnLabel,t?Xn.active:Xn.notActive,e.nested&&"pl-5!"),children:[r.jsx("input",{type:"checkbox",checked:t[e.value],name:e.value,onChange:n}),r.jsxs("p",{className:"flex justify-between w-full",children:[r.jsx("span",{"data-tooltip-content":e.value,"data-tooltip-id":"default",children:e.label}),r.jsx("span",{className:"text-blue-600",children:e.type})]})]},e.value),Rf={columns:"c",groupBy:"g"},to=({mode:e})=>{const t=hs(f=>f[e]),{allColumns:n}=l.useContext(qe),{state:s,setState:o}=l.useContext(xe),[a,i]=l.useState({}),[c,u]=l.useState(""),d=l.useMemo(()=>Sf(n),[n]),m=s.aggregations.length>0||s.groupBy.length>0,h=l.useMemo(()=>c?Ef(d,c):d,[c,d]),p=f=>{i(w=>({...w,[f.target.name]:f.target.checked}))},x=f=>{const w=f.target.checked;i(C=>{for(const _ of n)C[_.full]=w;return{...C}})},b=()=>{ms(e)},g=()=>{const f=[];for(const[w,C]of Object.entries(a))if(C){const[_,E]=w.split(" ");f.push({value:E||_,fn:E?_:void 0})}o(w=>({...w,[e]:f})),b()},v=l.useMemo(()=>{for(const f of n)if(!a[f.full])return!1;return!0},[a,n]);Re(Rf[e],()=>{e==="columns"?m?je.error("Columns are ignored when there is at least one aggregation or group by"):ts("columns"):ts("groupBy")}),l.useEffect(()=>{t&&i(()=>Cf(s[e].map(f=>f.fn?f.fn+" "+f.value:f.value)))},[t,i]);const y=()=>{u(""),i({})};return r.jsxs(ve,{isVisible:t,onClose:b,portal:!0,onClosed:y,children:[r.jsx(it,{onClick:b}),r.jsxs("div",{className:Xn.container,children:[r.jsx("h2",{className:"text-lg font-semibold",children:e==="groupBy"?"Group by":"Show columns"}),r.jsx("input",{autoFocus:!0,className:"input my-2",placeholder:"Filter",value:c,onChange:f=>u(f.target.value)}),r.jsx("div",{className:"overflow-y-auto",children:h.map(f=>r.jsxs("div",{className:"my-2",children:[r.jsxs("p",{className:"font-semibold sticky top-0 bg-white p-1 z-1",children:["📄 ",f.name]}),f.columns.map(w=>r.jsx(kf,{column:w,selected:a,onCheck:p},w.value))]},f.name))}),r.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[r.jsxs("label",{className:"button tertiary flex gap-2 items-center",children:[r.jsx("input",{type:"checkbox",checked:v,onChange:x}),r.jsx("span",{children:"Select all"})]}),r.jsx("span",{className:"flex-1"}),r.jsx("button",{className:"button tertiary",onClick:b,children:"Cancel"}),r.jsx("button",{className:"button primary",onClick:g,children:"Apply"})]})]})]})},Tf="_options-container_1wdge_2",Lf={optionsContainer:Tf},As="COUNT all",Af=()=>{const e=hs(b=>b.aggregate),{dataSourceId:t}=l.useContext(qe),{setState:n,state:s}=l.useContext(xe),{data:o}=l.useContext(Ae),[a,i]=l.useState({fn:"",col:""}),c=b=>i({...a,fn:b.currentTarget.value}),u=b=>i({...a,col:b}),d=()=>ms("aggregate"),m=()=>{const b=a.fn===As?{value:"*",fn:"COUNT"}:{fn:a.fn,value:a.col,distinct:a.fn==="COUNT"};n(g=>({...g,aggregations:[...g.aggregations,b]}))},h=a.fn===As,p=h?!1:!a.col||!a.fn,x=b=>{const g=qo(b);n(v=>({...v,aggregations:v.aggregations.filter(y=>y.fn!==b.fn||y.value!==b.value),orderBy:v.orderBy.filter(y=>y.column!==g)}))};return Re("a",()=>{ts("aggregate")}),r.jsxs(ve,{isVisible:e,onClose:d,backdropClose:!0,portal:!0,children:[r.jsx(it,{onClick:d}),r.jsxs("div",{children:[r.jsx("h2",{className:"text-lg font-semibold",children:"Aggregate"}),De(s.aggregations.length,0)&&r.jsx("div",{className:"flex flex-col gap-1 mt-4",children:s.aggregations.map((b,g)=>r.jsxs("p",{className:"p-2 rounded-md bg-gray-50 flex items-center justify-between",children:[r.jsx("span",{children:Yn(b)}),r.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove aggregation",className:"p-0.5 text-sm cursor-pointer",onClick:()=>x(b),children:r.jsx(jt,{width:20,height:20,className:"text-red-600"})})]},g))}),r.jsxs("div",{className:Lf.optionsContainer,children:[r.jsxs("label",{className:A(h&&"col-span-2"),children:[r.jsx("p",{className:"font-semibold text-xs",children:"Function"}),r.jsxs("select",{className:"input w-full",value:a.fn,onChange:c,autoFocus:!0,children:[r.jsx("option",{value:"",disabled:!0,children:"Select function"}),r.jsx("option",{value:As,children:"Count all rows"}),r.jsx("option",{value:"COUNT",children:"Count"}),r.jsx("option",{value:"SUM",children:"Sum"}),r.jsx("option",{value:"MAX",children:"Max"}),r.jsx("option",{value:"MIN",children:"Min"}),r.jsx("option",{value:"AVG",children:"Avg"})]})]}),!h&&r.jsxs("label",{children:[r.jsx("p",{className:"font-semibold text-xs",children:"Column"}),r.jsx(ka,{inputClassName:"input w-full",dataSourceId:t,allowTables:o?.result.tables||[],onChange:u,value:a.col})]}),r.jsx("button",{className:"button primary",disabled:p,onClick:m,children:"Add"})]})]})]})},Pf="_container_1291a_2",If="_yellow-pill_1291a_2 _pill_1291a_2",Of="_blue-pill_1291a_2 _pill_1291a_2",Mf="_purple-pill_1291a_2 _pill_1291a_2",$f="_red-pill_1291a_2 _pill_1291a_2",Df="_black-pill_1291a_2 _pill_1291a_2",Ff="_disabled-pill_1291a_2",bt={container:Pf,yellowPill:If,bluePill:Of,purplePill:Mf,redPill:$f,blackPill:Df,disabledPill:Ff};function Ta(e,t=500,n){const[s,o]=l.useState(e),a=l.useRef(n);return a.current=n,l.useEffect(()=>{const i=setTimeout(()=>{o(e),a.current&&a.current(e)},t);return()=>clearTimeout(i)},[e,t]),s}function Bf(e){return!(e===!0||e===void 0)}const qf=()=>{const{state:{aggregations:e,columns:t,groupBy:n}}=l.useContext(xe),{toggle:s,joins:o}=Ra(),{filters:a,setFilters:i,removeFilter:c}=rr(),u=()=>Me("joins"),d=()=>Me("aggregate"),m=()=>Me("columns"),h=()=>Me("groupBy"),p=g=>{g.preventDefault(),g.stopPropagation(),s(o[o.length-1])},x=g=>{i(a.map(v=>({...v,isEnabled:g===v.id?Bf(v.isEnabled):v.isEnabled})),!0)},b=g=>v=>{v.preventDefault(),v.stopPropagation(),c(g)};return a.length>0||o.length>0||n.length>0||t.length>0||e.length>0?r.jsxs("div",{className:bt.container,children:[o.map((g,v)=>r.jsxs("button",{onClick:u,className:bt.yellowPill,"data-tooltip-id":"default","data-tooltip-content":`Joins ${g.table} on ${g.on}`,children:[r.jsx("p",{className:"text-sm",children:g.table}),v===o.length-1&&r.jsx(jt,{onClick:p,width:18,height:18})]},g.table)),a.map(g=>r.jsxs("button",{onClick:()=>x(g.id),onAuxClick:()=>c(g.id),className:A(bt.bluePill,g.isEnabled===!1&&bt.disabledPill),"data-tooltip-id":"default","data-tooltip-content":`${g.column} ${g.value}`,children:[r.jsx("p",{className:"text-sm",children:g.column}),r.jsx("p",{className:"text-sm",children:g.value}),r.jsx(jt,{onClick:b(g.id),width:18,height:18})]},g.id)),e.map(g=>r.jsx("button",{onClick:d,className:A(bt.purplePill),"data-tooltip-id":"default","data-tooltip-content":Yn(g),children:r.jsx("p",{className:"text-sm",children:Yn(g)})},Yn(g))),t.length>0&&r.jsx("button",{onClick:m,className:A(bt.redPill),"data-tooltip-id":"default","data-tooltip-content":"Has hidden columns",children:r.jsx("p",{className:"text-sm",children:"Hidden columns"})}),n.length>0&&r.jsx("button",{onClick:h,className:A(bt.blackPill),"data-tooltip-id":"default","data-tooltip-content":"Has GROUP BY",children:r.jsx("p",{className:"text-sm",children:"Grouped columns"})}),!1]}):null},Uf=({options:e,updater:t,name:n,tabId:s})=>{const o=Fc(e,t),a=Jc(s,o.state),i=Dc(a.data,o.state.dataSourceId,n,s);return r.jsx(qe,{value:i,children:r.jsx(xe,{value:o,children:r.jsxs(Ae,{value:a,children:[r.jsx(tf,{}),r.jsx(qf,{}),r.jsxs("div",{className:"flex-1 flex overflow-hidden border-t border-t-gray-200",children:[r.jsx("div",{className:"flex-1 overflow-auto pb-24 lg:pb-12 no-scrollbar",children:r.jsx(kh,{})}),r.jsx(xf,{}),r.jsx(wf,{}),r.jsx(to,{mode:"columns"}),r.jsx(to,{mode:"groupBy"}),r.jsx(Af,{})]})]})})})},hr=()=>r.jsxs("div",{role:"status",children:[r.jsxs("svg",{"aria-hidden":"true",className:"w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.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"}),r.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"})]}),r.jsx("span",{className:"sr-only",children:"Loading..."})]}),Wf=({id:e})=>{const{data:t}=Qc(e),n=l.useCallback(s=>{if(!t)return;const o=s(en(t.opts));Q.setQueryData(["workbench-tabs",t.id],{...t,opts:{...t.opts,...o}})},[t]);return t?r.jsx(Uf,{updater:n,options:t.opts,name:t.name,tabId:t.id}):r.jsx("div",{className:"flex-1 flex justify-center items-center",children:r.jsx(hr,{})})},Hf=e=>{setTimeout(t=>{const n=document.querySelector(`[data-tab-id="${t}"]`);n&&n.scrollIntoView({behavior:"smooth"})},50,e)},zf=()=>{const{id:e}=Mi(),t=Y(),{data:n}=us(),s=Gc(),o=Go(sr.laptop),a=u=>{if(u===e&&n){if(n.length===1)return t(P.home.build());if(n.length>1){const d=n.find(m=>m.id!==u);if(d)return t(`/workbench/tab/${d.id}`)}}},i=u=>{u.stopPropagation(),u.preventDefault();const d=u.currentTarget.getAttribute("data-tab-id");d&&(s.mutate(d),a(d))},c=u=>{s.mutate(u),a(u)};return l.useEffect(()=>{e&&Hf(e)},[e,n]),r.jsxs("div",{className:"h-screen max-h-screen bg-(--bg) flex flex-col",children:[e?r.jsx(Wf,{id:e}):r.jsx("div",{className:"flex-1"}),r.jsx("div",{className:A(gn.tabs,"no-scrollbar",!o&&gn.mobile),children:n?.map(u=>r.jsxs("div",{onClick:()=>t(P.workbenchTab.build({id:u.id})),className:A(gn.tab,u.id===e&&gn.active),"data-tooltip-id":"default","data-tab-id":u.id,"data-tooltip-content":u.name,onAuxClick:()=>c(u.id),children:[r.jsxs("span",{className:"truncate w-full",children:["🛠️ ",u.name]}),r.jsx("button",{"data-tab-id":u.id,className:gn.closeButton,onClick:i,children:r.jsx(jt,{width:20,height:20})})]},u.id))})]})},Kf="_root_m02v8_2",Vf="_up_m02v8_2",Qf="_down_m02v8_2",Gf="_chevron_m02v8_2",Yf="_table-name-container_m02v8_2",Jf="_link_m02v8_2",Xf="_table-name_m02v8_2",Zf="_ul_m02v8_2",ep="_column-type_m02v8_2",tp="_action-blue_m02v8_2 _action_m02v8_2",np="_action-red_m02v8_2 _action_m02v8_2",sp="_db-header-container_m02v8_2",rp="_db-header_m02v8_2",op="_db-subheader_m02v8_2 _db-header_m02v8_2",te={root:Kf,up:Vf,down:Qf,chevron:Gf,tableNameContainer:Yf,link:Jf,tableName:Xf,ul:Zf,columnType:ep,actionBlue:tp,actionRed:np,dbHeaderContainer:sp,dbHeader:rp,dbSubheader:op},ap="_sidebar_9itzl_2",ip="_sidebar-visible_9itzl_2",lp="_sidebar-container_9itzl_2",cp="_sidebar-invisible_9itzl_2",up="_backdrop_9itzl_2",bn={sidebar:ap,sidebarVisible:ip,sidebarContainer:lp,sidebarInvisible:cp,backdrop:up},La=({children:e,backdropClose:t,isVisible:n,onClose:s,onClosed:o,contentClassName:a})=>{const[i,c]=l.useState(!1),u=l.useRef(s);u.current=s;const d=()=>{t&&s()},m=h=>{n||getComputedStyle(h.currentTarget).opacity==="0"&&(c(!1),o&&o())};return l.useEffect(()=>{n&&c(!0)},[n]),l.useEffect(()=>{const h=p=>{n&&p.key==="Escape"&&u.current()};return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h)}},[n]),r.jsxs("div",{onTransitionEnd:m,className:A(bn.sidebar,n?bn.sidebarVisible:bn.sidebarInvisible),children:[r.jsx("div",{onClick:d,className:bn.backdrop}),r.jsx("div",{className:A(bn.sidebarContainer,a),children:i&&e})]})},dp=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})),hp=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"})),Aa=(e,t=!0)=>{const n=navigator.clipboard.writeText(e);t&&n.then(()=>{je.success(`Copied "${e}"`)})},mp=new Intl.DateTimeFormat("en",{dateStyle:"full",timeStyle:"long"}),Vn=18;function fp(e,t){return t&&e.toLowerCase().includes(t)?"bg-yellow-200 cursor-pointer":"cursor-pointer"}const pp=({insp:e,filter:t,expanded:n})=>{const s=l.useMemo(()=>n?e.columns:t.length<1?[]:e.columns.filter(o=>o.name.toLowerCase().includes(t)),[e,t,n]);return r.jsx("ul",{className:te.ul,children:s.map(o=>r.jsx(r.Fragment,{children:r.jsxs("li",{children:[o.isPrimary?"🔐":"🏷️"," ",r.jsx("span",{onClick:()=>Aa(o.name),className:fp(o.name,t),children:o.name})," ",r.jsxs("span",{className:te.columnType,children:["[",o.type,"]"]}),o.ref&&r.jsxs("span",{children:[" ➡️ ",r.jsx("span",{className:te.columnType,children:o.ref.table}),".",o.ref.field]})]},o.name+o.type)}))},e.id)};function xp({id:e}){const{data:t}=cs(e),{data:n}=En(e),s=Y(),o=ic(),a=Do(),i=lc(),c=tn(),u=l.useMemo(()=>t?.lastInspected?mp.format(new Date(t.lastInspected)):"--",[t]),[d,m]=l.useState({}),[h,p]=l.useState(""),[x,b]=l.useState("table"),g=Tn(pe.EDITOR),v=h.toLowerCase(),y=l.useMemo(()=>{if(!v||!n)return n||[];const S=[];for(const I of n){if(I.tableName.toLowerCase().includes(v)){S.push(I);continue}x!=="table"&&I.columns.findIndex(B=>B.name.toLowerCase().includes(v))>=0&&S.push(I)}return S},[v,n,x]),f=S=>{m(I=>({...I,[S]:!I[S]}))},w=S=>{c.mutateAsync({name:S,opts:en({table:S,dataSourceId:e})}).then(I=>{Kt(void 0),s(P.workbenchTab.build({id:I.id}))})},C=()=>{a.mutate(e)},_=async()=>{const S=await Ln("Enter name",t?.name);S&&o.mutate({id:e,dataSource:{name:S}})},E=async()=>{await Vo("Are you sure you want to delete this data source?")&&(i.mutate(e),Kt(void 0))},j=x==="column";return r.jsxs("div",{className:te.root,children:[r.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-4 py-2 z-1",children:[r.jsxs("div",{className:te.dbHeaderContainer,children:[r.jsxs("div",{className:te.dbHeader,children:[t&&r.jsx(lt,{size:24,type:t.dbType}),r.jsx("p",{className:"truncate text-(--text-color-primary) text-lg",children:t?.name})]}),r.jsxs("div",{className:te.dbSubheader,children:[r.jsx("p",{className:"text-xs text-(--text-color-secondary) truncate",children:u}),g&&r.jsxs("div",{className:"flex justify-end",children:[r.jsx("button",{disabled:a.isPending,onClick:C,className:te.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Refresh schema",children:r.jsx(va,{width:16,height:16})}),r.jsx("button",{disabled:a.isPending,onClick:_,className:te.actionBlue,"data-tooltip-id":"default-xs","data-tooltip-content":"Update name",children:r.jsx(oa,{width:16,height:16})}),r.jsx("button",{disabled:a.isPending,onClick:E,className:te.actionRed,"data-tooltip-id":"default-xs","data-tooltip-content":"Delete data source",children:r.jsx(hp,{width:16,height:16})})]})]})]}),r.jsxs("div",{className:"flex gap-2 items-center mt-2",children:[r.jsxs("select",{className:"input",value:x,onChange:S=>b(S.currentTarget.value),children:[r.jsx("option",{value:"table",children:"Table"}),r.jsx("option",{value:"column",children:"Column"})]}),r.jsx("input",{className:"input flex-1 bg-gray-50",placeholder:j?"Search column":"Search table",value:h,onChange:S=>p(S.target.value),autoFocus:!0})]})]}),r.jsx("div",{className:"overflow-y-auto p-4",children:y?.map(S=>r.jsxs("div",{children:[r.jsxs("div",{className:te.tableNameContainer,children:[r.jsx("button",{className:A(te.chevron,d[S.id]?te.down:te.up),onClick:()=>f(S.id),children:r.jsx(Ge,{width:16,height:16})}),r.jsx("button",{className:A(te.tableName,"flex-1"),onClick:()=>f(S.id),children:S.tableName}),r.jsx("button",{className:te.link,onClick:()=>w(S.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Explore table data",children:r.jsx(dp,{width:Vn,height:Vn})}),r.jsx("button",{className:te.link,onClick:()=>Aa(S.tableName),"data-tooltip-id":"default-xs","data-tooltip-content":"Copy table name",children:r.jsx(ra,{width:Vn,height:Vn})})]}),(d[S.id]||h.length>0)&&r.jsx(pp,{insp:S,filter:j?v:"",expanded:d[S.id]})]},S.id))})]})}const gp=()=>{const e=Tu(),[t,n]=l.useState(void 0);l.useEffect(()=>{e&&n(e)},[e]);const s=()=>Kt(void 0);return r.jsx(La,{isVisible:e!=null,onClose:s,onClosed:()=>n(void 0),backdropClose:!0,children:t&&r.jsx(xp,{id:t})})},bp="_search_j0hbg_2",vp="_entry_j0hbg_2",yp="_ds_j0hbg_2",wp="_ds-container_j0hbg_2",Cp="_ds-entry_j0hbg_2",jp="_enabled_j0hbg_2",Ut={search:bp,entry:vp,ds:yp,dsContainer:wp,dsEntry:Cp,enabled:jp};function Np(e,t,n){try{const s=n.getItem(e);if(s)return JSON.parse(s)}catch(s){console.warn("Failed to restore tabs",s)}return t}const _p=({storage:e=localStorage,localStorageKey:t,initialData:n})=>{const s=Se(Np(t,n,e));return s[2].subscribe(o=>{e.setItem(t,JSON.stringify(o))}),s},[Sp,Ep]=_p({initialData:[],localStorageKey:"selected-data-sources-v1"}),kp=e=>Ep(t=>{const n=t.indexOf(e);return n>-1?(t.splice(n,1),[...t]):[...t,e]}),Rp={table:"📄",query:"📖",tab:"🛠️"},Tp=({onTable:e,onQuery:t,onWorkbenchTab:n,autoFocus:s})=>{const[o,a]=l.useState(""),[i,c]=l.useState(-1),u=Ta(o,200),d=Sp(),{data:m}=ue(),{data:h}=Xs({teamId:m?.teamId}),p=l.useMemo(()=>{const f=[],w=eo(d);if(!h||h.length===0)return[];for(const C of h)w[C.id]&&f.push(C.id);return f},[d,h]),{data:x}=Yl(u,{teamId:m?.teamId,selectedDataSources:p}),b=f=>{f.type==="table"?e(f.name,f.dataSourceId):f.type==="query"?t(f.id,f.dataSourceId):f.type==="tab"&&n(f.id,f.dataSourceId)},g=f=>{x&&(f.key==="ArrowDown"?(f.preventDefault(),c(w=>(w+1)%x.length)):f.key==="ArrowUp"?(f.preventDefault(),c(w=>(w-1+x.length)%x.length)):f.key==="Enter"&&i>=0&&x[i]?.name&&(f.preventDefault(),b(x[i])))},v=f=>{const w=f.currentTarget.dataset.tableId,C=x?.find(_=>_.id===w);C&&b(C)},y=l.useMemo(()=>eo(d),[d]);return r.jsxs("div",{className:"overflow-hidden flex flex-col w-full lg:w-lg",children:[De(h?.length,0)?r.jsx("div",{className:Ut.dsContainer+" no-scrollbar",children:h.map(f=>r.jsxs("button",{className:A(Ut.dsEntry,y[f.id]&&Ut.enabled),onClick:()=>kp(f.id),children:[r.jsx(lt,{size:24,type:f.dbType}),r.jsx("span",{children:f.name})]},f.id))}):r.jsx(ne,{variant:"warning",className:"mb-4",children:"Connect at least one data source to start using DataRamen"}),r.jsx("input",{className:Ut.search,placeholder:"Search table or saved query to start from",value:o,onChange:f=>a(f.target.value),onKeyDown:g,autoFocus:s}),De(x?.length,0)&&r.jsx("div",{className:"overflow-y-auto max-h-full mt-2",children:x.map((f,w)=>r.jsxs("button",{className:Ut.entry,"data-is-active":i===w,"data-table-id":f.id,onClick:v,children:[r.jsxs("p",{className:"font-semibold truncate",children:[Rp[f.type]," ",f.name]}),r.jsxs("p",{className:Ut.ds,children:["📦 ",f.dataSourceName]})]},f.id))})]})},Lp=()=>{const e=Zc(),t=(a,i)=>{e?.onConfirm("table",a,i)},n=(a,i)=>{e?.onConfirm("query",a,i)},s=(a,i)=>{e?.onConfirm("tab",a,i)},o=()=>{e?.onCancel()};return r.jsx(ve,{isVisible:!!e,onClose:o,backdropClose:!0,children:r.jsx(Tp,{autoFocus:!0,onTable:t,onQuery:n,onWorkbenchTab:s})})},Ap=()=>{const e=Rn("Hotkey"),t=Y(),{pathname:n}=le(),{data:s}=ue(),{data:o}=us(),a=P.home.check(n);Re("n",()=>{s&&e()}),Re("w",()=>{s&&(o&&o.length>0?t(P.workbenchTab.build({id:o[0].id})):e())},{enabled:a}),Re("h",()=>{Vt({show:!0})})},Pp=()=>{const e=le();l.useEffect(()=>{},[e.pathname])},[Ip,Pa]=Se(!1),Ps=()=>Pa(!1),Ia=()=>Pa(!0),Op=({repeatPassword:e,password:t})=>t.length<1?null:t.length<8?r.jsx(ne,{variant:"warning",children:"New password should be at least 8 characters long"}):t!==e?r.jsx(ne,{variant:"warning",children:"Repeat password should match new password"}):null,Mp=()=>{const e=Ip(),{data:t}=ue(),{mutateAsync:n,isPending:s}=cc(),o=Y(),[{password:a,repeatPassword:i},{change:c,touched:u,reset:d}]=jn({password:"",repeatPassword:""}),m=()=>{o("/"),zs.logout().then(()=>{Ps()})},h=()=>{n({password:a}).then(()=>{d(),je.success("Password successfully updated!")})},p=a.length<8||a!==i||s,x=u.includes("password");return r.jsxs(ve,{isVisible:e,onClose:Ps,children:[r.jsx(it,{onClick:Ps}),r.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[r.jsx(Ko,{children:"Account settings"}),r.jsxs("label",{children:[r.jsx("p",{className:"text-xs font-semibold mb-1",children:"Username"}),r.jsx("input",{className:"input w-full",readOnly:!0,disabled:!0,value:t?.username})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.jsxs("label",{children:[r.jsx("p",{className:"text-xs font-semibold mb-1",children:"Change password"}),r.jsx("input",{className:"input w-full",type:"password",name:"newPassword",autoComplete:"new-password",value:a,onChange:c("password")})]}),r.jsxs("label",{children:[r.jsx("p",{className:"text-xs font-semibold mb-1",children:"Repeat password"}),r.jsx("input",{className:"input w-full",type:"password",value:i,onChange:c("repeatPassword")})]})]}),x&&r.jsx(Op,{password:a,repeatPassword:i}),r.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[r.jsx("button",{className:"button tertiary",disabled:p,onClick:h,children:"Update password"}),r.jsx("button",{className:"button danger",onClick:m,children:"Log out"})]})]})]})},[$p,Oa]=Se(!1),Ma=()=>Oa(!0),no=()=>Oa(!1),Dp=e=>ce({queryKey:["team-users"],queryFn:async()=>{const{data:t}=await O.get("/teams/"+e+"/users");return t.data},enabled:!!e}),Fp=()=>X({mutationFn:async({role:e,teamId:t,userId:n})=>(await O.patch("/teams/"+t+"/user-role",{role:e,userId:n}),!0),onSuccess:()=>{Q.invalidateQueries({queryKey:["team-users"]})}}),Bp=()=>X({mutationFn:async({teamId:e,userId:t})=>(await O.delete("/teams/"+e,{params:{userId:t}}),!0),onSuccess:()=>{Q.invalidateQueries({queryKey:["team-users"]})}}),qp="_user-entry_o919l_2",Up="_select-container_o919l_2",so={userEntry:qp,selectContainer:Up},Wp=()=>{const e=$p(),{data:t}=ue(),{data:n}=Dp(t?.teamId),{mutate:s,isPending:o}=uc(),{mutate:a,isPending:i}=Fp(),{mutate:c,isPending:u}=Bp(),[d,{change:m,reset:h}]=jn({password:"",username:""}),p=()=>{s({username:d.username,password:d.password,teamId:t?.teamId||""}),h()},x=(y,f)=>{a({teamId:t.teamId,role:f,userId:y})},b=y=>{Vo("Are you sure you want to remove this user?").then(f=>{f&&c({userId:y,teamId:t.teamId})})},g=Tn(pe.ADMIN),v=o||i||u;return r.jsxs(ve,{isVisible:e,onClose:no,backdropClose:!0,children:[r.jsx(it,{onClick:no}),r.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[r.jsx(Ko,{children:"Manage users"}),De(n?.length,0)&&r.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:n.map(y=>r.jsxs("div",{className:so.userEntry,children:[r.jsx("div",{className:so.selectContainer,children:r.jsxs("select",{value:y.role,disabled:!g||v,onChange:f=>x(y.id,f.currentTarget.value),children:[r.jsx("option",{value:pe.OWNER,children:"Owner"}),r.jsx("option",{value:pe.ADMIN,children:"Admin"}),r.jsx("option",{value:pe.EDITOR,children:"Editor"}),r.jsx("option",{value:pe.READ_ONLY,children:"Reader"})]})}),r.jsx("p",{className:"flex-1 mx-2",children:y.name}),g&&r.jsx("button",{className:"p-1 cursor-pointer text-red-500 text-sm",onClick:()=>b(y.id),children:"❌"})]},y.id))}),g&&r.jsxs("div",{className:"mt-4",children:[r.jsx("p",{className:"font-semibold",children:"Create new user"}),r.jsxs("div",{className:"flex flex-col lg:flex-row gap-2 lg:items-center mt-2",children:[r.jsx("input",{className:"input flex-1",onChange:m("username"),value:d.username,placeholder:"Username",disabled:v}),r.jsx("input",{className:"input",onChange:m("password"),value:d.password,type:"password",name:"newPassword",autoComplete:"new-password",placeholder:"Password",disabled:v}),r.jsx("button",{className:"button primary",onClick:p,disabled:v,children:"Create user"})]}),r.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."})]})]})]})},Hp=()=>{const[e,t]=l.useState(""),[n,s]=l.useState(""),[o,a]=l.useState(),[i,c]=l.useState(!1),u=Y(),d=m=>{m.preventDefault(),a(void 0),zs.login({password:n,username:e}).then(()=>{u("/",{replace:!0})}).catch(a)};return r.jsx("div",{className:"page-container bg-(--bg) h-screen",children:r.jsx("div",{className:"page-content items-center",children:r.jsxs("form",{className:"flex flex-col gap-2 w-full lg:w-lg",onSubmit:d,children:[r.jsx("p",{className:"font-semibold text-xl min-w-md",children:"Login"}),o&&r.jsx(ne,{variant:"danger",children:"Failed to login. Please verify your credentials"}),r.jsx("input",{value:e,onChange:m=>t(m.currentTarget.value),className:"input",placeholder:"User name"}),r.jsx("input",{value:n,onChange:m=>s(m.currentTarget.value),className:"input",type:"password",placeholder:"Password"}),r.jsx("button",{type:"submit",className:"button primary",children:"Login"}),i?r.jsxs(ne,{className:"w-full border border-blue-500",children:[r.jsx("p",{children:"If this is your first login, the default credentials are:"}),r.jsxs("ul",{className:"mt-2",children:[r.jsxs("li",{children:["Username: ",r.jsx("strong",{children:"admin"})]}),r.jsxs("li",{children:["Password: ",r.jsx("strong",{children:"admin"})]})]}),r.jsx("p",{className:"mt-2",children:"Please make sure to change the default password to a secure one."})]}):r.jsx("button",{className:"button tertiary",onClick:()=>c(!0),children:"First login?"})]})})})},zp=()=>{const e=Y(),{pathname:t}=le(),{data:n,isLoading:s}=Fo();l.useEffect(()=>{!n&&!s&&!P.login.check(t)&&e(P.login.build())},[n,s,e,t])},Kp=()=>{},Vp=__CLIENT_CONFIG__.skipAuth?Kp:zp,Qp=()=>{const[e]=El(),t=Y(),n=tn(),s=e.get("shareId");return l.useEffect(()=>{s&&n.mutateAsync({queryId:s}).then(o=>{t(P.workbenchTab.build({id:o.id}),{replace:!0})})},[s]),r.jsxs("div",{className:"page-container flex items-center justify-center h-screen",children:[n.isPending&&r.jsxs("div",{className:"flex items-center flex-col gap-2",children:[r.jsx(hr,{}),r.jsx("p",{children:"Fetching query information"})]}),n.isError&&r.jsx(ne,{variant:"danger",children:"Failed to load query information"})]})},Gp="_container_wvlsy_2",Yp="_header_wvlsy_2",Jp="_close-button_wvlsy_2",Xp="_tab-container_wvlsy_2",Zp="_tab-name_wvlsy_2",e0="_archived-badge_wvlsy_2 _badge_wvlsy_2",t0="_active-badge_wvlsy_2 _badge_wvlsy_2",n0="_delete-action_wvlsy_2",s0="_load-more-btn_wvlsy_2",ze={container:Gp,header:Yp,closeButton:Jp,tabContainer:Xp,tabName:Zp,archivedBadge:e0,activeBadge:t0,deleteAction:n0,loadMoreBtn:s0},r0=new Intl.DateTimeFormat,o0=()=>{const{data:e}=ue(),{data:t,fetchNextPage:n,hasNextPage:s,isFetching:o}=Jl(e?.teamId,25),a=Y(),i=Wo(),c=Xc(),u=l.useRef(null),d=l.useRef(null),m=x=>{i.mutate(x),Vt({show:!1}),a(P.workbenchTab.build({id:x}))},h=()=>{u.current?.close(),c.mutate(d.current)},p=t&&t?.length>0;return r.jsxs("div",{className:ze.container,children:[r.jsxs("div",{className:ze.header,children:[r.jsx("h3",{className:"text-lg",children:"Recent tabs"}),r.jsx("button",{className:ze.closeButton,onClick:()=>Vt({show:!1}),children:r.jsx(jt,{width:24,height:24})})]}),!p&&r.jsx(ne,{variant:"warning",children:"History is empty."}),t?.map(x=>r.jsxs("div",{className:ze.tabContainer,onClick:()=>m(x.id),onContextMenu:b=>{d.current=x.id,u.current?.open(b,!1)},children:[r.jsxs("div",{className:"flex gap-2 items-center",children:[r.jsx("p",{className:ze.tabName,children:x.name}),x.dataSourceType&&r.jsx(lt,{size:16,type:x.dataSourceType}),r.jsx("p",{className:"text-xs text-(--text-color-secondary)",children:x.dataSourceName})]}),r.jsxs("div",{className:"flex gap-2 items-center mt-1",children:[r.jsx("p",{className:"text-xs text-(--text-color-secondary) italic",children:r0.format(new Date(x.updatedAt))}),x.archived?r.jsx("span",{className:ze.archivedBadge,children:"Archived"}):r.jsx("span",{className:ze.activeBadge,children:"Active"})]})]},x.id)),r.jsx(sa,{ref:u,children:r.jsx("button",{onClick:h,className:ze.deleteAction,children:"🗑 Delete"})}),s&&!o&&r.jsx("div",{className:"flex justify-center my-2",children:r.jsx("button",{className:ze.loadMoreBtn,onClick:()=>n(),children:"Load more"})})]})},a0=()=>{const e=Lu(t=>t.show);return r.jsx(La,{isVisible:e,onClose:()=>Vt({show:!1}),backdropClose:!0,children:r.jsx(o0,{})})},i0="_queries-container_cnd4g_2",l0="_query-entry_cnd4g_2",ro={queriesContainer:i0,queryEntry:l0},c0=()=>{const{data:e}=ue(),[t,n]=l.useState(""),s=Ta(t),{data:o,isLoading:a,fetchNextPage:i,hasNextPage:c}=Xl(e?.teamId,s),u=l.useRef(void 0),d=Y(),m=Lh(),h=tn(),p=Th(),x=Xo(),b=y=>{h.mutateAsync({queryId:y}).then(f=>{d(P.workbenchTab.build({id:f.id}))})},g=async y=>{const f=o?.find(C=>C.id===y);if(!f)return;const w=await Ln("New name?",f?.name);w&&m.mutate({id:f.savedQueryId,payload:{name:w}})},v=y=>{const f=o?.find(w=>w.id===y)?.savedQueryId;f&&p.mutate(f)};return r.jsxs("div",{className:ro.queriesContainer,children:[r.jsx("div",{className:"sticky top-0 p-4 bg-(--bg)",children:r.jsx("input",{className:"input w-full",placeholder:"Filter",value:t,onChange:y=>n(y.target.value)})}),De(o?.length,0)&&o.map(y=>r.jsxs("button",{className:ro.queryEntry,onClick:()=>b(y.id),onContextMenu:f=>{u.current=y.id,x.open(f)},children:[r.jsxs("p",{className:"text-left",children:["📖 ",y.name]}),r.jsxs("p",{className:"flex gap-2 items-center",children:[r.jsx(lt,{size:20,type:y.datasourceType}),r.jsx("span",{className:"truncate text-sm text-(--text-color-secondary)",children:y.datasourceName})]})]},y.savedQueryId)),c&&r.jsx("button",{className:"button primary mx-auto mt-4",onClick:()=>i(),children:"Load more"}),!a&&th(o?.length,1)&&r.jsx("p",{className:"text-center text-sm text-(--text-color-secondary)",children:"Empty"}),r.jsx(Zo,{handler:x,children:r.jsxs("div",{className:"context-menu-container",children:[r.jsx("button",{onClick:y=>{y.preventDefault(),y.stopPropagation(),x.close(),g(u.current)},className:"context-menu-item",children:"✏️ Rename"}),r.jsx("button",{onClick:y=>{y.preventDefault(),y.stopPropagation(),x.close(),v(u.current)},className:"context-menu-item",children:"🗑️ Delete"})]})})]})},u0=()=>{const{data:e}=ue(),{data:t,isLoading:n}=tc(e?.teamId);return r.jsx("div",{className:"page-container h-screen max-h-screen",children:r.jsxs("div",{className:"page-content max-h-full",children:[r.jsx("div",{className:"py-10 text-center w-full",children:r.jsx("h1",{className:"comfortaa text-3xl font-semibold text-(--text-color-primary)",children:P.savedQueries.name})}),t?r.jsx(c0,{}):r.jsx(r.Fragment,{children:n?r.jsx(hr,{}):r.jsx(ne,{variant:"warning",children:"You don't have saved queries."})})]})})},d0=()=>{const{data:e}=ue(),t=ec(e?.teamId),n=Y();return l.useEffect(()=>{t.mutateAsync().then(s=>{s?n(P.workbenchTab.build({id:s.id}),{replace:!0}):n(P.home.build(),{replace:!0})})},[]),null};function h0(){return Ap(),Pp(),Vp(),r.jsxs(r.Fragment,{children:[r.jsxs(Ji,{children:[r.jsx(vt,{path:P.home.path,element:r.jsx(Fu,{})}),r.jsx(vt,{path:P.workbench.path,element:r.jsx(d0,{})}),r.jsx(vt,{path:P.workbenchTab.path,element:r.jsx(zf,{})}),r.jsx(vt,{path:P.login.path,element:r.jsx(Hp,{})}),r.jsx(vt,{path:P.share.path,element:r.jsx(Qp,{})}),r.jsx(vt,{path:P.savedQueries.path,element:r.jsx(u0,{})})]}),r.jsx(Ju,{}),r.jsx(id,{}),r.jsx(yd,{}),r.jsx(gp,{}),r.jsx(Lp,{}),r.jsx(Mp,{}),r.jsx(Wp,{}),r.jsx(a0,{}),r.jsx(pd,{}),r.jsx(ud,{})]})}const m0="_hidden_7arb0_2",f0="_desktop-layout_7arb0_2",p0="_mobile-layout_7arb0_2",x0="_nav_7arb0_2",g0="_shown_7arb0_2",b0="_main_7arb0_2",v0="_header_7arb0_2",y0="_expand_7arb0_2",w0="_show_7arb0_2",C0="_hide_7arb0_2",j0="_icon_7arb0_2",N0="_nav-item_7arb0_2",_0="_project-wrapper_7arb0_2",$={hidden:m0,desktopLayout:f0,mobileLayout:p0,nav:x0,shown:g0,main:b0,header:v0,expand:y0,show:w0,hide:C0,icon:j0,navItem:N0,projectWrapper:_0},S0="_container_i6lsu_2",E0={container:S0},k0=({dataSource:e,index:t})=>{const n=()=>{Kt(e.id)};return Re(t.toString(),()=>{Kt(s=>{if(s!==e.id)return e.id})}),r.jsxs("button",{className:$.navItem,onClick:n,children:[r.jsx("span",{className:$.icon,children:r.jsx(lt,{size:20,type:e.dbType})}),r.jsx("span",{className:"truncate",children:e.name}),r.jsx("span",{className:"hotkey secondary",children:t})]})},R0=()=>{const{data:e}=ue(),{data:t}=Ql(e?.teamId);return r.jsx("div",{className:E0.container,children:De(t?.length,0)&&r.jsxs("div",{className:"mt-4 flex flex-col",children:[r.jsx("p",{className:"font-semibold truncate text-(--text-color-secondary) mb-2",children:"Data sources"}),t.map((n,s)=>r.jsx(k0,{dataSource:n,index:s+1},n.id))]})})},T0=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"ionicon",viewBox:"0 0 512 512",...e},l.createElement("path",{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",{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"})),L0=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"})),A0=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"})),P0=!__CLIENT_CONFIG__.skipAuth,oo=(()=>{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`}})();function I0(){switch(__CLIENT_CONFIG__.modeName){case"docker":return r.jsx(T0,{className:"text-(--text-color-secondary)",width:20,height:20});case"cli":return r.jsx(L0,{className:"text-(--text-color-secondary)",width:20,height:20});default:return r.jsx(A0,{className:"text-(--text-color-secondary)",width:20,height:20})}}const O0=()=>{const e=Y(),{pathname:t}=le(),{data:n}=ue(),s=Rn("Desktop nav"),[o,a]=l.useState(!1),{data:i}=us(),c=()=>{P.home.check(t)||e(P.home.build())},u=p=>{P.workbenchTab.check(t)||e(P.workbenchTab.build({id:p}))},d=()=>{P.savedQueries.check(t)||e(P.savedQueries.build())},m=()=>Vt({show:!0}),h=o?void 0:"default";return r.jsxs("nav",{className:A($.nav,o?$.shown:$.hidden),children:[n&&r.jsxs("div",{className:$.header,children:[r.jsxs("button",{onClick:c,className:$.navItem,"data-tooltip-id":h,"data-tooltip-content":"Home",children:[r.jsx("span",{className:$.icon,children:"🏠"}),r.jsx("span",{className:"truncate",children:"Home"})]}),r.jsxs("button",{onClick:s,className:$.navItem,"data-tooltip-id":h,"data-tooltip-content":"New query",children:[r.jsx("span",{className:$.icon,children:"🔎"}),r.jsx("span",{className:"truncate",children:"New query"}),r.jsx("span",{className:"hotkey secondary",children:"N"})]}),r.jsxs("button",{onClick:m,className:$.navItem,"data-tooltip-id":h,"data-tooltip-content":"Recent tabs",children:[r.jsx("span",{className:$.icon,children:"⌛"}),r.jsx("span",{className:"truncate",children:"Recent tabs"}),r.jsx("span",{className:"hotkey secondary",children:"H"})]}),r.jsxs("button",{onClick:d,className:$.navItem,"data-tooltip-id":h,"data-tooltip-content":"Saved queries",children:[r.jsx("span",{className:$.icon,children:"💾"}),r.jsx("span",{className:"truncate",children:"Saved queries"})]}),De(i?.length,0)&&r.jsxs("button",{onClick:()=>u(i[0].id),className:$.navItem,"data-tooltip-id":h,"data-tooltip-content":"Workbench",children:[r.jsx("span",{className:$.icon,children:"🛠️"}),r.jsx("span",{className:"truncate",children:"Workbench"})]}),P0&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{onClick:Ia,className:$.navItem,"data-tooltip-id":h,"data-tooltip-content":"User settings",children:[r.jsx("span",{className:$.icon,children:"🪪"}),r.jsx("span",{className:"truncate",children:n.username})]}),r.jsxs("button",{onClick:Ma,className:$.navItem,"data-tooltip-id":h,"data-tooltip-content":"Manage users",children:[r.jsx("span",{className:$.icon,children:"👥"}),r.jsx("span",{className:"truncate",children:"Manage users"})]})]})]}),r.jsx("div",{className:A($.projectWrapper,o?$.show:$.hide),children:r.jsx(R0,{})}),r.jsxs("button",{onClick:()=>a(!o),className:`${$.navItem} mx-2`,children:[r.jsx("span",{className:A($.icon,$.expand,o?$.show:$.hide),children:r.jsx(Ge,{className:"text-(--text-color-secondary)",width:20,height:20})}),r.jsx("span",{className:"truncate text-sm text-(--text-color-secondary)",children:"Collapse menu"})]}),r.jsxs("div",{className:`${$.navItem} mx-2 mb-2`,"data-tooltip-id":h,"data-tooltip-content":oo,children:[r.jsx("span",{className:$.icon,children:r.jsx(I0,{})}),r.jsx("span",{className:"truncate text-sm text-(--text-color-secondary)",children:oo})]})]})},M0="_root_r5ahz_2",$0={root:M0},$a=!__CLIENT_CONFIG__.skipAuth,D0=`${$0.root} ${$a?"grid-cols-4":"grid-cols-2"}`,F0=()=>{const{pathname:e}=le(),t=Y(),n=Rn("Mobile nav"),s=()=>{P.home.check(e)||t(P.home.build())};return r.jsxs("div",{className:D0,children:[r.jsxs("button",{onClick:s,children:[r.jsx("p",{children:"🏠"}),r.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Home"})]}),r.jsxs("button",{onClick:n,children:[r.jsx("p",{children:"🔎"}),r.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"New query"})]}),$a&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{onClick:Ia,children:[r.jsx("p",{children:"🪪"}),r.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Account"})]}),r.jsxs("button",{onClick:Ma,children:[r.jsx("p",{children:"👥"}),r.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Users"})]})]})]})},B0=({children:e,isLogin:t})=>r.jsxs("div",{className:$.desktopLayout,children:[r.jsx(os,{id:"default",className:"z-100"}),r.jsx(os,{id:"default-xs",className:"z-100 text-xs!"}),!t&&r.jsx(O0,{}),r.jsx("main",{className:$.main,children:e})]}),q0=({children:e,isLogin:t})=>r.jsxs("div",{className:$.mobileLayout,children:[r.jsx("main",{className:$.main,children:e}),!t&&r.jsx(F0,{})]}),U0=({children:e})=>{const t=Go(sr.laptop),{pathname:n}=le(),s=P.login.check(n);return t?r.jsx(B0,{isLogin:s,children:e}):r.jsx(q0,{isLogin:s,children:e})};Xa.createRoot(document.getElementById("root")).render(r.jsxs(et.StrictMode,{children:[r.jsx(Za,{}),r.jsx($l,{client:Q,children:r.jsx(Cl,{children:r.jsx(U0,{children:r.jsx(h0,{})})})})]}));
|