@dataramen/cli 0.0.47 → 0.0.48
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var c=(r,e)=>{for(var m in e)n(r,m,{get:e[m],enumerable:!0})},y=(r,e,m,d)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of o(e))!l.call(r,t)&&t!==m&&n(r,t,{get:()=>e[t],enumerable:!(d=i(e,t))||d.enumerable});return r};var N=r=>y(n({},"__esModule",{value:!0}),r);var p={};c(p,{QueriesHistory1758316062697:()=>s});module.exports=N(p);var a=require("typeorm");var u=process.env.APP_DB_TYPE==="sqlite"?"datetime":"timestamp";var s=class{name="QueriesHistory1758316062697";async up(e){await e.createTable(new a.Table({name:"queryHistory",columns:[{name:"id",type:"uuid",isPrimary:!0,isGenerated:!0,generationStrategy:"uuid"},{name:"name",type:"varchar"},{name:"opts",type:"json",default:"'{}'"},{name:"createdAt",type:u,default:"CURRENT_TIMESTAMP"},{name:"updatedAt",type:u,default:"CURRENT_TIMESTAMP"},{name:"teamId",type:"uuid",isNullable:!0},{name:"dataSourceId",type:"uuid",isNullable:!0},{name:"userId",type:"uuid",isNullable:!1}]})),await e.createForeignKeys("queryHistory",[new a.TableForeignKey({columnNames:["teamId"],referencedTableName:"teams",referencedColumnNames:["id"]}),new a.TableForeignKey({columnNames:["dataSourceId"],referencedTableName:"data_sources",referencedColumnNames:["id"]})]),await e.addColumns("query",[new a.TableColumn({name:"userId",type:"uuid",isNullable:!0})]),await e.createForeignKeys("query",[new a.TableForeignKey({columnNames:["userId"],referencedTableName:"users",referencedColumnNames:["id"]})])}async down(e){await e.dropForeignKeys("query",[new a.TableForeignKey({columnNames:["userId"],referencedTableName:"users",referencedColumnNames:["id"]})]),await e.dropColumns("query",["userId"]),await e.dropForeignKeys("queryHistory",[new a.TableForeignKey({columnNames:["teamId"],referencedTableName:"teams",referencedColumnNames:["id"]}),new a.TableForeignKey({columnNames:["dataSourceId"],referencedTableName:"data_sources",referencedColumnNames:["id"]})]),await e.dropTable("queryHistory",!0)}};0&&(module.exports={QueriesHistory1758316062697});
|
|
@@ -234,7 +234,7 @@ to {
|
|
|
234
234
|
Licensed under the MIT License (MIT), see
|
|
235
235
|
http://jedwatson.github.io/classnames
|
|
236
236
|
*/var Yb;function AN(){return Yb||(Yb=1,function(e){(function(){var n={}.hasOwnProperty;function i(){for(var o="",c=0;c<arguments.length;c++){var f=arguments[c];f&&(o=s(o,l(f)))}return o}function l(o){if(typeof o=="string"||typeof o=="number")return o;if(typeof o!="object")return"";if(Array.isArray(o))return i.apply(null,o);if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]"))return o.toString();var c="";for(var f in o)n.call(o,f)&&o[f]&&(c=s(c,f));return c}function s(o,c){return c?o?o+" "+c:o+c:o}e.exports?(i.default=i,e.exports=i):window.classNames=i})()}(hh)),hh.exports}var TN=AN();const ep=ka(TN);var Kb={};const _N="react-tooltip-core-styles",NN="react-tooltip-base-styles",Gb={core:!1,base:!1};function Xb({css:e,id:n=NN,type:i="base",ref:l}){var s,o;if(!e||typeof document>"u"||Gb[i]||i==="core"&&typeof process<"u"&&(!((s=process==null?void 0:Kb)===null||s===void 0)&&s.REACT_TOOLTIP_DISABLE_CORE_STYLES)||i!=="base"&&typeof process<"u"&&(!((o=process==null?void 0:Kb)===null||o===void 0)&&o.REACT_TOOLTIP_DISABLE_BASE_STYLES))return;i==="core"&&(n=_N),l||(l={});const{insertAt:c}=l;if(document.getElementById(n))return;const f=document.head||document.getElementsByTagName("head")[0],h=document.createElement("style");h.id=n,h.type="text/css",c==="top"&&f.firstChild?f.insertBefore(h,f.firstChild):f.appendChild(h),h.styleSheet?h.styleSheet.cssText=e:h.appendChild(document.createTextNode(e)),Gb[i]=!0}const Zb=async({elementReference:e=null,tooltipReference:n=null,tooltipArrowReference:i=null,place:l="top",offset:s=10,strategy:o="absolute",middlewares:c=[SN(Number(s)),EN({fallbackAxisSideDirection:"start"}),CN({padding:5})],border:f,arrowSize:h=8})=>{if(!e)return{tooltipStyles:{},tooltipArrowStyles:{},place:l};if(n===null)return{tooltipStyles:{},tooltipArrowStyles:{},place:l};const d=c;return i?(d.push(kN({element:i,padding:5})),$b(e,n,{placement:l,strategy:o,middleware:d}).then(({x:m,y,placement:x,middlewareData:v})=>{var w,T;const _={left:`${m}px`,top:`${y}px`,border:f},{x:E,y:N}=(w=v.arrow)!==null&&w!==void 0?w:{x:0,y:0},j=(T={top:"bottom",right:"left",bottom:"top",left:"right"}[x.split("-")[0]])!==null&&T!==void 0?T:"bottom",q=f&&{borderBottom:f,borderRight:f};let L=0;if(f){const D=`${f}`.match(/(\d+)px/);L=D!=null&&D[1]?Number(D[1]):1}return{tooltipStyles:_,tooltipArrowStyles:{left:E!=null?`${E}px`:"",top:N!=null?`${N}px`:"",right:"",bottom:"",...q,[j]:`-${h/2+L}px`},place:x}})):$b(e,n,{placement:"bottom",strategy:o,middleware:d}).then(({x:m,y,placement:x})=>({tooltipStyles:{left:`${m}px`,top:`${y}px`},tooltipArrowStyles:{},place:x}))},Jb=(e,n)=>!("CSS"in window&&"supports"in window.CSS)||window.CSS.supports(e,n),Wb=(e,n,i)=>{let l=null;const s=function(...o){const c=()=>{l=null};!l&&(e.apply(this,o),l=setTimeout(c,n))};return s.cancel=()=>{l&&(clearTimeout(l),l=null)},s},e1=e=>e!==null&&!Array.isArray(e)&&typeof e=="object",tp=(e,n)=>{if(e===n)return!0;if(Array.isArray(e)&&Array.isArray(n))return e.length===n.length&&e.every((s,o)=>tp(s,n[o]));if(Array.isArray(e)!==Array.isArray(n))return!1;if(!e1(e)||!e1(n))return e===n;const i=Object.keys(e),l=Object.keys(n);return i.length===l.length&&i.every(s=>tp(e[s],n[s]))},RN=e=>{if(!(e instanceof HTMLElement||e instanceof SVGElement))return!1;const n=getComputedStyle(e);return["overflow","overflow-x","overflow-y"].some(i=>{const l=n.getPropertyValue(i);return l==="auto"||l==="scroll"})},t1=e=>{if(!e)return null;let n=e.parentElement;for(;n;){if(RN(n))return n;n=n.parentElement}return document.scrollingElement||document.documentElement},jN=typeof window<"u"?k.useLayoutEffect:k.useEffect,Xn=e=>{e.current&&(clearTimeout(e.current),e.current=null)},ON="DEFAULT_TOOLTIP_ID",DN={anchorRefs:new Set,activeAnchor:{current:null},attach:()=>{},detach:()=>{},setActiveAnchor:()=>{}},MN=k.createContext({getTooltipData:()=>DN});function _x(e=ON){return k.useContext(MN).getTooltipData(e)}var da={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"},ph={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 LN=({forwardRef:e,id:n,className:i,classNameArrow:l,variant:s="dark",anchorId:o,anchorSelect:c,place:f="top",offset:h=10,events:d=["hover"],openOnClick:m=!1,positionStrategy:y="absolute",middlewares:x,wrapper:v,delayShow:w=0,delayHide:T=0,float:_=!1,hidden:E=!1,noArrow:N=!1,clickable:j=!1,closeOnEsc:q=!1,closeOnScroll:L=!1,closeOnResize:D=!1,openEvents:X,closeEvents:ee,globalCloseEvents:ie,imperativeModeOnly:U,style:ae,position:te,afterShow:ue,afterHide:J,disableTooltip:oe,content:B,contentWrapperRef:G,isOpen:ne,defaultIsOpen:pe=!1,setIsOpen:C,activeAnchor:I,setActiveAnchor:se,border:R,opacity:fe,arrowColor:Te,arrowSize:ce=8,role:ft="tooltip"})=>{var je;const Ie=k.useRef(null),Ft=k.useRef(null),wt=k.useRef(null),fn=k.useRef(null),nr=k.useRef(null),[dn,ui]=k.useState({tooltipStyles:{},tooltipArrowStyles:{},place:f}),[Dt,Mt]=k.useState(!1),[rr,Cn]=k.useState(!1),[Ke,Un]=k.useState(null),Lr=k.useRef(!1),gr=k.useRef(null),{anchorRefs:zr,setActiveAnchor:ci}=_x(n),$=k.useRef(!1),[W,me]=k.useState([]),ge=k.useRef(!1),qe=m||d.includes("click"),Pt=qe||(X==null?void 0:X.click)||(X==null?void 0:X.dblclick)||(X==null?void 0:X.mousedown),Yt=X?{...X}:{mouseover:!0,focus:!0,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1};!X&&qe&&Object.assign(Yt,{mouseenter:!1,focus:!1,mouseover:!1,click:!0});const gt=ee?{...ee}:{mouseout:!0,blur:!0,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1};!ee&&qe&&Object.assign(gt,{mouseleave:!1,blur:!1,mouseout:!1});const yt=ie?{...ie}:{escape:q||!1,scroll:L||!1,resize:D||!1,clickOutsideAnchor:Pt||!1};U&&(Object.assign(Yt,{mouseover:!1,focus:!1,mouseenter:!1,click:!1,dblclick:!1,mousedown:!1}),Object.assign(gt,{mouseout:!1,blur:!1,mouseleave:!1,click:!1,dblclick:!1,mouseup:!1}),Object.assign(yt,{escape:!1,scroll:!1,resize:!1,clickOutsideAnchor:!1})),jN(()=>(ge.current=!0,()=>{ge.current=!1}),[]);const He=le=>{ge.current&&(le&&Cn(!0),setTimeout(()=>{ge.current&&(C==null||C(le),ne===void 0&&Mt(le))},10))};k.useEffect(()=>{if(ne===void 0)return()=>null;ne&&Cn(!0);const le=setTimeout(()=>{Mt(ne)},10);return()=>{clearTimeout(le)}},[ne]),k.useEffect(()=>{if(Dt!==Lr.current)if(Xn(nr),Lr.current=Dt,Dt)ue==null||ue();else{const le=(he=>{const Ee=he.match(/^([\d.]+)(ms|s)$/);if(!Ee)return 0;const[,ht,Ut]=Ee;return Number(ht)*(Ut==="ms"?1:1e3)})(getComputedStyle(document.body).getPropertyValue("--rt-transition-show-delay"));nr.current=setTimeout(()=>{Cn(!1),Un(null),J==null||J()},le+25)}},[Dt]);const dt=le=>{ui(he=>tp(he,le)?he:le)},Lt=(le=w)=>{Xn(wt),rr?He(!0):wt.current=setTimeout(()=>{He(!0)},le)},zt=(le=T)=>{Xn(fn),fn.current=setTimeout(()=>{$.current||He(!1)},le)},fi=le=>{var he;if(!le)return;const Ee=(he=le.currentTarget)!==null&&he!==void 0?he:le.target;if(!(Ee!=null&&Ee.isConnected))return se(null),void ci({current:null});w?Lt():He(!0),se(Ee),ci({current:Ee}),Xn(fn)},Ur=()=>{j?zt(T||100):T?zt():He(!1),Xn(wt)},yr=({x:le,y:he})=>{var Ee;const ht={getBoundingClientRect:()=>({x:le,y:he,width:0,height:0,top:he,left:le,right:le,bottom:he})};Zb({place:(Ee=Ke==null?void 0:Ke.place)!==null&&Ee!==void 0?Ee:f,offset:h,elementReference:ht,tooltipReference:Ie.current,tooltipArrowReference:Ft.current,strategy:y,middlewares:x,border:R,arrowSize:ce}).then(Ut=>{dt(Ut)})},Bn=le=>{if(!le)return;const he=le,Ee={x:he.clientX,y:he.clientY};yr(Ee),gr.current=Ee},Vi=le=>{var he;if(!Dt)return;const Ee=le.target;Ee.isConnected&&(!((he=Ie.current)===null||he===void 0)&&he.contains(Ee)||[document.querySelector(`[id='${o}']`),...W].some(ht=>ht==null?void 0:ht.contains(Ee))||(He(!1),Xn(wt)))},$i=Wb(fi,50),St=Wb(Ur,50),Kt=le=>{St.cancel(),$i(le)},we=()=>{$i.cancel(),St()},Le=k.useCallback(()=>{var le,he;const Ee=(le=Ke==null?void 0:Ke.position)!==null&&le!==void 0?le:te;Ee?yr(Ee):_?gr.current&&yr(gr.current):I!=null&&I.isConnected&&Zb({place:(he=Ke==null?void 0:Ke.place)!==null&&he!==void 0?he:f,offset:h,elementReference:I,tooltipReference:Ie.current,tooltipArrowReference:Ft.current,strategy:y,middlewares:x,border:R,arrowSize:ce}).then(ht=>{ge.current&&dt(ht)})},[Dt,I,B,ae,f,Ke==null?void 0:Ke.place,h,y,te,Ke==null?void 0:Ke.position,_,ce]);k.useEffect(()=>{var le,he;const Ee=new Set(zr);W.forEach($e=>{oe!=null&&oe($e)||Ee.add({current:$e})});const ht=document.querySelector(`[id='${o}']`);ht&&!(oe!=null&&oe(ht))&&Ee.add({current:ht});const Ut=()=>{He(!1)},qn=t1(I),En=t1(Ie.current);yt.scroll&&(window.addEventListener("scroll",Ut),qn==null||qn.addEventListener("scroll",Ut),En==null||En.addEventListener("scroll",Ut));let Ct=null;yt.resize?window.addEventListener("resize",Ut):I&&Ie.current&&(Ct=wN(I,Ie.current,Le,{ancestorResize:!0,elementResize:!0,layoutShift:!0}));const Xt=$e=>{$e.key==="Escape"&&He(!1)};yt.escape&&window.addEventListener("keydown",Xt),yt.clickOutsideAnchor&&window.addEventListener("click",Vi);const Ve=[],kn=$e=>!!($e!=null&&$e.target&&(I!=null&&I.contains($e.target))),Yi=$e=>{Dt&&kn($e)||fi($e)},di=$e=>{Dt&&kn($e)&&Ur()},Et=["mouseover","mouseout","mouseenter","mouseleave","focus","blur"],Ba=["click","dblclick","mousedown","mouseup"];Object.entries(Yt).forEach(([$e,Hn])=>{Hn&&(Et.includes($e)?Ve.push({event:$e,listener:Kt}):Ba.includes($e)&&Ve.push({event:$e,listener:Yi}))}),Object.entries(gt).forEach(([$e,Hn])=>{Hn&&(Et.includes($e)?Ve.push({event:$e,listener:we}):Ba.includes($e)&&Ve.push({event:$e,listener:di}))}),_&&Ve.push({event:"pointermove",listener:Bn});const qa=()=>{$.current=!0},br=()=>{$.current=!1,Ur()},Br=j&&(gt.mouseout||gt.mouseleave);return Br&&((le=Ie.current)===null||le===void 0||le.addEventListener("mouseover",qa),(he=Ie.current)===null||he===void 0||he.addEventListener("mouseout",br)),Ve.forEach(({event:$e,listener:Hn})=>{Ee.forEach(Tl=>{var Ki;(Ki=Tl.current)===null||Ki===void 0||Ki.addEventListener($e,Hn)})}),()=>{var $e,Hn;yt.scroll&&(window.removeEventListener("scroll",Ut),qn==null||qn.removeEventListener("scroll",Ut),En==null||En.removeEventListener("scroll",Ut)),yt.resize?window.removeEventListener("resize",Ut):Ct==null||Ct(),yt.clickOutsideAnchor&&window.removeEventListener("click",Vi),yt.escape&&window.removeEventListener("keydown",Xt),Br&&(($e=Ie.current)===null||$e===void 0||$e.removeEventListener("mouseover",qa),(Hn=Ie.current)===null||Hn===void 0||Hn.removeEventListener("mouseout",br)),Ve.forEach(({event:Tl,listener:Ki})=>{Ee.forEach(_l=>{var hi;(hi=_l.current)===null||hi===void 0||hi.removeEventListener(Tl,Ki)})})}},[I,Le,rr,zr,W,X,ee,ie,qe,w,T]),k.useEffect(()=>{var le,he;let Ee=(he=(le=Ke==null?void 0:Ke.anchorSelect)!==null&&le!==void 0?le:c)!==null&&he!==void 0?he:"";!Ee&&n&&(Ee=`[data-tooltip-id='${n.replace(/'/g,"\\'")}']`);const ht=new MutationObserver(Ut=>{const qn=[],En=[];Ut.forEach(Ct=>{if(Ct.type==="attributes"&&Ct.attributeName==="data-tooltip-id"&&(Ct.target.getAttribute("data-tooltip-id")===n?qn.push(Ct.target):Ct.oldValue===n&&En.push(Ct.target)),Ct.type==="childList"){if(I){const Xt=[...Ct.removedNodes].filter(Ve=>Ve.nodeType===1);if(Ee)try{En.push(...Xt.filter(Ve=>Ve.matches(Ee))),En.push(...Xt.flatMap(Ve=>[...Ve.querySelectorAll(Ee)]))}catch{}Xt.some(Ve=>{var kn;return!!(!((kn=Ve==null?void 0:Ve.contains)===null||kn===void 0)&&kn.call(Ve,I))&&(Cn(!1),He(!1),se(null),Xn(wt),Xn(fn),!0)})}if(Ee)try{const Xt=[...Ct.addedNodes].filter(Ve=>Ve.nodeType===1);qn.push(...Xt.filter(Ve=>Ve.matches(Ee))),qn.push(...Xt.flatMap(Ve=>[...Ve.querySelectorAll(Ee)]))}catch{}}}),(qn.length||En.length)&&me(Ct=>[...Ct.filter(Xt=>!En.includes(Xt)),...qn])});return ht.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["data-tooltip-id"],attributeOldValue:!0}),()=>{ht.disconnect()}},[n,c,Ke==null?void 0:Ke.anchorSelect,I]),k.useEffect(()=>{Le()},[Le]),k.useEffect(()=>{if(!(G!=null&&G.current))return()=>null;const le=new ResizeObserver(()=>{setTimeout(()=>Le())});return le.observe(G.current),()=>{le.disconnect()}},[B,G==null?void 0:G.current]),k.useEffect(()=>{var le;const he=document.querySelector(`[id='${o}']`),Ee=[...W,he];I&&Ee.includes(I)||se((le=W[0])!==null&&le!==void 0?le:he)},[o,W,I]),k.useEffect(()=>(pe&&He(!0),()=>{Xn(wt),Xn(fn)}),[]),k.useEffect(()=>{var le;let he=(le=Ke==null?void 0:Ke.anchorSelect)!==null&&le!==void 0?le:c;if(!he&&n&&(he=`[data-tooltip-id='${n.replace(/'/g,"\\'")}']`),he)try{const Ee=Array.from(document.querySelectorAll(he));me(Ee)}catch{me([])}},[n,c,Ke==null?void 0:Ke.anchorSelect]),k.useEffect(()=>{wt.current&&(Xn(wt),Lt(w))},[w]);const an=(je=Ke==null?void 0:Ke.content)!==null&&je!==void 0?je:B,Gt=Dt&&Object.keys(dn.tooltipStyles).length>0;return k.useImperativeHandle(e,()=>({open:le=>{if(le!=null&&le.anchorSelect)try{document.querySelector(le.anchorSelect)}catch{return void console.warn(`[react-tooltip] "${le.anchorSelect}" is not a valid CSS selector`)}Un(le??null),le!=null&&le.delay?Lt(le.delay):He(!0)},close:le=>{le!=null&&le.delay?zt(le.delay):He(!1)},activeAnchor:I,place:dn.place,isOpen:!!(rr&&!E&&an&&Gt)})),rr&&!E&&an?nt.createElement(v,{id:n,role:ft,className:ep("react-tooltip",da.tooltip,ph.tooltip,ph[s],i,`react-tooltip__place-${dn.place}`,da[Gt?"show":"closing"],Gt?"react-tooltip__show":"react-tooltip__closing",y==="fixed"&&da.fixed,j&&da.clickable),onTransitionEnd:le=>{Xn(nr),Dt||le.propertyName!=="opacity"||(Cn(!1),Un(null),J==null||J())},style:{...ae,...dn.tooltipStyles,opacity:fe!==void 0&&Gt?fe:void 0},ref:Ie},an,nt.createElement(v,{className:ep("react-tooltip-arrow",da.arrow,ph.arrow,l,N&&da.noArrow),style:{...dn.tooltipArrowStyles,background:Te?`linear-gradient(to right bottom, transparent 50%, ${Te} 50%)`:void 0,"--rt-arrow-size":`${ce}px`},ref:Ft})):null},zN=({content:e})=>nt.createElement("span",{dangerouslySetInnerHTML:{__html:e}}),Kp=nt.forwardRef(({id:e,anchorId:n,anchorSelect:i,content:l,html:s,render:o,className:c,classNameArrow:f,variant:h="dark",place:d="top",offset:m=10,wrapper:y="div",children:x=null,events:v=["hover"],openOnClick:w=!1,positionStrategy:T="absolute",middlewares:_,delayShow:E=0,delayHide:N=0,float:j=!1,hidden:q=!1,noArrow:L=!1,clickable:D=!1,closeOnEsc:X=!1,closeOnScroll:ee=!1,closeOnResize:ie=!1,openEvents:U,closeEvents:ae,globalCloseEvents:te,imperativeModeOnly:ue=!1,style:J,position:oe,isOpen:B,defaultIsOpen:G=!1,disableStyleInjection:ne=!1,border:pe,opacity:C,arrowColor:I,arrowSize:se,setIsOpen:R,afterShow:fe,afterHide:Te,disableTooltip:ce,role:ft="tooltip"},je)=>{const[Ie,Ft]=k.useState(l),[wt,fn]=k.useState(s),[nr,dn]=k.useState(d),[ui,Dt]=k.useState(h),[Mt,rr]=k.useState(m),[Cn,Ke]=k.useState(E),[Un,Lr]=k.useState(N),[gr,zr]=k.useState(j),[ci,$]=k.useState(q),[W,me]=k.useState(y),[ge,qe]=k.useState(v),[Pt,Yt]=k.useState(T),[gt,yt]=k.useState(null),[He,dt]=k.useState(null),Lt=k.useRef(ne),{anchorRefs:zt,activeAnchor:fi}=_x(e),Ur=St=>St==null?void 0:St.getAttributeNames().reduce((Kt,we)=>{var Le;return we.startsWith("data-tooltip-")&&(Kt[we.replace(/^data-tooltip-/,"")]=(Le=St==null?void 0:St.getAttribute(we))!==null&&Le!==void 0?Le:null),Kt},{}),yr=St=>{const Kt={place:we=>{var Le;dn((Le=we)!==null&&Le!==void 0?Le:d)},content:we=>{Ft(we??l)},html:we=>{fn(we??s)},variant:we=>{var Le;Dt((Le=we)!==null&&Le!==void 0?Le:h)},offset:we=>{rr(we===null?m:Number(we))},wrapper:we=>{var Le;me((Le=we)!==null&&Le!==void 0?Le:y)},events:we=>{const Le=we==null?void 0:we.split(" ");qe(Le??v)},"position-strategy":we=>{var Le;Yt((Le=we)!==null&&Le!==void 0?Le:T)},"delay-show":we=>{Ke(we===null?E:Number(we))},"delay-hide":we=>{Lr(we===null?N:Number(we))},float:we=>{zr(we===null?j:we==="true")},hidden:we=>{$(we===null?q:we==="true")},"class-name":we=>{yt(we)}};Object.values(Kt).forEach(we=>we(null)),Object.entries(St).forEach(([we,Le])=>{var an;(an=Kt[we])===null||an===void 0||an.call(Kt,Le)})};k.useEffect(()=>{Ft(l)},[l]),k.useEffect(()=>{fn(s)},[s]),k.useEffect(()=>{dn(d)},[d]),k.useEffect(()=>{Dt(h)},[h]),k.useEffect(()=>{rr(m)},[m]),k.useEffect(()=>{Ke(E)},[E]),k.useEffect(()=>{Lr(N)},[N]),k.useEffect(()=>{zr(j)},[j]),k.useEffect(()=>{$(q)},[q]),k.useEffect(()=>{Yt(T)},[T]),k.useEffect(()=>{Lt.current!==ne&&console.warn("[react-tooltip] Do not change `disableStyleInjection` dynamically.")},[ne]),k.useEffect(()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("react-tooltip-inject-styles",{detail:{disableCore:ne==="core",disableBase:ne}}))},[]),k.useEffect(()=>{var St;const Kt=new Set(zt);let we=i;if(!we&&e&&(we=`[data-tooltip-id='${e.replace(/'/g,"\\'")}']`),we)try{document.querySelectorAll(we).forEach(he=>{Kt.add({current:he})})}catch{console.warn(`[react-tooltip] "${we}" is not a valid CSS selector`)}const Le=document.querySelector(`[id='${n}']`);if(Le&&Kt.add({current:Le}),!Kt.size)return()=>null;const an=(St=He??Le)!==null&&St!==void 0?St:fi.current,Gt=new MutationObserver(he=>{he.forEach(Ee=>{var ht;if(!an||Ee.type!=="attributes"||!(!((ht=Ee.attributeName)===null||ht===void 0)&&ht.startsWith("data-tooltip-")))return;const Ut=Ur(an);yr(Ut)})}),le={attributes:!0,childList:!1,subtree:!1};if(an){const he=Ur(an);yr(he),Gt.observe(an,le)}return()=>{Gt.disconnect()}},[zt,fi,He,n,i]),k.useEffect(()=>{J!=null&&J.border&&console.warn("[react-tooltip] Do not set `style.border`. Use `border` prop instead."),pe&&!Jb("border",`${pe}`)&&console.warn(`[react-tooltip] "${pe}" is not a valid \`border\`.`),J!=null&&J.opacity&&console.warn("[react-tooltip] Do not set `style.opacity`. Use `opacity` prop instead."),C&&!Jb("opacity",`${C}`)&&console.warn(`[react-tooltip] "${C}" is not a valid \`opacity\`.`)},[]);let Bn=x;const Vi=k.useRef(null);if(o){const St=o({content:(He==null?void 0:He.getAttribute("data-tooltip-content"))||Ie||null,activeAnchor:He});Bn=St?nt.createElement("div",{ref:Vi,className:"react-tooltip-content-wrapper"},St):null}else Ie&&(Bn=Ie);wt&&(Bn=nt.createElement(zN,{content:wt}));const $i={forwardRef:je,id:e,anchorId:n,anchorSelect:i,className:ep(c,gt),classNameArrow:f,content:Bn,contentWrapperRef:Vi,place:nr,variant:ui,offset:Mt,wrapper:W,events:ge,openOnClick:w,positionStrategy:Pt,middlewares:_,delayShow:Cn,delayHide:Un,float:gr,hidden:ci,noArrow:L,clickable:D,closeOnEsc:X,closeOnScroll:ee,closeOnResize:ie,openEvents:U,closeEvents:ae,globalCloseEvents:te,imperativeModeOnly:ue,style:J,position:oe,isOpen:B,defaultIsOpen:G,border:pe,opacity:C,arrowColor:I,arrowSize:se,setIsOpen:R,afterShow:fe,afterHide:Te,disableTooltip:ce,activeAnchor:He,setActiveAnchor:St=>dt(St),role:ft};return nt.createElement(LN,{...$i})});typeof window<"u"&&window.addEventListener("react-tooltip-inject-styles",e=>{e.detail.disableCore||Xb({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||Xb({css:`
|
|
237
|
-
.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"})});function UN(){return b.jsxs("div",{className:"flex items-center bg-white border-b border-gray-200 overflow-auto no-scrollbar",children:[b.jsx(BN,{}),b.jsx(qN,{}),b.jsx(HN,{}),b.jsx(FN,{})]})}function BN(){const{state:e}=k.useContext(Rt),{dataSourceId:n,name:i}=k.useContext(Or),{data:l}=_c(n),{data:s}=k.useContext(mr),o=uo(bn.EDITOR),c=F_(),f=()=>{var d,m;(d=s==null?void 0:s.columns)!=null&&d[0].table&&Lp({table:(m=s==null?void 0:s.columns)==null?void 0:m[0].table,dataSourceId:n})},h=async()=>{const d=Q_(e,["size","page"]),m=await kl("Query name",i);m&&c.mutate({name:m,dataSourceId:n,opts:d})};return Jn("s",h,"Save query"),b.jsxs("div",{className:be.tableConfig,children:[b.jsxs("button",{"data-tooltip-id":"default","data-tooltip-content":"Manage filters",onClick:()=>sr("filters"),className:xe(be.tableAction,be.blue),children:[b.jsx("span",{children:"Filter"}),b.jsx("span",{className:"hotkey",children:"F"})]}),b.jsxs("button",{"data-tooltip-id":"default","data-tooltip-content":"Join tables",onClick:()=>sr("joins"),className:xe(be.tableAction,be.blue),children:[b.jsx("span",{children:"Join"}),b.jsx("span",{className:"hotkey",children:"J"})]}),b.jsx(PN,{}),b.jsxs("button",{"data-tooltip-id":"explorer-more-actions",className:xe(be.tableAction,be.blue),children:[b.jsx("span",{children:"More actions"}),b.jsx(Bp,{width:16,height:16,className:"rotate-90"})]}),b.jsxs(Kp,{id:"explorer-more-actions",className:"z-10 shadow-md flex flex-col",clickable:!0,variant:"light",opacity:1,children:[b.jsxs("button",{onClick:()=>sr("columns"),className:xe(be.tableAction,be.modal,be.blue,"justify-between"),children:[b.jsx("span",{children:"Columns"}),b.jsx("span",{className:"hotkey",children:"C"})]}),b.jsxs("button",{onClick:()=>sr("groupBy"),className:xe(be.tableAction,be.modal,be.blue,"justify-between"),children:[b.jsx("span",{children:"Group by"}),b.jsx("span",{className:"hotkey",children:"G"})]}),b.jsxs("button",{onClick:()=>sr("aggregate"),className:xe(be.tableAction,be.modal,be.blue,"justify-between"),children:[b.jsx("span",{children:"Aggregate"}),b.jsx("span",{className:"hotkey",children:"A"})]}),b.jsxs("button",{onClick:qp,className:xe(be.tableAction,be.modal,be.blue,"justify-between"),children:[b.jsx("span",{children:"Query editor"}),b.jsx("span",{className:"hotkey",children:"E"})]}),o&&b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"h-0.5 my-2 bg-gray-100"}),b.jsxs("button",{onClick:h,className:xe(be.tableAction,be.modal,be.blue),children:[b.jsx("span",{children:"Save query"}),b.jsx("span",{className:"hotkey",children:"S"})]}),(l==null?void 0:l.allowInsert)===!0&&b.jsx("button",{onClick:f,className:xe(be.tableAction,be.modal,be.blue),children:"Insert new row"})]})]})]})}function qN(){const{name:e}=k.useContext(Or),{state:n}=k.useContext(Rt),{refetch:i}=k.useContext(mr),l=oo("Workbook"),s=()=>{xl(e,n,!0),Xh()};return Jn("e",qp,"Show editor sidebar"),b.jsxs("div",{className:be.tableConfig,children:[b.jsx("button",{"data-tooltip-id":"default","data-tooltip-content":"Refresh data",onClick:()=>i(),className:xe(be.tableAction,be.blue),children:"Refresh"}),b.jsx("button",{"data-tooltip-id":"default","data-tooltip-content":"Clone in a new tab",onClick:s,className:xe(be.tableAction,be.blue),children:"Clone"}),b.jsxs("button",{"data-tooltip-id":"default","data-tooltip-content":"Start new query tab",onClick:l,className:xe(be.tableAction,be.blue),children:[b.jsx("span",{children:"New query"}),b.jsx("span",{className:"hotkey",children:"N"})]})]})}function HN(){const{page:e,size:n,setPage:i}=mx(),{data:l}=k.useContext(mr),s=(l==null?void 0:l.rows.length)===n;return b.jsxs("div",{className:be.tableConfig,children:[b.jsx("button",{"data-tooltip-content":"Previous page","data-tooltip-id":"default",disabled:e<=0,className:xe(be.tableAction,be.blue),onClick:()=>i(e-1),children:"Prev"}),b.jsx("span",{className:"text-sm bg-gray-50 rounded-md px-2 border border-gray-200",children:e+1}),b.jsx("button",{"data-tooltip-content":"Next page","data-tooltip-id":"default",disabled:!s,className:xe(be.tableAction,be.blue),onClick:()=>i(e+1),children:"Next"})]})}function FN(){const{size:e,setSize:n}=mx();return b.jsx("div",{className:be.tableConfig,children:b.jsx("label",{className:be.tableAction,"data-tooltip-content":"Size","data-tooltip-id":"default",children:b.jsxs("select",{style:{height:"20px"},value:e,onChange:i=>n(parseInt(i.target.value,10)),children:[b.jsx("option",{value:5,children:"5 rows"}),b.jsx("option",{value:10,children:"10 rows"}),b.jsx("option",{value:20,children:"20 rows"}),b.jsx("option",{value:50,children:"50 rows"}),b.jsx("option",{value:100,children:"100 rows"}),b.jsx("option",{value:200,children:"200 rows"})]})})})}function PN(){const{state:e,setState:n}=k.useContext(Rt),i=()=>{n(s=>({...s,searchAll:void 0}))},l=()=>{kl("Search all text values for",e.searchAll||"",{type:"info",message:"This will search all text values using LIKE operator (numbers, dates and other non string values are not searched)."}).then(s=>{s!==void 0&&n(o=>({...o,searchAll:s.length>0?s:void 0}))})};return Jn("k",l,"Search text"),e.searchAll?b.jsx("button",{"data-tooltip-id":"default","data-tooltip-content":"Remove search all filter",onClick:i,className:xe(be.tableAction,be.red),children:b.jsxs("span",{className:"truncate px-1",children:["❌ ",e.searchAll]})}):b.jsxs("button",{"data-tooltip-id":"default","data-tooltip-content":"Search text in all columns",onClick:l,className:xe(be.tableAction,be.blue),children:[b.jsx("span",{children:"Search text"}),b.jsx("span",{className:"hotkey",children:"K"})]})}const QN="_drop-container_u16km_2",IN="_item_u16km_2",n1={dropContainer:QN,item:IN},np=({dataSourceId:e,focusId:n,placeholder:i="Column",onChange:l,value:s,autoFocus:o,allowTables:c})=>{const{data:f}=Da(e),h=k.useRef(null),d=k.useMemo(()=>{if(!f)return[];let E=f;return c&&(E=f.filter(N=>c.includes(N.tableName))),E.flatMap(N=>N.columns.map(j=>({value:N.tableName+"."+j.name,label:j.name,table:N.tableName,searchValue:j.name.toLowerCase()})))},[f,c]),m=k.useMemo(()=>{const E=s.toLowerCase()||"",N=[];for(let j=0;j<d.length&&N.length<10;j++)d[j].searchValue.includes(E)&&N.push(d[j]);return N},[d,s]),[y,x]=k.useState(!1),[v,w]=k.useState(0),T=E=>{var N;if(E.key==="ArrowDown")E.preventDefault(),w(j=>(j+1)%m.length);else if(E.key==="ArrowUp")E.preventDefault(),w(j=>(j-1+m.length)%m.length);else if(E.key==="Enter"&&v>=0&&v<m.length){E.preventDefault();const j=m[v].value;x(!1);const q=d.findIndex(L=>L.value===j)>-1;l(((N=m[v])==null?void 0:N.value)||j,q,!0)}};k.useEffect(()=>{var N;const E=(N=h.current)==null?void 0:N.querySelector('[data-is-active="true"]');E&&E.scrollIntoView({behavior:"smooth",block:"nearest"})},[v]);const _=E=>{const N=E.currentTarget.value,j=d.findIndex(q=>q.value===N)>-1;l(N,j,!1)};return b.jsxs("div",{className:"relative",onFocus:()=>x(!0),onBlur:()=>x(!1),children:[b.jsx("input",{autoFocus:o,onKeyDown:T,value:s,onChange:_,className:"input w-full",placeholder:i,"data-focus":n}),y&&m.length>0&&b.jsx("div",{className:n1.dropContainer,ref:h,tabIndex:-1,children:m.map((E,N)=>b.jsxs("div",{className:n1.item,"data-is-active":v===N,onMouseDownCapture:j=>{j.preventDefault(),x(!1),l(E.value,!0,!0)},children:[b.jsx("span",{className:"text-xs font-semibold truncate",children:E.table}),b.jsx("p",{className:"truncate text-sm",children:E.label})]},N))})]})},VN="_drop-container_19uk9_2",$N="_item_19uk9_2",r1={dropContainer:VN,item:$N};function YN(e){return Xk.includes(e)?Yk:Zk.includes(e)?$k:Jk.includes(e)?Kk:_p}const KN=({value:e,onChange:n,autoFocus:i,focusId:l,colType:s})=>{const o=k.useMemo(()=>{const x=e.toLowerCase()||"";return YN(s||"").filter(v=>v.label.includes(x))},[e,s]),c=k.useRef(null),[f,h]=k.useState(!1),[d,m]=k.useState(0),y=x=>{var v;x.key==="ArrowDown"?(x.preventDefault(),m(w=>(w+1)%o.length)):x.key==="ArrowUp"?(x.preventDefault(),m(w=>(w-1+o.length)%o.length)):x.key==="Enter"&&(d>=0&&d<o.length?(x.preventDefault(),h(!1),n(((v=o[d])==null?void 0:v.label)||"",!0)):n(e,!0))};return k.useEffect(()=>{var v;const x=(v=c.current)==null?void 0:v.querySelector('[data-is-active="true"]');x&&x.scrollIntoView({behavior:"smooth",block:"nearest"})},[d]),b.jsxs("div",{className:"relative",children:[b.jsx("input",{onKeyDown:y,value:e,onChange:x=>n(x.target.value,!1),className:"input w-full",placeholder:"Operator",autoFocus:i,onFocus:()=>h(!0),onBlur:()=>h(!1),"data-focus":l}),f&&o.length>0&&b.jsx("ul",{className:r1.dropContainer,ref:c,tabIndex:-1,children:o.map((x,v)=>b.jsx("li",{className:r1.item,"data-is-active":d===v,onMouseDownCapture:w=>{w.preventDefault(),h(!1),n(x.label,!0)},children:x.label},v))})]})},GN="_actions_jpxzd_2",XN="_filter-actions_jpxzd_2",Nx={actions:GN,filterActions:XN},ZN=["=","<",">",">=","<>","!=","<="];function JN(e){for(let n=0;n<e.length;n++){const i=e[n];if(!i.operator.length&&!i.value.length&&!i.column.length)continue;if(!i.column.includes("."))return tn.error(`Filter #${n+1} has invalid column value`),!1;const l=Rp[i.operator];if(!l)return tn.error(`Filter #${n+1} has invalid operator`),!1;if(i.isColumnRef&&!ZN.includes(l))return tn.error(`Filter #${n+1} cannot reference another column because it uses '${i.operator}' operator`),!1}return!0}function WN(e){const n=[];return e.forEach(i=>{if(!i.operator.length||!i.value.length||!i.column.length)return;const l=Rp[i.operator];n.push({id:i.id,value:i.isColumnRef?[{value:i.value,isColumn:!0}]:Gk(l,i.value),operator:l,column:i.column,isEnabled:!0,connector:"AND"})}),n}function eR(e){let n="";if(e.value)for(let i=0;i<e.value.length;i++)n+=e.value[i].value,i<e.value.length-1&&(n+=", ");return n}const tR=({filter:e,dataSourceId:n,allowedTables:i,inspections:l,autoFocus:s,onChangeColumn:o,onChangeOperator:c,onChangeValue:f,onRemoveFilter:h,onIsColumnChange:d})=>{const m=k.useMemo(()=>{if(!l)return"";let y=null;for(const x of l)for(const v of x.columns)x.tableName+"."+v.name===e.column&&(y=v);return y!=null&&y.type?y.type:""},[e.column,l]);return b.jsxs("div",{className:"flex gap-2 items-center",children:[b.jsx("label",{className:"w-full",children:b.jsx(np,{dataSourceId:n,onChange:y=>o(e.id,y),value:e.column,allowTables:i,focusId:"column",autoFocus:s})}),b.jsx("label",{children:b.jsx(KN,{onChange:y=>c(e.id,y),focusId:"operator",colType:m,value:e.operator})}),lx(Rp[e.operator])&&b.jsx("label",{className:"w-full",children:e.isColumnRef?b.jsx(np,{dataSourceId:n,onChange:y=>f(e.id,y),value:e.value,allowTables:i,focusId:"value",placeholder:"Search column"}):b.jsx("input",{className:"input w-full",placeholder:"Filter value",value:e.value,onChange:y=>f(e.id,y.currentTarget.value),"data-focus":"value"})}),b.jsxs("div",{className:Nx.filterActions,children:[b.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"If enabled, the value will reference another column instead of being raw string",className:xe("p-0.5 cursor-pointer rounded-lg border",e.isColumnRef?"bg-blue-50 border-blue-200":"bg-white border-white"),onClick:()=>d(e.id,!e.isColumnRef),children:"🏷️"}),b.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove aggregation",className:"p-0.5 text-sm cursor-pointer",onClick:()=>h(e.id),children:b.jsx(pr,{width:20,height:20,className:"text-red-600"})})]})]})},nR=()=>{const{state:e}=k.useContext(Rt),{setFilters:n}=hx(),i=Dc(T=>T.filters),{data:l}=Da(e.dataSourceId),s=k.useMemo(()=>[e.table,...e.joins.map(T=>T.table)],[e.table,e.joins]),[o,c]=k.useState([]),f=(T,_)=>{c(E=>[...E.map(N=>N.id===T?{...N,column:_}:N)])},h=(T,_)=>{c(E=>[...E.map(N=>N.id===T?{...N,operator:_}:N)])},d=(T,_)=>{c(E=>[...E.map(N=>N.id===T?{...N,value:_}:N)])},m=()=>{c(T=>[...T,{id:ai(),value:"",column:"",operator:"",isColumnRef:!1}])},y=(T,_)=>{c(E=>[...E.map(N=>N.id===T?{...N,isColumnRef:_}:N)])},x=T=>{c(_=>_.filter(E=>E.id!==T))},v=()=>Mc("filters"),w=()=>{JN(o)&&(n(WN(o)),v())};return k.useEffect(()=>{i&&c(()=>{const T=e.filters.map(_=>{var E,N;return{id:_.id,value:eR(_),column:_.column,operator:Np[_.operator],isColumnRef:!!((N=(E=_.value)==null?void 0:E[0])!=null&&N.isColumn)}});return T.push({id:ai(),value:"",column:"",operator:"",isColumnRef:!1}),T})},[i]),Jn("f",()=>{oc("filters")},"Add new filter"),b.jsxs(rn,{isVisible:i,onClose:v,portal:!0,children:[b.jsx(tr,{onClick:v}),b.jsx("h2",{className:"text-lg font-semibold",children:"Filters"}),b.jsxs("div",{className:"flex gap-4 flex-col w-full lg:w-lg my-4",children:[o.length<1&&b.jsx("p",{className:"p-1 text-center rounded-lg bg-gray-50 border border-gray-200",children:"No filters"}),o.map((T,_)=>b.jsx(tR,{filter:T,dataSourceId:e.dataSourceId,allowedTables:s,inspections:l||[],onChangeColumn:f,onChangeOperator:h,onChangeValue:d,onRemoveFilter:x,onIsColumnChange:y,autoFocus:_===o.length-1},T.id))]}),b.jsxs("div",{className:Nx.actions,children:[b.jsx("button",{className:"button tertiary",onClick:m,children:"Add filter"}),b.jsx("button",{className:"button primary",onClick:w,children:"Apply filters"})]})]})},rR="_card_zpu14_2",iR="_cards-list_zpu14_2",lR="_join-modal_zpu14_2",aR="_close-button_zpu14_2",Ou={card:rR,cardsList:iR,joinModal:lR,closeButton:aR},sR=()=>{const{isFetching:e}=k.useContext(mr),n=Dc(d=>d.joins),{toggle:i,joins:l}=px(),{availableJoins:s}=k.useContext(Or),[o,c]=k.useState(""),f=k.useMemo(()=>{const d=o.toLowerCase();return s.filter(m=>m.on.toTable.toLowerCase().includes(d))},[s,o]),h=()=>Mc("joins");return Jn("j",()=>{s.length>0?sr("joins"):tn.error("No available tables to join")},"Add new join"),b.jsxs(rn,{isVisible:n,onClose:h,portal:!0,children:[b.jsx(tr,{onClick:h}),b.jsxs("div",{className:Ou.joinModal,children:[b.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Join table"}),l.length>0&&b.jsx("div",{className:Ou.cardsList,children:l.map((d,m)=>b.jsxs("div",{className:Ou.card,children:[b.jsxs("p",{className:"text-sm truncate",children:[d.table," on ",d.on]}),m===l.length-1&&b.jsx("button",{className:Ou.closeButton,onClick:()=>i(d),disabled:e,children:b.jsx(pr,{width:20,height:20})})]},d.table+d.on))}),f.length>0?b.jsx("input",{className:"input w-full",placeholder:"Filter",autoFocus:!0,onChange:d=>c(d.target.value),value:o,disabled:e}):b.jsx(cn,{variant:"warning",children:b.jsx("p",{className:"text-sm truncate",children:"No more tables to join"})}),b.jsx("div",{className:`flex flex-col mt-2 overflow-y-auto ${e?"opacity-40":""}`,children:f.map(d=>b.jsx(dx,{hook:d,onClick:()=>{e||(i({table:d.on.toTable,type:"LEFT",on:d.where}),c(""))}},d.where))})]})]})};function oR(e){return e.reduce((n,i)=>(n[i]=!0,n),{})}function uR(e){return e.reduce((n,i)=>(n[i]=!0,n),{})}const cR="_container_126ac_2",fR="_column-label_126ac_2",dR="_not-active_126ac_2",Gu={container:cR,columnLabel:fR,notActive:dR};function hR(e){if(!e)return[];const n={};return e.forEach(i=>{n[i.table]?n[i.table].push({value:i.full,ogColumn:i.column,label:qi(i.column),type:i.type}):n[i.table]=[{value:i.full,ogColumn:i.column,label:qi(i.column),type:i.type}],Wk[i.type]&&["YEAR","MONTH","DAY"].forEach(l=>{n[i.table].push({value:l+" "+i.full,ogColumn:i.column,label:l+" "+qi(i.column),type:"number",nested:!0})})}),Object.entries(n).reduce((i,[l,s])=>(i.push({name:qi(l),columns:s}),i),[])}function pR(e,n){const i=n.toLowerCase();return e.map(l=>{const s=l.columns.filter(o=>o.label.toLowerCase().includes(i)||o.ogColumn.toLowerCase().includes(i));return{...l,columns:s}}).filter(l=>l.columns.length>0)}const mR=({column:e,selected:n,onCheck:i})=>b.jsxs("label",{className:xe(Gu.columnLabel,n?Gu.active:Gu.notActive,e.nested&&"pl-5!"),children:[b.jsx("input",{type:"checkbox",checked:n[e.value],name:e.value,onChange:i}),b.jsxs("p",{className:"flex justify-between w-full",children:[b.jsx("span",{"data-tooltip-content":e.value,"data-tooltip-id":"default",children:e.label}),b.jsx("span",{className:"text-blue-600",children:e.type})]})]},e.value),gR={columns:"c",groupBy:"g"},i1=({mode:e})=>{const n=Dc(E=>E[e]),{allColumns:i}=k.useContext(Or),{state:l,setState:s}=k.useContext(Rt),[o,c]=k.useState(()=>oR(l[e].map(E=>E.fn?E.fn+" "+E.value:E.value))),[f,h]=k.useState(""),d=k.useMemo(()=>hR(i),[i]),m=l.aggregations.length>0||l.groupBy.length>0,y=k.useMemo(()=>f?pR(d,f):d,[f,d]),x=E=>{c(N=>({...N,[E.target.name]:E.target.checked}))},v=E=>{const N=E.target.checked;c(j=>{for(const q of i)j[q.full]=N;return{...j}})},w=()=>{Mc(e)},T=()=>{const E=[];for(const[N,j]of Object.entries(o))if(j){const[q,L]=N.split(" ");E.push({value:L||q,fn:L?q:void 0})}s(N=>({...N,[e]:E})),w()},_=k.useMemo(()=>{for(const E of i)if(!o[E.full])return!1;return!0},[o,i]);return Jn(gR[e],()=>{e==="columns"?m?tn.error("Columns are ignored when there is at least one aggregation or group by"):oc("columns"):oc("groupBy")},"Manage "+e),b.jsxs(rn,{isVisible:n,onClose:w,portal:!0,children:[b.jsx(tr,{onClick:w}),b.jsxs("div",{className:Gu.container,children:[b.jsx("h2",{className:"text-lg font-semibold",children:e==="groupBy"?"Group by":"Show columns"}),b.jsx("input",{autoFocus:!0,className:"input my-2",placeholder:"Filter",value:f,onChange:E=>h(E.target.value)}),b.jsx("div",{className:"overflow-y-auto",children:y.map(E=>b.jsxs("div",{className:"my-2",children:[b.jsxs("p",{className:"font-semibold sticky top-0 bg-white p-1 z-1",children:["📄 ",E.name]}),E.columns.map(N=>b.jsx(mR,{column:N,selected:o,onCheck:x},N.value))]},E.name))}),b.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[b.jsxs("label",{className:"button tertiary flex gap-2 items-center",children:[b.jsx("input",{type:"checkbox",checked:_,onChange:v}),b.jsx("span",{children:"Select all"})]}),b.jsx("span",{className:"flex-1"}),b.jsx("button",{className:"button tertiary",onClick:w,children:"Cancel"}),b.jsx("button",{className:"button primary",onClick:T,children:"Apply"})]})]})]})},yR="_options-container_1fpdf_2",bR={optionsContainer:yR},mh="COUNT all",vR=e=>e.distinct?[e.fn,"DISTINCT",e.value].join(" "):[e.fn,e.value].join(" "),xR=()=>{const e=Dc(w=>w.aggregate),{dataSourceId:n}=k.useContext(Or),{setState:i,state:l}=k.useContext(Rt),{data:s}=k.useContext(mr),[o,c]=k.useState({fn:"",col:""}),f=w=>c({...o,fn:w.currentTarget.value}),h=w=>c({...o,col:w}),d=()=>Mc("aggregate"),m=()=>{const w=o.fn===mh?{value:"*",fn:"COUNT"}:{fn:o.fn,value:o.col,distinct:o.fn==="COUNT"};i(T=>({...T,aggregations:[...T.aggregations,w]}))},y=o.fn===mh,x=y?!1:!o.col||!o.fn,v=w=>{const T=ri(w);i(_=>({..._,aggregations:_.aggregations.filter(E=>E.fn!==w.fn||E.value!==w.value),orderBy:_.orderBy.filter(E=>E.column!==T)}))};return Jn("a",()=>{oc("aggregate")},"Aggregate data"),b.jsxs(rn,{isVisible:e,onClose:d,backdropClose:!0,portal:!0,children:[b.jsx(tr,{onClick:d}),b.jsxs("div",{children:[b.jsx("h2",{className:"text-lg font-semibold",children:"Aggregate"}),Fi(l.aggregations.length,0)&&b.jsx("div",{className:"flex flex-col gap-1 mt-4",children:l.aggregations.map((w,T)=>b.jsxs("p",{className:"p-2 rounded-md bg-gray-50 flex items-center justify-between",children:[b.jsx("span",{children:vR(w)}),b.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove aggregation",className:"p-0.5 text-sm cursor-pointer",onClick:()=>v(w),children:b.jsx(pr,{width:20,height:20,className:"text-red-600"})})]},T))}),b.jsxs("div",{className:bR.optionsContainer,children:[b.jsxs("label",{className:xe(y&&"col-span-2"),children:[b.jsx("p",{className:"font-semibold text-xs",children:"Function"}),b.jsxs("select",{className:"input w-full",value:o.fn,onChange:f,autoFocus:!0,children:[b.jsx("option",{value:"",disabled:!0,children:"Select function"}),b.jsx("option",{value:mh,children:"Count all rows"}),b.jsx("option",{value:"COUNT",children:"Count"}),b.jsx("option",{value:"SUM",children:"Sum"}),b.jsx("option",{value:"MAX",children:"Max"}),b.jsx("option",{value:"MIN",children:"Min"}),b.jsx("option",{value:"AVG",children:"Avg"})]})]}),!y&&b.jsxs("label",{children:[b.jsx("p",{className:"font-semibold text-xs",children:"Column"}),b.jsx(np,{dataSourceId:n,allowTables:(s==null?void 0:s.tables)||[],onChange:h,value:o.col})]}),b.jsx("button",{className:"button primary",disabled:x,onClick:m,children:"Add"})]})]})]})};function wR(e,n,i){const l=[];return n.length>0||i.length>0?l.push(...n,...i):e.length>0&&l.push(...e),l}const Rx=({options:e,updater:n,name:i,tabId:l})=>{const s=nA(e,n),{state:o}=s,c=$A({datasourceId:e.dataSourceId,table:e.table,filters:o.filters,joins:o.joins,page:o.page,size:o.size,orderBy:o.orderBy,columns:wR(o.columns,o.groupBy,o.aggregations),groupBy:o.groupBy,searchAll:o.searchAll}),f=tA(c.data,e.dataSourceId,i,l);return b.jsx(Or,{value:f,children:b.jsx(Rt,{value:s,children:b.jsxs(mr,{value:c,children:[b.jsx(UN,{}),b.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[b.jsxs("div",{className:"m-1 flex-1 overflow-auto pb-12 no-scrollbar",children:[b.jsx("div",{className:"pb-0.5 sticky bottom-0"}),b.jsx(o_,{})]}),b.jsx(nR,{}),b.jsx(sR,{}),b.jsx(i1,{mode:"columns"}),b.jsx(i1,{mode:"groupBy"}),b.jsx(xR,{}),b.jsx(q_,{})]})]})})})},SR=e=>{if(!e)return;const n=mt.getQueryData([vl]);if(!n)return;const i=mt.getQueryData([si,n.teamId]);return i==null?void 0:i.find(l=>l.id===e)},CR=({content:e,activeAnchor:n})=>{if(!n)return null;const i=n.getAttribute("data-tab-id"),l=jc.get().find(c=>c.id===i),s=SR(l==null?void 0:l.options.dataSourceId);if(!l)return e;const o=()=>{kl("New tab name",l.label).then(c=>{c&&Dp(l.id,c)})};return b.jsxs("div",{children:[b.jsxs("button",{className:Ar.tooltipLabel,onClick:o,children:[b.jsxs("div",{className:"overflow-hidden",children:[b.jsx("p",{className:"text-xs",children:"label"}),b.jsx("p",{className:"truncate font-semibold",children:l.label})]}),b.jsx("span",{children:"✏️"})]}),b.jsxs("div",{className:Ar.tooltipInfoEntry,children:[b.jsx("p",{className:"text-sm",children:"table"}),b.jsx("p",{className:"truncate font-semibold",children:l.options.table})]}),s&&b.jsxs("div",{className:Ar.tooltipInfoEntry,children:[b.jsxs("p",{className:"text-sm",children:["data source [",s.dbType,"]"]}),b.jsx("p",{className:"truncate font-semibold",children:s.name})]}),l.options.joins.length>0&&b.jsxs("div",{className:Ar.tooltipInfoEntry,children:[b.jsx("p",{className:"text-sm",children:"joins"}),b.jsx("p",{className:"truncate font-semibold",children:l.options.joins.map(c=>c.table).join(", ")})]}),l.options.filters.length>0&&b.jsxs("div",{className:Ar.tooltipInfoEntry,children:[b.jsx("p",{className:"text-sm",children:"filters"}),l.options.filters.map(c=>b.jsx("p",{className:"truncate font-semibold",children:HA(c)}))]})]})},ER=()=>{const e=iA(),n=Nc(),i=Hp(Oc.laptop),l=k.useMemo(()=>{if(!n)return;const h=n.find(d=>d.id===e);return h||n[0]},[e,n]),s=h=>{h.stopPropagation(),h.preventDefault();const d=h.currentTarget.getAttribute("data-tab-id");d&&jb(d)},o=h=>{h.button===1&&jb(h.currentTarget.dataset.tabId)},c=h=>{const d=n.find(m=>m.id===h);kl("New tab name",d==null?void 0:d.label).then(m=>{m&&Dp(h,m)})},f=k.useCallback(h=>{Rc(d=>d.map(m=>m.id!==l.id?m:{...m,options:h(m.options)}))},[l]);return n.length<1?b.jsx(VC,{to:"/"}):b.jsxs("div",{className:"h-screen max-h-screen bg-(--bg) flex flex-col",children:[i&&b.jsx(Kp,{id:"tab",render:CR,className:"z-10 shadow-md p-0!",offset:-1,noArrow:!0,opacity:1,variant:"light",clickable:!0,delayShow:500}),l&&b.jsx(Rx,{updater:f,options:l.options,name:l.label,tabId:l.id}),b.jsx("div",{className:xe(Ar.tabs,"no-scrollbar",!i&&Ar.mobile),children:n==null?void 0:n.map(h=>b.jsxs("div",{onClick:()=>Op(h.id),className:xe(Ar.tab,h.id===(l==null?void 0:l.id)&&Ar.active),"data-tab-id":h.id,"data-tooltip-id":"tab","data-tooltip-content":h.label,onAuxClick:o,onContextMenu:d=>{d.preventDefault(),c(h.id)},children:[b.jsxs("span",{className:"truncate w-full",children:["📄 ",h.label]}),b.jsx("button",{"data-tab-id":h.id,className:Ar.closeButton,onClick:s,children:b.jsx(pr,{width:20,height:20})})]},h.id))})]})},kR=()=>{const e=I_(),n=k.useCallback(i=>{gx(l=>l?{...l,options:i(l.options)}:(tn.error("Something went wrong."),l))},[]);return e?b.jsxs(rn,{isVisible:!0,onClose:Xh,children:[b.jsx(tr,{onClick:Xh}),b.jsx("div",{className:"border border-gray-200 bg-(--bg) flex flex-col",children:b.jsx(Rx,{name:e.label,options:e.options,updater:n})})]}):null},AR="_root_1uact_2",TR="_down_1uact_2",_R="_chevron_1uact_2",NR="_table-name-container_1uact_2",RR="_link_1uact_2",jR="_table-name_1uact_2",OR="_ul_1uact_2",DR="_column-type_1uact_2",ti={root:AR,down:TR,chevron:_R,tableNameContainer:NR,link:RR,tableName:jR,ul:OR,columnType:DR},[T9,MR]=wn(!1),jx=()=>MR(!1),LR=new Intl.DateTimeFormat("en",{dateStyle:"full",timeStyle:"long"});function zR(e,n){if(n&&e.toLowerCase().includes(n))return"bg-yellow-200"}const UR=({insp:e,filter:n,expanded:i})=>{const l=k.useMemo(()=>i?e.columns:n.length<1?[]:e.columns.filter(s=>s.name.toLowerCase().includes(n)),[e,n,i]);return b.jsx("ul",{className:ti.ul,children:l.map(s=>b.jsx(b.Fragment,{children:b.jsxs("li",{children:[s.isPrimary?"🔐":"🏷️"," ",b.jsx("span",{className:zR(s.name,n),children:s.name})," ",b.jsxs("span",{className:ti.columnType,children:["[",s.type,"]"]}),s.ref&&b.jsxs("span",{children:[" ➡️ ",b.jsx("span",{className:ti.columnType,children:s.ref.table}),".",s.ref.field]})]},s.name+s.type)}))},e.id)};function BR({id:e}){const{data:n}=_c(e),{data:i}=Da(e),l=Wn(),{pathname:s}=nn(),o=Mk(),c=nx(),f=Lk(),h=k.useMemo(()=>n!=null&&n.lastInspected?LR.format(new Date(n.lastInspected)):"--",[n]),[d,m]=k.useState({}),[y,x]=k.useState(""),[v,w]=k.useState("table"),T=uo(bn.EDITOR),_=y.toLowerCase(),E=k.useMemo(()=>{if(!_||!i)return i||[];const ee=[];for(const ie of i){if(ie.tableName.toLowerCase().includes(_)){ee.push(ie);continue}v!=="table"&&ie.columns.findIndex(U=>U.name.toLowerCase().includes(_))>=0&&ee.push(ie)}return ee},[_,i,v]),N=ee=>{m(ie=>({...ie,[ee]:!ie[ee]}))},j=ee=>{xl(ee,{table:ee,dataSourceId:e},!0),xa(void 0),jx(),s!==rt.workbench.path&&l(rt.workbench.path)},q=()=>{c.mutate(e)},L=async()=>{const ee=await kl("Enter name",n==null?void 0:n.name);ee&&o.mutate({id:e,dataSource:{name:ee}})},D=async()=>{await ox("Are you sure you want to delete this data source?")&&(f.mutate(e),xa(void 0))},X=v==="column";return b.jsxs("div",{className:ti.root,children:[b.jsxs("h3",{className:"page-head flex gap-2",children:[n&&b.jsx(Mp,{size:32,type:n.dbType}),b.jsx("span",{className:"truncate",children:n==null?void 0:n.name})]}),b.jsx("p",{className:"mt-1 text-sm font-semibold",children:h}),T&&b.jsxs("div",{className:"mt-2 flex gap-2",children:[b.jsx("button",{disabled:c.isLoading,onClick:q,className:"button tertiary flex items-center gap-1",children:"Refresh schema"}),b.jsx("button",{disabled:c.isLoading,onClick:L,className:"button tertiary",children:"Rename"}),b.jsx("button",{disabled:c.isLoading,onClick:D,className:"button tertiary",children:"Delete"})]}),b.jsxs("div",{className:"flex gap-1 items-center mb-2 mt-4",children:[b.jsx("input",{className:"input flex-1 bg-gray-50",placeholder:X?"Search column":"Search table",value:y,onChange:ee=>x(ee.target.value),autoFocus:!0}),b.jsx("button",{className:"button primary w-20",onClick:()=>w(X?"table":"column"),children:X?"Column":"Table"})]}),b.jsx("div",{className:"overflow-y-auto",children:E==null?void 0:E.map(ee=>b.jsxs("div",{children:[b.jsxs("div",{className:ti.tableNameContainer,children:[b.jsx("button",{className:xe(ti.chevron,d[ee.id]&&ti.down),onClick:()=>N(ee.id),children:b.jsx(Bp,{width:16,height:16})}),b.jsx("button",{className:xe(ti.tableName,"flex-1"),onClick:()=>N(ee.id),children:ee.tableName}),b.jsx("button",{className:ti.link,onClick:()=>j(ee.tableName),children:"↗️"})]}),(d[ee.id]||y.length>0)&&b.jsx(UR,{insp:ee,filter:X?_:"",expanded:d[ee.id]})]},ee.id))})]})}const qR=()=>{const e=jA(),[n,i]=k.useState(void 0);k.useEffect(()=>{e&&i(e)},[e]);const l=()=>xa(void 0);return b.jsxs(rn,{isVisible:e!=null,onClose:l,onClosed:()=>i(void 0),backdropClose:!0,children:[b.jsx(tr,{onClick:l}),n&&b.jsx(BR,{id:n})]})};function HR(e,n=500){const[i,l]=k.useState(e);return k.useEffect(()=>{const s=setTimeout(()=>l(e),n);return()=>clearTimeout(s)},[e,n]),i}const FR="_search_d7ba7_2",PR="_entry_d7ba7_2",QR="_ds_d7ba7_2",IR="_ds-entry_d7ba7_2",Du={search:FR,entry:PR,ds:QR,dsEntry:IR},[VR,$R]=jp({initialData:[],localStorageKey:"selected-data-sources-v1"}),YR=e=>$R(n=>{const i=n.indexOf(e);return i>-1?(n.splice(i,1),[...n]):[...n,e]}),KR={table:"📄",query:"📖"},GR=({onTable:e,onQuery:n,autoFocus:i})=>{const[l,s]=k.useState(""),[o,c]=k.useState(-1),f=HR(l,200),h=VR(),{data:d}=jr(),{data:m}=Tp({teamId:d==null?void 0:d.teamId}),{data:y}=Nk(f,{teamId:d==null?void 0:d.teamId,selectedDataSources:h}),x=_=>{_.type==="table"?e(_.name,_.dataSourceId):_.type==="query"&&n(_.id,_.dataSourceId)},v=_=>{var E;y&&(_.key==="ArrowDown"?(_.preventDefault(),c(N=>(N+1)%y.length)):_.key==="ArrowUp"?(_.preventDefault(),c(N=>(N-1+y.length)%y.length)):_.key==="Enter"&&o>=0&&(E=y[o])!=null&&E.name&&(_.preventDefault(),x(y[o])))},w=_=>{const E=_.currentTarget.dataset.tableId,N=y==null?void 0:y.find(j=>j.id===E);N&&x(N)},T=k.useMemo(()=>uR(h),[h]);return b.jsxs("div",{className:"overflow-hidden flex flex-col w-full lg:w-lg",children:[Fi(m==null?void 0:m.length,0)&&b.jsx("div",{className:"flex overflow-x-auto mb-2 gap-2 no-scrollbar",children:m.map(_=>b.jsxs("label",{className:Du.dsEntry,children:[b.jsx("input",{type:"checkbox",checked:T[_.id]===!0,onChange:()=>YR(_.id)}),b.jsx("span",{children:_.name})]},_.id))}),b.jsx("input",{className:Du.search,placeholder:"Search table or saved query to start from",value:l,onChange:_=>s(_.target.value),onKeyDown:v,autoFocus:i}),Fi(y==null?void 0:y.length,0)&&b.jsx("div",{className:"overflow-y-auto max-h-full mt-2",children:y.map((_,E)=>b.jsxs("button",{className:Du.entry,"data-is-active":o===E,"data-table-id":_.id,onClick:w,children:[b.jsxs("p",{className:"font-semibold",children:[KR[_.type]," ",_.name]}),b.jsxs("p",{className:Du.ds,children:["📦 ",_.dataSourceName]})]},_.id))})]})},XR=()=>{const e=uA(),n=(s,o)=>{e==null||e.onConfirm("table",s,o)},i=(s,o)=>{e==null||e.onConfirm("query",s,o)},l=()=>{e==null||e.onCancel()};return b.jsxs(rn,{isVisible:!!e,onClose:l,children:[b.jsx(tr,{onClick:l}),b.jsx(GR,{autoFocus:!0,onTable:n,onQuery:i})]})},ZR=()=>{const e=nn();k.useEffect(()=>{},[e.pathname])},l1={active:!1,version:""};async function JR(){try{const{data:e}=await Tc.get("/status",{timeout:500,validateStatus:()=>!0});return(e==null?void 0:e.data)||l1}catch{return l1}}function WR(){const e=mt.getQueryState([vl]);(e==null?void 0:e.status)==="error"&&mt.invalidateQueries({queryKey:[vl]})}function ej(){const e=mt.getQueryState([vl]);(e==null?void 0:e.status)==="success"&&mt.resetQueries({queryKey:[vl]})}const tj=()=>zn({queryKey:["server-status"],queryFn:JR,onSuccess:({active:e})=>{e?WR():ej()},refetchOnWindowFocus:!0,refetchInterval:(e,n)=>{var i,l;return(l=(i=n==null?void 0:n.state)==null?void 0:i.data)!=null&&l.active?2e4:4e3},retry:!1}),a1=e=>{const[n]=e.split("-");return n.split(".").map(Number)},nj=(e,n)=>{const i=a1(e),l=a1(n);for(let s=0;s<3;s++){const o=i[s]||0,c=l[s]||0;if(o>c)return 1;if(o<c)return-1}return 0};function s1(e,n){const i=String(e);if(typeof n!="string")throw new TypeError("Expected character");let l=0,s=i.indexOf(n);for(;s!==-1;)l++,s=i.indexOf(n,s+n.length);return l}const un=Ii(/[A-Za-z]/),en=Ii(/[\dA-Za-z]/),rj=Ii(/[#-'*+\--9=?A-Z^-~]/);function dc(e){return e!==null&&(e<32||e===127)}const rp=Ii(/\d/),ij=Ii(/[\dA-Fa-f]/),lj=Ii(/[!-/:-@[-`{-~]/);function Se(e){return e!==null&&e<-2}function it(e){return e!==null&&(e<0||e===32)}function Be(e){return e===-2||e===-1||e===32}const Bc=Ii(new RegExp("\\p{P}|\\p{S}","u")),Cl=Ii(/\s/);function Ii(e){return n;function n(i){return i!==null&&i>-1&&e.test(String.fromCharCode(i))}}function aj(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const qc=function(e){if(e==null)return cj;if(typeof e=="function")return Hc(e);if(typeof e=="object")return Array.isArray(e)?sj(e):oj(e);if(typeof e=="string")return uj(e);throw new Error("Expected function, string, or object as test")};function sj(e){const n=[];let i=-1;for(;++i<e.length;)n[i]=qc(e[i]);return Hc(l);function l(...s){let o=-1;for(;++o<n.length;)if(n[o].apply(this,s))return!0;return!1}}function oj(e){const n=e;return Hc(i);function i(l){const s=l;let o;for(o in e)if(s[o]!==n[o])return!1;return!0}}function uj(e){return Hc(n);function n(i){return i&&i.type===e}}function Hc(e){return n;function n(i,l,s){return!!(fj(i)&&e.call(this,i,typeof l=="number"?l:void 0,s||void 0))}}function cj(){return!0}function fj(e){return e!==null&&typeof e=="object"&&"type"in e}const Ox=[],dj=!0,ip=!1,hj="skip";function Dx(e,n,i,l){let s;typeof n=="function"&&typeof i!="function"?(l=i,i=n):s=n;const o=qc(s),c=l?-1:1;f(e,void 0,[])();function f(h,d,m){const y=h&&typeof h=="object"?h:{};if(typeof y.type=="string"){const v=typeof y.tagName=="string"?y.tagName:typeof y.name=="string"?y.name:void 0;Object.defineProperty(x,"name",{value:"node ("+(h.type+(v?"<"+v+">":""))+")"})}return x;function x(){let v=Ox,w,T,_;if((!n||o(h,d,m[m.length-1]||void 0))&&(v=pj(i(h,m)),v[0]===ip))return v;if("children"in h&&h.children){const E=h;if(E.children&&v[0]!==hj)for(T=(l?E.children.length:-1)+c,_=m.concat(E);T>-1&&T<E.children.length;){const N=E.children[T];if(w=f(N,T,_)(),w[0]===ip)return w;T=typeof w[1]=="number"?w[1]:T+c}}return v}}}function pj(e){return Array.isArray(e)?e:typeof e=="number"?[dj,e]:e==null?Ox:[e]}function mj(e,n,i){const s=qc((i||{}).ignore||[]),o=gj(n);let c=-1;for(;++c<o.length;)Dx(e,"text",f);function f(d,m){let y=-1,x;for(;++y<m.length;){const v=m[y],w=x?x.children:void 0;if(s(v,w?w.indexOf(v):void 0,x))return;x=v}if(x)return h(d,m)}function h(d,m){const y=m[m.length-1],x=o[c][0],v=o[c][1];let w=0;const _=y.children.indexOf(d);let E=!1,N=[];x.lastIndex=0;let j=x.exec(d.value);for(;j;){const q=j.index,L={index:j.index,input:j.input,stack:[...m,d]};let D=v(...j,L);if(typeof D=="string"&&(D=D.length>0?{type:"text",value:D}:void 0),D===!1?x.lastIndex=q+1:(w!==q&&N.push({type:"text",value:d.value.slice(w,q)}),Array.isArray(D)?N.push(...D):D&&N.push(D),w=q+j[0].length,E=!0),!x.global)break;j=x.exec(d.value)}return E?(w<d.value.length&&N.push({type:"text",value:d.value.slice(w)}),y.children.splice(_,1,...N)):N=[d],_+N.length}}function gj(e){const n=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const i=!e[0]||Array.isArray(e[0])?e:[e];let l=-1;for(;++l<i.length;){const s=i[l];n.push([yj(s[0]),bj(s[1])])}return n}function yj(e){return typeof e=="string"?new RegExp(aj(e),"g"):e}function bj(e){return typeof e=="function"?e:function(){return e}}const gh="phrasing",yh=["autolink","link","image","label"];function vj(){return{transforms:[Aj],enter:{literalAutolink:wj,literalAutolinkEmail:bh,literalAutolinkHttp:bh,literalAutolinkWww:bh},exit:{literalAutolink:kj,literalAutolinkEmail:Ej,literalAutolinkHttp:Sj,literalAutolinkWww:Cj}}}function xj(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:gh,notInConstruct:yh},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:gh,notInConstruct:yh},{character:":",before:"[ps]",after:"\\/",inConstruct:gh,notInConstruct:yh}]}}function wj(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function bh(e){this.config.enter.autolinkProtocol.call(this,e)}function Sj(e){this.config.exit.autolinkProtocol.call(this,e)}function Cj(e){this.config.exit.data.call(this,e);const n=this.stack[this.stack.length-1];n.type,n.url="http://"+this.sliceSerialize(e)}function Ej(e){this.config.exit.autolinkEmail.call(this,e)}function kj(e){this.exit(e)}function Aj(e){mj(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Tj],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),_j]],{ignore:["link","linkReference"]})}function Tj(e,n,i,l,s){let o="";if(!Mx(s)||(/^w/i.test(n)&&(i=n+i,n="",o="http://"),!Nj(i)))return!1;const c=Rj(i+l);if(!c[0])return!1;const f={type:"link",title:null,url:o+n+c[0],children:[{type:"text",value:n+c[0]}]};return c[1]?[f,{type:"text",value:c[1]}]:f}function _j(e,n,i,l){return!Mx(l,!0)||/[-\d_]$/.test(i)?!1:{type:"link",title:null,url:"mailto:"+n+"@"+i,children:[{type:"text",value:n+"@"+i}]}}function Nj(e){const n=e.split(".");return!(n.length<2||n[n.length-1]&&(/_/.test(n[n.length-1])||!/[a-zA-Z\d]/.test(n[n.length-1]))||n[n.length-2]&&(/_/.test(n[n.length-2])||!/[a-zA-Z\d]/.test(n[n.length-2])))}function Rj(e){const n=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!n)return[e,void 0];e=e.slice(0,n.index);let i=n[0],l=i.indexOf(")");const s=s1(e,"(");let o=s1(e,")");for(;l!==-1&&s>o;)e+=i.slice(0,l+1),i=i.slice(l+1),l=i.indexOf(")"),o++;return[e,i]}function Mx(e,n){const i=e.input.charCodeAt(e.index-1);return(e.index===0||Cl(i)||Bc(i))&&(!n||i!==47)}function or(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}Lx.peek=qj;function jj(){this.buffer()}function Oj(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Dj(){this.buffer()}function Mj(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Lj(e){const n=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=or(this.sliceSerialize(e)).toLowerCase(),i.label=n}function zj(e){this.exit(e)}function Uj(e){const n=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=or(this.sliceSerialize(e)).toLowerCase(),i.label=n}function Bj(e){this.exit(e)}function qj(){return"["}function Lx(e,n,i,l){const s=i.createTracker(l);let o=s.move("[^");const c=i.enter("footnoteReference"),f=i.enter("reference");return o+=s.move(i.safe(i.associationId(e),{after:"]",before:o})),f(),c(),o+=s.move("]"),o}function Hj(){return{enter:{gfmFootnoteCallString:jj,gfmFootnoteCall:Oj,gfmFootnoteDefinitionLabelString:Dj,gfmFootnoteDefinition:Mj},exit:{gfmFootnoteCallString:Lj,gfmFootnoteCall:zj,gfmFootnoteDefinitionLabelString:Uj,gfmFootnoteDefinition:Bj}}}function Fj(e){let n=!1;return e&&e.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:i,footnoteReference:Lx},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function i(l,s,o,c){const f=o.createTracker(c);let h=f.move("[^");const d=o.enter("footnoteDefinition"),m=o.enter("label");return h+=f.move(o.safe(o.associationId(l),{before:h,after:"]"})),m(),h+=f.move("]:"),l.children&&l.children.length>0&&(f.shift(4),h+=f.move((n?`
|
|
237
|
+
.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"})});function UN(){return b.jsxs("div",{className:"flex items-center bg-white border-b border-gray-200 overflow-auto no-scrollbar",children:[b.jsx(BN,{}),b.jsx(qN,{}),b.jsx(HN,{}),b.jsx(FN,{})]})}function BN(){const{state:e}=k.useContext(Rt),{dataSourceId:n,name:i}=k.useContext(Or),{data:l}=_c(n),{data:s}=k.useContext(mr),o=uo(bn.EDITOR),c=F_(),f=()=>{var d,m;(d=s==null?void 0:s.columns)!=null&&d[0].table&&Lp({table:(m=s==null?void 0:s.columns)==null?void 0:m[0].table,dataSourceId:n})},h=async()=>{const d=Q_(e,["size","page"]),m=await kl("Query name",i);m&&c.mutate({name:m,dataSourceId:n,opts:d})};return Jn("s",h,"Save query"),b.jsxs("div",{className:be.tableConfig,children:[b.jsxs("button",{"data-tooltip-id":"default","data-tooltip-content":"Manage filters",onClick:()=>sr("filters"),className:xe(be.tableAction,be.blue),children:[b.jsx("span",{children:"Filter"}),b.jsx("span",{className:"hotkey",children:"F"})]}),b.jsxs("button",{"data-tooltip-id":"default","data-tooltip-content":"Join tables",onClick:()=>sr("joins"),className:xe(be.tableAction,be.blue),children:[b.jsx("span",{children:"Join"}),b.jsx("span",{className:"hotkey",children:"J"})]}),b.jsx(PN,{}),b.jsxs("button",{"data-tooltip-id":"explorer-more-actions",className:xe(be.tableAction,be.blue),children:[b.jsx("span",{children:"More actions"}),b.jsx(Bp,{width:16,height:16,className:"rotate-90"})]}),b.jsxs(Kp,{id:"explorer-more-actions",className:"z-10 shadow-md flex flex-col",clickable:!0,variant:"light",opacity:1,children:[b.jsxs("button",{onClick:()=>sr("columns"),className:xe(be.tableAction,be.modal,be.blue,"justify-between"),children:[b.jsx("span",{children:"Columns"}),b.jsx("span",{className:"hotkey",children:"C"})]}),b.jsxs("button",{onClick:()=>sr("groupBy"),className:xe(be.tableAction,be.modal,be.blue,"justify-between"),children:[b.jsx("span",{children:"Group by"}),b.jsx("span",{className:"hotkey",children:"G"})]}),b.jsxs("button",{onClick:()=>sr("aggregate"),className:xe(be.tableAction,be.modal,be.blue,"justify-between"),children:[b.jsx("span",{children:"Aggregate"}),b.jsx("span",{className:"hotkey",children:"A"})]}),b.jsxs("button",{onClick:qp,className:xe(be.tableAction,be.modal,be.blue,"justify-between"),children:[b.jsx("span",{children:"Query editor"}),b.jsx("span",{className:"hotkey",children:"E"})]}),o&&b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"h-0.5 my-2 bg-gray-100"}),b.jsxs("button",{onClick:h,className:xe(be.tableAction,be.modal,be.blue),children:[b.jsx("span",{children:"Save query"}),b.jsx("span",{className:"hotkey",children:"S"})]}),(l==null?void 0:l.allowInsert)===!0&&b.jsx("button",{onClick:f,className:xe(be.tableAction,be.modal,be.blue),children:"Insert new row"})]})]})]})}function qN(){const{name:e}=k.useContext(Or),{state:n}=k.useContext(Rt),{refetch:i}=k.useContext(mr),l=oo("Workbook"),s=()=>{xl(e,n,!0),Xh()};return Jn("e",qp,"Show editor sidebar"),b.jsxs("div",{className:be.tableConfig,children:[b.jsx("button",{"data-tooltip-id":"default","data-tooltip-content":"Refresh data",onClick:()=>i(),className:xe(be.tableAction,be.blue),children:"Refresh"}),b.jsx("button",{"data-tooltip-id":"default","data-tooltip-content":"Clone in a new tab",onClick:s,className:xe(be.tableAction,be.blue),children:"Clone"}),b.jsxs("button",{"data-tooltip-id":"default","data-tooltip-content":"Start new query tab",onClick:l,className:xe(be.tableAction,be.blue),children:[b.jsx("span",{children:"New query"}),b.jsx("span",{className:"hotkey",children:"N"})]})]})}function HN(){const{page:e,size:n,setPage:i}=mx(),{data:l}=k.useContext(mr),s=(l==null?void 0:l.rows.length)===n;return b.jsxs("div",{className:be.tableConfig,children:[b.jsx("button",{"data-tooltip-content":"Previous page","data-tooltip-id":"default",disabled:e<=0,className:xe(be.tableAction,be.blue),onClick:()=>i(e-1),children:"Prev"}),b.jsx("span",{className:"text-sm bg-gray-50 rounded-md px-2 border border-gray-200",children:e+1}),b.jsx("button",{"data-tooltip-content":"Next page","data-tooltip-id":"default",disabled:!s,className:xe(be.tableAction,be.blue),onClick:()=>i(e+1),children:"Next"})]})}function FN(){const{size:e,setSize:n}=mx();return b.jsx("div",{className:be.tableConfig,children:b.jsx("label",{className:be.tableAction,"data-tooltip-content":"Size","data-tooltip-id":"default",children:b.jsxs("select",{style:{height:"20px"},value:e,onChange:i=>n(parseInt(i.target.value,10)),children:[b.jsx("option",{value:5,children:"5 rows"}),b.jsx("option",{value:10,children:"10 rows"}),b.jsx("option",{value:20,children:"20 rows"}),b.jsx("option",{value:50,children:"50 rows"}),b.jsx("option",{value:100,children:"100 rows"}),b.jsx("option",{value:200,children:"200 rows"})]})})})}function PN(){const{state:e,setState:n}=k.useContext(Rt),i=()=>{n(s=>({...s,searchAll:void 0}))},l=()=>{kl("Search all text values for",e.searchAll||"",{type:"info",message:"This will search all text values using LIKE operator (numbers, dates and other non string values are not searched)."}).then(s=>{s!==void 0&&n(o=>({...o,searchAll:s.length>0?s:void 0}))})};return Jn("k",l,"Search text"),e.searchAll?b.jsx("button",{"data-tooltip-id":"default","data-tooltip-content":"Remove search all filter",onClick:i,className:xe(be.tableAction,be.red),children:b.jsxs("span",{className:"truncate px-1",children:["❌ ",e.searchAll]})}):b.jsxs("button",{"data-tooltip-id":"default","data-tooltip-content":"Search text in all columns",onClick:l,className:xe(be.tableAction,be.blue),children:[b.jsx("span",{children:"Search text"}),b.jsx("span",{className:"hotkey",children:"K"})]})}const QN="_drop-container_u16km_2",IN="_item_u16km_2",n1={dropContainer:QN,item:IN},np=({dataSourceId:e,focusId:n,placeholder:i="Column",onChange:l,value:s,autoFocus:o,allowTables:c})=>{const{data:f}=Da(e),h=k.useRef(null),d=k.useMemo(()=>{if(!f)return[];let E=f;return c&&(E=f.filter(N=>c.includes(N.tableName))),E.flatMap(N=>N.columns.map(j=>({value:N.tableName+"."+j.name,label:j.name,table:N.tableName,searchValue:j.name.toLowerCase()})))},[f,c]),m=k.useMemo(()=>{const E=s.toLowerCase()||"",N=[];for(let j=0;j<d.length&&N.length<10;j++)d[j].searchValue.includes(E)&&N.push(d[j]);return N},[d,s]),[y,x]=k.useState(!1),[v,w]=k.useState(0),T=E=>{var N;if(E.key==="ArrowDown")E.preventDefault(),w(j=>(j+1)%m.length);else if(E.key==="ArrowUp")E.preventDefault(),w(j=>(j-1+m.length)%m.length);else if(E.key==="Enter"&&v>=0&&v<m.length){E.preventDefault();const j=m[v].value;x(!1);const q=d.findIndex(L=>L.value===j)>-1;l(((N=m[v])==null?void 0:N.value)||j,q,!0)}};k.useEffect(()=>{var N;const E=(N=h.current)==null?void 0:N.querySelector('[data-is-active="true"]');E&&E.scrollIntoView({behavior:"smooth",block:"nearest"})},[v]);const _=E=>{const N=E.currentTarget.value,j=d.findIndex(q=>q.value===N)>-1;l(N,j,!1)};return b.jsxs("div",{className:"relative",onFocus:()=>x(!0),onBlur:()=>x(!1),children:[b.jsx("input",{autoFocus:o,onKeyDown:T,value:s,onChange:_,className:"input w-full",placeholder:i,"data-focus":n}),y&&m.length>0&&b.jsx("div",{className:n1.dropContainer,ref:h,tabIndex:-1,children:m.map((E,N)=>b.jsxs("div",{className:n1.item,"data-is-active":v===N,onMouseDownCapture:j=>{j.preventDefault(),x(!1),l(E.value,!0,!0)},children:[b.jsx("span",{className:"text-xs font-semibold truncate",children:E.table}),b.jsx("p",{className:"truncate text-sm",children:E.label})]},N))})]})},VN="_drop-container_19uk9_2",$N="_item_19uk9_2",r1={dropContainer:VN,item:$N};function YN(e){return Xk.includes(e)?Yk:Zk.includes(e)?$k:Jk.includes(e)?Kk:_p}const KN=({value:e,onChange:n,autoFocus:i,focusId:l,colType:s})=>{const o=k.useMemo(()=>{const x=e.toLowerCase()||"";return YN(s||"").filter(v=>v.label.includes(x))},[e,s]),c=k.useRef(null),[f,h]=k.useState(!1),[d,m]=k.useState(0),y=x=>{var v;x.key==="ArrowDown"?(x.preventDefault(),m(w=>(w+1)%o.length)):x.key==="ArrowUp"?(x.preventDefault(),m(w=>(w-1+o.length)%o.length)):x.key==="Enter"&&(d>=0&&d<o.length?(x.preventDefault(),h(!1),n(((v=o[d])==null?void 0:v.label)||"",!0)):n(e,!0))};return k.useEffect(()=>{var v;const x=(v=c.current)==null?void 0:v.querySelector('[data-is-active="true"]');x&&x.scrollIntoView({behavior:"smooth",block:"nearest"})},[d]),b.jsxs("div",{className:"relative",children:[b.jsx("input",{onKeyDown:y,value:e,onChange:x=>n(x.target.value,!1),className:"input w-full",placeholder:"Operator",autoFocus:i,onFocus:()=>h(!0),onBlur:()=>h(!1),"data-focus":l}),f&&o.length>0&&b.jsx("ul",{className:r1.dropContainer,ref:c,tabIndex:-1,children:o.map((x,v)=>b.jsx("li",{className:r1.item,"data-is-active":d===v,onMouseDownCapture:w=>{w.preventDefault(),h(!1),n(x.label,!0)},children:x.label},v))})]})},GN="_actions_jpxzd_2",XN="_filter-actions_jpxzd_2",Nx={actions:GN,filterActions:XN},ZN=["=","<",">",">=","<>","!=","<="];function JN(e){for(let n=0;n<e.length;n++){const i=e[n];if(!i.operator.length&&!i.value.length&&!i.column.length)continue;if(!i.column.includes("."))return tn.error(`Filter #${n+1} has invalid column value`),!1;const l=Rp[i.operator];if(!l)return tn.error(`Filter #${n+1} has invalid operator`),!1;if(i.isColumnRef&&!ZN.includes(l))return tn.error(`Filter #${n+1} cannot reference another column because it uses '${i.operator}' operator`),!1}return!0}function WN(e){const n=[];return e.forEach(i=>{if(!i.operator.length||!i.value.length||!i.column.length)return;const l=Rp[i.operator];n.push({id:i.id,value:i.isColumnRef?[{value:i.value,isColumn:!0}]:Gk(l,i.value),operator:l,column:i.column,isEnabled:!0,connector:"AND"})}),n}function eR(e){let n="";if(e.value)for(let i=0;i<e.value.length;i++)n+=e.value[i].value,i<e.value.length-1&&(n+=", ");return n}const tR=({filter:e,dataSourceId:n,allowedTables:i,inspections:l,autoFocus:s,onChangeColumn:o,onChangeOperator:c,onChangeValue:f,onRemoveFilter:h,onIsColumnChange:d})=>{const m=k.useMemo(()=>{if(!l)return"";let y=null;for(const x of l)for(const v of x.columns)x.tableName+"."+v.name===e.column&&(y=v);return y!=null&&y.type?y.type:""},[e.column,l]);return b.jsxs("div",{className:"flex gap-2 items-center",children:[b.jsx("label",{className:"w-full",children:b.jsx(np,{dataSourceId:n,onChange:y=>o(e.id,y),value:e.column,allowTables:i,focusId:"column",autoFocus:s})}),b.jsx("label",{children:b.jsx(KN,{onChange:y=>c(e.id,y),focusId:"operator",colType:m,value:e.operator})}),lx(Rp[e.operator])&&b.jsx("label",{className:"w-full",children:e.isColumnRef?b.jsx(np,{dataSourceId:n,onChange:y=>f(e.id,y),value:e.value,allowTables:i,focusId:"value",placeholder:"Search column"}):b.jsx("input",{className:"input w-full",placeholder:"Filter value",value:e.value,onChange:y=>f(e.id,y.currentTarget.value),"data-focus":"value"})}),b.jsxs("div",{className:Nx.filterActions,children:[b.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"If enabled, the value will reference another column instead of being raw string",className:xe("p-0.5 cursor-pointer rounded-lg border",e.isColumnRef?"bg-blue-50 border-blue-200":"bg-white border-white"),onClick:()=>d(e.id,!e.isColumnRef),children:"🏷️"}),b.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove aggregation",className:"p-0.5 text-sm cursor-pointer",onClick:()=>h(e.id),children:b.jsx(pr,{width:20,height:20,className:"text-red-600"})})]})]})},nR=()=>{const{state:e}=k.useContext(Rt),{setFilters:n}=hx(),i=Dc(T=>T.filters),{data:l}=Da(e.dataSourceId),s=k.useMemo(()=>[e.table,...e.joins.map(T=>T.table)],[e.table,e.joins]),[o,c]=k.useState([]),f=(T,_)=>{c(E=>[...E.map(N=>N.id===T?{...N,column:_}:N)])},h=(T,_)=>{c(E=>[...E.map(N=>N.id===T?{...N,operator:_}:N)])},d=(T,_)=>{c(E=>[...E.map(N=>N.id===T?{...N,value:_}:N)])},m=()=>{c(T=>[...T,{id:ai(),value:"",column:"",operator:"",isColumnRef:!1}])},y=(T,_)=>{c(E=>[...E.map(N=>N.id===T?{...N,isColumnRef:_}:N)])},x=T=>{c(_=>_.filter(E=>E.id!==T))},v=()=>Mc("filters"),w=()=>{JN(o)&&(n(WN(o)),v())};return k.useEffect(()=>{if(!i){c([]);return}c(()=>{const T=e.filters.map(_=>{var E,N;return{id:_.id,value:eR(_),column:_.column,operator:Np[_.operator],isColumnRef:!!((N=(E=_.value)==null?void 0:E[0])!=null&&N.isColumn)}});return T.push({id:ai(),value:"",column:"",operator:"",isColumnRef:!1}),T})},[i]),Jn("f",()=>{oc("filters")},"Add new filter"),b.jsxs(rn,{isVisible:i,onClose:v,portal:!0,children:[b.jsx(tr,{onClick:v}),b.jsx("h2",{className:"text-lg font-semibold",children:"Filters"}),b.jsxs("div",{className:"flex gap-4 flex-col w-full lg:w-lg my-4",children:[o.length<1&&b.jsx("p",{className:"p-1 text-center rounded-lg bg-gray-50 border border-gray-200",children:"No filters"}),o.map((T,_)=>b.jsx(tR,{filter:T,dataSourceId:e.dataSourceId,allowedTables:s,inspections:l||[],onChangeColumn:f,onChangeOperator:h,onChangeValue:d,onRemoveFilter:x,onIsColumnChange:y,autoFocus:_===o.length-1},T.id))]}),b.jsxs("div",{className:Nx.actions,children:[b.jsx("button",{className:"button tertiary",onClick:m,children:"Add filter"}),b.jsx("button",{className:"button primary",onClick:w,children:"Apply filters"})]})]})},rR="_card_zpu14_2",iR="_cards-list_zpu14_2",lR="_join-modal_zpu14_2",aR="_close-button_zpu14_2",Ou={card:rR,cardsList:iR,joinModal:lR,closeButton:aR},sR=()=>{const{isFetching:e}=k.useContext(mr),n=Dc(d=>d.joins),{toggle:i,joins:l}=px(),{availableJoins:s}=k.useContext(Or),[o,c]=k.useState(""),f=k.useMemo(()=>{const d=o.toLowerCase();return s.filter(m=>m.on.toTable.toLowerCase().includes(d))},[s,o]),h=()=>Mc("joins");return Jn("j",()=>{s.length>0?sr("joins"):tn.error("No available tables to join")},"Add new join"),b.jsxs(rn,{isVisible:n,onClose:h,portal:!0,children:[b.jsx(tr,{onClick:h}),b.jsxs("div",{className:Ou.joinModal,children:[b.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Join table"}),l.length>0&&b.jsx("div",{className:Ou.cardsList,children:l.map((d,m)=>b.jsxs("div",{className:Ou.card,children:[b.jsxs("p",{className:"text-sm truncate",children:[d.table," on ",d.on]}),m===l.length-1&&b.jsx("button",{className:Ou.closeButton,onClick:()=>i(d),disabled:e,children:b.jsx(pr,{width:20,height:20})})]},d.table+d.on))}),f.length>0?b.jsx("input",{className:"input w-full",placeholder:"Filter",autoFocus:!0,onChange:d=>c(d.target.value),value:o,disabled:e}):b.jsx(cn,{variant:"warning",children:b.jsx("p",{className:"text-sm truncate",children:"No more tables to join"})}),b.jsx("div",{className:`flex flex-col mt-2 overflow-y-auto ${e?"opacity-40":""}`,children:f.map(d=>b.jsx(dx,{hook:d,onClick:()=>{e||(i({table:d.on.toTable,type:"LEFT",on:d.where}),c(""))}},d.where))})]})]})};function oR(e){return e.reduce((n,i)=>(n[i]=!0,n),{})}function uR(e){return e.reduce((n,i)=>(n[i]=!0,n),{})}const cR="_container_126ac_2",fR="_column-label_126ac_2",dR="_not-active_126ac_2",Gu={container:cR,columnLabel:fR,notActive:dR};function hR(e){if(!e)return[];const n={};return e.forEach(i=>{n[i.table]?n[i.table].push({value:i.full,ogColumn:i.column,label:qi(i.column),type:i.type}):n[i.table]=[{value:i.full,ogColumn:i.column,label:qi(i.column),type:i.type}],Wk[i.type]&&["YEAR","MONTH","DAY"].forEach(l=>{n[i.table].push({value:l+" "+i.full,ogColumn:i.column,label:l+" "+qi(i.column),type:"number",nested:!0})})}),Object.entries(n).reduce((i,[l,s])=>(i.push({name:qi(l),columns:s}),i),[])}function pR(e,n){const i=n.toLowerCase();return e.map(l=>{const s=l.columns.filter(o=>o.label.toLowerCase().includes(i)||o.ogColumn.toLowerCase().includes(i));return{...l,columns:s}}).filter(l=>l.columns.length>0)}const mR=({column:e,selected:n,onCheck:i})=>b.jsxs("label",{className:xe(Gu.columnLabel,n?Gu.active:Gu.notActive,e.nested&&"pl-5!"),children:[b.jsx("input",{type:"checkbox",checked:n[e.value],name:e.value,onChange:i}),b.jsxs("p",{className:"flex justify-between w-full",children:[b.jsx("span",{"data-tooltip-content":e.value,"data-tooltip-id":"default",children:e.label}),b.jsx("span",{className:"text-blue-600",children:e.type})]})]},e.value),gR={columns:"c",groupBy:"g"},i1=({mode:e})=>{const n=Dc(E=>E[e]),{allColumns:i}=k.useContext(Or),{state:l,setState:s}=k.useContext(Rt),[o,c]=k.useState({}),[f,h]=k.useState(""),d=k.useMemo(()=>hR(i),[i]),m=l.aggregations.length>0||l.groupBy.length>0,y=k.useMemo(()=>f?pR(d,f):d,[f,d]),x=E=>{c(N=>({...N,[E.target.name]:E.target.checked}))},v=E=>{const N=E.target.checked;c(j=>{for(const q of i)j[q.full]=N;return{...j}})},w=()=>{Mc(e)},T=()=>{const E=[];for(const[N,j]of Object.entries(o))if(j){const[q,L]=N.split(" ");E.push({value:L||q,fn:L?q:void 0})}s(N=>({...N,[e]:E})),w()},_=k.useMemo(()=>{for(const E of i)if(!o[E.full])return!1;return!0},[o,i]);return Jn(gR[e],()=>{e==="columns"?m?tn.error("Columns are ignored when there is at least one aggregation or group by"):oc("columns"):oc("groupBy")},"Manage "+e),k.useEffect(()=>{if(!n){c({});return}c(()=>oR(l[e].map(E=>E.fn?E.fn+" "+E.value:E.value)))},[n,c]),b.jsxs(rn,{isVisible:n,onClose:w,portal:!0,children:[b.jsx(tr,{onClick:w}),b.jsxs("div",{className:Gu.container,children:[b.jsx("h2",{className:"text-lg font-semibold",children:e==="groupBy"?"Group by":"Show columns"}),b.jsx("input",{autoFocus:!0,className:"input my-2",placeholder:"Filter",value:f,onChange:E=>h(E.target.value)}),b.jsx("div",{className:"overflow-y-auto",children:y.map(E=>b.jsxs("div",{className:"my-2",children:[b.jsxs("p",{className:"font-semibold sticky top-0 bg-white p-1 z-1",children:["📄 ",E.name]}),E.columns.map(N=>b.jsx(mR,{column:N,selected:o,onCheck:x},N.value))]},E.name))}),b.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[b.jsxs("label",{className:"button tertiary flex gap-2 items-center",children:[b.jsx("input",{type:"checkbox",checked:_,onChange:v}),b.jsx("span",{children:"Select all"})]}),b.jsx("span",{className:"flex-1"}),b.jsx("button",{className:"button tertiary",onClick:w,children:"Cancel"}),b.jsx("button",{className:"button primary",onClick:T,children:"Apply"})]})]})]})},yR="_options-container_1fpdf_2",bR={optionsContainer:yR},mh="COUNT all",vR=e=>e.distinct?[e.fn,"DISTINCT",e.value].join(" "):[e.fn,e.value].join(" "),xR=()=>{const e=Dc(w=>w.aggregate),{dataSourceId:n}=k.useContext(Or),{setState:i,state:l}=k.useContext(Rt),{data:s}=k.useContext(mr),[o,c]=k.useState({fn:"",col:""}),f=w=>c({...o,fn:w.currentTarget.value}),h=w=>c({...o,col:w}),d=()=>Mc("aggregate"),m=()=>{const w=o.fn===mh?{value:"*",fn:"COUNT"}:{fn:o.fn,value:o.col,distinct:o.fn==="COUNT"};i(T=>({...T,aggregations:[...T.aggregations,w]}))},y=o.fn===mh,x=y?!1:!o.col||!o.fn,v=w=>{const T=ri(w);i(_=>({..._,aggregations:_.aggregations.filter(E=>E.fn!==w.fn||E.value!==w.value),orderBy:_.orderBy.filter(E=>E.column!==T)}))};return Jn("a",()=>{oc("aggregate")},"Aggregate data"),b.jsxs(rn,{isVisible:e,onClose:d,backdropClose:!0,portal:!0,children:[b.jsx(tr,{onClick:d}),b.jsxs("div",{children:[b.jsx("h2",{className:"text-lg font-semibold",children:"Aggregate"}),Fi(l.aggregations.length,0)&&b.jsx("div",{className:"flex flex-col gap-1 mt-4",children:l.aggregations.map((w,T)=>b.jsxs("p",{className:"p-2 rounded-md bg-gray-50 flex items-center justify-between",children:[b.jsx("span",{children:vR(w)}),b.jsx("button",{tabIndex:-1,"data-tooltip-id":"default","data-tooltip-content":"Remove aggregation",className:"p-0.5 text-sm cursor-pointer",onClick:()=>v(w),children:b.jsx(pr,{width:20,height:20,className:"text-red-600"})})]},T))}),b.jsxs("div",{className:bR.optionsContainer,children:[b.jsxs("label",{className:xe(y&&"col-span-2"),children:[b.jsx("p",{className:"font-semibold text-xs",children:"Function"}),b.jsxs("select",{className:"input w-full",value:o.fn,onChange:f,autoFocus:!0,children:[b.jsx("option",{value:"",disabled:!0,children:"Select function"}),b.jsx("option",{value:mh,children:"Count all rows"}),b.jsx("option",{value:"COUNT",children:"Count"}),b.jsx("option",{value:"SUM",children:"Sum"}),b.jsx("option",{value:"MAX",children:"Max"}),b.jsx("option",{value:"MIN",children:"Min"}),b.jsx("option",{value:"AVG",children:"Avg"})]})]}),!y&&b.jsxs("label",{children:[b.jsx("p",{className:"font-semibold text-xs",children:"Column"}),b.jsx(np,{dataSourceId:n,allowTables:(s==null?void 0:s.tables)||[],onChange:h,value:o.col})]}),b.jsx("button",{className:"button primary",disabled:x,onClick:m,children:"Add"})]})]})]})};function wR(e,n,i){const l=[];return n.length>0||i.length>0?l.push(...n,...i):e.length>0&&l.push(...e),l}const Rx=({options:e,updater:n,name:i,tabId:l})=>{const s=nA(e,n),{state:o}=s,c=$A({datasourceId:e.dataSourceId,table:e.table,filters:o.filters,joins:o.joins,page:o.page,size:o.size,orderBy:o.orderBy,columns:wR(o.columns,o.groupBy,o.aggregations),groupBy:o.groupBy,searchAll:o.searchAll}),f=tA(c.data,e.dataSourceId,i,l);return b.jsx(Or,{value:f,children:b.jsx(Rt,{value:s,children:b.jsxs(mr,{value:c,children:[b.jsx(UN,{}),b.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[b.jsxs("div",{className:"m-1 flex-1 overflow-auto pb-12 no-scrollbar",children:[b.jsx("div",{className:"pb-0.5 sticky bottom-0"}),b.jsx(o_,{})]}),b.jsx(nR,{}),b.jsx(sR,{}),b.jsx(i1,{mode:"columns"}),b.jsx(i1,{mode:"groupBy"}),b.jsx(xR,{}),b.jsx(q_,{})]})]})})})},SR=e=>{if(!e)return;const n=mt.getQueryData([vl]);if(!n)return;const i=mt.getQueryData([si,n.teamId]);return i==null?void 0:i.find(l=>l.id===e)},CR=({content:e,activeAnchor:n})=>{if(!n)return null;const i=n.getAttribute("data-tab-id"),l=jc.get().find(c=>c.id===i),s=SR(l==null?void 0:l.options.dataSourceId);if(!l)return e;const o=()=>{kl("New tab name",l.label).then(c=>{c&&Dp(l.id,c)})};return b.jsxs("div",{children:[b.jsxs("button",{className:Ar.tooltipLabel,onClick:o,children:[b.jsxs("div",{className:"overflow-hidden",children:[b.jsx("p",{className:"text-xs",children:"label"}),b.jsx("p",{className:"truncate font-semibold",children:l.label})]}),b.jsx("span",{children:"✏️"})]}),b.jsxs("div",{className:Ar.tooltipInfoEntry,children:[b.jsx("p",{className:"text-sm",children:"table"}),b.jsx("p",{className:"truncate font-semibold",children:l.options.table})]}),s&&b.jsxs("div",{className:Ar.tooltipInfoEntry,children:[b.jsxs("p",{className:"text-sm",children:["data source [",s.dbType,"]"]}),b.jsx("p",{className:"truncate font-semibold",children:s.name})]}),l.options.joins.length>0&&b.jsxs("div",{className:Ar.tooltipInfoEntry,children:[b.jsx("p",{className:"text-sm",children:"joins"}),b.jsx("p",{className:"truncate font-semibold",children:l.options.joins.map(c=>c.table).join(", ")})]}),l.options.filters.length>0&&b.jsxs("div",{className:Ar.tooltipInfoEntry,children:[b.jsx("p",{className:"text-sm",children:"filters"}),l.options.filters.map(c=>b.jsx("p",{className:"truncate font-semibold",children:HA(c)}))]})]})},ER=()=>{const e=iA(),n=Nc(),i=Hp(Oc.laptop),l=k.useMemo(()=>{if(!n)return;const h=n.find(d=>d.id===e);return h||n[0]},[e,n]),s=h=>{h.stopPropagation(),h.preventDefault();const d=h.currentTarget.getAttribute("data-tab-id");d&&jb(d)},o=h=>{h.button===1&&jb(h.currentTarget.dataset.tabId)},c=h=>{const d=n.find(m=>m.id===h);kl("New tab name",d==null?void 0:d.label).then(m=>{m&&Dp(h,m)})},f=k.useCallback(h=>{Rc(d=>d.map(m=>m.id!==l.id?m:{...m,options:h(m.options)}))},[l]);return n.length<1?b.jsx(VC,{to:"/"}):b.jsxs("div",{className:"h-screen max-h-screen bg-(--bg) flex flex-col",children:[i&&b.jsx(Kp,{id:"tab",render:CR,className:"z-10 shadow-md p-0!",offset:-1,noArrow:!0,opacity:1,variant:"light",clickable:!0,delayShow:500}),l&&b.jsx(Rx,{updater:f,options:l.options,name:l.label,tabId:l.id}),b.jsx("div",{className:xe(Ar.tabs,"no-scrollbar",!i&&Ar.mobile),children:n==null?void 0:n.map(h=>b.jsxs("div",{onClick:()=>Op(h.id),className:xe(Ar.tab,h.id===(l==null?void 0:l.id)&&Ar.active),"data-tab-id":h.id,"data-tooltip-id":"tab","data-tooltip-content":h.label,onAuxClick:o,onContextMenu:d=>{d.preventDefault(),c(h.id)},children:[b.jsxs("span",{className:"truncate w-full",children:["📄 ",h.label]}),b.jsx("button",{"data-tab-id":h.id,className:Ar.closeButton,onClick:s,children:b.jsx(pr,{width:20,height:20})})]},h.id))})]})},kR=()=>{const e=I_(),n=k.useCallback(i=>{gx(l=>l?{...l,options:i(l.options)}:(tn.error("Something went wrong."),l))},[]);return e?b.jsxs(rn,{isVisible:!0,onClose:Xh,children:[b.jsx(tr,{onClick:Xh}),b.jsx("div",{className:"border border-gray-200 bg-(--bg) flex flex-col",children:b.jsx(Rx,{name:e.label,options:e.options,updater:n})})]}):null},AR="_root_1uact_2",TR="_down_1uact_2",_R="_chevron_1uact_2",NR="_table-name-container_1uact_2",RR="_link_1uact_2",jR="_table-name_1uact_2",OR="_ul_1uact_2",DR="_column-type_1uact_2",ti={root:AR,down:TR,chevron:_R,tableNameContainer:NR,link:RR,tableName:jR,ul:OR,columnType:DR},[T9,MR]=wn(!1),jx=()=>MR(!1),LR=new Intl.DateTimeFormat("en",{dateStyle:"full",timeStyle:"long"});function zR(e,n){if(n&&e.toLowerCase().includes(n))return"bg-yellow-200"}const UR=({insp:e,filter:n,expanded:i})=>{const l=k.useMemo(()=>i?e.columns:n.length<1?[]:e.columns.filter(s=>s.name.toLowerCase().includes(n)),[e,n,i]);return b.jsx("ul",{className:ti.ul,children:l.map(s=>b.jsx(b.Fragment,{children:b.jsxs("li",{children:[s.isPrimary?"🔐":"🏷️"," ",b.jsx("span",{className:zR(s.name,n),children:s.name})," ",b.jsxs("span",{className:ti.columnType,children:["[",s.type,"]"]}),s.ref&&b.jsxs("span",{children:[" ➡️ ",b.jsx("span",{className:ti.columnType,children:s.ref.table}),".",s.ref.field]})]},s.name+s.type)}))},e.id)};function BR({id:e}){const{data:n}=_c(e),{data:i}=Da(e),l=Wn(),{pathname:s}=nn(),o=Mk(),c=nx(),f=Lk(),h=k.useMemo(()=>n!=null&&n.lastInspected?LR.format(new Date(n.lastInspected)):"--",[n]),[d,m]=k.useState({}),[y,x]=k.useState(""),[v,w]=k.useState("table"),T=uo(bn.EDITOR),_=y.toLowerCase(),E=k.useMemo(()=>{if(!_||!i)return i||[];const ee=[];for(const ie of i){if(ie.tableName.toLowerCase().includes(_)){ee.push(ie);continue}v!=="table"&&ie.columns.findIndex(U=>U.name.toLowerCase().includes(_))>=0&&ee.push(ie)}return ee},[_,i,v]),N=ee=>{m(ie=>({...ie,[ee]:!ie[ee]}))},j=ee=>{xl(ee,{table:ee,dataSourceId:e},!0),xa(void 0),jx(),s!==rt.workbench.path&&l(rt.workbench.path)},q=()=>{c.mutate(e)},L=async()=>{const ee=await kl("Enter name",n==null?void 0:n.name);ee&&o.mutate({id:e,dataSource:{name:ee}})},D=async()=>{await ox("Are you sure you want to delete this data source?")&&(f.mutate(e),xa(void 0))},X=v==="column";return b.jsxs("div",{className:ti.root,children:[b.jsxs("h3",{className:"page-head flex gap-2",children:[n&&b.jsx(Mp,{size:32,type:n.dbType}),b.jsx("span",{className:"truncate",children:n==null?void 0:n.name})]}),b.jsx("p",{className:"mt-1 text-sm font-semibold",children:h}),T&&b.jsxs("div",{className:"mt-2 flex gap-2",children:[b.jsx("button",{disabled:c.isLoading,onClick:q,className:"button tertiary flex items-center gap-1",children:"Refresh schema"}),b.jsx("button",{disabled:c.isLoading,onClick:L,className:"button tertiary",children:"Rename"}),b.jsx("button",{disabled:c.isLoading,onClick:D,className:"button tertiary",children:"Delete"})]}),b.jsxs("div",{className:"flex gap-1 items-center mb-2 mt-4",children:[b.jsx("input",{className:"input flex-1 bg-gray-50",placeholder:X?"Search column":"Search table",value:y,onChange:ee=>x(ee.target.value),autoFocus:!0}),b.jsx("button",{className:"button primary w-20",onClick:()=>w(X?"table":"column"),children:X?"Column":"Table"})]}),b.jsx("div",{className:"overflow-y-auto",children:E==null?void 0:E.map(ee=>b.jsxs("div",{children:[b.jsxs("div",{className:ti.tableNameContainer,children:[b.jsx("button",{className:xe(ti.chevron,d[ee.id]&&ti.down),onClick:()=>N(ee.id),children:b.jsx(Bp,{width:16,height:16})}),b.jsx("button",{className:xe(ti.tableName,"flex-1"),onClick:()=>N(ee.id),children:ee.tableName}),b.jsx("button",{className:ti.link,onClick:()=>j(ee.tableName),children:"↗️"})]}),(d[ee.id]||y.length>0)&&b.jsx(UR,{insp:ee,filter:X?_:"",expanded:d[ee.id]})]},ee.id))})]})}const qR=()=>{const e=jA(),[n,i]=k.useState(void 0);k.useEffect(()=>{e&&i(e)},[e]);const l=()=>xa(void 0);return b.jsxs(rn,{isVisible:e!=null,onClose:l,onClosed:()=>i(void 0),backdropClose:!0,children:[b.jsx(tr,{onClick:l}),n&&b.jsx(BR,{id:n})]})};function HR(e,n=500){const[i,l]=k.useState(e);return k.useEffect(()=>{const s=setTimeout(()=>l(e),n);return()=>clearTimeout(s)},[e,n]),i}const FR="_search_d7ba7_2",PR="_entry_d7ba7_2",QR="_ds_d7ba7_2",IR="_ds-entry_d7ba7_2",Du={search:FR,entry:PR,ds:QR,dsEntry:IR},[VR,$R]=jp({initialData:[],localStorageKey:"selected-data-sources-v1"}),YR=e=>$R(n=>{const i=n.indexOf(e);return i>-1?(n.splice(i,1),[...n]):[...n,e]}),KR={table:"📄",query:"📖"},GR=({onTable:e,onQuery:n,autoFocus:i})=>{const[l,s]=k.useState(""),[o,c]=k.useState(-1),f=HR(l,200),h=VR(),{data:d}=jr(),{data:m}=Tp({teamId:d==null?void 0:d.teamId}),{data:y}=Nk(f,{teamId:d==null?void 0:d.teamId,selectedDataSources:h}),x=_=>{_.type==="table"?e(_.name,_.dataSourceId):_.type==="query"&&n(_.id,_.dataSourceId)},v=_=>{var E;y&&(_.key==="ArrowDown"?(_.preventDefault(),c(N=>(N+1)%y.length)):_.key==="ArrowUp"?(_.preventDefault(),c(N=>(N-1+y.length)%y.length)):_.key==="Enter"&&o>=0&&(E=y[o])!=null&&E.name&&(_.preventDefault(),x(y[o])))},w=_=>{const E=_.currentTarget.dataset.tableId,N=y==null?void 0:y.find(j=>j.id===E);N&&x(N)},T=k.useMemo(()=>uR(h),[h]);return b.jsxs("div",{className:"overflow-hidden flex flex-col w-full lg:w-lg",children:[Fi(m==null?void 0:m.length,0)&&b.jsx("div",{className:"flex overflow-x-auto mb-2 gap-2 no-scrollbar",children:m.map(_=>b.jsxs("label",{className:Du.dsEntry,children:[b.jsx("input",{type:"checkbox",checked:T[_.id]===!0,onChange:()=>YR(_.id)}),b.jsx("span",{children:_.name})]},_.id))}),b.jsx("input",{className:Du.search,placeholder:"Search table or saved query to start from",value:l,onChange:_=>s(_.target.value),onKeyDown:v,autoFocus:i}),Fi(y==null?void 0:y.length,0)&&b.jsx("div",{className:"overflow-y-auto max-h-full mt-2",children:y.map((_,E)=>b.jsxs("button",{className:Du.entry,"data-is-active":o===E,"data-table-id":_.id,onClick:w,children:[b.jsxs("p",{className:"font-semibold",children:[KR[_.type]," ",_.name]}),b.jsxs("p",{className:Du.ds,children:["📦 ",_.dataSourceName]})]},_.id))})]})},XR=()=>{const e=uA(),n=(s,o)=>{e==null||e.onConfirm("table",s,o)},i=(s,o)=>{e==null||e.onConfirm("query",s,o)},l=()=>{e==null||e.onCancel()};return b.jsxs(rn,{isVisible:!!e,onClose:l,children:[b.jsx(tr,{onClick:l}),b.jsx(GR,{autoFocus:!0,onTable:n,onQuery:i})]})},ZR=()=>{const e=nn();k.useEffect(()=>{},[e.pathname])},l1={active:!1,version:""};async function JR(){try{const{data:e}=await Tc.get("/status",{timeout:500,validateStatus:()=>!0});return(e==null?void 0:e.data)||l1}catch{return l1}}function WR(){const e=mt.getQueryState([vl]);(e==null?void 0:e.status)==="error"&&mt.invalidateQueries({queryKey:[vl]})}function ej(){const e=mt.getQueryState([vl]);(e==null?void 0:e.status)==="success"&&mt.resetQueries({queryKey:[vl]})}const tj=()=>zn({queryKey:["server-status"],queryFn:JR,onSuccess:({active:e})=>{e?WR():ej()},refetchOnWindowFocus:!0,refetchInterval:(e,n)=>{var i,l;return(l=(i=n==null?void 0:n.state)==null?void 0:i.data)!=null&&l.active?2e4:4e3},retry:!1}),a1=e=>{const[n]=e.split("-");return n.split(".").map(Number)},nj=(e,n)=>{const i=a1(e),l=a1(n);for(let s=0;s<3;s++){const o=i[s]||0,c=l[s]||0;if(o>c)return 1;if(o<c)return-1}return 0};function s1(e,n){const i=String(e);if(typeof n!="string")throw new TypeError("Expected character");let l=0,s=i.indexOf(n);for(;s!==-1;)l++,s=i.indexOf(n,s+n.length);return l}const un=Ii(/[A-Za-z]/),en=Ii(/[\dA-Za-z]/),rj=Ii(/[#-'*+\--9=?A-Z^-~]/);function dc(e){return e!==null&&(e<32||e===127)}const rp=Ii(/\d/),ij=Ii(/[\dA-Fa-f]/),lj=Ii(/[!-/:-@[-`{-~]/);function Se(e){return e!==null&&e<-2}function it(e){return e!==null&&(e<0||e===32)}function Be(e){return e===-2||e===-1||e===32}const Bc=Ii(new RegExp("\\p{P}|\\p{S}","u")),Cl=Ii(/\s/);function Ii(e){return n;function n(i){return i!==null&&i>-1&&e.test(String.fromCharCode(i))}}function aj(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const qc=function(e){if(e==null)return cj;if(typeof e=="function")return Hc(e);if(typeof e=="object")return Array.isArray(e)?sj(e):oj(e);if(typeof e=="string")return uj(e);throw new Error("Expected function, string, or object as test")};function sj(e){const n=[];let i=-1;for(;++i<e.length;)n[i]=qc(e[i]);return Hc(l);function l(...s){let o=-1;for(;++o<n.length;)if(n[o].apply(this,s))return!0;return!1}}function oj(e){const n=e;return Hc(i);function i(l){const s=l;let o;for(o in e)if(s[o]!==n[o])return!1;return!0}}function uj(e){return Hc(n);function n(i){return i&&i.type===e}}function Hc(e){return n;function n(i,l,s){return!!(fj(i)&&e.call(this,i,typeof l=="number"?l:void 0,s||void 0))}}function cj(){return!0}function fj(e){return e!==null&&typeof e=="object"&&"type"in e}const Ox=[],dj=!0,ip=!1,hj="skip";function Dx(e,n,i,l){let s;typeof n=="function"&&typeof i!="function"?(l=i,i=n):s=n;const o=qc(s),c=l?-1:1;f(e,void 0,[])();function f(h,d,m){const y=h&&typeof h=="object"?h:{};if(typeof y.type=="string"){const v=typeof y.tagName=="string"?y.tagName:typeof y.name=="string"?y.name:void 0;Object.defineProperty(x,"name",{value:"node ("+(h.type+(v?"<"+v+">":""))+")"})}return x;function x(){let v=Ox,w,T,_;if((!n||o(h,d,m[m.length-1]||void 0))&&(v=pj(i(h,m)),v[0]===ip))return v;if("children"in h&&h.children){const E=h;if(E.children&&v[0]!==hj)for(T=(l?E.children.length:-1)+c,_=m.concat(E);T>-1&&T<E.children.length;){const N=E.children[T];if(w=f(N,T,_)(),w[0]===ip)return w;T=typeof w[1]=="number"?w[1]:T+c}}return v}}}function pj(e){return Array.isArray(e)?e:typeof e=="number"?[dj,e]:e==null?Ox:[e]}function mj(e,n,i){const s=qc((i||{}).ignore||[]),o=gj(n);let c=-1;for(;++c<o.length;)Dx(e,"text",f);function f(d,m){let y=-1,x;for(;++y<m.length;){const v=m[y],w=x?x.children:void 0;if(s(v,w?w.indexOf(v):void 0,x))return;x=v}if(x)return h(d,m)}function h(d,m){const y=m[m.length-1],x=o[c][0],v=o[c][1];let w=0;const _=y.children.indexOf(d);let E=!1,N=[];x.lastIndex=0;let j=x.exec(d.value);for(;j;){const q=j.index,L={index:j.index,input:j.input,stack:[...m,d]};let D=v(...j,L);if(typeof D=="string"&&(D=D.length>0?{type:"text",value:D}:void 0),D===!1?x.lastIndex=q+1:(w!==q&&N.push({type:"text",value:d.value.slice(w,q)}),Array.isArray(D)?N.push(...D):D&&N.push(D),w=q+j[0].length,E=!0),!x.global)break;j=x.exec(d.value)}return E?(w<d.value.length&&N.push({type:"text",value:d.value.slice(w)}),y.children.splice(_,1,...N)):N=[d],_+N.length}}function gj(e){const n=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const i=!e[0]||Array.isArray(e[0])?e:[e];let l=-1;for(;++l<i.length;){const s=i[l];n.push([yj(s[0]),bj(s[1])])}return n}function yj(e){return typeof e=="string"?new RegExp(aj(e),"g"):e}function bj(e){return typeof e=="function"?e:function(){return e}}const gh="phrasing",yh=["autolink","link","image","label"];function vj(){return{transforms:[Aj],enter:{literalAutolink:wj,literalAutolinkEmail:bh,literalAutolinkHttp:bh,literalAutolinkWww:bh},exit:{literalAutolink:kj,literalAutolinkEmail:Ej,literalAutolinkHttp:Sj,literalAutolinkWww:Cj}}}function xj(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:gh,notInConstruct:yh},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:gh,notInConstruct:yh},{character:":",before:"[ps]",after:"\\/",inConstruct:gh,notInConstruct:yh}]}}function wj(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function bh(e){this.config.enter.autolinkProtocol.call(this,e)}function Sj(e){this.config.exit.autolinkProtocol.call(this,e)}function Cj(e){this.config.exit.data.call(this,e);const n=this.stack[this.stack.length-1];n.type,n.url="http://"+this.sliceSerialize(e)}function Ej(e){this.config.exit.autolinkEmail.call(this,e)}function kj(e){this.exit(e)}function Aj(e){mj(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Tj],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),_j]],{ignore:["link","linkReference"]})}function Tj(e,n,i,l,s){let o="";if(!Mx(s)||(/^w/i.test(n)&&(i=n+i,n="",o="http://"),!Nj(i)))return!1;const c=Rj(i+l);if(!c[0])return!1;const f={type:"link",title:null,url:o+n+c[0],children:[{type:"text",value:n+c[0]}]};return c[1]?[f,{type:"text",value:c[1]}]:f}function _j(e,n,i,l){return!Mx(l,!0)||/[-\d_]$/.test(i)?!1:{type:"link",title:null,url:"mailto:"+n+"@"+i,children:[{type:"text",value:n+"@"+i}]}}function Nj(e){const n=e.split(".");return!(n.length<2||n[n.length-1]&&(/_/.test(n[n.length-1])||!/[a-zA-Z\d]/.test(n[n.length-1]))||n[n.length-2]&&(/_/.test(n[n.length-2])||!/[a-zA-Z\d]/.test(n[n.length-2])))}function Rj(e){const n=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!n)return[e,void 0];e=e.slice(0,n.index);let i=n[0],l=i.indexOf(")");const s=s1(e,"(");let o=s1(e,")");for(;l!==-1&&s>o;)e+=i.slice(0,l+1),i=i.slice(l+1),l=i.indexOf(")"),o++;return[e,i]}function Mx(e,n){const i=e.input.charCodeAt(e.index-1);return(e.index===0||Cl(i)||Bc(i))&&(!n||i!==47)}function or(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}Lx.peek=qj;function jj(){this.buffer()}function Oj(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function Dj(){this.buffer()}function Mj(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Lj(e){const n=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=or(this.sliceSerialize(e)).toLowerCase(),i.label=n}function zj(e){this.exit(e)}function Uj(e){const n=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=or(this.sliceSerialize(e)).toLowerCase(),i.label=n}function Bj(e){this.exit(e)}function qj(){return"["}function Lx(e,n,i,l){const s=i.createTracker(l);let o=s.move("[^");const c=i.enter("footnoteReference"),f=i.enter("reference");return o+=s.move(i.safe(i.associationId(e),{after:"]",before:o})),f(),c(),o+=s.move("]"),o}function Hj(){return{enter:{gfmFootnoteCallString:jj,gfmFootnoteCall:Oj,gfmFootnoteDefinitionLabelString:Dj,gfmFootnoteDefinition:Mj},exit:{gfmFootnoteCallString:Lj,gfmFootnoteCall:zj,gfmFootnoteDefinitionLabelString:Uj,gfmFootnoteDefinition:Bj}}}function Fj(e){let n=!1;return e&&e.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:i,footnoteReference:Lx},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function i(l,s,o,c){const f=o.createTracker(c);let h=f.move("[^");const d=o.enter("footnoteDefinition"),m=o.enter("label");return h+=f.move(o.safe(o.associationId(l),{before:h,after:"]"})),m(),h+=f.move("]:"),l.children&&l.children.length>0&&(f.shift(4),h+=f.move((n?`
|
|
238
238
|
`:" ")+o.indentLines(o.containerFlow(l,f.current()),n?zx:Pj))),d(),h}}function Pj(e,n,i){return n===0?e:zx(e,n,i)}function zx(e,n,i){return(i?"":" ")+e}const Qj=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Ux.peek=Kj;function Ij(){return{canContainEols:["delete"],enter:{strikethrough:$j},exit:{strikethrough:Yj}}}function Vj(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Qj}],handlers:{delete:Ux}}}function $j(e){this.enter({type:"delete",children:[]},e)}function Yj(e){this.exit(e)}function Ux(e,n,i,l){const s=i.createTracker(l),o=i.enter("strikethrough");let c=s.move("~~");return c+=i.containerPhrasing(e,{...s.current(),before:c,after:"~"}),c+=s.move("~~"),o(),c}function Kj(){return"~"}function Gj(e){return e.length}function Xj(e,n){const i=n||{},l=(i.align||[]).concat(),s=i.stringLength||Gj,o=[],c=[],f=[],h=[];let d=0,m=-1;for(;++m<e.length;){const T=[],_=[];let E=-1;for(e[m].length>d&&(d=e[m].length);++E<e[m].length;){const N=Zj(e[m][E]);if(i.alignDelimiters!==!1){const j=s(N);_[E]=j,(h[E]===void 0||j>h[E])&&(h[E]=j)}T.push(N)}c[m]=T,f[m]=_}let y=-1;if(typeof l=="object"&&"length"in l)for(;++y<d;)o[y]=o1(l[y]);else{const T=o1(l);for(;++y<d;)o[y]=T}y=-1;const x=[],v=[];for(;++y<d;){const T=o[y];let _="",E="";T===99?(_=":",E=":"):T===108?_=":":T===114&&(E=":");let N=i.alignDelimiters===!1?1:Math.max(1,h[y]-_.length-E.length);const j=_+"-".repeat(N)+E;i.alignDelimiters!==!1&&(N=_.length+N+E.length,N>h[y]&&(h[y]=N),v[y]=N),x[y]=j}c.splice(1,0,x),f.splice(1,0,v),m=-1;const w=[];for(;++m<c.length;){const T=c[m],_=f[m];y=-1;const E=[];for(;++y<d;){const N=T[y]||"";let j="",q="";if(i.alignDelimiters!==!1){const L=h[y]-(_[y]||0),D=o[y];D===114?j=" ".repeat(L):D===99?L%2?(j=" ".repeat(L/2+.5),q=" ".repeat(L/2-.5)):(j=" ".repeat(L/2),q=j):q=" ".repeat(L)}i.delimiterStart!==!1&&!y&&E.push("|"),i.padding!==!1&&!(i.alignDelimiters===!1&&N==="")&&(i.delimiterStart!==!1||y)&&E.push(" "),i.alignDelimiters!==!1&&E.push(j),E.push(N),i.alignDelimiters!==!1&&E.push(q),i.padding!==!1&&E.push(" "),(i.delimiterEnd!==!1||y!==d-1)&&E.push("|")}w.push(i.delimiterEnd===!1?E.join("").replace(/ +$/,""):E.join(""))}return w.join(`
|
|
239
239
|
`)}function Zj(e){return e==null?"":String(e)}function o1(e){const n=typeof e=="string"?e.codePointAt(0):0;return n===67||n===99?99:n===76||n===108?108:n===82||n===114?114:0}function Jj(e,n,i,l){const s=i.enter("blockquote"),o=i.createTracker(l);o.move("> "),o.shift(2);const c=i.indentLines(i.containerFlow(e,o.current()),Wj);return s(),c}function Wj(e,n,i){return">"+(i?"":" ")+e}function eO(e,n){return u1(e,n.inConstruct,!0)&&!u1(e,n.notInConstruct,!1)}function u1(e,n,i){if(typeof n=="string"&&(n=[n]),!n||n.length===0)return i;let l=-1;for(;++l<n.length;)if(e.includes(n[l]))return!0;return!1}function c1(e,n,i,l){let s=-1;for(;++s<i.unsafe.length;)if(i.unsafe[s].character===`
|
|
240
240
|
`&&eO(i.stack,i.unsafe[s]))return/[ \t]/.test(l.before)?"":" ";return`\\
|
|
@@ -264,7 +264,7 @@ to {
|
|
|
264
264
|
`}),i}function F1(e){let n=0,i=e.charCodeAt(n);for(;i===9||i===32;)n++,i=e.charCodeAt(n);return e.slice(n)}function P1(e,n){const i=$8(e,n),l=i.one(e,void 0),s=I8(i),o=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return s&&o.children.push({type:"text",value:`
|
|
265
265
|
`},s),o}function Z8(e,n){return e&&"run"in e?async function(i,l){const s=P1(i,{file:l,...n});await e.run(s,l)}:function(i,l){return P1(i,{file:l,...e||n})}}function Q1(e){if(e)throw e}var kh,I1;function J8(){if(I1)return kh;I1=1;var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,i=Object.defineProperty,l=Object.getOwnPropertyDescriptor,s=function(d){return typeof Array.isArray=="function"?Array.isArray(d):n.call(d)==="[object Array]"},o=function(d){if(!d||n.call(d)!=="[object Object]")return!1;var m=e.call(d,"constructor"),y=d.constructor&&d.constructor.prototype&&e.call(d.constructor.prototype,"isPrototypeOf");if(d.constructor&&!m&&!y)return!1;var x;for(x in d);return typeof x>"u"||e.call(d,x)},c=function(d,m){i&&m.name==="__proto__"?i(d,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):d[m.name]=m.newValue},f=function(d,m){if(m==="__proto__")if(e.call(d,m)){if(l)return l(d,m).value}else return;return d[m]};return kh=function h(){var d,m,y,x,v,w,T=arguments[0],_=1,E=arguments.length,N=!1;for(typeof T=="boolean"&&(N=T,T=arguments[1]||{},_=2),(T==null||typeof T!="object"&&typeof T!="function")&&(T={});_<E;++_)if(d=arguments[_],d!=null)for(m in d)y=f(T,m),x=f(d,m),T!==x&&(N&&x&&(o(x)||(v=s(x)))?(v?(v=!1,w=y&&s(y)?y:[]):w=y&&o(y)?y:{},c(T,{name:m,newValue:h(N,w,x)})):typeof x<"u"&&c(T,{name:m,newValue:x}));return T},kh}var W8=J8();const Ah=ka(W8);function dp(e){if(typeof e!="object"||e===null)return!1;const n=Object.getPrototypeOf(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function eM(){const e=[],n={run:i,use:l};return n;function i(...s){let o=-1;const c=s.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);f(null,...s);function f(h,...d){const m=e[++o];let y=-1;if(h){c(h);return}for(;++y<s.length;)(d[y]===null||d[y]===void 0)&&(d[y]=s[y]);s=d,m?tM(m,f)(...d):c(null,...d)}}function l(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),n}}function tM(e,n){let i;return l;function l(...c){const f=e.length>c.length;let h;f&&c.push(s);try{h=e.apply(this,c)}catch(d){const m=d;if(f&&i)throw m;return s(m)}f||(h&&h.then&&typeof h.then=="function"?h.then(o,s):h instanceof Error?s(h):o(h))}function s(c,...f){i||(i=!0,n(c,...f))}function o(c){s(null,c)}}const kr={basename:nM,dirname:rM,extname:iM,join:lM,sep:"/"};function nM(e,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');bo(e);let i=0,l=-1,s=e.length,o;if(n===void 0||n.length===0||n.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(o){i=s+1;break}}else l<0&&(o=!0,l=s+1);return l<0?"":e.slice(i,l)}if(n===e)return"";let c=-1,f=n.length-1;for(;s--;)if(e.codePointAt(s)===47){if(o){i=s+1;break}}else c<0&&(o=!0,c=s+1),f>-1&&(e.codePointAt(s)===n.codePointAt(f--)?f<0&&(l=s):(f=-1,l=c));return i===l?l=c:l<0&&(l=e.length),e.slice(i,l)}function rM(e){if(bo(e),e.length===0)return".";let n=-1,i=e.length,l;for(;--i;)if(e.codePointAt(i)===47){if(l){n=i;break}}else l||(l=!0);return n<0?e.codePointAt(0)===47?"/":".":n===1&&e.codePointAt(0)===47?"//":e.slice(0,n)}function iM(e){bo(e);let n=e.length,i=-1,l=0,s=-1,o=0,c;for(;n--;){const f=e.codePointAt(n);if(f===47){if(c){l=n+1;break}continue}i<0&&(c=!0,i=n+1),f===46?s<0?s=n:o!==1&&(o=1):s>-1&&(o=-1)}return s<0||i<0||o===0||o===1&&s===i-1&&s===l+1?"":e.slice(s,i)}function lM(...e){let n=-1,i;for(;++n<e.length;)bo(e[n]),e[n]&&(i=i===void 0?e[n]:i+"/"+e[n]);return i===void 0?".":aM(i)}function aM(e){bo(e);const n=e.codePointAt(0)===47;let i=sM(e,!n);return i.length===0&&!n&&(i="."),i.length>0&&e.codePointAt(e.length-1)===47&&(i+="/"),n?"/"+i:i}function sM(e,n){let i="",l=0,s=-1,o=0,c=-1,f,h;for(;++c<=e.length;){if(c<e.length)f=e.codePointAt(c);else{if(f===47)break;f=47}if(f===47){if(!(s===c-1||o===1))if(s!==c-1&&o===2){if(i.length<2||l!==2||i.codePointAt(i.length-1)!==46||i.codePointAt(i.length-2)!==46){if(i.length>2){if(h=i.lastIndexOf("/"),h!==i.length-1){h<0?(i="",l=0):(i=i.slice(0,h),l=i.length-1-i.lastIndexOf("/")),s=c,o=0;continue}}else if(i.length>0){i="",l=0,s=c,o=0;continue}}n&&(i=i.length>0?i+"/..":"..",l=2)}else i.length>0?i+="/"+e.slice(s+1,c):i=e.slice(s+1,c),l=c-s-1;s=c,o=0}else f===46&&o>-1?o++:o=-1}return i}function bo(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const oM={cwd:uM};function uM(){return"/"}function hp(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function cM(e){if(typeof e=="string")e=new URL(e);else if(!hp(e)){const n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(e.protocol!=="file:"){const n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return fM(e)}function fM(e){if(e.hostname!==""){const l=new TypeError('File URL host must be "localhost" or empty on darwin');throw l.code="ERR_INVALID_FILE_URL_HOST",l}const n=e.pathname;let i=-1;for(;++i<n.length;)if(n.codePointAt(i)===37&&n.codePointAt(i+1)===50){const l=n.codePointAt(i+2);if(l===70||l===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(n)}const Th=["history","path","basename","stem","extname","dirname"];class Lw{constructor(n){let i;n?hp(n)?i={path:n}:typeof n=="string"||dM(n)?i={value:n}:i=n:i={},this.cwd="cwd"in i?"":oM.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let l=-1;for(;++l<Th.length;){const o=Th[l];o in i&&i[o]!==void 0&&i[o]!==null&&(this[o]=o==="history"?[...i[o]]:i[o])}let s;for(s in i)Th.includes(s)||(this[s]=i[s])}get basename(){return typeof this.path=="string"?kr.basename(this.path):void 0}set basename(n){Nh(n,"basename"),_h(n,"basename"),this.path=kr.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?kr.dirname(this.path):void 0}set dirname(n){V1(this.basename,"dirname"),this.path=kr.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?kr.extname(this.path):void 0}set extname(n){if(_h(n,"extname"),V1(this.dirname,"extname"),n){if(n.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(n.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=kr.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){hp(n)&&(n=cM(n)),Nh(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?kr.basename(this.path,this.extname):void 0}set stem(n){Nh(n,"stem"),_h(n,"stem"),this.path=kr.join(this.dirname||"",n+(this.extname||""))}fail(n,i,l){const s=this.message(n,i,l);throw s.fatal=!0,s}info(n,i,l){const s=this.message(n,i,l);return s.fatal=void 0,s}message(n,i,l){const s=new ln(n,i,l);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}}function _h(e,n){if(e&&e.includes(kr.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+kr.sep+"`")}function Nh(e,n){if(!e)throw new Error("`"+n+"` cannot be empty")}function V1(e,n){if(!e)throw new Error("Setting `"+n+"` requires `path` to be set too")}function dM(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const hM=function(e){const l=this.constructor.prototype,s=l[e],o=function(){return s.apply(o,arguments)};return Object.setPrototypeOf(o,l),o},pM={}.hasOwnProperty;class dm extends hM{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=eM()}copy(){const n=new dm;let i=-1;for(;++i<this.attachers.length;){const l=this.attachers[i];n.use(...l)}return n.data(Ah(!0,{},this.namespace)),n}data(n,i){return typeof n=="string"?arguments.length===2?(Oh("data",this.frozen),this.namespace[n]=i,this):pM.call(this.namespace,n)&&this.namespace[n]||void 0:n?(Oh("data",this.frozen),this.namespace=n,this):this.namespace}freeze(){if(this.frozen)return this;const n=this;for(;++this.freezeIndex<this.attachers.length;){const[i,...l]=this.attachers[this.freezeIndex];if(l[0]===!1)continue;l[0]===!0&&(l[0]=void 0);const s=i.call(n,...l);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(n){this.freeze();const i=Uu(n),l=this.parser||this.Parser;return Rh("parse",l),l(String(i),i)}process(n,i){const l=this;return this.freeze(),Rh("process",this.parser||this.Parser),jh("process",this.compiler||this.Compiler),i?s(void 0,i):new Promise(s);function s(o,c){const f=Uu(n),h=l.parse(f);l.run(h,f,function(m,y,x){if(m||!y||!x)return d(m);const v=y,w=l.stringify(v,x);yM(w)?x.value=w:x.result=w,d(m,x)});function d(m,y){m||!y?c(m):o?o(y):i(void 0,y)}}}processSync(n){let i=!1,l;return this.freeze(),Rh("processSync",this.parser||this.Parser),jh("processSync",this.compiler||this.Compiler),this.process(n,s),Y1("processSync","process",i),l;function s(o,c){i=!0,Q1(o),l=c}}run(n,i,l){$1(n),this.freeze();const s=this.transformers;return!l&&typeof i=="function"&&(l=i,i=void 0),l?o(void 0,l):new Promise(o);function o(c,f){const h=Uu(i);s.run(n,h,d);function d(m,y,x){const v=y||n;m?f(m):c?c(v):l(void 0,v,x)}}}runSync(n,i){let l=!1,s;return this.run(n,i,o),Y1("runSync","run",l),s;function o(c,f){Q1(c),s=f,l=!0}}stringify(n,i){this.freeze();const l=Uu(i),s=this.compiler||this.Compiler;return jh("stringify",s),$1(n),s(n,l)}use(n,...i){const l=this.attachers,s=this.namespace;if(Oh("use",this.frozen),n!=null)if(typeof n=="function")h(n,i);else if(typeof n=="object")Array.isArray(n)?f(n):c(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function o(d){if(typeof d=="function")h(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[m,...y]=d;h(m,y)}else c(d);else throw new TypeError("Expected usable value, not `"+d+"`")}function c(d){if(!("plugins"in d)&&!("settings"in d))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");f(d.plugins),d.settings&&(s.settings=Ah(!0,s.settings,d.settings))}function f(d){let m=-1;if(d!=null)if(Array.isArray(d))for(;++m<d.length;){const y=d[m];o(y)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function h(d,m){let y=-1,x=-1;for(;++y<l.length;)if(l[y][0]===d){x=y;break}if(x===-1)l.push([d,...m]);else if(m.length>0){let[v,...w]=m;const T=l[x][1];dp(T)&&dp(v)&&(v=Ah(!0,T,v)),l[x]=[d,v,...w]}}}}const mM=new dm().freeze();function Rh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function jh(e,n){if(typeof n!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Oh(e,n){if(n)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function $1(e){if(!dp(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Y1(e,n,i){if(!i)throw new Error("`"+e+"` finished async. Use `"+n+"` instead")}function Uu(e){return gM(e)?e:new Lw(e)}function gM(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function yM(e){return typeof e=="string"||bM(e)}function bM(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const vM="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",K1=[],G1={allowDangerousHtml:!0},xM=/^(https?|ircs?|mailto|xmpp)$/i,wM=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function SM(e){const n=CM(e),i=EM(e);return kM(n.runSync(n.parse(i),i),e)}function CM(e){const n=e.rehypePlugins||K1,i=e.remarkPlugins||K1,l=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...G1}:G1;return mM().use(f8).use(i).use(Z8,l).use(n)}function EM(e){const n=e.children||"",i=new Lw;return typeof n=="string"&&(i.value=n),i}function kM(e,n){const i=n.allowedElements,l=n.allowElement,s=n.components,o=n.disallowedElements,c=n.skipHtml,f=n.unwrapDisallowed,h=n.urlTransform||AM;for(const m of wM)Object.hasOwn(n,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+vM+m.id,void 0);return Xp(e,d),vD(e,{Fragment:b.Fragment,components:s,ignoreInvalidStyle:!0,jsx:b.jsx,jsxs:b.jsxs,passKeys:!0,passNode:!0});function d(m,y,x){if(m.type==="raw"&&x&&typeof y=="number")return c?x.children.splice(y,1):x.children[y]={type:"text",value:m.value},y;if(m.type==="element"){let v;for(v in Eh)if(Object.hasOwn(Eh,v)&&Object.hasOwn(m.properties,v)){const w=m.properties[v],T=Eh[v];(T===null||T.includes(m.tagName))&&(m.properties[v]=h(String(w||""),v,m))}}if(m.type==="element"){let v=i?!i.includes(m.tagName):o?o.includes(m.tagName):!1;if(!v&&l&&typeof y=="number"&&(v=!l(m,y,x)),v&&x&&typeof y=="number")return f&&m.children?x.children.splice(y,1,...m.children):x.children.splice(y,1),y}}}function AM(e){const n=e.indexOf(":"),i=e.indexOf("?"),l=e.indexOf("#"),s=e.indexOf("/");return n===-1||s!==-1&&n>s||i!==-1&&n>i||l!==-1&&n>l||xM.test(e.slice(0,n))?e:""}const TM=({children:e,...n})=>b.jsx("code",{className:"bg-gray-100 text-gray-600 px-1.5 py-0.5 rounded text-sm font-mono",...n,children:e}),_M=e=>Array.isArray(e)&&typeof e[0]=="string"?e[0]:typeof e=="string"?e:"",NM=({getText:e})=>{const n=async()=>{await navigator.clipboard.writeText(e()),tn.success("Copied!")};return b.jsx("button",{onClick:n,className:"text-xs text-white px-2 py-1 rounded hover:bg-gray-600 cursor-pointer",children:"📋"})},RM=({children:e,className:n,...i})=>{const l=(n==null?void 0:n.replace("language-",""))||"";return b.jsxs("div",{className:"mb-4 not-prose",children:[l&&b.jsxs("div",{className:"bg-gray-800 text-gray-300 px-4 py-2 text-sm font-mono rounded-t-md flex justify-between items-center",children:[b.jsx("span",{children:l}),b.jsx(NM,{getText:()=>_M(e).trim()})]}),b.jsx("pre",{className:`bg-gray-900 text-gray-100 p-4 overflow-x-auto ${l?"rounded-b-md":"rounded-md"}`,...i,children:b.jsx("code",{className:"font-mono text-sm",children:e})})]})},jM={code:({className:e,children:n,...i})=>e?b.jsx(RM,{className:e,...i,children:n}):b.jsx(TM,{...i,children:n}),pre:({children:e})=>b.jsx(b.Fragment,{children:e})},OM=({content:e})=>b.jsx("div",{className:"prose max-w-none",children:b.jsx(SM,{remarkPlugins:[I5],components:jM,children:e})}),DM=`### ⚠️ You are running an outdated local server version.
|
|
266
266
|
|
|
267
|
-
Please update your local server version to **0.0.
|
|
267
|
+
Please update your local server version to **0.0.71**
|
|
268
268
|
|
|
269
269
|
### 🔧 Update Command
|
|
270
270
|
|
|
@@ -281,4 +281,4 @@ dataramen start
|
|
|
281
281
|
\`\`\`
|
|
282
282
|
|
|
283
283
|
Once done, click on the "Check again" button below or refresh the page.
|
|
284
|
-
`,MM=()=>{const{data:e,refetch:n}=tj();return!(e!=null&&e.active)||nj(e.version,"0.0.70")===0?null:b.jsx(rn,{isVisible:!0,onClose:()=>null,children:b.jsxs("div",{children:[b.jsx(OM,{content:DM}),b.jsx("div",{className:"flex justify-end mt-2",children:b.jsx("button",{className:"button primary",onClick:()=>n(),children:"Check again"})})]})})},[LM,zw]=wn(!1),Dh=()=>zw(!1),Uw=()=>zw(!0),zM=({repeatPassword:e,password:n})=>n.length<1?null:n.length<8?b.jsx(cn,{variant:"warning",children:"New password should be at least 8 characters long"}):n!==e?b.jsx(cn,{variant:"warning",children:"Repeat password should match new password"}):null,UM=()=>{const e=LM(),{data:n}=jr(),{mutateAsync:i,isLoading:l}=zk(),s=Wn(),[{password:o,repeatPassword:c},{change:f,touched:h,reset:d}]=co({password:"",repeatPassword:""}),m=()=>{s("/"),ao.logout().then(()=>{Dh()})},y=()=>{i({password:o}).then(()=>{d(),tn.success("Password successfully updated!")})},x=o.length<8||o!==c||l,v=h.includes("password");return b.jsxs(rn,{isVisible:e,onClose:Dh,children:[b.jsx(tr,{onClick:Dh}),b.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[b.jsx(sx,{children:"Account settings"}),b.jsxs("label",{children:[b.jsx("p",{className:"text-xs font-semibold mb-1",children:"Username"}),b.jsx("input",{className:"input w-full",readOnly:!0,disabled:!0,value:n==null?void 0:n.username})]}),b.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[b.jsxs("label",{children:[b.jsx("p",{className:"text-xs font-semibold mb-1",children:"Change password"}),b.jsx("input",{className:"input w-full",type:"password",name:"newPassword",autoComplete:"new-password",value:o,onChange:f("password")})]}),b.jsxs("label",{children:[b.jsx("p",{className:"text-xs font-semibold mb-1",children:"Repeat password"}),b.jsx("input",{className:"input w-full",type:"password",value:c,onChange:f("repeatPassword")})]})]}),v&&b.jsx(zM,{password:o,repeatPassword:c}),b.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[b.jsx("button",{className:"button tertiary",disabled:x,onClick:y,children:"Update password"}),b.jsx("button",{className:"button danger",onClick:m,children:"Log out"})]})]})]})},[BM,Bw]=wn(!1),qw=()=>Bw(!0),X1=()=>Bw(!1),qM=e=>zn({queryKey:["team-users"],queryFn:async()=>{const{data:n}=await st.get("/teams/"+e+"/users");return n.data},enabled:!!e}),HM=()=>er({mutationFn:async({role:e,teamId:n,userId:i})=>(await st.patch("/teams/"+n+"/user-role",{role:e,userId:i}),!0),onSuccess:()=>{mt.invalidateQueries({queryKey:["team-users"]})}}),FM=()=>er({mutationFn:async({teamId:e,userId:n})=>(await st.delete("/teams/"+e,{params:{userId:n}}),!0),onSuccess:()=>{mt.invalidateQueries({queryKey:["team-users"]})}}),PM="_user-entry_8y1kw_2",QM={userEntry:PM},IM=()=>{const e=BM(),{data:n}=jr(),{data:i}=qM(n==null?void 0:n.teamId),{mutate:l,isLoading:s}=Uk(),{mutate:o,isLoading:c}=HM(),{mutate:f,isLoading:h}=FM(),[d,{change:m,reset:y}]=co({password:"",username:""}),x=()=>{l({username:d.username,password:d.password,teamId:(n==null?void 0:n.teamId)||""}),y()},v=(E,N)=>{o({teamId:n.teamId,role:N,userId:E})},w=E=>{ox("Are you sure you want to remove this user?").then(N=>{N&&f({userId:E,teamId:n.teamId})})},T=uo(bn.ADMIN),_=s||c||h;return b.jsxs(rn,{isVisible:e,onClose:X1,backdropClose:!0,children:[b.jsx(tr,{onClick:X1}),b.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[b.jsx(sx,{children:"Manage users"}),Fi(i==null?void 0:i.length,0)&&b.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:i.map(E=>b.jsxs("div",{className:QM.userEntry,children:[b.jsxs("select",{className:"input",value:E.role,disabled:!T||_,onChange:N=>v(E.id,N.currentTarget.value),children:[b.jsx("option",{value:bn.OWNER,children:"Owner"}),b.jsx("option",{value:bn.ADMIN,children:"Admin"}),b.jsx("option",{value:bn.EDITOR,children:"Editor"}),b.jsx("option",{value:bn.READ_ONLY,children:"Reader"})]}),b.jsx("p",{className:"flex-1 mx-2",children:E.name}),T&&b.jsx("button",{className:"p-1 cursor-pointer text-red-500 text-sm",onClick:()=>w(E.id),children:"❌"})]},E.id))}),T&&b.jsxs("div",{className:"mt-4",children:[b.jsx("p",{className:"font-semibold",children:"Create new user"}),b.jsxs("div",{className:"flex flex-col lg:flex-row gap-2 lg:items-center mt-2",children:[b.jsx("input",{className:"input flex-1",onChange:m("username"),value:d.username,placeholder:"Username",disabled:_}),b.jsx("input",{className:"input",onChange:m("password"),value:d.password,type:"password",name:"newPassword",autoComplete:"new-password",placeholder:"Password",disabled:_}),b.jsx("button",{className:"button primary",onClick:x,disabled:_,children:"Create user"})]}),b.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."})]})]})]})},VM=()=>{const[e,n]=k.useState(""),[i,l]=k.useState(""),[s,o]=k.useState(),[c,f]=k.useState(!1),h=Wn(),d=m=>{m.preventDefault(),o(void 0),ao.login({password:i,username:e}).then(()=>{h("/",{replace:!0})}).catch(o)};return b.jsx("div",{className:"page-container bg-(--bg) h-screen",children:b.jsx("div",{className:"page-content items-center",children:b.jsxs("form",{className:"flex flex-col gap-2 w-full lg:w-lg",onSubmit:d,children:[b.jsx("p",{className:"font-semibold text-xl min-w-md",children:"Login"}),s&&b.jsx(cn,{variant:"danger",children:"Failed to login. Please verify your credentials"}),b.jsx("input",{value:e,onChange:m=>n(m.currentTarget.value),className:"input",placeholder:"User name"}),b.jsx("input",{value:i,onChange:m=>l(m.currentTarget.value),className:"input",type:"password",placeholder:"Password"}),b.jsx("button",{type:"submit",className:"button primary",children:"Login"}),c?b.jsxs(cn,{className:"w-full border border-blue-500",children:[b.jsx("p",{children:"If this is your first login, the default credentials are:"}),b.jsxs("ul",{className:"mt-2",children:[b.jsxs("li",{children:["Username: ",b.jsx("strong",{children:"admin"})]}),b.jsxs("li",{children:["Password: ",b.jsx("strong",{children:"admin"})]})]}),b.jsx("p",{className:"mt-2",children:"Please make sure to change the default password to a secure one."})]}):b.jsx("button",{className:"button tertiary",onClick:()=>f(!0),children:"First login?"})]})})})},$M=()=>{const e=Wn(),{pathname:n}=nn(),{data:i,isLoading:l}=rx();k.useEffect(()=>{!i&&!l&&n!==rt.login.path&&e(rt.login.path)},[i,l,e,n])};function YM(){return R_(),ZR(),$M(),b.jsxs(b.Fragment,{children:[b.jsxs(YC,{children:[b.jsx(Bu,{path:rt.home.path,element:b.jsx(UA,{})}),b.jsx(Bu,{path:rt.workbench.path,element:b.jsx(ER,{})}),b.jsx(Bu,{path:rt.login.path,element:b.jsx(VM,{})})]}),b.jsx(kR,{}),b.jsx(ZA,{}),b.jsx(sT,{}),b.jsx(xT,{}),b.jsx(qR,{}),b.jsx(XR,{}),b.jsx(MM,{}),b.jsx(UM,{}),b.jsx(IM,{}),b.jsx(mT,{}),b.jsx(cT,{})]})}const KM="_desktop-layout_187ca_2",GM="_mobile-layout_187ca_2",XM="_nav_187ca_2",ZM="_main_187ca_2",JM="_header_187ca_2",Ea={desktopLayout:KM,mobileLayout:GM,nav:XM,main:ZM,header:JM},WM="_container_eyzr9_2",e9="_menu_eyzr9_2",gc={container:WM,menu:e9},t9=({name:e,id:n,onRename:i,onDelete:l,onOpen:s})=>{const o=cx();return b.jsxs("button",{className:gc.menu,onContextMenu:o.open,onClick:()=>s(n),children:[b.jsx(fx,{handler:o,children:b.jsxs("div",{className:"context-menu-container",children:[b.jsx("button",{onClick:c=>{c.preventDefault(),c.stopPropagation(),o.close(),i(n)},className:"context-menu-item",children:"✏️ Rename"}),b.jsx("button",{onClick:c=>{c.preventDefault(),c.stopPropagation(),o.close(),l(n)},className:"context-menu-item",children:"🗑️ Delete"})]})}),b.jsxs("span",{children:["📖 ",e]})]})},n9=({dataSource:e,index:n})=>{const i=()=>{xa(e.id)};return Jn(n.toString(),()=>{xa(l=>{if(l!==e.id)return e.id})},e.name),b.jsxs("button",{className:gc.menu,onClick:i,children:[b.jsx(Mp,{size:20,type:e.dbType}),b.jsx("p",{className:"truncate flex-1 text-left mx-1.5",children:e.name}),b.jsx("span",{className:"hotkey",children:n})]})},r9=()=>{const e=Wn(),n=nn(),{data:i}=jr(),{data:l}=Ak(i==null?void 0:i.teamId),{data:s}=Tk(i==null?void 0:i.teamId),o=Nc(),c=P_(),f=y=>{ax(y).then(x=>{xl(x.name,Xs(x.opts),!0),n.pathname!==rt.workbench.path&&e(rt.workbench.path)})},h=async y=>{const x=s==null?void 0:s.find(w=>w.id===y),v=await kl("New name?",x==null?void 0:x.name);v&&c.mutate({id:y,payload:{name:v}})},d=y=>{c.mutate({id:y,payload:{isTrash:!0}})},m=y=>{Op(y),n.pathname!==rt.workbench.path&&e(rt.workbench.path)};return b.jsx("div",{className:gc.container,children:b.jsxs("div",{className:"flex-1 overflow-y-auto",children:[Fi(l==null?void 0:l.length,0)&&b.jsxs("div",{className:"mt-4",children:[b.jsx("p",{className:"font-semibold text-sm text-gray-600 mb-2",children:"DATA SOURCES"}),l.map((y,x)=>b.jsx(n9,{dataSource:y,index:x+1},y.id))]}),Fi(s==null?void 0:s.length,0)&&b.jsxs("div",{className:"mt-4",children:[b.jsx("p",{className:"font-semibold text-sm text-gray-600 mb-2",children:"SAVED QUERIES"}),s.map(y=>b.jsx(t9,{onDelete:d,onRename:h,onOpen:f,name:y.name,id:y.id},y.id))]}),Fi(o==null?void 0:o.length,0)&&b.jsxs("div",{className:"mt-4",children:[b.jsx("p",{className:"font-semibold text-sm text-gray-600 mb-2",children:"WORKBENCH TABS"}),o==null?void 0:o.map(y=>b.jsxs("button",{className:gc.menu,onClick:()=>m(y.id),children:["📄 ",y.label]},y.id))]})]})})},i9=()=>{const e=Wn(),{pathname:n}=nn(),{data:i}=jr(),l=()=>{jx(),n!==rt.home.path&&e(rt.home.path)};return b.jsxs("nav",{className:Ea.nav,children:[i&&b.jsxs("div",{className:Ea.header,children:[b.jsx("button",{onClick:l,children:"🏠 Home"}),b.jsxs("button",{onClick:Uw,children:["🪪 ",i.username]}),b.jsx("button",{onClick:qw,children:"👥 Manage users"})]}),b.jsx(r9,{})]})},l9="_root_xc78y_2",a9={root:l9},s9=()=>{const{pathname:e}=nn(),n=Wn(),i=oo("Mobile home workbench"),l=Nc(),s=()=>{e!==rt.home.path&&n(rt.home.path)},o=()=>{l.length<1?i():e!==rt.workbench.path&&n(rt.workbench.path)};return b.jsxs("div",{className:a9.root,children:[b.jsxs("button",{onClick:s,children:[b.jsx("p",{children:"🏠"}),b.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Home"})]}),b.jsxs("button",{onClick:o,children:[b.jsx("p",{children:"🛠️"}),b.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Workbench"})]}),b.jsxs("button",{onClick:Uw,children:[b.jsx("p",{children:"🪪"}),b.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Account"})]}),b.jsxs("button",{onClick:qw,children:[b.jsx("p",{children:"👥"}),b.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Users"})]})]})},o9=({children:e,isLogin:n})=>b.jsxs("div",{className:Ea.desktopLayout,children:[b.jsx(Kp,{id:"default",className:"z-100"}),!n&&b.jsx(i9,{}),b.jsx("main",{className:Ea.main,children:e})]}),u9=({children:e,isLogin:n})=>b.jsxs("div",{className:Ea.mobileLayout,children:[b.jsx("main",{className:Ea.main,children:e}),!n&&b.jsx(s9,{})]}),c9=({children:e})=>{const n=Hp(Oc.laptop),{pathname:i}=nn(),l=i===rt.login.path;return n?b.jsx(o9,{isLogin:l,children:e}):b.jsx(u9,{isLogin:l,children:e})};tC.createRoot(document.getElementById("root")).render(b.jsxs(nt.StrictMode,{children:[b.jsx(Ck,{}),b.jsx(ZE,{client:mt,children:b.jsx(yE,{children:b.jsx(c9,{children:b.jsx(YM,{})})})})]}));
|
|
284
|
+
`,MM=()=>{const{data:e,refetch:n}=tj();return!(e!=null&&e.active)||nj(e.version,"0.0.71")===0?null:b.jsx(rn,{isVisible:!0,onClose:()=>null,children:b.jsxs("div",{children:[b.jsx(OM,{content:DM}),b.jsx("div",{className:"flex justify-end mt-2",children:b.jsx("button",{className:"button primary",onClick:()=>n(),children:"Check again"})})]})})},[LM,zw]=wn(!1),Dh=()=>zw(!1),Uw=()=>zw(!0),zM=({repeatPassword:e,password:n})=>n.length<1?null:n.length<8?b.jsx(cn,{variant:"warning",children:"New password should be at least 8 characters long"}):n!==e?b.jsx(cn,{variant:"warning",children:"Repeat password should match new password"}):null,UM=()=>{const e=LM(),{data:n}=jr(),{mutateAsync:i,isLoading:l}=zk(),s=Wn(),[{password:o,repeatPassword:c},{change:f,touched:h,reset:d}]=co({password:"",repeatPassword:""}),m=()=>{s("/"),ao.logout().then(()=>{Dh()})},y=()=>{i({password:o}).then(()=>{d(),tn.success("Password successfully updated!")})},x=o.length<8||o!==c||l,v=h.includes("password");return b.jsxs(rn,{isVisible:e,onClose:Dh,children:[b.jsx(tr,{onClick:Dh}),b.jsxs("div",{className:"w-full lg:w-lg flex flex-col gap-2",children:[b.jsx(sx,{children:"Account settings"}),b.jsxs("label",{children:[b.jsx("p",{className:"text-xs font-semibold mb-1",children:"Username"}),b.jsx("input",{className:"input w-full",readOnly:!0,disabled:!0,value:n==null?void 0:n.username})]}),b.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[b.jsxs("label",{children:[b.jsx("p",{className:"text-xs font-semibold mb-1",children:"Change password"}),b.jsx("input",{className:"input w-full",type:"password",name:"newPassword",autoComplete:"new-password",value:o,onChange:f("password")})]}),b.jsxs("label",{children:[b.jsx("p",{className:"text-xs font-semibold mb-1",children:"Repeat password"}),b.jsx("input",{className:"input w-full",type:"password",value:c,onChange:f("repeatPassword")})]})]}),v&&b.jsx(zM,{password:o,repeatPassword:c}),b.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[b.jsx("button",{className:"button tertiary",disabled:x,onClick:y,children:"Update password"}),b.jsx("button",{className:"button danger",onClick:m,children:"Log out"})]})]})]})},[BM,Bw]=wn(!1),qw=()=>Bw(!0),X1=()=>Bw(!1),qM=e=>zn({queryKey:["team-users"],queryFn:async()=>{const{data:n}=await st.get("/teams/"+e+"/users");return n.data},enabled:!!e}),HM=()=>er({mutationFn:async({role:e,teamId:n,userId:i})=>(await st.patch("/teams/"+n+"/user-role",{role:e,userId:i}),!0),onSuccess:()=>{mt.invalidateQueries({queryKey:["team-users"]})}}),FM=()=>er({mutationFn:async({teamId:e,userId:n})=>(await st.delete("/teams/"+e,{params:{userId:n}}),!0),onSuccess:()=>{mt.invalidateQueries({queryKey:["team-users"]})}}),PM="_user-entry_8y1kw_2",QM={userEntry:PM},IM=()=>{const e=BM(),{data:n}=jr(),{data:i}=qM(n==null?void 0:n.teamId),{mutate:l,isLoading:s}=Uk(),{mutate:o,isLoading:c}=HM(),{mutate:f,isLoading:h}=FM(),[d,{change:m,reset:y}]=co({password:"",username:""}),x=()=>{l({username:d.username,password:d.password,teamId:(n==null?void 0:n.teamId)||""}),y()},v=(E,N)=>{o({teamId:n.teamId,role:N,userId:E})},w=E=>{ox("Are you sure you want to remove this user?").then(N=>{N&&f({userId:E,teamId:n.teamId})})},T=uo(bn.ADMIN),_=s||c||h;return b.jsxs(rn,{isVisible:e,onClose:X1,backdropClose:!0,children:[b.jsx(tr,{onClick:X1}),b.jsxs("div",{className:"w-full lg:w-lg flex flex-col overflow-hidden",children:[b.jsx(sx,{children:"Manage users"}),Fi(i==null?void 0:i.length,0)&&b.jsx("div",{className:"mt-4 overflow-y-auto flex-1",children:i.map(E=>b.jsxs("div",{className:QM.userEntry,children:[b.jsxs("select",{className:"input",value:E.role,disabled:!T||_,onChange:N=>v(E.id,N.currentTarget.value),children:[b.jsx("option",{value:bn.OWNER,children:"Owner"}),b.jsx("option",{value:bn.ADMIN,children:"Admin"}),b.jsx("option",{value:bn.EDITOR,children:"Editor"}),b.jsx("option",{value:bn.READ_ONLY,children:"Reader"})]}),b.jsx("p",{className:"flex-1 mx-2",children:E.name}),T&&b.jsx("button",{className:"p-1 cursor-pointer text-red-500 text-sm",onClick:()=>w(E.id),children:"❌"})]},E.id))}),T&&b.jsxs("div",{className:"mt-4",children:[b.jsx("p",{className:"font-semibold",children:"Create new user"}),b.jsxs("div",{className:"flex flex-col lg:flex-row gap-2 lg:items-center mt-2",children:[b.jsx("input",{className:"input flex-1",onChange:m("username"),value:d.username,placeholder:"Username",disabled:_}),b.jsx("input",{className:"input",onChange:m("password"),value:d.password,type:"password",name:"newPassword",autoComplete:"new-password",placeholder:"Password",disabled:_}),b.jsx("button",{className:"button primary",onClick:x,disabled:_,children:"Create user"})]}),b.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."})]})]})]})},VM=()=>{const[e,n]=k.useState(""),[i,l]=k.useState(""),[s,o]=k.useState(),[c,f]=k.useState(!1),h=Wn(),d=m=>{m.preventDefault(),o(void 0),ao.login({password:i,username:e}).then(()=>{h("/",{replace:!0})}).catch(o)};return b.jsx("div",{className:"page-container bg-(--bg) h-screen",children:b.jsx("div",{className:"page-content items-center",children:b.jsxs("form",{className:"flex flex-col gap-2 w-full lg:w-lg",onSubmit:d,children:[b.jsx("p",{className:"font-semibold text-xl min-w-md",children:"Login"}),s&&b.jsx(cn,{variant:"danger",children:"Failed to login. Please verify your credentials"}),b.jsx("input",{value:e,onChange:m=>n(m.currentTarget.value),className:"input",placeholder:"User name"}),b.jsx("input",{value:i,onChange:m=>l(m.currentTarget.value),className:"input",type:"password",placeholder:"Password"}),b.jsx("button",{type:"submit",className:"button primary",children:"Login"}),c?b.jsxs(cn,{className:"w-full border border-blue-500",children:[b.jsx("p",{children:"If this is your first login, the default credentials are:"}),b.jsxs("ul",{className:"mt-2",children:[b.jsxs("li",{children:["Username: ",b.jsx("strong",{children:"admin"})]}),b.jsxs("li",{children:["Password: ",b.jsx("strong",{children:"admin"})]})]}),b.jsx("p",{className:"mt-2",children:"Please make sure to change the default password to a secure one."})]}):b.jsx("button",{className:"button tertiary",onClick:()=>f(!0),children:"First login?"})]})})})},$M=()=>{const e=Wn(),{pathname:n}=nn(),{data:i,isLoading:l}=rx();k.useEffect(()=>{!i&&!l&&n!==rt.login.path&&e(rt.login.path)},[i,l,e,n])};function YM(){return R_(),ZR(),$M(),b.jsxs(b.Fragment,{children:[b.jsxs(YC,{children:[b.jsx(Bu,{path:rt.home.path,element:b.jsx(UA,{})}),b.jsx(Bu,{path:rt.workbench.path,element:b.jsx(ER,{})}),b.jsx(Bu,{path:rt.login.path,element:b.jsx(VM,{})})]}),b.jsx(kR,{}),b.jsx(ZA,{}),b.jsx(sT,{}),b.jsx(xT,{}),b.jsx(qR,{}),b.jsx(XR,{}),b.jsx(MM,{}),b.jsx(UM,{}),b.jsx(IM,{}),b.jsx(mT,{}),b.jsx(cT,{})]})}const KM="_desktop-layout_187ca_2",GM="_mobile-layout_187ca_2",XM="_nav_187ca_2",ZM="_main_187ca_2",JM="_header_187ca_2",Ea={desktopLayout:KM,mobileLayout:GM,nav:XM,main:ZM,header:JM},WM="_container_eyzr9_2",e9="_menu_eyzr9_2",gc={container:WM,menu:e9},t9=({name:e,id:n,onRename:i,onDelete:l,onOpen:s})=>{const o=cx();return b.jsxs("button",{className:gc.menu,onContextMenu:o.open,onClick:()=>s(n),children:[b.jsx(fx,{handler:o,children:b.jsxs("div",{className:"context-menu-container",children:[b.jsx("button",{onClick:c=>{c.preventDefault(),c.stopPropagation(),o.close(),i(n)},className:"context-menu-item",children:"✏️ Rename"}),b.jsx("button",{onClick:c=>{c.preventDefault(),c.stopPropagation(),o.close(),l(n)},className:"context-menu-item",children:"🗑️ Delete"})]})}),b.jsxs("span",{children:["📖 ",e]})]})},n9=({dataSource:e,index:n})=>{const i=()=>{xa(e.id)};return Jn(n.toString(),()=>{xa(l=>{if(l!==e.id)return e.id})},e.name),b.jsxs("button",{className:gc.menu,onClick:i,children:[b.jsx(Mp,{size:20,type:e.dbType}),b.jsx("p",{className:"truncate flex-1 text-left mx-1.5",children:e.name}),b.jsx("span",{className:"hotkey",children:n})]})},r9=()=>{const e=Wn(),n=nn(),{data:i}=jr(),{data:l}=Ak(i==null?void 0:i.teamId),{data:s}=Tk(i==null?void 0:i.teamId),o=Nc(),c=P_(),f=y=>{ax(y).then(x=>{xl(x.name,Xs(x.opts),!0),n.pathname!==rt.workbench.path&&e(rt.workbench.path)})},h=async y=>{const x=s==null?void 0:s.find(w=>w.id===y),v=await kl("New name?",x==null?void 0:x.name);v&&c.mutate({id:y,payload:{name:v}})},d=y=>{c.mutate({id:y,payload:{isTrash:!0}})},m=y=>{Op(y),n.pathname!==rt.workbench.path&&e(rt.workbench.path)};return b.jsx("div",{className:gc.container,children:b.jsxs("div",{className:"flex-1 overflow-y-auto",children:[Fi(l==null?void 0:l.length,0)&&b.jsxs("div",{className:"mt-4",children:[b.jsx("p",{className:"font-semibold text-sm text-gray-600 mb-2",children:"DATA SOURCES"}),l.map((y,x)=>b.jsx(n9,{dataSource:y,index:x+1},y.id))]}),Fi(s==null?void 0:s.length,0)&&b.jsxs("div",{className:"mt-4",children:[b.jsx("p",{className:"font-semibold text-sm text-gray-600 mb-2",children:"SAVED QUERIES"}),s.map(y=>b.jsx(t9,{onDelete:d,onRename:h,onOpen:f,name:y.name,id:y.id},y.id))]}),Fi(o==null?void 0:o.length,0)&&b.jsxs("div",{className:"mt-4",children:[b.jsx("p",{className:"font-semibold text-sm text-gray-600 mb-2",children:"WORKBENCH TABS"}),o==null?void 0:o.map(y=>b.jsxs("button",{className:gc.menu,onClick:()=>m(y.id),children:["📄 ",y.label]},y.id))]})]})})},i9=()=>{const e=Wn(),{pathname:n}=nn(),{data:i}=jr(),l=()=>{jx(),n!==rt.home.path&&e(rt.home.path)};return b.jsxs("nav",{className:Ea.nav,children:[i&&b.jsxs("div",{className:Ea.header,children:[b.jsx("button",{onClick:l,children:"🏠 Home"}),b.jsxs("button",{onClick:Uw,children:["🪪 ",i.username]}),b.jsx("button",{onClick:qw,children:"👥 Manage users"})]}),b.jsx(r9,{})]})},l9="_root_xc78y_2",a9={root:l9},s9=()=>{const{pathname:e}=nn(),n=Wn(),i=oo("Mobile home workbench"),l=Nc(),s=()=>{e!==rt.home.path&&n(rt.home.path)},o=()=>{l.length<1?i():e!==rt.workbench.path&&n(rt.workbench.path)};return b.jsxs("div",{className:a9.root,children:[b.jsxs("button",{onClick:s,children:[b.jsx("p",{children:"🏠"}),b.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Home"})]}),b.jsxs("button",{onClick:o,children:[b.jsx("p",{children:"🛠️"}),b.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Workbench"})]}),b.jsxs("button",{onClick:Uw,children:[b.jsx("p",{children:"🪪"}),b.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Account"})]}),b.jsxs("button",{onClick:qw,children:[b.jsx("p",{children:"👥"}),b.jsx("p",{className:"text-xs font-semibold text-gray-600",children:"Users"})]})]})},o9=({children:e,isLogin:n})=>b.jsxs("div",{className:Ea.desktopLayout,children:[b.jsx(Kp,{id:"default",className:"z-100"}),!n&&b.jsx(i9,{}),b.jsx("main",{className:Ea.main,children:e})]}),u9=({children:e,isLogin:n})=>b.jsxs("div",{className:Ea.mobileLayout,children:[b.jsx("main",{className:Ea.main,children:e}),!n&&b.jsx(s9,{})]}),c9=({children:e})=>{const n=Hp(Oc.laptop),{pathname:i}=nn(),l=i===rt.login.path;return n?b.jsx(o9,{isLogin:l,children:e}):b.jsx(u9,{isLogin:l,children:e})};tC.createRoot(document.getElementById("root")).render(b.jsxs(nt.StrictMode,{children:[b.jsx(Ck,{}),b.jsx(ZE,{client:mt,children:b.jsx(yE,{children:b.jsx(c9,{children:b.jsx(YM,{})})})})]}));
|
package/dist/code/web/index.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<title>DataRamen | Lightweight GUI for MySQL & PostgreSQL</title>
|
|
8
8
|
<meta name="description" content="Designed for speed, DataRamen makes navigating MySQL and PostgreSQL data effortless with a clean, high-performance interface." />
|
|
9
9
|
<meta name="robots" content="noindex, nofollow">
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-BW25Buy1.js"></script>
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/index-D0gQqbz6.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
package/dist/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@dataramen/server","version":"0.0.
|
|
1
|
+
{"name":"@dataramen/server","version":"0.0.71","license":"MIT","main":"code/server.js","dependencies":{"@fastify/cors":"^11.0.1","@fastify/static":"^8.2.0","@fastify/cookie":"^11.0.2","dotenv":"^16.5.0","fast-glob":"^3.3.3","fastify":"^5.3.2","mysql2":"^3.14.1","pg":"^8.15.6","sqlite3":"^5.1.7","typeorm":"^0.3.23","bcryptjs":"^3.0.2","jose":"^6.0.12","reflect-metadata":"^0.2.2","qs":"^6.14.0"},"devDependencies":{"fs-extra":"^11.3.0","open":"^10.2.0","yargs":"^18.0.0","yocto-spinner":"^1.0.0"}}
|