@meetploy/emulator 1.46.0 → 1.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dashboard-dist/assets/{main-kA1jYbUI.js → main-CZaQjl0j.js} +1 -1
- package/dist/dashboard-dist/index.html +1 -1
- package/dist/services/dashboard-routes.js +5 -1
- package/dist/services/dashboard-routes.js.map +1 -1
- package/dist/services/email-service.d.ts +13 -0
- package/dist/services/email-service.js +56 -5
- package/dist/services/email-service.js.map +1 -1
- package/dist/services/email-service.spec.js +44 -1
- package/dist/services/email-service.spec.js.map +1 -1
- package/dist/utils/sqlite.js +3 -1
- package/dist/utils/sqlite.js.map +1 -1
- package/package.json +1 -1
|
@@ -343,4 +343,4 @@ Please change the parent <Route path="${D}"> to <Route path="${D==="/"?"*":`${D}
|
|
|
343
343
|
*
|
|
344
344
|
* This source code is licensed under the ISC license.
|
|
345
345
|
* See the LICENSE file in the root directory of this source tree.
|
|
346
|
-
*/const mE=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],pE=$n("x",mE);function gE(a){const l=Math.floor((new Date().getTime()-a.getTime())/1e3);return l<5?"just now":l<60?`${String(l)}s ago`:l<3600?`${String(Math.floor(l/60))}m ago`:l<86400?`${String(Math.floor(l/3600))}h ago`:l<604800?`${String(Math.floor(l/86400))}d ago`:a.toLocaleDateString()}function hd({value:a}){const[l,s]=x.useState(!1);return r.jsx("button",{onClick:o=>{o.stopPropagation(),navigator.clipboard.writeText(a).then(()=>{s(!0),setTimeout(()=>{s(!1)},2e3)}).catch(()=>{const f=document.createElement("textarea");f.value=a,document.body.appendChild(f),f.select();try{document.execCommand("copy")}catch{}document.body.removeChild(f),s(!0),setTimeout(()=>{s(!1)},2e3)})},className:ve("p-1 rounded transition-colors flex-shrink-0",l?"text-green-500":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"),title:l?"Copied!":"Copy to clipboard",children:l?r.jsx(Gx,{className:"w-3 h-3"}):r.jsx(iE,{className:"w-3 h-3"})})}function yn({timestamp:a,className:l,rawValue:s,forceOpen:o=!1}){const[f,d]=x.useState(!1),[,m]=x.useState(0),y=o||f;if(x.useEffect(()=>{const S=setInterval(()=>{m(w=>w+1)},1e3);return()=>{clearInterval(S)}},[]),!a)return null;let p;typeof a=="number"?p=new Date(a<1e10?a*1e3:a):p=new Date(a);const g=p.toISOString(),b=p.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}),j=gE(p);return r.jsxs("div",{className:ve("relative inline-block",l),onMouseEnter:()=>{d(!0)},onMouseLeave:()=>{d(!1)},children:[r.jsx("time",{dateTime:g,className:"cursor-help border-b border-gray-400 dark:border-gray-400 text-gray-700 dark:text-gray-300",children:j}),r.jsx("div",{className:ve("absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-[9999] w-72","transition-all duration-200 ease-out origin-bottom",y?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 translate-y-2 pointer-events-none"),children:r.jsx(Mo,{rounded:"lg",shadow:"lg",className:"p-3 text-xs !bg-white dark:!bg-gray-900 !backdrop-blur-none",children:r.jsxs("div",{className:"space-y-2.5",children:[s!==void 0&&r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold mb-0.5",children:"Raw Value"}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"font-mono text-gray-700 dark:text-gray-200 break-all leading-tight",children:typeof s=="object"?JSON.stringify(s):String(s)}),r.jsx(hd,{value:typeof s=="object"?JSON.stringify(s):String(s)})]})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold mb-0.5",children:"UTC ISO"}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"font-mono text-gray-700 dark:text-gray-200 break-all leading-tight",children:g}),r.jsx(hd,{value:g})]})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold mb-0.5",children:"Local Time"}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"text-gray-700 dark:text-gray-200 leading-tight",children:b}),r.jsx(hd,{value:b})]})]})]})})})]})}function yE(a){return a<1e3?`${a.toFixed(2)}ms`:`${(a/1e3).toFixed(2)}s`}function xE(a){return typeof a!="string"?!1:[/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,/^\d{4}-\d{2}-\d{2}$/].some(l=>l.test(a))}function vE(a){const l=a.toLowerCase();return!!(l.includes("created")||l.includes("date")||l.includes("updated")||a.endsWith("At")||l.endsWith("_at"))}function bE(a,l){for(const s of l){const o=s[a];if(o!=null)return typeof o=="boolean"?"bool":typeof o=="number"&&vE(a)?"date":typeof o=="number"?"number":xE(o)?"date":"string"}return"string"}function Vx({results:a,meta:l,columns:s,error:o,title:f="Results",pageSize:d=25,onExportCsv:m,onExportJson:y,serverPagination:p}){const g=a??[],[b,j]=x.useState(""),[S,w]=x.useState(null),[E,M]=x.useState(new Set),[O,z]=x.useState(1),D=!!p,$=p?Math.floor(p.offset/p.limit)+1:1,_=p?Math.ceil(p.total/p.limit):1,V=x.useMemo(()=>s||(g.length===0?[]:Object.keys(g[0]).map(le=>({key:le,label:le,type:bE(le,g)}))),[s,g]),ae=x.useMemo(()=>b?g.filter(le=>Object.values(le).some(ne=>String(ne).toLowerCase().includes(b.toLowerCase()))):g,[g,b]),Z=x.useMemo(()=>S?[...ae].sort((le,ne)=>{const A=le[S.key],X=ne[S.key];return A==null?1:X==null?-1:A<X?S.direction==="asc"?-1:1:A>X?S.direction==="asc"?1:-1:0}):ae,[ae,S]),q=Math.ceil(Z.length/d),J=x.useMemo(()=>{const le=(O-1)*d;return Z.slice(le,le+d)},[Z,O,d]);x.useMemo(()=>{z(1)},[b,S]);const Q=le=>{w(ne=>(ne==null?void 0:ne.key)===le?ne.direction==="asc"?{key:le,direction:"desc"}:null:{key:le,direction:"asc"})},se=()=>{E.size===J.length?M(new Set):M(new Set(J.map((le,ne)=>ne)))},re=le=>{const ne=new Set(E);ne.has(le)?ne.delete(le):ne.add(le),M(ne)},ue=(le,ne)=>{const A=le[ne.key];if(A==null)return r.jsx("span",{className:"text-xs italic dark:text-gray-600 text-gray-400",children:"NULL"});switch(ne.type??"string"){case"bool":return A===!0?r.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-full dark:bg-white/[0.06] bg-black/[0.04] dark:text-gray-300 text-gray-700",children:r.jsx(Gx,{className:"w-3.5 h-3.5"})}):r.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-full dark:bg-white/[0.06] bg-black/[0.04] dark:text-gray-300 text-gray-700",children:r.jsx(pE,{className:"w-3.5 h-3.5"})});case"date":return r.jsx(yn,{timestamp:A,rawValue:typeof A=="number"?A:void 0});case"number":return r.jsx("span",{className:"text-sm font-mono dark:text-gray-300 text-gray-700",children:typeof A=="number"?A.toLocaleString():JSON.stringify(A)});default:return typeof A=="object"?r.jsx("span",{className:"text-sm font-mono dark:text-gray-300 text-gray-700",children:JSON.stringify(A)}):r.jsx("span",{className:"text-sm dark:text-gray-300 text-gray-700",children:typeof A=="object"?JSON.stringify(A):String(A)})}};return o?r.jsxs(Mo,{rounded:"2xl",shadow:"lg",className:"border-red-500/30 dark:border-red-500/20",children:[r.jsx("div",{className:"p-5 border-b dark:border-white/[0.08] border-gray-200",children:r.jsx("h2",{className:"text-lg font-semibold text-red-500",children:"Query Error"})}),r.jsx("div",{className:"p-5",children:r.jsx("p",{className:"font-mono text-sm text-red-500",children:o})})]}):r.jsxs(Mo,{rounded:"2xl",shadow:"lg",className:"flex flex-col",children:[r.jsxs("div",{className:"p-5 border-b dark:border-white/[0.08] border-gray-200 flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("h2",{className:"text-lg font-semibold dark:text-white text-gray-900",children:f}),l&&r.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-green-500/10 text-green-600 dark:text-green-400 border border-green-500/20",children:yE(l.duration)}),r.jsxs("span",{className:"text-sm dark:text-gray-500 text-gray-500",children:[g.length," row",g.length!==1?"s":""]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"relative group",children:[r.jsx(hE,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 group-focus-within:text-blue-500 transition-colors"}),r.jsx("input",{type:"text",placeholder:"Search results...",value:b,onChange:le=>{j(le.target.value)},className:"pl-9 pr-4 py-2 rounded-lg text-sm bg-gray-100 dark:bg-white/[0.06] border border-transparent focus:bg-white dark:focus:bg-black focus:border-blue-500 focus:ring-1 focus:ring-blue-500 outline-none transition-all w-full sm:w-64 dark:text-white text-gray-900 placeholder-gray-500"})]}),(m??y)&&r.jsxs("div",{className:"flex items-center gap-2 border-l dark:border-white/[0.08] border-gray-200 pl-3 ml-1",children:[m&&r.jsx("button",{onClick:m,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] text-gray-500 dark:text-gray-400 transition-colors",title:"Export CSV",children:r.jsx(oE,{className:"w-4 h-4"})}),y&&r.jsx("button",{onClick:y,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] text-gray-500 dark:text-gray-400 transition-colors",title:"Export JSON",children:r.jsx(rE,{className:"w-4 h-4"})})]})]})]}),r.jsx("div",{className:"overflow-x-auto overflow-y-visible",children:r.jsxs("table",{className:"w-full text-left border-collapse font-mono",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b dark:border-white/[0.08] border-gray-200 bg-gray-50/50 dark:bg-white/[0.02]",children:[r.jsx("th",{className:"p-4 w-12",children:r.jsx("input",{type:"checkbox",checked:E.size===J.length&&J.length>0,onChange:se,className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 bg-transparent"})}),V.map(le=>r.jsx("th",{className:"p-4 text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 cursor-pointer hover:text-blue-500 dark:hover:text-blue-400 transition-colors select-none group",onClick:()=>{Q(le.key)},children:r.jsxs("div",{className:"flex items-center gap-1",children:[le.label,r.jsxs("div",{className:ve("flex flex-col opacity-0 group-hover:opacity-50",(S==null?void 0:S.key)===le.key&&"opacity-100"),children:[r.jsx(aE,{className:ve("w-2 h-2",(S==null?void 0:S.key)===le.key&&S.direction==="asc"&&"text-blue-500")}),r.jsx(Ww,{className:ve("w-2 h-2",(S==null?void 0:S.key)===le.key&&S.direction==="desc"&&"text-blue-500")})]})]})},le.key))]})}),r.jsx("tbody",{className:"divide-y dark:divide-white/[0.04] divide-gray-100",children:J.length>0?J.map((le,ne)=>r.jsxs("tr",{className:ve("group transition-colors",E.has(ne)?"bg-blue-50/50 dark:bg-blue-500/10":"hover:bg-gray-50 dark:hover:bg-white/[0.02]"),children:[r.jsx("td",{className:"p-4",children:r.jsx("input",{type:"checkbox",checked:E.has(ne),onChange:()=>{re(ne)},className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 bg-transparent"})}),V.map(A=>r.jsx("td",{className:"p-4 whitespace-nowrap",children:ue(le,A)},`${String(ne)}-${A.key}`))]},ne)):r.jsx("tr",{children:r.jsx("td",{colSpan:V.length+1,className:"p-8 text-center text-gray-500 dark:text-gray-400",children:b?`No results found matching "${b}"`:"Query executed successfully. No rows returned."})})})]})}),r.jsxs("div",{className:"p-4 border-t dark:border-white/[0.08] border-gray-200 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[r.jsxs("div",{children:[D?r.jsxs(r.Fragment,{children:["Showing"," ",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:p.offset+1}),"-",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:Math.min(p.offset+g.length,p.total)})," ","of"," ",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:p.total})," ","total"]}):r.jsxs(r.Fragment,{children:["Showing"," ",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:J.length})," ","of"," ",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:Z.length})," ","results"]}),E.size>0&&r.jsxs("span",{className:"ml-3 text-blue-500 font-medium",children:[E.size," row",E.size!==1?"s":""," ","selected"]})]}),D&&_>1&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>{p.onPageChange(Math.max(0,p.offset-p.limit))},disabled:$===1,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:r.jsx(a0,{className:"w-4 h-4"})}),r.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(_,5)},(le,ne)=>{let A;return _<=5||$<=3?A=ne+1:$>=_-2?A=_-4+ne:A=$-2+ne,r.jsx("button",{onClick:()=>{p.onPageChange((A-1)*p.limit)},className:ve("px-2.5 py-1 rounded-lg font-medium transition-colors",$===A?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"hover:bg-gray-100 dark:hover:bg-white/[0.06]"),children:A},A)})}),r.jsx("button",{onClick:()=>{p.onPageChange(p.offset+p.limit)},disabled:$===_,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:r.jsx(l0,{className:"w-4 h-4"})})]}),!D&&q>1&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>{z(le=>Math.max(1,le-1))},disabled:O===1,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:r.jsx(a0,{className:"w-4 h-4"})}),r.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(q,5)},(le,ne)=>{let A;return q<=5||O<=3?A=ne+1:O>=q-2?A=q-4+ne:A=O-2+ne,r.jsx("button",{onClick:()=>{z(A)},className:ve("px-2.5 py-1 rounded-lg font-medium transition-colors",O===A?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"hover:bg-gray-100 dark:hover:bg-white/[0.06]"),children:A},A)})}),r.jsx("button",{onClick:()=>{z(le=>Math.min(q,le+1))},disabled:O===q,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:r.jsx(l0,{className:"w-4 h-4"})})]})]})]})}function dh(){return typeof window<"u"}function Ts(a){var l;return(a==null||(l=a.ownerDocument)==null?void 0:l.defaultView)||window}function SE(a){return dh()?a instanceof Element||a instanceof Ts(a).Element:!1}function Lo(a){return dh()?a instanceof HTMLElement||a instanceof Ts(a).HTMLElement:!1}function jE(a){return!dh()||typeof ShadowRoot>"u"?!1:a instanceof ShadowRoot||a instanceof Ts(a).ShadowRoot}function NE(a){return Ts(a).getComputedStyle(a)}const hh={...y2},md=hh.useInsertionEffect,wE=md&&md!==hh.useLayoutEffect?md:a=>a();function qe(a){const l=sa(EE).current;return l.next=a,wE(l.effect),l.trampoline}function EE(){const a={next:void 0,callback:CE,trampoline:(...l)=>{var s;return(s=a.callback)==null?void 0:s.call(a,...l)},effect:()=>{a.callback=a.next}};return a}function CE(){}const TE=()=>{},Ve=typeof document<"u"?x.useLayoutEffect:TE,Xx=x.createContext(void 0);function mh(a=!1){const l=x.useContext(Xx);if(l===void 0&&!a)throw new Error(Ba(16));return l}function ME(a){const{focusableWhenDisabled:l,disabled:s,composite:o=!1,tabIndex:f=0,isNativeButton:d}=a,m=o&&l!==!1,y=o&&l===!1;return{props:x.useMemo(()=>{const g={onKeyDown(b){s&&l&&b.key!=="Tab"&&b.preventDefault()}};return o||(g.tabIndex=f,!d&&s&&(g.tabIndex=l?f:-1)),(d&&(l||m)||!d&&s)&&(g["aria-disabled"]=s),d&&(!l||y)&&(g.disabled=s),g},[o,s,l,m,y,d,f])}}function qd(a){return(a==null?void 0:a.ownerDocument)||document}function So(a,l,{detail:s=0}={}){a.dispatchEvent(new(Ts(a)).PointerEvent("click",{bubbles:!0,cancelable:!0,composed:!0,detail:s,shiftKey:l.shiftKey,ctrlKey:l.ctrlKey,altKey:l.altKey,metaKey:l.metaKey}))}function Uo(a={}){const{disabled:l=!1,focusableWhenDisabled:s,tabIndex:o=0,native:f=!0,composite:d}=a,m=x.useRef(null),y=mh(!0),p=d??y!==void 0,{props:g}=ME({focusableWhenDisabled:s,disabled:l,composite:p,tabIndex:o,isNativeButton:f}),b=x.useCallback(()=>{const w=m.current;pd(w)&&p&&l&&g.disabled===void 0&&w.disabled&&(w.disabled=!1)},[l,g.disabled,p]);Ve(b,[b]);const j=x.useCallback((w={})=>{const{onClick:E,onMouseDown:M,onKeyUp:O,onKeyDown:z,onPointerDown:D,...$}=w;return _o({onClick(_){if(l){_.preventDefault();return}E==null||E(_)},onMouseDown(_){l||M==null||M(_)},onKeyDown(_){if(l||(Co(_),z==null||z(_),_.baseUIHandlerPrevented))return;const V=_.target===_.currentTarget,ae=_.currentTarget,Z=pd(ae),q=!f&&AE(ae),J=V&&(f?Z:!q),Q=_.key==="Enter",se=_.key===" ",re=ae.getAttribute("role"),ue=(re==null?void 0:re.startsWith("menuitem"))||re==="option"||re==="gridcell";if(V&&p&&se){if(_.defaultPrevented&&ue)return;_.preventDefault(),(!f||Z)&&(_.preventBaseUIHandler(),So(ae,_));return}if(!J||f||!se&&!Q){V&&q&&se&&_.preventDefault();return}_.defaultPrevented||(_.preventDefault(),Q&&(_.preventBaseUIHandler(),So(ae,_)))},onKeyUp(_){if(!l){if(Co(_),O==null||O(_),_.target===_.currentTarget&&f&&p&&pd(_.currentTarget)&&_.key===" "){_.preventDefault();return}_.baseUIHandlerPrevented||_.target===_.currentTarget&&!f&&!p&&!_.defaultPrevented&&_.key===" "&&(_.preventBaseUIHandler(),So(_.currentTarget,_))}},onPointerDown(_){if(l){_.preventDefault();return}D==null||D(_)}},f?{type:"button"}:{role:"button"},g,$)},[l,g,p,f]),S=qe(w=>{m.current=w,b()});return{getButtonProps:j,buttonRef:S}}function pd(a){return Lo(a)&&a.tagName==="BUTTON"}function AE(a){return Lo(a)&&a.tagName==="A"&&!!a.href}const RE=x.forwardRef(function(l,s){const{render:o,className:f,disabled:d=!1,focusableWhenDisabled:m=!1,nativeButton:y=!0,style:p,...g}=l,{getButtonProps:b,buttonRef:j}=Uo({disabled:d,focusableWhenDisabled:m,native:y});return qt("button",l,{state:{disabled:d},ref:[s,j],props:[g,b]})}),OE={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},zE={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},kE={disabled:!1,...zE},Kx={valid(a){return a===null?null:a?{"data-valid":""}:{"data-invalid":""}}},DE={invalid:void 0,name:void 0,validityData:{state:OE,errors:[],error:"",value:"",initialValue:null},setValidityData:Zt,disabled:void 0,setTouched:Zt,setDirty:Zt,setFilled:Zt,setFocused:Zt,validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:kE,registerFieldControl:Zt,validation:{getValidationProps:(a,l=Da)=>l,inputRef:{current:null},registeredInputs:new Map,registerInput:Zt,getInputControl:()=>null,commit:async()=>{},change:Zt}},_E=x.createContext(DE);function ph(a=!0){const l=x.useContext(_E);if(l.setValidityData===Zt&&!a)throw new Error(Ba(28));return l}const LE=x.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:Zt,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function $x(){return x.useContext(LE)}let i0=0;function UE(a,l="mui"){const[s,o]=x.useState(a),f=a||s;return x.useEffect(()=>{s==null&&(i0+=1,o(`${l}-${i0}`))},[s,l]),f}const s0=hh.useId;function HE(a,l){if(s0!==void 0){const s=s0();return a??`${l}-${s}`}return UE(a,l)}function ui(a){return HE(a,"base-ui")}const qE=x.createContext({controlId:void 0,registerControlId:Zt,labelId:void 0,setLabelId:Zt,messageIds:[],setMessageIds:Zt,getDescriptionProps:a=>a});function gh(){return x.useContext(qE)}function BE(a,l,s,o=!0,f){const[d,m]=x.useState(),y=ui(f?`${f}-label`:void 0),p=a??l??d;return Ve(()=>{const g=a||l||!o?void 0:QE(s.current,y);d!==g&&m(g)}),p}function QE(a,l){const s=YE(a);if(s)return!s.id&&l&&(s.id=l),s.id||void 0}function YE(a){if(!a)return;const l=a.parentElement;if(l&&l.tagName==="LABEL")return l;const s=a.id;if(s){const f=a.nextElementSibling;if(f&&f.htmlFor===s)return f}const o=a.labels;return o&&o[0]}function Zx(a={}){const{id:l,implicit:s=!1,controlRef:o}=a,{controlId:f,registerControlId:d}=gh(),m=ui(l),y=s?f:void 0,p=sa(()=>Symbol()),g=x.useRef(!1),b=x.useRef(l!=null),j=qe(()=>{!g.current||d===Zt||(g.current=!1,d(p.current,void 0))});return Ve(()=>{if(d===Zt)return;let S;if(s){const w=o==null?void 0:o.current;SE(w)&&w.closest("label")!=null?S=l??null:S=y??m}else if(l!=null)b.current=!0,S=l;else if(b.current)S=m;else{j();return}if(S===void 0){j();return}g.current=!0,d(p.current,S)},[l,o,y,d,s,m,p,j]),x.useEffect(()=>j,[j]),f??m}function GE(){return typeof navigator>"u"?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:VE,platform:XE,maxTouchPoints:RC}=GE(),Fx=VE.toLowerCase();XE.toLowerCase();var _0;const yh=typeof CSS<"u"&&!!((_0=CSS.supports)!=null&&_0.call(CSS,"-webkit-backdrop-filter:none"));!yh&&Fx.includes("firefox");!yh&&Fx.includes("chrom");function Jx(a){var s;let l=a.activeElement;for(;((s=l==null?void 0:l.shadowRoot)==null?void 0:s.activeElement)!=null;)l=l.shadowRoot.activeElement;return l}function xh(a,l){var o;if(!a||!l)return!1;const s=(o=l.getRootNode)==null?void 0:o.call(l);if(a.contains(l))return!0;if(s&&jE(s)){let f=l;for(;f;){if(a===f)return!0;f=f.parentNode||f.host}}return!1}function Bd(a){return"composedPath"in a?a.composedPath()[0]:a.target}function gd(a,l){return l<0||l>=a.length}function KE(a,l){return Or(a.current,{disabledIndices:l})}function $E(a,l){return Or(a.current,{decrement:!0,startingIndex:a.current.length,disabledIndices:l})}function Or(a,{startingIndex:l=-1,decrement:s=!1,disabledIndices:o,amount:f=1}={}){let d=l;do d+=s?-f:f;while(d>=0&&d<=a.length-1&&Qd(a,d,o));return d}function Qd(a,l,s){if(typeof s=="function"?s(l):(s==null?void 0:s.includes(l))??!1)return!0;const f=a[l];return f?!FE(f)||f.matches(":disabled")?!0:!s&&(f.hasAttribute("disabled")||f.getAttribute("aria-disabled")==="true"):!1}function ZE(a){return a.visibility==="hidden"||a.visibility==="collapse"}function FE(a,l=a?NE(a):null){return!a||!a.isConnected||!l||ZE(l)?!1:typeof a.checkVisibility=="function"?a.checkVisibility():l.display!=="none"&&l.display!=="contents"}function Px(a){x.useEffect(a,To)}const Tr=0;class vh{constructor(){pn(this,"currentId",Tr);pn(this,"clear",()=>{this.currentId!==Tr&&(clearTimeout(this.currentId),this.currentId=Tr)});pn(this,"disposeEffect",()=>this.clear)}static create(){return new vh}start(l,s){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Tr,s()},l)}isStarted(){return this.currentId!==Tr}}function Ao(){const a=sa(vh.create).current;return Px(a.disposeEffect),a}const uo=null;class JE{constructor(){pn(this,"callbacks",[]);pn(this,"callbacksCount",0);pn(this,"nextId",1);pn(this,"startId",1);pn(this,"isScheduled",!1);pn(this,"tick",l=>{var f;this.isScheduled=!1;const s=this.callbacks,o=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,o>0)for(let d=0;d<s.length;d+=1)(f=s[d])==null||f.call(s,l)})}request(l){const s=this.nextId;return this.nextId+=1,this.callbacks.push(l),this.callbacksCount+=1,(!this.isScheduled||!1)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),s}cancel(l){const s=l-this.startId;s<0||s>=this.callbacks.length||(this.callbacks[s]=null,this.callbacksCount-=1)}}let oo=new JE;class gn{constructor(){pn(this,"currentId",uo);pn(this,"cancel",()=>{this.currentId!==uo&&(oo.cancel(this.currentId),this.currentId=uo)});pn(this,"disposeEffect",()=>this.cancel)}static create(){return new gn}static request(l){return oo.request(l)}static cancel(l){return oo.cancel(l)}request(l){this.cancel(),this.currentId=oo.request(()=>{this.currentId=uo,l()})}}function PE(){const a=sa(gn.create).current;return Px(a.disposeEffect),a}function IE(a){return a==null?a:"current"in a?a.current:a}function Ix(a,l=!1){const s=PE();return qe((o,f=null)=>{s.cancel();const d=IE(a);if(d==null)return;const m=d,y=()=>{sj.flushSync(o)};if(typeof m.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){o();return}function p(){Promise.all(m.getAnimations().map(g=>g.finished)).then(()=>{f!=null&&f.aborted||y()},()=>{if(f!=null&&f.aborted)return;if(m.getAnimations().some(b=>b.pending||b.playState!=="finished")){p();return}y()})}if(l){const g="data-starting-style";if(!m.hasAttribute(g)){s.request(p);return}const b=new MutationObserver(()=>{m.hasAttribute(g)||(b.disconnect(),p())});b.observe(m,{attributes:!0,attributeFilter:[g]}),f==null||f.addEventListener("abort",()=>b.disconnect(),{once:!0});return}s.request(p)})}function Wx(a){const{enabled:l=!0,open:s,ref:o,onComplete:f}=a,d=qe(f),m=Ix(o,s);x.useEffect(()=>{if(!l)return;const y=new AbortController;return m(d,y.signal),()=>{y.abort()}},[l,s,d,m])}let r0=(function(a){return a.startingStyle="data-starting-style",a.endingStyle="data-ending-style",a})({});const WE={"data-starting-style":""},e3={"data-ending-style":""},bh={transitionStatus(a){return a==="starting"?WE:a==="ending"?e3:null}};function ev(a,l=!1,s=!1){const[o,f]=x.useState(a&&l?"idle":void 0),[d,m]=x.useState(a);return a&&!d&&(m(!0),f("starting")),!a&&d&&o!=="ending"&&!s&&f("ending"),!a&&!d&&o==="ending"&&f(void 0),Ve(()=>{if(!a&&d&&o!=="ending"&&s){const y=gn.request(()=>{f("ending")});return()=>{gn.cancel(y)}}},[a,d,o,s]),Ve(()=>{if(!a||l)return;const y=gn.request(()=>{f(void 0)});return()=>{gn.cancel(y)}},[l,a]),Ve(()=>{if(!a||!l)return;a&&d&&o!=="idle"&&f("starting");const y=gn.request(()=>{f("idle")});return()=>{gn.cancel(y)}},[l,a,d,o]),{mounted:d,setMounted:m,transitionStatus:o}}function Ho({controlled:a,default:l,name:s,state:o="value"}){const{current:f}=x.useRef(a!==void 0),[d,m]=x.useState(l),y=f?a:d,p=x.useCallback(g=>{f||m(g)},[]);return[y,p]}function tv(a,l,s,o,f=!0,d){const{registerFieldControl:m}=ph(),y=sa(()=>Symbol());Ve(()=>{const p=y.current;if(!f){m(p,void 0);return}m(p,{controlRef:a,getValue:o,id:l,name:d,value:s})},[a,f,o,l,d,m,y,s]),Ve(()=>{const p=y.current;return()=>{m(p,void 0)}},[m,y])}const qo="none",t3="trigger-press",n3="disabled",u0="missing",o0="initial";function Ms(a,l,s,o){let f=!1,d=!1;const m=o??Da;return{reason:a,event:l??new Event("base-ui"),cancel(){f=!0},allowPropagation(){d=!0},get isCanceled(){return f},get isPropagationAllowed(){return d},trigger:s,...m}}const a3=x.forwardRef(function(l,s){const{render:o,className:f,id:d,name:m,value:y,disabled:p=!1,onValueChange:g,defaultValue:b,autoFocus:j=!1,style:S,...w}=l,{state:E,name:M,disabled:O,setTouched:z,setDirty:D,validityData:$,setFocused:_,setFilled:V,validationMode:ae,validation:Z}=ph(),{clearErrors:q}=$x(),J=O||p,Q=M??m,se={...E,disabled:J},{labelId:re}=gh(),ue=Zx({id:d});Ve(()=>{var N;const I=y!=null;(N=Z.inputRef.current)!=null&&N.value||I&&y!==""?V(!0):I&&y===""&&V(!1)},[Z.inputRef,V,y]);const le=x.useRef(null);Ve(()=>{j&&le.current===Jx(qd(le.current))&&_(!0)},[j,_]);const[ne]=Ho({controlled:y,default:b,name:"FieldControl",state:"value"}),A=y!==void 0,X=A?ne:void 0,Y=qe(()=>{var I;return(I=Z.inputRef.current)==null?void 0:I.value});return tv(Z.inputRef,ue,X,Y,!J,m),qt("input",l,{ref:[s,le],state:se,props:[{id:ue,disabled:J,name:Q,ref:Z.inputRef,"aria-labelledby":re,autoFocus:j,...A?{value:X}:{defaultValue:b},onChange(I){const N=I.currentTarget.value;g==null||g(N,Ms(qo,I.nativeEvent)),D(N!==($.initialValue??"")),V(N!==""),I.nativeEvent.defaultPrevented||(q(Q),Z.change(N))},onFocus(){_(!0)},onBlur(I){z(!0),_(!1),ae==="onBlur"&&Z.commit(I.currentTarget.value)},onKeyDown(I){I.currentTarget.tagName==="INPUT"&&I.key==="Enter"&&(z(!0),Z.commit(I.currentTarget.value))}},w,I=>Z.getValidationProps(J,I)],stateAttributesMapping:Kx})}),l3=x.forwardRef(function(l,s){return r.jsx(a3,{ref:s,...l})}),nv=x.createContext(void 0);function Bo(){const a=x.useContext(nv);if(a===void 0)throw new Error(Ba(53));return a}const i3=500,Yd=16;function El(a,l,s){if(!a)return 0;const o=getComputedStyle(a),f=`${l}${s==="x"?"Inline":"Block"}`,d=parseFloat(o[`${f}Start`]);return s==="x"&&l==="margin"?d*2:d+parseFloat(o[`${f}End`])}const co="base-ui-disable-scrollbar",av={className:co,getElement(a){return r.jsx("style",{nonce:a,href:co,precedence:"base-ui:low",children:`.${co}{scrollbar-width:none}.${co}::-webkit-scrollbar{display:none}`})}},Wi=a=>l=>l?{[a]:""}:null,Sh={hasOverflowX:Wi("data-has-overflow-x"),hasOverflowY:Wi("data-has-overflow-y"),overflowXStart:Wi("data-overflow-x-start"),overflowXEnd:Wi("data-overflow-x-end"),overflowYStart:Wi("data-overflow-y-start"),overflowYEnd:Wi("data-overflow-y-end"),cornerHidden:()=>null},s3=x.createContext(void 0),r3={disableStyleElements:!1};function u3(){return x.useContext(s3)??r3}const o3={x:0,y:0},c0={width:0,height:0},c3={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},f3={x:!0,y:!0,corner:!0},d3=x.forwardRef(function(l,s){const{render:o,className:f,overflowEdgeThreshold:d,style:m,...y}=l,{xStart:p,xEnd:g,yStart:b,yEnd:j}=h3(d),S=ui(),w=Ao(),E=Ao(),{nonce:M,disableStyleElements:O}=u3(),[z,D]=x.useState(!1),[$,_]=x.useState(!1),[V,ae]=x.useState(!1),[Z,q]=x.useState(!1),[J,Q]=x.useState(!1),[se,re]=x.useState(c0),[ue,le]=x.useState(c0),[ne,A]=x.useState(c3),[X,Y]=x.useState(f3),F=x.useRef(null),I=x.useRef(null),N=x.useRef(null),L=x.useRef(null),K=x.useRef(null),ee=x.useRef(null),ie=x.useRef(null),oe=x.useRef(null),ce=x.useRef(0),ge=x.useRef(0),ye=x.useRef(0),Xe=x.useRef(0),Be=x.useRef("vertical"),tt=x.useRef(o3),ft=x.useRef(null);function Ee(Re){const Ke=Re?ae:_,Je=Re?w:E;Ke(!0),Je.start(i3,()=>{Ke(!1)})}const Nt=qe(Re=>{const Ke=Re.x-tt.current.x,Je=Re.y-tt.current.y;tt.current=Re,Je!==0&&Ee(!0),Ke!==0&&Ee(!1)}),Bt=qe(()=>{const Re=I.current;Re&&ft.current===null&&(ft.current=Re.style.scrollSnapType,Re.style.scrollSnapType="none")}),ci=qe(Re=>{if(Re.button!==0)return;if(oe.current!==null){const rn=Be.current==="vertical"?K.current:ee.current;if(rn!=null&&rn.hasPointerCapture(oe.current))return}oe.current=Re.pointerId,ce.current=Re.clientY,ge.current=Re.clientX,Be.current=Re.currentTarget.getAttribute("data-orientation");const Ke=I.current;Ke&&(ye.current=Ke.scrollTop,Xe.current=Ke.scrollLeft,Bt());const Je=Be.current==="vertical"?K.current:ee.current;Je==null||Je.setPointerCapture(Re.pointerId)}),Ya=qe(Re=>{if(Re.pointerId!==oe.current)return;oe.current=null,(Be.current==="vertical"?ae:_)(!1),ft.current!==null&&(I.current&&(I.current.style.scrollSnapType=ft.current),ft.current=null);const Ke=Be.current==="vertical"?K.current:ee.current;Ke!=null&&Ke.hasPointerCapture(Re.pointerId)&&Ke.releasePointerCapture(Re.pointerId)}),Zn=qe(Re=>{if(Re.pointerId!==oe.current)return;if(Re.buttons%2===0){Ya(Re);return}const Ke=I.current;if(!Ke)return;const Je=Be.current==="vertical",rn=Je?K.current:ee.current,ua=Je?N.current:L.current;if(!rn||!ua)return;const fi=Je?"y":"x",di=El(ua,"padding",fi),Jn=El(rn,"margin",fi),At=Je?rn.offsetHeight:rn.offsetWidth,wt=(Je?ua.offsetHeight:ua.offsetWidth)-At-di-Jn,hi=Je?Re.clientY-ce.current:Re.clientX-ge.current,Rs=wt<=0?0:hi/wt,Os=Je?Ke.scrollHeight:Ke.scrollWidth,Pn=Je?Ke.clientHeight:Ke.clientWidth,ca=(Je?ye.current:Xe.current)+Rs*(Os-Pn);Je?Ke.scrollTop=ca:Ke.scrollLeft=ca,Re.preventDefault(),Ee(Je)});function Fn(Re){q(Re.pointerType==="touch")}function Un(Re){if(Fn(Re),Re.pointerType!=="touch"){const Ke=xh(F.current,Re.target);D(Ke)}}const ra=x.useMemo(()=>({scrolling:$||V,hasOverflowX:!X.x,hasOverflowY:!X.y,overflowXStart:ne.xStart,overflowXEnd:ne.xEnd,overflowYStart:ne.yStart,overflowYEnd:ne.yEnd,cornerHidden:X.corner}),[$,V,X.x,X.y,X.corner,ne]),Al={role:"presentation",onPointerEnter:Un,onPointerMove:Un,onPointerDown:Fn,onPointerLeave(){D(!1)},style:{position:"relative","--scroll-area-corner-height":`${se.height}px`,"--scroll-area-corner-width":`${se.width}px`}},Mt=qt("div",l,{state:ra,ref:[s,F],props:[Al,y],stateAttributesMapping:Sh}),As=x.useMemo(()=>({handlePointerDown:ci,handlePointerMove:Zn,handlePointerUp:Ya,handleScroll:Nt,disableViewportSnap:Bt,cornerSize:se,setCornerSize:re,thumbSize:ue,setThumbSize:le,hasMeasuredScrollbar:J,setHasMeasuredScrollbar:Q,touchModality:Z,cornerRef:ie,scrollingX:$,scrollingY:V,hovering:z,setHovering:D,viewportRef:I,scrollbarYRef:N,scrollbarXRef:L,thumbYRef:K,thumbXRef:ee,rootId:S,hiddenState:X,setHiddenState:Y,overflowEdges:ne,setOverflowEdges:A,viewportState:ra,overflowEdgeThreshold:{xStart:p,xEnd:g,yStart:b,yEnd:j}}),[ci,Zn,Ya,Nt,Bt,se,ue,J,Z,$,V,z,S,X,ne,ra,p,g,b,j]);return r.jsxs(nv.Provider,{value:As,children:[!O&&av.getElement(M),Mt]})});function h3(a){const l=typeof a=="number"?{xStart:a,xEnd:a,yStart:a,yEnd:a}:a;return{xStart:Math.max(0,(l==null?void 0:l.xStart)||0),xEnd:Math.max(0,(l==null?void 0:l.xEnd)||0),yStart:Math.max(0,(l==null?void 0:l.yStart)||0),yEnd:Math.max(0,(l==null?void 0:l.yEnd)||0)}}const m3=x.createContext(void 0),p3=x.createContext(void 0);function jh(){const a=x.useContext(p3);return(a==null?void 0:a.direction)??"ltr"}function lv(a,l=Number.MIN_SAFE_INTEGER,s=Number.MAX_SAFE_INTEGER){return Math.max(l,Math.min(a,s))}const f0=1;function d0(a,l){if(l<=0)return 0;const s=lv(a,0,l),o=s,f=l-s,d=o<=f0,m=f<=f0;return d&&m?o<=f?0:l:d?0:m?l:s}const iv=["--scroll-area-overflow-x-start","--scroll-area-overflow-x-end","--scroll-area-overflow-y-start","--scroll-area-overflow-y-end"];let h0=!1;function g3(){h0||yh||(typeof CSS<"u"&&"registerProperty"in CSS&&iv.forEach(a=>{try{CSS.registerProperty({name:a,syntax:"<length>",inherits:!1,initialValue:"0px"})}catch{}}),h0=!0)}const y3=x.forwardRef(function(l,s){const{render:o,className:f,style:d,...m}=l,{viewportRef:y,scrollbarYRef:p,scrollbarXRef:g,thumbYRef:b,thumbXRef:j,cornerRef:S,cornerSize:w,setCornerSize:E,setThumbSize:M,rootId:O,setHiddenState:z,hiddenState:D,setHasMeasuredScrollbar:$,handleScroll:_,touchModality:V,setHovering:ae,setOverflowEdges:Z,overflowEdgeThreshold:q,viewportState:J}=Bo(),Q=jh(),se=x.useRef(!0),re=x.useRef([NaN,NaN,NaN,NaN]),ue=Ao(),le=Ao(),ne=qe(()=>{const I=y.current,N=p.current,L=g.current,K=b.current,ee=j.current,ie=S.current;if(!I)return;const oe=I.scrollHeight,ce=I.scrollWidth,ge=I.clientHeight,ye=I.clientWidth,Xe=I.scrollTop,Be=I.scrollLeft,tt=re.current,ft=Number.isNaN(tt[0]);if(tt[0]=ge,tt[1]=oe,tt[2]=ye,tt[3]=ce,ft&&$(!0),oe===0||ce===0)return;const Ee=x3(I),Nt=Ee.y,Bt=Ee.x,ci=ye/ce,Ya=ge/oe,Zn=Math.max(0,ce-ye),Fn=Math.max(0,oe-ge);let Un=0,ra=0;Bt||(Un=d0(Q==="rtl"?-Be:Be,Zn),ra=Zn-Un);const Al=Nt?0:d0(Xe,Fn),Mt=Nt?0:Fn-Al,As=Bt?0:ye,Re=Nt?0:ge;let Ke=0,Je=0;!Bt&&!Nt&&(Ke=(N==null?void 0:N.offsetWidth)||0,Je=(L==null?void 0:L.offsetHeight)||0);const rn=w.width===0&&w.height===0,ua=rn?Ke:0,fi=rn?Je:0,di=El(L,"padding","x"),Jn=El(N,"padding","y"),At=El(ee,"margin","x"),xn=El(K,"margin","y"),wt=As-di-At,hi=Re-Jn-xn,Rs=L?Math.min(L.offsetWidth-ua,wt):wt,Os=N?Math.min(N.offsetHeight-fi,hi):hi,Pn=Math.max(Yd,Rs*ci),oa=Math.max(Yd,Os*Ya);if(M(Rt=>fo(Rt,{width:Pn,height:oa})),N&&K){const Rt=N.offsetHeight-oa-Jn-xn,Hn=m0(K,"--scroll-area-thumb-height",Xe,Fn,oe,oa,Rt);K.style.transform=`translate3d(0,${Hn}px,0)`}if(L&&ee){const Rt=L.offsetWidth-Pn-di-At,Hn=Q==="rtl"?-Be:Be,Vr=m0(ee,"--scroll-area-thumb-width",Hn,Zn,ce,Pn,Rt);ee.style.transform=`translate3d(${Q==="rtl"?-Vr:Vr}px,0,0)`}const ca=[Un,ra,Al,Mt];iv.forEach((Rt,Hn)=>{I.style.setProperty(Rt,`${ca[Hn]}px`)}),ie&&E(Rt=>fo(Rt,{width:Ke,height:Je})),z(Rt=>fo(Rt,Ee));const fa={xStart:!Bt&&Un>q.xStart,xEnd:!Bt&&ra>q.xEnd,yStart:!Nt&&Al>q.yStart,yEnd:!Nt&&Mt>q.yEnd};Z(Rt=>fo(Rt,fa))});Ve(()=>{g3()},[]),Ve(()=>{queueMicrotask(ne)},[ne,D,Q,q.xStart,q.xEnd,q.yStart,q.yEnd]),Ve(()=>{var I;(I=y.current)!=null&&I.matches(":hover")&&ae(!0)},[y,ae]),Ve(()=>{const I=y.current;if(typeof ResizeObserver>"u"||!I)return;let N=!1;const L=new ResizeObserver(()=>{if(!N){N=!0;const K=re.current;if(K[0]===I.clientHeight&&K[1]===I.scrollHeight&&K[2]===I.clientWidth&&K[3]===I.scrollWidth)return}ne()});return L.observe(I),le.start(0,()=>{const K=I.getAnimations({subtree:!0});K.length!==0&&Promise.allSettled(K.map(ee=>ee.finished)).then(ne).catch(()=>{})}),()=>{L.disconnect(),le.clear()}},[ne,y,le]);function A(){se.current=!1}const X={role:"presentation",...O&&{"data-id":`${O}-viewport`},tabIndex:D.x&&D.y?-1:0,className:av.className,style:{overflow:"scroll"},onScroll(){y.current&&(ne(),(V||!se.current)&&_({x:y.current.scrollLeft,y:y.current.scrollTop}),ue.start(100,()=>{se.current=!0}))},onWheel:A,onPointerMove:A,onPointerEnter:A,onKeyDown:A},Y=qt("div",l,{ref:[s,y],state:J,props:[X,m],stateAttributesMapping:Sh}),F=x.useMemo(()=>({computeThumbPosition:ne}),[ne]);return r.jsx(m3.Provider,{value:F,children:Y})});function x3(a){const l=a.clientHeight>=a.scrollHeight,s=a.clientWidth>=a.scrollWidth;return{y:l,x:s,corner:l||s}}function fo(a,l){for(const s in l)if(a[s]!==l[s])return l;return a}function m0(a,l,s,o,f,d,m){const y=lv(s,0,o),p=s-y,g=Math.max(Yd,d*f/(f+Math.abs(p)));return a.style.setProperty(l,p?`${g}px`:""),(o?y/o*m:0)+(p>0?d-g:0)}function sv(a,l,s,o){return a.addEventListener(l,s,o),()=>{a.removeEventListener(l,s,o)}}const rv=x.createContext(void 0);function v3(){const a=x.useContext(rv);if(a===void 0)throw new Error(Ba(54));return a}const b3=x.forwardRef(function(l,s){const{render:o,className:f,orientation:d="vertical",keepMounted:m=!1,style:y,...p}=l,{hovering:g,scrollingX:b,scrollingY:j,hiddenState:S,scrollbarYRef:w,scrollbarXRef:E,viewportRef:M,thumbYRef:O,thumbXRef:z,handlePointerDown:D,handlePointerUp:$,handleScroll:_,disableViewportSnap:V,rootId:ae,thumbSize:Z,hasMeasuredScrollbar:q,viewportState:J}=Bo(),Q=d==="vertical",se={...J,hovering:g,scrolling:Q?j:b,orientation:d},re=jh(),ue=!q&&!m,le=Q?S.y:S.x,ne=m||!le;x.useEffect(()=>{if(!ne)return;const Y=M.current,F=Q?w.current:E.current;if(!F)return;function I(N){if(!Y||N.ctrlKey)return;const L=!Q,K=L?"scrollLeft":"scrollTop",ee=L?N.deltaX:N.deltaY;if(ee===0)return;const ie=L?Y.scrollWidth-Y.clientWidth:Y.scrollHeight-Y.clientHeight,oe=L&&re==="rtl"?-ie:0,ce=L&&re==="rtl"?0:ie,ge=Y[K];ge<=oe&&ee<0||ge>=ce&&ee>0||(N.preventDefault(),Y[K]=Math.min(ce,Math.max(oe,ge+ee)),_({x:Y.scrollLeft,y:Y.scrollTop}))}return sv(F,"wheel",I,{passive:!1})},[re,_,Q,E,w,ne,M]);const A={...ae&&{"data-id":`${ae}-scrollbar`},onPointerDown(Y){if(Y.button!==0)return;const F=Bd(Y.nativeEvent),I=Q?O.current:z.current;if(I&&xh(I,F))return;const N=M.current;if(!N)return;const L=Q?w.current:E.current;if(!I||!L)return;const K=Q?"y":"x",ee=El(I,"margin",K),ie=El(L,"padding",K),oe=Q?I.offsetHeight:I.offsetWidth,ce=L.getBoundingClientRect(),ge=Q?Y.clientY-ce.top-oe/2-ie+ee/2:Y.clientX-ce.left-oe/2-ie+ee/2,ye=Q?N.scrollHeight:N.scrollWidth,Xe=Q?N.clientHeight:N.clientWidth,tt=(Q?L.offsetHeight:L.offsetWidth)-oe-ie-ee;if(tt<=0)return;const ft=ge/tt,Ee=ye-Xe;V(),Q?N.scrollTop=ft*Ee:re==="rtl"?N.scrollLeft=-(1-ft)*Ee:N.scrollLeft=ft*Ee,_({x:N.scrollLeft,y:N.scrollTop}),D(Y)},onPointerUp:$,onPointerCancel:$,style:{position:"absolute",touchAction:"none",WebkitUserSelect:"none",userSelect:"none",visibility:ue?"hidden":void 0,...Q?{top:0,bottom:"var(--scroll-area-corner-height)",insetInlineEnd:0,"--scroll-area-thumb-height":`${Z.height}px`}:{insetInlineStart:0,insetInlineEnd:"var(--scroll-area-corner-width)",bottom:0,"--scroll-area-thumb-width":`${Z.width}px`}}},X=qt("div",l,{ref:[s,Q?w:E],state:se,props:[A,p],stateAttributesMapping:Sh});return ne?r.jsx(rv.Provider,{value:d,children:X}):null}),S3=x.forwardRef(function(l,s){const{render:o,className:f,style:d,...m}=l,{thumbYRef:y,thumbXRef:p,handlePointerDown:g,handlePointerMove:b,handlePointerUp:j,scrollingX:S,scrollingY:w,hasMeasuredScrollbar:E}=Bo(),M=v3(),O=M==="vertical";return qt("div",l,{ref:[s,O?y:p],state:{scrolling:O?w:S,orientation:M},props:[{onPointerDown:g,onPointerMove:b,onPointerUp:j,onPointerCancel:j,style:{visibility:E?void 0:"hidden",...O?{height:"var(--scroll-area-thumb-height)"}:{width:"var(--scroll-area-thumb-width)"}}},m]})}),j3=x.forwardRef(function(l,s){const{render:o,className:f,style:d,...m}=l,{cornerRef:y,cornerSize:p,hiddenState:g}=Bo(),b=qt("div",l,{ref:[s,y],props:[{style:{position:"absolute",bottom:0,insetInlineEnd:0,width:p.width,height:p.height}},m]});return g.corner?null:b});function kn({className:a,...l}){return r.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:r.jsx("table",{"data-slot":"table",className:ve("w-full caption-bottom text-sm",a),...l})})}function Dn({className:a,...l}){return r.jsx("thead",{"data-slot":"table-header",className:ve("[&_tr]:border-b",a),...l})}function _n({className:a,...l}){return r.jsx("tbody",{"data-slot":"table-body",className:ve("[&_tr:last-child]:border-0",a),...l})}function ct({className:a,...l}){return r.jsx("tr",{"data-slot":"table-row",className:ve("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",a),...l})}function je({className:a,...l}){return r.jsx("th",{"data-slot":"table-head",className:ve("h-12 px-3 text-left align-middle text-xs font-medium tracking-wider whitespace-nowrap text-muted-foreground uppercase [&:has([role=checkbox])]:pr-0",a),...l})}function Ne({className:a,...l}){return r.jsx("td",{"data-slot":"table-cell",className:ve("p-3 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",a),...l})}const uv=x.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function N3(){return x.useContext(uv)}function ov(a={}){const{guess:l,label:s,metadata:o,textRef:f,index:d}=a,{register:m,unregister:y,subscribeMapChange:p,nextIndexRef:g}=N3(),b=x.useRef(-1),[j,S]=x.useState(d==null&&l?()=>{if(b.current===-1){const O=g.current;g.current+=1,b.current=O}return b.current}:-1),w=d??j,E=x.useRef(null),M=x.useCallback(O=>{const z=E.current;z&&y(z),E.current=O,O&&m(O,{metadata:o??null,index:d??null,label:s,textRef:f})},[d,m,y,o,s,f]);return Ve(()=>{if(d==null)return p(O=>{var D;const z=E.current?(D=O.get(E.current))==null?void 0:D.index:null;z!=null&&S(z)})},[d,p]),{ref:M,index:w}}function w3(a){const l=sa(E3,a).current;return l.next=a,Ve(l.effect),l}function E3(a){const l={current:a,next:a,effect:()=>{l.current=l.next}};return l}const cv={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},C3={...cv,position:"fixed",top:0,left:0},T3={...cv,position:"absolute"},Gd="ArrowUp",Vd="ArrowDown",Xd="ArrowLeft",Kd="ArrowRight",$d="Home",Zd="End",M3=new Set([Gd,Vd,Xd,Kd,$d,Zd]),A3="Shift",R3=[A3,"Control","Alt","Meta"];function O3(a){return Lo(a)&&a.tagName==="INPUT"}function p0(a){return!!(O3(a)&&a.selectionStart!=null||Lo(a)&&a.tagName==="TEXTAREA")}function g0(a,l,s,o){if(!a||!l||!l.scrollTo)return;let f=a.scrollLeft,d=a.scrollTop;const m=a.clientWidth<a.scrollWidth,y=a.clientHeight<a.scrollHeight;if(m&&o!=="vertical"){const p=y0(a,l,"left"),g=ho(a),b=ho(l);s==="ltr"&&(p+l.offsetWidth+b.scrollMarginRight>a.scrollLeft+a.clientWidth-g.scrollPaddingRight?f=p+l.offsetWidth+b.scrollMarginRight-a.clientWidth+g.scrollPaddingRight:p-b.scrollMarginLeft<a.scrollLeft+g.scrollPaddingLeft&&(f=p-b.scrollMarginLeft-g.scrollPaddingLeft)),s==="rtl"&&(p-b.scrollMarginLeft<a.scrollLeft+g.scrollPaddingLeft?f=p-b.scrollMarginLeft-g.scrollPaddingLeft:p+l.offsetWidth+b.scrollMarginRight>a.scrollLeft+a.clientWidth-g.scrollPaddingRight&&(f=p+l.offsetWidth+b.scrollMarginRight-a.clientWidth+g.scrollPaddingRight))}if(y&&o!=="horizontal"){const p=y0(a,l,"top"),g=ho(a),b=ho(l);p-b.scrollMarginTop<a.scrollTop+g.scrollPaddingTop?d=p-b.scrollMarginTop-g.scrollPaddingTop:p+l.offsetHeight+b.scrollMarginBottom>a.scrollTop+a.clientHeight-g.scrollPaddingBottom&&(d=p+l.offsetHeight+b.scrollMarginBottom-a.clientHeight+g.scrollPaddingBottom)}a.scrollTo({left:f,top:d,behavior:"auto"})}function y0(a,l,s){const o=s==="left"?"offsetLeft":"offsetTop";let f=0;for(;l.offsetParent&&(f+=l[o],l.offsetParent!==a);)l=l.offsetParent;return f}function ho(a){const l=getComputedStyle(a);return{scrollMarginTop:parseFloat(l.scrollMarginTop)||0,scrollMarginRight:parseFloat(l.scrollMarginRight)||0,scrollMarginBottom:parseFloat(l.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(l.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(l.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(l.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(l.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(l.scrollPaddingLeft)||0}}function z3(a){return Ax(19)?a:a?"true":void 0}function fv(a){const{children:l,elementsRef:s,labelsRef:o,onMapChange:f}=a,d=qe(f),[,m]=x.useState(!1),y=sa(D3).current,p=sa(k3).current,g=x.useRef(0),b=x.useRef(!0),j=x.useRef([]),S=x.useRef(null),w=qe(()=>{b.current||(b.current=!0,m(V=>!V))}),E=qe((V,ae)=>{p.set(V,ae),w()}),M=qe(V=>{p.delete(V),w()}),O=qe(V=>{const ae=new Map;return s.current.length=0,o&&(o.current.length=0),V.forEach(Z=>{var q,J;ae.set(Z.element,{...Z.registration.metadata??{},index:Z.index}),s.current[Z.index]=Z.element,o&&(o.current[Z.index]=Z.registration.label!==void 0?Z.registration.label:((J=(q=Z.registration.textRef)==null?void 0:q.current)==null?void 0:J.textContent)??Z.element.textContent)}),g.current=s.current.length,ae});function z(V){var q;if((q=S.current)==null||q.disconnect(),S.current=null,typeof MutationObserver!="function"||V.length<2)return;const ae=new MutationObserver(J=>{if(!U3(J))return;let Q=null;for(const se of V)if(se.isConnected){if(Q&&dv(Q,se)>0){ae.disconnect(),w();return}Q=se}});S.current=ae;const Z=new Set;for(let J=1;J<V.length;J+=1){const Q=L3(V[J-1],V[J]);Q&&Z.add(Q)}Z.forEach(J=>ae.observe(J,{childList:!0}))}const D=qe(()=>{const[V,ae]=_3(p),Z=O(V);z(ae),j.current=V,b.current=!1,y.forEach(q=>q(Z)),d(Z)});Ve(()=>(b.current||O(j.current),()=>{s.current=[],o&&(o.current=[])}),[s,o,O]),Ve(()=>{b.current&&D()}),Ve(()=>()=>{var V;(V=S.current)==null||V.disconnect(),b.current=!0},[]);const $=qe(V=>(y.add(V),()=>{y.delete(V)})),_=x.useMemo(()=>({register:E,unregister:M,subscribeMapChange:$,nextIndexRef:g}),[E,M,$,g]);return r.jsx(uv.Provider,{value:_,children:l})}function k3(){return new Map}function D3(){return new Set}function _3(a){const l=new Set,s=[],o=[];a.forEach((d,m)=>{if(!m.isConnected)return;const y=d.index,p={index:y??-1,element:m,registration:d};y===null?o.push(p):y>=0&&(l.add(y),s.push(p))});let f=0;return o.sort((d,m)=>dv(d.element,m.element)),o.forEach(d=>{for(;l.has(f);)f+=1;d.index=f,s.push(d),f+=1}),l.size>0&&s.sort((d,m)=>d.index-m.index),[s,o.map(d=>d.element)]}function L3(a,l){let s=a.parentElement;for(;s&&!s.contains(l);)s=s.parentElement;return s}function U3(a){for(const l of a)for(let s=0;s<l.removedNodes.length;s+=1)if(l.removedNodes[s].isConnected)return!0;return!1}function dv(a,l){return a.compareDocumentPosition(l)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function H3(a,l){const s=x.useRef(a),o=qe(l);Ve(()=>{s.current!==a&&o(s.current),s.current=a},[a,o])}function q3(a={}){const{highlightItemOnHover:l,highlightedIndex:s,onHighlightedIndexChange:o}=mh(),{ref:f,index:d}=ov(a),m=s===d,y=x.useRef(null),p=vs(f,y);return{compositeProps:{tabIndex:m?0:-1,onFocus(){o(d)},onMouseMove(){const b=y.current;if(!l||!b)return;const j=b.hasAttribute("disabled")||b.ariaDisabled==="true";!m&&!j&&b.focus()}},compositeRef:p,index:d}}function B3(a){return a==null||a.hasAttribute("disabled")||a.getAttribute("aria-disabled")==="true"}const hv="data-composite-item-active",Q3=[];function Y3(a){const{loopFocus:l=!0,orientation:s="both",grid:o,onLoop:f,direction:d,highlightedIndex:m,onHighlightedIndexChange:y,rootRef:p,enableHomeAndEndKeys:g=!1,stopEventPropagation:b,disabledIndices:j,modifierKeys:S=Q3}=a,[w,E]=x.useState(0),M=o!=null,O=x.useRef(null),z=vs(O,p),D=x.useRef([]),$=x.useRef(!1),_=m??w,V=qe((Q,se=!1)=>{if((y??E)(Q),se){const re=D.current[Q];g0(O.current,re,d,s)}}),ae=qe(Q=>{var le;if(Q.size===0||$.current)return;$.current=!0;const se=Array.from(Q.keys()),re=se.find(ne=>ne==null?void 0:ne.hasAttribute(hv))??null,ue=re?((le=Q.get(re))==null?void 0:le.index)??-1:-1;if(ue!==-1)V(ue);else if(Qd(se,_,j)){const ne=Or(se,{disabledIndices:j});gd(se,ne)||V(ne)}g0(O.current,re,d,s)});Ve(()=>{if(j==null||m!=null||!$.current)return;const Q=D.current;if(Qd(Q,_,j)){const se=Or(Q,{disabledIndices:j});gd(Q,se)||V(se)}},[j,m,_,D,V]);const Z=qe((Q,se,re)=>f?f(Q,se,re,D):re),q=qe(Q=>{const se=Q.key===$d||Q.key===Zd;if(!M3.has(Q.key)||!g&&se||G3(Q,S)||!O.current)return;const ue=d==="rtl",le=ue?Xd:Kd,ne=ue?Kd:Xd,A=s==="vertical"?Vd:le,X=s==="vertical"?Gd:ne,Y=Bd(Q.nativeEvent);if(Y!=null&&p0(Y)&&!B3(Y)){const ee=Y.selectionStart,ie=Y.selectionEnd,oe=Y.value;if(ee==null||Q.shiftKey||ee!==ie||Q.key!==X&&ee<oe.length||Q.key!==A&&ee>0)return}let F=_;const I=KE(D,j),N=$E(D,j);o!=null&&(F=o({disabledIndices:j,elementsRef:D,event:Q,highlightedIndex:_,loopFocus:l,maxIndex:N,minIndex:I,onLoop:Z,orientation:s,rtl:ue}));const L=s!=="vertical"&&Q.key===le||s!=="horizontal"&&Q.key===Vd,K=s!=="vertical"&&Q.key===ne||s!=="horizontal"&&Q.key===Gd;g&&(Q.key===$d?F=I:Q.key===Zd&&(F=N)),F===_&&(L||K)&&(l&&F===N&&L?(F=I,f&&(F=f(Q,_,F,D))):l&&F===I&&K?(F=N,f&&(F=f(Q,_,F,D))):F=Or(D.current,{startingIndex:F,decrement:K,disabledIndices:j})),F!==_&&!gd(D.current,F)&&(b&&Q.stopPropagation(),(M||se||L||K)&&Q.preventDefault(),V(F,!0),queueMicrotask(()=>{var ee;(ee=D.current[F])==null||ee.focus()}))});return{props:{ref:z,onFocus(Q){const se=O.current,re=Bd(Q.nativeEvent);!se||re==null||!p0(re)||re.setSelectionRange(0,re.value.length)},onKeyDown:q},highlightedIndex:_,onHighlightedIndexChange:V,elementsRef:D,onMapChange:ae,relayKeyboardEvent:q}}function G3(a,l){for(const s of R3)if(!l.includes(s)&&a.getModifierState(s))return!0;return!1}function V3(a){const{render:l,className:s,style:o,refs:f=To,props:d=To,state:m=Da,stateAttributesMapping:y,highlightedIndex:p,onHighlightedIndexChange:g,orientation:b,grid:j,loopFocus:S,onLoop:w,enableHomeAndEndKeys:E,onMapChange:M,stopEventPropagation:O=!0,rootRef:z,disabledIndices:D,modifierKeys:$,highlightItemOnHover:_=!1,tag:V="div",...ae}=a,Z=jh(),{props:q,highlightedIndex:J,onHighlightedIndexChange:Q,elementsRef:se,onMapChange:re,relayKeyboardEvent:ue}=Y3({grid:j,loopFocus:S,onLoop:w,orientation:b,highlightedIndex:p,onHighlightedIndexChange:g,rootRef:z,stopEventPropagation:O,enableHomeAndEndKeys:E,direction:Z,disabledIndices:D,modifierKeys:$}),le=qt(V,a,{state:m,ref:f,props:[q,...d,ae],stateAttributesMapping:y}),ne=x.useMemo(()=>({highlightedIndex:J,onHighlightedIndexChange:Q,highlightItemOnHover:_,relayKeyboardEvent:ue}),[J,Q,_,ue]);return r.jsx(Xx.Provider,{value:ne,children:r.jsx(fv,{elementsRef:se,onMapChange:A=>{M==null||M(A),re(A)},children:le})})}const mv=x.createContext(void 0);function X3(){const a=x.useContext(mv);if(a===void 0)throw new Error(Ba(63));return a}const pv={...Kx,checked(a){return a?{"data-checked":""}:{"data-unchecked":""}}},K3=x.forwardRef(function(l,s){const{checked:o,className:f,defaultChecked:d,"aria-labelledby":m,form:y,id:p,inputRef:g,name:b,nativeButton:j=!1,onCheckedChange:S,readOnly:w=!1,required:E=!1,disabled:M=!1,render:O,uncheckedValue:z,value:D,style:$,..._}=l,{clearErrors:V}=$x(),{state:ae,setTouched:Z,setDirty:q,validityData:J,setFilled:Q,setFocused:se,validationMode:re,disabled:ue,name:le,validation:ne}=ph(),{labelId:A}=gh(),X=ue||M,Y=le??b,F=x.useRef(null),I=vs(F,g,ne.inputRef),N=x.useRef(null),L=ui(),K=Zx({id:p,implicit:!1,controlRef:N}),ee=j?void 0:K,[ie,oe]=Ho({controlled:o,default:!!d,name:"Switch",state:"checked"});tv(N,L,ie,void 0,!X,b),Ve(()=>{F.current&&Q(F.current.checked)},[Q]),H3(ie,()=>{V(Y),q(ie!==J.initialValue),Q(ie),ne.change(ie)});const{getButtonProps:ce,buttonRef:ge}=Uo({disabled:X,native:j}),ye=BE(m,A,F,!j,ee),Xe={id:j?K:L,role:"switch","aria-checked":ie,"aria-readonly":w||void 0,"aria-required":E||void 0,"aria-labelledby":ye,onFocus(){X||se(!0)},onBlur(){const Ee=F.current;!Ee||X||(Z(!0),se(!1),re==="onBlur"&&ne.commit(Ee.checked))},onClick(Ee){if(w||X)return;Ee.preventDefault();const Nt=F.current;Nt&&So(Nt,Ee)}},Be={...ne.getValidationProps(X),checked:ie,disabled:X,form:y,id:ee,name:Y,required:E,style:Y?T3:C3,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:I,onChange(Ee){if(Ee.nativeEvent.defaultPrevented)return;if(w){Ee.preventDefault();return}const Nt=Ee.currentTarget.checked,Bt=Ms(qo,Ee.nativeEvent);S==null||S(Nt,Bt),!Bt.isCanceled&&oe(Nt)},onClick(Ee){Ee.stopPropagation()},onFocus(){var Ee;(Ee=N.current)==null||Ee.focus()},...D!==void 0?{value:D}:Da},tt=x.useMemo(()=>({...ae,checked:ie,disabled:X,readOnly:w,required:E}),[ae,ie,X,w,E]),ft=qt("span",l,{state:tt,ref:[s,N,ge],props:[Xe,_,ce,Ee=>ne.getValidationProps(X,Ee)],stateAttributesMapping:pv});return r.jsxs(mv.Provider,{value:tt,children:[ft,!ie&&Y&&z!==void 0&&r.jsx("input",{type:"hidden",form:y,name:Y,value:z,disabled:X}),r.jsx("input",{...Be,suppressHydrationWarning:!0})]})}),$3=x.forwardRef(function(l,s){const{render:o,className:f,style:d,...m}=l,y=X3();return qt("span",l,{state:y,ref:s,stateAttributesMapping:pv,props:m})}),gv=x.createContext(void 0);function Nh(){const a=x.useContext(gv);if(a===void 0)throw new Error(Ba(64));return a}const Qo={tabActivationDirection:a=>({"data-activation-direction":a})},Z3=x.forwardRef(function(l,s){const{className:o,defaultValue:f=0,onValueChange:d,orientation:m="horizontal",render:y,value:p,style:g,...b}=l,j=l.defaultValue!==void 0,S=x.useRef([]),[w,E]=x.useState(()=>new Map),[M,O]=Ho({controlled:p,default:f,name:"Tabs",state:"value"}),z=p!==void 0,[D,$]=x.useState(()=>new Map),_=x.useRef(void 0),V=x.useCallback(ge=>Fd(D,ge),[D]),[ae,Z]=x.useState(()=>({previousValue:M,tabActivationDirection:"none"})),{previousValue:q,tabActivationDirection:J}=ae;let Q=J,se=!1;q!==M&&(Q=x0(q,M,m,D),se=q!=null&&M!=null&&V(M)==null);const re=se?q:M,ue=q!==re||J!==Q;Ve(()=>{ue&&Z({previousValue:re,tabActivationDirection:Q})},[re,ue,Q]);const le=qe((ge,ye)=>{const Xe=x0(M,ge,m,D);ye.activationDirection=Xe,d==null||d(ge,ye),!ye.isCanceled&&O(ge)}),ne=qe((ge,ye)=>{d==null||d(ge,Ms(ye,void 0,void 0,{activationDirection:"none"}))}),A=qe((ge,ye)=>(E(Xe=>{const Be=new Map(Xe);return Be.set(ge,ye),Be}),()=>{E(Xe=>{if(Xe.get(ge)!==ye)return Xe;const Be=new Map(Xe);return Be.delete(ge),Be})})),X=x.useCallback(ge=>w.get(ge),[w]),Y=x.useCallback(ge=>{for(const ye of D.values())if(ge===ye.value)return ye.id},[D]),F=x.useMemo(()=>({getTabElementBySelectedValue:V,getTabIdByPanelValue:Y,getTabPanelIdByValue:X,onValueChange:le,orientation:m,registerMountedTabPanel:A,setTabMap:$,tabActivationDirection:Q,value:M}),[V,Y,X,le,m,A,$,Q,M]),I=x.useMemo(()=>{for(const ge of D.values())if(ge.value===M)return ge},[D,M]),N=x.useMemo(()=>{for(const ge of D.values())if(!ge.disabled)return ge.value},[D]),L=x.useRef(!j),K=x.useRef(f),ee=x.useRef(j),ie=x.useRef(!1);Ve(()=>{var tt;if(z)return;function ge(ft,Ee){O(ft),Z({previousValue:ft,tabActivationDirection:"none"}),ne(ft,Ee),L.current=!1}if(D.size===0){ie.current&&M!==null&&!((tt=_.current)!=null&&tt.isConnected)&&ge(null,u0);return}ie.current=!0,_.current=D.keys().next().value;const ye=I==null?void 0:I.disabled,Xe=I==null&&M!==null;if(!ye&&M===K.current&&(ee.current=!1),ee.current&&ye&&M===K.current)return;const Be=L.current;if(ye||Xe){const ft=N??null;if(M===ft){L.current=!1;return}let Ee=u0;Be?Ee=o0:ye&&(Ee=n3),ge(ft,Ee);return}Be&&I!=null&&(ne(M,o0),L.current=!1)},[N,z,ne,I,O,D,M]);const ce=qt("div",l,{state:{orientation:m,tabActivationDirection:Q},ref:s,props:b,stateAttributesMapping:Qo});return r.jsx(gv.Provider,{value:F,children:r.jsx(fv,{elementsRef:S,children:ce})})});function Fd(a,l){for(const[s,o]of a.entries())if(l===o.value)return s;return null}function x0(a,l,s,o){if(a==null||l==null)return"none";const[f,d,m]=s==="horizontal"?["left","left","right"]:["top","up","down"],y=Fd(o,a),p=Fd(o,l);if(y==null||p==null)return y!==p&&(typeof a=="number"||typeof a=="string")&&typeof a==typeof l?l>a?m:d:"none";const g=y.getBoundingClientRect()[f],b=p.getBoundingClientRect()[f];return b<g?d:b>g?m:"none"}const yv=x.createContext(void 0);function F3(){const a=x.useContext(yv);if(a===void 0)throw new Error(Ba(65));return a}const J3=x.forwardRef(function(l,s){const{className:o,disabled:f=!1,render:d,value:m,id:y,nativeButton:p=!0,style:g,...b}=l,{value:j,getTabPanelIdByValue:S,onValueChange:w,orientation:E,tabActivationDirection:M}=Nh(),{activateOnFocus:O,registerTabResizeObserverElement:z,tabsListElement:D}=F3(),{highlightedIndex:$,onHighlightedIndexChange:_}=mh(),V=ui(y),ae=x.useMemo(()=>({disabled:f,id:V,value:m}),[f,V,m]),{compositeProps:Z,compositeRef:q,index:J}=q3({metadata:ae}),Q=m===j,se=x.useRef(!1),re=x.useRef(null),ue=qe(ie=>{var oe;(oe=re.current)==null||oe.call(re),re.current=ie?z(ie):null});Ve(()=>{if(se.current){se.current=!1;return}if(!(Q&&J>-1&&$!==J))return;const ie=D;if(ie!=null){const oe=Jx(qd(ie));if(oe&&xh(ie,oe))return}f||_(J)},[Q,J,$,_,f,D]);const{getButtonProps:le,buttonRef:ne}=Uo({disabled:f,native:p,focusableWhenDisabled:!0}),A=S(m),X=x.useRef(!1),Y=x.useRef(!1);function F(ie){w(m,Ms(qo,ie.nativeEvent,void 0,{activationDirection:"none"}))}function I(ie){Q||f||F(ie)}function N(ie){Q||f||O&&(!X.current||Y.current)&&F(ie)}function L(ie){if(Q||f)return;X.current=!0,Y.current=ie.button===0;const oe=qd(ie.currentTarget);function ce(){X.current=!1,Y.current=!1,oe.removeEventListener("pointerup",ce),oe.removeEventListener("pointercancel",ce)}oe.addEventListener("pointerup",ce),oe.addEventListener("pointercancel",ce)}return qt("button",l,{state:{disabled:f,active:Q,orientation:E,tabActivationDirection:M},ref:[s,ne,q,ue],props:[Z,{role:"tab","aria-controls":A,"aria-selected":Q,id:V,onClick:I,onFocus:N,onPointerDown:L,[hv]:Q?"":void 0,onKeyDownCapture(){se.current=!0}},b,le],stateAttributesMapping:Qo})}),P3={...Qo,...bh},I3=x.forwardRef(function(l,s){const{className:o,value:f,render:d,keepMounted:m=!1,style:y,...p}=l,{value:g,getTabIdByPanelValue:b,orientation:j,tabActivationDirection:S,registerMountedTabPanel:w}=Nh(),E=ui(),{ref:M,index:O}=ov(),z=f===g,{mounted:D,transitionStatus:$,setMounted:_}=ev(z),V=!D,ae=b(f),Z={hidden:V,orientation:j,tabActivationDirection:S,transitionStatus:$},q=x.useRef(null),J=qt("div",l,{state:Z,ref:[s,M,q],props:[{"aria-labelledby":ae,hidden:V,id:E,role:"tabpanel",tabIndex:z?0:-1,inert:z3(!z),"data-index":O},p],stateAttributesMapping:P3});return Wx({open:z,ref:q,onComplete(){z||_(!1)}}),Ve(()=>{if(!(E==null||V&&!m))return w(f,E)},[V,m,f,E,w]),m||D?J:null}),W3=x.forwardRef(function(l,s){const{activateOnFocus:o=!1,className:f,loopFocus:d=!0,render:m,style:y,...p}=l,{orientation:g,setTabMap:b,tabActivationDirection:j}=Nh(),[S,w]=x.useState(0),[E,M]=x.useState(null),O=x.useRef(new Set),z=x.useRef(new Set),D=x.useRef(null);Ve(()=>{if(typeof ResizeObserver>"u")return;const q=new ResizeObserver(()=>{O.current.forEach(J=>{J()})});return D.current=q,E&&q.observe(E),z.current.forEach(J=>{q.observe(J)}),()=>{q.disconnect(),D.current=null}},[E]);const $=qe(q=>(O.current.add(q),()=>{O.current.delete(q)})),_=qe(q=>{var J;return z.current.add(q),(J=D.current)==null||J.observe(q),()=>{var Q;z.current.delete(q),(Q=D.current)==null||Q.unobserve(q)}}),V={orientation:g,tabActivationDirection:j},ae={"aria-orientation":g==="vertical"?"vertical":void 0,role:"tablist"},Z=x.useMemo(()=>({activateOnFocus:o,registerIndicatorUpdateListener:$,registerTabResizeObserverElement:_,tabsListElement:E}),[o,$,_,E]);return r.jsx(yv.Provider,{value:Z,children:r.jsx(V3,{render:m,className:f,style:y,state:V,refs:[s,M],props:[ae,p],stateAttributesMapping:Qo,highlightedIndex:S,enableHomeAndEndKeys:!0,loopFocus:d,orientation:g,onHighlightedIndexChange:w,onMapChange:b,disabledIndices:To})})});function e4(a){const{open:l,defaultOpen:s,onOpenChange:o,disabled:f}=a,[d,m]=Ho({controlled:l,default:s,name:"Collapsible",state:"open"}),{mounted:y,setMounted:p,transitionStatus:g}=ev(d,!0,!0),b=ui(),[j,S]=x.useState(),w=j===null?void 0:j??b,E=qe(M=>{const O=!d,z=Ms(t3,M.nativeEvent);o(O,z),!z.isCanceled&&m(O)});return x.useMemo(()=>({defaultPanelId:b,disabled:f,handleTrigger:E,mounted:y,open:d,panelId:w,setMounted:p,setOpen:m,setPanelIdState:S,transitionStatus:g}),[b,f,E,y,d,w,p,m,S,g])}const xv=x.createContext(void 0);function vv(){const a=x.useContext(xv);if(a===void 0)throw new Error(Ba(15));return a}let wh=(function(a){return a.open="data-open",a.closed="data-closed",a[a.startingStyle=r0.startingStyle]="startingStyle",a[a.endingStyle=r0.endingStyle]="endingStyle",a})({}),t4=(function(a){return a.panelOpen="data-panel-open",a})({});const n4={[wh.open]:""},a4={[wh.closed]:""},l4={open(a){return a?{[t4.panelOpen]:""}:null}},i4={open(a){return a?n4:a4}},Mr={height:void 0,width:void 0};function s4(a){const{externalRef:l,hiddenUntilFound:s,id:o,keepMounted:f,mounted:d,onOpenChange:m,open:y,setMounted:p,setOpen:g,transitionStatus:b}=a,j=x.useRef(null),S=x.useRef(null),[w,E]=x.useState(Mr),M=x.useRef(Mr),O=x.useRef(!1),z=x.useRef(y),D=x.useRef(!1),[$,_]=x.useState(!1),V=x.useRef(null),ae=vs(l,j),Z=w3(y),q=Ix(j),J=!y&&!d,Q=$?"idle":b,se=y&&(z.current||D.current),re=!y&&d&&S.current==="css-animation"&&w.height===void 0&&w.width===void 0?M.current:w,ue=s&&J&&S.current!=="css-animation",le=qe((F,I=!0)=>{I&&(M.current=F),E(F)}),ne=qe(()=>{var F;(F=V.current)==null||F.call(V),V.current=null}),A=qe(F=>{ne(),V.current=()=>{V.current=null,F()}}),X=qe(()=>{y&&d&&S.current==="css-animation"&&(D.current=!0)});Ve(()=>{!$||b==="starting"||_(!1)},[$,b]),x.useEffect(()=>()=>{X(),ne()},[X,ne]),Ve(()=>{const F=j.current;if(!F)return;!y&&V.current&&ne();const I=r4(F,se);if(S.current=I,y&&b==="idle"&&z.current&&I==="css-animation"){M.current=es(F);return}if(y&&b==="starting"){const K=O.current;if(O.current=!1,I==="none"){le(es(F)),_(!0);return}if(I==="css-transition"){const oe=u4(F);if(le(es(F)),!K)return oe;const ce=mo(F,"transition-duration","0s");return A(ce),_(!0),oe}le(es(F));const ee=mo(F,"animation-name","none");if(!K){ee();return}const ie=mo(F,"animation-duration","0s");ee(),A(ie),_(!0);return}if(!y&&d&&(b==="idle"||b==="starting")){if(z.current=!1,D.current=!1,I==="none"){le(Mr,!1),p(!1);return}le(es(F));return}if(b!=="ending")return;if(I==="none"){p(!1);return}const N=es(F);if(!(N.height>0||N.width>0)){p(!1);return}le(N),I==="css-animation"&&mo(F,"animation-name","none")()},[d,y,ne,le,p,A,se,b]),Wx({enabled:y&&d&&Q==="idle",open:!0,ref:j,onComplete(){y&&le(Mr,!1)}}),x.useEffect(()=>{if(y||!d||Q!=="ending"||!j.current)return;const I=new AbortController;let N=-1;function L(){Z.current||(p(!1),le(Mr,!1))}return N=gn.request(()=>{q(L,I.signal)}),()=>{gn.cancel(N),I.abort()}},[Z,d,y,Q,q,le,p]),Ve(()=>{const F=j.current;!F||!s||!J||F.setAttribute("hidden","until-found")},[J,s]),x.useEffect(function(){const I=j.current;if(!I)return;function N(L){const K=Ms(qo,L);m(!0,K),!K.isCanceled&&(O.current=!0,g(!0))}return sv(I,"beforematch",N)},[m,g]);const Y=f||s||d||y;return{height:re.height,props:{...ue?{[wh.startingStyle]:""}:void 0,hidden:J,id:o},ref:ae,shouldPreventOpenAnimation:se,shouldRender:Y,transitionStatus:Q,width:re.width}}function es(a){return{height:a.scrollHeight,width:a.scrollWidth}}function r4(a,l){const s=Ts(a).getComputedStyle(a),o=(s.animationName.split(",").map(d=>d.trim()).some(d=>d!==""&&d!=="none")||l)&&v0(s.animationDuration),f=v0(s.transitionDuration);return o&&f||f?"css-transition":o?"css-animation":"none"}function v0(a){return a.split(",").map(l=>l.trim()).some(l=>l!==""&&Number.parseFloat(l)>0)}function mo(a,l,s){const o=a.style.getPropertyValue(l),f=a.style.getPropertyPriority(l);return a.style.setProperty(l,s),()=>{if(o===""){a.style.removeProperty(l);return}a.style.setProperty(l,o,f)}}function u4(a){const l={"justify-content":a.style.justifyContent,"align-items":a.style.alignItems,"align-content":a.style.alignContent,"justify-items":a.style.justifyItems};Object.keys(l).forEach(f=>{a.style.setProperty(f,"initial","important")});function s(){Object.entries(l).forEach(([f,d])=>{if(d===""){a.style.removeProperty(f);return}a.style.setProperty(f,d)})}const o=gn.request(s);return()=>{gn.cancel(o),s()}}const bv={...i4,...bh},o4=x.forwardRef(function(l,s){const{render:o,className:f,defaultOpen:d=!1,disabled:m=!1,onOpenChange:y,open:p,style:g,...b}=l,j=qe(y),S=e4({open:p,defaultOpen:d,onOpenChange:j,disabled:m}),w=x.useMemo(()=>({open:S.open,disabled:S.disabled,transitionStatus:S.transitionStatus}),[S.open,S.disabled,S.transitionStatus]),E=x.useMemo(()=>({...S,onOpenChange:j,state:w}),[S,j,w]),M=qt("div",l,{state:w,ref:s,props:b,stateAttributesMapping:bv});return r.jsx(xv.Provider,{value:E,children:M})}),c4={...l4,...bh},f4=x.forwardRef(function(l,s){const{panelId:o,open:f,handleTrigger:d,state:m,disabled:y}=vv(),{className:p,disabled:g=y,render:b,nativeButton:j=!0,style:S,...w}=l,{getButtonProps:E,buttonRef:M}=Uo({disabled:g,focusableWhenDisabled:!0,native:j});return qt("button",l,{state:m,ref:[s,M],props:[{"aria-controls":f?o:void 0,"aria-expanded":f,onClick:d},w,E],stateAttributesMapping:c4})});let b0=(function(a){return a.collapsiblePanelHeight="--collapsible-panel-height",a.collapsiblePanelWidth="--collapsible-panel-width",a})({});const d4=x.forwardRef(function(l,s){const{className:o,hiddenUntilFound:f,keepMounted:d,render:m,id:y,style:p,...g}=l,{defaultPanelId:b,mounted:j,onOpenChange:S,open:w,setMounted:E,setPanelIdState:M,setOpen:O,state:z,transitionStatus:D}=vv(),$=f??!1,_=d??!1,V=y||void 0,ae=V??b;Ve(()=>(M(X=>V??(X===null?void 0:X)),()=>{M(X=>X===V?null:X)}),[V,M]);const{height:Z,props:q,ref:J,shouldPreventOpenAnimation:Q,shouldRender:se,transitionStatus:re,width:ue}=s4({externalRef:s,hiddenUntilFound:$,id:ae,keepMounted:_,mounted:j,onOpenChange:S,open:w,setMounted:E,setOpen:O,transitionStatus:D}),le={...z,transitionStatus:re},ne=Rx(p,le),A=qt("div",{...l,style:void 0},{state:le,ref:J,props:[q,{style:{[b0.collapsiblePanelHeight]:Z===void 0?"auto":`${Z}px`,[b0.collapsiblePanelWidth]:ue===void 0?"auto":`${ue}px`}},g,ne?{style:ne}:void 0,Q?{style:{animationName:"none"}}:void 0],stateAttributesMapping:bv});return se?A:null});function Sv(a){var l,s,o="";if(typeof a=="string"||typeof a=="number")o+=a;else if(typeof a=="object")if(Array.isArray(a)){var f=a.length;for(l=0;l<f;l++)a[l]&&(s=Sv(a[l]))&&(o&&(o+=" "),o+=s)}else for(s in a)a[s]&&(o&&(o+=" "),o+=s);return o}function h4(){for(var a,l,s=0,o="",f=arguments.length;s<f;s++)(a=arguments[s])&&(l=Sv(a))&&(o&&(o+=" "),o+=l);return o}const S0=a=>typeof a=="boolean"?`${a}`:a===0?"0":a,j0=h4,Eh=(a,l)=>s=>{var o;if((l==null?void 0:l.variants)==null)return j0(a,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:f,defaultVariants:d}=l,m=Object.keys(f).map(g=>{const b=s==null?void 0:s[g],j=d==null?void 0:d[g];if(b===null)return null;const S=S0(b)||S0(j);return f[g][S]}),y=s&&Object.entries(s).reduce((g,b)=>{let[j,S]=b;return S===void 0||(g[j]=S),g},{}),p=l==null||(o=l.compoundVariants)===null||o===void 0?void 0:o.reduce((g,b)=>{let{class:j,className:S,...w}=b;return Object.entries(w).every(E=>{let[M,O]=E;return Array.isArray(O)?O.includes({...d,...y}[M]):{...d,...y}[M]===O})?[...g,j,S]:g},[]);return j0(a,m,p,s==null?void 0:s.class,s==null?void 0:s.className)},m4=Eh("inline-flex w-fit shrink-0 items-center justify-center gap-1.5 overflow-hidden rounded-none border px-2 py-0.5 text-[0.625rem] font-semibold uppercase tracking-widest whitespace-nowrap transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 aria-invalid:border-destructive [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/80",destructive:"border-destructive/20 bg-destructive/10 text-destructive [a&]:hover:bg-destructive/20",outline:"border-border text-foreground [a&]:hover:bg-muted [a&]:hover:text-foreground"}},defaultVariants:{variant:"default"}});function p4({className:a,variant:l="default",render:s,...o}){return uw({defaultTagName:"span",props:_o({className:ve(m4({variant:l}),a)},o),render:s,state:{slot:"badge",variant:l}})}const g4={default:"text-muted-foreground bg-muted border-border",success:"text-emerald-700 bg-emerald-500/10 border-emerald-500/25 dark:text-emerald-400",error:"text-red-700 bg-red-500/10 border-red-500/25 dark:text-red-400",warning:"text-amber-700 bg-amber-500/10 border-amber-500/25 dark:text-amber-400",purple:"text-purple-700 bg-purple-500/10 border-purple-500/25 dark:text-purple-400",blue:"text-blue-700 bg-blue-500/10 border-blue-500/25 dark:text-blue-400",orange:"text-orange-700 bg-orange-500/10 border-orange-500/25 dark:text-orange-400",emerald:"text-emerald-700 bg-emerald-500/10 border-emerald-500/25 dark:text-emerald-400"};function Ml({className:a,icon:l,variant:s="default",children:o,...f}){return r.jsxs("div",{"data-slot":"tag",className:ve("inline-flex items-center gap-1.5 rounded-none border px-2.5 py-1 text-[0.625rem] font-semibold uppercase tracking-widest [&_svg]:h-3 [&_svg]:w-3",g4[s],a),...f,children:[l&&r.jsx("span",{className:"flex-shrink-0",children:l}),r.jsx("span",{className:"leading-none",children:o})]})}const y4=Eh("group/button relative inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-none border border-transparent bg-clip-padding text-xs font-semibold uppercase tracking-widest transition-all outline-none select-none cursor-pointer focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",primary:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",outline:"border-border bg-transparent hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-input/30",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",danger:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",success:"bg-emerald-500/10 text-emerald-700 hover:bg-emerald-500/20 dark:bg-emerald-500/15 dark:text-emerald-400 dark:hover:bg-emerald-500/25",link:"text-primary underline underline-offset-4 hover:underline",icon:"border-border bg-transparent hover:bg-muted hover:text-foreground dark:hover:bg-input/30"},size:{default:"h-10 gap-1.5 px-6 has-data-[icon=inline-end]:pr-4 has-data-[icon=inline-start]:pl-4",xs:"h-7 gap-1 px-3 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3",sm:"h-9 gap-1 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",md:"h-10 gap-1.5 px-6 has-data-[icon=inline-end]:pr-4 has-data-[icon=inline-start]:pl-4",lg:"h-11 gap-1.5 px-8 has-data-[icon=inline-end]:pr-5 has-data-[icon=inline-start]:pl-5",icon:"size-10","icon-xs":"size-7 [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-9","icon-md":"size-10","icon-lg":"size-11"}},defaultVariants:{variant:"default",size:"default"}});function De({className:a,variant:l="default",size:s="default",isLoading:o=!1,children:f,disabled:d,render:m,nativeButton:y,...p}){const g=y??(m===void 0||x.isValidElement(m)&&m.type==="button");return r.jsxs(RE,{"data-slot":"button",className:ve(y4({variant:l,size:s,className:a})),disabled:d===!0||o,render:m,nativeButton:g,...p,children:[o&&r.jsx(fE,{className:"size-3.5 animate-spin"}),f]})}const x4={sm:"h-9 text-xs",md:"h-10 text-sm",lg:"h-11 text-base"};function ls({className:a,label:l,error:s,leftIcon:o,rightContent:f,inputSize:d="md","aria-invalid":m,...y}){const p=!!s||m!==void 0&&m!==!1&&m!=="false";return r.jsxs("div",{className:"w-full",children:[l&&r.jsx("label",{className:"mb-2 block text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:l}),r.jsxs("div",{className:ve("flex items-center gap-2 border border-transparent border-b-input bg-transparent transition-[color,border-color] focus-within:border-b-ring",p&&"border-b-destructive focus-within:border-b-destructive",a),children:[o&&r.jsx(o,{className:"size-3.5 shrink-0 text-muted-foreground"}),r.jsx(l3,{"data-slot":"input","aria-invalid":p||void 0,className:ve("w-full min-w-0 flex-1 border-0 bg-transparent px-0 py-1 outline-none placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50","file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground",x4[d]),...y}),f&&r.jsx("div",{className:"shrink-0",children:f})]}),s&&r.jsx("p",{className:"mt-2 text-xs text-destructive",children:s})]})}function jv({className:a,children:l,...s}){return r.jsxs(d3,{"data-slot":"scroll-area",className:ve("relative",a),...s,children:[r.jsx(y3,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:l}),r.jsx(v4,{}),r.jsx(j3,{})]})}function v4({className:a,orientation:l="vertical",...s}){return r.jsx(b3,{"data-slot":"scroll-area-scrollbar","data-orientation":l,orientation:l,className:ve("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",a),...s,children:r.jsx(S3,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-none bg-border"})})}ve("flex items-center justify-between gap-2 rounded-none border border-border bg-transparent px-3 py-2 text-xs font-semibold uppercase tracking-widest transition-colors","hover:bg-muted focus:outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 data-popup-open:bg-muted");function yd({className:a,size:l="default",...s}){return r.jsx(K3,{"data-slot":"switch","data-size":l,className:ve("peer group/switch relative inline-flex shrink-0 items-center rounded-none border transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 data-[size=default]:h-4.5 data-[size=default]:w-8.25 data-[size=sm]:h-3.5 data-[size=sm]:w-6.25 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-unchecked:border-input/50 data-unchecked:bg-input data-disabled:cursor-not-allowed data-disabled:opacity-50",a),...s,children:r.jsx($3,{"data-slot":"switch-thumb",className:"pointer-events-none block bg-background ring-0 transition-transform group-data-[size=default]/switch:size-3.5 group-data-[size=sm]/switch:size-2.5 data-checked:translate-x-[calc(100%+2px)] dark:data-checked:bg-primary-foreground data-unchecked:translate-x-0.25 dark:data-unchecked:bg-foreground"})})}function Nv({className:a,orientation:l="horizontal",...s}){return r.jsx(Z3,{"data-slot":"tabs","data-orientation":l,className:ve("group/tabs flex gap-2 data-horizontal:flex-col",a),...s})}const b4=Eh("group/tabs-list inline-flex w-fit items-center justify-center p-1 text-muted-foreground group-data-horizontal/tabs:h-10 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function wv({className:a,variant:l="default",...s}){return r.jsx(W3,{"data-slot":"tabs-list","data-variant":l,className:ve(b4({variant:l}),a),...s})}function zr({className:a,...l}){return r.jsx(J3,{"data-slot":"tabs-trigger",className:ve("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-2 border border-transparent px-4 py-1.5 text-xs font-semibold tracking-wider whitespace-nowrap text-foreground/60 uppercase transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start group-data-vertical/tabs:px-4 group-data-vertical/tabs:py-2 hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent","data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground","after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",a),...l})}function kr({className:a,...l}){return r.jsx(I3,{"data-slot":"tabs-content",className:ve("flex-1 text-sm outline-none",a),...l})}function Cl({className:a,...l}){return r.jsx("label",{"data-slot":"label",className:ve("flex items-center gap-2 text-xs font-semibold tracking-wide uppercase select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50 peer-data-[slot=checkbox]:text-sm peer-data-[slot=checkbox]:font-normal peer-data-[slot=checkbox]:tracking-normal peer-data-[slot=checkbox]:normal-case peer-data-[slot=radio-group-item]:text-sm peer-data-[slot=radio-group-item]:font-normal peer-data-[slot=radio-group-item]:tracking-normal peer-data-[slot=radio-group-item]:normal-case peer-data-[slot=switch]:text-sm peer-data-[slot=switch]:font-normal peer-data-[slot=switch]:tracking-normal peer-data-[slot=switch]:normal-case",a),...l})}function S4({className:a,...l}){return r.jsx("textarea",{"data-slot":"textarea",className:ve("flex field-sizing-content min-h-16 w-full resize-none rounded-none border border-transparent border-b-input bg-transparent px-0 py-3 text-base transition-[color,border-color] outline-none placeholder:text-muted-foreground focus-visible:border-b-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-b-destructive md:text-sm dark:aria-invalid:border-b-destructive/50",a),...l})}function Ev({...a}){return r.jsx(o4,{"data-slot":"collapsible",...a})}function Cv({...a}){return r.jsx(f4,{"data-slot":"collapsible-trigger",...a})}function Tv({...a}){return r.jsx(d4,{"data-slot":"collapsible-content",...a})}const j4=["prompt_tokens","completion_tokens","input_tokens","output_tokens","inputTokens","outputTokens","inputTokens.total","outputTokens.total","cost","cost_usd_total","cost_details.total_cost"],N4=new Set(["model","modelId","provider","type","message.model","metadata.used_model","metadata.used_provider","providerMetadata.llmgateway.usedModel","providerMetadata.llmgateway.usedProvider","providerMetadata.llmgateway.provider",...j4.flatMap(a=>["usage","message.usage","providerMetadata.llmgateway.usage","providerMetadata.llmgateway","providerMetadata.gateway"].map(l=>`${l}.${a}`))]),Mv=new Set([...N4].flatMap(a=>{const l=a.split(".");return l.map((s,o)=>l.slice(0,o+1).join("."))}));Mv.add("choices");Mv.add("error");var N0;(function(a){a.STATIC="static",a.DYNAMIC="dynamic"})(N0||(N0={}));var ns;(function(a){a.SMALL="small",a.DEFAULT="default",a.LARGE="large",a.XLARGE="xlarge"})(ns||(ns={}));ns.SMALL+"",ns.DEFAULT+"",ns.LARGE+"",ns.XLARGE+"";var w0;(function(a){a.INFO="info",a.ERROR="error",a.WARNING="warning"})(w0||(w0={}));ve("relative overflow-hidden","dark:bg-[#1a1a1a] bg-white","border dark:border-white/[0.08] border-gray-200","backdrop-blur-xl","rounded-2xl","dark:shadow-[0_8px_32px_rgba(0,0,0,0.4)] shadow-[0_2px_8px_rgba(0,0,0,0.04)]");function w4({column:a,onInsertText:l}){return r.jsxs("button",{onClick:()=>l==null?void 0:l(a.name),className:"flex w-full items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-muted",title:`Click to insert "${a.name}"`,children:[a.primaryKey?r.jsx(yx,{className:"h-3 w-3 shrink-0 text-yellow-500"}):r.jsx(px,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate font-mono",children:a.name}),r.jsxs("span",{className:"ml-auto truncate text-muted-foreground",children:[a.type,a.notNull&&!a.primaryKey&&" NOT NULL"]})]})}function E4({table:a,onInsertText:l}){const[s,o]=x.useState(!1);return r.jsxs(Ev,{open:s,onOpenChange:o,children:[r.jsxs(Cv,{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm hover:bg-muted",children:[s?r.jsx(mx,{className:"h-4 w-4 shrink-0"}):r.jsx(si,{className:"h-4 w-4 shrink-0"}),r.jsx(ko,{className:"h-4 w-4 shrink-0 text-blue-500"}),r.jsx("span",{className:"truncate font-medium cursor-pointer",onClick:f=>{f.stopPropagation(),l==null||l(a.name)},title:`Click to insert "${a.name}"`,children:a.name}),r.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[a.columns.length," cols"]})]}),r.jsx(Tv,{children:r.jsx("div",{className:"ml-4 border-l pl-2",children:a.columns.map(f=>r.jsx(w4,{column:f,onInsertText:l},f.name))})})]})}function C4({onInsertText:a}){const{data:l,isLoading:s,refetch:o}=it({queryKey:["auth-schema"],queryFn:UN,staleTime:3e4}),f=(l==null?void 0:l.tables)||[];return r.jsxs("div",{className:"flex h-full flex-col border-l bg-card",children:[r.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[r.jsx("h3",{className:"text-sm font-semibold",children:"Auth Tables"}),r.jsx(De,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>o(),disabled:s,children:r.jsx(Gr,{className:ve("h-4 w-4",s&&"animate-spin")})})]}),r.jsx(jv,{className:"flex-1",children:r.jsx("div",{className:"p-2",children:s?r.jsx("p",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"Loading schema..."}):f.length===0?r.jsx("p",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No tables found"}):r.jsx("div",{className:"space-y-0.5",children:f.map(d=>r.jsx(E4,{table:d,onInsertText:a},d.name))})})}),r.jsx("div",{className:"border-t px-3 py-2 text-xs text-muted-foreground",children:"Click table/column names to insert"})]})}function T4(a){return a===null?"NULL":a===void 0?"":typeof a=="object"?JSON.stringify(a):String(a)}function M4(a){if(a<60)return`${a} seconds`;if(a<3600)return`${Math.floor(a/60)} minutes`;if(a<86400){const s=Math.floor(a/3600);return`${s} hour${s>1?"s":""}`}const l=Math.floor(a/86400);return`${l} day${l>1?"s":""}`}function A4({settings:a,onUpdate:l,isUpdating:s}){const[o,f]=x.useState(a.sessionTokenExpiry.toString()),[d,m]=x.useState(a.allowSignups),[y,p]=x.useState(a.requireEmailVerification),[g,b]=x.useState(a.requireName),j=()=>{l({sessionTokenExpiry:parseInt(o,10),allowSignups:d,requireEmailVerification:y,requireName:g})},S=parseInt(o,10)!==a.sessionTokenExpiry||d!==a.allowSignups||y!==a.requireEmailVerification||g!==a.requireName;return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Cl,{htmlFor:"sessionTokenExpiry",children:"Session Token Expiry (seconds)"}),r.jsx(ls,{id:"sessionTokenExpiry",type:"number",min:3600,max:7776e3,value:o,onChange:w=>f(w.target.value)}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Current: ",M4(parseInt(o,10)||0)," (min: 1 hour, max: 90 days)"]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Cl,{children:"Allow Signups"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Allow new users to create accounts"})]}),r.jsx(yd,{checked:d,onCheckedChange:m})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Cl,{children:"Require Email Verification"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Users must verify their email before accessing the app"})]}),r.jsx(yd,{checked:y,onCheckedChange:p})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Cl,{children:"Require Name"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Require users to enter their name during sign up"})]}),r.jsx(yd,{checked:g,onCheckedChange:b})]})]}),r.jsx("div",{className:"flex justify-end",children:r.jsx(De,{onClick:j,disabled:!S||s,children:s?"Saving...":"Save Settings"})})]})}function R4(){var ue,le,ne,A,X,Y;const a=Ss(),[l,s]=x.useState("settings"),[o,f]=x.useState(""),[d,m]=x.useState(null),[y,p]=x.useState(null),[g,b]=x.useState(null),[j,S]=x.useState(0),w=50,M=((le=(ue=it({queryKey:["config"],queryFn:Do,staleTime:6e4}).data)==null?void 0:ue.auth)==null?void 0:le.binding)||"AUTH",O=it({queryKey:["auth-settings"],queryFn:qN,staleTime:0}),z=xs({mutationFn:BN,onSuccess:()=>{a.invalidateQueries({queryKey:["auth-settings"]})}}),D=F=>{z.mutate(F)},$=x.useCallback(F=>{f(I=>I+F)},[]),_=xs({mutationFn:F=>HN(F),onSuccess:F=>{m(F),p(null)},onError:F=>{p(F instanceof Error?F.message:"Failed to execute query"),m(null)}}),V=()=>{o.trim()&&_.mutate(o)},ae=it({queryKey:["auth-tables"],queryFn:_N,staleTime:0,gcTime:0}),Z=it({queryKey:["auth-tableData",g,w,j],queryFn:()=>LN(g,w,j),staleTime:0,gcTime:0,enabled:!!g}),q=((ne=ae.data)==null?void 0:ne.tables)||[],J=((A=Z.data)==null?void 0:A.data)||[],Q=((X=Z.data)==null?void 0:X.columns)||[],se=((Y=Z.data)==null?void 0:Y.total)||0,re=F=>{b(F),S(0)};return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsxs("h2",{className:"text-3xl font-bold tracking-tight",children:["Auth: ",M]}),r.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/50 p-4",children:[r.jsx(gx,{className:"h-5 w-5 mt-0.5 text-blue-500 shrink-0"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:"Ploy Auth Database"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"This is the Ploy Auth database containing user accounts and refresh tokens. Password hashes are hidden for security. Only SELECT queries are allowed."})]})]}),r.jsxs(Nv,{value:l,onValueChange:s,children:[r.jsxs(wv,{children:[r.jsxs(zr,{value:"settings",children:[r.jsx(iN,{className:"mr-2 h-4 w-4"}),"Settings"]}),r.jsx(zr,{value:"query",children:"SQL Editor"}),r.jsx(zr,{value:"tables",children:"Tables"})]}),r.jsx(kr,{value:"settings",className:"mt-4",children:r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Auth Settings"}),r.jsx(kt,{children:"Configure authentication settings for local development."})]}),r.jsx(ut,{children:O.isLoading?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(zn,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):O.data?r.jsx(A4,{settings:O.data,onUpdate:D,isUpdating:z.isPending}):r.jsx("p",{className:"text-muted-foreground",children:"Failed to load settings"})})]})}),r.jsx(kr,{value:"query",className:"mt-4",children:r.jsxs("div",{className:"grid grid-cols-1 gap-0 lg:grid-cols-[1fr_280px]",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"SQL Query"}),r.jsx(kt,{children:"Execute read-only SELECT queries against auth tables"})]}),r.jsxs(ut,{className:"space-y-4",children:[r.jsx("textarea",{value:o,onChange:F=>f(F.target.value),onKeyDown:F=>{(F.metaKey||F.ctrlKey)&&F.key==="Enter"&&V()},placeholder:"SELECT * FROM auth_users LIMIT 10;",className:"w-full h-32 p-2 font-mono text-sm border rounded bg-background"}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Press Cmd/Ctrl + Enter to execute (SELECT only)"}),r.jsxs(De,{onClick:V,disabled:_.isPending||!o.trim(),children:[r.jsx(uh,{className:"mr-2 h-4 w-4"}),_.isPending?"Executing...":"Execute"]})]})]})]}),y&&r.jsx(rt,{className:"border-destructive/50",children:r.jsx(ut,{className:"pt-6",children:r.jsx("p",{className:"font-mono text-sm text-destructive",children:y})})}),d&&r.jsx(Vx,{results:d.results,meta:d.meta,error:d.error})]}),r.jsx("div",{className:"hidden h-[500px] lg:block",children:r.jsx(C4,{onInsertText:$})})]})}),r.jsx(kr,{value:"tables",className:"mt-4",children:r.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-4",children:[r.jsxs(rt,{className:"md:col-span-1",children:[r.jsxs(yt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(xt,{className:"text-base",children:"Tables"}),r.jsx(De,{variant:"ghost",size:"icon",onClick:()=>ae.refetch(),className:"h-8 w-8",children:r.jsx(Gr,{className:"h-4 w-4"})})]}),r.jsx(ut,{children:ae.isLoading?r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."}):q.length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:"No tables found"}):r.jsx("div",{className:"space-y-1",children:q.map(F=>r.jsxs("button",{onClick:()=>re(F.name),className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors hover:bg-muted ${g===F.name?"bg-muted font-medium":""}`,children:[r.jsx(ko,{className:"h-4 w-4 shrink-0"}),r.jsx("span",{className:"truncate",children:F.name})]},F.name))})})]}),r.jsxs(rt,{className:"md:col-span-3",children:[r.jsxs(yt,{children:[r.jsx(xt,{children:g||"Select a Table"}),g&&r.jsxs(kt,{children:[se," total rows"]})]}),r.jsx(ut,{children:g?Z.isLoading?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(zn,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):J.length===0?r.jsx("p",{className:"py-8 text-center text-muted-foreground",children:"No data in this table"}):r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"overflow-x-auto rounded-md border",children:r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsx(ct,{children:Q.map(F=>r.jsx(je,{className:"font-mono",children:F},F))})}),r.jsx(_n,{children:J.map((F,I)=>r.jsx(ct,{children:Q.map(N=>r.jsx(Ne,{className:"font-mono text-sm",children:T4(F[N])},N))},I))})]})}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-sm text-muted-foreground",children:["Showing ",j+1," -"," ",Math.min(j+w,se)," of ",se]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",disabled:j===0,onClick:()=>S(Math.max(0,j-w)),children:[r.jsx(Yr,{className:"mr-1 h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",disabled:j+w>=se,onClick:()=>S(j+w),children:["Next",r.jsx(si,{className:"ml-1 h-4 w-4"})]})]})]})]}):r.jsx("p",{className:"py-8 text-center text-muted-foreground",children:"Select a table from the list to view its data"})})]})]})})]})]})})}function Ln(){return r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(zn,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}function sn({children:a}){return r.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:a})}function oi({id:a}){return r.jsxs("span",{className:"font-mono text-xs",children:[a.slice(0,8),"..."]})}function Vt({title:a,value:l,icon:s,isLoading:o}){return r.jsxs(rt,{children:[r.jsxs(yt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(xt,{className:"text-sm font-medium",children:a}),s]}),r.jsx(ut,{children:r.jsx("div",{className:"text-2xl font-bold",children:o?r.jsx(zn,{className:"h-5 w-5 animate-spin"}):l})})]})}function Qa({title:a,children:l}){return r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:a}),l]})}function O4(a){const l='<base target="_blank">';return/<head[^>]*>/i.test(a)?a.replace(/<head[^>]*>/i,s=>`${s}${l}`):`${l}${a}`}function z4({receive:a,inbox:l}){var g,b;const s=Ss(),o=(g=a[0])!=null&&g.startsWith("*@")?`test${a[0].slice(1)}`:a[0]??(l?"inbox@in.ploy.email":""),[f,d]=x.useState({from:"sender@example.com",to:o,subject:"Hello",text:"This is a test email from the Ploy dev dashboard."}),m=xs({mutationFn:VN,onSuccess:async()=>{await s.invalidateQueries({queryKey:["auth-emails"]})}}),y=j=>S=>{d({...f,[j]:S.target.value})},p=(b=m.data)==null?void 0:b.result;return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Send test email"}),r.jsx(kt,{children:"Delivers an email to your worker's email() handler, as if it arrived at an address in email.receive or the project's inbox address. Replies and forwards land in the inbox below."})]}),r.jsx(ut,{children:r.jsxs("form",{className:"grid gap-3 md:grid-cols-2",onSubmit:j=>{j.preventDefault(),m.mutate(f)},children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Cl,{htmlFor:"test-email-from",children:"From"}),r.jsx(ls,{id:"test-email-from",value:f.from,onChange:y("from")})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Cl,{htmlFor:"test-email-to",children:"To"}),r.jsx(ls,{id:"test-email-to",value:f.to,onChange:y("to")})]}),r.jsxs("div",{className:"space-y-1 md:col-span-2",children:[r.jsx(Cl,{htmlFor:"test-email-subject",children:"Subject"}),r.jsx(ls,{id:"test-email-subject",value:f.subject,onChange:y("subject")})]}),r.jsxs("div",{className:"space-y-1 md:col-span-2",children:[r.jsx(Cl,{htmlFor:"test-email-text",children:"Text"}),r.jsx(S4,{id:"test-email-text",rows:3,value:f.text,onChange:y("text")})]}),r.jsxs("div",{className:"flex items-center gap-3 md:col-span-2",children:[r.jsxs(De,{type:"submit",size:"sm",disabled:m.isPending,children:[r.jsx(aN,{className:"mr-2 h-4 w-4"}),"Send"]}),r.jsx("span",{className:"text-sm text-muted-foreground",children:m.error?m.error.message:p!=null&&p.rejected?`Rejected: ${p.rejected}`:p!=null&&p.success?"Handled by email()":(p==null?void 0:p.error)??""})]})]})})]})}function k4({id:a}){const{data:l,isLoading:s}=it({queryKey:["auth-email",a],queryFn:()=>YN(a)});if(s)return r.jsx(Ln,{});if(!l)return r.jsx(sn,{children:"Email not found"});const{email:o}=l;return r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"space-y-1 text-sm",children:[o.from&&r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"From: "}),o.from]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"To: "}),o.to]}),o.cc&&r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Cc: "}),o.cc]}),o.bcc&&r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Bcc: "}),o.bcc]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Subject: "}),o.subject]}),r.jsx("div",{className:"text-muted-foreground",children:new Date(o.createdAt).toLocaleString()})]}),o.html?r.jsx("iframe",{title:o.subject,sandbox:"allow-popups allow-popups-to-escape-sandbox",srcDoc:O4(o.html),className:"h-[560px] w-full rounded-md border bg-white"}):null,r.jsxs("details",{className:"text-sm",open:!o.html,children:[r.jsx("summary",{className:"cursor-pointer text-muted-foreground",children:"Plain text"}),r.jsx("pre",{className:"mt-2 whitespace-pre-wrap rounded-md bg-muted p-3 font-mono text-xs",children:o.text})]})]})}function D4(){var g;const a=Ss(),[l,s]=x.useState(null),{data:o,isLoading:f}=it({queryKey:["auth-emails"],queryFn:QN,refetchInterval:3e3}),{data:d}=it({queryKey:["config"],queryFn:Do}),m=xs({mutationFn:GN,onSuccess:async()=>{s(null),await a.invalidateQueries({queryKey:["auth-emails"]})}}),y=(o==null?void 0:o.emails)??[],p=l??((g=y[0])==null?void 0:g.id)??null;return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:"Emails",children:r.jsxs(De,{variant:"outline",size:"sm",disabled:y.length===0||m.isPending,onClick:()=>{m.mutate()},children:[r.jsx(Sx,{className:"mr-2 h-4 w-4"}),"Clear inbox"]})}),(d==null?void 0:d.email)&&r.jsx(z4,{receive:d.email.receive??[],inbox:d.email.inbox??!1}),r.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]",children:[r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Inbox"}),r.jsx(kt,{children:"Emails from Ploy Auth and from your worker's email binding. Under ploy dev nothing is sent; every email lands here."})]}),r.jsx(ut,{children:f?r.jsx(Ln,{}):y.length===0?r.jsx(sn,{children:"No emails yet. Send one from your worker, sign up or request a password reset to see one."}):r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Time"}),r.jsx(je,{children:"Type"}),r.jsx(je,{children:"To"}),r.jsx(je,{children:"Subject"})]})}),r.jsx(_n,{children:y.map(b=>r.jsxs(ct,{className:ve("cursor-pointer",b.id===p&&"bg-muted"),onClick:()=>{s(b.id)},children:[r.jsx(Ne,{className:"whitespace-nowrap text-xs text-muted-foreground",children:new Date(b.createdAt).toLocaleTimeString()}),r.jsx(Ne,{children:r.jsx(p4,{variant:"outline",children:b.purpose==="worker"?"Worker":"Auth"})}),r.jsx(Ne,{className:"text-sm",children:b.to}),r.jsx(Ne,{className:"text-sm",children:b.subject})]},b.id))})]})})]}),r.jsx(rt,{children:r.jsx(ut,{className:"pt-6",children:p?r.jsx(k4,{id:p}):r.jsx(sn,{children:"Select an email to preview it"})})})]})]})})}const po=20;function _4(a){if(a===null)return"Never";const l=a-Math.floor(Date.now()/1e3);return l<=0?"Expired":l<60?`${l}s`:l<3600?`${Math.floor(l/60)}m`:l<86400?`${Math.floor(l/3600)}h`:`${Math.floor(l/86400)}d`}function L4({entries:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Cache Entries"}),r.jsx(kt,{children:"Key-value entries in this cache store (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Key"}),r.jsx(je,{children:"Value"}),r.jsx(je,{children:"Expires"})]})}),r.jsx(_n,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{className:"font-mono text-sm",children:s.key}),r.jsx(Ne,{className:"max-w-[400px] truncate font-mono text-xs text-muted-foreground",children:s.value}),r.jsx(Ne,{className:"font-mono text-xs text-muted-foreground",children:_4(s.expiresAt)})]},s.key))})]}):r.jsx(sn,{children:"No entries in this cache store"})})]})}function U4(){const{binding:a}=qa(),l=a||"",[s,o]=x.useState(0),[f,d]=x.useState(""),[m,y]=x.useState(""),{data:p,isLoading:g}=it({queryKey:["cacheEntries",l,s,f],queryFn:()=>EN(l,po,s,f),enabled:!!l,refetchInterval:5e3}),b=(p==null?void 0:p.hasMore)??!1,j=Math.floor(s/po)+1,S=w=>{w.preventDefault(),d(m),o(0)};return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:`Cache: ${l}`}),r.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[r.jsx(ls,{placeholder:"Search by key...",value:m,onChange:w=>y(w.target.value),className:"max-w-sm"}),r.jsxs(De,{type:"submit",variant:"outline",size:"sm",children:[r.jsx(bx,{className:"h-4 w-4 mr-1"}),"Search"]}),f&&r.jsx(De,{type:"button",variant:"ghost",size:"sm",onClick:()=>{d(""),y(""),o(0)},children:"Clear"})]}),r.jsx(L4,{entries:p==null?void 0:p.entries,isLoading:g}),(s>0||b)&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",j]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>o(Math.max(0,s-po)),disabled:s===0,children:[r.jsx(Yr,{className:"h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>o(s+po),disabled:!b,children:["Next",r.jsx(si,{className:"h-4 w-4"})]})]})]})]})})}const H4={PENDING:{variant:"default",icon:r.jsx(ri,{className:"h-3 w-3"}),label:"Pending"},RUNNING:{variant:"blue",icon:r.jsx(zn,{className:"h-3 w-3 animate-spin"}),label:"Running"},COMPLETED:{variant:"success",icon:r.jsx(Tl,{className:"h-3 w-3"}),label:"Completed"},FAILED:{variant:"error",icon:r.jsx(ws,{className:"h-3 w-3"}),label:"Failed"},CANCELLED:{variant:"default",icon:r.jsx(yj,{className:"h-3 w-3"}),label:"Cancelled"}},q4={PENDING:{variant:"default",icon:r.jsx(ri,{className:"h-3 w-3"}),label:"Pending"},PROCESSING:{variant:"blue",icon:r.jsx(zn,{className:"h-3 w-3 animate-spin"}),label:"Processing"},ACKNOWLEDGED:{variant:"success",icon:r.jsx(Tl,{className:"h-3 w-3"}),label:"Acknowledged"},FAILED:{variant:"error",icon:r.jsx(ws,{className:"h-3 w-3"}),label:"Failed"},DEAD_LETTER:{variant:"orange",icon:r.jsx(Aj,{className:"h-3 w-3"}),label:"Dead Letter"}};function Ch({status:a}){const l=H4[a];return l?r.jsx(Ml,{variant:l.variant,icon:l.icon,children:l.label}):r.jsx(Ml,{children:a})}const B4={PENDING:{variant:"default",icon:r.jsx(ri,{className:"h-3 w-3"}),label:"Pending"},FIRED:{variant:"success",icon:r.jsx(Tl,{className:"h-3 w-3"}),label:"Fired"},COMPLETED:{variant:"success",icon:r.jsx(Tl,{className:"h-3 w-3"}),label:"Completed"},FAILED:{variant:"error",icon:r.jsx(ws,{className:"h-3 w-3"}),label:"Failed"}};function Av({status:a}){const l=B4[a];return l?r.jsx(Ml,{variant:l.variant,icon:l.icon,children:l.label}):r.jsx(Ml,{children:a})}function Q4({status:a}){const l=q4[a];return l?r.jsx(Ml,{variant:l.variant,icon:l.icon,children:l.label}):r.jsx(Ml,{children:a})}const Y4={provisioning:{variant:"blue",icon:r.jsx(zn,{className:"h-3 w-3 animate-spin"}),label:"Provisioning"},active:{variant:"success",icon:r.jsx(dx,{className:"h-3 w-3"}),label:"Active"},idle:{variant:"default",icon:r.jsx(vx,{className:"h-3 w-3"}),label:"Idle"},sleeping:{variant:"warning",icon:r.jsx(xx,{className:"h-3 w-3"}),label:"Sleeping"},stopped:{variant:"default",icon:r.jsx(fN,{className:"h-3 w-3"}),label:"Stopped"},destroyed:{variant:"error",icon:r.jsx(Sx,{className:"h-3 w-3"}),label:"Destroyed"}};function G4({status:a,active:l}){const o=Y4[a==="running"?l?"active":"idle":a];return o?r.jsx(Ml,{variant:o.variant,icon:o.icon,children:o.label}):r.jsx(Ml,{children:a})}function V4({executions:a,cronExpression:l,isLoading:s}){const o=(a==null?void 0:a.filter(d=>d.status==="COMPLETED").length)??0,f=(a==null?void 0:a.filter(d=>d.status==="FAILED").length)??0;return r.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[r.jsx(Vt,{title:"Schedule",value:l??"-",icon:r.jsx(ri,{className:"h-4 w-4 text-muted-foreground"}),isLoading:s}),r.jsx(Vt,{title:"Completed",value:o,icon:r.jsx(Tl,{className:"h-4 w-4 text-green-500"}),isLoading:s}),r.jsx(Vt,{title:"Failed",value:f,icon:r.jsx(ws,{className:"h-4 w-4 text-red-500"}),isLoading:s})]})}function X4({executions:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Execution History"}),r.jsx(kt,{children:"Recent cron handler executions (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Triggered"}),r.jsx(je,{children:"Duration"}),r.jsx(je,{children:"Error"}),r.jsx(je,{children:"Completed"})]})}),r.jsx(_n,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(oi,{id:s.id})}),r.jsx(Ne,{children:r.jsx(Ch,{status:s.status})}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.triggeredAt})}),r.jsx(Ne,{children:s.durationMs!==void 0&&s.durationMs!==null?`${s.durationMs}ms`:"-"}),r.jsx(Ne,{className:"max-w-[200px] truncate text-xs text-red-500",children:s.error??"-"}),r.jsx(Ne,{children:s.completedAt?r.jsx(yn,{timestamp:s.completedAt}):"-"})]},s.id))})]}):r.jsx(sn,{children:"No cron executions yet"})})]})}function K4(){const{binding:a}=qa(),l=a||"",s=Ss(),{data:o,isLoading:f}=it({queryKey:["cronExecutions",l],queryFn:()=>kN(l,20),enabled:!!l,refetchInterval:5e3}),d=xs({mutationFn:()=>DN(l),onSettled:()=>{s.invalidateQueries({queryKey:["cronExecutions",l]})}});return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:`Cron: ${l}`,children:r.jsxs(De,{size:"sm",disabled:!l||d.isPending,onClick:()=>{d.mutate()},children:[r.jsx(uh,{className:"h-4 w-4 mr-1"}),d.isPending?"Running...":"Run now"]})}),r.jsx(V4,{executions:o==null?void 0:o.executions,cronExpression:o==null?void 0:o.cronExpression,isLoading:f}),r.jsx(X4,{executions:o==null?void 0:o.executions,isLoading:f})]})})}function $4({column:a,onInsertText:l}){return r.jsxs("button",{onClick:()=>l==null?void 0:l(a.name),className:"flex w-full items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-muted",title:`Click to insert "${a.name}"`,children:[a.primaryKey?r.jsx(yx,{className:"h-3 w-3 shrink-0 text-yellow-500"}):r.jsx(px,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate font-mono",children:a.name}),r.jsxs("span",{className:"ml-auto truncate text-muted-foreground",children:[a.type,a.notNull&&!a.primaryKey&&" NOT NULL"]})]})}function Z4({table:a,onInsertText:l}){const[s,o]=x.useState(!1);return r.jsxs(Ev,{open:s,onOpenChange:o,children:[r.jsxs(Cv,{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm hover:bg-muted",children:[s?r.jsx(mx,{className:"h-4 w-4 shrink-0"}):r.jsx(si,{className:"h-4 w-4 shrink-0"}),r.jsx(ko,{className:"h-4 w-4 shrink-0 text-blue-500"}),r.jsx("span",{className:"truncate font-medium cursor-pointer",onClick:f=>{f.stopPropagation(),l==null||l(a.name)},title:`Click to insert "${a.name}"`,children:a.name}),r.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[a.columns.length," cols"]})]}),r.jsx(Tv,{children:r.jsx("div",{className:"ml-4 border-l pl-2",children:a.columns.map(f=>r.jsx($4,{column:f,onInsertText:l},f.name))})})]})}function F4({bindingName:a,onInsertText:l}){const{data:s,isLoading:o,refetch:f}=it({queryKey:["schema",a],queryFn:()=>NN(a),staleTime:3e4}),d=(s==null?void 0:s.tables)||[];return r.jsxs("div",{className:"flex h-full flex-col border-l bg-card",children:[r.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[r.jsx("h3",{className:"text-sm font-semibold",children:"Tables"}),r.jsx(De,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>f(),disabled:o,children:r.jsx(Gr,{className:ve("h-4 w-4",o&&"animate-spin")})})]}),r.jsx(jv,{className:"flex-1",children:r.jsx("div",{className:"p-2",children:o?r.jsx("p",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"Loading schema..."}):d.length===0?r.jsx("p",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No tables found"}):r.jsx("div",{className:"space-y-0.5",children:d.map(m=>r.jsx(Z4,{table:m,onInsertText:l},m.name))})})}),r.jsx("div",{className:"border-t px-3 py-2 text-xs text-muted-foreground",children:"Click table/column names to insert"})]})}function J4(a){return a===null?"NULL":a===void 0?"":typeof a=="object"?JSON.stringify(a):String(a)}function P4(){var J,Q,se,re;const{binding:a}=qa(),l=a||"",[s,o]=x.useState("query"),[f,d]=x.useState(""),[m,y]=x.useState(null),[p,g]=x.useState(null),[b,j]=x.useState(null),[S,w]=x.useState(0),E=50,M=x.useCallback(ue=>{d(le=>le+ue)},[]),O=xs({mutationFn:ue=>bN(l,ue),onSuccess:ue=>{y(ue),g(null)},onError:ue=>{g(ue instanceof Error?ue.message:"Failed to execute query"),y(null)}}),z=()=>{f.trim()&&O.mutate(f)},D=it({queryKey:["tables",l],queryFn:()=>SN(l),staleTime:0,gcTime:0,enabled:!!l}),$=it({queryKey:["tableData",l,b,E,S],queryFn:()=>jN(l,b,E,S),staleTime:0,gcTime:0,enabled:!!l&&!!b}),_=((J=D.data)==null?void 0:J.tables)||[],V=((Q=$.data)==null?void 0:Q.data)||[],ae=((se=$.data)==null?void 0:se.columns)||[],Z=((re=$.data)==null?void 0:re.total)||0,q=ue=>{j(ue),w(0)};return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsxs("h2",{className:"text-3xl font-bold tracking-tight",children:["Database: ",l]}),r.jsxs(Nv,{value:s,onValueChange:o,children:[r.jsxs(wv,{children:[r.jsx(zr,{value:"query",children:"SQL Editor"}),r.jsx(zr,{value:"tables",children:"Tables"})]}),r.jsx(kr,{value:"query",className:"mt-4",children:r.jsxs("div",{className:"grid grid-cols-1 gap-0 lg:grid-cols-[1fr_280px]",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"SQL Query"}),r.jsx(kt,{children:"Execute SQL queries against your database"})]}),r.jsxs(ut,{className:"space-y-4",children:[r.jsx("textarea",{value:f,onChange:ue=>d(ue.target.value),onKeyDown:ue=>{(ue.metaKey||ue.ctrlKey)&&ue.key==="Enter"&&z()},placeholder:"SELECT * FROM users LIMIT 10;",className:"w-full h-32 p-2 font-mono text-sm border rounded bg-background"}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Press Cmd/Ctrl + Enter to execute"}),r.jsxs(De,{onClick:z,disabled:O.isPending||!f.trim(),children:[r.jsx(uh,{className:"mr-2 h-4 w-4"}),O.isPending?"Executing...":"Execute"]})]})]})]}),p&&r.jsx(rt,{className:"border-destructive/50",children:r.jsx(ut,{className:"pt-6",children:r.jsx("p",{className:"font-mono text-sm text-destructive",children:p})})}),m&&r.jsx(Vx,{results:m.results,meta:m.meta,error:m.error})]}),r.jsx("div",{className:"hidden h-[500px] lg:block",children:r.jsx(F4,{bindingName:l,onInsertText:M})})]})}),r.jsx(kr,{value:"tables",className:"mt-4",children:r.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-4",children:[r.jsxs(rt,{className:"md:col-span-1",children:[r.jsxs(yt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(xt,{className:"text-base",children:"Tables"}),r.jsx(De,{variant:"ghost",size:"icon",onClick:()=>D.refetch(),className:"h-8 w-8",children:r.jsx(Gr,{className:"h-4 w-4"})})]}),r.jsx(ut,{children:D.isLoading?r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."}):_.length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:"No tables found"}):r.jsx("div",{className:"space-y-1",children:_.map(ue=>r.jsxs("button",{onClick:()=>q(ue.name),className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors hover:bg-muted ${b===ue.name?"bg-muted font-medium":""}`,children:[r.jsx(ko,{className:"h-4 w-4 shrink-0"}),r.jsx("span",{className:"truncate",children:ue.name})]},ue.name))})})]}),r.jsxs(rt,{className:"md:col-span-3",children:[r.jsxs(yt,{children:[r.jsx(xt,{children:b||"Select a Table"}),b&&r.jsxs(kt,{children:[Z," total rows"]})]}),r.jsx(ut,{children:b?$.isLoading?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(zn,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):V.length===0?r.jsx("p",{className:"py-8 text-center text-muted-foreground",children:"No data in this table"}):r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"overflow-x-auto rounded-md border",children:r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsx(ct,{children:ae.map(ue=>r.jsx(je,{className:"font-mono",children:ue},ue))})}),r.jsx(_n,{children:V.map((ue,le)=>r.jsx(ct,{children:ae.map(ne=>r.jsx(Ne,{className:"font-mono text-sm",children:J4(ue[ne])},ne))},le))})]})}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-sm text-muted-foreground",children:["Showing ",S+1," -"," ",Math.min(S+E,Z)," of ",Z]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",disabled:S===0,onClick:()=>w(Math.max(0,S-E)),children:[r.jsx(Yr,{className:"mr-1 h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",disabled:S+E>=Z,onClick:()=>w(S+E),children:["Next",r.jsx(si,{className:"ml-1 h-4 w-4"})]})]})]})]}):r.jsx("p",{className:"py-8 text-center text-muted-foreground",children:"Select a table from the list to view its data"})})]})]})})]})]})})}const Zl=20;function I4(a){return a<1024?`${a} B`:a<1024*1024?`${(a/1024).toFixed(1)} KB`:a<1024*1024*1024?`${(a/(1024*1024)).toFixed(1)} MB`:`${(a/(1024*1024*1024)).toFixed(1)} GB`}function W4({entries:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Files"}),r.jsx(kt,{children:"Stored files with metadata (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Key"}),r.jsx(je,{children:"Size"}),r.jsx(je,{children:"Content Type"}),r.jsx(je,{children:"Created At"})]})}),r.jsx(_n,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{className:"font-mono text-sm",children:s.key}),r.jsx(Ne,{className:"text-sm text-muted-foreground",children:I4(s.size)}),r.jsx(Ne,{className:"font-mono text-xs text-muted-foreground",children:s.contentType}),r.jsx(Ne,{className:"text-sm text-muted-foreground",children:s.createdAt})]},s.key))})]}):r.jsx(sn,{children:"No files in this storage"})})]})}function eC(){const{binding:a}=qa(),l=a||"",[s,o]=x.useState(0),{data:f,isLoading:d}=it({queryKey:["fileStorageEntries",l,s],queryFn:()=>XN(l,Zl,s),enabled:!!l,refetchInterval:5e3}),m=(f==null?void 0:f.total)??0,y=Math.floor(s/Zl)+1,p=Math.ceil(m/Zl);return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:`File Storage: ${l}`}),r.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:r.jsx(Vt,{title:"Total Files",value:m})}),r.jsx(W4,{entries:f==null?void 0:f.entries,isLoading:d}),m>Zl&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",y," of ",p]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>o(Math.max(0,s-Zl)),disabled:s===0,children:[r.jsx(Yr,{className:"h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>o(s+Zl),disabled:s+Zl>=m,children:["Next",r.jsx(si,{className:"h-4 w-4"})]})]})]})]})})}function tC({metrics:a,isLoading:l}){return r.jsxs("div",{className:"grid gap-4 md:grid-cols-5",children:[r.jsx(Vt,{title:"Pending",value:(a==null?void 0:a.pending)??0,icon:r.jsx(ri,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Processing",value:(a==null?void 0:a.processing)??0,icon:r.jsx(zn,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Acknowledged",value:(a==null?void 0:a.acknowledged)??0,icon:r.jsx(Tl,{className:"h-4 w-4 text-green-500"}),isLoading:l}),r.jsx(Vt,{title:"Failed",value:(a==null?void 0:a.failed)??0,icon:r.jsx(ws,{className:"h-4 w-4 text-red-500"}),isLoading:l}),r.jsx(Vt,{title:"Dead Letter",value:(a==null?void 0:a.deadLetter)??0,icon:r.jsx(Zj,{className:"h-4 w-4 text-orange-500"}),isLoading:l})]})}function nC({messages:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Recent Messages"}),r.jsx(kt,{children:"Latest messages in this queue (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Payload"}),r.jsx(je,{children:"Attempt"}),r.jsx(je,{children:"Created"})]})}),r.jsx(_n,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(oi,{id:s.id})}),r.jsx(Ne,{children:r.jsx(Q4,{status:s.status})}),r.jsx(Ne,{className:"max-w-[200px] truncate font-mono text-xs",children:JSON.stringify(s.payload)}),r.jsx(Ne,{children:s.attempt}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.createdAt})})]},s.id))})]}):r.jsx(sn,{children:"No messages in this queue"})})]})}function aC(){const{binding:a}=qa(),l=a||"",{data:s,isLoading:o}=it({queryKey:["queueMetrics",l],queryFn:()=>CN(l),enabled:!!l,refetchInterval:5e3}),{data:f,isLoading:d}=it({queryKey:["queueMessages",l],queryFn:()=>TN(l,10),enabled:!!l,refetchInterval:5e3});return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:`Queue: ${l}`}),r.jsx(tC,{metrics:s==null?void 0:s.metrics,isLoading:o}),r.jsx(nC,{messages:f==null?void 0:f.messages,isLoading:d})]})})}function lC({sandboxes:a,isLoading:l}){const s=(a==null?void 0:a.length)??0,o=(a==null?void 0:a.filter(y=>y.active).length)??0,f=(a==null?void 0:a.filter(y=>y.status==="running"&&!y.active).length)??0,d=(a==null?void 0:a.filter(y=>y.status==="sleeping").length)??0,m=(a==null?void 0:a.reduce((y,p)=>y+p.sessionCount,0))??0;return r.jsxs("div",{className:"grid gap-4 md:grid-cols-5",children:[r.jsx(Vt,{title:"Sandboxes",value:s,icon:r.jsx(hx,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Active",value:o,icon:r.jsx(dx,{className:"h-4 w-4 text-green-500"}),isLoading:l}),r.jsx(Vt,{title:"Idle",value:f,icon:r.jsx(vx,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Sleeping",value:d,icon:r.jsx(xx,{className:"h-4 w-4 text-orange-500"}),isLoading:l}),r.jsx(Vt,{title:"Sessions",value:m,icon:r.jsx(oN,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l})]})}function iC({sandboxes:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Sandboxes"}),r.jsx(kt,{children:"Live sandbox instances launched via env.<binding>.get(id) (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Image"}),r.jsx(je,{children:"Sessions"}),r.jsx(je,{children:"Container"})]})}),r.jsx(_n,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{className:"font-mono text-xs",children:s.externalId}),r.jsx(Ne,{children:r.jsx(G4,{status:s.status,active:s.active})}),r.jsx(Ne,{className:"font-mono text-xs",children:s.image}),r.jsx(Ne,{children:s.sessionCount}),r.jsx(Ne,{children:s.containerId?r.jsx(oi,{id:s.containerId}):r.jsx("span",{className:"text-muted-foreground",children:"—"})})]},s.id))})]}):r.jsx(sn,{children:"No sandboxes yet — call env.<binding>.get(id) from your worker to launch one"})})]})}function sC(){const{data:a,isLoading:l}=it({queryKey:["sandboxes"],queryFn:vN,refetchInterval:5e3});return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:"Sandboxes"}),r.jsx(lC,{sandboxes:a==null?void 0:a.sandboxes,isLoading:l}),r.jsx(iC,{sandboxes:a==null?void 0:a.sandboxes,isLoading:l})]})})}const go=20;function rC({entries:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"State Entries"}),r.jsx(kt,{children:"Key-value entries in this state store (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Key"}),r.jsx(je,{children:"Value"})]})}),r.jsx(_n,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{className:"font-mono text-sm",children:s.key}),r.jsx(Ne,{className:"max-w-[400px] truncate font-mono text-xs text-muted-foreground",children:s.value})]},s.key))})]}):r.jsx(sn,{children:"No entries in this state store"})})]})}function uC(){const{binding:a}=qa(),l=a||"",[s,o]=x.useState(0),[f,d]=x.useState(""),[m,y]=x.useState(""),{data:p,isLoading:g}=it({queryKey:["stateEntries",l,s,f],queryFn:()=>wN(l,go,s,f),enabled:!!l,refetchInterval:5e3}),b=(p==null?void 0:p.hasMore)??!1,j=Math.floor(s/go)+1,S=w=>{w.preventDefault(),d(m),o(0)};return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:`State: ${l}`}),r.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[r.jsx(ls,{placeholder:"Search by key...",value:m,onChange:w=>y(w.target.value),className:"max-w-sm"}),r.jsxs(De,{type:"submit",variant:"outline",size:"sm",children:[r.jsx(bx,{className:"h-4 w-4 mr-1"}),"Search"]}),f&&r.jsx(De,{type:"button",variant:"ghost",size:"sm",onClick:()=>{d(""),y(""),o(0)},children:"Clear"})]}),r.jsx(rC,{entries:p==null?void 0:p.entries,isLoading:g}),(s>0||b)&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",j]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>o(Math.max(0,s-go)),disabled:s===0,children:[r.jsx(Yr,{className:"h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>o(s+go),disabled:!b,children:["Next",r.jsx(si,{className:"h-4 w-4"})]})]})]})]})})}function oC(a){if(a<1e3)return`${a}ms`;const l=Math.floor(a/1e3);if(l<60)return`${l}s`;const s=Math.floor(l/60),o=l%60;if(s<60)return o===0?`${s}m`:`${s}m ${o}s`;const f=Math.floor(s/60),d=s%60;if(f<24)return d===0?`${f}h`:`${f}h ${d}m`;const m=Math.floor(f/24),y=f%24;return y===0?`${m}d`:`${m}d ${y}h`}function cC({metrics:a,isLoading:l}){return r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[r.jsx(Vt,{title:"Pending",value:(a==null?void 0:a.pending)??0,icon:r.jsx(ri,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Fired",value:(a==null?void 0:a.fired)??0,icon:r.jsx(Tl,{className:"h-4 w-4 text-green-500"}),isLoading:l})]})}function fC({entries:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Scheduled Timers"}),r.jsx(kt,{children:"Timer entries scheduled by your worker (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Scheduled Time"}),r.jsx(je,{children:"Interval"}),r.jsx(je,{children:"Payload"}),r.jsx(je,{children:"Created"})]})}),r.jsx(_n,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(oi,{id:s.id})}),r.jsx(Ne,{children:r.jsx(Av,{status:s.status})}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.scheduledTime})}),r.jsx(Ne,{className:"text-xs",children:s.intervalMs!==void 0&&s.intervalMs!==null?r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(eN,{className:"h-3 w-3"}),oC(s.intervalMs)]}):"-"}),r.jsx(Ne,{className:"max-w-[200px] truncate font-mono text-xs",children:s.payload!==void 0&&s.payload!==null?JSON.stringify(s.payload):"-"}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.createdAt})})]},s.id))})]}):r.jsx(sn,{children:"No timers scheduled"})})]})}function dC({executions:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Execution History"}),r.jsx(kt,{children:"Recent timer handler executions"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Timer ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Scheduled Time"}),r.jsx(je,{children:"Duration"}),r.jsx(je,{children:"Error"}),r.jsx(je,{children:"Executed"})]})}),r.jsx(_n,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(oi,{id:s.timerId})}),r.jsx(Ne,{children:r.jsx(Av,{status:s.status})}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.scheduledTime})}),r.jsx(Ne,{children:s.durationMs!==void 0&&s.durationMs!==null?`${s.durationMs}ms`:"-"}),r.jsx(Ne,{className:"max-w-[200px] truncate text-xs text-red-500",children:s.error??"-"}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.createdAt})})]},s.id))})]}):r.jsx(sn,{children:"No timer executions yet"})})]})}function hC(){const{binding:a}=qa(),l=a||"",{data:s,isLoading:o}=it({queryKey:["timerMetrics",l],queryFn:()=>ON(l),enabled:!!l,refetchInterval:5e3}),{data:f,isLoading:d}=it({queryKey:["timerEntries",l],queryFn:()=>RN(l,20),enabled:!!l,refetchInterval:5e3}),{data:m,isLoading:y}=it({queryKey:["timerExecutions",l],queryFn:()=>zN(l,20),enabled:!!l,refetchInterval:5e3});return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:`Timers: ${l}`}),r.jsx(cC,{metrics:s==null?void 0:s.metrics,isLoading:o}),r.jsx(fC,{entries:f==null?void 0:f.entries,isLoading:d}),r.jsx(dC,{executions:m==null?void 0:m.executions,isLoading:y})]})})}function Rr(a){return a!=null}function mC(a,l){const s=[];a&&Rr(a.input)&&s.push("execution-input"),a&&Rr(a.output)&&s.push("execution-output");for(const o of l)Rr(o.input)&&s.push(`${o.id}-input`),Rr(o.output)&&s.push(`${o.id}-output`);return s}function Ro({id:a,label:l,value:s,isOpen:o,onToggle:f}){return Rr(s)?r.jsxs("details",{className:"mt-2",open:o,onToggle:d=>{f(a,d.currentTarget.open)},children:[r.jsx("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:l}),r.jsx("pre",{className:"mt-1 p-2 rounded bg-muted text-xs font-mono overflow-x-auto",children:JSON.stringify(s,null,2)})]}):null}function pC({status:a}){switch(a){case"COMPLETED":return r.jsx(Tl,{className:"h-5 w-5 text-green-500"});case"RUNNING":return r.jsx(zn,{className:"h-5 w-5 text-blue-500 animate-spin"});case"FAILED":return r.jsx(ws,{className:"h-5 w-5 text-red-500"});case"PENDING":default:return r.jsx(ri,{className:"h-5 w-5 text-gray-400"})}}function gC(a){switch(a){case"COMPLETED":return"bg-green-500";case"RUNNING":return"bg-blue-500";case"FAILED":return"bg-red-500";case"PENDING":default:return"bg-gray-300 dark:bg-gray-600"}}function yC(a){return a.attempt!==null&&a.attempt!==void 0&&a.maxRetries!==null&&a.maxRetries!==void 0&&(a.attempt>1||a.status!=="COMPLETED")}function xC({steps:a,openIoSectionIds:l,onToggleIoSection:s}){if(a.length===0)return r.jsx(sn,{children:"No steps recorded for this execution"});const o=a.reduce((f,d)=>f+(d.durationMs||0),0);return r.jsxs("div",{className:"space-y-4",children:[o>0&&r.jsxs("div",{className:"mb-6",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-muted-foreground mb-2",children:[r.jsx("span",{children:"Total Duration"}),r.jsx("span",{children:ts(o)})]}),r.jsx("div",{className:"h-3 bg-muted rounded-full overflow-hidden flex",children:a.map((f,d)=>{const m=f.durationMs?f.durationMs/o*100:0;return r.jsx("div",{className:ve(gC(f.status),"h-full transition-all",d>0&&"border-l border-background"),style:{width:`${m}%`},title:`${f.stepName}: ${ts(f.durationMs)}`},f.id)})})]}),r.jsx("div",{className:"relative",children:a.map((f,d)=>{const m=yC(f);return r.jsxs("div",{className:"relative pb-6 last:pb-0",children:[d<a.length-1&&r.jsx("div",{className:ve("absolute left-[9px] top-6 w-0.5 h-full -ml-px",f.status==="COMPLETED"?"bg-green-200 dark:bg-green-900":"bg-muted")}),r.jsxs("div",{className:"flex gap-4",children:[r.jsx("div",{className:"flex-shrink-0 relative z-10 bg-background",children:r.jsx(pC,{status:f.status})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"font-medium",children:f.stepName}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(Step ",f.stepIndex+1,")"]}),m&&r.jsxs("span",{className:ve("inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded-full font-mono",f.attempt!==null&&f.attempt!==void 0&&f.attempt>1?f.status==="FAILED"?"bg-red-100 text-red-700 dark:bg-red-950 dark:text-red-300":"bg-yellow-100 text-yellow-700 dark:bg-yellow-950 dark:text-yellow-300":"bg-muted text-muted-foreground"),children:[r.jsx(Gr,{className:"h-3 w-3"}),f.attempt,"/",(f.maxRetries??0)+1]})]}),r.jsx("span",{className:"text-sm font-mono text-muted-foreground",children:ts(f.durationMs)})]}),f.errorMessage&&r.jsx("div",{className:"mt-2 p-2 rounded bg-red-50 dark:bg-red-950 text-red-700 dark:text-red-300 text-sm font-mono",children:f.errorMessage}),f.retryAttempts&&f.retryAttempts.length>0&&r.jsxs("div",{className:"mt-2 space-y-2",children:[r.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Previous failures"}),f.retryAttempts.map(y=>r.jsxs("div",{className:"rounded border border-yellow-200 bg-yellow-50 px-3 py-2 dark:border-yellow-900 dark:bg-yellow-950/40",children:[r.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 text-xs text-yellow-800 dark:text-yellow-200",children:[r.jsxs("span",{className:"font-medium",children:["Attempt ",y.attempt," failed"]}),r.jsx("span",{className:"font-mono",children:ts(y.durationMs??null)})]}),r.jsx("pre",{className:"whitespace-pre-wrap text-xs font-mono text-yellow-900 dark:text-yellow-100",children:y.errorMessage})]},`${f.id}-${y.attempt}`))]}),r.jsx(Ro,{id:`${f.id}-input`,label:"View input",value:f.input,isOpen:l.has(`${f.id}-input`),onToggle:s}),r.jsx(Ro,{id:`${f.id}-output`,label:"View output",value:f.output,isOpen:l.has(`${f.id}-output`),onToggle:s}),r.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:r.jsx(yn,{timestamp:f.createdAt})})]})]})]},f.id)})})]})}function vC(){const{binding:a,executionId:l}=qa(),s=a||"",o=l||"",{data:f,isLoading:d}=it({queryKey:["workflowExecution",s,o],queryFn:()=>AN(s,o),enabled:!!s&&!!o,refetchInterval:5e3}),m=f==null?void 0:f.execution,y=(f==null?void 0:f.steps)||[],p=mC(m??null,y),[g,b]=x.useState(()=>new Set),j=p.length>0&&p.every(E=>g.has(E));function S(E,M){b(O=>{const z=new Set(O);return M?z.add(E):z.delete(E),z})}function w(){b(()=>j?new Set:new Set(p))}return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(Gt,{to:`/workflows/${s}`,children:r.jsxs(De,{variant:"ghost",size:"sm",children:[r.jsx(pj,{className:"mr-2 h-4 w-4"}),"Back"]})}),r.jsxs("h2",{className:"text-3xl font-bold tracking-tight",children:["Execution: ",r.jsx(oi,{id:o})]})]}),p.length>0&&r.jsxs(De,{variant:"ghost",size:"sm",onClick:w,children:[j?r.jsx(Ej,{className:"h-4 w-4"}):r.jsx(Tj,{className:"h-4 w-4"}),j?"Collapse All I/O":"Expand All I/O"]})]}),d?r.jsx(Ln,{}):m?r.jsxs(r.Fragment,{children:[r.jsxs(rt,{children:[r.jsx(yt,{children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(xt,{children:"Execution Details"}),r.jsx(kt,{children:m.startedAt?r.jsxs(r.Fragment,{children:["Started ",r.jsx(yn,{timestamp:m.startedAt})]}):"Not started yet"})]}),r.jsx(Ch,{status:m.status})]})}),r.jsxs(ut,{children:[r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Duration"}),r.jsx("p",{className:"font-mono",children:ts(m.durationMs)})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Steps Completed"}),r.jsxs("p",{className:"font-mono",children:[m.stepsCompleted," / ",m.stepsCount]})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Created"}),r.jsx("p",{className:"font-mono text-sm",children:r.jsx(yn,{timestamp:m.createdAt})})]}),m.completedAt&&r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Completed"}),r.jsx("p",{className:"font-mono text-sm",children:r.jsx(yn,{timestamp:m.completedAt})})]})]}),m.errorMessage&&r.jsx("div",{className:"mt-4 p-3 rounded bg-red-50 dark:bg-red-950 text-red-700 dark:text-red-300 text-sm font-mono",children:m.errorMessage}),r.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-2",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Execution Input"}),r.jsx(Ro,{id:"execution-input",label:"View execution input",value:m.input,isOpen:g.has("execution-input"),onToggle:S})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Execution Output"}),r.jsx(Ro,{id:"execution-output",label:"View execution output",value:m.output,isOpen:g.has("execution-output"),onToggle:S})]})]})]})]}),r.jsxs(rt,{children:[r.jsx(yt,{children:r.jsxs("div",{children:[r.jsx(xt,{children:"Steps"}),r.jsx(kt,{children:"Workflow step execution timeline"})]})}),r.jsx(ut,{children:r.jsx(xC,{steps:y,openIoSectionIds:g,onToggleIoSection:S})})]})]}):r.jsx(sn,{children:"Execution not found"})]})})}const xd=20,bC=[{value:"",label:"All statuses"},{value:"pending",label:"Pending"},{value:"running",label:"Running"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"cancelled",label:"Cancelled"}],SC=[{value:"",label:"All time"},{value:"1h",label:"Last hour"},{value:"24h",label:"Last 24 hours"},{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"}];function jC({executions:a,isLoading:l,bindingName:s}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Recent Executions"}),r.jsx(kt,{children:"Workflow executions (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Steps"}),r.jsx(je,{children:"Duration"}),r.jsx(je,{children:"Started"}),r.jsx(je,{})]})}),r.jsx(_n,{children:a.map(o=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(oi,{id:o.id})}),r.jsx(Ne,{children:r.jsx(Ch,{status:o.status})}),r.jsx(Ne,{children:r.jsxs("span",{className:"text-sm",children:[o.stepsCompleted,"/",o.stepsCount]})}),r.jsx(Ne,{className:"text-sm",children:ts(o.durationMs)}),r.jsx(Ne,{children:o.startedAt?r.jsx(yn,{timestamp:o.startedAt}):"-"}),r.jsx(Ne,{children:r.jsx(Gt,{to:`/workflows/${s}/${o.id}`,className:"flex items-center text-sm text-primary hover:underline",children:"View"})})]},o.id))})]}):r.jsx(sn,{children:"No executions for this workflow"})})]})}function NC(){const{binding:a}=qa(),l=a||"",[s,o]=x.useState(""),[f,d]=x.useState(""),[m,y]=x.useState(0),p=m*xd,{data:g,isLoading:b}=it({queryKey:["workflowExecutions",l,s,f,m],queryFn:()=>MN(l,xd,p,s||void 0,f||void 0),enabled:!!l,refetchInterval:5e3}),j=g?Math.ceil(g.total/xd):0,S=()=>y(0);return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:`Workflow: ${l}`}),r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[r.jsx("select",{value:s,onChange:w=>{o(w.target.value),S()},className:"text-sm border rounded px-2 py-1 bg-background",children:bC.map(w=>r.jsx("option",{value:w.value,children:w.label},w.value))}),r.jsx("select",{value:f,onChange:w=>{d(w.target.value),S()},className:"text-sm border rounded px-2 py-1 bg-background",children:SC.map(w=>r.jsx("option",{value:w.value,children:w.label},w.value))}),g&&r.jsxs("span",{className:"text-sm text-muted-foreground",children:[g.total," total"]})]}),r.jsx(jC,{executions:g==null?void 0:g.executions,isLoading:b,bindingName:l}),j>1&&r.jsxs("div",{className:"flex items-center justify-between pt-2",children:[r.jsx("button",{className:"text-sm px-3 py-1 border rounded disabled:opacity-40",disabled:m===0,onClick:()=>y(w=>w-1),children:"Previous"}),r.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",m+1," of ",j]}),r.jsx("button",{className:"text-sm px-3 py-1 border rounded disabled:opacity-40",disabled:m>=j-1,onClick:()=>y(w=>w+1),children:"Next"})]})]})})}function wC(){const a=Ha(),{data:l,isLoading:s}=it({queryKey:["config"],queryFn:Do,staleTime:6e4}),o=l!=null&&l.db?Object.keys(l.db):[],f=l!=null&&l.queue?Object.keys(l.queue):[],d=l!=null&&l.state?Object.keys(l.state):[],m=l!=null&&l.cache?Object.keys(l.cache):[],y=l!=null&&l.fs?Object.keys(l.fs):[],p=l!=null&&l.workflow?Object.keys(l.workflow):[],g=l!=null&&l.cron?Object.keys(l.cron):[],b=l!=null&&l.timer?Object.keys(l.timer):[],j=l!=null&&l.sandbox?Object.keys(l.sandbox):[];return r.jsxs("aside",{className:"fixed inset-y-0 left-0 z-10 w-64 flex flex-col border-r bg-background",children:[r.jsx("div",{className:"flex h-14 items-center border-b px-4",children:r.jsxs(Gt,{to:"/",className:"flex items-center gap-2 font-semibold",children:[r.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground",children:"P"}),r.jsx("span",{children:"Ploy Dev"})]})}),r.jsx("nav",{className:"flex-1 overflow-auto p-4",children:s?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(zn,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):r.jsxs("div",{className:"space-y-6",children:[o.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Database"}),r.jsx("div",{className:"space-y-1",children:o.map(S=>{const w=a.pathname===`/db/${S}`;return r.jsx(Gt,{to:`/db/${S}`,children:r.jsxs(De,{variant:w?"secondary":"ghost",className:ve("w-full justify-start",w&&"bg-muted"),children:[r.jsx(_j,{className:"mr-2 h-4 w-4"}),S]})},S)})})]}),(l==null?void 0:l.auth)&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Auth"}),r.jsx("div",{className:"space-y-1",children:r.jsx(Gt,{to:"/auth",children:r.jsxs(De,{variant:a.pathname==="/auth"?"secondary":"ghost",className:ve("w-full justify-start",a.pathname==="/auth"&&"bg-muted"),children:[r.jsx(rN,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 text-left",children:l.auth.binding}),r.jsx(gx,{className:"h-3.5 w-3.5 text-muted-foreground",title:"Ploy Auth tables (users & sessions)"})]})})})]}),((l==null?void 0:l.auth)||(l==null?void 0:l.email))&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Email"}),r.jsx("div",{className:"space-y-1",children:r.jsx(Gt,{to:"/auth/emails",children:r.jsxs(De,{variant:a.pathname==="/auth/emails"?"secondary":"ghost",className:ve("w-full justify-start",a.pathname==="/auth/emails"&&"bg-muted"),children:[r.jsx(Kj,{className:"mr-2 h-4 w-4"}),"Emails"]})})})]}),f.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Queues"}),r.jsx("div",{className:"space-y-1",children:f.map(S=>{const w=a.pathname===`/queues/${S}`;return r.jsx(Gt,{to:`/queues/${S}`,children:r.jsxs(De,{variant:w?"secondary":"ghost",className:ve("w-full justify-start",w&&"bg-muted"),children:[r.jsx(Qj,{className:"mr-2 h-4 w-4"}),S]})},S)})})]}),d.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"State"}),r.jsx("div",{className:"space-y-1",children:d.map(S=>{const w=a.pathname===`/state/${S}`;return r.jsx(Gt,{to:`/state/${S}`,children:r.jsxs(De,{variant:w?"secondary":"ghost",className:ve("w-full justify-start",w&&"bg-muted"),children:[r.jsx(hj,{className:"mr-2 h-4 w-4"}),S]})},S)})})]}),m.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Cache"}),r.jsx("div",{className:"space-y-1",children:m.map(S=>{const w=a.pathname===`/cache/${S}`;return r.jsx(Gt,{to:`/cache/${S}`,children:r.jsxs(De,{variant:w?"secondary":"ghost",className:ve("w-full justify-start",w&&"bg-muted"),children:[r.jsx(yN,{className:"mr-2 h-4 w-4"}),S]})},S)})})]}),y.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"File Storage"}),r.jsx("div",{className:"space-y-1",children:y.map(S=>{const w=a.pathname===`/fs/${S}`;return r.jsx(Gt,{to:`/fs/${S}`,children:r.jsxs(De,{variant:w?"secondary":"ghost",className:ve("w-full justify-start",w&&"bg-muted"),children:[r.jsx(Uj,{className:"mr-2 h-4 w-4"}),S]})},S)})})]}),p.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Workflows"}),r.jsx("div",{className:"space-y-1",children:p.map(S=>{const w=a.pathname.startsWith(`/workflows/${S}`);return r.jsx(Gt,{to:`/workflows/${S}`,children:r.jsxs(De,{variant:w?"secondary":"ghost",className:ve("w-full justify-start",w&&"bg-muted"),children:[r.jsx(qj,{className:"mr-2 h-4 w-4"}),S]})},S)})})]}),g.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Cron"}),r.jsx("div",{className:"space-y-1",children:g.map(S=>{const w=a.pathname===`/cron/${S}`;return r.jsx(Gt,{to:`/cron/${S}`,children:r.jsxs(De,{variant:w?"secondary":"ghost",className:ve("w-full justify-start",w&&"bg-muted"),children:[r.jsx(mN,{className:"mr-2 h-4 w-4"}),S]})},S)})})]}),b.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Timers"}),r.jsx("div",{className:"space-y-1",children:b.map(S=>{const w=a.pathname===`/timers/${S}`;return r.jsx(Gt,{to:`/timers/${S}`,children:r.jsxs(De,{variant:w?"secondary":"ghost",className:ve("w-full justify-start",w&&"bg-muted"),children:[r.jsx(vj,{className:"mr-2 h-4 w-4"}),S]})},S)})})]}),j.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Sandboxes"}),r.jsx("div",{className:"space-y-1",children:r.jsx(Gt,{to:"/sandboxes",children:r.jsxs(De,{variant:a.pathname==="/sandboxes"?"secondary":"ghost",className:ve("w-full justify-start",a.pathname==="/sandboxes"&&"bg-muted"),children:[r.jsx(hx,{className:"mr-2 h-4 w-4"}),"Sandboxes"]})})})]}),o.length===0&&f.length===0&&d.length===0&&m.length===0&&y.length===0&&p.length===0&&g.length===0&&b.length===0&&j.length===0&&!(l!=null&&l.auth)&&r.jsx("div",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No bindings configured in ploy.yaml"})]})})]})}function EC(){const{data:a,isLoading:l}=it({queryKey:["config"],queryFn:Do,staleTime:6e4});if(!l&&a){const s=a.db?Object.keys(a.db):[],o=a.queue?Object.keys(a.queue):[],f=a.state?Object.keys(a.state):[],d=a.fs?Object.keys(a.fs):[],m=a.workflow?Object.keys(a.workflow):[];if(s.length>0)return r.jsx(na,{to:`/db/${s[0]}`,replace:!0});if(a.auth)return r.jsx(na,{to:"/auth",replace:!0});if(o.length>0)return r.jsx(na,{to:`/queues/${o[0]}`,replace:!0});if(f.length>0)return r.jsx(na,{to:`/state/${f[0]}`,replace:!0});const y=a.cache?Object.keys(a.cache):[];if(y.length>0)return r.jsx(na,{to:`/cache/${y[0]}`,replace:!0});if(d.length>0)return r.jsx(na,{to:`/fs/${d[0]}`,replace:!0});if(m.length>0)return r.jsx(na,{to:`/workflows/${m[0]}`,replace:!0});const p=a.cron?Object.keys(a.cron):[];if(p.length>0)return r.jsx(na,{to:`/cron/${p[0]}`,replace:!0});const g=a.timer?Object.keys(a.timer):[];if(g.length>0)return r.jsx(na,{to:`/timers/${g[0]}`,replace:!0});if((a.sandbox?Object.keys(a.sandbox):[]).length>0)return r.jsx(na,{to:"/sandboxes",replace:!0})}return r.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[r.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Ploy Dev Dashboard"}),l?r.jsx(zn,{className:"h-6 w-6 animate-spin text-muted-foreground"}):r.jsx("p",{className:"text-muted-foreground",children:"Configure database, queue, or workflow bindings in ploy.yaml to get started."})]})}function CC(){return r.jsxs("div",{className:"min-h-screen bg-background",children:[r.jsx(wC,{}),r.jsx("main",{className:"pl-64",children:r.jsx("div",{className:"container mx-auto px-6 py-4",children:r.jsxs(CS,{children:[r.jsx(nn,{path:"/",element:r.jsx(EC,{})}),r.jsx(nn,{path:"/db/:binding",element:r.jsx(P4,{})}),r.jsx(nn,{path:"/auth",element:r.jsx(R4,{})}),r.jsx(nn,{path:"/auth/emails",element:r.jsx(D4,{})}),r.jsx(nn,{path:"/queues/:binding",element:r.jsx(aC,{})}),r.jsx(nn,{path:"/state/:binding",element:r.jsx(uC,{})}),r.jsx(nn,{path:"/cache/:binding",element:r.jsx(U4,{})}),r.jsx(nn,{path:"/fs/:binding",element:r.jsx(eC,{})}),r.jsx(nn,{path:"/cron/:binding",element:r.jsx(K4,{})}),r.jsx(nn,{path:"/timers/:binding",element:r.jsx(hC,{})}),r.jsx(nn,{path:"/workflows/:binding",element:r.jsx(NC,{})}),r.jsx(nn,{path:"/workflows/:binding/:executionId",element:r.jsx(vC,{})}),r.jsx(nn,{path:"/sandboxes",element:r.jsx(sC,{})})]})})})]})}function Rv(){const a=window.matchMedia("(prefers-color-scheme: dark)").matches;document.documentElement.classList.toggle("dark",a)}Rv();window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",Rv);const TC=new c2({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}});_2.createRoot(document.getElementById("root")).render(r.jsx(x.StrictMode,{children:r.jsx(x2,{client:TC,children:r.jsx(JS,{children:r.jsx(CC,{})})})}));
|
|
346
|
+
*/const mE=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],pE=$n("x",mE);function gE(a){const l=Math.floor((new Date().getTime()-a.getTime())/1e3);return l<5?"just now":l<60?`${String(l)}s ago`:l<3600?`${String(Math.floor(l/60))}m ago`:l<86400?`${String(Math.floor(l/3600))}h ago`:l<604800?`${String(Math.floor(l/86400))}d ago`:a.toLocaleDateString()}function hd({value:a}){const[l,s]=x.useState(!1);return r.jsx("button",{onClick:o=>{o.stopPropagation(),navigator.clipboard.writeText(a).then(()=>{s(!0),setTimeout(()=>{s(!1)},2e3)}).catch(()=>{const f=document.createElement("textarea");f.value=a,document.body.appendChild(f),f.select();try{document.execCommand("copy")}catch{}document.body.removeChild(f),s(!0),setTimeout(()=>{s(!1)},2e3)})},className:ve("p-1 rounded transition-colors flex-shrink-0",l?"text-green-500":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"),title:l?"Copied!":"Copy to clipboard",children:l?r.jsx(Gx,{className:"w-3 h-3"}):r.jsx(iE,{className:"w-3 h-3"})})}function yn({timestamp:a,className:l,rawValue:s,forceOpen:o=!1}){const[f,d]=x.useState(!1),[,m]=x.useState(0),y=o||f;if(x.useEffect(()=>{const S=setInterval(()=>{m(w=>w+1)},1e3);return()=>{clearInterval(S)}},[]),!a)return null;let p;typeof a=="number"?p=new Date(a<1e10?a*1e3:a):p=new Date(a);const g=p.toISOString(),b=p.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}),j=gE(p);return r.jsxs("div",{className:ve("relative inline-block",l),onMouseEnter:()=>{d(!0)},onMouseLeave:()=>{d(!1)},children:[r.jsx("time",{dateTime:g,className:"cursor-help border-b border-gray-400 dark:border-gray-400 text-gray-700 dark:text-gray-300",children:j}),r.jsx("div",{className:ve("absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-[9999] w-72","transition-all duration-200 ease-out origin-bottom",y?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 translate-y-2 pointer-events-none"),children:r.jsx(Mo,{rounded:"lg",shadow:"lg",className:"p-3 text-xs !bg-white dark:!bg-gray-900 !backdrop-blur-none",children:r.jsxs("div",{className:"space-y-2.5",children:[s!==void 0&&r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold mb-0.5",children:"Raw Value"}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"font-mono text-gray-700 dark:text-gray-200 break-all leading-tight",children:typeof s=="object"?JSON.stringify(s):String(s)}),r.jsx(hd,{value:typeof s=="object"?JSON.stringify(s):String(s)})]})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold mb-0.5",children:"UTC ISO"}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"font-mono text-gray-700 dark:text-gray-200 break-all leading-tight",children:g}),r.jsx(hd,{value:g})]})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold mb-0.5",children:"Local Time"}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"text-gray-700 dark:text-gray-200 leading-tight",children:b}),r.jsx(hd,{value:b})]})]})]})})})]})}function yE(a){return a<1e3?`${a.toFixed(2)}ms`:`${(a/1e3).toFixed(2)}s`}function xE(a){return typeof a!="string"?!1:[/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,/^\d{4}-\d{2}-\d{2}$/].some(l=>l.test(a))}function vE(a){const l=a.toLowerCase();return!!(l.includes("created")||l.includes("date")||l.includes("updated")||a.endsWith("At")||l.endsWith("_at"))}function bE(a,l){for(const s of l){const o=s[a];if(o!=null)return typeof o=="boolean"?"bool":typeof o=="number"&&vE(a)?"date":typeof o=="number"?"number":xE(o)?"date":"string"}return"string"}function Vx({results:a,meta:l,columns:s,error:o,title:f="Results",pageSize:d=25,onExportCsv:m,onExportJson:y,serverPagination:p}){const g=a??[],[b,j]=x.useState(""),[S,w]=x.useState(null),[E,M]=x.useState(new Set),[O,z]=x.useState(1),D=!!p,$=p?Math.floor(p.offset/p.limit)+1:1,_=p?Math.ceil(p.total/p.limit):1,V=x.useMemo(()=>s||(g.length===0?[]:Object.keys(g[0]).map(le=>({key:le,label:le,type:bE(le,g)}))),[s,g]),ae=x.useMemo(()=>b?g.filter(le=>Object.values(le).some(ne=>String(ne).toLowerCase().includes(b.toLowerCase()))):g,[g,b]),Z=x.useMemo(()=>S?[...ae].sort((le,ne)=>{const A=le[S.key],X=ne[S.key];return A==null?1:X==null?-1:A<X?S.direction==="asc"?-1:1:A>X?S.direction==="asc"?1:-1:0}):ae,[ae,S]),q=Math.ceil(Z.length/d),J=x.useMemo(()=>{const le=(O-1)*d;return Z.slice(le,le+d)},[Z,O,d]);x.useMemo(()=>{z(1)},[b,S]);const Q=le=>{w(ne=>(ne==null?void 0:ne.key)===le?ne.direction==="asc"?{key:le,direction:"desc"}:null:{key:le,direction:"asc"})},se=()=>{E.size===J.length?M(new Set):M(new Set(J.map((le,ne)=>ne)))},re=le=>{const ne=new Set(E);ne.has(le)?ne.delete(le):ne.add(le),M(ne)},ue=(le,ne)=>{const A=le[ne.key];if(A==null)return r.jsx("span",{className:"text-xs italic dark:text-gray-600 text-gray-400",children:"NULL"});switch(ne.type??"string"){case"bool":return A===!0?r.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-full dark:bg-white/[0.06] bg-black/[0.04] dark:text-gray-300 text-gray-700",children:r.jsx(Gx,{className:"w-3.5 h-3.5"})}):r.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-full dark:bg-white/[0.06] bg-black/[0.04] dark:text-gray-300 text-gray-700",children:r.jsx(pE,{className:"w-3.5 h-3.5"})});case"date":return r.jsx(yn,{timestamp:A,rawValue:typeof A=="number"?A:void 0});case"number":return r.jsx("span",{className:"text-sm font-mono dark:text-gray-300 text-gray-700",children:typeof A=="number"?A.toLocaleString():JSON.stringify(A)});default:return typeof A=="object"?r.jsx("span",{className:"text-sm font-mono dark:text-gray-300 text-gray-700",children:JSON.stringify(A)}):r.jsx("span",{className:"text-sm dark:text-gray-300 text-gray-700",children:typeof A=="object"?JSON.stringify(A):String(A)})}};return o?r.jsxs(Mo,{rounded:"2xl",shadow:"lg",className:"border-red-500/30 dark:border-red-500/20",children:[r.jsx("div",{className:"p-5 border-b dark:border-white/[0.08] border-gray-200",children:r.jsx("h2",{className:"text-lg font-semibold text-red-500",children:"Query Error"})}),r.jsx("div",{className:"p-5",children:r.jsx("p",{className:"font-mono text-sm text-red-500",children:o})})]}):r.jsxs(Mo,{rounded:"2xl",shadow:"lg",className:"flex flex-col",children:[r.jsxs("div",{className:"p-5 border-b dark:border-white/[0.08] border-gray-200 flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("h2",{className:"text-lg font-semibold dark:text-white text-gray-900",children:f}),l&&r.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-green-500/10 text-green-600 dark:text-green-400 border border-green-500/20",children:yE(l.duration)}),r.jsxs("span",{className:"text-sm dark:text-gray-500 text-gray-500",children:[g.length," row",g.length!==1?"s":""]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"relative group",children:[r.jsx(hE,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 group-focus-within:text-blue-500 transition-colors"}),r.jsx("input",{type:"text",placeholder:"Search results...",value:b,onChange:le=>{j(le.target.value)},className:"pl-9 pr-4 py-2 rounded-lg text-sm bg-gray-100 dark:bg-white/[0.06] border border-transparent focus:bg-white dark:focus:bg-black focus:border-blue-500 focus:ring-1 focus:ring-blue-500 outline-none transition-all w-full sm:w-64 dark:text-white text-gray-900 placeholder-gray-500"})]}),(m??y)&&r.jsxs("div",{className:"flex items-center gap-2 border-l dark:border-white/[0.08] border-gray-200 pl-3 ml-1",children:[m&&r.jsx("button",{onClick:m,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] text-gray-500 dark:text-gray-400 transition-colors",title:"Export CSV",children:r.jsx(oE,{className:"w-4 h-4"})}),y&&r.jsx("button",{onClick:y,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] text-gray-500 dark:text-gray-400 transition-colors",title:"Export JSON",children:r.jsx(rE,{className:"w-4 h-4"})})]})]})]}),r.jsx("div",{className:"overflow-x-auto overflow-y-visible",children:r.jsxs("table",{className:"w-full text-left border-collapse font-mono",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b dark:border-white/[0.08] border-gray-200 bg-gray-50/50 dark:bg-white/[0.02]",children:[r.jsx("th",{className:"p-4 w-12",children:r.jsx("input",{type:"checkbox",checked:E.size===J.length&&J.length>0,onChange:se,className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 bg-transparent"})}),V.map(le=>r.jsx("th",{className:"p-4 text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 cursor-pointer hover:text-blue-500 dark:hover:text-blue-400 transition-colors select-none group",onClick:()=>{Q(le.key)},children:r.jsxs("div",{className:"flex items-center gap-1",children:[le.label,r.jsxs("div",{className:ve("flex flex-col opacity-0 group-hover:opacity-50",(S==null?void 0:S.key)===le.key&&"opacity-100"),children:[r.jsx(aE,{className:ve("w-2 h-2",(S==null?void 0:S.key)===le.key&&S.direction==="asc"&&"text-blue-500")}),r.jsx(Ww,{className:ve("w-2 h-2",(S==null?void 0:S.key)===le.key&&S.direction==="desc"&&"text-blue-500")})]})]})},le.key))]})}),r.jsx("tbody",{className:"divide-y dark:divide-white/[0.04] divide-gray-100",children:J.length>0?J.map((le,ne)=>r.jsxs("tr",{className:ve("group transition-colors",E.has(ne)?"bg-blue-50/50 dark:bg-blue-500/10":"hover:bg-gray-50 dark:hover:bg-white/[0.02]"),children:[r.jsx("td",{className:"p-4",children:r.jsx("input",{type:"checkbox",checked:E.has(ne),onChange:()=>{re(ne)},className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 bg-transparent"})}),V.map(A=>r.jsx("td",{className:"p-4 whitespace-nowrap",children:ue(le,A)},`${String(ne)}-${A.key}`))]},ne)):r.jsx("tr",{children:r.jsx("td",{colSpan:V.length+1,className:"p-8 text-center text-gray-500 dark:text-gray-400",children:b?`No results found matching "${b}"`:"Query executed successfully. No rows returned."})})})]})}),r.jsxs("div",{className:"p-4 border-t dark:border-white/[0.08] border-gray-200 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[r.jsxs("div",{children:[D?r.jsxs(r.Fragment,{children:["Showing"," ",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:p.offset+1}),"-",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:Math.min(p.offset+g.length,p.total)})," ","of"," ",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:p.total})," ","total"]}):r.jsxs(r.Fragment,{children:["Showing"," ",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:J.length})," ","of"," ",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:Z.length})," ","results"]}),E.size>0&&r.jsxs("span",{className:"ml-3 text-blue-500 font-medium",children:[E.size," row",E.size!==1?"s":""," ","selected"]})]}),D&&_>1&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>{p.onPageChange(Math.max(0,p.offset-p.limit))},disabled:$===1,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:r.jsx(a0,{className:"w-4 h-4"})}),r.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(_,5)},(le,ne)=>{let A;return _<=5||$<=3?A=ne+1:$>=_-2?A=_-4+ne:A=$-2+ne,r.jsx("button",{onClick:()=>{p.onPageChange((A-1)*p.limit)},className:ve("px-2.5 py-1 rounded-lg font-medium transition-colors",$===A?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"hover:bg-gray-100 dark:hover:bg-white/[0.06]"),children:A},A)})}),r.jsx("button",{onClick:()=>{p.onPageChange(p.offset+p.limit)},disabled:$===_,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:r.jsx(l0,{className:"w-4 h-4"})})]}),!D&&q>1&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>{z(le=>Math.max(1,le-1))},disabled:O===1,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:r.jsx(a0,{className:"w-4 h-4"})}),r.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(q,5)},(le,ne)=>{let A;return q<=5||O<=3?A=ne+1:O>=q-2?A=q-4+ne:A=O-2+ne,r.jsx("button",{onClick:()=>{z(A)},className:ve("px-2.5 py-1 rounded-lg font-medium transition-colors",O===A?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"hover:bg-gray-100 dark:hover:bg-white/[0.06]"),children:A},A)})}),r.jsx("button",{onClick:()=>{z(le=>Math.min(q,le+1))},disabled:O===q,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:r.jsx(l0,{className:"w-4 h-4"})})]})]})]})}function dh(){return typeof window<"u"}function Ts(a){var l;return(a==null||(l=a.ownerDocument)==null?void 0:l.defaultView)||window}function SE(a){return dh()?a instanceof Element||a instanceof Ts(a).Element:!1}function Lo(a){return dh()?a instanceof HTMLElement||a instanceof Ts(a).HTMLElement:!1}function jE(a){return!dh()||typeof ShadowRoot>"u"?!1:a instanceof ShadowRoot||a instanceof Ts(a).ShadowRoot}function NE(a){return Ts(a).getComputedStyle(a)}const hh={...y2},md=hh.useInsertionEffect,wE=md&&md!==hh.useLayoutEffect?md:a=>a();function qe(a){const l=sa(EE).current;return l.next=a,wE(l.effect),l.trampoline}function EE(){const a={next:void 0,callback:CE,trampoline:(...l)=>{var s;return(s=a.callback)==null?void 0:s.call(a,...l)},effect:()=>{a.callback=a.next}};return a}function CE(){}const TE=()=>{},Ve=typeof document<"u"?x.useLayoutEffect:TE,Xx=x.createContext(void 0);function mh(a=!1){const l=x.useContext(Xx);if(l===void 0&&!a)throw new Error(Ba(16));return l}function ME(a){const{focusableWhenDisabled:l,disabled:s,composite:o=!1,tabIndex:f=0,isNativeButton:d}=a,m=o&&l!==!1,y=o&&l===!1;return{props:x.useMemo(()=>{const g={onKeyDown(b){s&&l&&b.key!=="Tab"&&b.preventDefault()}};return o||(g.tabIndex=f,!d&&s&&(g.tabIndex=l?f:-1)),(d&&(l||m)||!d&&s)&&(g["aria-disabled"]=s),d&&(!l||y)&&(g.disabled=s),g},[o,s,l,m,y,d,f])}}function qd(a){return(a==null?void 0:a.ownerDocument)||document}function So(a,l,{detail:s=0}={}){a.dispatchEvent(new(Ts(a)).PointerEvent("click",{bubbles:!0,cancelable:!0,composed:!0,detail:s,shiftKey:l.shiftKey,ctrlKey:l.ctrlKey,altKey:l.altKey,metaKey:l.metaKey}))}function Uo(a={}){const{disabled:l=!1,focusableWhenDisabled:s,tabIndex:o=0,native:f=!0,composite:d}=a,m=x.useRef(null),y=mh(!0),p=d??y!==void 0,{props:g}=ME({focusableWhenDisabled:s,disabled:l,composite:p,tabIndex:o,isNativeButton:f}),b=x.useCallback(()=>{const w=m.current;pd(w)&&p&&l&&g.disabled===void 0&&w.disabled&&(w.disabled=!1)},[l,g.disabled,p]);Ve(b,[b]);const j=x.useCallback((w={})=>{const{onClick:E,onMouseDown:M,onKeyUp:O,onKeyDown:z,onPointerDown:D,...$}=w;return _o({onClick(_){if(l){_.preventDefault();return}E==null||E(_)},onMouseDown(_){l||M==null||M(_)},onKeyDown(_){if(l||(Co(_),z==null||z(_),_.baseUIHandlerPrevented))return;const V=_.target===_.currentTarget,ae=_.currentTarget,Z=pd(ae),q=!f&&AE(ae),J=V&&(f?Z:!q),Q=_.key==="Enter",se=_.key===" ",re=ae.getAttribute("role"),ue=(re==null?void 0:re.startsWith("menuitem"))||re==="option"||re==="gridcell";if(V&&p&&se){if(_.defaultPrevented&&ue)return;_.preventDefault(),(!f||Z)&&(_.preventBaseUIHandler(),So(ae,_));return}if(!J||f||!se&&!Q){V&&q&&se&&_.preventDefault();return}_.defaultPrevented||(_.preventDefault(),Q&&(_.preventBaseUIHandler(),So(ae,_)))},onKeyUp(_){if(!l){if(Co(_),O==null||O(_),_.target===_.currentTarget&&f&&p&&pd(_.currentTarget)&&_.key===" "){_.preventDefault();return}_.baseUIHandlerPrevented||_.target===_.currentTarget&&!f&&!p&&!_.defaultPrevented&&_.key===" "&&(_.preventBaseUIHandler(),So(_.currentTarget,_))}},onPointerDown(_){if(l){_.preventDefault();return}D==null||D(_)}},f?{type:"button"}:{role:"button"},g,$)},[l,g,p,f]),S=qe(w=>{m.current=w,b()});return{getButtonProps:j,buttonRef:S}}function pd(a){return Lo(a)&&a.tagName==="BUTTON"}function AE(a){return Lo(a)&&a.tagName==="A"&&!!a.href}const RE=x.forwardRef(function(l,s){const{render:o,className:f,disabled:d=!1,focusableWhenDisabled:m=!1,nativeButton:y=!0,style:p,...g}=l,{getButtonProps:b,buttonRef:j}=Uo({disabled:d,focusableWhenDisabled:m,native:y});return qt("button",l,{state:{disabled:d},ref:[s,j],props:[g,b]})}),OE={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},zE={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},kE={disabled:!1,...zE},Kx={valid(a){return a===null?null:a?{"data-valid":""}:{"data-invalid":""}}},DE={invalid:void 0,name:void 0,validityData:{state:OE,errors:[],error:"",value:"",initialValue:null},setValidityData:Zt,disabled:void 0,setTouched:Zt,setDirty:Zt,setFilled:Zt,setFocused:Zt,validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:kE,registerFieldControl:Zt,validation:{getValidationProps:(a,l=Da)=>l,inputRef:{current:null},registeredInputs:new Map,registerInput:Zt,getInputControl:()=>null,commit:async()=>{},change:Zt}},_E=x.createContext(DE);function ph(a=!0){const l=x.useContext(_E);if(l.setValidityData===Zt&&!a)throw new Error(Ba(28));return l}const LE=x.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:Zt,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function $x(){return x.useContext(LE)}let i0=0;function UE(a,l="mui"){const[s,o]=x.useState(a),f=a||s;return x.useEffect(()=>{s==null&&(i0+=1,o(`${l}-${i0}`))},[s,l]),f}const s0=hh.useId;function HE(a,l){if(s0!==void 0){const s=s0();return a??`${l}-${s}`}return UE(a,l)}function ui(a){return HE(a,"base-ui")}const qE=x.createContext({controlId:void 0,registerControlId:Zt,labelId:void 0,setLabelId:Zt,messageIds:[],setMessageIds:Zt,getDescriptionProps:a=>a});function gh(){return x.useContext(qE)}function BE(a,l,s,o=!0,f){const[d,m]=x.useState(),y=ui(f?`${f}-label`:void 0),p=a??l??d;return Ve(()=>{const g=a||l||!o?void 0:QE(s.current,y);d!==g&&m(g)}),p}function QE(a,l){const s=YE(a);if(s)return!s.id&&l&&(s.id=l),s.id||void 0}function YE(a){if(!a)return;const l=a.parentElement;if(l&&l.tagName==="LABEL")return l;const s=a.id;if(s){const f=a.nextElementSibling;if(f&&f.htmlFor===s)return f}const o=a.labels;return o&&o[0]}function Zx(a={}){const{id:l,implicit:s=!1,controlRef:o}=a,{controlId:f,registerControlId:d}=gh(),m=ui(l),y=s?f:void 0,p=sa(()=>Symbol()),g=x.useRef(!1),b=x.useRef(l!=null),j=qe(()=>{!g.current||d===Zt||(g.current=!1,d(p.current,void 0))});return Ve(()=>{if(d===Zt)return;let S;if(s){const w=o==null?void 0:o.current;SE(w)&&w.closest("label")!=null?S=l??null:S=y??m}else if(l!=null)b.current=!0,S=l;else if(b.current)S=m;else{j();return}if(S===void 0){j();return}g.current=!0,d(p.current,S)},[l,o,y,d,s,m,p,j]),x.useEffect(()=>j,[j]),f??m}function GE(){return typeof navigator>"u"?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:VE,platform:XE,maxTouchPoints:RC}=GE(),Fx=VE.toLowerCase();XE.toLowerCase();var _0;const yh=typeof CSS<"u"&&!!((_0=CSS.supports)!=null&&_0.call(CSS,"-webkit-backdrop-filter:none"));!yh&&Fx.includes("firefox");!yh&&Fx.includes("chrom");function Jx(a){var s;let l=a.activeElement;for(;((s=l==null?void 0:l.shadowRoot)==null?void 0:s.activeElement)!=null;)l=l.shadowRoot.activeElement;return l}function xh(a,l){var o;if(!a||!l)return!1;const s=(o=l.getRootNode)==null?void 0:o.call(l);if(a.contains(l))return!0;if(s&&jE(s)){let f=l;for(;f;){if(a===f)return!0;f=f.parentNode||f.host}}return!1}function Bd(a){return"composedPath"in a?a.composedPath()[0]:a.target}function gd(a,l){return l<0||l>=a.length}function KE(a,l){return Or(a.current,{disabledIndices:l})}function $E(a,l){return Or(a.current,{decrement:!0,startingIndex:a.current.length,disabledIndices:l})}function Or(a,{startingIndex:l=-1,decrement:s=!1,disabledIndices:o,amount:f=1}={}){let d=l;do d+=s?-f:f;while(d>=0&&d<=a.length-1&&Qd(a,d,o));return d}function Qd(a,l,s){if(typeof s=="function"?s(l):(s==null?void 0:s.includes(l))??!1)return!0;const f=a[l];return f?!FE(f)||f.matches(":disabled")?!0:!s&&(f.hasAttribute("disabled")||f.getAttribute("aria-disabled")==="true"):!1}function ZE(a){return a.visibility==="hidden"||a.visibility==="collapse"}function FE(a,l=a?NE(a):null){return!a||!a.isConnected||!l||ZE(l)?!1:typeof a.checkVisibility=="function"?a.checkVisibility():l.display!=="none"&&l.display!=="contents"}function Px(a){x.useEffect(a,To)}const Tr=0;class vh{constructor(){pn(this,"currentId",Tr);pn(this,"clear",()=>{this.currentId!==Tr&&(clearTimeout(this.currentId),this.currentId=Tr)});pn(this,"disposeEffect",()=>this.clear)}static create(){return new vh}start(l,s){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Tr,s()},l)}isStarted(){return this.currentId!==Tr}}function Ao(){const a=sa(vh.create).current;return Px(a.disposeEffect),a}const uo=null;class JE{constructor(){pn(this,"callbacks",[]);pn(this,"callbacksCount",0);pn(this,"nextId",1);pn(this,"startId",1);pn(this,"isScheduled",!1);pn(this,"tick",l=>{var f;this.isScheduled=!1;const s=this.callbacks,o=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,o>0)for(let d=0;d<s.length;d+=1)(f=s[d])==null||f.call(s,l)})}request(l){const s=this.nextId;return this.nextId+=1,this.callbacks.push(l),this.callbacksCount+=1,(!this.isScheduled||!1)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),s}cancel(l){const s=l-this.startId;s<0||s>=this.callbacks.length||(this.callbacks[s]=null,this.callbacksCount-=1)}}let oo=new JE;class gn{constructor(){pn(this,"currentId",uo);pn(this,"cancel",()=>{this.currentId!==uo&&(oo.cancel(this.currentId),this.currentId=uo)});pn(this,"disposeEffect",()=>this.cancel)}static create(){return new gn}static request(l){return oo.request(l)}static cancel(l){return oo.cancel(l)}request(l){this.cancel(),this.currentId=oo.request(()=>{this.currentId=uo,l()})}}function PE(){const a=sa(gn.create).current;return Px(a.disposeEffect),a}function IE(a){return a==null?a:"current"in a?a.current:a}function Ix(a,l=!1){const s=PE();return qe((o,f=null)=>{s.cancel();const d=IE(a);if(d==null)return;const m=d,y=()=>{sj.flushSync(o)};if(typeof m.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){o();return}function p(){Promise.all(m.getAnimations().map(g=>g.finished)).then(()=>{f!=null&&f.aborted||y()},()=>{if(f!=null&&f.aborted)return;if(m.getAnimations().some(b=>b.pending||b.playState!=="finished")){p();return}y()})}if(l){const g="data-starting-style";if(!m.hasAttribute(g)){s.request(p);return}const b=new MutationObserver(()=>{m.hasAttribute(g)||(b.disconnect(),p())});b.observe(m,{attributes:!0,attributeFilter:[g]}),f==null||f.addEventListener("abort",()=>b.disconnect(),{once:!0});return}s.request(p)})}function Wx(a){const{enabled:l=!0,open:s,ref:o,onComplete:f}=a,d=qe(f),m=Ix(o,s);x.useEffect(()=>{if(!l)return;const y=new AbortController;return m(d,y.signal),()=>{y.abort()}},[l,s,d,m])}let r0=(function(a){return a.startingStyle="data-starting-style",a.endingStyle="data-ending-style",a})({});const WE={"data-starting-style":""},e3={"data-ending-style":""},bh={transitionStatus(a){return a==="starting"?WE:a==="ending"?e3:null}};function ev(a,l=!1,s=!1){const[o,f]=x.useState(a&&l?"idle":void 0),[d,m]=x.useState(a);return a&&!d&&(m(!0),f("starting")),!a&&d&&o!=="ending"&&!s&&f("ending"),!a&&!d&&o==="ending"&&f(void 0),Ve(()=>{if(!a&&d&&o!=="ending"&&s){const y=gn.request(()=>{f("ending")});return()=>{gn.cancel(y)}}},[a,d,o,s]),Ve(()=>{if(!a||l)return;const y=gn.request(()=>{f(void 0)});return()=>{gn.cancel(y)}},[l,a]),Ve(()=>{if(!a||!l)return;a&&d&&o!=="idle"&&f("starting");const y=gn.request(()=>{f("idle")});return()=>{gn.cancel(y)}},[l,a,d,o]),{mounted:d,setMounted:m,transitionStatus:o}}function Ho({controlled:a,default:l,name:s,state:o="value"}){const{current:f}=x.useRef(a!==void 0),[d,m]=x.useState(l),y=f?a:d,p=x.useCallback(g=>{f||m(g)},[]);return[y,p]}function tv(a,l,s,o,f=!0,d){const{registerFieldControl:m}=ph(),y=sa(()=>Symbol());Ve(()=>{const p=y.current;if(!f){m(p,void 0);return}m(p,{controlRef:a,getValue:o,id:l,name:d,value:s})},[a,f,o,l,d,m,y,s]),Ve(()=>{const p=y.current;return()=>{m(p,void 0)}},[m,y])}const qo="none",t3="trigger-press",n3="disabled",u0="missing",o0="initial";function Ms(a,l,s,o){let f=!1,d=!1;const m=o??Da;return{reason:a,event:l??new Event("base-ui"),cancel(){f=!0},allowPropagation(){d=!0},get isCanceled(){return f},get isPropagationAllowed(){return d},trigger:s,...m}}const a3=x.forwardRef(function(l,s){const{render:o,className:f,id:d,name:m,value:y,disabled:p=!1,onValueChange:g,defaultValue:b,autoFocus:j=!1,style:S,...w}=l,{state:E,name:M,disabled:O,setTouched:z,setDirty:D,validityData:$,setFocused:_,setFilled:V,validationMode:ae,validation:Z}=ph(),{clearErrors:q}=$x(),J=O||p,Q=M??m,se={...E,disabled:J},{labelId:re}=gh(),ue=Zx({id:d});Ve(()=>{var N;const I=y!=null;(N=Z.inputRef.current)!=null&&N.value||I&&y!==""?V(!0):I&&y===""&&V(!1)},[Z.inputRef,V,y]);const le=x.useRef(null);Ve(()=>{j&&le.current===Jx(qd(le.current))&&_(!0)},[j,_]);const[ne]=Ho({controlled:y,default:b,name:"FieldControl",state:"value"}),A=y!==void 0,X=A?ne:void 0,Y=qe(()=>{var I;return(I=Z.inputRef.current)==null?void 0:I.value});return tv(Z.inputRef,ue,X,Y,!J,m),qt("input",l,{ref:[s,le],state:se,props:[{id:ue,disabled:J,name:Q,ref:Z.inputRef,"aria-labelledby":re,autoFocus:j,...A?{value:X}:{defaultValue:b},onChange(I){const N=I.currentTarget.value;g==null||g(N,Ms(qo,I.nativeEvent)),D(N!==($.initialValue??"")),V(N!==""),I.nativeEvent.defaultPrevented||(q(Q),Z.change(N))},onFocus(){_(!0)},onBlur(I){z(!0),_(!1),ae==="onBlur"&&Z.commit(I.currentTarget.value)},onKeyDown(I){I.currentTarget.tagName==="INPUT"&&I.key==="Enter"&&(z(!0),Z.commit(I.currentTarget.value))}},w,I=>Z.getValidationProps(J,I)],stateAttributesMapping:Kx})}),l3=x.forwardRef(function(l,s){return r.jsx(a3,{ref:s,...l})}),nv=x.createContext(void 0);function Bo(){const a=x.useContext(nv);if(a===void 0)throw new Error(Ba(53));return a}const i3=500,Yd=16;function El(a,l,s){if(!a)return 0;const o=getComputedStyle(a),f=`${l}${s==="x"?"Inline":"Block"}`,d=parseFloat(o[`${f}Start`]);return s==="x"&&l==="margin"?d*2:d+parseFloat(o[`${f}End`])}const co="base-ui-disable-scrollbar",av={className:co,getElement(a){return r.jsx("style",{nonce:a,href:co,precedence:"base-ui:low",children:`.${co}{scrollbar-width:none}.${co}::-webkit-scrollbar{display:none}`})}},Wi=a=>l=>l?{[a]:""}:null,Sh={hasOverflowX:Wi("data-has-overflow-x"),hasOverflowY:Wi("data-has-overflow-y"),overflowXStart:Wi("data-overflow-x-start"),overflowXEnd:Wi("data-overflow-x-end"),overflowYStart:Wi("data-overflow-y-start"),overflowYEnd:Wi("data-overflow-y-end"),cornerHidden:()=>null},s3=x.createContext(void 0),r3={disableStyleElements:!1};function u3(){return x.useContext(s3)??r3}const o3={x:0,y:0},c0={width:0,height:0},c3={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},f3={x:!0,y:!0,corner:!0},d3=x.forwardRef(function(l,s){const{render:o,className:f,overflowEdgeThreshold:d,style:m,...y}=l,{xStart:p,xEnd:g,yStart:b,yEnd:j}=h3(d),S=ui(),w=Ao(),E=Ao(),{nonce:M,disableStyleElements:O}=u3(),[z,D]=x.useState(!1),[$,_]=x.useState(!1),[V,ae]=x.useState(!1),[Z,q]=x.useState(!1),[J,Q]=x.useState(!1),[se,re]=x.useState(c0),[ue,le]=x.useState(c0),[ne,A]=x.useState(c3),[X,Y]=x.useState(f3),F=x.useRef(null),I=x.useRef(null),N=x.useRef(null),L=x.useRef(null),K=x.useRef(null),ee=x.useRef(null),ie=x.useRef(null),oe=x.useRef(null),ce=x.useRef(0),ge=x.useRef(0),ye=x.useRef(0),Xe=x.useRef(0),Be=x.useRef("vertical"),tt=x.useRef(o3),ft=x.useRef(null);function Ee(Re){const Ke=Re?ae:_,Je=Re?w:E;Ke(!0),Je.start(i3,()=>{Ke(!1)})}const Nt=qe(Re=>{const Ke=Re.x-tt.current.x,Je=Re.y-tt.current.y;tt.current=Re,Je!==0&&Ee(!0),Ke!==0&&Ee(!1)}),Bt=qe(()=>{const Re=I.current;Re&&ft.current===null&&(ft.current=Re.style.scrollSnapType,Re.style.scrollSnapType="none")}),ci=qe(Re=>{if(Re.button!==0)return;if(oe.current!==null){const rn=Be.current==="vertical"?K.current:ee.current;if(rn!=null&&rn.hasPointerCapture(oe.current))return}oe.current=Re.pointerId,ce.current=Re.clientY,ge.current=Re.clientX,Be.current=Re.currentTarget.getAttribute("data-orientation");const Ke=I.current;Ke&&(ye.current=Ke.scrollTop,Xe.current=Ke.scrollLeft,Bt());const Je=Be.current==="vertical"?K.current:ee.current;Je==null||Je.setPointerCapture(Re.pointerId)}),Ya=qe(Re=>{if(Re.pointerId!==oe.current)return;oe.current=null,(Be.current==="vertical"?ae:_)(!1),ft.current!==null&&(I.current&&(I.current.style.scrollSnapType=ft.current),ft.current=null);const Ke=Be.current==="vertical"?K.current:ee.current;Ke!=null&&Ke.hasPointerCapture(Re.pointerId)&&Ke.releasePointerCapture(Re.pointerId)}),Zn=qe(Re=>{if(Re.pointerId!==oe.current)return;if(Re.buttons%2===0){Ya(Re);return}const Ke=I.current;if(!Ke)return;const Je=Be.current==="vertical",rn=Je?K.current:ee.current,ua=Je?N.current:L.current;if(!rn||!ua)return;const fi=Je?"y":"x",di=El(ua,"padding",fi),Jn=El(rn,"margin",fi),At=Je?rn.offsetHeight:rn.offsetWidth,wt=(Je?ua.offsetHeight:ua.offsetWidth)-At-di-Jn,hi=Je?Re.clientY-ce.current:Re.clientX-ge.current,Rs=wt<=0?0:hi/wt,Os=Je?Ke.scrollHeight:Ke.scrollWidth,Pn=Je?Ke.clientHeight:Ke.clientWidth,ca=(Je?ye.current:Xe.current)+Rs*(Os-Pn);Je?Ke.scrollTop=ca:Ke.scrollLeft=ca,Re.preventDefault(),Ee(Je)});function Fn(Re){q(Re.pointerType==="touch")}function Un(Re){if(Fn(Re),Re.pointerType!=="touch"){const Ke=xh(F.current,Re.target);D(Ke)}}const ra=x.useMemo(()=>({scrolling:$||V,hasOverflowX:!X.x,hasOverflowY:!X.y,overflowXStart:ne.xStart,overflowXEnd:ne.xEnd,overflowYStart:ne.yStart,overflowYEnd:ne.yEnd,cornerHidden:X.corner}),[$,V,X.x,X.y,X.corner,ne]),Al={role:"presentation",onPointerEnter:Un,onPointerMove:Un,onPointerDown:Fn,onPointerLeave(){D(!1)},style:{position:"relative","--scroll-area-corner-height":`${se.height}px`,"--scroll-area-corner-width":`${se.width}px`}},Mt=qt("div",l,{state:ra,ref:[s,F],props:[Al,y],stateAttributesMapping:Sh}),As=x.useMemo(()=>({handlePointerDown:ci,handlePointerMove:Zn,handlePointerUp:Ya,handleScroll:Nt,disableViewportSnap:Bt,cornerSize:se,setCornerSize:re,thumbSize:ue,setThumbSize:le,hasMeasuredScrollbar:J,setHasMeasuredScrollbar:Q,touchModality:Z,cornerRef:ie,scrollingX:$,scrollingY:V,hovering:z,setHovering:D,viewportRef:I,scrollbarYRef:N,scrollbarXRef:L,thumbYRef:K,thumbXRef:ee,rootId:S,hiddenState:X,setHiddenState:Y,overflowEdges:ne,setOverflowEdges:A,viewportState:ra,overflowEdgeThreshold:{xStart:p,xEnd:g,yStart:b,yEnd:j}}),[ci,Zn,Ya,Nt,Bt,se,ue,J,Z,$,V,z,S,X,ne,ra,p,g,b,j]);return r.jsxs(nv.Provider,{value:As,children:[!O&&av.getElement(M),Mt]})});function h3(a){const l=typeof a=="number"?{xStart:a,xEnd:a,yStart:a,yEnd:a}:a;return{xStart:Math.max(0,(l==null?void 0:l.xStart)||0),xEnd:Math.max(0,(l==null?void 0:l.xEnd)||0),yStart:Math.max(0,(l==null?void 0:l.yStart)||0),yEnd:Math.max(0,(l==null?void 0:l.yEnd)||0)}}const m3=x.createContext(void 0),p3=x.createContext(void 0);function jh(){const a=x.useContext(p3);return(a==null?void 0:a.direction)??"ltr"}function lv(a,l=Number.MIN_SAFE_INTEGER,s=Number.MAX_SAFE_INTEGER){return Math.max(l,Math.min(a,s))}const f0=1;function d0(a,l){if(l<=0)return 0;const s=lv(a,0,l),o=s,f=l-s,d=o<=f0,m=f<=f0;return d&&m?o<=f?0:l:d?0:m?l:s}const iv=["--scroll-area-overflow-x-start","--scroll-area-overflow-x-end","--scroll-area-overflow-y-start","--scroll-area-overflow-y-end"];let h0=!1;function g3(){h0||yh||(typeof CSS<"u"&&"registerProperty"in CSS&&iv.forEach(a=>{try{CSS.registerProperty({name:a,syntax:"<length>",inherits:!1,initialValue:"0px"})}catch{}}),h0=!0)}const y3=x.forwardRef(function(l,s){const{render:o,className:f,style:d,...m}=l,{viewportRef:y,scrollbarYRef:p,scrollbarXRef:g,thumbYRef:b,thumbXRef:j,cornerRef:S,cornerSize:w,setCornerSize:E,setThumbSize:M,rootId:O,setHiddenState:z,hiddenState:D,setHasMeasuredScrollbar:$,handleScroll:_,touchModality:V,setHovering:ae,setOverflowEdges:Z,overflowEdgeThreshold:q,viewportState:J}=Bo(),Q=jh(),se=x.useRef(!0),re=x.useRef([NaN,NaN,NaN,NaN]),ue=Ao(),le=Ao(),ne=qe(()=>{const I=y.current,N=p.current,L=g.current,K=b.current,ee=j.current,ie=S.current;if(!I)return;const oe=I.scrollHeight,ce=I.scrollWidth,ge=I.clientHeight,ye=I.clientWidth,Xe=I.scrollTop,Be=I.scrollLeft,tt=re.current,ft=Number.isNaN(tt[0]);if(tt[0]=ge,tt[1]=oe,tt[2]=ye,tt[3]=ce,ft&&$(!0),oe===0||ce===0)return;const Ee=x3(I),Nt=Ee.y,Bt=Ee.x,ci=ye/ce,Ya=ge/oe,Zn=Math.max(0,ce-ye),Fn=Math.max(0,oe-ge);let Un=0,ra=0;Bt||(Un=d0(Q==="rtl"?-Be:Be,Zn),ra=Zn-Un);const Al=Nt?0:d0(Xe,Fn),Mt=Nt?0:Fn-Al,As=Bt?0:ye,Re=Nt?0:ge;let Ke=0,Je=0;!Bt&&!Nt&&(Ke=(N==null?void 0:N.offsetWidth)||0,Je=(L==null?void 0:L.offsetHeight)||0);const rn=w.width===0&&w.height===0,ua=rn?Ke:0,fi=rn?Je:0,di=El(L,"padding","x"),Jn=El(N,"padding","y"),At=El(ee,"margin","x"),xn=El(K,"margin","y"),wt=As-di-At,hi=Re-Jn-xn,Rs=L?Math.min(L.offsetWidth-ua,wt):wt,Os=N?Math.min(N.offsetHeight-fi,hi):hi,Pn=Math.max(Yd,Rs*ci),oa=Math.max(Yd,Os*Ya);if(M(Rt=>fo(Rt,{width:Pn,height:oa})),N&&K){const Rt=N.offsetHeight-oa-Jn-xn,Hn=m0(K,"--scroll-area-thumb-height",Xe,Fn,oe,oa,Rt);K.style.transform=`translate3d(0,${Hn}px,0)`}if(L&&ee){const Rt=L.offsetWidth-Pn-di-At,Hn=Q==="rtl"?-Be:Be,Vr=m0(ee,"--scroll-area-thumb-width",Hn,Zn,ce,Pn,Rt);ee.style.transform=`translate3d(${Q==="rtl"?-Vr:Vr}px,0,0)`}const ca=[Un,ra,Al,Mt];iv.forEach((Rt,Hn)=>{I.style.setProperty(Rt,`${ca[Hn]}px`)}),ie&&E(Rt=>fo(Rt,{width:Ke,height:Je})),z(Rt=>fo(Rt,Ee));const fa={xStart:!Bt&&Un>q.xStart,xEnd:!Bt&&ra>q.xEnd,yStart:!Nt&&Al>q.yStart,yEnd:!Nt&&Mt>q.yEnd};Z(Rt=>fo(Rt,fa))});Ve(()=>{g3()},[]),Ve(()=>{queueMicrotask(ne)},[ne,D,Q,q.xStart,q.xEnd,q.yStart,q.yEnd]),Ve(()=>{var I;(I=y.current)!=null&&I.matches(":hover")&&ae(!0)},[y,ae]),Ve(()=>{const I=y.current;if(typeof ResizeObserver>"u"||!I)return;let N=!1;const L=new ResizeObserver(()=>{if(!N){N=!0;const K=re.current;if(K[0]===I.clientHeight&&K[1]===I.scrollHeight&&K[2]===I.clientWidth&&K[3]===I.scrollWidth)return}ne()});return L.observe(I),le.start(0,()=>{const K=I.getAnimations({subtree:!0});K.length!==0&&Promise.allSettled(K.map(ee=>ee.finished)).then(ne).catch(()=>{})}),()=>{L.disconnect(),le.clear()}},[ne,y,le]);function A(){se.current=!1}const X={role:"presentation",...O&&{"data-id":`${O}-viewport`},tabIndex:D.x&&D.y?-1:0,className:av.className,style:{overflow:"scroll"},onScroll(){y.current&&(ne(),(V||!se.current)&&_({x:y.current.scrollLeft,y:y.current.scrollTop}),ue.start(100,()=>{se.current=!0}))},onWheel:A,onPointerMove:A,onPointerEnter:A,onKeyDown:A},Y=qt("div",l,{ref:[s,y],state:J,props:[X,m],stateAttributesMapping:Sh}),F=x.useMemo(()=>({computeThumbPosition:ne}),[ne]);return r.jsx(m3.Provider,{value:F,children:Y})});function x3(a){const l=a.clientHeight>=a.scrollHeight,s=a.clientWidth>=a.scrollWidth;return{y:l,x:s,corner:l||s}}function fo(a,l){for(const s in l)if(a[s]!==l[s])return l;return a}function m0(a,l,s,o,f,d,m){const y=lv(s,0,o),p=s-y,g=Math.max(Yd,d*f/(f+Math.abs(p)));return a.style.setProperty(l,p?`${g}px`:""),(o?y/o*m:0)+(p>0?d-g:0)}function sv(a,l,s,o){return a.addEventListener(l,s,o),()=>{a.removeEventListener(l,s,o)}}const rv=x.createContext(void 0);function v3(){const a=x.useContext(rv);if(a===void 0)throw new Error(Ba(54));return a}const b3=x.forwardRef(function(l,s){const{render:o,className:f,orientation:d="vertical",keepMounted:m=!1,style:y,...p}=l,{hovering:g,scrollingX:b,scrollingY:j,hiddenState:S,scrollbarYRef:w,scrollbarXRef:E,viewportRef:M,thumbYRef:O,thumbXRef:z,handlePointerDown:D,handlePointerUp:$,handleScroll:_,disableViewportSnap:V,rootId:ae,thumbSize:Z,hasMeasuredScrollbar:q,viewportState:J}=Bo(),Q=d==="vertical",se={...J,hovering:g,scrolling:Q?j:b,orientation:d},re=jh(),ue=!q&&!m,le=Q?S.y:S.x,ne=m||!le;x.useEffect(()=>{if(!ne)return;const Y=M.current,F=Q?w.current:E.current;if(!F)return;function I(N){if(!Y||N.ctrlKey)return;const L=!Q,K=L?"scrollLeft":"scrollTop",ee=L?N.deltaX:N.deltaY;if(ee===0)return;const ie=L?Y.scrollWidth-Y.clientWidth:Y.scrollHeight-Y.clientHeight,oe=L&&re==="rtl"?-ie:0,ce=L&&re==="rtl"?0:ie,ge=Y[K];ge<=oe&&ee<0||ge>=ce&&ee>0||(N.preventDefault(),Y[K]=Math.min(ce,Math.max(oe,ge+ee)),_({x:Y.scrollLeft,y:Y.scrollTop}))}return sv(F,"wheel",I,{passive:!1})},[re,_,Q,E,w,ne,M]);const A={...ae&&{"data-id":`${ae}-scrollbar`},onPointerDown(Y){if(Y.button!==0)return;const F=Bd(Y.nativeEvent),I=Q?O.current:z.current;if(I&&xh(I,F))return;const N=M.current;if(!N)return;const L=Q?w.current:E.current;if(!I||!L)return;const K=Q?"y":"x",ee=El(I,"margin",K),ie=El(L,"padding",K),oe=Q?I.offsetHeight:I.offsetWidth,ce=L.getBoundingClientRect(),ge=Q?Y.clientY-ce.top-oe/2-ie+ee/2:Y.clientX-ce.left-oe/2-ie+ee/2,ye=Q?N.scrollHeight:N.scrollWidth,Xe=Q?N.clientHeight:N.clientWidth,tt=(Q?L.offsetHeight:L.offsetWidth)-oe-ie-ee;if(tt<=0)return;const ft=ge/tt,Ee=ye-Xe;V(),Q?N.scrollTop=ft*Ee:re==="rtl"?N.scrollLeft=-(1-ft)*Ee:N.scrollLeft=ft*Ee,_({x:N.scrollLeft,y:N.scrollTop}),D(Y)},onPointerUp:$,onPointerCancel:$,style:{position:"absolute",touchAction:"none",WebkitUserSelect:"none",userSelect:"none",visibility:ue?"hidden":void 0,...Q?{top:0,bottom:"var(--scroll-area-corner-height)",insetInlineEnd:0,"--scroll-area-thumb-height":`${Z.height}px`}:{insetInlineStart:0,insetInlineEnd:"var(--scroll-area-corner-width)",bottom:0,"--scroll-area-thumb-width":`${Z.width}px`}}},X=qt("div",l,{ref:[s,Q?w:E],state:se,props:[A,p],stateAttributesMapping:Sh});return ne?r.jsx(rv.Provider,{value:d,children:X}):null}),S3=x.forwardRef(function(l,s){const{render:o,className:f,style:d,...m}=l,{thumbYRef:y,thumbXRef:p,handlePointerDown:g,handlePointerMove:b,handlePointerUp:j,scrollingX:S,scrollingY:w,hasMeasuredScrollbar:E}=Bo(),M=v3(),O=M==="vertical";return qt("div",l,{ref:[s,O?y:p],state:{scrolling:O?w:S,orientation:M},props:[{onPointerDown:g,onPointerMove:b,onPointerUp:j,onPointerCancel:j,style:{visibility:E?void 0:"hidden",...O?{height:"var(--scroll-area-thumb-height)"}:{width:"var(--scroll-area-thumb-width)"}}},m]})}),j3=x.forwardRef(function(l,s){const{render:o,className:f,style:d,...m}=l,{cornerRef:y,cornerSize:p,hiddenState:g}=Bo(),b=qt("div",l,{ref:[s,y],props:[{style:{position:"absolute",bottom:0,insetInlineEnd:0,width:p.width,height:p.height}},m]});return g.corner?null:b});function kn({className:a,...l}){return r.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:r.jsx("table",{"data-slot":"table",className:ve("w-full caption-bottom text-sm",a),...l})})}function Dn({className:a,...l}){return r.jsx("thead",{"data-slot":"table-header",className:ve("[&_tr]:border-b",a),...l})}function _n({className:a,...l}){return r.jsx("tbody",{"data-slot":"table-body",className:ve("[&_tr:last-child]:border-0",a),...l})}function ct({className:a,...l}){return r.jsx("tr",{"data-slot":"table-row",className:ve("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",a),...l})}function je({className:a,...l}){return r.jsx("th",{"data-slot":"table-head",className:ve("h-12 px-3 text-left align-middle text-xs font-medium tracking-wider whitespace-nowrap text-muted-foreground uppercase [&:has([role=checkbox])]:pr-0",a),...l})}function Ne({className:a,...l}){return r.jsx("td",{"data-slot":"table-cell",className:ve("p-3 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",a),...l})}const uv=x.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function N3(){return x.useContext(uv)}function ov(a={}){const{guess:l,label:s,metadata:o,textRef:f,index:d}=a,{register:m,unregister:y,subscribeMapChange:p,nextIndexRef:g}=N3(),b=x.useRef(-1),[j,S]=x.useState(d==null&&l?()=>{if(b.current===-1){const O=g.current;g.current+=1,b.current=O}return b.current}:-1),w=d??j,E=x.useRef(null),M=x.useCallback(O=>{const z=E.current;z&&y(z),E.current=O,O&&m(O,{metadata:o??null,index:d??null,label:s,textRef:f})},[d,m,y,o,s,f]);return Ve(()=>{if(d==null)return p(O=>{var D;const z=E.current?(D=O.get(E.current))==null?void 0:D.index:null;z!=null&&S(z)})},[d,p]),{ref:M,index:w}}function w3(a){const l=sa(E3,a).current;return l.next=a,Ve(l.effect),l}function E3(a){const l={current:a,next:a,effect:()=>{l.current=l.next}};return l}const cv={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},C3={...cv,position:"fixed",top:0,left:0},T3={...cv,position:"absolute"},Gd="ArrowUp",Vd="ArrowDown",Xd="ArrowLeft",Kd="ArrowRight",$d="Home",Zd="End",M3=new Set([Gd,Vd,Xd,Kd,$d,Zd]),A3="Shift",R3=[A3,"Control","Alt","Meta"];function O3(a){return Lo(a)&&a.tagName==="INPUT"}function p0(a){return!!(O3(a)&&a.selectionStart!=null||Lo(a)&&a.tagName==="TEXTAREA")}function g0(a,l,s,o){if(!a||!l||!l.scrollTo)return;let f=a.scrollLeft,d=a.scrollTop;const m=a.clientWidth<a.scrollWidth,y=a.clientHeight<a.scrollHeight;if(m&&o!=="vertical"){const p=y0(a,l,"left"),g=ho(a),b=ho(l);s==="ltr"&&(p+l.offsetWidth+b.scrollMarginRight>a.scrollLeft+a.clientWidth-g.scrollPaddingRight?f=p+l.offsetWidth+b.scrollMarginRight-a.clientWidth+g.scrollPaddingRight:p-b.scrollMarginLeft<a.scrollLeft+g.scrollPaddingLeft&&(f=p-b.scrollMarginLeft-g.scrollPaddingLeft)),s==="rtl"&&(p-b.scrollMarginLeft<a.scrollLeft+g.scrollPaddingLeft?f=p-b.scrollMarginLeft-g.scrollPaddingLeft:p+l.offsetWidth+b.scrollMarginRight>a.scrollLeft+a.clientWidth-g.scrollPaddingRight&&(f=p+l.offsetWidth+b.scrollMarginRight-a.clientWidth+g.scrollPaddingRight))}if(y&&o!=="horizontal"){const p=y0(a,l,"top"),g=ho(a),b=ho(l);p-b.scrollMarginTop<a.scrollTop+g.scrollPaddingTop?d=p-b.scrollMarginTop-g.scrollPaddingTop:p+l.offsetHeight+b.scrollMarginBottom>a.scrollTop+a.clientHeight-g.scrollPaddingBottom&&(d=p+l.offsetHeight+b.scrollMarginBottom-a.clientHeight+g.scrollPaddingBottom)}a.scrollTo({left:f,top:d,behavior:"auto"})}function y0(a,l,s){const o=s==="left"?"offsetLeft":"offsetTop";let f=0;for(;l.offsetParent&&(f+=l[o],l.offsetParent!==a);)l=l.offsetParent;return f}function ho(a){const l=getComputedStyle(a);return{scrollMarginTop:parseFloat(l.scrollMarginTop)||0,scrollMarginRight:parseFloat(l.scrollMarginRight)||0,scrollMarginBottom:parseFloat(l.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(l.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(l.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(l.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(l.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(l.scrollPaddingLeft)||0}}function z3(a){return Ax(19)?a:a?"true":void 0}function fv(a){const{children:l,elementsRef:s,labelsRef:o,onMapChange:f}=a,d=qe(f),[,m]=x.useState(!1),y=sa(D3).current,p=sa(k3).current,g=x.useRef(0),b=x.useRef(!0),j=x.useRef([]),S=x.useRef(null),w=qe(()=>{b.current||(b.current=!0,m(V=>!V))}),E=qe((V,ae)=>{p.set(V,ae),w()}),M=qe(V=>{p.delete(V),w()}),O=qe(V=>{const ae=new Map;return s.current.length=0,o&&(o.current.length=0),V.forEach(Z=>{var q,J;ae.set(Z.element,{...Z.registration.metadata??{},index:Z.index}),s.current[Z.index]=Z.element,o&&(o.current[Z.index]=Z.registration.label!==void 0?Z.registration.label:((J=(q=Z.registration.textRef)==null?void 0:q.current)==null?void 0:J.textContent)??Z.element.textContent)}),g.current=s.current.length,ae});function z(V){var q;if((q=S.current)==null||q.disconnect(),S.current=null,typeof MutationObserver!="function"||V.length<2)return;const ae=new MutationObserver(J=>{if(!U3(J))return;let Q=null;for(const se of V)if(se.isConnected){if(Q&&dv(Q,se)>0){ae.disconnect(),w();return}Q=se}});S.current=ae;const Z=new Set;for(let J=1;J<V.length;J+=1){const Q=L3(V[J-1],V[J]);Q&&Z.add(Q)}Z.forEach(J=>ae.observe(J,{childList:!0}))}const D=qe(()=>{const[V,ae]=_3(p),Z=O(V);z(ae),j.current=V,b.current=!1,y.forEach(q=>q(Z)),d(Z)});Ve(()=>(b.current||O(j.current),()=>{s.current=[],o&&(o.current=[])}),[s,o,O]),Ve(()=>{b.current&&D()}),Ve(()=>()=>{var V;(V=S.current)==null||V.disconnect(),b.current=!0},[]);const $=qe(V=>(y.add(V),()=>{y.delete(V)})),_=x.useMemo(()=>({register:E,unregister:M,subscribeMapChange:$,nextIndexRef:g}),[E,M,$,g]);return r.jsx(uv.Provider,{value:_,children:l})}function k3(){return new Map}function D3(){return new Set}function _3(a){const l=new Set,s=[],o=[];a.forEach((d,m)=>{if(!m.isConnected)return;const y=d.index,p={index:y??-1,element:m,registration:d};y===null?o.push(p):y>=0&&(l.add(y),s.push(p))});let f=0;return o.sort((d,m)=>dv(d.element,m.element)),o.forEach(d=>{for(;l.has(f);)f+=1;d.index=f,s.push(d),f+=1}),l.size>0&&s.sort((d,m)=>d.index-m.index),[s,o.map(d=>d.element)]}function L3(a,l){let s=a.parentElement;for(;s&&!s.contains(l);)s=s.parentElement;return s}function U3(a){for(const l of a)for(let s=0;s<l.removedNodes.length;s+=1)if(l.removedNodes[s].isConnected)return!0;return!1}function dv(a,l){return a.compareDocumentPosition(l)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function H3(a,l){const s=x.useRef(a),o=qe(l);Ve(()=>{s.current!==a&&o(s.current),s.current=a},[a,o])}function q3(a={}){const{highlightItemOnHover:l,highlightedIndex:s,onHighlightedIndexChange:o}=mh(),{ref:f,index:d}=ov(a),m=s===d,y=x.useRef(null),p=vs(f,y);return{compositeProps:{tabIndex:m?0:-1,onFocus(){o(d)},onMouseMove(){const b=y.current;if(!l||!b)return;const j=b.hasAttribute("disabled")||b.ariaDisabled==="true";!m&&!j&&b.focus()}},compositeRef:p,index:d}}function B3(a){return a==null||a.hasAttribute("disabled")||a.getAttribute("aria-disabled")==="true"}const hv="data-composite-item-active",Q3=[];function Y3(a){const{loopFocus:l=!0,orientation:s="both",grid:o,onLoop:f,direction:d,highlightedIndex:m,onHighlightedIndexChange:y,rootRef:p,enableHomeAndEndKeys:g=!1,stopEventPropagation:b,disabledIndices:j,modifierKeys:S=Q3}=a,[w,E]=x.useState(0),M=o!=null,O=x.useRef(null),z=vs(O,p),D=x.useRef([]),$=x.useRef(!1),_=m??w,V=qe((Q,se=!1)=>{if((y??E)(Q),se){const re=D.current[Q];g0(O.current,re,d,s)}}),ae=qe(Q=>{var le;if(Q.size===0||$.current)return;$.current=!0;const se=Array.from(Q.keys()),re=se.find(ne=>ne==null?void 0:ne.hasAttribute(hv))??null,ue=re?((le=Q.get(re))==null?void 0:le.index)??-1:-1;if(ue!==-1)V(ue);else if(Qd(se,_,j)){const ne=Or(se,{disabledIndices:j});gd(se,ne)||V(ne)}g0(O.current,re,d,s)});Ve(()=>{if(j==null||m!=null||!$.current)return;const Q=D.current;if(Qd(Q,_,j)){const se=Or(Q,{disabledIndices:j});gd(Q,se)||V(se)}},[j,m,_,D,V]);const Z=qe((Q,se,re)=>f?f(Q,se,re,D):re),q=qe(Q=>{const se=Q.key===$d||Q.key===Zd;if(!M3.has(Q.key)||!g&&se||G3(Q,S)||!O.current)return;const ue=d==="rtl",le=ue?Xd:Kd,ne=ue?Kd:Xd,A=s==="vertical"?Vd:le,X=s==="vertical"?Gd:ne,Y=Bd(Q.nativeEvent);if(Y!=null&&p0(Y)&&!B3(Y)){const ee=Y.selectionStart,ie=Y.selectionEnd,oe=Y.value;if(ee==null||Q.shiftKey||ee!==ie||Q.key!==X&&ee<oe.length||Q.key!==A&&ee>0)return}let F=_;const I=KE(D,j),N=$E(D,j);o!=null&&(F=o({disabledIndices:j,elementsRef:D,event:Q,highlightedIndex:_,loopFocus:l,maxIndex:N,minIndex:I,onLoop:Z,orientation:s,rtl:ue}));const L=s!=="vertical"&&Q.key===le||s!=="horizontal"&&Q.key===Vd,K=s!=="vertical"&&Q.key===ne||s!=="horizontal"&&Q.key===Gd;g&&(Q.key===$d?F=I:Q.key===Zd&&(F=N)),F===_&&(L||K)&&(l&&F===N&&L?(F=I,f&&(F=f(Q,_,F,D))):l&&F===I&&K?(F=N,f&&(F=f(Q,_,F,D))):F=Or(D.current,{startingIndex:F,decrement:K,disabledIndices:j})),F!==_&&!gd(D.current,F)&&(b&&Q.stopPropagation(),(M||se||L||K)&&Q.preventDefault(),V(F,!0),queueMicrotask(()=>{var ee;(ee=D.current[F])==null||ee.focus()}))});return{props:{ref:z,onFocus(Q){const se=O.current,re=Bd(Q.nativeEvent);!se||re==null||!p0(re)||re.setSelectionRange(0,re.value.length)},onKeyDown:q},highlightedIndex:_,onHighlightedIndexChange:V,elementsRef:D,onMapChange:ae,relayKeyboardEvent:q}}function G3(a,l){for(const s of R3)if(!l.includes(s)&&a.getModifierState(s))return!0;return!1}function V3(a){const{render:l,className:s,style:o,refs:f=To,props:d=To,state:m=Da,stateAttributesMapping:y,highlightedIndex:p,onHighlightedIndexChange:g,orientation:b,grid:j,loopFocus:S,onLoop:w,enableHomeAndEndKeys:E,onMapChange:M,stopEventPropagation:O=!0,rootRef:z,disabledIndices:D,modifierKeys:$,highlightItemOnHover:_=!1,tag:V="div",...ae}=a,Z=jh(),{props:q,highlightedIndex:J,onHighlightedIndexChange:Q,elementsRef:se,onMapChange:re,relayKeyboardEvent:ue}=Y3({grid:j,loopFocus:S,onLoop:w,orientation:b,highlightedIndex:p,onHighlightedIndexChange:g,rootRef:z,stopEventPropagation:O,enableHomeAndEndKeys:E,direction:Z,disabledIndices:D,modifierKeys:$}),le=qt(V,a,{state:m,ref:f,props:[q,...d,ae],stateAttributesMapping:y}),ne=x.useMemo(()=>({highlightedIndex:J,onHighlightedIndexChange:Q,highlightItemOnHover:_,relayKeyboardEvent:ue}),[J,Q,_,ue]);return r.jsx(Xx.Provider,{value:ne,children:r.jsx(fv,{elementsRef:se,onMapChange:A=>{M==null||M(A),re(A)},children:le})})}const mv=x.createContext(void 0);function X3(){const a=x.useContext(mv);if(a===void 0)throw new Error(Ba(63));return a}const pv={...Kx,checked(a){return a?{"data-checked":""}:{"data-unchecked":""}}},K3=x.forwardRef(function(l,s){const{checked:o,className:f,defaultChecked:d,"aria-labelledby":m,form:y,id:p,inputRef:g,name:b,nativeButton:j=!1,onCheckedChange:S,readOnly:w=!1,required:E=!1,disabled:M=!1,render:O,uncheckedValue:z,value:D,style:$,..._}=l,{clearErrors:V}=$x(),{state:ae,setTouched:Z,setDirty:q,validityData:J,setFilled:Q,setFocused:se,validationMode:re,disabled:ue,name:le,validation:ne}=ph(),{labelId:A}=gh(),X=ue||M,Y=le??b,F=x.useRef(null),I=vs(F,g,ne.inputRef),N=x.useRef(null),L=ui(),K=Zx({id:p,implicit:!1,controlRef:N}),ee=j?void 0:K,[ie,oe]=Ho({controlled:o,default:!!d,name:"Switch",state:"checked"});tv(N,L,ie,void 0,!X,b),Ve(()=>{F.current&&Q(F.current.checked)},[Q]),H3(ie,()=>{V(Y),q(ie!==J.initialValue),Q(ie),ne.change(ie)});const{getButtonProps:ce,buttonRef:ge}=Uo({disabled:X,native:j}),ye=BE(m,A,F,!j,ee),Xe={id:j?K:L,role:"switch","aria-checked":ie,"aria-readonly":w||void 0,"aria-required":E||void 0,"aria-labelledby":ye,onFocus(){X||se(!0)},onBlur(){const Ee=F.current;!Ee||X||(Z(!0),se(!1),re==="onBlur"&&ne.commit(Ee.checked))},onClick(Ee){if(w||X)return;Ee.preventDefault();const Nt=F.current;Nt&&So(Nt,Ee)}},Be={...ne.getValidationProps(X),checked:ie,disabled:X,form:y,id:ee,name:Y,required:E,style:Y?T3:C3,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:I,onChange(Ee){if(Ee.nativeEvent.defaultPrevented)return;if(w){Ee.preventDefault();return}const Nt=Ee.currentTarget.checked,Bt=Ms(qo,Ee.nativeEvent);S==null||S(Nt,Bt),!Bt.isCanceled&&oe(Nt)},onClick(Ee){Ee.stopPropagation()},onFocus(){var Ee;(Ee=N.current)==null||Ee.focus()},...D!==void 0?{value:D}:Da},tt=x.useMemo(()=>({...ae,checked:ie,disabled:X,readOnly:w,required:E}),[ae,ie,X,w,E]),ft=qt("span",l,{state:tt,ref:[s,N,ge],props:[Xe,_,ce,Ee=>ne.getValidationProps(X,Ee)],stateAttributesMapping:pv});return r.jsxs(mv.Provider,{value:tt,children:[ft,!ie&&Y&&z!==void 0&&r.jsx("input",{type:"hidden",form:y,name:Y,value:z,disabled:X}),r.jsx("input",{...Be,suppressHydrationWarning:!0})]})}),$3=x.forwardRef(function(l,s){const{render:o,className:f,style:d,...m}=l,y=X3();return qt("span",l,{state:y,ref:s,stateAttributesMapping:pv,props:m})}),gv=x.createContext(void 0);function Nh(){const a=x.useContext(gv);if(a===void 0)throw new Error(Ba(64));return a}const Qo={tabActivationDirection:a=>({"data-activation-direction":a})},Z3=x.forwardRef(function(l,s){const{className:o,defaultValue:f=0,onValueChange:d,orientation:m="horizontal",render:y,value:p,style:g,...b}=l,j=l.defaultValue!==void 0,S=x.useRef([]),[w,E]=x.useState(()=>new Map),[M,O]=Ho({controlled:p,default:f,name:"Tabs",state:"value"}),z=p!==void 0,[D,$]=x.useState(()=>new Map),_=x.useRef(void 0),V=x.useCallback(ge=>Fd(D,ge),[D]),[ae,Z]=x.useState(()=>({previousValue:M,tabActivationDirection:"none"})),{previousValue:q,tabActivationDirection:J}=ae;let Q=J,se=!1;q!==M&&(Q=x0(q,M,m,D),se=q!=null&&M!=null&&V(M)==null);const re=se?q:M,ue=q!==re||J!==Q;Ve(()=>{ue&&Z({previousValue:re,tabActivationDirection:Q})},[re,ue,Q]);const le=qe((ge,ye)=>{const Xe=x0(M,ge,m,D);ye.activationDirection=Xe,d==null||d(ge,ye),!ye.isCanceled&&O(ge)}),ne=qe((ge,ye)=>{d==null||d(ge,Ms(ye,void 0,void 0,{activationDirection:"none"}))}),A=qe((ge,ye)=>(E(Xe=>{const Be=new Map(Xe);return Be.set(ge,ye),Be}),()=>{E(Xe=>{if(Xe.get(ge)!==ye)return Xe;const Be=new Map(Xe);return Be.delete(ge),Be})})),X=x.useCallback(ge=>w.get(ge),[w]),Y=x.useCallback(ge=>{for(const ye of D.values())if(ge===ye.value)return ye.id},[D]),F=x.useMemo(()=>({getTabElementBySelectedValue:V,getTabIdByPanelValue:Y,getTabPanelIdByValue:X,onValueChange:le,orientation:m,registerMountedTabPanel:A,setTabMap:$,tabActivationDirection:Q,value:M}),[V,Y,X,le,m,A,$,Q,M]),I=x.useMemo(()=>{for(const ge of D.values())if(ge.value===M)return ge},[D,M]),N=x.useMemo(()=>{for(const ge of D.values())if(!ge.disabled)return ge.value},[D]),L=x.useRef(!j),K=x.useRef(f),ee=x.useRef(j),ie=x.useRef(!1);Ve(()=>{var tt;if(z)return;function ge(ft,Ee){O(ft),Z({previousValue:ft,tabActivationDirection:"none"}),ne(ft,Ee),L.current=!1}if(D.size===0){ie.current&&M!==null&&!((tt=_.current)!=null&&tt.isConnected)&&ge(null,u0);return}ie.current=!0,_.current=D.keys().next().value;const ye=I==null?void 0:I.disabled,Xe=I==null&&M!==null;if(!ye&&M===K.current&&(ee.current=!1),ee.current&&ye&&M===K.current)return;const Be=L.current;if(ye||Xe){const ft=N??null;if(M===ft){L.current=!1;return}let Ee=u0;Be?Ee=o0:ye&&(Ee=n3),ge(ft,Ee);return}Be&&I!=null&&(ne(M,o0),L.current=!1)},[N,z,ne,I,O,D,M]);const ce=qt("div",l,{state:{orientation:m,tabActivationDirection:Q},ref:s,props:b,stateAttributesMapping:Qo});return r.jsx(gv.Provider,{value:F,children:r.jsx(fv,{elementsRef:S,children:ce})})});function Fd(a,l){for(const[s,o]of a.entries())if(l===o.value)return s;return null}function x0(a,l,s,o){if(a==null||l==null)return"none";const[f,d,m]=s==="horizontal"?["left","left","right"]:["top","up","down"],y=Fd(o,a),p=Fd(o,l);if(y==null||p==null)return y!==p&&(typeof a=="number"||typeof a=="string")&&typeof a==typeof l?l>a?m:d:"none";const g=y.getBoundingClientRect()[f],b=p.getBoundingClientRect()[f];return b<g?d:b>g?m:"none"}const yv=x.createContext(void 0);function F3(){const a=x.useContext(yv);if(a===void 0)throw new Error(Ba(65));return a}const J3=x.forwardRef(function(l,s){const{className:o,disabled:f=!1,render:d,value:m,id:y,nativeButton:p=!0,style:g,...b}=l,{value:j,getTabPanelIdByValue:S,onValueChange:w,orientation:E,tabActivationDirection:M}=Nh(),{activateOnFocus:O,registerTabResizeObserverElement:z,tabsListElement:D}=F3(),{highlightedIndex:$,onHighlightedIndexChange:_}=mh(),V=ui(y),ae=x.useMemo(()=>({disabled:f,id:V,value:m}),[f,V,m]),{compositeProps:Z,compositeRef:q,index:J}=q3({metadata:ae}),Q=m===j,se=x.useRef(!1),re=x.useRef(null),ue=qe(ie=>{var oe;(oe=re.current)==null||oe.call(re),re.current=ie?z(ie):null});Ve(()=>{if(se.current){se.current=!1;return}if(!(Q&&J>-1&&$!==J))return;const ie=D;if(ie!=null){const oe=Jx(qd(ie));if(oe&&xh(ie,oe))return}f||_(J)},[Q,J,$,_,f,D]);const{getButtonProps:le,buttonRef:ne}=Uo({disabled:f,native:p,focusableWhenDisabled:!0}),A=S(m),X=x.useRef(!1),Y=x.useRef(!1);function F(ie){w(m,Ms(qo,ie.nativeEvent,void 0,{activationDirection:"none"}))}function I(ie){Q||f||F(ie)}function N(ie){Q||f||O&&(!X.current||Y.current)&&F(ie)}function L(ie){if(Q||f)return;X.current=!0,Y.current=ie.button===0;const oe=qd(ie.currentTarget);function ce(){X.current=!1,Y.current=!1,oe.removeEventListener("pointerup",ce),oe.removeEventListener("pointercancel",ce)}oe.addEventListener("pointerup",ce),oe.addEventListener("pointercancel",ce)}return qt("button",l,{state:{disabled:f,active:Q,orientation:E,tabActivationDirection:M},ref:[s,ne,q,ue],props:[Z,{role:"tab","aria-controls":A,"aria-selected":Q,id:V,onClick:I,onFocus:N,onPointerDown:L,[hv]:Q?"":void 0,onKeyDownCapture(){se.current=!0}},b,le],stateAttributesMapping:Qo})}),P3={...Qo,...bh},I3=x.forwardRef(function(l,s){const{className:o,value:f,render:d,keepMounted:m=!1,style:y,...p}=l,{value:g,getTabIdByPanelValue:b,orientation:j,tabActivationDirection:S,registerMountedTabPanel:w}=Nh(),E=ui(),{ref:M,index:O}=ov(),z=f===g,{mounted:D,transitionStatus:$,setMounted:_}=ev(z),V=!D,ae=b(f),Z={hidden:V,orientation:j,tabActivationDirection:S,transitionStatus:$},q=x.useRef(null),J=qt("div",l,{state:Z,ref:[s,M,q],props:[{"aria-labelledby":ae,hidden:V,id:E,role:"tabpanel",tabIndex:z?0:-1,inert:z3(!z),"data-index":O},p],stateAttributesMapping:P3});return Wx({open:z,ref:q,onComplete(){z||_(!1)}}),Ve(()=>{if(!(E==null||V&&!m))return w(f,E)},[V,m,f,E,w]),m||D?J:null}),W3=x.forwardRef(function(l,s){const{activateOnFocus:o=!1,className:f,loopFocus:d=!0,render:m,style:y,...p}=l,{orientation:g,setTabMap:b,tabActivationDirection:j}=Nh(),[S,w]=x.useState(0),[E,M]=x.useState(null),O=x.useRef(new Set),z=x.useRef(new Set),D=x.useRef(null);Ve(()=>{if(typeof ResizeObserver>"u")return;const q=new ResizeObserver(()=>{O.current.forEach(J=>{J()})});return D.current=q,E&&q.observe(E),z.current.forEach(J=>{q.observe(J)}),()=>{q.disconnect(),D.current=null}},[E]);const $=qe(q=>(O.current.add(q),()=>{O.current.delete(q)})),_=qe(q=>{var J;return z.current.add(q),(J=D.current)==null||J.observe(q),()=>{var Q;z.current.delete(q),(Q=D.current)==null||Q.unobserve(q)}}),V={orientation:g,tabActivationDirection:j},ae={"aria-orientation":g==="vertical"?"vertical":void 0,role:"tablist"},Z=x.useMemo(()=>({activateOnFocus:o,registerIndicatorUpdateListener:$,registerTabResizeObserverElement:_,tabsListElement:E}),[o,$,_,E]);return r.jsx(yv.Provider,{value:Z,children:r.jsx(V3,{render:m,className:f,style:y,state:V,refs:[s,M],props:[ae,p],stateAttributesMapping:Qo,highlightedIndex:S,enableHomeAndEndKeys:!0,loopFocus:d,orientation:g,onHighlightedIndexChange:w,onMapChange:b,disabledIndices:To})})});function e4(a){const{open:l,defaultOpen:s,onOpenChange:o,disabled:f}=a,[d,m]=Ho({controlled:l,default:s,name:"Collapsible",state:"open"}),{mounted:y,setMounted:p,transitionStatus:g}=ev(d,!0,!0),b=ui(),[j,S]=x.useState(),w=j===null?void 0:j??b,E=qe(M=>{const O=!d,z=Ms(t3,M.nativeEvent);o(O,z),!z.isCanceled&&m(O)});return x.useMemo(()=>({defaultPanelId:b,disabled:f,handleTrigger:E,mounted:y,open:d,panelId:w,setMounted:p,setOpen:m,setPanelIdState:S,transitionStatus:g}),[b,f,E,y,d,w,p,m,S,g])}const xv=x.createContext(void 0);function vv(){const a=x.useContext(xv);if(a===void 0)throw new Error(Ba(15));return a}let wh=(function(a){return a.open="data-open",a.closed="data-closed",a[a.startingStyle=r0.startingStyle]="startingStyle",a[a.endingStyle=r0.endingStyle]="endingStyle",a})({}),t4=(function(a){return a.panelOpen="data-panel-open",a})({});const n4={[wh.open]:""},a4={[wh.closed]:""},l4={open(a){return a?{[t4.panelOpen]:""}:null}},i4={open(a){return a?n4:a4}},Mr={height:void 0,width:void 0};function s4(a){const{externalRef:l,hiddenUntilFound:s,id:o,keepMounted:f,mounted:d,onOpenChange:m,open:y,setMounted:p,setOpen:g,transitionStatus:b}=a,j=x.useRef(null),S=x.useRef(null),[w,E]=x.useState(Mr),M=x.useRef(Mr),O=x.useRef(!1),z=x.useRef(y),D=x.useRef(!1),[$,_]=x.useState(!1),V=x.useRef(null),ae=vs(l,j),Z=w3(y),q=Ix(j),J=!y&&!d,Q=$?"idle":b,se=y&&(z.current||D.current),re=!y&&d&&S.current==="css-animation"&&w.height===void 0&&w.width===void 0?M.current:w,ue=s&&J&&S.current!=="css-animation",le=qe((F,I=!0)=>{I&&(M.current=F),E(F)}),ne=qe(()=>{var F;(F=V.current)==null||F.call(V),V.current=null}),A=qe(F=>{ne(),V.current=()=>{V.current=null,F()}}),X=qe(()=>{y&&d&&S.current==="css-animation"&&(D.current=!0)});Ve(()=>{!$||b==="starting"||_(!1)},[$,b]),x.useEffect(()=>()=>{X(),ne()},[X,ne]),Ve(()=>{const F=j.current;if(!F)return;!y&&V.current&&ne();const I=r4(F,se);if(S.current=I,y&&b==="idle"&&z.current&&I==="css-animation"){M.current=es(F);return}if(y&&b==="starting"){const K=O.current;if(O.current=!1,I==="none"){le(es(F)),_(!0);return}if(I==="css-transition"){const oe=u4(F);if(le(es(F)),!K)return oe;const ce=mo(F,"transition-duration","0s");return A(ce),_(!0),oe}le(es(F));const ee=mo(F,"animation-name","none");if(!K){ee();return}const ie=mo(F,"animation-duration","0s");ee(),A(ie),_(!0);return}if(!y&&d&&(b==="idle"||b==="starting")){if(z.current=!1,D.current=!1,I==="none"){le(Mr,!1),p(!1);return}le(es(F));return}if(b!=="ending")return;if(I==="none"){p(!1);return}const N=es(F);if(!(N.height>0||N.width>0)){p(!1);return}le(N),I==="css-animation"&&mo(F,"animation-name","none")()},[d,y,ne,le,p,A,se,b]),Wx({enabled:y&&d&&Q==="idle",open:!0,ref:j,onComplete(){y&&le(Mr,!1)}}),x.useEffect(()=>{if(y||!d||Q!=="ending"||!j.current)return;const I=new AbortController;let N=-1;function L(){Z.current||(p(!1),le(Mr,!1))}return N=gn.request(()=>{q(L,I.signal)}),()=>{gn.cancel(N),I.abort()}},[Z,d,y,Q,q,le,p]),Ve(()=>{const F=j.current;!F||!s||!J||F.setAttribute("hidden","until-found")},[J,s]),x.useEffect(function(){const I=j.current;if(!I)return;function N(L){const K=Ms(qo,L);m(!0,K),!K.isCanceled&&(O.current=!0,g(!0))}return sv(I,"beforematch",N)},[m,g]);const Y=f||s||d||y;return{height:re.height,props:{...ue?{[wh.startingStyle]:""}:void 0,hidden:J,id:o},ref:ae,shouldPreventOpenAnimation:se,shouldRender:Y,transitionStatus:Q,width:re.width}}function es(a){return{height:a.scrollHeight,width:a.scrollWidth}}function r4(a,l){const s=Ts(a).getComputedStyle(a),o=(s.animationName.split(",").map(d=>d.trim()).some(d=>d!==""&&d!=="none")||l)&&v0(s.animationDuration),f=v0(s.transitionDuration);return o&&f||f?"css-transition":o?"css-animation":"none"}function v0(a){return a.split(",").map(l=>l.trim()).some(l=>l!==""&&Number.parseFloat(l)>0)}function mo(a,l,s){const o=a.style.getPropertyValue(l),f=a.style.getPropertyPriority(l);return a.style.setProperty(l,s),()=>{if(o===""){a.style.removeProperty(l);return}a.style.setProperty(l,o,f)}}function u4(a){const l={"justify-content":a.style.justifyContent,"align-items":a.style.alignItems,"align-content":a.style.alignContent,"justify-items":a.style.justifyItems};Object.keys(l).forEach(f=>{a.style.setProperty(f,"initial","important")});function s(){Object.entries(l).forEach(([f,d])=>{if(d===""){a.style.removeProperty(f);return}a.style.setProperty(f,d)})}const o=gn.request(s);return()=>{gn.cancel(o),s()}}const bv={...i4,...bh},o4=x.forwardRef(function(l,s){const{render:o,className:f,defaultOpen:d=!1,disabled:m=!1,onOpenChange:y,open:p,style:g,...b}=l,j=qe(y),S=e4({open:p,defaultOpen:d,onOpenChange:j,disabled:m}),w=x.useMemo(()=>({open:S.open,disabled:S.disabled,transitionStatus:S.transitionStatus}),[S.open,S.disabled,S.transitionStatus]),E=x.useMemo(()=>({...S,onOpenChange:j,state:w}),[S,j,w]),M=qt("div",l,{state:w,ref:s,props:b,stateAttributesMapping:bv});return r.jsx(xv.Provider,{value:E,children:M})}),c4={...l4,...bh},f4=x.forwardRef(function(l,s){const{panelId:o,open:f,handleTrigger:d,state:m,disabled:y}=vv(),{className:p,disabled:g=y,render:b,nativeButton:j=!0,style:S,...w}=l,{getButtonProps:E,buttonRef:M}=Uo({disabled:g,focusableWhenDisabled:!0,native:j});return qt("button",l,{state:m,ref:[s,M],props:[{"aria-controls":f?o:void 0,"aria-expanded":f,onClick:d},w,E],stateAttributesMapping:c4})});let b0=(function(a){return a.collapsiblePanelHeight="--collapsible-panel-height",a.collapsiblePanelWidth="--collapsible-panel-width",a})({});const d4=x.forwardRef(function(l,s){const{className:o,hiddenUntilFound:f,keepMounted:d,render:m,id:y,style:p,...g}=l,{defaultPanelId:b,mounted:j,onOpenChange:S,open:w,setMounted:E,setPanelIdState:M,setOpen:O,state:z,transitionStatus:D}=vv(),$=f??!1,_=d??!1,V=y||void 0,ae=V??b;Ve(()=>(M(X=>V??(X===null?void 0:X)),()=>{M(X=>X===V?null:X)}),[V,M]);const{height:Z,props:q,ref:J,shouldPreventOpenAnimation:Q,shouldRender:se,transitionStatus:re,width:ue}=s4({externalRef:s,hiddenUntilFound:$,id:ae,keepMounted:_,mounted:j,onOpenChange:S,open:w,setMounted:E,setOpen:O,transitionStatus:D}),le={...z,transitionStatus:re},ne=Rx(p,le),A=qt("div",{...l,style:void 0},{state:le,ref:J,props:[q,{style:{[b0.collapsiblePanelHeight]:Z===void 0?"auto":`${Z}px`,[b0.collapsiblePanelWidth]:ue===void 0?"auto":`${ue}px`}},g,ne?{style:ne}:void 0,Q?{style:{animationName:"none"}}:void 0],stateAttributesMapping:bv});return se?A:null});function Sv(a){var l,s,o="";if(typeof a=="string"||typeof a=="number")o+=a;else if(typeof a=="object")if(Array.isArray(a)){var f=a.length;for(l=0;l<f;l++)a[l]&&(s=Sv(a[l]))&&(o&&(o+=" "),o+=s)}else for(s in a)a[s]&&(o&&(o+=" "),o+=s);return o}function h4(){for(var a,l,s=0,o="",f=arguments.length;s<f;s++)(a=arguments[s])&&(l=Sv(a))&&(o&&(o+=" "),o+=l);return o}const S0=a=>typeof a=="boolean"?`${a}`:a===0?"0":a,j0=h4,Eh=(a,l)=>s=>{var o;if((l==null?void 0:l.variants)==null)return j0(a,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:f,defaultVariants:d}=l,m=Object.keys(f).map(g=>{const b=s==null?void 0:s[g],j=d==null?void 0:d[g];if(b===null)return null;const S=S0(b)||S0(j);return f[g][S]}),y=s&&Object.entries(s).reduce((g,b)=>{let[j,S]=b;return S===void 0||(g[j]=S),g},{}),p=l==null||(o=l.compoundVariants)===null||o===void 0?void 0:o.reduce((g,b)=>{let{class:j,className:S,...w}=b;return Object.entries(w).every(E=>{let[M,O]=E;return Array.isArray(O)?O.includes({...d,...y}[M]):{...d,...y}[M]===O})?[...g,j,S]:g},[]);return j0(a,m,p,s==null?void 0:s.class,s==null?void 0:s.className)},m4=Eh("inline-flex w-fit shrink-0 items-center justify-center gap-1.5 overflow-hidden rounded-none border px-2 py-0.5 text-[0.625rem] font-semibold uppercase tracking-widest whitespace-nowrap transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 aria-invalid:border-destructive [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/80",destructive:"border-destructive/20 bg-destructive/10 text-destructive [a&]:hover:bg-destructive/20",outline:"border-border text-foreground [a&]:hover:bg-muted [a&]:hover:text-foreground"}},defaultVariants:{variant:"default"}});function p4({className:a,variant:l="default",render:s,...o}){return uw({defaultTagName:"span",props:_o({className:ve(m4({variant:l}),a)},o),render:s,state:{slot:"badge",variant:l}})}const g4={default:"text-muted-foreground bg-muted border-border",success:"text-emerald-700 bg-emerald-500/10 border-emerald-500/25 dark:text-emerald-400",error:"text-red-700 bg-red-500/10 border-red-500/25 dark:text-red-400",warning:"text-amber-700 bg-amber-500/10 border-amber-500/25 dark:text-amber-400",purple:"text-purple-700 bg-purple-500/10 border-purple-500/25 dark:text-purple-400",blue:"text-blue-700 bg-blue-500/10 border-blue-500/25 dark:text-blue-400",orange:"text-orange-700 bg-orange-500/10 border-orange-500/25 dark:text-orange-400",emerald:"text-emerald-700 bg-emerald-500/10 border-emerald-500/25 dark:text-emerald-400"};function Ml({className:a,icon:l,variant:s="default",children:o,...f}){return r.jsxs("div",{"data-slot":"tag",className:ve("inline-flex items-center gap-1.5 rounded-none border px-2.5 py-1 text-[0.625rem] font-semibold uppercase tracking-widest [&_svg]:h-3 [&_svg]:w-3",g4[s],a),...f,children:[l&&r.jsx("span",{className:"flex-shrink-0",children:l}),r.jsx("span",{className:"leading-none",children:o})]})}const y4=Eh("group/button relative inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-none border border-transparent bg-clip-padding text-xs font-semibold uppercase tracking-widest transition-all outline-none select-none cursor-pointer focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",primary:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",outline:"border-border bg-transparent hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-input/30",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",danger:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",success:"bg-emerald-500/10 text-emerald-700 hover:bg-emerald-500/20 dark:bg-emerald-500/15 dark:text-emerald-400 dark:hover:bg-emerald-500/25",link:"text-primary underline underline-offset-4 hover:underline",icon:"border-border bg-transparent hover:bg-muted hover:text-foreground dark:hover:bg-input/30"},size:{default:"h-10 gap-1.5 px-6 has-data-[icon=inline-end]:pr-4 has-data-[icon=inline-start]:pl-4",xs:"h-7 gap-1 px-3 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3",sm:"h-9 gap-1 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",md:"h-10 gap-1.5 px-6 has-data-[icon=inline-end]:pr-4 has-data-[icon=inline-start]:pl-4",lg:"h-11 gap-1.5 px-8 has-data-[icon=inline-end]:pr-5 has-data-[icon=inline-start]:pl-5",icon:"size-10","icon-xs":"size-7 [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-9","icon-md":"size-10","icon-lg":"size-11"}},defaultVariants:{variant:"default",size:"default"}});function De({className:a,variant:l="default",size:s="default",isLoading:o=!1,children:f,disabled:d,render:m,nativeButton:y,...p}){const g=y??(m===void 0||x.isValidElement(m)&&m.type==="button");return r.jsxs(RE,{"data-slot":"button",className:ve(y4({variant:l,size:s,className:a})),disabled:d===!0||o,render:m,nativeButton:g,...p,children:[o&&r.jsx(fE,{className:"size-3.5 animate-spin"}),f]})}const x4={sm:"h-9 text-xs",md:"h-10 text-sm",lg:"h-11 text-base"};function ls({className:a,label:l,error:s,leftIcon:o,rightContent:f,inputSize:d="md","aria-invalid":m,...y}){const p=!!s||m!==void 0&&m!==!1&&m!=="false";return r.jsxs("div",{className:"w-full",children:[l&&r.jsx("label",{className:"mb-2 block text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:l}),r.jsxs("div",{className:ve("flex items-center gap-2 border border-transparent border-b-input bg-transparent transition-[color,border-color] focus-within:border-b-ring",p&&"border-b-destructive focus-within:border-b-destructive",a),children:[o&&r.jsx(o,{className:"size-3.5 shrink-0 text-muted-foreground"}),r.jsx(l3,{"data-slot":"input","aria-invalid":p||void 0,className:ve("w-full min-w-0 flex-1 border-0 bg-transparent px-0 py-1 outline-none placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50","file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground",x4[d]),...y}),f&&r.jsx("div",{className:"shrink-0",children:f})]}),s&&r.jsx("p",{className:"mt-2 text-xs text-destructive",children:s})]})}function jv({className:a,children:l,...s}){return r.jsxs(d3,{"data-slot":"scroll-area",className:ve("relative",a),...s,children:[r.jsx(y3,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:l}),r.jsx(v4,{}),r.jsx(j3,{})]})}function v4({className:a,orientation:l="vertical",...s}){return r.jsx(b3,{"data-slot":"scroll-area-scrollbar","data-orientation":l,orientation:l,className:ve("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",a),...s,children:r.jsx(S3,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-none bg-border"})})}ve("flex items-center justify-between gap-2 rounded-none border border-border bg-transparent px-3 py-2 text-xs font-semibold uppercase tracking-widest transition-colors","hover:bg-muted focus:outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 data-popup-open:bg-muted");function yd({className:a,size:l="default",...s}){return r.jsx(K3,{"data-slot":"switch","data-size":l,className:ve("peer group/switch relative inline-flex shrink-0 items-center rounded-none border transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 data-[size=default]:h-4.5 data-[size=default]:w-8.25 data-[size=sm]:h-3.5 data-[size=sm]:w-6.25 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-unchecked:border-input/50 data-unchecked:bg-input data-disabled:cursor-not-allowed data-disabled:opacity-50",a),...s,children:r.jsx($3,{"data-slot":"switch-thumb",className:"pointer-events-none block bg-background ring-0 transition-transform group-data-[size=default]/switch:size-3.5 group-data-[size=sm]/switch:size-2.5 data-checked:translate-x-[calc(100%+2px)] dark:data-checked:bg-primary-foreground data-unchecked:translate-x-0.25 dark:data-unchecked:bg-foreground"})})}function Nv({className:a,orientation:l="horizontal",...s}){return r.jsx(Z3,{"data-slot":"tabs","data-orientation":l,className:ve("group/tabs flex gap-2 data-horizontal:flex-col",a),...s})}const b4=Eh("group/tabs-list inline-flex w-fit items-center justify-center p-1 text-muted-foreground group-data-horizontal/tabs:h-10 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function wv({className:a,variant:l="default",...s}){return r.jsx(W3,{"data-slot":"tabs-list","data-variant":l,className:ve(b4({variant:l}),a),...s})}function zr({className:a,...l}){return r.jsx(J3,{"data-slot":"tabs-trigger",className:ve("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-2 border border-transparent px-4 py-1.5 text-xs font-semibold tracking-wider whitespace-nowrap text-foreground/60 uppercase transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start group-data-vertical/tabs:px-4 group-data-vertical/tabs:py-2 hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent","data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground","after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",a),...l})}function kr({className:a,...l}){return r.jsx(I3,{"data-slot":"tabs-content",className:ve("flex-1 text-sm outline-none",a),...l})}function Cl({className:a,...l}){return r.jsx("label",{"data-slot":"label",className:ve("flex items-center gap-2 text-xs font-semibold tracking-wide uppercase select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50 peer-data-[slot=checkbox]:text-sm peer-data-[slot=checkbox]:font-normal peer-data-[slot=checkbox]:tracking-normal peer-data-[slot=checkbox]:normal-case peer-data-[slot=radio-group-item]:text-sm peer-data-[slot=radio-group-item]:font-normal peer-data-[slot=radio-group-item]:tracking-normal peer-data-[slot=radio-group-item]:normal-case peer-data-[slot=switch]:text-sm peer-data-[slot=switch]:font-normal peer-data-[slot=switch]:tracking-normal peer-data-[slot=switch]:normal-case",a),...l})}function S4({className:a,...l}){return r.jsx("textarea",{"data-slot":"textarea",className:ve("flex field-sizing-content min-h-16 w-full resize-none rounded-none border border-transparent border-b-input bg-transparent px-0 py-3 text-base transition-[color,border-color] outline-none placeholder:text-muted-foreground focus-visible:border-b-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-b-destructive md:text-sm dark:aria-invalid:border-b-destructive/50",a),...l})}function Ev({...a}){return r.jsx(o4,{"data-slot":"collapsible",...a})}function Cv({...a}){return r.jsx(f4,{"data-slot":"collapsible-trigger",...a})}function Tv({...a}){return r.jsx(d4,{"data-slot":"collapsible-content",...a})}const j4=["prompt_tokens","completion_tokens","input_tokens","output_tokens","inputTokens","outputTokens","inputTokens.total","outputTokens.total","cost","cost_usd_total","cost_details.total_cost"],N4=new Set(["model","modelId","provider","type","message.model","metadata.used_model","metadata.used_provider","providerMetadata.llmgateway.usedModel","providerMetadata.llmgateway.usedProvider","providerMetadata.llmgateway.provider",...j4.flatMap(a=>["usage","message.usage","providerMetadata.llmgateway.usage","providerMetadata.llmgateway","providerMetadata.gateway"].map(l=>`${l}.${a}`))]),Mv=new Set([...N4].flatMap(a=>{const l=a.split(".");return l.map((s,o)=>l.slice(0,o+1).join("."))}));Mv.add("choices");Mv.add("error");var N0;(function(a){a.STATIC="static",a.DYNAMIC="dynamic"})(N0||(N0={}));var ns;(function(a){a.SMALL="small",a.DEFAULT="default",a.LARGE="large",a.XLARGE="xlarge"})(ns||(ns={}));ns.SMALL+"",ns.DEFAULT+"",ns.LARGE+"",ns.XLARGE+"";var w0;(function(a){a.INFO="info",a.ERROR="error",a.WARNING="warning"})(w0||(w0={}));ve("relative overflow-hidden","dark:bg-[#1a1a1a] bg-white","border dark:border-white/[0.08] border-gray-200","backdrop-blur-xl","rounded-2xl","dark:shadow-[0_8px_32px_rgba(0,0,0,0.4)] shadow-[0_2px_8px_rgba(0,0,0,0.04)]");function w4({column:a,onInsertText:l}){return r.jsxs("button",{onClick:()=>l==null?void 0:l(a.name),className:"flex w-full items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-muted",title:`Click to insert "${a.name}"`,children:[a.primaryKey?r.jsx(yx,{className:"h-3 w-3 shrink-0 text-yellow-500"}):r.jsx(px,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate font-mono",children:a.name}),r.jsxs("span",{className:"ml-auto truncate text-muted-foreground",children:[a.type,a.notNull&&!a.primaryKey&&" NOT NULL"]})]})}function E4({table:a,onInsertText:l}){const[s,o]=x.useState(!1);return r.jsxs(Ev,{open:s,onOpenChange:o,children:[r.jsxs(Cv,{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm hover:bg-muted",children:[s?r.jsx(mx,{className:"h-4 w-4 shrink-0"}):r.jsx(si,{className:"h-4 w-4 shrink-0"}),r.jsx(ko,{className:"h-4 w-4 shrink-0 text-blue-500"}),r.jsx("span",{className:"truncate font-medium cursor-pointer",onClick:f=>{f.stopPropagation(),l==null||l(a.name)},title:`Click to insert "${a.name}"`,children:a.name}),r.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[a.columns.length," cols"]})]}),r.jsx(Tv,{children:r.jsx("div",{className:"ml-4 border-l pl-2",children:a.columns.map(f=>r.jsx(w4,{column:f,onInsertText:l},f.name))})})]})}function C4({onInsertText:a}){const{data:l,isLoading:s,refetch:o}=it({queryKey:["auth-schema"],queryFn:UN,staleTime:3e4}),f=(l==null?void 0:l.tables)||[];return r.jsxs("div",{className:"flex h-full flex-col border-l bg-card",children:[r.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[r.jsx("h3",{className:"text-sm font-semibold",children:"Auth Tables"}),r.jsx(De,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>o(),disabled:s,children:r.jsx(Gr,{className:ve("h-4 w-4",s&&"animate-spin")})})]}),r.jsx(jv,{className:"flex-1",children:r.jsx("div",{className:"p-2",children:s?r.jsx("p",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"Loading schema..."}):f.length===0?r.jsx("p",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No tables found"}):r.jsx("div",{className:"space-y-0.5",children:f.map(d=>r.jsx(E4,{table:d,onInsertText:a},d.name))})})}),r.jsx("div",{className:"border-t px-3 py-2 text-xs text-muted-foreground",children:"Click table/column names to insert"})]})}function T4(a){return a===null?"NULL":a===void 0?"":typeof a=="object"?JSON.stringify(a):String(a)}function M4(a){if(a<60)return`${a} seconds`;if(a<3600)return`${Math.floor(a/60)} minutes`;if(a<86400){const s=Math.floor(a/3600);return`${s} hour${s>1?"s":""}`}const l=Math.floor(a/86400);return`${l} day${l>1?"s":""}`}function A4({settings:a,onUpdate:l,isUpdating:s}){const[o,f]=x.useState(a.sessionTokenExpiry.toString()),[d,m]=x.useState(a.allowSignups),[y,p]=x.useState(a.requireEmailVerification),[g,b]=x.useState(a.requireName),j=()=>{l({sessionTokenExpiry:parseInt(o,10),allowSignups:d,requireEmailVerification:y,requireName:g})},S=parseInt(o,10)!==a.sessionTokenExpiry||d!==a.allowSignups||y!==a.requireEmailVerification||g!==a.requireName;return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Cl,{htmlFor:"sessionTokenExpiry",children:"Session Token Expiry (seconds)"}),r.jsx(ls,{id:"sessionTokenExpiry",type:"number",min:3600,max:7776e3,value:o,onChange:w=>f(w.target.value)}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Current: ",M4(parseInt(o,10)||0)," (min: 1 hour, max: 90 days)"]})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Cl,{children:"Allow Signups"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Allow new users to create accounts"})]}),r.jsx(yd,{checked:d,onCheckedChange:m})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Cl,{children:"Require Email Verification"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Users must verify their email before accessing the app"})]}),r.jsx(yd,{checked:y,onCheckedChange:p})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(Cl,{children:"Require Name"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Require users to enter their name during sign up"})]}),r.jsx(yd,{checked:g,onCheckedChange:b})]})]}),r.jsx("div",{className:"flex justify-end",children:r.jsx(De,{onClick:j,disabled:!S||s,children:s?"Saving...":"Save Settings"})})]})}function R4(){var ue,le,ne,A,X,Y;const a=Ss(),[l,s]=x.useState("settings"),[o,f]=x.useState(""),[d,m]=x.useState(null),[y,p]=x.useState(null),[g,b]=x.useState(null),[j,S]=x.useState(0),w=50,M=((le=(ue=it({queryKey:["config"],queryFn:Do,staleTime:6e4}).data)==null?void 0:ue.auth)==null?void 0:le.binding)||"AUTH",O=it({queryKey:["auth-settings"],queryFn:qN,staleTime:0}),z=xs({mutationFn:BN,onSuccess:()=>{a.invalidateQueries({queryKey:["auth-settings"]})}}),D=F=>{z.mutate(F)},$=x.useCallback(F=>{f(I=>I+F)},[]),_=xs({mutationFn:F=>HN(F),onSuccess:F=>{m(F),p(null)},onError:F=>{p(F instanceof Error?F.message:"Failed to execute query"),m(null)}}),V=()=>{o.trim()&&_.mutate(o)},ae=it({queryKey:["auth-tables"],queryFn:_N,staleTime:0,gcTime:0}),Z=it({queryKey:["auth-tableData",g,w,j],queryFn:()=>LN(g,w,j),staleTime:0,gcTime:0,enabled:!!g}),q=((ne=ae.data)==null?void 0:ne.tables)||[],J=((A=Z.data)==null?void 0:A.data)||[],Q=((X=Z.data)==null?void 0:X.columns)||[],se=((Y=Z.data)==null?void 0:Y.total)||0,re=F=>{b(F),S(0)};return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsxs("h2",{className:"text-3xl font-bold tracking-tight",children:["Auth: ",M]}),r.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/50 p-4",children:[r.jsx(gx,{className:"h-5 w-5 mt-0.5 text-blue-500 shrink-0"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:"Ploy Auth Database"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"This is the Ploy Auth database containing user accounts and refresh tokens. Password hashes are hidden for security. Only SELECT queries are allowed."})]})]}),r.jsxs(Nv,{value:l,onValueChange:s,children:[r.jsxs(wv,{children:[r.jsxs(zr,{value:"settings",children:[r.jsx(iN,{className:"mr-2 h-4 w-4"}),"Settings"]}),r.jsx(zr,{value:"query",children:"SQL Editor"}),r.jsx(zr,{value:"tables",children:"Tables"})]}),r.jsx(kr,{value:"settings",className:"mt-4",children:r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Auth Settings"}),r.jsx(kt,{children:"Configure authentication settings for local development."})]}),r.jsx(ut,{children:O.isLoading?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(zn,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):O.data?r.jsx(A4,{settings:O.data,onUpdate:D,isUpdating:z.isPending}):r.jsx("p",{className:"text-muted-foreground",children:"Failed to load settings"})})]})}),r.jsx(kr,{value:"query",className:"mt-4",children:r.jsxs("div",{className:"grid grid-cols-1 gap-0 lg:grid-cols-[1fr_280px]",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"SQL Query"}),r.jsx(kt,{children:"Execute read-only SELECT queries against auth tables"})]}),r.jsxs(ut,{className:"space-y-4",children:[r.jsx("textarea",{value:o,onChange:F=>f(F.target.value),onKeyDown:F=>{(F.metaKey||F.ctrlKey)&&F.key==="Enter"&&V()},placeholder:"SELECT * FROM auth_users LIMIT 10;",className:"w-full h-32 p-2 font-mono text-sm border rounded bg-background"}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Press Cmd/Ctrl + Enter to execute (SELECT only)"}),r.jsxs(De,{onClick:V,disabled:_.isPending||!o.trim(),children:[r.jsx(uh,{className:"mr-2 h-4 w-4"}),_.isPending?"Executing...":"Execute"]})]})]})]}),y&&r.jsx(rt,{className:"border-destructive/50",children:r.jsx(ut,{className:"pt-6",children:r.jsx("p",{className:"font-mono text-sm text-destructive",children:y})})}),d&&r.jsx(Vx,{results:d.results,meta:d.meta,error:d.error})]}),r.jsx("div",{className:"hidden h-[500px] lg:block",children:r.jsx(C4,{onInsertText:$})})]})}),r.jsx(kr,{value:"tables",className:"mt-4",children:r.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-4",children:[r.jsxs(rt,{className:"md:col-span-1",children:[r.jsxs(yt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(xt,{className:"text-base",children:"Tables"}),r.jsx(De,{variant:"ghost",size:"icon",onClick:()=>ae.refetch(),className:"h-8 w-8",children:r.jsx(Gr,{className:"h-4 w-4"})})]}),r.jsx(ut,{children:ae.isLoading?r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."}):q.length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:"No tables found"}):r.jsx("div",{className:"space-y-1",children:q.map(F=>r.jsxs("button",{onClick:()=>re(F.name),className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors hover:bg-muted ${g===F.name?"bg-muted font-medium":""}`,children:[r.jsx(ko,{className:"h-4 w-4 shrink-0"}),r.jsx("span",{className:"truncate",children:F.name})]},F.name))})})]}),r.jsxs(rt,{className:"md:col-span-3",children:[r.jsxs(yt,{children:[r.jsx(xt,{children:g||"Select a Table"}),g&&r.jsxs(kt,{children:[se," total rows"]})]}),r.jsx(ut,{children:g?Z.isLoading?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(zn,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):J.length===0?r.jsx("p",{className:"py-8 text-center text-muted-foreground",children:"No data in this table"}):r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"overflow-x-auto rounded-md border",children:r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsx(ct,{children:Q.map(F=>r.jsx(je,{className:"font-mono",children:F},F))})}),r.jsx(_n,{children:J.map((F,I)=>r.jsx(ct,{children:Q.map(N=>r.jsx(Ne,{className:"font-mono text-sm",children:T4(F[N])},N))},I))})]})}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-sm text-muted-foreground",children:["Showing ",j+1," -"," ",Math.min(j+w,se)," of ",se]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",disabled:j===0,onClick:()=>S(Math.max(0,j-w)),children:[r.jsx(Yr,{className:"mr-1 h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",disabled:j+w>=se,onClick:()=>S(j+w),children:["Next",r.jsx(si,{className:"ml-1 h-4 w-4"})]})]})]})]}):r.jsx("p",{className:"py-8 text-center text-muted-foreground",children:"Select a table from the list to view its data"})})]})]})})]})]})})}function Ln(){return r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(zn,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}function sn({children:a}){return r.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:a})}function oi({id:a}){return r.jsxs("span",{className:"font-mono text-xs",children:[a.slice(0,8),"..."]})}function Vt({title:a,value:l,icon:s,isLoading:o}){return r.jsxs(rt,{children:[r.jsxs(yt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(xt,{className:"text-sm font-medium",children:a}),s]}),r.jsx(ut,{children:r.jsx("div",{className:"text-2xl font-bold",children:o?r.jsx(zn,{className:"h-5 w-5 animate-spin"}):l})})]})}function Qa({title:a,children:l}){return r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:a}),l]})}function O4(a){const l='<base target="_blank">';return/<head[^>]*>/i.test(a)?a.replace(/<head[^>]*>/i,s=>`${s}${l}`):`${l}${a}`}function z4({receive:a,inbox:l}){var g,b;const s=Ss(),o=(g=a[0])!=null&&g.startsWith("*@")?`test${a[0].slice(1)}`:a[0]??(l?"inbox@in.ploy.email":""),[f,d]=x.useState({from:"sender@example.com",to:o,subject:"Hello",text:"This is a test email from the Ploy dev dashboard."}),m=xs({mutationFn:VN,onSuccess:async()=>{await s.invalidateQueries({queryKey:["auth-emails"]})}}),y=j=>S=>{d({...f,[j]:S.target.value})},p=(b=m.data)==null?void 0:b.result;return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Send test email"}),r.jsx(kt,{children:"Delivers an email to your worker's email() handler, as if it arrived at an address in email.receive or the project's inbox address. Replies and forwards land in the inbox below."})]}),r.jsx(ut,{children:r.jsxs("form",{className:"grid gap-3 md:grid-cols-2",onSubmit:j=>{j.preventDefault(),m.mutate(f)},children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(Cl,{htmlFor:"test-email-from",children:"From"}),r.jsx(ls,{id:"test-email-from",value:f.from,onChange:y("from")})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(Cl,{htmlFor:"test-email-to",children:"To"}),r.jsx(ls,{id:"test-email-to",value:f.to,onChange:y("to")})]}),r.jsxs("div",{className:"space-y-1 md:col-span-2",children:[r.jsx(Cl,{htmlFor:"test-email-subject",children:"Subject"}),r.jsx(ls,{id:"test-email-subject",value:f.subject,onChange:y("subject")})]}),r.jsxs("div",{className:"space-y-1 md:col-span-2",children:[r.jsx(Cl,{htmlFor:"test-email-text",children:"Text"}),r.jsx(S4,{id:"test-email-text",rows:3,value:f.text,onChange:y("text")})]}),r.jsxs("div",{className:"flex items-center gap-3 md:col-span-2",children:[r.jsxs(De,{type:"submit",size:"sm",disabled:m.isPending,children:[r.jsx(aN,{className:"mr-2 h-4 w-4"}),"Send"]}),r.jsx("span",{className:"text-sm text-muted-foreground",children:m.error?m.error.message:p!=null&&p.rejected?`Rejected: ${p.rejected}`:p!=null&&p.relayed?"Relayed to the original sender":p!=null&&p.success?"Handled by email()":(p==null?void 0:p.error)??""})]})]})})]})}function k4({id:a}){const{data:l,isLoading:s}=it({queryKey:["auth-email",a],queryFn:()=>YN(a)});if(s)return r.jsx(Ln,{});if(!l)return r.jsx(sn,{children:"Email not found"});const{email:o}=l;return r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"space-y-1 text-sm",children:[o.from&&r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"From: "}),o.from]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"To: "}),o.to]}),o.cc&&r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Cc: "}),o.cc]}),o.bcc&&r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Bcc: "}),o.bcc]}),o.replyTo&&r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Reply-To: "}),o.replyTo]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Subject: "}),o.subject]}),r.jsx("div",{className:"text-muted-foreground",children:new Date(o.createdAt).toLocaleString()})]}),o.html?r.jsx("iframe",{title:o.subject,sandbox:"allow-popups allow-popups-to-escape-sandbox",srcDoc:O4(o.html),className:"h-[560px] w-full rounded-md border bg-white"}):null,r.jsxs("details",{className:"text-sm",open:!o.html,children:[r.jsx("summary",{className:"cursor-pointer text-muted-foreground",children:"Plain text"}),r.jsx("pre",{className:"mt-2 whitespace-pre-wrap rounded-md bg-muted p-3 font-mono text-xs",children:o.text})]})]})}function D4(){var g;const a=Ss(),[l,s]=x.useState(null),{data:o,isLoading:f}=it({queryKey:["auth-emails"],queryFn:QN,refetchInterval:3e3}),{data:d}=it({queryKey:["config"],queryFn:Do}),m=xs({mutationFn:GN,onSuccess:async()=>{s(null),await a.invalidateQueries({queryKey:["auth-emails"]})}}),y=(o==null?void 0:o.emails)??[],p=l??((g=y[0])==null?void 0:g.id)??null;return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:"Emails",children:r.jsxs(De,{variant:"outline",size:"sm",disabled:y.length===0||m.isPending,onClick:()=>{m.mutate()},children:[r.jsx(Sx,{className:"mr-2 h-4 w-4"}),"Clear inbox"]})}),(d==null?void 0:d.email)&&r.jsx(z4,{receive:d.email.receive??[],inbox:d.email.inbox??!1}),r.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]",children:[r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Inbox"}),r.jsx(kt,{children:"Emails from Ploy Auth and from your worker's email binding. Under ploy dev nothing is sent; every email lands here."})]}),r.jsx(ut,{children:f?r.jsx(Ln,{}):y.length===0?r.jsx(sn,{children:"No emails yet. Send one from your worker, sign up or request a password reset to see one."}):r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Time"}),r.jsx(je,{children:"Type"}),r.jsx(je,{children:"To"}),r.jsx(je,{children:"Subject"})]})}),r.jsx(_n,{children:y.map(b=>r.jsxs(ct,{className:ve("cursor-pointer",b.id===p&&"bg-muted"),onClick:()=>{s(b.id)},children:[r.jsx(Ne,{className:"whitespace-nowrap text-xs text-muted-foreground",children:new Date(b.createdAt).toLocaleTimeString()}),r.jsx(Ne,{children:r.jsx(p4,{variant:"outline",children:b.purpose==="worker"?"Worker":"Auth"})}),r.jsx(Ne,{className:"text-sm",children:b.to}),r.jsx(Ne,{className:"text-sm",children:b.subject})]},b.id))})]})})]}),r.jsx(rt,{children:r.jsx(ut,{className:"pt-6",children:p?r.jsx(k4,{id:p}):r.jsx(sn,{children:"Select an email to preview it"})})})]})]})})}const po=20;function _4(a){if(a===null)return"Never";const l=a-Math.floor(Date.now()/1e3);return l<=0?"Expired":l<60?`${l}s`:l<3600?`${Math.floor(l/60)}m`:l<86400?`${Math.floor(l/3600)}h`:`${Math.floor(l/86400)}d`}function L4({entries:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Cache Entries"}),r.jsx(kt,{children:"Key-value entries in this cache store (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Key"}),r.jsx(je,{children:"Value"}),r.jsx(je,{children:"Expires"})]})}),r.jsx(_n,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{className:"font-mono text-sm",children:s.key}),r.jsx(Ne,{className:"max-w-[400px] truncate font-mono text-xs text-muted-foreground",children:s.value}),r.jsx(Ne,{className:"font-mono text-xs text-muted-foreground",children:_4(s.expiresAt)})]},s.key))})]}):r.jsx(sn,{children:"No entries in this cache store"})})]})}function U4(){const{binding:a}=qa(),l=a||"",[s,o]=x.useState(0),[f,d]=x.useState(""),[m,y]=x.useState(""),{data:p,isLoading:g}=it({queryKey:["cacheEntries",l,s,f],queryFn:()=>EN(l,po,s,f),enabled:!!l,refetchInterval:5e3}),b=(p==null?void 0:p.hasMore)??!1,j=Math.floor(s/po)+1,S=w=>{w.preventDefault(),d(m),o(0)};return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:`Cache: ${l}`}),r.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[r.jsx(ls,{placeholder:"Search by key...",value:m,onChange:w=>y(w.target.value),className:"max-w-sm"}),r.jsxs(De,{type:"submit",variant:"outline",size:"sm",children:[r.jsx(bx,{className:"h-4 w-4 mr-1"}),"Search"]}),f&&r.jsx(De,{type:"button",variant:"ghost",size:"sm",onClick:()=>{d(""),y(""),o(0)},children:"Clear"})]}),r.jsx(L4,{entries:p==null?void 0:p.entries,isLoading:g}),(s>0||b)&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",j]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>o(Math.max(0,s-po)),disabled:s===0,children:[r.jsx(Yr,{className:"h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>o(s+po),disabled:!b,children:["Next",r.jsx(si,{className:"h-4 w-4"})]})]})]})]})})}const H4={PENDING:{variant:"default",icon:r.jsx(ri,{className:"h-3 w-3"}),label:"Pending"},RUNNING:{variant:"blue",icon:r.jsx(zn,{className:"h-3 w-3 animate-spin"}),label:"Running"},COMPLETED:{variant:"success",icon:r.jsx(Tl,{className:"h-3 w-3"}),label:"Completed"},FAILED:{variant:"error",icon:r.jsx(ws,{className:"h-3 w-3"}),label:"Failed"},CANCELLED:{variant:"default",icon:r.jsx(yj,{className:"h-3 w-3"}),label:"Cancelled"}},q4={PENDING:{variant:"default",icon:r.jsx(ri,{className:"h-3 w-3"}),label:"Pending"},PROCESSING:{variant:"blue",icon:r.jsx(zn,{className:"h-3 w-3 animate-spin"}),label:"Processing"},ACKNOWLEDGED:{variant:"success",icon:r.jsx(Tl,{className:"h-3 w-3"}),label:"Acknowledged"},FAILED:{variant:"error",icon:r.jsx(ws,{className:"h-3 w-3"}),label:"Failed"},DEAD_LETTER:{variant:"orange",icon:r.jsx(Aj,{className:"h-3 w-3"}),label:"Dead Letter"}};function Ch({status:a}){const l=H4[a];return l?r.jsx(Ml,{variant:l.variant,icon:l.icon,children:l.label}):r.jsx(Ml,{children:a})}const B4={PENDING:{variant:"default",icon:r.jsx(ri,{className:"h-3 w-3"}),label:"Pending"},FIRED:{variant:"success",icon:r.jsx(Tl,{className:"h-3 w-3"}),label:"Fired"},COMPLETED:{variant:"success",icon:r.jsx(Tl,{className:"h-3 w-3"}),label:"Completed"},FAILED:{variant:"error",icon:r.jsx(ws,{className:"h-3 w-3"}),label:"Failed"}};function Av({status:a}){const l=B4[a];return l?r.jsx(Ml,{variant:l.variant,icon:l.icon,children:l.label}):r.jsx(Ml,{children:a})}function Q4({status:a}){const l=q4[a];return l?r.jsx(Ml,{variant:l.variant,icon:l.icon,children:l.label}):r.jsx(Ml,{children:a})}const Y4={provisioning:{variant:"blue",icon:r.jsx(zn,{className:"h-3 w-3 animate-spin"}),label:"Provisioning"},active:{variant:"success",icon:r.jsx(dx,{className:"h-3 w-3"}),label:"Active"},idle:{variant:"default",icon:r.jsx(vx,{className:"h-3 w-3"}),label:"Idle"},sleeping:{variant:"warning",icon:r.jsx(xx,{className:"h-3 w-3"}),label:"Sleeping"},stopped:{variant:"default",icon:r.jsx(fN,{className:"h-3 w-3"}),label:"Stopped"},destroyed:{variant:"error",icon:r.jsx(Sx,{className:"h-3 w-3"}),label:"Destroyed"}};function G4({status:a,active:l}){const o=Y4[a==="running"?l?"active":"idle":a];return o?r.jsx(Ml,{variant:o.variant,icon:o.icon,children:o.label}):r.jsx(Ml,{children:a})}function V4({executions:a,cronExpression:l,isLoading:s}){const o=(a==null?void 0:a.filter(d=>d.status==="COMPLETED").length)??0,f=(a==null?void 0:a.filter(d=>d.status==="FAILED").length)??0;return r.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[r.jsx(Vt,{title:"Schedule",value:l??"-",icon:r.jsx(ri,{className:"h-4 w-4 text-muted-foreground"}),isLoading:s}),r.jsx(Vt,{title:"Completed",value:o,icon:r.jsx(Tl,{className:"h-4 w-4 text-green-500"}),isLoading:s}),r.jsx(Vt,{title:"Failed",value:f,icon:r.jsx(ws,{className:"h-4 w-4 text-red-500"}),isLoading:s})]})}function X4({executions:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Execution History"}),r.jsx(kt,{children:"Recent cron handler executions (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Triggered"}),r.jsx(je,{children:"Duration"}),r.jsx(je,{children:"Error"}),r.jsx(je,{children:"Completed"})]})}),r.jsx(_n,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(oi,{id:s.id})}),r.jsx(Ne,{children:r.jsx(Ch,{status:s.status})}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.triggeredAt})}),r.jsx(Ne,{children:s.durationMs!==void 0&&s.durationMs!==null?`${s.durationMs}ms`:"-"}),r.jsx(Ne,{className:"max-w-[200px] truncate text-xs text-red-500",children:s.error??"-"}),r.jsx(Ne,{children:s.completedAt?r.jsx(yn,{timestamp:s.completedAt}):"-"})]},s.id))})]}):r.jsx(sn,{children:"No cron executions yet"})})]})}function K4(){const{binding:a}=qa(),l=a||"",s=Ss(),{data:o,isLoading:f}=it({queryKey:["cronExecutions",l],queryFn:()=>kN(l,20),enabled:!!l,refetchInterval:5e3}),d=xs({mutationFn:()=>DN(l),onSettled:()=>{s.invalidateQueries({queryKey:["cronExecutions",l]})}});return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:`Cron: ${l}`,children:r.jsxs(De,{size:"sm",disabled:!l||d.isPending,onClick:()=>{d.mutate()},children:[r.jsx(uh,{className:"h-4 w-4 mr-1"}),d.isPending?"Running...":"Run now"]})}),r.jsx(V4,{executions:o==null?void 0:o.executions,cronExpression:o==null?void 0:o.cronExpression,isLoading:f}),r.jsx(X4,{executions:o==null?void 0:o.executions,isLoading:f})]})})}function $4({column:a,onInsertText:l}){return r.jsxs("button",{onClick:()=>l==null?void 0:l(a.name),className:"flex w-full items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-muted",title:`Click to insert "${a.name}"`,children:[a.primaryKey?r.jsx(yx,{className:"h-3 w-3 shrink-0 text-yellow-500"}):r.jsx(px,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate font-mono",children:a.name}),r.jsxs("span",{className:"ml-auto truncate text-muted-foreground",children:[a.type,a.notNull&&!a.primaryKey&&" NOT NULL"]})]})}function Z4({table:a,onInsertText:l}){const[s,o]=x.useState(!1);return r.jsxs(Ev,{open:s,onOpenChange:o,children:[r.jsxs(Cv,{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm hover:bg-muted",children:[s?r.jsx(mx,{className:"h-4 w-4 shrink-0"}):r.jsx(si,{className:"h-4 w-4 shrink-0"}),r.jsx(ko,{className:"h-4 w-4 shrink-0 text-blue-500"}),r.jsx("span",{className:"truncate font-medium cursor-pointer",onClick:f=>{f.stopPropagation(),l==null||l(a.name)},title:`Click to insert "${a.name}"`,children:a.name}),r.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[a.columns.length," cols"]})]}),r.jsx(Tv,{children:r.jsx("div",{className:"ml-4 border-l pl-2",children:a.columns.map(f=>r.jsx($4,{column:f,onInsertText:l},f.name))})})]})}function F4({bindingName:a,onInsertText:l}){const{data:s,isLoading:o,refetch:f}=it({queryKey:["schema",a],queryFn:()=>NN(a),staleTime:3e4}),d=(s==null?void 0:s.tables)||[];return r.jsxs("div",{className:"flex h-full flex-col border-l bg-card",children:[r.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[r.jsx("h3",{className:"text-sm font-semibold",children:"Tables"}),r.jsx(De,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>f(),disabled:o,children:r.jsx(Gr,{className:ve("h-4 w-4",o&&"animate-spin")})})]}),r.jsx(jv,{className:"flex-1",children:r.jsx("div",{className:"p-2",children:o?r.jsx("p",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"Loading schema..."}):d.length===0?r.jsx("p",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No tables found"}):r.jsx("div",{className:"space-y-0.5",children:d.map(m=>r.jsx(Z4,{table:m,onInsertText:l},m.name))})})}),r.jsx("div",{className:"border-t px-3 py-2 text-xs text-muted-foreground",children:"Click table/column names to insert"})]})}function J4(a){return a===null?"NULL":a===void 0?"":typeof a=="object"?JSON.stringify(a):String(a)}function P4(){var J,Q,se,re;const{binding:a}=qa(),l=a||"",[s,o]=x.useState("query"),[f,d]=x.useState(""),[m,y]=x.useState(null),[p,g]=x.useState(null),[b,j]=x.useState(null),[S,w]=x.useState(0),E=50,M=x.useCallback(ue=>{d(le=>le+ue)},[]),O=xs({mutationFn:ue=>bN(l,ue),onSuccess:ue=>{y(ue),g(null)},onError:ue=>{g(ue instanceof Error?ue.message:"Failed to execute query"),y(null)}}),z=()=>{f.trim()&&O.mutate(f)},D=it({queryKey:["tables",l],queryFn:()=>SN(l),staleTime:0,gcTime:0,enabled:!!l}),$=it({queryKey:["tableData",l,b,E,S],queryFn:()=>jN(l,b,E,S),staleTime:0,gcTime:0,enabled:!!l&&!!b}),_=((J=D.data)==null?void 0:J.tables)||[],V=((Q=$.data)==null?void 0:Q.data)||[],ae=((se=$.data)==null?void 0:se.columns)||[],Z=((re=$.data)==null?void 0:re.total)||0,q=ue=>{j(ue),w(0)};return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsxs("h2",{className:"text-3xl font-bold tracking-tight",children:["Database: ",l]}),r.jsxs(Nv,{value:s,onValueChange:o,children:[r.jsxs(wv,{children:[r.jsx(zr,{value:"query",children:"SQL Editor"}),r.jsx(zr,{value:"tables",children:"Tables"})]}),r.jsx(kr,{value:"query",className:"mt-4",children:r.jsxs("div",{className:"grid grid-cols-1 gap-0 lg:grid-cols-[1fr_280px]",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"SQL Query"}),r.jsx(kt,{children:"Execute SQL queries against your database"})]}),r.jsxs(ut,{className:"space-y-4",children:[r.jsx("textarea",{value:f,onChange:ue=>d(ue.target.value),onKeyDown:ue=>{(ue.metaKey||ue.ctrlKey)&&ue.key==="Enter"&&z()},placeholder:"SELECT * FROM users LIMIT 10;",className:"w-full h-32 p-2 font-mono text-sm border rounded bg-background"}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Press Cmd/Ctrl + Enter to execute"}),r.jsxs(De,{onClick:z,disabled:O.isPending||!f.trim(),children:[r.jsx(uh,{className:"mr-2 h-4 w-4"}),O.isPending?"Executing...":"Execute"]})]})]})]}),p&&r.jsx(rt,{className:"border-destructive/50",children:r.jsx(ut,{className:"pt-6",children:r.jsx("p",{className:"font-mono text-sm text-destructive",children:p})})}),m&&r.jsx(Vx,{results:m.results,meta:m.meta,error:m.error})]}),r.jsx("div",{className:"hidden h-[500px] lg:block",children:r.jsx(F4,{bindingName:l,onInsertText:M})})]})}),r.jsx(kr,{value:"tables",className:"mt-4",children:r.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-4",children:[r.jsxs(rt,{className:"md:col-span-1",children:[r.jsxs(yt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(xt,{className:"text-base",children:"Tables"}),r.jsx(De,{variant:"ghost",size:"icon",onClick:()=>D.refetch(),className:"h-8 w-8",children:r.jsx(Gr,{className:"h-4 w-4"})})]}),r.jsx(ut,{children:D.isLoading?r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."}):_.length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:"No tables found"}):r.jsx("div",{className:"space-y-1",children:_.map(ue=>r.jsxs("button",{onClick:()=>q(ue.name),className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors hover:bg-muted ${b===ue.name?"bg-muted font-medium":""}`,children:[r.jsx(ko,{className:"h-4 w-4 shrink-0"}),r.jsx("span",{className:"truncate",children:ue.name})]},ue.name))})})]}),r.jsxs(rt,{className:"md:col-span-3",children:[r.jsxs(yt,{children:[r.jsx(xt,{children:b||"Select a Table"}),b&&r.jsxs(kt,{children:[Z," total rows"]})]}),r.jsx(ut,{children:b?$.isLoading?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(zn,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):V.length===0?r.jsx("p",{className:"py-8 text-center text-muted-foreground",children:"No data in this table"}):r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"overflow-x-auto rounded-md border",children:r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsx(ct,{children:ae.map(ue=>r.jsx(je,{className:"font-mono",children:ue},ue))})}),r.jsx(_n,{children:V.map((ue,le)=>r.jsx(ct,{children:ae.map(ne=>r.jsx(Ne,{className:"font-mono text-sm",children:J4(ue[ne])},ne))},le))})]})}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-sm text-muted-foreground",children:["Showing ",S+1," -"," ",Math.min(S+E,Z)," of ",Z]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",disabled:S===0,onClick:()=>w(Math.max(0,S-E)),children:[r.jsx(Yr,{className:"mr-1 h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",disabled:S+E>=Z,onClick:()=>w(S+E),children:["Next",r.jsx(si,{className:"ml-1 h-4 w-4"})]})]})]})]}):r.jsx("p",{className:"py-8 text-center text-muted-foreground",children:"Select a table from the list to view its data"})})]})]})})]})]})})}const Zl=20;function I4(a){return a<1024?`${a} B`:a<1024*1024?`${(a/1024).toFixed(1)} KB`:a<1024*1024*1024?`${(a/(1024*1024)).toFixed(1)} MB`:`${(a/(1024*1024*1024)).toFixed(1)} GB`}function W4({entries:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Files"}),r.jsx(kt,{children:"Stored files with metadata (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Key"}),r.jsx(je,{children:"Size"}),r.jsx(je,{children:"Content Type"}),r.jsx(je,{children:"Created At"})]})}),r.jsx(_n,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{className:"font-mono text-sm",children:s.key}),r.jsx(Ne,{className:"text-sm text-muted-foreground",children:I4(s.size)}),r.jsx(Ne,{className:"font-mono text-xs text-muted-foreground",children:s.contentType}),r.jsx(Ne,{className:"text-sm text-muted-foreground",children:s.createdAt})]},s.key))})]}):r.jsx(sn,{children:"No files in this storage"})})]})}function eC(){const{binding:a}=qa(),l=a||"",[s,o]=x.useState(0),{data:f,isLoading:d}=it({queryKey:["fileStorageEntries",l,s],queryFn:()=>XN(l,Zl,s),enabled:!!l,refetchInterval:5e3}),m=(f==null?void 0:f.total)??0,y=Math.floor(s/Zl)+1,p=Math.ceil(m/Zl);return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:`File Storage: ${l}`}),r.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:r.jsx(Vt,{title:"Total Files",value:m})}),r.jsx(W4,{entries:f==null?void 0:f.entries,isLoading:d}),m>Zl&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",y," of ",p]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>o(Math.max(0,s-Zl)),disabled:s===0,children:[r.jsx(Yr,{className:"h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>o(s+Zl),disabled:s+Zl>=m,children:["Next",r.jsx(si,{className:"h-4 w-4"})]})]})]})]})})}function tC({metrics:a,isLoading:l}){return r.jsxs("div",{className:"grid gap-4 md:grid-cols-5",children:[r.jsx(Vt,{title:"Pending",value:(a==null?void 0:a.pending)??0,icon:r.jsx(ri,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Processing",value:(a==null?void 0:a.processing)??0,icon:r.jsx(zn,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Acknowledged",value:(a==null?void 0:a.acknowledged)??0,icon:r.jsx(Tl,{className:"h-4 w-4 text-green-500"}),isLoading:l}),r.jsx(Vt,{title:"Failed",value:(a==null?void 0:a.failed)??0,icon:r.jsx(ws,{className:"h-4 w-4 text-red-500"}),isLoading:l}),r.jsx(Vt,{title:"Dead Letter",value:(a==null?void 0:a.deadLetter)??0,icon:r.jsx(Zj,{className:"h-4 w-4 text-orange-500"}),isLoading:l})]})}function nC({messages:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Recent Messages"}),r.jsx(kt,{children:"Latest messages in this queue (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Payload"}),r.jsx(je,{children:"Attempt"}),r.jsx(je,{children:"Created"})]})}),r.jsx(_n,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(oi,{id:s.id})}),r.jsx(Ne,{children:r.jsx(Q4,{status:s.status})}),r.jsx(Ne,{className:"max-w-[200px] truncate font-mono text-xs",children:JSON.stringify(s.payload)}),r.jsx(Ne,{children:s.attempt}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.createdAt})})]},s.id))})]}):r.jsx(sn,{children:"No messages in this queue"})})]})}function aC(){const{binding:a}=qa(),l=a||"",{data:s,isLoading:o}=it({queryKey:["queueMetrics",l],queryFn:()=>CN(l),enabled:!!l,refetchInterval:5e3}),{data:f,isLoading:d}=it({queryKey:["queueMessages",l],queryFn:()=>TN(l,10),enabled:!!l,refetchInterval:5e3});return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:`Queue: ${l}`}),r.jsx(tC,{metrics:s==null?void 0:s.metrics,isLoading:o}),r.jsx(nC,{messages:f==null?void 0:f.messages,isLoading:d})]})})}function lC({sandboxes:a,isLoading:l}){const s=(a==null?void 0:a.length)??0,o=(a==null?void 0:a.filter(y=>y.active).length)??0,f=(a==null?void 0:a.filter(y=>y.status==="running"&&!y.active).length)??0,d=(a==null?void 0:a.filter(y=>y.status==="sleeping").length)??0,m=(a==null?void 0:a.reduce((y,p)=>y+p.sessionCount,0))??0;return r.jsxs("div",{className:"grid gap-4 md:grid-cols-5",children:[r.jsx(Vt,{title:"Sandboxes",value:s,icon:r.jsx(hx,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Active",value:o,icon:r.jsx(dx,{className:"h-4 w-4 text-green-500"}),isLoading:l}),r.jsx(Vt,{title:"Idle",value:f,icon:r.jsx(vx,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Sleeping",value:d,icon:r.jsx(xx,{className:"h-4 w-4 text-orange-500"}),isLoading:l}),r.jsx(Vt,{title:"Sessions",value:m,icon:r.jsx(oN,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l})]})}function iC({sandboxes:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Sandboxes"}),r.jsx(kt,{children:"Live sandbox instances launched via env.<binding>.get(id) (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Image"}),r.jsx(je,{children:"Sessions"}),r.jsx(je,{children:"Container"})]})}),r.jsx(_n,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{className:"font-mono text-xs",children:s.externalId}),r.jsx(Ne,{children:r.jsx(G4,{status:s.status,active:s.active})}),r.jsx(Ne,{className:"font-mono text-xs",children:s.image}),r.jsx(Ne,{children:s.sessionCount}),r.jsx(Ne,{children:s.containerId?r.jsx(oi,{id:s.containerId}):r.jsx("span",{className:"text-muted-foreground",children:"—"})})]},s.id))})]}):r.jsx(sn,{children:"No sandboxes yet — call env.<binding>.get(id) from your worker to launch one"})})]})}function sC(){const{data:a,isLoading:l}=it({queryKey:["sandboxes"],queryFn:vN,refetchInterval:5e3});return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:"Sandboxes"}),r.jsx(lC,{sandboxes:a==null?void 0:a.sandboxes,isLoading:l}),r.jsx(iC,{sandboxes:a==null?void 0:a.sandboxes,isLoading:l})]})})}const go=20;function rC({entries:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"State Entries"}),r.jsx(kt,{children:"Key-value entries in this state store (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Key"}),r.jsx(je,{children:"Value"})]})}),r.jsx(_n,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{className:"font-mono text-sm",children:s.key}),r.jsx(Ne,{className:"max-w-[400px] truncate font-mono text-xs text-muted-foreground",children:s.value})]},s.key))})]}):r.jsx(sn,{children:"No entries in this state store"})})]})}function uC(){const{binding:a}=qa(),l=a||"",[s,o]=x.useState(0),[f,d]=x.useState(""),[m,y]=x.useState(""),{data:p,isLoading:g}=it({queryKey:["stateEntries",l,s,f],queryFn:()=>wN(l,go,s,f),enabled:!!l,refetchInterval:5e3}),b=(p==null?void 0:p.hasMore)??!1,j=Math.floor(s/go)+1,S=w=>{w.preventDefault(),d(m),o(0)};return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:`State: ${l}`}),r.jsxs("form",{onSubmit:S,className:"flex gap-2",children:[r.jsx(ls,{placeholder:"Search by key...",value:m,onChange:w=>y(w.target.value),className:"max-w-sm"}),r.jsxs(De,{type:"submit",variant:"outline",size:"sm",children:[r.jsx(bx,{className:"h-4 w-4 mr-1"}),"Search"]}),f&&r.jsx(De,{type:"button",variant:"ghost",size:"sm",onClick:()=>{d(""),y(""),o(0)},children:"Clear"})]}),r.jsx(rC,{entries:p==null?void 0:p.entries,isLoading:g}),(s>0||b)&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",j]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>o(Math.max(0,s-go)),disabled:s===0,children:[r.jsx(Yr,{className:"h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>o(s+go),disabled:!b,children:["Next",r.jsx(si,{className:"h-4 w-4"})]})]})]})]})})}function oC(a){if(a<1e3)return`${a}ms`;const l=Math.floor(a/1e3);if(l<60)return`${l}s`;const s=Math.floor(l/60),o=l%60;if(s<60)return o===0?`${s}m`:`${s}m ${o}s`;const f=Math.floor(s/60),d=s%60;if(f<24)return d===0?`${f}h`:`${f}h ${d}m`;const m=Math.floor(f/24),y=f%24;return y===0?`${m}d`:`${m}d ${y}h`}function cC({metrics:a,isLoading:l}){return r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[r.jsx(Vt,{title:"Pending",value:(a==null?void 0:a.pending)??0,icon:r.jsx(ri,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Fired",value:(a==null?void 0:a.fired)??0,icon:r.jsx(Tl,{className:"h-4 w-4 text-green-500"}),isLoading:l})]})}function fC({entries:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Scheduled Timers"}),r.jsx(kt,{children:"Timer entries scheduled by your worker (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Scheduled Time"}),r.jsx(je,{children:"Interval"}),r.jsx(je,{children:"Payload"}),r.jsx(je,{children:"Created"})]})}),r.jsx(_n,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(oi,{id:s.id})}),r.jsx(Ne,{children:r.jsx(Av,{status:s.status})}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.scheduledTime})}),r.jsx(Ne,{className:"text-xs",children:s.intervalMs!==void 0&&s.intervalMs!==null?r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(eN,{className:"h-3 w-3"}),oC(s.intervalMs)]}):"-"}),r.jsx(Ne,{className:"max-w-[200px] truncate font-mono text-xs",children:s.payload!==void 0&&s.payload!==null?JSON.stringify(s.payload):"-"}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.createdAt})})]},s.id))})]}):r.jsx(sn,{children:"No timers scheduled"})})]})}function dC({executions:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Execution History"}),r.jsx(kt,{children:"Recent timer handler executions"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Timer ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Scheduled Time"}),r.jsx(je,{children:"Duration"}),r.jsx(je,{children:"Error"}),r.jsx(je,{children:"Executed"})]})}),r.jsx(_n,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(oi,{id:s.timerId})}),r.jsx(Ne,{children:r.jsx(Av,{status:s.status})}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.scheduledTime})}),r.jsx(Ne,{children:s.durationMs!==void 0&&s.durationMs!==null?`${s.durationMs}ms`:"-"}),r.jsx(Ne,{className:"max-w-[200px] truncate text-xs text-red-500",children:s.error??"-"}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.createdAt})})]},s.id))})]}):r.jsx(sn,{children:"No timer executions yet"})})]})}function hC(){const{binding:a}=qa(),l=a||"",{data:s,isLoading:o}=it({queryKey:["timerMetrics",l],queryFn:()=>ON(l),enabled:!!l,refetchInterval:5e3}),{data:f,isLoading:d}=it({queryKey:["timerEntries",l],queryFn:()=>RN(l,20),enabled:!!l,refetchInterval:5e3}),{data:m,isLoading:y}=it({queryKey:["timerExecutions",l],queryFn:()=>zN(l,20),enabled:!!l,refetchInterval:5e3});return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:`Timers: ${l}`}),r.jsx(cC,{metrics:s==null?void 0:s.metrics,isLoading:o}),r.jsx(fC,{entries:f==null?void 0:f.entries,isLoading:d}),r.jsx(dC,{executions:m==null?void 0:m.executions,isLoading:y})]})})}function Rr(a){return a!=null}function mC(a,l){const s=[];a&&Rr(a.input)&&s.push("execution-input"),a&&Rr(a.output)&&s.push("execution-output");for(const o of l)Rr(o.input)&&s.push(`${o.id}-input`),Rr(o.output)&&s.push(`${o.id}-output`);return s}function Ro({id:a,label:l,value:s,isOpen:o,onToggle:f}){return Rr(s)?r.jsxs("details",{className:"mt-2",open:o,onToggle:d=>{f(a,d.currentTarget.open)},children:[r.jsx("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:l}),r.jsx("pre",{className:"mt-1 p-2 rounded bg-muted text-xs font-mono overflow-x-auto",children:JSON.stringify(s,null,2)})]}):null}function pC({status:a}){switch(a){case"COMPLETED":return r.jsx(Tl,{className:"h-5 w-5 text-green-500"});case"RUNNING":return r.jsx(zn,{className:"h-5 w-5 text-blue-500 animate-spin"});case"FAILED":return r.jsx(ws,{className:"h-5 w-5 text-red-500"});case"PENDING":default:return r.jsx(ri,{className:"h-5 w-5 text-gray-400"})}}function gC(a){switch(a){case"COMPLETED":return"bg-green-500";case"RUNNING":return"bg-blue-500";case"FAILED":return"bg-red-500";case"PENDING":default:return"bg-gray-300 dark:bg-gray-600"}}function yC(a){return a.attempt!==null&&a.attempt!==void 0&&a.maxRetries!==null&&a.maxRetries!==void 0&&(a.attempt>1||a.status!=="COMPLETED")}function xC({steps:a,openIoSectionIds:l,onToggleIoSection:s}){if(a.length===0)return r.jsx(sn,{children:"No steps recorded for this execution"});const o=a.reduce((f,d)=>f+(d.durationMs||0),0);return r.jsxs("div",{className:"space-y-4",children:[o>0&&r.jsxs("div",{className:"mb-6",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-muted-foreground mb-2",children:[r.jsx("span",{children:"Total Duration"}),r.jsx("span",{children:ts(o)})]}),r.jsx("div",{className:"h-3 bg-muted rounded-full overflow-hidden flex",children:a.map((f,d)=>{const m=f.durationMs?f.durationMs/o*100:0;return r.jsx("div",{className:ve(gC(f.status),"h-full transition-all",d>0&&"border-l border-background"),style:{width:`${m}%`},title:`${f.stepName}: ${ts(f.durationMs)}`},f.id)})})]}),r.jsx("div",{className:"relative",children:a.map((f,d)=>{const m=yC(f);return r.jsxs("div",{className:"relative pb-6 last:pb-0",children:[d<a.length-1&&r.jsx("div",{className:ve("absolute left-[9px] top-6 w-0.5 h-full -ml-px",f.status==="COMPLETED"?"bg-green-200 dark:bg-green-900":"bg-muted")}),r.jsxs("div",{className:"flex gap-4",children:[r.jsx("div",{className:"flex-shrink-0 relative z-10 bg-background",children:r.jsx(pC,{status:f.status})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"font-medium",children:f.stepName}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(Step ",f.stepIndex+1,")"]}),m&&r.jsxs("span",{className:ve("inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded-full font-mono",f.attempt!==null&&f.attempt!==void 0&&f.attempt>1?f.status==="FAILED"?"bg-red-100 text-red-700 dark:bg-red-950 dark:text-red-300":"bg-yellow-100 text-yellow-700 dark:bg-yellow-950 dark:text-yellow-300":"bg-muted text-muted-foreground"),children:[r.jsx(Gr,{className:"h-3 w-3"}),f.attempt,"/",(f.maxRetries??0)+1]})]}),r.jsx("span",{className:"text-sm font-mono text-muted-foreground",children:ts(f.durationMs)})]}),f.errorMessage&&r.jsx("div",{className:"mt-2 p-2 rounded bg-red-50 dark:bg-red-950 text-red-700 dark:text-red-300 text-sm font-mono",children:f.errorMessage}),f.retryAttempts&&f.retryAttempts.length>0&&r.jsxs("div",{className:"mt-2 space-y-2",children:[r.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Previous failures"}),f.retryAttempts.map(y=>r.jsxs("div",{className:"rounded border border-yellow-200 bg-yellow-50 px-3 py-2 dark:border-yellow-900 dark:bg-yellow-950/40",children:[r.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 text-xs text-yellow-800 dark:text-yellow-200",children:[r.jsxs("span",{className:"font-medium",children:["Attempt ",y.attempt," failed"]}),r.jsx("span",{className:"font-mono",children:ts(y.durationMs??null)})]}),r.jsx("pre",{className:"whitespace-pre-wrap text-xs font-mono text-yellow-900 dark:text-yellow-100",children:y.errorMessage})]},`${f.id}-${y.attempt}`))]}),r.jsx(Ro,{id:`${f.id}-input`,label:"View input",value:f.input,isOpen:l.has(`${f.id}-input`),onToggle:s}),r.jsx(Ro,{id:`${f.id}-output`,label:"View output",value:f.output,isOpen:l.has(`${f.id}-output`),onToggle:s}),r.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:r.jsx(yn,{timestamp:f.createdAt})})]})]})]},f.id)})})]})}function vC(){const{binding:a,executionId:l}=qa(),s=a||"",o=l||"",{data:f,isLoading:d}=it({queryKey:["workflowExecution",s,o],queryFn:()=>AN(s,o),enabled:!!s&&!!o,refetchInterval:5e3}),m=f==null?void 0:f.execution,y=(f==null?void 0:f.steps)||[],p=mC(m??null,y),[g,b]=x.useState(()=>new Set),j=p.length>0&&p.every(E=>g.has(E));function S(E,M){b(O=>{const z=new Set(O);return M?z.add(E):z.delete(E),z})}function w(){b(()=>j?new Set:new Set(p))}return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(Gt,{to:`/workflows/${s}`,children:r.jsxs(De,{variant:"ghost",size:"sm",children:[r.jsx(pj,{className:"mr-2 h-4 w-4"}),"Back"]})}),r.jsxs("h2",{className:"text-3xl font-bold tracking-tight",children:["Execution: ",r.jsx(oi,{id:o})]})]}),p.length>0&&r.jsxs(De,{variant:"ghost",size:"sm",onClick:w,children:[j?r.jsx(Ej,{className:"h-4 w-4"}):r.jsx(Tj,{className:"h-4 w-4"}),j?"Collapse All I/O":"Expand All I/O"]})]}),d?r.jsx(Ln,{}):m?r.jsxs(r.Fragment,{children:[r.jsxs(rt,{children:[r.jsx(yt,{children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(xt,{children:"Execution Details"}),r.jsx(kt,{children:m.startedAt?r.jsxs(r.Fragment,{children:["Started ",r.jsx(yn,{timestamp:m.startedAt})]}):"Not started yet"})]}),r.jsx(Ch,{status:m.status})]})}),r.jsxs(ut,{children:[r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Duration"}),r.jsx("p",{className:"font-mono",children:ts(m.durationMs)})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Steps Completed"}),r.jsxs("p",{className:"font-mono",children:[m.stepsCompleted," / ",m.stepsCount]})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Created"}),r.jsx("p",{className:"font-mono text-sm",children:r.jsx(yn,{timestamp:m.createdAt})})]}),m.completedAt&&r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Completed"}),r.jsx("p",{className:"font-mono text-sm",children:r.jsx(yn,{timestamp:m.completedAt})})]})]}),m.errorMessage&&r.jsx("div",{className:"mt-4 p-3 rounded bg-red-50 dark:bg-red-950 text-red-700 dark:text-red-300 text-sm font-mono",children:m.errorMessage}),r.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-2",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Execution Input"}),r.jsx(Ro,{id:"execution-input",label:"View execution input",value:m.input,isOpen:g.has("execution-input"),onToggle:S})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Execution Output"}),r.jsx(Ro,{id:"execution-output",label:"View execution output",value:m.output,isOpen:g.has("execution-output"),onToggle:S})]})]})]})]}),r.jsxs(rt,{children:[r.jsx(yt,{children:r.jsxs("div",{children:[r.jsx(xt,{children:"Steps"}),r.jsx(kt,{children:"Workflow step execution timeline"})]})}),r.jsx(ut,{children:r.jsx(xC,{steps:y,openIoSectionIds:g,onToggleIoSection:S})})]})]}):r.jsx(sn,{children:"Execution not found"})]})})}const xd=20,bC=[{value:"",label:"All statuses"},{value:"pending",label:"Pending"},{value:"running",label:"Running"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"cancelled",label:"Cancelled"}],SC=[{value:"",label:"All time"},{value:"1h",label:"Last hour"},{value:"24h",label:"Last 24 hours"},{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"}];function jC({executions:a,isLoading:l,bindingName:s}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Recent Executions"}),r.jsx(kt,{children:"Workflow executions (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Ln,{}):a!=null&&a.length?r.jsxs(kn,{children:[r.jsx(Dn,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Steps"}),r.jsx(je,{children:"Duration"}),r.jsx(je,{children:"Started"}),r.jsx(je,{})]})}),r.jsx(_n,{children:a.map(o=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(oi,{id:o.id})}),r.jsx(Ne,{children:r.jsx(Ch,{status:o.status})}),r.jsx(Ne,{children:r.jsxs("span",{className:"text-sm",children:[o.stepsCompleted,"/",o.stepsCount]})}),r.jsx(Ne,{className:"text-sm",children:ts(o.durationMs)}),r.jsx(Ne,{children:o.startedAt?r.jsx(yn,{timestamp:o.startedAt}):"-"}),r.jsx(Ne,{children:r.jsx(Gt,{to:`/workflows/${s}/${o.id}`,className:"flex items-center text-sm text-primary hover:underline",children:"View"})})]},o.id))})]}):r.jsx(sn,{children:"No executions for this workflow"})})]})}function NC(){const{binding:a}=qa(),l=a||"",[s,o]=x.useState(""),[f,d]=x.useState(""),[m,y]=x.useState(0),p=m*xd,{data:g,isLoading:b}=it({queryKey:["workflowExecutions",l,s,f,m],queryFn:()=>MN(l,xd,p,s||void 0,f||void 0),enabled:!!l,refetchInterval:5e3}),j=g?Math.ceil(g.total/xd):0,S=()=>y(0);return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Qa,{title:`Workflow: ${l}`}),r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[r.jsx("select",{value:s,onChange:w=>{o(w.target.value),S()},className:"text-sm border rounded px-2 py-1 bg-background",children:bC.map(w=>r.jsx("option",{value:w.value,children:w.label},w.value))}),r.jsx("select",{value:f,onChange:w=>{d(w.target.value),S()},className:"text-sm border rounded px-2 py-1 bg-background",children:SC.map(w=>r.jsx("option",{value:w.value,children:w.label},w.value))}),g&&r.jsxs("span",{className:"text-sm text-muted-foreground",children:[g.total," total"]})]}),r.jsx(jC,{executions:g==null?void 0:g.executions,isLoading:b,bindingName:l}),j>1&&r.jsxs("div",{className:"flex items-center justify-between pt-2",children:[r.jsx("button",{className:"text-sm px-3 py-1 border rounded disabled:opacity-40",disabled:m===0,onClick:()=>y(w=>w-1),children:"Previous"}),r.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",m+1," of ",j]}),r.jsx("button",{className:"text-sm px-3 py-1 border rounded disabled:opacity-40",disabled:m>=j-1,onClick:()=>y(w=>w+1),children:"Next"})]})]})})}function wC(){const a=Ha(),{data:l,isLoading:s}=it({queryKey:["config"],queryFn:Do,staleTime:6e4}),o=l!=null&&l.db?Object.keys(l.db):[],f=l!=null&&l.queue?Object.keys(l.queue):[],d=l!=null&&l.state?Object.keys(l.state):[],m=l!=null&&l.cache?Object.keys(l.cache):[],y=l!=null&&l.fs?Object.keys(l.fs):[],p=l!=null&&l.workflow?Object.keys(l.workflow):[],g=l!=null&&l.cron?Object.keys(l.cron):[],b=l!=null&&l.timer?Object.keys(l.timer):[],j=l!=null&&l.sandbox?Object.keys(l.sandbox):[];return r.jsxs("aside",{className:"fixed inset-y-0 left-0 z-10 w-64 flex flex-col border-r bg-background",children:[r.jsx("div",{className:"flex h-14 items-center border-b px-4",children:r.jsxs(Gt,{to:"/",className:"flex items-center gap-2 font-semibold",children:[r.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground",children:"P"}),r.jsx("span",{children:"Ploy Dev"})]})}),r.jsx("nav",{className:"flex-1 overflow-auto p-4",children:s?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(zn,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):r.jsxs("div",{className:"space-y-6",children:[o.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Database"}),r.jsx("div",{className:"space-y-1",children:o.map(S=>{const w=a.pathname===`/db/${S}`;return r.jsx(Gt,{to:`/db/${S}`,children:r.jsxs(De,{variant:w?"secondary":"ghost",className:ve("w-full justify-start",w&&"bg-muted"),children:[r.jsx(_j,{className:"mr-2 h-4 w-4"}),S]})},S)})})]}),(l==null?void 0:l.auth)&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Auth"}),r.jsx("div",{className:"space-y-1",children:r.jsx(Gt,{to:"/auth",children:r.jsxs(De,{variant:a.pathname==="/auth"?"secondary":"ghost",className:ve("w-full justify-start",a.pathname==="/auth"&&"bg-muted"),children:[r.jsx(rN,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 text-left",children:l.auth.binding}),r.jsx(gx,{className:"h-3.5 w-3.5 text-muted-foreground",title:"Ploy Auth tables (users & sessions)"})]})})})]}),((l==null?void 0:l.auth)||(l==null?void 0:l.email))&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Email"}),r.jsx("div",{className:"space-y-1",children:r.jsx(Gt,{to:"/auth/emails",children:r.jsxs(De,{variant:a.pathname==="/auth/emails"?"secondary":"ghost",className:ve("w-full justify-start",a.pathname==="/auth/emails"&&"bg-muted"),children:[r.jsx(Kj,{className:"mr-2 h-4 w-4"}),"Emails"]})})})]}),f.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Queues"}),r.jsx("div",{className:"space-y-1",children:f.map(S=>{const w=a.pathname===`/queues/${S}`;return r.jsx(Gt,{to:`/queues/${S}`,children:r.jsxs(De,{variant:w?"secondary":"ghost",className:ve("w-full justify-start",w&&"bg-muted"),children:[r.jsx(Qj,{className:"mr-2 h-4 w-4"}),S]})},S)})})]}),d.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"State"}),r.jsx("div",{className:"space-y-1",children:d.map(S=>{const w=a.pathname===`/state/${S}`;return r.jsx(Gt,{to:`/state/${S}`,children:r.jsxs(De,{variant:w?"secondary":"ghost",className:ve("w-full justify-start",w&&"bg-muted"),children:[r.jsx(hj,{className:"mr-2 h-4 w-4"}),S]})},S)})})]}),m.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Cache"}),r.jsx("div",{className:"space-y-1",children:m.map(S=>{const w=a.pathname===`/cache/${S}`;return r.jsx(Gt,{to:`/cache/${S}`,children:r.jsxs(De,{variant:w?"secondary":"ghost",className:ve("w-full justify-start",w&&"bg-muted"),children:[r.jsx(yN,{className:"mr-2 h-4 w-4"}),S]})},S)})})]}),y.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"File Storage"}),r.jsx("div",{className:"space-y-1",children:y.map(S=>{const w=a.pathname===`/fs/${S}`;return r.jsx(Gt,{to:`/fs/${S}`,children:r.jsxs(De,{variant:w?"secondary":"ghost",className:ve("w-full justify-start",w&&"bg-muted"),children:[r.jsx(Uj,{className:"mr-2 h-4 w-4"}),S]})},S)})})]}),p.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Workflows"}),r.jsx("div",{className:"space-y-1",children:p.map(S=>{const w=a.pathname.startsWith(`/workflows/${S}`);return r.jsx(Gt,{to:`/workflows/${S}`,children:r.jsxs(De,{variant:w?"secondary":"ghost",className:ve("w-full justify-start",w&&"bg-muted"),children:[r.jsx(qj,{className:"mr-2 h-4 w-4"}),S]})},S)})})]}),g.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Cron"}),r.jsx("div",{className:"space-y-1",children:g.map(S=>{const w=a.pathname===`/cron/${S}`;return r.jsx(Gt,{to:`/cron/${S}`,children:r.jsxs(De,{variant:w?"secondary":"ghost",className:ve("w-full justify-start",w&&"bg-muted"),children:[r.jsx(mN,{className:"mr-2 h-4 w-4"}),S]})},S)})})]}),b.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Timers"}),r.jsx("div",{className:"space-y-1",children:b.map(S=>{const w=a.pathname===`/timers/${S}`;return r.jsx(Gt,{to:`/timers/${S}`,children:r.jsxs(De,{variant:w?"secondary":"ghost",className:ve("w-full justify-start",w&&"bg-muted"),children:[r.jsx(vj,{className:"mr-2 h-4 w-4"}),S]})},S)})})]}),j.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Sandboxes"}),r.jsx("div",{className:"space-y-1",children:r.jsx(Gt,{to:"/sandboxes",children:r.jsxs(De,{variant:a.pathname==="/sandboxes"?"secondary":"ghost",className:ve("w-full justify-start",a.pathname==="/sandboxes"&&"bg-muted"),children:[r.jsx(hx,{className:"mr-2 h-4 w-4"}),"Sandboxes"]})})})]}),o.length===0&&f.length===0&&d.length===0&&m.length===0&&y.length===0&&p.length===0&&g.length===0&&b.length===0&&j.length===0&&!(l!=null&&l.auth)&&r.jsx("div",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No bindings configured in ploy.yaml"})]})})]})}function EC(){const{data:a,isLoading:l}=it({queryKey:["config"],queryFn:Do,staleTime:6e4});if(!l&&a){const s=a.db?Object.keys(a.db):[],o=a.queue?Object.keys(a.queue):[],f=a.state?Object.keys(a.state):[],d=a.fs?Object.keys(a.fs):[],m=a.workflow?Object.keys(a.workflow):[];if(s.length>0)return r.jsx(na,{to:`/db/${s[0]}`,replace:!0});if(a.auth)return r.jsx(na,{to:"/auth",replace:!0});if(o.length>0)return r.jsx(na,{to:`/queues/${o[0]}`,replace:!0});if(f.length>0)return r.jsx(na,{to:`/state/${f[0]}`,replace:!0});const y=a.cache?Object.keys(a.cache):[];if(y.length>0)return r.jsx(na,{to:`/cache/${y[0]}`,replace:!0});if(d.length>0)return r.jsx(na,{to:`/fs/${d[0]}`,replace:!0});if(m.length>0)return r.jsx(na,{to:`/workflows/${m[0]}`,replace:!0});const p=a.cron?Object.keys(a.cron):[];if(p.length>0)return r.jsx(na,{to:`/cron/${p[0]}`,replace:!0});const g=a.timer?Object.keys(a.timer):[];if(g.length>0)return r.jsx(na,{to:`/timers/${g[0]}`,replace:!0});if((a.sandbox?Object.keys(a.sandbox):[]).length>0)return r.jsx(na,{to:"/sandboxes",replace:!0})}return r.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[r.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Ploy Dev Dashboard"}),l?r.jsx(zn,{className:"h-6 w-6 animate-spin text-muted-foreground"}):r.jsx("p",{className:"text-muted-foreground",children:"Configure database, queue, or workflow bindings in ploy.yaml to get started."})]})}function CC(){return r.jsxs("div",{className:"min-h-screen bg-background",children:[r.jsx(wC,{}),r.jsx("main",{className:"pl-64",children:r.jsx("div",{className:"container mx-auto px-6 py-4",children:r.jsxs(CS,{children:[r.jsx(nn,{path:"/",element:r.jsx(EC,{})}),r.jsx(nn,{path:"/db/:binding",element:r.jsx(P4,{})}),r.jsx(nn,{path:"/auth",element:r.jsx(R4,{})}),r.jsx(nn,{path:"/auth/emails",element:r.jsx(D4,{})}),r.jsx(nn,{path:"/queues/:binding",element:r.jsx(aC,{})}),r.jsx(nn,{path:"/state/:binding",element:r.jsx(uC,{})}),r.jsx(nn,{path:"/cache/:binding",element:r.jsx(U4,{})}),r.jsx(nn,{path:"/fs/:binding",element:r.jsx(eC,{})}),r.jsx(nn,{path:"/cron/:binding",element:r.jsx(K4,{})}),r.jsx(nn,{path:"/timers/:binding",element:r.jsx(hC,{})}),r.jsx(nn,{path:"/workflows/:binding",element:r.jsx(NC,{})}),r.jsx(nn,{path:"/workflows/:binding/:executionId",element:r.jsx(vC,{})}),r.jsx(nn,{path:"/sandboxes",element:r.jsx(sC,{})})]})})})]})}function Rv(){const a=window.matchMedia("(prefers-color-scheme: dark)").matches;document.documentElement.classList.toggle("dark",a)}Rv();window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",Rv);const TC=new c2({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}});_2.createRoot(document.getElementById("root")).render(r.jsx(x.StrictMode,{children:r.jsx(x2,{client:TC,children:r.jsx(JS,{children:r.jsx(CC,{})})})}));
|