dccxx-s3-explorer 1.0.18 → 1.0.19
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/s3-explorer.umd.cjs
CHANGED
|
@@ -133,6 +133,6 @@
|
|
|
133
133
|
|
|
134
134
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
135
135
|
|
|
136
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return d.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},ym="DialogDescriptionWarning",wm=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ml(ym).contentName}}.`;return d.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},bm=bl,xm=Cl,Cm=El,kl=Nl,Il=Pl,$l=Tl,Ll=Fl,Sm=Rl;const on=bm,lr=xm,Em=Cm,Vl=d.forwardRef(({className:e,...t},n)=>c.jsx(kl,{ref:n,className:J("s3-explr-ui-dialog-overlay fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Vl.displayName=kl.displayName;const Vt=d.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Em,{children:[c.jsx(Vl,{}),c.jsxs(Il,{ref:r,className:J("s3-explr-ui-dialog-content fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,c.jsxs(Sm,{className:J("s3-explr-ui-dialog-close absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"),children:[c.jsx(va,{className:"s3-explr-ui-dialog-close-icon h-4 w-4"}),c.jsx("span",{className:"s3-explr-ui-dialog-close-text sr-only",children:"Close"})]})]})]}));Vt.displayName=Il.displayName;const Bt=({className:e,...t})=>c.jsx("div",{className:J("s3-explr-ui-dialog-header flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Bt.displayName="DialogHeader";const cr=({className:e,...t})=>c.jsx("div",{className:J("s3-explr-ui-dialog-footer flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});cr.displayName="DialogFooter";const zt=d.forwardRef(({className:e,...t},n)=>c.jsx($l,{ref:n,className:J("s3-explr-ui-dialog-title text-lg font-semibold leading-none tracking-tight",e),...t}));zt.displayName=$l.displayName;const Qo=d.forwardRef(({className:e,...t},n)=>c.jsx(Ll,{ref:n,className:J("s3-explr-ui-dialog-description text-sm text-muted-foreground",e),...t}));Qo.displayName=Ll.displayName;const Et=d.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:J("s3-explr-ui-input","flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Et.displayName="Input";var Nm="Label",Bl=d.forwardRef((e,t)=>c.jsx(ye.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Bl.displayName=Nm;var zl=Bl;const Pm=Ro("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 s3-explr-ui-label",{variants:{variant:{default:"s3-explr-ui-label-default",required:"s3-explr-ui-label-required",disabled:"s3-explr-ui-label-disabled"},size:{default:"s3-explr-ui-label-size-default",sm:"s3-explr-ui-label-size-sm",lg:"s3-explr-ui-label-size-lg"}},defaultVariants:{variant:"default",size:"default"}}),Ht=d.forwardRef(({className:e,variant:t,size:n,...r},o)=>c.jsx(zl,{ref:o,className:J(Pm({variant:t,size:n}),e),...r}));Ht.displayName=zl.displayName;const ur=d.forwardRef(({className:e,...t},n)=>c.jsx("div",{className:J("relative w-full overflow-auto","s3-explr-ui-table-container"),children:c.jsx("table",{ref:n,className:J("w-full caption-bottom text-sm","s3-explr-ui-table",e),...t})}));ur.displayName="Table";const dr=d.forwardRef(({className:e,...t},n)=>c.jsx("thead",{ref:n,className:J("[&_tr]:border-b","s3-explr-ui-table-header",e),...t}));dr.displayName="TableHeader";const fr=d.forwardRef(({className:e,...t},n)=>c.jsx("tbody",{ref:n,className:J("[&_tr:last-child]:border-0","s3-explr-ui-table-body",e),...t}));fr.displayName="TableBody";const Am=d.forwardRef(({className:e,...t},n)=>c.jsx("tfoot",{ref:n,className:J("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0","s3-explr-ui-table-footer",e),...t}));Am.displayName="TableFooter";const je=d.forwardRef(({className:e,...t},n)=>c.jsx("tr",{ref:n,className:J("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted","s3-explr-ui-table-row",e),...t}));je.displayName="TableRow";const et=d.forwardRef(({className:e,...t},n)=>c.jsx("th",{ref:n,className:J("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]","s3-explr-ui-table-head",e),...t}));et.displayName="TableHead";const _e=d.forwardRef(({className:e,...t},n)=>c.jsx("td",{ref:n,className:J("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]","s3-explr-ui-table-cell",e),...t}));_e.displayName="TableCell";const Tm=d.forwardRef(({className:e,...t},n)=>c.jsx("caption",{ref:n,className:J("mt-4 text-sm text-muted-foreground","s3-explr-ui-table-caption",e),...t}));Tm.displayName="TableCaption";function es(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function sn(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Hl(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function ts(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Hl(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Hl(e[o],null)}}}}function ns(...e){return d.useCallback(ts(...e),e)}var rs=d.forwardRef((e,t)=>{const{children:n,...r}=e,o=d.Children.toArray(n),s=o.find(Fm);if(s){const i=s.props.children,a=o.map(u=>u===s?d.Children.count(i)>1?d.Children.only(null):d.isValidElement(i)?i.props.children:null:u);return c.jsx(os,{...r,ref:t,children:d.isValidElement(i)?d.cloneElement(i,void 0,a):null})}return c.jsx(os,{...r,ref:t,children:n})});rs.displayName="Slot";var os=d.forwardRef((e,t)=>{const{children:n,...r}=e;if(d.isValidElement(n)){const o=Rm(n);return d.cloneElement(n,{...Om(r,n.props),ref:t?ts(t,o):o})}return d.Children.count(n)>1?d.Children.only(null):null});os.displayName="SlotClone";var _m=({children:e})=>c.jsx(c.Fragment,{children:e});function Fm(e){return d.isValidElement(e)&&e.type===_m}function Om(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function Rm(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Dm(e){const t=e+"CollectionProvider",[n,r]=Ze(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=p=>{const{scope:v,children:m}=p,y=O.useRef(null),w=O.useRef(new Map).current;return c.jsx(o,{scope:v,itemMap:w,collectionRef:y,children:m})};i.displayName=t;const a=e+"CollectionSlot",u=O.forwardRef((p,v)=>{const{scope:m,children:y}=p,w=s(a,m),x=ns(v,w.collectionRef);return c.jsx(rs,{ref:x,children:y})});u.displayName=a;const l=e+"CollectionItemSlot",f="data-radix-collection-item",g=O.forwardRef((p,v)=>{const{scope:m,children:y,...w}=p,x=O.useRef(null),N=ns(v,x),P=s(l,m);return O.useEffect(()=>(P.itemMap.set(x,{ref:x,...w}),()=>void P.itemMap.delete(x))),c.jsx(rs,{[f]:"",ref:N,children:y})});g.displayName=l;function h(p){const v=s(e+"CollectionConsumer",p);return O.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const w=Array.from(y.querySelectorAll(`[${f}]`));return Array.from(v.itemMap.values()).sort((P,b)=>w.indexOf(P.ref.current)-w.indexOf(b.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:u,ItemSlot:g},h,r]}var Ul=d.forwardRef((e,t)=>{const{children:n,...r}=e,o=d.Children.toArray(n),s=o.find(km);if(s){const i=s.props.children,a=o.map(u=>u===s?d.Children.count(i)>1?d.Children.only(null):d.isValidElement(i)?i.props.children:null:u);return c.jsx(ss,{...r,ref:t,children:d.isValidElement(i)?d.cloneElement(i,void 0,a):null})}return c.jsx(ss,{...r,ref:t,children:n})});Ul.displayName="Slot";var ss=d.forwardRef((e,t)=>{const{children:n,...r}=e;if(d.isValidElement(n)){const o=$m(n);return d.cloneElement(n,{...Im(r,n.props),ref:t?ts(t,o):o})}return d.Children.count(n)>1?d.Children.only(null):null});ss.displayName="SlotClone";var Mm=({children:e})=>c.jsx(c.Fragment,{children:e});function km(e){return d.isValidElement(e)&&e.type===Mm}function Im(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function $m(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Lm=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],jl=Lm.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?Ul:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Vm=d.createContext(void 0);function is(e){const t=d.useContext(Vm);return e||t||"ltr"}var as="rovingFocusGroup.onEntryFocus",Bm={bubbles:!1,cancelable:!0},pr="RovingFocusGroup",[ls,Gl,zm]=Dm(pr),[Hm,gr]=Ze(pr,[zm]),[Um,jm]=Hm(pr),Wl=d.forwardRef((e,t)=>c.jsx(ls.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(ls.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Gm,{...e,ref:t})})}));Wl.displayName=pr;var Gm=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:u,onEntryFocus:l,preventScrollOnEntryFocus:f=!1,...g}=e,h=d.useRef(null),p=ns(t,h),v=is(s),[m=null,y]=$t({prop:i,defaultProp:a,onChange:u}),[w,x]=d.useState(!1),N=Ee(l),P=Gl(n),b=d.useRef(!1),[S,E]=d.useState(0);return d.useEffect(()=>{const M=h.current;if(M)return M.addEventListener(as,N),()=>M.removeEventListener(as,N)},[N]),c.jsx(Um,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:m,onItemFocus:d.useCallback(M=>y(M),[y]),onItemShiftTab:d.useCallback(()=>x(!0),[]),onFocusableItemAdd:d.useCallback(()=>E(M=>M+1),[]),onFocusableItemRemove:d.useCallback(()=>E(M=>M-1),[]),children:c.jsx(jl.div,{tabIndex:w||S===0?-1:0,"data-orientation":r,...g,ref:p,style:{outline:"none",...e.style},onMouseDown:sn(e.onMouseDown,()=>{b.current=!0}),onFocus:sn(e.onFocus,M=>{const H=!b.current;if(M.target===M.currentTarget&&H&&!w){const U=new CustomEvent(as,Bm);if(M.currentTarget.dispatchEvent(U),!U.defaultPrevented){const Z=P().filter(B=>B.focusable),F=Z.find(B=>B.active),I=Z.find(B=>B.id===m),G=[F,I,...Z].filter(Boolean).map(B=>B.ref.current);Xl(G,f)}}b.current=!1}),onBlur:sn(e.onBlur,()=>x(!1))})})}),ql="RovingFocusGroupItem",Kl=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,...i}=e,a=Qt(),u=s||a,l=jm(ql,n),f=l.currentTabStopId===u,g=Gl(n),{onFocusableItemAdd:h,onFocusableItemRemove:p}=l;return d.useEffect(()=>{if(r)return h(),()=>p()},[r,h,p]),c.jsx(ls.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(jl.span,{tabIndex:f?0:-1,"data-orientation":l.orientation,...i,ref:t,onMouseDown:sn(e.onMouseDown,v=>{r?l.onItemFocus(u):v.preventDefault()}),onFocus:sn(e.onFocus,()=>l.onItemFocus(u)),onKeyDown:sn(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){l.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const m=Km(v,l.orientation,l.dir);if(m!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let w=g().filter(x=>x.focusable).map(x=>x.ref.current);if(m==="last")w.reverse();else if(m==="prev"||m==="next"){m==="prev"&&w.reverse();const x=w.indexOf(v.currentTarget);w=l.loop?Xm(w,x+1):w.slice(x+1)}setTimeout(()=>Xl(w))}})})})});Kl.displayName=ql;var Wm={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function qm(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Km(e,t,n){const r=qm(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Wm[r]}function Xl(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Xm(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Yl=Wl,Jl=Kl;function Zl(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ym(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Zl(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Zl(e[o],null)}}}}function Jm(...e){return d.useCallback(Ym(...e),e)}function Zm(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var Ql=e=>{const{present:t,children:n}=e,r=Qm(t),o=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),s=Jm(r.ref,ev(o));return typeof n=="function"||r.isPresent?d.cloneElement(o,{ref:s}):null};Ql.displayName="Presence";function Qm(e){const[t,n]=d.useState(),r=d.useRef({}),o=d.useRef(e),s=d.useRef("none"),i=e?"mounted":"unmounted",[a,u]=Zm(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const l=hr(r.current);s.current=a==="mounted"?l:"none"},[a]),Ne(()=>{const l=r.current,f=o.current;if(f!==e){const h=s.current,p=hr(l);e?u("MOUNT"):p==="none"||(l==null?void 0:l.display)==="none"?u("UNMOUNT"):u(f&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,u]),Ne(()=>{if(t){let l;const f=t.ownerDocument.defaultView??window,g=p=>{const m=hr(r.current).includes(p.animationName);if(p.target===t&&m&&(u("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",l=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},h=p=>{p.target===t&&(s.current=hr(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{f.clearTimeout(l),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:d.useCallback(l=>{l&&(r.current=getComputedStyle(l)),n(l)},[])}}function hr(e){return(e==null?void 0:e.animationName)||"none"}function ev(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function ec(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function tv(...e){return t=>{let n=!1;const r=e.map(o=>{const s=ec(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():ec(e[o],null)}}}}var tc=d.forwardRef((e,t)=>{const{children:n,...r}=e,o=d.Children.toArray(n),s=o.find(rv);if(s){const i=s.props.children,a=o.map(u=>u===s?d.Children.count(i)>1?d.Children.only(null):d.isValidElement(i)?i.props.children:null:u);return c.jsx(cs,{...r,ref:t,children:d.isValidElement(i)?d.cloneElement(i,void 0,a):null})}return c.jsx(cs,{...r,ref:t,children:n})});tc.displayName="Slot";var cs=d.forwardRef((e,t)=>{const{children:n,...r}=e;if(d.isValidElement(n)){const o=sv(n);return d.cloneElement(n,{...ov(r,n.props),ref:t?tv(t,o):o})}return d.Children.count(n)>1?d.Children.only(null):null});cs.displayName="SlotClone";var nv=({children:e})=>c.jsx(c.Fragment,{children:e});function rv(e){return d.isValidElement(e)&&e.type===nv}function ov(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function sv(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var iv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],mr=iv.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?tc:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),us="Tabs",[av,iC]=Ze(us,[gr]),nc=gr(),[lv,ds]=av(us),rc=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:s,orientation:i="horizontal",dir:a,activationMode:u="automatic",...l}=e,f=is(a),[g,h]=$t({prop:r,onChange:o,defaultProp:s});return c.jsx(lv,{scope:n,baseId:Qt(),value:g,onValueChange:h,orientation:i,dir:f,activationMode:u,children:c.jsx(mr.div,{dir:f,"data-orientation":i,...l,ref:t})})});rc.displayName=us;var oc="TabsList",sc=d.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,s=ds(oc,n),i=nc(n);return c.jsx(Yl,{asChild:!0,...i,orientation:s.orientation,dir:s.dir,loop:r,children:c.jsx(mr.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:t})})});sc.displayName=oc;var ic="TabsTrigger",ac=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...s}=e,i=ds(ic,n),a=nc(n),u=uc(i.baseId,r),l=dc(i.baseId,r),f=r===i.value;return c.jsx(Jl,{asChild:!0,...a,focusable:!o,active:f,children:c.jsx(mr.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":l,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...s,ref:t,onMouseDown:es(e.onMouseDown,g=>{!o&&g.button===0&&g.ctrlKey===!1?i.onValueChange(r):g.preventDefault()}),onKeyDown:es(e.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&i.onValueChange(r)}),onFocus:es(e.onFocus,()=>{const g=i.activationMode!=="manual";!f&&!o&&g&&i.onValueChange(r)})})})});ac.displayName=ic;var lc="TabsContent",cc=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:s,...i}=e,a=ds(lc,n),u=uc(a.baseId,r),l=dc(a.baseId,r),f=r===a.value,g=d.useRef(f);return d.useEffect(()=>{const h=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(h)},[]),c.jsx(Ql,{present:o||f,children:({present:h})=>c.jsx(mr.div,{"data-state":f?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":u,hidden:!h,id:l,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:g.current?"0s":void 0},children:h&&s})})});cc.displayName=lc;function uc(e,t){return`${e}-trigger-${t}`}function dc(e,t){return`${e}-content-${t}`}var cv=rc,fc=sc,pc=ac,gc=cc;const uv=cv,hc=d.forwardRef(({className:e,...t},n)=>c.jsx(fc,{ref:n,className:J("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));hc.displayName=fc.displayName;const fs=d.forwardRef(({className:e,...t},n)=>c.jsx(pc,{ref:n,className:J("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...t}));fs.displayName=pc.displayName;const ps=d.forwardRef(({className:e,...t},n)=>c.jsx(gc,{ref:n,className:J("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));ps.displayName=gc.displayName;const vr=d.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:J("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));vr.displayName="Textarea";function dv(e,t=[]){let n=[];function r(s,i){const a=d.createContext(i),u=n.length;n=[...n,i];function l(g){const{scope:h,children:p,...v}=g,m=(h==null?void 0:h[e][u])||a,y=d.useMemo(()=>v,Object.values(v));return c.jsx(m.Provider,{value:y,children:p})}function f(g,h){const p=(h==null?void 0:h[e][u])||a,v=d.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${g}\` must be used within \`${s}\``)}return l.displayName=s+"Provider",[l,f]}const o=()=>{const s=n.map(i=>d.createContext(i));return function(a){const u=(a==null?void 0:a[e])||s;return d.useMemo(()=>({[`__scope${e}`]:{...a,[e]:u}}),[a,u])}};return o.scopeName=e,[r,fv(o,...t)]}function fv(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:u,scopeName:l})=>{const g=u(s)[`__scope${l}`];return{...a,...g}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var gs=d.forwardRef((e,t)=>{const{children:n,...r}=e,o=d.Children.toArray(n),s=o.find(gv);if(s){const i=s.props.children,a=o.map(u=>u===s?d.Children.count(i)>1?d.Children.only(null):d.isValidElement(i)?i.props.children:null:u);return c.jsx(hs,{...r,ref:t,children:d.isValidElement(i)?d.cloneElement(i,void 0,a):null})}return c.jsx(hs,{...r,ref:t,children:n})});gs.displayName="Slot";var hs=d.forwardRef((e,t)=>{const{children:n,...r}=e;if(d.isValidElement(n)){const o=mv(n);return d.cloneElement(n,{...hv(r,n.props),ref:t?Zn(t,o):o})}return d.Children.count(n)>1?d.Children.only(null):null});hs.displayName="SlotClone";var pv=({children:e})=>c.jsx(c.Fragment,{children:e});function gv(e){return d.isValidElement(e)&&e.type===pv}function hv(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function mv(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function vv(e){const t=e+"CollectionProvider",[n,r]=dv(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=p=>{const{scope:v,children:m}=p,y=O.useRef(null),w=O.useRef(new Map).current;return c.jsx(o,{scope:v,itemMap:w,collectionRef:y,children:m})};i.displayName=t;const a=e+"CollectionSlot",u=O.forwardRef((p,v)=>{const{scope:m,children:y}=p,w=s(a,m),x=$e(v,w.collectionRef);return c.jsx(gs,{ref:x,children:y})});u.displayName=a;const l=e+"CollectionItemSlot",f="data-radix-collection-item",g=O.forwardRef((p,v)=>{const{scope:m,children:y,...w}=p,x=O.useRef(null),N=$e(v,x),P=s(l,m);return O.useEffect(()=>(P.itemMap.set(x,{ref:x,...w}),()=>void P.itemMap.delete(x))),c.jsx(gs,{[f]:"",ref:N,children:y})});g.displayName=l;function h(p){const v=s(e+"CollectionConsumer",p);return O.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const w=Array.from(y.querySelectorAll(`[${f}]`));return Array.from(v.itemMap.values()).sort((P,b)=>w.indexOf(P.ref.current)-w.indexOf(b.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:u,ItemSlot:g},h,r]}var yv="VisuallyHidden",ms=d.forwardRef((e,t)=>c.jsx(ye.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));ms.displayName=yv;var vs="ToastProvider",[ys,wv,bv]=vv("Toast"),[mc,aC]=Ze("Toast",[bv]),[xv,yr]=mc(vs),vc=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,u]=d.useState(null),[l,f]=d.useState(0),g=d.useRef(!1),h=d.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${vs}\`. Expected non-empty \`string\`.`),c.jsx(ys.Provider,{scope:t,children:c.jsx(xv,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:l,viewport:a,onViewportChange:u,onToastAdd:d.useCallback(()=>f(p=>p+1),[]),onToastRemove:d.useCallback(()=>f(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:g,isClosePausedRef:h,children:i})})};vc.displayName=vs;var yc="ToastViewport",Cv=["F8"],ws="toast.viewportPause",bs="toast.viewportResume",wc=d.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=Cv,label:o="Notifications ({hotkey})",...s}=e,i=yr(yc,n),a=wv(n),u=d.useRef(null),l=d.useRef(null),f=d.useRef(null),g=d.useRef(null),h=$e(t,g,i.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;d.useEffect(()=>{const y=w=>{var N;r.length!==0&&r.every(P=>w[P]||w.code===P)&&((N=g.current)==null||N.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[r]),d.useEffect(()=>{const y=u.current,w=g.current;if(v&&y&&w){const x=()=>{if(!i.isClosePausedRef.current){const S=new CustomEvent(ws);w.dispatchEvent(S),i.isClosePausedRef.current=!0}},N=()=>{if(i.isClosePausedRef.current){const S=new CustomEvent(bs);w.dispatchEvent(S),i.isClosePausedRef.current=!1}},P=S=>{!y.contains(S.relatedTarget)&&N()},b=()=>{y.contains(document.activeElement)||N()};return y.addEventListener("focusin",x),y.addEventListener("focusout",P),y.addEventListener("pointermove",x),y.addEventListener("pointerleave",b),window.addEventListener("blur",x),window.addEventListener("focus",N),()=>{y.removeEventListener("focusin",x),y.removeEventListener("focusout",P),y.removeEventListener("pointermove",x),y.removeEventListener("pointerleave",b),window.removeEventListener("blur",x),window.removeEventListener("focus",N)}}},[v,i.isClosePausedRef]);const m=d.useCallback(({tabbingDirection:y})=>{const x=a().map(N=>{const P=N.ref.current,b=[P,...kv(P)];return y==="forwards"?b:b.reverse()});return(y==="forwards"?x.reverse():x).flat()},[a]);return d.useEffect(()=>{const y=g.current;if(y){const w=x=>{var b,S,E;const N=x.altKey||x.ctrlKey||x.metaKey;if(x.key==="Tab"&&!N){const M=document.activeElement,H=x.shiftKey;if(x.target===y&&H){(b=l.current)==null||b.focus();return}const F=m({tabbingDirection:H?"backwards":"forwards"}),I=F.findIndex(R=>R===M);Ss(F.slice(I+1))?x.preventDefault():H?(S=l.current)==null||S.focus():(E=f.current)==null||E.focus()}};return y.addEventListener("keydown",w),()=>y.removeEventListener("keydown",w)}},[a,m]),c.jsxs(ph,{ref:u,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&c.jsx(xs,{ref:l,onFocusFromOutsideViewport:()=>{const y=m({tabbingDirection:"forwards"});Ss(y)}}),c.jsx(ys.Slot,{scope:n,children:c.jsx(ye.ol,{tabIndex:-1,...s,ref:h})}),v&&c.jsx(xs,{ref:f,onFocusFromOutsideViewport:()=>{const y=m({tabbingDirection:"backwards"});Ss(y)}})]})});wc.displayName=yc;var bc="ToastFocusProxy",xs=d.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=yr(bc,n);return c.jsx(ms,{"aria-hidden":!0,tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var l;const a=i.relatedTarget;!((l=s.viewport)!=null&&l.contains(a))&&r()}})});xs.displayName=bc;var wr="Toast",Sv="toast.swipeStart",Ev="toast.swipeMove",Nv="toast.swipeCancel",Pv="toast.swipeEnd",xc=d.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a=!0,u]=$t({prop:r,defaultProp:o,onChange:s});return c.jsx(Zt,{present:n||a,children:c.jsx(_v,{open:a,...i,ref:t,onClose:()=>u(!1),onPause:Ee(e.onPause),onResume:Ee(e.onResume),onSwipeStart:me(e.onSwipeStart,l=>{l.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:me(e.onSwipeMove,l=>{const{x:f,y:g}=l.detail.delta;l.currentTarget.setAttribute("data-swipe","move"),l.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${f}px`),l.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${g}px`)}),onSwipeCancel:me(e.onSwipeCancel,l=>{l.currentTarget.setAttribute("data-swipe","cancel"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),l.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:me(e.onSwipeEnd,l=>{const{x:f,y:g}=l.detail.delta;l.currentTarget.setAttribute("data-swipe","end"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),l.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${f}px`),l.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${g}px`),u(!1)})})})});xc.displayName=wr;var[Av,Tv]=mc(wr,{onClose(){}}),_v=d.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:u,onResume:l,onSwipeStart:f,onSwipeMove:g,onSwipeCancel:h,onSwipeEnd:p,...v}=e,m=yr(wr,n),[y,w]=d.useState(null),x=$e(t,R=>w(R)),N=d.useRef(null),P=d.useRef(null),b=o||m.duration,S=d.useRef(0),E=d.useRef(b),M=d.useRef(0),{onToastAdd:H,onToastRemove:U}=m,Z=Ee(()=>{var G;(y==null?void 0:y.contains(document.activeElement))&&((G=m.viewport)==null||G.focus()),i()}),F=d.useCallback(R=>{!R||R===1/0||(window.clearTimeout(M.current),S.current=new Date().getTime(),M.current=window.setTimeout(Z,R))},[Z]);d.useEffect(()=>{const R=m.viewport;if(R){const G=()=>{F(E.current),l==null||l()},B=()=>{const K=new Date().getTime()-S.current;E.current=E.current-K,window.clearTimeout(M.current),u==null||u()};return R.addEventListener(ws,B),R.addEventListener(bs,G),()=>{R.removeEventListener(ws,B),R.removeEventListener(bs,G)}}},[m.viewport,b,u,l,F]),d.useEffect(()=>{s&&!m.isClosePausedRef.current&&F(b)},[s,b,m.isClosePausedRef,F]),d.useEffect(()=>(H(),()=>U()),[H,U]);const I=d.useMemo(()=>y?Tc(y):null,[y]);return m.viewport?c.jsxs(c.Fragment,{children:[I&&c.jsx(Fv,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0,children:I}),c.jsx(Av,{scope:n,onClose:Z,children:kn.createPortal(c.jsx(ys.ItemSlot,{scope:n,children:c.jsx(fh,{asChild:!0,onEscapeKeyDown:me(a,()=>{m.isFocusedToastEscapeKeyDownRef.current||Z(),m.isFocusedToastEscapeKeyDownRef.current=!1}),children:c.jsx(ye.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":m.swipeDirection,...v,ref:x,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:me(e.onKeyDown,R=>{R.key==="Escape"&&(a==null||a(R.nativeEvent),R.nativeEvent.defaultPrevented||(m.isFocusedToastEscapeKeyDownRef.current=!0,Z()))}),onPointerDown:me(e.onPointerDown,R=>{R.button===0&&(N.current={x:R.clientX,y:R.clientY})}),onPointerMove:me(e.onPointerMove,R=>{if(!N.current)return;const G=R.clientX-N.current.x,B=R.clientY-N.current.y,K=!!P.current,q=["left","right"].includes(m.swipeDirection),ee=["left","up"].includes(m.swipeDirection)?Math.min:Math.max,ie=q?ee(0,G):0,ue=q?0:ee(0,B),Se=R.pointerType==="touch"?10:2,ae={x:ie,y:ue},lt={originalEvent:R,delta:ae};K?(P.current=ae,br(Ev,g,lt,{discrete:!1})):_c(ae,m.swipeDirection,Se)?(P.current=ae,br(Sv,f,lt,{discrete:!1}),R.target.setPointerCapture(R.pointerId)):(Math.abs(G)>Se||Math.abs(B)>Se)&&(N.current=null)}),onPointerUp:me(e.onPointerUp,R=>{const G=P.current,B=R.target;if(B.hasPointerCapture(R.pointerId)&&B.releasePointerCapture(R.pointerId),P.current=null,N.current=null,G){const K=R.currentTarget,q={originalEvent:R,delta:G};_c(G,m.swipeDirection,m.swipeThreshold)?br(Pv,p,q,{discrete:!0}):br(Nv,h,q,{discrete:!0}),K.addEventListener("click",ee=>ee.preventDefault(),{once:!0})}})})})}),m.viewport)})]}):null}),Fv=e=>{const{__scopeToast:t,children:n,...r}=e,o=yr(wr,t),[s,i]=d.useState(!1),[a,u]=d.useState(!1);return Dv(()=>i(!0)),d.useEffect(()=>{const l=window.setTimeout(()=>u(!0),1e3);return()=>window.clearTimeout(l)},[]),a?null:c.jsx(zo,{asChild:!0,children:c.jsx(ms,{...r,children:s&&c.jsxs(c.Fragment,{children:[o.label," ",n]})})})},Ov="ToastTitle",Cc=d.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return c.jsx(ye.div,{...r,ref:t})});Cc.displayName=Ov;var Rv="ToastDescription",Sc=d.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return c.jsx(ye.div,{...r,ref:t})});Sc.displayName=Rv;var Ec="ToastAction",Nc=d.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?c.jsx(Ac,{altText:n,asChild:!0,children:c.jsx(Cs,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Ec}\`. Expected non-empty \`string\`.`),null)});Nc.displayName=Ec;var Pc="ToastClose",Cs=d.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=Tv(Pc,n);return c.jsx(Ac,{asChild:!0,children:c.jsx(ye.button,{type:"button",...r,ref:t,onClick:me(e.onClick,o.onClose)})})});Cs.displayName=Pc;var Ac=d.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return c.jsx(ye.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Tc(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),Mv(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...Tc(r))}}),t}function br(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?$a(o,s):o.dispatchEvent(s)}var _c=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function Dv(e=()=>{}){const t=Ee(e);Ne(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function Mv(e){return e.nodeType===e.ELEMENT_NODE}function kv(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Ss(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var Iv=vc,Fc=wc,Oc=xc,Rc=Cc,Dc=Sc,Mc=Nc,kc=Cs;const $v=Iv,Ic=d.forwardRef(({className:e,...t},n)=>c.jsx(Fc,{ref:n,className:J("s3-explr-ui-toast-viewport fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...t}));Ic.displayName=Fc.displayName;const Lv=Ro("s3-explr-ui-toast group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"s3-explr-ui-toast-default border bg-background text-foreground",destructive:"s3-explr-ui-toast-destructive destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),$c=d.forwardRef(({className:e,variant:t,...n},r)=>c.jsx(Oc,{ref:r,className:J(Lv({variant:t}),e),...n}));$c.displayName=Oc.displayName;const Vv=d.forwardRef(({className:e,...t},n)=>c.jsx(Mc,{ref:n,className:J("s3-explr-ui-toast-action inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));Vv.displayName=Mc.displayName;const Lc=d.forwardRef(({className:e,...t},n)=>c.jsx(kc,{ref:n,className:J("s3-explr-ui-toast-close absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:c.jsx(va,{className:"s3-explr-ui-toast-close-icon h-4 w-4"})}));Lc.displayName=kc.displayName;const Vc=d.forwardRef(({className:e,...t},n)=>c.jsx(Rc,{ref:n,className:J("s3-explr-ui-toast-title text-sm font-semibold [&+div]:text-xs",e),...t}));Vc.displayName=Rc.displayName;const Bc=d.forwardRef(({className:e,...t},n)=>c.jsx(Dc,{ref:n,className:J("s3-explr-ui-toast-description text-sm opacity-90",e),...t}));Bc.displayName=Dc.displayName;const Bv=1,zv=1e6;let Es=0;function Hv(){return Es=(Es+1)%Number.MAX_SAFE_INTEGER,Es.toString()}const Ns=new Map,zc=e=>{if(Ns.has(e))return;const t=setTimeout(()=>{Ns.delete(e),xn({type:"REMOVE_TOAST",toastId:e})},zv);Ns.set(e,t)},Uv=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Bv)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?zc(n):e.toasts.forEach(r=>{zc(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},xr=[];let Cr={toasts:[]};function xn(e){Cr=Uv(Cr,e),xr.forEach(t=>{t(Cr)})}function jv({...e}){const t=Hv(),n=o=>xn({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>xn({type:"DISMISS_TOAST",toastId:t});return xn({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Ps(){const[e,t]=d.useState(Cr);return d.useEffect(()=>(xr.push(t),()=>{const n=xr.indexOf(t);n>-1&&xr.splice(n,1)}),[e]),{...e,toast:jv,dismiss:n=>xn({type:"DISMISS_TOAST",toastId:n})}}function Hc(){const{toasts:e}=Ps();return c.jsxs($v,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return c.jsxs($c,{...s,className:`s3-explr-ui-toast ${s.className||""}`,children:[c.jsxs("div",{className:"s3-explr-ui-toast-content grid gap-1",children:[n&&c.jsx(Vc,{className:"s3-explr-ui-toast-title",children:n}),r&&c.jsx(Bc,{className:"s3-explr-ui-toast-description",children:r})]}),o&&c.jsx("div",{className:"s3-explr-ui-toast-action",children:o}),c.jsx(Lc,{className:"s3-explr-ui-toast-close"})]},t)}),c.jsx(Ic,{className:"s3-explr-ui-toast-viewport"})]})}function Gv({title:e,titleId:t,...n},r){return d.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?d.createElement("title",{id:t},e):null,d.createElement("path",{fillRule:"evenodd",d:"M5.47 5.47a.75.75 0 0 1 1.06 0L12 10.94l5.47-5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47a.75.75 0 1 1-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 0 1-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const Wv=d.forwardRef(Gv);var qv=function(e){return function(t,n){var r=O.useRef(!1);e(function(){return function(){r.current=!1}},[]),e(function(){if(!r.current)r.current=!0;else return t()},n)}},Uc=function(e){return typeof e=="function"},jc=process.env.NODE_ENV==="development"||process.env.NODE_ENV==="test";const Kv=qv(O.useEffect);function Gc(e){var t=O.useRef(e);return t.current=e,t}var Xv=function(e){jc&&(Uc(e)||console.error("useUnmount expected parameter is a function, got ".concat(typeof e)));var t=Gc(e);O.useEffect(function(){return function(){t.current()}},[])},Sr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Jv(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Wc=Jv,Zv=typeof Sr=="object"&&Sr&&Sr.Object===Object&&Sr,Qv=Zv,ey=Qv,ty=typeof self=="object"&&self&&self.Object===Object&&self,ny=ey||ty||Function("return this")(),qc=ny,ry=qc,oy=function(){return ry.Date.now()},sy=oy,iy=/\s/;function ay(e){for(var t=e.length;t--&&iy.test(e.charAt(t)););return t}var ly=ay,cy=ly,uy=/^\s+/;function dy(e){return e&&e.slice(0,cy(e)+1).replace(uy,"")}var fy=dy,py=qc,gy=py.Symbol,Kc=gy,Xc=Kc,Yc=Object.prototype,hy=Yc.hasOwnProperty,my=Yc.toString,Cn=Xc?Xc.toStringTag:void 0;function vy(e){var t=hy.call(e,Cn),n=e[Cn];try{e[Cn]=void 0;var r=!0}catch{}var o=my.call(e);return r&&(t?e[Cn]=n:delete e[Cn]),o}var yy=vy,wy=Object.prototype,by=wy.toString;function xy(e){return by.call(e)}var Cy=xy,Jc=Kc,Sy=yy,Ey=Cy,Ny="[object Null]",Py="[object Undefined]",Zc=Jc?Jc.toStringTag:void 0;function Ay(e){return e==null?e===void 0?Py:Ny:Zc&&Zc in Object(e)?Sy(e):Ey(e)}var Ty=Ay;function _y(e){return e!=null&&typeof e=="object"}var Fy=_y,Oy=Ty,Ry=Fy,Dy="[object Symbol]";function My(e){return typeof e=="symbol"||Ry(e)&&Oy(e)==Dy}var ky=My,Iy=fy,Qc=Wc,$y=ky,eu=NaN,Ly=/^[-+]0x[0-9a-f]+$/i,Vy=/^0b[01]+$/i,By=/^0o[0-7]+$/i,zy=parseInt;function Hy(e){if(typeof e=="number")return e;if($y(e))return eu;if(Qc(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Qc(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Iy(e);var n=Vy.test(e);return n||By.test(e)?zy(e.slice(2),n?2:8):Ly.test(e)?eu:+e}var Uy=Hy,jy=Wc,As=sy,tu=Uy,Gy="Expected a function",Wy=Math.max,qy=Math.min;function Ky(e,t,n){var r,o,s,i,a,u,l=0,f=!1,g=!1,h=!0;if(typeof e!="function")throw new TypeError(Gy);t=tu(t)||0,jy(n)&&(f=!!n.leading,g="maxWait"in n,s=g?Wy(tu(n.maxWait)||0,t):s,h="trailing"in n?!!n.trailing:h);function p(S){var E=r,M=o;return r=o=void 0,l=S,i=e.apply(M,E),i}function v(S){return l=S,a=setTimeout(w,t),f?p(S):i}function m(S){var E=S-u,M=S-l,H=t-E;return g?qy(H,s-M):H}function y(S){var E=S-u,M=S-l;return u===void 0||E>=t||E<0||g&&M>=s}function w(){var S=As();if(y(S))return x(S);a=setTimeout(w,m(S))}function x(S){return a=void 0,h&&r?p(S):(r=o=void 0,i)}function N(){a!==void 0&&clearTimeout(a),l=0,r=u=o=a=void 0}function P(){return a===void 0?i:x(As())}function b(){var S=As(),E=y(S);if(r=arguments,o=this,u=S,E){if(a===void 0)return v(u);if(g)return clearTimeout(a),a=setTimeout(w,t),p(u)}return a===void 0&&(a=setTimeout(w,t)),i}return b.cancel=N,b.flush=P,b}var Xy=Ky;const Yy=Yv(Xy);function Jy(){var e=(typeof global>"u"?"undefined":typeof global)=="object"&&global&&global.Object===Object&&global,t=typeof self=="object"&&self&&self.Object===Object&&self;return e||t}Jy()||(global.Date=Date);function Zy(e,t){var n;jc&&(Uc(e)||console.error("useDebounceFn expected parameter is a function, got ".concat(typeof e)));var r=Gc(e),o=(n=t==null?void 0:t.wait)!==null&&n!==void 0?n:1e3,s=O.useMemo(function(){return Yy(function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];return r.current.apply(r,ol([],rl(i),!1))},o,t)},[]);return Xv(function(){s.cancel()}),{run:s,cancel:s.cancel,flush:s.flush}}function Qy(e,t,n){var r=rl(O.useState({}),2),o=r[0],s=r[1],i=Zy(function(){s({})},n).run;O.useEffect(function(){return i()},t),Kv(e,[o])}const ew=O.forwardRef(({onChange:e},t)=>{const n=O.useRef(null),[r,o]=O.useState("");return O.useImperativeHandle(t,()=>({setValue:s=>{var i;o(s),(i=n.current)==null||i.focus()}})),Qy(()=>{e==null||e(r)},[r],{wait:300}),c.jsxs(c.Fragment,{children:[c.jsx(Et,{ref:n,type:"text",placeholder:"Search files...",value:r,onChange:s=>o(s.target.value),className:"pr-8"}),r&&c.jsx("button",{onClick:()=>{var s;o(""),(s=n.current)==null||s.focus()},className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700",children:c.jsx(Wv,{className:"h-5 w-5"})})]})}),tt={current:!1},tw=(e,t,n)=>{const r=[],o=s=>{(e[s]||[]).forEach(a=>{a.name.toLowerCase().includes(t.toLowerCase())&&r.push(a),a.isFolder&&a.key.startsWith(n)&&o(a.key)})};return o(n),r},Er=(e,t)=>{const n=[],r=o=>{(e[o]||[]).forEach(i=>{n.push(i.key),i.isFolder&&r(i.key)})};return r(t),n},nw=(e,t)=>{const n=[];return(e[t]||[]).forEach(o=>{n.push(o.key),o.isFolder&&n.push(...Er(e,o.key))}),n},rw=(e,t)=>{const[n,r]=O.useState({}),[o,s]=O.useState(!1),[i,a]=O.useState(null),u=async()=>{s(!0);try{const l=!tt.current;tt.current&&(tt.current=!1);const f=await oe.get(`${e}/api/files`,{params:{cache:l,prefix:t}});r(f.data),a(null)}catch(l){a(l instanceof Error?l:new Error("Failed to fetch files"))}finally{s(!1)}};return O.useEffect(()=>{u()},[]),{data:n,isLoading:o,error:i,refetch:u}},Nr=e=>{var r,o,s;const t=((s=(o=(r=e==null?void 0:e.name)==null?void 0:r.split("."))==null?void 0:o.pop())==null?void 0:s.toLowerCase())??"";return["txt","md","json","js","ts","jsx","tsx","css","html","xml","yaml","yml"].includes(t||"")},ow=O.memo(({homeLabel:e="Document Store",apiBaseUrl:t="http://localhost:3000",rootPrefix:n="",asSelector:r=!1,onSelected:o=s=>console.log("selected:",s)})=>{const[s,i]=O.useState(""),[a,u]=O.useState(new Set),[l,f]=O.useState(n),[g,h]=O.useState(!1),[p,v]=O.useState(""),[m,y]=O.useState(!1),[w,x]=O.useState(null),[N,P]=O.useState(!1),[b,S]=O.useState(!1),[E,M]=O.useState(!1),[H,U]=O.useState(null),Z=O.useRef(null),{toast:F}=Ps(),[I,R]=O.useState(null),[G,B]=O.useState(""),[K,q]=O.useState(!1),[ee,ie]=O.useState(new Set),[ue,Se]=O.useState(""),[ae,lt]=O.useState(!1),[Gt,_t]=O.useState(!1),[Ft,Ke]=O.useState("rename"),{data:be={},isLoading:Ot,error:Wt,refetch:Ve}=rw(t,n),Xe=O.useMemo(()=>be[l]||[],[be,l]),Ie=O.useMemo(()=>s?tw(be,s,l):Xe,[Xe,s,l,be]),Rt=O.useMemo(()=>{const D={};return Ie.forEach(($,j)=>{a.has($.key)&&(D[j]=!0)}),D},[a,Ie]),Wr=D=>{const $=Er(be,D);if($.length===0)return a.has(D)?"all":"none";const j=$.filter(re=>a.has(re)).length;return j===0?"none":j===$.length?"all":"partial"},qt=D=>{f(D)},C=async(D,$)=>{y(!0);try{const j=`${$}${D}/`;if((await oe.post(`${t}/api/create-folder`,{prefix:j})).status!==200){F({title:"Error",description:"Failed to create folder",variant:"destructive"});return}tt.current=!0,await Ve(),F({title:"Folder Created",description:`Successfully created folder "${D}"`}),v(""),h(!1)}catch(j){console.error("Error creating folder:",j),F({title:"Error",description:"Failed to create folder",variant:"destructive"})}finally{y(!1)}},A=async(D,$,j)=>{U(j);try{const re=new FormData;re.append("prefix",$),Array.from(D).forEach(pe=>{pe instanceof File&&re.append("files",pe)}),(await oe.post(`${t}/api/upload`,re,{headers:{"Content-Type":"multipart/form-data"}})).status===200&&(tt.current=!0,await Ve(),F({title:"Files Uploaded",description:`Successfully uploaded ${D.length} files`}))}catch(re){console.error("Error uploading files:",re),F({title:"Error",description:"Failed to upload files",variant:"destructive"})}finally{U(null)}},_=async D=>{P(!0);try{await oe.delete(`${t}/api/files`,{data:{paths:[D.key]}}),tt.current=!0,await Ve(),F({title:"File Deleted",description:`Successfully deleted "${D.name}"`}),x(null)}catch($){console.error("Error deleting file:",$),F({title:"Error",description:"Failed to delete file",variant:"destructive"})}finally{P(!1)}},V=D=>{const $=new Set(a),j=typeof D=="function"?D(Rt):D;new Set(Object.keys(Rt).map(Number)).forEach(se=>{const pe=Ie[se];pe&&(j[se]||($.delete(pe.key),pe.isFolder&&Er(be,pe.key).forEach(Oe=>$.delete(Oe))))}),Object.entries(j).forEach(([se,pe])=>{const Oe=parseInt(se),vt=Ie[Oe];vt&&pe&&($.add(vt.key),vt.isFolder&&Er(be,vt.key).forEach(gi=>$.add(gi)))}),u($)},L=async()=>{S(!0);try{const D=Array.from(a).map($=>{var j;for(const re in be){const se=(j=be[re])==null?void 0:j.find(pe=>pe.key===$);if(se)return se}return null}).filter($=>$!==null);await oe.delete(`${t}/api/files`,{data:{paths:Array.from(a)}}),tt.current=!0,await Ve(),F({title:"Files Deleted",description:`Successfully deleted ${D.length} items`}),M(!1),u(new Set)}catch(D){console.error("Error deleting files:",D),F({title:"Error",description:"Failed to delete selected files",variant:"destructive"})}finally{S(!1)}},k=async(D,$)=>{q(!0);try{const j=D.key;let re;D.isFolder?re=j.split("/").slice(0,-2).join("/")+"/":re=j.substring(0,j.lastIndexOf("/")+1);const se=re+$+(D.isFolder?"/":"");await oe.post(`${t}/api/rename`,{oldPath:j,newPath:se}),tt.current=!0,await Ve(),F({title:"Item Renamed",description:`Successfully renamed "${D.name}" to "${$}"`}),R(null),B("")}catch(j){console.error("Error renaming item:",j),F({title:"Error",description:"Failed to rename item",variant:"destructive"})}finally{q(!1)}},W=async D=>{ie($=>new Set([...$,...D]));try{const $=await oe.post(`${t}/api/download`,{paths:D},{responseType:"blob"}),j=window.URL.createObjectURL($.data),re=document.createElement("a");re.href=j;const se=$.headers["Content-Disposition"]||$.headers["content-disposition"],pe=se==null?void 0:se.match(/filename="(.+)"/),Oe=pe?decodeURIComponent(pe[1]):"download.zip";re.setAttribute("download",Oe),document.body.appendChild(re),re.click(),document.body.removeChild(re),window.URL.revokeObjectURL(j),F({title:"Download Started",description:`Your download has started for ${D.length} item${D.length>1?"s":""}`})}catch($){console.error("Error downloading files:",$),F({title:"Error",description:"Failed to download files",variant:"destructive"})}finally{ie($=>{const j=new Set($);return D.forEach(re=>j.delete(re)),j})}},ne=l?l.replace(n,"").split("/").filter(Boolean):[],ve=()=>Array.from(a).map(D=>{var $;for(const j in be){const re=($=be[j])==null?void 0:$.find(se=>se.key===D);if(re)return re}return null}).filter(D=>D!==null),he=O.useMemo(()=>{const D=[{id:"select",header:()=>{const $=nw(be,l),j=$.length>0&&$.every(se=>a.has(se)),re=$.some(se=>a.has(se));return c.jsx(Io,{checked:j?!0:re?"indeterminate":!1,onCheckedChange:se=>{if(se){const pe=Ie.reduce((Oe,vt,gi)=>(Oe[gi]=!0,Oe),{});V(pe)}else V({})},"aria-label":"Select all"})},cell:({row:$})=>{const j=$.original,se=j.isFolder?Wr(j.key):a.has(j.key)?"all":"none";return c.jsx("div",{className:"flex items-center",children:c.jsx(Io,{checked:se==="partial"?"indeterminate":se==="all",onCheckedChange:pe=>{const Oe={...Rt};pe?Oe[$.index]=!0:delete Oe[$.index],V(Oe)},"aria-label":"Select row"})})},enableSorting:!1},{id:"fileName",header:"File Name",accessorKey:"name",cell:({row:$})=>{const j=$.original,re=j.key.substring(0,j.key.lastIndexOf("/"))||"/",se=s.trim()!==""&&re!==l,pe=re.split("/").filter(Boolean);return c.jsxs("div",{className:"flex flex-col",children:[c.jsxs("div",{className:`flex items-center gap-2 ${j.isFolder?"cursor-pointer hover:text-blue-600":""}`,onClick:()=>{j.isFolder&&qt(j.key)},children:[j.isFolder?c.jsx(Kr,{className:"h-5 w-5 text-blue-500"}):null,j.name]}),se&&c.jsxs("div",{className:"text-sm text-gray-500 flex items-center",children:[c.jsx(Kr,{className:"h-4 w-4 text-gray-500 my-auto"}),c.jsxs("span",{className:"flex items-center ml-1",children:[c.jsx("span",{className:"cursor-pointer hover:text-blue-600",onClick:()=>{qt("")},children:"/"}),pe.map((Oe,vt)=>c.jsxs("span",{className:"flex items-center",children:[c.jsx("span",{className:"cursor-pointer hover:text-blue-600",onClick:()=>{qt(pe.slice(0,vt+1).join("/")+"/")},children:Oe}),vt<pe.length-1&&c.jsx("span",{children:"/"})]},vt))]})]})]})}}];return r||D.push({id:"size",header:"Size",accessorKey:"size",cell:({getValue:$,row:j})=>{const re=$();return c.jsx("span",{children:j.original.isFolder?"-":Vg(re)})}},{id:"lastModified",header:"Last Modified",accessorKey:"lastModified",cell:({row:$})=>{const j=$.original.lastModified;return c.jsx("span",{children:j.toLocaleString()})}},{id:"actions",header:"Actions",accessorKey:"key",cell:({row:$})=>c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(de,{variant:"ghost",size:"icon",onClick:()=>W([$.original.key]),className:"h-8 w-8 p-0",disabled:ee.has($.original.key),children:ee.has($.original.key)?c.jsx(Te,{className:"h-4 w-4 animate-spin"}):c.jsx(mi,{className:"h-4 w-4"})}),c.jsx(de,{variant:"ghost",size:"icon",onClick:()=>{R($.original),B($.original.name)},className:"h-8 w-8 p-0",children:c.jsx(Hd,{className:"h-4 w-4"})}),c.jsx(de,{variant:"ghost",size:"icon",onClick:()=>x($.original),className:"h-8 w-8 p-0",children:c.jsx(vi,{className:"h-4 w-4"})})]})}),D},[a,Ie,Rt,ee,r]),Ye=Fi({data:Ie,columns:he,state:{rowSelection:Rt},enableRowSelection:!0,onRowSelectionChange:V,getCoreRowModel:_i()}),pi=async D=>{if(Nr(D)){lt(!0);try{const $=await oe.get(`${t}/api/read-text`,{params:{path:D.key}});Se($.data.content)}catch($){console.error("Error loading file content:",$),F({title:"Error",description:"Failed to load file content",variant:"destructive"})}finally{lt(!1)}}},Mn=async(D,$)=>{_t(!0);try{await oe.post(`${t}/api/modify-text`,{path:D.key,content:$}),F({title:"File Saved",description:"File content has been updated successfully"}),tt.current=!0,await Ve(),R(null),Se(""),Ke("rename")}catch(j){console.error("Error saving file content:",j),F({title:"Error",description:"Failed to save file content",variant:"destructive"})}finally{_t(!1)}};return O.useEffect(()=>{I&&Nr(I)&&(pi(I),Ke("rename"))},[I]),c.jsxs("div",{className:"space-y-4 s3-explr-container",children:[c.jsx(_a,{className:"s3-explr-breadcrumb",children:c.jsxs(Fa,{className:"s3-explr-breadcrumb-list",children:[c.jsx(Fo,{className:"s3-explr-breadcrumb-item",children:c.jsx(Oo,{onClick:()=>f(n),className:"flex items-center gap-1 cursor-pointer s3-explr-breadcrumb-home",children:e})}),ne.map((D,$)=>c.jsxs(c.Fragment,{children:[c.jsx(Oa,{className:"s3-explr-breadcrumb-separator"},`sep-${$}`),c.jsx(Fo,{className:"s3-explr-breadcrumb-item",children:c.jsx(Oo,{onClick:()=>qt(n+ne.slice(0,$+1).join("/")+"/"),className:"cursor-pointer s3-explr-breadcrumb-link",children:D})},`item-${D}`)]}))]})}),c.jsxs("div",{className:"flex items-center space-x-4 s3-explr-toolbar",children:[c.jsx("div",{className:"relative max-w-sm w-full s3-explr-search-container",children:c.jsx(ew,{ref:Z,onChange:D=>i(D)})}),c.jsxs(de,{variant:"outline",size:"sm",onClick:()=>{tt.current=!0,Ve()},disabled:Ot,className:"flex items-center gap-2 s3-explr-refresh-btn",children:[c.jsx(kd,{className:`h-4 w-4 s3-explr-refresh-icon ${Ot?"animate-spin":""}`}),"Refresh"]}),!r&&c.jsxs(c.Fragment,{children:[a.size>0&&c.jsxs(c.Fragment,{children:[c.jsxs(de,{variant:"outline",size:"sm",onClick:()=>W(Array.from(a)),disabled:Array.from(a).some(D=>ee.has(D)),className:"flex items-center gap-2 s3-explr-download-selected-btn",children:[Array.from(a).some(D=>ee.has(D))?c.jsx(Te,{className:"h-4 w-4 animate-spin mr-2 s3-explr-loader"}):c.jsx(mi,{className:"h-4 w-4 s3-explr-download-icon"}),"Download Selected (",a.size,")"]}),c.jsxs(on,{open:E,onOpenChange:M,children:[c.jsx(lr,{asChild:!0,children:c.jsxs(de,{variant:"destructive",size:"sm",className:"flex items-center gap-2 s3-explr-bulk-delete-btn",children:[c.jsx(vi,{className:"h-4 w-4 s3-explr-trash-icon"}),"Remove Selected (",a.size,")"]})}),c.jsxs(Vt,{className:"s3-explr-dialog-content",children:[c.jsxs(Bt,{className:"s3-explr-dialog-header",children:[c.jsx(zt,{className:"s3-explr-dialog-title",children:"Confirm Bulk Deletion"}),c.jsxs(Qo,{className:"s3-explr-dialog-description",children:["Are you sure you want to delete ",a.size," selected items? This action cannot be undone."]})]}),c.jsxs(cr,{className:"s3-explr-dialog-footer",children:[c.jsx(de,{variant:"outline",onClick:()=>M(!1),className:"s3-explr-cancel-btn",children:"Cancel"}),c.jsx(de,{variant:"destructive",onClick:L,disabled:b,className:"s3-explr-confirm-delete-btn",children:b?c.jsxs(c.Fragment,{children:[c.jsx(Te,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Deleting..."]}):"Delete Selected"})]})]})]})]}),c.jsxs(on,{open:g,onOpenChange:h,children:[c.jsx(lr,{asChild:!0,children:c.jsxs(de,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-new-folder-btn",children:[c.jsx(Vd,{className:"h-4 w-4 s3-explr-folder-plus-icon"}),"New Folder"]})}),c.jsxs(Vt,{className:"s3-explr-dialog-content",children:[c.jsx(Bt,{className:"s3-explr-dialog-header",children:c.jsx(zt,{className:"s3-explr-dialog-title",children:"Create New Folder"})}),c.jsxs("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:[c.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[c.jsx(Ht,{htmlFor:"name",className:"s3-explr-label",children:"Folder Name"}),c.jsx(Et,{disabled:m,id:"name",value:p,onChange:D=>v(D.target.value),placeholder:"Enter folder name",className:"s3-explr-input"})]}),c.jsxs(de,{onClick:()=>{p.trim()&&C(p,l)},disabled:m,className:"s3-explr-create-btn",children:[m&&c.jsx(Te,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),m?"Creating...":"Create"]})]})]})]}),c.jsxs("div",{className:"flex items-center gap-2 s3-explr-upload-group",children:[c.jsx(de,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-upload-files-btn",onClick:()=>{const D=document.createElement("input");D.type="file",D.multiple=!0,D.onchange=$=>{const j=$.target.files;j&&A(j,l,"files")},D.click()},disabled:H!==null,children:H==="files"?c.jsxs(c.Fragment,{children:[c.jsx(Te,{className:"h-4 w-4 animate-spin mr-2 s3-explr-loader"}),"Uploading..."]}):c.jsxs(c.Fragment,{children:[c.jsx($d,{className:"h-4 w-4 s3-explr-upload-icon"}),"Upload Files"]})}),c.jsx(de,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-upload-folder-btn",onClick:()=>{const D=document.createElement("input");D.type="file",D.multiple=!0,D.webkitdirectory=!0,D.onchange=$=>{const j=$.target.files;j&&A(j,l,"folder")},D.click()},disabled:H!==null,children:H==="folder"?c.jsxs(c.Fragment,{children:[c.jsx(Te,{className:"h-4 w-4 animate-spin mr-2 s3-explr-loader"}),"Uploading..."]}):c.jsxs(c.Fragment,{children:[c.jsx(Kr,{className:"h-4 w-4 s3-explr-folder-icon"}),"Upload Folder"]})})]}),c.jsx(on,{open:!!w,onOpenChange:D=>!D&&x(null),children:c.jsxs(Vt,{className:"s3-explr-dialog-content",children:[c.jsxs(Bt,{className:"s3-explr-dialog-header",children:[c.jsx(zt,{className:"s3-explr-dialog-title",children:"Confirm Deletion"}),c.jsxs(Qo,{className:"s3-explr-dialog-description",children:["Are you sure you want to delete ",w==null?void 0:w.name,"? This action cannot be undone."]})]}),c.jsxs(cr,{className:"s3-explr-dialog-footer",children:[c.jsx(de,{variant:"outline",onClick:()=>x(null),className:"s3-explr-cancel-btn",children:"Cancel"}),c.jsx(de,{variant:"destructive",onClick:()=>_(w),disabled:N,className:"s3-explr-confirm-delete-btn",children:N?c.jsxs(c.Fragment,{children:[c.jsx(Te,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Deleting..."]}):"Delete"})]})]})}),c.jsx(on,{open:!!I,onOpenChange:D=>{D||(R(null),B(""),Se(""),Ke("rename"))},children:c.jsxs(Vt,{className:"s3-explr-dialog-content max-w-2xl",children:[c.jsx(Bt,{className:"s3-explr-dialog-header",children:c.jsx(zt,{className:"s3-explr-dialog-title",children:I!=null&&I.isFolder?"Rename Folder":Nr(I)?"Manage File":"Rename File"})}),I&&!I.isFolder&&Nr(I)?c.jsxs(uv,{value:Ft,onValueChange:D=>Ke(D),children:[c.jsxs(hc,{className:"grid w-full grid-cols-2",children:[c.jsx(fs,{value:"rename",children:"Rename"}),c.jsx(fs,{value:"edit",children:"Edit Content"})]}),c.jsx(ps,{value:"rename",children:c.jsx("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:c.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[c.jsx(Ht,{htmlFor:"newName",className:"s3-explr-label",children:"New Name"}),c.jsx(Et,{id:"newName",value:G,onChange:D=>B(D.target.value),placeholder:"Enter new name",disabled:K,className:"s3-explr-input"})]})})}),c.jsx(ps,{value:"edit",children:c.jsx("div",{className:"space-y-4 py-4",children:ae?c.jsx("div",{className:"flex items-center justify-center py-4",children:c.jsx(Te,{className:"h-6 w-6 animate-spin"})}):c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ht,{htmlFor:"content",className:"s3-explr-label",children:"File Content"}),c.jsx(vr,{id:"content",value:ue,onChange:D=>Se(D.target.value),placeholder:"Enter file content",className:"min-h-[200px] font-mono",disabled:Gt})]})})})]}):c.jsx("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:c.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[c.jsx(Ht,{htmlFor:"newName",className:"s3-explr-label",children:"New Name"}),c.jsx(Et,{id:"newName",value:G,onChange:D=>B(D.target.value),placeholder:"Enter new name",disabled:K,className:"s3-explr-input"})]})}),c.jsxs(cr,{className:"s3-explr-dialog-footer",children:[c.jsx(de,{variant:"outline",onClick:()=>{R(null),B(""),Se("")},className:"s3-explr-cancel-btn",children:"Cancel"}),Ft==="edit"?c.jsx(de,{onClick:()=>I&&Mn(I,ue),disabled:Gt||ae,className:"s3-explr-save-btn",children:Gt?c.jsxs(c.Fragment,{children:[c.jsx(Te,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Saving..."]}):"Save Changes"}):c.jsx(de,{onClick:()=>{G.trim()&&I&&k(I,G.trim())},disabled:K||!G.trim()||G.trim()===(I==null?void 0:I.name),className:"s3-explr-rename-btn",children:K?c.jsxs(c.Fragment,{children:[c.jsx(Te,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Renaming..."]}):"Rename"})]})]})})]})]}),Wt&&c.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative s3-explr-error",children:"An error occurred while fetching files"}),c.jsx("div",{className:"rounded-md border s3-explr-table-container",children:c.jsxs(ur,{className:"s3-explr-table",children:[c.jsx(dr,{className:"s3-explr-table-header",children:Ye.getHeaderGroups().map(D=>c.jsx(je,{className:"hover:bg-transparent s3-explr-header-row",children:D.headers.map($=>c.jsx(et,{className:"s3-explr-header-cell",children:$.isPlaceholder?null:Bn($.column.columnDef.header,$.getContext())},$.id))},D.id))}),c.jsx(fr,{className:"s3-explr-table-body",children:Ye.getRowModel().rows.length===0?c.jsx(je,{className:"s3-explr-empty-row",children:c.jsx(_e,{colSpan:he.length,className:"h-24 text-center s3-explr-empty-cell",children:s?c.jsxs("div",{className:"text-gray-500 s3-explr-no-results",children:['No files or folders found matching "',s,'"']}):c.jsx("div",{className:"text-gray-500 s3-explr-empty-message",children:Ot?"Retrieving folder contents... Please wait":"This folder contains no files or subdirectories"})})}):Ye.getRowModel().rows.map(D=>c.jsx(je,{className:"h-12 s3-explr-row",children:D.getVisibleCells().map($=>c.jsx(_e,{className:"align-middle s3-explr-cell",children:Bn($.column.columnDef.cell,$.getContext())},$.id))},D.id))})]})}),r&&o&&c.jsxs("div",{className:"flex justify-between items-center mt-4 s3-explr-selector-footer",children:[c.jsxs("div",{className:"text-sm text-gray-500 s3-explr-selection-count",children:[a.size," ",a.size===1?"file":"files"," selected"]}),c.jsx(de,{variant:"default",onClick:()=>o(ve()),disabled:a.size===0,className:"s3-explr-ok-btn",children:"OK"})]}),!r&&c.jsx(Hc,{})]})});var Sn=e=>e.type==="checkbox",Ut=e=>e instanceof Date,Pe=e=>e==null;const nu=e=>typeof e=="object";var ge=e=>!Pe(e)&&!Array.isArray(e)&&nu(e)&&!Ut(e),sw=e=>ge(e)&&e.target?Sn(e.target)?e.target.checked:e.target.value:e,iw=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,aw=(e,t)=>e.has(iw(t)),lw=e=>{const t=e.constructor&&e.constructor.prototype;return ge(t)&&t.hasOwnProperty("isPrototypeOf")},Ts=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Le(e){let t;const n=Array.isArray(e),r=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(Ts&&(e instanceof Blob||r))&&(n||ge(e)))if(t=n?[]:{},!n&&!lw(e))t=e;else for(const o in e)e.hasOwnProperty(o)&&(t[o]=Le(e[o]));else return e;return t}var Pr=e=>Array.isArray(e)?e.filter(Boolean):[],fe=e=>e===void 0,z=(e,t,n)=>{if(!t||!ge(e))return n;const r=Pr(t.split(/[,[\].]+?/)).reduce((o,s)=>Pe(o)?o:o[s],e);return fe(r)||r===e?fe(e[t])?n:e[t]:r},nt=e=>typeof e=="boolean",_s=e=>/^\w*$/.test(e),ru=e=>Pr(e.replace(/["|']|\]/g,"").split(/\.|\[/)),ce=(e,t,n)=>{let r=-1;const o=_s(t)?[t]:ru(t),s=o.length,i=s-1;for(;++r<s;){const a=o[r];let u=n;if(r!==i){const l=e[a];u=ge(l)||Array.isArray(l)?l:isNaN(+o[r+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;e[a]=u,e=e[a]}return e};const ou={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Ge={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ft={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};O.createContext(null);var cw=(e,t,n,r=!0)=>{const o={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(o,s,{get:()=>{const i=s;return t._proxyFormState[i]!==Ge.all&&(t._proxyFormState[i]=!r||Ge.all),e[i]}});return o},Fe=e=>ge(e)&&!Object.keys(e).length,uw=(e,t,n,r)=>{n(e);const{name:o,...s}=e;return Fe(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(i=>t[i]===Ge.all)},Ar=e=>Array.isArray(e)?e:[e];function dw(e){const t=O.useRef(e);t.current=e,O.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}var rt=e=>typeof e=="string",fw=(e,t,n,r,o)=>rt(e)?(r&&t.watch.add(e),z(n,e,o)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),z(n,s))):(r&&(t.watchAll=!0),n),pw=(e,t,n,r,o)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:o||!0}}:{},su=e=>({isOnSubmit:!e||e===Ge.onSubmit,isOnBlur:e===Ge.onBlur,isOnChange:e===Ge.onChange,isOnAll:e===Ge.all,isOnTouch:e===Ge.onTouched}),iu=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const En=(e,t,n,r)=>{for(const o of n||Object.keys(e)){const s=z(e,o);if(s){const{_f:i,...a}=s;if(i){if(i.refs&&i.refs[0]&&t(i.refs[0],o)&&!r)return!0;if(i.ref&&t(i.ref,i.name)&&!r)return!0;if(En(a,t))break}else if(ge(a)&&En(a,t))break}}};var gw=(e,t,n)=>{const r=Ar(z(e,n));return ce(r,"root",t[n]),ce(e,n,r),e},Fs=e=>e.type==="file",ot=e=>typeof e=="function",Tr=e=>{if(!Ts)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},_r=e=>rt(e),Os=e=>e.type==="radio",Fr=e=>e instanceof RegExp;const au={value:!1,isValid:!1},lu={value:!0,isValid:!0};var cu=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!fe(e[0].attributes.value)?fe(e[0].value)||e[0].value===""?lu:{value:e[0].value,isValid:!0}:lu:au}return au};const uu={isValid:!1,value:null};var du=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,uu):uu;function fu(e,t,n="validate"){if(_r(e)||Array.isArray(e)&&e.every(_r)||nt(e)&&!e)return{type:n,message:_r(e)?e:"",ref:t}}var an=e=>ge(e)&&!Fr(e)?e:{value:e,message:""},pu=async(e,t,n,r,o)=>{const{ref:s,refs:i,required:a,maxLength:u,minLength:l,min:f,max:g,pattern:h,validate:p,name:v,valueAsNumber:m,mount:y,disabled:w}=e._f,x=z(t,v);if(!y||w)return{};const N=i?i[0]:s,P=F=>{r&&N.reportValidity&&(N.setCustomValidity(nt(F)?"":F||""),N.reportValidity())},b={},S=Os(s),E=Sn(s),M=S||E,H=(m||Fs(s))&&fe(s.value)&&fe(x)||Tr(s)&&s.value===""||x===""||Array.isArray(x)&&!x.length,U=pw.bind(null,v,n,b),Z=(F,I,R,G=ft.maxLength,B=ft.minLength)=>{const K=F?I:R;b[v]={type:F?G:B,message:K,ref:s,...U(F?G:B,K)}};if(o?!Array.isArray(x)||!x.length:a&&(!M&&(H||Pe(x))||nt(x)&&!x||E&&!cu(i).isValid||S&&!du(i).isValid)){const{value:F,message:I}=_r(a)?{value:!!a,message:a}:an(a);if(F&&(b[v]={type:ft.required,message:I,ref:N,...U(ft.required,I)},!n))return P(I),b}if(!H&&(!Pe(f)||!Pe(g))){let F,I;const R=an(g),G=an(f);if(!Pe(x)&&!isNaN(x)){const B=s.valueAsNumber||x&&+x;Pe(R.value)||(F=B>R.value),Pe(G.value)||(I=B<G.value)}else{const B=s.valueAsDate||new Date(x),K=ie=>new Date(new Date().toDateString()+" "+ie),q=s.type=="time",ee=s.type=="week";rt(R.value)&&x&&(F=q?K(x)>K(R.value):ee?x>R.value:B>new Date(R.value)),rt(G.value)&&x&&(I=q?K(x)<K(G.value):ee?x<G.value:B<new Date(G.value))}if((F||I)&&(Z(!!F,R.message,G.message,ft.max,ft.min),!n))return P(b[v].message),b}if((u||l)&&!H&&(rt(x)||o&&Array.isArray(x))){const F=an(u),I=an(l),R=!Pe(F.value)&&x.length>+F.value,G=!Pe(I.value)&&x.length<+I.value;if((R||G)&&(Z(R,F.message,I.message),!n))return P(b[v].message),b}if(h&&!H&&rt(x)){const{value:F,message:I}=an(h);if(Fr(F)&&!x.match(F)&&(b[v]={type:ft.pattern,message:I,ref:s,...U(ft.pattern,I)},!n))return P(I),b}if(p){if(ot(p)){const F=await p(x,t),I=fu(F,N);if(I&&(b[v]={...I,...U(ft.validate,I.message)},!n))return P(I.message),b}else if(ge(p)){let F={};for(const I in p){if(!Fe(F)&&!n)break;const R=fu(await p[I](x,t),N,I);R&&(F={...R,...U(I,R.message)},P(R.message),n&&(b[v]=F))}if(!Fe(F)&&(b[v]={ref:N,...F},!n))return b}}return P(!0),b};function hw(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=fe(e)?r++:e[t[r++]];return e}function mw(e){for(const t in e)if(e.hasOwnProperty(t)&&!fe(e[t]))return!1;return!0}function we(e,t){const n=Array.isArray(t)?t:_s(t)?[t]:ru(t),r=n.length===1?e:hw(e,n),o=n.length-1,s=n[o];return r&&delete r[s],o!==0&&(ge(r)&&Fe(r)||Array.isArray(r)&&mw(r))&&we(e,n.slice(0,-1)),e}var Rs=()=>{let e=[];return{get observers(){return e},next:o=>{for(const s of e)s.next&&s.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(s=>s!==o)}}),unsubscribe:()=>{e=[]}}},Ds=e=>Pe(e)||!nu(e);function Nt(e,t){if(Ds(e)||Ds(t))return e===t;if(Ut(e)&&Ut(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){const s=e[o];if(!r.includes(o))return!1;if(o!=="ref"){const i=t[o];if(Ut(s)&&Ut(i)||ge(s)&&ge(i)||Array.isArray(s)&&Array.isArray(i)?!Nt(s,i):s!==i)return!1}}return!0}var gu=e=>e.type==="select-multiple",vw=e=>Os(e)||Sn(e),Ms=e=>Tr(e)&&e.isConnected,hu=e=>{for(const t in e)if(ot(e[t]))return!0;return!1};function Or(e,t={}){const n=Array.isArray(e);if(ge(e)||n)for(const r in e)Array.isArray(e[r])||ge(e[r])&&!hu(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Or(e[r],t[r])):Pe(e[r])||(t[r]=!0);return t}function mu(e,t,n){const r=Array.isArray(e);if(ge(e)||r)for(const o in e)Array.isArray(e[o])||ge(e[o])&&!hu(e[o])?fe(t)||Ds(n[o])?n[o]=Array.isArray(e[o])?Or(e[o],[]):{...Or(e[o])}:mu(e[o],Pe(t)?{}:t[o],n[o]):n[o]=!Nt(e[o],t[o]);return n}var Nn=(e,t)=>mu(e,t,Or(t)),vu=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>fe(e)?e:t?e===""?NaN:e&&+e:n&&rt(e)?new Date(e):r?r(e):e;function ks(e){const t=e.ref;if(!(e.refs?e.refs.every(n=>n.disabled):t.disabled))return Fs(t)?t.files:Os(t)?du(e.refs).value:gu(t)?[...t.selectedOptions].map(({value:n})=>n):Sn(t)?cu(e.refs).value:vu(fe(t.value)?e.ref.value:t.value,e)}var yw=(e,t,n,r)=>{const o={};for(const s of e){const i=z(t,s);i&&ce(o,s,i._f)}return{criteriaMode:n,names:[...e],fields:o,shouldUseNativeValidation:r}},Pn=e=>fe(e)?e:Fr(e)?e.source:ge(e)?Fr(e.value)?e.value.source:e.value:e;const yu="AsyncFunction";var ww=e=>!!e&&!!e.validate&&!!(ot(e.validate)&&e.validate.constructor.name===yu||ge(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===yu)),bw=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function wu(e,t,n){const r=z(e,n);if(r||_s(n))return{error:r,name:n};const o=n.split(".");for(;o.length;){const s=o.join("."),i=z(t,s),a=z(e,s);if(i&&!Array.isArray(i)&&n!==s)return{name:n};if(a&&a.type)return{name:s,error:a};o.pop()}return{name:n}}var xw=(e,t,n,r,o)=>o.isOnAll?!1:!n&&o.isOnTouch?!(t||e):(n?r.isOnBlur:o.isOnBlur)?!e:(n?r.isOnChange:o.isOnChange)?e:!0,Cw=(e,t)=>!Pr(z(e,t)).length&&we(e,t);const Sw={mode:Ge.onSubmit,reValidateMode:Ge.onChange,shouldFocusError:!0};function Ew(e={}){let t={...Sw,...e},n={submitCount:0,isDirty:!1,isLoading:ot(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},o=ge(t.defaultValues)||ge(t.values)?Le(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:Le(o),i={action:!1,mount:!1,watch:!1},a={mount:new Set,unMount:new Set,array:new Set,watch:new Set},u,l=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},g={values:Rs(),array:Rs(),state:Rs()},h=su(t.mode),p=su(t.reValidateMode),v=t.criteriaMode===Ge.all,m=C=>A=>{clearTimeout(l),l=setTimeout(C,A)},y=async C=>{if(!t.disabled&&(f.isValid||C)){const A=t.resolver?Fe((await M()).errors):await U(r,!0);A!==n.isValid&&g.state.next({isValid:A})}},w=(C,A)=>{!t.disabled&&(f.isValidating||f.validatingFields)&&((C||Array.from(a.mount)).forEach(_=>{_&&(A?ce(n.validatingFields,_,A):we(n.validatingFields,_))}),g.state.next({validatingFields:n.validatingFields,isValidating:!Fe(n.validatingFields)}))},x=(C,A=[],_,V,L=!0,k=!0)=>{if(V&&_&&!t.disabled){if(i.action=!0,k&&Array.isArray(z(r,C))){const W=_(z(r,C),V.argA,V.argB);L&&ce(r,C,W)}if(k&&Array.isArray(z(n.errors,C))){const W=_(z(n.errors,C),V.argA,V.argB);L&&ce(n.errors,C,W),Cw(n.errors,C)}if(f.touchedFields&&k&&Array.isArray(z(n.touchedFields,C))){const W=_(z(n.touchedFields,C),V.argA,V.argB);L&&ce(n.touchedFields,C,W)}f.dirtyFields&&(n.dirtyFields=Nn(o,s)),g.state.next({name:C,isDirty:F(C,A),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else ce(s,C,A)},N=(C,A)=>{ce(n.errors,C,A),g.state.next({errors:n.errors})},P=C=>{n.errors=C,g.state.next({errors:n.errors,isValid:!1})},b=(C,A,_,V)=>{const L=z(r,C);if(L){const k=z(s,C,fe(_)?z(o,C):_);fe(k)||V&&V.defaultChecked||A?ce(s,C,A?k:ks(L._f)):G(C,k),i.mount&&y()}},S=(C,A,_,V,L)=>{let k=!1,W=!1;const ne={name:C};if(!t.disabled){const ve=!!(z(r,C)&&z(r,C)._f&&z(r,C)._f.disabled);if(!_||V){f.isDirty&&(W=n.isDirty,n.isDirty=ne.isDirty=F(),k=W!==ne.isDirty);const he=ve||Nt(z(o,C),A);W=!!(!ve&&z(n.dirtyFields,C)),he||ve?we(n.dirtyFields,C):ce(n.dirtyFields,C,!0),ne.dirtyFields=n.dirtyFields,k=k||f.dirtyFields&&W!==!he}if(_){const he=z(n.touchedFields,C);he||(ce(n.touchedFields,C,_),ne.touchedFields=n.touchedFields,k=k||f.touchedFields&&he!==_)}k&&L&&g.state.next(ne)}return k?ne:{}},E=(C,A,_,V)=>{const L=z(n.errors,C),k=f.isValid&&nt(A)&&n.isValid!==A;if(t.delayError&&_?(u=m(()=>N(C,_)),u(t.delayError)):(clearTimeout(l),u=null,_?ce(n.errors,C,_):we(n.errors,C)),(_?!Nt(L,_):L)||!Fe(V)||k){const W={...V,...k&&nt(A)?{isValid:A}:{},errors:n.errors,name:C};n={...n,...W},g.state.next(W)}},M=async C=>{w(C,!0);const A=await t.resolver(s,t.context,yw(C||a.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return w(C),A},H=async C=>{const{errors:A}=await M(C);if(C)for(const _ of C){const V=z(A,_);V?ce(n.errors,_,V):we(n.errors,_)}else n.errors=A;return A},U=async(C,A,_={valid:!0})=>{for(const V in C){const L=C[V];if(L){const{_f:k,...W}=L;if(k){const ne=a.array.has(k.name),ve=L._f&&ww(L._f);ve&&f.validatingFields&&w([V],!0);const he=await pu(L,s,v,t.shouldUseNativeValidation&&!A,ne);if(ve&&f.validatingFields&&w([V]),he[k.name]&&(_.valid=!1,A))break;!A&&(z(he,k.name)?ne?gw(n.errors,he,k.name):ce(n.errors,k.name,he[k.name]):we(n.errors,k.name))}!Fe(W)&&await U(W,A,_)}}return _.valid},Z=()=>{for(const C of a.unMount){const A=z(r,C);A&&(A._f.refs?A._f.refs.every(_=>!Ms(_)):!Ms(A._f.ref))&&_t(C)}a.unMount=new Set},F=(C,A)=>!t.disabled&&(C&&A&&ce(s,C,A),!Nt(ue(),o)),I=(C,A,_)=>fw(C,a,{...i.mount?s:fe(A)?o:rt(C)?{[C]:A}:A},_,A),R=C=>Pr(z(i.mount?s:o,C,t.shouldUnregister?z(o,C,[]):[])),G=(C,A,_={})=>{const V=z(r,C);let L=A;if(V){const k=V._f;k&&(!k.disabled&&ce(s,C,vu(A,k)),L=Tr(k.ref)&&Pe(A)?"":A,gu(k.ref)?[...k.ref.options].forEach(W=>W.selected=L.includes(W.value)):k.refs?Sn(k.ref)?k.refs.length>1?k.refs.forEach(W=>(!W.defaultChecked||!W.disabled)&&(W.checked=Array.isArray(L)?!!L.find(ne=>ne===W.value):L===W.value)):k.refs[0]&&(k.refs[0].checked=!!L):k.refs.forEach(W=>W.checked=W.value===L):Fs(k.ref)?k.ref.value="":(k.ref.value=L,k.ref.type||g.values.next({name:C,values:{...s}})))}(_.shouldDirty||_.shouldTouch)&&S(C,L,_.shouldTouch,_.shouldDirty,!0),_.shouldValidate&&ie(C)},B=(C,A,_)=>{for(const V in A){const L=A[V],k=`${C}.${V}`,W=z(r,k);(a.array.has(C)||ge(L)||W&&!W._f)&&!Ut(L)?B(k,L,_):G(k,L,_)}},K=(C,A,_={})=>{const V=z(r,C),L=a.array.has(C),k=Le(A);ce(s,C,k),L?(g.array.next({name:C,values:{...s}}),(f.isDirty||f.dirtyFields)&&_.shouldDirty&&g.state.next({name:C,dirtyFields:Nn(o,s),isDirty:F(C,k)})):V&&!V._f&&!Pe(k)?B(C,k,_):G(C,k,_),iu(C,a)&&g.state.next({...n}),g.values.next({name:i.mount?C:void 0,values:{...s}})},q=async C=>{i.mount=!0;const A=C.target;let _=A.name,V=!0;const L=z(r,_),k=()=>A.type?ks(L._f):sw(C),W=ne=>{V=Number.isNaN(ne)||Ut(ne)&&isNaN(ne.getTime())||Nt(ne,z(s,_,ne))};if(L){let ne,ve;const he=k(),Ye=C.type===ou.BLUR||C.type===ou.FOCUS_OUT,pi=!bw(L._f)&&!t.resolver&&!z(n.errors,_)&&!L._f.deps||xw(Ye,z(n.touchedFields,_),n.isSubmitted,p,h),Mn=iu(_,a,Ye);ce(s,_,he),Ye?(L._f.onBlur&&L._f.onBlur(C),u&&u(0)):L._f.onChange&&L._f.onChange(C);const D=S(_,he,Ye,!1),$=!Fe(D)||Mn;if(!Ye&&g.values.next({name:_,type:C.type,values:{...s}}),pi)return f.isValid&&(t.mode==="onBlur"?Ye&&y():y()),$&&g.state.next({name:_,...Mn?{}:D});if(!Ye&&Mn&&g.state.next({...n}),t.resolver){const{errors:j}=await M([_]);if(W(he),V){const re=wu(n.errors,r,_),se=wu(j,r,re.name||_);ne=se.error,_=se.name,ve=Fe(j)}}else w([_],!0),ne=(await pu(L,s,v,t.shouldUseNativeValidation))[_],w([_]),W(he),V&&(ne?ve=!1:f.isValid&&(ve=await U(r,!0)));V&&(L._f.deps&&ie(L._f.deps),E(_,ve,ne,D))}},ee=(C,A)=>{if(z(n.errors,A)&&C.focus)return C.focus(),1},ie=async(C,A={})=>{let _,V;const L=Ar(C);if(t.resolver){const k=await H(fe(C)?C:L);_=Fe(k),V=C?!L.some(W=>z(k,W)):_}else C?(V=(await Promise.all(L.map(async k=>{const W=z(r,k);return await U(W&&W._f?{[k]:W}:W)}))).every(Boolean),!(!V&&!n.isValid)&&y()):V=_=await U(r);return g.state.next({...!rt(C)||f.isValid&&_!==n.isValid?{}:{name:C},...t.resolver||!C?{isValid:_}:{},errors:n.errors}),A.shouldFocus&&!V&&En(r,ee,C?L:a.mount),V},ue=C=>{const A={...i.mount?s:o};return fe(C)?A:rt(C)?z(A,C):C.map(_=>z(A,_))},Se=(C,A)=>({invalid:!!z((A||n).errors,C),isDirty:!!z((A||n).dirtyFields,C),error:z((A||n).errors,C),isValidating:!!z(n.validatingFields,C),isTouched:!!z((A||n).touchedFields,C)}),ae=C=>{C&&Ar(C).forEach(A=>we(n.errors,A)),g.state.next({errors:C?n.errors:{}})},lt=(C,A,_)=>{const V=(z(r,C,{_f:{}})._f||{}).ref,L=z(n.errors,C)||{},{ref:k,message:W,type:ne,...ve}=L;ce(n.errors,C,{...ve,...A,ref:V}),g.state.next({name:C,errors:n.errors,isValid:!1}),_&&_.shouldFocus&&V&&V.focus&&V.focus()},Gt=(C,A)=>ot(C)?g.values.subscribe({next:_=>C(I(void 0,A),_)}):I(C,A,!0),_t=(C,A={})=>{for(const _ of C?Ar(C):a.mount)a.mount.delete(_),a.array.delete(_),A.keepValue||(we(r,_),we(s,_)),!A.keepError&&we(n.errors,_),!A.keepDirty&&we(n.dirtyFields,_),!A.keepTouched&&we(n.touchedFields,_),!A.keepIsValidating&&we(n.validatingFields,_),!t.shouldUnregister&&!A.keepDefaultValue&&we(o,_);g.values.next({values:{...s}}),g.state.next({...n,...A.keepDirty?{isDirty:F()}:{}}),!A.keepIsValid&&y()},Ft=({disabled:C,name:A,field:_,fields:V,value:L})=>{if(nt(C)&&i.mount||C){const k=C?void 0:fe(L)?ks(_?_._f:z(V,A)._f):L;(C||!C&&!fe(k))&&ce(s,A,k),S(A,k,!1,!1,!0)}},Ke=(C,A={})=>{let _=z(r,C);const V=nt(A.disabled)||nt(t.disabled);return ce(r,C,{..._||{},_f:{..._&&_._f?_._f:{ref:{name:C}},name:C,mount:!0,...A}}),a.mount.add(C),_?Ft({field:_,disabled:nt(A.disabled)?A.disabled:t.disabled,name:C,value:A.value}):b(C,!0,A.value),{...V?{disabled:A.disabled||t.disabled}:{},...t.progressive?{required:!!A.required,min:Pn(A.min),max:Pn(A.max),minLength:Pn(A.minLength),maxLength:Pn(A.maxLength),pattern:Pn(A.pattern)}:{},name:C,onChange:q,onBlur:q,ref:L=>{if(L){Ke(C,A),_=z(r,C);const k=fe(L.value)&&L.querySelectorAll&&L.querySelectorAll("input,select,textarea")[0]||L,W=vw(k),ne=_._f.refs||[];if(W?ne.find(ve=>ve===k):k===_._f.ref)return;ce(r,C,{_f:{..._._f,...W?{refs:[...ne.filter(Ms),k,...Array.isArray(z(o,C))?[{}]:[]],ref:{type:k.type,name:C}}:{ref:k}}}),b(C,!1,void 0,k)}else _=z(r,C,{}),_._f&&(_._f.mount=!1),(t.shouldUnregister||A.shouldUnregister)&&!(aw(a.array,C)&&i.action)&&a.unMount.add(C)}}},be=()=>t.shouldFocusError&&En(r,ee,a.mount),Ot=C=>{nt(C)&&(g.state.next({disabled:C}),En(r,(A,_)=>{const V=z(r,_);V&&(A.disabled=V._f.disabled||C,Array.isArray(V._f.refs)&&V._f.refs.forEach(L=>{L.disabled=V._f.disabled||C}))},0,!1))},Wt=(C,A)=>async _=>{let V;if(_&&(_.preventDefault&&_.preventDefault(),_.persist&&_.persist()),t.disabled){A&&await A({...n.errors},_);return}let L=Le(s);if(g.state.next({isSubmitting:!0}),t.resolver){const{errors:k,values:W}=await M();n.errors=k,L=W}else await U(r);if(we(n.errors,"root"),Fe(n.errors)){g.state.next({errors:{}});try{await C(L,_)}catch(k){V=k}}else A&&await A({...n.errors},_),be(),setTimeout(be);if(g.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Fe(n.errors)&&!V,submitCount:n.submitCount+1,errors:n.errors}),V)throw V},Ve=(C,A={})=>{z(r,C)&&(fe(A.defaultValue)?K(C,Le(z(o,C))):(K(C,A.defaultValue),ce(o,C,Le(A.defaultValue))),A.keepTouched||we(n.touchedFields,C),A.keepDirty||(we(n.dirtyFields,C),n.isDirty=A.defaultValue?F(C,Le(z(o,C))):F()),A.keepError||(we(n.errors,C),f.isValid&&y()),g.state.next({...n}))},Xe=(C,A={})=>{const _=C?Le(C):o,V=Le(_),L=Fe(C),k=L?o:V;if(A.keepDefaultValues||(o=_),!A.keepValues){if(A.keepDirtyValues){const W=new Set([...a.mount,...Object.keys(Nn(o,s))]);for(const ne of Array.from(W))z(n.dirtyFields,ne)?ce(k,ne,z(s,ne)):K(ne,z(k,ne))}else{if(Ts&&fe(C))for(const W of a.mount){const ne=z(r,W);if(ne&&ne._f){const ve=Array.isArray(ne._f.refs)?ne._f.refs[0]:ne._f.ref;if(Tr(ve)){const he=ve.closest("form");if(he){he.reset();break}}}}r={}}s=t.shouldUnregister?A.keepDefaultValues?Le(o):{}:Le(k),g.array.next({values:{...k}}),g.values.next({values:{...k}})}a={mount:A.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!f.isValid||!!A.keepIsValid||!!A.keepDirtyValues,i.watch=!!t.shouldUnregister,g.state.next({submitCount:A.keepSubmitCount?n.submitCount:0,isDirty:L?!1:A.keepDirty?n.isDirty:!!(A.keepDefaultValues&&!Nt(C,o)),isSubmitted:A.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:L?{}:A.keepDirtyValues?A.keepDefaultValues&&s?Nn(o,s):n.dirtyFields:A.keepDefaultValues&&C?Nn(o,C):A.keepDirty?n.dirtyFields:{},touchedFields:A.keepTouched?n.touchedFields:{},errors:A.keepErrors?n.errors:{},isSubmitSuccessful:A.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},Ie=(C,A)=>Xe(ot(C)?C(s):C,A);return{control:{register:Ke,unregister:_t,getFieldState:Se,handleSubmit:Wt,setError:lt,_executeSchema:M,_getWatch:I,_getDirty:F,_updateValid:y,_removeUnmounted:Z,_updateFieldArray:x,_updateDisabledField:Ft,_getFieldArray:R,_reset:Xe,_resetDefaultValues:()=>ot(t.defaultValues)&&t.defaultValues().then(C=>{Ie(C,t.resetOptions),g.state.next({isLoading:!1})}),_updateFormState:C=>{n={...n,...C}},_disableForm:Ot,_subjects:g,_proxyFormState:f,_setErrors:P,get _fields(){return r},get _formValues(){return s},get _state(){return i},set _state(C){i=C},get _defaultValues(){return o},get _names(){return a},set _names(C){a=C},get _formState(){return n},set _formState(C){n=C},get _options(){return t},set _options(C){t={...t,...C}}},trigger:ie,register:Ke,handleSubmit:Wt,watch:Gt,setValue:K,getValues:ue,reset:Ie,resetField:Ve,clearErrors:ae,unregister:_t,setError:lt,setFocus:(C,A={})=>{const _=z(r,C),V=_&&_._f;if(V){const L=V.refs?V.refs[0]:V.ref;L.focus&&(L.focus(),A.shouldSelect&&ot(L.select)&&L.select())}},getFieldState:Se}}function Nw(e={}){const t=O.useRef(),n=O.useRef(),[r,o]=O.useState({isDirty:!1,isValidating:!1,isLoading:ot(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ot(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Ew(e),formState:r});const s=t.current.control;return s._options=e,dw({subject:s._subjects.state,next:i=>{uw(i,s._proxyFormState,s._updateFormState)&&o({...s._formState})}}),O.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),O.useEffect(()=>{if(s._proxyFormState.isDirty){const i=s._getDirty();i!==r.isDirty&&s._subjects.state.next({isDirty:i})}},[s,r.isDirty]),O.useEffect(()=>{e.values&&!Nt(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,o(i=>({...i}))):s._resetDefaultValues()},[e.values,s]),O.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),O.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),O.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),O.useMemo(()=>({...t.current,formState:cw(r,s)}),[r,s])}function pt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function bu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Pw(...e){return t=>{let n=!1;const r=e.map(o=>{const s=bu(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():bu(e[o],null)}}}}function An(...e){return d.useCallback(Pw(...e),e)}var Aw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Tn=Aw.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?It:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function Tw(e,t){e&&kn.flushSync(()=>e.dispatchEvent(t))}var _w="DismissableLayer",Is="dismissableLayer.update",Fw="dismissableLayer.pointerDownOutside",Ow="dismissableLayer.focusOutside",xu,Cu=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Su=d.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...u}=e,l=d.useContext(Cu),[f,g]=d.useState(null),h=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=d.useState({}),v=An(t,E=>g(E)),m=Array.from(l.layers),[y]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),w=m.indexOf(y),x=f?m.indexOf(f):-1,N=l.layersWithOutsidePointerEventsDisabled.size>0,P=x>=w,b=Mw(E=>{const M=E.target,H=[...l.branches].some(U=>U.contains(M));!P||H||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),S=kw(E=>{const M=E.target;[...l.branches].some(U=>U.contains(M))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return Ua(E=>{x===l.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),d.useEffect(()=>{if(f)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(xu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(f)),l.layers.add(f),Eu(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=xu)}},[f,h,n,l]),d.useEffect(()=>()=>{f&&(l.layers.delete(f),l.layersWithOutsidePointerEventsDisabled.delete(f),Eu())},[f,l]),d.useEffect(()=>{const E=()=>p({});return document.addEventListener(Is,E),()=>document.removeEventListener(Is,E)},[]),c.jsx(Tn.div,{...u,ref:v,style:{pointerEvents:N?P?"auto":"none":void 0,...e.style},onFocusCapture:pt(e.onFocusCapture,S.onFocusCapture),onBlurCapture:pt(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:pt(e.onPointerDownCapture,b.onPointerDownCapture)})});Su.displayName=_w;var Rw="DismissableLayerBranch",Dw=d.forwardRef((e,t)=>{const n=d.useContext(Cu),r=d.useRef(null),o=An(t,r);return d.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(Tn.div,{...e,ref:o})});Dw.displayName=Rw;function Mw(e,t=globalThis==null?void 0:globalThis.document){const n=Ee(e),r=d.useRef(!1),o=d.useRef(()=>{});return d.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let u=function(){Nu(Fw,n,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=u,t.addEventListener("click",o.current,{once:!0})):u()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function kw(e,t=globalThis==null?void 0:globalThis.document){const n=Ee(e),r=d.useRef(!1);return d.useEffect(()=>{const o=s=>{s.target&&!r.current&&Nu(Ow,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Eu(){const e=new CustomEvent(Is);document.dispatchEvent(e)}function Nu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Tw(o,s):o.dispatchEvent(s)}const Iw=["top","right","bottom","left"],Pt=Math.min,Me=Math.max,Rr=Math.round,Dr=Math.floor,st=e=>({x:e,y:e}),$w={left:"right",right:"left",bottom:"top",top:"bottom"},Lw={start:"end",end:"start"};function $s(e,t,n){return Me(e,Pt(t,n))}function gt(e,t){return typeof e=="function"?e(t):e}function ht(e){return e.split("-")[0]}function ln(e){return e.split("-")[1]}function Ls(e){return e==="x"?"y":"x"}function Vs(e){return e==="y"?"height":"width"}function At(e){return["top","bottom"].includes(ht(e))?"y":"x"}function Bs(e){return Ls(At(e))}function Vw(e,t,n){n===void 0&&(n=!1);const r=ln(e),o=Bs(e),s=Vs(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Mr(i)),[i,Mr(i)]}function Bw(e){const t=Mr(e);return[zs(e),t,zs(t)]}function zs(e){return e.replace(/start|end/g,t=>Lw[t])}function zw(e,t,n){const r=["left","right"],o=["right","left"],s=["top","bottom"],i=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?s:i;default:return[]}}function Hw(e,t,n,r){const o=ln(e);let s=zw(ht(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(zs)))),s}function Mr(e){return e.replace(/left|right|bottom|top/g,t=>$w[t])}function Uw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Pu(e){return typeof e!="number"?Uw(e):{top:e,right:e,bottom:e,left:e}}function kr(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Au(e,t,n){let{reference:r,floating:o}=e;const s=At(t),i=Bs(t),a=Vs(i),u=ht(t),l=s==="y",f=r.x+r.width/2-o.width/2,g=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(u){case"top":p={x:f,y:r.y-o.height};break;case"bottom":p={x:f,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:g};break;case"left":p={x:r.x-o.width,y:g};break;default:p={x:r.x,y:r.y}}switch(ln(t)){case"start":p[i]-=h*(n&&l?-1:1);break;case"end":p[i]+=h*(n&&l?-1:1);break}return p}const jw=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),u=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:g}=Au(l,r,u),h=r,p={},v=0;for(let m=0;m<a.length;m++){const{name:y,fn:w}=a[m],{x,y:N,data:P,reset:b}=await w({x:f,y:g,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:l,platform:i,elements:{reference:e,floating:t}});f=x??f,g=N??g,p={...p,[y]:{...p[y],...P}},b&&v<=50&&(v++,typeof b=="object"&&(b.placement&&(h=b.placement),b.rects&&(l=b.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):b.rects),{x:f,y:g}=Au(l,h,u)),m=-1)}return{x:f,y:g,placement:h,strategy:o,middlewareData:p}};async function _n(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:u}=e,{boundary:l="clippingAncestors",rootBoundary:f="viewport",elementContext:g="floating",altBoundary:h=!1,padding:p=0}=gt(t,e),v=Pu(p),y=a[h?g==="floating"?"reference":"floating":g],w=kr(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:l,rootBoundary:f,strategy:u})),x=g==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,N=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),P=await(s.isElement==null?void 0:s.isElement(N))?await(s.getScale==null?void 0:s.getScale(N))||{x:1,y:1}:{x:1,y:1},b=kr(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:N,strategy:u}):x);return{top:(w.top-b.top+v.top)/P.y,bottom:(b.bottom-w.bottom+v.bottom)/P.y,left:(w.left-b.left+v.left)/P.x,right:(b.right-w.right+v.right)/P.x}}const Gw=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:u}=t,{element:l,padding:f=0}=gt(e,t)||{};if(l==null)return{};const g=Pu(f),h={x:n,y:r},p=Bs(o),v=Vs(p),m=await i.getDimensions(l),y=p==="y",w=y?"top":"left",x=y?"bottom":"right",N=y?"clientHeight":"clientWidth",P=s.reference[v]+s.reference[p]-h[p]-s.floating[v],b=h[p]-s.reference[p],S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l));let E=S?S[N]:0;(!E||!await(i.isElement==null?void 0:i.isElement(S)))&&(E=a.floating[N]||s.floating[v]);const M=P/2-b/2,H=E/2-m[v]/2-1,U=Pt(g[w],H),Z=Pt(g[x],H),F=U,I=E-m[v]-Z,R=E/2-m[v]/2+M,G=$s(F,R,I),B=!u.arrow&&ln(o)!=null&&R!==G&&s.reference[v]/2-(R<F?U:Z)-m[v]/2<0,K=B?R<F?R-F:R-I:0;return{[p]:h[p]+K,data:{[p]:G,centerOffset:R-G-K,...B&&{alignmentOffset:K}},reset:B}}}),Ww=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:u,elements:l}=t,{mainAxis:f=!0,crossAxis:g=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:m=!0,...y}=gt(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=ht(o),x=At(a),N=ht(a)===a,P=await(u.isRTL==null?void 0:u.isRTL(l.floating)),b=h||(N||!m?[Mr(a)]:Bw(a)),S=v!=="none";!h&&S&&b.push(...Hw(a,m,v,P));const E=[a,...b],M=await _n(t,y),H=[];let U=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&H.push(M[w]),g){const R=Vw(o,i,P);H.push(M[R[0]],M[R[1]])}if(U=[...U,{placement:o,overflows:H}],!H.every(R=>R<=0)){var Z,F;const R=(((Z=s.flip)==null?void 0:Z.index)||0)+1,G=E[R];if(G)return{data:{index:R,overflows:U},reset:{placement:G}};let B=(F=U.filter(K=>K.overflows[0]<=0).sort((K,q)=>K.overflows[1]-q.overflows[1])[0])==null?void 0:F.placement;if(!B)switch(p){case"bestFit":{var I;const K=(I=U.filter(q=>{if(S){const ee=At(q.placement);return ee===x||ee==="y"}return!0}).map(q=>[q.placement,q.overflows.filter(ee=>ee>0).reduce((ee,ie)=>ee+ie,0)]).sort((q,ee)=>q[1]-ee[1])[0])==null?void 0:I[0];K&&(B=K);break}case"initialPlacement":B=a;break}if(o!==B)return{reset:{placement:B}}}return{}}}};function Tu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function _u(e){return Iw.some(t=>e[t]>=0)}const qw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=gt(e,t);switch(r){case"referenceHidden":{const s=await _n(t,{...o,elementContext:"reference"}),i=Tu(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:_u(i)}}}case"escaped":{const s=await _n(t,{...o,altBoundary:!0}),i=Tu(s,n.floating);return{data:{escapedOffsets:i,escaped:_u(i)}}}default:return{}}}}};async function Kw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=ht(n),a=ln(n),u=At(n)==="y",l=["left","top"].includes(i)?-1:1,f=s&&u?-1:1,g=gt(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:v}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),u?{x:p*f,y:h*l}:{x:h*l,y:p*f}}const Xw=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,u=await Kw(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:s+u.y,data:{...u,placement:i}}}}},Yw=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:y=>{let{x:w,y:x}=y;return{x:w,y:x}}},...u}=gt(e,t),l={x:n,y:r},f=await _n(t,u),g=At(ht(o)),h=Ls(g);let p=l[h],v=l[g];if(s){const y=h==="y"?"top":"left",w=h==="y"?"bottom":"right",x=p+f[y],N=p-f[w];p=$s(x,p,N)}if(i){const y=g==="y"?"top":"left",w=g==="y"?"bottom":"right",x=v+f[y],N=v-f[w];v=$s(x,v,N)}const m=a.fn({...t,[h]:p,[g]:v});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[h]:s,[g]:i}}}}}},Jw=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:u=!0,crossAxis:l=!0}=gt(e,t),f={x:n,y:r},g=At(o),h=Ls(g);let p=f[h],v=f[g];const m=gt(a,t),y=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(u){const N=h==="y"?"height":"width",P=s.reference[h]-s.floating[N]+y.mainAxis,b=s.reference[h]+s.reference[N]-y.mainAxis;p<P?p=P:p>b&&(p=b)}if(l){var w,x;const N=h==="y"?"width":"height",P=["top","left"].includes(ht(o)),b=s.reference[g]-s.floating[N]+(P&&((w=i.offset)==null?void 0:w[g])||0)+(P?0:y.crossAxis),S=s.reference[g]+s.reference[N]+(P?0:((x=i.offset)==null?void 0:x[g])||0)-(P?y.crossAxis:0);v<b?v=b:v>S&&(v=S)}return{[h]:p,[g]:v}}}},Zw=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:u=()=>{},...l}=gt(e,t),f=await _n(t,l),g=ht(o),h=ln(o),p=At(o)==="y",{width:v,height:m}=s.floating;let y,w;g==="top"||g==="bottom"?(y=g,w=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(w=g,y=h==="end"?"top":"bottom");const x=m-f.top-f.bottom,N=v-f.left-f.right,P=Pt(m-f[y],x),b=Pt(v-f[w],N),S=!t.middlewareData.shift;let E=P,M=b;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(M=N),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=x),S&&!h){const U=Me(f.left,0),Z=Me(f.right,0),F=Me(f.top,0),I=Me(f.bottom,0);p?M=v-2*(U!==0||Z!==0?U+Z:Me(f.left,f.right)):E=m-2*(F!==0||I!==0?F+I:Me(f.top,f.bottom))}await u({...t,availableWidth:M,availableHeight:E});const H=await i.getDimensions(a.floating);return v!==H.width||m!==H.height?{reset:{rects:!0}}:{}}}};function Ir(){return typeof window<"u"}function cn(e){return Fu(e)?(e.nodeName||"").toLowerCase():"#document"}function ke(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function it(e){var t;return(t=(Fu(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Fu(e){return Ir()?e instanceof Node||e instanceof ke(e).Node:!1}function We(e){return Ir()?e instanceof Element||e instanceof ke(e).Element:!1}function at(e){return Ir()?e instanceof HTMLElement||e instanceof ke(e).HTMLElement:!1}function Ou(e){return!Ir()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ke(e).ShadowRoot}function Fn(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=qe(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function Qw(e){return["table","td","th"].includes(cn(e))}function $r(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function Hs(e){const t=Us(),n=We(e)?qe(e):e;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function eb(e){let t=Tt(e);for(;at(t)&&!un(t);){if(Hs(t))return t;if($r(t))return null;t=Tt(t)}return null}function Us(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function un(e){return["html","body","#document"].includes(cn(e))}function qe(e){return ke(e).getComputedStyle(e)}function Lr(e){return We(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Tt(e){if(cn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ou(e)&&e.host||it(e);return Ou(t)?t.host:t}function Ru(e){const t=Tt(e);return un(t)?e.ownerDocument?e.ownerDocument.body:e.body:at(t)&&Fn(t)?t:Ru(t)}function On(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Ru(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=ke(o);if(s){const a=js(i);return t.concat(i,i.visualViewport||[],Fn(o)?o:[],a&&n?On(a):[])}return t.concat(o,On(o,[],n))}function js(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Du(e){const t=qe(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=at(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Rr(n)!==s||Rr(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Gs(e){return We(e)?e:e.contextElement}function dn(e){const t=Gs(e);if(!at(t))return st(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Du(t);let i=(s?Rr(n.width):n.width)/r,a=(s?Rr(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const tb=st(0);function Mu(e){const t=ke(e);return!Us()||!t.visualViewport?tb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function nb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ke(e)?!1:t}function jt(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Gs(e);let i=st(1);t&&(r?We(r)&&(i=dn(r)):i=dn(e));const a=nb(s,n,r)?Mu(s):st(0);let u=(o.left+a.x)/i.x,l=(o.top+a.y)/i.y,f=o.width/i.x,g=o.height/i.y;if(s){const h=ke(s),p=r&&We(r)?ke(r):r;let v=h,m=js(v);for(;m&&r&&p!==v;){const y=dn(m),w=m.getBoundingClientRect(),x=qe(m),N=w.left+(m.clientLeft+parseFloat(x.paddingLeft))*y.x,P=w.top+(m.clientTop+parseFloat(x.paddingTop))*y.y;u*=y.x,l*=y.y,f*=y.x,g*=y.y,u+=N,l+=P,v=ke(m),m=js(v)}}return kr({width:f,height:g,x:u,y:l})}function Ws(e,t){const n=Lr(e).scrollLeft;return t?t.left+n:jt(it(e)).left+n}function ku(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:Ws(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function rb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=it(r),a=t?$r(t.floating):!1;if(r===i||a&&s)return n;let u={scrollLeft:0,scrollTop:0},l=st(1);const f=st(0),g=at(r);if((g||!g&&!s)&&((cn(r)!=="body"||Fn(i))&&(u=Lr(r)),at(r))){const p=jt(r);l=dn(r),f.x=p.x+r.clientLeft,f.y=p.y+r.clientTop}const h=i&&!g&&!s?ku(i,u,!0):st(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-u.scrollLeft*l.x+f.x+h.x,y:n.y*l.y-u.scrollTop*l.y+f.y+h.y}}function ob(e){return Array.from(e.getClientRects())}function sb(e){const t=it(e),n=Lr(e),r=e.ownerDocument.body,o=Me(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Me(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Ws(e);const a=-n.scrollTop;return qe(r).direction==="rtl"&&(i+=Me(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function ib(e,t){const n=ke(e),r=it(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,u=0;if(o){s=o.width,i=o.height;const l=Us();(!l||l&&t==="fixed")&&(a=o.offsetLeft,u=o.offsetTop)}return{width:s,height:i,x:a,y:u}}function ab(e,t){const n=jt(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=at(e)?dn(e):st(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,u=o*s.x,l=r*s.y;return{width:i,height:a,x:u,y:l}}function Iu(e,t,n){let r;if(t==="viewport")r=ib(e,n);else if(t==="document")r=sb(it(e));else if(We(t))r=ab(t,n);else{const o=Mu(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return kr(r)}function $u(e,t){const n=Tt(e);return n===t||!We(n)||un(n)?!1:qe(n).position==="fixed"||$u(n,t)}function lb(e,t){const n=t.get(e);if(n)return n;let r=On(e,[],!1).filter(a=>We(a)&&cn(a)!=="body"),o=null;const s=qe(e).position==="fixed";let i=s?Tt(e):e;for(;We(i)&&!un(i);){const a=qe(i),u=Hs(i);!u&&a.position==="fixed"&&(o=null),(s?!u&&!o:!u&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Fn(i)&&!u&&$u(e,i))?r=r.filter(f=>f!==i):o=a,i=Tt(i)}return t.set(e,r),r}function cb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?$r(t)?[]:lb(t,this._c):[].concat(n),r],a=i[0],u=i.reduce((l,f)=>{const g=Iu(t,f,o);return l.top=Me(g.top,l.top),l.right=Pt(g.right,l.right),l.bottom=Pt(g.bottom,l.bottom),l.left=Me(g.left,l.left),l},Iu(t,a,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function ub(e){const{width:t,height:n}=Du(e);return{width:t,height:n}}function db(e,t,n){const r=at(t),o=it(t),s=n==="fixed",i=jt(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const u=st(0);if(r||!r&&!s)if((cn(t)!=="body"||Fn(o))&&(a=Lr(t)),r){const h=jt(t,!0,s,t);u.x=h.x+t.clientLeft,u.y=h.y+t.clientTop}else o&&(u.x=Ws(o));const l=o&&!r&&!s?ku(o,a):st(0),f=i.left+a.scrollLeft-u.x-l.x,g=i.top+a.scrollTop-u.y-l.y;return{x:f,y:g,width:i.width,height:i.height}}function qs(e){return qe(e).position==="static"}function Lu(e,t){if(!at(e)||qe(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return it(e)===n&&(n=n.ownerDocument.body),n}function Vu(e,t){const n=ke(e);if($r(e))return n;if(!at(e)){let o=Tt(e);for(;o&&!un(o);){if(We(o)&&!qs(o))return o;o=Tt(o)}return n}let r=Lu(e,t);for(;r&&Qw(r)&&qs(r);)r=Lu(r,t);return r&&un(r)&&qs(r)&&!Hs(r)?n:r||eb(e)||n}const fb=async function(e){const t=this.getOffsetParent||Vu,n=this.getDimensions,r=await n(e.floating);return{reference:db(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function pb(e){return qe(e).direction==="rtl"}const gb={convertOffsetParentRelativeRectToViewportRelativeRect:rb,getDocumentElement:it,getClippingRect:cb,getOffsetParent:Vu,getElementRects:fb,getClientRects:ob,getDimensions:ub,getScale:dn,isElement:We,isRTL:pb};function hb(e,t){let n=null,r;const o=it(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,u){a===void 0&&(a=!1),u===void 0&&(u=1),s();const{left:l,top:f,width:g,height:h}=e.getBoundingClientRect();if(a||t(),!g||!h)return;const p=Dr(f),v=Dr(o.clientWidth-(l+g)),m=Dr(o.clientHeight-(f+h)),y=Dr(l),x={rootMargin:-p+"px "+-v+"px "+-m+"px "+-y+"px",threshold:Me(0,Pt(1,u))||1};let N=!0;function P(b){const S=b[0].intersectionRatio;if(S!==u){if(!N)return i();S?i(!1,S):r=setTimeout(()=>{i(!1,1e-7)},1e3)}N=!1}try{n=new IntersectionObserver(P,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(P,x)}n.observe(e)}return i(!0),s}function mb(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,l=Gs(e),f=o||s?[...l?On(l):[],...On(t)]:[];f.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),s&&w.addEventListener("resize",n)});const g=l&&a?hb(l,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(w=>{let[x]=w;x&&x.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var N;(N=p)==null||N.observe(t)})),n()}),l&&!u&&p.observe(l),p.observe(t));let v,m=u?jt(e):null;u&&y();function y(){const w=jt(e);m&&(w.x!==m.x||w.y!==m.y||w.width!==m.width||w.height!==m.height)&&n(),m=w,v=requestAnimationFrame(y)}return n(),()=>{var w;f.forEach(x=>{o&&x.removeEventListener("scroll",n),s&&x.removeEventListener("resize",n)}),g==null||g(),(w=p)==null||w.disconnect(),p=null,u&&cancelAnimationFrame(v)}}const vb=Xw,yb=Yw,wb=Ww,bb=Zw,xb=qw,Bu=Gw,Cb=Jw,Sb=(e,t,n)=>{const r=new Map,o={platform:gb,...n},s={...o.platform,_c:r};return jw(e,t,{...o,platform:s})};var Vr=typeof document<"u"?O.useLayoutEffect:O.useEffect;function Br(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Br(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Br(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function zu(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Hu(e,t){const n=zu(e);return Math.round(t*n)/n}function Ks(e){const t=d.useRef(e);return Vr(()=>{t.current=e}),t}function Eb(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:u,open:l}=e,[f,g]=d.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=d.useState(r);Br(h,r)||p(r);const[v,m]=d.useState(null),[y,w]=d.useState(null),x=d.useCallback(q=>{q!==S.current&&(S.current=q,m(q))},[]),N=d.useCallback(q=>{q!==E.current&&(E.current=q,w(q))},[]),P=s||v,b=i||y,S=d.useRef(null),E=d.useRef(null),M=d.useRef(f),H=u!=null,U=Ks(u),Z=Ks(o),F=Ks(l),I=d.useCallback(()=>{if(!S.current||!E.current)return;const q={placement:t,strategy:n,middleware:h};Z.current&&(q.platform=Z.current),Sb(S.current,E.current,q).then(ee=>{const ie={...ee,isPositioned:F.current!==!1};R.current&&!Br(M.current,ie)&&(M.current=ie,kn.flushSync(()=>{g(ie)}))})},[h,t,n,Z,F]);Vr(()=>{l===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,g(q=>({...q,isPositioned:!1})))},[l]);const R=d.useRef(!1);Vr(()=>(R.current=!0,()=>{R.current=!1}),[]),Vr(()=>{if(P&&(S.current=P),b&&(E.current=b),P&&b){if(U.current)return U.current(P,b,I);I()}},[P,b,I,U,H]);const G=d.useMemo(()=>({reference:S,floating:E,setReference:x,setFloating:N}),[x,N]),B=d.useMemo(()=>({reference:P,floating:b}),[P,b]),K=d.useMemo(()=>{const q={position:n,left:0,top:0};if(!B.floating)return q;const ee=Hu(B.floating,f.x),ie=Hu(B.floating,f.y);return a?{...q,transform:"translate("+ee+"px, "+ie+"px)",...zu(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:ee,top:ie}},[n,a,B.floating,f.x,f.y]);return d.useMemo(()=>({...f,update:I,refs:G,elements:B,floatingStyles:K}),[f,I,G,B,K])}const Nb=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Bu({element:r.current,padding:o}).fn(n):{}:r?Bu({element:r,padding:o}).fn(n):{}}}},Pb=(e,t)=>({...vb(e),options:[e,t]}),Ab=(e,t)=>({...yb(e),options:[e,t]}),Tb=(e,t)=>({...Cb(e),options:[e,t]}),_b=(e,t)=>({...wb(e),options:[e,t]}),Fb=(e,t)=>({...bb(e),options:[e,t]}),Ob=(e,t)=>({...xb(e),options:[e,t]}),Rb=(e,t)=>({...Nb(e),options:[e,t]});var Db=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Mb=Db.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?It:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),kb="Arrow",Uu=d.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(Mb.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Uu.displayName=kb;var Ib=Uu;function ju(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function $b(...e){return t=>{let n=!1;const r=e.map(o=>{const s=ju(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():ju(e[o],null)}}}}function Gu(...e){return d.useCallback($b(...e),e)}var Lb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Wu=Lb.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?It:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Xs="Popper",[qu,Ku]=Ze(Xs),[Vb,Xu]=qu(Xs),Yu=e=>{const{__scopePopper:t,children:n}=e,[r,o]=d.useState(null);return c.jsx(Vb,{scope:t,anchor:r,onAnchorChange:o,children:n})};Yu.displayName=Xs;var Ju="PopperAnchor",Zu=d.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Xu(Ju,n),i=d.useRef(null),a=Gu(t,i);return d.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:c.jsx(Wu.div,{...o,ref:a})});Zu.displayName=Ju;var Ys="PopperContent",[Bb,zb]=qu(Ys),Qu=d.forwardRef((e,t)=>{var Ft,Ke,be,Ot,Wt,Ve;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:u=!0,collisionBoundary:l=[],collisionPadding:f=0,sticky:g="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:v,...m}=e,y=Xu(Ys,n),[w,x]=d.useState(null),N=Gu(t,Xe=>x(Xe)),[P,b]=d.useState(null),S=Do(P),E=(S==null?void 0:S.width)??0,M=(S==null?void 0:S.height)??0,H=r+(s!=="center"?"-"+s:""),U=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},Z=Array.isArray(l)?l:[l],F=Z.length>0,I={padding:U,boundary:Z.filter(Ub),altBoundary:F},{refs:R,floatingStyles:G,placement:B,isPositioned:K,middlewareData:q}=Eb({strategy:"fixed",placement:H,whileElementsMounted:(...Xe)=>mb(...Xe,{animationFrame:p==="always"}),elements:{reference:y.anchor},middleware:[Pb({mainAxis:o+M,alignmentAxis:i}),u&&Ab({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?Tb():void 0,...I}),u&&_b({...I}),Fb({...I,apply:({elements:Xe,rects:Ie,availableWidth:Rt,availableHeight:Wr})=>{const{width:qt,height:C}=Ie.reference,A=Xe.floating.style;A.setProperty("--radix-popper-available-width",`${Rt}px`),A.setProperty("--radix-popper-available-height",`${Wr}px`),A.setProperty("--radix-popper-anchor-width",`${qt}px`),A.setProperty("--radix-popper-anchor-height",`${C}px`)}}),P&&Rb({element:P,padding:a}),jb({arrowWidth:E,arrowHeight:M}),h&&Ob({strategy:"referenceHidden",...I})]}),[ee,ie]=nd(B),ue=Ee(v);Ne(()=>{K&&(ue==null||ue())},[K,ue]);const Se=(Ft=q.arrow)==null?void 0:Ft.x,ae=(Ke=q.arrow)==null?void 0:Ke.y,lt=((be=q.arrow)==null?void 0:be.centerOffset)!==0,[Gt,_t]=d.useState();return Ne(()=>{w&&_t(window.getComputedStyle(w).zIndex)},[w]),c.jsx("div",{ref:R.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:K?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Gt,"--radix-popper-transform-origin":[(Ot=q.transformOrigin)==null?void 0:Ot.x,(Wt=q.transformOrigin)==null?void 0:Wt.y].join(" "),...((Ve=q.hide)==null?void 0:Ve.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(Bb,{scope:n,placedSide:ee,onArrowChange:b,arrowX:Se,arrowY:ae,shouldHideArrow:lt,children:c.jsx(Wu.div,{"data-side":ee,"data-align":ie,...m,ref:N,style:{...m.style,animation:K?void 0:"none"}})})})});Qu.displayName=Ys;var ed="PopperArrow",Hb={top:"bottom",right:"left",bottom:"top",left:"right"},td=d.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=zb(ed,r),i=Hb[s.placedSide];return c.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:c.jsx(Ib,{...o,ref:n,style:{...o.style,display:"block"}})})});td.displayName=ed;function Ub(e){return e!==null}var jb=e=>({name:"transformOrigin",options:e,fn(t){var y,w,x;const{placement:n,rects:r,middlewareData:o}=t,i=((y=o.arrow)==null?void 0:y.centerOffset)!==0,a=i?0:e.arrowWidth,u=i?0:e.arrowHeight,[l,f]=nd(n),g={start:"0%",center:"50%",end:"100%"}[f],h=(((w=o.arrow)==null?void 0:w.x)??0)+a/2,p=(((x=o.arrow)==null?void 0:x.y)??0)+u/2;let v="",m="";return l==="bottom"?(v=i?g:`${h}px`,m=`${-u}px`):l==="top"?(v=i?g:`${h}px`,m=`${r.floating.height+u}px`):l==="right"?(v=`${-u}px`,m=i?g:`${p}px`):l==="left"&&(v=`${r.floating.width+u}px`,m=i?g:`${p}px`),{data:{x:v,y:m}}}});function nd(e){const[t,n="center"]=e.split("-");return[t,n]}var Gb=Yu,Wb=Zu,qb=Qu,Kb=td,Xb="Portal",rd=d.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=d.useState(!1);Ne(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?qr.createPortal(c.jsx(Tn.div,{...r,ref:t}),i):null});rd.displayName=Xb;function Yb(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var Js=e=>{const{present:t,children:n}=e,r=Jb(t),o=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),s=An(r.ref,Zb(o));return typeof n=="function"||r.isPresent?d.cloneElement(o,{ref:s}):null};Js.displayName="Presence";function Jb(e){const[t,n]=d.useState(),r=d.useRef({}),o=d.useRef(e),s=d.useRef("none"),i=e?"mounted":"unmounted",[a,u]=Yb(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const l=zr(r.current);s.current=a==="mounted"?l:"none"},[a]),Ne(()=>{const l=r.current,f=o.current;if(f!==e){const h=s.current,p=zr(l);e?u("MOUNT"):p==="none"||(l==null?void 0:l.display)==="none"?u("UNMOUNT"):u(f&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,u]),Ne(()=>{if(t){let l;const f=t.ownerDocument.defaultView??window,g=p=>{const m=zr(r.current).includes(p.animationName);if(p.target===t&&m&&(u("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",l=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},h=p=>{p.target===t&&(s.current=zr(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{f.clearTimeout(l),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:d.useCallback(l=>{l&&(r.current=getComputedStyle(l)),n(l)},[])}}function zr(e){return(e==null?void 0:e.animationName)||"none"}function Zb(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Qb="VisuallyHidden",od=d.forwardRef((e,t)=>c.jsx(Tn.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));od.displayName=Qb;var ex=od,[Hr,lC]=Ze("Tooltip",[Ku]),Ur=Ku(),sd="TooltipProvider",tx=700,Zs="tooltip.open",[nx,Qs]=Hr(sd),id=e=>{const{__scopeTooltip:t,delayDuration:n=tx,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,[i,a]=d.useState(!0),u=d.useRef(!1),l=d.useRef(0);return d.useEffect(()=>{const f=l.current;return()=>window.clearTimeout(f)},[]),c.jsx(nx,{scope:t,isOpenDelayed:i,delayDuration:n,onOpen:d.useCallback(()=>{window.clearTimeout(l.current),a(!1)},[]),onClose:d.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>a(!0),r)},[r]),isPointerInTransitRef:u,onPointerInTransitChange:d.useCallback(f=>{u.current=f},[]),disableHoverableContent:o,children:s})};id.displayName=sd;var jr="Tooltip",[rx,Rn]=Hr(jr),ad=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o=!1,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,u=Qs(jr,e.__scopeTooltip),l=Ur(t),[f,g]=d.useState(null),h=Qt(),p=d.useRef(0),v=i??u.disableHoverableContent,m=a??u.delayDuration,y=d.useRef(!1),[w=!1,x]=$t({prop:r,defaultProp:o,onChange:E=>{E?(u.onOpen(),document.dispatchEvent(new CustomEvent(Zs))):u.onClose(),s==null||s(E)}}),N=d.useMemo(()=>w?y.current?"delayed-open":"instant-open":"closed",[w]),P=d.useCallback(()=>{window.clearTimeout(p.current),p.current=0,y.current=!1,x(!0)},[x]),b=d.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x(!1)},[x]),S=d.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{y.current=!0,x(!0),p.current=0},m)},[m,x]);return d.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),c.jsx(Gb,{...l,children:c.jsx(rx,{scope:t,contentId:h,open:w,stateAttribute:N,trigger:f,onTriggerChange:g,onTriggerEnter:d.useCallback(()=>{u.isOpenDelayed?S():P()},[u.isOpenDelayed,S,P]),onTriggerLeave:d.useCallback(()=>{v?b():(window.clearTimeout(p.current),p.current=0)},[b,v]),onOpen:P,onClose:b,disableHoverableContent:v,children:n})})};ad.displayName=jr;var ei="TooltipTrigger",ld=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Rn(ei,n),s=Qs(ei,n),i=Ur(n),a=d.useRef(null),u=An(t,a,o.onTriggerChange),l=d.useRef(!1),f=d.useRef(!1),g=d.useCallback(()=>l.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),c.jsx(Wb,{asChild:!0,...i,children:c.jsx(Tn.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:u,onPointerMove:pt(e.onPointerMove,h=>{h.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:pt(e.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:pt(e.onPointerDown,()=>{l.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:pt(e.onFocus,()=>{l.current||o.onOpen()}),onBlur:pt(e.onBlur,o.onClose),onClick:pt(e.onClick,o.onClose)})})});ld.displayName=ei;var ti="TooltipPortal",[ox,sx]=Hr(ti,{forceMount:void 0}),cd=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,s=Rn(ti,t);return c.jsx(ox,{scope:t,forceMount:n,children:c.jsx(Js,{present:n||s.open,children:c.jsx(rd,{asChild:!0,container:o,children:r})})})};cd.displayName=ti;var fn="TooltipContent",ud=d.forwardRef((e,t)=>{const n=sx(fn,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=Rn(fn,e.__scopeTooltip);return c.jsx(Js,{present:r||i.open,children:i.disableHoverableContent?c.jsx(dd,{side:o,...s,ref:t}):c.jsx(ix,{side:o,...s,ref:t})})}),ix=d.forwardRef((e,t)=>{const n=Rn(fn,e.__scopeTooltip),r=Qs(fn,e.__scopeTooltip),o=d.useRef(null),s=An(t,o),[i,a]=d.useState(null),{trigger:u,onClose:l}=n,f=o.current,{onPointerInTransitChange:g}=r,h=d.useCallback(()=>{a(null),g(!1)},[g]),p=d.useCallback((v,m)=>{const y=v.currentTarget,w={x:v.clientX,y:v.clientY},x=ux(w,y.getBoundingClientRect()),N=dx(w,x),P=fx(m.getBoundingClientRect()),b=gx([...N,...P]);a(b),g(!0)},[g]);return d.useEffect(()=>()=>h(),[h]),d.useEffect(()=>{if(u&&f){const v=y=>p(y,f),m=y=>p(y,u);return u.addEventListener("pointerleave",v),f.addEventListener("pointerleave",m),()=>{u.removeEventListener("pointerleave",v),f.removeEventListener("pointerleave",m)}}},[u,f,p,h]),d.useEffect(()=>{if(i){const v=m=>{const y=m.target,w={x:m.clientX,y:m.clientY},x=(u==null?void 0:u.contains(y))||(f==null?void 0:f.contains(y)),N=!px(w,i);x?h():N&&(h(),l())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[u,f,i,l,h]),c.jsx(dd,{...e,ref:s})}),[ax,lx]=Hr(jr,{isInside:!1}),dd=d.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,u=Rn(fn,n),l=Ur(n),{onClose:f}=u;return d.useEffect(()=>(document.addEventListener(Zs,f),()=>document.removeEventListener(Zs,f)),[f]),d.useEffect(()=>{if(u.trigger){const g=h=>{const p=h.target;p!=null&&p.contains(u.trigger)&&f()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[u.trigger,f]),c.jsx(Su,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:g=>g.preventDefault(),onDismiss:f,children:c.jsxs(qb,{"data-state":u.stateAttribute,...l,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[c.jsx(wa,{children:r}),c.jsx(ax,{scope:n,isInside:!0,children:c.jsx(ex,{id:u.contentId,role:"tooltip",children:o||r})})]})})});ud.displayName=fn;var fd="TooltipArrow",cx=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Ur(n);return lx(fd,n).isInside?null:c.jsx(Kb,{...o,...r,ref:t})});cx.displayName=fd;function ux(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function dx(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function fx(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function px(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s].x,u=t[s].y,l=t[i].x,f=t[i].y;u>r!=f>r&&n<(l-a)*(r-u)/(f-u)+a&&(o=!o)}return o}function gx(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),hx(t)}function hx(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var mx=id,vx=ad,yx=ld,wx=cd,pd=ud;const bx=mx,xx=vx,Cx=yx,gd=d.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(wx,{children:c.jsx(pd,{ref:r,sideOffset:t,className:J("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));gd.displayName=pd.displayName;const hd=({className:e,children:t,content:n,side:r})=>{const[o,s]=O.useState(!1);return c.jsx(bx,{delayDuration:0,children:c.jsxs(xx,{open:o,children:[c.jsx(Cx,{asChild:!0,children:c.jsx("button",{type:"button",className:J("cursor-pointer",e),onClick:()=>s(!o),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),onTouchStart:()=>s(!o),onKeyDown:i=>{i.preventDefault(),i.key==="Enter"&&s(!o)},children:t})}),c.jsx(gd,{side:r,className:n?"":"hidden",children:c.jsx("span",{className:"inline-block",children:n})})]})})},ni=({className:e,...t})=>c.jsx("nav",{role:"navigation","aria-label":"pagination",className:J("mx-auto flex w-full justify-center",e),...t});ni.displayName="Pagination";const ri=d.forwardRef(({className:e,...t},n)=>c.jsx("ul",{ref:n,className:J("flex flex-row items-center gap-1",e),...t}));ri.displayName="PaginationContent";const mt=d.forwardRef(({className:e,...t},n)=>c.jsx("li",{ref:n,className:J("",e),...t}));mt.displayName="PaginationItem";const Dn=({className:e,isActive:t,size:n="icon",...r})=>c.jsx("a",{"aria-current":t?"page":void 0,className:J(Ma({variant:t?"outline":"ghost",size:n}),e),...r});Dn.displayName="PaginationLink";const oi=({className:e,...t})=>c.jsxs(Dn,{"aria-label":"Go to previous page",size:"default",className:J("gap-1 pl-2.5",e),...t,children:[c.jsx(eg,{className:"h-4 w-4"}),c.jsx("span",{children:"Previous"})]});oi.displayName="PaginationPrevious";const si=({className:e,...t})=>c.jsxs(Dn,{"aria-label":"Go to next page",size:"default",className:J("gap-1 pr-2.5",e),...t,children:[c.jsx("span",{children:"Next"}),c.jsx(ma,{className:"h-4 w-4"})]});si.displayName="PaginationNext";const ii=({className:e,...t})=>c.jsxs("span",{"aria-hidden":!0,className:J("flex h-9 w-9 items-center justify-center",e),...t,children:[c.jsx(ng,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"More pages"})]});ii.displayName="PaginationEllipsis";function ai(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function md(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Sx(...e){return t=>{let n=!1;const r=e.map(o=>{const s=md(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():md(e[o],null)}}}}function li(...e){return d.useCallback(Sx(...e),e)}var Ex=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],ci=Ex.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?It:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function Nx(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var vd=e=>{const{present:t,children:n}=e,r=Px(t),o=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),s=li(r.ref,Ax(o));return typeof n=="function"||r.isPresent?d.cloneElement(o,{ref:s}):null};vd.displayName="Presence";function Px(e){const[t,n]=d.useState(),r=d.useRef({}),o=d.useRef(e),s=d.useRef("none"),i=e?"mounted":"unmounted",[a,u]=Nx(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const l=Gr(r.current);s.current=a==="mounted"?l:"none"},[a]),Ne(()=>{const l=r.current,f=o.current;if(f!==e){const h=s.current,p=Gr(l);e?u("MOUNT"):p==="none"||(l==null?void 0:l.display)==="none"?u("UNMOUNT"):u(f&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,u]),Ne(()=>{if(t){let l;const f=t.ownerDocument.defaultView??window,g=p=>{const m=Gr(r.current).includes(p.animationName);if(p.target===t&&m&&(u("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",l=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},h=p=>{p.target===t&&(s.current=Gr(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{f.clearTimeout(l),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:d.useCallback(l=>{l&&(r.current=getComputedStyle(l)),n(l)},[])}}function Gr(e){return(e==null?void 0:e.animationName)||"none"}function Ax(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ui="Radio",[Tx,yd]=Ze(ui),[_x,Fx]=Tx(ui),wd=d.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:o=!1,required:s,disabled:i,value:a="on",onCheck:u,form:l,...f}=e,[g,h]=d.useState(null),p=li(t,y=>h(y)),v=d.useRef(!1),m=g?l||!!g.closest("form"):!0;return c.jsxs(_x,{scope:n,checked:o,disabled:i,children:[c.jsx(ci.button,{type:"button",role:"radio","aria-checked":o,"data-state":Cd(o),"data-disabled":i?"":void 0,disabled:i,value:a,...f,ref:p,onClick:ai(e.onClick,y=>{o||u==null||u(),m&&(v.current=y.isPropagationStopped(),v.current||y.stopPropagation())})}),m&&c.jsx(Ox,{control:g,bubbles:!v.current,name:r,value:a,checked:o,required:s,disabled:i,form:l,style:{transform:"translateX(-100%)"}})]})});wd.displayName=ui;var bd="RadioIndicator",xd=d.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...o}=e,s=Fx(bd,n);return c.jsx(vd,{present:r||s.checked,children:c.jsx(ci.span,{"data-state":Cd(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t})})});xd.displayName=bd;var Ox=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,s=d.useRef(null),i=ka(n),a=Do(t);return d.useEffect(()=>{const u=s.current,l=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(l,"checked").set;if(i!==n&&g){const h=new Event("click",{bubbles:r});g.call(u,n),u.dispatchEvent(h)}},[i,n,r]),c.jsx("input",{type:"radio","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:s,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function Cd(e){return e?"checked":"unchecked"}var Rx=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],di="RadioGroup",[Dx,cC]=Ze(di,[gr,yd]),Sd=gr(),Ed=yd(),[Mx,kx]=Dx(di),Nd=d.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:o,value:s,required:i=!1,disabled:a=!1,orientation:u,dir:l,loop:f=!0,onValueChange:g,...h}=e,p=Sd(n),v=is(l),[m,y]=$t({prop:s,defaultProp:o,onChange:g});return c.jsx(Mx,{scope:n,name:r,required:i,disabled:a,value:m,onValueChange:y,children:c.jsx(Yl,{asChild:!0,...p,orientation:u,dir:v,loop:f,children:c.jsx(ci.div,{role:"radiogroup","aria-required":i,"aria-orientation":u,"data-disabled":a?"":void 0,dir:v,...h,ref:t})})})});Nd.displayName=di;var Pd="RadioGroupItem",Ad=d.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...o}=e,s=kx(Pd,n),i=s.disabled||r,a=Sd(n),u=Ed(n),l=d.useRef(null),f=li(t,l),g=s.value===o.value,h=d.useRef(!1);return d.useEffect(()=>{const p=m=>{Rx.includes(m.key)&&(h.current=!0)},v=()=>h.current=!1;return document.addEventListener("keydown",p),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",v)}},[]),c.jsx(Jl,{asChild:!0,...a,focusable:!i,active:g,children:c.jsx(wd,{disabled:i,required:s.required,checked:g,...u,...o,name:s.name,ref:f,onCheck:()=>s.onValueChange(o.value),onKeyDown:ai(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:ai(o.onFocus,()=>{var p;h.current&&((p=l.current)==null||p.click())})})})});Ad.displayName=Pd;var Ix="RadioGroupIndicator",Td=d.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,o=Ed(n);return c.jsx(xd,{...o,...r,ref:t})});Td.displayName=Ix;var _d=Nd,Fd=Ad,$x=Td;const Od=d.forwardRef(({className:e,...t},n)=>c.jsx(_d,{className:J("grid gap-2",e),...t,ref:n}));Od.displayName=_d.displayName;const fi=d.forwardRef(({className:e,...t},n)=>c.jsx(Fd,{ref:n,className:J("aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:c.jsx($x,{className:"flex items-center justify-center",children:c.jsx(tg,{className:"h-3.5 w-3.5 fill-primary"})})}));fi.displayName=Fd.displayName;const Lx=({apiBaseUrl:e="http://localhost:3000"})=>{var x,N,P;const[t,n]=O.useState([]),[r,o]=O.useState(!1),[s,i]=O.useState([]),[a,u]=O.useState(1),[l,f]=O.useState(1),[g,h]=O.useState(null),p=b=>b.map(E=>({id:E==null?void 0:E.id,prefix:(E==null?void 0:E.prefix)||"",model:(E==null?void 0:E.model)||"",fileName:(E==null?void 0:E.file_name)||"",code:(E==null?void 0:E.stock_id)||"",content:(E==null?void 0:E.text_summary)||"",status:(E==null?void 0:E.status)||"",note:(E==null?void 0:E.note)||"",lastUpdate:E==null?void 0:E.updated_at,stock_id:E==null?void 0:E.stock_id})),v=b=>{if(!(b!=null&&b.data))return[];const S=p(b==null?void 0:b.data);n(S),f(b.pagination.totalPages)},m=async(b=1,S=15)=>{console.log("🚀 ~ fetchData ~ page:",b),h(b);try{const E=await oe.get(`${e}/api/latest-summaries`,{params:{page:b,limit:S}});console.log("🚀 ~ fetchData ~ result.data:",E.data),(E==null?void 0:E.status)===200?v(E.data):console.error(E)}catch(E){console.error("Error fetching data:",E)}finally{h(null),o(!1)}};O.useEffect(()=>{m(a)},[a]);const y=O.useMemo(()=>[{id:"code",header:"Mã",accessorKey:"code",cell:({row:S})=>c.jsx("span",{className:"flex flex-col",children:S.original.code})},{id:"content",header:"Nội dung",accessorKey:"content",cell:({row:S})=>{const E=S.getValue("content");return c.jsx(hd,{content:c.jsx("div",{className:"font-medium text-[16px] max-w-[90dvw]",children:E}),children:c.jsx("div",{className:"text-start truncate text-ellipsis overflow-hidden whitespace-nowrap max-w-[30dvw]",children:E})})}},{id:"status",header:"Trạng thái",accessorKey:"status",cell:({row:S})=>c.jsx("span",{className:"flex flex-col",children:S.original.status})},{id:"note",header:"Ghi chú",accessorKey:"note",cell:({row:S})=>c.jsx(hd,{content:c.jsx("div",{className:"font-medium text-[16px] max-w-[90dvw]",children:S.original.note}),children:c.jsx("div",{className:"text-start truncate text-ellipsis overflow-hidden whitespace-nowrap max-w-[20dvw]",children:S.original.note})})},{id:"last-update",header:"Cập nhật",accessorKey:"last-update",cell:({row:S})=>{const E=new Date(S.original.lastUpdate),M=E.getDate(),H=E.getMonth()+1,U=`ngày ${M} tháng ${H}`;return c.jsx("span",{className:"flex flex-col",children:U})}},{accessorKey:"edit",header:()=>c.jsx("div",{className:"font-medium text-center",children:"Sửa"}),cell:({row:S})=>{const[E,M]=O.useState(!1),[H,U]=O.useState(!1),{handleSubmit:Z,register:F,reset:I}=Nw(),R=S.original.id,G=async B=>{M(!0);try{const K=await oe.patch(`${e}/api/update-summary`,{note:B.note,text_summary:B.content,id:R});K.status===200?(await m(a),U(!1)):console.error("Failed to update summary:",K)}catch(K){console.error("Error updating summary:",K)}return M(!1)};return c.jsxs(on,{open:H,onOpenChange:B=>{U(B),B?I({content:S.original.content,note:S.original.note}):I()},children:[c.jsx(lr,{className:"w-full",children:c.jsx("div",{onClick:()=>U(B=>!B),className:"font-medium text-center text-orange-500 cursor-pointer",children:"sửa"})}),c.jsx(Vt,{className:"rounded-lg sm:px-3 h-[calc(100dvh-200px)] min-w-[calc(100dvw-112px)]",children:c.jsxs(Bt,{className:"flex flex-col gap-3",children:[c.jsx(zt,{className:"max-sm:hidden text-center",children:"Sửa summary"}),c.jsxs("form",{className:"flex flex-col gap-3 h-full justify-between",onSubmit:Z(G),children:[c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsxs("div",{className:"flex flex-col items-start",children:[c.jsx("span",{children:"Nội dung:"}),c.jsx(vr,{placeholder:"Nội dung",className:"w-full input-scroll-bar",defaultValue:S.original.answer||"",rows:10,...F("content")})]}),c.jsxs("div",{className:"flex flex-col items-start",children:[c.jsx("span",{children:"Lưu ý:"}),c.jsx(vr,{placeholder:"Nội dung",className:"w-full input-scroll-bar",defaultValue:S.original.note||"",rows:1,...F("note")})]})]}),c.jsx("div",{className:"flex justify-end",children:c.jsx(de,{disabled:E,type:"submit",variant:"default",children:"Ok"})})]})]})})]})}},{id:"publish",header:"",accessorKey:"publish",cell:({row:S})=>{const[E,M]=O.useState(!1),[H,U]=O.useState("create"),[Z,F]=O.useState(!1),I=S.original.id,R=S.getValue("status"),G=S.getValue("code"),K=new Date(S.original.lastUpdate).getMonth()+1,[q,ee]=O.useState(""),[ie,ue]=O.useState("1"),Se=async()=>{try{M(!0);try{const ae=await oe.patch(`${e}/api/toggle-publish/${I}`,{id:I,typeAction:H,status:R,idInput:ie,stock_id:S.original.stock_id,bucket:q,prefix:S.original.prefix,model:S.original.model,summary_result:S.original.content,note:S.original.note});ae.status===200?(m(a),F(!1)):console.error("Failed to toggle publish status:",ae)}catch(ae){console.error("Error toggling publish status:",ae)}finally{ee(""),M(!1)}}catch{}};return c.jsxs(on,{open:Z,onOpenChange:ae=>{F(ae)},children:[c.jsx(lr,{className:"w-full",children:c.jsx("div",{onClick:()=>F(ae=>!ae),className:"font-medium text-start text-green-400 cursor-pointer",children:R==="unpublish"?"Publish":"Unpublish"})}),c.jsx(Vt,{className:"rounded-lg sm:px-3 sm:w-[calc(100%-30px)]",children:c.jsxs(Bt,{className:"flex flex-col gap-3",children:[c.jsxs(zt,{className:"text-center",children:[R==="unpublish"?"Publish":"Unpublish"," Summary?"]}),c.jsxs("span",{className:"text-start",children:["Bạn có muốn ",R==="unpublish"?"publish":"unpublish"," summary mã ",G," ","tháng ",K," không?"]}),c.jsxs(Od,{onValueChange:ae=>U(ae),defaultValue:"create",className:"flex items-center",children:[c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx(fi,{value:"create",id:"r1"}),c.jsx(Ht,{htmlFor:"r1",children:"Create"})]}),c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx(fi,{value:"update",id:"r2"}),c.jsx(Ht,{htmlFor:"r2",children:"Update"})]})]}),c.jsxs("div",{children:[c.jsx("span",{className:"text-start",children:"id:"}),c.jsx(Et,{type:"number",value:ie,onChange:ae=>ue(ae.target.value)})]}),c.jsxs("div",{children:[c.jsx("span",{className:"text-start",children:"bucket:"}),c.jsx(Et,{value:q,onChange:ae=>ee(ae.target.value)})]}),c.jsx("div",{className:"flex items-center justify-end",children:c.jsx(de,{onClick:Se,disabled:E,children:"ok"})})]})})]})}}],[]),w=Fi({data:t,columns:y,state:{columnFilters:s},enableRowSelection:!0,onColumnFiltersChange:i,getFilteredRowModel:Cf(),getCoreRowModel:_i()});return c.jsxs("div",{className:"space-y-4 s3-explr-container",children:[c.jsx("div",{className:"flex items-center space-x-4 s3-explr-toolbar",children:c.jsx(Et,{placeholder:"Tìm kiếm theo mã...",value:((x=w.getColumn("code"))==null?void 0:x.getFilterValue())??"",onChange:b=>{var S;return(S=w.getColumn("code"))==null?void 0:S.setFilterValue(b.target.value)},className:"max-w-sm"})}),c.jsx("div",{className:"rounded-md border s3-explr-table-container",children:c.jsxs(ur,{className:"s3-explr-table",children:[c.jsx(dr,{className:"s3-explr-table-header",children:w.getHeaderGroups().map(b=>c.jsx(je,{className:"hover:bg-transparent s3-explr-header-row",children:b.headers.map(S=>c.jsx(et,{className:"s3-explr-header-cell",children:S.isPlaceholder?null:Bn(S.column.columnDef.header,S.getContext())},S.id))},b.id))}),c.jsx(fr,{className:"s3-explr-table-body",children:(N=w.getRowModel().rows)!=null&&N.length?(P=w.getRowModel().rows)==null?void 0:P.map(b=>c.jsx(je,{className:"h-12 s3-explr-row",children:b.getVisibleCells().map(S=>c.jsx(_e,{className:"align-middle s3-explr-cell",children:Bn(S.column.columnDef.cell,S.getContext())},S.id))},b.id)):r?c.jsx(je,{children:c.jsx(_e,{colSpan:y.length,className:"h-24 text-center",children:"loading..."})}):c.jsx(je,{children:c.jsx(_e,{colSpan:y.length,className:"h-24 text-center",children:"Không có kết quả."})})})]})}),c.jsx("div",{className:"mt-4",children:c.jsx(ni,{children:c.jsxs(ri,{children:[c.jsx(mt,{children:c.jsx(oi,{onClick:()=>u(b=>Math.max(1,b-1)),className:a===1?"pointer-events-none opacity-50":"cursor-pointer"})}),Array.from({length:l},(b,S)=>S+1).filter(b=>b===1||b===l||Math.abs(b-a)<=1).map((b,S,E)=>c.jsxs(c.Fragment,{children:[S>0&&E[S-1]!==b-1&&c.jsx(mt,{children:c.jsx(ii,{})},b+"..."),c.jsx(mt,{children:c.jsx(Dn,{onClick:()=>u(b),isActive:a===b,className:`cursor-pointer ${r?"pointer-events-none":""}`,children:g===b?c.jsx(Te,{className:"h-4 w-4 animate-spin"}):b})},b)]})),c.jsx(mt,{children:c.jsx(si,{onClick:()=>u(b=>Math.min(l,b+1)),className:a===l||g!==null?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})},Rd=10,Vx=O.memo(({apiBaseUrl:e="http://localhost:3000"})=>{const[t,n]=O.useState(1),[r,o]=O.useState([]),[s,i]=O.useState({total:0,page:1,limit:Rd,totalPages:1}),[a,u]=O.useState(!0),[l,f]=O.useState(null),[g,h]=O.useState(new Set),{toast:p}=Ps(),[v,m]=O.useState(!1),y=async b=>{try{f(b);const S=await oe.get(`${e}/api/jobs`,{params:{page:b.toString(),limit:Rd.toString()}});o(S.data.data),i(S.data.pagination)}catch{p({variant:"destructive",title:"Error",description:"Failed to fetch jobs. Please try again."})}finally{f(null),u(!1)}};O.useEffect(()=>{y(t)},[t,e]);const w=async b=>{h(S=>new Set(S).add(b.toString()));try{await oe.post(`${e}/api/retry-job`,{jobId:b}),p({title:"Job Restarted",description:`Job ${b} has been successfully restarted.`}),y(t)}catch{p({variant:"destructive",title:"Retry Failed",description:`Failed to restart job ${b}. Please try again.`})}finally{h(S=>{const E=new Set(S);return E.delete(b.toString()),E})}},x=async()=>{m(!0),n(1),await y(1),m(!1)},N=b=>new Date(b).toLocaleString(),P=b=>{if(b=parseFloat(b),b<60)return`${b.toFixed(2)}s`;const S=Math.floor(b/60),E=(b%60).toFixed(0);return`${S}m ${E}s`};return c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[c.jsx(Zp,{className:"w-8 h-8 text-primary"}),c.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Job Management"}),c.jsx(de,{variant:"outline",size:"icon",onClick:x,disabled:v||a,className:"ml-2",children:c.jsx(rg,{className:`h-4 w-4 ${v?"animate-spin":""}`})})]}),c.jsx("div",{className:"rounded-md border",children:c.jsxs(ur,{children:[c.jsx(dr,{children:c.jsxs(je,{children:[c.jsx(et,{children:"ID"}),c.jsx(et,{children:"Tên Công Việc"}),c.jsx(et,{children:"Thời Gian Bắt Đầu"}),c.jsx(et,{children:"Thời Gian Cập Nhật"}),c.jsx(et,{children:"Thời Gian Thực Thi"}),c.jsx(et,{children:"Trạng Thái"}),c.jsx(et,{children:"Thao Tác"})]})}),c.jsx(fr,{children:a&&r.length===0?c.jsx(je,{children:c.jsx(_e,{colSpan:7,className:"text-center py-4",children:c.jsx(Te,{className:"w-6 h-6 animate-spin mx-auto"})})}):r.map(b=>{var S,E;return c.jsxs(je,{children:[c.jsx(_e,{className:"!w-[100px]",children:b.id}),c.jsx(_e,{className:"font-medium",children:(S=b.job_name)==null?void 0:S.replace("Upload file","Summary")}),c.jsx(_e,{className:"!w-[200px]",children:N(b.created_at)}),c.jsx(_e,{className:"!w-[200px]",children:N(b.updated_at)}),c.jsx(_e,{className:"!w-[150px]",children:P(b.execution_time_seconds)}),c.jsx(_e,{className:"!w-[200px]",children:c.jsx("div",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium
|
|
136
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return d.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},ym="DialogDescriptionWarning",wm=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ml(ym).contentName}}.`;return d.useEffect(()=>{var s;const o=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},bm=bl,xm=Cl,Cm=El,kl=Nl,Il=Pl,$l=Tl,Ll=Fl,Sm=Rl;const on=bm,lr=xm,Em=Cm,Vl=d.forwardRef(({className:e,...t},n)=>c.jsx(kl,{ref:n,className:J("s3-explr-ui-dialog-overlay fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Vl.displayName=kl.displayName;const Vt=d.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Em,{children:[c.jsx(Vl,{}),c.jsxs(Il,{ref:r,className:J("s3-explr-ui-dialog-content fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,c.jsxs(Sm,{className:J("s3-explr-ui-dialog-close absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground"),children:[c.jsx(va,{className:"s3-explr-ui-dialog-close-icon h-4 w-4"}),c.jsx("span",{className:"s3-explr-ui-dialog-close-text sr-only",children:"Close"})]})]})]}));Vt.displayName=Il.displayName;const Bt=({className:e,...t})=>c.jsx("div",{className:J("s3-explr-ui-dialog-header flex flex-col space-y-1.5 text-center sm:text-left",e),...t});Bt.displayName="DialogHeader";const cr=({className:e,...t})=>c.jsx("div",{className:J("s3-explr-ui-dialog-footer flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});cr.displayName="DialogFooter";const zt=d.forwardRef(({className:e,...t},n)=>c.jsx($l,{ref:n,className:J("s3-explr-ui-dialog-title text-lg font-semibold leading-none tracking-tight",e),...t}));zt.displayName=$l.displayName;const Qo=d.forwardRef(({className:e,...t},n)=>c.jsx(Ll,{ref:n,className:J("s3-explr-ui-dialog-description text-sm text-muted-foreground",e),...t}));Qo.displayName=Ll.displayName;const Et=d.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:J("s3-explr-ui-input","flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Et.displayName="Input";var Nm="Label",Bl=d.forwardRef((e,t)=>c.jsx(ye.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Bl.displayName=Nm;var zl=Bl;const Pm=Ro("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 s3-explr-ui-label",{variants:{variant:{default:"s3-explr-ui-label-default",required:"s3-explr-ui-label-required",disabled:"s3-explr-ui-label-disabled"},size:{default:"s3-explr-ui-label-size-default",sm:"s3-explr-ui-label-size-sm",lg:"s3-explr-ui-label-size-lg"}},defaultVariants:{variant:"default",size:"default"}}),Ht=d.forwardRef(({className:e,variant:t,size:n,...r},o)=>c.jsx(zl,{ref:o,className:J(Pm({variant:t,size:n}),e),...r}));Ht.displayName=zl.displayName;const ur=d.forwardRef(({className:e,...t},n)=>c.jsx("div",{className:J("relative w-full overflow-auto","s3-explr-ui-table-container"),children:c.jsx("table",{ref:n,className:J("w-full caption-bottom text-sm","s3-explr-ui-table",e),...t})}));ur.displayName="Table";const dr=d.forwardRef(({className:e,...t},n)=>c.jsx("thead",{ref:n,className:J("[&_tr]:border-b","s3-explr-ui-table-header",e),...t}));dr.displayName="TableHeader";const fr=d.forwardRef(({className:e,...t},n)=>c.jsx("tbody",{ref:n,className:J("[&_tr:last-child]:border-0","s3-explr-ui-table-body",e),...t}));fr.displayName="TableBody";const Am=d.forwardRef(({className:e,...t},n)=>c.jsx("tfoot",{ref:n,className:J("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0","s3-explr-ui-table-footer",e),...t}));Am.displayName="TableFooter";const je=d.forwardRef(({className:e,...t},n)=>c.jsx("tr",{ref:n,className:J("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted","s3-explr-ui-table-row",e),...t}));je.displayName="TableRow";const et=d.forwardRef(({className:e,...t},n)=>c.jsx("th",{ref:n,className:J("h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]","s3-explr-ui-table-head",e),...t}));et.displayName="TableHead";const _e=d.forwardRef(({className:e,...t},n)=>c.jsx("td",{ref:n,className:J("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]","s3-explr-ui-table-cell",e),...t}));_e.displayName="TableCell";const Tm=d.forwardRef(({className:e,...t},n)=>c.jsx("caption",{ref:n,className:J("mt-4 text-sm text-muted-foreground","s3-explr-ui-table-caption",e),...t}));Tm.displayName="TableCaption";function es(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function sn(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function Hl(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function ts(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Hl(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Hl(e[o],null)}}}}function ns(...e){return d.useCallback(ts(...e),e)}var rs=d.forwardRef((e,t)=>{const{children:n,...r}=e,o=d.Children.toArray(n),s=o.find(Fm);if(s){const i=s.props.children,a=o.map(u=>u===s?d.Children.count(i)>1?d.Children.only(null):d.isValidElement(i)?i.props.children:null:u);return c.jsx(os,{...r,ref:t,children:d.isValidElement(i)?d.cloneElement(i,void 0,a):null})}return c.jsx(os,{...r,ref:t,children:n})});rs.displayName="Slot";var os=d.forwardRef((e,t)=>{const{children:n,...r}=e;if(d.isValidElement(n)){const o=Rm(n);return d.cloneElement(n,{...Om(r,n.props),ref:t?ts(t,o):o})}return d.Children.count(n)>1?d.Children.only(null):null});os.displayName="SlotClone";var _m=({children:e})=>c.jsx(c.Fragment,{children:e});function Fm(e){return d.isValidElement(e)&&e.type===_m}function Om(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function Rm(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function Dm(e){const t=e+"CollectionProvider",[n,r]=Ze(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=p=>{const{scope:v,children:m}=p,y=O.useRef(null),w=O.useRef(new Map).current;return c.jsx(o,{scope:v,itemMap:w,collectionRef:y,children:m})};i.displayName=t;const a=e+"CollectionSlot",u=O.forwardRef((p,v)=>{const{scope:m,children:y}=p,w=s(a,m),x=ns(v,w.collectionRef);return c.jsx(rs,{ref:x,children:y})});u.displayName=a;const l=e+"CollectionItemSlot",f="data-radix-collection-item",g=O.forwardRef((p,v)=>{const{scope:m,children:y,...w}=p,x=O.useRef(null),N=ns(v,x),P=s(l,m);return O.useEffect(()=>(P.itemMap.set(x,{ref:x,...w}),()=>void P.itemMap.delete(x))),c.jsx(rs,{[f]:"",ref:N,children:y})});g.displayName=l;function h(p){const v=s(e+"CollectionConsumer",p);return O.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const w=Array.from(y.querySelectorAll(`[${f}]`));return Array.from(v.itemMap.values()).sort((P,b)=>w.indexOf(P.ref.current)-w.indexOf(b.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:u,ItemSlot:g},h,r]}var Ul=d.forwardRef((e,t)=>{const{children:n,...r}=e,o=d.Children.toArray(n),s=o.find(km);if(s){const i=s.props.children,a=o.map(u=>u===s?d.Children.count(i)>1?d.Children.only(null):d.isValidElement(i)?i.props.children:null:u);return c.jsx(ss,{...r,ref:t,children:d.isValidElement(i)?d.cloneElement(i,void 0,a):null})}return c.jsx(ss,{...r,ref:t,children:n})});Ul.displayName="Slot";var ss=d.forwardRef((e,t)=>{const{children:n,...r}=e;if(d.isValidElement(n)){const o=$m(n);return d.cloneElement(n,{...Im(r,n.props),ref:t?ts(t,o):o})}return d.Children.count(n)>1?d.Children.only(null):null});ss.displayName="SlotClone";var Mm=({children:e})=>c.jsx(c.Fragment,{children:e});function km(e){return d.isValidElement(e)&&e.type===Mm}function Im(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function $m(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Lm=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],jl=Lm.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?Ul:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Vm=d.createContext(void 0);function is(e){const t=d.useContext(Vm);return e||t||"ltr"}var as="rovingFocusGroup.onEntryFocus",Bm={bubbles:!1,cancelable:!0},pr="RovingFocusGroup",[ls,Gl,zm]=Dm(pr),[Hm,gr]=Ze(pr,[zm]),[Um,jm]=Hm(pr),Wl=d.forwardRef((e,t)=>c.jsx(ls.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(ls.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Gm,{...e,ref:t})})}));Wl.displayName=pr;var Gm=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:u,onEntryFocus:l,preventScrollOnEntryFocus:f=!1,...g}=e,h=d.useRef(null),p=ns(t,h),v=is(s),[m=null,y]=$t({prop:i,defaultProp:a,onChange:u}),[w,x]=d.useState(!1),N=Ee(l),P=Gl(n),b=d.useRef(!1),[S,E]=d.useState(0);return d.useEffect(()=>{const M=h.current;if(M)return M.addEventListener(as,N),()=>M.removeEventListener(as,N)},[N]),c.jsx(Um,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:m,onItemFocus:d.useCallback(M=>y(M),[y]),onItemShiftTab:d.useCallback(()=>x(!0),[]),onFocusableItemAdd:d.useCallback(()=>E(M=>M+1),[]),onFocusableItemRemove:d.useCallback(()=>E(M=>M-1),[]),children:c.jsx(jl.div,{tabIndex:w||S===0?-1:0,"data-orientation":r,...g,ref:p,style:{outline:"none",...e.style},onMouseDown:sn(e.onMouseDown,()=>{b.current=!0}),onFocus:sn(e.onFocus,M=>{const H=!b.current;if(M.target===M.currentTarget&&H&&!w){const U=new CustomEvent(as,Bm);if(M.currentTarget.dispatchEvent(U),!U.defaultPrevented){const Z=P().filter(B=>B.focusable),F=Z.find(B=>B.active),I=Z.find(B=>B.id===m),G=[F,I,...Z].filter(Boolean).map(B=>B.ref.current);Xl(G,f)}}b.current=!1}),onBlur:sn(e.onBlur,()=>x(!1))})})}),ql="RovingFocusGroupItem",Kl=d.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,...i}=e,a=Qt(),u=s||a,l=jm(ql,n),f=l.currentTabStopId===u,g=Gl(n),{onFocusableItemAdd:h,onFocusableItemRemove:p}=l;return d.useEffect(()=>{if(r)return h(),()=>p()},[r,h,p]),c.jsx(ls.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(jl.span,{tabIndex:f?0:-1,"data-orientation":l.orientation,...i,ref:t,onMouseDown:sn(e.onMouseDown,v=>{r?l.onItemFocus(u):v.preventDefault()}),onFocus:sn(e.onFocus,()=>l.onItemFocus(u)),onKeyDown:sn(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){l.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const m=Km(v,l.orientation,l.dir);if(m!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let w=g().filter(x=>x.focusable).map(x=>x.ref.current);if(m==="last")w.reverse();else if(m==="prev"||m==="next"){m==="prev"&&w.reverse();const x=w.indexOf(v.currentTarget);w=l.loop?Xm(w,x+1):w.slice(x+1)}setTimeout(()=>Xl(w))}})})})});Kl.displayName=ql;var Wm={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function qm(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Km(e,t,n){const r=qm(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Wm[r]}function Xl(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Xm(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Yl=Wl,Jl=Kl;function Zl(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ym(...e){return t=>{let n=!1;const r=e.map(o=>{const s=Zl(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():Zl(e[o],null)}}}}function Jm(...e){return d.useCallback(Ym(...e),e)}function Zm(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var Ql=e=>{const{present:t,children:n}=e,r=Qm(t),o=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),s=Jm(r.ref,ev(o));return typeof n=="function"||r.isPresent?d.cloneElement(o,{ref:s}):null};Ql.displayName="Presence";function Qm(e){const[t,n]=d.useState(),r=d.useRef({}),o=d.useRef(e),s=d.useRef("none"),i=e?"mounted":"unmounted",[a,u]=Zm(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const l=hr(r.current);s.current=a==="mounted"?l:"none"},[a]),Ne(()=>{const l=r.current,f=o.current;if(f!==e){const h=s.current,p=hr(l);e?u("MOUNT"):p==="none"||(l==null?void 0:l.display)==="none"?u("UNMOUNT"):u(f&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,u]),Ne(()=>{if(t){let l;const f=t.ownerDocument.defaultView??window,g=p=>{const m=hr(r.current).includes(p.animationName);if(p.target===t&&m&&(u("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",l=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},h=p=>{p.target===t&&(s.current=hr(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{f.clearTimeout(l),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:d.useCallback(l=>{l&&(r.current=getComputedStyle(l)),n(l)},[])}}function hr(e){return(e==null?void 0:e.animationName)||"none"}function ev(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function ec(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function tv(...e){return t=>{let n=!1;const r=e.map(o=>{const s=ec(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():ec(e[o],null)}}}}var tc=d.forwardRef((e,t)=>{const{children:n,...r}=e,o=d.Children.toArray(n),s=o.find(rv);if(s){const i=s.props.children,a=o.map(u=>u===s?d.Children.count(i)>1?d.Children.only(null):d.isValidElement(i)?i.props.children:null:u);return c.jsx(cs,{...r,ref:t,children:d.isValidElement(i)?d.cloneElement(i,void 0,a):null})}return c.jsx(cs,{...r,ref:t,children:n})});tc.displayName="Slot";var cs=d.forwardRef((e,t)=>{const{children:n,...r}=e;if(d.isValidElement(n)){const o=sv(n);return d.cloneElement(n,{...ov(r,n.props),ref:t?tv(t,o):o})}return d.Children.count(n)>1?d.Children.only(null):null});cs.displayName="SlotClone";var nv=({children:e})=>c.jsx(c.Fragment,{children:e});function rv(e){return d.isValidElement(e)&&e.type===nv}function ov(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function sv(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var iv=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],mr=iv.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?tc:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),us="Tabs",[av,iC]=Ze(us,[gr]),nc=gr(),[lv,ds]=av(us),rc=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:s,orientation:i="horizontal",dir:a,activationMode:u="automatic",...l}=e,f=is(a),[g,h]=$t({prop:r,onChange:o,defaultProp:s});return c.jsx(lv,{scope:n,baseId:Qt(),value:g,onValueChange:h,orientation:i,dir:f,activationMode:u,children:c.jsx(mr.div,{dir:f,"data-orientation":i,...l,ref:t})})});rc.displayName=us;var oc="TabsList",sc=d.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,s=ds(oc,n),i=nc(n);return c.jsx(Yl,{asChild:!0,...i,orientation:s.orientation,dir:s.dir,loop:r,children:c.jsx(mr.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:t})})});sc.displayName=oc;var ic="TabsTrigger",ac=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...s}=e,i=ds(ic,n),a=nc(n),u=uc(i.baseId,r),l=dc(i.baseId,r),f=r===i.value;return c.jsx(Jl,{asChild:!0,...a,focusable:!o,active:f,children:c.jsx(mr.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":l,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...s,ref:t,onMouseDown:es(e.onMouseDown,g=>{!o&&g.button===0&&g.ctrlKey===!1?i.onValueChange(r):g.preventDefault()}),onKeyDown:es(e.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&i.onValueChange(r)}),onFocus:es(e.onFocus,()=>{const g=i.activationMode!=="manual";!f&&!o&&g&&i.onValueChange(r)})})})});ac.displayName=ic;var lc="TabsContent",cc=d.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:s,...i}=e,a=ds(lc,n),u=uc(a.baseId,r),l=dc(a.baseId,r),f=r===a.value,g=d.useRef(f);return d.useEffect(()=>{const h=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(h)},[]),c.jsx(Ql,{present:o||f,children:({present:h})=>c.jsx(mr.div,{"data-state":f?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":u,hidden:!h,id:l,tabIndex:0,...i,ref:t,style:{...e.style,animationDuration:g.current?"0s":void 0},children:h&&s})})});cc.displayName=lc;function uc(e,t){return`${e}-trigger-${t}`}function dc(e,t){return`${e}-content-${t}`}var cv=rc,fc=sc,pc=ac,gc=cc;const uv=cv,hc=d.forwardRef(({className:e,...t},n)=>c.jsx(fc,{ref:n,className:J("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...t}));hc.displayName=fc.displayName;const fs=d.forwardRef(({className:e,...t},n)=>c.jsx(pc,{ref:n,className:J("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...t}));fs.displayName=pc.displayName;const ps=d.forwardRef(({className:e,...t},n)=>c.jsx(gc,{ref:n,className:J("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));ps.displayName=gc.displayName;const vr=d.forwardRef(({className:e,...t},n)=>c.jsx("textarea",{className:J("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...t}));vr.displayName="Textarea";function dv(e,t=[]){let n=[];function r(s,i){const a=d.createContext(i),u=n.length;n=[...n,i];function l(g){const{scope:h,children:p,...v}=g,m=(h==null?void 0:h[e][u])||a,y=d.useMemo(()=>v,Object.values(v));return c.jsx(m.Provider,{value:y,children:p})}function f(g,h){const p=(h==null?void 0:h[e][u])||a,v=d.useContext(p);if(v)return v;if(i!==void 0)return i;throw new Error(`\`${g}\` must be used within \`${s}\``)}return l.displayName=s+"Provider",[l,f]}const o=()=>{const s=n.map(i=>d.createContext(i));return function(a){const u=(a==null?void 0:a[e])||s;return d.useMemo(()=>({[`__scope${e}`]:{...a,[e]:u}}),[a,u])}};return o.scopeName=e,[r,fv(o,...t)]}function fv(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:u,scopeName:l})=>{const g=u(s)[`__scope${l}`];return{...a,...g}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var gs=d.forwardRef((e,t)=>{const{children:n,...r}=e,o=d.Children.toArray(n),s=o.find(gv);if(s){const i=s.props.children,a=o.map(u=>u===s?d.Children.count(i)>1?d.Children.only(null):d.isValidElement(i)?i.props.children:null:u);return c.jsx(hs,{...r,ref:t,children:d.isValidElement(i)?d.cloneElement(i,void 0,a):null})}return c.jsx(hs,{...r,ref:t,children:n})});gs.displayName="Slot";var hs=d.forwardRef((e,t)=>{const{children:n,...r}=e;if(d.isValidElement(n)){const o=mv(n);return d.cloneElement(n,{...hv(r,n.props),ref:t?Zn(t,o):o})}return d.Children.count(n)>1?d.Children.only(null):null});hs.displayName="SlotClone";var pv=({children:e})=>c.jsx(c.Fragment,{children:e});function gv(e){return d.isValidElement(e)&&e.type===pv}function hv(e,t){const n={...t};for(const r in t){const o=e[r],s=t[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{s(...a),o(...a)}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...e,...n}}function mv(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function vv(e){const t=e+"CollectionProvider",[n,r]=dv(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=p=>{const{scope:v,children:m}=p,y=O.useRef(null),w=O.useRef(new Map).current;return c.jsx(o,{scope:v,itemMap:w,collectionRef:y,children:m})};i.displayName=t;const a=e+"CollectionSlot",u=O.forwardRef((p,v)=>{const{scope:m,children:y}=p,w=s(a,m),x=$e(v,w.collectionRef);return c.jsx(gs,{ref:x,children:y})});u.displayName=a;const l=e+"CollectionItemSlot",f="data-radix-collection-item",g=O.forwardRef((p,v)=>{const{scope:m,children:y,...w}=p,x=O.useRef(null),N=$e(v,x),P=s(l,m);return O.useEffect(()=>(P.itemMap.set(x,{ref:x,...w}),()=>void P.itemMap.delete(x))),c.jsx(gs,{[f]:"",ref:N,children:y})});g.displayName=l;function h(p){const v=s(e+"CollectionConsumer",p);return O.useCallback(()=>{const y=v.collectionRef.current;if(!y)return[];const w=Array.from(y.querySelectorAll(`[${f}]`));return Array.from(v.itemMap.values()).sort((P,b)=>w.indexOf(P.ref.current)-w.indexOf(b.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:i,Slot:u,ItemSlot:g},h,r]}var yv="VisuallyHidden",ms=d.forwardRef((e,t)=>c.jsx(ye.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));ms.displayName=yv;var vs="ToastProvider",[ys,wv,bv]=vv("Toast"),[mc,aC]=Ze("Toast",[bv]),[xv,yr]=mc(vs),vc=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:s=50,children:i}=e,[a,u]=d.useState(null),[l,f]=d.useState(0),g=d.useRef(!1),h=d.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${vs}\`. Expected non-empty \`string\`.`),c.jsx(ys.Provider,{scope:t,children:c.jsx(xv,{scope:t,label:n,duration:r,swipeDirection:o,swipeThreshold:s,toastCount:l,viewport:a,onViewportChange:u,onToastAdd:d.useCallback(()=>f(p=>p+1),[]),onToastRemove:d.useCallback(()=>f(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:g,isClosePausedRef:h,children:i})})};vc.displayName=vs;var yc="ToastViewport",Cv=["F8"],ws="toast.viewportPause",bs="toast.viewportResume",wc=d.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=Cv,label:o="Notifications ({hotkey})",...s}=e,i=yr(yc,n),a=wv(n),u=d.useRef(null),l=d.useRef(null),f=d.useRef(null),g=d.useRef(null),h=$e(t,g,i.onViewportChange),p=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=i.toastCount>0;d.useEffect(()=>{const y=w=>{var N;r.length!==0&&r.every(P=>w[P]||w.code===P)&&((N=g.current)==null||N.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[r]),d.useEffect(()=>{const y=u.current,w=g.current;if(v&&y&&w){const x=()=>{if(!i.isClosePausedRef.current){const S=new CustomEvent(ws);w.dispatchEvent(S),i.isClosePausedRef.current=!0}},N=()=>{if(i.isClosePausedRef.current){const S=new CustomEvent(bs);w.dispatchEvent(S),i.isClosePausedRef.current=!1}},P=S=>{!y.contains(S.relatedTarget)&&N()},b=()=>{y.contains(document.activeElement)||N()};return y.addEventListener("focusin",x),y.addEventListener("focusout",P),y.addEventListener("pointermove",x),y.addEventListener("pointerleave",b),window.addEventListener("blur",x),window.addEventListener("focus",N),()=>{y.removeEventListener("focusin",x),y.removeEventListener("focusout",P),y.removeEventListener("pointermove",x),y.removeEventListener("pointerleave",b),window.removeEventListener("blur",x),window.removeEventListener("focus",N)}}},[v,i.isClosePausedRef]);const m=d.useCallback(({tabbingDirection:y})=>{const x=a().map(N=>{const P=N.ref.current,b=[P,...kv(P)];return y==="forwards"?b:b.reverse()});return(y==="forwards"?x.reverse():x).flat()},[a]);return d.useEffect(()=>{const y=g.current;if(y){const w=x=>{var b,S,E;const N=x.altKey||x.ctrlKey||x.metaKey;if(x.key==="Tab"&&!N){const M=document.activeElement,H=x.shiftKey;if(x.target===y&&H){(b=l.current)==null||b.focus();return}const F=m({tabbingDirection:H?"backwards":"forwards"}),I=F.findIndex(R=>R===M);Ss(F.slice(I+1))?x.preventDefault():H?(S=l.current)==null||S.focus():(E=f.current)==null||E.focus()}};return y.addEventListener("keydown",w),()=>y.removeEventListener("keydown",w)}},[a,m]),c.jsxs(ph,{ref:u,role:"region","aria-label":o.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&c.jsx(xs,{ref:l,onFocusFromOutsideViewport:()=>{const y=m({tabbingDirection:"forwards"});Ss(y)}}),c.jsx(ys.Slot,{scope:n,children:c.jsx(ye.ol,{tabIndex:-1,...s,ref:h})}),v&&c.jsx(xs,{ref:f,onFocusFromOutsideViewport:()=>{const y=m({tabbingDirection:"backwards"});Ss(y)}})]})});wc.displayName=yc;var bc="ToastFocusProxy",xs=d.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=e,s=yr(bc,n);return c.jsx(ms,{"aria-hidden":!0,tabIndex:0,...o,ref:t,style:{position:"fixed"},onFocus:i=>{var l;const a=i.relatedTarget;!((l=s.viewport)!=null&&l.contains(a))&&r()}})});xs.displayName=bc;var wr="Toast",Sv="toast.swipeStart",Ev="toast.swipeMove",Nv="toast.swipeCancel",Pv="toast.swipeEnd",xc=d.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:s,...i}=e,[a=!0,u]=$t({prop:r,defaultProp:o,onChange:s});return c.jsx(Zt,{present:n||a,children:c.jsx(_v,{open:a,...i,ref:t,onClose:()=>u(!1),onPause:Ee(e.onPause),onResume:Ee(e.onResume),onSwipeStart:me(e.onSwipeStart,l=>{l.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:me(e.onSwipeMove,l=>{const{x:f,y:g}=l.detail.delta;l.currentTarget.setAttribute("data-swipe","move"),l.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${f}px`),l.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${g}px`)}),onSwipeCancel:me(e.onSwipeCancel,l=>{l.currentTarget.setAttribute("data-swipe","cancel"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),l.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:me(e.onSwipeEnd,l=>{const{x:f,y:g}=l.detail.delta;l.currentTarget.setAttribute("data-swipe","end"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),l.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),l.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${f}px`),l.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${g}px`),u(!1)})})})});xc.displayName=wr;var[Av,Tv]=mc(wr,{onClose(){}}),_v=d.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:s,onClose:i,onEscapeKeyDown:a,onPause:u,onResume:l,onSwipeStart:f,onSwipeMove:g,onSwipeCancel:h,onSwipeEnd:p,...v}=e,m=yr(wr,n),[y,w]=d.useState(null),x=$e(t,R=>w(R)),N=d.useRef(null),P=d.useRef(null),b=o||m.duration,S=d.useRef(0),E=d.useRef(b),M=d.useRef(0),{onToastAdd:H,onToastRemove:U}=m,Z=Ee(()=>{var G;(y==null?void 0:y.contains(document.activeElement))&&((G=m.viewport)==null||G.focus()),i()}),F=d.useCallback(R=>{!R||R===1/0||(window.clearTimeout(M.current),S.current=new Date().getTime(),M.current=window.setTimeout(Z,R))},[Z]);d.useEffect(()=>{const R=m.viewport;if(R){const G=()=>{F(E.current),l==null||l()},B=()=>{const K=new Date().getTime()-S.current;E.current=E.current-K,window.clearTimeout(M.current),u==null||u()};return R.addEventListener(ws,B),R.addEventListener(bs,G),()=>{R.removeEventListener(ws,B),R.removeEventListener(bs,G)}}},[m.viewport,b,u,l,F]),d.useEffect(()=>{s&&!m.isClosePausedRef.current&&F(b)},[s,b,m.isClosePausedRef,F]),d.useEffect(()=>(H(),()=>U()),[H,U]);const I=d.useMemo(()=>y?Tc(y):null,[y]);return m.viewport?c.jsxs(c.Fragment,{children:[I&&c.jsx(Fv,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0,children:I}),c.jsx(Av,{scope:n,onClose:Z,children:kn.createPortal(c.jsx(ys.ItemSlot,{scope:n,children:c.jsx(fh,{asChild:!0,onEscapeKeyDown:me(a,()=>{m.isFocusedToastEscapeKeyDownRef.current||Z(),m.isFocusedToastEscapeKeyDownRef.current=!1}),children:c.jsx(ye.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":m.swipeDirection,...v,ref:x,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:me(e.onKeyDown,R=>{R.key==="Escape"&&(a==null||a(R.nativeEvent),R.nativeEvent.defaultPrevented||(m.isFocusedToastEscapeKeyDownRef.current=!0,Z()))}),onPointerDown:me(e.onPointerDown,R=>{R.button===0&&(N.current={x:R.clientX,y:R.clientY})}),onPointerMove:me(e.onPointerMove,R=>{if(!N.current)return;const G=R.clientX-N.current.x,B=R.clientY-N.current.y,K=!!P.current,q=["left","right"].includes(m.swipeDirection),ee=["left","up"].includes(m.swipeDirection)?Math.min:Math.max,ie=q?ee(0,G):0,ue=q?0:ee(0,B),Se=R.pointerType==="touch"?10:2,ae={x:ie,y:ue},lt={originalEvent:R,delta:ae};K?(P.current=ae,br(Ev,g,lt,{discrete:!1})):_c(ae,m.swipeDirection,Se)?(P.current=ae,br(Sv,f,lt,{discrete:!1}),R.target.setPointerCapture(R.pointerId)):(Math.abs(G)>Se||Math.abs(B)>Se)&&(N.current=null)}),onPointerUp:me(e.onPointerUp,R=>{const G=P.current,B=R.target;if(B.hasPointerCapture(R.pointerId)&&B.releasePointerCapture(R.pointerId),P.current=null,N.current=null,G){const K=R.currentTarget,q={originalEvent:R,delta:G};_c(G,m.swipeDirection,m.swipeThreshold)?br(Pv,p,q,{discrete:!0}):br(Nv,h,q,{discrete:!0}),K.addEventListener("click",ee=>ee.preventDefault(),{once:!0})}})})})}),m.viewport)})]}):null}),Fv=e=>{const{__scopeToast:t,children:n,...r}=e,o=yr(wr,t),[s,i]=d.useState(!1),[a,u]=d.useState(!1);return Dv(()=>i(!0)),d.useEffect(()=>{const l=window.setTimeout(()=>u(!0),1e3);return()=>window.clearTimeout(l)},[]),a?null:c.jsx(zo,{asChild:!0,children:c.jsx(ms,{...r,children:s&&c.jsxs(c.Fragment,{children:[o.label," ",n]})})})},Ov="ToastTitle",Cc=d.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return c.jsx(ye.div,{...r,ref:t})});Cc.displayName=Ov;var Rv="ToastDescription",Sc=d.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return c.jsx(ye.div,{...r,ref:t})});Sc.displayName=Rv;var Ec="ToastAction",Nc=d.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?c.jsx(Ac,{altText:n,asChild:!0,children:c.jsx(Cs,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Ec}\`. Expected non-empty \`string\`.`),null)});Nc.displayName=Ec;var Pc="ToastClose",Cs=d.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,o=Tv(Pc,n);return c.jsx(Ac,{asChild:!0,children:c.jsx(ye.button,{type:"button",...r,ref:t,onClick:me(e.onClick,o.onClose)})})});Cs.displayName=Pc;var Ac=d.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...o}=e;return c.jsx(ye.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:t})});function Tc(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),Mv(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!o)if(s){const i=r.dataset.radixToastAnnounceAlt;i&&t.push(i)}else t.push(...Tc(r))}}),t}function br(e,t,n,{discrete:r}){const o=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?$a(o,s):o.dispatchEvent(s)}var _c=(e,t,n=0)=>{const r=Math.abs(e.x),o=Math.abs(e.y),s=r>o;return t==="left"||t==="right"?s&&r>n:!s&&o>n};function Dv(e=()=>{}){const t=Ee(e);Ne(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function Mv(e){return e.nodeType===e.ELEMENT_NODE}function kv(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Ss(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var Iv=vc,Fc=wc,Oc=xc,Rc=Cc,Dc=Sc,Mc=Nc,kc=Cs;const $v=Iv,Ic=d.forwardRef(({className:e,...t},n)=>c.jsx(Fc,{ref:n,className:J("s3-explr-ui-toast-viewport fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...t}));Ic.displayName=Fc.displayName;const Lv=Ro("s3-explr-ui-toast group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"s3-explr-ui-toast-default border bg-background text-foreground",destructive:"s3-explr-ui-toast-destructive destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),$c=d.forwardRef(({className:e,variant:t,...n},r)=>c.jsx(Oc,{ref:r,className:J(Lv({variant:t}),e),...n}));$c.displayName=Oc.displayName;const Vv=d.forwardRef(({className:e,...t},n)=>c.jsx(Mc,{ref:n,className:J("s3-explr-ui-toast-action inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));Vv.displayName=Mc.displayName;const Lc=d.forwardRef(({className:e,...t},n)=>c.jsx(kc,{ref:n,className:J("s3-explr-ui-toast-close absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:c.jsx(va,{className:"s3-explr-ui-toast-close-icon h-4 w-4"})}));Lc.displayName=kc.displayName;const Vc=d.forwardRef(({className:e,...t},n)=>c.jsx(Rc,{ref:n,className:J("s3-explr-ui-toast-title text-sm font-semibold [&+div]:text-xs",e),...t}));Vc.displayName=Rc.displayName;const Bc=d.forwardRef(({className:e,...t},n)=>c.jsx(Dc,{ref:n,className:J("s3-explr-ui-toast-description text-sm opacity-90",e),...t}));Bc.displayName=Dc.displayName;const Bv=1,zv=1e6;let Es=0;function Hv(){return Es=(Es+1)%Number.MAX_SAFE_INTEGER,Es.toString()}const Ns=new Map,zc=e=>{if(Ns.has(e))return;const t=setTimeout(()=>{Ns.delete(e),xn({type:"REMOVE_TOAST",toastId:e})},zv);Ns.set(e,t)},Uv=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Bv)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?zc(n):e.toasts.forEach(r=>{zc(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}},xr=[];let Cr={toasts:[]};function xn(e){Cr=Uv(Cr,e),xr.forEach(t=>{t(Cr)})}function jv({...e}){const t=Hv(),n=o=>xn({type:"UPDATE_TOAST",toast:{...o,id:t}}),r=()=>xn({type:"DISMISS_TOAST",toastId:t});return xn({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:o=>{o||r()}}}),{id:t,dismiss:r,update:n}}function Ps(){const[e,t]=d.useState(Cr);return d.useEffect(()=>(xr.push(t),()=>{const n=xr.indexOf(t);n>-1&&xr.splice(n,1)}),[e]),{...e,toast:jv,dismiss:n=>xn({type:"DISMISS_TOAST",toastId:n})}}function Hc(){const{toasts:e}=Ps();return c.jsxs($v,{children:[e.map(function({id:t,title:n,description:r,action:o,...s}){return c.jsxs($c,{...s,className:`s3-explr-ui-toast ${s.className||""}`,children:[c.jsxs("div",{className:"s3-explr-ui-toast-content grid gap-1",children:[n&&c.jsx(Vc,{className:"s3-explr-ui-toast-title",children:n}),r&&c.jsx(Bc,{className:"s3-explr-ui-toast-description",children:r})]}),o&&c.jsx("div",{className:"s3-explr-ui-toast-action",children:o}),c.jsx(Lc,{className:"s3-explr-ui-toast-close"})]},t)}),c.jsx(Ic,{className:"s3-explr-ui-toast-viewport"})]})}function Gv({title:e,titleId:t,...n},r){return d.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?d.createElement("title",{id:t},e):null,d.createElement("path",{fillRule:"evenodd",d:"M5.47 5.47a.75.75 0 0 1 1.06 0L12 10.94l5.47-5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47a.75.75 0 1 1-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 0 1-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const Wv=d.forwardRef(Gv);var qv=function(e){return function(t,n){var r=O.useRef(!1);e(function(){return function(){r.current=!1}},[]),e(function(){if(!r.current)r.current=!0;else return t()},n)}},Uc=function(e){return typeof e=="function"},jc=process.env.NODE_ENV==="development"||process.env.NODE_ENV==="test";const Kv=qv(O.useEffect);function Gc(e){var t=O.useRef(e);return t.current=e,t}var Xv=function(e){jc&&(Uc(e)||console.error("useUnmount expected parameter is a function, got ".concat(typeof e)));var t=Gc(e);O.useEffect(function(){return function(){t.current()}},[])},Sr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Jv(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Wc=Jv,Zv=typeof Sr=="object"&&Sr&&Sr.Object===Object&&Sr,Qv=Zv,ey=Qv,ty=typeof self=="object"&&self&&self.Object===Object&&self,ny=ey||ty||Function("return this")(),qc=ny,ry=qc,oy=function(){return ry.Date.now()},sy=oy,iy=/\s/;function ay(e){for(var t=e.length;t--&&iy.test(e.charAt(t)););return t}var ly=ay,cy=ly,uy=/^\s+/;function dy(e){return e&&e.slice(0,cy(e)+1).replace(uy,"")}var fy=dy,py=qc,gy=py.Symbol,Kc=gy,Xc=Kc,Yc=Object.prototype,hy=Yc.hasOwnProperty,my=Yc.toString,Cn=Xc?Xc.toStringTag:void 0;function vy(e){var t=hy.call(e,Cn),n=e[Cn];try{e[Cn]=void 0;var r=!0}catch{}var o=my.call(e);return r&&(t?e[Cn]=n:delete e[Cn]),o}var yy=vy,wy=Object.prototype,by=wy.toString;function xy(e){return by.call(e)}var Cy=xy,Jc=Kc,Sy=yy,Ey=Cy,Ny="[object Null]",Py="[object Undefined]",Zc=Jc?Jc.toStringTag:void 0;function Ay(e){return e==null?e===void 0?Py:Ny:Zc&&Zc in Object(e)?Sy(e):Ey(e)}var Ty=Ay;function _y(e){return e!=null&&typeof e=="object"}var Fy=_y,Oy=Ty,Ry=Fy,Dy="[object Symbol]";function My(e){return typeof e=="symbol"||Ry(e)&&Oy(e)==Dy}var ky=My,Iy=fy,Qc=Wc,$y=ky,eu=NaN,Ly=/^[-+]0x[0-9a-f]+$/i,Vy=/^0b[01]+$/i,By=/^0o[0-7]+$/i,zy=parseInt;function Hy(e){if(typeof e=="number")return e;if($y(e))return eu;if(Qc(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Qc(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Iy(e);var n=Vy.test(e);return n||By.test(e)?zy(e.slice(2),n?2:8):Ly.test(e)?eu:+e}var Uy=Hy,jy=Wc,As=sy,tu=Uy,Gy="Expected a function",Wy=Math.max,qy=Math.min;function Ky(e,t,n){var r,o,s,i,a,u,l=0,f=!1,g=!1,h=!0;if(typeof e!="function")throw new TypeError(Gy);t=tu(t)||0,jy(n)&&(f=!!n.leading,g="maxWait"in n,s=g?Wy(tu(n.maxWait)||0,t):s,h="trailing"in n?!!n.trailing:h);function p(S){var E=r,M=o;return r=o=void 0,l=S,i=e.apply(M,E),i}function v(S){return l=S,a=setTimeout(w,t),f?p(S):i}function m(S){var E=S-u,M=S-l,H=t-E;return g?qy(H,s-M):H}function y(S){var E=S-u,M=S-l;return u===void 0||E>=t||E<0||g&&M>=s}function w(){var S=As();if(y(S))return x(S);a=setTimeout(w,m(S))}function x(S){return a=void 0,h&&r?p(S):(r=o=void 0,i)}function N(){a!==void 0&&clearTimeout(a),l=0,r=u=o=a=void 0}function P(){return a===void 0?i:x(As())}function b(){var S=As(),E=y(S);if(r=arguments,o=this,u=S,E){if(a===void 0)return v(u);if(g)return clearTimeout(a),a=setTimeout(w,t),p(u)}return a===void 0&&(a=setTimeout(w,t)),i}return b.cancel=N,b.flush=P,b}var Xy=Ky;const Yy=Yv(Xy);function Jy(){var e=(typeof global>"u"?"undefined":typeof global)=="object"&&global&&global.Object===Object&&global,t=typeof self=="object"&&self&&self.Object===Object&&self;return e||t}Jy()||(global.Date=Date);function Zy(e,t){var n;jc&&(Uc(e)||console.error("useDebounceFn expected parameter is a function, got ".concat(typeof e)));var r=Gc(e),o=(n=t==null?void 0:t.wait)!==null&&n!==void 0?n:1e3,s=O.useMemo(function(){return Yy(function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];return r.current.apply(r,ol([],rl(i),!1))},o,t)},[]);return Xv(function(){s.cancel()}),{run:s,cancel:s.cancel,flush:s.flush}}function Qy(e,t,n){var r=rl(O.useState({}),2),o=r[0],s=r[1],i=Zy(function(){s({})},n).run;O.useEffect(function(){return i()},t),Kv(e,[o])}const ew=O.forwardRef(({onChange:e},t)=>{const n=O.useRef(null),[r,o]=O.useState("");return O.useImperativeHandle(t,()=>({setValue:s=>{var i;o(s),(i=n.current)==null||i.focus()}})),Qy(()=>{e==null||e(r)},[r],{wait:300}),c.jsxs(c.Fragment,{children:[c.jsx(Et,{ref:n,type:"text",placeholder:"Search files...",value:r,onChange:s=>o(s.target.value),className:"pr-8"}),r&&c.jsx("button",{onClick:()=>{var s;o(""),(s=n.current)==null||s.focus()},className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700",children:c.jsx(Wv,{className:"h-5 w-5"})})]})}),tt={current:!1},tw=(e,t,n)=>{const r=[],o=s=>{(e[s]||[]).forEach(a=>{a.name.toLowerCase().includes(t.toLowerCase())&&r.push(a),a.isFolder&&a.key.startsWith(n)&&o(a.key)})};return o(n),r},Er=(e,t)=>{const n=[],r=o=>{(e[o]||[]).forEach(i=>{n.push(i.key),i.isFolder&&r(i.key)})};return r(t),n},nw=(e,t)=>{const n=[];return(e[t]||[]).forEach(o=>{n.push(o.key),o.isFolder&&n.push(...Er(e,o.key))}),n},rw=(e,t)=>{const[n,r]=O.useState({}),[o,s]=O.useState(!1),[i,a]=O.useState(null),u=async()=>{s(!0);try{const l=!tt.current;tt.current&&(tt.current=!1);const f=await oe.get(`${e}/api/files`,{params:{cache:l,prefix:t}});r(f.data),a(null)}catch(l){a(l instanceof Error?l:new Error("Failed to fetch files"))}finally{s(!1)}};return O.useEffect(()=>{u()},[]),{data:n,isLoading:o,error:i,refetch:u}},Nr=e=>{var r,o,s;const t=((s=(o=(r=e==null?void 0:e.name)==null?void 0:r.split("."))==null?void 0:o.pop())==null?void 0:s.toLowerCase())??"";return["txt","md","json","js","ts","jsx","tsx","css","html","xml","yaml","yml"].includes(t||"")},ow=O.memo(({homeLabel:e="Document Store",apiBaseUrl:t="http://localhost:3000",rootPrefix:n="",asSelector:r=!1,onSelected:o=s=>console.log("selected:",s)})=>{const[s,i]=O.useState(""),[a,u]=O.useState(new Set),[l,f]=O.useState(n),[g,h]=O.useState(!1),[p,v]=O.useState(""),[m,y]=O.useState(!1),[w,x]=O.useState(null),[N,P]=O.useState(!1),[b,S]=O.useState(!1),[E,M]=O.useState(!1),[H,U]=O.useState(null),Z=O.useRef(null),{toast:F}=Ps(),[I,R]=O.useState(null),[G,B]=O.useState(""),[K,q]=O.useState(!1),[ee,ie]=O.useState(new Set),[ue,Se]=O.useState(""),[ae,lt]=O.useState(!1),[Gt,_t]=O.useState(!1),[Ft,Ke]=O.useState("rename"),{data:be={},isLoading:Ot,error:Wt,refetch:Ve}=rw(t,n),Xe=O.useMemo(()=>be[l]||[],[be,l]),Ie=O.useMemo(()=>s?tw(be,s,l):Xe,[Xe,s,l,be]),Rt=O.useMemo(()=>{const D={};return Ie.forEach(($,j)=>{a.has($.key)&&(D[j]=!0)}),D},[a,Ie]),Wr=D=>{const $=Er(be,D);if($.length===0)return a.has(D)?"all":"none";const j=$.filter(re=>a.has(re)).length;return j===0?"none":j===$.length?"all":"partial"},qt=D=>{f(D)},C=async(D,$)=>{y(!0);try{const j=`${$}${D}/`;if((await oe.post(`${t}/api/create-folder`,{prefix:j})).status!==200){F({title:"Error",description:"Failed to create folder",variant:"destructive"});return}tt.current=!0,await Ve(),F({title:"Folder Created",description:`Successfully created folder "${D}"`}),v(""),h(!1)}catch(j){console.error("Error creating folder:",j),F({title:"Error",description:"Failed to create folder",variant:"destructive"})}finally{y(!1)}},A=async(D,$,j)=>{U(j);try{const re=new FormData;re.append("prefix",$),Array.from(D).forEach(pe=>{pe instanceof File&&re.append("files",pe)}),(await oe.post(`${t}/api/upload`,re,{headers:{"Content-Type":"multipart/form-data"}})).status===200&&(tt.current=!0,await Ve(),F({title:"Files Uploaded",description:`Successfully uploaded ${D.length} files`}))}catch(re){console.error("Error uploading files:",re),F({title:"Error",description:"Failed to upload files",variant:"destructive"})}finally{U(null)}},_=async D=>{P(!0);try{await oe.delete(`${t}/api/files`,{data:{paths:[D.key]}}),tt.current=!0,await Ve(),F({title:"File Deleted",description:`Successfully deleted "${D.name}"`}),x(null)}catch($){console.error("Error deleting file:",$),F({title:"Error",description:"Failed to delete file",variant:"destructive"})}finally{P(!1)}},V=D=>{const $=new Set(a),j=typeof D=="function"?D(Rt):D;new Set(Object.keys(Rt).map(Number)).forEach(se=>{const pe=Ie[se];pe&&(j[se]||($.delete(pe.key),pe.isFolder&&Er(be,pe.key).forEach(Oe=>$.delete(Oe))))}),Object.entries(j).forEach(([se,pe])=>{const Oe=parseInt(se),vt=Ie[Oe];vt&&pe&&($.add(vt.key),vt.isFolder&&Er(be,vt.key).forEach(gi=>$.add(gi)))}),u($)},L=async()=>{S(!0);try{const D=Array.from(a).map($=>{var j;for(const re in be){const se=(j=be[re])==null?void 0:j.find(pe=>pe.key===$);if(se)return se}return null}).filter($=>$!==null);await oe.delete(`${t}/api/files`,{data:{paths:Array.from(a)}}),tt.current=!0,await Ve(),F({title:"Files Deleted",description:`Successfully deleted ${D.length} items`}),M(!1),u(new Set)}catch(D){console.error("Error deleting files:",D),F({title:"Error",description:"Failed to delete selected files",variant:"destructive"})}finally{S(!1)}},k=async(D,$)=>{q(!0);try{const j=D.key;let re;D.isFolder?re=j.split("/").slice(0,-2).join("/")+"/":re=j.substring(0,j.lastIndexOf("/")+1);const se=re+$+(D.isFolder?"/":"");await oe.post(`${t}/api/rename`,{oldPath:j,newPath:se}),tt.current=!0,await Ve(),F({title:"Item Renamed",description:`Successfully renamed "${D.name}" to "${$}"`}),R(null),B("")}catch(j){console.error("Error renaming item:",j),F({title:"Error",description:"Failed to rename item",variant:"destructive"})}finally{q(!1)}},W=async D=>{ie($=>new Set([...$,...D]));try{const $=await oe.post(`${t}/api/download`,{paths:D},{responseType:"blob"}),j=window.URL.createObjectURL($.data),re=document.createElement("a");re.href=j;const se=$.headers["Content-Disposition"]||$.headers["content-disposition"],pe=se==null?void 0:se.match(/filename="(.+)"/),Oe=pe?decodeURIComponent(pe[1]):"download.zip";re.setAttribute("download",Oe),document.body.appendChild(re),re.click(),document.body.removeChild(re),window.URL.revokeObjectURL(j),F({title:"Download Started",description:`Your download has started for ${D.length} item${D.length>1?"s":""}`})}catch($){console.error("Error downloading files:",$),F({title:"Error",description:"Failed to download files",variant:"destructive"})}finally{ie($=>{const j=new Set($);return D.forEach(re=>j.delete(re)),j})}},ne=l?l.replace(n,"").split("/").filter(Boolean):[],ve=()=>Array.from(a).map(D=>{var $;for(const j in be){const re=($=be[j])==null?void 0:$.find(se=>se.key===D);if(re)return re}return null}).filter(D=>D!==null),he=O.useMemo(()=>{const D=[{id:"select",header:()=>{const $=nw(be,l),j=$.length>0&&$.every(se=>a.has(se)),re=$.some(se=>a.has(se));return c.jsx(Io,{checked:j?!0:re?"indeterminate":!1,onCheckedChange:se=>{if(se){const pe=Ie.reduce((Oe,vt,gi)=>(Oe[gi]=!0,Oe),{});V(pe)}else V({})},"aria-label":"Select all"})},cell:({row:$})=>{const j=$.original,se=j.isFolder?Wr(j.key):a.has(j.key)?"all":"none";return c.jsx("div",{className:"flex items-center",children:c.jsx(Io,{checked:se==="partial"?"indeterminate":se==="all",onCheckedChange:pe=>{const Oe={...Rt};pe?Oe[$.index]=!0:delete Oe[$.index],V(Oe)},"aria-label":"Select row"})})},enableSorting:!1},{id:"fileName",header:"File Name",accessorKey:"name",cell:({row:$})=>{const j=$.original,re=j.key.substring(0,j.key.lastIndexOf("/"))||"/",se=s.trim()!==""&&re!==l,pe=re.split("/").filter(Boolean);return c.jsxs("div",{className:"flex flex-col",children:[c.jsxs("div",{className:`flex items-center gap-2 ${j.isFolder?"cursor-pointer hover:text-blue-600":""}`,onClick:()=>{j.isFolder&&qt(j.key)},children:[j.isFolder?c.jsx(Kr,{className:"h-5 w-5 text-blue-500"}):null,j.name]}),se&&c.jsxs("div",{className:"text-sm text-gray-500 flex items-center",children:[c.jsx(Kr,{className:"h-4 w-4 text-gray-500 my-auto"}),c.jsxs("span",{className:"flex items-center ml-1",children:[c.jsx("span",{className:"cursor-pointer hover:text-blue-600",onClick:()=>{qt("")},children:"/"}),pe.map((Oe,vt)=>c.jsxs("span",{className:"flex items-center",children:[c.jsx("span",{className:"cursor-pointer hover:text-blue-600",onClick:()=>{qt(pe.slice(0,vt+1).join("/")+"/")},children:Oe}),vt<pe.length-1&&c.jsx("span",{children:"/"})]},vt))]})]})]})}}];return r||D.push({id:"size",header:"Size",accessorKey:"size",cell:({getValue:$,row:j})=>{const re=$();return c.jsx("span",{children:j.original.isFolder?"-":Vg(re)})}},{id:"lastModified",header:"Last Modified",accessorKey:"lastModified",cell:({row:$})=>{const j=$.original.lastModified;return c.jsx("span",{children:j.toLocaleString()})}},{id:"actions",header:"Actions",accessorKey:"key",cell:({row:$})=>c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(de,{variant:"ghost",size:"icon",onClick:()=>W([$.original.key]),className:"h-8 w-8 p-0",disabled:ee.has($.original.key),children:ee.has($.original.key)?c.jsx(Te,{className:"h-4 w-4 animate-spin"}):c.jsx(mi,{className:"h-4 w-4"})}),c.jsx(de,{variant:"ghost",size:"icon",onClick:()=>{R($.original),B($.original.name)},className:"h-8 w-8 p-0",children:c.jsx(Hd,{className:"h-4 w-4"})}),c.jsx(de,{variant:"ghost",size:"icon",onClick:()=>x($.original),className:"h-8 w-8 p-0",children:c.jsx(vi,{className:"h-4 w-4"})})]})}),D},[a,Ie,Rt,ee,r]),Ye=Fi({data:Ie,columns:he,state:{rowSelection:Rt},enableRowSelection:!0,onRowSelectionChange:V,getCoreRowModel:_i()}),pi=async D=>{if(Nr(D)){lt(!0);try{const $=await oe.get(`${t}/api/read-text`,{params:{path:D.key}});Se($.data.content)}catch($){console.error("Error loading file content:",$),F({title:"Error",description:"Failed to load file content",variant:"destructive"})}finally{lt(!1)}}},Mn=async(D,$)=>{_t(!0);try{await oe.post(`${t}/api/modify-text`,{path:D.key,content:$}),F({title:"File Saved",description:"File content has been updated successfully"}),tt.current=!0,await Ve(),R(null),Se(""),Ke("rename")}catch(j){console.error("Error saving file content:",j),F({title:"Error",description:"Failed to save file content",variant:"destructive"})}finally{_t(!1)}};return O.useEffect(()=>{I&&Nr(I)&&(pi(I),Ke("rename"))},[I]),c.jsxs("div",{className:"space-y-4 s3-explr-container",children:[c.jsx(_a,{className:"s3-explr-breadcrumb",children:c.jsxs(Fa,{className:"s3-explr-breadcrumb-list",children:[c.jsx(Fo,{className:"s3-explr-breadcrumb-item",children:c.jsx(Oo,{onClick:()=>f(n),className:"flex items-center gap-1 cursor-pointer s3-explr-breadcrumb-home",children:e})}),ne.map((D,$)=>c.jsxs(c.Fragment,{children:[c.jsx(Oa,{className:"s3-explr-breadcrumb-separator"},`sep-${$}`),c.jsx(Fo,{className:"s3-explr-breadcrumb-item",children:c.jsx(Oo,{onClick:()=>qt(n+ne.slice(0,$+1).join("/")+"/"),className:"cursor-pointer s3-explr-breadcrumb-link",children:D})},`item-${D}`)]}))]})}),c.jsxs("div",{className:"flex items-center space-x-4 s3-explr-toolbar",children:[c.jsx("div",{className:"relative max-w-sm w-full s3-explr-search-container",children:c.jsx(ew,{ref:Z,onChange:D=>i(D)})}),c.jsxs(de,{variant:"outline",size:"sm",onClick:()=>{tt.current=!0,Ve()},disabled:Ot,className:"flex items-center gap-2 s3-explr-refresh-btn",children:[c.jsx(kd,{className:`h-4 w-4 s3-explr-refresh-icon ${Ot?"animate-spin":""}`}),"Refresh"]}),!r&&c.jsxs(c.Fragment,{children:[a.size>0&&c.jsxs(c.Fragment,{children:[c.jsxs(de,{variant:"outline",size:"sm",onClick:()=>W(Array.from(a)),disabled:Array.from(a).some(D=>ee.has(D)),className:"flex items-center gap-2 s3-explr-download-selected-btn",children:[Array.from(a).some(D=>ee.has(D))?c.jsx(Te,{className:"h-4 w-4 animate-spin mr-2 s3-explr-loader"}):c.jsx(mi,{className:"h-4 w-4 s3-explr-download-icon"}),"Download Selected (",a.size,")"]}),c.jsxs(on,{open:E,onOpenChange:M,children:[c.jsx(lr,{asChild:!0,children:c.jsxs(de,{variant:"destructive",size:"sm",className:"flex items-center gap-2 s3-explr-bulk-delete-btn",children:[c.jsx(vi,{className:"h-4 w-4 s3-explr-trash-icon"}),"Remove Selected (",a.size,")"]})}),c.jsxs(Vt,{className:"s3-explr-dialog-content",children:[c.jsxs(Bt,{className:"s3-explr-dialog-header",children:[c.jsx(zt,{className:"s3-explr-dialog-title",children:"Confirm Bulk Deletion"}),c.jsxs(Qo,{className:"s3-explr-dialog-description",children:["Are you sure you want to delete ",a.size," selected items? This action cannot be undone."]})]}),c.jsxs(cr,{className:"s3-explr-dialog-footer",children:[c.jsx(de,{variant:"outline",onClick:()=>M(!1),className:"s3-explr-cancel-btn",children:"Cancel"}),c.jsx(de,{variant:"destructive",onClick:L,disabled:b,className:"s3-explr-confirm-delete-btn",children:b?c.jsxs(c.Fragment,{children:[c.jsx(Te,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Deleting..."]}):"Delete Selected"})]})]})]})]}),c.jsxs(on,{open:g,onOpenChange:h,children:[c.jsx(lr,{asChild:!0,children:c.jsxs(de,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-new-folder-btn",children:[c.jsx(Vd,{className:"h-4 w-4 s3-explr-folder-plus-icon"}),"New Folder"]})}),c.jsxs(Vt,{className:"s3-explr-dialog-content",children:[c.jsx(Bt,{className:"s3-explr-dialog-header",children:c.jsx(zt,{className:"s3-explr-dialog-title",children:"Create New Folder"})}),c.jsxs("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:[c.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[c.jsx(Ht,{htmlFor:"name",className:"s3-explr-label",children:"Folder Name"}),c.jsx(Et,{disabled:m,id:"name",value:p,onChange:D=>v(D.target.value),placeholder:"Enter folder name",className:"s3-explr-input"})]}),c.jsxs(de,{onClick:()=>{p.trim()&&C(p,l)},disabled:m,className:"s3-explr-create-btn",children:[m&&c.jsx(Te,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),m?"Creating...":"Create"]})]})]})]}),c.jsxs("div",{className:"flex items-center gap-2 s3-explr-upload-group",children:[c.jsx(de,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-upload-files-btn",onClick:()=>{const D=document.createElement("input");D.type="file",D.multiple=!0,D.onchange=$=>{const j=$.target.files;j&&A(j,l,"files")},D.click()},disabled:H!==null,children:H==="files"?c.jsxs(c.Fragment,{children:[c.jsx(Te,{className:"h-4 w-4 animate-spin mr-2 s3-explr-loader"}),"Uploading..."]}):c.jsxs(c.Fragment,{children:[c.jsx($d,{className:"h-4 w-4 s3-explr-upload-icon"}),"Upload Files"]})}),c.jsx(de,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-upload-folder-btn",onClick:()=>{const D=document.createElement("input");D.type="file",D.multiple=!0,D.webkitdirectory=!0,D.onchange=$=>{const j=$.target.files;j&&A(j,l,"folder")},D.click()},disabled:H!==null,children:H==="folder"?c.jsxs(c.Fragment,{children:[c.jsx(Te,{className:"h-4 w-4 animate-spin mr-2 s3-explr-loader"}),"Uploading..."]}):c.jsxs(c.Fragment,{children:[c.jsx(Kr,{className:"h-4 w-4 s3-explr-folder-icon"}),"Upload Folder"]})})]}),c.jsx(on,{open:!!w,onOpenChange:D=>!D&&x(null),children:c.jsxs(Vt,{className:"s3-explr-dialog-content",children:[c.jsxs(Bt,{className:"s3-explr-dialog-header",children:[c.jsx(zt,{className:"s3-explr-dialog-title",children:"Confirm Deletion"}),c.jsxs(Qo,{className:"s3-explr-dialog-description",children:["Are you sure you want to delete ",w==null?void 0:w.name,"? This action cannot be undone."]})]}),c.jsxs(cr,{className:"s3-explr-dialog-footer",children:[c.jsx(de,{variant:"outline",onClick:()=>x(null),className:"s3-explr-cancel-btn",children:"Cancel"}),c.jsx(de,{variant:"destructive",onClick:()=>_(w),disabled:N,className:"s3-explr-confirm-delete-btn",children:N?c.jsxs(c.Fragment,{children:[c.jsx(Te,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Deleting..."]}):"Delete"})]})]})}),c.jsx(on,{open:!!I,onOpenChange:D=>{D||(R(null),B(""),Se(""),Ke("rename"))},children:c.jsxs(Vt,{className:"s3-explr-dialog-content max-w-2xl",children:[c.jsx(Bt,{className:"s3-explr-dialog-header",children:c.jsx(zt,{className:"s3-explr-dialog-title",children:I!=null&&I.isFolder?"Rename Folder":Nr(I)?"Manage File":"Rename File"})}),I&&!I.isFolder&&Nr(I)?c.jsxs(uv,{value:Ft,onValueChange:D=>Ke(D),children:[c.jsxs(hc,{className:"grid w-full grid-cols-2",children:[c.jsx(fs,{value:"rename",children:"Rename"}),c.jsx(fs,{value:"edit",children:"Edit Content"})]}),c.jsx(ps,{value:"rename",children:c.jsx("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:c.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[c.jsx(Ht,{htmlFor:"newName",className:"s3-explr-label",children:"New Name"}),c.jsx(Et,{id:"newName",value:G,onChange:D=>B(D.target.value),placeholder:"Enter new name",disabled:K,className:"s3-explr-input"})]})})}),c.jsx(ps,{value:"edit",children:c.jsx("div",{className:"space-y-4 py-4",children:ae?c.jsx("div",{className:"flex items-center justify-center py-4",children:c.jsx(Te,{className:"h-6 w-6 animate-spin"})}):c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ht,{htmlFor:"content",className:"s3-explr-label",children:"File Content"}),c.jsx(vr,{id:"content",value:ue,onChange:D=>Se(D.target.value),placeholder:"Enter file content",className:"min-h-[200px] font-mono",disabled:Gt})]})})})]}):c.jsx("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:c.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[c.jsx(Ht,{htmlFor:"newName",className:"s3-explr-label",children:"New Name"}),c.jsx(Et,{id:"newName",value:G,onChange:D=>B(D.target.value),placeholder:"Enter new name",disabled:K,className:"s3-explr-input"})]})}),c.jsxs(cr,{className:"s3-explr-dialog-footer",children:[c.jsx(de,{variant:"outline",onClick:()=>{R(null),B(""),Se("")},className:"s3-explr-cancel-btn",children:"Cancel"}),Ft==="edit"?c.jsx(de,{onClick:()=>I&&Mn(I,ue),disabled:Gt||ae,className:"s3-explr-save-btn",children:Gt?c.jsxs(c.Fragment,{children:[c.jsx(Te,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Saving..."]}):"Save Changes"}):c.jsx(de,{onClick:()=>{G.trim()&&I&&k(I,G.trim())},disabled:K||!G.trim()||G.trim()===(I==null?void 0:I.name),className:"s3-explr-rename-btn",children:K?c.jsxs(c.Fragment,{children:[c.jsx(Te,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Renaming..."]}):"Rename"})]})]})})]})]}),Wt&&c.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative s3-explr-error",children:"An error occurred while fetching files"}),c.jsx("div",{className:"rounded-md border s3-explr-table-container",children:c.jsxs(ur,{className:"s3-explr-table",children:[c.jsx(dr,{className:"s3-explr-table-header",children:Ye.getHeaderGroups().map(D=>c.jsx(je,{className:"hover:bg-transparent s3-explr-header-row",children:D.headers.map($=>c.jsx(et,{className:"s3-explr-header-cell",children:$.isPlaceholder?null:Bn($.column.columnDef.header,$.getContext())},$.id))},D.id))}),c.jsx(fr,{className:"s3-explr-table-body",children:Ye.getRowModel().rows.length===0?c.jsx(je,{className:"s3-explr-empty-row",children:c.jsx(_e,{colSpan:he.length,className:"h-24 text-center s3-explr-empty-cell",children:s?c.jsxs("div",{className:"text-gray-500 s3-explr-no-results",children:['No files or folders found matching "',s,'"']}):c.jsx("div",{className:"text-gray-500 s3-explr-empty-message",children:Ot?"Retrieving folder contents... Please wait":"This folder contains no files or subdirectories"})})}):Ye.getRowModel().rows.map(D=>c.jsx(je,{className:"h-12 s3-explr-row",children:D.getVisibleCells().map($=>c.jsx(_e,{className:"align-middle s3-explr-cell",children:Bn($.column.columnDef.cell,$.getContext())},$.id))},D.id))})]})}),r&&o&&c.jsxs("div",{className:"flex justify-between items-center mt-4 s3-explr-selector-footer",children:[c.jsxs("div",{className:"text-sm text-gray-500 s3-explr-selection-count",children:[a.size," ",a.size===1?"file":"files"," selected"]}),c.jsx(de,{variant:"default",onClick:()=>o(ve()),disabled:a.size===0,className:"s3-explr-ok-btn",children:"OK"})]}),!r&&c.jsx(Hc,{})]})});var Sn=e=>e.type==="checkbox",Ut=e=>e instanceof Date,Pe=e=>e==null;const nu=e=>typeof e=="object";var ge=e=>!Pe(e)&&!Array.isArray(e)&&nu(e)&&!Ut(e),sw=e=>ge(e)&&e.target?Sn(e.target)?e.target.checked:e.target.value:e,iw=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,aw=(e,t)=>e.has(iw(t)),lw=e=>{const t=e.constructor&&e.constructor.prototype;return ge(t)&&t.hasOwnProperty("isPrototypeOf")},Ts=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Le(e){let t;const n=Array.isArray(e),r=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(Ts&&(e instanceof Blob||r))&&(n||ge(e)))if(t=n?[]:{},!n&&!lw(e))t=e;else for(const o in e)e.hasOwnProperty(o)&&(t[o]=Le(e[o]));else return e;return t}var Pr=e=>Array.isArray(e)?e.filter(Boolean):[],fe=e=>e===void 0,z=(e,t,n)=>{if(!t||!ge(e))return n;const r=Pr(t.split(/[,[\].]+?/)).reduce((o,s)=>Pe(o)?o:o[s],e);return fe(r)||r===e?fe(e[t])?n:e[t]:r},nt=e=>typeof e=="boolean",_s=e=>/^\w*$/.test(e),ru=e=>Pr(e.replace(/["|']|\]/g,"").split(/\.|\[/)),ce=(e,t,n)=>{let r=-1;const o=_s(t)?[t]:ru(t),s=o.length,i=s-1;for(;++r<s;){const a=o[r];let u=n;if(r!==i){const l=e[a];u=ge(l)||Array.isArray(l)?l:isNaN(+o[r+1])?{}:[]}if(a==="__proto__"||a==="constructor"||a==="prototype")return;e[a]=u,e=e[a]}return e};const ou={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Ge={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ft={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};O.createContext(null);var cw=(e,t,n,r=!0)=>{const o={defaultValues:t._defaultValues};for(const s in e)Object.defineProperty(o,s,{get:()=>{const i=s;return t._proxyFormState[i]!==Ge.all&&(t._proxyFormState[i]=!r||Ge.all),e[i]}});return o},Fe=e=>ge(e)&&!Object.keys(e).length,uw=(e,t,n,r)=>{n(e);const{name:o,...s}=e;return Fe(s)||Object.keys(s).length>=Object.keys(t).length||Object.keys(s).find(i=>t[i]===Ge.all)},Ar=e=>Array.isArray(e)?e:[e];function dw(e){const t=O.useRef(e);t.current=e,O.useEffect(()=>{const n=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{n&&n.unsubscribe()}},[e.disabled])}var rt=e=>typeof e=="string",fw=(e,t,n,r,o)=>rt(e)?(r&&t.watch.add(e),z(n,e,o)):Array.isArray(e)?e.map(s=>(r&&t.watch.add(s),z(n,s))):(r&&(t.watchAll=!0),n),pw=(e,t,n,r,o)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:o||!0}}:{},su=e=>({isOnSubmit:!e||e===Ge.onSubmit,isOnBlur:e===Ge.onBlur,isOnChange:e===Ge.onChange,isOnAll:e===Ge.all,isOnTouch:e===Ge.onTouched}),iu=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const En=(e,t,n,r)=>{for(const o of n||Object.keys(e)){const s=z(e,o);if(s){const{_f:i,...a}=s;if(i){if(i.refs&&i.refs[0]&&t(i.refs[0],o)&&!r)return!0;if(i.ref&&t(i.ref,i.name)&&!r)return!0;if(En(a,t))break}else if(ge(a)&&En(a,t))break}}};var gw=(e,t,n)=>{const r=Ar(z(e,n));return ce(r,"root",t[n]),ce(e,n,r),e},Fs=e=>e.type==="file",ot=e=>typeof e=="function",Tr=e=>{if(!Ts)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},_r=e=>rt(e),Os=e=>e.type==="radio",Fr=e=>e instanceof RegExp;const au={value:!1,isValid:!1},lu={value:!0,isValid:!0};var cu=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!fe(e[0].attributes.value)?fe(e[0].value)||e[0].value===""?lu:{value:e[0].value,isValid:!0}:lu:au}return au};const uu={isValid:!1,value:null};var du=e=>Array.isArray(e)?e.reduce((t,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:t,uu):uu;function fu(e,t,n="validate"){if(_r(e)||Array.isArray(e)&&e.every(_r)||nt(e)&&!e)return{type:n,message:_r(e)?e:"",ref:t}}var an=e=>ge(e)&&!Fr(e)?e:{value:e,message:""},pu=async(e,t,n,r,o)=>{const{ref:s,refs:i,required:a,maxLength:u,minLength:l,min:f,max:g,pattern:h,validate:p,name:v,valueAsNumber:m,mount:y,disabled:w}=e._f,x=z(t,v);if(!y||w)return{};const N=i?i[0]:s,P=F=>{r&&N.reportValidity&&(N.setCustomValidity(nt(F)?"":F||""),N.reportValidity())},b={},S=Os(s),E=Sn(s),M=S||E,H=(m||Fs(s))&&fe(s.value)&&fe(x)||Tr(s)&&s.value===""||x===""||Array.isArray(x)&&!x.length,U=pw.bind(null,v,n,b),Z=(F,I,R,G=ft.maxLength,B=ft.minLength)=>{const K=F?I:R;b[v]={type:F?G:B,message:K,ref:s,...U(F?G:B,K)}};if(o?!Array.isArray(x)||!x.length:a&&(!M&&(H||Pe(x))||nt(x)&&!x||E&&!cu(i).isValid||S&&!du(i).isValid)){const{value:F,message:I}=_r(a)?{value:!!a,message:a}:an(a);if(F&&(b[v]={type:ft.required,message:I,ref:N,...U(ft.required,I)},!n))return P(I),b}if(!H&&(!Pe(f)||!Pe(g))){let F,I;const R=an(g),G=an(f);if(!Pe(x)&&!isNaN(x)){const B=s.valueAsNumber||x&&+x;Pe(R.value)||(F=B>R.value),Pe(G.value)||(I=B<G.value)}else{const B=s.valueAsDate||new Date(x),K=ie=>new Date(new Date().toDateString()+" "+ie),q=s.type=="time",ee=s.type=="week";rt(R.value)&&x&&(F=q?K(x)>K(R.value):ee?x>R.value:B>new Date(R.value)),rt(G.value)&&x&&(I=q?K(x)<K(G.value):ee?x<G.value:B<new Date(G.value))}if((F||I)&&(Z(!!F,R.message,G.message,ft.max,ft.min),!n))return P(b[v].message),b}if((u||l)&&!H&&(rt(x)||o&&Array.isArray(x))){const F=an(u),I=an(l),R=!Pe(F.value)&&x.length>+F.value,G=!Pe(I.value)&&x.length<+I.value;if((R||G)&&(Z(R,F.message,I.message),!n))return P(b[v].message),b}if(h&&!H&&rt(x)){const{value:F,message:I}=an(h);if(Fr(F)&&!x.match(F)&&(b[v]={type:ft.pattern,message:I,ref:s,...U(ft.pattern,I)},!n))return P(I),b}if(p){if(ot(p)){const F=await p(x,t),I=fu(F,N);if(I&&(b[v]={...I,...U(ft.validate,I.message)},!n))return P(I.message),b}else if(ge(p)){let F={};for(const I in p){if(!Fe(F)&&!n)break;const R=fu(await p[I](x,t),N,I);R&&(F={...R,...U(I,R.message)},P(R.message),n&&(b[v]=F))}if(!Fe(F)&&(b[v]={ref:N,...F},!n))return b}}return P(!0),b};function hw(e,t){const n=t.slice(0,-1).length;let r=0;for(;r<n;)e=fe(e)?r++:e[t[r++]];return e}function mw(e){for(const t in e)if(e.hasOwnProperty(t)&&!fe(e[t]))return!1;return!0}function we(e,t){const n=Array.isArray(t)?t:_s(t)?[t]:ru(t),r=n.length===1?e:hw(e,n),o=n.length-1,s=n[o];return r&&delete r[s],o!==0&&(ge(r)&&Fe(r)||Array.isArray(r)&&mw(r))&&we(e,n.slice(0,-1)),e}var Rs=()=>{let e=[];return{get observers(){return e},next:o=>{for(const s of e)s.next&&s.next(o)},subscribe:o=>(e.push(o),{unsubscribe:()=>{e=e.filter(s=>s!==o)}}),unsubscribe:()=>{e=[]}}},Ds=e=>Pe(e)||!nu(e);function Nt(e,t){if(Ds(e)||Ds(t))return e===t;if(Ut(e)&&Ut(t))return e.getTime()===t.getTime();const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){const s=e[o];if(!r.includes(o))return!1;if(o!=="ref"){const i=t[o];if(Ut(s)&&Ut(i)||ge(s)&&ge(i)||Array.isArray(s)&&Array.isArray(i)?!Nt(s,i):s!==i)return!1}}return!0}var gu=e=>e.type==="select-multiple",vw=e=>Os(e)||Sn(e),Ms=e=>Tr(e)&&e.isConnected,hu=e=>{for(const t in e)if(ot(e[t]))return!0;return!1};function Or(e,t={}){const n=Array.isArray(e);if(ge(e)||n)for(const r in e)Array.isArray(e[r])||ge(e[r])&&!hu(e[r])?(t[r]=Array.isArray(e[r])?[]:{},Or(e[r],t[r])):Pe(e[r])||(t[r]=!0);return t}function mu(e,t,n){const r=Array.isArray(e);if(ge(e)||r)for(const o in e)Array.isArray(e[o])||ge(e[o])&&!hu(e[o])?fe(t)||Ds(n[o])?n[o]=Array.isArray(e[o])?Or(e[o],[]):{...Or(e[o])}:mu(e[o],Pe(t)?{}:t[o],n[o]):n[o]=!Nt(e[o],t[o]);return n}var Nn=(e,t)=>mu(e,t,Or(t)),vu=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>fe(e)?e:t?e===""?NaN:e&&+e:n&&rt(e)?new Date(e):r?r(e):e;function ks(e){const t=e.ref;if(!(e.refs?e.refs.every(n=>n.disabled):t.disabled))return Fs(t)?t.files:Os(t)?du(e.refs).value:gu(t)?[...t.selectedOptions].map(({value:n})=>n):Sn(t)?cu(e.refs).value:vu(fe(t.value)?e.ref.value:t.value,e)}var yw=(e,t,n,r)=>{const o={};for(const s of e){const i=z(t,s);i&&ce(o,s,i._f)}return{criteriaMode:n,names:[...e],fields:o,shouldUseNativeValidation:r}},Pn=e=>fe(e)?e:Fr(e)?e.source:ge(e)?Fr(e.value)?e.value.source:e.value:e;const yu="AsyncFunction";var ww=e=>!!e&&!!e.validate&&!!(ot(e.validate)&&e.validate.constructor.name===yu||ge(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===yu)),bw=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function wu(e,t,n){const r=z(e,n);if(r||_s(n))return{error:r,name:n};const o=n.split(".");for(;o.length;){const s=o.join("."),i=z(t,s),a=z(e,s);if(i&&!Array.isArray(i)&&n!==s)return{name:n};if(a&&a.type)return{name:s,error:a};o.pop()}return{name:n}}var xw=(e,t,n,r,o)=>o.isOnAll?!1:!n&&o.isOnTouch?!(t||e):(n?r.isOnBlur:o.isOnBlur)?!e:(n?r.isOnChange:o.isOnChange)?e:!0,Cw=(e,t)=>!Pr(z(e,t)).length&&we(e,t);const Sw={mode:Ge.onSubmit,reValidateMode:Ge.onChange,shouldFocusError:!0};function Ew(e={}){let t={...Sw,...e},n={submitCount:0,isDirty:!1,isLoading:ot(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},o=ge(t.defaultValues)||ge(t.values)?Le(t.defaultValues||t.values)||{}:{},s=t.shouldUnregister?{}:Le(o),i={action:!1,mount:!1,watch:!1},a={mount:new Set,unMount:new Set,array:new Set,watch:new Set},u,l=0;const f={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},g={values:Rs(),array:Rs(),state:Rs()},h=su(t.mode),p=su(t.reValidateMode),v=t.criteriaMode===Ge.all,m=C=>A=>{clearTimeout(l),l=setTimeout(C,A)},y=async C=>{if(!t.disabled&&(f.isValid||C)){const A=t.resolver?Fe((await M()).errors):await U(r,!0);A!==n.isValid&&g.state.next({isValid:A})}},w=(C,A)=>{!t.disabled&&(f.isValidating||f.validatingFields)&&((C||Array.from(a.mount)).forEach(_=>{_&&(A?ce(n.validatingFields,_,A):we(n.validatingFields,_))}),g.state.next({validatingFields:n.validatingFields,isValidating:!Fe(n.validatingFields)}))},x=(C,A=[],_,V,L=!0,k=!0)=>{if(V&&_&&!t.disabled){if(i.action=!0,k&&Array.isArray(z(r,C))){const W=_(z(r,C),V.argA,V.argB);L&&ce(r,C,W)}if(k&&Array.isArray(z(n.errors,C))){const W=_(z(n.errors,C),V.argA,V.argB);L&&ce(n.errors,C,W),Cw(n.errors,C)}if(f.touchedFields&&k&&Array.isArray(z(n.touchedFields,C))){const W=_(z(n.touchedFields,C),V.argA,V.argB);L&&ce(n.touchedFields,C,W)}f.dirtyFields&&(n.dirtyFields=Nn(o,s)),g.state.next({name:C,isDirty:F(C,A),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else ce(s,C,A)},N=(C,A)=>{ce(n.errors,C,A),g.state.next({errors:n.errors})},P=C=>{n.errors=C,g.state.next({errors:n.errors,isValid:!1})},b=(C,A,_,V)=>{const L=z(r,C);if(L){const k=z(s,C,fe(_)?z(o,C):_);fe(k)||V&&V.defaultChecked||A?ce(s,C,A?k:ks(L._f)):G(C,k),i.mount&&y()}},S=(C,A,_,V,L)=>{let k=!1,W=!1;const ne={name:C};if(!t.disabled){const ve=!!(z(r,C)&&z(r,C)._f&&z(r,C)._f.disabled);if(!_||V){f.isDirty&&(W=n.isDirty,n.isDirty=ne.isDirty=F(),k=W!==ne.isDirty);const he=ve||Nt(z(o,C),A);W=!!(!ve&&z(n.dirtyFields,C)),he||ve?we(n.dirtyFields,C):ce(n.dirtyFields,C,!0),ne.dirtyFields=n.dirtyFields,k=k||f.dirtyFields&&W!==!he}if(_){const he=z(n.touchedFields,C);he||(ce(n.touchedFields,C,_),ne.touchedFields=n.touchedFields,k=k||f.touchedFields&&he!==_)}k&&L&&g.state.next(ne)}return k?ne:{}},E=(C,A,_,V)=>{const L=z(n.errors,C),k=f.isValid&&nt(A)&&n.isValid!==A;if(t.delayError&&_?(u=m(()=>N(C,_)),u(t.delayError)):(clearTimeout(l),u=null,_?ce(n.errors,C,_):we(n.errors,C)),(_?!Nt(L,_):L)||!Fe(V)||k){const W={...V,...k&&nt(A)?{isValid:A}:{},errors:n.errors,name:C};n={...n,...W},g.state.next(W)}},M=async C=>{w(C,!0);const A=await t.resolver(s,t.context,yw(C||a.mount,r,t.criteriaMode,t.shouldUseNativeValidation));return w(C),A},H=async C=>{const{errors:A}=await M(C);if(C)for(const _ of C){const V=z(A,_);V?ce(n.errors,_,V):we(n.errors,_)}else n.errors=A;return A},U=async(C,A,_={valid:!0})=>{for(const V in C){const L=C[V];if(L){const{_f:k,...W}=L;if(k){const ne=a.array.has(k.name),ve=L._f&&ww(L._f);ve&&f.validatingFields&&w([V],!0);const he=await pu(L,s,v,t.shouldUseNativeValidation&&!A,ne);if(ve&&f.validatingFields&&w([V]),he[k.name]&&(_.valid=!1,A))break;!A&&(z(he,k.name)?ne?gw(n.errors,he,k.name):ce(n.errors,k.name,he[k.name]):we(n.errors,k.name))}!Fe(W)&&await U(W,A,_)}}return _.valid},Z=()=>{for(const C of a.unMount){const A=z(r,C);A&&(A._f.refs?A._f.refs.every(_=>!Ms(_)):!Ms(A._f.ref))&&_t(C)}a.unMount=new Set},F=(C,A)=>!t.disabled&&(C&&A&&ce(s,C,A),!Nt(ue(),o)),I=(C,A,_)=>fw(C,a,{...i.mount?s:fe(A)?o:rt(C)?{[C]:A}:A},_,A),R=C=>Pr(z(i.mount?s:o,C,t.shouldUnregister?z(o,C,[]):[])),G=(C,A,_={})=>{const V=z(r,C);let L=A;if(V){const k=V._f;k&&(!k.disabled&&ce(s,C,vu(A,k)),L=Tr(k.ref)&&Pe(A)?"":A,gu(k.ref)?[...k.ref.options].forEach(W=>W.selected=L.includes(W.value)):k.refs?Sn(k.ref)?k.refs.length>1?k.refs.forEach(W=>(!W.defaultChecked||!W.disabled)&&(W.checked=Array.isArray(L)?!!L.find(ne=>ne===W.value):L===W.value)):k.refs[0]&&(k.refs[0].checked=!!L):k.refs.forEach(W=>W.checked=W.value===L):Fs(k.ref)?k.ref.value="":(k.ref.value=L,k.ref.type||g.values.next({name:C,values:{...s}})))}(_.shouldDirty||_.shouldTouch)&&S(C,L,_.shouldTouch,_.shouldDirty,!0),_.shouldValidate&&ie(C)},B=(C,A,_)=>{for(const V in A){const L=A[V],k=`${C}.${V}`,W=z(r,k);(a.array.has(C)||ge(L)||W&&!W._f)&&!Ut(L)?B(k,L,_):G(k,L,_)}},K=(C,A,_={})=>{const V=z(r,C),L=a.array.has(C),k=Le(A);ce(s,C,k),L?(g.array.next({name:C,values:{...s}}),(f.isDirty||f.dirtyFields)&&_.shouldDirty&&g.state.next({name:C,dirtyFields:Nn(o,s),isDirty:F(C,k)})):V&&!V._f&&!Pe(k)?B(C,k,_):G(C,k,_),iu(C,a)&&g.state.next({...n}),g.values.next({name:i.mount?C:void 0,values:{...s}})},q=async C=>{i.mount=!0;const A=C.target;let _=A.name,V=!0;const L=z(r,_),k=()=>A.type?ks(L._f):sw(C),W=ne=>{V=Number.isNaN(ne)||Ut(ne)&&isNaN(ne.getTime())||Nt(ne,z(s,_,ne))};if(L){let ne,ve;const he=k(),Ye=C.type===ou.BLUR||C.type===ou.FOCUS_OUT,pi=!bw(L._f)&&!t.resolver&&!z(n.errors,_)&&!L._f.deps||xw(Ye,z(n.touchedFields,_),n.isSubmitted,p,h),Mn=iu(_,a,Ye);ce(s,_,he),Ye?(L._f.onBlur&&L._f.onBlur(C),u&&u(0)):L._f.onChange&&L._f.onChange(C);const D=S(_,he,Ye,!1),$=!Fe(D)||Mn;if(!Ye&&g.values.next({name:_,type:C.type,values:{...s}}),pi)return f.isValid&&(t.mode==="onBlur"?Ye&&y():y()),$&&g.state.next({name:_,...Mn?{}:D});if(!Ye&&Mn&&g.state.next({...n}),t.resolver){const{errors:j}=await M([_]);if(W(he),V){const re=wu(n.errors,r,_),se=wu(j,r,re.name||_);ne=se.error,_=se.name,ve=Fe(j)}}else w([_],!0),ne=(await pu(L,s,v,t.shouldUseNativeValidation))[_],w([_]),W(he),V&&(ne?ve=!1:f.isValid&&(ve=await U(r,!0)));V&&(L._f.deps&&ie(L._f.deps),E(_,ve,ne,D))}},ee=(C,A)=>{if(z(n.errors,A)&&C.focus)return C.focus(),1},ie=async(C,A={})=>{let _,V;const L=Ar(C);if(t.resolver){const k=await H(fe(C)?C:L);_=Fe(k),V=C?!L.some(W=>z(k,W)):_}else C?(V=(await Promise.all(L.map(async k=>{const W=z(r,k);return await U(W&&W._f?{[k]:W}:W)}))).every(Boolean),!(!V&&!n.isValid)&&y()):V=_=await U(r);return g.state.next({...!rt(C)||f.isValid&&_!==n.isValid?{}:{name:C},...t.resolver||!C?{isValid:_}:{},errors:n.errors}),A.shouldFocus&&!V&&En(r,ee,C?L:a.mount),V},ue=C=>{const A={...i.mount?s:o};return fe(C)?A:rt(C)?z(A,C):C.map(_=>z(A,_))},Se=(C,A)=>({invalid:!!z((A||n).errors,C),isDirty:!!z((A||n).dirtyFields,C),error:z((A||n).errors,C),isValidating:!!z(n.validatingFields,C),isTouched:!!z((A||n).touchedFields,C)}),ae=C=>{C&&Ar(C).forEach(A=>we(n.errors,A)),g.state.next({errors:C?n.errors:{}})},lt=(C,A,_)=>{const V=(z(r,C,{_f:{}})._f||{}).ref,L=z(n.errors,C)||{},{ref:k,message:W,type:ne,...ve}=L;ce(n.errors,C,{...ve,...A,ref:V}),g.state.next({name:C,errors:n.errors,isValid:!1}),_&&_.shouldFocus&&V&&V.focus&&V.focus()},Gt=(C,A)=>ot(C)?g.values.subscribe({next:_=>C(I(void 0,A),_)}):I(C,A,!0),_t=(C,A={})=>{for(const _ of C?Ar(C):a.mount)a.mount.delete(_),a.array.delete(_),A.keepValue||(we(r,_),we(s,_)),!A.keepError&&we(n.errors,_),!A.keepDirty&&we(n.dirtyFields,_),!A.keepTouched&&we(n.touchedFields,_),!A.keepIsValidating&&we(n.validatingFields,_),!t.shouldUnregister&&!A.keepDefaultValue&&we(o,_);g.values.next({values:{...s}}),g.state.next({...n,...A.keepDirty?{isDirty:F()}:{}}),!A.keepIsValid&&y()},Ft=({disabled:C,name:A,field:_,fields:V,value:L})=>{if(nt(C)&&i.mount||C){const k=C?void 0:fe(L)?ks(_?_._f:z(V,A)._f):L;(C||!C&&!fe(k))&&ce(s,A,k),S(A,k,!1,!1,!0)}},Ke=(C,A={})=>{let _=z(r,C);const V=nt(A.disabled)||nt(t.disabled);return ce(r,C,{..._||{},_f:{..._&&_._f?_._f:{ref:{name:C}},name:C,mount:!0,...A}}),a.mount.add(C),_?Ft({field:_,disabled:nt(A.disabled)?A.disabled:t.disabled,name:C,value:A.value}):b(C,!0,A.value),{...V?{disabled:A.disabled||t.disabled}:{},...t.progressive?{required:!!A.required,min:Pn(A.min),max:Pn(A.max),minLength:Pn(A.minLength),maxLength:Pn(A.maxLength),pattern:Pn(A.pattern)}:{},name:C,onChange:q,onBlur:q,ref:L=>{if(L){Ke(C,A),_=z(r,C);const k=fe(L.value)&&L.querySelectorAll&&L.querySelectorAll("input,select,textarea")[0]||L,W=vw(k),ne=_._f.refs||[];if(W?ne.find(ve=>ve===k):k===_._f.ref)return;ce(r,C,{_f:{..._._f,...W?{refs:[...ne.filter(Ms),k,...Array.isArray(z(o,C))?[{}]:[]],ref:{type:k.type,name:C}}:{ref:k}}}),b(C,!1,void 0,k)}else _=z(r,C,{}),_._f&&(_._f.mount=!1),(t.shouldUnregister||A.shouldUnregister)&&!(aw(a.array,C)&&i.action)&&a.unMount.add(C)}}},be=()=>t.shouldFocusError&&En(r,ee,a.mount),Ot=C=>{nt(C)&&(g.state.next({disabled:C}),En(r,(A,_)=>{const V=z(r,_);V&&(A.disabled=V._f.disabled||C,Array.isArray(V._f.refs)&&V._f.refs.forEach(L=>{L.disabled=V._f.disabled||C}))},0,!1))},Wt=(C,A)=>async _=>{let V;if(_&&(_.preventDefault&&_.preventDefault(),_.persist&&_.persist()),t.disabled){A&&await A({...n.errors},_);return}let L=Le(s);if(g.state.next({isSubmitting:!0}),t.resolver){const{errors:k,values:W}=await M();n.errors=k,L=W}else await U(r);if(we(n.errors,"root"),Fe(n.errors)){g.state.next({errors:{}});try{await C(L,_)}catch(k){V=k}}else A&&await A({...n.errors},_),be(),setTimeout(be);if(g.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Fe(n.errors)&&!V,submitCount:n.submitCount+1,errors:n.errors}),V)throw V},Ve=(C,A={})=>{z(r,C)&&(fe(A.defaultValue)?K(C,Le(z(o,C))):(K(C,A.defaultValue),ce(o,C,Le(A.defaultValue))),A.keepTouched||we(n.touchedFields,C),A.keepDirty||(we(n.dirtyFields,C),n.isDirty=A.defaultValue?F(C,Le(z(o,C))):F()),A.keepError||(we(n.errors,C),f.isValid&&y()),g.state.next({...n}))},Xe=(C,A={})=>{const _=C?Le(C):o,V=Le(_),L=Fe(C),k=L?o:V;if(A.keepDefaultValues||(o=_),!A.keepValues){if(A.keepDirtyValues){const W=new Set([...a.mount,...Object.keys(Nn(o,s))]);for(const ne of Array.from(W))z(n.dirtyFields,ne)?ce(k,ne,z(s,ne)):K(ne,z(k,ne))}else{if(Ts&&fe(C))for(const W of a.mount){const ne=z(r,W);if(ne&&ne._f){const ve=Array.isArray(ne._f.refs)?ne._f.refs[0]:ne._f.ref;if(Tr(ve)){const he=ve.closest("form");if(he){he.reset();break}}}}r={}}s=t.shouldUnregister?A.keepDefaultValues?Le(o):{}:Le(k),g.array.next({values:{...k}}),g.values.next({values:{...k}})}a={mount:A.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},i.mount=!f.isValid||!!A.keepIsValid||!!A.keepDirtyValues,i.watch=!!t.shouldUnregister,g.state.next({submitCount:A.keepSubmitCount?n.submitCount:0,isDirty:L?!1:A.keepDirty?n.isDirty:!!(A.keepDefaultValues&&!Nt(C,o)),isSubmitted:A.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:L?{}:A.keepDirtyValues?A.keepDefaultValues&&s?Nn(o,s):n.dirtyFields:A.keepDefaultValues&&C?Nn(o,C):A.keepDirty?n.dirtyFields:{},touchedFields:A.keepTouched?n.touchedFields:{},errors:A.keepErrors?n.errors:{},isSubmitSuccessful:A.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},Ie=(C,A)=>Xe(ot(C)?C(s):C,A);return{control:{register:Ke,unregister:_t,getFieldState:Se,handleSubmit:Wt,setError:lt,_executeSchema:M,_getWatch:I,_getDirty:F,_updateValid:y,_removeUnmounted:Z,_updateFieldArray:x,_updateDisabledField:Ft,_getFieldArray:R,_reset:Xe,_resetDefaultValues:()=>ot(t.defaultValues)&&t.defaultValues().then(C=>{Ie(C,t.resetOptions),g.state.next({isLoading:!1})}),_updateFormState:C=>{n={...n,...C}},_disableForm:Ot,_subjects:g,_proxyFormState:f,_setErrors:P,get _fields(){return r},get _formValues(){return s},get _state(){return i},set _state(C){i=C},get _defaultValues(){return o},get _names(){return a},set _names(C){a=C},get _formState(){return n},set _formState(C){n=C},get _options(){return t},set _options(C){t={...t,...C}}},trigger:ie,register:Ke,handleSubmit:Wt,watch:Gt,setValue:K,getValues:ue,reset:Ie,resetField:Ve,clearErrors:ae,unregister:_t,setError:lt,setFocus:(C,A={})=>{const _=z(r,C),V=_&&_._f;if(V){const L=V.refs?V.refs[0]:V.ref;L.focus&&(L.focus(),A.shouldSelect&&ot(L.select)&&L.select())}},getFieldState:Se}}function Nw(e={}){const t=O.useRef(),n=O.useRef(),[r,o]=O.useState({isDirty:!1,isValidating:!1,isLoading:ot(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:ot(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...Ew(e),formState:r});const s=t.current.control;return s._options=e,dw({subject:s._subjects.state,next:i=>{uw(i,s._proxyFormState,s._updateFormState)&&o({...s._formState})}}),O.useEffect(()=>s._disableForm(e.disabled),[s,e.disabled]),O.useEffect(()=>{if(s._proxyFormState.isDirty){const i=s._getDirty();i!==r.isDirty&&s._subjects.state.next({isDirty:i})}},[s,r.isDirty]),O.useEffect(()=>{e.values&&!Nt(e.values,n.current)?(s._reset(e.values,s._options.resetOptions),n.current=e.values,o(i=>({...i}))):s._resetDefaultValues()},[e.values,s]),O.useEffect(()=>{e.errors&&s._setErrors(e.errors)},[e.errors,s]),O.useEffect(()=>{s._state.mount||(s._updateValid(),s._state.mount=!0),s._state.watch&&(s._state.watch=!1,s._subjects.state.next({...s._formState})),s._removeUnmounted()}),O.useEffect(()=>{e.shouldUnregister&&s._subjects.values.next({values:s._getWatch()})},[e.shouldUnregister,s]),O.useMemo(()=>({...t.current,formState:cw(r,s)}),[r,s])}function pt(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function bu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Pw(...e){return t=>{let n=!1;const r=e.map(o=>{const s=bu(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():bu(e[o],null)}}}}function An(...e){return d.useCallback(Pw(...e),e)}var Aw=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Tn=Aw.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?It:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function Tw(e,t){e&&kn.flushSync(()=>e.dispatchEvent(t))}var _w="DismissableLayer",Is="dismissableLayer.update",Fw="dismissableLayer.pointerDownOutside",Ow="dismissableLayer.focusOutside",xu,Cu=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Su=d.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...u}=e,l=d.useContext(Cu),[f,g]=d.useState(null),h=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=d.useState({}),v=An(t,E=>g(E)),m=Array.from(l.layers),[y]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),w=m.indexOf(y),x=f?m.indexOf(f):-1,N=l.layersWithOutsidePointerEventsDisabled.size>0,P=x>=w,b=Mw(E=>{const M=E.target,H=[...l.branches].some(U=>U.contains(M));!P||H||(o==null||o(E),i==null||i(E),E.defaultPrevented||a==null||a())},h),S=kw(E=>{const M=E.target;[...l.branches].some(U=>U.contains(M))||(s==null||s(E),i==null||i(E),E.defaultPrevented||a==null||a())},h);return Ua(E=>{x===l.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&a&&(E.preventDefault(),a()))},h),d.useEffect(()=>{if(f)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(xu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(f)),l.layers.add(f),Eu(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=xu)}},[f,h,n,l]),d.useEffect(()=>()=>{f&&(l.layers.delete(f),l.layersWithOutsidePointerEventsDisabled.delete(f),Eu())},[f,l]),d.useEffect(()=>{const E=()=>p({});return document.addEventListener(Is,E),()=>document.removeEventListener(Is,E)},[]),c.jsx(Tn.div,{...u,ref:v,style:{pointerEvents:N?P?"auto":"none":void 0,...e.style},onFocusCapture:pt(e.onFocusCapture,S.onFocusCapture),onBlurCapture:pt(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:pt(e.onPointerDownCapture,b.onPointerDownCapture)})});Su.displayName=_w;var Rw="DismissableLayerBranch",Dw=d.forwardRef((e,t)=>{const n=d.useContext(Cu),r=d.useRef(null),o=An(t,r);return d.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),c.jsx(Tn.div,{...e,ref:o})});Dw.displayName=Rw;function Mw(e,t=globalThis==null?void 0:globalThis.document){const n=Ee(e),r=d.useRef(!1),o=d.useRef(()=>{});return d.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let u=function(){Nu(Fw,n,l,{discrete:!0})};const l={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=u,t.addEventListener("click",o.current,{once:!0})):u()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",s),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function kw(e,t=globalThis==null?void 0:globalThis.document){const n=Ee(e),r=d.useRef(!1);return d.useEffect(()=>{const o=s=>{s.target&&!r.current&&Nu(Ow,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Eu(){const e=new CustomEvent(Is);document.dispatchEvent(e)}function Nu(e,t,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?Tw(o,s):o.dispatchEvent(s)}const Iw=["top","right","bottom","left"],Pt=Math.min,Me=Math.max,Rr=Math.round,Dr=Math.floor,st=e=>({x:e,y:e}),$w={left:"right",right:"left",bottom:"top",top:"bottom"},Lw={start:"end",end:"start"};function $s(e,t,n){return Me(e,Pt(t,n))}function gt(e,t){return typeof e=="function"?e(t):e}function ht(e){return e.split("-")[0]}function ln(e){return e.split("-")[1]}function Ls(e){return e==="x"?"y":"x"}function Vs(e){return e==="y"?"height":"width"}function At(e){return["top","bottom"].includes(ht(e))?"y":"x"}function Bs(e){return Ls(At(e))}function Vw(e,t,n){n===void 0&&(n=!1);const r=ln(e),o=Bs(e),s=Vs(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Mr(i)),[i,Mr(i)]}function Bw(e){const t=Mr(e);return[zs(e),t,zs(t)]}function zs(e){return e.replace(/start|end/g,t=>Lw[t])}function zw(e,t,n){const r=["left","right"],o=["right","left"],s=["top","bottom"],i=["bottom","top"];switch(e){case"top":case"bottom":return n?t?o:r:t?r:o;case"left":case"right":return t?s:i;default:return[]}}function Hw(e,t,n,r){const o=ln(e);let s=zw(ht(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(zs)))),s}function Mr(e){return e.replace(/left|right|bottom|top/g,t=>$w[t])}function Uw(e){return{top:0,right:0,bottom:0,left:0,...e}}function Pu(e){return typeof e!="number"?Uw(e):{top:e,right:e,bottom:e,left:e}}function kr(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Au(e,t,n){let{reference:r,floating:o}=e;const s=At(t),i=Bs(t),a=Vs(i),u=ht(t),l=s==="y",f=r.x+r.width/2-o.width/2,g=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(u){case"top":p={x:f,y:r.y-o.height};break;case"bottom":p={x:f,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:g};break;case"left":p={x:r.x-o.width,y:g};break;default:p={x:r.x,y:r.y}}switch(ln(t)){case"start":p[i]-=h*(n&&l?-1:1);break;case"end":p[i]+=h*(n&&l?-1:1);break}return p}const jw=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),u=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:g}=Au(l,r,u),h=r,p={},v=0;for(let m=0;m<a.length;m++){const{name:y,fn:w}=a[m],{x,y:N,data:P,reset:b}=await w({x:f,y:g,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:l,platform:i,elements:{reference:e,floating:t}});f=x??f,g=N??g,p={...p,[y]:{...p[y],...P}},b&&v<=50&&(v++,typeof b=="object"&&(b.placement&&(h=b.placement),b.rects&&(l=b.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):b.rects),{x:f,y:g}=Au(l,h,u)),m=-1)}return{x:f,y:g,placement:h,strategy:o,middlewareData:p}};async function _n(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:u}=e,{boundary:l="clippingAncestors",rootBoundary:f="viewport",elementContext:g="floating",altBoundary:h=!1,padding:p=0}=gt(t,e),v=Pu(p),y=a[h?g==="floating"?"reference":"floating":g],w=kr(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:l,rootBoundary:f,strategy:u})),x=g==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,N=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),P=await(s.isElement==null?void 0:s.isElement(N))?await(s.getScale==null?void 0:s.getScale(N))||{x:1,y:1}:{x:1,y:1},b=kr(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:x,offsetParent:N,strategy:u}):x);return{top:(w.top-b.top+v.top)/P.y,bottom:(b.bottom-w.bottom+v.bottom)/P.y,left:(w.left-b.left+v.left)/P.x,right:(b.right-w.right+v.right)/P.x}}const Gw=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:u}=t,{element:l,padding:f=0}=gt(e,t)||{};if(l==null)return{};const g=Pu(f),h={x:n,y:r},p=Bs(o),v=Vs(p),m=await i.getDimensions(l),y=p==="y",w=y?"top":"left",x=y?"bottom":"right",N=y?"clientHeight":"clientWidth",P=s.reference[v]+s.reference[p]-h[p]-s.floating[v],b=h[p]-s.reference[p],S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l));let E=S?S[N]:0;(!E||!await(i.isElement==null?void 0:i.isElement(S)))&&(E=a.floating[N]||s.floating[v]);const M=P/2-b/2,H=E/2-m[v]/2-1,U=Pt(g[w],H),Z=Pt(g[x],H),F=U,I=E-m[v]-Z,R=E/2-m[v]/2+M,G=$s(F,R,I),B=!u.arrow&&ln(o)!=null&&R!==G&&s.reference[v]/2-(R<F?U:Z)-m[v]/2<0,K=B?R<F?R-F:R-I:0;return{[p]:h[p]+K,data:{[p]:G,centerOffset:R-G-K,...B&&{alignmentOffset:K}},reset:B}}}),Ww=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:u,elements:l}=t,{mainAxis:f=!0,crossAxis:g=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:m=!0,...y}=gt(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=ht(o),x=At(a),N=ht(a)===a,P=await(u.isRTL==null?void 0:u.isRTL(l.floating)),b=h||(N||!m?[Mr(a)]:Bw(a)),S=v!=="none";!h&&S&&b.push(...Hw(a,m,v,P));const E=[a,...b],M=await _n(t,y),H=[];let U=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&H.push(M[w]),g){const R=Vw(o,i,P);H.push(M[R[0]],M[R[1]])}if(U=[...U,{placement:o,overflows:H}],!H.every(R=>R<=0)){var Z,F;const R=(((Z=s.flip)==null?void 0:Z.index)||0)+1,G=E[R];if(G)return{data:{index:R,overflows:U},reset:{placement:G}};let B=(F=U.filter(K=>K.overflows[0]<=0).sort((K,q)=>K.overflows[1]-q.overflows[1])[0])==null?void 0:F.placement;if(!B)switch(p){case"bestFit":{var I;const K=(I=U.filter(q=>{if(S){const ee=At(q.placement);return ee===x||ee==="y"}return!0}).map(q=>[q.placement,q.overflows.filter(ee=>ee>0).reduce((ee,ie)=>ee+ie,0)]).sort((q,ee)=>q[1]-ee[1])[0])==null?void 0:I[0];K&&(B=K);break}case"initialPlacement":B=a;break}if(o!==B)return{reset:{placement:B}}}return{}}}};function Tu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function _u(e){return Iw.some(t=>e[t]>=0)}const qw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=gt(e,t);switch(r){case"referenceHidden":{const s=await _n(t,{...o,elementContext:"reference"}),i=Tu(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:_u(i)}}}case"escaped":{const s=await _n(t,{...o,altBoundary:!0}),i=Tu(s,n.floating);return{data:{escapedOffsets:i,escaped:_u(i)}}}default:return{}}}}};async function Kw(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=ht(n),a=ln(n),u=At(n)==="y",l=["left","top"].includes(i)?-1:1,f=s&&u?-1:1,g=gt(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:v}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),u?{x:p*f,y:h*l}:{x:h*l,y:p*f}}const Xw=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,u=await Kw(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:s+u.y,data:{...u,placement:i}}}}},Yw=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:y=>{let{x:w,y:x}=y;return{x:w,y:x}}},...u}=gt(e,t),l={x:n,y:r},f=await _n(t,u),g=At(ht(o)),h=Ls(g);let p=l[h],v=l[g];if(s){const y=h==="y"?"top":"left",w=h==="y"?"bottom":"right",x=p+f[y],N=p-f[w];p=$s(x,p,N)}if(i){const y=g==="y"?"top":"left",w=g==="y"?"bottom":"right",x=v+f[y],N=v-f[w];v=$s(x,v,N)}const m=a.fn({...t,[h]:p,[g]:v});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[h]:s,[g]:i}}}}}},Jw=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:u=!0,crossAxis:l=!0}=gt(e,t),f={x:n,y:r},g=At(o),h=Ls(g);let p=f[h],v=f[g];const m=gt(a,t),y=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(u){const N=h==="y"?"height":"width",P=s.reference[h]-s.floating[N]+y.mainAxis,b=s.reference[h]+s.reference[N]-y.mainAxis;p<P?p=P:p>b&&(p=b)}if(l){var w,x;const N=h==="y"?"width":"height",P=["top","left"].includes(ht(o)),b=s.reference[g]-s.floating[N]+(P&&((w=i.offset)==null?void 0:w[g])||0)+(P?0:y.crossAxis),S=s.reference[g]+s.reference[N]+(P?0:((x=i.offset)==null?void 0:x[g])||0)-(P?y.crossAxis:0);v<b?v=b:v>S&&(v=S)}return{[h]:p,[g]:v}}}},Zw=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:u=()=>{},...l}=gt(e,t),f=await _n(t,l),g=ht(o),h=ln(o),p=At(o)==="y",{width:v,height:m}=s.floating;let y,w;g==="top"||g==="bottom"?(y=g,w=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(w=g,y=h==="end"?"top":"bottom");const x=m-f.top-f.bottom,N=v-f.left-f.right,P=Pt(m-f[y],x),b=Pt(v-f[w],N),S=!t.middlewareData.shift;let E=P,M=b;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(M=N),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=x),S&&!h){const U=Me(f.left,0),Z=Me(f.right,0),F=Me(f.top,0),I=Me(f.bottom,0);p?M=v-2*(U!==0||Z!==0?U+Z:Me(f.left,f.right)):E=m-2*(F!==0||I!==0?F+I:Me(f.top,f.bottom))}await u({...t,availableWidth:M,availableHeight:E});const H=await i.getDimensions(a.floating);return v!==H.width||m!==H.height?{reset:{rects:!0}}:{}}}};function Ir(){return typeof window<"u"}function cn(e){return Fu(e)?(e.nodeName||"").toLowerCase():"#document"}function ke(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function it(e){var t;return(t=(Fu(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Fu(e){return Ir()?e instanceof Node||e instanceof ke(e).Node:!1}function We(e){return Ir()?e instanceof Element||e instanceof ke(e).Element:!1}function at(e){return Ir()?e instanceof HTMLElement||e instanceof ke(e).HTMLElement:!1}function Ou(e){return!Ir()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ke(e).ShadowRoot}function Fn(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=qe(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!["inline","contents"].includes(o)}function Qw(e){return["table","td","th"].includes(cn(e))}function $r(e){return[":popover-open",":modal"].some(t=>{try{return e.matches(t)}catch{return!1}})}function Hs(e){const t=Us(),n=We(e)?qe(e):e;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function eb(e){let t=Tt(e);for(;at(t)&&!un(t);){if(Hs(t))return t;if($r(t))return null;t=Tt(t)}return null}function Us(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function un(e){return["html","body","#document"].includes(cn(e))}function qe(e){return ke(e).getComputedStyle(e)}function Lr(e){return We(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Tt(e){if(cn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ou(e)&&e.host||it(e);return Ou(t)?t.host:t}function Ru(e){const t=Tt(e);return un(t)?e.ownerDocument?e.ownerDocument.body:e.body:at(t)&&Fn(t)?t:Ru(t)}function On(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Ru(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=ke(o);if(s){const a=js(i);return t.concat(i,i.visualViewport||[],Fn(o)?o:[],a&&n?On(a):[])}return t.concat(o,On(o,[],n))}function js(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Du(e){const t=qe(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=at(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Rr(n)!==s||Rr(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Gs(e){return We(e)?e:e.contextElement}function dn(e){const t=Gs(e);if(!at(t))return st(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=Du(t);let i=(s?Rr(n.width):n.width)/r,a=(s?Rr(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const tb=st(0);function Mu(e){const t=ke(e);return!Us()||!t.visualViewport?tb:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function nb(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ke(e)?!1:t}function jt(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Gs(e);let i=st(1);t&&(r?We(r)&&(i=dn(r)):i=dn(e));const a=nb(s,n,r)?Mu(s):st(0);let u=(o.left+a.x)/i.x,l=(o.top+a.y)/i.y,f=o.width/i.x,g=o.height/i.y;if(s){const h=ke(s),p=r&&We(r)?ke(r):r;let v=h,m=js(v);for(;m&&r&&p!==v;){const y=dn(m),w=m.getBoundingClientRect(),x=qe(m),N=w.left+(m.clientLeft+parseFloat(x.paddingLeft))*y.x,P=w.top+(m.clientTop+parseFloat(x.paddingTop))*y.y;u*=y.x,l*=y.y,f*=y.x,g*=y.y,u+=N,l+=P,v=ke(m),m=js(v)}}return kr({width:f,height:g,x:u,y:l})}function Ws(e,t){const n=Lr(e).scrollLeft;return t?t.left+n:jt(it(e)).left+n}function ku(e,t,n){n===void 0&&(n=!1);const r=e.getBoundingClientRect(),o=r.left+t.scrollLeft-(n?0:Ws(e,r)),s=r.top+t.scrollTop;return{x:o,y:s}}function rb(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=it(r),a=t?$r(t.floating):!1;if(r===i||a&&s)return n;let u={scrollLeft:0,scrollTop:0},l=st(1);const f=st(0),g=at(r);if((g||!g&&!s)&&((cn(r)!=="body"||Fn(i))&&(u=Lr(r)),at(r))){const p=jt(r);l=dn(r),f.x=p.x+r.clientLeft,f.y=p.y+r.clientTop}const h=i&&!g&&!s?ku(i,u,!0):st(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-u.scrollLeft*l.x+f.x+h.x,y:n.y*l.y-u.scrollTop*l.y+f.y+h.y}}function ob(e){return Array.from(e.getClientRects())}function sb(e){const t=it(e),n=Lr(e),r=e.ownerDocument.body,o=Me(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Me(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Ws(e);const a=-n.scrollTop;return qe(r).direction==="rtl"&&(i+=Me(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}function ib(e,t){const n=ke(e),r=it(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,u=0;if(o){s=o.width,i=o.height;const l=Us();(!l||l&&t==="fixed")&&(a=o.offsetLeft,u=o.offsetTop)}return{width:s,height:i,x:a,y:u}}function ab(e,t){const n=jt(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=at(e)?dn(e):st(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,u=o*s.x,l=r*s.y;return{width:i,height:a,x:u,y:l}}function Iu(e,t,n){let r;if(t==="viewport")r=ib(e,n);else if(t==="document")r=sb(it(e));else if(We(t))r=ab(t,n);else{const o=Mu(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return kr(r)}function $u(e,t){const n=Tt(e);return n===t||!We(n)||un(n)?!1:qe(n).position==="fixed"||$u(n,t)}function lb(e,t){const n=t.get(e);if(n)return n;let r=On(e,[],!1).filter(a=>We(a)&&cn(a)!=="body"),o=null;const s=qe(e).position==="fixed";let i=s?Tt(e):e;for(;We(i)&&!un(i);){const a=qe(i),u=Hs(i);!u&&a.position==="fixed"&&(o=null),(s?!u&&!o:!u&&a.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||Fn(i)&&!u&&$u(e,i))?r=r.filter(f=>f!==i):o=a,i=Tt(i)}return t.set(e,r),r}function cb(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?$r(t)?[]:lb(t,this._c):[].concat(n),r],a=i[0],u=i.reduce((l,f)=>{const g=Iu(t,f,o);return l.top=Me(g.top,l.top),l.right=Pt(g.right,l.right),l.bottom=Pt(g.bottom,l.bottom),l.left=Me(g.left,l.left),l},Iu(t,a,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function ub(e){const{width:t,height:n}=Du(e);return{width:t,height:n}}function db(e,t,n){const r=at(t),o=it(t),s=n==="fixed",i=jt(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const u=st(0);if(r||!r&&!s)if((cn(t)!=="body"||Fn(o))&&(a=Lr(t)),r){const h=jt(t,!0,s,t);u.x=h.x+t.clientLeft,u.y=h.y+t.clientTop}else o&&(u.x=Ws(o));const l=o&&!r&&!s?ku(o,a):st(0),f=i.left+a.scrollLeft-u.x-l.x,g=i.top+a.scrollTop-u.y-l.y;return{x:f,y:g,width:i.width,height:i.height}}function qs(e){return qe(e).position==="static"}function Lu(e,t){if(!at(e)||qe(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return it(e)===n&&(n=n.ownerDocument.body),n}function Vu(e,t){const n=ke(e);if($r(e))return n;if(!at(e)){let o=Tt(e);for(;o&&!un(o);){if(We(o)&&!qs(o))return o;o=Tt(o)}return n}let r=Lu(e,t);for(;r&&Qw(r)&&qs(r);)r=Lu(r,t);return r&&un(r)&&qs(r)&&!Hs(r)?n:r||eb(e)||n}const fb=async function(e){const t=this.getOffsetParent||Vu,n=this.getDimensions,r=await n(e.floating);return{reference:db(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function pb(e){return qe(e).direction==="rtl"}const gb={convertOffsetParentRelativeRectToViewportRelativeRect:rb,getDocumentElement:it,getClippingRect:cb,getOffsetParent:Vu,getElementRects:fb,getClientRects:ob,getDimensions:ub,getScale:dn,isElement:We,isRTL:pb};function hb(e,t){let n=null,r;const o=it(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,u){a===void 0&&(a=!1),u===void 0&&(u=1),s();const{left:l,top:f,width:g,height:h}=e.getBoundingClientRect();if(a||t(),!g||!h)return;const p=Dr(f),v=Dr(o.clientWidth-(l+g)),m=Dr(o.clientHeight-(f+h)),y=Dr(l),x={rootMargin:-p+"px "+-v+"px "+-m+"px "+-y+"px",threshold:Me(0,Pt(1,u))||1};let N=!0;function P(b){const S=b[0].intersectionRatio;if(S!==u){if(!N)return i();S?i(!1,S):r=setTimeout(()=>{i(!1,1e-7)},1e3)}N=!1}try{n=new IntersectionObserver(P,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(P,x)}n.observe(e)}return i(!0),s}function mb(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,l=Gs(e),f=o||s?[...l?On(l):[],...On(t)]:[];f.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),s&&w.addEventListener("resize",n)});const g=l&&a?hb(l,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(w=>{let[x]=w;x&&x.target===l&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var N;(N=p)==null||N.observe(t)})),n()}),l&&!u&&p.observe(l),p.observe(t));let v,m=u?jt(e):null;u&&y();function y(){const w=jt(e);m&&(w.x!==m.x||w.y!==m.y||w.width!==m.width||w.height!==m.height)&&n(),m=w,v=requestAnimationFrame(y)}return n(),()=>{var w;f.forEach(x=>{o&&x.removeEventListener("scroll",n),s&&x.removeEventListener("resize",n)}),g==null||g(),(w=p)==null||w.disconnect(),p=null,u&&cancelAnimationFrame(v)}}const vb=Xw,yb=Yw,wb=Ww,bb=Zw,xb=qw,Bu=Gw,Cb=Jw,Sb=(e,t,n)=>{const r=new Map,o={platform:gb,...n},s={...o.platform,_c:r};return jw(e,t,{...o,platform:s})};var Vr=typeof document<"u"?O.useLayoutEffect:O.useEffect;function Br(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Br(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Br(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function zu(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Hu(e,t){const n=zu(e);return Math.round(t*n)/n}function Ks(e){const t=d.useRef(e);return Vr(()=>{t.current=e}),t}function Eb(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:u,open:l}=e,[f,g]=d.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=d.useState(r);Br(h,r)||p(r);const[v,m]=d.useState(null),[y,w]=d.useState(null),x=d.useCallback(q=>{q!==S.current&&(S.current=q,m(q))},[]),N=d.useCallback(q=>{q!==E.current&&(E.current=q,w(q))},[]),P=s||v,b=i||y,S=d.useRef(null),E=d.useRef(null),M=d.useRef(f),H=u!=null,U=Ks(u),Z=Ks(o),F=Ks(l),I=d.useCallback(()=>{if(!S.current||!E.current)return;const q={placement:t,strategy:n,middleware:h};Z.current&&(q.platform=Z.current),Sb(S.current,E.current,q).then(ee=>{const ie={...ee,isPositioned:F.current!==!1};R.current&&!Br(M.current,ie)&&(M.current=ie,kn.flushSync(()=>{g(ie)}))})},[h,t,n,Z,F]);Vr(()=>{l===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,g(q=>({...q,isPositioned:!1})))},[l]);const R=d.useRef(!1);Vr(()=>(R.current=!0,()=>{R.current=!1}),[]),Vr(()=>{if(P&&(S.current=P),b&&(E.current=b),P&&b){if(U.current)return U.current(P,b,I);I()}},[P,b,I,U,H]);const G=d.useMemo(()=>({reference:S,floating:E,setReference:x,setFloating:N}),[x,N]),B=d.useMemo(()=>({reference:P,floating:b}),[P,b]),K=d.useMemo(()=>{const q={position:n,left:0,top:0};if(!B.floating)return q;const ee=Hu(B.floating,f.x),ie=Hu(B.floating,f.y);return a?{...q,transform:"translate("+ee+"px, "+ie+"px)",...zu(B.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:ee,top:ie}},[n,a,B.floating,f.x,f.y]);return d.useMemo(()=>({...f,update:I,refs:G,elements:B,floatingStyles:K}),[f,I,G,B,K])}const Nb=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Bu({element:r.current,padding:o}).fn(n):{}:r?Bu({element:r,padding:o}).fn(n):{}}}},Pb=(e,t)=>({...vb(e),options:[e,t]}),Ab=(e,t)=>({...yb(e),options:[e,t]}),Tb=(e,t)=>({...Cb(e),options:[e,t]}),_b=(e,t)=>({...wb(e),options:[e,t]}),Fb=(e,t)=>({...bb(e),options:[e,t]}),Ob=(e,t)=>({...xb(e),options:[e,t]}),Rb=(e,t)=>({...Nb(e),options:[e,t]});var Db=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Mb=Db.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?It:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),kb="Arrow",Uu=d.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(Mb.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});Uu.displayName=kb;var Ib=Uu;function ju(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function $b(...e){return t=>{let n=!1;const r=e.map(o=>{const s=ju(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():ju(e[o],null)}}}}function Gu(...e){return d.useCallback($b(...e),e)}var Lb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Wu=Lb.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?It:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{}),Xs="Popper",[qu,Ku]=Ze(Xs),[Vb,Xu]=qu(Xs),Yu=e=>{const{__scopePopper:t,children:n}=e,[r,o]=d.useState(null);return c.jsx(Vb,{scope:t,anchor:r,onAnchorChange:o,children:n})};Yu.displayName=Xs;var Ju="PopperAnchor",Zu=d.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Xu(Ju,n),i=d.useRef(null),a=Gu(t,i);return d.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||i.current)}),r?null:c.jsx(Wu.div,{...o,ref:a})});Zu.displayName=Ju;var Ys="PopperContent",[Bb,zb]=qu(Ys),Qu=d.forwardRef((e,t)=>{var Ft,Ke,be,Ot,Wt,Ve;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:u=!0,collisionBoundary:l=[],collisionPadding:f=0,sticky:g="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:v,...m}=e,y=Xu(Ys,n),[w,x]=d.useState(null),N=Gu(t,Xe=>x(Xe)),[P,b]=d.useState(null),S=Do(P),E=(S==null?void 0:S.width)??0,M=(S==null?void 0:S.height)??0,H=r+(s!=="center"?"-"+s:""),U=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},Z=Array.isArray(l)?l:[l],F=Z.length>0,I={padding:U,boundary:Z.filter(Ub),altBoundary:F},{refs:R,floatingStyles:G,placement:B,isPositioned:K,middlewareData:q}=Eb({strategy:"fixed",placement:H,whileElementsMounted:(...Xe)=>mb(...Xe,{animationFrame:p==="always"}),elements:{reference:y.anchor},middleware:[Pb({mainAxis:o+M,alignmentAxis:i}),u&&Ab({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?Tb():void 0,...I}),u&&_b({...I}),Fb({...I,apply:({elements:Xe,rects:Ie,availableWidth:Rt,availableHeight:Wr})=>{const{width:qt,height:C}=Ie.reference,A=Xe.floating.style;A.setProperty("--radix-popper-available-width",`${Rt}px`),A.setProperty("--radix-popper-available-height",`${Wr}px`),A.setProperty("--radix-popper-anchor-width",`${qt}px`),A.setProperty("--radix-popper-anchor-height",`${C}px`)}}),P&&Rb({element:P,padding:a}),jb({arrowWidth:E,arrowHeight:M}),h&&Ob({strategy:"referenceHidden",...I})]}),[ee,ie]=nd(B),ue=Ee(v);Ne(()=>{K&&(ue==null||ue())},[K,ue]);const Se=(Ft=q.arrow)==null?void 0:Ft.x,ae=(Ke=q.arrow)==null?void 0:Ke.y,lt=((be=q.arrow)==null?void 0:be.centerOffset)!==0,[Gt,_t]=d.useState();return Ne(()=>{w&&_t(window.getComputedStyle(w).zIndex)},[w]),c.jsx("div",{ref:R.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:K?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Gt,"--radix-popper-transform-origin":[(Ot=q.transformOrigin)==null?void 0:Ot.x,(Wt=q.transformOrigin)==null?void 0:Wt.y].join(" "),...((Ve=q.hide)==null?void 0:Ve.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(Bb,{scope:n,placedSide:ee,onArrowChange:b,arrowX:Se,arrowY:ae,shouldHideArrow:lt,children:c.jsx(Wu.div,{"data-side":ee,"data-align":ie,...m,ref:N,style:{...m.style,animation:K?void 0:"none"}})})})});Qu.displayName=Ys;var ed="PopperArrow",Hb={top:"bottom",right:"left",bottom:"top",left:"right"},td=d.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=zb(ed,r),i=Hb[s.placedSide];return c.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:c.jsx(Ib,{...o,ref:n,style:{...o.style,display:"block"}})})});td.displayName=ed;function Ub(e){return e!==null}var jb=e=>({name:"transformOrigin",options:e,fn(t){var y,w,x;const{placement:n,rects:r,middlewareData:o}=t,i=((y=o.arrow)==null?void 0:y.centerOffset)!==0,a=i?0:e.arrowWidth,u=i?0:e.arrowHeight,[l,f]=nd(n),g={start:"0%",center:"50%",end:"100%"}[f],h=(((w=o.arrow)==null?void 0:w.x)??0)+a/2,p=(((x=o.arrow)==null?void 0:x.y)??0)+u/2;let v="",m="";return l==="bottom"?(v=i?g:`${h}px`,m=`${-u}px`):l==="top"?(v=i?g:`${h}px`,m=`${r.floating.height+u}px`):l==="right"?(v=`${-u}px`,m=i?g:`${p}px`):l==="left"&&(v=`${r.floating.width+u}px`,m=i?g:`${p}px`),{data:{x:v,y:m}}}});function nd(e){const[t,n="center"]=e.split("-");return[t,n]}var Gb=Yu,Wb=Zu,qb=Qu,Kb=td,Xb="Portal",rd=d.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[o,s]=d.useState(!1);Ne(()=>s(!0),[]);const i=n||o&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?qr.createPortal(c.jsx(Tn.div,{...r,ref:t}),i):null});rd.displayName=Xb;function Yb(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var Js=e=>{const{present:t,children:n}=e,r=Jb(t),o=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),s=An(r.ref,Zb(o));return typeof n=="function"||r.isPresent?d.cloneElement(o,{ref:s}):null};Js.displayName="Presence";function Jb(e){const[t,n]=d.useState(),r=d.useRef({}),o=d.useRef(e),s=d.useRef("none"),i=e?"mounted":"unmounted",[a,u]=Yb(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const l=zr(r.current);s.current=a==="mounted"?l:"none"},[a]),Ne(()=>{const l=r.current,f=o.current;if(f!==e){const h=s.current,p=zr(l);e?u("MOUNT"):p==="none"||(l==null?void 0:l.display)==="none"?u("UNMOUNT"):u(f&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,u]),Ne(()=>{if(t){let l;const f=t.ownerDocument.defaultView??window,g=p=>{const m=zr(r.current).includes(p.animationName);if(p.target===t&&m&&(u("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",l=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},h=p=>{p.target===t&&(s.current=zr(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{f.clearTimeout(l),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:d.useCallback(l=>{l&&(r.current=getComputedStyle(l)),n(l)},[])}}function zr(e){return(e==null?void 0:e.animationName)||"none"}function Zb(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Qb="VisuallyHidden",od=d.forwardRef((e,t)=>c.jsx(Tn.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));od.displayName=Qb;var ex=od,[Hr,lC]=Ze("Tooltip",[Ku]),Ur=Ku(),sd="TooltipProvider",tx=700,Zs="tooltip.open",[nx,Qs]=Hr(sd),id=e=>{const{__scopeTooltip:t,delayDuration:n=tx,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=e,[i,a]=d.useState(!0),u=d.useRef(!1),l=d.useRef(0);return d.useEffect(()=>{const f=l.current;return()=>window.clearTimeout(f)},[]),c.jsx(nx,{scope:t,isOpenDelayed:i,delayDuration:n,onOpen:d.useCallback(()=>{window.clearTimeout(l.current),a(!1)},[]),onClose:d.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>a(!0),r)},[r]),isPointerInTransitRef:u,onPointerInTransitChange:d.useCallback(f=>{u.current=f},[]),disableHoverableContent:o,children:s})};id.displayName=sd;var jr="Tooltip",[rx,Rn]=Hr(jr),ad=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o=!1,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=e,u=Qs(jr,e.__scopeTooltip),l=Ur(t),[f,g]=d.useState(null),h=Qt(),p=d.useRef(0),v=i??u.disableHoverableContent,m=a??u.delayDuration,y=d.useRef(!1),[w=!1,x]=$t({prop:r,defaultProp:o,onChange:E=>{E?(u.onOpen(),document.dispatchEvent(new CustomEvent(Zs))):u.onClose(),s==null||s(E)}}),N=d.useMemo(()=>w?y.current?"delayed-open":"instant-open":"closed",[w]),P=d.useCallback(()=>{window.clearTimeout(p.current),p.current=0,y.current=!1,x(!0)},[x]),b=d.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x(!1)},[x]),S=d.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{y.current=!0,x(!0),p.current=0},m)},[m,x]);return d.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),c.jsx(Gb,{...l,children:c.jsx(rx,{scope:t,contentId:h,open:w,stateAttribute:N,trigger:f,onTriggerChange:g,onTriggerEnter:d.useCallback(()=>{u.isOpenDelayed?S():P()},[u.isOpenDelayed,S,P]),onTriggerLeave:d.useCallback(()=>{v?b():(window.clearTimeout(p.current),p.current=0)},[b,v]),onOpen:P,onClose:b,disableHoverableContent:v,children:n})})};ad.displayName=jr;var ei="TooltipTrigger",ld=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Rn(ei,n),s=Qs(ei,n),i=Ur(n),a=d.useRef(null),u=An(t,a,o.onTriggerChange),l=d.useRef(!1),f=d.useRef(!1),g=d.useCallback(()=>l.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),c.jsx(Wb,{asChild:!0,...i,children:c.jsx(Tn.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:u,onPointerMove:pt(e.onPointerMove,h=>{h.pointerType!=="touch"&&!f.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:pt(e.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:pt(e.onPointerDown,()=>{l.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:pt(e.onFocus,()=>{l.current||o.onOpen()}),onBlur:pt(e.onBlur,o.onClose),onClick:pt(e.onClick,o.onClose)})})});ld.displayName=ei;var ti="TooltipPortal",[ox,sx]=Hr(ti,{forceMount:void 0}),cd=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,s=Rn(ti,t);return c.jsx(ox,{scope:t,forceMount:n,children:c.jsx(Js,{present:n||s.open,children:c.jsx(rd,{asChild:!0,container:o,children:r})})})};cd.displayName=ti;var fn="TooltipContent",ud=d.forwardRef((e,t)=>{const n=sx(fn,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=e,i=Rn(fn,e.__scopeTooltip);return c.jsx(Js,{present:r||i.open,children:i.disableHoverableContent?c.jsx(dd,{side:o,...s,ref:t}):c.jsx(ix,{side:o,...s,ref:t})})}),ix=d.forwardRef((e,t)=>{const n=Rn(fn,e.__scopeTooltip),r=Qs(fn,e.__scopeTooltip),o=d.useRef(null),s=An(t,o),[i,a]=d.useState(null),{trigger:u,onClose:l}=n,f=o.current,{onPointerInTransitChange:g}=r,h=d.useCallback(()=>{a(null),g(!1)},[g]),p=d.useCallback((v,m)=>{const y=v.currentTarget,w={x:v.clientX,y:v.clientY},x=ux(w,y.getBoundingClientRect()),N=dx(w,x),P=fx(m.getBoundingClientRect()),b=gx([...N,...P]);a(b),g(!0)},[g]);return d.useEffect(()=>()=>h(),[h]),d.useEffect(()=>{if(u&&f){const v=y=>p(y,f),m=y=>p(y,u);return u.addEventListener("pointerleave",v),f.addEventListener("pointerleave",m),()=>{u.removeEventListener("pointerleave",v),f.removeEventListener("pointerleave",m)}}},[u,f,p,h]),d.useEffect(()=>{if(i){const v=m=>{const y=m.target,w={x:m.clientX,y:m.clientY},x=(u==null?void 0:u.contains(y))||(f==null?void 0:f.contains(y)),N=!px(w,i);x?h():N&&(h(),l())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[u,f,i,l,h]),c.jsx(dd,{...e,ref:s})}),[ax,lx]=Hr(jr,{isInside:!1}),dd=d.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=e,u=Rn(fn,n),l=Ur(n),{onClose:f}=u;return d.useEffect(()=>(document.addEventListener(Zs,f),()=>document.removeEventListener(Zs,f)),[f]),d.useEffect(()=>{if(u.trigger){const g=h=>{const p=h.target;p!=null&&p.contains(u.trigger)&&f()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[u.trigger,f]),c.jsx(Su,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:g=>g.preventDefault(),onDismiss:f,children:c.jsxs(qb,{"data-state":u.stateAttribute,...l,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[c.jsx(wa,{children:r}),c.jsx(ax,{scope:n,isInside:!0,children:c.jsx(ex,{id:u.contentId,role:"tooltip",children:o||r})})]})})});ud.displayName=fn;var fd="TooltipArrow",cx=d.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=Ur(n);return lx(fd,n).isInside?null:c.jsx(Kb,{...o,...r,ref:t})});cx.displayName=fd;function ux(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function dx(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function fx(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function px(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s].x,u=t[s].y,l=t[i].x,f=t[i].y;u>r!=f>r&&n<(l-a)*(r-u)/(f-u)+a&&(o=!o)}return o}function gx(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),hx(t)}function hx(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const s=t[t.length-1],i=t[t.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var mx=id,vx=ad,yx=ld,wx=cd,pd=ud;const bx=mx,xx=vx,Cx=yx,gd=d.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(wx,{children:c.jsx(pd,{ref:r,sideOffset:t,className:J("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));gd.displayName=pd.displayName;const hd=({className:e,children:t,content:n,side:r})=>{const[o,s]=O.useState(!1);return c.jsx(bx,{delayDuration:0,children:c.jsxs(xx,{open:o,children:[c.jsx(Cx,{asChild:!0,children:c.jsx("button",{type:"button",className:J("cursor-pointer",e),onClick:()=>s(!o),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),onTouchStart:()=>s(!o),onKeyDown:i=>{i.preventDefault(),i.key==="Enter"&&s(!o)},children:t})}),c.jsx(gd,{side:r,className:n?"":"hidden",children:c.jsx("span",{className:"inline-block",children:n})})]})})},ni=({className:e,...t})=>c.jsx("nav",{role:"navigation","aria-label":"pagination",className:J("mx-auto flex w-full justify-center",e),...t});ni.displayName="Pagination";const ri=d.forwardRef(({className:e,...t},n)=>c.jsx("ul",{ref:n,className:J("flex flex-row items-center gap-1",e),...t}));ri.displayName="PaginationContent";const mt=d.forwardRef(({className:e,...t},n)=>c.jsx("li",{ref:n,className:J("",e),...t}));mt.displayName="PaginationItem";const Dn=({className:e,isActive:t,size:n="icon",...r})=>c.jsx("a",{"aria-current":t?"page":void 0,className:J(Ma({variant:t?"outline":"ghost",size:n}),e),...r});Dn.displayName="PaginationLink";const oi=({className:e,...t})=>c.jsxs(Dn,{"aria-label":"Go to previous page",size:"default",className:J("gap-1 pl-2.5",e),...t,children:[c.jsx(eg,{className:"h-4 w-4"}),c.jsx("span",{children:"Previous"})]});oi.displayName="PaginationPrevious";const si=({className:e,...t})=>c.jsxs(Dn,{"aria-label":"Go to next page",size:"default",className:J("gap-1 pr-2.5",e),...t,children:[c.jsx("span",{children:"Next"}),c.jsx(ma,{className:"h-4 w-4"})]});si.displayName="PaginationNext";const ii=({className:e,...t})=>c.jsxs("span",{"aria-hidden":!0,className:J("flex h-9 w-9 items-center justify-center",e),...t,children:[c.jsx(ng,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"More pages"})]});ii.displayName="PaginationEllipsis";function ai(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function md(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Sx(...e){return t=>{let n=!1;const r=e.map(o=>{const s=md(o,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():md(e[o],null)}}}}function li(...e){return d.useCallback(Sx(...e),e)}var Ex=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],ci=Ex.reduce((e,t)=>{const n=d.forwardRef((r,o)=>{const{asChild:s,...i}=r,a=s?It:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(a,{...i,ref:o})});return n.displayName=`Primitive.${t}`,{...e,[t]:n}},{});function Nx(e,t){return d.useReducer((n,r)=>t[n][r]??n,e)}var vd=e=>{const{present:t,children:n}=e,r=Px(t),o=typeof n=="function"?n({present:r.isPresent}):d.Children.only(n),s=li(r.ref,Ax(o));return typeof n=="function"||r.isPresent?d.cloneElement(o,{ref:s}):null};vd.displayName="Presence";function Px(e){const[t,n]=d.useState(),r=d.useRef({}),o=d.useRef(e),s=d.useRef("none"),i=e?"mounted":"unmounted",[a,u]=Nx(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return d.useEffect(()=>{const l=Gr(r.current);s.current=a==="mounted"?l:"none"},[a]),Ne(()=>{const l=r.current,f=o.current;if(f!==e){const h=s.current,p=Gr(l);e?u("MOUNT"):p==="none"||(l==null?void 0:l.display)==="none"?u("UNMOUNT"):u(f&&h!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,u]),Ne(()=>{if(t){let l;const f=t.ownerDocument.defaultView??window,g=p=>{const m=Gr(r.current).includes(p.animationName);if(p.target===t&&m&&(u("ANIMATION_END"),!o.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",l=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},h=p=>{p.target===t&&(s.current=Gr(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{f.clearTimeout(l),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:d.useCallback(l=>{l&&(r.current=getComputedStyle(l)),n(l)},[])}}function Gr(e){return(e==null?void 0:e.animationName)||"none"}function Ax(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ui="Radio",[Tx,yd]=Ze(ui),[_x,Fx]=Tx(ui),wd=d.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:o=!1,required:s,disabled:i,value:a="on",onCheck:u,form:l,...f}=e,[g,h]=d.useState(null),p=li(t,y=>h(y)),v=d.useRef(!1),m=g?l||!!g.closest("form"):!0;return c.jsxs(_x,{scope:n,checked:o,disabled:i,children:[c.jsx(ci.button,{type:"button",role:"radio","aria-checked":o,"data-state":Cd(o),"data-disabled":i?"":void 0,disabled:i,value:a,...f,ref:p,onClick:ai(e.onClick,y=>{o||u==null||u(),m&&(v.current=y.isPropagationStopped(),v.current||y.stopPropagation())})}),m&&c.jsx(Ox,{control:g,bubbles:!v.current,name:r,value:a,checked:o,required:s,disabled:i,form:l,style:{transform:"translateX(-100%)"}})]})});wd.displayName=ui;var bd="RadioIndicator",xd=d.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...o}=e,s=Fx(bd,n);return c.jsx(vd,{present:r||s.checked,children:c.jsx(ci.span,{"data-state":Cd(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t})})});xd.displayName=bd;var Ox=e=>{const{control:t,checked:n,bubbles:r=!0,...o}=e,s=d.useRef(null),i=ka(n),a=Do(t);return d.useEffect(()=>{const u=s.current,l=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(l,"checked").set;if(i!==n&&g){const h=new Event("click",{bubbles:r});g.call(u,n),u.dispatchEvent(h)}},[i,n,r]),c.jsx("input",{type:"radio","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:s,style:{...e.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function Cd(e){return e?"checked":"unchecked"}var Rx=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],di="RadioGroup",[Dx,cC]=Ze(di,[gr,yd]),Sd=gr(),Ed=yd(),[Mx,kx]=Dx(di),Nd=d.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:o,value:s,required:i=!1,disabled:a=!1,orientation:u,dir:l,loop:f=!0,onValueChange:g,...h}=e,p=Sd(n),v=is(l),[m,y]=$t({prop:s,defaultProp:o,onChange:g});return c.jsx(Mx,{scope:n,name:r,required:i,disabled:a,value:m,onValueChange:y,children:c.jsx(Yl,{asChild:!0,...p,orientation:u,dir:v,loop:f,children:c.jsx(ci.div,{role:"radiogroup","aria-required":i,"aria-orientation":u,"data-disabled":a?"":void 0,dir:v,...h,ref:t})})})});Nd.displayName=di;var Pd="RadioGroupItem",Ad=d.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...o}=e,s=kx(Pd,n),i=s.disabled||r,a=Sd(n),u=Ed(n),l=d.useRef(null),f=li(t,l),g=s.value===o.value,h=d.useRef(!1);return d.useEffect(()=>{const p=m=>{Rx.includes(m.key)&&(h.current=!0)},v=()=>h.current=!1;return document.addEventListener("keydown",p),document.addEventListener("keyup",v),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",v)}},[]),c.jsx(Jl,{asChild:!0,...a,focusable:!i,active:g,children:c.jsx(wd,{disabled:i,required:s.required,checked:g,...u,...o,name:s.name,ref:f,onCheck:()=>s.onValueChange(o.value),onKeyDown:ai(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:ai(o.onFocus,()=>{var p;h.current&&((p=l.current)==null||p.click())})})})});Ad.displayName=Pd;var Ix="RadioGroupIndicator",Td=d.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,o=Ed(n);return c.jsx(xd,{...o,...r,ref:t})});Td.displayName=Ix;var _d=Nd,Fd=Ad,$x=Td;const Od=d.forwardRef(({className:e,...t},n)=>c.jsx(_d,{className:J("grid gap-2",e),...t,ref:n}));Od.displayName=_d.displayName;const fi=d.forwardRef(({className:e,...t},n)=>c.jsx(Fd,{ref:n,className:J("aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:c.jsx($x,{className:"flex items-center justify-center",children:c.jsx(tg,{className:"h-3.5 w-3.5 fill-primary"})})}));fi.displayName=Fd.displayName;const Lx=({apiBaseUrl:e="http://localhost:3000"})=>{var x,N,P;const[t,n]=O.useState([]),[r,o]=O.useState(!1),[s,i]=O.useState([]),[a,u]=O.useState(1),[l,f]=O.useState(1),[g,h]=O.useState(null),p=b=>b.map(E=>({id:E==null?void 0:E.id,prefix:(E==null?void 0:E.prefix)||"",model:(E==null?void 0:E.model)||"",fileName:(E==null?void 0:E.file_name)||"",code:(E==null?void 0:E.stock_id)||"",content:(E==null?void 0:E.text_summary)||"",status:(E==null?void 0:E.status)||"",note:(E==null?void 0:E.note)||"",lastUpdate:E==null?void 0:E.updated_at,stock_id:E==null?void 0:E.stock_id})),v=b=>{if(!(b!=null&&b.data))return[];const S=p(b==null?void 0:b.data);n(S),f(b.pagination.totalPages)},m=async(b=1,S=15)=>{console.log("🚀 ~ fetchData ~ page:",b),h(b);try{const E=await oe.get(`${e}/api/latest-summaries`,{params:{page:b,limit:S}});console.log("🚀 ~ fetchData ~ result.data:",E.data),(E==null?void 0:E.status)===200?v(E.data):console.error(E)}catch(E){console.error("Error fetching data:",E)}finally{h(null),o(!1)}};O.useEffect(()=>{m(a)},[a]);const y=O.useMemo(()=>[{id:"code",header:"Mã",accessorKey:"code",cell:({row:S})=>c.jsx("span",{className:"flex flex-col",children:S.original.code})},{id:"content",header:"Nội dung",accessorKey:"content",cell:({row:S})=>{const E=S.getValue("content");return c.jsx(hd,{content:c.jsx("div",{className:"font-medium text-[16px] max-w-[90dvw]",children:E}),children:c.jsx("div",{className:"text-start truncate text-ellipsis overflow-hidden whitespace-nowrap max-w-[30dvw]",children:E})})}},{id:"status",header:"Trạng thái",accessorKey:"status",cell:({row:S})=>c.jsx("span",{className:"flex flex-col",children:S.original.status})},{id:"note",header:"Ghi chú",accessorKey:"note",cell:({row:S})=>c.jsx(hd,{content:c.jsx("div",{className:"font-medium text-[16px] max-w-[90dvw]",children:S.original.note}),children:c.jsx("div",{className:"text-start truncate text-ellipsis overflow-hidden whitespace-nowrap max-w-[20dvw]",children:S.original.note})})},{id:"last-update",header:"Cập nhật",accessorKey:"last-update",cell:({row:S})=>{const E=new Date(S.original.lastUpdate),M=E.getDate(),H=E.getMonth()+1,U=`ngày ${M} tháng ${H}`;return c.jsx("span",{className:"flex flex-col",children:U})}},{accessorKey:"edit",header:()=>c.jsx("div",{className:"font-medium text-center",children:"Sửa"}),cell:({row:S})=>{const[E,M]=O.useState(!1),[H,U]=O.useState(!1),{handleSubmit:Z,register:F,reset:I}=Nw(),R=S.original.id,G=async B=>{M(!0);try{const K=await oe.patch(`${e}/api/update-summary`,{note:B.note,text_summary:B.content,id:R});K.status===200?(await m(a),U(!1)):console.error("Failed to update summary:",K)}catch(K){console.error("Error updating summary:",K)}return M(!1)};return c.jsxs(on,{open:H,onOpenChange:B=>{U(B),B?I({content:S.original.content,note:S.original.note}):I()},children:[c.jsx(lr,{className:"w-full",children:c.jsx("div",{onClick:()=>U(B=>!B),className:"font-medium text-center text-orange-500 cursor-pointer",children:"sửa"})}),c.jsx(Vt,{className:"rounded-lg sm:px-3 h-[calc(100dvh-200px)] min-w-[calc(100dvw-112px)]",children:c.jsxs(Bt,{className:"flex flex-col gap-3",children:[c.jsx(zt,{className:"max-sm:hidden text-center",children:"Sửa summary"}),c.jsxs("form",{className:"flex flex-col gap-3 h-full justify-between",onSubmit:Z(G),children:[c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsxs("div",{className:"flex flex-col items-start",children:[c.jsx("span",{children:"Nội dung:"}),c.jsx(vr,{placeholder:"Nội dung",className:"w-full input-scroll-bar",defaultValue:S.original.answer||"",rows:10,...F("content")})]}),c.jsxs("div",{className:"flex flex-col items-start",children:[c.jsx("span",{children:"Lưu ý:"}),c.jsx(vr,{placeholder:"Nội dung",className:"w-full input-scroll-bar",defaultValue:S.original.note||"",rows:1,...F("note")})]})]}),c.jsx("div",{className:"flex justify-end",children:c.jsx(de,{disabled:E,type:"submit",variant:"default",children:"Ok"})})]})]})})]})}},{id:"publish",header:"",accessorKey:"publish",cell:({row:S})=>{const[E,M]=O.useState(!1),[H,U]=O.useState("create"),[Z,F]=O.useState(!1),I=S.original.id,R=S.getValue("status"),G=S.getValue("code"),K=new Date(S.original.lastUpdate).getMonth()+1,[q,ee]=O.useState(""),[ie,ue]=O.useState(I),Se=async()=>{try{M(!0);try{const ae=await oe.patch(`${e}/api/toggle-publish/${I}`,{id:I,typeAction:H,status:R,idInput:ie,stock_id:S.original.stock_id,bucket:q,prefix:S.original.prefix,model:S.original.model,summary_result:S.original.content,note:S.original.note});ae.status===200?(m(a),F(!1)):console.error("Failed to toggle publish status:",ae)}catch(ae){console.error("Error toggling publish status:",ae)}finally{ee(""),M(!1)}}catch{}};return c.jsxs(on,{open:Z,onOpenChange:ae=>{F(ae)},children:[c.jsx(lr,{className:"w-full",children:c.jsx("div",{onClick:()=>F(ae=>!ae),className:"font-medium text-start text-green-400 cursor-pointer",children:R==="unpublish"?"Publish":"Unpublish"})}),c.jsx(Vt,{className:"rounded-lg sm:px-3 sm:w-[calc(100%-30px)]",children:c.jsxs(Bt,{className:"flex flex-col gap-3",children:[c.jsxs(zt,{className:"text-center",children:[R==="unpublish"?"Publish":"Unpublish"," Summary?"]}),c.jsxs("span",{className:"text-start",children:["Bạn có muốn ",R==="unpublish"?"publish":"unpublish"," summary mã ",G," ","tháng ",K," không?"]}),c.jsxs(Od,{onValueChange:ae=>U(ae),defaultValue:"create",className:"flex items-center",children:[c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx(fi,{value:"create",id:"r1"}),c.jsx(Ht,{htmlFor:"r1",children:"Create"})]}),c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx(fi,{value:"update",id:"r2"}),c.jsx(Ht,{htmlFor:"r2",children:"Update"})]})]}),c.jsxs("div",{className:"text-start",children:[c.jsx("span",{className:"text-start",children:"id:"}),c.jsx(Et,{type:"number",value:ie,onChange:ae=>ue(ae.target.value)})]}),c.jsxs("div",{className:"text-start",children:[c.jsx("span",{className:"text-start",children:"bucket:"}),c.jsx(Et,{value:q,onChange:ae=>ee(ae.target.value)})]}),c.jsx("div",{className:"flex items-center justify-end",children:c.jsx(de,{onClick:Se,disabled:E,children:"ok"})})]})})]})}}],[]),w=Fi({data:t,columns:y,state:{columnFilters:s},enableRowSelection:!0,onColumnFiltersChange:i,getFilteredRowModel:Cf(),getCoreRowModel:_i()});return c.jsxs("div",{className:"space-y-4 s3-explr-container",children:[c.jsx("div",{className:"flex items-center space-x-4 s3-explr-toolbar",children:c.jsx(Et,{placeholder:"Tìm kiếm theo mã...",value:((x=w.getColumn("code"))==null?void 0:x.getFilterValue())??"",onChange:b=>{var S;return(S=w.getColumn("code"))==null?void 0:S.setFilterValue(b.target.value)},className:"max-w-sm"})}),c.jsx("div",{className:"rounded-md border s3-explr-table-container",children:c.jsxs(ur,{className:"s3-explr-table",children:[c.jsx(dr,{className:"s3-explr-table-header",children:w.getHeaderGroups().map(b=>c.jsx(je,{className:"hover:bg-transparent s3-explr-header-row",children:b.headers.map(S=>c.jsx(et,{className:"s3-explr-header-cell",children:S.isPlaceholder?null:Bn(S.column.columnDef.header,S.getContext())},S.id))},b.id))}),c.jsx(fr,{className:"s3-explr-table-body",children:(N=w.getRowModel().rows)!=null&&N.length?(P=w.getRowModel().rows)==null?void 0:P.map(b=>c.jsx(je,{className:"h-12 s3-explr-row",children:b.getVisibleCells().map(S=>c.jsx(_e,{className:"align-middle s3-explr-cell",children:Bn(S.column.columnDef.cell,S.getContext())},S.id))},b.id)):r?c.jsx(je,{children:c.jsx(_e,{colSpan:y.length,className:"h-24 text-center",children:"loading..."})}):c.jsx(je,{children:c.jsx(_e,{colSpan:y.length,className:"h-24 text-center",children:"Không có kết quả."})})})]})}),c.jsx("div",{className:"mt-4",children:c.jsx(ni,{children:c.jsxs(ri,{children:[c.jsx(mt,{children:c.jsx(oi,{onClick:()=>u(b=>Math.max(1,b-1)),className:a===1?"pointer-events-none opacity-50":"cursor-pointer"})}),Array.from({length:l},(b,S)=>S+1).filter(b=>b===1||b===l||Math.abs(b-a)<=1).map((b,S,E)=>c.jsxs(c.Fragment,{children:[S>0&&E[S-1]!==b-1&&c.jsx(mt,{children:c.jsx(ii,{})},b+"..."),c.jsx(mt,{children:c.jsx(Dn,{onClick:()=>u(b),isActive:a===b,className:`cursor-pointer ${r?"pointer-events-none":""}`,children:g===b?c.jsx(Te,{className:"h-4 w-4 animate-spin"}):b})},b)]})),c.jsx(mt,{children:c.jsx(si,{onClick:()=>u(b=>Math.min(l,b+1)),className:a===l||g!==null?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})},Rd=10,Vx=O.memo(({apiBaseUrl:e="http://localhost:3000"})=>{const[t,n]=O.useState(1),[r,o]=O.useState([]),[s,i]=O.useState({total:0,page:1,limit:Rd,totalPages:1}),[a,u]=O.useState(!0),[l,f]=O.useState(null),[g,h]=O.useState(new Set),{toast:p}=Ps(),[v,m]=O.useState(!1),y=async b=>{try{f(b);const S=await oe.get(`${e}/api/jobs`,{params:{page:b.toString(),limit:Rd.toString()}});o(S.data.data),i(S.data.pagination)}catch{p({variant:"destructive",title:"Error",description:"Failed to fetch jobs. Please try again."})}finally{f(null),u(!1)}};O.useEffect(()=>{y(t)},[t,e]);const w=async b=>{h(S=>new Set(S).add(b.toString()));try{await oe.post(`${e}/api/retry-job`,{jobId:b}),p({title:"Job Restarted",description:`Job ${b} has been successfully restarted.`}),y(t)}catch{p({variant:"destructive",title:"Retry Failed",description:`Failed to restart job ${b}. Please try again.`})}finally{h(S=>{const E=new Set(S);return E.delete(b.toString()),E})}},x=async()=>{m(!0),n(1),await y(1),m(!1)},N=b=>new Date(b).toLocaleString(),P=b=>{if(b=parseFloat(b),b<60)return`${b.toFixed(2)}s`;const S=Math.floor(b/60),E=(b%60).toFixed(0);return`${S}m ${E}s`};return c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[c.jsx(Zp,{className:"w-8 h-8 text-primary"}),c.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Job Management"}),c.jsx(de,{variant:"outline",size:"icon",onClick:x,disabled:v||a,className:"ml-2",children:c.jsx(rg,{className:`h-4 w-4 ${v?"animate-spin":""}`})})]}),c.jsx("div",{className:"rounded-md border",children:c.jsxs(ur,{children:[c.jsx(dr,{children:c.jsxs(je,{children:[c.jsx(et,{children:"ID"}),c.jsx(et,{children:"Tên Công Việc"}),c.jsx(et,{children:"Thời Gian Bắt Đầu"}),c.jsx(et,{children:"Thời Gian Cập Nhật"}),c.jsx(et,{children:"Thời Gian Thực Thi"}),c.jsx(et,{children:"Trạng Thái"}),c.jsx(et,{children:"Thao Tác"})]})}),c.jsx(fr,{children:a&&r.length===0?c.jsx(je,{children:c.jsx(_e,{colSpan:7,className:"text-center py-4",children:c.jsx(Te,{className:"w-6 h-6 animate-spin mx-auto"})})}):r.map(b=>{var S,E;return c.jsxs(je,{children:[c.jsx(_e,{className:"!w-[100px]",children:b.id}),c.jsx(_e,{className:"font-medium",children:(S=b.job_name)==null?void 0:S.replace("Upload file","Summary")}),c.jsx(_e,{className:"!w-[200px]",children:N(b.created_at)}),c.jsx(_e,{className:"!w-[200px]",children:N(b.updated_at)}),c.jsx(_e,{className:"!w-[150px]",children:P(b.execution_time_seconds)}),c.jsx(_e,{className:"!w-[200px]",children:c.jsx("div",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium
|
|
137
137
|
${b.status==="done"?"bg-green-100 text-green-800":b.status==="fail"?"bg-red-100 text-red-800":"bg-yellow-100 text-yellow-800"}`,children:(E=b.status)==null?void 0:E.replace("fail","failed").toUpperCase()})}),c.jsx(_e,{className:"!w-[200px]",children:b.status==="fail"?c.jsx(de,{variant:"outline",size:"sm",onClick:()=>w(b.id),disabled:g.has(b.id.toString()),className:"h-[32px]",children:g.has(b.id.toString())?c.jsxs(c.Fragment,{children:[c.jsx(Te,{className:"mr-2 h-4 w-4 animate-spin"}),"Đang thử lại..."]}):"Thử Lại"}):c.jsx("div",{className:"h-[32px]"})})]},b.id)})})]})}),c.jsx("div",{className:"mt-4",children:c.jsx(ni,{children:c.jsxs(ri,{children:[c.jsx(mt,{children:c.jsx(oi,{onClick:()=>n(b=>Math.max(1,b-1)),className:t===1?"pointer-events-none opacity-50":"cursor-pointer"})}),Array.from({length:s.totalPages},(b,S)=>S+1).filter(b=>b===1||b===s.totalPages||Math.abs(b-t)<=1).map((b,S,E)=>c.jsxs(c.Fragment,{children:[S>0&&E[S-1]!==b-1&&c.jsx(mt,{children:c.jsx(ii,{})},b+"..."),c.jsx(mt,{children:c.jsx(Dn,{onClick:()=>n(b),isActive:t===b,className:`cursor-pointer ${l!==null?"pointer-events-none":""}`,children:l===b?c.jsx(Te,{className:"h-4 w-4 animate-spin"}):b})},b)]})),c.jsx(mt,{children:c.jsx(si,{onClick:()=>n(b=>Math.min(s.totalPages,b+1)),className:t===s.totalPages||l!==null?"pointer-events-none opacity-50":"cursor-pointer"})})]})})}),c.jsx(Hc,{})]})});Be.Job=Vx,Be.S3Explorer=ow,Be.Summary=Lx,Object.defineProperty(Be,Symbol.toStringTag,{value:"Module"})});
|
|
138
138
|
//# sourceMappingURL=s3-explorer.umd.cjs.map
|