dccxx-s3-explorer 1.0.79 → 1.0.80
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
|
@@ -196,7 +196,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
196
196
|
* This source code is licensed under the ISC license.
|
|
197
197
|
* See the LICENSE file in the root directory of this source tree.
|
|
198
198
|
*/const ig=On("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Hx(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var o=t.length;for(e=0;e<o;e++)t[e]&&(n=Hx(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Ux(){for(var t,e,n=0,r="",o=arguments.length;n<o;n++)(t=arguments[n])&&(e=Hx(t))&&(r&&(r+=" "),r+=e);return r}function GD(t){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e.firstChild?e.insertBefore(n,e.firstChild):e.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}GD(`:root{--toastify-color-light: #fff;--toastify-color-dark: #121212;--toastify-color-info: #3498db;--toastify-color-success: #07bc0c;--toastify-color-warning: #f1c40f;--toastify-color-error: hsl(6, 78%, 57%);--toastify-color-transparent: rgba(255, 255, 255, .7);--toastify-icon-color-info: var(--toastify-color-info);--toastify-icon-color-success: var(--toastify-color-success);--toastify-icon-color-warning: var(--toastify-color-warning);--toastify-icon-color-error: var(--toastify-color-error);--toastify-container-width: fit-content;--toastify-toast-width: 320px;--toastify-toast-offset: 16px;--toastify-toast-top: max(var(--toastify-toast-offset), env(safe-area-inset-top));--toastify-toast-right: max(var(--toastify-toast-offset), env(safe-area-inset-right));--toastify-toast-left: max(var(--toastify-toast-offset), env(safe-area-inset-left));--toastify-toast-bottom: max(var(--toastify-toast-offset), env(safe-area-inset-bottom));--toastify-toast-background: #fff;--toastify-toast-padding: 14px;--toastify-toast-min-height: 64px;--toastify-toast-max-height: 800px;--toastify-toast-bd-radius: 6px;--toastify-toast-shadow: 0px 4px 12px rgba(0, 0, 0, .1);--toastify-font-family: sans-serif;--toastify-z-index: 9999;--toastify-text-color-light: #757575;--toastify-text-color-dark: #fff;--toastify-text-color-info: #fff;--toastify-text-color-success: #fff;--toastify-text-color-warning: #fff;--toastify-text-color-error: #fff;--toastify-spinner-color: #616161;--toastify-spinner-color-empty-area: #e0e0e0;--toastify-color-progress-light: linear-gradient(to right, #4cd964, #5ac8fa, #007aff, #34aadc, #5856d6, #ff2d55);--toastify-color-progress-dark: #bb86fc;--toastify-color-progress-info: var(--toastify-color-info);--toastify-color-progress-success: var(--toastify-color-success);--toastify-color-progress-warning: var(--toastify-color-warning);--toastify-color-progress-error: var(--toastify-color-error);--toastify-color-progress-bgo: .2}.Toastify__toast-container{z-index:var(--toastify-z-index);-webkit-transform:translate3d(0,0,var(--toastify-z-index));position:fixed;width:var(--toastify-container-width);box-sizing:border-box;color:#fff;display:flex;flex-direction:column}.Toastify__toast-container--top-left{top:var(--toastify-toast-top);left:var(--toastify-toast-left)}.Toastify__toast-container--top-center{top:var(--toastify-toast-top);left:50%;transform:translate(-50%);align-items:center}.Toastify__toast-container--top-right{top:var(--toastify-toast-top);right:var(--toastify-toast-right);align-items:end}.Toastify__toast-container--bottom-left{bottom:var(--toastify-toast-bottom);left:var(--toastify-toast-left)}.Toastify__toast-container--bottom-center{bottom:var(--toastify-toast-bottom);left:50%;transform:translate(-50%);align-items:center}.Toastify__toast-container--bottom-right{bottom:var(--toastify-toast-bottom);right:var(--toastify-toast-right);align-items:end}.Toastify__toast{--y: 0;position:relative;touch-action:none;width:var(--toastify-toast-width);min-height:var(--toastify-toast-min-height);box-sizing:border-box;margin-bottom:1rem;padding:var(--toastify-toast-padding);border-radius:var(--toastify-toast-bd-radius);box-shadow:var(--toastify-toast-shadow);max-height:var(--toastify-toast-max-height);font-family:var(--toastify-font-family);z-index:0;display:flex;flex:1 auto;align-items:center;word-break:break-word}@media only screen and (max-width: 480px){.Toastify__toast-container{width:100vw;left:env(safe-area-inset-left);margin:0}.Toastify__toast-container--top-left,.Toastify__toast-container--top-center,.Toastify__toast-container--top-right{top:env(safe-area-inset-top);transform:translate(0)}.Toastify__toast-container--bottom-left,.Toastify__toast-container--bottom-center,.Toastify__toast-container--bottom-right{bottom:env(safe-area-inset-bottom);transform:translate(0)}.Toastify__toast-container--rtl{right:env(safe-area-inset-right);left:initial}.Toastify__toast{--toastify-toast-width: 100%;margin-bottom:0;border-radius:0}}.Toastify__toast-container[data-stacked=true]{width:var(--toastify-toast-width)}.Toastify__toast--stacked{position:absolute;width:100%;transform:translate3d(0,var(--y),0) scale(var(--s));transition:transform .3s}.Toastify__toast--stacked[data-collapsed] .Toastify__toast-body,.Toastify__toast--stacked[data-collapsed] .Toastify__close-button{transition:opacity .1s}.Toastify__toast--stacked[data-collapsed=false]{overflow:visible}.Toastify__toast--stacked[data-collapsed=true]:not(:last-child)>*{opacity:0}.Toastify__toast--stacked:after{content:"";position:absolute;left:0;right:0;height:calc(var(--g) * 1px);bottom:100%}.Toastify__toast--stacked[data-pos=top]{top:0}.Toastify__toast--stacked[data-pos=bot]{bottom:0}.Toastify__toast--stacked[data-pos=bot].Toastify__toast--stacked:before{transform-origin:top}.Toastify__toast--stacked[data-pos=top].Toastify__toast--stacked:before{transform-origin:bottom}.Toastify__toast--stacked:before{content:"";position:absolute;left:0;right:0;bottom:0;height:100%;transform:scaleY(3);z-index:-1}.Toastify__toast--rtl{direction:rtl}.Toastify__toast--close-on-click{cursor:pointer}.Toastify__toast-icon{margin-inline-end:10px;width:22px;flex-shrink:0;display:flex}.Toastify--animate{animation-fill-mode:both;animation-duration:.5s}.Toastify--animate-icon{animation-fill-mode:both;animation-duration:.3s}.Toastify__toast-theme--dark{background:var(--toastify-color-dark);color:var(--toastify-text-color-dark)}.Toastify__toast-theme--light,.Toastify__toast-theme--colored.Toastify__toast--default{background:var(--toastify-color-light);color:var(--toastify-text-color-light)}.Toastify__toast-theme--colored.Toastify__toast--info{color:var(--toastify-text-color-info);background:var(--toastify-color-info)}.Toastify__toast-theme--colored.Toastify__toast--success{color:var(--toastify-text-color-success);background:var(--toastify-color-success)}.Toastify__toast-theme--colored.Toastify__toast--warning{color:var(--toastify-text-color-warning);background:var(--toastify-color-warning)}.Toastify__toast-theme--colored.Toastify__toast--error{color:var(--toastify-text-color-error);background:var(--toastify-color-error)}.Toastify__progress-bar-theme--light{background:var(--toastify-color-progress-light)}.Toastify__progress-bar-theme--dark{background:var(--toastify-color-progress-dark)}.Toastify__progress-bar--info{background:var(--toastify-color-progress-info)}.Toastify__progress-bar--success{background:var(--toastify-color-progress-success)}.Toastify__progress-bar--warning{background:var(--toastify-color-progress-warning)}.Toastify__progress-bar--error{background:var(--toastify-color-progress-error)}.Toastify__progress-bar-theme--colored.Toastify__progress-bar--info,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--success,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--warning,.Toastify__progress-bar-theme--colored.Toastify__progress-bar--error{background:var(--toastify-color-transparent)}.Toastify__close-button{color:#fff;position:absolute;top:6px;right:6px;background:transparent;outline:none;border:none;padding:0;cursor:pointer;opacity:.7;transition:.3s ease;z-index:1}.Toastify__toast--rtl .Toastify__close-button{left:6px;right:unset}.Toastify__close-button--light{color:#000;opacity:.3}.Toastify__close-button>svg{fill:currentColor;height:16px;width:14px}.Toastify__close-button:hover,.Toastify__close-button:focus{opacity:1}@keyframes Toastify__trackProgress{0%{transform:scaleX(1)}to{transform:scaleX(0)}}.Toastify__progress-bar{position:absolute;bottom:0;left:0;width:100%;height:100%;z-index:1;opacity:.7;transform-origin:left}.Toastify__progress-bar--animated{animation:Toastify__trackProgress linear 1 forwards}.Toastify__progress-bar--controlled{transition:transform .2s}.Toastify__progress-bar--rtl{right:0;left:initial;transform-origin:right;border-bottom-left-radius:initial}.Toastify__progress-bar--wrp{position:absolute;overflow:hidden;bottom:0;left:0;width:100%;height:5px;border-bottom-left-radius:var(--toastify-toast-bd-radius);border-bottom-right-radius:var(--toastify-toast-bd-radius)}.Toastify__progress-bar--wrp[data-hidden=true]{opacity:0}.Toastify__progress-bar--bg{opacity:var(--toastify-color-progress-bgo);width:100%;height:100%}.Toastify__spinner{width:20px;height:20px;box-sizing:border-box;border:2px solid;border-radius:100%;border-color:var(--toastify-spinner-color-empty-area);border-right-color:var(--toastify-spinner-color);animation:Toastify__spin .65s linear infinite}@keyframes Toastify__bounceInRight{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(3000px,0,0)}60%{opacity:1;transform:translate3d(-25px,0,0)}75%{transform:translate3d(10px,0,0)}90%{transform:translate3d(-5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutRight{20%{opacity:1;transform:translate3d(-20px,var(--y),0)}to{opacity:0;transform:translate3d(2000px,var(--y),0)}}@keyframes Toastify__bounceInLeft{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(-3000px,0,0)}60%{opacity:1;transform:translate3d(25px,0,0)}75%{transform:translate3d(-10px,0,0)}90%{transform:translate3d(5px,0,0)}to{transform:none}}@keyframes Toastify__bounceOutLeft{20%{opacity:1;transform:translate3d(20px,var(--y),0)}to{opacity:0;transform:translate3d(-2000px,var(--y),0)}}@keyframes Toastify__bounceInUp{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,3000px,0)}60%{opacity:1;transform:translate3d(0,-20px,0)}75%{transform:translate3d(0,10px,0)}90%{transform:translate3d(0,-5px,0)}to{transform:translateZ(0)}}@keyframes Toastify__bounceOutUp{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,-2000px,0)}}@keyframes Toastify__bounceInDown{0%,60%,75%,90%,to{animation-timing-function:cubic-bezier(.215,.61,.355,1)}0%{opacity:0;transform:translate3d(0,-3000px,0)}60%{opacity:1;transform:translate3d(0,25px,0)}75%{transform:translate3d(0,-10px,0)}90%{transform:translate3d(0,5px,0)}to{transform:none}}@keyframes Toastify__bounceOutDown{20%{transform:translate3d(0,calc(var(--y) - 10px),0)}40%,45%{opacity:1;transform:translate3d(0,calc(var(--y) + 20px),0)}to{opacity:0;transform:translate3d(0,2000px,0)}}.Toastify__bounce-enter--top-left,.Toastify__bounce-enter--bottom-left{animation-name:Toastify__bounceInLeft}.Toastify__bounce-enter--top-right,.Toastify__bounce-enter--bottom-right{animation-name:Toastify__bounceInRight}.Toastify__bounce-enter--top-center{animation-name:Toastify__bounceInDown}.Toastify__bounce-enter--bottom-center{animation-name:Toastify__bounceInUp}.Toastify__bounce-exit--top-left,.Toastify__bounce-exit--bottom-left{animation-name:Toastify__bounceOutLeft}.Toastify__bounce-exit--top-right,.Toastify__bounce-exit--bottom-right{animation-name:Toastify__bounceOutRight}.Toastify__bounce-exit--top-center{animation-name:Toastify__bounceOutUp}.Toastify__bounce-exit--bottom-center{animation-name:Toastify__bounceOutDown}@keyframes Toastify__zoomIn{0%{opacity:0;transform:scale3d(.3,.3,.3)}50%{opacity:1}}@keyframes Toastify__zoomOut{0%{opacity:1}50%{opacity:0;transform:translate3d(0,var(--y),0) scale3d(.3,.3,.3)}to{opacity:0}}.Toastify__zoom-enter{animation-name:Toastify__zoomIn}.Toastify__zoom-exit{animation-name:Toastify__zoomOut}@keyframes Toastify__flipIn{0%{transform:perspective(400px) rotateX(90deg);animation-timing-function:ease-in;opacity:0}40%{transform:perspective(400px) rotateX(-20deg);animation-timing-function:ease-in}60%{transform:perspective(400px) rotateX(10deg);opacity:1}80%{transform:perspective(400px) rotateX(-5deg)}to{transform:perspective(400px)}}@keyframes Toastify__flipOut{0%{transform:translate3d(0,var(--y),0) perspective(400px)}30%{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(-20deg);opacity:1}to{transform:translate3d(0,var(--y),0) perspective(400px) rotateX(90deg);opacity:0}}.Toastify__flip-enter{animation-name:Toastify__flipIn}.Toastify__flip-exit{animation-name:Toastify__flipOut}@keyframes Toastify__slideInRight{0%{transform:translate3d(110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInLeft{0%{transform:translate3d(-110%,0,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInUp{0%{transform:translate3d(0,110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideInDown{0%{transform:translate3d(0,-110%,0);visibility:visible}to{transform:translate3d(0,var(--y),0)}}@keyframes Toastify__slideOutRight{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(110%,var(--y),0)}}@keyframes Toastify__slideOutLeft{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(-110%,var(--y),0)}}@keyframes Toastify__slideOutDown{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,500px,0)}}@keyframes Toastify__slideOutUp{0%{transform:translate3d(0,var(--y),0)}to{visibility:hidden;transform:translate3d(0,-500px,0)}}.Toastify__slide-enter--top-left,.Toastify__slide-enter--bottom-left{animation-name:Toastify__slideInLeft}.Toastify__slide-enter--top-right,.Toastify__slide-enter--bottom-right{animation-name:Toastify__slideInRight}.Toastify__slide-enter--top-center{animation-name:Toastify__slideInDown}.Toastify__slide-enter--bottom-center{animation-name:Toastify__slideInUp}.Toastify__slide-exit--top-left,.Toastify__slide-exit--bottom-left{animation-name:Toastify__slideOutLeft;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--top-right,.Toastify__slide-exit--bottom-right{animation-name:Toastify__slideOutRight;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--top-center{animation-name:Toastify__slideOutUp;animation-timing-function:ease-in;animation-duration:.3s}.Toastify__slide-exit--bottom-center{animation-name:Toastify__slideOutDown;animation-timing-function:ease-in;animation-duration:.3s}@keyframes Toastify__spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
|
|
199
|
-
`);var ag=t=>typeof t=="number"&&!isNaN(t),Xs=t=>typeof t=="string",Bx=t=>typeof t=="function",jD=t=>Xs(t)||ag(t),WD=t=>O.isValidElement(t)||Xs(t)||Bx(t)||ag(t),qD=1,zx=()=>`${qD++}`,co=new Map,sg=[],Vx=new Set,Kx=()=>co.size>0,YD=(t,{containerId:e})=>{var n;return(n=co.get(e||1))==null?void 0:n.toasts.get(t)};function JD(t,e){var n;if(e)return!!((n=co.get(e))!=null&&n.isToastActive(t));let r=!1;return co.forEach(o=>{o.isToastActive(t)&&(r=!0)}),r}function QD(t){if(!Kx()){sg=sg.filter(e=>t!=null&&e.options.toastId!==t);return}if(t==null||jD(t))co.forEach(e=>{e.removeToast(t)});else if(t&&("containerId"in t||"id"in t)){let e=co.get(t.containerId);e?e.removeToast(t.id):co.forEach(n=>{n.removeToast(t.id)})}}var XD=(t={})=>{co.forEach(e=>{e.props.limit&&(!t.containerId||e.id===t.containerId)&&e.clearQueue()})};function ZD(t,e){WD(t)&&(Kx()||sg.push({content:t,options:e}),co.forEach(n=>{n.buildToast(t,e)}))}function Gx(t,e){co.forEach(n=>{(e==null||!(e!=null&&e.containerId)||(e==null?void 0:e.containerId)===n.id)&&n.toggle(t,e==null?void 0:e.id)})}function eL(t){return Vx.add(t),()=>{Vx.delete(t)}}function tL(t){return t&&(Xs(t.toastId)||ag(t.toastId))?t.toastId:zx()}function Zs(t,e){return ZD(t,e),e.toastId}function Dd(t,e){return{...e,type:e&&e.type||t,toastId:tL(e)}}function Ld(t){return(e,n)=>Zs(e,Dd(t,n))}function st(t,e){return Zs(t,Dd("default",e))}st.loading=(t,e)=>Zs(t,Dd("default",{isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1,...e}));function nL(t,{pending:e,error:n,success:r},o){let i;e&&(i=Xs(e)?st.loading(e,o):st.loading(e.render,{...o,...e}));let s={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},l=(h,p,g)=>{if(p==null){st.dismiss(i);return}let C={type:h,...s,...o,data:g},w=Xs(p)?{render:p}:p;return i?st.update(i,{...C,...w}):st(w.render,{...C,...w}),g},u=Bx(t)?t():t;return u.then(h=>l("success",r,h)).catch(h=>l("error",n,h)),u}st.promise=nL,st.success=Ld("success"),st.info=Ld("info"),st.error=Ld("error"),st.warning=Ld("warning"),st.warn=st.warning,st.dark=(t,e)=>Zs(t,Dd("default",{theme:"dark",...e}));function rL(t){QD(t)}st.dismiss=rL,st.clearWaitingQueue=XD,st.isActive=JD,st.update=(t,e={})=>{let n=YD(t,e);if(n){let{props:r,content:o}=n,i={delay:100,...r,...e,toastId:e.toastId||t,updateId:zx()};i.toastId!==t&&(i.staleId=t);let s=i.render||o;delete i.render,Zs(s,i)}},st.done=t=>{st.update(t,{progress:1})},st.onChange=eL,st.play=t=>Gx(!0,t),st.pause=t=>Gx(!1,t);const oL={category:"Thư mục gốc",fileName:"Tên tệp",fullPath:"Đường dẫn đầy đủ",createAt:"Ngày tạo",creator:"Người tạo",creatorId:"ID người tạo",DataSource:"Nguồn dữ liệu",SuggestedAICategories:"Danh mục AI gợi ý",KeywordAISuggestion:"Từ khóa AI gợi ý",SummaryOfSuggestedAI:"Tóm tắt AI gợi ý",AccessLevel:"Cấp độ truy cập"},iL=t=>t==="SummaryOfSuggestedAI"||t==="KeywordAISuggestion"||t==="SuggestedAICategories",cg=t=>t==="fullPath"||t==="createAt"||t==="creator"||t==="creatorId"||t==="DataSource"||t==="AccessLevel"||t==="category"||t==="fileName",aL={STARTING:"Đang bắt đầu",IN_PROGRESS:"Đang đồng bộ",COMPLETE:"Đồng bộ thành công",FAILED:"Đồng bộ thất bại",STOPPING:"Đang dừng",STOPPED:"Đã dừng"},sL=t=>aL[t]||t;function cL(t){const e=lL(t),n=m.forwardRef((r,o)=>{const{children:i,...s}=r,l=m.Children.toArray(i),u=l.find(uL);if(u){const h=u.props.children,p=l.map(g=>g===u?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return d.jsx(e,{...s,ref:o,children:m.isValidElement(h)?m.cloneElement(h,void 0,p):null})}return d.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}var jx=cL("Slot");function lL(t){const e=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const s=hL(o),l=fL(i,o.props);return o.type!==m.Fragment&&(l.ref=r?Hi(r,s):s),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var dL=Symbol("radix.slottable");function uL(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===dL}function fL(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function hL(t){var r,o;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}const lg="-",pL=t=>{const e=mL(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:s=>{const l=s.split(lg);return l[0]===""&&l.length!==1&&l.shift(),Wx(l,e)||gL(s)},getConflictingClassGroupIds:(s,l)=>{const u=n[s]||[];return l&&r[s]?[...u,...r[s]]:u}}},Wx=(t,e)=>{var s;if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),o=r?Wx(t.slice(1),r):void 0;if(o)return o;if(e.validators.length===0)return;const i=t.join(lg);return(s=e.validators.find(({validator:l})=>l(i)))==null?void 0:s.classGroupId},qx=/^\[(.+)\]$/,gL=t=>{if(qx.test(t)){const e=qx.exec(t)[1],n=e==null?void 0:e.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},mL=t=>{const{theme:e,prefix:n}=t,r={nextPart:new Map,validators:[]};return yL(Object.entries(t.classGroups),n).forEach(([i,s])=>{dg(s,r,i,e)}),r},dg=(t,e,n,r)=>{t.forEach(o=>{if(typeof o=="string"){const i=o===""?e:Yx(e,o);i.classGroupId=n;return}if(typeof o=="function"){if(vL(o)){dg(o(r),e,n,r);return}e.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([i,s])=>{dg(s,Yx(e,i),n,r)})})},Yx=(t,e)=>{let n=t;return e.split(lg).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},vL=t=>t.isThemeGetter,yL=(t,e)=>e?t.map(([n,r])=>{const o=r.map(i=>typeof i=="string"?e+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([s,l])=>[e+s,l])):i);return[n,o]}):t,wL=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,r=new Map;const o=(i,s)=>{n.set(i,s),e++,e>t&&(e=0,r=n,n=new Map)};return{get(i){let s=n.get(i);if(s!==void 0)return s;if((s=r.get(i))!==void 0)return o(i,s),s},set(i,s){n.has(i)?n.set(i,s):o(i,s)}}},Jx="!",CL=t=>{const{separator:e,experimentalParseClassName:n}=t,r=e.length===1,o=e[0],i=e.length,s=l=>{const u=[];let h=0,p=0,g;for(let x=0;x<l.length;x++){let E=l[x];if(h===0){if(E===o&&(r||l.slice(x,x+i)===e)){u.push(l.slice(p,x)),p=x+i;continue}if(E==="/"){g=x;continue}}E==="["?h++:E==="]"&&h--}const C=u.length===0?l:l.substring(p),w=C.startsWith(Jx),b=w?C.substring(1):C,v=g&&g>p?g-p:void 0;return{modifiers:u,hasImportantModifier:w,baseClassName:b,maybePostfixModifierPosition:v}};return n?l=>n({className:l,parseClassName:s}):s},bL=t=>{if(t.length<=1)return t;const e=[];let n=[];return t.forEach(r=>{r[0]==="["?(e.push(...n.sort(),r),n=[]):n.push(r)}),e.push(...n.sort()),e},xL=t=>({cache:wL(t.cacheSize),parseClassName:CL(t),...pL(t)}),SL=/\s+/,_L=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o}=e,i=[],s=t.trim().split(SL);let l="";for(let u=s.length-1;u>=0;u-=1){const h=s[u],{modifiers:p,hasImportantModifier:g,baseClassName:C,maybePostfixModifierPosition:w}=n(h);let b=!!w,v=r(b?C.substring(0,w):C);if(!v){if(!b){l=h+(l.length>0?" "+l:l);continue}if(v=r(C),!v){l=h+(l.length>0?" "+l:l);continue}b=!1}const x=bL(p).join(":"),E=g?x+Jx:x,A=E+v;if(i.includes(A))continue;i.push(A);const N=o(v,b);for(let P=0;P<N.length;++P){const _=N[P];i.push(E+_)}l=h+(l.length>0?" "+l:l)}return l};function EL(){let t=0,e,n,r="";for(;t<arguments.length;)(e=arguments[t++])&&(n=Qx(e))&&(r&&(r+=" "),r+=n);return r}const Qx=t=>{if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=Qx(t[r]))&&(n&&(n+=" "),n+=e);return n};function TL(t,...e){let n,r,o,i=s;function s(u){const h=e.reduce((p,g)=>g(p),t());return n=xL(h),r=n.cache.get,o=n.cache.set,i=l,l(u)}function l(u){const h=r(u);if(h)return h;const p=_L(u,n);return o(u,p),p}return function(){return i(EL.apply(null,arguments))}}const Ft=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},Xx=/^\[(?:([a-z-]+):)?(.+)\]$/i,AL=/^\d+\/\d+$/,IL=new Set(["px","full","screen"]),kL=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,NL=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,PL=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,OL=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ML=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Oo=t=>Ya(t)||IL.has(t)||AL.test(t),fi=t=>Ja(t,"length",BL),Ya=t=>!!t&&!Number.isNaN(Number(t)),ug=t=>Ja(t,"number",Ya),ec=t=>!!t&&Number.isInteger(Number(t)),RL=t=>t.endsWith("%")&&Ya(t.slice(0,-1)),ot=t=>Xx.test(t),hi=t=>kL.test(t),DL=new Set(["length","size","percentage"]),LL=t=>Ja(t,DL,Zx),FL=t=>Ja(t,"position",Zx),$L=new Set(["image","url"]),HL=t=>Ja(t,$L,VL),UL=t=>Ja(t,"",zL),tc=()=>!0,Ja=(t,e,n)=>{const r=Xx.exec(t);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):n(r[2]):!1},BL=t=>NL.test(t)&&!PL.test(t),Zx=()=>!1,zL=t=>OL.test(t),VL=t=>ML.test(t),KL=TL(()=>{const t=Ft("colors"),e=Ft("spacing"),n=Ft("blur"),r=Ft("brightness"),o=Ft("borderColor"),i=Ft("borderRadius"),s=Ft("borderSpacing"),l=Ft("borderWidth"),u=Ft("contrast"),h=Ft("grayscale"),p=Ft("hueRotate"),g=Ft("invert"),C=Ft("gap"),w=Ft("gradientColorStops"),b=Ft("gradientColorStopPositions"),v=Ft("inset"),x=Ft("margin"),E=Ft("opacity"),A=Ft("padding"),N=Ft("saturate"),P=Ft("scale"),_=Ft("sepia"),D=Ft("skew"),H=Ft("space"),K=Ft("translate"),ee=()=>["auto","contain","none"],W=()=>["auto","hidden","clip","visible","scroll"],de=()=>["auto",ot,e],se=()=>[ot,e],fe=()=>["",Oo,fi],q=()=>["auto",Ya,ot],Z=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Y=()=>["solid","dashed","dotted","double","none"],oe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Q=()=>["start","end","center","between","around","evenly","stretch"],X=()=>["","0",ot],$=()=>["auto","avoid","all","avoid-page","page","left","right","column"],te=()=>[Ya,ot];return{cacheSize:500,separator:":",theme:{colors:[tc],spacing:[Oo,fi],blur:["none","",hi,ot],brightness:te(),borderColor:[t],borderRadius:["none","","full",hi,ot],borderSpacing:se(),borderWidth:fe(),contrast:te(),grayscale:X(),hueRotate:te(),invert:X(),gap:se(),gradientColorStops:[t],gradientColorStopPositions:[RL,fi],inset:de(),margin:de(),opacity:te(),padding:se(),saturate:te(),scale:te(),sepia:X(),skew:te(),space:se(),translate:se()},classGroups:{aspect:[{aspect:["auto","square","video",ot]}],container:["container"],columns:[{columns:[hi]}],"break-after":[{"break-after":$()}],"break-before":[{"break-before":$()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...Z(),ot]}],overflow:[{overflow:W()}],"overflow-x":[{"overflow-x":W()}],"overflow-y":[{"overflow-y":W()}],overscroll:[{overscroll:ee()}],"overscroll-x":[{"overscroll-x":ee()}],"overscroll-y":[{"overscroll-y":ee()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[v]}],"inset-x":[{"inset-x":[v]}],"inset-y":[{"inset-y":[v]}],start:[{start:[v]}],end:[{end:[v]}],top:[{top:[v]}],right:[{right:[v]}],bottom:[{bottom:[v]}],left:[{left:[v]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",ec,ot]}],basis:[{basis:de()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ot]}],grow:[{grow:X()}],shrink:[{shrink:X()}],order:[{order:["first","last","none",ec,ot]}],"grid-cols":[{"grid-cols":[tc]}],"col-start-end":[{col:["auto",{span:["full",ec,ot]},ot]}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":[tc]}],"row-start-end":[{row:["auto",{span:[ec,ot]},ot]}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ot]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ot]}],gap:[{gap:[C]}],"gap-x":[{"gap-x":[C]}],"gap-y":[{"gap-y":[C]}],"justify-content":[{justify:["normal",...Q()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...Q(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...Q(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[A]}],px:[{px:[A]}],py:[{py:[A]}],ps:[{ps:[A]}],pe:[{pe:[A]}],pt:[{pt:[A]}],pr:[{pr:[A]}],pb:[{pb:[A]}],pl:[{pl:[A]}],m:[{m:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[H]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[H]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ot,e]}],"min-w":[{"min-w":[ot,e,"min","max","fit"]}],"max-w":[{"max-w":[ot,e,"none","full","min","max","fit","prose",{screen:[hi]},hi]}],h:[{h:[ot,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ot,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ot,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ot,e,"auto","min","max","fit"]}],"font-size":[{text:["base",hi,fi]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",ug]}],"font-family":[{font:[tc]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",ot]}],"line-clamp":[{"line-clamp":["none",Ya,ug]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Oo,ot]}],"list-image":[{"list-image":["none",ot]}],"list-style-type":[{list:["none","disc","decimal",ot]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[E]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[E]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Y(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Oo,fi]}],"underline-offset":[{"underline-offset":["auto",Oo,ot]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:se()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ot]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ot]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[E]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Z(),FL]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",LL]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},HL]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[b]}],"gradient-via-pos":[{via:[b]}],"gradient-to-pos":[{to:[b]}],"gradient-from":[{from:[w]}],"gradient-via":[{via:[w]}],"gradient-to":[{to:[w]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[E]}],"border-style":[{border:[...Y(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[E]}],"divide-style":[{divide:Y()}],"border-color":[{border:[o]}],"border-color-x":[{"border-x":[o]}],"border-color-y":[{"border-y":[o]}],"border-color-s":[{"border-s":[o]}],"border-color-e":[{"border-e":[o]}],"border-color-t":[{"border-t":[o]}],"border-color-r":[{"border-r":[o]}],"border-color-b":[{"border-b":[o]}],"border-color-l":[{"border-l":[o]}],"divide-color":[{divide:[o]}],"outline-style":[{outline:["",...Y()]}],"outline-offset":[{"outline-offset":[Oo,ot]}],"outline-w":[{outline:[Oo,fi]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:fe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[E]}],"ring-offset-w":[{"ring-offset":[Oo,fi]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",hi,UL]}],"shadow-color":[{shadow:[tc]}],opacity:[{opacity:[E]}],"mix-blend":[{"mix-blend":[...oe(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":oe()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",hi,ot]}],grayscale:[{grayscale:[h]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[g]}],saturate:[{saturate:[N]}],sepia:[{sepia:[_]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[h]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[p]}],"backdrop-invert":[{"backdrop-invert":[g]}],"backdrop-opacity":[{"backdrop-opacity":[E]}],"backdrop-saturate":[{"backdrop-saturate":[N]}],"backdrop-sepia":[{"backdrop-sepia":[_]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ot]}],duration:[{duration:te()}],ease:[{ease:["linear","in","out","in-out",ot]}],delay:[{delay:te()}],animate:[{animate:["none","spin","ping","pulse","bounce",ot]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[P]}],"scale-x":[{"scale-x":[P]}],"scale-y":[{"scale-y":[P]}],rotate:[{rotate:[ec,ot]}],"translate-x":[{"translate-x":[K]}],"translate-y":[{"translate-y":[K]}],"skew-x":[{"skew-x":[D]}],"skew-y":[{"skew-y":[D]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ot]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ot]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":se()}],"scroll-mx":[{"scroll-mx":se()}],"scroll-my":[{"scroll-my":se()}],"scroll-ms":[{"scroll-ms":se()}],"scroll-me":[{"scroll-me":se()}],"scroll-mt":[{"scroll-mt":se()}],"scroll-mr":[{"scroll-mr":se()}],"scroll-mb":[{"scroll-mb":se()}],"scroll-ml":[{"scroll-ml":se()}],"scroll-p":[{"scroll-p":se()}],"scroll-px":[{"scroll-px":se()}],"scroll-py":[{"scroll-py":se()}],"scroll-ps":[{"scroll-ps":se()}],"scroll-pe":[{"scroll-pe":se()}],"scroll-pt":[{"scroll-pt":se()}],"scroll-pr":[{"scroll-pr":se()}],"scroll-pb":[{"scroll-pb":se()}],"scroll-pl":[{"scroll-pl":se()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ot]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Oo,fi,ug]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}});function ze(...t){return KL(Ux(t))}function Gi(){let t=localStorage.getItem("dataLogin"),e;try{t&&(t=JSON.parse(t),e=t.user)}catch(n){console.error("Error parsing dataLogin from localStorage:",n),t=null}return e}const Fd=m.forwardRef(({className:t,...e},n)=>d.jsx("nav",{ref:n,"aria-label":"breadcrumb",className:ze("s3-explr-ui-breadcrumb",t),...e}));Fd.displayName="Breadcrumb";const $d=m.forwardRef(({className:t,...e},n)=>d.jsx("ol",{ref:n,className:ze("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5","s3-explr-ui-breadcrumb-list",t),...e}));$d.displayName="BreadcrumbList";const nc=m.forwardRef(({className:t,...e},n)=>d.jsx("li",{ref:n,className:ze("inline-flex items-center gap-1.5","s3-explr-ui-breadcrumb-item",t),...e}));nc.displayName="BreadcrumbItem";const rc=m.forwardRef(({asChild:t,className:e,...n},r)=>{const o=t?jx:"a";return d.jsx(o,{ref:r,className:ze("transition-colors hover:text-foreground","s3-explr-ui-breadcrumb-link",e),...n})});rc.displayName="BreadcrumbLink";const GL=m.forwardRef(({className:t,...e},n)=>d.jsx("span",{ref:n,role:"link","aria-disabled":"true","aria-current":"page",className:ze("font-normal text-foreground","s3-explr-ui-breadcrumb-page",t),...e}));GL.displayName="BreadcrumbPage";const Hd=({children:t,className:e,...n})=>d.jsx("li",{role:"presentation","aria-hidden":"true",className:ze("[&>svg]:w-3.5 [&>svg]:h-3.5","s3-explr-ui-breadcrumb-separator",e),...n,children:t??d.jsx(Fx,{})});Hd.displayName="BreadcrumbSeparator";const eS=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,tS=Ux,fg=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return tS(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:i}=e,s=Object.keys(o).map(h=>{const p=n==null?void 0:n[h],g=i==null?void 0:i[h];if(p===null)return null;const C=eS(p)||eS(g);return o[h][C]}),l=n&&Object.entries(n).reduce((h,p)=>{let[g,C]=p;return C===void 0||(h[g]=C),h},{}),u=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((h,p)=>{let{class:g,className:C,...w}=p;return Object.entries(w).every(b=>{let[v,x]=b;return Array.isArray(x)?x.includes({...i,...l}[v]):{...i,...l}[v]===x})?[...h,g,C]:h},[]);return tS(t,s,u,n==null?void 0:n.class,n==null?void 0:n.className)},nS=fg("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 s3-explr-ui-button",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90 s3-explr-ui-button-default",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 s3-explr-ui-button-destructive",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground s3-explr-ui-button-outline",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80 s3-explr-ui-button-secondary",ghost:"hover:bg-accent hover:text-accent-foreground s3-explr-ui-button-ghost",link:"text-primary underline-offset-4 hover:underline s3-explr-ui-button-link"},size:{default:"h-9 px-4 py-2 s3-explr-ui-button-size-default",sm:"h-8 rounded-md px-3 text-xs s3-explr-ui-button-size-sm",lg:"h-10 rounded-md px-8 s3-explr-ui-button-size-lg",icon:"h-9 w-9 s3-explr-ui-button-size-icon"}},defaultVariants:{variant:"default",size:"default"}}),He=m.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,...o},i)=>{const s=r?jx:"button";return d.jsx(s,{className:ze(nS({variant:e,size:n,className:t})),ref:i,...o})});He.displayName="Button";function rS(t){const e=m.useRef({value:t,previous:t});return m.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}function hg(t){const[e,n]=m.useState(void 0);return rn(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,l;if("borderBoxSize"in i){const u=i.borderBoxSize,h=Array.isArray(u)?u[0]:u;s=h.inlineSize,l=h.blockSize}else s=t.offsetWidth,l=t.offsetHeight;n({width:s,height:l})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var Ud="Checkbox",[jL,hW]=hr(Ud),[WL,pg]=jL(Ud);function qL(t){const{__scopeCheckbox:e,checked:n,children:r,defaultChecked:o,disabled:i,form:s,name:l,onCheckedChange:u,required:h,value:p="on",internal_do_not_use_render:g}=t,[C,w]=si({prop:n,defaultProp:o??!1,onChange:u,caller:Ud}),[b,v]=m.useState(null),[x,E]=m.useState(null),A=m.useRef(!1),N=b?!!s||!!b.closest("form"):!0,P={checked:C,disabled:i,setChecked:w,control:b,setControl:v,name:l,form:s,value:p,hasConsumerStoppedPropagationRef:A,required:h,defaultChecked:pi(o)?!1:o,isFormControl:N,bubbleInput:x,setBubbleInput:E};return d.jsx(WL,{scope:e,...P,children:YL(g)?g(P):r})}var oS="CheckboxTrigger",iS=m.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:n,...r},o)=>{const{control:i,value:s,disabled:l,checked:u,required:h,setControl:p,setChecked:g,hasConsumerStoppedPropagationRef:C,isFormControl:w,bubbleInput:b}=pg(oS,t),v=rt(o,p),x=m.useRef(u);return m.useEffect(()=>{const E=i==null?void 0:i.form;if(E){const A=()=>g(x.current);return E.addEventListener("reset",A),()=>E.removeEventListener("reset",A)}},[i,g]),d.jsx(mt.button,{type:"button",role:"checkbox","aria-checked":pi(u)?"mixed":u,"aria-required":h,"data-state":dS(u),"data-disabled":l?"":void 0,disabled:l,value:s,...r,ref:v,onKeyDown:Ue(e,E=>{E.key==="Enter"&&E.preventDefault()}),onClick:Ue(n,E=>{g(A=>pi(A)?!0:!A),b&&w&&(C.current=E.isPropagationStopped(),C.current||E.stopPropagation())})})});iS.displayName=oS;var gg=m.forwardRef((t,e)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:l,value:u,onCheckedChange:h,form:p,...g}=t;return d.jsx(qL,{__scopeCheckbox:n,checked:o,defaultChecked:i,disabled:l,required:s,onCheckedChange:h,name:r,form:p,value:u,internal_do_not_use_render:({isFormControl:C})=>d.jsxs(d.Fragment,{children:[d.jsx(iS,{...g,ref:e,__scopeCheckbox:n}),C&&d.jsx(lS,{__scopeCheckbox:n})]})})});gg.displayName=Ud;var aS="CheckboxIndicator",sS=m.forwardRef((t,e)=>{const{__scopeCheckbox:n,forceMount:r,...o}=t,i=pg(aS,n);return d.jsx(ko,{present:r||pi(i.checked)||i.checked===!0,children:d.jsx(mt.span,{"data-state":dS(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:e,style:{pointerEvents:"none",...t.style}})})});sS.displayName=aS;var cS="CheckboxBubbleInput",lS=m.forwardRef(({__scopeCheckbox:t,...e},n)=>{const{control:r,hasConsumerStoppedPropagationRef:o,checked:i,defaultChecked:s,required:l,disabled:u,name:h,value:p,form:g,bubbleInput:C,setBubbleInput:w}=pg(cS,t),b=rt(n,w),v=rS(i),x=hg(r);m.useEffect(()=>{const A=C;if(!A)return;const N=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(N,"checked").set,D=!o.current;if(v!==i&&_){const H=new Event("click",{bubbles:D});A.indeterminate=pi(i),_.call(A,pi(i)?!1:i),A.dispatchEvent(H)}},[C,v,i,o]);const E=m.useRef(pi(i)?!1:i);return d.jsx(mt.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??E.current,required:l,disabled:u,name:h,value:p,form:g,...e,tabIndex:-1,ref:b,style:{...e.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});lS.displayName=cS;function YL(t){return typeof t=="function"}function pi(t){return t==="indeterminate"}function dS(t){return pi(t)?"indeterminate":t?"checked":"unchecked"}const oc=m.forwardRef(({className:t,...e},n)=>d.jsx(gg,{ref:n,className:ze("s3-explr-ui-checkbox peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...e,children:d.jsx(sS,{className:ze("s3-explr-ui-checkbox-indicator flex items-center justify-center text-current"),children:d.jsx(Lx,{className:"s3-explr-ui-checkbox-check h-4 w-4"})})}));oc.displayName=gg.displayName;const or=Gs,ic=cM,JL=lM,uS=m.forwardRef(({className:t,...e},n)=>d.jsx(Ga,{ref:n,className:ze("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",t),...e}));uS.displayName=Ga.displayName;const Kn=m.forwardRef(({className:t,children:e,...n},r)=>d.jsxs(JL,{children:[d.jsx(uS,{}),d.jsxs(ja,{ref:r,className:ze("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",t),...n,children:[e,d.jsxs(Ep,{className:ze("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:[d.jsx(ig,{className:"s3-explr-ui-dialog-close-icon h-4 w-4"}),d.jsx("span",{className:"s3-explr-ui-dialog-close-text sr-only",children:"Close"})]})]})]}));Kn.displayName=ja.displayName;const Gn=({className:t,...e})=>d.jsx("div",{className:ze("s3-explr-ui-dialog-header flex flex-col space-y-1.5 text-center sm:text-left",t),...e});Gn.displayName="DialogHeader";const Lr=({className:t,...e})=>d.jsx("div",{className:ze("s3-explr-ui-dialog-footer flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});Lr.displayName="DialogFooter";const jn=m.forwardRef(({className:t,...e},n)=>d.jsx(kb,{ref:n,className:ze("s3-explr-ui-dialog-title text-lg font-semibold leading-none tracking-tight",t),...e}));jn.displayName=kb.displayName;const gi=m.forwardRef(({className:t,...e},n)=>d.jsx(Nb,{ref:n,className:ze("s3-explr-ui-dialog-description text-sm text-muted-foreground",t),...e}));gi.displayName=Nb.displayName;const Wn=m.forwardRef(({className:t,type:e,...n},r)=>d.jsx("input",{type:e,className:ze("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",t),ref:r,...n}));Wn.displayName="Input";var QL="Label",fS=m.forwardRef((t,e)=>d.jsx(mt.label,{...t,ref:e,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=t.onMouseDown)==null||o.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));fS.displayName=QL;var hS=fS;const XL=fg("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"}}),pr=m.forwardRef(({className:t,variant:e,size:n,...r},o)=>d.jsx(hS,{ref:o,className:ze(XL({variant:e,size:n}),t),...r}));pr.displayName=hS.displayName;const Bd=({className:t,...e})=>d.jsx("nav",{role:"navigation","aria-label":"pagination",className:ze("mx-auto flex w-full justify-center",t),...e});Bd.displayName="Pagination";const zd=m.forwardRef(({className:t,...e},n)=>d.jsx("ul",{ref:n,className:ze("flex flex-row items-center gap-1",t),...e}));zd.displayName="PaginationContent";const Fr=m.forwardRef(({className:t,...e},n)=>d.jsx("li",{ref:n,className:ze("",t),...e}));Fr.displayName="PaginationItem";const Qa=({className:t,isActive:e,size:n="icon",...r})=>d.jsx("a",{"aria-current":e?"page":void 0,className:ze(nS({variant:e?"outline":"ghost",size:n}),t),...r});Qa.displayName="PaginationLink";const Vd=({className:t,...e})=>d.jsxs(Qa,{"aria-label":"Go to previous page",size:"default",className:ze("gap-1 pl-2.5",t),...e,children:[d.jsx(UD,{className:"h-4 w-4"}),d.jsx("span",{children:"Previous"})]});Vd.displayName="PaginationPrevious";const Kd=({className:t,...e})=>d.jsxs(Qa,{"aria-label":"Go to next page",size:"default",className:ze("gap-1 pr-2.5",t),...e,children:[d.jsx("span",{children:"Next"}),d.jsx(Fx,{className:"h-4 w-4"})]});Kd.displayName="PaginationNext";const Gd=({className:t,...e})=>d.jsxs("span",{"aria-hidden":!0,className:ze("flex h-9 w-9 items-center justify-center",t),...e,children:[d.jsx(BD,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"More pages"})]});Gd.displayName="PaginationEllipsis";const jd=m.forwardRef(({className:t,...e},n)=>d.jsx("div",{className:ze("relative w-full overflow-auto","s3-explr-ui-table-container"),children:d.jsx("table",{ref:n,className:ze("w-full caption-bottom text-sm","s3-explr-ui-table",t),...e})}));jd.displayName="Table";const Wd=m.forwardRef(({className:t,...e},n)=>d.jsx("thead",{ref:n,className:ze("[&_tr]:border-b","s3-explr-ui-table-header",t),...e}));Wd.displayName="TableHeader";const qd=m.forwardRef(({className:t,...e},n)=>d.jsx("tbody",{ref:n,className:ze("[&_tr:last-child]:border-0","s3-explr-ui-table-body",t),...e}));qd.displayName="TableBody";const ZL=m.forwardRef(({className:t,...e},n)=>d.jsx("tfoot",{ref:n,className:ze("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0","s3-explr-ui-table-footer",t),...e}));ZL.displayName="TableFooter";const $r=m.forwardRef(({className:t,...e},n)=>d.jsx("tr",{ref:n,className:ze("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted","s3-explr-ui-table-row",t),...e}));$r.displayName="TableRow";const lo=m.forwardRef(({className:t,...e},n)=>d.jsx("th",{ref:n,className:ze("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",t),...e}));lo.displayName="TableHead";const qn=m.forwardRef(({className:t,...e},n)=>d.jsx("td",{ref:n,className:ze("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]","s3-explr-ui-table-cell",t),...e}));qn.displayName="TableCell";const eF=m.forwardRef(({className:t,...e},n)=>d.jsx("caption",{ref:n,className:ze("mt-4 text-sm text-muted-foreground","s3-explr-ui-table-caption",t),...e}));eF.displayName="TableCaption";function pS(t){const e=tF(t),n=m.forwardRef((r,o)=>{const{children:i,...s}=r,l=m.Children.toArray(i),u=l.find(rF);if(u){const h=u.props.children,p=l.map(g=>g===u?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return d.jsx(e,{...s,ref:o,children:m.isValidElement(h)?m.cloneElement(h,void 0,p):null})}return d.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}function tF(t){const e=m.forwardRef((n,r)=>{const{children:o,...i}=n,s=m.isValidElement(o)?iF(o):void 0,l=rt(s,r);if(m.isValidElement(o)){const u=oF(i,o.props);return o.type!==m.Fragment&&(u.ref=l),m.cloneElement(o,u)}return m.Children.count(o)>1?m.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var nF=Symbol("radix.slottable");function rF(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===nF}function oF(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function iF(t){var r,o;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function aF(t){const e=t+"CollectionProvider",[n,r]=hr(e),[o,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),s=v=>{const{scope:x,children:E}=v,A=O.useRef(null),N=O.useRef(new Map).current;return d.jsx(o,{scope:x,itemMap:N,collectionRef:A,children:E})};s.displayName=e;const l=t+"CollectionSlot",u=pS(l),h=O.forwardRef((v,x)=>{const{scope:E,children:A}=v,N=i(l,E),P=rt(x,N.collectionRef);return d.jsx(u,{ref:P,children:A})});h.displayName=l;const p=t+"CollectionItemSlot",g="data-radix-collection-item",C=pS(p),w=O.forwardRef((v,x)=>{const{scope:E,children:A,...N}=v,P=O.useRef(null),_=rt(x,P),D=i(p,E);return O.useEffect(()=>(D.itemMap.set(P,{ref:P,...N}),()=>void D.itemMap.delete(P))),d.jsx(C,{[g]:"",ref:_,children:A})});w.displayName=p;function b(v){const x=i(t+"CollectionConsumer",v);return O.useCallback(()=>{const A=x.collectionRef.current;if(!A)return[];const N=Array.from(A.querySelectorAll(`[${g}]`));return Array.from(x.itemMap.values()).sort((D,H)=>N.indexOf(D.ref.current)-N.indexOf(H.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:s,Slot:h,ItemSlot:w},b,r]}var sF=m.createContext(void 0);function mg(t){const e=m.useContext(sF);return t||e||"ltr"}var vg="rovingFocusGroup.onEntryFocus",cF={bubbles:!1,cancelable:!0},ac="RovingFocusGroup",[yg,gS,lF]=aF(ac),[dF,mS]=hr(ac,[lF]),[uF,fF]=dF(ac),vS=m.forwardRef((t,e)=>d.jsx(yg.Provider,{scope:t.__scopeRovingFocusGroup,children:d.jsx(yg.Slot,{scope:t.__scopeRovingFocusGroup,children:d.jsx(hF,{...t,ref:e})})}));vS.displayName=ac;var hF=m.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:p=!1,...g}=t,C=m.useRef(null),w=rt(e,C),b=mg(i),[v,x]=si({prop:s,defaultProp:l??null,onChange:u,caller:ac}),[E,A]=m.useState(!1),N=mn(h),P=gS(n),_=m.useRef(!1),[D,H]=m.useState(0);return m.useEffect(()=>{const K=C.current;if(K)return K.addEventListener(vg,N),()=>K.removeEventListener(vg,N)},[N]),d.jsx(uF,{scope:n,orientation:r,dir:b,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(K=>x(K),[x]),onItemShiftTab:m.useCallback(()=>A(!0),[]),onFocusableItemAdd:m.useCallback(()=>H(K=>K+1),[]),onFocusableItemRemove:m.useCallback(()=>H(K=>K-1),[]),children:d.jsx(mt.div,{tabIndex:E||D===0?-1:0,"data-orientation":r,...g,ref:w,style:{outline:"none",...t.style},onMouseDown:Ue(t.onMouseDown,()=>{_.current=!0}),onFocus:Ue(t.onFocus,K=>{const ee=!_.current;if(K.target===K.currentTarget&&ee&&!E){const W=new CustomEvent(vg,cF);if(K.currentTarget.dispatchEvent(W),!W.defaultPrevented){const de=P().filter(Y=>Y.focusable),se=de.find(Y=>Y.active),fe=de.find(Y=>Y.id===v),Z=[se,fe,...de].filter(Boolean).map(Y=>Y.ref.current);CS(Z,p)}}_.current=!1}),onBlur:Ue(t.onBlur,()=>A(!1))})})}),yS="RovingFocusGroupItem",wS=m.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:s,...l}=t,u=Io(),h=i||u,p=fF(yS,n),g=p.currentTabStopId===h,C=gS(n),{onFocusableItemAdd:w,onFocusableItemRemove:b,currentTabStopId:v}=p;return m.useEffect(()=>{if(r)return w(),()=>b()},[r,w,b]),d.jsx(yg.ItemSlot,{scope:n,id:h,focusable:r,active:o,children:d.jsx(mt.span,{tabIndex:g?0:-1,"data-orientation":p.orientation,...l,ref:e,onMouseDown:Ue(t.onMouseDown,x=>{r?p.onItemFocus(h):x.preventDefault()}),onFocus:Ue(t.onFocus,()=>p.onItemFocus(h)),onKeyDown:Ue(t.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){p.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const E=mF(x,p.orientation,p.dir);if(E!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let N=C().filter(P=>P.focusable).map(P=>P.ref.current);if(E==="last")N.reverse();else if(E==="prev"||E==="next"){E==="prev"&&N.reverse();const P=N.indexOf(x.currentTarget);N=p.loop?vF(N,P+1):N.slice(P+1)}setTimeout(()=>CS(N))}}),children:typeof s=="function"?s({isCurrentTabStop:g,hasTabStop:v!=null}):s})})});wS.displayName=yS;var pF={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function gF(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function mF(t,e,n){const r=gF(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return pF[r]}function CS(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function vF(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var yF=vS,wF=wS,Yd="Tabs",[CF,pW]=hr(Yd,[mS]),bS=mS(),[bF,wg]=CF(Yd),xS=m.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:l,activationMode:u="automatic",...h}=t,p=mg(l),[g,C]=si({prop:r,onChange:o,defaultProp:i??"",caller:Yd});return d.jsx(bF,{scope:n,baseId:Io(),value:g,onValueChange:C,orientation:s,dir:p,activationMode:u,children:d.jsx(mt.div,{dir:p,"data-orientation":s,...h,ref:e})})});xS.displayName=Yd;var SS="TabsList",_S=m.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...o}=t,i=wg(SS,n),s=bS(n);return d.jsx(yF,{asChild:!0,...s,orientation:i.orientation,dir:i.dir,loop:r,children:d.jsx(mt.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:e})})});_S.displayName=SS;var ES="TabsTrigger",TS=m.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=t,s=wg(ES,n),l=bS(n),u=kS(s.baseId,r),h=NS(s.baseId,r),p=r===s.value;return d.jsx(wF,{asChild:!0,...l,focusable:!o,active:p,children:d.jsx(mt.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":h,"data-state":p?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...i,ref:e,onMouseDown:Ue(t.onMouseDown,g=>{!o&&g.button===0&&g.ctrlKey===!1?s.onValueChange(r):g.preventDefault()}),onKeyDown:Ue(t.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&s.onValueChange(r)}),onFocus:Ue(t.onFocus,()=>{const g=s.activationMode!=="manual";!p&&!o&&g&&s.onValueChange(r)})})})});TS.displayName=ES;var AS="TabsContent",IS=m.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=t,l=wg(AS,n),u=kS(l.baseId,r),h=NS(l.baseId,r),p=r===l.value,g=m.useRef(p);return m.useEffect(()=>{const C=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(C)},[]),d.jsx(ko,{present:o||p,children:({present:C})=>d.jsx(mt.div,{"data-state":p?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":u,hidden:!C,id:h,tabIndex:0,...s,ref:e,style:{...t.style,animationDuration:g.current?"0s":void 0},children:C&&i})})});IS.displayName=AS;function kS(t,e){return`${t}-trigger-${e}`}function NS(t,e){return`${t}-content-${e}`}var xF=xS,PS=_S,OS=TS,MS=IS;const Cg=xF,Jd=m.forwardRef(({className:t,...e},n)=>d.jsx(PS,{ref:n,className:ze("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));Jd.displayName=PS.displayName;const ji=m.forwardRef(({className:t,...e},n)=>d.jsx(OS,{ref:n,className:ze("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",t),...e}));ji.displayName=OS.displayName;const Wi=m.forwardRef(({className:t,...e},n)=>d.jsx(MS,{ref:n,className:ze("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));Wi.displayName=MS.displayName;const sc=m.forwardRef(({className:t,...e},n)=>d.jsx("textarea",{className:ze("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",t),ref:n,...e}));sc.displayName="Textarea";function RS(t){const e=SF(t),n=m.forwardRef((r,o)=>{const{children:i,...s}=r,l=m.Children.toArray(i),u=l.find(EF);if(u){const h=u.props.children,p=l.map(g=>g===u?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return d.jsx(e,{...s,ref:o,children:m.isValidElement(h)?m.cloneElement(h,void 0,p):null})}return d.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}function SF(t){const e=m.forwardRef((n,r)=>{const{children:o,...i}=n,s=m.isValidElement(o)?AF(o):void 0,l=rt(s,r);if(m.isValidElement(o)){const u=TF(i,o.props);return o.type!==m.Fragment&&(u.ref=l),m.cloneElement(o,u)}return m.Children.count(o)>1?m.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var _F=Symbol("radix.slottable");function EF(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===_F}function TF(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function AF(t){var r,o;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function IF(t){const e=t+"CollectionProvider",[n,r]=hr(e),[o,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),s=v=>{const{scope:x,children:E}=v,A=O.useRef(null),N=O.useRef(new Map).current;return d.jsx(o,{scope:x,itemMap:N,collectionRef:A,children:E})};s.displayName=e;const l=t+"CollectionSlot",u=RS(l),h=O.forwardRef((v,x)=>{const{scope:E,children:A}=v,N=i(l,E),P=rt(x,N.collectionRef);return d.jsx(u,{ref:P,children:A})});h.displayName=l;const p=t+"CollectionItemSlot",g="data-radix-collection-item",C=RS(p),w=O.forwardRef((v,x)=>{const{scope:E,children:A,...N}=v,P=O.useRef(null),_=rt(x,P),D=i(p,E);return O.useEffect(()=>(D.itemMap.set(P,{ref:P,...N}),()=>void D.itemMap.delete(P))),d.jsx(C,{[g]:"",ref:_,children:A})});w.displayName=p;function b(v){const x=i(t+"CollectionConsumer",v);return O.useCallback(()=>{const A=x.collectionRef.current;if(!A)return[];const N=Array.from(A.querySelectorAll(`[${g}]`));return Array.from(x.itemMap.values()).sort((D,H)=>N.indexOf(D.ref.current)-N.indexOf(H.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:s,Slot:h,ItemSlot:w},b,r]}var kF=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),NF="VisuallyHidden",bg=m.forwardRef((t,e)=>d.jsx(mt.span,{...t,ref:e,style:{...kF,...t.style}}));bg.displayName=NF;var xg="ToastProvider",[Sg,PF,OF]=IF("Toast"),[DS,gW]=hr("Toast",[OF]),[MF,Qd]=DS(xg),LS=t=>{const{__scopeToast:e,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:i=50,children:s}=t,[l,u]=m.useState(null),[h,p]=m.useState(0),g=m.useRef(!1),C=m.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${xg}\`. Expected non-empty \`string\`.`),d.jsx(Sg.Provider,{scope:e,children:d.jsx(MF,{scope:e,label:n,duration:r,swipeDirection:o,swipeThreshold:i,toastCount:h,viewport:l,onViewportChange:u,onToastAdd:m.useCallback(()=>p(w=>w+1),[]),onToastRemove:m.useCallback(()=>p(w=>w-1),[]),isFocusedToastEscapeKeyDownRef:g,isClosePausedRef:C,children:s})})};LS.displayName=xg;var FS="ToastViewport",RF=["F8"],_g="toast.viewportPause",Eg="toast.viewportResume",$S=m.forwardRef((t,e)=>{const{__scopeToast:n,hotkey:r=RF,label:o="Notifications ({hotkey})",...i}=t,s=Qd(FS,n),l=PF(n),u=m.useRef(null),h=m.useRef(null),p=m.useRef(null),g=m.useRef(null),C=rt(e,g,s.onViewportChange),w=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),b=s.toastCount>0;m.useEffect(()=>{const x=E=>{var N;r.length!==0&&r.every(P=>E[P]||E.code===P)&&((N=g.current)==null||N.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),m.useEffect(()=>{const x=u.current,E=g.current;if(b&&x&&E){const A=()=>{if(!s.isClosePausedRef.current){const D=new CustomEvent(_g);E.dispatchEvent(D),s.isClosePausedRef.current=!0}},N=()=>{if(s.isClosePausedRef.current){const D=new CustomEvent(Eg);E.dispatchEvent(D),s.isClosePausedRef.current=!1}},P=D=>{!x.contains(D.relatedTarget)&&N()},_=()=>{x.contains(document.activeElement)||N()};return x.addEventListener("focusin",A),x.addEventListener("focusout",P),x.addEventListener("pointermove",A),x.addEventListener("pointerleave",_),window.addEventListener("blur",A),window.addEventListener("focus",N),()=>{x.removeEventListener("focusin",A),x.removeEventListener("focusout",P),x.removeEventListener("pointermove",A),x.removeEventListener("pointerleave",_),window.removeEventListener("blur",A),window.removeEventListener("focus",N)}}},[b,s.isClosePausedRef]);const v=m.useCallback(({tabbingDirection:x})=>{const A=l().map(N=>{const P=N.ref.current,_=[P,...WF(P)];return x==="forwards"?_:_.reverse()});return(x==="forwards"?A.reverse():A).flat()},[l]);return m.useEffect(()=>{const x=g.current;if(x){const E=A=>{var _,D,H;const N=A.altKey||A.ctrlKey||A.metaKey;if(A.key==="Tab"&&!N){const K=document.activeElement,ee=A.shiftKey;if(A.target===x&&ee){(_=h.current)==null||_.focus();return}const se=v({tabbingDirection:ee?"backwards":"forwards"}),fe=se.findIndex(q=>q===K);Ig(se.slice(fe+1))?A.preventDefault():ee?(D=h.current)==null||D.focus():(H=p.current)==null||H.focus()}};return x.addEventListener("keydown",E),()=>x.removeEventListener("keydown",E)}},[l,v]),d.jsxs(QO,{ref:u,role:"region","aria-label":o.replace("{hotkey}",w),tabIndex:-1,style:{pointerEvents:b?void 0:"none"},children:[b&&d.jsx(Tg,{ref:h,onFocusFromOutsideViewport:()=>{const x=v({tabbingDirection:"forwards"});Ig(x)}}),d.jsx(Sg.Slot,{scope:n,children:d.jsx(mt.ol,{tabIndex:-1,...i,ref:C})}),b&&d.jsx(Tg,{ref:p,onFocusFromOutsideViewport:()=>{const x=v({tabbingDirection:"backwards"});Ig(x)}})]})});$S.displayName=FS;var HS="ToastFocusProxy",Tg=m.forwardRef((t,e)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=t,i=Qd(HS,n);return d.jsx(bg,{"aria-hidden":!0,tabIndex:0,...o,ref:e,style:{position:"fixed"},onFocus:s=>{var h;const l=s.relatedTarget;!((h=i.viewport)!=null&&h.contains(l))&&r()}})});Tg.displayName=HS;var cc="Toast",DF="toast.swipeStart",LF="toast.swipeMove",FF="toast.swipeCancel",$F="toast.swipeEnd",US=m.forwardRef((t,e)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:i,...s}=t,[l,u]=si({prop:r,defaultProp:o??!0,onChange:i,caller:cc});return d.jsx(ko,{present:n||l,children:d.jsx(BF,{open:l,...s,ref:e,onClose:()=>u(!1),onPause:mn(t.onPause),onResume:mn(t.onResume),onSwipeStart:Ue(t.onSwipeStart,h=>{h.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Ue(t.onSwipeMove,h=>{const{x:p,y:g}=h.detail.delta;h.currentTarget.setAttribute("data-swipe","move"),h.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${p}px`),h.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${g}px`)}),onSwipeCancel:Ue(t.onSwipeCancel,h=>{h.currentTarget.setAttribute("data-swipe","cancel"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),h.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),h.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Ue(t.onSwipeEnd,h=>{const{x:p,y:g}=h.detail.delta;h.currentTarget.setAttribute("data-swipe","end"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),h.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${p}px`),h.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${g}px`),u(!1)})})})});US.displayName=cc;var[HF,UF]=DS(cc,{onClose(){}}),BF=m.forwardRef((t,e)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:i,onClose:s,onEscapeKeyDown:l,onPause:u,onResume:h,onSwipeStart:p,onSwipeMove:g,onSwipeCancel:C,onSwipeEnd:w,...b}=t,v=Qd(cc,n),[x,E]=m.useState(null),A=rt(e,q=>E(q)),N=m.useRef(null),P=m.useRef(null),_=o||v.duration,D=m.useRef(0),H=m.useRef(_),K=m.useRef(0),{onToastAdd:ee,onToastRemove:W}=v,de=mn(()=>{var Z;(x==null?void 0:x.contains(document.activeElement))&&((Z=v.viewport)==null||Z.focus()),s()}),se=m.useCallback(q=>{!q||q===1/0||(window.clearTimeout(K.current),D.current=new Date().getTime(),K.current=window.setTimeout(de,q))},[de]);m.useEffect(()=>{const q=v.viewport;if(q){const Z=()=>{se(H.current),h==null||h()},Y=()=>{const oe=new Date().getTime()-D.current;H.current=H.current-oe,window.clearTimeout(K.current),u==null||u()};return q.addEventListener(_g,Y),q.addEventListener(Eg,Z),()=>{q.removeEventListener(_g,Y),q.removeEventListener(Eg,Z)}}},[v.viewport,_,u,h,se]),m.useEffect(()=>{i&&!v.isClosePausedRef.current&&se(_)},[i,_,v.isClosePausedRef,se]),m.useEffect(()=>(ee(),()=>W()),[ee,W]);const fe=m.useMemo(()=>x?WS(x):null,[x]);return v.viewport?d.jsxs(d.Fragment,{children:[fe&&d.jsx(zF,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0,children:fe}),d.jsx(HF,{scope:n,onClose:de,children:Aa.createPortal(d.jsx(Sg.ItemSlot,{scope:n,children:d.jsx(JO,{asChild:!0,onEscapeKeyDown:Ue(l,()=>{v.isFocusedToastEscapeKeyDownRef.current||de(),v.isFocusedToastEscapeKeyDownRef.current=!1}),children:d.jsx(mt.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":i?"open":"closed","data-swipe-direction":v.swipeDirection,...b,ref:A,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Ue(t.onKeyDown,q=>{q.key==="Escape"&&(l==null||l(q.nativeEvent),q.nativeEvent.defaultPrevented||(v.isFocusedToastEscapeKeyDownRef.current=!0,de()))}),onPointerDown:Ue(t.onPointerDown,q=>{q.button===0&&(N.current={x:q.clientX,y:q.clientY})}),onPointerMove:Ue(t.onPointerMove,q=>{if(!N.current)return;const Z=q.clientX-N.current.x,Y=q.clientY-N.current.y,oe=!!P.current,Q=["left","right"].includes(v.swipeDirection),X=["left","up"].includes(v.swipeDirection)?Math.min:Math.max,$=Q?X(0,Z):0,te=Q?0:X(0,Y),_e=q.pointerType==="touch"?10:2,ke={x:$,y:te},xe={originalEvent:q,delta:ke};oe?(P.current=ke,Xd(LF,g,xe,{discrete:!1})):qS(ke,v.swipeDirection,_e)?(P.current=ke,Xd(DF,p,xe,{discrete:!1}),q.target.setPointerCapture(q.pointerId)):(Math.abs(Z)>_e||Math.abs(Y)>_e)&&(N.current=null)}),onPointerUp:Ue(t.onPointerUp,q=>{const Z=P.current,Y=q.target;if(Y.hasPointerCapture(q.pointerId)&&Y.releasePointerCapture(q.pointerId),P.current=null,N.current=null,Z){const oe=q.currentTarget,Q={originalEvent:q,delta:Z};qS(Z,v.swipeDirection,v.swipeThreshold)?Xd($F,w,Q,{discrete:!0}):Xd(FF,C,Q,{discrete:!0}),oe.addEventListener("click",X=>X.preventDefault(),{once:!0})}})})})}),v.viewport)})]}):null}),zF=t=>{const{__scopeToast:e,children:n,...r}=t,o=Qd(cc,e),[i,s]=m.useState(!1),[l,u]=m.useState(!1);return GF(()=>s(!0)),m.useEffect(()=>{const h=window.setTimeout(()=>u(!0),1e3);return()=>window.clearTimeout(h)},[]),l?null:d.jsx(od,{asChild:!0,children:d.jsx(bg,{...r,children:i&&d.jsxs(d.Fragment,{children:[o.label," ",n]})})})},VF="ToastTitle",BS=m.forwardRef((t,e)=>{const{__scopeToast:n,...r}=t;return d.jsx(mt.div,{...r,ref:e})});BS.displayName=VF;var KF="ToastDescription",zS=m.forwardRef((t,e)=>{const{__scopeToast:n,...r}=t;return d.jsx(mt.div,{...r,ref:e})});zS.displayName=KF;var VS="ToastAction",KS=m.forwardRef((t,e)=>{const{altText:n,...r}=t;return n.trim()?d.jsx(jS,{altText:n,asChild:!0,children:d.jsx(Ag,{...r,ref:e})}):(console.error(`Invalid prop \`altText\` supplied to \`${VS}\`. Expected non-empty \`string\`.`),null)});KS.displayName=VS;var GS="ToastClose",Ag=m.forwardRef((t,e)=>{const{__scopeToast:n,...r}=t,o=UF(GS,n);return d.jsx(jS,{asChild:!0,children:d.jsx(mt.button,{type:"button",...r,ref:e,onClick:Ue(t.onClick,o.onClose)})})});Ag.displayName=GS;var jS=m.forwardRef((t,e)=>{const{__scopeToast:n,altText:r,...o}=t;return d.jsx(mt.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:e})});function WS(t){const e=[];return Array.from(t.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&e.push(r.textContent),jF(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",i=r.dataset.radixToastAnnounceExclude==="";if(!o)if(i){const s=r.dataset.radixToastAnnounceAlt;s&&e.push(s)}else e.push(...WS(r))}}),e}function Xd(t,e,n,{discrete:r}){const o=n.originalEvent.currentTarget,i=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n});e&&o.addEventListener(t,e,{once:!0}),r?LC(o,i):o.dispatchEvent(i)}var qS=(t,e,n=0)=>{const r=Math.abs(t.x),o=Math.abs(t.y),i=r>o;return e==="left"||e==="right"?i&&r>n:!i&&o>n};function GF(t=()=>{}){const e=mn(t);rn(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(e)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[e])}function jF(t){return t.nodeType===t.ELEMENT_NODE}function WF(t){const e=[],n=document.createTreeWalker(t,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();)e.push(n.currentNode);return e}function Ig(t){const e=document.activeElement;return t.some(n=>n===e?!0:(n.focus(),document.activeElement!==e))}var qF=LS,YS=$S,JS=US,QS=BS,XS=zS,ZS=KS,e_=Ag;const YF=qF,t_=m.forwardRef(({className:t,...e},n)=>d.jsx(YS,{ref:n,className:ze("s3-explr-ui-toast-viewport fixed top-0 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] z-[10000]",t),...e}));t_.displayName=YS.displayName;const JF=fg("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"}}),n_=m.forwardRef(({className:t,variant:e,...n},r)=>d.jsx(JS,{ref:r,className:ze(JF({variant:e}),t),...n}));n_.displayName=JS.displayName;const QF=m.forwardRef(({className:t,...e},n)=>d.jsx(ZS,{ref:n,className:ze("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",t),...e}));QF.displayName=ZS.displayName;const r_=m.forwardRef(({className:t,...e},n)=>d.jsx(e_,{ref:n,className:ze("absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity duration-200 ease-in-out 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 font-bold",t),"toast-close":"",...e,children:d.jsx(ig,{className:"s3-explr-ui-toast-close-icon h-4 w-4"})}));r_.displayName=e_.displayName;const o_=m.forwardRef(({className:t,...e},n)=>d.jsx(QS,{ref:n,className:ze("s3-explr-ui-toast-title text-sm font-semibold [&+div]:text-xs",t),...e}));o_.displayName=QS.displayName;const i_=m.forwardRef(({className:t,...e},n)=>d.jsx(XS,{ref:n,className:ze("text-sm opacity-90 font-bold",t),...e}));i_.displayName=XS.displayName;const XF=1,ZF=1e6;let kg=0;function e2(){return kg=(kg+1)%Number.MAX_SAFE_INTEGER,kg.toString()}const Ng=new Map,a_=t=>{if(Ng.has(t))return;const e=setTimeout(()=>{Ng.delete(t),lc({type:"REMOVE_TOAST",toastId:t})},ZF);Ng.set(t,e)},t2=(t,e)=>{switch(e.type){case"ADD_TOAST":return{...t,toasts:[e.toast,...t.toasts].slice(0,XF)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(n=>n.id===e.toast.id?{...n,...e.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=e;return n?a_(n):t.toasts.forEach(r=>{a_(r.id)}),{...t,toasts:t.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return e.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(n=>n.id!==e.toastId)}}},Zd=[];let eu={toasts:[]};function lc(t){eu=t2(eu,t),Zd.forEach(e=>{e(eu)})}function n2({...t}){const e=e2(),n=o=>lc({type:"UPDATE_TOAST",toast:{...o,id:e}}),r=()=>lc({type:"DISMISS_TOAST",toastId:e});return lc({type:"ADD_TOAST",toast:{...t,id:e,open:!0,onOpenChange:o=>{o||r()}}}),{id:e,dismiss:r,update:n}}function dc(){const[t,e]=m.useState(eu);return m.useEffect(()=>(Zd.push(e),()=>{const n=Zd.indexOf(e);n>-1&&Zd.splice(n,1)}),[t]),{...t,toast:n2,dismiss:n=>lc({type:"DISMISS_TOAST",toastId:n})}}function s_(){const{toasts:t}=dc();return d.jsxs(YF,{children:[t.map(function({id:e,title:n,description:r,action:o,...i}){return d.jsxs(n_,{...i,className:`s3-explr-ui-toast ${i.className||""}`,children:[d.jsxs("div",{className:"s3-explr-ui-toast-content grid gap-1",children:[n&&d.jsx(o_,{className:"s3-explr-ui-toast-title",children:n}),r&&d.jsx(i_,{className:"s3-explr-ui-toast-description",children:r})]}),o&&d.jsx("div",{className:"s3-explr-ui-toast-action",children:o}),d.jsx(r_,{className:"s3-explr-ui-toast-close"})]},e)}),d.jsx(t_,{className:"s3-explr-ui-toast-viewport"})]})}const r2=["top","right","bottom","left"],mi=Math.min,ir=Math.max,tu=Math.round,nu=Math.floor,uo=t=>({x:t,y:t}),o2={left:"right",right:"left",bottom:"top",top:"bottom"},i2={start:"end",end:"start"};function Pg(t,e,n){return ir(t,mi(e,n))}function Mo(t,e){return typeof t=="function"?t(e):t}function Ro(t){return t.split("-")[0]}function Xa(t){return t.split("-")[1]}function Og(t){return t==="x"?"y":"x"}function Mg(t){return t==="y"?"height":"width"}function Do(t){return["top","bottom"].includes(Ro(t))?"y":"x"}function Rg(t){return Og(Do(t))}function a2(t,e,n){n===void 0&&(n=!1);const r=Xa(t),o=Rg(t),i=Mg(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=ru(s)),[s,ru(s)]}function s2(t){const e=ru(t);return[Dg(t),e,Dg(e)]}function Dg(t){return t.replace(/start|end/g,e=>i2[e])}function c2(t,e,n){const r=["left","right"],o=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(t){case"top":case"bottom":return n?e?o:r:e?r:o;case"left":case"right":return e?i:s;default:return[]}}function l2(t,e,n,r){const o=Xa(t);let i=c2(Ro(t),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),e&&(i=i.concat(i.map(Dg)))),i}function ru(t){return t.replace(/left|right|bottom|top/g,e=>o2[e])}function d2(t){return{top:0,right:0,bottom:0,left:0,...t}}function c_(t){return typeof t!="number"?d2(t):{top:t,right:t,bottom:t,left:t}}function ou(t){const{x:e,y:n,width:r,height:o}=t;return{width:r,height:o,top:n,left:e,right:e+r,bottom:n+o,x:e,y:n}}function l_(t,e,n){let{reference:r,floating:o}=t;const i=Do(e),s=Rg(e),l=Mg(s),u=Ro(e),h=i==="y",p=r.x+r.width/2-o.width/2,g=r.y+r.height/2-o.height/2,C=r[l]/2-o[l]/2;let w;switch(u){case"top":w={x:p,y:r.y-o.height};break;case"bottom":w={x:p,y:r.y+r.height};break;case"right":w={x:r.x+r.width,y:g};break;case"left":w={x:r.x-o.width,y:g};break;default:w={x:r.x,y:r.y}}switch(Xa(e)){case"start":w[s]-=C*(n&&h?-1:1);break;case"end":w[s]+=C*(n&&h?-1:1);break}return w}const u2=async(t,e,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,l=i.filter(Boolean),u=await(s.isRTL==null?void 0:s.isRTL(e));let h=await s.getElementRects({reference:t,floating:e,strategy:o}),{x:p,y:g}=l_(h,r,u),C=r,w={},b=0;for(let v=0;v<l.length;v++){const{name:x,fn:E}=l[v],{x:A,y:N,data:P,reset:_}=await E({x:p,y:g,initialPlacement:r,placement:C,strategy:o,middlewareData:w,rects:h,platform:s,elements:{reference:t,floating:e}});p=A??p,g=N??g,w={...w,[x]:{...w[x],...P}},_&&b<=50&&(b++,typeof _=="object"&&(_.placement&&(C=_.placement),_.rects&&(h=_.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:o}):_.rects),{x:p,y:g}=l_(h,C,u)),v=-1)}return{x:p,y:g,placement:C,strategy:o,middlewareData:w}};async function uc(t,e){var n;e===void 0&&(e={});const{x:r,y:o,platform:i,rects:s,elements:l,strategy:u}=t,{boundary:h="clippingAncestors",rootBoundary:p="viewport",elementContext:g="floating",altBoundary:C=!1,padding:w=0}=Mo(e,t),b=c_(w),x=l[C?g==="floating"?"reference":"floating":g],E=ou(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(x)))==null||n?x:x.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:h,rootBoundary:p,strategy:u})),A=g==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,N=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),P=await(i.isElement==null?void 0:i.isElement(N))?await(i.getScale==null?void 0:i.getScale(N))||{x:1,y:1}:{x:1,y:1},_=ou(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:A,offsetParent:N,strategy:u}):A);return{top:(E.top-_.top+b.top)/P.y,bottom:(_.bottom-E.bottom+b.bottom)/P.y,left:(E.left-_.left+b.left)/P.x,right:(_.right-E.right+b.right)/P.x}}const f2=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:o,rects:i,platform:s,elements:l,middlewareData:u}=e,{element:h,padding:p=0}=Mo(t,e)||{};if(h==null)return{};const g=c_(p),C={x:n,y:r},w=Rg(o),b=Mg(w),v=await s.getDimensions(h),x=w==="y",E=x?"top":"left",A=x?"bottom":"right",N=x?"clientHeight":"clientWidth",P=i.reference[b]+i.reference[w]-C[w]-i.floating[b],_=C[w]-i.reference[w],D=await(s.getOffsetParent==null?void 0:s.getOffsetParent(h));let H=D?D[N]:0;(!H||!await(s.isElement==null?void 0:s.isElement(D)))&&(H=l.floating[N]||i.floating[b]);const K=P/2-_/2,ee=H/2-v[b]/2-1,W=mi(g[E],ee),de=mi(g[A],ee),se=W,fe=H-v[b]-de,q=H/2-v[b]/2+K,Z=Pg(se,q,fe),Y=!u.arrow&&Xa(o)!=null&&q!==Z&&i.reference[b]/2-(q<se?W:de)-v[b]/2<0,oe=Y?q<se?q-se:q-fe:0;return{[w]:C[w]+oe,data:{[w]:Z,centerOffset:q-Z-oe,...Y&&{alignmentOffset:oe}},reset:Y}}}),h2=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:l,platform:u,elements:h}=e,{mainAxis:p=!0,crossAxis:g=!0,fallbackPlacements:C,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:v=!0,...x}=Mo(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const E=Ro(o),A=Do(l),N=Ro(l)===l,P=await(u.isRTL==null?void 0:u.isRTL(h.floating)),_=C||(N||!v?[ru(l)]:s2(l)),D=b!=="none";!C&&D&&_.push(...l2(l,v,b,P));const H=[l,..._],K=await uc(e,x),ee=[];let W=((r=i.flip)==null?void 0:r.overflows)||[];if(p&&ee.push(K[E]),g){const Z=a2(o,s,P);ee.push(K[Z[0]],K[Z[1]])}if(W=[...W,{placement:o,overflows:ee}],!ee.every(Z=>Z<=0)){var de,se;const Z=(((de=i.flip)==null?void 0:de.index)||0)+1,Y=H[Z];if(Y){var fe;const Q=g==="alignment"?A!==Do(Y):!1,X=((fe=W[0])==null?void 0:fe.overflows[0])>0;if(!Q||X)return{data:{index:Z,overflows:W},reset:{placement:Y}}}let oe=(se=W.filter(Q=>Q.overflows[0]<=0).sort((Q,X)=>Q.overflows[1]-X.overflows[1])[0])==null?void 0:se.placement;if(!oe)switch(w){case"bestFit":{var q;const Q=(q=W.filter(X=>{if(D){const $=Do(X.placement);return $===A||$==="y"}return!0}).map(X=>[X.placement,X.overflows.filter($=>$>0).reduce(($,te)=>$+te,0)]).sort((X,$)=>X[1]-$[1])[0])==null?void 0:q[0];Q&&(oe=Q);break}case"initialPlacement":oe=l;break}if(o!==oe)return{reset:{placement:oe}}}return{}}}};function d_(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function u_(t){return r2.some(e=>t[e]>=0)}const p2=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...o}=Mo(t,e);switch(r){case"referenceHidden":{const i=await uc(e,{...o,elementContext:"reference"}),s=d_(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:u_(s)}}}case"escaped":{const i=await uc(e,{...o,altBoundary:!0}),s=d_(i,n.floating);return{data:{escapedOffsets:s,escaped:u_(s)}}}default:return{}}}}};async function g2(t,e){const{placement:n,platform:r,elements:o}=t,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=Ro(n),l=Xa(n),u=Do(n)==="y",h=["left","top"].includes(s)?-1:1,p=i&&u?-1:1,g=Mo(e,t);let{mainAxis:C,crossAxis:w,alignmentAxis:b}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return l&&typeof b=="number"&&(w=l==="end"?b*-1:b),u?{x:w*p,y:C*h}:{x:C*h,y:w*p}}const m2=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:o,y:i,placement:s,middlewareData:l}=e,u=await g2(e,t);return s===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:i+u.y,data:{...u,placement:s}}}}},v2=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:o}=e,{mainAxis:i=!0,crossAxis:s=!1,limiter:l={fn:x=>{let{x:E,y:A}=x;return{x:E,y:A}}},...u}=Mo(t,e),h={x:n,y:r},p=await uc(e,u),g=Do(Ro(o)),C=Og(g);let w=h[C],b=h[g];if(i){const x=C==="y"?"top":"left",E=C==="y"?"bottom":"right",A=w+p[x],N=w-p[E];w=Pg(A,w,N)}if(s){const x=g==="y"?"top":"left",E=g==="y"?"bottom":"right",A=b+p[x],N=b-p[E];b=Pg(A,b,N)}const v=l.fn({...e,[C]:w,[g]:b});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[C]:i,[g]:s}}}}}},y2=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=e,{offset:l=0,mainAxis:u=!0,crossAxis:h=!0}=Mo(t,e),p={x:n,y:r},g=Do(o),C=Og(g);let w=p[C],b=p[g];const v=Mo(l,e),x=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(u){const N=C==="y"?"height":"width",P=i.reference[C]-i.floating[N]+x.mainAxis,_=i.reference[C]+i.reference[N]-x.mainAxis;w<P?w=P:w>_&&(w=_)}if(h){var E,A;const N=C==="y"?"width":"height",P=["top","left"].includes(Ro(o)),_=i.reference[g]-i.floating[N]+(P&&((E=s.offset)==null?void 0:E[g])||0)+(P?0:x.crossAxis),D=i.reference[g]+i.reference[N]+(P?0:((A=s.offset)==null?void 0:A[g])||0)-(P?x.crossAxis:0);b<_?b=_:b>D&&(b=D)}return{[C]:w,[g]:b}}}},w2=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:o,rects:i,platform:s,elements:l}=e,{apply:u=()=>{},...h}=Mo(t,e),p=await uc(e,h),g=Ro(o),C=Xa(o),w=Do(o)==="y",{width:b,height:v}=i.floating;let x,E;g==="top"||g==="bottom"?(x=g,E=C===(await(s.isRTL==null?void 0:s.isRTL(l.floating))?"start":"end")?"left":"right"):(E=g,x=C==="end"?"top":"bottom");const A=v-p.top-p.bottom,N=b-p.left-p.right,P=mi(v-p[x],A),_=mi(b-p[E],N),D=!e.middlewareData.shift;let H=P,K=_;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(K=N),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(H=A),D&&!C){const W=ir(p.left,0),de=ir(p.right,0),se=ir(p.top,0),fe=ir(p.bottom,0);w?K=b-2*(W!==0||de!==0?W+de:ir(p.left,p.right)):H=v-2*(se!==0||fe!==0?se+fe:ir(p.top,p.bottom))}await u({...e,availableWidth:K,availableHeight:H});const ee=await s.getDimensions(l.floating);return b!==ee.width||v!==ee.height?{reset:{rects:!0}}:{}}}};function iu(){return typeof window<"u"}function Za(t){return f_(t)?(t.nodeName||"").toLowerCase():"#document"}function ar(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function fo(t){var e;return(e=(f_(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function f_(t){return iu()?t instanceof Node||t instanceof ar(t).Node:!1}function Hr(t){return iu()?t instanceof Element||t instanceof ar(t).Element:!1}function ho(t){return iu()?t instanceof HTMLElement||t instanceof ar(t).HTMLElement:!1}function h_(t){return!iu()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof ar(t).ShadowRoot}function fc(t){const{overflow:e,overflowX:n,overflowY:r,display:o}=Ur(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!["inline","contents"].includes(o)}function C2(t){return["table","td","th"].includes(Za(t))}function au(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function Lg(t){const e=Fg(),n=Hr(t)?Ur(t):t;return["transform","translate","scale","rotate","perspective"].some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function b2(t){let e=vi(t);for(;ho(e)&&!es(e);){if(Lg(e))return e;if(au(e))return null;e=vi(e)}return null}function Fg(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function es(t){return["html","body","#document"].includes(Za(t))}function Ur(t){return ar(t).getComputedStyle(t)}function su(t){return Hr(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function vi(t){if(Za(t)==="html")return t;const e=t.assignedSlot||t.parentNode||h_(t)&&t.host||fo(t);return h_(e)?e.host:e}function p_(t){const e=vi(t);return es(e)?t.ownerDocument?t.ownerDocument.body:t.body:ho(e)&&fc(e)?e:p_(e)}function hc(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const o=p_(t),i=o===((r=t.ownerDocument)==null?void 0:r.body),s=ar(o);if(i){const l=$g(s);return e.concat(s,s.visualViewport||[],fc(o)?o:[],l&&n?hc(l):[])}return e.concat(o,hc(o,[],n))}function $g(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function g_(t){const e=Ur(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const o=ho(t),i=o?t.offsetWidth:n,s=o?t.offsetHeight:r,l=tu(n)!==i||tu(r)!==s;return l&&(n=i,r=s),{width:n,height:r,$:l}}function Hg(t){return Hr(t)?t:t.contextElement}function ts(t){const e=Hg(t);if(!ho(e))return uo(1);const n=e.getBoundingClientRect(),{width:r,height:o,$:i}=g_(e);let s=(i?tu(n.width):n.width)/r,l=(i?tu(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}const x2=uo(0);function m_(t){const e=ar(t);return!Fg()||!e.visualViewport?x2:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function S2(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==ar(t)?!1:e}function qi(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const o=t.getBoundingClientRect(),i=Hg(t);let s=uo(1);e&&(r?Hr(r)&&(s=ts(r)):s=ts(t));const l=S2(i,n,r)?m_(i):uo(0);let u=(o.left+l.x)/s.x,h=(o.top+l.y)/s.y,p=o.width/s.x,g=o.height/s.y;if(i){const C=ar(i),w=r&&Hr(r)?ar(r):r;let b=C,v=$g(b);for(;v&&r&&w!==b;){const x=ts(v),E=v.getBoundingClientRect(),A=Ur(v),N=E.left+(v.clientLeft+parseFloat(A.paddingLeft))*x.x,P=E.top+(v.clientTop+parseFloat(A.paddingTop))*x.y;u*=x.x,h*=x.y,p*=x.x,g*=x.y,u+=N,h+=P,b=ar(v),v=$g(b)}}return ou({width:p,height:g,x:u,y:h})}function Ug(t,e){const n=su(t).scrollLeft;return e?e.left+n:qi(fo(t)).left+n}function v_(t,e,n){n===void 0&&(n=!1);const r=t.getBoundingClientRect(),o=r.left+e.scrollLeft-(n?0:Ug(t,r)),i=r.top+e.scrollTop;return{x:o,y:i}}function _2(t){let{elements:e,rect:n,offsetParent:r,strategy:o}=t;const i=o==="fixed",s=fo(r),l=e?au(e.floating):!1;if(r===s||l&&i)return n;let u={scrollLeft:0,scrollTop:0},h=uo(1);const p=uo(0),g=ho(r);if((g||!g&&!i)&&((Za(r)!=="body"||fc(s))&&(u=su(r)),ho(r))){const w=qi(r);h=ts(r),p.x=w.x+r.clientLeft,p.y=w.y+r.clientTop}const C=s&&!g&&!i?v_(s,u,!0):uo(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-u.scrollLeft*h.x+p.x+C.x,y:n.y*h.y-u.scrollTop*h.y+p.y+C.y}}function E2(t){return Array.from(t.getClientRects())}function T2(t){const e=fo(t),n=su(t),r=t.ownerDocument.body,o=ir(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=ir(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+Ug(t);const l=-n.scrollTop;return Ur(r).direction==="rtl"&&(s+=ir(e.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:l}}function A2(t,e){const n=ar(t),r=fo(t),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,l=0,u=0;if(o){i=o.width,s=o.height;const h=Fg();(!h||h&&e==="fixed")&&(l=o.offsetLeft,u=o.offsetTop)}return{width:i,height:s,x:l,y:u}}function I2(t,e){const n=qi(t,!0,e==="fixed"),r=n.top+t.clientTop,o=n.left+t.clientLeft,i=ho(t)?ts(t):uo(1),s=t.clientWidth*i.x,l=t.clientHeight*i.y,u=o*i.x,h=r*i.y;return{width:s,height:l,x:u,y:h}}function y_(t,e,n){let r;if(e==="viewport")r=A2(t,n);else if(e==="document")r=T2(fo(t));else if(Hr(e))r=I2(e,n);else{const o=m_(t);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return ou(r)}function w_(t,e){const n=vi(t);return n===e||!Hr(n)||es(n)?!1:Ur(n).position==="fixed"||w_(n,e)}function k2(t,e){const n=e.get(t);if(n)return n;let r=hc(t,[],!1).filter(l=>Hr(l)&&Za(l)!=="body"),o=null;const i=Ur(t).position==="fixed";let s=i?vi(t):t;for(;Hr(s)&&!es(s);){const l=Ur(s),u=Lg(s);!u&&l.position==="fixed"&&(o=null),(i?!u&&!o:!u&&l.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||fc(s)&&!u&&w_(t,s))?r=r.filter(p=>p!==s):o=l,s=vi(s)}return e.set(t,r),r}function N2(t){let{element:e,boundary:n,rootBoundary:r,strategy:o}=t;const s=[...n==="clippingAncestors"?au(e)?[]:k2(e,this._c):[].concat(n),r],l=s[0],u=s.reduce((h,p)=>{const g=y_(e,p,o);return h.top=ir(g.top,h.top),h.right=mi(g.right,h.right),h.bottom=mi(g.bottom,h.bottom),h.left=ir(g.left,h.left),h},y_(e,l,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function P2(t){const{width:e,height:n}=g_(t);return{width:e,height:n}}function O2(t,e,n){const r=ho(e),o=fo(e),i=n==="fixed",s=qi(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const u=uo(0);function h(){u.x=Ug(o)}if(r||!r&&!i)if((Za(e)!=="body"||fc(o))&&(l=su(e)),r){const w=qi(e,!0,i,e);u.x=w.x+e.clientLeft,u.y=w.y+e.clientTop}else o&&h();i&&!r&&o&&h();const p=o&&!r&&!i?v_(o,l):uo(0),g=s.left+l.scrollLeft-u.x-p.x,C=s.top+l.scrollTop-u.y-p.y;return{x:g,y:C,width:s.width,height:s.height}}function Bg(t){return Ur(t).position==="static"}function C_(t,e){if(!ho(t)||Ur(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return fo(t)===n&&(n=n.ownerDocument.body),n}function b_(t,e){const n=ar(t);if(au(t))return n;if(!ho(t)){let o=vi(t);for(;o&&!es(o);){if(Hr(o)&&!Bg(o))return o;o=vi(o)}return n}let r=C_(t,e);for(;r&&C2(r)&&Bg(r);)r=C_(r,e);return r&&es(r)&&Bg(r)&&!Lg(r)?n:r||b2(t)||n}const M2=async function(t){const e=this.getOffsetParent||b_,n=this.getDimensions,r=await n(t.floating);return{reference:O2(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function R2(t){return Ur(t).direction==="rtl"}const D2={convertOffsetParentRelativeRectToViewportRelativeRect:_2,getDocumentElement:fo,getClippingRect:N2,getOffsetParent:b_,getElementRects:M2,getClientRects:E2,getDimensions:P2,getScale:ts,isElement:Hr,isRTL:R2};function x_(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function L2(t,e){let n=null,r;const o=fo(t);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function s(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),i();const h=t.getBoundingClientRect(),{left:p,top:g,width:C,height:w}=h;if(l||e(),!C||!w)return;const b=nu(g),v=nu(o.clientWidth-(p+C)),x=nu(o.clientHeight-(g+w)),E=nu(p),N={rootMargin:-b+"px "+-v+"px "+-x+"px "+-E+"px",threshold:ir(0,mi(1,u))||1};let P=!0;function _(D){const H=D[0].intersectionRatio;if(H!==u){if(!P)return s();H?s(!1,H):r=setTimeout(()=>{s(!1,1e-7)},1e3)}H===1&&!x_(h,t.getBoundingClientRect())&&s(),P=!1}try{n=new IntersectionObserver(_,{...N,root:o.ownerDocument})}catch{n=new IntersectionObserver(_,N)}n.observe(t)}return s(!0),i}function S_(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,h=Hg(t),p=o||i?[...h?hc(h):[],...hc(e)]:[];p.forEach(E=>{o&&E.addEventListener("scroll",n,{passive:!0}),i&&E.addEventListener("resize",n)});const g=h&&l?L2(h,n):null;let C=-1,w=null;s&&(w=new ResizeObserver(E=>{let[A]=E;A&&A.target===h&&w&&(w.unobserve(e),cancelAnimationFrame(C),C=requestAnimationFrame(()=>{var N;(N=w)==null||N.observe(e)})),n()}),h&&!u&&w.observe(h),w.observe(e));let b,v=u?qi(t):null;u&&x();function x(){const E=qi(t);v&&!x_(v,E)&&n(),v=E,b=requestAnimationFrame(x)}return n(),()=>{var E;p.forEach(A=>{o&&A.removeEventListener("scroll",n),i&&A.removeEventListener("resize",n)}),g==null||g(),(E=w)==null||E.disconnect(),w=null,u&&cancelAnimationFrame(b)}}const F2=m2,$2=v2,H2=h2,U2=w2,B2=p2,__=f2,z2=y2,V2=(t,e,n)=>{const r=new Map,o={platform:D2,...n},i={...o.platform,_c:r};return u2(t,e,{...o,platform:i})};var cu=typeof document<"u"?O.useLayoutEffect:O.useEffect;function lu(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,o;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!lu(t[r],e[r]))return!1;return!0}if(o=Object.keys(t),n=o.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&t.$$typeof)&&!lu(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function E_(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function T_(t,e){const n=E_(t);return Math.round(e*n)/n}function zg(t){const e=m.useRef(t);return cu(()=>{e.current=t}),e}function A_(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:l=!0,whileElementsMounted:u,open:h}=t,[p,g]=m.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[C,w]=m.useState(r);lu(C,r)||w(r);const[b,v]=m.useState(null),[x,E]=m.useState(null),A=m.useCallback(Q=>{Q!==D.current&&(D.current=Q,v(Q))},[]),N=m.useCallback(Q=>{Q!==H.current&&(H.current=Q,E(Q))},[]),P=i||b,_=s||x,D=m.useRef(null),H=m.useRef(null),K=m.useRef(p),ee=u!=null,W=zg(u),de=zg(o),se=zg(h),fe=m.useCallback(()=>{if(!D.current||!H.current)return;const Q={placement:e,strategy:n,middleware:C};de.current&&(Q.platform=de.current),V2(D.current,H.current,Q).then(X=>{const $={...X,isPositioned:se.current!==!1};q.current&&!lu(K.current,$)&&(K.current=$,Aa.flushSync(()=>{g($)}))})},[C,e,n,de,se]);cu(()=>{h===!1&&K.current.isPositioned&&(K.current.isPositioned=!1,g(Q=>({...Q,isPositioned:!1})))},[h]);const q=m.useRef(!1);cu(()=>(q.current=!0,()=>{q.current=!1}),[]),cu(()=>{if(P&&(D.current=P),_&&(H.current=_),P&&_){if(W.current)return W.current(P,_,fe);fe()}},[P,_,fe,W,ee]);const Z=m.useMemo(()=>({reference:D,floating:H,setReference:A,setFloating:N}),[A,N]),Y=m.useMemo(()=>({reference:P,floating:_}),[P,_]),oe=m.useMemo(()=>{const Q={position:n,left:0,top:0};if(!Y.floating)return Q;const X=T_(Y.floating,p.x),$=T_(Y.floating,p.y);return l?{...Q,transform:"translate("+X+"px, "+$+"px)",...E_(Y.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:X,top:$}},[n,l,Y.floating,p.x,p.y]);return m.useMemo(()=>({...p,update:fe,refs:Z,elements:Y,floatingStyles:oe}),[p,fe,Z,Y,oe])}const K2=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:o}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?__({element:r.current,padding:o}).fn(n):{}:r?__({element:r,padding:o}).fn(n):{}}}},I_=(t,e)=>({...F2(t),options:[t,e]}),k_=(t,e)=>({...$2(t),options:[t,e]}),N_=(t,e)=>({...z2(t),options:[t,e]}),P_=(t,e)=>({...H2(t),options:[t,e]}),O_=(t,e)=>({...U2(t),options:[t,e]}),M_=(t,e)=>({...B2(t),options:[t,e]}),R_=(t,e)=>({...K2(t),options:[t,e]});var G2="Arrow",D_=m.forwardRef((t,e)=>{const{children:n,width:r=10,height:o=5,...i}=t;return d.jsx(mt.svg,{...i,ref:e,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});D_.displayName=G2;var j2=D_,Vg="Popper",[L_,F_]=hr(Vg),[W2,$_]=L_(Vg),H_=t=>{const{__scopePopper:e,children:n}=t,[r,o]=m.useState(null);return d.jsx(W2,{scope:e,anchor:r,onAnchorChange:o,children:n})};H_.displayName=Vg;var U_="PopperAnchor",B_=m.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...o}=t,i=$_(U_,n),s=m.useRef(null),l=rt(e,s);return m.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||s.current)}),r?null:d.jsx(mt.div,{...o,ref:l})});B_.displayName=U_;var Kg="PopperContent",[q2,Y2]=L_(Kg),z_=m.forwardRef((t,e)=>{var z,ce,Ae,Ce,Ne,ne;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:h=[],collisionPadding:p=0,sticky:g="partial",hideWhenDetached:C=!1,updatePositionStrategy:w="optimized",onPlaced:b,...v}=t,x=$_(Kg,n),[E,A]=m.useState(null),N=rt(e,Ve=>A(Ve)),[P,_]=m.useState(null),D=hg(P),H=(D==null?void 0:D.width)??0,K=(D==null?void 0:D.height)??0,ee=r+(i!=="center"?"-"+i:""),W=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},de=Array.isArray(h)?h:[h],se=de.length>0,fe={padding:W,boundary:de.filter(Q2),altBoundary:se},{refs:q,floatingStyles:Z,placement:Y,isPositioned:oe,middlewareData:Q}=A_({strategy:"fixed",placement:ee,whileElementsMounted:(...Ve)=>S_(...Ve,{animationFrame:w==="always"}),elements:{reference:x.anchor},middleware:[I_({mainAxis:o+K,alignmentAxis:s}),u&&k_({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?N_():void 0,...fe}),u&&P_({...fe}),O_({...fe,apply:({elements:Ve,rects:Qe,availableWidth:Ct,availableHeight:Jt})=>{const{width:bt,height:an}=Qe.reference,zt=Ve.floating.style;zt.setProperty("--radix-popper-available-width",`${Ct}px`),zt.setProperty("--radix-popper-available-height",`${Jt}px`),zt.setProperty("--radix-popper-anchor-width",`${bt}px`),zt.setProperty("--radix-popper-anchor-height",`${an}px`)}}),P&&R_({element:P,padding:l}),X2({arrowWidth:H,arrowHeight:K}),C&&M_({strategy:"referenceHidden",...fe})]}),[X,$]=G_(Y),te=mn(b);rn(()=>{oe&&(te==null||te())},[oe,te]);const _e=(z=Q.arrow)==null?void 0:z.x,ke=(ce=Q.arrow)==null?void 0:ce.y,xe=((Ae=Q.arrow)==null?void 0:Ae.centerOffset)!==0,[Pe,Te]=m.useState();return rn(()=>{E&&Te(window.getComputedStyle(E).zIndex)},[E]),d.jsx("div",{ref:q.setFloating,"data-radix-popper-content-wrapper":"",style:{...Z,transform:oe?Z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Pe,"--radix-popper-transform-origin":[(Ce=Q.transformOrigin)==null?void 0:Ce.x,(Ne=Q.transformOrigin)==null?void 0:Ne.y].join(" "),...((ne=Q.hide)==null?void 0:ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:d.jsx(q2,{scope:n,placedSide:X,onArrowChange:_,arrowX:_e,arrowY:ke,shouldHideArrow:xe,children:d.jsx(mt.div,{"data-side":X,"data-align":$,...v,ref:N,style:{...v.style,animation:oe?void 0:"none"}})})})});z_.displayName=Kg;var V_="PopperArrow",J2={top:"bottom",right:"left",bottom:"top",left:"right"},K_=m.forwardRef(function(e,n){const{__scopePopper:r,...o}=e,i=Y2(V_,r),s=J2[i.placedSide];return d.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:d.jsx(j2,{...o,ref:n,style:{...o.style,display:"block"}})})});K_.displayName=V_;function Q2(t){return t!==null}var X2=t=>({name:"transformOrigin",options:t,fn(e){var x,E,A;const{placement:n,rects:r,middlewareData:o}=e,s=((x=o.arrow)==null?void 0:x.centerOffset)!==0,l=s?0:t.arrowWidth,u=s?0:t.arrowHeight,[h,p]=G_(n),g={start:"0%",center:"50%",end:"100%"}[p],C=(((E=o.arrow)==null?void 0:E.x)??0)+l/2,w=(((A=o.arrow)==null?void 0:A.y)??0)+u/2;let b="",v="";return h==="bottom"?(b=s?g:`${C}px`,v=`${-u}px`):h==="top"?(b=s?g:`${C}px`,v=`${r.floating.height+u}px`):h==="right"?(b=`${-u}px`,v=s?g:`${w}px`):h==="left"&&(b=`${r.floating.width+u}px`,v=s?g:`${w}px`),{data:{x:b,y:v}}}});function G_(t){const[e,n="center"]=t.split("-");return[e,n]}var Z2=H_,e$=B_,t$=z_,n$=K_,r$=Symbol("radix.slottable");function o$(t){const e=({children:n})=>d.jsx(d.Fragment,{children:n});return e.displayName=`${t}.Slottable`,e.__radixId=r$,e}var i$=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),a$="VisuallyHidden",j_=m.forwardRef((t,e)=>d.jsx(mt.span,{...t,ref:e,style:{...i$,...t.style}}));j_.displayName=a$;var s$=j_,[du,mW]=hr("Tooltip",[F_]),uu=F_(),W_="TooltipProvider",c$=700,Gg="tooltip.open",[l$,jg]=du(W_),q_=t=>{const{__scopeTooltip:e,delayDuration:n=c$,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=t,s=m.useRef(!0),l=m.useRef(!1),u=m.useRef(0);return m.useEffect(()=>{const h=u.current;return()=>window.clearTimeout(h)},[]),d.jsx(l$,{scope:e,isOpenDelayedRef:s,delayDuration:n,onOpen:m.useCallback(()=>{window.clearTimeout(u.current),s.current=!1},[]),onClose:m.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>s.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:m.useCallback(h=>{l.current=h},[]),disableHoverableContent:o,children:i})};q_.displayName=W_;var pc="Tooltip",[d$,gc]=du(pc),Y_=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:s,delayDuration:l}=t,u=jg(pc,t.__scopeTooltip),h=uu(e),[p,g]=m.useState(null),C=Io(),w=m.useRef(0),b=s??u.disableHoverableContent,v=l??u.delayDuration,x=m.useRef(!1),[E,A]=si({prop:r,defaultProp:o??!1,onChange:H=>{H?(u.onOpen(),document.dispatchEvent(new CustomEvent(Gg))):u.onClose(),i==null||i(H)},caller:pc}),N=m.useMemo(()=>E?x.current?"delayed-open":"instant-open":"closed",[E]),P=m.useCallback(()=>{window.clearTimeout(w.current),w.current=0,x.current=!1,A(!0)},[A]),_=m.useCallback(()=>{window.clearTimeout(w.current),w.current=0,A(!1)},[A]),D=m.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>{x.current=!0,A(!0),w.current=0},v)},[v,A]);return m.useEffect(()=>()=>{w.current&&(window.clearTimeout(w.current),w.current=0)},[]),d.jsx(Z2,{...h,children:d.jsx(d$,{scope:e,contentId:C,open:E,stateAttribute:N,trigger:p,onTriggerChange:g,onTriggerEnter:m.useCallback(()=>{u.isOpenDelayedRef.current?D():P()},[u.isOpenDelayedRef,D,P]),onTriggerLeave:m.useCallback(()=>{b?_():(window.clearTimeout(w.current),w.current=0)},[_,b]),onOpen:P,onClose:_,disableHoverableContent:b,children:n})})};Y_.displayName=pc;var Wg="TooltipTrigger",J_=m.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,o=gc(Wg,n),i=jg(Wg,n),s=uu(n),l=m.useRef(null),u=rt(e,l,o.onTriggerChange),h=m.useRef(!1),p=m.useRef(!1),g=m.useCallback(()=>h.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),d.jsx(e$,{asChild:!0,...s,children:d.jsx(mt.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:u,onPointerMove:Ue(t.onPointerMove,C=>{C.pointerType!=="touch"&&!p.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),p.current=!0)}),onPointerLeave:Ue(t.onPointerLeave,()=>{o.onTriggerLeave(),p.current=!1}),onPointerDown:Ue(t.onPointerDown,()=>{o.open&&o.onClose(),h.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:Ue(t.onFocus,()=>{h.current||o.onOpen()}),onBlur:Ue(t.onBlur,o.onClose),onClick:Ue(t.onClick,o.onClose)})})});J_.displayName=Wg;var qg="TooltipPortal",[u$,f$]=du(qg,{forceMount:void 0}),Q_=t=>{const{__scopeTooltip:e,forceMount:n,children:r,container:o}=t,i=gc(qg,e);return d.jsx(u$,{scope:e,forceMount:n,children:d.jsx(ko,{present:n||i.open,children:d.jsx(od,{asChild:!0,container:o,children:r})})})};Q_.displayName=qg;var ns="TooltipContent",X_=m.forwardRef((t,e)=>{const n=f$(ns,t.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=t,s=gc(ns,t.__scopeTooltip);return d.jsx(ko,{present:r||s.open,children:s.disableHoverableContent?d.jsx(Z_,{side:o,...i,ref:e}):d.jsx(h$,{side:o,...i,ref:e})})}),h$=m.forwardRef((t,e)=>{const n=gc(ns,t.__scopeTooltip),r=jg(ns,t.__scopeTooltip),o=m.useRef(null),i=rt(e,o),[s,l]=m.useState(null),{trigger:u,onClose:h}=n,p=o.current,{onPointerInTransitChange:g}=r,C=m.useCallback(()=>{l(null),g(!1)},[g]),w=m.useCallback((b,v)=>{const x=b.currentTarget,E={x:b.clientX,y:b.clientY},A=y$(E,x.getBoundingClientRect()),N=w$(E,A),P=C$(v.getBoundingClientRect()),_=x$([...N,...P]);l(_),g(!0)},[g]);return m.useEffect(()=>()=>C(),[C]),m.useEffect(()=>{if(u&&p){const b=x=>w(x,p),v=x=>w(x,u);return u.addEventListener("pointerleave",b),p.addEventListener("pointerleave",v),()=>{u.removeEventListener("pointerleave",b),p.removeEventListener("pointerleave",v)}}},[u,p,w,C]),m.useEffect(()=>{if(s){const b=v=>{const x=v.target,E={x:v.clientX,y:v.clientY},A=(u==null?void 0:u.contains(x))||(p==null?void 0:p.contains(x)),N=!b$(E,s);A?C():N&&(C(),h())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[u,p,s,h,C]),d.jsx(Z_,{...t,ref:i})}),[p$,g$]=du(pc,{isInside:!1}),m$=o$("TooltipContent"),Z_=m.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:s,...l}=t,u=gc(ns,n),h=uu(n),{onClose:p}=u;return m.useEffect(()=>(document.addEventListener(Gg,p),()=>document.removeEventListener(Gg,p)),[p]),m.useEffect(()=>{if(u.trigger){const g=C=>{const w=C.target;w!=null&&w.contains(u.trigger)&&p()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[u.trigger,p]),d.jsx(rd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:g=>g.preventDefault(),onDismiss:p,children:d.jsxs(t$,{"data-state":u.stateAttribute,...h,...l,ref:e,style:{...l.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:[d.jsx(m$,{children:r}),d.jsx(p$,{scope:n,isInside:!0,children:d.jsx(s$,{id:u.contentId,role:"tooltip",children:o||r})})]})})});X_.displayName=ns;var eE="TooltipArrow",v$=m.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,o=uu(n);return g$(eE,n).isInside?null:d.jsx(n$,{...o,...r,ref:e})});v$.displayName=eE;function y$(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),o=Math.abs(e.right-t.x),i=Math.abs(e.left-t.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function w$(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function C$(t){const{top:e,right:n,bottom:r,left:o}=t;return[{x:o,y:e},{x:n,y:e},{x:n,y:r},{x:o,y:r}]}function b$(t,e){const{x:n,y:r}=t;let o=!1;for(let i=0,s=e.length-1;i<e.length;s=i++){const l=e[i],u=e[s],h=l.x,p=l.y,g=u.x,C=u.y;p>r!=C>r&&n<(g-h)*(r-p)/(C-p)+h&&(o=!o)}return o}function x$(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),S$(e)}function S$(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const o=t[r];for(;e.length>=2;){const i=e[e.length-1],s=e[e.length-2];if((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x))e.pop();else break}e.push(o)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const o=t[r];for(;n.length>=2;){const i=n[n.length-1],s=n[n.length-2];if((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x))n.pop();else break}n.push(o)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var _$=q_,E$=Y_,T$=J_,A$=Q_,tE=X_;const gr=_$,mr=E$,vr=T$,sr=m.forwardRef(({className:t,sideOffset:e=4,...n},r)=>d.jsx(A$,{children:d.jsx(tE,{ref:r,sideOffset:e,className:ze("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",t),...n})}));sr.displayName=tE.displayName;function I$({title:t,titleId:e,...n},r){return m.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":e},n),t?m.createElement("title",{id:e},t):null,m.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 k$=m.forwardRef(I$);var N$=function(t){return function(e,n){var r=O.useRef(!1);t(function(){return function(){r.current=!1}},[]),t(function(){if(!r.current)r.current=!0;else return e()},n)}},nE=function(t){return typeof t=="function"},rE=process.env.NODE_ENV==="development"||process.env.NODE_ENV==="test";const P$=N$(O.useEffect);function oE(t){var e=O.useRef(t);return e.current=t,e}var O$=function(t){rE&&(nE(t)||console.error("useUnmount expected parameter is a function, got ".concat(typeof t)));var e=oE(t);O.useEffect(function(){return function(){e.current()}},[])};function M$(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var iE=M$,R$=typeof so=="object"&&so&&so.Object===Object&&so,D$=R$,L$=D$,F$=typeof self=="object"&&self&&self.Object===Object&&self,$$=L$||F$||Function("return this")(),aE=$$,H$=aE,U$=function(){return H$.Date.now()},B$=U$,z$=/\s/;function V$(t){for(var e=t.length;e--&&z$.test(t.charAt(e)););return e}var K$=V$,G$=K$,j$=/^\s+/;function W$(t){return t&&t.slice(0,G$(t)+1).replace(j$,"")}var q$=W$,Y$=aE,J$=Y$.Symbol,sE=J$,cE=sE,lE=Object.prototype,Q$=lE.hasOwnProperty,X$=lE.toString,mc=cE?cE.toStringTag:void 0;function Z$(t){var e=Q$.call(t,mc),n=t[mc];try{t[mc]=void 0;var r=!0}catch{}var o=X$.call(t);return r&&(e?t[mc]=n:delete t[mc]),o}var eH=Z$,tH=Object.prototype,nH=tH.toString;function rH(t){return nH.call(t)}var oH=rH,dE=sE,iH=eH,aH=oH,sH="[object Null]",cH="[object Undefined]",uE=dE?dE.toStringTag:void 0;function lH(t){return t==null?t===void 0?cH:sH:uE&&uE in Object(t)?iH(t):aH(t)}var dH=lH;function uH(t){return t!=null&&typeof t=="object"}var fH=uH,hH=dH,pH=fH,gH="[object Symbol]";function mH(t){return typeof t=="symbol"||pH(t)&&hH(t)==gH}var vH=mH,yH=q$,fE=iE,wH=vH,hE=NaN,CH=/^[-+]0x[0-9a-f]+$/i,bH=/^0b[01]+$/i,xH=/^0o[0-7]+$/i,SH=parseInt;function _H(t){if(typeof t=="number")return t;if(wH(t))return hE;if(fE(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=fE(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=yH(t);var n=bH.test(t);return n||xH.test(t)?SH(t.slice(2),n?2:8):CH.test(t)?hE:+t}var EH=_H,TH=iE,Yg=B$,pE=EH,AH="Expected a function",IH=Math.max,kH=Math.min;function NH(t,e,n){var r,o,i,s,l,u,h=0,p=!1,g=!1,C=!0;if(typeof t!="function")throw new TypeError(AH);e=pE(e)||0,TH(n)&&(p=!!n.leading,g="maxWait"in n,i=g?IH(pE(n.maxWait)||0,e):i,C="trailing"in n?!!n.trailing:C);function w(D){var H=r,K=o;return r=o=void 0,h=D,s=t.apply(K,H),s}function b(D){return h=D,l=setTimeout(E,e),p?w(D):s}function v(D){var H=D-u,K=D-h,ee=e-H;return g?kH(ee,i-K):ee}function x(D){var H=D-u,K=D-h;return u===void 0||H>=e||H<0||g&&K>=i}function E(){var D=Yg();if(x(D))return A(D);l=setTimeout(E,v(D))}function A(D){return l=void 0,C&&r?w(D):(r=o=void 0,s)}function N(){l!==void 0&&clearTimeout(l),h=0,r=u=o=l=void 0}function P(){return l===void 0?s:A(Yg())}function _(){var D=Yg(),H=x(D);if(r=arguments,o=this,u=D,H){if(l===void 0)return b(u);if(g)return clearTimeout(l),l=setTimeout(E,e),w(u)}return l===void 0&&(l=setTimeout(E,e)),s}return _.cancel=N,_.flush=P,_}var PH=NH;const OH=Od(PH);function MH(){var t=(typeof global>"u"?"undefined":typeof global)=="object"&&global&&global.Object===Object&&global,e=typeof self=="object"&&self&&self.Object===Object&&self;return t||e}MH()||(global.Date=Date);function RH(t,e){var n;rE&&(nE(t)||console.error("useDebounceFn expected parameter is a function, got ".concat(typeof t)));var r=oE(t),o=(n=e==null?void 0:e.wait)!==null&&n!==void 0?n:1e3,i=O.useMemo(function(){return OH(function(){for(var s=[],l=0;l<arguments.length;l++)s[l]=arguments[l];return r.current.apply(r,ZC([],XC(s),!1))},o,e)},[]);return O$(function(){i.cancel()}),{run:i,cancel:i.cancel,flush:i.flush}}function DH(t,e,n){var r=XC(O.useState({}),2),o=r[0],i=r[1],s=RH(function(){i({})},n).run;O.useEffect(function(){return s()},e),P$(t,[o])}const LH=O.forwardRef(({onChange:t},e)=>{const n=O.useRef(null),[r,o]=O.useState("");return O.useImperativeHandle(e,()=>({setValue:i=>{var s;o(i),(s=n.current)==null||s.focus()}})),DH(()=>{t==null||t(r)},[r],{wait:300}),d.jsxs(d.Fragment,{children:[d.jsx(Wn,{ref:n,type:"text",placeholder:"Search files...",value:r,onChange:i=>o(i.target.value),className:"pr-8"}),r&&d.jsx("button",{onClick:()=>{var i;o(""),(i=n.current)==null||i.focus()},className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700",children:d.jsx(k$,{className:"h-5 w-5"})})]})});var Br=(t=>(t.VIEW_DOCUMENT="VIEW_DOCUMENT",t.DOWNLOAD_DOCUMENT="DOWNLOAD_DOCUMENT",t.EDIT_DOCUMENT="EDIT_DOCUMENT",t.OWNER_DOCUMENT="OWNER_DOCUMENT",t))(Br||{});const FH=(t,e)=>{const[n,r]=O.useState([]),[o,i]=O.useState([]),[s,l]=O.useState([]),[u,h]=O.useState([]),{toast:p}=dc(),[g,C]=O.useState(!1),[w,b]=O.useState(!1),v=O.useCallback(async(P,_,D)=>{if(!w){b(!0);try{const H=await Le.post(t+"/document-permission/grandted",{path:P,grandtedBy:_,data:D});return H.status===200&&(p({title:"Phân quyền tài liệu thành công."}),await N(P)),H}catch{return null}finally{b(!1)}}},[]),x=O.useCallback(async()=>{var P;try{return(P=(await Le.get(e+"/admin/users/get-all",{params:{limit:1e4}})).data||[])==null?void 0:P.filter(K=>K.role!=="MASTER_ADMIN")}catch(_){return console.error("Error fetchAllUsers",_),[]}},[]),E=O.useCallback(async()=>{try{return(await Le.get(e+"/admin/group-users")).data.filter(_=>`${_.groupname}`.toUpperCase()!=="MASTER_ADMIN").map(_=>{var D;return{..._,users:((D=_.users)==null?void 0:D.length)||0}})}catch(P){return console.error("Error fetchAllGroups",P),[]}},[]),A=O.useCallback(async P=>{try{const D=(await Le.get(t+"/document-permission/grandted",{params:{path:P}})).data;return{usersShared:(D==null?void 0:D.users)||[],groupsShared:(D==null?void 0:D.groups)||[]}}catch(_){return console.error("Error fetchShared",_),{usersShared:[],groupsShared:[]}}},[]),N=O.useCallback(async P=>{if(g)return;C(!0);let[_,D,{usersShared:H,groupsShared:K}]=await Promise.all([x(),E(),A(P)]);_=_==null?void 0:_.filter(ee=>!(H!=null&&H.find(W=>W.userId===ee.id))),D=D==null?void 0:D.filter(ee=>!(K!=null&&K.find(W=>W.groupname===ee.groupname))),Array.isArray(_)&&r(_),Array.isArray(D)&&i(D),Array.isArray(H)&&l(H),Array.isArray(K)&&h(K),C(!1)},[]);return{users:n,groups:o,sharedUsers:s,sharedGroups:u,setUsers:r,setGroups:i,setSharedUsers:l,setSharedGroups:h,fetchData:N,loading:g,postGranted:v,loadingGrandted:w}},$H=({failureReasons:t})=>{const e=s=>{const l=[];return s.forEach(u=>{try{JSON.parse(u).forEach(p=>{const g=p.match(/\[Files: ([^\]]+)\]/),C=p.match(/^([^[]+)/);if(g&&C&&g[1]&&C[1]){const w=g[1].split(", ").map(x=>x.trim()),b=C[1].trim().replace("Encountered error: ","");let v="unknown";b.includes("invalid metadata attributes")||b.includes("metadata quota")?v="metadata":b.includes("No metadata was provided")||b.includes("metadata file")?v="missing_metadata":b.includes("file size")||b.includes("exceeds")||b.includes("50 MB")?v="file_size":b.includes("format not supported")||b.includes("unsupported format")||b.includes("file type")?v="file_format":b.includes("embedding failed")||b.includes("EMBEDDING_FAILED")?v="embedding_failed":b.includes("indexing failed")||b.includes("INDEXING_FAILED")?v="indexing_failed":b.includes("access denied")||b.includes("AccessDeniedException")||b.includes("permission")?v="access_denied":(b.includes("quota")||b.includes("limit")||b.includes("ServiceQuotaExceededException"))&&(v="quota_exceeded"),l.push({errorMessage:b,files:w,errorType:v})}})}catch{l.push({errorMessage:u,files:[],errorType:"unknown"})}}),l},n=s=>{switch(s){case"metadata":return d.jsx(ui,{className:"h-4 w-4 text-orange-500"});case"missing_metadata":return d.jsx(og,{className:"h-4 w-4 text-red-500"});case"file_size":return d.jsx(ui,{className:"h-4 w-4 text-yellow-500"});case"file_format":return d.jsx(og,{className:"h-4 w-4 text-purple-500"});case"embedding_failed":return d.jsx(ui,{className:"h-4 w-4 text-red-600"});case"indexing_failed":return d.jsx(ui,{className:"h-4 w-4 text-red-600"});case"access_denied":return d.jsx(ui,{className:"h-4 w-4 text-red-700"});case"quota_exceeded":return d.jsx(ui,{className:"h-4 w-4 text-orange-600"});default:return d.jsx(ui,{className:"h-4 w-4 text-red-500"})}},r=s=>{switch(s){case"metadata":return"border-orange-200 bg-orange-50";case"missing_metadata":return"border-red-200 bg-red-50";case"file_size":return"border-yellow-200 bg-yellow-50";case"file_format":return"border-purple-200 bg-purple-50";case"embedding_failed":return"border-red-300 bg-red-100";case"indexing_failed":return"border-red-300 bg-red-100";case"access_denied":return"border-red-400 bg-red-100";case"quota_exceeded":return"border-orange-300 bg-orange-100";default:return"border-red-200 bg-red-50"}},o=s=>{switch(s){case"metadata":return"text-orange-800";case"missing_metadata":return"text-red-800";case"file_size":return"text-yellow-800";case"file_format":return"text-purple-800";case"embedding_failed":return"text-red-900";case"indexing_failed":return"text-red-900";case"access_denied":return"text-red-900";case"quota_exceeded":return"text-orange-900";default:return"text-red-800"}},i=e(t);return i.length===0?null:d.jsxs("div",{className:"border-t pt-2",children:[d.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[d.jsx(ui,{className:"h-4 w-4 text-red-500"}),d.jsxs("p",{className:"text-red-600 font-medium",children:["Các file lỗi (",i.reduce((s,l)=>s+l.files.length,0)," file)"]})]}),d.jsx("div",{className:"space-y-3 max-h-80 overflow-y-auto",children:i.map((s,l)=>d.jsxs("div",{className:`p-3 rounded-lg border ${r(s.errorType)}`,children:[d.jsx("div",{className:"flex items-start justify-between",children:d.jsxs("div",{className:"flex items-start gap-2 flex-1",children:[n(s.errorType),d.jsxs("div",{className:"flex-1",children:[d.jsx("p",{className:`font-medium text-sm ${o(s.errorType)}`,children:s.errorMessage}),s.files.length>0&&d.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:[s.files.length," file bị ảnh hưởng"]})]})]})}),s.files.length>0&&d.jsxs("div",{className:"mt-3 pt-2 border-t border-gray-200",children:[d.jsx("p",{className:"text-xs font-medium text-gray-700 mb-2",children:"Danh sách file lỗi:"}),d.jsx("div",{className:"max-h-32 overflow-y-auto space-y-1",children:s.files.map((u,h)=>d.jsxs("div",{className:"flex items-center gap-2 text-xs p-2 bg-white/50 rounded",children:[d.jsx(og,{className:"h-3 w-3 text-red-400 flex-shrink-0"}),d.jsx("span",{className:"text-gray-700 break-all font-mono",children:u.replace("s3://cts-llm-docs-bucket/","")})]},h))})]})]},l))})]})};var Jg={exports:{}},fu={exports:{}},yt={};/** @license React v16.13.1
|
|
199
|
+
`);var ag=t=>typeof t=="number"&&!isNaN(t),Xs=t=>typeof t=="string",Bx=t=>typeof t=="function",jD=t=>Xs(t)||ag(t),WD=t=>O.isValidElement(t)||Xs(t)||Bx(t)||ag(t),qD=1,zx=()=>`${qD++}`,co=new Map,sg=[],Vx=new Set,Kx=()=>co.size>0,YD=(t,{containerId:e})=>{var n;return(n=co.get(e||1))==null?void 0:n.toasts.get(t)};function JD(t,e){var n;if(e)return!!((n=co.get(e))!=null&&n.isToastActive(t));let r=!1;return co.forEach(o=>{o.isToastActive(t)&&(r=!0)}),r}function QD(t){if(!Kx()){sg=sg.filter(e=>t!=null&&e.options.toastId!==t);return}if(t==null||jD(t))co.forEach(e=>{e.removeToast(t)});else if(t&&("containerId"in t||"id"in t)){let e=co.get(t.containerId);e?e.removeToast(t.id):co.forEach(n=>{n.removeToast(t.id)})}}var XD=(t={})=>{co.forEach(e=>{e.props.limit&&(!t.containerId||e.id===t.containerId)&&e.clearQueue()})};function ZD(t,e){WD(t)&&(Kx()||sg.push({content:t,options:e}),co.forEach(n=>{n.buildToast(t,e)}))}function Gx(t,e){co.forEach(n=>{(e==null||!(e!=null&&e.containerId)||(e==null?void 0:e.containerId)===n.id)&&n.toggle(t,e==null?void 0:e.id)})}function eL(t){return Vx.add(t),()=>{Vx.delete(t)}}function tL(t){return t&&(Xs(t.toastId)||ag(t.toastId))?t.toastId:zx()}function Zs(t,e){return ZD(t,e),e.toastId}function Dd(t,e){return{...e,type:e&&e.type||t,toastId:tL(e)}}function Ld(t){return(e,n)=>Zs(e,Dd(t,n))}function st(t,e){return Zs(t,Dd("default",e))}st.loading=(t,e)=>Zs(t,Dd("default",{isLoading:!0,autoClose:!1,closeOnClick:!1,closeButton:!1,draggable:!1,...e}));function nL(t,{pending:e,error:n,success:r},o){let i;e&&(i=Xs(e)?st.loading(e,o):st.loading(e.render,{...o,...e}));let s={isLoading:null,autoClose:null,closeOnClick:null,closeButton:null,draggable:null},l=(h,p,g)=>{if(p==null){st.dismiss(i);return}let C={type:h,...s,...o,data:g},w=Xs(p)?{render:p}:p;return i?st.update(i,{...C,...w}):st(w.render,{...C,...w}),g},u=Bx(t)?t():t;return u.then(h=>l("success",r,h)).catch(h=>l("error",n,h)),u}st.promise=nL,st.success=Ld("success"),st.info=Ld("info"),st.error=Ld("error"),st.warning=Ld("warning"),st.warn=st.warning,st.dark=(t,e)=>Zs(t,Dd("default",{theme:"dark",...e}));function rL(t){QD(t)}st.dismiss=rL,st.clearWaitingQueue=XD,st.isActive=JD,st.update=(t,e={})=>{let n=YD(t,e);if(n){let{props:r,content:o}=n,i={delay:100,...r,...e,toastId:e.toastId||t,updateId:zx()};i.toastId!==t&&(i.staleId=t);let s=i.render||o;delete i.render,Zs(s,i)}},st.done=t=>{st.update(t,{progress:1})},st.onChange=eL,st.play=t=>Gx(!0,t),st.pause=t=>Gx(!1,t);const oL={category:"Thư mục gốc",fileName:"Tên tệp",fullPath:"Đường dẫn đầy đủ",createAt:"Ngày tạo",creator:"Người tạo",creatorId:"ID người tạo",DataSource:"Nguồn dữ liệu",SuggestedAICategories:"Danh mục AI gợi ý",KeywordAISuggestion:"Từ khóa AI gợi ý",SummaryOfSuggestedAI:"Tóm tắt AI gợi ý",AccessLevel:"Cấp độ truy cập"},iL=t=>t==="SummaryOfSuggestedAI"||t==="KeywordAISuggestion"||t==="SuggestedAICategories",cg=t=>t==="fullPath"||t==="createAt"||t==="creator"||t==="creatorId"||t==="DataSource"||t==="AccessLevel"||t==="category"||t==="fileName",aL={STARTING:"Đang bắt đầu",IN_PROGRESS:"Đang đồng bộ",COMPLETE:"Đồng bộ thành công",FAILED:"Đồng bộ thất bại",STOPPING:"Đang dừng",STOPPED:"Đã dừng"},sL=t=>aL[t]||t;function cL(t){const e=lL(t),n=m.forwardRef((r,o)=>{const{children:i,...s}=r,l=m.Children.toArray(i),u=l.find(uL);if(u){const h=u.props.children,p=l.map(g=>g===u?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return d.jsx(e,{...s,ref:o,children:m.isValidElement(h)?m.cloneElement(h,void 0,p):null})}return d.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}var jx=cL("Slot");function lL(t){const e=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const s=hL(o),l=fL(i,o.props);return o.type!==m.Fragment&&(l.ref=r?Hi(r,s):s),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var dL=Symbol("radix.slottable");function uL(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===dL}function fL(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function hL(t){var r,o;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}const lg="-",pL=t=>{const e=mL(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:s=>{const l=s.split(lg);return l[0]===""&&l.length!==1&&l.shift(),Wx(l,e)||gL(s)},getConflictingClassGroupIds:(s,l)=>{const u=n[s]||[];return l&&r[s]?[...u,...r[s]]:u}}},Wx=(t,e)=>{var s;if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),o=r?Wx(t.slice(1),r):void 0;if(o)return o;if(e.validators.length===0)return;const i=t.join(lg);return(s=e.validators.find(({validator:l})=>l(i)))==null?void 0:s.classGroupId},qx=/^\[(.+)\]$/,gL=t=>{if(qx.test(t)){const e=qx.exec(t)[1],n=e==null?void 0:e.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},mL=t=>{const{theme:e,prefix:n}=t,r={nextPart:new Map,validators:[]};return yL(Object.entries(t.classGroups),n).forEach(([i,s])=>{dg(s,r,i,e)}),r},dg=(t,e,n,r)=>{t.forEach(o=>{if(typeof o=="string"){const i=o===""?e:Yx(e,o);i.classGroupId=n;return}if(typeof o=="function"){if(vL(o)){dg(o(r),e,n,r);return}e.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([i,s])=>{dg(s,Yx(e,i),n,r)})})},Yx=(t,e)=>{let n=t;return e.split(lg).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},vL=t=>t.isThemeGetter,yL=(t,e)=>e?t.map(([n,r])=>{const o=r.map(i=>typeof i=="string"?e+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([s,l])=>[e+s,l])):i);return[n,o]}):t,wL=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,r=new Map;const o=(i,s)=>{n.set(i,s),e++,e>t&&(e=0,r=n,n=new Map)};return{get(i){let s=n.get(i);if(s!==void 0)return s;if((s=r.get(i))!==void 0)return o(i,s),s},set(i,s){n.has(i)?n.set(i,s):o(i,s)}}},Jx="!",CL=t=>{const{separator:e,experimentalParseClassName:n}=t,r=e.length===1,o=e[0],i=e.length,s=l=>{const u=[];let h=0,p=0,g;for(let x=0;x<l.length;x++){let E=l[x];if(h===0){if(E===o&&(r||l.slice(x,x+i)===e)){u.push(l.slice(p,x)),p=x+i;continue}if(E==="/"){g=x;continue}}E==="["?h++:E==="]"&&h--}const C=u.length===0?l:l.substring(p),w=C.startsWith(Jx),b=w?C.substring(1):C,v=g&&g>p?g-p:void 0;return{modifiers:u,hasImportantModifier:w,baseClassName:b,maybePostfixModifierPosition:v}};return n?l=>n({className:l,parseClassName:s}):s},bL=t=>{if(t.length<=1)return t;const e=[];let n=[];return t.forEach(r=>{r[0]==="["?(e.push(...n.sort(),r),n=[]):n.push(r)}),e.push(...n.sort()),e},xL=t=>({cache:wL(t.cacheSize),parseClassName:CL(t),...pL(t)}),SL=/\s+/,_L=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o}=e,i=[],s=t.trim().split(SL);let l="";for(let u=s.length-1;u>=0;u-=1){const h=s[u],{modifiers:p,hasImportantModifier:g,baseClassName:C,maybePostfixModifierPosition:w}=n(h);let b=!!w,v=r(b?C.substring(0,w):C);if(!v){if(!b){l=h+(l.length>0?" "+l:l);continue}if(v=r(C),!v){l=h+(l.length>0?" "+l:l);continue}b=!1}const x=bL(p).join(":"),E=g?x+Jx:x,A=E+v;if(i.includes(A))continue;i.push(A);const N=o(v,b);for(let P=0;P<N.length;++P){const _=N[P];i.push(E+_)}l=h+(l.length>0?" "+l:l)}return l};function EL(){let t=0,e,n,r="";for(;t<arguments.length;)(e=arguments[t++])&&(n=Qx(e))&&(r&&(r+=" "),r+=n);return r}const Qx=t=>{if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=Qx(t[r]))&&(n&&(n+=" "),n+=e);return n};function TL(t,...e){let n,r,o,i=s;function s(u){const h=e.reduce((p,g)=>g(p),t());return n=xL(h),r=n.cache.get,o=n.cache.set,i=l,l(u)}function l(u){const h=r(u);if(h)return h;const p=_L(u,n);return o(u,p),p}return function(){return i(EL.apply(null,arguments))}}const Ft=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},Xx=/^\[(?:([a-z-]+):)?(.+)\]$/i,AL=/^\d+\/\d+$/,IL=new Set(["px","full","screen"]),kL=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,NL=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,PL=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,OL=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ML=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Oo=t=>Ya(t)||IL.has(t)||AL.test(t),fi=t=>Ja(t,"length",BL),Ya=t=>!!t&&!Number.isNaN(Number(t)),ug=t=>Ja(t,"number",Ya),ec=t=>!!t&&Number.isInteger(Number(t)),RL=t=>t.endsWith("%")&&Ya(t.slice(0,-1)),ot=t=>Xx.test(t),hi=t=>kL.test(t),DL=new Set(["length","size","percentage"]),LL=t=>Ja(t,DL,Zx),FL=t=>Ja(t,"position",Zx),$L=new Set(["image","url"]),HL=t=>Ja(t,$L,VL),UL=t=>Ja(t,"",zL),tc=()=>!0,Ja=(t,e,n)=>{const r=Xx.exec(t);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):n(r[2]):!1},BL=t=>NL.test(t)&&!PL.test(t),Zx=()=>!1,zL=t=>OL.test(t),VL=t=>ML.test(t),KL=TL(()=>{const t=Ft("colors"),e=Ft("spacing"),n=Ft("blur"),r=Ft("brightness"),o=Ft("borderColor"),i=Ft("borderRadius"),s=Ft("borderSpacing"),l=Ft("borderWidth"),u=Ft("contrast"),h=Ft("grayscale"),p=Ft("hueRotate"),g=Ft("invert"),C=Ft("gap"),w=Ft("gradientColorStops"),b=Ft("gradientColorStopPositions"),v=Ft("inset"),x=Ft("margin"),E=Ft("opacity"),A=Ft("padding"),N=Ft("saturate"),P=Ft("scale"),_=Ft("sepia"),D=Ft("skew"),H=Ft("space"),K=Ft("translate"),ee=()=>["auto","contain","none"],W=()=>["auto","hidden","clip","visible","scroll"],de=()=>["auto",ot,e],se=()=>[ot,e],fe=()=>["",Oo,fi],q=()=>["auto",Ya,ot],Z=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Y=()=>["solid","dashed","dotted","double","none"],oe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Q=()=>["start","end","center","between","around","evenly","stretch"],X=()=>["","0",ot],$=()=>["auto","avoid","all","avoid-page","page","left","right","column"],te=()=>[Ya,ot];return{cacheSize:500,separator:":",theme:{colors:[tc],spacing:[Oo,fi],blur:["none","",hi,ot],brightness:te(),borderColor:[t],borderRadius:["none","","full",hi,ot],borderSpacing:se(),borderWidth:fe(),contrast:te(),grayscale:X(),hueRotate:te(),invert:X(),gap:se(),gradientColorStops:[t],gradientColorStopPositions:[RL,fi],inset:de(),margin:de(),opacity:te(),padding:se(),saturate:te(),scale:te(),sepia:X(),skew:te(),space:se(),translate:se()},classGroups:{aspect:[{aspect:["auto","square","video",ot]}],container:["container"],columns:[{columns:[hi]}],"break-after":[{"break-after":$()}],"break-before":[{"break-before":$()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...Z(),ot]}],overflow:[{overflow:W()}],"overflow-x":[{"overflow-x":W()}],"overflow-y":[{"overflow-y":W()}],overscroll:[{overscroll:ee()}],"overscroll-x":[{"overscroll-x":ee()}],"overscroll-y":[{"overscroll-y":ee()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[v]}],"inset-x":[{"inset-x":[v]}],"inset-y":[{"inset-y":[v]}],start:[{start:[v]}],end:[{end:[v]}],top:[{top:[v]}],right:[{right:[v]}],bottom:[{bottom:[v]}],left:[{left:[v]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",ec,ot]}],basis:[{basis:de()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ot]}],grow:[{grow:X()}],shrink:[{shrink:X()}],order:[{order:["first","last","none",ec,ot]}],"grid-cols":[{"grid-cols":[tc]}],"col-start-end":[{col:["auto",{span:["full",ec,ot]},ot]}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":[tc]}],"row-start-end":[{row:["auto",{span:[ec,ot]},ot]}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ot]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ot]}],gap:[{gap:[C]}],"gap-x":[{"gap-x":[C]}],"gap-y":[{"gap-y":[C]}],"justify-content":[{justify:["normal",...Q()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...Q(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...Q(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[A]}],px:[{px:[A]}],py:[{py:[A]}],ps:[{ps:[A]}],pe:[{pe:[A]}],pt:[{pt:[A]}],pr:[{pr:[A]}],pb:[{pb:[A]}],pl:[{pl:[A]}],m:[{m:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[H]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[H]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ot,e]}],"min-w":[{"min-w":[ot,e,"min","max","fit"]}],"max-w":[{"max-w":[ot,e,"none","full","min","max","fit","prose",{screen:[hi]},hi]}],h:[{h:[ot,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ot,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ot,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ot,e,"auto","min","max","fit"]}],"font-size":[{text:["base",hi,fi]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",ug]}],"font-family":[{font:[tc]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",ot]}],"line-clamp":[{"line-clamp":["none",Ya,ug]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Oo,ot]}],"list-image":[{"list-image":["none",ot]}],"list-style-type":[{list:["none","disc","decimal",ot]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[E]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[E]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Y(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Oo,fi]}],"underline-offset":[{"underline-offset":["auto",Oo,ot]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:se()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ot]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ot]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[E]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Z(),FL]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",LL]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},HL]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[b]}],"gradient-via-pos":[{via:[b]}],"gradient-to-pos":[{to:[b]}],"gradient-from":[{from:[w]}],"gradient-via":[{via:[w]}],"gradient-to":[{to:[w]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[E]}],"border-style":[{border:[...Y(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[E]}],"divide-style":[{divide:Y()}],"border-color":[{border:[o]}],"border-color-x":[{"border-x":[o]}],"border-color-y":[{"border-y":[o]}],"border-color-s":[{"border-s":[o]}],"border-color-e":[{"border-e":[o]}],"border-color-t":[{"border-t":[o]}],"border-color-r":[{"border-r":[o]}],"border-color-b":[{"border-b":[o]}],"border-color-l":[{"border-l":[o]}],"divide-color":[{divide:[o]}],"outline-style":[{outline:["",...Y()]}],"outline-offset":[{"outline-offset":[Oo,ot]}],"outline-w":[{outline:[Oo,fi]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:fe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[E]}],"ring-offset-w":[{"ring-offset":[Oo,fi]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",hi,UL]}],"shadow-color":[{shadow:[tc]}],opacity:[{opacity:[E]}],"mix-blend":[{"mix-blend":[...oe(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":oe()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",hi,ot]}],grayscale:[{grayscale:[h]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[g]}],saturate:[{saturate:[N]}],sepia:[{sepia:[_]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[h]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[p]}],"backdrop-invert":[{"backdrop-invert":[g]}],"backdrop-opacity":[{"backdrop-opacity":[E]}],"backdrop-saturate":[{"backdrop-saturate":[N]}],"backdrop-sepia":[{"backdrop-sepia":[_]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ot]}],duration:[{duration:te()}],ease:[{ease:["linear","in","out","in-out",ot]}],delay:[{delay:te()}],animate:[{animate:["none","spin","ping","pulse","bounce",ot]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[P]}],"scale-x":[{"scale-x":[P]}],"scale-y":[{"scale-y":[P]}],rotate:[{rotate:[ec,ot]}],"translate-x":[{"translate-x":[K]}],"translate-y":[{"translate-y":[K]}],"skew-x":[{"skew-x":[D]}],"skew-y":[{"skew-y":[D]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ot]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ot]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":se()}],"scroll-mx":[{"scroll-mx":se()}],"scroll-my":[{"scroll-my":se()}],"scroll-ms":[{"scroll-ms":se()}],"scroll-me":[{"scroll-me":se()}],"scroll-mt":[{"scroll-mt":se()}],"scroll-mr":[{"scroll-mr":se()}],"scroll-mb":[{"scroll-mb":se()}],"scroll-ml":[{"scroll-ml":se()}],"scroll-p":[{"scroll-p":se()}],"scroll-px":[{"scroll-px":se()}],"scroll-py":[{"scroll-py":se()}],"scroll-ps":[{"scroll-ps":se()}],"scroll-pe":[{"scroll-pe":se()}],"scroll-pt":[{"scroll-pt":se()}],"scroll-pr":[{"scroll-pr":se()}],"scroll-pb":[{"scroll-pb":se()}],"scroll-pl":[{"scroll-pl":se()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ot]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Oo,fi,ug]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}});function ze(...t){return KL(Ux(t))}function Gi(){let t=localStorage.getItem("dataLogin"),e;try{t&&(t=JSON.parse(t),e=t.user)}catch(n){console.error("Error parsing dataLogin from localStorage:",n),t=null}return e}const Fd=m.forwardRef(({className:t,...e},n)=>d.jsx("nav",{ref:n,"aria-label":"breadcrumb",className:ze("s3-explr-ui-breadcrumb",t),...e}));Fd.displayName="Breadcrumb";const $d=m.forwardRef(({className:t,...e},n)=>d.jsx("ol",{ref:n,className:ze("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5","s3-explr-ui-breadcrumb-list",t),...e}));$d.displayName="BreadcrumbList";const nc=m.forwardRef(({className:t,...e},n)=>d.jsx("li",{ref:n,className:ze("inline-flex items-center gap-1.5","s3-explr-ui-breadcrumb-item",t),...e}));nc.displayName="BreadcrumbItem";const rc=m.forwardRef(({asChild:t,className:e,...n},r)=>{const o=t?jx:"a";return d.jsx(o,{ref:r,className:ze("transition-colors hover:text-foreground","s3-explr-ui-breadcrumb-link",e),...n})});rc.displayName="BreadcrumbLink";const GL=m.forwardRef(({className:t,...e},n)=>d.jsx("span",{ref:n,role:"link","aria-disabled":"true","aria-current":"page",className:ze("font-normal text-foreground","s3-explr-ui-breadcrumb-page",t),...e}));GL.displayName="BreadcrumbPage";const Hd=({children:t,className:e,...n})=>d.jsx("li",{role:"presentation","aria-hidden":"true",className:ze("[&>svg]:w-3.5 [&>svg]:h-3.5","s3-explr-ui-breadcrumb-separator",e),...n,children:t??d.jsx(Fx,{})});Hd.displayName="BreadcrumbSeparator";const eS=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,tS=Ux,fg=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return tS(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:i}=e,s=Object.keys(o).map(h=>{const p=n==null?void 0:n[h],g=i==null?void 0:i[h];if(p===null)return null;const C=eS(p)||eS(g);return o[h][C]}),l=n&&Object.entries(n).reduce((h,p)=>{let[g,C]=p;return C===void 0||(h[g]=C),h},{}),u=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((h,p)=>{let{class:g,className:C,...w}=p;return Object.entries(w).every(b=>{let[v,x]=b;return Array.isArray(x)?x.includes({...i,...l}[v]):{...i,...l}[v]===x})?[...h,g,C]:h},[]);return tS(t,s,u,n==null?void 0:n.class,n==null?void 0:n.className)},nS=fg("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 s3-explr-ui-button",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90 s3-explr-ui-button-default",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 s3-explr-ui-button-destructive",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground s3-explr-ui-button-outline",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80 s3-explr-ui-button-secondary",ghost:"hover:bg-accent hover:text-accent-foreground s3-explr-ui-button-ghost",link:"text-primary underline-offset-4 hover:underline s3-explr-ui-button-link"},size:{default:"h-9 px-4 py-2 s3-explr-ui-button-size-default",sm:"h-8 rounded-md px-3 text-xs s3-explr-ui-button-size-sm",lg:"h-10 rounded-md px-8 s3-explr-ui-button-size-lg",icon:"h-9 w-9 s3-explr-ui-button-size-icon"}},defaultVariants:{variant:"default",size:"default"}}),He=m.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,...o},i)=>{const s=r?jx:"button";return d.jsx(s,{className:ze(nS({variant:e,size:n,className:t})),ref:i,...o})});He.displayName="Button";function rS(t){const e=m.useRef({value:t,previous:t});return m.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}function hg(t){const[e,n]=m.useState(void 0);return rn(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let s,l;if("borderBoxSize"in i){const u=i.borderBoxSize,h=Array.isArray(u)?u[0]:u;s=h.inlineSize,l=h.blockSize}else s=t.offsetWidth,l=t.offsetHeight;n({width:s,height:l})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var Ud="Checkbox",[jL,hW]=hr(Ud),[WL,pg]=jL(Ud);function qL(t){const{__scopeCheckbox:e,checked:n,children:r,defaultChecked:o,disabled:i,form:s,name:l,onCheckedChange:u,required:h,value:p="on",internal_do_not_use_render:g}=t,[C,w]=si({prop:n,defaultProp:o??!1,onChange:u,caller:Ud}),[b,v]=m.useState(null),[x,E]=m.useState(null),A=m.useRef(!1),N=b?!!s||!!b.closest("form"):!0,P={checked:C,disabled:i,setChecked:w,control:b,setControl:v,name:l,form:s,value:p,hasConsumerStoppedPropagationRef:A,required:h,defaultChecked:pi(o)?!1:o,isFormControl:N,bubbleInput:x,setBubbleInput:E};return d.jsx(WL,{scope:e,...P,children:YL(g)?g(P):r})}var oS="CheckboxTrigger",iS=m.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:n,...r},o)=>{const{control:i,value:s,disabled:l,checked:u,required:h,setControl:p,setChecked:g,hasConsumerStoppedPropagationRef:C,isFormControl:w,bubbleInput:b}=pg(oS,t),v=rt(o,p),x=m.useRef(u);return m.useEffect(()=>{const E=i==null?void 0:i.form;if(E){const A=()=>g(x.current);return E.addEventListener("reset",A),()=>E.removeEventListener("reset",A)}},[i,g]),d.jsx(mt.button,{type:"button",role:"checkbox","aria-checked":pi(u)?"mixed":u,"aria-required":h,"data-state":dS(u),"data-disabled":l?"":void 0,disabled:l,value:s,...r,ref:v,onKeyDown:Ue(e,E=>{E.key==="Enter"&&E.preventDefault()}),onClick:Ue(n,E=>{g(A=>pi(A)?!0:!A),b&&w&&(C.current=E.isPropagationStopped(),C.current||E.stopPropagation())})})});iS.displayName=oS;var gg=m.forwardRef((t,e)=>{const{__scopeCheckbox:n,name:r,checked:o,defaultChecked:i,required:s,disabled:l,value:u,onCheckedChange:h,form:p,...g}=t;return d.jsx(qL,{__scopeCheckbox:n,checked:o,defaultChecked:i,disabled:l,required:s,onCheckedChange:h,name:r,form:p,value:u,internal_do_not_use_render:({isFormControl:C})=>d.jsxs(d.Fragment,{children:[d.jsx(iS,{...g,ref:e,__scopeCheckbox:n}),C&&d.jsx(lS,{__scopeCheckbox:n})]})})});gg.displayName=Ud;var aS="CheckboxIndicator",sS=m.forwardRef((t,e)=>{const{__scopeCheckbox:n,forceMount:r,...o}=t,i=pg(aS,n);return d.jsx(ko,{present:r||pi(i.checked)||i.checked===!0,children:d.jsx(mt.span,{"data-state":dS(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:e,style:{pointerEvents:"none",...t.style}})})});sS.displayName=aS;var cS="CheckboxBubbleInput",lS=m.forwardRef(({__scopeCheckbox:t,...e},n)=>{const{control:r,hasConsumerStoppedPropagationRef:o,checked:i,defaultChecked:s,required:l,disabled:u,name:h,value:p,form:g,bubbleInput:C,setBubbleInput:w}=pg(cS,t),b=rt(n,w),v=rS(i),x=hg(r);m.useEffect(()=>{const A=C;if(!A)return;const N=window.HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(N,"checked").set,D=!o.current;if(v!==i&&_){const H=new Event("click",{bubbles:D});A.indeterminate=pi(i),_.call(A,pi(i)?!1:i),A.dispatchEvent(H)}},[C,v,i,o]);const E=m.useRef(pi(i)?!1:i);return d.jsx(mt.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??E.current,required:l,disabled:u,name:h,value:p,form:g,...e,tabIndex:-1,ref:b,style:{...e.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});lS.displayName=cS;function YL(t){return typeof t=="function"}function pi(t){return t==="indeterminate"}function dS(t){return pi(t)?"indeterminate":t?"checked":"unchecked"}const oc=m.forwardRef(({className:t,...e},n)=>d.jsx(gg,{ref:n,className:ze("s3-explr-ui-checkbox peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...e,children:d.jsx(sS,{className:ze("s3-explr-ui-checkbox-indicator flex items-center justify-center text-current"),children:d.jsx(Lx,{className:"s3-explr-ui-checkbox-check h-4 w-4"})})}));oc.displayName=gg.displayName;const or=Gs,ic=cM,JL=lM,uS=m.forwardRef(({className:t,...e},n)=>d.jsx(Ga,{ref:n,className:ze("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",t),...e}));uS.displayName=Ga.displayName;const Kn=m.forwardRef(({className:t,children:e,...n},r)=>d.jsxs(JL,{children:[d.jsx(uS,{}),d.jsxs(ja,{ref:r,className:ze("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",t),...n,children:[e,d.jsxs(Ep,{className:ze("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:[d.jsx(ig,{className:"s3-explr-ui-dialog-close-icon h-4 w-4"}),d.jsx("span",{className:"s3-explr-ui-dialog-close-text sr-only",children:"Close"})]})]})]}));Kn.displayName=ja.displayName;const Gn=({className:t,...e})=>d.jsx("div",{className:ze("s3-explr-ui-dialog-header flex flex-col space-y-1.5 text-center sm:text-left",t),...e});Gn.displayName="DialogHeader";const Lr=({className:t,...e})=>d.jsx("div",{className:ze("s3-explr-ui-dialog-footer flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});Lr.displayName="DialogFooter";const jn=m.forwardRef(({className:t,...e},n)=>d.jsx(kb,{ref:n,className:ze("s3-explr-ui-dialog-title text-lg font-semibold leading-none tracking-tight",t),...e}));jn.displayName=kb.displayName;const gi=m.forwardRef(({className:t,...e},n)=>d.jsx(Nb,{ref:n,className:ze("s3-explr-ui-dialog-description text-sm text-muted-foreground",t),...e}));gi.displayName=Nb.displayName;const Wn=m.forwardRef(({className:t,type:e,...n},r)=>d.jsx("input",{type:e,className:ze("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",t),ref:r,...n}));Wn.displayName="Input";var QL="Label",fS=m.forwardRef((t,e)=>d.jsx(mt.label,{...t,ref:e,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=t.onMouseDown)==null||o.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));fS.displayName=QL;var hS=fS;const XL=fg("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"}}),pr=m.forwardRef(({className:t,variant:e,size:n,...r},o)=>d.jsx(hS,{ref:o,className:ze(XL({variant:e,size:n}),t),...r}));pr.displayName=hS.displayName;const Bd=({className:t,...e})=>d.jsx("nav",{role:"navigation","aria-label":"pagination",className:ze("mx-auto flex w-full justify-center",t),...e});Bd.displayName="Pagination";const zd=m.forwardRef(({className:t,...e},n)=>d.jsx("ul",{ref:n,className:ze("flex flex-row items-center gap-1",t),...e}));zd.displayName="PaginationContent";const Fr=m.forwardRef(({className:t,...e},n)=>d.jsx("li",{ref:n,className:ze("",t),...e}));Fr.displayName="PaginationItem";const Qa=({className:t,isActive:e,size:n="icon",...r})=>d.jsx("a",{"aria-current":e?"page":void 0,className:ze(nS({variant:e?"outline":"ghost",size:n}),t),...r});Qa.displayName="PaginationLink";const Vd=({className:t,...e})=>d.jsxs(Qa,{"aria-label":"Go to previous page",size:"default",className:ze("gap-1 pl-2.5",t),...e,children:[d.jsx(UD,{className:"h-4 w-4"}),d.jsx("span",{children:"Previous"})]});Vd.displayName="PaginationPrevious";const Kd=({className:t,...e})=>d.jsxs(Qa,{"aria-label":"Go to next page",size:"default",className:ze("gap-1 pr-2.5",t),...e,children:[d.jsx("span",{children:"Next"}),d.jsx(Fx,{className:"h-4 w-4"})]});Kd.displayName="PaginationNext";const Gd=({className:t,...e})=>d.jsxs("span",{"aria-hidden":!0,className:ze("flex h-9 w-9 items-center justify-center",t),...e,children:[d.jsx(BD,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"More pages"})]});Gd.displayName="PaginationEllipsis";const jd=m.forwardRef(({className:t,...e},n)=>d.jsx("div",{className:ze("relative w-full overflow-auto","s3-explr-ui-table-container"),children:d.jsx("table",{ref:n,className:ze("w-full caption-bottom text-sm","s3-explr-ui-table",t),...e})}));jd.displayName="Table";const Wd=m.forwardRef(({className:t,...e},n)=>d.jsx("thead",{ref:n,className:ze("[&_tr]:border-b","s3-explr-ui-table-header",t),...e}));Wd.displayName="TableHeader";const qd=m.forwardRef(({className:t,...e},n)=>d.jsx("tbody",{ref:n,className:ze("[&_tr:last-child]:border-0","s3-explr-ui-table-body",t),...e}));qd.displayName="TableBody";const ZL=m.forwardRef(({className:t,...e},n)=>d.jsx("tfoot",{ref:n,className:ze("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0","s3-explr-ui-table-footer",t),...e}));ZL.displayName="TableFooter";const $r=m.forwardRef(({className:t,...e},n)=>d.jsx("tr",{ref:n,className:ze("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted","s3-explr-ui-table-row",t),...e}));$r.displayName="TableRow";const lo=m.forwardRef(({className:t,...e},n)=>d.jsx("th",{ref:n,className:ze("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",t),...e}));lo.displayName="TableHead";const qn=m.forwardRef(({className:t,...e},n)=>d.jsx("td",{ref:n,className:ze("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]","s3-explr-ui-table-cell",t),...e}));qn.displayName="TableCell";const eF=m.forwardRef(({className:t,...e},n)=>d.jsx("caption",{ref:n,className:ze("mt-4 text-sm text-muted-foreground","s3-explr-ui-table-caption",t),...e}));eF.displayName="TableCaption";function pS(t){const e=tF(t),n=m.forwardRef((r,o)=>{const{children:i,...s}=r,l=m.Children.toArray(i),u=l.find(rF);if(u){const h=u.props.children,p=l.map(g=>g===u?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return d.jsx(e,{...s,ref:o,children:m.isValidElement(h)?m.cloneElement(h,void 0,p):null})}return d.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}function tF(t){const e=m.forwardRef((n,r)=>{const{children:o,...i}=n,s=m.isValidElement(o)?iF(o):void 0,l=rt(s,r);if(m.isValidElement(o)){const u=oF(i,o.props);return o.type!==m.Fragment&&(u.ref=l),m.cloneElement(o,u)}return m.Children.count(o)>1?m.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var nF=Symbol("radix.slottable");function rF(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===nF}function oF(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function iF(t){var r,o;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function aF(t){const e=t+"CollectionProvider",[n,r]=hr(e),[o,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),s=v=>{const{scope:x,children:E}=v,A=O.useRef(null),N=O.useRef(new Map).current;return d.jsx(o,{scope:x,itemMap:N,collectionRef:A,children:E})};s.displayName=e;const l=t+"CollectionSlot",u=pS(l),h=O.forwardRef((v,x)=>{const{scope:E,children:A}=v,N=i(l,E),P=rt(x,N.collectionRef);return d.jsx(u,{ref:P,children:A})});h.displayName=l;const p=t+"CollectionItemSlot",g="data-radix-collection-item",C=pS(p),w=O.forwardRef((v,x)=>{const{scope:E,children:A,...N}=v,P=O.useRef(null),_=rt(x,P),D=i(p,E);return O.useEffect(()=>(D.itemMap.set(P,{ref:P,...N}),()=>void D.itemMap.delete(P))),d.jsx(C,{[g]:"",ref:_,children:A})});w.displayName=p;function b(v){const x=i(t+"CollectionConsumer",v);return O.useCallback(()=>{const A=x.collectionRef.current;if(!A)return[];const N=Array.from(A.querySelectorAll(`[${g}]`));return Array.from(x.itemMap.values()).sort((D,H)=>N.indexOf(D.ref.current)-N.indexOf(H.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:s,Slot:h,ItemSlot:w},b,r]}var sF=m.createContext(void 0);function mg(t){const e=m.useContext(sF);return t||e||"ltr"}var vg="rovingFocusGroup.onEntryFocus",cF={bubbles:!1,cancelable:!0},ac="RovingFocusGroup",[yg,gS,lF]=aF(ac),[dF,mS]=hr(ac,[lF]),[uF,fF]=dF(ac),vS=m.forwardRef((t,e)=>d.jsx(yg.Provider,{scope:t.__scopeRovingFocusGroup,children:d.jsx(yg.Slot,{scope:t.__scopeRovingFocusGroup,children:d.jsx(hF,{...t,ref:e})})}));vS.displayName=ac;var hF=m.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:p=!1,...g}=t,C=m.useRef(null),w=rt(e,C),b=mg(i),[v,x]=si({prop:s,defaultProp:l??null,onChange:u,caller:ac}),[E,A]=m.useState(!1),N=mn(h),P=gS(n),_=m.useRef(!1),[D,H]=m.useState(0);return m.useEffect(()=>{const K=C.current;if(K)return K.addEventListener(vg,N),()=>K.removeEventListener(vg,N)},[N]),d.jsx(uF,{scope:n,orientation:r,dir:b,loop:o,currentTabStopId:v,onItemFocus:m.useCallback(K=>x(K),[x]),onItemShiftTab:m.useCallback(()=>A(!0),[]),onFocusableItemAdd:m.useCallback(()=>H(K=>K+1),[]),onFocusableItemRemove:m.useCallback(()=>H(K=>K-1),[]),children:d.jsx(mt.div,{tabIndex:E||D===0?-1:0,"data-orientation":r,...g,ref:w,style:{outline:"none",...t.style},onMouseDown:Ue(t.onMouseDown,()=>{_.current=!0}),onFocus:Ue(t.onFocus,K=>{const ee=!_.current;if(K.target===K.currentTarget&&ee&&!E){const W=new CustomEvent(vg,cF);if(K.currentTarget.dispatchEvent(W),!W.defaultPrevented){const de=P().filter(Y=>Y.focusable),se=de.find(Y=>Y.active),fe=de.find(Y=>Y.id===v),Z=[se,fe,...de].filter(Boolean).map(Y=>Y.ref.current);CS(Z,p)}}_.current=!1}),onBlur:Ue(t.onBlur,()=>A(!1))})})}),yS="RovingFocusGroupItem",wS=m.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:s,...l}=t,u=Io(),h=i||u,p=fF(yS,n),g=p.currentTabStopId===h,C=gS(n),{onFocusableItemAdd:w,onFocusableItemRemove:b,currentTabStopId:v}=p;return m.useEffect(()=>{if(r)return w(),()=>b()},[r,w,b]),d.jsx(yg.ItemSlot,{scope:n,id:h,focusable:r,active:o,children:d.jsx(mt.span,{tabIndex:g?0:-1,"data-orientation":p.orientation,...l,ref:e,onMouseDown:Ue(t.onMouseDown,x=>{r?p.onItemFocus(h):x.preventDefault()}),onFocus:Ue(t.onFocus,()=>p.onItemFocus(h)),onKeyDown:Ue(t.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){p.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const E=mF(x,p.orientation,p.dir);if(E!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let N=C().filter(P=>P.focusable).map(P=>P.ref.current);if(E==="last")N.reverse();else if(E==="prev"||E==="next"){E==="prev"&&N.reverse();const P=N.indexOf(x.currentTarget);N=p.loop?vF(N,P+1):N.slice(P+1)}setTimeout(()=>CS(N))}}),children:typeof s=="function"?s({isCurrentTabStop:g,hasTabStop:v!=null}):s})})});wS.displayName=yS;var pF={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function gF(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function mF(t,e,n){const r=gF(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return pF[r]}function CS(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function vF(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var yF=vS,wF=wS,Yd="Tabs",[CF,pW]=hr(Yd,[mS]),bS=mS(),[bF,wg]=CF(Yd),xS=m.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:l,activationMode:u="automatic",...h}=t,p=mg(l),[g,C]=si({prop:r,onChange:o,defaultProp:i??"",caller:Yd});return d.jsx(bF,{scope:n,baseId:Io(),value:g,onValueChange:C,orientation:s,dir:p,activationMode:u,children:d.jsx(mt.div,{dir:p,"data-orientation":s,...h,ref:e})})});xS.displayName=Yd;var SS="TabsList",_S=m.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...o}=t,i=wg(SS,n),s=bS(n);return d.jsx(yF,{asChild:!0,...s,orientation:i.orientation,dir:i.dir,loop:r,children:d.jsx(mt.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:e})})});_S.displayName=SS;var ES="TabsTrigger",TS=m.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=t,s=wg(ES,n),l=bS(n),u=kS(s.baseId,r),h=NS(s.baseId,r),p=r===s.value;return d.jsx(wF,{asChild:!0,...l,focusable:!o,active:p,children:d.jsx(mt.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":h,"data-state":p?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...i,ref:e,onMouseDown:Ue(t.onMouseDown,g=>{!o&&g.button===0&&g.ctrlKey===!1?s.onValueChange(r):g.preventDefault()}),onKeyDown:Ue(t.onKeyDown,g=>{[" ","Enter"].includes(g.key)&&s.onValueChange(r)}),onFocus:Ue(t.onFocus,()=>{const g=s.activationMode!=="manual";!p&&!o&&g&&s.onValueChange(r)})})})});TS.displayName=ES;var AS="TabsContent",IS=m.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...s}=t,l=wg(AS,n),u=kS(l.baseId,r),h=NS(l.baseId,r),p=r===l.value,g=m.useRef(p);return m.useEffect(()=>{const C=requestAnimationFrame(()=>g.current=!1);return()=>cancelAnimationFrame(C)},[]),d.jsx(ko,{present:o||p,children:({present:C})=>d.jsx(mt.div,{"data-state":p?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":u,hidden:!C,id:h,tabIndex:0,...s,ref:e,style:{...t.style,animationDuration:g.current?"0s":void 0},children:C&&i})})});IS.displayName=AS;function kS(t,e){return`${t}-trigger-${e}`}function NS(t,e){return`${t}-content-${e}`}var xF=xS,PS=_S,OS=TS,MS=IS;const Cg=xF,Jd=m.forwardRef(({className:t,...e},n)=>d.jsx(PS,{ref:n,className:ze("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));Jd.displayName=PS.displayName;const ji=m.forwardRef(({className:t,...e},n)=>d.jsx(OS,{ref:n,className:ze("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",t),...e}));ji.displayName=OS.displayName;const Wi=m.forwardRef(({className:t,...e},n)=>d.jsx(MS,{ref:n,className:ze("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));Wi.displayName=MS.displayName;const sc=m.forwardRef(({className:t,...e},n)=>d.jsx("textarea",{className:ze("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",t),ref:n,...e}));sc.displayName="Textarea";function RS(t){const e=SF(t),n=m.forwardRef((r,o)=>{const{children:i,...s}=r,l=m.Children.toArray(i),u=l.find(EF);if(u){const h=u.props.children,p=l.map(g=>g===u?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return d.jsx(e,{...s,ref:o,children:m.isValidElement(h)?m.cloneElement(h,void 0,p):null})}return d.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}function SF(t){const e=m.forwardRef((n,r)=>{const{children:o,...i}=n,s=m.isValidElement(o)?AF(o):void 0,l=rt(s,r);if(m.isValidElement(o)){const u=TF(i,o.props);return o.type!==m.Fragment&&(u.ref=l),m.cloneElement(o,u)}return m.Children.count(o)>1?m.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var _F=Symbol("radix.slottable");function EF(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===_F}function TF(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function AF(t){var r,o;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function IF(t){const e=t+"CollectionProvider",[n,r]=hr(e),[o,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),s=v=>{const{scope:x,children:E}=v,A=O.useRef(null),N=O.useRef(new Map).current;return d.jsx(o,{scope:x,itemMap:N,collectionRef:A,children:E})};s.displayName=e;const l=t+"CollectionSlot",u=RS(l),h=O.forwardRef((v,x)=>{const{scope:E,children:A}=v,N=i(l,E),P=rt(x,N.collectionRef);return d.jsx(u,{ref:P,children:A})});h.displayName=l;const p=t+"CollectionItemSlot",g="data-radix-collection-item",C=RS(p),w=O.forwardRef((v,x)=>{const{scope:E,children:A,...N}=v,P=O.useRef(null),_=rt(x,P),D=i(p,E);return O.useEffect(()=>(D.itemMap.set(P,{ref:P,...N}),()=>void D.itemMap.delete(P))),d.jsx(C,{[g]:"",ref:_,children:A})});w.displayName=p;function b(v){const x=i(t+"CollectionConsumer",v);return O.useCallback(()=>{const A=x.collectionRef.current;if(!A)return[];const N=Array.from(A.querySelectorAll(`[${g}]`));return Array.from(x.itemMap.values()).sort((D,H)=>N.indexOf(D.ref.current)-N.indexOf(H.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:s,Slot:h,ItemSlot:w},b,r]}var kF=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),NF="VisuallyHidden",bg=m.forwardRef((t,e)=>d.jsx(mt.span,{...t,ref:e,style:{...kF,...t.style}}));bg.displayName=NF;var xg="ToastProvider",[Sg,PF,OF]=IF("Toast"),[DS,gW]=hr("Toast",[OF]),[MF,Qd]=DS(xg),LS=t=>{const{__scopeToast:e,label:n="Notification",duration:r=5e3,swipeDirection:o="right",swipeThreshold:i=50,children:s}=t,[l,u]=m.useState(null),[h,p]=m.useState(0),g=m.useRef(!1),C=m.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${xg}\`. Expected non-empty \`string\`.`),d.jsx(Sg.Provider,{scope:e,children:d.jsx(MF,{scope:e,label:n,duration:r,swipeDirection:o,swipeThreshold:i,toastCount:h,viewport:l,onViewportChange:u,onToastAdd:m.useCallback(()=>p(w=>w+1),[]),onToastRemove:m.useCallback(()=>p(w=>w-1),[]),isFocusedToastEscapeKeyDownRef:g,isClosePausedRef:C,children:s})})};LS.displayName=xg;var FS="ToastViewport",RF=["F8"],_g="toast.viewportPause",Eg="toast.viewportResume",$S=m.forwardRef((t,e)=>{const{__scopeToast:n,hotkey:r=RF,label:o="Notifications ({hotkey})",...i}=t,s=Qd(FS,n),l=PF(n),u=m.useRef(null),h=m.useRef(null),p=m.useRef(null),g=m.useRef(null),C=rt(e,g,s.onViewportChange),w=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),b=s.toastCount>0;m.useEffect(()=>{const x=E=>{var N;r.length!==0&&r.every(P=>E[P]||E.code===P)&&((N=g.current)==null||N.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]),m.useEffect(()=>{const x=u.current,E=g.current;if(b&&x&&E){const A=()=>{if(!s.isClosePausedRef.current){const D=new CustomEvent(_g);E.dispatchEvent(D),s.isClosePausedRef.current=!0}},N=()=>{if(s.isClosePausedRef.current){const D=new CustomEvent(Eg);E.dispatchEvent(D),s.isClosePausedRef.current=!1}},P=D=>{!x.contains(D.relatedTarget)&&N()},_=()=>{x.contains(document.activeElement)||N()};return x.addEventListener("focusin",A),x.addEventListener("focusout",P),x.addEventListener("pointermove",A),x.addEventListener("pointerleave",_),window.addEventListener("blur",A),window.addEventListener("focus",N),()=>{x.removeEventListener("focusin",A),x.removeEventListener("focusout",P),x.removeEventListener("pointermove",A),x.removeEventListener("pointerleave",_),window.removeEventListener("blur",A),window.removeEventListener("focus",N)}}},[b,s.isClosePausedRef]);const v=m.useCallback(({tabbingDirection:x})=>{const A=l().map(N=>{const P=N.ref.current,_=[P,...WF(P)];return x==="forwards"?_:_.reverse()});return(x==="forwards"?A.reverse():A).flat()},[l]);return m.useEffect(()=>{const x=g.current;if(x){const E=A=>{var _,D,H;const N=A.altKey||A.ctrlKey||A.metaKey;if(A.key==="Tab"&&!N){const K=document.activeElement,ee=A.shiftKey;if(A.target===x&&ee){(_=h.current)==null||_.focus();return}const se=v({tabbingDirection:ee?"backwards":"forwards"}),fe=se.findIndex(q=>q===K);Ig(se.slice(fe+1))?A.preventDefault():ee?(D=h.current)==null||D.focus():(H=p.current)==null||H.focus()}};return x.addEventListener("keydown",E),()=>x.removeEventListener("keydown",E)}},[l,v]),d.jsxs(QO,{ref:u,role:"region","aria-label":o.replace("{hotkey}",w),tabIndex:-1,style:{pointerEvents:b?void 0:"none"},children:[b&&d.jsx(Tg,{ref:h,onFocusFromOutsideViewport:()=>{const x=v({tabbingDirection:"forwards"});Ig(x)}}),d.jsx(Sg.Slot,{scope:n,children:d.jsx(mt.ol,{tabIndex:-1,...i,ref:C})}),b&&d.jsx(Tg,{ref:p,onFocusFromOutsideViewport:()=>{const x=v({tabbingDirection:"backwards"});Ig(x)}})]})});$S.displayName=FS;var HS="ToastFocusProxy",Tg=m.forwardRef((t,e)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...o}=t,i=Qd(HS,n);return d.jsx(bg,{"aria-hidden":!0,tabIndex:0,...o,ref:e,style:{position:"fixed"},onFocus:s=>{var h;const l=s.relatedTarget;!((h=i.viewport)!=null&&h.contains(l))&&r()}})});Tg.displayName=HS;var cc="Toast",DF="toast.swipeStart",LF="toast.swipeMove",FF="toast.swipeCancel",$F="toast.swipeEnd",US=m.forwardRef((t,e)=>{const{forceMount:n,open:r,defaultOpen:o,onOpenChange:i,...s}=t,[l,u]=si({prop:r,defaultProp:o??!0,onChange:i,caller:cc});return d.jsx(ko,{present:n||l,children:d.jsx(BF,{open:l,...s,ref:e,onClose:()=>u(!1),onPause:mn(t.onPause),onResume:mn(t.onResume),onSwipeStart:Ue(t.onSwipeStart,h=>{h.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Ue(t.onSwipeMove,h=>{const{x:p,y:g}=h.detail.delta;h.currentTarget.setAttribute("data-swipe","move"),h.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${p}px`),h.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${g}px`)}),onSwipeCancel:Ue(t.onSwipeCancel,h=>{h.currentTarget.setAttribute("data-swipe","cancel"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),h.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),h.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Ue(t.onSwipeEnd,h=>{const{x:p,y:g}=h.detail.delta;h.currentTarget.setAttribute("data-swipe","end"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),h.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),h.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${p}px`),h.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${g}px`),u(!1)})})})});US.displayName=cc;var[HF,UF]=DS(cc,{onClose(){}}),BF=m.forwardRef((t,e)=>{const{__scopeToast:n,type:r="foreground",duration:o,open:i,onClose:s,onEscapeKeyDown:l,onPause:u,onResume:h,onSwipeStart:p,onSwipeMove:g,onSwipeCancel:C,onSwipeEnd:w,...b}=t,v=Qd(cc,n),[x,E]=m.useState(null),A=rt(e,q=>E(q)),N=m.useRef(null),P=m.useRef(null),_=o||v.duration,D=m.useRef(0),H=m.useRef(_),K=m.useRef(0),{onToastAdd:ee,onToastRemove:W}=v,de=mn(()=>{var Z;(x==null?void 0:x.contains(document.activeElement))&&((Z=v.viewport)==null||Z.focus()),s()}),se=m.useCallback(q=>{!q||q===1/0||(window.clearTimeout(K.current),D.current=new Date().getTime(),K.current=window.setTimeout(de,q))},[de]);m.useEffect(()=>{const q=v.viewport;if(q){const Z=()=>{se(H.current),h==null||h()},Y=()=>{const oe=new Date().getTime()-D.current;H.current=H.current-oe,window.clearTimeout(K.current),u==null||u()};return q.addEventListener(_g,Y),q.addEventListener(Eg,Z),()=>{q.removeEventListener(_g,Y),q.removeEventListener(Eg,Z)}}},[v.viewport,_,u,h,se]),m.useEffect(()=>{i&&!v.isClosePausedRef.current&&se(_)},[i,_,v.isClosePausedRef,se]),m.useEffect(()=>(ee(),()=>W()),[ee,W]);const fe=m.useMemo(()=>x?WS(x):null,[x]);return v.viewport?d.jsxs(d.Fragment,{children:[fe&&d.jsx(zF,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite","aria-atomic":!0,children:fe}),d.jsx(HF,{scope:n,onClose:de,children:Aa.createPortal(d.jsx(Sg.ItemSlot,{scope:n,children:d.jsx(JO,{asChild:!0,onEscapeKeyDown:Ue(l,()=>{v.isFocusedToastEscapeKeyDownRef.current||de(),v.isFocusedToastEscapeKeyDownRef.current=!1}),children:d.jsx(mt.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":i?"open":"closed","data-swipe-direction":v.swipeDirection,...b,ref:A,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Ue(t.onKeyDown,q=>{q.key==="Escape"&&(l==null||l(q.nativeEvent),q.nativeEvent.defaultPrevented||(v.isFocusedToastEscapeKeyDownRef.current=!0,de()))}),onPointerDown:Ue(t.onPointerDown,q=>{q.button===0&&(N.current={x:q.clientX,y:q.clientY})}),onPointerMove:Ue(t.onPointerMove,q=>{if(!N.current)return;const Z=q.clientX-N.current.x,Y=q.clientY-N.current.y,oe=!!P.current,Q=["left","right"].includes(v.swipeDirection),X=["left","up"].includes(v.swipeDirection)?Math.min:Math.max,$=Q?X(0,Z):0,te=Q?0:X(0,Y),_e=q.pointerType==="touch"?10:2,ke={x:$,y:te},xe={originalEvent:q,delta:ke};oe?(P.current=ke,Xd(LF,g,xe,{discrete:!1})):qS(ke,v.swipeDirection,_e)?(P.current=ke,Xd(DF,p,xe,{discrete:!1}),q.target.setPointerCapture(q.pointerId)):(Math.abs(Z)>_e||Math.abs(Y)>_e)&&(N.current=null)}),onPointerUp:Ue(t.onPointerUp,q=>{const Z=P.current,Y=q.target;if(Y.hasPointerCapture(q.pointerId)&&Y.releasePointerCapture(q.pointerId),P.current=null,N.current=null,Z){const oe=q.currentTarget,Q={originalEvent:q,delta:Z};qS(Z,v.swipeDirection,v.swipeThreshold)?Xd($F,w,Q,{discrete:!0}):Xd(FF,C,Q,{discrete:!0}),oe.addEventListener("click",X=>X.preventDefault(),{once:!0})}})})})}),v.viewport)})]}):null}),zF=t=>{const{__scopeToast:e,children:n,...r}=t,o=Qd(cc,e),[i,s]=m.useState(!1),[l,u]=m.useState(!1);return GF(()=>s(!0)),m.useEffect(()=>{const h=window.setTimeout(()=>u(!0),1e3);return()=>window.clearTimeout(h)},[]),l?null:d.jsx(od,{asChild:!0,children:d.jsx(bg,{...r,children:i&&d.jsxs(d.Fragment,{children:[o.label," ",n]})})})},VF="ToastTitle",BS=m.forwardRef((t,e)=>{const{__scopeToast:n,...r}=t;return d.jsx(mt.div,{...r,ref:e})});BS.displayName=VF;var KF="ToastDescription",zS=m.forwardRef((t,e)=>{const{__scopeToast:n,...r}=t;return d.jsx(mt.div,{...r,ref:e})});zS.displayName=KF;var VS="ToastAction",KS=m.forwardRef((t,e)=>{const{altText:n,...r}=t;return n.trim()?d.jsx(jS,{altText:n,asChild:!0,children:d.jsx(Ag,{...r,ref:e})}):(console.error(`Invalid prop \`altText\` supplied to \`${VS}\`. Expected non-empty \`string\`.`),null)});KS.displayName=VS;var GS="ToastClose",Ag=m.forwardRef((t,e)=>{const{__scopeToast:n,...r}=t,o=UF(GS,n);return d.jsx(jS,{asChild:!0,children:d.jsx(mt.button,{type:"button",...r,ref:e,onClick:Ue(t.onClick,o.onClose)})})});Ag.displayName=GS;var jS=m.forwardRef((t,e)=>{const{__scopeToast:n,altText:r,...o}=t;return d.jsx(mt.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...o,ref:e})});function WS(t){const e=[];return Array.from(t.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&e.push(r.textContent),jF(r)){const o=r.ariaHidden||r.hidden||r.style.display==="none",i=r.dataset.radixToastAnnounceExclude==="";if(!o)if(i){const s=r.dataset.radixToastAnnounceAlt;s&&e.push(s)}else e.push(...WS(r))}}),e}function Xd(t,e,n,{discrete:r}){const o=n.originalEvent.currentTarget,i=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n});e&&o.addEventListener(t,e,{once:!0}),r?LC(o,i):o.dispatchEvent(i)}var qS=(t,e,n=0)=>{const r=Math.abs(t.x),o=Math.abs(t.y),i=r>o;return e==="left"||e==="right"?i&&r>n:!i&&o>n};function GF(t=()=>{}){const e=mn(t);rn(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(e)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[e])}function jF(t){return t.nodeType===t.ELEMENT_NODE}function WF(t){const e=[],n=document.createTreeWalker(t,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();)e.push(n.currentNode);return e}function Ig(t){const e=document.activeElement;return t.some(n=>n===e?!0:(n.focus(),document.activeElement!==e))}var qF=LS,YS=$S,JS=US,QS=BS,XS=zS,ZS=KS,e_=Ag;const YF=qF,t_=m.forwardRef(({className:t,...e},n)=>d.jsx(YS,{ref:n,className:ze("s3-explr-ui-toast-viewport fixed top-0 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] z-[10000]",t),...e}));t_.displayName=YS.displayName;const JF=fg("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"}}),n_=m.forwardRef(({className:t,variant:e,...n},r)=>d.jsx(JS,{ref:r,className:ze(JF({variant:e}),t),...n}));n_.displayName=JS.displayName;const QF=m.forwardRef(({className:t,...e},n)=>d.jsx(ZS,{ref:n,className:ze("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",t),...e}));QF.displayName=ZS.displayName;const r_=m.forwardRef(({className:t,...e},n)=>d.jsx(e_,{ref:n,className:ze("absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity duration-200 ease-in-out 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 font-bold",t),"toast-close":"",...e,children:d.jsx(ig,{className:"s3-explr-ui-toast-close-icon h-4 w-4"})}));r_.displayName=e_.displayName;const o_=m.forwardRef(({className:t,...e},n)=>d.jsx(QS,{ref:n,className:ze("s3-explr-ui-toast-title text-sm font-semibold [&+div]:text-xs",t),...e}));o_.displayName=QS.displayName;const i_=m.forwardRef(({className:t,...e},n)=>d.jsx(XS,{ref:n,className:ze("text-sm opacity-90 font-bold",t),...e}));i_.displayName=XS.displayName;const XF=1,ZF=1e6;let kg=0;function e2(){return kg=(kg+1)%Number.MAX_SAFE_INTEGER,kg.toString()}const Ng=new Map,a_=t=>{if(Ng.has(t))return;const e=setTimeout(()=>{Ng.delete(t),lc({type:"REMOVE_TOAST",toastId:t})},ZF);Ng.set(t,e)},t2=(t,e)=>{switch(e.type){case"ADD_TOAST":return{...t,toasts:[e.toast,...t.toasts].slice(0,XF)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(n=>n.id===e.toast.id?{...n,...e.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=e;return n?a_(n):t.toasts.forEach(r=>{a_(r.id)}),{...t,toasts:t.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return e.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(n=>n.id!==e.toastId)}}},Zd=[];let eu={toasts:[]};function lc(t){eu=t2(eu,t),Zd.forEach(e=>{e(eu)})}function n2({...t}){const e=e2(),n=o=>lc({type:"UPDATE_TOAST",toast:{...o,id:e}}),r=()=>lc({type:"DISMISS_TOAST",toastId:e});return lc({type:"ADD_TOAST",toast:{...t,id:e,open:!0,onOpenChange:o=>{o||r()}}}),{id:e,dismiss:r,update:n}}function dc(){const[t,e]=m.useState(eu);return m.useEffect(()=>(Zd.push(e),()=>{const n=Zd.indexOf(e);n>-1&&Zd.splice(n,1)}),[t]),{...t,toast:n2,dismiss:n=>lc({type:"DISMISS_TOAST",toastId:n})}}function s_(){const{toasts:t}=dc();return d.jsxs(YF,{children:[t.map(function({id:e,title:n,description:r,action:o,...i}){return d.jsxs(n_,{...i,className:`s3-explr-ui-toast ${i.className||""}`,children:[d.jsxs("div",{className:"s3-explr-ui-toast-content grid gap-1",children:[n&&d.jsx(o_,{className:"s3-explr-ui-toast-title",children:n}),r&&d.jsx(i_,{className:"s3-explr-ui-toast-description",children:r})]}),o&&d.jsx("div",{className:"s3-explr-ui-toast-action",children:o}),d.jsx(r_,{className:"s3-explr-ui-toast-close"})]},e)}),d.jsx(t_,{className:"s3-explr-ui-toast-viewport"})]})}const r2=["top","right","bottom","left"],mi=Math.min,ir=Math.max,tu=Math.round,nu=Math.floor,uo=t=>({x:t,y:t}),o2={left:"right",right:"left",bottom:"top",top:"bottom"},i2={start:"end",end:"start"};function Pg(t,e,n){return ir(t,mi(e,n))}function Mo(t,e){return typeof t=="function"?t(e):t}function Ro(t){return t.split("-")[0]}function Xa(t){return t.split("-")[1]}function Og(t){return t==="x"?"y":"x"}function Mg(t){return t==="y"?"height":"width"}function Do(t){return["top","bottom"].includes(Ro(t))?"y":"x"}function Rg(t){return Og(Do(t))}function a2(t,e,n){n===void 0&&(n=!1);const r=Xa(t),o=Rg(t),i=Mg(o);let s=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=ru(s)),[s,ru(s)]}function s2(t){const e=ru(t);return[Dg(t),e,Dg(e)]}function Dg(t){return t.replace(/start|end/g,e=>i2[e])}function c2(t,e,n){const r=["left","right"],o=["right","left"],i=["top","bottom"],s=["bottom","top"];switch(t){case"top":case"bottom":return n?e?o:r:e?r:o;case"left":case"right":return e?i:s;default:return[]}}function l2(t,e,n,r){const o=Xa(t);let i=c2(Ro(t),n==="start",r);return o&&(i=i.map(s=>s+"-"+o),e&&(i=i.concat(i.map(Dg)))),i}function ru(t){return t.replace(/left|right|bottom|top/g,e=>o2[e])}function d2(t){return{top:0,right:0,bottom:0,left:0,...t}}function c_(t){return typeof t!="number"?d2(t):{top:t,right:t,bottom:t,left:t}}function ou(t){const{x:e,y:n,width:r,height:o}=t;return{width:r,height:o,top:n,left:e,right:e+r,bottom:n+o,x:e,y:n}}function l_(t,e,n){let{reference:r,floating:o}=t;const i=Do(e),s=Rg(e),l=Mg(s),u=Ro(e),h=i==="y",p=r.x+r.width/2-o.width/2,g=r.y+r.height/2-o.height/2,C=r[l]/2-o[l]/2;let w;switch(u){case"top":w={x:p,y:r.y-o.height};break;case"bottom":w={x:p,y:r.y+r.height};break;case"right":w={x:r.x+r.width,y:g};break;case"left":w={x:r.x-o.width,y:g};break;default:w={x:r.x,y:r.y}}switch(Xa(e)){case"start":w[s]-=C*(n&&h?-1:1);break;case"end":w[s]+=C*(n&&h?-1:1);break}return w}const u2=async(t,e,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:s}=n,l=i.filter(Boolean),u=await(s.isRTL==null?void 0:s.isRTL(e));let h=await s.getElementRects({reference:t,floating:e,strategy:o}),{x:p,y:g}=l_(h,r,u),C=r,w={},b=0;for(let v=0;v<l.length;v++){const{name:x,fn:E}=l[v],{x:A,y:N,data:P,reset:_}=await E({x:p,y:g,initialPlacement:r,placement:C,strategy:o,middlewareData:w,rects:h,platform:s,elements:{reference:t,floating:e}});p=A??p,g=N??g,w={...w,[x]:{...w[x],...P}},_&&b<=50&&(b++,typeof _=="object"&&(_.placement&&(C=_.placement),_.rects&&(h=_.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:o}):_.rects),{x:p,y:g}=l_(h,C,u)),v=-1)}return{x:p,y:g,placement:C,strategy:o,middlewareData:w}};async function uc(t,e){var n;e===void 0&&(e={});const{x:r,y:o,platform:i,rects:s,elements:l,strategy:u}=t,{boundary:h="clippingAncestors",rootBoundary:p="viewport",elementContext:g="floating",altBoundary:C=!1,padding:w=0}=Mo(e,t),b=c_(w),x=l[C?g==="floating"?"reference":"floating":g],E=ou(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(x)))==null||n?x:x.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:h,rootBoundary:p,strategy:u})),A=g==="floating"?{x:r,y:o,width:s.floating.width,height:s.floating.height}:s.reference,N=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),P=await(i.isElement==null?void 0:i.isElement(N))?await(i.getScale==null?void 0:i.getScale(N))||{x:1,y:1}:{x:1,y:1},_=ou(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:A,offsetParent:N,strategy:u}):A);return{top:(E.top-_.top+b.top)/P.y,bottom:(_.bottom-E.bottom+b.bottom)/P.y,left:(E.left-_.left+b.left)/P.x,right:(_.right-E.right+b.right)/P.x}}const f2=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:o,rects:i,platform:s,elements:l,middlewareData:u}=e,{element:h,padding:p=0}=Mo(t,e)||{};if(h==null)return{};const g=c_(p),C={x:n,y:r},w=Rg(o),b=Mg(w),v=await s.getDimensions(h),x=w==="y",E=x?"top":"left",A=x?"bottom":"right",N=x?"clientHeight":"clientWidth",P=i.reference[b]+i.reference[w]-C[w]-i.floating[b],_=C[w]-i.reference[w],D=await(s.getOffsetParent==null?void 0:s.getOffsetParent(h));let H=D?D[N]:0;(!H||!await(s.isElement==null?void 0:s.isElement(D)))&&(H=l.floating[N]||i.floating[b]);const K=P/2-_/2,ee=H/2-v[b]/2-1,W=mi(g[E],ee),de=mi(g[A],ee),se=W,fe=H-v[b]-de,q=H/2-v[b]/2+K,Z=Pg(se,q,fe),Y=!u.arrow&&Xa(o)!=null&&q!==Z&&i.reference[b]/2-(q<se?W:de)-v[b]/2<0,oe=Y?q<se?q-se:q-fe:0;return{[w]:C[w]+oe,data:{[w]:Z,centerOffset:q-Z-oe,...Y&&{alignmentOffset:oe}},reset:Y}}}),h2=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:o,middlewareData:i,rects:s,initialPlacement:l,platform:u,elements:h}=e,{mainAxis:p=!0,crossAxis:g=!0,fallbackPlacements:C,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:v=!0,...x}=Mo(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const E=Ro(o),A=Do(l),N=Ro(l)===l,P=await(u.isRTL==null?void 0:u.isRTL(h.floating)),_=C||(N||!v?[ru(l)]:s2(l)),D=b!=="none";!C&&D&&_.push(...l2(l,v,b,P));const H=[l,..._],K=await uc(e,x),ee=[];let W=((r=i.flip)==null?void 0:r.overflows)||[];if(p&&ee.push(K[E]),g){const Z=a2(o,s,P);ee.push(K[Z[0]],K[Z[1]])}if(W=[...W,{placement:o,overflows:ee}],!ee.every(Z=>Z<=0)){var de,se;const Z=(((de=i.flip)==null?void 0:de.index)||0)+1,Y=H[Z];if(Y){var fe;const Q=g==="alignment"?A!==Do(Y):!1,X=((fe=W[0])==null?void 0:fe.overflows[0])>0;if(!Q||X)return{data:{index:Z,overflows:W},reset:{placement:Y}}}let oe=(se=W.filter(Q=>Q.overflows[0]<=0).sort((Q,X)=>Q.overflows[1]-X.overflows[1])[0])==null?void 0:se.placement;if(!oe)switch(w){case"bestFit":{var q;const Q=(q=W.filter(X=>{if(D){const $=Do(X.placement);return $===A||$==="y"}return!0}).map(X=>[X.placement,X.overflows.filter($=>$>0).reduce(($,te)=>$+te,0)]).sort((X,$)=>X[1]-$[1])[0])==null?void 0:q[0];Q&&(oe=Q);break}case"initialPlacement":oe=l;break}if(o!==oe)return{reset:{placement:oe}}}return{}}}};function d_(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function u_(t){return r2.some(e=>t[e]>=0)}const p2=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...o}=Mo(t,e);switch(r){case"referenceHidden":{const i=await uc(e,{...o,elementContext:"reference"}),s=d_(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:u_(s)}}}case"escaped":{const i=await uc(e,{...o,altBoundary:!0}),s=d_(i,n.floating);return{data:{escapedOffsets:s,escaped:u_(s)}}}default:return{}}}}};async function g2(t,e){const{placement:n,platform:r,elements:o}=t,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),s=Ro(n),l=Xa(n),u=Do(n)==="y",h=["left","top"].includes(s)?-1:1,p=i&&u?-1:1,g=Mo(e,t);let{mainAxis:C,crossAxis:w,alignmentAxis:b}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return l&&typeof b=="number"&&(w=l==="end"?b*-1:b),u?{x:w*p,y:C*h}:{x:C*h,y:w*p}}const m2=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:o,y:i,placement:s,middlewareData:l}=e,u=await g2(e,t);return s===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:i+u.y,data:{...u,placement:s}}}}},v2=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:o}=e,{mainAxis:i=!0,crossAxis:s=!1,limiter:l={fn:x=>{let{x:E,y:A}=x;return{x:E,y:A}}},...u}=Mo(t,e),h={x:n,y:r},p=await uc(e,u),g=Do(Ro(o)),C=Og(g);let w=h[C],b=h[g];if(i){const x=C==="y"?"top":"left",E=C==="y"?"bottom":"right",A=w+p[x],N=w-p[E];w=Pg(A,w,N)}if(s){const x=g==="y"?"top":"left",E=g==="y"?"bottom":"right",A=b+p[x],N=b-p[E];b=Pg(A,b,N)}const v=l.fn({...e,[C]:w,[g]:b});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[C]:i,[g]:s}}}}}},y2=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:o,rects:i,middlewareData:s}=e,{offset:l=0,mainAxis:u=!0,crossAxis:h=!0}=Mo(t,e),p={x:n,y:r},g=Do(o),C=Og(g);let w=p[C],b=p[g];const v=Mo(l,e),x=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(u){const N=C==="y"?"height":"width",P=i.reference[C]-i.floating[N]+x.mainAxis,_=i.reference[C]+i.reference[N]-x.mainAxis;w<P?w=P:w>_&&(w=_)}if(h){var E,A;const N=C==="y"?"width":"height",P=["top","left"].includes(Ro(o)),_=i.reference[g]-i.floating[N]+(P&&((E=s.offset)==null?void 0:E[g])||0)+(P?0:x.crossAxis),D=i.reference[g]+i.reference[N]+(P?0:((A=s.offset)==null?void 0:A[g])||0)-(P?x.crossAxis:0);b<_?b=_:b>D&&(b=D)}return{[C]:w,[g]:b}}}},w2=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:o,rects:i,platform:s,elements:l}=e,{apply:u=()=>{},...h}=Mo(t,e),p=await uc(e,h),g=Ro(o),C=Xa(o),w=Do(o)==="y",{width:b,height:v}=i.floating;let x,E;g==="top"||g==="bottom"?(x=g,E=C===(await(s.isRTL==null?void 0:s.isRTL(l.floating))?"start":"end")?"left":"right"):(E=g,x=C==="end"?"top":"bottom");const A=v-p.top-p.bottom,N=b-p.left-p.right,P=mi(v-p[x],A),_=mi(b-p[E],N),D=!e.middlewareData.shift;let H=P,K=_;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(K=N),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(H=A),D&&!C){const W=ir(p.left,0),de=ir(p.right,0),se=ir(p.top,0),fe=ir(p.bottom,0);w?K=b-2*(W!==0||de!==0?W+de:ir(p.left,p.right)):H=v-2*(se!==0||fe!==0?se+fe:ir(p.top,p.bottom))}await u({...e,availableWidth:K,availableHeight:H});const ee=await s.getDimensions(l.floating);return b!==ee.width||v!==ee.height?{reset:{rects:!0}}:{}}}};function iu(){return typeof window<"u"}function Za(t){return f_(t)?(t.nodeName||"").toLowerCase():"#document"}function ar(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function fo(t){var e;return(e=(f_(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function f_(t){return iu()?t instanceof Node||t instanceof ar(t).Node:!1}function Hr(t){return iu()?t instanceof Element||t instanceof ar(t).Element:!1}function ho(t){return iu()?t instanceof HTMLElement||t instanceof ar(t).HTMLElement:!1}function h_(t){return!iu()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof ar(t).ShadowRoot}function fc(t){const{overflow:e,overflowX:n,overflowY:r,display:o}=Ur(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!["inline","contents"].includes(o)}function C2(t){return["table","td","th"].includes(Za(t))}function au(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function Lg(t){const e=Fg(),n=Hr(t)?Ur(t):t;return["transform","translate","scale","rotate","perspective"].some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function b2(t){let e=vi(t);for(;ho(e)&&!es(e);){if(Lg(e))return e;if(au(e))return null;e=vi(e)}return null}function Fg(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function es(t){return["html","body","#document"].includes(Za(t))}function Ur(t){return ar(t).getComputedStyle(t)}function su(t){return Hr(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function vi(t){if(Za(t)==="html")return t;const e=t.assignedSlot||t.parentNode||h_(t)&&t.host||fo(t);return h_(e)?e.host:e}function p_(t){const e=vi(t);return es(e)?t.ownerDocument?t.ownerDocument.body:t.body:ho(e)&&fc(e)?e:p_(e)}function hc(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const o=p_(t),i=o===((r=t.ownerDocument)==null?void 0:r.body),s=ar(o);if(i){const l=$g(s);return e.concat(s,s.visualViewport||[],fc(o)?o:[],l&&n?hc(l):[])}return e.concat(o,hc(o,[],n))}function $g(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function g_(t){const e=Ur(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const o=ho(t),i=o?t.offsetWidth:n,s=o?t.offsetHeight:r,l=tu(n)!==i||tu(r)!==s;return l&&(n=i,r=s),{width:n,height:r,$:l}}function Hg(t){return Hr(t)?t:t.contextElement}function ts(t){const e=Hg(t);if(!ho(e))return uo(1);const n=e.getBoundingClientRect(),{width:r,height:o,$:i}=g_(e);let s=(i?tu(n.width):n.width)/r,l=(i?tu(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!l||!Number.isFinite(l))&&(l=1),{x:s,y:l}}const x2=uo(0);function m_(t){const e=ar(t);return!Fg()||!e.visualViewport?x2:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function S2(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==ar(t)?!1:e}function qi(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const o=t.getBoundingClientRect(),i=Hg(t);let s=uo(1);e&&(r?Hr(r)&&(s=ts(r)):s=ts(t));const l=S2(i,n,r)?m_(i):uo(0);let u=(o.left+l.x)/s.x,h=(o.top+l.y)/s.y,p=o.width/s.x,g=o.height/s.y;if(i){const C=ar(i),w=r&&Hr(r)?ar(r):r;let b=C,v=$g(b);for(;v&&r&&w!==b;){const x=ts(v),E=v.getBoundingClientRect(),A=Ur(v),N=E.left+(v.clientLeft+parseFloat(A.paddingLeft))*x.x,P=E.top+(v.clientTop+parseFloat(A.paddingTop))*x.y;u*=x.x,h*=x.y,p*=x.x,g*=x.y,u+=N,h+=P,b=ar(v),v=$g(b)}}return ou({width:p,height:g,x:u,y:h})}function Ug(t,e){const n=su(t).scrollLeft;return e?e.left+n:qi(fo(t)).left+n}function v_(t,e,n){n===void 0&&(n=!1);const r=t.getBoundingClientRect(),o=r.left+e.scrollLeft-(n?0:Ug(t,r)),i=r.top+e.scrollTop;return{x:o,y:i}}function _2(t){let{elements:e,rect:n,offsetParent:r,strategy:o}=t;const i=o==="fixed",s=fo(r),l=e?au(e.floating):!1;if(r===s||l&&i)return n;let u={scrollLeft:0,scrollTop:0},h=uo(1);const p=uo(0),g=ho(r);if((g||!g&&!i)&&((Za(r)!=="body"||fc(s))&&(u=su(r)),ho(r))){const w=qi(r);h=ts(r),p.x=w.x+r.clientLeft,p.y=w.y+r.clientTop}const C=s&&!g&&!i?v_(s,u,!0):uo(0);return{width:n.width*h.x,height:n.height*h.y,x:n.x*h.x-u.scrollLeft*h.x+p.x+C.x,y:n.y*h.y-u.scrollTop*h.y+p.y+C.y}}function E2(t){return Array.from(t.getClientRects())}function T2(t){const e=fo(t),n=su(t),r=t.ownerDocument.body,o=ir(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=ir(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let s=-n.scrollLeft+Ug(t);const l=-n.scrollTop;return Ur(r).direction==="rtl"&&(s+=ir(e.clientWidth,r.clientWidth)-o),{width:o,height:i,x:s,y:l}}function A2(t,e){const n=ar(t),r=fo(t),o=n.visualViewport;let i=r.clientWidth,s=r.clientHeight,l=0,u=0;if(o){i=o.width,s=o.height;const h=Fg();(!h||h&&e==="fixed")&&(l=o.offsetLeft,u=o.offsetTop)}return{width:i,height:s,x:l,y:u}}function I2(t,e){const n=qi(t,!0,e==="fixed"),r=n.top+t.clientTop,o=n.left+t.clientLeft,i=ho(t)?ts(t):uo(1),s=t.clientWidth*i.x,l=t.clientHeight*i.y,u=o*i.x,h=r*i.y;return{width:s,height:l,x:u,y:h}}function y_(t,e,n){let r;if(e==="viewport")r=A2(t,n);else if(e==="document")r=T2(fo(t));else if(Hr(e))r=I2(e,n);else{const o=m_(t);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return ou(r)}function w_(t,e){const n=vi(t);return n===e||!Hr(n)||es(n)?!1:Ur(n).position==="fixed"||w_(n,e)}function k2(t,e){const n=e.get(t);if(n)return n;let r=hc(t,[],!1).filter(l=>Hr(l)&&Za(l)!=="body"),o=null;const i=Ur(t).position==="fixed";let s=i?vi(t):t;for(;Hr(s)&&!es(s);){const l=Ur(s),u=Lg(s);!u&&l.position==="fixed"&&(o=null),(i?!u&&!o:!u&&l.position==="static"&&!!o&&["absolute","fixed"].includes(o.position)||fc(s)&&!u&&w_(t,s))?r=r.filter(p=>p!==s):o=l,s=vi(s)}return e.set(t,r),r}function N2(t){let{element:e,boundary:n,rootBoundary:r,strategy:o}=t;const s=[...n==="clippingAncestors"?au(e)?[]:k2(e,this._c):[].concat(n),r],l=s[0],u=s.reduce((h,p)=>{const g=y_(e,p,o);return h.top=ir(g.top,h.top),h.right=mi(g.right,h.right),h.bottom=mi(g.bottom,h.bottom),h.left=ir(g.left,h.left),h},y_(e,l,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function P2(t){const{width:e,height:n}=g_(t);return{width:e,height:n}}function O2(t,e,n){const r=ho(e),o=fo(e),i=n==="fixed",s=qi(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const u=uo(0);function h(){u.x=Ug(o)}if(r||!r&&!i)if((Za(e)!=="body"||fc(o))&&(l=su(e)),r){const w=qi(e,!0,i,e);u.x=w.x+e.clientLeft,u.y=w.y+e.clientTop}else o&&h();i&&!r&&o&&h();const p=o&&!r&&!i?v_(o,l):uo(0),g=s.left+l.scrollLeft-u.x-p.x,C=s.top+l.scrollTop-u.y-p.y;return{x:g,y:C,width:s.width,height:s.height}}function Bg(t){return Ur(t).position==="static"}function C_(t,e){if(!ho(t)||Ur(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return fo(t)===n&&(n=n.ownerDocument.body),n}function b_(t,e){const n=ar(t);if(au(t))return n;if(!ho(t)){let o=vi(t);for(;o&&!es(o);){if(Hr(o)&&!Bg(o))return o;o=vi(o)}return n}let r=C_(t,e);for(;r&&C2(r)&&Bg(r);)r=C_(r,e);return r&&es(r)&&Bg(r)&&!Lg(r)?n:r||b2(t)||n}const M2=async function(t){const e=this.getOffsetParent||b_,n=this.getDimensions,r=await n(t.floating);return{reference:O2(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function R2(t){return Ur(t).direction==="rtl"}const D2={convertOffsetParentRelativeRectToViewportRelativeRect:_2,getDocumentElement:fo,getClippingRect:N2,getOffsetParent:b_,getElementRects:M2,getClientRects:E2,getDimensions:P2,getScale:ts,isElement:Hr,isRTL:R2};function x_(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function L2(t,e){let n=null,r;const o=fo(t);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function s(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),i();const h=t.getBoundingClientRect(),{left:p,top:g,width:C,height:w}=h;if(l||e(),!C||!w)return;const b=nu(g),v=nu(o.clientWidth-(p+C)),x=nu(o.clientHeight-(g+w)),E=nu(p),N={rootMargin:-b+"px "+-v+"px "+-x+"px "+-E+"px",threshold:ir(0,mi(1,u))||1};let P=!0;function _(D){const H=D[0].intersectionRatio;if(H!==u){if(!P)return s();H?s(!1,H):r=setTimeout(()=>{s(!1,1e-7)},1e3)}H===1&&!x_(h,t.getBoundingClientRect())&&s(),P=!1}try{n=new IntersectionObserver(_,{...N,root:o.ownerDocument})}catch{n=new IntersectionObserver(_,N)}n.observe(t)}return s(!0),i}function S_(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,h=Hg(t),p=o||i?[...h?hc(h):[],...hc(e)]:[];p.forEach(E=>{o&&E.addEventListener("scroll",n,{passive:!0}),i&&E.addEventListener("resize",n)});const g=h&&l?L2(h,n):null;let C=-1,w=null;s&&(w=new ResizeObserver(E=>{let[A]=E;A&&A.target===h&&w&&(w.unobserve(e),cancelAnimationFrame(C),C=requestAnimationFrame(()=>{var N;(N=w)==null||N.observe(e)})),n()}),h&&!u&&w.observe(h),w.observe(e));let b,v=u?qi(t):null;u&&x();function x(){const E=qi(t);v&&!x_(v,E)&&n(),v=E,b=requestAnimationFrame(x)}return n(),()=>{var E;p.forEach(A=>{o&&A.removeEventListener("scroll",n),i&&A.removeEventListener("resize",n)}),g==null||g(),(E=w)==null||E.disconnect(),w=null,u&&cancelAnimationFrame(b)}}const F2=m2,$2=v2,H2=h2,U2=w2,B2=p2,__=f2,z2=y2,V2=(t,e,n)=>{const r=new Map,o={platform:D2,...n},i={...o.platform,_c:r};return u2(t,e,{...o,platform:i})};var cu=typeof document<"u"?O.useLayoutEffect:O.useEffect;function lu(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,o;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!lu(t[r],e[r]))return!1;return!0}if(o=Object.keys(t),n=o.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&t.$$typeof)&&!lu(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function E_(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function T_(t,e){const n=E_(t);return Math.round(e*n)/n}function zg(t){const e=m.useRef(t);return cu(()=>{e.current=t}),e}function A_(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:s}={},transform:l=!0,whileElementsMounted:u,open:h}=t,[p,g]=m.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[C,w]=m.useState(r);lu(C,r)||w(r);const[b,v]=m.useState(null),[x,E]=m.useState(null),A=m.useCallback(Q=>{Q!==D.current&&(D.current=Q,v(Q))},[]),N=m.useCallback(Q=>{Q!==H.current&&(H.current=Q,E(Q))},[]),P=i||b,_=s||x,D=m.useRef(null),H=m.useRef(null),K=m.useRef(p),ee=u!=null,W=zg(u),de=zg(o),se=zg(h),fe=m.useCallback(()=>{if(!D.current||!H.current)return;const Q={placement:e,strategy:n,middleware:C};de.current&&(Q.platform=de.current),V2(D.current,H.current,Q).then(X=>{const $={...X,isPositioned:se.current!==!1};q.current&&!lu(K.current,$)&&(K.current=$,Aa.flushSync(()=>{g($)}))})},[C,e,n,de,se]);cu(()=>{h===!1&&K.current.isPositioned&&(K.current.isPositioned=!1,g(Q=>({...Q,isPositioned:!1})))},[h]);const q=m.useRef(!1);cu(()=>(q.current=!0,()=>{q.current=!1}),[]),cu(()=>{if(P&&(D.current=P),_&&(H.current=_),P&&_){if(W.current)return W.current(P,_,fe);fe()}},[P,_,fe,W,ee]);const Z=m.useMemo(()=>({reference:D,floating:H,setReference:A,setFloating:N}),[A,N]),Y=m.useMemo(()=>({reference:P,floating:_}),[P,_]),oe=m.useMemo(()=>{const Q={position:n,left:0,top:0};if(!Y.floating)return Q;const X=T_(Y.floating,p.x),$=T_(Y.floating,p.y);return l?{...Q,transform:"translate("+X+"px, "+$+"px)",...E_(Y.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:X,top:$}},[n,l,Y.floating,p.x,p.y]);return m.useMemo(()=>({...p,update:fe,refs:Z,elements:Y,floatingStyles:oe}),[p,fe,Z,Y,oe])}const K2=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:o}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?__({element:r.current,padding:o}).fn(n):{}:r?__({element:r,padding:o}).fn(n):{}}}},I_=(t,e)=>({...F2(t),options:[t,e]}),k_=(t,e)=>({...$2(t),options:[t,e]}),N_=(t,e)=>({...z2(t),options:[t,e]}),P_=(t,e)=>({...H2(t),options:[t,e]}),O_=(t,e)=>({...U2(t),options:[t,e]}),M_=(t,e)=>({...B2(t),options:[t,e]}),R_=(t,e)=>({...K2(t),options:[t,e]});var G2="Arrow",D_=m.forwardRef((t,e)=>{const{children:n,width:r=10,height:o=5,...i}=t;return d.jsx(mt.svg,{...i,ref:e,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});D_.displayName=G2;var j2=D_,Vg="Popper",[L_,F_]=hr(Vg),[W2,$_]=L_(Vg),H_=t=>{const{__scopePopper:e,children:n}=t,[r,o]=m.useState(null);return d.jsx(W2,{scope:e,anchor:r,onAnchorChange:o,children:n})};H_.displayName=Vg;var U_="PopperAnchor",B_=m.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...o}=t,i=$_(U_,n),s=m.useRef(null),l=rt(e,s);return m.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||s.current)}),r?null:d.jsx(mt.div,{...o,ref:l})});B_.displayName=U_;var Kg="PopperContent",[q2,Y2]=L_(Kg),z_=m.forwardRef((t,e)=>{var z,ce,Ae,Ce,Ne,ne;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:h=[],collisionPadding:p=0,sticky:g="partial",hideWhenDetached:C=!1,updatePositionStrategy:w="optimized",onPlaced:b,...v}=t,x=$_(Kg,n),[E,A]=m.useState(null),N=rt(e,Ve=>A(Ve)),[P,_]=m.useState(null),D=hg(P),H=(D==null?void 0:D.width)??0,K=(D==null?void 0:D.height)??0,ee=r+(i!=="center"?"-"+i:""),W=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},de=Array.isArray(h)?h:[h],se=de.length>0,fe={padding:W,boundary:de.filter(Q2),altBoundary:se},{refs:q,floatingStyles:Z,placement:Y,isPositioned:oe,middlewareData:Q}=A_({strategy:"fixed",placement:ee,whileElementsMounted:(...Ve)=>S_(...Ve,{animationFrame:w==="always"}),elements:{reference:x.anchor},middleware:[I_({mainAxis:o+K,alignmentAxis:s}),u&&k_({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?N_():void 0,...fe}),u&&P_({...fe}),O_({...fe,apply:({elements:Ve,rects:Qe,availableWidth:Ct,availableHeight:Jt})=>{const{width:bt,height:an}=Qe.reference,zt=Ve.floating.style;zt.setProperty("--radix-popper-available-width",`${Ct}px`),zt.setProperty("--radix-popper-available-height",`${Jt}px`),zt.setProperty("--radix-popper-anchor-width",`${bt}px`),zt.setProperty("--radix-popper-anchor-height",`${an}px`)}}),P&&R_({element:P,padding:l}),X2({arrowWidth:H,arrowHeight:K}),C&&M_({strategy:"referenceHidden",...fe})]}),[X,$]=G_(Y),te=mn(b);rn(()=>{oe&&(te==null||te())},[oe,te]);const _e=(z=Q.arrow)==null?void 0:z.x,ke=(ce=Q.arrow)==null?void 0:ce.y,xe=((Ae=Q.arrow)==null?void 0:Ae.centerOffset)!==0,[Pe,Te]=m.useState();return rn(()=>{E&&Te(window.getComputedStyle(E).zIndex)},[E]),d.jsx("div",{ref:q.setFloating,"data-radix-popper-content-wrapper":"",style:{...Z,transform:oe?Z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Pe,"--radix-popper-transform-origin":[(Ce=Q.transformOrigin)==null?void 0:Ce.x,(Ne=Q.transformOrigin)==null?void 0:Ne.y].join(" "),...((ne=Q.hide)==null?void 0:ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:d.jsx(q2,{scope:n,placedSide:X,onArrowChange:_,arrowX:_e,arrowY:ke,shouldHideArrow:xe,children:d.jsx(mt.div,{"data-side":X,"data-align":$,...v,ref:N,style:{...v.style,animation:oe?void 0:"none"}})})})});z_.displayName=Kg;var V_="PopperArrow",J2={top:"bottom",right:"left",bottom:"top",left:"right"},K_=m.forwardRef(function(e,n){const{__scopePopper:r,...o}=e,i=Y2(V_,r),s=J2[i.placedSide];return d.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:d.jsx(j2,{...o,ref:n,style:{...o.style,display:"block"}})})});K_.displayName=V_;function Q2(t){return t!==null}var X2=t=>({name:"transformOrigin",options:t,fn(e){var x,E,A;const{placement:n,rects:r,middlewareData:o}=e,s=((x=o.arrow)==null?void 0:x.centerOffset)!==0,l=s?0:t.arrowWidth,u=s?0:t.arrowHeight,[h,p]=G_(n),g={start:"0%",center:"50%",end:"100%"}[p],C=(((E=o.arrow)==null?void 0:E.x)??0)+l/2,w=(((A=o.arrow)==null?void 0:A.y)??0)+u/2;let b="",v="";return h==="bottom"?(b=s?g:`${C}px`,v=`${-u}px`):h==="top"?(b=s?g:`${C}px`,v=`${r.floating.height+u}px`):h==="right"?(b=`${-u}px`,v=s?g:`${w}px`):h==="left"&&(b=`${r.floating.width+u}px`,v=s?g:`${w}px`),{data:{x:b,y:v}}}});function G_(t){const[e,n="center"]=t.split("-");return[e,n]}var Z2=H_,e$=B_,t$=z_,n$=K_,r$=Symbol("radix.slottable");function o$(t){const e=({children:n})=>d.jsx(d.Fragment,{children:n});return e.displayName=`${t}.Slottable`,e.__radixId=r$,e}var i$=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),a$="VisuallyHidden",j_=m.forwardRef((t,e)=>d.jsx(mt.span,{...t,ref:e,style:{...i$,...t.style}}));j_.displayName=a$;var s$=j_,[du,mW]=hr("Tooltip",[F_]),uu=F_(),W_="TooltipProvider",c$=700,Gg="tooltip.open",[l$,jg]=du(W_),q_=t=>{const{__scopeTooltip:e,delayDuration:n=c$,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=t,s=m.useRef(!0),l=m.useRef(!1),u=m.useRef(0);return m.useEffect(()=>{const h=u.current;return()=>window.clearTimeout(h)},[]),d.jsx(l$,{scope:e,isOpenDelayedRef:s,delayDuration:n,onOpen:m.useCallback(()=>{window.clearTimeout(u.current),s.current=!1},[]),onClose:m.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>s.current=!0,r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:m.useCallback(h=>{l.current=h},[]),disableHoverableContent:o,children:i})};q_.displayName=W_;var pc="Tooltip",[d$,gc]=du(pc),Y_=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:s,delayDuration:l}=t,u=jg(pc,t.__scopeTooltip),h=uu(e),[p,g]=m.useState(null),C=Io(),w=m.useRef(0),b=s??u.disableHoverableContent,v=l??u.delayDuration,x=m.useRef(!1),[E,A]=si({prop:r,defaultProp:o??!1,onChange:H=>{H?(u.onOpen(),document.dispatchEvent(new CustomEvent(Gg))):u.onClose(),i==null||i(H)},caller:pc}),N=m.useMemo(()=>E?x.current?"delayed-open":"instant-open":"closed",[E]),P=m.useCallback(()=>{window.clearTimeout(w.current),w.current=0,x.current=!1,A(!0)},[A]),_=m.useCallback(()=>{window.clearTimeout(w.current),w.current=0,A(!1)},[A]),D=m.useCallback(()=>{window.clearTimeout(w.current),w.current=window.setTimeout(()=>{x.current=!0,A(!0),w.current=0},v)},[v,A]);return m.useEffect(()=>()=>{w.current&&(window.clearTimeout(w.current),w.current=0)},[]),d.jsx(Z2,{...h,children:d.jsx(d$,{scope:e,contentId:C,open:E,stateAttribute:N,trigger:p,onTriggerChange:g,onTriggerEnter:m.useCallback(()=>{u.isOpenDelayedRef.current?D():P()},[u.isOpenDelayedRef,D,P]),onTriggerLeave:m.useCallback(()=>{b?_():(window.clearTimeout(w.current),w.current=0)},[_,b]),onOpen:P,onClose:_,disableHoverableContent:b,children:n})})};Y_.displayName=pc;var Wg="TooltipTrigger",J_=m.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,o=gc(Wg,n),i=jg(Wg,n),s=uu(n),l=m.useRef(null),u=rt(e,l,o.onTriggerChange),h=m.useRef(!1),p=m.useRef(!1),g=m.useCallback(()=>h.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",g),[g]),d.jsx(e$,{asChild:!0,...s,children:d.jsx(mt.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:u,onPointerMove:Ue(t.onPointerMove,C=>{C.pointerType!=="touch"&&!p.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),p.current=!0)}),onPointerLeave:Ue(t.onPointerLeave,()=>{o.onTriggerLeave(),p.current=!1}),onPointerDown:Ue(t.onPointerDown,()=>{o.open&&o.onClose(),h.current=!0,document.addEventListener("pointerup",g,{once:!0})}),onFocus:Ue(t.onFocus,()=>{h.current||o.onOpen()}),onBlur:Ue(t.onBlur,o.onClose),onClick:Ue(t.onClick,o.onClose)})})});J_.displayName=Wg;var qg="TooltipPortal",[u$,f$]=du(qg,{forceMount:void 0}),Q_=t=>{const{__scopeTooltip:e,forceMount:n,children:r,container:o}=t,i=gc(qg,e);return d.jsx(u$,{scope:e,forceMount:n,children:d.jsx(ko,{present:n||i.open,children:d.jsx(od,{asChild:!0,container:o,children:r})})})};Q_.displayName=qg;var ns="TooltipContent",X_=m.forwardRef((t,e)=>{const n=f$(ns,t.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=t,s=gc(ns,t.__scopeTooltip);return d.jsx(ko,{present:r||s.open,children:s.disableHoverableContent?d.jsx(Z_,{side:o,...i,ref:e}):d.jsx(h$,{side:o,...i,ref:e})})}),h$=m.forwardRef((t,e)=>{const n=gc(ns,t.__scopeTooltip),r=jg(ns,t.__scopeTooltip),o=m.useRef(null),i=rt(e,o),[s,l]=m.useState(null),{trigger:u,onClose:h}=n,p=o.current,{onPointerInTransitChange:g}=r,C=m.useCallback(()=>{l(null),g(!1)},[g]),w=m.useCallback((b,v)=>{const x=b.currentTarget,E={x:b.clientX,y:b.clientY},A=y$(E,x.getBoundingClientRect()),N=w$(E,A),P=C$(v.getBoundingClientRect()),_=x$([...N,...P]);l(_),g(!0)},[g]);return m.useEffect(()=>()=>C(),[C]),m.useEffect(()=>{if(u&&p){const b=x=>w(x,p),v=x=>w(x,u);return u.addEventListener("pointerleave",b),p.addEventListener("pointerleave",v),()=>{u.removeEventListener("pointerleave",b),p.removeEventListener("pointerleave",v)}}},[u,p,w,C]),m.useEffect(()=>{if(s){const b=v=>{const x=v.target,E={x:v.clientX,y:v.clientY},A=(u==null?void 0:u.contains(x))||(p==null?void 0:p.contains(x)),N=!b$(E,s);A?C():N&&(C(),h())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[u,p,s,h,C]),d.jsx(Z_,{...t,ref:i})}),[p$,g$]=du(pc,{isInside:!1}),m$=o$("TooltipContent"),Z_=m.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:s,...l}=t,u=gc(ns,n),h=uu(n),{onClose:p}=u;return m.useEffect(()=>(document.addEventListener(Gg,p),()=>document.removeEventListener(Gg,p)),[p]),m.useEffect(()=>{if(u.trigger){const g=C=>{const w=C.target;w!=null&&w.contains(u.trigger)&&p()};return window.addEventListener("scroll",g,{capture:!0}),()=>window.removeEventListener("scroll",g,{capture:!0})}},[u.trigger,p]),d.jsx(rd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:g=>g.preventDefault(),onDismiss:p,children:d.jsxs(t$,{"data-state":u.stateAttribute,...h,...l,ref:e,style:{...l.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:[d.jsx(m$,{children:r}),d.jsx(p$,{scope:n,isInside:!0,children:d.jsx(s$,{id:u.contentId,role:"tooltip",children:o||r})})]})})});X_.displayName=ns;var eE="TooltipArrow",v$=m.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,o=uu(n);return g$(eE,n).isInside?null:d.jsx(n$,{...o,...r,ref:e})});v$.displayName=eE;function y$(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),o=Math.abs(e.right-t.x),i=Math.abs(e.left-t.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function w$(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function C$(t){const{top:e,right:n,bottom:r,left:o}=t;return[{x:o,y:e},{x:n,y:e},{x:n,y:r},{x:o,y:r}]}function b$(t,e){const{x:n,y:r}=t;let o=!1;for(let i=0,s=e.length-1;i<e.length;s=i++){const l=e[i],u=e[s],h=l.x,p=l.y,g=u.x,C=u.y;p>r!=C>r&&n<(g-h)*(r-p)/(C-p)+h&&(o=!o)}return o}function x$(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),S$(e)}function S$(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const o=t[r];for(;e.length>=2;){const i=e[e.length-1],s=e[e.length-2];if((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x))e.pop();else break}e.push(o)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const o=t[r];for(;n.length>=2;){const i=n[n.length-1],s=n[n.length-2];if((i.x-s.x)*(o.y-s.y)>=(i.y-s.y)*(o.x-s.x))n.pop();else break}n.push(o)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var _$=q_,E$=Y_,T$=J_,A$=Q_,tE=X_;const gr=_$,mr=E$,vr=T$,sr=m.forwardRef(({className:t,sideOffset:e=4,...n},r)=>d.jsx(A$,{children:d.jsx(tE,{ref:r,sideOffset:e,className:ze("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",t),...n})}));sr.displayName=tE.displayName;function I$({title:t,titleId:e,...n},r){return m.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":e},n),t?m.createElement("title",{id:e},t):null,m.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 k$=m.forwardRef(I$);var N$=function(t){return function(e,n){var r=O.useRef(!1);t(function(){return function(){r.current=!1}},[]),t(function(){if(!r.current)r.current=!0;else return e()},n)}},nE=function(t){return typeof t=="function"},rE=process.env.NODE_ENV==="development"||process.env.NODE_ENV==="test";const P$=N$(O.useEffect);function oE(t){var e=O.useRef(t);return e.current=t,e}var O$=function(t){rE&&(nE(t)||console.error("useUnmount expected parameter is a function, got ".concat(typeof t)));var e=oE(t);O.useEffect(function(){return function(){e.current()}},[])};function M$(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var iE=M$,R$=typeof so=="object"&&so&&so.Object===Object&&so,D$=R$,L$=D$,F$=typeof self=="object"&&self&&self.Object===Object&&self,$$=L$||F$||Function("return this")(),aE=$$,H$=aE,U$=function(){return H$.Date.now()},B$=U$,z$=/\s/;function V$(t){for(var e=t.length;e--&&z$.test(t.charAt(e)););return e}var K$=V$,G$=K$,j$=/^\s+/;function W$(t){return t&&t.slice(0,G$(t)+1).replace(j$,"")}var q$=W$,Y$=aE,J$=Y$.Symbol,sE=J$,cE=sE,lE=Object.prototype,Q$=lE.hasOwnProperty,X$=lE.toString,mc=cE?cE.toStringTag:void 0;function Z$(t){var e=Q$.call(t,mc),n=t[mc];try{t[mc]=void 0;var r=!0}catch{}var o=X$.call(t);return r&&(e?t[mc]=n:delete t[mc]),o}var eH=Z$,tH=Object.prototype,nH=tH.toString;function rH(t){return nH.call(t)}var oH=rH,dE=sE,iH=eH,aH=oH,sH="[object Null]",cH="[object Undefined]",uE=dE?dE.toStringTag:void 0;function lH(t){return t==null?t===void 0?cH:sH:uE&&uE in Object(t)?iH(t):aH(t)}var dH=lH;function uH(t){return t!=null&&typeof t=="object"}var fH=uH,hH=dH,pH=fH,gH="[object Symbol]";function mH(t){return typeof t=="symbol"||pH(t)&&hH(t)==gH}var vH=mH,yH=q$,fE=iE,wH=vH,hE=NaN,CH=/^[-+]0x[0-9a-f]+$/i,bH=/^0b[01]+$/i,xH=/^0o[0-7]+$/i,SH=parseInt;function _H(t){if(typeof t=="number")return t;if(wH(t))return hE;if(fE(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=fE(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=yH(t);var n=bH.test(t);return n||xH.test(t)?SH(t.slice(2),n?2:8):CH.test(t)?hE:+t}var EH=_H,TH=iE,Yg=B$,pE=EH,AH="Expected a function",IH=Math.max,kH=Math.min;function NH(t,e,n){var r,o,i,s,l,u,h=0,p=!1,g=!1,C=!0;if(typeof t!="function")throw new TypeError(AH);e=pE(e)||0,TH(n)&&(p=!!n.leading,g="maxWait"in n,i=g?IH(pE(n.maxWait)||0,e):i,C="trailing"in n?!!n.trailing:C);function w(D){var H=r,K=o;return r=o=void 0,h=D,s=t.apply(K,H),s}function b(D){return h=D,l=setTimeout(E,e),p?w(D):s}function v(D){var H=D-u,K=D-h,ee=e-H;return g?kH(ee,i-K):ee}function x(D){var H=D-u,K=D-h;return u===void 0||H>=e||H<0||g&&K>=i}function E(){var D=Yg();if(x(D))return A(D);l=setTimeout(E,v(D))}function A(D){return l=void 0,C&&r?w(D):(r=o=void 0,s)}function N(){l!==void 0&&clearTimeout(l),h=0,r=u=o=l=void 0}function P(){return l===void 0?s:A(Yg())}function _(){var D=Yg(),H=x(D);if(r=arguments,o=this,u=D,H){if(l===void 0)return b(u);if(g)return clearTimeout(l),l=setTimeout(E,e),w(u)}return l===void 0&&(l=setTimeout(E,e)),s}return _.cancel=N,_.flush=P,_}var PH=NH;const OH=Od(PH);function MH(){var t=(typeof global>"u"?"undefined":typeof global)=="object"&&global&&global.Object===Object&&global,e=typeof self=="object"&&self&&self.Object===Object&&self;return t||e}MH()||(global.Date=Date);function RH(t,e){var n;rE&&(nE(t)||console.error("useDebounceFn expected parameter is a function, got ".concat(typeof t)));var r=oE(t),o=(n=e==null?void 0:e.wait)!==null&&n!==void 0?n:1e3,i=O.useMemo(function(){return OH(function(){for(var s=[],l=0;l<arguments.length;l++)s[l]=arguments[l];return r.current.apply(r,ZC([],XC(s),!1))},o,e)},[]);return O$(function(){i.cancel()}),{run:i,cancel:i.cancel,flush:i.flush}}function DH(t,e,n){var r=XC(O.useState({}),2),o=r[0],i=r[1],s=RH(function(){i({})},n).run;O.useEffect(function(){return s()},e),P$(t,[o])}const LH=O.forwardRef(({onChange:t},e)=>{const n=O.useRef(null),[r,o]=O.useState("");return O.useImperativeHandle(e,()=>({setValue:i=>{var s;o(i),(s=n.current)==null||s.focus()}})),DH(()=>{t==null||t(r)},[r],{wait:300}),d.jsxs(d.Fragment,{children:[d.jsx(Wn,{ref:n,type:"text",placeholder:"Search files...",value:r,onChange:i=>o(i.target.value),className:"pr-8"}),r&&d.jsx("button",{onClick:()=>{var i;o(""),(i=n.current)==null||i.focus()},className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700",children:d.jsx(k$,{className:"h-5 w-5"})})]})});var Br=(t=>(t.VIEW_DOCUMENT="VIEW_DOCUMENT",t.DOWNLOAD_DOCUMENT="DOWNLOAD_DOCUMENT",t.EDIT_DOCUMENT="EDIT_DOCUMENT",t.OWNER_DOCUMENT="OWNER_DOCUMENT",t))(Br||{});const FH=(t,e)=>{const[n,r]=O.useState([]),[o,i]=O.useState([]),[s,l]=O.useState([]),[u,h]=O.useState([]),{toast:p}=dc(),[g,C]=O.useState(!1),[w,b]=O.useState(!1),v=O.useCallback(async(P,_,D)=>{if(!w){b(!0);try{const H=await Le.post(t+"/document-permission/grandted",{path:P,grandtedBy:_,data:D});return H.status===200&&(p({title:"Phân quyền tài liệu thành công."}),await N(P)),H}catch{return null}finally{b(!1)}}},[]),x=O.useCallback(async()=>{var P;try{return(P=(await Le.get(e+"admin/users/get-all",{params:{limit:1e4}})).data||[])==null?void 0:P.filter(K=>K.role!=="MASTER_ADMIN")}catch(_){return console.error("Error fetchAllUsers",_),[]}},[]),E=O.useCallback(async()=>{try{return(await Le.get(e+"admin/group-users")).data.filter(_=>`${_.groupname}`.toUpperCase()!=="MASTER_ADMIN").map(_=>{var D;return{..._,users:((D=_.users)==null?void 0:D.length)||0}})}catch(P){return console.error("Error fetchAllGroups",P),[]}},[]),A=O.useCallback(async P=>{try{const D=(await Le.get(t+"/document-permission/grandted",{params:{path:P}})).data;return{usersShared:(D==null?void 0:D.users)||[],groupsShared:(D==null?void 0:D.groups)||[]}}catch(_){return console.error("Error fetchShared",_),{usersShared:[],groupsShared:[]}}},[]),N=O.useCallback(async P=>{if(g)return;C(!0);let[_,D,{usersShared:H,groupsShared:K}]=await Promise.all([x(),E(),A(P)]);_=_==null?void 0:_.filter(ee=>!(H!=null&&H.find(W=>W.userId===ee.id))),D=D==null?void 0:D.filter(ee=>!(K!=null&&K.find(W=>W.groupname===ee.groupname))),Array.isArray(_)&&r(_),Array.isArray(D)&&i(D),Array.isArray(H)&&l(H),Array.isArray(K)&&h(K),C(!1)},[]);return{users:n,groups:o,sharedUsers:s,sharedGroups:u,setUsers:r,setGroups:i,setSharedUsers:l,setSharedGroups:h,fetchData:N,loading:g,postGranted:v,loadingGrandted:w}},$H=({failureReasons:t})=>{const e=s=>{const l=[];return s.forEach(u=>{try{JSON.parse(u).forEach(p=>{const g=p.match(/\[Files: ([^\]]+)\]/),C=p.match(/^([^[]+)/);if(g&&C&&g[1]&&C[1]){const w=g[1].split(", ").map(x=>x.trim()),b=C[1].trim().replace("Encountered error: ","");let v="unknown";b.includes("invalid metadata attributes")||b.includes("metadata quota")?v="metadata":b.includes("No metadata was provided")||b.includes("metadata file")?v="missing_metadata":b.includes("file size")||b.includes("exceeds")||b.includes("50 MB")?v="file_size":b.includes("format not supported")||b.includes("unsupported format")||b.includes("file type")?v="file_format":b.includes("embedding failed")||b.includes("EMBEDDING_FAILED")?v="embedding_failed":b.includes("indexing failed")||b.includes("INDEXING_FAILED")?v="indexing_failed":b.includes("access denied")||b.includes("AccessDeniedException")||b.includes("permission")?v="access_denied":(b.includes("quota")||b.includes("limit")||b.includes("ServiceQuotaExceededException"))&&(v="quota_exceeded"),l.push({errorMessage:b,files:w,errorType:v})}})}catch{l.push({errorMessage:u,files:[],errorType:"unknown"})}}),l},n=s=>{switch(s){case"metadata":return d.jsx(ui,{className:"h-4 w-4 text-orange-500"});case"missing_metadata":return d.jsx(og,{className:"h-4 w-4 text-red-500"});case"file_size":return d.jsx(ui,{className:"h-4 w-4 text-yellow-500"});case"file_format":return d.jsx(og,{className:"h-4 w-4 text-purple-500"});case"embedding_failed":return d.jsx(ui,{className:"h-4 w-4 text-red-600"});case"indexing_failed":return d.jsx(ui,{className:"h-4 w-4 text-red-600"});case"access_denied":return d.jsx(ui,{className:"h-4 w-4 text-red-700"});case"quota_exceeded":return d.jsx(ui,{className:"h-4 w-4 text-orange-600"});default:return d.jsx(ui,{className:"h-4 w-4 text-red-500"})}},r=s=>{switch(s){case"metadata":return"border-orange-200 bg-orange-50";case"missing_metadata":return"border-red-200 bg-red-50";case"file_size":return"border-yellow-200 bg-yellow-50";case"file_format":return"border-purple-200 bg-purple-50";case"embedding_failed":return"border-red-300 bg-red-100";case"indexing_failed":return"border-red-300 bg-red-100";case"access_denied":return"border-red-400 bg-red-100";case"quota_exceeded":return"border-orange-300 bg-orange-100";default:return"border-red-200 bg-red-50"}},o=s=>{switch(s){case"metadata":return"text-orange-800";case"missing_metadata":return"text-red-800";case"file_size":return"text-yellow-800";case"file_format":return"text-purple-800";case"embedding_failed":return"text-red-900";case"indexing_failed":return"text-red-900";case"access_denied":return"text-red-900";case"quota_exceeded":return"text-orange-900";default:return"text-red-800"}},i=e(t);return i.length===0?null:d.jsxs("div",{className:"border-t pt-2",children:[d.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[d.jsx(ui,{className:"h-4 w-4 text-red-500"}),d.jsxs("p",{className:"text-red-600 font-medium",children:["Các file lỗi (",i.reduce((s,l)=>s+l.files.length,0)," file)"]})]}),d.jsx("div",{className:"space-y-3 max-h-80 overflow-y-auto",children:i.map((s,l)=>d.jsxs("div",{className:`p-3 rounded-lg border ${r(s.errorType)}`,children:[d.jsx("div",{className:"flex items-start justify-between",children:d.jsxs("div",{className:"flex items-start gap-2 flex-1",children:[n(s.errorType),d.jsxs("div",{className:"flex-1",children:[d.jsx("p",{className:`font-medium text-sm ${o(s.errorType)}`,children:s.errorMessage}),s.files.length>0&&d.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:[s.files.length," file bị ảnh hưởng"]})]})]})}),s.files.length>0&&d.jsxs("div",{className:"mt-3 pt-2 border-t border-gray-200",children:[d.jsx("p",{className:"text-xs font-medium text-gray-700 mb-2",children:"Danh sách file lỗi:"}),d.jsx("div",{className:"max-h-32 overflow-y-auto space-y-1",children:s.files.map((u,h)=>d.jsxs("div",{className:"flex items-center gap-2 text-xs p-2 bg-white/50 rounded",children:[d.jsx(og,{className:"h-3 w-3 text-red-400 flex-shrink-0"}),d.jsx("span",{className:"text-gray-700 break-all font-mono",children:u.replace("s3://cts-llm-docs-bucket/","")})]},h))})]})]},l))})]})};var Jg={exports:{}},fu={exports:{}},yt={};/** @license React v16.13.1
|
|
200
200
|
* react-is.production.min.js
|
|
201
201
|
*
|
|
202
202
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -219,7 +219,7 @@ Valid keys: `+JSON.stringify(Object.keys($),null," "));var ne=Ne(z,Ce,xe,Pe,Te+
|
|
|
219
219
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function sU(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function cU(t){if(Array.isArray(t))return am(t)}function OE(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function ME(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?OE(Object(n),!0).forEach(function(r){RE(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):OE(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function RE(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vc(t,e){return uU(t)||dU(t,e)||DE(t,e)||lU()}function lU(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
220
220
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function DE(t,e){if(t){if(typeof t=="string")return am(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return am(t,e)}}function am(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function dU(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r=[],o=!0,i=!1,s,l;try{for(n=n.call(t);!(o=(s=n.next()).done)&&(r.push(s.value),!(e&&r.length===e));o=!0);}catch(u){i=!0,l=u}finally{try{!o&&n.return!=null&&n.return()}finally{if(i)throw l}}return r}}function uU(t){if(Array.isArray(t))return t}var fU=typeof im=="function"?im:im.default,hU="file-invalid-type",pU="file-too-large",gU="file-too-small",mU="too-many-files",vU=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",n=e.split(","),r=n.length>1?"one of ".concat(n.join(", ")):n[0];return{code:hU,message:"File type must be ".concat(r)}},LE=function(e){return{code:pU,message:"File is larger than ".concat(e," ").concat(e===1?"byte":"bytes")}},FE=function(e){return{code:gU,message:"File is smaller than ".concat(e," ").concat(e===1?"byte":"bytes")}},yU={code:mU,message:"Too many files"};function $E(t,e){var n=t.type==="application/x-moz-file"||fU(t,e);return[n,n?null:vU(e)]}function HE(t,e,n){if(Yi(t.size))if(Yi(e)&&Yi(n)){if(t.size>n)return[!1,LE(n)];if(t.size<e)return[!1,FE(e)]}else{if(Yi(e)&&t.size<e)return[!1,FE(e)];if(Yi(n)&&t.size>n)return[!1,LE(n)]}return[!0,null]}function Yi(t){return t!=null}function wU(t){var e=t.files,n=t.accept,r=t.minSize,o=t.maxSize,i=t.multiple,s=t.maxFiles,l=t.validator;return!i&&e.length>1||i&&s>=1&&e.length>s?!1:e.every(function(u){var h=$E(u,n),p=vc(h,1),g=p[0],C=HE(u,r,o),w=vc(C,1),b=w[0],v=l?l(u):null;return g&&b&&!v})}function pu(t){return typeof t.isPropagationStopped=="function"?t.isPropagationStopped():typeof t.cancelBubble<"u"?t.cancelBubble:!1}function gu(t){return t.dataTransfer?Array.prototype.some.call(t.dataTransfer.types,function(e){return e==="Files"||e==="application/x-moz-file"}):!!t.target&&!!t.target.files}function UE(t){t.preventDefault()}function CU(t){return t.indexOf("MSIE")!==-1||t.indexOf("Trident/")!==-1}function bU(t){return t.indexOf("Edge/")!==-1}function xU(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return CU(t)||bU(t)}function po(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return function(r){for(var o=arguments.length,i=new Array(o>1?o-1:0),s=1;s<o;s++)i[s-1]=arguments[s];return e.some(function(l){return!pu(r)&&l&&l.apply(void 0,[r].concat(i)),pu(r)})}}function SU(){return"showOpenFilePicker"in window}function _U(t){if(Yi(t)){var e=Object.entries(t).filter(function(n){var r=vc(n,2),o=r[0],i=r[1],s=!0;return BE(o)||(console.warn('Skipped "'.concat(o,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),s=!1),(!Array.isArray(i)||!i.every(zE))&&(console.warn('Skipped "'.concat(o,'" because an invalid file extension was provided.')),s=!1),s}).reduce(function(n,r){var o=vc(r,2),i=o[0],s=o[1];return ME(ME({},n),{},RE({},i,s))},{});return[{description:"Files",accept:e}]}return t}function EU(t){if(Yi(t))return Object.entries(t).reduce(function(e,n){var r=vc(n,2),o=r[0],i=r[1];return[].concat(PE(e),[o],PE(i))},[]).filter(function(e){return BE(e)||zE(e)}).join(",")}function TU(t){return t instanceof DOMException&&(t.name==="AbortError"||t.code===t.ABORT_ERR)}function AU(t){return t instanceof DOMException&&(t.name==="SecurityError"||t.code===t.SECURITY_ERR)}function BE(t){return t==="audio/*"||t==="video/*"||t==="image/*"||t==="text/*"||t==="application/*"||/\w+\/[-+.\w]+/g.test(t)}function zE(t){return/^.*\.[\w]+$/.test(t)}var IU=["children"],kU=["open"],NU=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],PU=["refKey","onChange","onClick"];function OU(t){return DU(t)||RU(t)||VE(t)||MU()}function MU(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
221
221
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function RU(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function DU(t){if(Array.isArray(t))return cm(t)}function sm(t,e){return $U(t)||FU(t,e)||VE(t,e)||LU()}function LU(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
222
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function VE(t,e){if(t){if(typeof t=="string")return cm(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return cm(t,e)}}function cm(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function FU(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r=[],o=!0,i=!1,s,l;try{for(n=n.call(t);!(o=(s=n.next()).done)&&(r.push(s.value),!(e&&r.length===e));o=!0);}catch(u){i=!0,l=u}finally{try{!o&&n.return!=null&&n.return()}finally{if(i)throw l}}return r}}function $U(t){if(Array.isArray(t))return t}function KE(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Bt(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?KE(Object(n),!0).forEach(function(r){lm(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):KE(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function lm(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mu(t,e){if(t==null)return{};var n=HU(t,e),r,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)r=i[o],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}function HU(t,e){if(t==null)return{};var n={},r=Object.keys(t),o,i;for(i=0;i<r.length;i++)o=r[i],!(e.indexOf(o)>=0)&&(n[o]=t[o]);return n}var dm=O.forwardRef(function(t,e){var n=t.children,r=mu(t,IU),o=jE(r),i=o.open,s=mu(o,kU);return O.useImperativeHandle(e,function(){return{open:i}},[i]),O.createElement(O.Fragment,null,n(Bt(Bt({},s),{},{open:i})))});dm.displayName="Dropzone";var GE={disabled:!1,getFilesFromEvent:QH,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};dm.defaultProps=GE,dm.propTypes={children:Ot.func,accept:Ot.objectOf(Ot.arrayOf(Ot.string)),multiple:Ot.bool,preventDropOnDocument:Ot.bool,noClick:Ot.bool,noKeyboard:Ot.bool,noDrag:Ot.bool,noDragEventsBubbling:Ot.bool,minSize:Ot.number,maxSize:Ot.number,maxFiles:Ot.number,disabled:Ot.bool,getFilesFromEvent:Ot.func,onFileDialogCancel:Ot.func,onFileDialogOpen:Ot.func,useFsAccessApi:Ot.bool,autoFocus:Ot.bool,onDragEnter:Ot.func,onDragLeave:Ot.func,onDragOver:Ot.func,onDrop:Ot.func,onDropAccepted:Ot.func,onDropRejected:Ot.func,onError:Ot.func,validator:Ot.func};var um={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function jE(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=Bt(Bt({},GE),t),n=e.accept,r=e.disabled,o=e.getFilesFromEvent,i=e.maxSize,s=e.minSize,l=e.multiple,u=e.maxFiles,h=e.onDragEnter,p=e.onDragLeave,g=e.onDragOver,C=e.onDrop,w=e.onDropAccepted,b=e.onDropRejected,v=e.onFileDialogCancel,x=e.onFileDialogOpen,E=e.useFsAccessApi,A=e.autoFocus,N=e.preventDropOnDocument,P=e.noClick,_=e.noKeyboard,D=e.noDrag,H=e.noDragEventsBubbling,K=e.onError,ee=e.validator,W=O.useMemo(function(){return EU(n)},[n]),de=O.useMemo(function(){return _U(n)},[n]),se=O.useMemo(function(){return typeof x=="function"?x:WE},[x]),fe=O.useMemo(function(){return typeof v=="function"?v:WE},[v]),q=O.useRef(null),Z=O.useRef(null),Y=O.useReducer(UU,um),oe=sm(Y,2),Q=oe[0],X=oe[1],$=Q.isFocused,te=Q.isFileDialogActive,_e=O.useRef(typeof window<"u"&&window.isSecureContext&&E&&SU()),ke=function(){!_e.current&&te&&setTimeout(function(){if(Z.current){var ae=Z.current.files;ae.length||(X({type:"closeDialog"}),fe())}},300)};O.useEffect(function(){return window.addEventListener("focus",ke,!1),function(){window.removeEventListener("focus",ke,!1)}},[Z,te,fe,_e]);var xe=O.useRef([]),Pe=function(ae){q.current&&q.current.contains(ae.target)||(ae.preventDefault(),xe.current=[])};O.useEffect(function(){return N&&(document.addEventListener("dragover",UE,!1),document.addEventListener("drop",Pe,!1)),function(){N&&(document.removeEventListener("dragover",UE),document.removeEventListener("drop",Pe))}},[q,N]),O.useEffect(function(){return!r&&A&&q.current&&q.current.focus(),function(){}},[q,A,r]);var Te=O.useCallback(function(U){K?K(U):console.error(U)},[K]),z=O.useCallback(function(U){U.preventDefault(),U.persist(),Dn(U),xe.current=[].concat(OU(xe.current),[U.target]),gu(U)&&Promise.resolve(o(U)).then(function(ae){if(!(pu(U)&&!H)){var ye=ae.length,he=ye>0&&wU({files:ae,accept:W,minSize:s,maxSize:i,multiple:l,maxFiles:u,validator:ee}),Ee=ye>0&&!he;X({isDragAccept:he,isDragReject:Ee,isDragActive:!0,type:"setDraggedFiles"}),h&&h(U)}}).catch(function(ae){return Te(ae)})},[o,h,Te,H,W,s,i,l,u,ee]),ce=O.useCallback(function(U){U.preventDefault(),U.persist(),Dn(U);var ae=gu(U);if(ae&&U.dataTransfer)try{U.dataTransfer.dropEffect="copy"}catch{}return ae&&g&&g(U),!1},[g,H]),Ae=O.useCallback(function(U){U.preventDefault(),U.persist(),Dn(U);var ae=xe.current.filter(function(he){return q.current&&q.current.contains(he)}),ye=ae.indexOf(U.target);ye!==-1&&ae.splice(ye,1),xe.current=ae,!(ae.length>0)&&(X({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),gu(U)&&p&&p(U))},[q,p,H]),Ce=O.useCallback(function(U,ae){var ye=[],he=[];U.forEach(function(Ee){var Xe=$E(Ee,W),ft=sm(Xe,2),xt=ft[0],vo=ft[1],Qt=HE(Ee,s,i),yn=sm(Qt,2),Gr=yn[0],Gt=yn[1],cr=ee?ee(Ee):null;if(xt&&Gr&&!cr)ye.push(Ee);else{var jr=[vo,Gt];cr&&(jr=jr.concat(cr)),he.push({file:Ee,errors:jr.filter(function(na){return na})})}}),(!l&&ye.length>1||l&&u>=1&&ye.length>u)&&(ye.forEach(function(Ee){he.push({file:Ee,errors:[yU]})}),ye.splice(0)),X({acceptedFiles:ye,fileRejections:he,isDragReject:he.length>0,type:"setFiles"}),C&&C(ye,he,ae),he.length>0&&b&&b(he,ae),ye.length>0&&w&&w(ye,ae)},[X,l,W,s,i,u,C,w,b,ee]),Ne=O.useCallback(function(U){U.preventDefault(),U.persist(),Dn(U),xe.current=[],gu(U)&&Promise.resolve(o(U)).then(function(ae){pu(U)&&!H||Ce(ae,U)}).catch(function(ae){return Te(ae)}),X({type:"reset"})},[o,Ce,Te,H]),ne=O.useCallback(function(){if(_e.current){X({type:"openDialog"}),se();var U={multiple:l,types:de};window.showOpenFilePicker(U).then(function(ae){return o(ae)}).then(function(ae){Ce(ae,null),X({type:"closeDialog"})}).catch(function(ae){TU(ae)?(fe(ae),X({type:"closeDialog"})):AU(ae)?(_e.current=!1,Z.current?(Z.current.value=null,Z.current.click()):Te(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):Te(ae)});return}Z.current&&(X({type:"openDialog"}),se(),Z.current.value=null,Z.current.click())},[X,se,fe,E,Ce,Te,de,l]),Ve=O.useCallback(function(U){!q.current||!q.current.isEqualNode(U.target)||(U.key===" "||U.key==="Enter"||U.keyCode===32||U.keyCode===13)&&(U.preventDefault(),ne())},[q,ne]),Qe=O.useCallback(function(){X({type:"focus"})},[]),Ct=O.useCallback(function(){X({type:"blur"})},[]),Jt=O.useCallback(function(){P||(xU()?setTimeout(ne,0):ne())},[P,ne]),bt=function(ae){return r?null:ae},an=function(ae){return _?null:bt(ae)},zt=function(ae){return D?null:bt(ae)},Dn=function(ae){H&&ae.stopPropagation()},Kt=O.useMemo(function(){return function(){var U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ae=U.refKey,ye=ae===void 0?"ref":ae,he=U.role,Ee=U.onKeyDown,Xe=U.onFocus,ft=U.onBlur,xt=U.onClick,vo=U.onDragEnter,Qt=U.onDragOver,yn=U.onDragLeave,Gr=U.onDrop,Gt=mu(U,NU);return Bt(Bt(lm({onKeyDown:an(po(Ee,Ve)),onFocus:an(po(Xe,Qe)),onBlur:an(po(ft,Ct)),onClick:bt(po(xt,Jt)),onDragEnter:zt(po(vo,z)),onDragOver:zt(po(Qt,ce)),onDragLeave:zt(po(yn,Ae)),onDrop:zt(po(Gr,Ne)),role:typeof he=="string"&&he!==""?he:"presentation"},ye,q),!r&&!_?{tabIndex:0}:{}),Gt)}},[q,Ve,Qe,Ct,Jt,z,ce,Ae,Ne,_,D,r]),L=O.useCallback(function(U){U.stopPropagation()},[]),J=O.useMemo(function(){return function(){var U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ae=U.refKey,ye=ae===void 0?"ref":ae,he=U.onChange,Ee=U.onClick,Xe=mu(U,PU),ft=lm({accept:W,multiple:l,type:"file",style:{border:0,clip:"rect(0, 0, 0, 0)",clipPath:"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"},onChange:bt(po(he,Ne)),onClick:bt(po(Ee,L)),tabIndex:-1},ye,Z);return Bt(Bt({},ft),Xe)}},[Z,n,l,Ne,r]);return Bt(Bt({},Q),{},{isFocused:$&&!r,getRootProps:Kt,getInputProps:J,rootRef:q,inputRef:Z,open:bt(ne)})}function UU(t,e){switch(e.type){case"focus":return Bt(Bt({},t),{},{isFocused:!0});case"blur":return Bt(Bt({},t),{},{isFocused:!1});case"openDialog":return Bt(Bt({},um),{},{isFileDialogActive:!0});case"closeDialog":return Bt(Bt({},t),{},{isFileDialogActive:!1});case"setDraggedFiles":return Bt(Bt({},t),{},{isDragActive:e.isDragActive,isDragAccept:e.isDragAccept,isDragReject:e.isDragReject});case"setFiles":return Bt(Bt({},t),{},{acceptedFiles:e.acceptedFiles,fileRejections:e.fileRejections,isDragReject:e.isDragReject});case"reset":return Bt({},um);default:return t}}function WE(){}const BU=({onFilesSelected:t,children:e})=>{const[n,r]=O.useState(!1),{getRootProps:o,getInputProps:i}=jE({noClick:!0,onDrop:s=>{if(s&&s.length>0)if(s[0].path.split("/").length>2){const u=s.map(h=>{const g=(h.path||h.relativePath||"").split("/").slice(1).join("/");return(!h.webkitRelativePath||h.webkitRelativePath==="")&&Object.defineProperty(h,"webkitRelativePath",{writable:!0,value:g,enumerable:!0,configurable:!0}),h});t(u,"folder")}else t(s,"files");r(!1)},onDragOver:s=>{s.preventDefault(),n||r(!0)},multiple:!0});return O.useEffect(()=>{const s=l=>{l.clientX===0&&l.clientY===0&&r(!1)};return document.addEventListener("dragleave",s),()=>{document.removeEventListener("dragleave",s)}},[]),d.jsxs("div",{...o(),className:"transition-opacity min-h-[600px]",children:[n?d.jsx("div",{className:"flex flex-col items-center justify-center p-4 border-2 border-dashed border-gray-300 rounded-lg bg-gray-50 h-screen"}):e,d.jsx("input",{...i()})]})},zU=({openDialogRename:t,setOpenDialogRename:e,apiBaseUrl:n,setFileToMove:r,fileToMove:o,refreshFiles:i,ignoreCache:s,autoSyncAfterFileOperation:l})=>{var N;const[u,h]=O.useState({}),[p,g]=O.useState(!1),[C,w]=O.useState(!1),[b,v]=O.useState(""),{toast:x}=dc();O.useEffect(()=>{t&&E(b)},[b,t]);const E=async P=>{try{w(!0);const _=await Le.get(`${n}/api/list-s3-folders?prefix=${P}`);h(_==null?void 0:_.data)}catch{x({title:"Error",description:"Unable to load S3 folder list",variant:"destructive"})}finally{w(!1)}},A=async()=>{g(!0);try{const P=o.key,_=P.endsWith("/")?P:`${P}/`,D=b.endsWith("/")?b:`${b}/`;if(_===D||P===b){x({title:"Lỗi",description:"Không thể di chuyển file đến cùng vị trí",variant:"destructive"}),g(!1);return}await Le.post(`${n}/api/move`,{oldPath:P,newPath:b}),s.current=!0,await i(),x({title:"Đã di chuyển",description:`Đã di chuyển thành công "${o.name}" đến "${b}"`}),e(!1),r(null),v(""),l&&await l("move")}catch(P){console.error("Error renaming item:",P),x({title:"Lỗi",description:"Không thể đổi tên",variant:"destructive"})}finally{g(!1)}};return d.jsx(or,{open:t,onOpenChange:P=>{P||(e(!1),r(null),v(""))},children:d.jsxs(Kn,{className:"max-h-[700px] pb-3 px-1 s3-explr-input-group max-w-5xl w-[90%] p-6 bg-white rounded-lg shadow-lg",children:[d.jsxs(Gn,{className:"mb-4 w-full h-full",children:[d.jsx("nav",{className:"mb-4",children:d.jsxs("ul",{className:"flex items-center space-x-2 text-sm text-gray-600",children:[d.jsx("li",{className:"cursor-pointer hover:text-blue-600 transition-colors",onClick:()=>v(""),children:"Root"}),b.split("/").map((P,_,D)=>d.jsx("li",{className:"cursor-pointer hover:text-blue-600 transition-colors",onClick:()=>v(P==="Root"?"":D.slice(0,_+1).join("/")+"/"),children:P},_))]})}),d.jsxs(jn,{className:"text-xl font-semibold text-gray-800",children:["Di chuyển"," ",d.jsxs("span",{className:"text-sm text-gray-500",children:["( file hoặc folder sẽ được di chuyển đến thư mục"," ",b===""?"Root":b," )"]})]}),d.jsx(gi,{className:"text-gray-600 w-full h-[50dvh] max-h-[500px] overflow-hidden overflow-y-auto",children:C?d.jsx("div",{className:"flex justify-center items-center py-4",children:d.jsx("div",{className:"loader ease-linear rounded-full border-4 border-t-4 border-gray-200 h-12 w-12"})}):d.jsx("ul",{className:"space-y-2",children:(N=Object.keys(u))==null?void 0:N.map(P=>d.jsx("li",{className:"cursor-pointer hover:bg-gray-100 p-2 rounded transition-colors",onClick:()=>v(P),children:P},P))})})]}),d.jsxs(Lr,{className:"flex justify-end space-x-2",children:[d.jsx(He,{variant:"outline",onClick:()=>e(!1),className:"px-4 py-2 rounded border border-gray-300 text-gray-700 hover:bg-gray-100 transition-colors",children:"Cancel"}),d.jsx(He,{onClick:A,disabled:p,className:"s3-explr-crawl-btn",children:"Move"})]})]})})};function qE(t,[e,n]){return Math.min(n,Math.max(e,t))}function YE(t){const e=VU(t),n=m.forwardRef((r,o)=>{const{children:i,...s}=r,l=m.Children.toArray(i),u=l.find(GU);if(u){const h=u.props.children,p=l.map(g=>g===u?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return d.jsx(e,{...s,ref:o,children:m.isValidElement(h)?m.cloneElement(h,void 0,p):null})}return d.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}function VU(t){const e=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const s=WU(o),l=jU(i,o.props);return o.type!==m.Fragment&&(l.ref=r?Hi(r,s):s),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var KU=Symbol("radix.slottable");function GU(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===KU}function jU(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function WU(t){var r,o;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function qU(t){const e=t+"CollectionProvider",[n,r]=hr(e),[o,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),s=v=>{const{scope:x,children:E}=v,A=O.useRef(null),N=O.useRef(new Map).current;return d.jsx(o,{scope:x,itemMap:N,collectionRef:A,children:E})};s.displayName=e;const l=t+"CollectionSlot",u=YE(l),h=O.forwardRef((v,x)=>{const{scope:E,children:A}=v,N=i(l,E),P=rt(x,N.collectionRef);return d.jsx(u,{ref:P,children:A})});h.displayName=l;const p=t+"CollectionItemSlot",g="data-radix-collection-item",C=YE(p),w=O.forwardRef((v,x)=>{const{scope:E,children:A,...N}=v,P=O.useRef(null),_=rt(x,P),D=i(p,E);return O.useEffect(()=>(D.itemMap.set(P,{ref:P,...N}),()=>void D.itemMap.delete(P))),d.jsx(C,{[g]:"",ref:_,children:A})});w.displayName=p;function b(v){const x=i(t+"CollectionConsumer",v);return O.useCallback(()=>{const A=x.collectionRef.current;if(!A)return[];const N=Array.from(A.querySelectorAll(`[${g}]`));return Array.from(x.itemMap.values()).sort((D,H)=>N.indexOf(D.ref.current)-N.indexOf(H.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:s,Slot:h,ItemSlot:w},b,r]}function JE(t){const e=YU(t),n=m.forwardRef((r,o)=>{const{children:i,...s}=r,l=m.Children.toArray(i),u=l.find(QU);if(u){const h=u.props.children,p=l.map(g=>g===u?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return d.jsx(e,{...s,ref:o,children:m.isValidElement(h)?m.cloneElement(h,void 0,p):null})}return d.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}function YU(t){const e=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const s=ZU(o),l=XU(i,o.props);return o.type!==m.Fragment&&(l.ref=r?Hi(r,s):s),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var JU=Symbol("radix.slottable");function QU(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===JU}function XU(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function ZU(t){var r,o;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var eB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],vn=eB.reduce((t,e)=>{const n=JE(`Primitive.${e}`),r=m.forwardRef((o,i)=>{const{asChild:s,...l}=o,u=s?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(u,{...l,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function tB(t,e){t&&Aa.flushSync(()=>t.dispatchEvent(e))}var nB="DismissableLayer",fm="dismissableLayer.update",rB="dismissableLayer.pointerDownOutside",oB="dismissableLayer.focusOutside",QE,XE=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ZE=m.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:l,...u}=t,h=m.useContext(XE),[p,g]=m.useState(null),C=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,w]=m.useState({}),b=rt(e,H=>g(H)),v=Array.from(h.layers),[x]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),E=v.indexOf(x),A=p?v.indexOf(p):-1,N=h.layersWithOutsidePointerEventsDisabled.size>0,P=A>=E,_=sB(H=>{const K=H.target,ee=[...h.branches].some(W=>W.contains(K));!P||ee||(o==null||o(H),s==null||s(H),H.defaultPrevented||l==null||l())},C),D=cB(H=>{const K=H.target;[...h.branches].some(W=>W.contains(K))||(i==null||i(H),s==null||s(H),H.defaultPrevented||l==null||l())},C);return FC(H=>{A===h.layers.size-1&&(r==null||r(H),!H.defaultPrevented&&l&&(H.preventDefault(),l()))},C),m.useEffect(()=>{if(p)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(QE=C.body.style.pointerEvents,C.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(p)),h.layers.add(p),eT(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(C.body.style.pointerEvents=QE)}},[p,C,n,h]),m.useEffect(()=>()=>{p&&(h.layers.delete(p),h.layersWithOutsidePointerEventsDisabled.delete(p),eT())},[p,h]),m.useEffect(()=>{const H=()=>w({});return document.addEventListener(fm,H),()=>document.removeEventListener(fm,H)},[]),d.jsx(vn.div,{...u,ref:b,style:{pointerEvents:N?P?"auto":"none":void 0,...t.style},onFocusCapture:Ue(t.onFocusCapture,D.onFocusCapture),onBlurCapture:Ue(t.onBlurCapture,D.onBlurCapture),onPointerDownCapture:Ue(t.onPointerDownCapture,_.onPointerDownCapture)})});ZE.displayName=nB;var iB="DismissableLayerBranch",aB=m.forwardRef((t,e)=>{const n=m.useContext(XE),r=m.useRef(null),o=rt(e,r);return m.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),d.jsx(vn.div,{...t,ref:o})});aB.displayName=iB;function sB(t,e=globalThis==null?void 0:globalThis.document){const n=mn(t),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const i=l=>{if(l.target&&!r.current){let u=function(){tT(rB,n,h,{discrete:!0})};const h={originalEvent:l};l.pointerType==="touch"?(e.removeEventListener("click",o.current),o.current=u,e.addEventListener("click",o.current,{once:!0})):u()}else e.removeEventListener("click",o.current);r.current=!1},s=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),e.removeEventListener("pointerdown",i),e.removeEventListener("click",o.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function cB(t,e=globalThis==null?void 0:globalThis.document){const n=mn(t),r=m.useRef(!1);return m.useEffect(()=>{const o=i=>{i.target&&!r.current&&tT(oB,n,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",o),()=>e.removeEventListener("focusin",o)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function eT(){const t=new CustomEvent(fm);document.dispatchEvent(t)}function tT(t,e,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&o.addEventListener(t,e,{once:!0}),r?tB(o,i):o.dispatchEvent(i)}var hm="focusScope.autoFocusOnMount",pm="focusScope.autoFocusOnUnmount",nT={bubbles:!1,cancelable:!0},lB="FocusScope",rT=m.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=t,[l,u]=m.useState(null),h=mn(o),p=mn(i),g=m.useRef(null),C=rt(e,v=>u(v)),w=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let v=function(N){if(w.paused||!l)return;const P=N.target;l.contains(P)?g.current=P:yi(g.current,{select:!0})},x=function(N){if(w.paused||!l)return;const P=N.relatedTarget;P!==null&&(l.contains(P)||yi(g.current,{select:!0}))},E=function(N){if(document.activeElement===document.body)for(const _ of N)_.removedNodes.length>0&&yi(l)};document.addEventListener("focusin",v),document.addEventListener("focusout",x);const A=new MutationObserver(E);return l&&A.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",x),A.disconnect()}}},[r,l,w.paused]),m.useEffect(()=>{if(l){aT.add(w);const v=document.activeElement;if(!l.contains(v)){const E=new CustomEvent(hm,nT);l.addEventListener(hm,h),l.dispatchEvent(E),E.defaultPrevented||(dB(gB(oT(l)),{select:!0}),document.activeElement===v&&yi(l))}return()=>{l.removeEventListener(hm,h),setTimeout(()=>{const E=new CustomEvent(pm,nT);l.addEventListener(pm,p),l.dispatchEvent(E),E.defaultPrevented||yi(v??document.body,{select:!0}),l.removeEventListener(pm,p),aT.remove(w)},0)}}},[l,h,p,w]);const b=m.useCallback(v=>{if(!n&&!r||w.paused)return;const x=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,E=document.activeElement;if(x&&E){const A=v.currentTarget,[N,P]=uB(A);N&&P?!v.shiftKey&&E===P?(v.preventDefault(),n&&yi(N,{select:!0})):v.shiftKey&&E===N&&(v.preventDefault(),n&&yi(P,{select:!0})):E===A&&v.preventDefault()}},[n,r,w.paused]);return d.jsx(vn.div,{tabIndex:-1,...s,ref:C,onKeyDown:b})});rT.displayName=lB;function dB(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(yi(r,{select:e}),document.activeElement!==n)return}function uB(t){const e=oT(t),n=iT(e,t),r=iT(e.reverse(),t);return[n,r]}function oT(t){const e=[],n=document.createTreeWalker(t,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();)e.push(n.currentNode);return e}function iT(t,e){for(const n of t)if(!fB(n,{upTo:e}))return n}function fB(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function hB(t){return t instanceof HTMLInputElement&&"select"in t}function yi(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&hB(t)&&e&&t.select()}}var aT=pB();function pB(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=sT(t,e),t.unshift(e)},remove(e){var n;t=sT(t,e),(n=t[0])==null||n.resume()}}}function sT(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function gB(t){return t.filter(e=>e.tagName!=="A")}function mB(t){const e=vB(t),n=m.forwardRef((r,o)=>{const{children:i,...s}=r,l=m.Children.toArray(i),u=l.find(wB);if(u){const h=u.props.children,p=l.map(g=>g===u?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return d.jsx(e,{...s,ref:o,children:m.isValidElement(h)?m.cloneElement(h,void 0,p):null})}return d.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}function vB(t){const e=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const s=bB(o),l=CB(i,o.props);return o.type!==m.Fragment&&(l.ref=r?Hi(r,s):s),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var yB=Symbol("radix.slottable");function wB(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===yB}function CB(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function bB(t){var r,o;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var xB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],SB=xB.reduce((t,e)=>{const n=mB(`Primitive.${e}`),r=m.forwardRef((o,i)=>{const{asChild:s,...l}=o,u=s?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(u,{...l,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),_B="Arrow",cT=m.forwardRef((t,e)=>{const{children:n,width:r=10,height:o=5,...i}=t;return d.jsx(SB.svg,{...i,ref:e,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});cT.displayName=_B;var EB=cT;function TB(t){const e=AB(t),n=m.forwardRef((r,o)=>{const{children:i,...s}=r,l=m.Children.toArray(i),u=l.find(kB);if(u){const h=u.props.children,p=l.map(g=>g===u?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return d.jsx(e,{...s,ref:o,children:m.isValidElement(h)?m.cloneElement(h,void 0,p):null})}return d.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}function AB(t){const e=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const s=PB(o),l=NB(i,o.props);return o.type!==m.Fragment&&(l.ref=r?Hi(r,s):s),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var IB=Symbol("radix.slottable");function kB(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===IB}function NB(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function PB(t){var r,o;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var OB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],lT=OB.reduce((t,e)=>{const n=TB(`Primitive.${e}`),r=m.forwardRef((o,i)=>{const{asChild:s,...l}=o,u=s?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(u,{...l,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),gm="Popper",[dT,uT]=hr(gm),[MB,fT]=dT(gm),hT=t=>{const{__scopePopper:e,children:n}=t,[r,o]=m.useState(null);return d.jsx(MB,{scope:e,anchor:r,onAnchorChange:o,children:n})};hT.displayName=gm;var pT="PopperAnchor",gT=m.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...o}=t,i=fT(pT,n),s=m.useRef(null),l=rt(e,s);return m.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||s.current)}),r?null:d.jsx(lT.div,{...o,ref:l})});gT.displayName=pT;var mm="PopperContent",[RB,DB]=dT(mm),mT=m.forwardRef((t,e)=>{var z,ce,Ae,Ce,Ne,ne;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:h=[],collisionPadding:p=0,sticky:g="partial",hideWhenDetached:C=!1,updatePositionStrategy:w="optimized",onPlaced:b,...v}=t,x=fT(mm,n),[E,A]=m.useState(null),N=rt(e,Ve=>A(Ve)),[P,_]=m.useState(null),D=hg(P),H=(D==null?void 0:D.width)??0,K=(D==null?void 0:D.height)??0,ee=r+(i!=="center"?"-"+i:""),W=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},de=Array.isArray(h)?h:[h],se=de.length>0,fe={padding:W,boundary:de.filter(FB),altBoundary:se},{refs:q,floatingStyles:Z,placement:Y,isPositioned:oe,middlewareData:Q}=A_({strategy:"fixed",placement:ee,whileElementsMounted:(...Ve)=>S_(...Ve,{animationFrame:w==="always"}),elements:{reference:x.anchor},middleware:[I_({mainAxis:o+K,alignmentAxis:s}),u&&k_({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?N_():void 0,...fe}),u&&P_({...fe}),O_({...fe,apply:({elements:Ve,rects:Qe,availableWidth:Ct,availableHeight:Jt})=>{const{width:bt,height:an}=Qe.reference,zt=Ve.floating.style;zt.setProperty("--radix-popper-available-width",`${Ct}px`),zt.setProperty("--radix-popper-available-height",`${Jt}px`),zt.setProperty("--radix-popper-anchor-width",`${bt}px`),zt.setProperty("--radix-popper-anchor-height",`${an}px`)}}),P&&R_({element:P,padding:l}),$B({arrowWidth:H,arrowHeight:K}),C&&M_({strategy:"referenceHidden",...fe})]}),[X,$]=wT(Y),te=mn(b);rn(()=>{oe&&(te==null||te())},[oe,te]);const _e=(z=Q.arrow)==null?void 0:z.x,ke=(ce=Q.arrow)==null?void 0:ce.y,xe=((Ae=Q.arrow)==null?void 0:Ae.centerOffset)!==0,[Pe,Te]=m.useState();return rn(()=>{E&&Te(window.getComputedStyle(E).zIndex)},[E]),d.jsx("div",{ref:q.setFloating,"data-radix-popper-content-wrapper":"",style:{...Z,transform:oe?Z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Pe,"--radix-popper-transform-origin":[(Ce=Q.transformOrigin)==null?void 0:Ce.x,(Ne=Q.transformOrigin)==null?void 0:Ne.y].join(" "),...((ne=Q.hide)==null?void 0:ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:d.jsx(RB,{scope:n,placedSide:X,onArrowChange:_,arrowX:_e,arrowY:ke,shouldHideArrow:xe,children:d.jsx(lT.div,{"data-side":X,"data-align":$,...v,ref:N,style:{...v.style,animation:oe?void 0:"none"}})})})});mT.displayName=mm;var vT="PopperArrow",LB={top:"bottom",right:"left",bottom:"top",left:"right"},yT=m.forwardRef(function(e,n){const{__scopePopper:r,...o}=e,i=DB(vT,r),s=LB[i.placedSide];return d.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:d.jsx(EB,{...o,ref:n,style:{...o.style,display:"block"}})})});yT.displayName=vT;function FB(t){return t!==null}var $B=t=>({name:"transformOrigin",options:t,fn(e){var x,E,A;const{placement:n,rects:r,middlewareData:o}=e,s=((x=o.arrow)==null?void 0:x.centerOffset)!==0,l=s?0:t.arrowWidth,u=s?0:t.arrowHeight,[h,p]=wT(n),g={start:"0%",center:"50%",end:"100%"}[p],C=(((E=o.arrow)==null?void 0:E.x)??0)+l/2,w=(((A=o.arrow)==null?void 0:A.y)??0)+u/2;let b="",v="";return h==="bottom"?(b=s?g:`${C}px`,v=`${-u}px`):h==="top"?(b=s?g:`${C}px`,v=`${r.floating.height+u}px`):h==="right"?(b=`${-u}px`,v=s?g:`${w}px`):h==="left"&&(b=`${r.floating.width+u}px`,v=s?g:`${w}px`),{data:{x:b,y:v}}}});function wT(t){const[e,n="center"]=t.split("-");return[e,n]}var HB=hT,UB=gT,BB=mT,zB=yT,VB="Portal",CT=m.forwardRef((t,e)=>{var l;const{container:n,...r}=t,[o,i]=m.useState(!1);rn(()=>i(!0),[]);const s=n||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return s?Hf.createPortal(d.jsx(vn.div,{...r,ref:e}),s):null});CT.displayName=VB;function KB(t){const e=GB(t),n=m.forwardRef((r,o)=>{const{children:i,...s}=r,l=m.Children.toArray(i),u=l.find(WB);if(u){const h=u.props.children,p=l.map(g=>g===u?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return d.jsx(e,{...s,ref:o,children:m.isValidElement(h)?m.cloneElement(h,void 0,p):null})}return d.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}function GB(t){const e=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const s=YB(o),l=qB(i,o.props);return o.type!==m.Fragment&&(l.ref=r?Hi(r,s):s),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var jB=Symbol("radix.slottable");function WB(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===jB}function qB(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function YB(t){var r,o;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var JB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],QB=JB.reduce((t,e)=>{const n=KB(`Primitive.${e}`),r=m.forwardRef((o,i)=>{const{asChild:s,...l}=o,u=s?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(u,{...l,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),bT=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),XB="VisuallyHidden",ZB=m.forwardRef((t,e)=>d.jsx(QB.span,{...t,ref:e,style:{...bT,...t.style}}));ZB.displayName=XB;var e3=[" ","Enter","ArrowUp","ArrowDown"],t3=[" ","Enter"],Ji="Select",[vu,yu,n3]=qU(Ji),[os,vW]=hr(Ji,[n3,uT]),wu=uT(),[r3,wi]=os(Ji),[o3,i3]=os(Ji),xT=t=>{const{__scopeSelect:e,children:n,open:r,defaultOpen:o,onOpenChange:i,value:s,defaultValue:l,onValueChange:u,dir:h,name:p,autoComplete:g,disabled:C,required:w,form:b}=t,v=wu(e),[x,E]=m.useState(null),[A,N]=m.useState(null),[P,_]=m.useState(!1),D=mg(h),[H,K]=si({prop:r,defaultProp:o??!1,onChange:i,caller:Ji}),[ee,W]=si({prop:s,defaultProp:l,onChange:u,caller:Ji}),de=m.useRef(null),se=x?b||!!x.closest("form"):!0,[fe,q]=m.useState(new Set),Z=Array.from(fe).map(Y=>Y.props.value).join(";");return d.jsx(HB,{...v,children:d.jsxs(r3,{required:w,scope:e,trigger:x,onTriggerChange:E,valueNode:A,onValueNodeChange:N,valueNodeHasChildren:P,onValueNodeHasChildrenChange:_,contentId:Io(),value:ee,onValueChange:W,open:H,onOpenChange:K,dir:D,triggerPointerDownPosRef:de,disabled:C,children:[d.jsx(vu.Provider,{scope:e,children:d.jsx(o3,{scope:t.__scopeSelect,onNativeOptionAdd:m.useCallback(Y=>{q(oe=>new Set(oe).add(Y))},[]),onNativeOptionRemove:m.useCallback(Y=>{q(oe=>{const Q=new Set(oe);return Q.delete(Y),Q})},[]),children:n})}),se?d.jsxs(KT,{"aria-hidden":!0,required:w,tabIndex:-1,name:p,autoComplete:g,value:ee,onChange:Y=>W(Y.target.value),disabled:C,form:b,children:[ee===void 0?d.jsx("option",{value:""}):null,Array.from(fe)]},Z):null]})})};xT.displayName=Ji;var ST="SelectTrigger",_T=m.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...o}=t,i=wu(n),s=wi(ST,n),l=s.disabled||r,u=rt(e,s.onTriggerChange),h=yu(n),p=m.useRef("touch"),[g,C,w]=jT(v=>{const x=h().filter(N=>!N.disabled),E=x.find(N=>N.value===s.value),A=WT(x,v,E);A!==void 0&&s.onValueChange(A.value)}),b=v=>{l||(s.onOpenChange(!0),w()),v&&(s.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return d.jsx(UB,{asChild:!0,...i,children:d.jsx(vn.button,{type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":GT(s.value)?"":void 0,...o,ref:u,onClick:Ue(o.onClick,v=>{v.currentTarget.focus(),p.current!=="mouse"&&b(v)}),onPointerDown:Ue(o.onPointerDown,v=>{p.current=v.pointerType;const x=v.target;x.hasPointerCapture(v.pointerId)&&x.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(b(v),v.preventDefault())}),onKeyDown:Ue(o.onKeyDown,v=>{const x=g.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&C(v.key),!(x&&v.key===" ")&&e3.includes(v.key)&&(b(),v.preventDefault())})})})});_T.displayName=ST;var ET="SelectValue",TT=m.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:o,children:i,placeholder:s="",...l}=t,u=wi(ET,n),{onValueNodeHasChildrenChange:h}=u,p=i!==void 0,g=rt(e,u.onValueNodeChange);return rn(()=>{h(p)},[h,p]),d.jsx(vn.span,{...l,ref:g,style:{pointerEvents:"none"},children:GT(u.value)?d.jsx(d.Fragment,{children:s}):i})});TT.displayName=ET;var a3="SelectIcon",AT=m.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...o}=t;return d.jsx(vn.span,{"aria-hidden":!0,...o,ref:e,children:r||"▼"})});AT.displayName=a3;var s3="SelectPortal",IT=t=>d.jsx(CT,{asChild:!0,...t});IT.displayName=s3;var Qi="SelectContent",kT=m.forwardRef((t,e)=>{const n=wi(Qi,t.__scopeSelect),[r,o]=m.useState();if(rn(()=>{o(new DocumentFragment)},[]),!n.open){const i=r;return i?Aa.createPortal(d.jsx(NT,{scope:t.__scopeSelect,children:d.jsx(vu.Slot,{scope:t.__scopeSelect,children:d.jsx("div",{children:t.children})})}),i):null}return d.jsx(PT,{...t,ref:e})});kT.displayName=Qi;var zr=10,[NT,Ci]=os(Qi),c3="SelectContentImpl",l3=JE("SelectContent.RemoveScroll"),PT=m.forwardRef((t,e)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:s,side:l,sideOffset:u,align:h,alignOffset:p,arrowPadding:g,collisionBoundary:C,collisionPadding:w,sticky:b,hideWhenDetached:v,avoidCollisions:x,...E}=t,A=wi(Qi,n),[N,P]=m.useState(null),[_,D]=m.useState(null),H=rt(e,z=>P(z)),[K,ee]=m.useState(null),[W,de]=m.useState(null),se=yu(n),[fe,q]=m.useState(!1),Z=m.useRef(!1);m.useEffect(()=>{if(N)return fb(N)},[N]),YC();const Y=m.useCallback(z=>{const[ce,...Ae]=se().map(ne=>ne.ref.current),[Ce]=Ae.slice(-1),Ne=document.activeElement;for(const ne of z)if(ne===Ne||(ne==null||ne.scrollIntoView({block:"nearest"}),ne===ce&&_&&(_.scrollTop=0),ne===Ce&&_&&(_.scrollTop=_.scrollHeight),ne==null||ne.focus(),document.activeElement!==Ne))return},[se,_]),oe=m.useCallback(()=>Y([K,N]),[Y,K,N]);m.useEffect(()=>{fe&&oe()},[fe,oe]);const{onOpenChange:Q,triggerPointerDownPosRef:X}=A;m.useEffect(()=>{if(N){let z={x:0,y:0};const ce=Ce=>{var Ne,ne;z={x:Math.abs(Math.round(Ce.pageX)-(((Ne=X.current)==null?void 0:Ne.x)??0)),y:Math.abs(Math.round(Ce.pageY)-(((ne=X.current)==null?void 0:ne.y)??0))}},Ae=Ce=>{z.x<=10&&z.y<=10?Ce.preventDefault():N.contains(Ce.target)||Q(!1),document.removeEventListener("pointermove",ce),X.current=null};return X.current!==null&&(document.addEventListener("pointermove",ce),document.addEventListener("pointerup",Ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ce),document.removeEventListener("pointerup",Ae,{capture:!0})}}},[N,Q,X]),m.useEffect(()=>{const z=()=>Q(!1);return window.addEventListener("blur",z),window.addEventListener("resize",z),()=>{window.removeEventListener("blur",z),window.removeEventListener("resize",z)}},[Q]);const[$,te]=jT(z=>{const ce=se().filter(Ne=>!Ne.disabled),Ae=ce.find(Ne=>Ne.ref.current===document.activeElement),Ce=WT(ce,z,Ae);Ce&&setTimeout(()=>Ce.ref.current.focus())}),_e=m.useCallback((z,ce,Ae)=>{const Ce=!Z.current&&!Ae;(A.value!==void 0&&A.value===ce||Ce)&&(ee(z),Ce&&(Z.current=!0))},[A.value]),ke=m.useCallback(()=>N==null?void 0:N.focus(),[N]),xe=m.useCallback((z,ce,Ae)=>{const Ce=!Z.current&&!Ae;(A.value!==void 0&&A.value===ce||Ce)&&de(z)},[A.value]),Pe=r==="popper"?vm:OT,Te=Pe===vm?{side:l,sideOffset:u,align:h,alignOffset:p,arrowPadding:g,collisionBoundary:C,collisionPadding:w,sticky:b,hideWhenDetached:v,avoidCollisions:x}:{};return d.jsx(NT,{scope:n,content:N,viewport:_,onViewportChange:D,itemRefCallback:_e,selectedItem:K,onItemLeave:ke,itemTextRefCallback:xe,focusSelectedItem:oe,selectedItemText:W,position:r,isPositioned:fe,searchRef:$,children:d.jsx(Cp,{as:l3,allowPinchZoom:!0,children:d.jsx(rT,{asChild:!0,trapped:A.open,onMountAutoFocus:z=>{z.preventDefault()},onUnmountAutoFocus:Ue(o,z=>{var ce;(ce=A.trigger)==null||ce.focus({preventScroll:!0}),z.preventDefault()}),children:d.jsx(ZE,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:z=>z.preventDefault(),onDismiss:()=>A.onOpenChange(!1),children:d.jsx(Pe,{role:"listbox",id:A.contentId,"data-state":A.open?"open":"closed",dir:A.dir,onContextMenu:z=>z.preventDefault(),...E,...Te,onPlaced:()=>q(!0),ref:H,style:{display:"flex",flexDirection:"column",outline:"none",...E.style},onKeyDown:Ue(E.onKeyDown,z=>{const ce=z.ctrlKey||z.altKey||z.metaKey;if(z.key==="Tab"&&z.preventDefault(),!ce&&z.key.length===1&&te(z.key),["ArrowUp","ArrowDown","Home","End"].includes(z.key)){let Ce=se().filter(Ne=>!Ne.disabled).map(Ne=>Ne.ref.current);if(["ArrowUp","End"].includes(z.key)&&(Ce=Ce.slice().reverse()),["ArrowUp","ArrowDown"].includes(z.key)){const Ne=z.target,ne=Ce.indexOf(Ne);Ce=Ce.slice(ne+1)}setTimeout(()=>Y(Ce)),z.preventDefault()}})})})})})})});PT.displayName=c3;var d3="SelectItemAlignedPosition",OT=m.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...o}=t,i=wi(Qi,n),s=Ci(Qi,n),[l,u]=m.useState(null),[h,p]=m.useState(null),g=rt(e,H=>p(H)),C=yu(n),w=m.useRef(!1),b=m.useRef(!0),{viewport:v,selectedItem:x,selectedItemText:E,focusSelectedItem:A}=s,N=m.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&h&&v&&x&&E){const H=i.trigger.getBoundingClientRect(),K=h.getBoundingClientRect(),ee=i.valueNode.getBoundingClientRect(),W=E.getBoundingClientRect();if(i.dir!=="rtl"){const Ne=W.left-K.left,ne=ee.left-Ne,Ve=H.left-ne,Qe=H.width+Ve,Ct=Math.max(Qe,K.width),Jt=window.innerWidth-zr,bt=qE(ne,[zr,Math.max(zr,Jt-Ct)]);l.style.minWidth=Qe+"px",l.style.left=bt+"px"}else{const Ne=K.right-W.right,ne=window.innerWidth-ee.right-Ne,Ve=window.innerWidth-H.right-ne,Qe=H.width+Ve,Ct=Math.max(Qe,K.width),Jt=window.innerWidth-zr,bt=qE(ne,[zr,Math.max(zr,Jt-Ct)]);l.style.minWidth=Qe+"px",l.style.right=bt+"px"}const de=C(),se=window.innerHeight-zr*2,fe=v.scrollHeight,q=window.getComputedStyle(h),Z=parseInt(q.borderTopWidth,10),Y=parseInt(q.paddingTop,10),oe=parseInt(q.borderBottomWidth,10),Q=parseInt(q.paddingBottom,10),X=Z+Y+fe+Q+oe,$=Math.min(x.offsetHeight*5,X),te=window.getComputedStyle(v),_e=parseInt(te.paddingTop,10),ke=parseInt(te.paddingBottom,10),xe=H.top+H.height/2-zr,Pe=se-xe,Te=x.offsetHeight/2,z=x.offsetTop+Te,ce=Z+Y+z,Ae=X-ce;if(ce<=xe){const Ne=de.length>0&&x===de[de.length-1].ref.current;l.style.bottom="0px";const ne=h.clientHeight-v.offsetTop-v.offsetHeight,Ve=Math.max(Pe,Te+(Ne?ke:0)+ne+oe),Qe=ce+Ve;l.style.height=Qe+"px"}else{const Ne=de.length>0&&x===de[0].ref.current;l.style.top="0px";const Ve=Math.max(xe,Z+v.offsetTop+(Ne?_e:0)+Te)+Ae;l.style.height=Ve+"px",v.scrollTop=ce-xe+v.offsetTop}l.style.margin=`${zr}px 0`,l.style.minHeight=$+"px",l.style.maxHeight=se+"px",r==null||r(),requestAnimationFrame(()=>w.current=!0)}},[C,i.trigger,i.valueNode,l,h,v,x,E,i.dir,r]);rn(()=>N(),[N]);const[P,_]=m.useState();rn(()=>{h&&_(window.getComputedStyle(h).zIndex)},[h]);const D=m.useCallback(H=>{H&&b.current===!0&&(N(),A==null||A(),b.current=!1)},[N,A]);return d.jsx(f3,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:w,onScrollButtonChange:D,children:d.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:P},children:d.jsx(vn.div,{...o,ref:g,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});OT.displayName=d3;var u3="SelectPopperPosition",vm=m.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=zr,...i}=t,s=wu(n);return d.jsx(BB,{...s,...i,ref:e,align:r,collisionPadding:o,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});vm.displayName=u3;var[f3,ym]=os(Qi,{}),wm="SelectViewport",MT=m.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...o}=t,i=Ci(wm,n),s=ym(wm,n),l=rt(e,i.onViewportChange),u=m.useRef(0);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),d.jsx(vu.Slot,{scope:n,children:d.jsx(vn.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Ue(o.onScroll,h=>{const p=h.currentTarget,{contentWrapper:g,shouldExpandOnScrollRef:C}=s;if(C!=null&&C.current&&g){const w=Math.abs(u.current-p.scrollTop);if(w>0){const b=window.innerHeight-zr*2,v=parseFloat(g.style.minHeight),x=parseFloat(g.style.height),E=Math.max(v,x);if(E<b){const A=E+w,N=Math.min(b,A),P=A-N;g.style.height=N+"px",g.style.bottom==="0px"&&(p.scrollTop=P>0?P:0,g.style.justifyContent="flex-end")}}}u.current=p.scrollTop})})})]})});MT.displayName=wm;var RT="SelectGroup",[h3,p3]=os(RT),g3=m.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,o=Io();return d.jsx(h3,{scope:n,id:o,children:d.jsx(vn.div,{role:"group","aria-labelledby":o,...r,ref:e})})});g3.displayName=RT;var DT="SelectLabel",LT=m.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,o=p3(DT,n);return d.jsx(vn.div,{id:o.id,...r,ref:e})});LT.displayName=DT;var Cu="SelectItem",[m3,FT]=os(Cu),$T=m.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:i,...s}=t,l=wi(Cu,n),u=Ci(Cu,n),h=l.value===r,[p,g]=m.useState(i??""),[C,w]=m.useState(!1),b=rt(e,A=>{var N;return(N=u.itemRefCallback)==null?void 0:N.call(u,A,r,o)}),v=Io(),x=m.useRef("touch"),E=()=>{o||(l.onValueChange(r),l.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return d.jsx(m3,{scope:n,value:r,disabled:o,textId:v,isSelected:h,onItemTextChange:m.useCallback(A=>{g(N=>N||((A==null?void 0:A.textContent)??"").trim())},[]),children:d.jsx(vu.ItemSlot,{scope:n,value:r,disabled:o,textValue:p,children:d.jsx(vn.div,{role:"option","aria-labelledby":v,"data-highlighted":C?"":void 0,"aria-selected":h&&C,"data-state":h?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...s,ref:b,onFocus:Ue(s.onFocus,()=>w(!0)),onBlur:Ue(s.onBlur,()=>w(!1)),onClick:Ue(s.onClick,()=>{x.current!=="mouse"&&E()}),onPointerUp:Ue(s.onPointerUp,()=>{x.current==="mouse"&&E()}),onPointerDown:Ue(s.onPointerDown,A=>{x.current=A.pointerType}),onPointerMove:Ue(s.onPointerMove,A=>{var N;x.current=A.pointerType,o?(N=u.onItemLeave)==null||N.call(u):x.current==="mouse"&&A.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ue(s.onPointerLeave,A=>{var N;A.currentTarget===document.activeElement&&((N=u.onItemLeave)==null||N.call(u))}),onKeyDown:Ue(s.onKeyDown,A=>{var P;((P=u.searchRef)==null?void 0:P.current)!==""&&A.key===" "||(t3.includes(A.key)&&E(),A.key===" "&&A.preventDefault())})})})})});$T.displayName=Cu;var yc="SelectItemText",HT=m.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:o,...i}=t,s=wi(yc,n),l=Ci(yc,n),u=FT(yc,n),h=i3(yc,n),[p,g]=m.useState(null),C=rt(e,E=>g(E),u.onItemTextChange,E=>{var A;return(A=l.itemTextRefCallback)==null?void 0:A.call(l,E,u.value,u.disabled)}),w=p==null?void 0:p.textContent,b=m.useMemo(()=>d.jsx("option",{value:u.value,disabled:u.disabled,children:w},u.value),[u.disabled,u.value,w]),{onNativeOptionAdd:v,onNativeOptionRemove:x}=h;return rn(()=>(v(b),()=>x(b)),[v,x,b]),d.jsxs(d.Fragment,{children:[d.jsx(vn.span,{id:u.textId,...i,ref:C}),u.isSelected&&s.valueNode&&!s.valueNodeHasChildren?Aa.createPortal(i.children,s.valueNode):null]})});HT.displayName=yc;var UT="SelectItemIndicator",BT=m.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return FT(UT,n).isSelected?d.jsx(vn.span,{"aria-hidden":!0,...r,ref:e}):null});BT.displayName=UT;var Cm="SelectScrollUpButton",v3=m.forwardRef((t,e)=>{const n=Ci(Cm,t.__scopeSelect),r=ym(Cm,t.__scopeSelect),[o,i]=m.useState(!1),s=rt(e,r.onScrollButtonChange);return rn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const h=u.scrollTop>0;i(h)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?d.jsx(zT,{...t,ref:s,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop-u.offsetHeight)}}):null});v3.displayName=Cm;var bm="SelectScrollDownButton",y3=m.forwardRef((t,e)=>{const n=Ci(bm,t.__scopeSelect),r=ym(bm,t.__scopeSelect),[o,i]=m.useState(!1),s=rt(e,r.onScrollButtonChange);return rn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const h=u.scrollHeight-u.clientHeight,p=Math.ceil(u.scrollTop)<h;i(p)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?d.jsx(zT,{...t,ref:s,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop+u.offsetHeight)}}):null});y3.displayName=bm;var zT=m.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=t,i=Ci("SelectScrollButton",n),s=m.useRef(null),l=yu(n),u=m.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return m.useEffect(()=>()=>u(),[u]),rn(()=>{var p;const h=l().find(g=>g.ref.current===document.activeElement);(p=h==null?void 0:h.ref.current)==null||p.scrollIntoView({block:"nearest"})},[l]),d.jsx(vn.div,{"aria-hidden":!0,...o,ref:e,style:{flexShrink:0,...o.style},onPointerDown:Ue(o.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:Ue(o.onPointerMove,()=>{var h;(h=i.onItemLeave)==null||h.call(i),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:Ue(o.onPointerLeave,()=>{u()})})}),w3="SelectSeparator",VT=m.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return d.jsx(vn.div,{"aria-hidden":!0,...r,ref:e})});VT.displayName=w3;var xm="SelectArrow",C3=m.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,o=wu(n),i=wi(xm,n),s=Ci(xm,n);return i.open&&s.position==="popper"?d.jsx(zB,{...o,...r,ref:e}):null});C3.displayName=xm;var b3="SelectBubbleInput",KT=m.forwardRef(({__scopeSelect:t,value:e,...n},r)=>{const o=m.useRef(null),i=rt(r,o),s=rS(e);return m.useEffect(()=>{const l=o.current;if(!l)return;const u=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(u,"value").set;if(s!==e&&p){const g=new Event("change",{bubbles:!0});p.call(l,e),l.dispatchEvent(g)}},[s,e]),d.jsx(vn.select,{...n,style:{...bT,...n.style},ref:i,defaultValue:e})});KT.displayName=b3;function GT(t){return t===""||t===void 0}function jT(t){const e=mn(t),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(s=>{const l=n.current+s;e(l),function u(h){n.current=h,window.clearTimeout(r.current),h!==""&&(r.current=window.setTimeout(()=>u(""),1e3))}(l)},[e]),i=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,i]}function WT(t,e,n){const o=e.length>1&&Array.from(e).every(h=>h===e[0])?e[0]:e,i=n?t.indexOf(n):-1;let s=x3(t,Math.max(i,0));o.length===1&&(s=s.filter(h=>h!==n));const u=s.find(h=>h.textValue.toLowerCase().startsWith(o.toLowerCase()));return u!==n?u:void 0}function x3(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var S3=xT,qT=_T,_3=TT,E3=AT,T3=IT,YT=kT,A3=MT,JT=LT,QT=$T,I3=HT,k3=BT,XT=VT;const Sm=S3,_m=_3,bu=m.forwardRef(({className:t,children:e,...n},r)=>d.jsxs(qT,{ref:r,className:ze("flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50",t),...n,children:[e,d.jsx(E3,{asChild:!0,children:d.jsx(HD,{className:"h-4 w-4 opacity-50"})})]}));bu.displayName=qT.displayName;const xu=m.forwardRef(({className:t,children:e,position:n="popper",...r},o)=>d.jsx(T3,{children:d.jsx(YT,{ref:o,className:ze("relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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-[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",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,...r,children:d.jsx(A3,{className:ze("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e})})}));xu.displayName=YT.displayName;const N3=m.forwardRef(({className:t,...e},n)=>d.jsx(JT,{ref:n,className:ze("px-2 py-1.5 text-sm font-semibold",t),...e}));N3.displayName=JT.displayName;const Xi=m.forwardRef(({className:t,children:e,...n},r)=>d.jsxs(QT,{ref:r,className:ze("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[d.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(k3,{children:d.jsx(Lx,{className:"h-4 w-4"})})}),d.jsx(I3,{children:e})]}));Xi.displayName=QT.displayName;const P3=m.forwardRef(({className:t,...e},n)=>d.jsx(XT,{ref:n,className:ze("-mx-1 my-1 h-px bg-muted",t),...e}));P3.displayName=XT.displayName;const Em=[{value:"VIEW_DOCUMENT",label:"Chỉ xem"},{value:"EDIT_DOCUMENT",label:"Chỉnh sửa"},{value:"DOWNLOAD_DOCUMENT",label:"Tải xuống"}];function O3({onClose:t,open:e,file:n,apiBaseUrl:r,rootUrlHostApi:o}){const[i,s]=O.useState("users"),[l,u]=O.useState(""),[h,p]=O.useState(""),[g,C]=O.useState(""),[w,b]=O.useState(""),[v,x]=O.useState(Br.VIEW_DOCUMENT),[E,A]=O.useState([]),{users:N,groups:P,sharedUsers:_,sharedGroups:D,fetchData:H,loading:K,postGranted:ee,loadingGrandted:W,setSharedGroups:de,setSharedUsers:se}=FH(r,o),fe=Gi(),q=n?n.key:"",Z=N.filter(z=>{var ce;return(fe==null?void 0:fe.id)!==z.id&&(z.username.toLowerCase().includes(l.toLowerCase())||((ce=z.email)==null?void 0:ce.toLowerCase().includes(l.toLowerCase())))}),Y=P.filter(z=>z.groupname.toLowerCase().includes(h.toLowerCase())),oe=_.filter(z=>{var ce,Ae;return((ce=z.username)==null?void 0:ce.toLowerCase().includes(g.toLowerCase()))||((Ae=z.email)==null?void 0:Ae.toLowerCase().includes(g.toLowerCase()))}),Q=D.filter(z=>{var ce;return(ce=z.groupname)==null?void 0:ce.toLowerCase().includes(w.toLowerCase())}),X=z=>{x(z),A(ce=>ce.map(Ae=>({...Ae,permissions:z})))},$=()=>{i==="users"?(u(""),C("")):(p(""),b(""),s("users")),A([]),x(Br.VIEW_DOCUMENT)};O.useEffect(()=>{e?H(q):$()},[e]);const te=z=>{z!==i&&(i==="users"?(u(""),C("")):(p(""),b(""))),s(z)},_e=z=>{n&&A(ce=>{if(ce.find(ne=>ne.userId===z))return ce.filter(ne=>ne.userId!==z);const Ne={path:n.key+n.name,permissions:v,userId:z,grandtedBy:fe==null?void 0:fe.id};return[...ce,Ne]})},ke=z=>{if(!n)return;const ce=z.groupname;A(Ae=>{if(Ae.find(Ve=>Ve.groupname===ce))return Ae.filter(Ve=>Ve.groupname!==ce);const ne={path:n.key+n.name,permissions:v,groupname:ce,groupId:z.id,grandtedBy:fe==null?void 0:fe.id,users:z.users};return[...Ae,ne]})},xe=async(z,ce,Ae)=>{const Ce={...z,permissions:ce};A(Ne=>{const ne=Ne.map(Qe=>Qe.id===Ce.id?Ce:Qe);return Ne.some(Qe=>Qe.id===Ce.id)||ne.push(Ce),ne}),Ae==="users"?se(Ne=>Ne.map(ne=>ne.id===z.id?Ce:ne)):de(Ne=>Ne.map(ne=>ne.id===z.id?Ce:ne))},Pe=async()=>{if(n){const z=(n==null?void 0:n.key)||""+(n==null?void 0:n.name),ce=await ee(z,fe==null?void 0:fe.id,E);(ce==null?void 0:ce.status)==200&&A([])}},Te="flex-1 min-h-0 overflow-y-auto border rounded-lg px-3 py-2 bg-background shadow-sm";return n?d.jsx(or,{open:e,onOpenChange:t,children:d.jsxs(Kn,{className:"max-w-5xl h-[70vh] flex flex-col overflow-hidden",children:[d.jsx(Gn,{children:d.jsxs(jn,{className:"text-lg font-semibold",children:["Chia sẻ tài liệu: ",n.name]})}),d.jsxs(Cg,{defaultValue:"users",className:"mt-6 flex-1 flex flex-col overflow-hidden",children:[d.jsxs(Jd,{className:"grid grid-cols-2 w-1/2 mx-auto mb-4 bg-muted rounded-lg",children:[d.jsx(ji,{value:"users",className:"py-2",onClick:()=>te("users"),children:"Người dùng"}),d.jsx(ji,{value:"groups",className:"py-2",onClick:()=>te("groups"),children:"Nhóm"})]}),d.jsx(Wi,{value:"users",className:"flex-1 h-full min-h-0 overflow-hidden",children:d.jsxs("div",{className:"grid grid-cols-2 gap-6 h-full",children:[d.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[d.jsx("p",{className:"text-sm font-semibold mb-2",children:"Chia sẻ với người dùng:"}),d.jsx(Wn,{placeholder:"Tìm người dùng...",className:"mb-3 border-input bg-background shadow-sm",value:l,onChange:z=>u(z.target.value)}),d.jsx("div",{className:Te,children:K?d.jsx("div",{className:"flex items-center justify-center h-full",children:d.jsx(Pt,{className:"h-10 w-10 animate-spin text-muted-foreground"})}):Z.length===0?d.jsx("p",{className:"text-muted-foreground italic text-center h-full flex items-center justify-center",children:"Không tìm thấy người dùng."}):d.jsx("ul",{className:"space-y-2",children:Z.map(z=>d.jsx("li",{onClick:()=>_e(z.id),className:"flex flex-col space-y-1 cursor-pointer hover:bg-accent p-2 rounded-md transition-colors",children:d.jsxs("div",{className:"flex items-center space-x-3",children:[d.jsx(oc,{id:`user-${z.id}`,checked:!!E.find(ce=>ce.userId===z.id)}),d.jsxs(pr,{className:"flex-1",children:[d.jsx("p",{className:"font-medium",children:z.username}),d.jsx("p",{className:"text-xs text-muted-foreground",children:z.email}),d.jsx("p",{className:"text-xs text-muted-foreground",children:z.groupname})]})]})},z.id))})})]}),d.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[d.jsx("p",{className:"text-sm font-semibold mb-2",children:"Đã chia sẻ với người dùng:"}),d.jsx(Wn,{placeholder:"Tìm người dùng đã chia sẻ...",className:"mb-3 border-input bg-background shadow-sm",value:g,onChange:z=>C(z.target.value)}),d.jsx("div",{className:Te,children:K?d.jsx("div",{className:"flex items-center justify-center h-full",children:d.jsx(Pt,{className:"h-10 w-10 animate-spin text-muted-foreground"})}):oe.length===0?d.jsx("p",{className:"text-muted-foreground italic text-center h-full flex items-center justify-center",children:"Chưa chia sẻ với người dùng nào."}):d.jsx("ul",{className:"space-y-2",children:oe.map(z=>d.jsxs("li",{className:"flex items-center justify-between gap-4 hover:bg-accent p-2 rounded-md transition-colors",children:[d.jsxs("div",{className:"flex flex-col",children:[d.jsx("p",{className:"font-medium",children:z.username}),d.jsx("p",{className:"text-xs text-muted-foreground",children:z.email}),d.jsx("p",{className:"text-xs text-muted-foreground",children:z.groupname})]}),d.jsxs(Sm,{value:z.permissions,onValueChange:ce=>xe(z,ce,"users"),disabled:z.permissions===Br.OWNER_DOCUMENT,children:[d.jsx(bu,{className:"w-[120px]",children:d.jsx(_m,{placeholder:"Chọn quyền"})}),d.jsxs(xu,{children:[Em.map(ce=>d.jsx(Xi,{value:ce.value,children:ce.label},ce.value)),z.permissions===Br.OWNER_DOCUMENT&&d.jsx(Xi,{value:Br.OWNER_DOCUMENT,children:"Chủ sở hữu"},Br.OWNER_DOCUMENT),d.jsx(Xi,{value:"None",children:"Thu hồi"},"None")]})]})]},z.id))})})]})]})}),d.jsx(Wi,{value:"groups",className:"flex-1 h-full min-h-0 overflow-hidden",children:d.jsxs("div",{className:"grid grid-cols-2 gap-6 h-full",children:[d.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[d.jsx("p",{className:"text-sm font-semibold mb-2",children:"Chia sẻ với nhóm:"}),d.jsx(Wn,{placeholder:"Tìm nhóm...",className:"mb-3 border-input bg-background shadow-sm",value:h,onChange:z=>p(z.target.value)}),d.jsx("div",{className:Te,children:K?d.jsx("div",{className:"flex items-center justify-center h-full",children:d.jsx(Pt,{className:"h-10 w-10 animate-spin text-muted-foreground"})}):Y.length===0?d.jsx("p",{className:"text-muted-foreground italic text-center h-full flex items-center justify-center",children:"Không tìm thấy nhóm."}):d.jsx("ul",{className:"space-y-2",children:Y.map(z=>d.jsxs("li",{onClick:()=>ke(z),className:"flex items-center space-x-3 cursor-pointer hover:bg-accent p-2 rounded-md transition-colors",children:[d.jsx(oc,{id:`group-${z.groupname}`,checked:!!E.find(ce=>ce.groupname===z.groupname)}),d.jsxs(pr,{className:"font-medium",children:[d.jsx("p",{className:"font-medium",children:z.groupname}),d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Số lượng: ",z.users||0]})]})]},z.groupname))})})]}),d.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[d.jsx("p",{className:"text-sm font-semibold mb-2",children:"Đã chia sẻ với nhóm:"}),d.jsx(Wn,{placeholder:"Tìm nhóm đã chia sẻ...",className:"mb-3 border-input bg-background shadow-sm",value:w,onChange:z=>b(z.target.value)}),d.jsx("div",{className:Te,children:K?d.jsx("div",{className:"flex items-center justify-center h-full",children:d.jsx(Pt,{className:"h-10 w-10 animate-spin text-muted-foreground"})}):Q.length===0?d.jsx("p",{className:"text-muted-foreground italic text-center h-full flex items-center justify-center",children:"Chưa chia sẻ với nhóm nào."}):d.jsx("ul",{className:"space-y-2",children:Q.map(z=>d.jsxs("li",{className:"flex items-center justify-between gap-4 hover:bg-accent p-2 rounded-md transition-colors",children:[d.jsxs("div",{className:"flex flex-col",children:[d.jsx("p",{className:"font-medium",children:z.groupname}),d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Số lượng: ",z.users||0]})]}),d.jsxs(Sm,{value:z.permissions,onValueChange:ce=>xe(z,ce,"groups"),children:[d.jsx(bu,{className:"w-[120px]",children:d.jsx(_m,{placeholder:"Chọn quyền"})}),d.jsxs(xu,{children:[Em.map(ce=>d.jsx(Xi,{value:ce.value,children:ce.label},ce.value)),d.jsx(Xi,{value:"None",children:"Thu hồi"},"None")]})]})]},z.groupname))})})]})]})})]}),d.jsxs("div",{className:"mt-4 bg-muted/50 p-4 rounded-lg",children:[d.jsx(pr,{className:"font-medium mb-2 block",children:"Phân quyền:"}),d.jsxs(Sm,{value:v,onValueChange:X,children:[d.jsx(bu,{className:"w-1/2 border border-input bg-background shadow-sm hover:bg-accent",children:d.jsx(_m,{placeholder:"Chọn quyền truy cập"})}),d.jsx(xu,{children:Em.map(z=>d.jsx(Xi,{value:z.value,className:"flex items-center gap-2",children:z.label}))})]})]}),d.jsxs(Lr,{children:[d.jsx(He,{variant:"outline",onClick:t,children:"Huỷ"}),d.jsx(He,{variant:"default",onClick:Pe,disabled:E.length===0||W,className:"w-[120px] justify-center",children:W?d.jsx(Pt,{className:"h-4 w-4 animate-spin"}):"Lưu thay đổi"})]})]})}):null}const M3={},R3="AIzaSyBI8KiTWudkw8iR5cjH7ZsA4JBN1NqJw8A",D3="726815747852-5deq413t8kd8j3mgj48d46eatjauapq5.apps.googleusercontent.com",L3="https://www.googleapis.com/auth/drive";Po(Le,{retries:3,shouldResetTimeout:!0,retryCondition:t=>Po.isRetryableError(t)&&t.config.method==="get"});const Yn={current:!1},ZT="crawl:jobs",is="crawl:current_job",F3=t=>{const[e,n]=O.useState(null),[r,o]=O.useState(0);return O.useEffect(()=>{const i=localStorage.getItem(is);if(i){const s=JSON.parse(i);n(s),s!=null&&s.startTime&&o(Math.floor((Date.now()-s.startTime)/1e3))}},[]),O.useEffect(()=>{if(!(e!=null&&e.startTime))return;const i=setInterval(()=>{o(Math.floor((Date.now()-e.startTime)/1e3))},1e3);return()=>clearInterval(i)},[e==null?void 0:e.startTime]),O.useEffect(()=>{if(!(e!=null&&e.id))return;const i=async()=>{try{const u=(await Le.get(`${t}/api/crawl/${e.id}?taskId=${e.taskId}`)).data;n(h=>{if(!h)return null;const p={...h,status:u};return localStorage.setItem(is,JSON.stringify(p)),(u.status==="completed"||u.status==="failed")&&setTimeout(()=>{n(null),localStorage.removeItem(is)},100),p})}catch(l){console.error("Error polling job status:",l)}},s=setInterval(i,3e3);return i(),()=>clearInterval(s)},[e==null?void 0:e.id,t]),{currentJob:e,elapsedTime:r,setCurrentJob:i=>{i&&!i.startTime&&(i.startTime=Date.now()),n(i),i?localStorage.setItem(is,JSON.stringify(i)):localStorage.removeItem(is)}}},Su=(t,e)=>{const n=[],r=o=>{(t[o]||[]).forEach(s=>{n.push(s.key),s.isFolder&&r(s.key)})};return r(e),n},$3=(t,e)=>{const n=[];return(t[e]||[]).forEach(o=>{n.push(o.key),o.isFolder&&n.push(...Su(t,o.key))}),n},H3=(t,e,n=[],r,o,i,s,l,u,h)=>{const[p,g]=O.useState({}),[C,w]=O.useState(!1),[b,v]=O.useState(null),[x,E]=O.useState(0),A=O.useRef(e);O.useEffect(()=>{A.current=e},[e]);const N=async()=>{var _;w(!0);try{const D=Gi(),H=await Le.get(`${t}/api/files`,{params:{cache:!1,displayPrefixes:JSON.stringify(n),prefix:A.current,userId:(D==null?void 0:D.id)||"",groupId:((_=D==null?void 0:D.group)==null?void 0:_.id)||"",groupname:(D==null?void 0:D.groupname)||""},timeout:3e5}),K=[];Rd.forEach(H.data,(ee,W)=>{l!=null&&l.has(W)&&Rd.forEach(ee,de=>{(u==null?void 0:u.current[de.key])!==!1&&K.push(de.key)})}),K.length&&(h==null||h(ee=>{const W=new Set(ee);return K.forEach(de=>W.add(de)),W})),g(H.data),v(null)}catch(D){v(D instanceof Error?D:new Error("Failed to fetch files"))}finally{w(!1),E(0),i("")}},P=async _=>{var D,H;try{if(!_)return;w(!0);const K=await Le.get(`${t}/api/search-db?query=${_}&rootPrefix=${e}&offset=${(o-1)*20}&limit=20`,{timeout:3e5});return g({[e]:((D=K==null?void 0:K.data)==null?void 0:D.result)||[]}),E(((H=K==null?void 0:K.data)==null?void 0:H.estimatedTotalHits)||0),K}catch(K){v(K instanceof Error?K:new Error("Failed to fetch files"))}finally{w(!1)}};return O.useEffect(()=>{!r&&!C&&N(),r&&!C&&P(r)},[r,o]),{data:p,isLoading:C,error:b,estimatedTotalHits:x,refetch:N}},Zi=t=>{var r,o,i;const e=((i=(o=(r=t==null?void 0:t.name)==null?void 0:r.split("."))==null?void 0:o.pop())==null?void 0:i.toLowerCase())??"";return["txt","md","json","js","ts","jsx","tsx","css","html","xml","yaml","yml"].includes(e||"")},U3={auth:{clientId:"584d5fa9-5123-4602-a1a5-a3746a83745f",authority:"https://login.microsoftonline.com/consumers",redirectUri:M3.VITE_ONE_DRIVE_REDIRECT_URI||"https://s3-explorer.cmcts1.studio.ai.vn/sharepoint/redirect"}},B3=new dp(U3),Tm={[Br.VIEW_DOCUMENT]:1,[Br.DOWNLOAD_DOCUMENT]:2,[Br.EDIT_DOCUMENT]:10,[Br.OWNER_DOCUMENT]:100},ea=t=>{const e=Gi();return`${e==null?void 0:e.groupname}`.toUpperCase()==="MASTER_ADMIN"?!0:t?Tm[t]>=10:!1},z3=t=>{const e=Gi();return`${e==null?void 0:e.groupname}`.toUpperCase()==="MASTER_ADMIN"?!0:t?Tm[t]>=2:!1},V3=t=>{const e=Gi();return`${e==null?void 0:e.groupname}`.toUpperCase()==="MASTER_ADMIN"?!0:t?Tm[t]>=1:!1},K3=O.memo(({homeLabel:t="Kho tài liệu",apiBaseUrl:e="http://localhost:3000",rootPrefix:n="",rootUrlHostApi:r="http://localhost:3003/api/v1",asSelector:o=!1,onSelected:i=h=>console.log("Đã chọn:",h),displayPrefixes:s,preSelectedFiles:l,idCreator:u})=>{var Qc;const[h,p]=O.useState([]),[g,C]=O.useState(""),[w,b]=O.useState(new Set(l)),[v,x]=O.useState(n),[E,A]=O.useState(""),[N,P]=O.useState(!1),[_,D]=O.useState(""),[H,K]=O.useState(!1),[ee,W]=O.useState(null),[de,se]=O.useState(null),[fe,q]=O.useState(!1),[Z,Y]=O.useState(!1),[,oe]=O.useState(null),Q=O.useRef(null),{toast:X}=dc(),[$,te]=O.useState(null),[_e,ke]=O.useState(null),[xe,Pe]=O.useState(null),[Te,z]=O.useState(""),[ce,Ae]=O.useState(!1),[Ce,Ne]=O.useState(!1),[ne,Ve]=O.useState(new Set),[Qe,Ct]=O.useState(""),[Jt,bt]=O.useState(!1),[an,zt]=O.useState(!1),[Dn,Kt]=O.useState("rename"),[L,J]=O.useState(!1),[U,ae]=O.useState(""),[ye,he]=O.useState("1"),[Ee,Xe]=O.useState(!1),[ft,xt]=O.useState(!1),[vo,Qt]=O.useState(!1),[yn,Gr]=O.useState(!1),[Gt,cr]=O.useState(1),[jr,na]=O.useState(!1),{currentJob:Je,elapsedTime:Fo,setCurrentJob:_c}=F3(e),[yo,ra]=O.useState(null),[oa,ss]=O.useState(""),[ku,ia]=O.useState(!1),[cs,Nu]=O.useState(""),[Ec,Pu]=O.useState(!1),[Tc,Ou]=O.useState(!1),[ls,Mu]=O.useState([]),[aa,Ru]=O.useState(!1),[ds,Mm]=O.useState(""),$o=O.useRef({}),[Ac,Ic]=O.useState(null),Rm=async T=>{Ou(!0);try{const M=await Le.get(`${r}get-knowledge-base/knowledge-base-name/${T}`,{headers:{Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjAyOTliMmIwLTk4MGEtNGQ1Yy04NjkyLWJjNjllM2I1NzZlMiIsInVzZXJuYW1lIjoiY21jX3RzX2FkbWluIiwiaWF0IjoxNzQ3MTk0MTg3fQ.7LB2rgd0fQnhZP_cFgTTCPMSYl0_apwffcNEd7oqjeM"}});M.status===200&&Mu(M.data.knowledgeBase.chatflows.map(G=>({...G,KnowledgeBaseId:M.data.knowledgeBase.knowledge_base_id})))}catch{}finally{Ou(!1)}};O.useEffect(()=>{cs&&r&&Rm(cs)},[cs]),O.useEffect(()=>{console.log("pre selected files",l)},[l]);const[Mt,kc]=O.useState(null),[x0,Dm]=O.useState(!1),[Nc,Pc]=O.useState(!1),[sa,us]=O.useState(!1),[Du,Lu]=O.useState([]),[Oc,Mc]=O.useState([]),[ca,Rc]=O.useState([{id:"root",name:"OneDrive"}]),[Lm,fs]=O.useState(!1),[hs,Dc]=O.useState([]),[Fu,Ho]=O.useState(!1),[ps,Lc]=O.useState([]),[Fc,gs]=O.useState([]),[ms,$u]=O.useState([]),[$c,la]=O.useState([{id:"root",name:"SharePoint"}]),[wo,da]=O.useState(!1),[Hc,Uc]=O.useState([]),[gt,Wr]=O.useState(null),[Hu,ua]=O.useState(!1),[Fm,fa]=O.useState(!1),Uu=new URL(window.location.href).searchParams.get("prefix")||""||E||n,[S0,Um]=O.useState(null),{data:Tn,isLoading:Uo,error:Bm,estimatedTotalHits:ha,refetch:un}=H3(e,Uu,s,g,Gt,C,u,w,$o,b),[Bc,yr]=O.useState(!1),zc=O.useRef(null),Vc=Gi(),Ht=(()=>{const T=localStorage.getItem("dataLogin");try{if(T){const M=JSON.parse(T);return(M==null?void 0:M.user)??null}}catch{return null}return null})();O.useEffect(()=>{if(!Bc)return;function T(M){zc.current&&!zc.current.contains(M.target)&&yr(!1)}return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},[Bc]);const zm=async()=>{try{const T=await Le.get(`${e}/api/login-sharepoint`),{loginUrl:M}=T.data,G=window.open(M,"SharePoint Login","width=600,height=600");if(!G)throw new Error("Không thể mở cửa sổ pop-up");G.focus();const pe=setInterval(()=>{try{if(G.closed){clearInterval(pe);return}const be=G.location.href;if(be.includes("code=")){const Ie=new URL(be).searchParams.get("code");Ie&&(At(Ie),G.close(),clearInterval(pe))}}catch(be){be instanceof Error&&!be.message.includes("cross-origin")&&console.error("SharePoint login error:",be)}},1e3)}catch(T){st.error("Lỗi khi đăng nhập SharePoint: "+(T instanceof Error?T.message:"Lỗi không xác định"))}},Vm=async()=>{try{Lc([]),la([{id:"root",name:"SharePoint"}]),window.location.href="https://login.microsoftonline.com/common/oauth2/v2.0/logout?post_logout_redirect_uri="+encodeURIComponent(window.location.origin),X({title:"Success",description:"Logged out from SharePoint"})}catch(T){console.error("Error logging out from SharePoint:",T),X({title:"Error",description:"Failed to logout from SharePoint",variant:"destructive"})}},At=async T=>{try{const M=await Le.post(`${e}/api/get-sharepoint-access-token`,{code:T,userId:"1"}),{accessToken:G}=M.data;localStorage.setItem("sharepoint_access_token",G),Pc(!0),da(!0)}catch(M){console.error("❌ Error fetching SharePoint access token:",M),X({title:"Error",description:"Failed to connect to SharePoint",variant:"destructive"})}},It=async()=>{try{Ho(!0);const M=(await Le.post(`${e}/api/list-site-sharepoint`,{userId:"1"})).data.sites.map(G=>{const pe=new URL(G.webUrl);return{id:G.id,name:G.name,description:G.description,hostname:G.hostname||pe.hostname,sitePath:G.sitePath||pe.pathname.replace(/^\/+/,"")}});console.log("data",M),Uc(M),Ho(!1)}catch(T){console.error("❌ Error fetching SharePoint sites:",T),X({title:"Error",description:"Failed to fetch SharePoint sites",variant:"destructive"}),Ho(!1)}},Km=async T=>{Wr(T),console.log(T),await vs("root",T.name,T.hostname||"",T.sitePath||"")},vs=async(T,M,G,pe)=>{try{Ho(!0);const Ie=(await Le.post(`${e}/api/list-file-sharepoint`,{folderId:T,userId:"1",hostname:G,sitePath:pe})).data.files.map(Me=>({id:Me.id,name:Me.name,size:Me.size??0,lastModified:Me.lastModifiedDateTime?new Date(Me.lastModifiedDateTime):new Date,contentType:Me.mimeType??void 0,isFolder:Me.type==="folder",parentId:Me.parentId??""}));gs(Ie.filter(Me=>Me.isFolder)),Lc(Ie.filter(Me=>!Me.isFolder)),da(!0),la(Me=>Me.some(jt=>jt.id===T)?Me:[...Me,{id:T,name:M==="root"?"SharePoint":M}]),Ho(!1)}catch(be){console.error("❌ Error fetching SharePoint files:",be),X({title:"Error",description:"Failed to fetch SharePoint files",variant:"destructive"}),Ho(!1)}},Gm=T=>{$u(M=>M.some(pe=>pe.id===T.id)?M.filter(pe=>pe.id!==T.id):[...M,{id:T.id,name:T.name,size:T.size,lastModified:T.lastModified,contentType:T.contentType,isFolder:T.isFolder,parentId:T.parentId}])},jm=T=>{var G;la(pe=>pe.slice(0,T+1));const M=(G=$c[T])==null?void 0:G.id;M&&vs(M,"SharePoint",(gt==null?void 0:gt.hostname)||"",(gt==null?void 0:gt.sitePath)||"")},Wm=async(T,M)=>{const G=localStorage.getItem("sharepoint_access_token");if(!G){st.error("Không tìm thấy access token. Vui lòng đăng nhập lại.");return}const pe=st.loading("Đang đồng bộ SharePoint...",{position:"bottom-right",autoClose:!1});try{const be={prefix:M,folders:[],files:[],hostname:(gt==null?void 0:gt.hostname)||"",sitePath:(gt==null?void 0:gt.sitePath)||""};T.forEach(Me=>{Me.isFolder?be.folders.push({id:Me.id,name:Me.name}):be.files.push({id:Me.id,name:Me.name})});const Ie=await Le.post(`${e}/api/sync-sharepoint-to-s3`,be,{headers:{Authorization:`Bearer ${G}`}});un(),st.update(pe,{render:`Đồng bộ thành công! Đã tải lên ${Ie.data.uploadedKeys.length} file.`,type:"success",isLoading:!1,autoClose:3e3,position:"bottom-right"}),da(!1)}catch(be){console.error("Lỗi khi đồng bộ file từ SharePoint:",be),st.update(pe,{render:"Không thể đồng bộ file từ SharePoint.",type:"error",isLoading:!1,autoClose:3e3,position:"bottom-right"})}},Bu=()=>{da(!1),Lc([]),$u([]),la([{id:"root",name:"SharePoint"}])};O.useEffect(()=>{if(wo){const M=new URLSearchParams(window.location.search).get("code");M&&(At(M),window.history.replaceState({},document.title,window.location.pathname))}},[wo]),O.useEffect(()=>{B3.initialize().then(()=>{Dm(!0)}).catch(T=>console.error("❌ Lỗi khởi tạo MSAL:",T))},[]),O.useEffect(()=>{zu()},[]);async function zu(){localStorage.getItem("onedrive_access_token")&&Pc(!0)}const Vu=T=>{Dc(M=>M.some(pe=>pe.id===T.id)?M.filter(pe=>pe.id!==T.id):[...M,{id:T.id,name:T.name,size:T.size,lastModified:T.lastModified,contentType:T.contentType,isFolder:T.isFolder,parentId:T.parentId}])};function Xt(T){if(T===0)return"0 B";const M=1024,G=["B","KB","MB","GB","TB"],pe=Math.floor(Math.log(T)/Math.log(M));return parseFloat((T/Math.pow(M,pe)).toFixed(1))+" "+G[pe]}function Kc(T){const M=new Date(T);return M.toLocaleDateString()+" "+M.toLocaleTimeString()}const Bo=async()=>{try{const T=await Le.get(`${e}/api/login-one-drive`),{loginUrl:M}=T.data,G=window.open(M,"OneDrive Login","width=600,height=600");if(!G)throw new Error("Không thể mở cửa sổ pop-up");G.focus();const pe=setInterval(()=>{try{if(G.closed){clearInterval(pe);return}const be=G.location.href;if(be.includes("code=")){const Ie=new URL(be).searchParams.get("code");Ie&&(Gc(Ie),G.close(),clearInterval(pe))}}catch(be){be instanceof Error&&!be.message.includes("cross-origin")&&console.error("OneDrive login error:",be)}},1e3)}catch(T){st.error("Lỗi khi đăng nhập OneDrive: "+(T instanceof Error?T.message:"Lỗi không xác định"))}},Ku=async()=>{try{await Le.post(`${e}/api/logout-one-drive`),localStorage.removeItem("onedrive_access_token"),st.success("Đã đăng xuất khỏi OneDrive"),window.location.href="https://login.microsoftonline.com/common/oauth2/v2.0/logout?post_logout_redirect_uri="+encodeURIComponent(window.location.origin)}catch(T){st.error("Lỗi khi đăng xuất OneDrive: "+(T instanceof Error?T.message:"Lỗi không xác định"))}},Gc=async T=>{try{const G=await Le.post(`${e}/api/get-one-drive-access-token`,{authorizationCode:T,userId:"1"}),{accessToken:pe}=G.data;localStorage.setItem("onedrive_access_token",pe),Pc(!0),us(!0),await wn("root","One Drive")}catch(M){console.error("❌ Lỗi khi lấy Access Token:",M)}},wn=async(T,M)=>{try{fs(!0);const be=(await Le.post(`${e}/api/list-file-one-drive`,{folderId:T,userId:"1"})).data.map(Ie=>({id:Ie.id,name:Ie.name,size:Ie.size??0,lastModified:Ie.lastModifiedDateTime?new Date(Ie.lastModifiedDateTime):new Date,contentType:Ie.mimeType??void 0,isFolder:Ie.type==="folder",parentId:Ie.parentId??""}));Lu(be.filter(Ie=>Ie.isFolder)),Mc(be.filter(Ie=>!Ie.isFolder)),us(!0),Rc(Ie=>Ie.some(Me=>Me.id===T)?Ie:[...Ie,{id:T,name:M==="root"?"OneDrive":M}]),fs(!1)}catch(G){console.error("Lỗi lấy danh sách file:",G),fs(!1)}},Gu=T=>{if(T===ca.length-1)return;const M=ca[T];M&&(Rc(ca.slice(0,T+1)),wn(M.id,M.name))},ju=async(T,M)=>{const G=localStorage.getItem("onedrive_access_token");if(!G){st.error("Không tìm thấy access token. Vui lòng đăng nhập lại.");return}const pe=st.loading("Đang đồng bộ OneDrive...",{position:"bottom-right",autoClose:!1});try{const be={prefix:M,folders:[],files:[]};T.forEach(Me=>{Me.isFolder?be.folders.push({id:Me.id,name:Me.name}):be.files.push({id:Me.id,name:Me.name})});const Ie=await Le.post(`${e}/api/sync-one-drive-to-s3`,be,{headers:{Authorization:`Bearer ${G}`}});un(),st.update(pe,{render:`Đồng bộ thành công! Đã tải lên ${Ie.data.uploadedKeys.length} file.`,type:"success",isLoading:!1,autoClose:3e3,position:"bottom-right"})}catch(be){console.error("Lỗi khi đồng bộ file từ OneDrive:",be),st.update(pe,{render:"Không thể đồng bộ file từ OneDrive.",type:"error",isLoading:!1,autoClose:3e3,position:"bottom-right"})}},jc=()=>{us(!1),Rc([{id:"root",name:"OneDrive"}]),Lu([]),Mc([]),Dc([]),fs(!1)},Wu=hM({onSuccess:T=>{Um(T.access_token),localStorage.setItem("google_access_token",T.access_token),qu(T.access_token)},onError:()=>{console.log("Đăng nhập thất bại!")},scope:L3}),qu=T=>{const M=document.createElement("script");M.src="https://apis.google.com/js/api.js",M.onload=()=>{window.gapi.load("picker",()=>Yu(T))},document.body.appendChild(M)},Yu=T=>{const M=new window.google.picker.DocsView(window.google.picker.ViewId.DOCS).setIncludeFolders(!0).setSelectFolderEnabled(!0).setOwnedByMe(!1),G=new window.google.picker.DocsView(window.google.picker.ViewId.DRIVE).setIncludeFolders(!0).setSelectFolderEnabled(!0);new window.google.picker.PickerBuilder().setDeveloperKey(R3).setOAuthToken(T).enableFeature(window.google.picker.Feature.MULTISELECT_ENABLED).setLocale("vi").addView(M).addView(G).setCallback(async be=>{if(be.action===window.google.picker.Action.PICKED){const Ie=be.docs.map(Me=>({id:Me.id,name:Me.name,mimeType:Me.mimeType}));await Ln(Ie,v)}}).build().setVisible(!0)},Ln=async(T,M="")=>{const G=localStorage.getItem("google_access_token");if(!G){console.error("❌ Không tìm thấy access token. Vui lòng đăng nhập lại."),st.error("Không tìm thấy access token. Vui lòng đăng nhập lại.",{position:"bottom-right"});return}const pe=st.loading("Đang đồng bộ...",{position:"bottom-right",autoClose:!1});try{const be={prefix:M,folders:[],files:[]};T.forEach(Me=>{Me.mimeType==="application/vnd.google-apps.folder"?be.folders.push({id:Me.id,name:Me.name}):be.files.push({id:Me.id,name:Me.name})});const Ie=await Le.post(`${e}/api/sync-drive-to-s3`,be,{headers:{Authorization:`Bearer ${G}`}});Yn.current=!0,un(),st.update(pe,{render:`Đồng bộ thành công! Đã tải lên ${Ie.data.uploadedKeys.length} file.`,type:"success",isLoading:!1,autoClose:3e3,position:"bottom-right"})}catch(be){console.error("❌ Lỗi khi đồng bộ file từ Google Drive:",be),st.update(pe,{render:"Không thể đồng bộ file từ Google Drive.",type:"error",isLoading:!1,autoClose:3e3,position:"bottom-right"})}};O.useEffect(()=>{const T=M=>{if(M.data.action==="logout"){const G=document.createElement("iframe");G.style.display="none",G.src="https://accounts.google.com/Logout",document.body.appendChild(G),setTimeout(()=>document.body.removeChild(G),2e3)}};return window.addEventListener("message",T),()=>window.removeEventListener("message",T)},[]),O.useEffect(()=>{const T=new Set(l);b(T)},[]),O.useEffect(()=>{Je!=null&&Je.status&&(Je.status.status==="completed"?(X({title:"Thu thập website hoàn tất",description:`Đã thu thập thành công ${Je.url} với ${Je.status.completed} trang`}),Yn.current=!0,un()):Je.status.status==="failed"&&X({title:"Thu thập website thất bại",description:`Không thể thu thập ${Je.url}. Vui lòng thử lại.`,variant:"destructive"}))},[(Qc=Je==null?void 0:Je.status)==null?void 0:Qc.status]);const Ju=O.useMemo(()=>Tn[v]||[],[Tn,v]),Zt=O.useMemo(()=>Ju.filter(T=>V3(T.permission)),[Ju,v,Tn]),pa=O.useMemo(()=>{const T={};return Zt.forEach((M,G)=>{w.has(M.key)&&(T[G]=!0)}),T},[w,Zt]),Qu=T=>{const M=Su(Tn,T);if(M.length===0)return w.has(T)?"all":"none";const G=M.filter(pe=>w.has(pe)).length;return G===0?"none":G===M.length?"all":"partial"},Fn=(T,M=!0)=>{if(v!==T){if(u&&!v)na(!0),A(T+u),x(T+u);else if(na(!0),A(T),x(T),M&&!o){const G=window.location.pathname==="/"?"":window.location.pathname,pe=T?`${window.location.origin}${G}?prefix=${encodeURIComponent(T)}`:`${window.location.origin}${G}`;window.history.pushState({path:pe},"",pe)}}};O.useEffect(()=>{jr&&(Yn.current=!0,un().finally(()=>na(!1)))},[jr]);const ys=async(T,M)=>{var G,pe;K(!0);try{if(Zt.some(jt=>jt.isFolder&&jt.name.toLowerCase()===T.toLowerCase())){X({title:"Lỗi",description:`Thư mục "${T}" đã tồn tại trong thư mục hiện tại.`,variant:"destructive"}),K(!1);return}const Ie=`${M}${T}/`;if((await Le.post(`${e}/api/create-folder`,{prefix:Ie,userId:(Vc==null?void 0:Vc.id)||""})).status!==200){X({title:"Lỗi",description:"Không thể tạo thư mục",variant:"destructive"});return}Yn.current=!0,await un(),X({title:"Đã tạo thư mục",description:`Đã tạo thành công thư mục "${T}"`}),D(""),P(!1)}catch(be){console.error("Error creating folder:",be);const Ie=((pe=(G=be==null?void 0:be.response)==null?void 0:G.data)==null?void 0:pe.error)||"Không thể tạo thư mục";X({title:"Lỗi",description:Ie,variant:"destructive"})}finally{K(!1)}},ga=async(T,M,G)=>{var pe,be,Ie,Me,jt,Yr,ma,Ko,tf;oe(G),Qt(!0);try{if(Array.from(T).reduce((cn,ya)=>cn+ya.size,0)>=100*1024*1024){X({title:"Lỗi",description:"Tổng kích thước các tập tin vượt quá 100 MB",variant:"destructive"}),oe(null),Qt(!1);return}const Ei=Array.from(T).filter(cn=>cn.size===0);if(Ei.length>0){const cn=Ei.map(ya=>ya.name).join(", ");X({title:"Lỗi tải lên",description:`Không thể tải lên tập tin rỗng: ${cn}`,variant:"destructive"}),Qt(!1),oe(null);return}const Co=new FormData;if(Ht!=null&&Ht.id&&Co.append("metadata",JSON.stringify({creator:Ht.username,creatorId:Ht.id,DataSource:"Tệp tải lên"})),G==="folder"&&T[0]){const cn=T[0].webkitRelativePath.split("/")[0];cn&&Co.append("folderName",cn)}Co.append("prefix",M),Array.from(T).forEach(cn=>G==="folder"?Co.append("files",cn,cn.webkitRelativePath):Co.append("files",cn)),Yn.current=!0;const kt=await Le.post(`${e}/api/check-files-existed`,Co,{headers:{"Content-Type":"multipart/form-data"}});if(((pe=kt==null?void 0:kt.data)==null?void 0:pe.status)===200)await Le.post(`${e}/api/upload`,Co,{headers:{"Content-Type":"multipart/form-data"},timeout:0}),C(""),A(M),setTimeout(async()=>{oe(null),await un(),Qt(!1),await Vo("upload")},500);else{if(((Ie=(be=kt==null?void 0:kt.data)==null?void 0:be.names)==null?void 0:Ie.length)>0&&!((Me=kt==null?void 0:kt.data)!=null&&Me.isFolder)){const cn=Array.from(T).filter(ya=>kt.data.names.includes(ya.name));ra(cn),ia(!0)}(jt=kt==null?void 0:kt.data)!=null&&jt.isFolder&&((Yr=kt==null?void 0:kt.data)!=null&&Yr.name)&&(ss((ma=kt==null?void 0:kt.data)==null?void 0:ma.name),ra(T),ia(!0))}}catch(va){console.error("Lỗi tải lên:",va);const Ei=((tf=(Ko=va==null?void 0:va.response)==null?void 0:Ko.data)==null?void 0:tf.error)||"Không thể tải lên tập tin";X({title:"Lỗi",description:Ei,variant:"destructive"}),oe(null),Qt(!1)}},Lt=async()=>{var T,M;try{Qt(!0);const G=new FormData;if(yo){oe(oa?"folder":"files"),ia(!1);let pe=localStorage.getItem("dataLogin"),be;try{pe&&(pe=JSON.parse(pe),be=pe.user)}catch{pe=null}if(oa&&yo[0]){const Ie=yo[0].webkitRelativePath.split("/")[0];Ie&&G.append("folderName",Ie)}G.append("prefix",v),Array.from(yo).forEach(Ie=>oa&&yo[0]?G.append("files",Ie,Ie.webkitRelativePath):G.append("files",Ie)),be!=null&&be.id&&G.append("metadata",JSON.stringify({creator:be.username,creatorId:be.id,DataSource:"Tệp tải lên"})),await Le.post(`${e}/api/upload`,G,{headers:{"Content-Type":"multipart/form-data"},timeout:0}),C(""),A(v),Yn.current=!0}}catch(G){console.error("Lỗi tải lên:",G);const pe=((M=(T=G==null?void 0:G.response)==null?void 0:T.data)==null?void 0:M.error)||"Không thể tải lên tập tin";X({title:"Lỗi",description:pe,variant:"destructive"})}finally{setTimeout(async()=>{oe(null),await un(),Qt(!1),ss(""),ra(null),await Vo("overwrite")},500)}},qr=async T=>{var M;try{if(await Le.delete(`${e}/api/files`,{data:{paths:[T.key]}}),w.has(T.key)){const pe=new Set(w);pe.delete(T.key),b(pe)}const G=((M=T.key)==null?void 0:M.replace(/^(.*?)(\/.*)?$/,(pe,be,Ie)=>!Ie||Ie==="/"?"":be+"/"))||"";A(G),Yn.current=!0,X({title:"Đã xóa tập tin",description:`Đã xóa thành công "${T.name}"`}),W(null),await Vo("delete")}catch(G){console.error("Error deleting file:",G),X({title:"Lỗi",description:"Không thể xóa tập tin",variant:"destructive"})}finally{Gr(!1),await un()}},xi=T=>{const M=new Set(w),G=typeof T=="function"?T(pa):T;new Set(Object.keys(pa).map(Number)).forEach(be=>{const Ie=Zt[be];Ie&&(G[be]||(M.delete(Ie.key),Ie.isFolder&&Su(Tn,Ie.key).forEach(Me=>M.delete(Me))))}),Object.entries(G).forEach(([be,Ie])=>{const Me=parseInt(be),jt=Zt[Me];jt&&Ie&&(M.add(jt.key),jt.isFolder&&Su(Tn,jt.key).forEach(Yr=>M.add(Yr)))}),b(M)},qm=async()=>{var T;q(!0);try{const M=Array.from(w),G=M.map(be=>Object.values(Tn).flat().find(Ie=>Ie.key===be)).filter(be=>be!==void 0);if(G.length===0){X({title:"Lỗi",description:"Không có tập tin nào được chọn để xóa",variant:"destructive"});return}await Le.delete(`${e}/api/files`,{data:{paths:M}});const pe=((T=G[0])==null?void 0:T.key.replace(/^(.*?)(\/.*)?$/,(be,Ie,Me)=>!Me||Me==="/"?"":Ie+"/"))||"";A(pe),Yn.current=!0,un(),X({title:"Đã xóa tập tin",description:`Đã xóa thành công ${G.length} mục`}),Y(!1),b(new Set),await Vo("bulk-delete")}catch(M){console.error("Error deleting files:",M),X({title:"Lỗi",description:"Không thể xóa các tập tin đã chọn",variant:"destructive"})}finally{q(!1)}},Wc=async(T,M)=>{if(!v.trim()){X({title:"Lỗi",description:"Không thể đổi tên tập tin hoặc thư mục ở thư mục gốc. Chỉ có thể xóa.",variant:"destructive"});return}Ne(!0);try{const G=T.key;let pe;T.isFolder?pe=G.split("/").slice(0,-2).join("/")+"/":pe=G.substring(0,G.lastIndexOf("/")+1);const be=pe+M+(T.isFolder?"/":"");await Le.post(`${e}/api/rename`,{oldPath:G,newPath:be}),Yn.current=!0,await un(),X({title:"Đã đổi tên",description:`Đã đổi tên thành công "${T.name}" thành "${M}"`}),te(null),z(""),Pe(null),await Vo("rename")}catch(G){console.error("Error renaming item:",G),X({title:"Lỗi",description:"Không thể đổi tên",variant:"destructive"})}finally{Ne(!1)}},Ym=async T=>{Ve(M=>new Set([...M,...T]));try{const M=await Le.post(`${e}/api/download`,{paths:T},{responseType:"blob"}),G=window.URL.createObjectURL(M.data),pe=document.createElement("a");pe.href=G;const be=M.headers["Content-Disposition"]||M.headers["content-disposition"],Ie=be==null?void 0:be.match(/filename="(.+)"/),Me=Ie?decodeURIComponent(Ie[1]):"download.zip";pe.setAttribute("download",Me),document.body.appendChild(pe),pe.click(),document.body.removeChild(pe),window.URL.revokeObjectURL(G),X({title:"Bắt đầu tải xuống",description:`Đã bắt đầu tải xuống ${T.length} mục${T.length>1,""}`})}catch(M){console.error("Error downloading files:",M),X({title:"Lỗi",description:"Không thể tải xuống tập tin",variant:"destructive"})}finally{Ve(M=>{const G=new Set(M);return T.forEach(pe=>G.delete(pe)),G})}},Xu=v?v.replace(n,"").split("/").filter(Boolean):[],Jm=()=>{let T=Array.from(w).map(G=>({key:G}));T.length>1&&(T=T.filter(G=>G.key!==n));const M=G=>Rd.findIndex(T,pe=>!pe.key.endsWith("/")&&pe.key.startsWith(G))!==-1;return T=T.filter(G=>G.key.endsWith("/")?!M(G.key):!0),T},qc=O.useMemo(()=>{const T=[...(Ht==null?void 0:Ht.role)!=="MASTER_ADMIN"&&(Ht==null?void 0:Ht.role)!=="SITE_ADMIN"&&(v===""||v==="/")?[]:[{id:"select",header:()=>{const M=$3(Tn,v),G=M.length>0&&M.every(be=>w.has(be)),pe=M.some(be=>w.has(be));return d.jsx(oc,{checked:G?!0:pe?"indeterminate":!1,onCheckedChange:be=>{if(be){const Ie=Zt.reduce((Me,jt,Yr)=>(Me[Yr]=!0,Me),{});xi(Ie)}else{for(const Ie of Array.from(w))Ie.startsWith(v)&&(w.delete(Ie),$o.current[Ie]=!1);Rd.forEach($o.current,(Ie,Me)=>{Me.startsWith(v)&&($o.current[Me]=!1)}),xi({})}},"aria-label":"Chọn tất cả"})},cell:({row:M})=>{const G=M.original;let be=G.isFolder?Qu(G.key):w.has(G.key)?"all":"none";if(be==="none"&&G.key.endsWith("/")){for(const Ie of Array.from(w))if(Ie.startsWith(G.key)){be="all";break}}return d.jsx("div",{className:"flex items-center",children:d.jsx(oc,{checked:be==="partial"?"indeterminate":be==="all",onCheckedChange:Ie=>{var jt,Yr;const Me={...pa};if(Ie?Me[M.index]=!0:delete Me[M.index],$o.current[((jt=M.original)==null?void 0:jt.key)||"_"]=!!Ie,(Yr=M.original)!=null&&Yr.key.endsWith("/"))for(const ma of Array.from(w))ma.startsWith(M.original.key)&&($o.current[M.original.key]=!1,w.delete(ma));xi(Me)},"aria-label":"Chọn dòng"})})},enableSorting:!1}],{id:"fileName",header:({column:M})=>d.jsxs(He,{variant:"ghost",onClick:()=>M.toggleSorting(M.getIsSorted()==="asc"),children:["Tên tập tin",d.jsx(rg,{})]}),accessorKey:"name",cell:({row:M})=>{const G=M.original,pe=G.key.substring(0,G.key.lastIndexOf("/"))||"/",be=g.trim()!==""&&pe!==v,Ie=pe.split("/").filter(Boolean);return d.jsxs("div",{className:"flex flex-col group",children:[d.jsxs("div",{className:"flex items-center",children:[d.jsxs("div",{className:`flex items-center gap-2 ${G.isFolder?"cursor-pointer hover:text-blue-600":""}`,onClick:()=>{G.isFolder&&Fn(G.key)},children:[G.isFolder?d.jsx(Ks,{className:"h-5 w-5 text-blue-500"}):null,G.name]}),d.jsx("button",{className:"ml-2 opacity-0 group-hover:opacity-100 transition-opacity",onClick:Me=>{Me.stopPropagation(),navigator.clipboard.writeText(G.key),X({title:"Copied to clipboard",description:`Path: ${G.key}`,duration:2e3})},title:"Copy path to clipboard",children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),d.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]}),be&&d.jsxs("div",{className:"text-sm text-gray-500 flex items-center",children:[d.jsx(Ks,{className:"h-4 w-4 text-gray-500 my-auto"}),d.jsxs("span",{className:"flex items-center ml-1",children:[d.jsx("span",{className:"cursor-pointer hover:text-blue-600",onClick:()=>{Fn("")},children:"/"}),Ie.map((Me,jt)=>d.jsxs("span",{className:"flex items-center",children:[d.jsx("span",{className:"cursor-pointer hover:text-blue-600",onClick:()=>{Fn(Ie.slice(0,jt+1).join("/")+"/")},children:Me}),jt<Ie.length-1&&d.jsx("span",{children:"/"})]},jt))]})]})]})}}];return o||T.push({id:"size",header:({column:M})=>d.jsxs(He,{variant:"ghost",onClick:()=>M.toggleSorting(M.getIsSorted()==="asc"),children:["Kích thước",d.jsx(rg,{})]}),accessorKey:"size",cell:({getValue:M,row:G})=>{const pe=M();return d.jsx("span",{children:G.original.isFolder?"-":Xt(pe)})}},{id:"lastModified",header:({column:M})=>d.jsxs(He,{variant:"ghost",onClick:()=>M.toggleSorting(M.getIsSorted()==="asc"),className:"px-0 w-full flex-row justify-end",children:["Sửa đổi lần cuối",d.jsx(rg,{})]}),accessorKey:"lastModified",cell:({row:M})=>{const G=M.original.lastModified;return d.jsx("div",{className:"w-full flex-row justify-end items-center text-right",children:d.jsx("span",{children:G&&Rx(G).isValid()?Rx(G).format("DD/MM/YYYY HH:mm"):"-"})})},size:200},{id:"actions",header:()=>d.jsx("span",{children:"Hành động"}),accessorKey:"key",cell:({row:M})=>d.jsxs("div",{className:"flex items-center gap-2",children:[v===""&&r&&d.jsx(gr,{children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsx(He,{variant:"ghost",size:"icon",onClick:()=>{Nu(M.original.key),Pu(!0)},className:"h-8 w-8 p-0",children:ne.has(M.original.key)?d.jsx(Pt,{className:"h-4 w-4 animate-spin"}):d.jsx(mO,{className:"h-4 w-4"})})}),d.jsx(sr,{children:"Những Flow sử dụng Folder này làm Data"})]})}),d.jsx(gr,{children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:!M.original.isFolder&&d.jsx(He,{variant:"ghost",size:"icon",onClick:()=>Ym([M.original.key]),className:"h-8 w-8 p-0",disabled:!z3(M.original.permission)||ne.has(M.original.key),children:ne.has(M.original.key)?d.jsx(Pt,{className:"h-4 w-4 animate-spin"}):d.jsx(fO,{className:"h-4 w-4"})})}),d.jsx(sr,{children:"Tải xuống"})]})}),v.trim()!==""&&(ea(M.original.permission)?d.jsx(gr,{children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsx(He,{variant:"ghost",size:"icon",onClick:()=>{te(M.original),z(M.original.name)},className:"h-8 w-8 p-0",disabled:!ea(M.original.permission),children:d.jsx(SO,{className:"h-4 w-4"})})}),d.jsx(sr,{children:"Đổi tên"})]})}):d.jsx(gr,{children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsx(He,{variant:"ghost",size:"icon",onClick:()=>{console.log("call"),ke(M.original)},className:"h-8 w-8 p-0",disabled:M.original.isFolder,children:d.jsx($x,{className:"h-4 w-4"})})}),d.jsx(sr,{children:"Xem"})]})})),d.jsx(gr,{children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsx(He,{variant:"ghost",size:"icon",onClick:()=>{Ae(!0),se(M.original)},className:"h-8 w-8 p-0",disabled:!ea(M.original.permission),children:d.jsx(zD,{className:"h-4 w-4"})})}),d.jsx(sr,{children:"Di chuyển"})]})}),!((Ht==null?void 0:Ht.role)!=="MASTER_ADMIN"&&(Ht==null?void 0:Ht.role)!=="SITE_ADMIN"&&(v===""||v==="/"))&&d.jsx(gr,{children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsx(He,{variant:"ghost",size:"icon",onClick:()=>W(M.original),className:"h-8 w-8 p-0",disabled:!ea(M.original.permission),children:d.jsx(RC,{className:"h-4 w-4"})})}),d.jsx(sr,{children:"Xóa"})]})}),d.jsx(gr,{children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsx(He,{variant:"ghost",size:"icon",onClick:()=>Ic(M.original),className:"h-8 w-8 p-0",disabled:!ea(M.original.permission),children:d.jsx(MC,{className:"h-4 w-4"})})}),d.jsx(sr,{children:"Chia sẻ"})]})})]})}),T},[w,Zt,pa,ne,o]),Si=Kb({data:Zt,columns:qc,state:{rowSelection:pa,sorting:h},onSortingChange:p,enableRowSelection:!0,onRowSelectionChange:xi,getCoreRowModel:Vb(),getSortedRowModel:WM()}),zo=async T=>{var M,G;bt(!0);try{if(Zi(T)){const pe=await Le.get(`${e}/api/read-text`,{params:{path:T.key}});Ct(pe.data.content)}try{const pe=await Le.get(`${e}/api/read-json`,{params:{path:T.key+".metadata.json"}}),be=((G=(M=pe==null?void 0:pe.data)==null?void 0:M.content)==null?void 0:G.metadataAttributes)||null;return Pe({fullPath:$==null?void 0:$.key,...be})}catch{return Pe("Lỗi phân tích siêu dữ liệu")}}catch(pe){console.error("Error loading file content:",pe),X({title:"Lỗi",description:"Không thể tải nội dung tập tin",variant:"destructive"})}finally{bt(!1)}},Qm=async(T,M)=>{zt(!0);try{await Le.post(`${e}/api/modify-text`,{path:T.key,content:M}),X({title:"Đã lưu tập tin",description:"Nội dung tập tin đã được cập nhật thành công"}),Yn.current=!0,await un(),te(null),Ct(""),Kt("rename"),await Vo("edit-content")}catch(G){console.error("Error saving file content:",G),X({title:"Lỗi",description:"Không thể lưu nội dung tập tin",variant:"destructive"})}finally{zt(!1)}},Zu=async T=>{zt(!0);try{await Le.post(`${e}/api/modify-json`,{path:T.key+".metadata.json",content:{metadataAttributes:xe}}),X({title:"Đã lưu tập tin",description:"Nội dung tập tin đã được cập nhật thành công"}),Yn.current=!0,await un(),te(null),Ct(""),Kt("rename")}catch(M){console.error("Error saving file content:",M),X({title:"Lỗi",description:"Không thể lưu nội dung tập tin",variant:"destructive"})}finally{zt(!1)}};O.useEffect(()=>{$&&($.isFolder||zo($),Kt("rename"))},[$]),O.useEffect(()=>{_e&&!_e.isFolder&&zo(_e)},[_e]);const Yc=async(T,M)=>{var G;if(Je){X({title:"Đang thu thập website",description:"Vui lòng đợi cho công việc thu thập hiện tại hoàn thành.",variant:"destructive"});return}Xe(!0);try{const{data:pe}=await Le.post(`${e}/api/crawl`,{url:T,limit:M,prefix:v});if(pe.id){_c({id:pe.id,url:T,limit:M,prefix:v,taskId:((G=pe.task)==null?void 0:G.id)||""});const be=localStorage.getItem(ZT),Ie=be?JSON.parse(be):[];Ie.some(Me=>Me.id===pe.id)||(Ie.unshift({url:T,id:pe.id,limit:M,prefix:v,timestamp:Date.now()}),Ie.length>20&&(Ie.length=20),localStorage.setItem(ZT,JSON.stringify(Ie))),X({title:"Bắt đầu thu thập website",description:`Đã thêm nhiệm vụ thu thập ${T} với giới hạn ${M}. Dữ liệu sẽ có sẵn sau khi thu thập hoàn tất.`}),J(!1),ae(""),he("1")}}catch(pe){console.error("Error crawling website:",pe),X({title:"Lỗi",description:"Không thể bắt đầu thu thập website",variant:"destructive"})}finally{Xe(!1)}},Jc=async()=>{try{if(!(Je!=null&&Je.id))return;_c(null),localStorage.removeItem(is),X({title:"Đã dừng thu thập",description:`Đã dừng thu thập website ${Je.url}`})}catch(T){console.error("Error stopping job:",T),X({title:"Lỗi",description:"Không thể dừng thu thập website",variant:"destructive"})}};O.useEffect(()=>{if(o)return;const T=(M=!0)=>{const pe=new URL(window.location.href).searchParams.get("prefix")||"";pe?Fn(pe,!1):(M&&!l&&b(new Set),A(n),x(n),Yn.current=!0,setTimeout(()=>{un()},0))};return T(!1),window.addEventListener("popstate",()=>T(!0)),()=>{window.removeEventListener("popstate",()=>T(!0))}},[]);const ws=async()=>{Ru(!0);try{await Le.post(`${e}/api/prediction-report`),X({title:"Xuất báo cáo thành công",description:"Báo cáo dự đoán đã được xuất"})}catch(T){console.error("Error exporting report:",T),X({title:"Lỗi",description:"Không thể xuất báo cáo dự đoán",variant:"destructive"})}finally{Ru(!1)}},ef=async()=>{try{const T=Gi();T&&(await Le.post(`${e}/api/start-ingestion-job`,{prefix:v,user_id:T.id,userName:T.username})).status===200&&await _i()}catch(T){xt(!1),console.log(T)}},Vo=async T=>{try{ds&&v.includes(ds)&&(console.log(`Auto syncing knowledge base after ${T} operation`),await _i())}catch(M){console.log(`Error auto syncing after ${T}:`,M)}},wr=O.useRef(),_i=async()=>{try{xt(!0);const T=await Le.post(`${e}/api/get-ingestion-job-status`,{prefix:v}),{status:M}=T==null?void 0:T.data;M==="FAILED"||M==="COMPLETE"||M==="STOPPED"||M==="STOPPING"||!M?(xt(!1),wr.current&&(clearInterval(wr.current),wr.current=null),kc(T==null?void 0:T.data)):(wr.current||(wr.current=setInterval(()=>_i(),5e3)),kc(T==null?void 0:T.data))}catch(T){console.log(T)}},Xm=()=>{const T=Array.from(w);let M;return v?M=T.filter(G=>G.startsWith(v)&&G!==v).length:M=new Set(T.filter(G=>G.split("/").shift())).size,`Đang chọn: ${M}`};return O.useEffect(()=>{const T=v==null?void 0:v.split("/")[0];return T!==ds&&(xt(!1),wr.current&&(clearInterval(wr.current),wr.current=null),Mm(T||""),kc(null),T&&_i()),()=>{}},[ds,v]),O.useEffect(()=>{wo&&Hc.length===0&&(It(),Wr(null))},[wo]),O.useEffect(()=>{if(l)for(const T of Array.from(l))$o.current[T]=!0},[]),d.jsxs("div",{className:"space-y-4 s3-explr-container",children:[d.jsx(s_,{}),d.jsx(or,{open:ku,onOpenChange:T=>{ia(T),T||(ss(""),ra(null),Qt(!1),oe(null))},children:d.jsxs(Kn,{children:[d.jsxs(Gn,{children:[d.jsx(jn,{children:"Cảnh báo trùng lặp"}),d.jsxs(gi,{children:[oa&&d.jsxs(d.Fragment,{children:["Folder $",oa," đã có."]}),yo&&yo.length>0&&d.jsxs(d.Fragment,{children:["Những tệp sau bị lặp:",d.jsx("ul",{className:"mt-2 list-disc pl-5 text-sm text-red-600",children:Array.from(yo).map((T,M)=>d.jsx("li",{children:T.name},M))})]})]})]}),d.jsxs(Lr,{children:[d.jsx(He,{variant:"outline",onClick:()=>{ia(!1),ss(""),ra(null),Qt(!1),oe(null)},children:"Bỏ qua"}),d.jsx(He,{variant:"destructive",onClick:()=>Lt(),children:"Ghi đè"})]})]})}),d.jsx(Fd,{className:"s3-explr-breadcrumb",children:d.jsxs($d,{className:"s3-explr-breadcrumb-list",children:[d.jsx(nc,{className:"s3-explr-breadcrumb-item",children:d.jsx(rc,{onClick:()=>Fn(n),className:"flex items-center gap-1 cursor-pointer s3-explr-breadcrumb-home",children:t})}),!u&&Xu.map((T,M)=>d.jsxs("div",{className:"flex items-center",children:[d.jsx(Hd,{className:"s3-explr-breadcrumb-separator"},`sep-${M}`),d.jsx(nc,{className:"s3-explr-breadcrumb-item",children:d.jsx(rc,{onClick:()=>Fn(n+Xu.slice(0,M+1).join("/")+"/"),className:"cursor-pointer s3-explr-breadcrumb-link",children:T})},`item-${T}`)]},M))]})}),d.jsxs("div",{className:"flex items-center space-x-4 s3-explr-toolbar",children:[d.jsx("div",{className:"relative max-w-sm w-full s3-explr-search-container",children:d.jsx(LH,{ref:Q,onChange:T=>C(T)})}),d.jsxs(He,{variant:"outline",size:"sm",onClick:()=>{A(v),Yn.current=!0,un()},disabled:Uo,className:"flex items-center gap-2 s3-explr-refresh-btn",children:[d.jsx(nd,{className:`h-4 w-4 s3-explr-refresh-icon ${Uo?"animate-spin":""}`}),"Làm mới"]}),v&&v!=="/"&&d.jsx(gr,{delayDuration:0,children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsxs(He,{variant:"outline",size:"sm",onClick:()=>{Uo||ft||(xt(!0),ef())},"aria-disabled":Uo||ft,className:"flex items-center gap-2 s3-explr-refresh-btn aria-disabled:opacity-50",children:[d.jsx(nd,{className:`h-4 w-4 s3-explr-refresh-icon ${Uo||ft?"animate-spin":""}`}),"Đồng bộ KB"]})}),Mt&&d.jsx(sr,{side:"right",sideOffset:5,children:d.jsxs("div",{className:"space-y-2 p-3 max-w-md",children:[d.jsx("p",{className:"font-semibold text-lg border-b pb-1",children:"Thông tin đồng bộ"}),d.jsx("div",{className:"space-y-1",children:d.jsxs("p",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"font-medium",children:"Trạng thái:"}),d.jsxs("span",{className:`flex items-center gap-1 font-semibold ${Mt.status==="COMPLETE"?"text-green-600":Mt.status==="FAILED"?"text-red-600":"text-yellow-600"}`,children:[Mt.status==="COMPLETE"&&d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),Mt.status==="FAILED"&&d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),Mt.status!=="COMPLETE"&&Mt.status!=="FAILED"&&d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 animate-spin",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),sL(Mt.status)]})]})}),Mt.statistics&&d.jsxs("div",{className:"space-y-1 border-t pt-2",children:[d.jsx("p",{className:"font-medium text-gray-50",children:"Thống kê xử lý:"}),d.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-sm",children:[d.jsxs("div",{className:"flex justify-between",children:[d.jsx("span",{children:"Tài liệu quét:"}),d.jsx("span",{className:"font-medium",children:Mt.statistics.numberOfDocumentsScanned})]}),d.jsxs("div",{className:"flex justify-between",children:[d.jsx("span",{children:"Metadata quét:"}),d.jsx("span",{className:"font-medium",children:Mt.statistics.numberOfMetadataDocumentsScanned})]}),d.jsxs("div",{className:"flex justify-between",children:[d.jsx("span",{children:"Tài liệu mới:"}),d.jsx("span",{className:"font-medium text-green-600",children:Mt.statistics.numberOfNewDocumentsIndexed})]}),d.jsxs("div",{className:"flex justify-between",children:[d.jsx("span",{children:"Tài liệu sửa:"}),d.jsx("span",{className:"font-medium text-blue-600",children:Mt.statistics.numberOfModifiedDocumentsIndexed})]}),d.jsxs("div",{className:"flex justify-between",children:[d.jsx("span",{children:"Metadata sửa:"}),d.jsx("span",{className:"font-medium text-blue-600",children:Mt.statistics.numberOfMetadataDocumentsModified})]}),d.jsxs("div",{className:"flex justify-between",children:[d.jsx("span",{children:"Tài liệu xóa:"}),d.jsx("span",{className:"font-medium text-orange-600",children:Mt.statistics.numberOfDocumentsDeleted})]}),d.jsxs("div",{className:"flex justify-between col-span-2",children:[d.jsx("span",{children:"Tài liệu lỗi:"}),d.jsx("span",{className:"font-medium text-red-600",children:Mt.statistics.numberOfDocumentsFailed})]})]})]}),d.jsxs("div",{className:"space-y-1 border-t pt-2 text-sm text-gray-200",children:[d.jsx("p",{className:"font-medium text-gray-50",children:"Chi tiết Job:"}),d.jsxs("p",{children:[d.jsx("span",{className:"font-medium",children:"DataSource ID:"})," ",Mt.dataSourceId]}),d.jsxs("p",{children:[d.jsx("span",{className:"font-medium",children:"Ingestion Job ID:"})," ",Mt.ingestionJobId]}),d.jsxs("p",{children:[d.jsx("span",{className:"font-medium",children:"Knowledge Base ID:"})," ",Mt.knowledgeBaseId]}),d.jsxs("p",{children:[d.jsx("span",{className:"font-medium",children:"Job trong queue:"})," ",Mt.is_still_in_stock?"Còn":"Không"]})]}),Mt.errorMessage&&d.jsxs("div",{className:"border-t pt-2",children:[d.jsx("p",{className:"text-red-600 font-medium",children:"Lỗi:"}),d.jsx("p",{className:"text-red-600 text-sm bg-red-50 p-2 rounded",children:Mt.errorMessage})]}),Mt.failureReasons&&Mt.failureReasons.length>0&&d.jsx($H,{failureReasons:Mt.failureReasons})]})})]})}),ea(Tn==null?void 0:Tn.prefixPermission)&&d.jsxs("div",{className:"relative",ref:zc,children:[d.jsxs(He,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-add-file-btn bg-[#1682fe] hover:bg-[#0f6cd4] text-white rounded-md px-4 py-2 transition-colors aria-disabled:hidden",onClick:()=>yr(T=>!T),"aria-disabled":(Ht==null?void 0:Ht.role)!=="MASTER_ADMIN"&&(Ht==null?void 0:Ht.role)!=="SITE_ADMIN"&&(v===""||v==="/"),children:[d.jsx(EO,{className:"w-4 h-4"}),"Add file"]}),Bc&&d.jsxs("div",{className:"absolute z-50 mt-2 right-0 w-56 bg-white border rounded-lg shadow-lg py-2 flex flex-col",children:[d.jsxs("button",{className:"flex items-center px-4 py-2 text-sm hover:bg-gray-100 text-left",onClick:()=>{yr(!1);const T=document.createElement("input");T.type="file",T.multiple=!0,T.onchange=M=>{const G=M.target.files;G&&ga(G,v,"files")},T.click()},children:[d.jsx(up,{className:"h-4 w-4 mr-2"})," Tải tệp tin"]}),d.jsxs("button",{className:"flex items-center px-4 py-2 text-sm hover:bg-gray-100 text-left",onClick:()=>{yr(!1);const T=document.createElement("input");T.type="file",T.multiple=!0,T.webkitdirectory=!0,T.onchange=M=>{const G=M.target.files;G&&ga(G,v,"folder")},T.click()},children:[d.jsx(Ks,{className:"h-4 w-4 mr-2"})," Tải lên thư mục"]}),d.jsxs("button",{className:"flex items-center px-4 py-2 text-sm hover:bg-gray-100 text-left",disabled:!!s&&!v,onClick:()=>P(!0),children:[d.jsx(yO,{className:"h-4 w-4 mr-2 s3-explr-folder-plus-icon"}),"Thư mục mới"]}),d.jsxs("button",{className:"flex items-center px-4 py-2 text-sm hover:bg-gray-100 text-left",onClick:()=>{yr(!1),J(!0)},children:[d.jsx(bO,{className:"h-4 w-4 mr-2"})," Thêm Website"]}),d.jsxs("button",{className:"flex items-center px-4 py-2 text-sm hover:bg-gray-100 text-left",onClick:()=>{yr(!1),Wu()},children:[d.jsxs("svg",{viewBox:"0 0 87.3 78",xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-2",children:[d.jsx("path",{d:"m6.6 66.85 3.85 6.65c.8 1.4 1.95 2.5 3.3 3.3l13.75-23.8h-27.5c0 1.55.4 3.1 1.2 4.5z",fill:"#0066da"}),d.jsx("path",{d:"m43.65 25-13.75-23.8c-1.35.8-2.5 1.9-3.3 3.3l-25.4 44a9.06 9.06 0 0 0 -1.2 4.5h27.5z",fill:"#00ac47"}),d.jsx("path",{d:"m73.55 76.8c1.35-.8 2.5-1.9 3.3-3.3l1.6-2.75 7.65-13.25c.8-1.4 1.2-2.95 1.2-4.5h-27.502l5.852 11.5z",fill:"#ea4335"}),d.jsx("path",{d:"m43.65 25 13.75-23.8c-1.35-.8-2.9-1.2-4.5-1.2h-18.5c-1.6 0-3.15.45-4.5 1.2z",fill:"#00832d"}),d.jsx("path",{d:"m59.8 53h-32.3l-13.75 23.8c1.35.8 2.9 1.2 4.5 1.2h50.8c1.6 0 3.15-.45 4.5-1.2z",fill:"#2684fc"}),d.jsx("path",{d:"m73.4 26.5-12.7-22c-.8-1.4-1.95-2.5-3.3-3.3l-13.75 23.8 16.15 28h27.45c0-1.55-.4-3.1-1.2-4.5z",fill:"#ffba00"})]})," ","Đồng bộ Google Drive"]}),d.jsxs("button",{className:"flex items-center px-4 py-2 text-sm hover:bg-gray-100 text-left",onClick:()=>{yr(!1),Bo()},children:[d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",className:"h-4 w-4 mr-2",children:[d.jsx("path",{fill:"#094ab2",d:"M47.3 28.2C45.3 18.6 37.1 12 28 12c-8.5 0-15.9 5.6-18.4 13.5C4.2 27.2 0 32.2 0 38c0 6.6 5.4 12 12 12h36c8.3 0 16-6.6 16-15.5 0-6.8-4.9-12.4-11.7-13.3z"}),d.jsx("path",{fill:"#0067c5",d:"M44.9 30.1c-.2 0-.4-.1-.6-.1H26c-3.3 0-6 2.7-6 6 0 .9.2 1.8.6 2.6-1.7-.7-3.5-1.1-5.5-1.1C7.6 37.5 4 41.5 4 46s3.6 8.5 8.1 8.5h34.3c6.8 0 12.6-5.4 12.6-12s-5.5-11.6-11.1-12.4z"})]})," ","Đồng bộ OneDrive"]}),d.jsxs("button",{className:"flex items-center px-4 py-2 text-sm hover:bg-gray-100 text-left",onClick:()=>{yr(!1),zm()},children:[d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",className:"h-4 w-4 mr-2",children:[d.jsx("path",{fill:"#036C70",d:"M19 14.5v-9c0-.28-.22-.5-.5-.5h-13c-.28 0-.5.22-.5.5v9c0 .28.22.5.5.5h13c.28 0 .5-.22.5-.5z"}),d.jsx("path",{fill:"#17828F",d:"M16 17.5v-9c0-.28-.22-.5-.5-.5h-13c-.28 0-.5.22-.5.5v9c0 .28.22.5.5.5h13c.28 0 .5-.22.5-.5z"}),d.jsx("path",{fill:"#4DB6AC",d:"M13 20.5v-9c0-.28-.22-.5-.5-.5h-13c-.28 0-.5.22-.5.5v9c0 .28.22.5.5.5h13c.28 0 .5-.22.5-.5z"}),d.jsx("path",{fill:"#fff",d:"M4.5 15.5v-3c0-.28.22-.5.5-.5h3c.28 0 .5.22.5.5v3c0 .28-.22.5-.5.5H5c-.28 0-.5-.22-.5-.5z"})]})," ","Đồng bộ SharePoint"]})]})]}),ea((Tn==null?void 0:Tn.prefixPermission)&&w.size>0)&&d.jsxs(He,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-add-file-btn bg-[#1682fe] hover:bg-[#0f6cd4] text-white rounded-md px-4 py-2 transition-colors aria-disabled:hidden",onClick:()=>Ic({contentType:"application/x-directory",isFolder:!0,key:"/",lastModified:"-",name:"",size:0}),children:[d.jsx(MC,{className:"w-4 h-4"}),"Chia sẻ"]}),!o&&d.jsxs(d.Fragment,{children:[w.size>0&&d.jsx(d.Fragment,{children:d.jsxs(or,{open:Z,onOpenChange:Y,children:[d.jsx(ic,{asChild:!0,children:d.jsxs(He,{variant:"destructive",size:"sm",className:"flex items-center gap-2 s3-explr-bulk-delete-btn",children:[d.jsx(RC,{className:"h-4 w-4 s3-explr-trash-icon"}),"Xóa đã chọn (",w.size,")"]})}),d.jsxs(Kn,{className:"s3-explr-dialog-content",children:[d.jsxs(Gn,{className:"s3-explr-dialog-header",children:[d.jsx(jn,{className:"s3-explr-dialog-title",children:"Xác nhận xóa hàng loạt"}),d.jsxs(gi,{className:"s3-explr-dialog-description",children:["Bạn có chắc chắn muốn xóa ",w.size," mục đã chọn? Hành động này không thể hoàn tác."]})]}),d.jsxs(Lr,{className:"s3-explr-dialog-footer",children:[d.jsx(He,{variant:"outline",onClick:()=>Y(!1),className:"s3-explr-cancel-btn",children:"Hủy"}),d.jsx(He,{variant:"destructive",onClick:qm,disabled:fe,className:"s3-explr-confirm-delete-btn",children:fe?d.jsxs(d.Fragment,{children:[d.jsx(Pt,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang xóa..."]}):"Xóa đã chọn"})]})]})]})}),!u&&d.jsxs(or,{open:N,onOpenChange:P,children:[d.jsx(ic,{asChild:!0}),d.jsxs(Kn,{className:"s3-explr-dialog-content",children:[d.jsx(Gn,{className:"s3-explr-dialog-header",children:d.jsx(jn,{className:"s3-explr-dialog-title",children:"Tạo thư mục mới"})}),d.jsxs("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:[d.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[d.jsx(pr,{htmlFor:"name",className:"s3-explr-label",children:"Tên thư mục"}),d.jsx(Wn,{disabled:H,id:"name",value:_,onChange:T=>D(T.target.value),placeholder:"Nhập tên thư mục",className:"s3-explr-input"})]}),d.jsxs(He,{onClick:()=>{_.trim()&&ys(_,v)},disabled:H,className:"s3-explr-create-btn",children:[H&&d.jsx(Pt,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),H?"Đang tạo...":"Tạo"]})]})]})]}),u&&!v?d.jsx(d.Fragment,{}):d.jsxs("div",{className:"flex items-center gap-2 s3-explr-upload-group",children:[Je?d.jsx(gr,{delayDuration:0,children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(He,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-add-website-btn",disabled:!0,children:[d.jsx(Pt,{className:"h-4 w-4 animate-spin s3-explr-loader"}),Je.status?d.jsxs(d.Fragment,{children:[Je.status.isProcessing?"Đang thu thập ":"Đang quét sitemap ","(",Je.status.completed,"/",Je.status.total,") -"," ",Math.floor(Fo/60),":",String(Fo%60).padStart(2,"0")]}):"Đang thu thập..."]}),d.jsxs(He,{variant:"destructive",size:"sm",onClick:()=>void Jc(),className:"flex items-center gap-2",children:[d.jsx("span",{className:"sr-only",children:"Dừng thu thập"}),d.jsx(IO,{className:"h-4 w-4"})]})]})}),Je.status&&d.jsx(sr,{side:"right",sideOffset:5,children:d.jsxs("div",{className:"space-y-1 p-2",children:[d.jsxs("p",{className:"font-semibold",children:["Đang thu thập ",Je==null?void 0:Je.url]}),d.jsxs("p",{children:["Tiến độ: ",Je==null?void 0:Je.status.completed,"/",Je==null?void 0:Je.status.total," ","trang"]}),d.jsxs("p",{children:["Thời gian: ",Math.floor(Fo/60),":",String(Fo%60).padStart(2,"0")]}),d.jsxs("p",{children:["Trạng thái:"," ",(Je==null?void 0:Je.status.status)==="scraping"?"Đang thu thập":(Je==null?void 0:Je.status.status)==="completed"?"Hoàn thành":"Thất bại"]})]})})]})}):!u&&d.jsxs(or,{open:L,onOpenChange:J,children:[d.jsx(ic,{asChild:!0}),d.jsxs(Kn,{className:"s3-explr-dialog-content",children:[d.jsxs(Gn,{className:"s3-explr-dialog-header",children:[d.jsx(jn,{className:"s3-explr-dialog-title",children:"Thêm website"}),d.jsx(gi,{className:"s3-explr-dialog-description",children:"Nhập URL website để thu thập và thêm vào S3."})]}),d.jsxs("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:[d.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[d.jsx(pr,{htmlFor:"websiteUrl",className:"s3-explr-label",children:"URL Website"}),d.jsx(Wn,{id:"websiteUrl",value:U,onChange:T=>ae(T.target.value),placeholder:"https://example.com",type:"url",disabled:Ee,className:"s3-explr-input"})]}),d.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[d.jsx(pr,{htmlFor:"crawlLimit",className:"s3-explr-label",children:"Giới hạn thu thập"}),d.jsx(Wn,{id:"crawlLimit",value:ye,onChange:T=>{const M=T.target.value;/^\d*$/.test(M)&&he(M)},placeholder:"1",type:"text",disabled:Ee,className:"s3-explr-input"}),d.jsx("p",{className:"text-sm text-gray-500",children:"Số lượng liên kết cần thu thập (mặc định: 1)"})]})]}),d.jsxs(Lr,{className:"s3-explr-dialog-footer",children:[d.jsx(He,{variant:"outline",onClick:()=>{J(!1),ae(""),he("1")},disabled:Ee,className:"s3-explr-cancel-btn",children:"Hủy"}),d.jsx(He,{onClick:()=>{U.trim()&&Yc(U.trim(),parseInt(ye)||1)},disabled:Ee||!U.trim(),className:"s3-explr-crawl-btn",children:Ee?d.jsxs(d.Fragment,{children:[d.jsx(Pt,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang thu thập..."]}):"Bắt đầu thu thập"})]})]})]}),v.startsWith("BKTTW/")&&d.jsx(gr,{delayDuration:0,children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsxs(He,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-add-website-btn",disabled:!!s&&!v,onClick:ws,children:[aa&&d.jsx(nd,{className:`h-4 w-4 s3-explr-refresh-icon ${aa?"animate-spin":""}`}),"Xuất báo cáo"]})}),(Je==null?void 0:Je.status)&&d.jsx(sr,{side:"right",sideOffset:5,children:d.jsxs("div",{className:"space-y-1 p-2",children:[d.jsxs("p",{className:"font-semibold",children:["Đang thu thập ",Je.url]}),d.jsxs("p",{children:["Tiến độ: ",Je.status.completed,"/",Je.status.total," ","trang"]}),d.jsxs("p",{children:["Thời gian: ",Math.floor(Fo/60),":",String(Fo%60).padStart(2,"0")]}),d.jsxs("p",{children:["Trạng thái:"," ",Je.status.status==="scraping"?"Đang thu thập":Je.status.status==="completed"?"Hoàn thành":"Thất bại"]})]})})]})}),d.jsxs(or,{open:L,onOpenChange:J,children:[d.jsx(ic,{asChild:!0}),d.jsxs(Kn,{className:"s3-explr-dialog-content",children:[d.jsxs(Gn,{className:"s3-explr-dialog-header",children:[d.jsx(jn,{className:"s3-explr-dialog-title",children:"Thêm website"}),d.jsx(gi,{className:"s3-explr-dialog-description",children:"Nhập URL website để thu thập và thêm vào S3."})]}),d.jsxs("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:[d.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[d.jsx(pr,{htmlFor:"websiteUrl",className:"s3-explr-label",children:"URL Website"}),d.jsx(Wn,{id:"websiteUrl",value:U,onChange:T=>ae(T.target.value),placeholder:"https://example.com",type:"url",disabled:Ee,className:"s3-explr-input"})]}),d.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[d.jsx(pr,{htmlFor:"crawlLimit",className:"s3-explr-label",children:"Giới hạn thu thập"}),d.jsx(Wn,{id:"crawlLimit",value:ye,onChange:T=>{const M=T.target.value;/^\d*$/.test(M)&&he(M)},placeholder:"1",type:"text",disabled:Ee,className:"s3-explr-input"}),d.jsx("p",{className:"text-sm text-gray-500",children:"Số lượng liên kết cần thu thập (mặc định: 1)"})]})]}),d.jsxs(Lr,{className:"s3-explr-dialog-footer",children:[d.jsx(He,{variant:"outline",onClick:()=>{J(!1),ae(""),he("1")},disabled:Ee,className:"s3-explr-cancel-btn",children:"Hủy"}),d.jsx(He,{onClick:()=>{U.trim()&&Yc(U.trim(),parseInt(ye)||1)},disabled:Ee||!U.trim(),className:"s3-explr-crawl-btn",children:Ee?d.jsxs(d.Fragment,{children:[d.jsx(Pt,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang thu thập..."]}):"Bắt đầu thu thập"})]})]})]})]}),v.startsWith("BKTTW/")&&d.jsx(gr,{delayDuration:0,children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsxs(He,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-add-website-btn",disabled:!!s&&!v,onClick:ws,children:[aa&&d.jsx(nd,{className:`h-4 w-4 s3-explr-refresh-icon ${aa?"animate-spin":""}`}),"Xuất báo cáo"]})}),aa&&d.jsx(sr,{sideOffset:5,children:"Đang xuất báo cáo"})]})}),d.jsxs("div",{className:"flex items-center gap-4",children:[sa&&d.jsxs(Gs,{open:sa,onOpenChange:us,children:[d.jsx(Ga,{className:"fixed inset-0 bg-black bg-opacity-50 z-50"}),d.jsxs(ja,{className:"fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-white p-6 rounded-lg shadow-lg w-[700px] max-w-[90vw] max-h-[80vh] z-50 flex flex-col",children:[d.jsxs("div",{className:"relative",children:[d.jsx(Ep,{asChild:!0,children:d.jsx("button",{className:"absolute top-2 right-2 text-gray-600",onClick:jc,children:"✖"})}),d.jsx("h2",{className:"text-lg font-semibold",children:"My OneDrive"}),d.jsx(Fd,{className:"onedrive-breadcrumb",children:d.jsx($d,{className:"onedrive-breadcrumb-list",children:ca.map((T,M)=>d.jsxs("div",{className:"flex items-center",children:[M>0&&d.jsx(Hd,{className:"onedrive-breadcrumb-separator"}),d.jsx(nc,{className:"onedrive-breadcrumb-item",children:d.jsx(rc,{onClick:()=>Gu(M),className:"cursor-pointer onedrive-breadcrumb-link",children:T.name})})]},M))})})]}),d.jsx("div",{className:"space-y-2 mt-4 flex-1 overflow-y-auto",children:Lm?d.jsx("div",{className:"text-sm text-gray-500",children:"Đang tải nội dung thư mục... Vui lòng đợi."}):d.jsx(d.Fragment,{children:[...Du,...Oc].length>0?[...Du,...Oc].map(T=>d.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg hover:bg-gray-100 ${hs.some(M=>M.id===T.id)?"bg-blue-100":""}`,children:[d.jsx("input",{type:"checkbox",checked:hs.some(M=>M.id===T.id),onChange:M=>{M.stopPropagation(),Vu(T)},className:"cursor-pointer"}),T.isFolder?d.jsx(Ks,{className:"text-blue-500 w-5 h-5 cursor-pointer",onClick:()=>wn(T.id,T.name)}):d.jsx(up,{className:"text-gray-500 w-5 h-5"}),d.jsxs("div",{className:"flex-1",children:[d.jsx("div",{className:`font-medium ${T.isFolder?"cursor-pointer text-blue-600":""}`,onClick:()=>{T.isFolder?wn(T.id,T.name):Vu(T)},children:T.name}),!T.isFolder&&d.jsxs("div",{className:"text-xs text-gray-500",children:[Xt(T.size)," •"," ",Kc(T.lastModified.toISOString())]})]})]},T.id)):d.jsx("div",{className:"text-sm text-gray-500",children:"Không có thư mục hoặc tệp nào."})})}),d.jsx("div",{className:"mt-4 flex flex-wrap justify-end gap-2",children:d.jsx(He,{onClick:()=>{ju(hs,v),jc()},className:"bg-[#1682fe] hover:bg-[#0f6cd4] text-white rounded-md px-4 py-2 transition-colors",disabled:hs.length===0,children:"Đồng bộ"})}),d.jsx("button",{onClick:()=>fa(!0),className:"absolute bottom-4 left-4 text-gray-600 hover:text-gray-800",title:"Đăng xuất OneDrive",children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),d.jsx("polyline",{points:"16 17 21 12 16 7"}),d.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]})})]})]}),d.jsxs(Gs,{open:Fm,onOpenChange:fa,children:[d.jsx(Ga,{className:"fixed inset-0 bg-black bg-opacity-50 z-[60]"}),d.jsxs(ja,{className:"fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-white p-6 rounded-lg shadow-lg w-[400px] max-w-[90vw] z-[60]",children:[d.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Xác nhận đăng xuất"}),d.jsx("p",{className:"text-gray-600 mb-6",children:"Bạn có chắc chắn muốn đăng xuất khỏi OneDrive?"}),d.jsxs("div",{className:"flex justify-end gap-2",children:[d.jsx(He,{variant:"outline",onClick:()=>fa(!1),children:"Hủy"}),d.jsx(He,{variant:"destructive",onClick:()=>{Ku(),fa(!1)},children:"Đăng xuất"})]})]})]}),wo&&d.jsxs(Gs,{open:wo,onOpenChange:da,children:[d.jsx(Ga,{className:"fixed inset-0 bg-black bg-opacity-50 z-50"}),d.jsxs(ja,{className:"fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-white p-6 rounded-lg shadow-lg w-[700px] max-w-[90vw] max-h-[80vh] z-50 flex flex-col",children:[d.jsxs("div",{className:"relative",children:[d.jsx(Ep,{asChild:!0,children:d.jsx("button",{className:"absolute top-2 right-2 text-gray-600",onClick:Bu,children:"✖"})}),d.jsxs("div",{className:"flex items-center gap-2",children:[gt&&d.jsx("button",{onClick:()=>Wr(null),className:"text-gray-600 hover:text-gray-800",children:d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),d.jsx("h2",{className:"text-lg font-semibold",children:"My SharePoint"})]}),gt&&d.jsx(Fd,{className:"sharepoint-breadcrumb",children:d.jsx($d,{className:"sharepoint-breadcrumb-list",children:$c.map((T,M)=>d.jsxs("div",{className:"flex items-center",children:[M>0&&d.jsx(Hd,{className:"sharepoint-breadcrumb-separator"}),d.jsx(nc,{className:"sharepoint-breadcrumb-item",children:d.jsx(rc,{onClick:()=>jm(M),className:"cursor-pointer sharepoint-breadcrumb-link",children:T.name})})]},M))})})]}),d.jsx("div",{className:"space-y-2 mt-4 flex-1 overflow-y-auto",children:Fu?d.jsx("div",{className:"text-sm text-gray-500",children:"Đang tải nội dung thư mục... Vui lòng đợi."}):gt?[...Fc,...ps].length===0?d.jsx("div",{className:"text-sm text-gray-500",children:"Không có thư mục hoặc tệp nào."}):[...Fc,...ps].map(T=>{const M=ms.some(G=>G.id===T.id);return d.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg hover:bg-gray-100 ${M?"bg-blue-100":""}`,children:[d.jsx("input",{type:"checkbox",checked:M,onChange:G=>{G.stopPropagation(),Gm(T)},className:"cursor-pointer"}),T.isFolder?d.jsx(Ks,{className:"text-blue-500 w-5 h-5 cursor-pointer",onClick:()=>vs(T.id,T.name,(gt==null?void 0:gt.hostname)||"",(gt==null?void 0:gt.sitePath)||"")}):d.jsx(up,{className:"text-gray-500 w-5 h-5"}),d.jsxs("div",{className:"flex-1",children:[d.jsx("div",{className:`font-medium ${T.isFolder?"cursor-pointer text-blue-600":""}`,onClick:()=>{T.isFolder&&vs(T.id,T.name,(gt==null?void 0:gt.hostname)||"",(gt==null?void 0:gt.sitePath)||"")},children:T.name}),!T.isFolder&&d.jsxs("div",{className:"text-xs text-gray-500",children:[Xt(T.size)," •"," ",T.lastModified.toLocaleString()]})]})]},T.id)}):d.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-6",children:Hc.map(T=>d.jsxs("div",{className:"cursor-pointer bg-white shadow-md rounded-xl p-5 flex flex-col justify-center items-start transition-shadow duration-200 hover:shadow-lg border border-gray-100 min-h-[120px]",style:{overflow:"hidden",wordBreak:"break-word",textOverflow:"ellipsis",whiteSpace:"normal"},onClick:()=>Km(T),children:[d.jsx("div",{className:"font-bold text-lg mb-1 truncate w-full",title:T.name,children:T.name}),d.jsx("div",{className:"text-sm text-gray-500 truncate w-full",title:T.description,children:T.description})]},T.id))})}),d.jsx("div",{className:"mt-4 flex flex-wrap justify-end gap-2",children:gt&&d.jsxs(d.Fragment,{children:[d.jsx(He,{onClick:()=>{Wm(ms,v),Bu()},className:"bg-[#1682fe] hover:bg-[#0f6cd4] text-white rounded-md px-4 py-2 transition-colors",disabled:ms.length===0,children:"Đồng bộ"}),d.jsx(He,{onClick:()=>Wr(null),children:"Quay lại"})]})}),d.jsx("button",{onClick:()=>ua(!0),className:"absolute bottom-4 left-4 text-gray-600 hover:text-gray-800",title:"Đăng xuất SharePoint",children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),d.jsx("polyline",{points:"16 17 21 12 16 7"}),d.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]})})]})]}),d.jsxs(Gs,{open:Hu,onOpenChange:ua,children:[d.jsx(Ga,{className:"fixed inset-0 bg-black bg-opacity-50 z-[60]"}),d.jsxs(ja,{className:"fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-white p-6 rounded-lg shadow-lg w-[400px] max-w-[90vw] z-[60]",children:[d.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Xác nhận đăng xuất"}),d.jsx("p",{className:"text-gray-600 mb-6",children:"Bạn có chắc chắn muốn đăng xuất khỏi SharePoint?"}),d.jsxs("div",{className:"flex justify-end gap-2",children:[d.jsx(He,{variant:"outline",onClick:()=>ua(!1),children:"Hủy"}),d.jsx(He,{variant:"destructive",onClick:()=>{Vm(),ua(!1)},children:"Đăng xuất"})]})]})]})]}),d.jsx(or,{open:!!Ec,onOpenChange:T=>{T||(Pu(!1),Mu([]),Nu(""))},children:d.jsxs(Kn,{className:"max-h-[700px] pb-3 px-1 s3-explr-input-group max-w-5xl w-[90%] p-6 bg-white rounded-lg shadow-lg",children:[d.jsxs(Gn,{className:"s3-explr-dialog-header",children:[d.jsx(jn,{className:"s3-explr-dialog-title",children:d.jsxs("h3",{className:"font-medium mb-2",children:["Danh sách flows đang sử dụng dữ liệu từ folder(",d.jsx("span",{className:"font-bold",children:cs}),"):"," "]})}),d.jsx(gi,{className:"s3-explr-dialog-description",children:Tc?d.jsxs("div",{className:"flex items-center justify-center py-4",children:[d.jsx(Pt,{className:"h-6 w-6 animate-spin"}),d.jsx("span",{className:"ml-2",children:"Đang tải thông tin flows..."})]}):d.jsx("div",{children:ls&&Array.isArray(ls)&&ls.length>0?d.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:d.jsxs("table",{className:"w-full border-collapse",children:[d.jsx("thead",{children:d.jsxs("tr",{className:"bg-gray-100",children:[d.jsx("th",{className:"border border-gray-300 px-4 py-2 text-left",children:"Tên Flow"}),d.jsx("th",{className:"border border-gray-300 px-4 py-2 text-left",children:"KnowledgeBase Id"}),d.jsx("th",{className:"border border-gray-300 px-4 py-2 text-left",children:"Loại"}),d.jsx("th",{className:"border border-gray-300 px-4 py-2 text-left",children:"Ngày tạo"})]})}),d.jsx("tbody",{children:ls.map((T,M)=>d.jsxs("tr",{className:M%2===0?"bg-white":"bg-gray-50",children:[d.jsx("td",{className:"border border-gray-300 px-4 py-2",children:T.name}),d.jsx("td",{className:"border border-gray-300 px-4 py-2",children:T.KnowledgeBaseId}),d.jsx("td",{className:"border border-gray-300 px-4 py-2",children:T.type==="MULTIAGENT"?"Agent Flow":"Chat Flow"}),d.jsx("td",{className:"border border-gray-300 px-4 py-2",children:T.createdDate?new Date(T.createdDate).toLocaleString("vi-VN"):"N/A"})]},M))})]})}):d.jsx("div",{className:"text-gray-500 italic py-2",children:"Không có flow nào sử dụng dữ liệu từ folder này"})})})]}),d.jsxs(Lr,{className:"s3-explr-dialog-footer",children:[d.jsx(He,{variant:"outline",onClick:()=>W(null),className:"s3-explr-cancel-btn",children:"Hủy"}),d.jsx(He,{variant:"destructive",onClick:()=>qr(ee),disabled:yn,className:"s3-explr-confirm-delete-btn",children:yn?d.jsxs(d.Fragment,{children:[d.jsx(Pt,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang xóa..."]}):"Xóa"})]})]})}),d.jsx(or,{open:!!ee,onOpenChange:T=>!T&&W(null),children:d.jsxs(Kn,{className:"s3-explr-dialog-content",children:[d.jsxs(Gn,{className:"s3-explr-dialog-header",children:[d.jsx(jn,{className:"s3-explr-dialog-title",children:"Xác nhận xóa"}),d.jsxs(gi,{className:"s3-explr-dialog-description",children:["Bạn có chắc chắn muốn xóa ",ee==null?void 0:ee.name,"? Hành động này không thể hoàn tác."]})]}),d.jsxs(Lr,{className:"s3-explr-dialog-footer",children:[d.jsx(He,{variant:"outline",onClick:()=>W(null),className:"s3-explr-cancel-btn",children:"Hủy"}),d.jsx(He,{variant:"destructive",onClick:()=>qr(ee),disabled:yn,className:"s3-explr-confirm-delete-btn",children:yn?d.jsxs(d.Fragment,{children:[d.jsx(Pt,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang xóa..."]}):"Xóa"})]})]})}),d.jsx(or,{open:!!$,onOpenChange:T=>{T||(te(null),Pe(null),z(""),Ct(""),Kt("rename"))},children:d.jsxs(Kn,{className:"s3-explr-dialog-content max-w-5xl w-[90%]",children:[d.jsx(Gn,{className:"s3-explr-dialog-header",children:d.jsx(jn,{className:"s3-explr-dialog-title",children:$!=null&&$.isFolder?"Đổi tên thư mục":Zi($)?"Quản lý tập tin":"Đổi tên tập tin"})}),$&&d.jsxs(Cg,{value:Dn,onValueChange:T=>Kt(T),children:[d.jsxs(Jd,{"aria-checked":!Zi($),"aria-disabled":$.isFolder,className:"grid w-full grid-cols-3 aria-checked:grid-cols-2 aria-disabled:grid-cols-1",children:[d.jsx(ji,{value:"rename",children:"Đổi tên"}),!$.isFolder&&d.jsxs(d.Fragment,{children:[Zi($)&&d.jsx(ji,{value:"edit",children:"Sửa nội dung"}),d.jsx(ji,{value:"edit-metadata",children:"Sửa metadata file"})]})]}),d.jsx(Wi,{value:"rename",children:d.jsx("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:d.jsxs("div",{className:"h-[70dvh] min-h-[500px] overflow-hidden overflow-y-auto pb-3 px-1 s3-explr-input-group",children:[d.jsx(pr,{htmlFor:"newName",className:"s3-explr-label",children:"Tên mới"}),d.jsx(Wn,{id:"newName",value:Te,onChange:T=>z(T.target.value),placeholder:"Nhập tên mới",disabled:Ce,className:"s3-explr-input"})]})})}),!$.isFolder&&d.jsxs(d.Fragment,{children:[Zi($)&&d.jsx(Wi,{value:"edit",children:d.jsx("div",{className:"space-y-4 py-4",children:Jt?d.jsx("div",{className:"flex items-center justify-center py-10",children:d.jsx(Pt,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):d.jsxs("div",{className:"max-h-[70dvh] overflow-auto rounded-md border px-4 py-3 bg-muted/30",children:[d.jsx(pr,{htmlFor:"content",className:"block text-sm font-medium mb-2 text-muted-foreground",children:"Nội dung tập tin"}),d.jsx(sc,{id:"content",value:Qe,onChange:T=>Ct(T.target.value),placeholder:"Nhập nội dung tập tin",className:"font-mono text-sm resize-none min-h-[200px] w-full",disabled:an,style:{height:"auto",maxHeight:"60vh"},rows:Math.max(10,Qe.split(`
|
|
222
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function VE(t,e){if(t){if(typeof t=="string")return cm(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return cm(t,e)}}function cm(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function FU(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r=[],o=!0,i=!1,s,l;try{for(n=n.call(t);!(o=(s=n.next()).done)&&(r.push(s.value),!(e&&r.length===e));o=!0);}catch(u){i=!0,l=u}finally{try{!o&&n.return!=null&&n.return()}finally{if(i)throw l}}return r}}function $U(t){if(Array.isArray(t))return t}function KE(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Bt(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?KE(Object(n),!0).forEach(function(r){lm(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):KE(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function lm(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mu(t,e){if(t==null)return{};var n=HU(t,e),r,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)r=i[o],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}function HU(t,e){if(t==null)return{};var n={},r=Object.keys(t),o,i;for(i=0;i<r.length;i++)o=r[i],!(e.indexOf(o)>=0)&&(n[o]=t[o]);return n}var dm=O.forwardRef(function(t,e){var n=t.children,r=mu(t,IU),o=jE(r),i=o.open,s=mu(o,kU);return O.useImperativeHandle(e,function(){return{open:i}},[i]),O.createElement(O.Fragment,null,n(Bt(Bt({},s),{},{open:i})))});dm.displayName="Dropzone";var GE={disabled:!1,getFilesFromEvent:QH,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};dm.defaultProps=GE,dm.propTypes={children:Ot.func,accept:Ot.objectOf(Ot.arrayOf(Ot.string)),multiple:Ot.bool,preventDropOnDocument:Ot.bool,noClick:Ot.bool,noKeyboard:Ot.bool,noDrag:Ot.bool,noDragEventsBubbling:Ot.bool,minSize:Ot.number,maxSize:Ot.number,maxFiles:Ot.number,disabled:Ot.bool,getFilesFromEvent:Ot.func,onFileDialogCancel:Ot.func,onFileDialogOpen:Ot.func,useFsAccessApi:Ot.bool,autoFocus:Ot.bool,onDragEnter:Ot.func,onDragLeave:Ot.func,onDragOver:Ot.func,onDrop:Ot.func,onDropAccepted:Ot.func,onDropRejected:Ot.func,onError:Ot.func,validator:Ot.func};var um={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function jE(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=Bt(Bt({},GE),t),n=e.accept,r=e.disabled,o=e.getFilesFromEvent,i=e.maxSize,s=e.minSize,l=e.multiple,u=e.maxFiles,h=e.onDragEnter,p=e.onDragLeave,g=e.onDragOver,C=e.onDrop,w=e.onDropAccepted,b=e.onDropRejected,v=e.onFileDialogCancel,x=e.onFileDialogOpen,E=e.useFsAccessApi,A=e.autoFocus,N=e.preventDropOnDocument,P=e.noClick,_=e.noKeyboard,D=e.noDrag,H=e.noDragEventsBubbling,K=e.onError,ee=e.validator,W=O.useMemo(function(){return EU(n)},[n]),de=O.useMemo(function(){return _U(n)},[n]),se=O.useMemo(function(){return typeof x=="function"?x:WE},[x]),fe=O.useMemo(function(){return typeof v=="function"?v:WE},[v]),q=O.useRef(null),Z=O.useRef(null),Y=O.useReducer(UU,um),oe=sm(Y,2),Q=oe[0],X=oe[1],$=Q.isFocused,te=Q.isFileDialogActive,_e=O.useRef(typeof window<"u"&&window.isSecureContext&&E&&SU()),ke=function(){!_e.current&&te&&setTimeout(function(){if(Z.current){var ae=Z.current.files;ae.length||(X({type:"closeDialog"}),fe())}},300)};O.useEffect(function(){return window.addEventListener("focus",ke,!1),function(){window.removeEventListener("focus",ke,!1)}},[Z,te,fe,_e]);var xe=O.useRef([]),Pe=function(ae){q.current&&q.current.contains(ae.target)||(ae.preventDefault(),xe.current=[])};O.useEffect(function(){return N&&(document.addEventListener("dragover",UE,!1),document.addEventListener("drop",Pe,!1)),function(){N&&(document.removeEventListener("dragover",UE),document.removeEventListener("drop",Pe))}},[q,N]),O.useEffect(function(){return!r&&A&&q.current&&q.current.focus(),function(){}},[q,A,r]);var Te=O.useCallback(function(U){K?K(U):console.error(U)},[K]),z=O.useCallback(function(U){U.preventDefault(),U.persist(),Dn(U),xe.current=[].concat(OU(xe.current),[U.target]),gu(U)&&Promise.resolve(o(U)).then(function(ae){if(!(pu(U)&&!H)){var ye=ae.length,he=ye>0&&wU({files:ae,accept:W,minSize:s,maxSize:i,multiple:l,maxFiles:u,validator:ee}),Ee=ye>0&&!he;X({isDragAccept:he,isDragReject:Ee,isDragActive:!0,type:"setDraggedFiles"}),h&&h(U)}}).catch(function(ae){return Te(ae)})},[o,h,Te,H,W,s,i,l,u,ee]),ce=O.useCallback(function(U){U.preventDefault(),U.persist(),Dn(U);var ae=gu(U);if(ae&&U.dataTransfer)try{U.dataTransfer.dropEffect="copy"}catch{}return ae&&g&&g(U),!1},[g,H]),Ae=O.useCallback(function(U){U.preventDefault(),U.persist(),Dn(U);var ae=xe.current.filter(function(he){return q.current&&q.current.contains(he)}),ye=ae.indexOf(U.target);ye!==-1&&ae.splice(ye,1),xe.current=ae,!(ae.length>0)&&(X({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),gu(U)&&p&&p(U))},[q,p,H]),Ce=O.useCallback(function(U,ae){var ye=[],he=[];U.forEach(function(Ee){var Xe=$E(Ee,W),ft=sm(Xe,2),xt=ft[0],vo=ft[1],Qt=HE(Ee,s,i),yn=sm(Qt,2),Gr=yn[0],Gt=yn[1],cr=ee?ee(Ee):null;if(xt&&Gr&&!cr)ye.push(Ee);else{var jr=[vo,Gt];cr&&(jr=jr.concat(cr)),he.push({file:Ee,errors:jr.filter(function(na){return na})})}}),(!l&&ye.length>1||l&&u>=1&&ye.length>u)&&(ye.forEach(function(Ee){he.push({file:Ee,errors:[yU]})}),ye.splice(0)),X({acceptedFiles:ye,fileRejections:he,isDragReject:he.length>0,type:"setFiles"}),C&&C(ye,he,ae),he.length>0&&b&&b(he,ae),ye.length>0&&w&&w(ye,ae)},[X,l,W,s,i,u,C,w,b,ee]),Ne=O.useCallback(function(U){U.preventDefault(),U.persist(),Dn(U),xe.current=[],gu(U)&&Promise.resolve(o(U)).then(function(ae){pu(U)&&!H||Ce(ae,U)}).catch(function(ae){return Te(ae)}),X({type:"reset"})},[o,Ce,Te,H]),ne=O.useCallback(function(){if(_e.current){X({type:"openDialog"}),se();var U={multiple:l,types:de};window.showOpenFilePicker(U).then(function(ae){return o(ae)}).then(function(ae){Ce(ae,null),X({type:"closeDialog"})}).catch(function(ae){TU(ae)?(fe(ae),X({type:"closeDialog"})):AU(ae)?(_e.current=!1,Z.current?(Z.current.value=null,Z.current.click()):Te(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):Te(ae)});return}Z.current&&(X({type:"openDialog"}),se(),Z.current.value=null,Z.current.click())},[X,se,fe,E,Ce,Te,de,l]),Ve=O.useCallback(function(U){!q.current||!q.current.isEqualNode(U.target)||(U.key===" "||U.key==="Enter"||U.keyCode===32||U.keyCode===13)&&(U.preventDefault(),ne())},[q,ne]),Qe=O.useCallback(function(){X({type:"focus"})},[]),Ct=O.useCallback(function(){X({type:"blur"})},[]),Jt=O.useCallback(function(){P||(xU()?setTimeout(ne,0):ne())},[P,ne]),bt=function(ae){return r?null:ae},an=function(ae){return _?null:bt(ae)},zt=function(ae){return D?null:bt(ae)},Dn=function(ae){H&&ae.stopPropagation()},Kt=O.useMemo(function(){return function(){var U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ae=U.refKey,ye=ae===void 0?"ref":ae,he=U.role,Ee=U.onKeyDown,Xe=U.onFocus,ft=U.onBlur,xt=U.onClick,vo=U.onDragEnter,Qt=U.onDragOver,yn=U.onDragLeave,Gr=U.onDrop,Gt=mu(U,NU);return Bt(Bt(lm({onKeyDown:an(po(Ee,Ve)),onFocus:an(po(Xe,Qe)),onBlur:an(po(ft,Ct)),onClick:bt(po(xt,Jt)),onDragEnter:zt(po(vo,z)),onDragOver:zt(po(Qt,ce)),onDragLeave:zt(po(yn,Ae)),onDrop:zt(po(Gr,Ne)),role:typeof he=="string"&&he!==""?he:"presentation"},ye,q),!r&&!_?{tabIndex:0}:{}),Gt)}},[q,Ve,Qe,Ct,Jt,z,ce,Ae,Ne,_,D,r]),L=O.useCallback(function(U){U.stopPropagation()},[]),J=O.useMemo(function(){return function(){var U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ae=U.refKey,ye=ae===void 0?"ref":ae,he=U.onChange,Ee=U.onClick,Xe=mu(U,PU),ft=lm({accept:W,multiple:l,type:"file",style:{border:0,clip:"rect(0, 0, 0, 0)",clipPath:"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"},onChange:bt(po(he,Ne)),onClick:bt(po(Ee,L)),tabIndex:-1},ye,Z);return Bt(Bt({},ft),Xe)}},[Z,n,l,Ne,r]);return Bt(Bt({},Q),{},{isFocused:$&&!r,getRootProps:Kt,getInputProps:J,rootRef:q,inputRef:Z,open:bt(ne)})}function UU(t,e){switch(e.type){case"focus":return Bt(Bt({},t),{},{isFocused:!0});case"blur":return Bt(Bt({},t),{},{isFocused:!1});case"openDialog":return Bt(Bt({},um),{},{isFileDialogActive:!0});case"closeDialog":return Bt(Bt({},t),{},{isFileDialogActive:!1});case"setDraggedFiles":return Bt(Bt({},t),{},{isDragActive:e.isDragActive,isDragAccept:e.isDragAccept,isDragReject:e.isDragReject});case"setFiles":return Bt(Bt({},t),{},{acceptedFiles:e.acceptedFiles,fileRejections:e.fileRejections,isDragReject:e.isDragReject});case"reset":return Bt({},um);default:return t}}function WE(){}const BU=({onFilesSelected:t,children:e})=>{const[n,r]=O.useState(!1),{getRootProps:o,getInputProps:i}=jE({noClick:!0,onDrop:s=>{if(s&&s.length>0)if(s[0].path.split("/").length>2){const u=s.map(h=>{const g=(h.path||h.relativePath||"").split("/").slice(1).join("/");return(!h.webkitRelativePath||h.webkitRelativePath==="")&&Object.defineProperty(h,"webkitRelativePath",{writable:!0,value:g,enumerable:!0,configurable:!0}),h});t(u,"folder")}else t(s,"files");r(!1)},onDragOver:s=>{s.preventDefault(),n||r(!0)},multiple:!0});return O.useEffect(()=>{const s=l=>{l.clientX===0&&l.clientY===0&&r(!1)};return document.addEventListener("dragleave",s),()=>{document.removeEventListener("dragleave",s)}},[]),d.jsxs("div",{...o(),className:"transition-opacity min-h-[600px]",children:[n?d.jsx("div",{className:"flex flex-col items-center justify-center p-4 border-2 border-dashed border-gray-300 rounded-lg bg-gray-50 h-screen"}):e,d.jsx("input",{...i()})]})},zU=({openDialogRename:t,setOpenDialogRename:e,apiBaseUrl:n,setFileToMove:r,fileToMove:o,refreshFiles:i,ignoreCache:s,autoSyncAfterFileOperation:l})=>{var N;const[u,h]=O.useState({}),[p,g]=O.useState(!1),[C,w]=O.useState(!1),[b,v]=O.useState(""),{toast:x}=dc();O.useEffect(()=>{t&&E(b)},[b,t]);const E=async P=>{try{w(!0);const _=await Le.get(`${n}/api/list-s3-folders?prefix=${P}`);h(_==null?void 0:_.data)}catch{x({title:"Error",description:"Unable to load S3 folder list",variant:"destructive"})}finally{w(!1)}},A=async()=>{g(!0);try{const P=o.key,_=P.endsWith("/")?P:`${P}/`,D=b.endsWith("/")?b:`${b}/`;if(_===D||P===b){x({title:"Lỗi",description:"Không thể di chuyển file đến cùng vị trí",variant:"destructive"}),g(!1);return}await Le.post(`${n}/api/move`,{oldPath:P,newPath:b}),s.current=!0,await i(),x({title:"Đã di chuyển",description:`Đã di chuyển thành công "${o.name}" đến "${b}"`}),e(!1),r(null),v(""),l&&await l("move")}catch(P){console.error("Error renaming item:",P),x({title:"Lỗi",description:"Không thể đổi tên",variant:"destructive"})}finally{g(!1)}};return d.jsx(or,{open:t,onOpenChange:P=>{P||(e(!1),r(null),v(""))},children:d.jsxs(Kn,{className:"max-h-[700px] pb-3 px-1 s3-explr-input-group max-w-5xl w-[90%] p-6 bg-white rounded-lg shadow-lg",children:[d.jsxs(Gn,{className:"mb-4 w-full h-full",children:[d.jsx("nav",{className:"mb-4",children:d.jsxs("ul",{className:"flex items-center space-x-2 text-sm text-gray-600",children:[d.jsx("li",{className:"cursor-pointer hover:text-blue-600 transition-colors",onClick:()=>v(""),children:"Root"}),b.split("/").map((P,_,D)=>d.jsx("li",{className:"cursor-pointer hover:text-blue-600 transition-colors",onClick:()=>v(P==="Root"?"":D.slice(0,_+1).join("/")+"/"),children:P},_))]})}),d.jsxs(jn,{className:"text-xl font-semibold text-gray-800",children:["Di chuyển"," ",d.jsxs("span",{className:"text-sm text-gray-500",children:["( file hoặc folder sẽ được di chuyển đến thư mục"," ",b===""?"Root":b," )"]})]}),d.jsx(gi,{className:"text-gray-600 w-full h-[50dvh] max-h-[500px] overflow-hidden overflow-y-auto",children:C?d.jsx("div",{className:"flex justify-center items-center py-4",children:d.jsx("div",{className:"loader ease-linear rounded-full border-4 border-t-4 border-gray-200 h-12 w-12"})}):d.jsx("ul",{className:"space-y-2",children:(N=Object.keys(u))==null?void 0:N.map(P=>d.jsx("li",{className:"cursor-pointer hover:bg-gray-100 p-2 rounded transition-colors",onClick:()=>v(P),children:P},P))})})]}),d.jsxs(Lr,{className:"flex justify-end space-x-2",children:[d.jsx(He,{variant:"outline",onClick:()=>e(!1),className:"px-4 py-2 rounded border border-gray-300 text-gray-700 hover:bg-gray-100 transition-colors",children:"Cancel"}),d.jsx(He,{onClick:A,disabled:p,className:"s3-explr-crawl-btn",children:"Move"})]})]})})};function qE(t,[e,n]){return Math.min(n,Math.max(e,t))}function YE(t){const e=VU(t),n=m.forwardRef((r,o)=>{const{children:i,...s}=r,l=m.Children.toArray(i),u=l.find(GU);if(u){const h=u.props.children,p=l.map(g=>g===u?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return d.jsx(e,{...s,ref:o,children:m.isValidElement(h)?m.cloneElement(h,void 0,p):null})}return d.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}function VU(t){const e=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const s=WU(o),l=jU(i,o.props);return o.type!==m.Fragment&&(l.ref=r?Hi(r,s):s),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var KU=Symbol("radix.slottable");function GU(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===KU}function jU(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function WU(t){var r,o;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function qU(t){const e=t+"CollectionProvider",[n,r]=hr(e),[o,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),s=v=>{const{scope:x,children:E}=v,A=O.useRef(null),N=O.useRef(new Map).current;return d.jsx(o,{scope:x,itemMap:N,collectionRef:A,children:E})};s.displayName=e;const l=t+"CollectionSlot",u=YE(l),h=O.forwardRef((v,x)=>{const{scope:E,children:A}=v,N=i(l,E),P=rt(x,N.collectionRef);return d.jsx(u,{ref:P,children:A})});h.displayName=l;const p=t+"CollectionItemSlot",g="data-radix-collection-item",C=YE(p),w=O.forwardRef((v,x)=>{const{scope:E,children:A,...N}=v,P=O.useRef(null),_=rt(x,P),D=i(p,E);return O.useEffect(()=>(D.itemMap.set(P,{ref:P,...N}),()=>void D.itemMap.delete(P))),d.jsx(C,{[g]:"",ref:_,children:A})});w.displayName=p;function b(v){const x=i(t+"CollectionConsumer",v);return O.useCallback(()=>{const A=x.collectionRef.current;if(!A)return[];const N=Array.from(A.querySelectorAll(`[${g}]`));return Array.from(x.itemMap.values()).sort((D,H)=>N.indexOf(D.ref.current)-N.indexOf(H.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:s,Slot:h,ItemSlot:w},b,r]}function JE(t){const e=YU(t),n=m.forwardRef((r,o)=>{const{children:i,...s}=r,l=m.Children.toArray(i),u=l.find(QU);if(u){const h=u.props.children,p=l.map(g=>g===u?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return d.jsx(e,{...s,ref:o,children:m.isValidElement(h)?m.cloneElement(h,void 0,p):null})}return d.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}function YU(t){const e=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const s=ZU(o),l=XU(i,o.props);return o.type!==m.Fragment&&(l.ref=r?Hi(r,s):s),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var JU=Symbol("radix.slottable");function QU(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===JU}function XU(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function ZU(t){var r,o;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var eB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],vn=eB.reduce((t,e)=>{const n=JE(`Primitive.${e}`),r=m.forwardRef((o,i)=>{const{asChild:s,...l}=o,u=s?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(u,{...l,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function tB(t,e){t&&Aa.flushSync(()=>t.dispatchEvent(e))}var nB="DismissableLayer",fm="dismissableLayer.update",rB="dismissableLayer.pointerDownOutside",oB="dismissableLayer.focusOutside",QE,XE=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ZE=m.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:s,onDismiss:l,...u}=t,h=m.useContext(XE),[p,g]=m.useState(null),C=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,w]=m.useState({}),b=rt(e,H=>g(H)),v=Array.from(h.layers),[x]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),E=v.indexOf(x),A=p?v.indexOf(p):-1,N=h.layersWithOutsidePointerEventsDisabled.size>0,P=A>=E,_=sB(H=>{const K=H.target,ee=[...h.branches].some(W=>W.contains(K));!P||ee||(o==null||o(H),s==null||s(H),H.defaultPrevented||l==null||l())},C),D=cB(H=>{const K=H.target;[...h.branches].some(W=>W.contains(K))||(i==null||i(H),s==null||s(H),H.defaultPrevented||l==null||l())},C);return FC(H=>{A===h.layers.size-1&&(r==null||r(H),!H.defaultPrevented&&l&&(H.preventDefault(),l()))},C),m.useEffect(()=>{if(p)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(QE=C.body.style.pointerEvents,C.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(p)),h.layers.add(p),eT(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(C.body.style.pointerEvents=QE)}},[p,C,n,h]),m.useEffect(()=>()=>{p&&(h.layers.delete(p),h.layersWithOutsidePointerEventsDisabled.delete(p),eT())},[p,h]),m.useEffect(()=>{const H=()=>w({});return document.addEventListener(fm,H),()=>document.removeEventListener(fm,H)},[]),d.jsx(vn.div,{...u,ref:b,style:{pointerEvents:N?P?"auto":"none":void 0,...t.style},onFocusCapture:Ue(t.onFocusCapture,D.onFocusCapture),onBlurCapture:Ue(t.onBlurCapture,D.onBlurCapture),onPointerDownCapture:Ue(t.onPointerDownCapture,_.onPointerDownCapture)})});ZE.displayName=nB;var iB="DismissableLayerBranch",aB=m.forwardRef((t,e)=>{const n=m.useContext(XE),r=m.useRef(null),o=rt(e,r);return m.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),d.jsx(vn.div,{...t,ref:o})});aB.displayName=iB;function sB(t,e=globalThis==null?void 0:globalThis.document){const n=mn(t),r=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const i=l=>{if(l.target&&!r.current){let u=function(){tT(rB,n,h,{discrete:!0})};const h={originalEvent:l};l.pointerType==="touch"?(e.removeEventListener("click",o.current),o.current=u,e.addEventListener("click",o.current,{once:!0})):u()}else e.removeEventListener("click",o.current);r.current=!1},s=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(s),e.removeEventListener("pointerdown",i),e.removeEventListener("click",o.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function cB(t,e=globalThis==null?void 0:globalThis.document){const n=mn(t),r=m.useRef(!1);return m.useEffect(()=>{const o=i=>{i.target&&!r.current&&tT(oB,n,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",o),()=>e.removeEventListener("focusin",o)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function eT(){const t=new CustomEvent(fm);document.dispatchEvent(t)}function tT(t,e,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&o.addEventListener(t,e,{once:!0}),r?tB(o,i):o.dispatchEvent(i)}var hm="focusScope.autoFocusOnMount",pm="focusScope.autoFocusOnUnmount",nT={bubbles:!1,cancelable:!0},lB="FocusScope",rT=m.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...s}=t,[l,u]=m.useState(null),h=mn(o),p=mn(i),g=m.useRef(null),C=rt(e,v=>u(v)),w=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let v=function(N){if(w.paused||!l)return;const P=N.target;l.contains(P)?g.current=P:yi(g.current,{select:!0})},x=function(N){if(w.paused||!l)return;const P=N.relatedTarget;P!==null&&(l.contains(P)||yi(g.current,{select:!0}))},E=function(N){if(document.activeElement===document.body)for(const _ of N)_.removedNodes.length>0&&yi(l)};document.addEventListener("focusin",v),document.addEventListener("focusout",x);const A=new MutationObserver(E);return l&&A.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",x),A.disconnect()}}},[r,l,w.paused]),m.useEffect(()=>{if(l){aT.add(w);const v=document.activeElement;if(!l.contains(v)){const E=new CustomEvent(hm,nT);l.addEventListener(hm,h),l.dispatchEvent(E),E.defaultPrevented||(dB(gB(oT(l)),{select:!0}),document.activeElement===v&&yi(l))}return()=>{l.removeEventListener(hm,h),setTimeout(()=>{const E=new CustomEvent(pm,nT);l.addEventListener(pm,p),l.dispatchEvent(E),E.defaultPrevented||yi(v??document.body,{select:!0}),l.removeEventListener(pm,p),aT.remove(w)},0)}}},[l,h,p,w]);const b=m.useCallback(v=>{if(!n&&!r||w.paused)return;const x=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,E=document.activeElement;if(x&&E){const A=v.currentTarget,[N,P]=uB(A);N&&P?!v.shiftKey&&E===P?(v.preventDefault(),n&&yi(N,{select:!0})):v.shiftKey&&E===N&&(v.preventDefault(),n&&yi(P,{select:!0})):E===A&&v.preventDefault()}},[n,r,w.paused]);return d.jsx(vn.div,{tabIndex:-1,...s,ref:C,onKeyDown:b})});rT.displayName=lB;function dB(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(yi(r,{select:e}),document.activeElement!==n)return}function uB(t){const e=oT(t),n=iT(e,t),r=iT(e.reverse(),t);return[n,r]}function oT(t){const e=[],n=document.createTreeWalker(t,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();)e.push(n.currentNode);return e}function iT(t,e){for(const n of t)if(!fB(n,{upTo:e}))return n}function fB(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function hB(t){return t instanceof HTMLInputElement&&"select"in t}function yi(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&hB(t)&&e&&t.select()}}var aT=pB();function pB(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=sT(t,e),t.unshift(e)},remove(e){var n;t=sT(t,e),(n=t[0])==null||n.resume()}}}function sT(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function gB(t){return t.filter(e=>e.tagName!=="A")}function mB(t){const e=vB(t),n=m.forwardRef((r,o)=>{const{children:i,...s}=r,l=m.Children.toArray(i),u=l.find(wB);if(u){const h=u.props.children,p=l.map(g=>g===u?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return d.jsx(e,{...s,ref:o,children:m.isValidElement(h)?m.cloneElement(h,void 0,p):null})}return d.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}function vB(t){const e=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const s=bB(o),l=CB(i,o.props);return o.type!==m.Fragment&&(l.ref=r?Hi(r,s):s),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var yB=Symbol("radix.slottable");function wB(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===yB}function CB(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function bB(t){var r,o;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var xB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],SB=xB.reduce((t,e)=>{const n=mB(`Primitive.${e}`),r=m.forwardRef((o,i)=>{const{asChild:s,...l}=o,u=s?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(u,{...l,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),_B="Arrow",cT=m.forwardRef((t,e)=>{const{children:n,width:r=10,height:o=5,...i}=t;return d.jsx(SB.svg,{...i,ref:e,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});cT.displayName=_B;var EB=cT;function TB(t){const e=AB(t),n=m.forwardRef((r,o)=>{const{children:i,...s}=r,l=m.Children.toArray(i),u=l.find(kB);if(u){const h=u.props.children,p=l.map(g=>g===u?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return d.jsx(e,{...s,ref:o,children:m.isValidElement(h)?m.cloneElement(h,void 0,p):null})}return d.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}function AB(t){const e=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const s=PB(o),l=NB(i,o.props);return o.type!==m.Fragment&&(l.ref=r?Hi(r,s):s),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var IB=Symbol("radix.slottable");function kB(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===IB}function NB(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function PB(t){var r,o;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var OB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],lT=OB.reduce((t,e)=>{const n=TB(`Primitive.${e}`),r=m.forwardRef((o,i)=>{const{asChild:s,...l}=o,u=s?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(u,{...l,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),gm="Popper",[dT,uT]=hr(gm),[MB,fT]=dT(gm),hT=t=>{const{__scopePopper:e,children:n}=t,[r,o]=m.useState(null);return d.jsx(MB,{scope:e,anchor:r,onAnchorChange:o,children:n})};hT.displayName=gm;var pT="PopperAnchor",gT=m.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...o}=t,i=fT(pT,n),s=m.useRef(null),l=rt(e,s);return m.useEffect(()=>{i.onAnchorChange((r==null?void 0:r.current)||s.current)}),r?null:d.jsx(lT.div,{...o,ref:l})});gT.displayName=pT;var mm="PopperContent",[RB,DB]=dT(mm),mT=m.forwardRef((t,e)=>{var z,ce,Ae,Ce,Ne,ne;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:s=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:h=[],collisionPadding:p=0,sticky:g="partial",hideWhenDetached:C=!1,updatePositionStrategy:w="optimized",onPlaced:b,...v}=t,x=fT(mm,n),[E,A]=m.useState(null),N=rt(e,Ve=>A(Ve)),[P,_]=m.useState(null),D=hg(P),H=(D==null?void 0:D.width)??0,K=(D==null?void 0:D.height)??0,ee=r+(i!=="center"?"-"+i:""),W=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},de=Array.isArray(h)?h:[h],se=de.length>0,fe={padding:W,boundary:de.filter(FB),altBoundary:se},{refs:q,floatingStyles:Z,placement:Y,isPositioned:oe,middlewareData:Q}=A_({strategy:"fixed",placement:ee,whileElementsMounted:(...Ve)=>S_(...Ve,{animationFrame:w==="always"}),elements:{reference:x.anchor},middleware:[I_({mainAxis:o+K,alignmentAxis:s}),u&&k_({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?N_():void 0,...fe}),u&&P_({...fe}),O_({...fe,apply:({elements:Ve,rects:Qe,availableWidth:Ct,availableHeight:Jt})=>{const{width:bt,height:an}=Qe.reference,zt=Ve.floating.style;zt.setProperty("--radix-popper-available-width",`${Ct}px`),zt.setProperty("--radix-popper-available-height",`${Jt}px`),zt.setProperty("--radix-popper-anchor-width",`${bt}px`),zt.setProperty("--radix-popper-anchor-height",`${an}px`)}}),P&&R_({element:P,padding:l}),$B({arrowWidth:H,arrowHeight:K}),C&&M_({strategy:"referenceHidden",...fe})]}),[X,$]=wT(Y),te=mn(b);rn(()=>{oe&&(te==null||te())},[oe,te]);const _e=(z=Q.arrow)==null?void 0:z.x,ke=(ce=Q.arrow)==null?void 0:ce.y,xe=((Ae=Q.arrow)==null?void 0:Ae.centerOffset)!==0,[Pe,Te]=m.useState();return rn(()=>{E&&Te(window.getComputedStyle(E).zIndex)},[E]),d.jsx("div",{ref:q.setFloating,"data-radix-popper-content-wrapper":"",style:{...Z,transform:oe?Z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Pe,"--radix-popper-transform-origin":[(Ce=Q.transformOrigin)==null?void 0:Ce.x,(Ne=Q.transformOrigin)==null?void 0:Ne.y].join(" "),...((ne=Q.hide)==null?void 0:ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:d.jsx(RB,{scope:n,placedSide:X,onArrowChange:_,arrowX:_e,arrowY:ke,shouldHideArrow:xe,children:d.jsx(lT.div,{"data-side":X,"data-align":$,...v,ref:N,style:{...v.style,animation:oe?void 0:"none"}})})})});mT.displayName=mm;var vT="PopperArrow",LB={top:"bottom",right:"left",bottom:"top",left:"right"},yT=m.forwardRef(function(e,n){const{__scopePopper:r,...o}=e,i=DB(vT,r),s=LB[i.placedSide];return d.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:d.jsx(EB,{...o,ref:n,style:{...o.style,display:"block"}})})});yT.displayName=vT;function FB(t){return t!==null}var $B=t=>({name:"transformOrigin",options:t,fn(e){var x,E,A;const{placement:n,rects:r,middlewareData:o}=e,s=((x=o.arrow)==null?void 0:x.centerOffset)!==0,l=s?0:t.arrowWidth,u=s?0:t.arrowHeight,[h,p]=wT(n),g={start:"0%",center:"50%",end:"100%"}[p],C=(((E=o.arrow)==null?void 0:E.x)??0)+l/2,w=(((A=o.arrow)==null?void 0:A.y)??0)+u/2;let b="",v="";return h==="bottom"?(b=s?g:`${C}px`,v=`${-u}px`):h==="top"?(b=s?g:`${C}px`,v=`${r.floating.height+u}px`):h==="right"?(b=`${-u}px`,v=s?g:`${w}px`):h==="left"&&(b=`${r.floating.width+u}px`,v=s?g:`${w}px`),{data:{x:b,y:v}}}});function wT(t){const[e,n="center"]=t.split("-");return[e,n]}var HB=hT,UB=gT,BB=mT,zB=yT,VB="Portal",CT=m.forwardRef((t,e)=>{var l;const{container:n,...r}=t,[o,i]=m.useState(!1);rn(()=>i(!0),[]);const s=n||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return s?Hf.createPortal(d.jsx(vn.div,{...r,ref:e}),s):null});CT.displayName=VB;function KB(t){const e=GB(t),n=m.forwardRef((r,o)=>{const{children:i,...s}=r,l=m.Children.toArray(i),u=l.find(WB);if(u){const h=u.props.children,p=l.map(g=>g===u?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return d.jsx(e,{...s,ref:o,children:m.isValidElement(h)?m.cloneElement(h,void 0,p):null})}return d.jsx(e,{...s,ref:o,children:i})});return n.displayName=`${t}.Slot`,n}function GB(t){const e=m.forwardRef((n,r)=>{const{children:o,...i}=n;if(m.isValidElement(o)){const s=YB(o),l=qB(i,o.props);return o.type!==m.Fragment&&(l.ref=r?Hi(r,s):s),m.cloneElement(o,l)}return m.Children.count(o)>1?m.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var jB=Symbol("radix.slottable");function WB(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===jB}function qB(t,e){const n={...e};for(const r in e){const o=t[r],i=e[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...t,...n}}function YB(t){var r,o;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(o=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var JB=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],QB=JB.reduce((t,e)=>{const n=KB(`Primitive.${e}`),r=m.forwardRef((o,i)=>{const{asChild:s,...l}=o,u=s?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(u,{...l,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),bT=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),XB="VisuallyHidden",ZB=m.forwardRef((t,e)=>d.jsx(QB.span,{...t,ref:e,style:{...bT,...t.style}}));ZB.displayName=XB;var e3=[" ","Enter","ArrowUp","ArrowDown"],t3=[" ","Enter"],Ji="Select",[vu,yu,n3]=qU(Ji),[os,vW]=hr(Ji,[n3,uT]),wu=uT(),[r3,wi]=os(Ji),[o3,i3]=os(Ji),xT=t=>{const{__scopeSelect:e,children:n,open:r,defaultOpen:o,onOpenChange:i,value:s,defaultValue:l,onValueChange:u,dir:h,name:p,autoComplete:g,disabled:C,required:w,form:b}=t,v=wu(e),[x,E]=m.useState(null),[A,N]=m.useState(null),[P,_]=m.useState(!1),D=mg(h),[H,K]=si({prop:r,defaultProp:o??!1,onChange:i,caller:Ji}),[ee,W]=si({prop:s,defaultProp:l,onChange:u,caller:Ji}),de=m.useRef(null),se=x?b||!!x.closest("form"):!0,[fe,q]=m.useState(new Set),Z=Array.from(fe).map(Y=>Y.props.value).join(";");return d.jsx(HB,{...v,children:d.jsxs(r3,{required:w,scope:e,trigger:x,onTriggerChange:E,valueNode:A,onValueNodeChange:N,valueNodeHasChildren:P,onValueNodeHasChildrenChange:_,contentId:Io(),value:ee,onValueChange:W,open:H,onOpenChange:K,dir:D,triggerPointerDownPosRef:de,disabled:C,children:[d.jsx(vu.Provider,{scope:e,children:d.jsx(o3,{scope:t.__scopeSelect,onNativeOptionAdd:m.useCallback(Y=>{q(oe=>new Set(oe).add(Y))},[]),onNativeOptionRemove:m.useCallback(Y=>{q(oe=>{const Q=new Set(oe);return Q.delete(Y),Q})},[]),children:n})}),se?d.jsxs(KT,{"aria-hidden":!0,required:w,tabIndex:-1,name:p,autoComplete:g,value:ee,onChange:Y=>W(Y.target.value),disabled:C,form:b,children:[ee===void 0?d.jsx("option",{value:""}):null,Array.from(fe)]},Z):null]})})};xT.displayName=Ji;var ST="SelectTrigger",_T=m.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...o}=t,i=wu(n),s=wi(ST,n),l=s.disabled||r,u=rt(e,s.onTriggerChange),h=yu(n),p=m.useRef("touch"),[g,C,w]=jT(v=>{const x=h().filter(N=>!N.disabled),E=x.find(N=>N.value===s.value),A=WT(x,v,E);A!==void 0&&s.onValueChange(A.value)}),b=v=>{l||(s.onOpenChange(!0),w()),v&&(s.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return d.jsx(UB,{asChild:!0,...i,children:d.jsx(vn.button,{type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":GT(s.value)?"":void 0,...o,ref:u,onClick:Ue(o.onClick,v=>{v.currentTarget.focus(),p.current!=="mouse"&&b(v)}),onPointerDown:Ue(o.onPointerDown,v=>{p.current=v.pointerType;const x=v.target;x.hasPointerCapture(v.pointerId)&&x.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(b(v),v.preventDefault())}),onKeyDown:Ue(o.onKeyDown,v=>{const x=g.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&C(v.key),!(x&&v.key===" ")&&e3.includes(v.key)&&(b(),v.preventDefault())})})})});_T.displayName=ST;var ET="SelectValue",TT=m.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:o,children:i,placeholder:s="",...l}=t,u=wi(ET,n),{onValueNodeHasChildrenChange:h}=u,p=i!==void 0,g=rt(e,u.onValueNodeChange);return rn(()=>{h(p)},[h,p]),d.jsx(vn.span,{...l,ref:g,style:{pointerEvents:"none"},children:GT(u.value)?d.jsx(d.Fragment,{children:s}):i})});TT.displayName=ET;var a3="SelectIcon",AT=m.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...o}=t;return d.jsx(vn.span,{"aria-hidden":!0,...o,ref:e,children:r||"▼"})});AT.displayName=a3;var s3="SelectPortal",IT=t=>d.jsx(CT,{asChild:!0,...t});IT.displayName=s3;var Qi="SelectContent",kT=m.forwardRef((t,e)=>{const n=wi(Qi,t.__scopeSelect),[r,o]=m.useState();if(rn(()=>{o(new DocumentFragment)},[]),!n.open){const i=r;return i?Aa.createPortal(d.jsx(NT,{scope:t.__scopeSelect,children:d.jsx(vu.Slot,{scope:t.__scopeSelect,children:d.jsx("div",{children:t.children})})}),i):null}return d.jsx(PT,{...t,ref:e})});kT.displayName=Qi;var zr=10,[NT,Ci]=os(Qi),c3="SelectContentImpl",l3=JE("SelectContent.RemoveScroll"),PT=m.forwardRef((t,e)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:s,side:l,sideOffset:u,align:h,alignOffset:p,arrowPadding:g,collisionBoundary:C,collisionPadding:w,sticky:b,hideWhenDetached:v,avoidCollisions:x,...E}=t,A=wi(Qi,n),[N,P]=m.useState(null),[_,D]=m.useState(null),H=rt(e,z=>P(z)),[K,ee]=m.useState(null),[W,de]=m.useState(null),se=yu(n),[fe,q]=m.useState(!1),Z=m.useRef(!1);m.useEffect(()=>{if(N)return fb(N)},[N]),YC();const Y=m.useCallback(z=>{const[ce,...Ae]=se().map(ne=>ne.ref.current),[Ce]=Ae.slice(-1),Ne=document.activeElement;for(const ne of z)if(ne===Ne||(ne==null||ne.scrollIntoView({block:"nearest"}),ne===ce&&_&&(_.scrollTop=0),ne===Ce&&_&&(_.scrollTop=_.scrollHeight),ne==null||ne.focus(),document.activeElement!==Ne))return},[se,_]),oe=m.useCallback(()=>Y([K,N]),[Y,K,N]);m.useEffect(()=>{fe&&oe()},[fe,oe]);const{onOpenChange:Q,triggerPointerDownPosRef:X}=A;m.useEffect(()=>{if(N){let z={x:0,y:0};const ce=Ce=>{var Ne,ne;z={x:Math.abs(Math.round(Ce.pageX)-(((Ne=X.current)==null?void 0:Ne.x)??0)),y:Math.abs(Math.round(Ce.pageY)-(((ne=X.current)==null?void 0:ne.y)??0))}},Ae=Ce=>{z.x<=10&&z.y<=10?Ce.preventDefault():N.contains(Ce.target)||Q(!1),document.removeEventListener("pointermove",ce),X.current=null};return X.current!==null&&(document.addEventListener("pointermove",ce),document.addEventListener("pointerup",Ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ce),document.removeEventListener("pointerup",Ae,{capture:!0})}}},[N,Q,X]),m.useEffect(()=>{const z=()=>Q(!1);return window.addEventListener("blur",z),window.addEventListener("resize",z),()=>{window.removeEventListener("blur",z),window.removeEventListener("resize",z)}},[Q]);const[$,te]=jT(z=>{const ce=se().filter(Ne=>!Ne.disabled),Ae=ce.find(Ne=>Ne.ref.current===document.activeElement),Ce=WT(ce,z,Ae);Ce&&setTimeout(()=>Ce.ref.current.focus())}),_e=m.useCallback((z,ce,Ae)=>{const Ce=!Z.current&&!Ae;(A.value!==void 0&&A.value===ce||Ce)&&(ee(z),Ce&&(Z.current=!0))},[A.value]),ke=m.useCallback(()=>N==null?void 0:N.focus(),[N]),xe=m.useCallback((z,ce,Ae)=>{const Ce=!Z.current&&!Ae;(A.value!==void 0&&A.value===ce||Ce)&&de(z)},[A.value]),Pe=r==="popper"?vm:OT,Te=Pe===vm?{side:l,sideOffset:u,align:h,alignOffset:p,arrowPadding:g,collisionBoundary:C,collisionPadding:w,sticky:b,hideWhenDetached:v,avoidCollisions:x}:{};return d.jsx(NT,{scope:n,content:N,viewport:_,onViewportChange:D,itemRefCallback:_e,selectedItem:K,onItemLeave:ke,itemTextRefCallback:xe,focusSelectedItem:oe,selectedItemText:W,position:r,isPositioned:fe,searchRef:$,children:d.jsx(Cp,{as:l3,allowPinchZoom:!0,children:d.jsx(rT,{asChild:!0,trapped:A.open,onMountAutoFocus:z=>{z.preventDefault()},onUnmountAutoFocus:Ue(o,z=>{var ce;(ce=A.trigger)==null||ce.focus({preventScroll:!0}),z.preventDefault()}),children:d.jsx(ZE,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:z=>z.preventDefault(),onDismiss:()=>A.onOpenChange(!1),children:d.jsx(Pe,{role:"listbox",id:A.contentId,"data-state":A.open?"open":"closed",dir:A.dir,onContextMenu:z=>z.preventDefault(),...E,...Te,onPlaced:()=>q(!0),ref:H,style:{display:"flex",flexDirection:"column",outline:"none",...E.style},onKeyDown:Ue(E.onKeyDown,z=>{const ce=z.ctrlKey||z.altKey||z.metaKey;if(z.key==="Tab"&&z.preventDefault(),!ce&&z.key.length===1&&te(z.key),["ArrowUp","ArrowDown","Home","End"].includes(z.key)){let Ce=se().filter(Ne=>!Ne.disabled).map(Ne=>Ne.ref.current);if(["ArrowUp","End"].includes(z.key)&&(Ce=Ce.slice().reverse()),["ArrowUp","ArrowDown"].includes(z.key)){const Ne=z.target,ne=Ce.indexOf(Ne);Ce=Ce.slice(ne+1)}setTimeout(()=>Y(Ce)),z.preventDefault()}})})})})})})});PT.displayName=c3;var d3="SelectItemAlignedPosition",OT=m.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...o}=t,i=wi(Qi,n),s=Ci(Qi,n),[l,u]=m.useState(null),[h,p]=m.useState(null),g=rt(e,H=>p(H)),C=yu(n),w=m.useRef(!1),b=m.useRef(!0),{viewport:v,selectedItem:x,selectedItemText:E,focusSelectedItem:A}=s,N=m.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&h&&v&&x&&E){const H=i.trigger.getBoundingClientRect(),K=h.getBoundingClientRect(),ee=i.valueNode.getBoundingClientRect(),W=E.getBoundingClientRect();if(i.dir!=="rtl"){const Ne=W.left-K.left,ne=ee.left-Ne,Ve=H.left-ne,Qe=H.width+Ve,Ct=Math.max(Qe,K.width),Jt=window.innerWidth-zr,bt=qE(ne,[zr,Math.max(zr,Jt-Ct)]);l.style.minWidth=Qe+"px",l.style.left=bt+"px"}else{const Ne=K.right-W.right,ne=window.innerWidth-ee.right-Ne,Ve=window.innerWidth-H.right-ne,Qe=H.width+Ve,Ct=Math.max(Qe,K.width),Jt=window.innerWidth-zr,bt=qE(ne,[zr,Math.max(zr,Jt-Ct)]);l.style.minWidth=Qe+"px",l.style.right=bt+"px"}const de=C(),se=window.innerHeight-zr*2,fe=v.scrollHeight,q=window.getComputedStyle(h),Z=parseInt(q.borderTopWidth,10),Y=parseInt(q.paddingTop,10),oe=parseInt(q.borderBottomWidth,10),Q=parseInt(q.paddingBottom,10),X=Z+Y+fe+Q+oe,$=Math.min(x.offsetHeight*5,X),te=window.getComputedStyle(v),_e=parseInt(te.paddingTop,10),ke=parseInt(te.paddingBottom,10),xe=H.top+H.height/2-zr,Pe=se-xe,Te=x.offsetHeight/2,z=x.offsetTop+Te,ce=Z+Y+z,Ae=X-ce;if(ce<=xe){const Ne=de.length>0&&x===de[de.length-1].ref.current;l.style.bottom="0px";const ne=h.clientHeight-v.offsetTop-v.offsetHeight,Ve=Math.max(Pe,Te+(Ne?ke:0)+ne+oe),Qe=ce+Ve;l.style.height=Qe+"px"}else{const Ne=de.length>0&&x===de[0].ref.current;l.style.top="0px";const Ve=Math.max(xe,Z+v.offsetTop+(Ne?_e:0)+Te)+Ae;l.style.height=Ve+"px",v.scrollTop=ce-xe+v.offsetTop}l.style.margin=`${zr}px 0`,l.style.minHeight=$+"px",l.style.maxHeight=se+"px",r==null||r(),requestAnimationFrame(()=>w.current=!0)}},[C,i.trigger,i.valueNode,l,h,v,x,E,i.dir,r]);rn(()=>N(),[N]);const[P,_]=m.useState();rn(()=>{h&&_(window.getComputedStyle(h).zIndex)},[h]);const D=m.useCallback(H=>{H&&b.current===!0&&(N(),A==null||A(),b.current=!1)},[N,A]);return d.jsx(f3,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:w,onScrollButtonChange:D,children:d.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:P},children:d.jsx(vn.div,{...o,ref:g,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});OT.displayName=d3;var u3="SelectPopperPosition",vm=m.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=zr,...i}=t,s=wu(n);return d.jsx(BB,{...s,...i,ref:e,align:r,collisionPadding:o,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});vm.displayName=u3;var[f3,ym]=os(Qi,{}),wm="SelectViewport",MT=m.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...o}=t,i=Ci(wm,n),s=ym(wm,n),l=rt(e,i.onViewportChange),u=m.useRef(0);return d.jsxs(d.Fragment,{children:[d.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),d.jsx(vu.Slot,{scope:n,children:d.jsx(vn.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Ue(o.onScroll,h=>{const p=h.currentTarget,{contentWrapper:g,shouldExpandOnScrollRef:C}=s;if(C!=null&&C.current&&g){const w=Math.abs(u.current-p.scrollTop);if(w>0){const b=window.innerHeight-zr*2,v=parseFloat(g.style.minHeight),x=parseFloat(g.style.height),E=Math.max(v,x);if(E<b){const A=E+w,N=Math.min(b,A),P=A-N;g.style.height=N+"px",g.style.bottom==="0px"&&(p.scrollTop=P>0?P:0,g.style.justifyContent="flex-end")}}}u.current=p.scrollTop})})})]})});MT.displayName=wm;var RT="SelectGroup",[h3,p3]=os(RT),g3=m.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,o=Io();return d.jsx(h3,{scope:n,id:o,children:d.jsx(vn.div,{role:"group","aria-labelledby":o,...r,ref:e})})});g3.displayName=RT;var DT="SelectLabel",LT=m.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,o=p3(DT,n);return d.jsx(vn.div,{id:o.id,...r,ref:e})});LT.displayName=DT;var Cu="SelectItem",[m3,FT]=os(Cu),$T=m.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:i,...s}=t,l=wi(Cu,n),u=Ci(Cu,n),h=l.value===r,[p,g]=m.useState(i??""),[C,w]=m.useState(!1),b=rt(e,A=>{var N;return(N=u.itemRefCallback)==null?void 0:N.call(u,A,r,o)}),v=Io(),x=m.useRef("touch"),E=()=>{o||(l.onValueChange(r),l.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return d.jsx(m3,{scope:n,value:r,disabled:o,textId:v,isSelected:h,onItemTextChange:m.useCallback(A=>{g(N=>N||((A==null?void 0:A.textContent)??"").trim())},[]),children:d.jsx(vu.ItemSlot,{scope:n,value:r,disabled:o,textValue:p,children:d.jsx(vn.div,{role:"option","aria-labelledby":v,"data-highlighted":C?"":void 0,"aria-selected":h&&C,"data-state":h?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...s,ref:b,onFocus:Ue(s.onFocus,()=>w(!0)),onBlur:Ue(s.onBlur,()=>w(!1)),onClick:Ue(s.onClick,()=>{x.current!=="mouse"&&E()}),onPointerUp:Ue(s.onPointerUp,()=>{x.current==="mouse"&&E()}),onPointerDown:Ue(s.onPointerDown,A=>{x.current=A.pointerType}),onPointerMove:Ue(s.onPointerMove,A=>{var N;x.current=A.pointerType,o?(N=u.onItemLeave)==null||N.call(u):x.current==="mouse"&&A.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ue(s.onPointerLeave,A=>{var N;A.currentTarget===document.activeElement&&((N=u.onItemLeave)==null||N.call(u))}),onKeyDown:Ue(s.onKeyDown,A=>{var P;((P=u.searchRef)==null?void 0:P.current)!==""&&A.key===" "||(t3.includes(A.key)&&E(),A.key===" "&&A.preventDefault())})})})})});$T.displayName=Cu;var yc="SelectItemText",HT=m.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:o,...i}=t,s=wi(yc,n),l=Ci(yc,n),u=FT(yc,n),h=i3(yc,n),[p,g]=m.useState(null),C=rt(e,E=>g(E),u.onItemTextChange,E=>{var A;return(A=l.itemTextRefCallback)==null?void 0:A.call(l,E,u.value,u.disabled)}),w=p==null?void 0:p.textContent,b=m.useMemo(()=>d.jsx("option",{value:u.value,disabled:u.disabled,children:w},u.value),[u.disabled,u.value,w]),{onNativeOptionAdd:v,onNativeOptionRemove:x}=h;return rn(()=>(v(b),()=>x(b)),[v,x,b]),d.jsxs(d.Fragment,{children:[d.jsx(vn.span,{id:u.textId,...i,ref:C}),u.isSelected&&s.valueNode&&!s.valueNodeHasChildren?Aa.createPortal(i.children,s.valueNode):null]})});HT.displayName=yc;var UT="SelectItemIndicator",BT=m.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return FT(UT,n).isSelected?d.jsx(vn.span,{"aria-hidden":!0,...r,ref:e}):null});BT.displayName=UT;var Cm="SelectScrollUpButton",v3=m.forwardRef((t,e)=>{const n=Ci(Cm,t.__scopeSelect),r=ym(Cm,t.__scopeSelect),[o,i]=m.useState(!1),s=rt(e,r.onScrollButtonChange);return rn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const h=u.scrollTop>0;i(h)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?d.jsx(zT,{...t,ref:s,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop-u.offsetHeight)}}):null});v3.displayName=Cm;var bm="SelectScrollDownButton",y3=m.forwardRef((t,e)=>{const n=Ci(bm,t.__scopeSelect),r=ym(bm,t.__scopeSelect),[o,i]=m.useState(!1),s=rt(e,r.onScrollButtonChange);return rn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const h=u.scrollHeight-u.clientHeight,p=Math.ceil(u.scrollTop)<h;i(p)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?d.jsx(zT,{...t,ref:s,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop+u.offsetHeight)}}):null});y3.displayName=bm;var zT=m.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=t,i=Ci("SelectScrollButton",n),s=m.useRef(null),l=yu(n),u=m.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return m.useEffect(()=>()=>u(),[u]),rn(()=>{var p;const h=l().find(g=>g.ref.current===document.activeElement);(p=h==null?void 0:h.ref.current)==null||p.scrollIntoView({block:"nearest"})},[l]),d.jsx(vn.div,{"aria-hidden":!0,...o,ref:e,style:{flexShrink:0,...o.style},onPointerDown:Ue(o.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:Ue(o.onPointerMove,()=>{var h;(h=i.onItemLeave)==null||h.call(i),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:Ue(o.onPointerLeave,()=>{u()})})}),w3="SelectSeparator",VT=m.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return d.jsx(vn.div,{"aria-hidden":!0,...r,ref:e})});VT.displayName=w3;var xm="SelectArrow",C3=m.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,o=wu(n),i=wi(xm,n),s=Ci(xm,n);return i.open&&s.position==="popper"?d.jsx(zB,{...o,...r,ref:e}):null});C3.displayName=xm;var b3="SelectBubbleInput",KT=m.forwardRef(({__scopeSelect:t,value:e,...n},r)=>{const o=m.useRef(null),i=rt(r,o),s=rS(e);return m.useEffect(()=>{const l=o.current;if(!l)return;const u=window.HTMLSelectElement.prototype,p=Object.getOwnPropertyDescriptor(u,"value").set;if(s!==e&&p){const g=new Event("change",{bubbles:!0});p.call(l,e),l.dispatchEvent(g)}},[s,e]),d.jsx(vn.select,{...n,style:{...bT,...n.style},ref:i,defaultValue:e})});KT.displayName=b3;function GT(t){return t===""||t===void 0}function jT(t){const e=mn(t),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(s=>{const l=n.current+s;e(l),function u(h){n.current=h,window.clearTimeout(r.current),h!==""&&(r.current=window.setTimeout(()=>u(""),1e3))}(l)},[e]),i=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,i]}function WT(t,e,n){const o=e.length>1&&Array.from(e).every(h=>h===e[0])?e[0]:e,i=n?t.indexOf(n):-1;let s=x3(t,Math.max(i,0));o.length===1&&(s=s.filter(h=>h!==n));const u=s.find(h=>h.textValue.toLowerCase().startsWith(o.toLowerCase()));return u!==n?u:void 0}function x3(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var S3=xT,qT=_T,_3=TT,E3=AT,T3=IT,YT=kT,A3=MT,JT=LT,QT=$T,I3=HT,k3=BT,XT=VT;const Sm=S3,_m=_3,bu=m.forwardRef(({className:t,children:e,...n},r)=>d.jsxs(qT,{ref:r,className:ze("flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50",t),...n,children:[e,d.jsx(E3,{asChild:!0,children:d.jsx(HD,{className:"h-4 w-4 opacity-50"})})]}));bu.displayName=qT.displayName;const xu=m.forwardRef(({className:t,children:e,position:n="popper",...r},o)=>d.jsx(T3,{children:d.jsx(YT,{ref:o,className:ze("relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md 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-[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",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,...r,children:d.jsx(A3,{className:ze("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e})})}));xu.displayName=YT.displayName;const N3=m.forwardRef(({className:t,...e},n)=>d.jsx(JT,{ref:n,className:ze("px-2 py-1.5 text-sm font-semibold",t),...e}));N3.displayName=JT.displayName;const Xi=m.forwardRef(({className:t,children:e,...n},r)=>d.jsxs(QT,{ref:r,className:ze("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[d.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(k3,{children:d.jsx(Lx,{className:"h-4 w-4"})})}),d.jsx(I3,{children:e})]}));Xi.displayName=QT.displayName;const P3=m.forwardRef(({className:t,...e},n)=>d.jsx(XT,{ref:n,className:ze("-mx-1 my-1 h-px bg-muted",t),...e}));P3.displayName=XT.displayName;const Em=[{value:"VIEW_DOCUMENT",label:"Chỉ xem"},{value:"EDIT_DOCUMENT",label:"Chỉnh sửa"},{value:"DOWNLOAD_DOCUMENT",label:"Tải xuống"}];function O3({onClose:t,open:e,file:n,apiBaseUrl:r,rootUrlHostApi:o}){const[i,s]=O.useState("users"),[l,u]=O.useState(""),[h,p]=O.useState(""),[g,C]=O.useState(""),[w,b]=O.useState(""),[v,x]=O.useState(Br.VIEW_DOCUMENT),[E,A]=O.useState([]),{users:N,groups:P,sharedUsers:_,sharedGroups:D,fetchData:H,loading:K,postGranted:ee,loadingGrandted:W,setSharedGroups:de,setSharedUsers:se}=FH(r,o),fe=Gi(),q=n?n.key:"",Z=N.filter(z=>{var ce;return(fe==null?void 0:fe.id)!==z.id&&(z.username.toLowerCase().includes(l.toLowerCase())||((ce=z.email)==null?void 0:ce.toLowerCase().includes(l.toLowerCase())))}),Y=P.filter(z=>z.groupname.toLowerCase().includes(h.toLowerCase())),oe=_.filter(z=>{var ce,Ae;return((ce=z.username)==null?void 0:ce.toLowerCase().includes(g.toLowerCase()))||((Ae=z.email)==null?void 0:Ae.toLowerCase().includes(g.toLowerCase()))}),Q=D.filter(z=>{var ce;return(ce=z.groupname)==null?void 0:ce.toLowerCase().includes(w.toLowerCase())}),X=z=>{x(z),A(ce=>ce.map(Ae=>({...Ae,permissions:z})))},$=()=>{i==="users"?(u(""),C("")):(p(""),b(""),s("users")),A([]),x(Br.VIEW_DOCUMENT)};O.useEffect(()=>{e?H(q):$()},[e,q]);const te=z=>{z!==i&&(i==="users"?(u(""),C("")):(p(""),b(""))),s(z)},_e=z=>{n&&A(ce=>{if(ce.find(ne=>ne.userId===z))return ce.filter(ne=>ne.userId!==z);const Ne={path:n.key+n.name,permissions:v,userId:z,grandtedBy:fe==null?void 0:fe.id};return[...ce,Ne]})},ke=z=>{if(!n)return;const ce=z.groupname;A(Ae=>{if(Ae.find(Ve=>Ve.groupname===ce))return Ae.filter(Ve=>Ve.groupname!==ce);const ne={path:n.key+n.name,permissions:v,groupname:ce,groupId:z.id,grandtedBy:fe==null?void 0:fe.id,users:z.users};return[...Ae,ne]})},xe=async(z,ce,Ae)=>{const Ce={...z,permissions:ce};A(Ne=>{const ne=Ne.map(Qe=>Qe.id===Ce.id?Ce:Qe);return Ne.some(Qe=>Qe.id===Ce.id)||ne.push(Ce),ne}),Ae==="users"?se(Ne=>Ne.map(ne=>ne.id===z.id?Ce:ne)):de(Ne=>Ne.map(ne=>ne.id===z.id?Ce:ne))},Pe=async()=>{if(n){const z=(n==null?void 0:n.key)||""+(n==null?void 0:n.name),ce=await ee(z,fe==null?void 0:fe.id,E);(ce==null?void 0:ce.status)==200&&A([])}},Te="flex-1 min-h-0 overflow-y-auto border rounded-lg px-3 py-2 bg-background shadow-sm";return n?d.jsx(or,{open:e,onOpenChange:t,children:d.jsxs(Kn,{className:"max-w-5xl h-[70vh] flex flex-col overflow-hidden",children:[d.jsx(Gn,{children:d.jsxs(jn,{className:"text-lg font-semibold",children:["Chia sẻ tài liệu: ",n.name]})}),d.jsxs(Cg,{defaultValue:"users",className:"mt-6 flex-1 flex flex-col overflow-hidden",children:[d.jsxs(Jd,{className:"grid grid-cols-2 w-1/2 mx-auto mb-4 bg-muted rounded-lg",children:[d.jsx(ji,{value:"users",className:"py-2",onClick:()=>te("users"),children:"Người dùng"}),d.jsx(ji,{value:"groups",className:"py-2",onClick:()=>te("groups"),children:"Nhóm"})]}),d.jsx(Wi,{value:"users",className:"flex-1 h-full min-h-0 overflow-hidden",children:d.jsxs("div",{className:"grid grid-cols-2 gap-6 h-full",children:[d.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[d.jsx("p",{className:"text-sm font-semibold mb-2",children:"Chia sẻ với người dùng:"}),d.jsx(Wn,{placeholder:"Tìm người dùng...",className:"mb-3 border-input bg-background shadow-sm",value:l,onChange:z=>u(z.target.value)}),d.jsx("div",{className:Te,children:K?d.jsx("div",{className:"flex items-center justify-center h-full",children:d.jsx(Pt,{className:"h-10 w-10 animate-spin text-muted-foreground"})}):Z.length===0?d.jsx("p",{className:"text-muted-foreground italic text-center h-full flex items-center justify-center",children:"Không tìm thấy người dùng."}):d.jsx("ul",{className:"space-y-2",children:Z.map(z=>d.jsx("li",{onClick:()=>_e(z.id),className:"flex flex-col space-y-1 cursor-pointer hover:bg-accent p-2 rounded-md transition-colors",children:d.jsxs("div",{className:"flex items-center space-x-3",children:[d.jsx(oc,{id:`user-${z.id}`,checked:!!E.find(ce=>ce.userId===z.id)}),d.jsxs(pr,{className:"flex-1",children:[d.jsx("p",{className:"font-medium",children:z.username}),d.jsx("p",{className:"text-xs text-muted-foreground",children:z.email}),d.jsx("p",{className:"text-xs text-muted-foreground",children:z.groupname})]})]})},z.id))})})]}),d.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[d.jsx("p",{className:"text-sm font-semibold mb-2",children:"Đã chia sẻ với người dùng:"}),d.jsx(Wn,{placeholder:"Tìm người dùng đã chia sẻ...",className:"mb-3 border-input bg-background shadow-sm",value:g,onChange:z=>C(z.target.value)}),d.jsx("div",{className:Te,children:K?d.jsx("div",{className:"flex items-center justify-center h-full",children:d.jsx(Pt,{className:"h-10 w-10 animate-spin text-muted-foreground"})}):oe.length===0?d.jsx("p",{className:"text-muted-foreground italic text-center h-full flex items-center justify-center",children:"Chưa chia sẻ với người dùng nào."}):d.jsx("ul",{className:"space-y-2",children:oe.map(z=>d.jsxs("li",{className:"flex items-center justify-between gap-4 hover:bg-accent p-2 rounded-md transition-colors",children:[d.jsxs("div",{className:"flex flex-col",children:[d.jsx("p",{className:"font-medium",children:z.username}),d.jsx("p",{className:"text-xs text-muted-foreground",children:z.email}),d.jsx("p",{className:"text-xs text-muted-foreground",children:z.groupname})]}),d.jsxs(Sm,{value:z.permissions,onValueChange:ce=>xe(z,ce,"users"),disabled:z.permissions===Br.OWNER_DOCUMENT,children:[d.jsx(bu,{className:"w-[120px]",children:d.jsx(_m,{placeholder:"Chọn quyền"})}),d.jsxs(xu,{children:[Em.map(ce=>d.jsx(Xi,{value:ce.value,children:ce.label},ce.value)),z.permissions===Br.OWNER_DOCUMENT&&d.jsx(Xi,{value:Br.OWNER_DOCUMENT,children:"Chủ sở hữu"},Br.OWNER_DOCUMENT),d.jsx(Xi,{value:"None",children:"Thu hồi"},"None")]})]})]},z.id))})})]})]})}),d.jsx(Wi,{value:"groups",className:"flex-1 h-full min-h-0 overflow-hidden",children:d.jsxs("div",{className:"grid grid-cols-2 gap-6 h-full",children:[d.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[d.jsx("p",{className:"text-sm font-semibold mb-2",children:"Chia sẻ với nhóm:"}),d.jsx(Wn,{placeholder:"Tìm nhóm...",className:"mb-3 border-input bg-background shadow-sm",value:h,onChange:z=>p(z.target.value)}),d.jsx("div",{className:Te,children:K?d.jsx("div",{className:"flex items-center justify-center h-full",children:d.jsx(Pt,{className:"h-10 w-10 animate-spin text-muted-foreground"})}):Y.length===0?d.jsx("p",{className:"text-muted-foreground italic text-center h-full flex items-center justify-center",children:"Không tìm thấy nhóm."}):d.jsx("ul",{className:"space-y-2",children:Y.map(z=>d.jsxs("li",{onClick:()=>ke(z),className:"flex items-center space-x-3 cursor-pointer hover:bg-accent p-2 rounded-md transition-colors",children:[d.jsx(oc,{id:`group-${z.groupname}`,checked:!!E.find(ce=>ce.groupname===z.groupname)}),d.jsxs(pr,{className:"font-medium",children:[d.jsx("p",{className:"font-medium",children:z.groupname}),d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Số lượng: ",z.users||0]})]})]},z.groupname))})})]}),d.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[d.jsx("p",{className:"text-sm font-semibold mb-2",children:"Đã chia sẻ với nhóm:"}),d.jsx(Wn,{placeholder:"Tìm nhóm đã chia sẻ...",className:"mb-3 border-input bg-background shadow-sm",value:w,onChange:z=>b(z.target.value)}),d.jsx("div",{className:Te,children:K?d.jsx("div",{className:"flex items-center justify-center h-full",children:d.jsx(Pt,{className:"h-10 w-10 animate-spin text-muted-foreground"})}):Q.length===0?d.jsx("p",{className:"text-muted-foreground italic text-center h-full flex items-center justify-center",children:"Chưa chia sẻ với nhóm nào."}):d.jsx("ul",{className:"space-y-2",children:Q.map(z=>d.jsxs("li",{className:"flex items-center justify-between gap-4 hover:bg-accent p-2 rounded-md transition-colors",children:[d.jsxs("div",{className:"flex flex-col",children:[d.jsx("p",{className:"font-medium",children:z.groupname}),d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Số lượng: ",z.users||0]})]}),d.jsxs(Sm,{value:z.permissions,onValueChange:ce=>xe(z,ce,"groups"),children:[d.jsx(bu,{className:"w-[120px]",children:d.jsx(_m,{placeholder:"Chọn quyền"})}),d.jsxs(xu,{children:[Em.map(ce=>d.jsx(Xi,{value:ce.value,children:ce.label},ce.value)),d.jsx(Xi,{value:"None",children:"Thu hồi"},"None")]})]})]},z.groupname))})})]})]})})]}),d.jsxs("div",{className:"mt-4 bg-muted/50 p-4 rounded-lg",children:[d.jsx(pr,{className:"font-medium mb-2 block",children:"Phân quyền:"}),d.jsxs(Sm,{value:v,onValueChange:X,children:[d.jsx(bu,{className:"w-1/2 border border-input bg-background shadow-sm hover:bg-accent",children:d.jsx(_m,{placeholder:"Chọn quyền truy cập"})}),d.jsx(xu,{children:Em.map(z=>d.jsx(Xi,{value:z.value,className:"flex items-center gap-2",children:z.label}))})]})]}),d.jsxs(Lr,{children:[d.jsx(He,{variant:"outline",onClick:t,children:"Huỷ"}),d.jsx(He,{variant:"default",onClick:Pe,disabled:E.length===0||W,className:"w-[120px] justify-center",children:W?d.jsx(Pt,{className:"h-4 w-4 animate-spin"}):"Lưu thay đổi"})]})]})}):null}const M3={},R3="AIzaSyBI8KiTWudkw8iR5cjH7ZsA4JBN1NqJw8A",D3="726815747852-5deq413t8kd8j3mgj48d46eatjauapq5.apps.googleusercontent.com",L3="https://www.googleapis.com/auth/drive";Po(Le,{retries:3,shouldResetTimeout:!0,retryCondition:t=>Po.isRetryableError(t)&&t.config.method==="get"});const Yn={current:!1},ZT="crawl:jobs",is="crawl:current_job",F3=t=>{const[e,n]=O.useState(null),[r,o]=O.useState(0);return O.useEffect(()=>{const i=localStorage.getItem(is);if(i){const s=JSON.parse(i);n(s),s!=null&&s.startTime&&o(Math.floor((Date.now()-s.startTime)/1e3))}},[]),O.useEffect(()=>{if(!(e!=null&&e.startTime))return;const i=setInterval(()=>{o(Math.floor((Date.now()-e.startTime)/1e3))},1e3);return()=>clearInterval(i)},[e==null?void 0:e.startTime]),O.useEffect(()=>{if(!(e!=null&&e.id))return;const i=async()=>{try{const u=(await Le.get(`${t}/api/crawl/${e.id}?taskId=${e.taskId}`)).data;n(h=>{if(!h)return null;const p={...h,status:u};return localStorage.setItem(is,JSON.stringify(p)),(u.status==="completed"||u.status==="failed")&&setTimeout(()=>{n(null),localStorage.removeItem(is)},100),p})}catch(l){console.error("Error polling job status:",l)}},s=setInterval(i,3e3);return i(),()=>clearInterval(s)},[e==null?void 0:e.id,t]),{currentJob:e,elapsedTime:r,setCurrentJob:i=>{i&&!i.startTime&&(i.startTime=Date.now()),n(i),i?localStorage.setItem(is,JSON.stringify(i)):localStorage.removeItem(is)}}},Su=(t,e)=>{const n=[],r=o=>{(t[o]||[]).forEach(s=>{n.push(s.key),s.isFolder&&r(s.key)})};return r(e),n},$3=(t,e)=>{const n=[];return(t[e]||[]).forEach(o=>{n.push(o.key),o.isFolder&&n.push(...Su(t,o.key))}),n},H3=(t,e,n=[],r,o,i,s,l,u,h)=>{const[p,g]=O.useState({}),[C,w]=O.useState(!1),[b,v]=O.useState(null),[x,E]=O.useState(0),A=O.useRef(e);O.useEffect(()=>{A.current=e},[e]);const N=async()=>{var _;w(!0);try{const D=Gi(),H=await Le.get(`${t}/api/files`,{params:{cache:!1,displayPrefixes:JSON.stringify(n),prefix:A.current,userId:(D==null?void 0:D.id)||"",groupId:((_=D==null?void 0:D.group)==null?void 0:_.id)||"",groupname:(D==null?void 0:D.groupname)||""},timeout:3e5}),K=[];Rd.forEach(H.data,(ee,W)=>{l!=null&&l.has(W)&&Rd.forEach(ee,de=>{(u==null?void 0:u.current[de.key])!==!1&&K.push(de.key)})}),K.length&&(h==null||h(ee=>{const W=new Set(ee);return K.forEach(de=>W.add(de)),W})),g(H.data),v(null)}catch(D){v(D instanceof Error?D:new Error("Failed to fetch files"))}finally{w(!1),E(0),i("")}},P=async _=>{var D,H;try{if(!_)return;w(!0);const K=await Le.get(`${t}/api/search-db?query=${_}&rootPrefix=${e}&offset=${(o-1)*20}&limit=20`,{timeout:3e5});return g({[e]:((D=K==null?void 0:K.data)==null?void 0:D.result)||[]}),E(((H=K==null?void 0:K.data)==null?void 0:H.estimatedTotalHits)||0),K}catch(K){v(K instanceof Error?K:new Error("Failed to fetch files"))}finally{w(!1)}};return O.useEffect(()=>{!r&&!C&&N(),r&&!C&&P(r)},[r,o]),{data:p,isLoading:C,error:b,estimatedTotalHits:x,refetch:N}},Zi=t=>{var r,o,i;const e=((i=(o=(r=t==null?void 0:t.name)==null?void 0:r.split("."))==null?void 0:o.pop())==null?void 0:i.toLowerCase())??"";return["txt","md","json","js","ts","jsx","tsx","css","html","xml","yaml","yml"].includes(e||"")},U3={auth:{clientId:"584d5fa9-5123-4602-a1a5-a3746a83745f",authority:"https://login.microsoftonline.com/consumers",redirectUri:M3.VITE_ONE_DRIVE_REDIRECT_URI||"https://s3-explorer.cmcts1.studio.ai.vn/sharepoint/redirect"}},B3=new dp(U3),Tm={[Br.VIEW_DOCUMENT]:1,[Br.DOWNLOAD_DOCUMENT]:2,[Br.EDIT_DOCUMENT]:10,[Br.OWNER_DOCUMENT]:100},ea=t=>{const e=Gi();return`${e==null?void 0:e.groupname}`.toUpperCase()==="MASTER_ADMIN"?!0:t?Tm[t]>=10:!1},z3=t=>{const e=Gi();return`${e==null?void 0:e.groupname}`.toUpperCase()==="MASTER_ADMIN"?!0:t?Tm[t]>=2:!1},V3=t=>{const e=Gi();return`${e==null?void 0:e.groupname}`.toUpperCase()==="MASTER_ADMIN"?!0:t?Tm[t]>=1:!1},K3=O.memo(({homeLabel:t="Kho tài liệu",apiBaseUrl:e="http://localhost:3000",rootPrefix:n="",rootUrlHostApi:r="http://localhost:3003/api/v1",asSelector:o=!1,onSelected:i=h=>console.log("Đã chọn:",h),displayPrefixes:s,preSelectedFiles:l,idCreator:u})=>{var Qc;const[h,p]=O.useState([]),[g,C]=O.useState(""),[w,b]=O.useState(new Set(l)),[v,x]=O.useState(n),[E,A]=O.useState(""),[N,P]=O.useState(!1),[_,D]=O.useState(""),[H,K]=O.useState(!1),[ee,W]=O.useState(null),[de,se]=O.useState(null),[fe,q]=O.useState(!1),[Z,Y]=O.useState(!1),[,oe]=O.useState(null),Q=O.useRef(null),{toast:X}=dc(),[$,te]=O.useState(null),[_e,ke]=O.useState(null),[xe,Pe]=O.useState(null),[Te,z]=O.useState(""),[ce,Ae]=O.useState(!1),[Ce,Ne]=O.useState(!1),[ne,Ve]=O.useState(new Set),[Qe,Ct]=O.useState(""),[Jt,bt]=O.useState(!1),[an,zt]=O.useState(!1),[Dn,Kt]=O.useState("rename"),[L,J]=O.useState(!1),[U,ae]=O.useState(""),[ye,he]=O.useState("1"),[Ee,Xe]=O.useState(!1),[ft,xt]=O.useState(!1),[vo,Qt]=O.useState(!1),[yn,Gr]=O.useState(!1),[Gt,cr]=O.useState(1),[jr,na]=O.useState(!1),{currentJob:Je,elapsedTime:Fo,setCurrentJob:_c}=F3(e),[yo,ra]=O.useState(null),[oa,ss]=O.useState(""),[ku,ia]=O.useState(!1),[cs,Nu]=O.useState(""),[Ec,Pu]=O.useState(!1),[Tc,Ou]=O.useState(!1),[ls,Mu]=O.useState([]),[aa,Ru]=O.useState(!1),[ds,Mm]=O.useState(""),$o=O.useRef({}),[Ac,Ic]=O.useState(null),Rm=async T=>{Ou(!0);try{const M=await Le.get(`${r}get-knowledge-base/knowledge-base-name/${T}`,{headers:{Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjAyOTliMmIwLTk4MGEtNGQ1Yy04NjkyLWJjNjllM2I1NzZlMiIsInVzZXJuYW1lIjoiY21jX3RzX2FkbWluIiwiaWF0IjoxNzQ3MTk0MTg3fQ.7LB2rgd0fQnhZP_cFgTTCPMSYl0_apwffcNEd7oqjeM"}});M.status===200&&Mu(M.data.knowledgeBase.chatflows.map(G=>({...G,KnowledgeBaseId:M.data.knowledgeBase.knowledge_base_id})))}catch{}finally{Ou(!1)}};O.useEffect(()=>{cs&&r&&Rm(cs)},[cs]),O.useEffect(()=>{console.log("pre selected files",l)},[l]);const[Mt,kc]=O.useState(null),[x0,Dm]=O.useState(!1),[Nc,Pc]=O.useState(!1),[sa,us]=O.useState(!1),[Du,Lu]=O.useState([]),[Oc,Mc]=O.useState([]),[ca,Rc]=O.useState([{id:"root",name:"OneDrive"}]),[Lm,fs]=O.useState(!1),[hs,Dc]=O.useState([]),[Fu,Ho]=O.useState(!1),[ps,Lc]=O.useState([]),[Fc,gs]=O.useState([]),[ms,$u]=O.useState([]),[$c,la]=O.useState([{id:"root",name:"SharePoint"}]),[wo,da]=O.useState(!1),[Hc,Uc]=O.useState([]),[gt,Wr]=O.useState(null),[Hu,ua]=O.useState(!1),[Fm,fa]=O.useState(!1),Uu=new URL(window.location.href).searchParams.get("prefix")||""||E||n,[S0,Um]=O.useState(null),{data:Tn,isLoading:Uo,error:Bm,estimatedTotalHits:ha,refetch:un}=H3(e,Uu,s,g,Gt,C,u,w,$o,b),[Bc,yr]=O.useState(!1),zc=O.useRef(null),Vc=Gi(),Ht=(()=>{const T=localStorage.getItem("dataLogin");try{if(T){const M=JSON.parse(T);return(M==null?void 0:M.user)??null}}catch{return null}return null})();O.useEffect(()=>{if(!Bc)return;function T(M){zc.current&&!zc.current.contains(M.target)&&yr(!1)}return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},[Bc]);const zm=async()=>{try{const T=await Le.get(`${e}/api/login-sharepoint`),{loginUrl:M}=T.data,G=window.open(M,"SharePoint Login","width=600,height=600");if(!G)throw new Error("Không thể mở cửa sổ pop-up");G.focus();const pe=setInterval(()=>{try{if(G.closed){clearInterval(pe);return}const be=G.location.href;if(be.includes("code=")){const Ie=new URL(be).searchParams.get("code");Ie&&(At(Ie),G.close(),clearInterval(pe))}}catch(be){be instanceof Error&&!be.message.includes("cross-origin")&&console.error("SharePoint login error:",be)}},1e3)}catch(T){st.error("Lỗi khi đăng nhập SharePoint: "+(T instanceof Error?T.message:"Lỗi không xác định"))}},Vm=async()=>{try{Lc([]),la([{id:"root",name:"SharePoint"}]),window.location.href="https://login.microsoftonline.com/common/oauth2/v2.0/logout?post_logout_redirect_uri="+encodeURIComponent(window.location.origin),X({title:"Success",description:"Logged out from SharePoint"})}catch(T){console.error("Error logging out from SharePoint:",T),X({title:"Error",description:"Failed to logout from SharePoint",variant:"destructive"})}},At=async T=>{try{const M=await Le.post(`${e}/api/get-sharepoint-access-token`,{code:T,userId:"1"}),{accessToken:G}=M.data;localStorage.setItem("sharepoint_access_token",G),Pc(!0),da(!0)}catch(M){console.error("❌ Error fetching SharePoint access token:",M),X({title:"Error",description:"Failed to connect to SharePoint",variant:"destructive"})}},It=async()=>{try{Ho(!0);const M=(await Le.post(`${e}/api/list-site-sharepoint`,{userId:"1"})).data.sites.map(G=>{const pe=new URL(G.webUrl);return{id:G.id,name:G.name,description:G.description,hostname:G.hostname||pe.hostname,sitePath:G.sitePath||pe.pathname.replace(/^\/+/,"")}});console.log("data",M),Uc(M),Ho(!1)}catch(T){console.error("❌ Error fetching SharePoint sites:",T),X({title:"Error",description:"Failed to fetch SharePoint sites",variant:"destructive"}),Ho(!1)}},Km=async T=>{Wr(T),console.log(T),await vs("root",T.name,T.hostname||"",T.sitePath||"")},vs=async(T,M,G,pe)=>{try{Ho(!0);const Ie=(await Le.post(`${e}/api/list-file-sharepoint`,{folderId:T,userId:"1",hostname:G,sitePath:pe})).data.files.map(Me=>({id:Me.id,name:Me.name,size:Me.size??0,lastModified:Me.lastModifiedDateTime?new Date(Me.lastModifiedDateTime):new Date,contentType:Me.mimeType??void 0,isFolder:Me.type==="folder",parentId:Me.parentId??""}));gs(Ie.filter(Me=>Me.isFolder)),Lc(Ie.filter(Me=>!Me.isFolder)),da(!0),la(Me=>Me.some(jt=>jt.id===T)?Me:[...Me,{id:T,name:M==="root"?"SharePoint":M}]),Ho(!1)}catch(be){console.error("❌ Error fetching SharePoint files:",be),X({title:"Error",description:"Failed to fetch SharePoint files",variant:"destructive"}),Ho(!1)}},Gm=T=>{$u(M=>M.some(pe=>pe.id===T.id)?M.filter(pe=>pe.id!==T.id):[...M,{id:T.id,name:T.name,size:T.size,lastModified:T.lastModified,contentType:T.contentType,isFolder:T.isFolder,parentId:T.parentId}])},jm=T=>{var G;la(pe=>pe.slice(0,T+1));const M=(G=$c[T])==null?void 0:G.id;M&&vs(M,"SharePoint",(gt==null?void 0:gt.hostname)||"",(gt==null?void 0:gt.sitePath)||"")},Wm=async(T,M)=>{const G=localStorage.getItem("sharepoint_access_token");if(!G){st.error("Không tìm thấy access token. Vui lòng đăng nhập lại.");return}const pe=st.loading("Đang đồng bộ SharePoint...",{position:"bottom-right",autoClose:!1});try{const be={prefix:M,folders:[],files:[],hostname:(gt==null?void 0:gt.hostname)||"",sitePath:(gt==null?void 0:gt.sitePath)||""};T.forEach(Me=>{Me.isFolder?be.folders.push({id:Me.id,name:Me.name}):be.files.push({id:Me.id,name:Me.name})});const Ie=await Le.post(`${e}/api/sync-sharepoint-to-s3`,be,{headers:{Authorization:`Bearer ${G}`}});un(),st.update(pe,{render:`Đồng bộ thành công! Đã tải lên ${Ie.data.uploadedKeys.length} file.`,type:"success",isLoading:!1,autoClose:3e3,position:"bottom-right"}),da(!1)}catch(be){console.error("Lỗi khi đồng bộ file từ SharePoint:",be),st.update(pe,{render:"Không thể đồng bộ file từ SharePoint.",type:"error",isLoading:!1,autoClose:3e3,position:"bottom-right"})}},Bu=()=>{da(!1),Lc([]),$u([]),la([{id:"root",name:"SharePoint"}])};O.useEffect(()=>{if(wo){const M=new URLSearchParams(window.location.search).get("code");M&&(At(M),window.history.replaceState({},document.title,window.location.pathname))}},[wo]),O.useEffect(()=>{B3.initialize().then(()=>{Dm(!0)}).catch(T=>console.error("❌ Lỗi khởi tạo MSAL:",T))},[]),O.useEffect(()=>{zu()},[]);async function zu(){localStorage.getItem("onedrive_access_token")&&Pc(!0)}const Vu=T=>{Dc(M=>M.some(pe=>pe.id===T.id)?M.filter(pe=>pe.id!==T.id):[...M,{id:T.id,name:T.name,size:T.size,lastModified:T.lastModified,contentType:T.contentType,isFolder:T.isFolder,parentId:T.parentId}])};function Xt(T){if(T===0)return"0 B";const M=1024,G=["B","KB","MB","GB","TB"],pe=Math.floor(Math.log(T)/Math.log(M));return parseFloat((T/Math.pow(M,pe)).toFixed(1))+" "+G[pe]}function Kc(T){const M=new Date(T);return M.toLocaleDateString()+" "+M.toLocaleTimeString()}const Bo=async()=>{try{const T=await Le.get(`${e}/api/login-one-drive`),{loginUrl:M}=T.data,G=window.open(M,"OneDrive Login","width=600,height=600");if(!G)throw new Error("Không thể mở cửa sổ pop-up");G.focus();const pe=setInterval(()=>{try{if(G.closed){clearInterval(pe);return}const be=G.location.href;if(be.includes("code=")){const Ie=new URL(be).searchParams.get("code");Ie&&(Gc(Ie),G.close(),clearInterval(pe))}}catch(be){be instanceof Error&&!be.message.includes("cross-origin")&&console.error("OneDrive login error:",be)}},1e3)}catch(T){st.error("Lỗi khi đăng nhập OneDrive: "+(T instanceof Error?T.message:"Lỗi không xác định"))}},Ku=async()=>{try{await Le.post(`${e}/api/logout-one-drive`),localStorage.removeItem("onedrive_access_token"),st.success("Đã đăng xuất khỏi OneDrive"),window.location.href="https://login.microsoftonline.com/common/oauth2/v2.0/logout?post_logout_redirect_uri="+encodeURIComponent(window.location.origin)}catch(T){st.error("Lỗi khi đăng xuất OneDrive: "+(T instanceof Error?T.message:"Lỗi không xác định"))}},Gc=async T=>{try{const G=await Le.post(`${e}/api/get-one-drive-access-token`,{authorizationCode:T,userId:"1"}),{accessToken:pe}=G.data;localStorage.setItem("onedrive_access_token",pe),Pc(!0),us(!0),await wn("root","One Drive")}catch(M){console.error("❌ Lỗi khi lấy Access Token:",M)}},wn=async(T,M)=>{try{fs(!0);const be=(await Le.post(`${e}/api/list-file-one-drive`,{folderId:T,userId:"1"})).data.map(Ie=>({id:Ie.id,name:Ie.name,size:Ie.size??0,lastModified:Ie.lastModifiedDateTime?new Date(Ie.lastModifiedDateTime):new Date,contentType:Ie.mimeType??void 0,isFolder:Ie.type==="folder",parentId:Ie.parentId??""}));Lu(be.filter(Ie=>Ie.isFolder)),Mc(be.filter(Ie=>!Ie.isFolder)),us(!0),Rc(Ie=>Ie.some(Me=>Me.id===T)?Ie:[...Ie,{id:T,name:M==="root"?"OneDrive":M}]),fs(!1)}catch(G){console.error("Lỗi lấy danh sách file:",G),fs(!1)}},Gu=T=>{if(T===ca.length-1)return;const M=ca[T];M&&(Rc(ca.slice(0,T+1)),wn(M.id,M.name))},ju=async(T,M)=>{const G=localStorage.getItem("onedrive_access_token");if(!G){st.error("Không tìm thấy access token. Vui lòng đăng nhập lại.");return}const pe=st.loading("Đang đồng bộ OneDrive...",{position:"bottom-right",autoClose:!1});try{const be={prefix:M,folders:[],files:[]};T.forEach(Me=>{Me.isFolder?be.folders.push({id:Me.id,name:Me.name}):be.files.push({id:Me.id,name:Me.name})});const Ie=await Le.post(`${e}/api/sync-one-drive-to-s3`,be,{headers:{Authorization:`Bearer ${G}`}});un(),st.update(pe,{render:`Đồng bộ thành công! Đã tải lên ${Ie.data.uploadedKeys.length} file.`,type:"success",isLoading:!1,autoClose:3e3,position:"bottom-right"})}catch(be){console.error("Lỗi khi đồng bộ file từ OneDrive:",be),st.update(pe,{render:"Không thể đồng bộ file từ OneDrive.",type:"error",isLoading:!1,autoClose:3e3,position:"bottom-right"})}},jc=()=>{us(!1),Rc([{id:"root",name:"OneDrive"}]),Lu([]),Mc([]),Dc([]),fs(!1)},Wu=hM({onSuccess:T=>{Um(T.access_token),localStorage.setItem("google_access_token",T.access_token),qu(T.access_token)},onError:()=>{console.log("Đăng nhập thất bại!")},scope:L3}),qu=T=>{const M=document.createElement("script");M.src="https://apis.google.com/js/api.js",M.onload=()=>{window.gapi.load("picker",()=>Yu(T))},document.body.appendChild(M)},Yu=T=>{const M=new window.google.picker.DocsView(window.google.picker.ViewId.DOCS).setIncludeFolders(!0).setSelectFolderEnabled(!0).setOwnedByMe(!1),G=new window.google.picker.DocsView(window.google.picker.ViewId.DRIVE).setIncludeFolders(!0).setSelectFolderEnabled(!0);new window.google.picker.PickerBuilder().setDeveloperKey(R3).setOAuthToken(T).enableFeature(window.google.picker.Feature.MULTISELECT_ENABLED).setLocale("vi").addView(M).addView(G).setCallback(async be=>{if(be.action===window.google.picker.Action.PICKED){const Ie=be.docs.map(Me=>({id:Me.id,name:Me.name,mimeType:Me.mimeType}));await Ln(Ie,v)}}).build().setVisible(!0)},Ln=async(T,M="")=>{const G=localStorage.getItem("google_access_token");if(!G){console.error("❌ Không tìm thấy access token. Vui lòng đăng nhập lại."),st.error("Không tìm thấy access token. Vui lòng đăng nhập lại.",{position:"bottom-right"});return}const pe=st.loading("Đang đồng bộ...",{position:"bottom-right",autoClose:!1});try{const be={prefix:M,folders:[],files:[]};T.forEach(Me=>{Me.mimeType==="application/vnd.google-apps.folder"?be.folders.push({id:Me.id,name:Me.name}):be.files.push({id:Me.id,name:Me.name})});const Ie=await Le.post(`${e}/api/sync-drive-to-s3`,be,{headers:{Authorization:`Bearer ${G}`}});Yn.current=!0,un(),st.update(pe,{render:`Đồng bộ thành công! Đã tải lên ${Ie.data.uploadedKeys.length} file.`,type:"success",isLoading:!1,autoClose:3e3,position:"bottom-right"})}catch(be){console.error("❌ Lỗi khi đồng bộ file từ Google Drive:",be),st.update(pe,{render:"Không thể đồng bộ file từ Google Drive.",type:"error",isLoading:!1,autoClose:3e3,position:"bottom-right"})}};O.useEffect(()=>{const T=M=>{if(M.data.action==="logout"){const G=document.createElement("iframe");G.style.display="none",G.src="https://accounts.google.com/Logout",document.body.appendChild(G),setTimeout(()=>document.body.removeChild(G),2e3)}};return window.addEventListener("message",T),()=>window.removeEventListener("message",T)},[]),O.useEffect(()=>{const T=new Set(l);b(T)},[]),O.useEffect(()=>{Je!=null&&Je.status&&(Je.status.status==="completed"?(X({title:"Thu thập website hoàn tất",description:`Đã thu thập thành công ${Je.url} với ${Je.status.completed} trang`}),Yn.current=!0,un()):Je.status.status==="failed"&&X({title:"Thu thập website thất bại",description:`Không thể thu thập ${Je.url}. Vui lòng thử lại.`,variant:"destructive"}))},[(Qc=Je==null?void 0:Je.status)==null?void 0:Qc.status]);const Ju=O.useMemo(()=>Tn[v]||[],[Tn,v]),Zt=O.useMemo(()=>Ju.filter(T=>V3(T.permission)),[Ju,v,Tn]),pa=O.useMemo(()=>{const T={};return Zt.forEach((M,G)=>{w.has(M.key)&&(T[G]=!0)}),T},[w,Zt]),Qu=T=>{const M=Su(Tn,T);if(M.length===0)return w.has(T)?"all":"none";const G=M.filter(pe=>w.has(pe)).length;return G===0?"none":G===M.length?"all":"partial"},Fn=(T,M=!0)=>{if(v!==T){if(u&&!v)na(!0),A(T+u),x(T+u);else if(na(!0),A(T),x(T),M&&!o){const G=window.location.pathname==="/"?"":window.location.pathname,pe=T?`${window.location.origin}${G}?prefix=${encodeURIComponent(T)}`:`${window.location.origin}${G}`;window.history.pushState({path:pe},"",pe)}}};O.useEffect(()=>{jr&&(Yn.current=!0,un().finally(()=>na(!1)))},[jr]);const ys=async(T,M)=>{var G,pe;K(!0);try{if(Zt.some(jt=>jt.isFolder&&jt.name.toLowerCase()===T.toLowerCase())){X({title:"Lỗi",description:`Thư mục "${T}" đã tồn tại trong thư mục hiện tại.`,variant:"destructive"}),K(!1);return}const Ie=`${M}${T}/`;if((await Le.post(`${e}/api/create-folder`,{prefix:Ie,userId:(Vc==null?void 0:Vc.id)||""})).status!==200){X({title:"Lỗi",description:"Không thể tạo thư mục",variant:"destructive"});return}Yn.current=!0,await un(),X({title:"Đã tạo thư mục",description:`Đã tạo thành công thư mục "${T}"`}),D(""),P(!1)}catch(be){console.error("Error creating folder:",be);const Ie=((pe=(G=be==null?void 0:be.response)==null?void 0:G.data)==null?void 0:pe.error)||"Không thể tạo thư mục";X({title:"Lỗi",description:Ie,variant:"destructive"})}finally{K(!1)}},ga=async(T,M,G)=>{var pe,be,Ie,Me,jt,Yr,ma,Ko,tf;oe(G),Qt(!0);try{if(Array.from(T).reduce((cn,ya)=>cn+ya.size,0)>=100*1024*1024){X({title:"Lỗi",description:"Tổng kích thước các tập tin vượt quá 100 MB",variant:"destructive"}),oe(null),Qt(!1);return}const Ei=Array.from(T).filter(cn=>cn.size===0);if(Ei.length>0){const cn=Ei.map(ya=>ya.name).join(", ");X({title:"Lỗi tải lên",description:`Không thể tải lên tập tin rỗng: ${cn}`,variant:"destructive"}),Qt(!1),oe(null);return}const Co=new FormData;if(Ht!=null&&Ht.id&&Co.append("metadata",JSON.stringify({creator:Ht.username,creatorId:Ht.id,DataSource:"Tệp tải lên"})),G==="folder"&&T[0]){const cn=T[0].webkitRelativePath.split("/")[0];cn&&Co.append("folderName",cn)}Co.append("prefix",M),Array.from(T).forEach(cn=>G==="folder"?Co.append("files",cn,cn.webkitRelativePath):Co.append("files",cn)),Yn.current=!0;const kt=await Le.post(`${e}/api/check-files-existed`,Co,{headers:{"Content-Type":"multipart/form-data"}});if(((pe=kt==null?void 0:kt.data)==null?void 0:pe.status)===200)await Le.post(`${e}/api/upload`,Co,{headers:{"Content-Type":"multipart/form-data"},timeout:0}),C(""),A(M),setTimeout(async()=>{oe(null),await un(),Qt(!1),await Vo("upload")},500);else{if(((Ie=(be=kt==null?void 0:kt.data)==null?void 0:be.names)==null?void 0:Ie.length)>0&&!((Me=kt==null?void 0:kt.data)!=null&&Me.isFolder)){const cn=Array.from(T).filter(ya=>kt.data.names.includes(ya.name));ra(cn),ia(!0)}(jt=kt==null?void 0:kt.data)!=null&&jt.isFolder&&((Yr=kt==null?void 0:kt.data)!=null&&Yr.name)&&(ss((ma=kt==null?void 0:kt.data)==null?void 0:ma.name),ra(T),ia(!0))}}catch(va){console.error("Lỗi tải lên:",va);const Ei=((tf=(Ko=va==null?void 0:va.response)==null?void 0:Ko.data)==null?void 0:tf.error)||"Không thể tải lên tập tin";X({title:"Lỗi",description:Ei,variant:"destructive"}),oe(null),Qt(!1)}},Lt=async()=>{var T,M;try{Qt(!0);const G=new FormData;if(yo){oe(oa?"folder":"files"),ia(!1);let pe=localStorage.getItem("dataLogin"),be;try{pe&&(pe=JSON.parse(pe),be=pe.user)}catch{pe=null}if(oa&&yo[0]){const Ie=yo[0].webkitRelativePath.split("/")[0];Ie&&G.append("folderName",Ie)}G.append("prefix",v),Array.from(yo).forEach(Ie=>oa&&yo[0]?G.append("files",Ie,Ie.webkitRelativePath):G.append("files",Ie)),be!=null&&be.id&&G.append("metadata",JSON.stringify({creator:be.username,creatorId:be.id,DataSource:"Tệp tải lên"})),await Le.post(`${e}/api/upload`,G,{headers:{"Content-Type":"multipart/form-data"},timeout:0}),C(""),A(v),Yn.current=!0}}catch(G){console.error("Lỗi tải lên:",G);const pe=((M=(T=G==null?void 0:G.response)==null?void 0:T.data)==null?void 0:M.error)||"Không thể tải lên tập tin";X({title:"Lỗi",description:pe,variant:"destructive"})}finally{setTimeout(async()=>{oe(null),await un(),Qt(!1),ss(""),ra(null),await Vo("overwrite")},500)}},qr=async T=>{var M;try{if(await Le.delete(`${e}/api/files`,{data:{paths:[T.key]}}),w.has(T.key)){const pe=new Set(w);pe.delete(T.key),b(pe)}const G=((M=T.key)==null?void 0:M.replace(/^(.*?)(\/.*)?$/,(pe,be,Ie)=>!Ie||Ie==="/"?"":be+"/"))||"";A(G),Yn.current=!0,X({title:"Đã xóa tập tin",description:`Đã xóa thành công "${T.name}"`}),W(null),await Vo("delete")}catch(G){console.error("Error deleting file:",G),X({title:"Lỗi",description:"Không thể xóa tập tin",variant:"destructive"})}finally{Gr(!1),await un()}},xi=T=>{const M=new Set(w),G=typeof T=="function"?T(pa):T;new Set(Object.keys(pa).map(Number)).forEach(be=>{const Ie=Zt[be];Ie&&(G[be]||(M.delete(Ie.key),Ie.isFolder&&Su(Tn,Ie.key).forEach(Me=>M.delete(Me))))}),Object.entries(G).forEach(([be,Ie])=>{const Me=parseInt(be),jt=Zt[Me];jt&&Ie&&(M.add(jt.key),jt.isFolder&&Su(Tn,jt.key).forEach(Yr=>M.add(Yr)))}),b(M)},qm=async()=>{var T;q(!0);try{const M=Array.from(w),G=M.map(be=>Object.values(Tn).flat().find(Ie=>Ie.key===be)).filter(be=>be!==void 0);if(G.length===0){X({title:"Lỗi",description:"Không có tập tin nào được chọn để xóa",variant:"destructive"});return}await Le.delete(`${e}/api/files`,{data:{paths:M}});const pe=((T=G[0])==null?void 0:T.key.replace(/^(.*?)(\/.*)?$/,(be,Ie,Me)=>!Me||Me==="/"?"":Ie+"/"))||"";A(pe),Yn.current=!0,un(),X({title:"Đã xóa tập tin",description:`Đã xóa thành công ${G.length} mục`}),Y(!1),b(new Set),await Vo("bulk-delete")}catch(M){console.error("Error deleting files:",M),X({title:"Lỗi",description:"Không thể xóa các tập tin đã chọn",variant:"destructive"})}finally{q(!1)}},Wc=async(T,M)=>{if(!v.trim()){X({title:"Lỗi",description:"Không thể đổi tên tập tin hoặc thư mục ở thư mục gốc. Chỉ có thể xóa.",variant:"destructive"});return}Ne(!0);try{const G=T.key;let pe;T.isFolder?pe=G.split("/").slice(0,-2).join("/")+"/":pe=G.substring(0,G.lastIndexOf("/")+1);const be=pe+M+(T.isFolder?"/":"");await Le.post(`${e}/api/rename`,{oldPath:G,newPath:be}),Yn.current=!0,await un(),X({title:"Đã đổi tên",description:`Đã đổi tên thành công "${T.name}" thành "${M}"`}),te(null),z(""),Pe(null),await Vo("rename")}catch(G){console.error("Error renaming item:",G),X({title:"Lỗi",description:"Không thể đổi tên",variant:"destructive"})}finally{Ne(!1)}},Ym=async T=>{Ve(M=>new Set([...M,...T]));try{const M=await Le.post(`${e}/api/download`,{paths:T},{responseType:"blob"}),G=window.URL.createObjectURL(M.data),pe=document.createElement("a");pe.href=G;const be=M.headers["Content-Disposition"]||M.headers["content-disposition"],Ie=be==null?void 0:be.match(/filename="(.+)"/),Me=Ie?decodeURIComponent(Ie[1]):"download.zip";pe.setAttribute("download",Me),document.body.appendChild(pe),pe.click(),document.body.removeChild(pe),window.URL.revokeObjectURL(G),X({title:"Bắt đầu tải xuống",description:`Đã bắt đầu tải xuống ${T.length} mục${T.length>1,""}`})}catch(M){console.error("Error downloading files:",M),X({title:"Lỗi",description:"Không thể tải xuống tập tin",variant:"destructive"})}finally{Ve(M=>{const G=new Set(M);return T.forEach(pe=>G.delete(pe)),G})}},Xu=v?v.replace(n,"").split("/").filter(Boolean):[],Jm=()=>{let T=Array.from(w).map(G=>({key:G}));T.length>1&&(T=T.filter(G=>G.key!==n));const M=G=>Rd.findIndex(T,pe=>!pe.key.endsWith("/")&&pe.key.startsWith(G))!==-1;return T=T.filter(G=>G.key.endsWith("/")?!M(G.key):!0),T},qc=O.useMemo(()=>{const T=[...(Ht==null?void 0:Ht.role)!=="MASTER_ADMIN"&&(Ht==null?void 0:Ht.role)!=="SITE_ADMIN"&&(v===""||v==="/")?[]:[{id:"select",header:()=>{const M=$3(Tn,v),G=M.length>0&&M.every(be=>w.has(be)),pe=M.some(be=>w.has(be));return d.jsx(oc,{checked:G?!0:pe?"indeterminate":!1,onCheckedChange:be=>{if(be){const Ie=Zt.reduce((Me,jt,Yr)=>(Me[Yr]=!0,Me),{});xi(Ie)}else{for(const Ie of Array.from(w))Ie.startsWith(v)&&(w.delete(Ie),$o.current[Ie]=!1);Rd.forEach($o.current,(Ie,Me)=>{Me.startsWith(v)&&($o.current[Me]=!1)}),xi({})}},"aria-label":"Chọn tất cả"})},cell:({row:M})=>{const G=M.original;let be=G.isFolder?Qu(G.key):w.has(G.key)?"all":"none";if(be==="none"&&G.key.endsWith("/")){for(const Ie of Array.from(w))if(Ie.startsWith(G.key)){be="all";break}}return d.jsx("div",{className:"flex items-center",children:d.jsx(oc,{checked:be==="partial"?"indeterminate":be==="all",onCheckedChange:Ie=>{var jt,Yr;const Me={...pa};if(Ie?Me[M.index]=!0:delete Me[M.index],$o.current[((jt=M.original)==null?void 0:jt.key)||"_"]=!!Ie,(Yr=M.original)!=null&&Yr.key.endsWith("/"))for(const ma of Array.from(w))ma.startsWith(M.original.key)&&($o.current[M.original.key]=!1,w.delete(ma));xi(Me)},"aria-label":"Chọn dòng"})})},enableSorting:!1}],{id:"fileName",header:({column:M})=>d.jsxs(He,{variant:"ghost",onClick:()=>M.toggleSorting(M.getIsSorted()==="asc"),children:["Tên tập tin",d.jsx(rg,{})]}),accessorKey:"name",cell:({row:M})=>{const G=M.original,pe=G.key.substring(0,G.key.lastIndexOf("/"))||"/",be=g.trim()!==""&&pe!==v,Ie=pe.split("/").filter(Boolean);return d.jsxs("div",{className:"flex flex-col group",children:[d.jsxs("div",{className:"flex items-center",children:[d.jsxs("div",{className:`flex items-center gap-2 ${G.isFolder?"cursor-pointer hover:text-blue-600":""}`,onClick:()=>{G.isFolder&&Fn(G.key)},children:[G.isFolder?d.jsx(Ks,{className:"h-5 w-5 text-blue-500"}):null,G.name]}),d.jsx("button",{className:"ml-2 opacity-0 group-hover:opacity-100 transition-opacity",onClick:Me=>{Me.stopPropagation(),navigator.clipboard.writeText(G.key),X({title:"Copied to clipboard",description:`Path: ${G.key}`,duration:2e3})},title:"Copy path to clipboard",children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),d.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]}),be&&d.jsxs("div",{className:"text-sm text-gray-500 flex items-center",children:[d.jsx(Ks,{className:"h-4 w-4 text-gray-500 my-auto"}),d.jsxs("span",{className:"flex items-center ml-1",children:[d.jsx("span",{className:"cursor-pointer hover:text-blue-600",onClick:()=>{Fn("")},children:"/"}),Ie.map((Me,jt)=>d.jsxs("span",{className:"flex items-center",children:[d.jsx("span",{className:"cursor-pointer hover:text-blue-600",onClick:()=>{Fn(Ie.slice(0,jt+1).join("/")+"/")},children:Me}),jt<Ie.length-1&&d.jsx("span",{children:"/"})]},jt))]})]})]})}}];return o||T.push({id:"size",header:({column:M})=>d.jsxs(He,{variant:"ghost",onClick:()=>M.toggleSorting(M.getIsSorted()==="asc"),children:["Kích thước",d.jsx(rg,{})]}),accessorKey:"size",cell:({getValue:M,row:G})=>{const pe=M();return d.jsx("span",{children:G.original.isFolder?"-":Xt(pe)})}},{id:"lastModified",header:({column:M})=>d.jsxs(He,{variant:"ghost",onClick:()=>M.toggleSorting(M.getIsSorted()==="asc"),className:"px-0 w-full flex-row justify-end",children:["Sửa đổi lần cuối",d.jsx(rg,{})]}),accessorKey:"lastModified",cell:({row:M})=>{const G=M.original.lastModified;return d.jsx("div",{className:"w-full flex-row justify-end items-center text-right",children:d.jsx("span",{children:G&&Rx(G).isValid()?Rx(G).format("DD/MM/YYYY HH:mm"):"-"})})},size:200},{id:"actions",header:()=>d.jsx("span",{children:"Hành động"}),accessorKey:"key",cell:({row:M})=>d.jsxs("div",{className:"flex items-center gap-2",children:[v===""&&r&&d.jsx(gr,{children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsx(He,{variant:"ghost",size:"icon",onClick:()=>{Nu(M.original.key),Pu(!0)},className:"h-8 w-8 p-0",children:ne.has(M.original.key)?d.jsx(Pt,{className:"h-4 w-4 animate-spin"}):d.jsx(mO,{className:"h-4 w-4"})})}),d.jsx(sr,{children:"Những Flow sử dụng Folder này làm Data"})]})}),d.jsx(gr,{children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:!M.original.isFolder&&d.jsx(He,{variant:"ghost",size:"icon",onClick:()=>Ym([M.original.key]),className:"h-8 w-8 p-0",disabled:!z3(M.original.permission)||ne.has(M.original.key),children:ne.has(M.original.key)?d.jsx(Pt,{className:"h-4 w-4 animate-spin"}):d.jsx(fO,{className:"h-4 w-4"})})}),d.jsx(sr,{children:"Tải xuống"})]})}),v.trim()!==""&&(ea(M.original.permission)?d.jsx(gr,{children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsx(He,{variant:"ghost",size:"icon",onClick:()=>{te(M.original),z(M.original.name)},className:"h-8 w-8 p-0",disabled:!ea(M.original.permission),children:d.jsx(SO,{className:"h-4 w-4"})})}),d.jsx(sr,{children:"Đổi tên"})]})}):d.jsx(gr,{children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsx(He,{variant:"ghost",size:"icon",onClick:()=>{console.log("call"),ke(M.original)},className:"h-8 w-8 p-0",disabled:M.original.isFolder,children:d.jsx($x,{className:"h-4 w-4"})})}),d.jsx(sr,{children:"Xem"})]})})),d.jsx(gr,{children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsx(He,{variant:"ghost",size:"icon",onClick:()=>{Ae(!0),se(M.original)},className:"h-8 w-8 p-0",disabled:!ea(M.original.permission),children:d.jsx(zD,{className:"h-4 w-4"})})}),d.jsx(sr,{children:"Di chuyển"})]})}),!((Ht==null?void 0:Ht.role)!=="MASTER_ADMIN"&&(Ht==null?void 0:Ht.role)!=="SITE_ADMIN"&&(v===""||v==="/"))&&d.jsx(gr,{children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsx(He,{variant:"ghost",size:"icon",onClick:()=>W(M.original),className:"h-8 w-8 p-0",disabled:!ea(M.original.permission),children:d.jsx(RC,{className:"h-4 w-4"})})}),d.jsx(sr,{children:"Xóa"})]})}),d.jsx(gr,{children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsx(He,{variant:"ghost",size:"icon",onClick:()=>Ic(M.original),className:"h-8 w-8 p-0",disabled:!ea(M.original.permission),children:d.jsx(MC,{className:"h-4 w-4"})})}),d.jsx(sr,{children:"Chia sẻ"})]})})]})}),T},[w,Zt,pa,ne,o]),Si=Kb({data:Zt,columns:qc,state:{rowSelection:pa,sorting:h},onSortingChange:p,enableRowSelection:!0,onRowSelectionChange:xi,getCoreRowModel:Vb(),getSortedRowModel:WM()}),zo=async T=>{var M,G;bt(!0);try{if(Zi(T)){const pe=await Le.get(`${e}/api/read-text`,{params:{path:T.key}});Ct(pe.data.content)}try{const pe=await Le.get(`${e}/api/read-json`,{params:{path:T.key+".metadata.json"}}),be=((G=(M=pe==null?void 0:pe.data)==null?void 0:M.content)==null?void 0:G.metadataAttributes)||null;return Pe({fullPath:$==null?void 0:$.key,...be})}catch{return Pe("Lỗi phân tích siêu dữ liệu")}}catch(pe){console.error("Error loading file content:",pe),X({title:"Lỗi",description:"Không thể tải nội dung tập tin",variant:"destructive"})}finally{bt(!1)}},Qm=async(T,M)=>{zt(!0);try{await Le.post(`${e}/api/modify-text`,{path:T.key,content:M}),X({title:"Đã lưu tập tin",description:"Nội dung tập tin đã được cập nhật thành công"}),Yn.current=!0,await un(),te(null),Ct(""),Kt("rename"),await Vo("edit-content")}catch(G){console.error("Error saving file content:",G),X({title:"Lỗi",description:"Không thể lưu nội dung tập tin",variant:"destructive"})}finally{zt(!1)}},Zu=async T=>{zt(!0);try{await Le.post(`${e}/api/modify-json`,{path:T.key+".metadata.json",content:{metadataAttributes:xe}}),X({title:"Đã lưu tập tin",description:"Nội dung tập tin đã được cập nhật thành công"}),Yn.current=!0,await un(),te(null),Ct(""),Kt("rename")}catch(M){console.error("Error saving file content:",M),X({title:"Lỗi",description:"Không thể lưu nội dung tập tin",variant:"destructive"})}finally{zt(!1)}};O.useEffect(()=>{$&&($.isFolder||zo($),Kt("rename"))},[$]),O.useEffect(()=>{_e&&!_e.isFolder&&zo(_e)},[_e]);const Yc=async(T,M)=>{var G;if(Je){X({title:"Đang thu thập website",description:"Vui lòng đợi cho công việc thu thập hiện tại hoàn thành.",variant:"destructive"});return}Xe(!0);try{const{data:pe}=await Le.post(`${e}/api/crawl`,{url:T,limit:M,prefix:v});if(pe.id){_c({id:pe.id,url:T,limit:M,prefix:v,taskId:((G=pe.task)==null?void 0:G.id)||""});const be=localStorage.getItem(ZT),Ie=be?JSON.parse(be):[];Ie.some(Me=>Me.id===pe.id)||(Ie.unshift({url:T,id:pe.id,limit:M,prefix:v,timestamp:Date.now()}),Ie.length>20&&(Ie.length=20),localStorage.setItem(ZT,JSON.stringify(Ie))),X({title:"Bắt đầu thu thập website",description:`Đã thêm nhiệm vụ thu thập ${T} với giới hạn ${M}. Dữ liệu sẽ có sẵn sau khi thu thập hoàn tất.`}),J(!1),ae(""),he("1")}}catch(pe){console.error("Error crawling website:",pe),X({title:"Lỗi",description:"Không thể bắt đầu thu thập website",variant:"destructive"})}finally{Xe(!1)}},Jc=async()=>{try{if(!(Je!=null&&Je.id))return;_c(null),localStorage.removeItem(is),X({title:"Đã dừng thu thập",description:`Đã dừng thu thập website ${Je.url}`})}catch(T){console.error("Error stopping job:",T),X({title:"Lỗi",description:"Không thể dừng thu thập website",variant:"destructive"})}};O.useEffect(()=>{if(o)return;const T=(M=!0)=>{const pe=new URL(window.location.href).searchParams.get("prefix")||"";pe?Fn(pe,!1):(M&&!l&&b(new Set),A(n),x(n),Yn.current=!0,setTimeout(()=>{un()},0))};return T(!1),window.addEventListener("popstate",()=>T(!0)),()=>{window.removeEventListener("popstate",()=>T(!0))}},[]);const ws=async()=>{Ru(!0);try{await Le.post(`${e}/api/prediction-report`),X({title:"Xuất báo cáo thành công",description:"Báo cáo dự đoán đã được xuất"})}catch(T){console.error("Error exporting report:",T),X({title:"Lỗi",description:"Không thể xuất báo cáo dự đoán",variant:"destructive"})}finally{Ru(!1)}},ef=async()=>{try{const T=Gi();T&&(await Le.post(`${e}/api/start-ingestion-job`,{prefix:v,user_id:T.id,userName:T.username})).status===200&&await _i()}catch(T){xt(!1),console.log(T)}},Vo=async T=>{try{ds&&v.includes(ds)&&(console.log(`Auto syncing knowledge base after ${T} operation`),await _i())}catch(M){console.log(`Error auto syncing after ${T}:`,M)}},wr=O.useRef(),_i=async()=>{try{xt(!0);const T=await Le.post(`${e}/api/get-ingestion-job-status`,{prefix:v}),{status:M}=T==null?void 0:T.data;M==="FAILED"||M==="COMPLETE"||M==="STOPPED"||M==="STOPPING"||!M?(xt(!1),wr.current&&(clearInterval(wr.current),wr.current=null),kc(T==null?void 0:T.data)):(wr.current||(wr.current=setInterval(()=>_i(),5e3)),kc(T==null?void 0:T.data))}catch(T){console.log(T)}},Xm=()=>{const T=Array.from(w);let M;return v?M=T.filter(G=>G.startsWith(v)&&G!==v).length:M=new Set(T.filter(G=>G.split("/").shift())).size,`Đang chọn: ${M}`};return O.useEffect(()=>{const T=v==null?void 0:v.split("/")[0];return T!==ds&&(xt(!1),wr.current&&(clearInterval(wr.current),wr.current=null),Mm(T||""),kc(null),T&&_i()),()=>{}},[ds,v]),O.useEffect(()=>{wo&&Hc.length===0&&(It(),Wr(null))},[wo]),O.useEffect(()=>{if(l)for(const T of Array.from(l))$o.current[T]=!0},[]),d.jsxs("div",{className:"space-y-4 s3-explr-container",children:[d.jsx(s_,{}),d.jsx(or,{open:ku,onOpenChange:T=>{ia(T),T||(ss(""),ra(null),Qt(!1),oe(null))},children:d.jsxs(Kn,{children:[d.jsxs(Gn,{children:[d.jsx(jn,{children:"Cảnh báo trùng lặp"}),d.jsxs(gi,{children:[oa&&d.jsxs(d.Fragment,{children:["Folder $",oa," đã có."]}),yo&&yo.length>0&&d.jsxs(d.Fragment,{children:["Những tệp sau bị lặp:",d.jsx("ul",{className:"mt-2 list-disc pl-5 text-sm text-red-600",children:Array.from(yo).map((T,M)=>d.jsx("li",{children:T.name},M))})]})]})]}),d.jsxs(Lr,{children:[d.jsx(He,{variant:"outline",onClick:()=>{ia(!1),ss(""),ra(null),Qt(!1),oe(null)},children:"Bỏ qua"}),d.jsx(He,{variant:"destructive",onClick:()=>Lt(),children:"Ghi đè"})]})]})}),d.jsx(Fd,{className:"s3-explr-breadcrumb",children:d.jsxs($d,{className:"s3-explr-breadcrumb-list",children:[d.jsx(nc,{className:"s3-explr-breadcrumb-item",children:d.jsx(rc,{onClick:()=>Fn(n),className:"flex items-center gap-1 cursor-pointer s3-explr-breadcrumb-home",children:t})}),!u&&Xu.map((T,M)=>d.jsxs("div",{className:"flex items-center",children:[d.jsx(Hd,{className:"s3-explr-breadcrumb-separator"},`sep-${M}`),d.jsx(nc,{className:"s3-explr-breadcrumb-item",children:d.jsx(rc,{onClick:()=>Fn(n+Xu.slice(0,M+1).join("/")+"/"),className:"cursor-pointer s3-explr-breadcrumb-link",children:T})},`item-${T}`)]},M))]})}),d.jsxs("div",{className:"flex items-center space-x-4 s3-explr-toolbar",children:[d.jsx("div",{className:"relative max-w-sm w-full s3-explr-search-container",children:d.jsx(LH,{ref:Q,onChange:T=>C(T)})}),d.jsxs(He,{variant:"outline",size:"sm",onClick:()=>{A(v),Yn.current=!0,un()},disabled:Uo,className:"flex items-center gap-2 s3-explr-refresh-btn",children:[d.jsx(nd,{className:`h-4 w-4 s3-explr-refresh-icon ${Uo?"animate-spin":""}`}),"Làm mới"]}),v&&v!=="/"&&d.jsx(gr,{delayDuration:0,children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsxs(He,{variant:"outline",size:"sm",onClick:()=>{Uo||ft||(xt(!0),ef())},"aria-disabled":Uo||ft,className:"flex items-center gap-2 s3-explr-refresh-btn aria-disabled:opacity-50",children:[d.jsx(nd,{className:`h-4 w-4 s3-explr-refresh-icon ${Uo||ft?"animate-spin":""}`}),"Đồng bộ KB"]})}),Mt&&d.jsx(sr,{side:"right",sideOffset:5,children:d.jsxs("div",{className:"space-y-2 p-3 max-w-md",children:[d.jsx("p",{className:"font-semibold text-lg border-b pb-1",children:"Thông tin đồng bộ"}),d.jsx("div",{className:"space-y-1",children:d.jsxs("p",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"font-medium",children:"Trạng thái:"}),d.jsxs("span",{className:`flex items-center gap-1 font-semibold ${Mt.status==="COMPLETE"?"text-green-600":Mt.status==="FAILED"?"text-red-600":"text-yellow-600"}`,children:[Mt.status==="COMPLETE"&&d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),Mt.status==="FAILED"&&d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),Mt.status!=="COMPLETE"&&Mt.status!=="FAILED"&&d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 animate-spin",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:d.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),sL(Mt.status)]})]})}),Mt.statistics&&d.jsxs("div",{className:"space-y-1 border-t pt-2",children:[d.jsx("p",{className:"font-medium text-gray-50",children:"Thống kê xử lý:"}),d.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-sm",children:[d.jsxs("div",{className:"flex justify-between",children:[d.jsx("span",{children:"Tài liệu quét:"}),d.jsx("span",{className:"font-medium",children:Mt.statistics.numberOfDocumentsScanned})]}),d.jsxs("div",{className:"flex justify-between",children:[d.jsx("span",{children:"Metadata quét:"}),d.jsx("span",{className:"font-medium",children:Mt.statistics.numberOfMetadataDocumentsScanned})]}),d.jsxs("div",{className:"flex justify-between",children:[d.jsx("span",{children:"Tài liệu mới:"}),d.jsx("span",{className:"font-medium text-green-600",children:Mt.statistics.numberOfNewDocumentsIndexed})]}),d.jsxs("div",{className:"flex justify-between",children:[d.jsx("span",{children:"Tài liệu sửa:"}),d.jsx("span",{className:"font-medium text-blue-600",children:Mt.statistics.numberOfModifiedDocumentsIndexed})]}),d.jsxs("div",{className:"flex justify-between",children:[d.jsx("span",{children:"Metadata sửa:"}),d.jsx("span",{className:"font-medium text-blue-600",children:Mt.statistics.numberOfMetadataDocumentsModified})]}),d.jsxs("div",{className:"flex justify-between",children:[d.jsx("span",{children:"Tài liệu xóa:"}),d.jsx("span",{className:"font-medium text-orange-600",children:Mt.statistics.numberOfDocumentsDeleted})]}),d.jsxs("div",{className:"flex justify-between col-span-2",children:[d.jsx("span",{children:"Tài liệu lỗi:"}),d.jsx("span",{className:"font-medium text-red-600",children:Mt.statistics.numberOfDocumentsFailed})]})]})]}),d.jsxs("div",{className:"space-y-1 border-t pt-2 text-sm text-gray-200",children:[d.jsx("p",{className:"font-medium text-gray-50",children:"Chi tiết Job:"}),d.jsxs("p",{children:[d.jsx("span",{className:"font-medium",children:"DataSource ID:"})," ",Mt.dataSourceId]}),d.jsxs("p",{children:[d.jsx("span",{className:"font-medium",children:"Ingestion Job ID:"})," ",Mt.ingestionJobId]}),d.jsxs("p",{children:[d.jsx("span",{className:"font-medium",children:"Knowledge Base ID:"})," ",Mt.knowledgeBaseId]}),d.jsxs("p",{children:[d.jsx("span",{className:"font-medium",children:"Job trong queue:"})," ",Mt.is_still_in_stock?"Còn":"Không"]})]}),Mt.errorMessage&&d.jsxs("div",{className:"border-t pt-2",children:[d.jsx("p",{className:"text-red-600 font-medium",children:"Lỗi:"}),d.jsx("p",{className:"text-red-600 text-sm bg-red-50 p-2 rounded",children:Mt.errorMessage})]}),Mt.failureReasons&&Mt.failureReasons.length>0&&d.jsx($H,{failureReasons:Mt.failureReasons})]})})]})}),ea(Tn==null?void 0:Tn.prefixPermission)&&d.jsxs("div",{className:"relative",ref:zc,children:[d.jsxs(He,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-add-file-btn bg-[#1682fe] hover:bg-[#0f6cd4] text-white rounded-md px-4 py-2 transition-colors aria-disabled:hidden",onClick:()=>yr(T=>!T),"aria-disabled":(Ht==null?void 0:Ht.role)!=="MASTER_ADMIN"&&(Ht==null?void 0:Ht.role)!=="SITE_ADMIN"&&(v===""||v==="/"),children:[d.jsx(EO,{className:"w-4 h-4"}),"Add file"]}),Bc&&d.jsxs("div",{className:"absolute z-50 mt-2 right-0 w-56 bg-white border rounded-lg shadow-lg py-2 flex flex-col",children:[d.jsxs("button",{className:"flex items-center px-4 py-2 text-sm hover:bg-gray-100 text-left",onClick:()=>{yr(!1);const T=document.createElement("input");T.type="file",T.multiple=!0,T.onchange=M=>{const G=M.target.files;G&&ga(G,v,"files")},T.click()},children:[d.jsx(up,{className:"h-4 w-4 mr-2"})," Tải tệp tin"]}),d.jsxs("button",{className:"flex items-center px-4 py-2 text-sm hover:bg-gray-100 text-left",onClick:()=>{yr(!1);const T=document.createElement("input");T.type="file",T.multiple=!0,T.webkitdirectory=!0,T.onchange=M=>{const G=M.target.files;G&&ga(G,v,"folder")},T.click()},children:[d.jsx(Ks,{className:"h-4 w-4 mr-2"})," Tải lên thư mục"]}),d.jsxs("button",{className:"flex items-center px-4 py-2 text-sm hover:bg-gray-100 text-left",disabled:!!s&&!v,onClick:()=>P(!0),children:[d.jsx(yO,{className:"h-4 w-4 mr-2 s3-explr-folder-plus-icon"}),"Thư mục mới"]}),d.jsxs("button",{className:"flex items-center px-4 py-2 text-sm hover:bg-gray-100 text-left",onClick:()=>{yr(!1),J(!0)},children:[d.jsx(bO,{className:"h-4 w-4 mr-2"})," Thêm Website"]}),d.jsxs("button",{className:"flex items-center px-4 py-2 text-sm hover:bg-gray-100 text-left",onClick:()=>{yr(!1),Wu()},children:[d.jsxs("svg",{viewBox:"0 0 87.3 78",xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-2",children:[d.jsx("path",{d:"m6.6 66.85 3.85 6.65c.8 1.4 1.95 2.5 3.3 3.3l13.75-23.8h-27.5c0 1.55.4 3.1 1.2 4.5z",fill:"#0066da"}),d.jsx("path",{d:"m43.65 25-13.75-23.8c-1.35.8-2.5 1.9-3.3 3.3l-25.4 44a9.06 9.06 0 0 0 -1.2 4.5h27.5z",fill:"#00ac47"}),d.jsx("path",{d:"m73.55 76.8c1.35-.8 2.5-1.9 3.3-3.3l1.6-2.75 7.65-13.25c.8-1.4 1.2-2.95 1.2-4.5h-27.502l5.852 11.5z",fill:"#ea4335"}),d.jsx("path",{d:"m43.65 25 13.75-23.8c-1.35-.8-2.9-1.2-4.5-1.2h-18.5c-1.6 0-3.15.45-4.5 1.2z",fill:"#00832d"}),d.jsx("path",{d:"m59.8 53h-32.3l-13.75 23.8c1.35.8 2.9 1.2 4.5 1.2h50.8c1.6 0 3.15-.45 4.5-1.2z",fill:"#2684fc"}),d.jsx("path",{d:"m73.4 26.5-12.7-22c-.8-1.4-1.95-2.5-3.3-3.3l-13.75 23.8 16.15 28h27.45c0-1.55-.4-3.1-1.2-4.5z",fill:"#ffba00"})]})," ","Đồng bộ Google Drive"]}),d.jsxs("button",{className:"flex items-center px-4 py-2 text-sm hover:bg-gray-100 text-left",onClick:()=>{yr(!1),Bo()},children:[d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",className:"h-4 w-4 mr-2",children:[d.jsx("path",{fill:"#094ab2",d:"M47.3 28.2C45.3 18.6 37.1 12 28 12c-8.5 0-15.9 5.6-18.4 13.5C4.2 27.2 0 32.2 0 38c0 6.6 5.4 12 12 12h36c8.3 0 16-6.6 16-15.5 0-6.8-4.9-12.4-11.7-13.3z"}),d.jsx("path",{fill:"#0067c5",d:"M44.9 30.1c-.2 0-.4-.1-.6-.1H26c-3.3 0-6 2.7-6 6 0 .9.2 1.8.6 2.6-1.7-.7-3.5-1.1-5.5-1.1C7.6 37.5 4 41.5 4 46s3.6 8.5 8.1 8.5h34.3c6.8 0 12.6-5.4 12.6-12s-5.5-11.6-11.1-12.4z"})]})," ","Đồng bộ OneDrive"]}),d.jsxs("button",{className:"flex items-center px-4 py-2 text-sm hover:bg-gray-100 text-left",onClick:()=>{yr(!1),zm()},children:[d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",className:"h-4 w-4 mr-2",children:[d.jsx("path",{fill:"#036C70",d:"M19 14.5v-9c0-.28-.22-.5-.5-.5h-13c-.28 0-.5.22-.5.5v9c0 .28.22.5.5.5h13c.28 0 .5-.22.5-.5z"}),d.jsx("path",{fill:"#17828F",d:"M16 17.5v-9c0-.28-.22-.5-.5-.5h-13c-.28 0-.5.22-.5.5v9c0 .28.22.5.5.5h13c.28 0 .5-.22.5-.5z"}),d.jsx("path",{fill:"#4DB6AC",d:"M13 20.5v-9c0-.28-.22-.5-.5-.5h-13c-.28 0-.5.22-.5.5v9c0 .28.22.5.5.5h13c.28 0 .5-.22.5-.5z"}),d.jsx("path",{fill:"#fff",d:"M4.5 15.5v-3c0-.28.22-.5.5-.5h3c.28 0 .5.22.5.5v3c0 .28-.22.5-.5.5H5c-.28 0-.5-.22-.5-.5z"})]})," ","Đồng bộ SharePoint"]})]})]}),ea((Tn==null?void 0:Tn.prefixPermission)&&w.size>0)&&d.jsxs(He,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-add-file-btn bg-[#1682fe] hover:bg-[#0f6cd4] text-white rounded-md px-4 py-2 transition-colors aria-disabled:hidden",onClick:()=>Ic({contentType:"application/x-directory",isFolder:!0,key:v||"/",lastModified:"-",name:"",size:0}),children:[d.jsx(MC,{className:"w-4 h-4"}),"Chia sẻ"]}),!o&&d.jsxs(d.Fragment,{children:[w.size>0&&d.jsx(d.Fragment,{children:d.jsxs(or,{open:Z,onOpenChange:Y,children:[d.jsx(ic,{asChild:!0,children:d.jsxs(He,{variant:"destructive",size:"sm",className:"flex items-center gap-2 s3-explr-bulk-delete-btn",children:[d.jsx(RC,{className:"h-4 w-4 s3-explr-trash-icon"}),"Xóa đã chọn (",w.size,")"]})}),d.jsxs(Kn,{className:"s3-explr-dialog-content",children:[d.jsxs(Gn,{className:"s3-explr-dialog-header",children:[d.jsx(jn,{className:"s3-explr-dialog-title",children:"Xác nhận xóa hàng loạt"}),d.jsxs(gi,{className:"s3-explr-dialog-description",children:["Bạn có chắc chắn muốn xóa ",w.size," mục đã chọn? Hành động này không thể hoàn tác."]})]}),d.jsxs(Lr,{className:"s3-explr-dialog-footer",children:[d.jsx(He,{variant:"outline",onClick:()=>Y(!1),className:"s3-explr-cancel-btn",children:"Hủy"}),d.jsx(He,{variant:"destructive",onClick:qm,disabled:fe,className:"s3-explr-confirm-delete-btn",children:fe?d.jsxs(d.Fragment,{children:[d.jsx(Pt,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang xóa..."]}):"Xóa đã chọn"})]})]})]})}),!u&&d.jsxs(or,{open:N,onOpenChange:P,children:[d.jsx(ic,{asChild:!0}),d.jsxs(Kn,{className:"s3-explr-dialog-content",children:[d.jsx(Gn,{className:"s3-explr-dialog-header",children:d.jsx(jn,{className:"s3-explr-dialog-title",children:"Tạo thư mục mới"})}),d.jsxs("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:[d.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[d.jsx(pr,{htmlFor:"name",className:"s3-explr-label",children:"Tên thư mục"}),d.jsx(Wn,{disabled:H,id:"name",value:_,onChange:T=>D(T.target.value),placeholder:"Nhập tên thư mục",className:"s3-explr-input"})]}),d.jsxs(He,{onClick:()=>{_.trim()&&ys(_,v)},disabled:H,className:"s3-explr-create-btn",children:[H&&d.jsx(Pt,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),H?"Đang tạo...":"Tạo"]})]})]})]}),u&&!v?d.jsx(d.Fragment,{}):d.jsxs("div",{className:"flex items-center gap-2 s3-explr-upload-group",children:[Je?d.jsx(gr,{delayDuration:0,children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(He,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-add-website-btn",disabled:!0,children:[d.jsx(Pt,{className:"h-4 w-4 animate-spin s3-explr-loader"}),Je.status?d.jsxs(d.Fragment,{children:[Je.status.isProcessing?"Đang thu thập ":"Đang quét sitemap ","(",Je.status.completed,"/",Je.status.total,") -"," ",Math.floor(Fo/60),":",String(Fo%60).padStart(2,"0")]}):"Đang thu thập..."]}),d.jsxs(He,{variant:"destructive",size:"sm",onClick:()=>void Jc(),className:"flex items-center gap-2",children:[d.jsx("span",{className:"sr-only",children:"Dừng thu thập"}),d.jsx(IO,{className:"h-4 w-4"})]})]})}),Je.status&&d.jsx(sr,{side:"right",sideOffset:5,children:d.jsxs("div",{className:"space-y-1 p-2",children:[d.jsxs("p",{className:"font-semibold",children:["Đang thu thập ",Je==null?void 0:Je.url]}),d.jsxs("p",{children:["Tiến độ: ",Je==null?void 0:Je.status.completed,"/",Je==null?void 0:Je.status.total," ","trang"]}),d.jsxs("p",{children:["Thời gian: ",Math.floor(Fo/60),":",String(Fo%60).padStart(2,"0")]}),d.jsxs("p",{children:["Trạng thái:"," ",(Je==null?void 0:Je.status.status)==="scraping"?"Đang thu thập":(Je==null?void 0:Je.status.status)==="completed"?"Hoàn thành":"Thất bại"]})]})})]})}):!u&&d.jsxs(or,{open:L,onOpenChange:J,children:[d.jsx(ic,{asChild:!0}),d.jsxs(Kn,{className:"s3-explr-dialog-content",children:[d.jsxs(Gn,{className:"s3-explr-dialog-header",children:[d.jsx(jn,{className:"s3-explr-dialog-title",children:"Thêm website"}),d.jsx(gi,{className:"s3-explr-dialog-description",children:"Nhập URL website để thu thập và thêm vào S3."})]}),d.jsxs("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:[d.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[d.jsx(pr,{htmlFor:"websiteUrl",className:"s3-explr-label",children:"URL Website"}),d.jsx(Wn,{id:"websiteUrl",value:U,onChange:T=>ae(T.target.value),placeholder:"https://example.com",type:"url",disabled:Ee,className:"s3-explr-input"})]}),d.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[d.jsx(pr,{htmlFor:"crawlLimit",className:"s3-explr-label",children:"Giới hạn thu thập"}),d.jsx(Wn,{id:"crawlLimit",value:ye,onChange:T=>{const M=T.target.value;/^\d*$/.test(M)&&he(M)},placeholder:"1",type:"text",disabled:Ee,className:"s3-explr-input"}),d.jsx("p",{className:"text-sm text-gray-500",children:"Số lượng liên kết cần thu thập (mặc định: 1)"})]})]}),d.jsxs(Lr,{className:"s3-explr-dialog-footer",children:[d.jsx(He,{variant:"outline",onClick:()=>{J(!1),ae(""),he("1")},disabled:Ee,className:"s3-explr-cancel-btn",children:"Hủy"}),d.jsx(He,{onClick:()=>{U.trim()&&Yc(U.trim(),parseInt(ye)||1)},disabled:Ee||!U.trim(),className:"s3-explr-crawl-btn",children:Ee?d.jsxs(d.Fragment,{children:[d.jsx(Pt,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang thu thập..."]}):"Bắt đầu thu thập"})]})]})]}),v.startsWith("BKTTW/")&&d.jsx(gr,{delayDuration:0,children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsxs(He,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-add-website-btn",disabled:!!s&&!v,onClick:ws,children:[aa&&d.jsx(nd,{className:`h-4 w-4 s3-explr-refresh-icon ${aa?"animate-spin":""}`}),"Xuất báo cáo"]})}),(Je==null?void 0:Je.status)&&d.jsx(sr,{side:"right",sideOffset:5,children:d.jsxs("div",{className:"space-y-1 p-2",children:[d.jsxs("p",{className:"font-semibold",children:["Đang thu thập ",Je.url]}),d.jsxs("p",{children:["Tiến độ: ",Je.status.completed,"/",Je.status.total," ","trang"]}),d.jsxs("p",{children:["Thời gian: ",Math.floor(Fo/60),":",String(Fo%60).padStart(2,"0")]}),d.jsxs("p",{children:["Trạng thái:"," ",Je.status.status==="scraping"?"Đang thu thập":Je.status.status==="completed"?"Hoàn thành":"Thất bại"]})]})})]})}),d.jsxs(or,{open:L,onOpenChange:J,children:[d.jsx(ic,{asChild:!0}),d.jsxs(Kn,{className:"s3-explr-dialog-content",children:[d.jsxs(Gn,{className:"s3-explr-dialog-header",children:[d.jsx(jn,{className:"s3-explr-dialog-title",children:"Thêm website"}),d.jsx(gi,{className:"s3-explr-dialog-description",children:"Nhập URL website để thu thập và thêm vào S3."})]}),d.jsxs("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:[d.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[d.jsx(pr,{htmlFor:"websiteUrl",className:"s3-explr-label",children:"URL Website"}),d.jsx(Wn,{id:"websiteUrl",value:U,onChange:T=>ae(T.target.value),placeholder:"https://example.com",type:"url",disabled:Ee,className:"s3-explr-input"})]}),d.jsxs("div",{className:"space-y-2 s3-explr-input-group",children:[d.jsx(pr,{htmlFor:"crawlLimit",className:"s3-explr-label",children:"Giới hạn thu thập"}),d.jsx(Wn,{id:"crawlLimit",value:ye,onChange:T=>{const M=T.target.value;/^\d*$/.test(M)&&he(M)},placeholder:"1",type:"text",disabled:Ee,className:"s3-explr-input"}),d.jsx("p",{className:"text-sm text-gray-500",children:"Số lượng liên kết cần thu thập (mặc định: 1)"})]})]}),d.jsxs(Lr,{className:"s3-explr-dialog-footer",children:[d.jsx(He,{variant:"outline",onClick:()=>{J(!1),ae(""),he("1")},disabled:Ee,className:"s3-explr-cancel-btn",children:"Hủy"}),d.jsx(He,{onClick:()=>{U.trim()&&Yc(U.trim(),parseInt(ye)||1)},disabled:Ee||!U.trim(),className:"s3-explr-crawl-btn",children:Ee?d.jsxs(d.Fragment,{children:[d.jsx(Pt,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang thu thập..."]}):"Bắt đầu thu thập"})]})]})]})]}),v.startsWith("BKTTW/")&&d.jsx(gr,{delayDuration:0,children:d.jsxs(mr,{children:[d.jsx(vr,{asChild:!0,children:d.jsxs(He,{variant:"outline",size:"sm",className:"flex items-center gap-2 s3-explr-add-website-btn",disabled:!!s&&!v,onClick:ws,children:[aa&&d.jsx(nd,{className:`h-4 w-4 s3-explr-refresh-icon ${aa?"animate-spin":""}`}),"Xuất báo cáo"]})}),aa&&d.jsx(sr,{sideOffset:5,children:"Đang xuất báo cáo"})]})}),d.jsxs("div",{className:"flex items-center gap-4",children:[sa&&d.jsxs(Gs,{open:sa,onOpenChange:us,children:[d.jsx(Ga,{className:"fixed inset-0 bg-black bg-opacity-50 z-50"}),d.jsxs(ja,{className:"fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-white p-6 rounded-lg shadow-lg w-[700px] max-w-[90vw] max-h-[80vh] z-50 flex flex-col",children:[d.jsxs("div",{className:"relative",children:[d.jsx(Ep,{asChild:!0,children:d.jsx("button",{className:"absolute top-2 right-2 text-gray-600",onClick:jc,children:"✖"})}),d.jsx("h2",{className:"text-lg font-semibold",children:"My OneDrive"}),d.jsx(Fd,{className:"onedrive-breadcrumb",children:d.jsx($d,{className:"onedrive-breadcrumb-list",children:ca.map((T,M)=>d.jsxs("div",{className:"flex items-center",children:[M>0&&d.jsx(Hd,{className:"onedrive-breadcrumb-separator"}),d.jsx(nc,{className:"onedrive-breadcrumb-item",children:d.jsx(rc,{onClick:()=>Gu(M),className:"cursor-pointer onedrive-breadcrumb-link",children:T.name})})]},M))})})]}),d.jsx("div",{className:"space-y-2 mt-4 flex-1 overflow-y-auto",children:Lm?d.jsx("div",{className:"text-sm text-gray-500",children:"Đang tải nội dung thư mục... Vui lòng đợi."}):d.jsx(d.Fragment,{children:[...Du,...Oc].length>0?[...Du,...Oc].map(T=>d.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg hover:bg-gray-100 ${hs.some(M=>M.id===T.id)?"bg-blue-100":""}`,children:[d.jsx("input",{type:"checkbox",checked:hs.some(M=>M.id===T.id),onChange:M=>{M.stopPropagation(),Vu(T)},className:"cursor-pointer"}),T.isFolder?d.jsx(Ks,{className:"text-blue-500 w-5 h-5 cursor-pointer",onClick:()=>wn(T.id,T.name)}):d.jsx(up,{className:"text-gray-500 w-5 h-5"}),d.jsxs("div",{className:"flex-1",children:[d.jsx("div",{className:`font-medium ${T.isFolder?"cursor-pointer text-blue-600":""}`,onClick:()=>{T.isFolder?wn(T.id,T.name):Vu(T)},children:T.name}),!T.isFolder&&d.jsxs("div",{className:"text-xs text-gray-500",children:[Xt(T.size)," •"," ",Kc(T.lastModified.toISOString())]})]})]},T.id)):d.jsx("div",{className:"text-sm text-gray-500",children:"Không có thư mục hoặc tệp nào."})})}),d.jsx("div",{className:"mt-4 flex flex-wrap justify-end gap-2",children:d.jsx(He,{onClick:()=>{ju(hs,v),jc()},className:"bg-[#1682fe] hover:bg-[#0f6cd4] text-white rounded-md px-4 py-2 transition-colors",disabled:hs.length===0,children:"Đồng bộ"})}),d.jsx("button",{onClick:()=>fa(!0),className:"absolute bottom-4 left-4 text-gray-600 hover:text-gray-800",title:"Đăng xuất OneDrive",children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),d.jsx("polyline",{points:"16 17 21 12 16 7"}),d.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]})})]})]}),d.jsxs(Gs,{open:Fm,onOpenChange:fa,children:[d.jsx(Ga,{className:"fixed inset-0 bg-black bg-opacity-50 z-[60]"}),d.jsxs(ja,{className:"fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-white p-6 rounded-lg shadow-lg w-[400px] max-w-[90vw] z-[60]",children:[d.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Xác nhận đăng xuất"}),d.jsx("p",{className:"text-gray-600 mb-6",children:"Bạn có chắc chắn muốn đăng xuất khỏi OneDrive?"}),d.jsxs("div",{className:"flex justify-end gap-2",children:[d.jsx(He,{variant:"outline",onClick:()=>fa(!1),children:"Hủy"}),d.jsx(He,{variant:"destructive",onClick:()=>{Ku(),fa(!1)},children:"Đăng xuất"})]})]})]}),wo&&d.jsxs(Gs,{open:wo,onOpenChange:da,children:[d.jsx(Ga,{className:"fixed inset-0 bg-black bg-opacity-50 z-50"}),d.jsxs(ja,{className:"fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-white p-6 rounded-lg shadow-lg w-[700px] max-w-[90vw] max-h-[80vh] z-50 flex flex-col",children:[d.jsxs("div",{className:"relative",children:[d.jsx(Ep,{asChild:!0,children:d.jsx("button",{className:"absolute top-2 right-2 text-gray-600",onClick:Bu,children:"✖"})}),d.jsxs("div",{className:"flex items-center gap-2",children:[gt&&d.jsx("button",{onClick:()=>Wr(null),className:"text-gray-600 hover:text-gray-800",children:d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),d.jsx("h2",{className:"text-lg font-semibold",children:"My SharePoint"})]}),gt&&d.jsx(Fd,{className:"sharepoint-breadcrumb",children:d.jsx($d,{className:"sharepoint-breadcrumb-list",children:$c.map((T,M)=>d.jsxs("div",{className:"flex items-center",children:[M>0&&d.jsx(Hd,{className:"sharepoint-breadcrumb-separator"}),d.jsx(nc,{className:"sharepoint-breadcrumb-item",children:d.jsx(rc,{onClick:()=>jm(M),className:"cursor-pointer sharepoint-breadcrumb-link",children:T.name})})]},M))})})]}),d.jsx("div",{className:"space-y-2 mt-4 flex-1 overflow-y-auto",children:Fu?d.jsx("div",{className:"text-sm text-gray-500",children:"Đang tải nội dung thư mục... Vui lòng đợi."}):gt?[...Fc,...ps].length===0?d.jsx("div",{className:"text-sm text-gray-500",children:"Không có thư mục hoặc tệp nào."}):[...Fc,...ps].map(T=>{const M=ms.some(G=>G.id===T.id);return d.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg hover:bg-gray-100 ${M?"bg-blue-100":""}`,children:[d.jsx("input",{type:"checkbox",checked:M,onChange:G=>{G.stopPropagation(),Gm(T)},className:"cursor-pointer"}),T.isFolder?d.jsx(Ks,{className:"text-blue-500 w-5 h-5 cursor-pointer",onClick:()=>vs(T.id,T.name,(gt==null?void 0:gt.hostname)||"",(gt==null?void 0:gt.sitePath)||"")}):d.jsx(up,{className:"text-gray-500 w-5 h-5"}),d.jsxs("div",{className:"flex-1",children:[d.jsx("div",{className:`font-medium ${T.isFolder?"cursor-pointer text-blue-600":""}`,onClick:()=>{T.isFolder&&vs(T.id,T.name,(gt==null?void 0:gt.hostname)||"",(gt==null?void 0:gt.sitePath)||"")},children:T.name}),!T.isFolder&&d.jsxs("div",{className:"text-xs text-gray-500",children:[Xt(T.size)," •"," ",T.lastModified.toLocaleString()]})]})]},T.id)}):d.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-6",children:Hc.map(T=>d.jsxs("div",{className:"cursor-pointer bg-white shadow-md rounded-xl p-5 flex flex-col justify-center items-start transition-shadow duration-200 hover:shadow-lg border border-gray-100 min-h-[120px]",style:{overflow:"hidden",wordBreak:"break-word",textOverflow:"ellipsis",whiteSpace:"normal"},onClick:()=>Km(T),children:[d.jsx("div",{className:"font-bold text-lg mb-1 truncate w-full",title:T.name,children:T.name}),d.jsx("div",{className:"text-sm text-gray-500 truncate w-full",title:T.description,children:T.description})]},T.id))})}),d.jsx("div",{className:"mt-4 flex flex-wrap justify-end gap-2",children:gt&&d.jsxs(d.Fragment,{children:[d.jsx(He,{onClick:()=>{Wm(ms,v),Bu()},className:"bg-[#1682fe] hover:bg-[#0f6cd4] text-white rounded-md px-4 py-2 transition-colors",disabled:ms.length===0,children:"Đồng bộ"}),d.jsx(He,{onClick:()=>Wr(null),children:"Quay lại"})]})}),d.jsx("button",{onClick:()=>ua(!0),className:"absolute bottom-4 left-4 text-gray-600 hover:text-gray-800",title:"Đăng xuất SharePoint",children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),d.jsx("polyline",{points:"16 17 21 12 16 7"}),d.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]})})]})]}),d.jsxs(Gs,{open:Hu,onOpenChange:ua,children:[d.jsx(Ga,{className:"fixed inset-0 bg-black bg-opacity-50 z-[60]"}),d.jsxs(ja,{className:"fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-white p-6 rounded-lg shadow-lg w-[400px] max-w-[90vw] z-[60]",children:[d.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Xác nhận đăng xuất"}),d.jsx("p",{className:"text-gray-600 mb-6",children:"Bạn có chắc chắn muốn đăng xuất khỏi SharePoint?"}),d.jsxs("div",{className:"flex justify-end gap-2",children:[d.jsx(He,{variant:"outline",onClick:()=>ua(!1),children:"Hủy"}),d.jsx(He,{variant:"destructive",onClick:()=>{Vm(),ua(!1)},children:"Đăng xuất"})]})]})]})]}),d.jsx(or,{open:!!Ec,onOpenChange:T=>{T||(Pu(!1),Mu([]),Nu(""))},children:d.jsxs(Kn,{className:"max-h-[700px] pb-3 px-1 s3-explr-input-group max-w-5xl w-[90%] p-6 bg-white rounded-lg shadow-lg",children:[d.jsxs(Gn,{className:"s3-explr-dialog-header",children:[d.jsx(jn,{className:"s3-explr-dialog-title",children:d.jsxs("h3",{className:"font-medium mb-2",children:["Danh sách flows đang sử dụng dữ liệu từ folder(",d.jsx("span",{className:"font-bold",children:cs}),"):"," "]})}),d.jsx(gi,{className:"s3-explr-dialog-description",children:Tc?d.jsxs("div",{className:"flex items-center justify-center py-4",children:[d.jsx(Pt,{className:"h-6 w-6 animate-spin"}),d.jsx("span",{className:"ml-2",children:"Đang tải thông tin flows..."})]}):d.jsx("div",{children:ls&&Array.isArray(ls)&&ls.length>0?d.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:d.jsxs("table",{className:"w-full border-collapse",children:[d.jsx("thead",{children:d.jsxs("tr",{className:"bg-gray-100",children:[d.jsx("th",{className:"border border-gray-300 px-4 py-2 text-left",children:"Tên Flow"}),d.jsx("th",{className:"border border-gray-300 px-4 py-2 text-left",children:"KnowledgeBase Id"}),d.jsx("th",{className:"border border-gray-300 px-4 py-2 text-left",children:"Loại"}),d.jsx("th",{className:"border border-gray-300 px-4 py-2 text-left",children:"Ngày tạo"})]})}),d.jsx("tbody",{children:ls.map((T,M)=>d.jsxs("tr",{className:M%2===0?"bg-white":"bg-gray-50",children:[d.jsx("td",{className:"border border-gray-300 px-4 py-2",children:T.name}),d.jsx("td",{className:"border border-gray-300 px-4 py-2",children:T.KnowledgeBaseId}),d.jsx("td",{className:"border border-gray-300 px-4 py-2",children:T.type==="MULTIAGENT"?"Agent Flow":"Chat Flow"}),d.jsx("td",{className:"border border-gray-300 px-4 py-2",children:T.createdDate?new Date(T.createdDate).toLocaleString("vi-VN"):"N/A"})]},M))})]})}):d.jsx("div",{className:"text-gray-500 italic py-2",children:"Không có flow nào sử dụng dữ liệu từ folder này"})})})]}),d.jsxs(Lr,{className:"s3-explr-dialog-footer",children:[d.jsx(He,{variant:"outline",onClick:()=>W(null),className:"s3-explr-cancel-btn",children:"Hủy"}),d.jsx(He,{variant:"destructive",onClick:()=>qr(ee),disabled:yn,className:"s3-explr-confirm-delete-btn",children:yn?d.jsxs(d.Fragment,{children:[d.jsx(Pt,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang xóa..."]}):"Xóa"})]})]})}),d.jsx(or,{open:!!ee,onOpenChange:T=>!T&&W(null),children:d.jsxs(Kn,{className:"s3-explr-dialog-content",children:[d.jsxs(Gn,{className:"s3-explr-dialog-header",children:[d.jsx(jn,{className:"s3-explr-dialog-title",children:"Xác nhận xóa"}),d.jsxs(gi,{className:"s3-explr-dialog-description",children:["Bạn có chắc chắn muốn xóa ",ee==null?void 0:ee.name,"? Hành động này không thể hoàn tác."]})]}),d.jsxs(Lr,{className:"s3-explr-dialog-footer",children:[d.jsx(He,{variant:"outline",onClick:()=>W(null),className:"s3-explr-cancel-btn",children:"Hủy"}),d.jsx(He,{variant:"destructive",onClick:()=>qr(ee),disabled:yn,className:"s3-explr-confirm-delete-btn",children:yn?d.jsxs(d.Fragment,{children:[d.jsx(Pt,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang xóa..."]}):"Xóa"})]})]})}),d.jsx(or,{open:!!$,onOpenChange:T=>{T||(te(null),Pe(null),z(""),Ct(""),Kt("rename"))},children:d.jsxs(Kn,{className:"s3-explr-dialog-content max-w-5xl w-[90%]",children:[d.jsx(Gn,{className:"s3-explr-dialog-header",children:d.jsx(jn,{className:"s3-explr-dialog-title",children:$!=null&&$.isFolder?"Đổi tên thư mục":Zi($)?"Quản lý tập tin":"Đổi tên tập tin"})}),$&&d.jsxs(Cg,{value:Dn,onValueChange:T=>Kt(T),children:[d.jsxs(Jd,{"aria-checked":!Zi($),"aria-disabled":$.isFolder,className:"grid w-full grid-cols-3 aria-checked:grid-cols-2 aria-disabled:grid-cols-1",children:[d.jsx(ji,{value:"rename",children:"Đổi tên"}),!$.isFolder&&d.jsxs(d.Fragment,{children:[Zi($)&&d.jsx(ji,{value:"edit",children:"Sửa nội dung"}),d.jsx(ji,{value:"edit-metadata",children:"Sửa metadata file"})]})]}),d.jsx(Wi,{value:"rename",children:d.jsx("div",{className:"space-y-4 py-4 s3-explr-dialog-body",children:d.jsxs("div",{className:"h-[70dvh] min-h-[500px] overflow-hidden overflow-y-auto pb-3 px-1 s3-explr-input-group",children:[d.jsx(pr,{htmlFor:"newName",className:"s3-explr-label",children:"Tên mới"}),d.jsx(Wn,{id:"newName",value:Te,onChange:T=>z(T.target.value),placeholder:"Nhập tên mới",disabled:Ce,className:"s3-explr-input"})]})})}),!$.isFolder&&d.jsxs(d.Fragment,{children:[Zi($)&&d.jsx(Wi,{value:"edit",children:d.jsx("div",{className:"space-y-4 py-4",children:Jt?d.jsx("div",{className:"flex items-center justify-center py-10",children:d.jsx(Pt,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):d.jsxs("div",{className:"max-h-[70dvh] overflow-auto rounded-md border px-4 py-3 bg-muted/30",children:[d.jsx(pr,{htmlFor:"content",className:"block text-sm font-medium mb-2 text-muted-foreground",children:"Nội dung tập tin"}),d.jsx(sc,{id:"content",value:Qe,onChange:T=>Ct(T.target.value),placeholder:"Nhập nội dung tập tin",className:"font-mono text-sm resize-none min-h-[200px] w-full",disabled:an,style:{height:"auto",maxHeight:"60vh"},rows:Math.max(10,Qe.split(`
|
|
223
223
|
`).length+1)})]})})}),d.jsx(Wi,{value:"edit-metadata",children:d.jsx("div",{className:"space-y-4 py-4",children:Jt?d.jsx("div",{className:"flex items-center justify-center py-4",children:d.jsx(Pt,{className:"h-6 w-6 animate-spin"})}):d.jsx("div",{className:"h-[70dvh] min-h-[500px] overflow-hidden overflow-y-auto pb-3 px-1",children:xe&&typeof xe=="object"&&Object.entries(xe).map(([T,M],G)=>d.jsxs("div",{className:"pb-3 flex flex-col gap-2",children:[d.jsxs(pr,{htmlFor:T,className:"s3-explr-label flex items-center gap-1",children:[oL[T]||T,cg(T)&&d.jsx(VD,{className:"h-[12px] w-[12px] text-red-500"})]}),iL(T)?d.jsx(sc,{id:T,value:typeof M=="string"?M:JSON.stringify(M),onChange:pe=>{const be={...xe,[T]:pe.target.value};Pe(be)},placeholder:"Nhập nội dung tập tin",className:"min-h-[200px] font-mono",disabled:an||cg(T)}):d.jsx(Wn,{id:T,value:typeof M=="string"?M:JSON.stringify(M),onChange:pe=>{const be={...xe,[T]:pe.target.value};Pe(be)},placeholder:"Nhập nội dung",className:"s3-explr-input",disabled:an||cg(T)})]},G))})})})]})]}),d.jsxs(Lr,{className:"s3-explr-dialog-footer",children:[d.jsx(He,{variant:"outline",onClick:()=>{te(null),Pe(null),z(""),Ct("")},className:"s3-explr-cancel-btn",children:"Hủy"}),Dn==="edit"?d.jsx(He,{onClick:()=>$&&Qm($,Qe),disabled:an||Jt,className:"s3-explr-save-btn",children:an?d.jsxs(d.Fragment,{children:[d.jsx(Pt,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang lưu..."]}):"Lưu thay đổi"}):Dn==="edit-metadata"?d.jsx(He,{onClick:()=>xe&&typeof xe=="object"&&$&&Zu($),disabled:an||Jt,className:"s3-explr-save-btn",children:an?d.jsxs(d.Fragment,{children:[d.jsx(Pt,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang lưu..."]}):"Lưu thay đổi"}):d.jsx(He,{onClick:()=>{Te.trim()&&$&&Wc($,Te.trim())},disabled:Ce||!Te.trim()||Te.trim()===($==null?void 0:$.name),className:"s3-explr-rename-btn",children:Ce?d.jsxs(d.Fragment,{children:[d.jsx(Pt,{className:"mr-2 h-4 w-4 animate-spin s3-explr-loader"}),"Đang đổi tên..."]}):"Đổi tên"})]})]})}),d.jsx(or,{open:!!_e,onOpenChange:T=>{T||(ke(null),Ct(""))},children:d.jsxs(Kn,{className:"s3-explr-dialog-content max-w-5xl w-[90%]",children:[d.jsx(Gn,{className:"s3-explr-dialog-header",children:d.jsx(jn,{className:"s3-explr-dialog-title",children:"Xem tập tin"})}),_e&&d.jsxs(Cg,{value:"view",children:[d.jsx(Jd,{className:"grid w-full grid-cols-1 ",children:!_e.isFolder&&Zi(_e)&&d.jsx(ji,{value:"view",children:"Nội dung"})}),!_e.isFolder&&Zi(_e)&&d.jsx(Wi,{value:"view",children:d.jsx("div",{className:"space-y-4 py-4",children:Jt?d.jsx("div",{className:"flex items-center justify-center py-4",children:d.jsx(Pt,{className:"h-6 w-6 animate-spin"})}):d.jsx("div",{className:"overflow-hidden overflow-y-auto pb-3 px-1",children:d.jsx("div",{className:"rounded-md bg-muted p-4 font-mono text-sm overflow-auto max-h-[60vh] border",children:d.jsx("pre",{className:"whitespace-pre-wrap break-words",children:Qe})})})})})]}),d.jsx(Lr,{className:"s3-explr-dialog-footer",children:d.jsx(He,{variant:"outline",onClick:()=>{ke(null),Ct("")},className:"s3-explr-cancel-btn",children:"Đóng"})})]})}),de&&ce&&d.jsx(zU,{openDialogRename:ce,setOpenDialogRename:Ae,apiBaseUrl:e,setFileToMove:se,fileToMove:de,refreshFiles:un,ignoreCache:Yn,autoSyncAfterFileOperation:Vo})]})]}),Bm&&d.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative s3-explr-error",children:"Đã xảy ra lỗi khi tải danh sách tập tin"}),d.jsx(BU,{onFilesSelected:(T,M)=>ga(T,v,M),children:d.jsx("div",{className:"rounded-md border s3-explr-table-container",children:d.jsxs(jd,{className:"s3-explr-table",children:[d.jsx(Wd,{className:"s3-explr-table-header",children:Si.getHeaderGroups().map(T=>d.jsx($r,{className:"hover:bg-transparent s3-explr-header-row",children:T.headers.map(M=>d.jsx(lo,{className:"s3-explr-header-cell",children:M.isPlaceholder?null:wd(M.column.columnDef.header,M.getContext())},M.id))},T.id))}),d.jsx(qd,{className:"s3-explr-table-body",children:Si.getRowModel().rows.length===0?d.jsx($r,{className:"s3-explr-empty-row",children:d.jsx(qn,{colSpan:qc.length,className:"h-24 text-center s3-explr-empty-cell",children:g?d.jsxs("div",{className:"text-gray-500 s3-explr-no-results",children:['Không tìm thấy tập tin hoặc thư mục nào khớp với "',g,'"']}):d.jsx("div",{className:"text-gray-500 s3-explr-empty-message",children:Uo?"Đang tải nội dung thư mục... Vui lòng đợi":"Thư mục này không chứa tập tin hoặc thư mục con nào"})})}):Si.getRowModel().rows.map(T=>d.jsx($r,{className:"h-12 s3-explr-row",children:T.getVisibleCells().map(M=>d.jsx(qn,{className:"align-middle s3-explr-cell",children:wd(M.column.columnDef.cell,M.getContext())},M.id))},T.id))})]})})}),g&&ha!==0&&d.jsx(d.Fragment,{children:d.jsx(Bd,{children:d.jsxs(zd,{children:[d.jsx(Vd,{onClick:()=>cr(T=>Math.max(T-1,1)),"aria-disabled":Gt===1,className:"cursor-pointer aria-disabled:pointer-events-none"}),Array.from({length:Math.ceil(ha/20)},(T,M)=>{const G=M+1,pe=Math.ceil(ha/20);return pe>7&&!(G===1||G===pe||G>=Gt-1&&G<=Gt+1)?G===Gt-2&&Gt>4||G===Gt+2&&Gt<pe-3?d.jsx(Gd,{className:"pointer-events-none",children:"..."},M):null:d.jsx(Fr,{className:"cursor-pointer",children:d.jsx(Qa,{isActive:Gt===G,onClick:()=>cr(G),className:`${Gt===G?"bg-blue-500 text-white":"bg-white text-black"} hover:bg-blue-100`,children:G})},M)}),d.jsx(Fr,{children:d.jsx(Kd,{onClick:()=>cr(T=>Math.min(T+1,Math.ceil(ha/20))),"aria-disabled":Gt===Math.ceil(ha/20),className:"cursor-pointer aria-disabled:pointer-events-none"})})]})})}),o&&i&&d.jsxs("div",{className:"flex justify-between items-center mt-4 s3-explr-selector-footer",children:[d.jsx("div",{className:"text-sm text-gray-500 s3-explr-selection-count",children:Xm()}),d.jsx(He,{variant:"default",onClick:()=>i(Jm()),disabled:w.size===0,className:"s3-explr-ok-btn",children:"OK"})]}),d.jsx(O3,{open:!!Ac,onClose:()=>Ic(null),file:Ac,apiBaseUrl:e,rootUrlHostApi:r})]})}),G3=t=>d.jsx(uM,{clientId:D3,children:d.jsx(K3,{...t})});var wc=t=>t.type==="checkbox",ta=t=>t instanceof Date,Mn=t=>t==null;const e0=t=>typeof t=="object";var Yt=t=>!Mn(t)&&!Array.isArray(t)&&e0(t)&&!ta(t),j3=t=>Yt(t)&&t.target?wc(t.target)?t.target.checked:t.target.value:t,W3=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,q3=(t,e)=>t.has(W3(e)),Y3=t=>{const e=t.constructor&&t.constructor.prototype;return Yt(e)&&e.hasOwnProperty("isPrototypeOf")},Am=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function En(t){let e;const n=Array.isArray(t),r=typeof FileList<"u"?t instanceof FileList:!1;if(t instanceof Date)e=new Date(t);else if(t instanceof Set)e=new Set(t);else if(!(Am&&(t instanceof Blob||r))&&(n||Yt(t)))if(e=n?[]:{},!n&&!Y3(t))e=t;else for(const o in t)t.hasOwnProperty(o)&&(e[o]=En(t[o]));else return t;return e}var _u=t=>Array.isArray(t)?t.filter(Boolean):[],on=t=>t===void 0,Fe=(t,e,n)=>{if(!e||!Yt(t))return n;const r=_u(e.split(/[,[\].]+?/)).reduce((o,i)=>Mn(o)?o:o[i],t);return on(r)||r===t?on(t[e])?n:t[e]:r},go=t=>typeof t=="boolean",Im=t=>/^\w*$/.test(t),t0=t=>_u(t.replace(/["|']|\]/g,"").split(/\.|\[/)),$t=(t,e,n)=>{let r=-1;const o=Im(e)?[e]:t0(e),i=o.length,s=i-1;for(;++r<i;){const l=o[r];let u=n;if(r!==s){const h=t[l];u=Yt(h)||Array.isArray(h)?h:isNaN(+o[r+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;t[l]=u,t=t[l]}};const n0={BLUR:"blur",FOCUS_OUT:"focusout"},Vr={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Lo={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"};O.createContext(null);var J3=(t,e,n,r=!0)=>{const o={defaultValues:e._defaultValues};for(const i in t)Object.defineProperty(o,i,{get:()=>{const s=i;return e._proxyFormState[s]!==Vr.all&&(e._proxyFormState[s]=!r||Vr.all),t[s]}});return o};const Q3=typeof window<"u"?m.useLayoutEffect:m.useEffect;var mo=t=>typeof t=="string",X3=(t,e,n,r,o)=>mo(t)?(r&&e.watch.add(t),Fe(n,t,o)):Array.isArray(t)?t.map(i=>(r&&e.watch.add(i),Fe(n,i))):(r&&(e.watchAll=!0),n),Z3=(t,e,n,r,o)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[r]:o||!0}}:{},Cc=t=>Array.isArray(t)?t:[t],r0=()=>{let t=[];return{get observers(){return t},next:o=>{for(const i of t)i.next&&i.next(o)},subscribe:o=>(t.push(o),{unsubscribe:()=>{t=t.filter(i=>i!==o)}}),unsubscribe:()=>{t=[]}}},km=t=>Mn(t)||!e0(t);function bi(t,e){if(km(t)||km(e))return t===e;if(ta(t)&&ta(e))return t.getTime()===e.getTime();const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(const o of n){const i=t[o];if(!r.includes(o))return!1;if(o!=="ref"){const s=e[o];if(ta(i)&&ta(s)||Yt(i)&&Yt(s)||Array.isArray(i)&&Array.isArray(s)?!bi(i,s):i!==s)return!1}}return!0}var Rn=t=>Yt(t)&&!Object.keys(t).length,Nm=t=>t.type==="file",Kr=t=>typeof t=="function",Eu=t=>{if(!Am)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},o0=t=>t.type==="select-multiple",Pm=t=>t.type==="radio",e5=t=>Pm(t)||wc(t),Om=t=>Eu(t)&&t.isConnected;function t5(t,e){const n=e.slice(0,-1).length;let r=0;for(;r<n;)t=on(t)?r++:t[e[r++]];return t}function n5(t){for(const e in t)if(t.hasOwnProperty(e)&&!on(t[e]))return!1;return!0}function sn(t,e){const n=Array.isArray(e)?e:Im(e)?[e]:t0(e),r=n.length===1?t:t5(t,n),o=n.length-1,i=n[o];return r&&delete r[i],o!==0&&(Yt(r)&&Rn(r)||Array.isArray(r)&&n5(r))&&sn(t,n.slice(0,-1)),t}var i0=t=>{for(const e in t)if(Kr(t[e]))return!0;return!1};function Tu(t,e={}){const n=Array.isArray(t);if(Yt(t)||n)for(const r in t)Array.isArray(t[r])||Yt(t[r])&&!i0(t[r])?(e[r]=Array.isArray(t[r])?[]:{},Tu(t[r],e[r])):Mn(t[r])||(e[r]=!0);return e}function a0(t,e,n){const r=Array.isArray(t);if(Yt(t)||r)for(const o in t)Array.isArray(t[o])||Yt(t[o])&&!i0(t[o])?on(e)||km(n[o])?n[o]=Array.isArray(t[o])?Tu(t[o],[]):{...Tu(t[o])}:a0(t[o],Mn(e)?{}:e[o],n[o]):n[o]=!bi(t[o],e[o]);return n}var bc=(t,e)=>a0(t,e,Tu(e));const s0={value:!1,isValid:!1},c0={value:!0,isValid:!0};var l0=t=>{if(Array.isArray(t)){if(t.length>1){const e=t.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:e,isValid:!!e.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!on(t[0].attributes.value)?on(t[0].value)||t[0].value===""?c0:{value:t[0].value,isValid:!0}:c0:s0}return s0},d0=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:r})=>on(t)?t:e?t===""?NaN:t&&+t:n&&mo(t)?new Date(t):r?r(t):t;const u0={isValid:!1,value:null};var f0=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,u0):u0;function h0(t){const e=t.ref;return Nm(e)?e.files:Pm(e)?f0(t.refs).value:o0(e)?[...e.selectedOptions].map(({value:n})=>n):wc(e)?l0(t.refs).value:d0(on(e.value)?t.ref.value:e.value,t)}var r5=(t,e,n,r)=>{const o={};for(const i of t){const s=Fe(e,i);s&&$t(o,i,s._f)}return{criteriaMode:n,names:[...t],fields:o,shouldUseNativeValidation:r}},Au=t=>t instanceof RegExp,xc=t=>on(t)?t:Au(t)?t.source:Yt(t)?Au(t.value)?t.value.source:t.value:t,p0=t=>({isOnSubmit:!t||t===Vr.onSubmit,isOnBlur:t===Vr.onBlur,isOnChange:t===Vr.onChange,isOnAll:t===Vr.all,isOnTouch:t===Vr.onTouched});const g0="AsyncFunction";var o5=t=>!!t&&!!t.validate&&!!(Kr(t.validate)&&t.validate.constructor.name===g0||Yt(t.validate)&&Object.values(t.validate).find(e=>e.constructor.name===g0)),i5=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),m0=(t,e,n)=>!n&&(e.watchAll||e.watch.has(t)||[...e.watch].some(r=>t.startsWith(r)&&/^\.\w+/.test(t.slice(r.length))));const Sc=(t,e,n,r)=>{for(const o of n||Object.keys(t)){const i=Fe(t,o);if(i){const{_f:s,...l}=i;if(s){if(s.refs&&s.refs[0]&&e(s.refs[0],o)&&!r)return!0;if(s.ref&&e(s.ref,s.name)&&!r)return!0;if(Sc(l,e))break}else if(Yt(l)&&Sc(l,e))break}}};function v0(t,e,n){const r=Fe(t,n);if(r||Im(n))return{error:r,name:n};const o=n.split(".");for(;o.length;){const i=o.join("."),s=Fe(e,i),l=Fe(t,i);if(s&&!Array.isArray(s)&&n!==i)return{name:n};if(l&&l.type)return{name:i,error:l};o.pop()}return{name:n}}var a5=(t,e,n,r)=>{n(t);const{name:o,...i}=t;return Rn(i)||Object.keys(i).length>=Object.keys(e).length||Object.keys(i).find(s=>e[s]===(!r||Vr.all))},s5=(t,e,n)=>!t||!e||t===e||Cc(t).some(r=>r&&(n?r===e:r.startsWith(e)||e.startsWith(r))),c5=(t,e,n,r,o)=>o.isOnAll?!1:!n&&o.isOnTouch?!(e||t):(n?r.isOnBlur:o.isOnBlur)?!t:(n?r.isOnChange:o.isOnChange)?t:!0,l5=(t,e)=>!_u(Fe(t,e)).length&&sn(t,e),d5=(t,e,n)=>{const r=Cc(Fe(t,n));return $t(r,"root",e[n]),$t(t,n,r),t},Iu=t=>mo(t);function y0(t,e,n="validate"){if(Iu(t)||Array.isArray(t)&&t.every(Iu)||go(t)&&!t)return{type:n,message:Iu(t)?t:"",ref:e}}var as=t=>Yt(t)&&!Au(t)?t:{value:t,message:""},w0=async(t,e,n,r,o,i)=>{const{ref:s,refs:l,required:u,maxLength:h,minLength:p,min:g,max:C,pattern:w,validate:b,name:v,valueAsNumber:x,mount:E}=t._f,A=Fe(n,v);if(!E||e.has(v))return{};const N=l?l[0]:s,P=se=>{o&&N.reportValidity&&(N.setCustomValidity(go(se)?"":se||""),N.reportValidity())},_={},D=Pm(s),H=wc(s),K=D||H,ee=(x||Nm(s))&&on(s.value)&&on(A)||Eu(s)&&s.value===""||A===""||Array.isArray(A)&&!A.length,W=Z3.bind(null,v,r,_),de=(se,fe,q,Z=Lo.maxLength,Y=Lo.minLength)=>{const oe=se?fe:q;_[v]={type:se?Z:Y,message:oe,ref:s,...W(se?Z:Y,oe)}};if(i?!Array.isArray(A)||!A.length:u&&(!K&&(ee||Mn(A))||go(A)&&!A||H&&!l0(l).isValid||D&&!f0(l).isValid)){const{value:se,message:fe}=Iu(u)?{value:!!u,message:u}:as(u);if(se&&(_[v]={type:Lo.required,message:fe,ref:N,...W(Lo.required,fe)},!r))return P(fe),_}if(!ee&&(!Mn(g)||!Mn(C))){let se,fe;const q=as(C),Z=as(g);if(!Mn(A)&&!isNaN(A)){const Y=s.valueAsNumber||A&&+A;Mn(q.value)||(se=Y>q.value),Mn(Z.value)||(fe=Y<Z.value)}else{const Y=s.valueAsDate||new Date(A),oe=$=>new Date(new Date().toDateString()+" "+$),Q=s.type=="time",X=s.type=="week";mo(q.value)&&A&&(se=Q?oe(A)>oe(q.value):X?A>q.value:Y>new Date(q.value)),mo(Z.value)&&A&&(fe=Q?oe(A)<oe(Z.value):X?A<Z.value:Y<new Date(Z.value))}if((se||fe)&&(de(!!se,q.message,Z.message,Lo.max,Lo.min),!r))return P(_[v].message),_}if((h||p)&&!ee&&(mo(A)||i&&Array.isArray(A))){const se=as(h),fe=as(p),q=!Mn(se.value)&&A.length>+se.value,Z=!Mn(fe.value)&&A.length<+fe.value;if((q||Z)&&(de(q,se.message,fe.message),!r))return P(_[v].message),_}if(w&&!ee&&mo(A)){const{value:se,message:fe}=as(w);if(Au(se)&&!A.match(se)&&(_[v]={type:Lo.pattern,message:fe,ref:s,...W(Lo.pattern,fe)},!r))return P(fe),_}if(b){if(Kr(b)){const se=await b(A,n),fe=y0(se,N);if(fe&&(_[v]={...fe,...W(Lo.validate,fe.message)},!r))return P(fe.message),_}else if(Yt(b)){let se={};for(const fe in b){if(!Rn(se)&&!r)break;const q=y0(await b[fe](A,n),N,fe);q&&(se={...q,...W(fe,q.message)},P(q.message),r&&(_[v]=se))}if(!Rn(se)&&(_[v]={ref:N,...se},!r))return _}}return P(!0),_};const u5={mode:Vr.onSubmit,reValidateMode:Vr.onChange,shouldFocusError:!0};function f5(t={}){let e={...u5,...t},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:Kr(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1};const r={};let o=Yt(e.defaultValues)||Yt(e.values)?En(e.defaultValues||e.values)||{}:{},i=e.shouldUnregister?{}:En(o),s={action:!1,mount:!1,watch:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},u,h=0;const p={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let g={...p};const C={array:r0(),state:r0()},w=p0(e.mode),b=p0(e.reValidateMode),v=e.criteriaMode===Vr.all,x=L=>J=>{clearTimeout(h),h=setTimeout(L,J)},E=async L=>{if(!e.disabled&&(p.isValid||g.isValid||L)){const J=e.resolver?Rn((await ee()).errors):await de(r,!0);J!==n.isValid&&C.state.next({isValid:J})}},A=(L,J)=>{!e.disabled&&(p.isValidating||p.validatingFields||g.isValidating||g.validatingFields)&&((L||Array.from(l.mount)).forEach(U=>{U&&(J?$t(n.validatingFields,U,J):sn(n.validatingFields,U))}),C.state.next({validatingFields:n.validatingFields,isValidating:!Rn(n.validatingFields)}))},N=(L,J=[],U,ae,ye=!0,he=!0)=>{if(ae&&U&&!e.disabled){if(s.action=!0,he&&Array.isArray(Fe(r,L))){const Ee=U(Fe(r,L),ae.argA,ae.argB);ye&&$t(r,L,Ee)}if(he&&Array.isArray(Fe(n.errors,L))){const Ee=U(Fe(n.errors,L),ae.argA,ae.argB);ye&&$t(n.errors,L,Ee),l5(n.errors,L)}if((p.touchedFields||g.touchedFields)&&he&&Array.isArray(Fe(n.touchedFields,L))){const Ee=U(Fe(n.touchedFields,L),ae.argA,ae.argB);ye&&$t(n.touchedFields,L,Ee)}(p.dirtyFields||g.dirtyFields)&&(n.dirtyFields=bc(o,i)),C.state.next({name:L,isDirty:fe(L,J),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else $t(i,L,J)},P=(L,J)=>{$t(n.errors,L,J),C.state.next({errors:n.errors})},_=L=>{n.errors=L,C.state.next({errors:n.errors,isValid:!1})},D=(L,J,U,ae)=>{const ye=Fe(r,L);if(ye){const he=Fe(i,L,on(U)?Fe(o,L):U);on(he)||ae&&ae.defaultChecked||J?$t(i,L,J?he:h0(ye._f)):Y(L,he),s.mount&&E()}},H=(L,J,U,ae,ye)=>{let he=!1,Ee=!1;const Xe={name:L};if(!e.disabled){if(!U||ae){(p.isDirty||g.isDirty)&&(Ee=n.isDirty,n.isDirty=Xe.isDirty=fe(),he=Ee!==Xe.isDirty);const ft=bi(Fe(o,L),J);Ee=!!Fe(n.dirtyFields,L),ft?sn(n.dirtyFields,L):$t(n.dirtyFields,L,!0),Xe.dirtyFields=n.dirtyFields,he=he||(p.dirtyFields||g.dirtyFields)&&Ee!==!ft}if(U){const ft=Fe(n.touchedFields,L);ft||($t(n.touchedFields,L,U),Xe.touchedFields=n.touchedFields,he=he||(p.touchedFields||g.touchedFields)&&ft!==U)}he&&ye&&C.state.next(Xe)}return he?Xe:{}},K=(L,J,U,ae)=>{const ye=Fe(n.errors,L),he=(p.isValid||g.isValid)&&go(J)&&n.isValid!==J;if(e.delayError&&U?(u=x(()=>P(L,U)),u(e.delayError)):(clearTimeout(h),u=null,U?$t(n.errors,L,U):sn(n.errors,L)),(U?!bi(ye,U):ye)||!Rn(ae)||he){const Ee={...ae,...he&&go(J)?{isValid:J}:{},errors:n.errors,name:L};n={...n,...Ee},C.state.next(Ee)}},ee=async L=>{A(L,!0);const J=await e.resolver(i,e.context,r5(L||l.mount,r,e.criteriaMode,e.shouldUseNativeValidation));return A(L),J},W=async L=>{const{errors:J}=await ee(L);if(L)for(const U of L){const ae=Fe(J,U);ae?$t(n.errors,U,ae):sn(n.errors,U)}else n.errors=J;return J},de=async(L,J,U={valid:!0})=>{for(const ae in L){const ye=L[ae];if(ye){const{_f:he,...Ee}=ye;if(he){const Xe=l.array.has(he.name),ft=ye._f&&o5(ye._f);ft&&p.validatingFields&&A([ae],!0);const xt=await w0(ye,l.disabled,i,v,e.shouldUseNativeValidation&&!J,Xe);if(ft&&p.validatingFields&&A([ae]),xt[he.name]&&(U.valid=!1,J))break;!J&&(Fe(xt,he.name)?Xe?d5(n.errors,xt,he.name):$t(n.errors,he.name,xt[he.name]):sn(n.errors,he.name))}!Rn(Ee)&&await de(Ee,J,U)}}return U.valid},se=()=>{for(const L of l.unMount){const J=Fe(r,L);J&&(J._f.refs?J._f.refs.every(U=>!Om(U)):!Om(J._f.ref))&&Ae(L)}l.unMount=new Set},fe=(L,J)=>!e.disabled&&(L&&J&&$t(i,L,J),!bi(_e(),o)),q=(L,J,U)=>X3(L,l,{...s.mount?i:on(J)?o:mo(L)?{[L]:J}:J},U,J),Z=L=>_u(Fe(s.mount?i:o,L,e.shouldUnregister?Fe(o,L,[]):[])),Y=(L,J,U={})=>{const ae=Fe(r,L);let ye=J;if(ae){const he=ae._f;he&&(!he.disabled&&$t(i,L,d0(J,he)),ye=Eu(he.ref)&&Mn(J)?"":J,o0(he.ref)?[...he.ref.options].forEach(Ee=>Ee.selected=ye.includes(Ee.value)):he.refs?wc(he.ref)?he.refs.length>1?he.refs.forEach(Ee=>(!Ee.defaultChecked||!Ee.disabled)&&(Ee.checked=Array.isArray(ye)?!!ye.find(Xe=>Xe===Ee.value):ye===Ee.value)):he.refs[0]&&(he.refs[0].checked=!!ye):he.refs.forEach(Ee=>Ee.checked=Ee.value===ye):Nm(he.ref)?he.ref.value="":(he.ref.value=ye,he.ref.type||C.state.next({name:L,values:En(i)})))}(U.shouldDirty||U.shouldTouch)&&H(L,ye,U.shouldTouch,U.shouldDirty,!0),U.shouldValidate&&te(L)},oe=(L,J,U)=>{for(const ae in J){const ye=J[ae],he=`${L}.${ae}`,Ee=Fe(r,he);(l.array.has(L)||Yt(ye)||Ee&&!Ee._f)&&!ta(ye)?oe(he,ye,U):Y(he,ye,U)}},Q=(L,J,U={})=>{const ae=Fe(r,L),ye=l.array.has(L),he=En(J);$t(i,L,he),ye?(C.array.next({name:L,values:En(i)}),(p.isDirty||p.dirtyFields||g.isDirty||g.dirtyFields)&&U.shouldDirty&&C.state.next({name:L,dirtyFields:bc(o,i),isDirty:fe(L,he)})):ae&&!ae._f&&!Mn(he)?oe(L,he,U):Y(L,he,U),m0(L,l)&&C.state.next({...n}),C.state.next({name:s.mount?L:void 0,values:En(i)})},X=async L=>{s.mount=!0;const J=L.target;let U=J.name,ae=!0;const ye=Fe(r,U),he=Ee=>{ae=Number.isNaN(Ee)||ta(Ee)&&isNaN(Ee.getTime())||bi(Ee,Fe(i,U,Ee))};if(ye){let Ee,Xe;const ft=J.type?h0(ye._f):j3(L),xt=L.type===n0.BLUR||L.type===n0.FOCUS_OUT,vo=!i5(ye._f)&&!e.resolver&&!Fe(n.errors,U)&&!ye._f.deps||c5(xt,Fe(n.touchedFields,U),n.isSubmitted,b,w),Qt=m0(U,l,xt);$t(i,U,ft),xt?(ye._f.onBlur&&ye._f.onBlur(L),u&&u(0)):ye._f.onChange&&ye._f.onChange(L);const yn=H(U,ft,xt),Gr=!Rn(yn)||Qt;if(!xt&&C.state.next({name:U,type:L.type,values:En(i)}),vo)return(p.isValid||g.isValid)&&(e.mode==="onBlur"?xt&&E():xt||E()),Gr&&C.state.next({name:U,...Qt?{}:yn});if(!xt&&Qt&&C.state.next({...n}),e.resolver){const{errors:Gt}=await ee([U]);if(he(ft),ae){const cr=v0(n.errors,r,U),jr=v0(Gt,r,cr.name||U);Ee=jr.error,U=jr.name,Xe=Rn(Gt)}}else A([U],!0),Ee=(await w0(ye,l.disabled,i,v,e.shouldUseNativeValidation))[U],A([U]),he(ft),ae&&(Ee?Xe=!1:(p.isValid||g.isValid)&&(Xe=await de(r,!0)));ae&&(ye._f.deps&&te(ye._f.deps),K(U,Xe,Ee,yn))}},$=(L,J)=>{if(Fe(n.errors,J)&&L.focus)return L.focus(),1},te=async(L,J={})=>{let U,ae;const ye=Cc(L);if(e.resolver){const he=await W(on(L)?L:ye);U=Rn(he),ae=L?!ye.some(Ee=>Fe(he,Ee)):U}else L?(ae=(await Promise.all(ye.map(async he=>{const Ee=Fe(r,he);return await de(Ee&&Ee._f?{[he]:Ee}:Ee)}))).every(Boolean),!(!ae&&!n.isValid)&&E()):ae=U=await de(r);return C.state.next({...!mo(L)||(p.isValid||g.isValid)&&U!==n.isValid?{}:{name:L},...e.resolver||!L?{isValid:U}:{},errors:n.errors}),J.shouldFocus&&!ae&&Sc(r,$,L?ye:l.mount),ae},_e=L=>{const J={...s.mount?i:o};return on(L)?J:mo(L)?Fe(J,L):L.map(U=>Fe(J,U))},ke=(L,J)=>({invalid:!!Fe((J||n).errors,L),isDirty:!!Fe((J||n).dirtyFields,L),error:Fe((J||n).errors,L),isValidating:!!Fe(n.validatingFields,L),isTouched:!!Fe((J||n).touchedFields,L)}),xe=L=>{L&&Cc(L).forEach(J=>sn(n.errors,J)),C.state.next({errors:L?n.errors:{}})},Pe=(L,J,U)=>{const ae=(Fe(r,L,{_f:{}})._f||{}).ref,ye=Fe(n.errors,L)||{},{ref:he,message:Ee,type:Xe,...ft}=ye;$t(n.errors,L,{...ft,...J,ref:ae}),C.state.next({name:L,errors:n.errors,isValid:!1}),U&&U.shouldFocus&&ae&&ae.focus&&ae.focus()},Te=(L,J)=>Kr(L)?C.state.subscribe({next:U=>L(q(void 0,J),U)}):q(L,J,!0),z=L=>C.state.subscribe({next:J=>{s5(L.name,J.name,L.exact)&&a5(J,L.formState||p,zt,L.reRenderRoot)&&L.callback({values:{...i},...n,...J})}}).unsubscribe,ce=L=>(s.mount=!0,g={...g,...L.formState},z({...L,formState:g})),Ae=(L,J={})=>{for(const U of L?Cc(L):l.mount)l.mount.delete(U),l.array.delete(U),J.keepValue||(sn(r,U),sn(i,U)),!J.keepError&&sn(n.errors,U),!J.keepDirty&&sn(n.dirtyFields,U),!J.keepTouched&&sn(n.touchedFields,U),!J.keepIsValidating&&sn(n.validatingFields,U),!e.shouldUnregister&&!J.keepDefaultValue&&sn(o,U);C.state.next({values:En(i)}),C.state.next({...n,...J.keepDirty?{isDirty:fe()}:{}}),!J.keepIsValid&&E()},Ce=({disabled:L,name:J})=>{(go(L)&&s.mount||L||l.disabled.has(J))&&(L?l.disabled.add(J):l.disabled.delete(J))},Ne=(L,J={})=>{let U=Fe(r,L);const ae=go(J.disabled)||go(e.disabled);return $t(r,L,{...U||{},_f:{...U&&U._f?U._f:{ref:{name:L}},name:L,mount:!0,...J}}),l.mount.add(L),U?Ce({disabled:go(J.disabled)?J.disabled:e.disabled,name:L}):D(L,!0,J.value),{...ae?{disabled:J.disabled||e.disabled}:{},...e.progressive?{required:!!J.required,min:xc(J.min),max:xc(J.max),minLength:xc(J.minLength),maxLength:xc(J.maxLength),pattern:xc(J.pattern)}:{},name:L,onChange:X,onBlur:X,ref:ye=>{if(ye){Ne(L,J),U=Fe(r,L);const he=on(ye.value)&&ye.querySelectorAll&&ye.querySelectorAll("input,select,textarea")[0]||ye,Ee=e5(he),Xe=U._f.refs||[];if(Ee?Xe.find(ft=>ft===he):he===U._f.ref)return;$t(r,L,{_f:{...U._f,...Ee?{refs:[...Xe.filter(Om),he,...Array.isArray(Fe(o,L))?[{}]:[]],ref:{type:he.type,name:L}}:{ref:he}}}),D(L,!1,void 0,he)}else U=Fe(r,L,{}),U._f&&(U._f.mount=!1),(e.shouldUnregister||J.shouldUnregister)&&!(q3(l.array,L)&&s.action)&&l.unMount.add(L)}}},ne=()=>e.shouldFocusError&&Sc(r,$,l.mount),Ve=L=>{go(L)&&(C.state.next({disabled:L}),Sc(r,(J,U)=>{const ae=Fe(r,U);ae&&(J.disabled=ae._f.disabled||L,Array.isArray(ae._f.refs)&&ae._f.refs.forEach(ye=>{ye.disabled=ae._f.disabled||L}))},0,!1))},Qe=(L,J)=>async U=>{let ae;U&&(U.preventDefault&&U.preventDefault(),U.persist&&U.persist());let ye=En(i);if(C.state.next({isSubmitting:!0}),e.resolver){const{errors:he,values:Ee}=await ee();n.errors=he,ye=Ee}else await de(r);if(l.disabled.size)for(const he of l.disabled)$t(ye,he,void 0);if(sn(n.errors,"root"),Rn(n.errors)){C.state.next({errors:{}});try{await L(ye,U)}catch(he){ae=he}}else J&&await J({...n.errors},U),ne(),setTimeout(ne);if(C.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Rn(n.errors)&&!ae,submitCount:n.submitCount+1,errors:n.errors}),ae)throw ae},Ct=(L,J={})=>{Fe(r,L)&&(on(J.defaultValue)?Q(L,En(Fe(o,L))):(Q(L,J.defaultValue),$t(o,L,En(J.defaultValue))),J.keepTouched||sn(n.touchedFields,L),J.keepDirty||(sn(n.dirtyFields,L),n.isDirty=J.defaultValue?fe(L,En(Fe(o,L))):fe()),J.keepError||(sn(n.errors,L),p.isValid&&E()),C.state.next({...n}))},Jt=(L,J={})=>{const U=L?En(L):o,ae=En(U),ye=Rn(L),he=ye?o:ae;if(J.keepDefaultValues||(o=U),!J.keepValues){if(J.keepDirtyValues){const Ee=new Set([...l.mount,...Object.keys(bc(o,i))]);for(const Xe of Array.from(Ee))Fe(n.dirtyFields,Xe)?$t(he,Xe,Fe(i,Xe)):Q(Xe,Fe(he,Xe))}else{if(Am&&on(L))for(const Ee of l.mount){const Xe=Fe(r,Ee);if(Xe&&Xe._f){const ft=Array.isArray(Xe._f.refs)?Xe._f.refs[0]:Xe._f.ref;if(Eu(ft)){const xt=ft.closest("form");if(xt){xt.reset();break}}}}for(const Ee of l.mount)Q(Ee,Fe(he,Ee))}i=En(he),C.array.next({values:{...he}}),C.state.next({values:{...he}})}l={mount:J.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},s.mount=!p.isValid||!!J.keepIsValid||!!J.keepDirtyValues,s.watch=!!e.shouldUnregister,C.state.next({submitCount:J.keepSubmitCount?n.submitCount:0,isDirty:ye?!1:J.keepDirty?n.isDirty:!!(J.keepDefaultValues&&!bi(L,o)),isSubmitted:J.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:ye?{}:J.keepDirtyValues?J.keepDefaultValues&&i?bc(o,i):n.dirtyFields:J.keepDefaultValues&&L?bc(o,L):J.keepDirty?n.dirtyFields:{},touchedFields:J.keepTouched?n.touchedFields:{},errors:J.keepErrors?n.errors:{},isSubmitSuccessful:J.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1})},bt=(L,J)=>Jt(Kr(L)?L(i):L,J),an=(L,J={})=>{const U=Fe(r,L),ae=U&&U._f;if(ae){const ye=ae.refs?ae.refs[0]:ae.ref;ye.focus&&(ye.focus(),J.shouldSelect&&Kr(ye.select)&&ye.select())}},zt=L=>{n={...n,...L}},Kt={control:{register:Ne,unregister:Ae,getFieldState:ke,handleSubmit:Qe,setError:Pe,_subscribe:z,_runSchema:ee,_getWatch:q,_getDirty:fe,_setValid:E,_setFieldArray:N,_setDisabledField:Ce,_setErrors:_,_getFieldArray:Z,_reset:Jt,_resetDefaultValues:()=>Kr(e.defaultValues)&&e.defaultValues().then(L=>{bt(L,e.resetOptions),C.state.next({isLoading:!1})}),_removeUnmounted:se,_disableForm:Ve,_subjects:C,_proxyFormState:p,get _fields(){return r},get _formValues(){return i},get _state(){return s},set _state(L){s=L},get _defaultValues(){return o},get _names(){return l},set _names(L){l=L},get _formState(){return n},get _options(){return e},set _options(L){e={...e,...L}}},subscribe:ce,trigger:te,register:Ne,handleSubmit:Qe,watch:Te,setValue:Q,getValues:_e,reset:bt,resetField:Ct,clearErrors:xe,unregister:Ae,setError:Pe,setFocus:an,getFieldState:ke};return{...Kt,formControl:Kt}}function h5(t={}){const e=O.useRef(void 0),n=O.useRef(void 0),[r,o]=O.useState({isDirty:!1,isValidating:!1,isLoading:Kr(t.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1,isReady:!1,defaultValues:Kr(t.defaultValues)?void 0:t.defaultValues});e.current||(e.current={...t.formControl?t.formControl:f5(t),formState:r},t.formControl&&t.defaultValues&&!Kr(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions));const i=e.current.control;return i._options=t,Q3(()=>{const s=i._subscribe({formState:i._proxyFormState,callback:()=>o({...i._formState}),reRenderRoot:!0});return o(l=>({...l,isReady:!0})),i._formState.isReady=!0,s},[i]),O.useEffect(()=>i._disableForm(t.disabled),[i,t.disabled]),O.useEffect(()=>{t.mode&&(i._options.mode=t.mode),t.reValidateMode&&(i._options.reValidateMode=t.reValidateMode),t.errors&&!Rn(t.errors)&&i._setErrors(t.errors)},[i,t.errors,t.mode,t.reValidateMode]),O.useEffect(()=>{t.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,t.shouldUnregister]),O.useEffect(()=>{if(i._proxyFormState.isDirty){const s=i._getDirty();s!==r.isDirty&&i._subjects.state.next({isDirty:s})}},[i,r.isDirty]),O.useEffect(()=>{t.values&&!bi(t.values,n.current)?(i._reset(t.values,i._options.resetOptions),n.current=t.values,o(s=>({...s}))):i._resetDefaultValues()},[i,t.values]),O.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),e.current.formState=J3(r,i),e.current}const C0=({className:t,children:e,content:n,side:r})=>{const[o,i]=O.useState(!1);return d.jsx(gr,{delayDuration:0,children:d.jsxs(mr,{open:o,children:[d.jsx(vr,{asChild:!0,children:d.jsx("button",{type:"button",className:ze("cursor-pointer",t),onClick:()=>i(!o),onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),onTouchStart:()=>i(!o),onKeyDown:s=>{s.preventDefault(),s.key==="Enter"&&i(!o)},children:e})}),d.jsx(sr,{side:r,className:n?"":"hidden",children:d.jsx("span",{className:"inline-block",children:n})})]})})},p5=(t,e)=>{const[n,r]=O.useState(t);return O.useEffect(()=>{const o=setTimeout(()=>{r(t)},e);return()=>{clearTimeout(o)}},[t,e]),n},g5=({apiBaseUrl:t="http://localhost:3002"})=>{var D,H;const[e,n]=O.useState([]),[r,o]=O.useState(!1),[i,s]=O.useState([]),[l,u]=O.useState(1),[h,p]=O.useState(1),[g,C]=O.useState(null),[w,b]=O.useState(""),v=p5(w,500),x=K=>{const ee=K.match(/\d{6}/);if(!ee)return{month:"",year:""};const W=ee[0],de=W.substring(0,2),se=W.substring(2);return{month:de,year:se}},E=K=>K.map(W=>{let de=(W==null?void 0:W.month)||"",se=(W==null?void 0:W.year)||"";if((!de||!se)&&(W!=null&&W.file_name)){const fe=x(W.file_name);de=de||fe.month,se=se||fe.year}return{id:W==null?void 0:W.id,prefix:(W==null?void 0:W.prefix)||"",model:(W==null?void 0:W.model)||"",fileName:(W==null?void 0:W.file_name)||"",code:(W==null?void 0:W.stock_id)||"",month:de,year:se,content:(W==null?void 0:W.text_summary)||"",status:(W==null?void 0:W.status)||"",note:(W==null?void 0:W.note)||"",lastUpdate:W==null?void 0:W.updated_at,stock_id:W==null?void 0:W.stock_id}}),A=K=>{if(!(K!=null&&K.data))return[];const ee=E(K==null?void 0:K.data);n(ee),p(K.pagination.totalPages)},N=async(K=1,ee=15)=>{C(K),o(!0);try{const W=await Le.get(`${t}/api/latest-summaries`,{params:{page:K,limit:ee,search:w}});(W==null?void 0:W.status)===200?A(W.data):console.error(W)}catch(W){console.error("Error fetching data:",W)}finally{C(null),o(!1)}};O.useEffect(()=>{v&&u(1),N(l)},[l,v]);const P=O.useMemo(()=>[{id:"code",header:"Mã",accessorKey:"code",cell:({row:ee})=>d.jsx("span",{className:"flex flex-col",children:ee.original.code})},{id:"month",header:"Tháng",accessorKey:"month",cell:({row:ee})=>{const W=ee.original.month,de=ee.original.year;return d.jsx("span",{className:"flex flex-col",children:`${W.toString().padStart(2,"0")}/${de}`})}},{id:"content",header:"Nội dung",accessorKey:"content",cell:({row:ee})=>{const W=ee.getValue("content");return d.jsx("div",{className:"text-start truncate text-ellipsis overflow-hidden whitespace-nowrap max-w-[30dvw]",children:W})}},{id:"status",header:"Trạng thái",accessorKey:"status",cell:({row:ee})=>{const de=ee.original.status!=="unpublish";return d.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0 text-[10px] font-bold ${de?"bg-green-50 text-green-700 ring-1 ring-inset ring-green-600/20":"bg-gray-50 text-gray-600 ring-1 ring-inset ring-gray-500/20"}`,children:de?"PUBLISHED":"UNPUBLISHED"})}},{id:"note",header:"Ghi chú",accessorKey:"note",cell:({row:ee})=>d.jsx(C0,{content:d.jsx("div",{className:"font-medium text-[16px] max-w-[90dvw]",children:ee.original.note}),children:d.jsx("div",{className:"text-start truncate text-ellipsis overflow-hidden whitespace-nowrap max-w-[20dvw]",children:ee.original.note})})},{id:"last-update",header:"Cập nhật",accessorKey:"last-update",cell:({row:ee})=>{const W=new Date(ee.original.lastUpdate),de=W.getDate(),se=W.getMonth()+1,fe=`ngày ${de} tháng ${se}`;return d.jsx("span",{className:"flex flex-col",children:fe})}},{accessorKey:"actions",header:()=>d.jsx("div",{className:"font-medium text-right",children:"Hành động"}),cell:({row:ee})=>{const[W,de]=O.useState(!1),[se,fe]=O.useState(!1),[q,Z]=O.useState(!1),{handleSubmit:Y,register:oe,reset:Q}=h5(),X=ee.original.id,$=ee.getValue("status"),te=ee.getValue("content"),[_e,ke]=O.useState(!1),xe=async()=>{try{ke(!0);const Te=$==="unpublish"?"published":"unpublish",z=await Le.patch(`${t}/api/toggle-publish/${X}`,{id:X,typeAction:"update",status:$,idInput:X,stock_id:ee.original.stock_id,prefix:ee.original.prefix,model:ee.original.model,summary_result:ee.original.content,note:ee.original.note});z.status===200?n(ce=>ce.map(Ae=>Ae.id===X?{...Ae,status:Te}:Ae)):console.error("Failed to toggle publish status:",z)}catch(Te){console.error("Error toggling publish status:",Te)}finally{ke(!1)}},Pe=async Te=>{de(!0);try{const z=await Le.patch(`${t}/api/update-summary`,{note:Te.note,text_summary:Te.content,id:X});z.status===200?(await N(l),fe(!1)):console.error("Failed to update summary:",z)}catch(z){console.error("Error updating summary:",z)}return de(!1)};return d.jsxs("div",{className:"flex items-center justify-end gap-2",children:[d.jsx(He,{variant:"outline",size:"sm",onClick:()=>Z(!0),className:"px-2 py-0.5 h-7",children:d.jsx($x,{className:"h-4 w-4"})}),d.jsx(or,{open:q,onOpenChange:Z,children:d.jsxs(Kn,{className:"max-w-3xl max-h-[80vh]",children:[d.jsx(Gn,{children:d.jsx(jn,{children:"Nội dung chi tiết"})}),d.jsx("div",{className:"mt-4 overflow-y-auto max-h-[60vh]",children:d.jsx("div",{className:"whitespace-pre-wrap text-[16px] leading-relaxed",children:te})})]})}),d.jsxs(or,{open:se,onOpenChange:Te=>{fe(Te),Te?Q({content:ee.original.content,note:ee.original.note}):Q()},children:[d.jsx(ic,{asChild:!0,children:d.jsx(He,{variant:"outline",size:"sm",onClick:()=>fe(!0),className:"px-2 py-0.5 h-7",children:"Sửa"})}),d.jsx(Kn,{className:"rounded-lg sm:px-3 h-[calc(100dvh-200px)] min-w-[calc(100dvw-112px)]",children:d.jsxs(Gn,{className:"flex flex-col gap-3",children:[d.jsx(jn,{className:"max-sm:hidden text-center",children:"Sửa summary"}),d.jsxs("form",{className:"flex flex-col gap-3 h-full justify-between",onSubmit:Y(Pe),children:[d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex flex-col items-start",children:[d.jsx("span",{children:"Nội dung:"}),d.jsx(sc,{placeholder:"Nội dung",className:"w-full input-scroll-bar",defaultValue:ee.original.answer||"",rows:10,...oe("content")})]}),d.jsxs("div",{className:"flex flex-col items-start",children:[d.jsx("span",{children:"Ghi chú:"}),d.jsx(sc,{placeholder:"Nội dung",className:"w-full input-scroll-bar",defaultValue:ee.original.note||"",rows:1,...oe("note")})]})]}),d.jsx("div",{className:"flex justify-end",children:d.jsx(He,{disabled:W,type:"submit",variant:"default",children:W?d.jsx(Pt,{className:"h-4 w-4 animate-spin"}):"Ok"})})]})]})})]}),d.jsx(He,{variant:"outline",size:"sm",onClick:xe,disabled:_e,className:"w-[70px] px-2 py-0.5 h-7",children:_e?d.jsx(Pt,{className:"h-4 w-4 animate-spin"}):$==="unpublish"?"Publish":"Unpublish"})]})}}],[]),_=Kb({data:e,columns:P,state:{columnFilters:i},enableRowSelection:!0,onColumnFiltersChange:s,getFilteredRowModel:jM(),getCoreRowModel:Vb()});return d.jsxs("div",{className:"space-y-4 s3-explr-container",children:[d.jsx("div",{className:"flex items-center space-x-4 s3-explr-toolbar",children:d.jsxs("div",{className:"relative max-w-sm",children:[d.jsx(Wn,{placeholder:"Tìm kiếm theo mã...",value:w,onChange:K=>b(K.target.value),className:"pr-8"}),w&&d.jsx(He,{variant:"ghost",size:"sm",className:"absolute right-1 top-1/2 -translate-y-1/2 h-6 w-6 p-0",onClick:()=>b(""),children:d.jsx(ig,{className:"h-4 w-4"})})]})}),d.jsx("div",{className:"rounded-md border s3-explr-table-container",children:d.jsxs(jd,{className:"s3-explr-table",children:[d.jsx(Wd,{className:"s3-explr-table-header",children:_.getHeaderGroups().map(K=>d.jsx($r,{className:"hover:bg-transparent s3-explr-header-row",children:K.headers.map(ee=>d.jsx(lo,{className:"s3-explr-header-cell",children:ee.isPlaceholder?null:wd(ee.column.columnDef.header,ee.getContext())},ee.id))},K.id))}),d.jsx(qd,{className:"s3-explr-table-body",children:r?d.jsx($r,{children:d.jsx(qn,{colSpan:P.length,className:"h-24 text-center",children:"Đang tải dữ liệu..."})}):(D=_.getRowModel().rows)!=null&&D.length?(H=_.getRowModel().rows)==null?void 0:H.map(K=>d.jsx($r,{className:"h-12 s3-explr-row",children:K.getVisibleCells().map(ee=>d.jsx(qn,{className:"align-middle s3-explr-cell",children:wd(ee.column.columnDef.cell,ee.getContext())},ee.id))},K.id)):d.jsx($r,{children:d.jsx(qn,{colSpan:P.length,className:"h-24 text-center",children:"Không có kết quả."})})})]})}),d.jsx("div",{className:"mt-4",children:d.jsx(Bd,{children:d.jsxs(zd,{children:[d.jsx(Fr,{children:d.jsx(Vd,{onClick:()=>u(K=>Math.max(1,K-1)),className:l===1?"pointer-events-none opacity-50":"cursor-pointer"})}),Array.from({length:h},(K,ee)=>ee+1).filter(K=>K===1||K===h||Math.abs(K-l)<=1).map((K,ee,W)=>d.jsxs(d.Fragment,{children:[ee>0&&W[ee-1]!==K-1&&d.jsx(Fr,{children:d.jsx(Gd,{})},K+"..."),d.jsx(Fr,{children:d.jsx(Qa,{onClick:()=>u(K),isActive:l===K,className:`cursor-pointer ${r?"pointer-events-none":""}`,children:g===K?d.jsx(Pt,{className:"h-4 w-4 animate-spin"}):K})},K)]})),d.jsx(Fr,{children:d.jsx(Kd,{onClick:()=>u(K=>Math.min(h,K+1)),className:l===h||g!==null?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})},b0=10,m5=O.memo(({apiBaseUrl:t="http://localhost:3002"})=>{const[e,n]=O.useState(1),[r,o]=O.useState([]),[i,s]=O.useState({total:0,page:1,limit:b0,totalPages:1}),[l,u]=O.useState(!0),[h,p]=O.useState(null),[g,C]=O.useState(new Set),{toast:w}=dc(),[b,v]=O.useState(!1),x=async _=>{try{p(_);const D=await Le.get(`${t}/api/jobs`,{params:{page:_.toString(),limit:b0.toString()}});o(D.data.data),s(D.data.pagination)}catch{w({variant:"destructive",title:"Error",description:"Failed to fetch jobs. Please try again."})}finally{p(null),u(!1)}};O.useEffect(()=>{x(e)},[e,t]);const E=async _=>{C(D=>new Set(D).add(_.toString()));try{await Le.post(`${t}/api/retry-job`,{jobId:_}),w({title:"Job Restarted",description:`Job ${_} has been successfully restarted.`}),x(e)}catch{w({variant:"destructive",title:"Retry Failed",description:`Failed to restart job ${_}. Please try again.`})}finally{C(D=>{const H=new Set(D);return H.delete(_.toString()),H})}},A=async()=>{v(!0),n(1),await x(1),v(!1)},N=_=>new Date(_).toLocaleString(),P=_=>{if(_=parseFloat(_),_<60)return`${_.toFixed(2)}s`;const D=Math.floor(_/60),H=(_%60).toFixed(0);return`${D}m ${H}s`};return d.jsxs("div",{children:[d.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[d.jsx($D,{className:"w-8 h-8 text-primary"}),d.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Job Management"}),d.jsx(He,{variant:"outline",size:"icon",onClick:A,disabled:b||l,className:"ml-2",children:d.jsx(KD,{className:`h-4 w-4 ${b?"animate-spin":""}`})})]}),d.jsx("div",{className:"rounded-md border",children:d.jsxs(jd,{children:[d.jsx(Wd,{children:d.jsxs($r,{children:[d.jsx(lo,{children:"ID"}),d.jsx(lo,{children:"Tên Công Việc"}),d.jsx(lo,{children:"Thời Gian Bắt Đầu"}),d.jsx(lo,{children:"Thời Gian Cập Nhật"}),d.jsx(lo,{children:"Thời Gian Thực Thi"}),d.jsx(lo,{children:"Trạng Thái"}),d.jsx(lo,{children:"Thao Tác"})]})}),d.jsx(qd,{children:l&&r.length===0?d.jsx($r,{children:d.jsx(qn,{colSpan:7,className:"text-center py-4",children:d.jsx(Pt,{className:"w-6 h-6 animate-spin mx-auto"})})}):r.map(_=>{var D,H;return d.jsxs($r,{children:[d.jsx(qn,{className:"!w-[100px]",children:_.id}),d.jsx(qn,{className:"font-medium",children:(D=_.job_name)==null?void 0:D.replace("Upload file","Summary")}),d.jsx(qn,{className:"!w-[200px]",children:N(_.created_at)}),d.jsx(qn,{className:"!w-[200px]",children:N(_.updated_at)}),d.jsx(qn,{className:"!w-[150px]",children:P(_.execution_time_seconds)}),d.jsx(qn,{className:"!w-[200px]",children:d.jsx(C0,{content:_.status==="fail"&&_.error?d.jsx("div",{className:"font-medium text-[16px] max-w-[90dvw]",children:_.error}):null,children:d.jsx("div",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium truncate text-ellipsis overflow-hidden whitespace-nowrap max-w-[30dvw]
|
|
224
224
|
${_.status==="done"?"bg-green-100 text-green-800":_.status==="fail"?"bg-red-100 text-red-800":"bg-yellow-100 text-yellow-800"}`,children:_.status==="fail"?"FAILED":(H=_.status)==null?void 0:H.toUpperCase()})})}),d.jsx(qn,{className:"!w-[200px]",children:_.status==="fail"?d.jsx(He,{variant:"outline",size:"sm",onClick:()=>E(_.id),disabled:g.has(_.id.toString()),className:"h-[32px]",children:g.has(_.id.toString())?d.jsxs(d.Fragment,{children:[d.jsx(Pt,{className:"mr-2 h-4 w-4 animate-spin"}),"Đang thử lại..."]}):"Thử Lại"}):d.jsx("div",{className:"h-[32px]"})})]},_.id)})})]})}),d.jsx("div",{className:"mt-4",children:d.jsx(Bd,{children:d.jsxs(zd,{children:[d.jsx(Fr,{children:d.jsx(Vd,{onClick:()=>n(_=>Math.max(1,_-1)),className:e===1?"pointer-events-none opacity-50":"cursor-pointer"})}),Array.from({length:i.totalPages},(_,D)=>D+1).filter(_=>_===1||_===i.totalPages||Math.abs(_-e)<=1).map((_,D,H)=>d.jsxs(d.Fragment,{children:[D>0&&H[D-1]!==_-1&&d.jsx(Fr,{children:d.jsx(Gd,{})},_+"..."),d.jsx(Fr,{children:d.jsx(Qa,{onClick:()=>n(_),isActive:e===_,className:`cursor-pointer ${h!==null?"pointer-events-none":""}`,children:h===_?d.jsx(Pt,{className:"h-4 w-4 animate-spin"}):_})},_)]})),d.jsx(Fr,{children:d.jsx(Kd,{onClick:()=>n(_=>Math.min(i.totalPages,_+1)),className:e===i.totalPages||h!==null?"pointer-events-none opacity-50":"cursor-pointer"})})]})})}),d.jsx(s_,{})]})});Tr.Job=m5,Tr.S3Explorer=G3,Tr.Summary=g5,Object.defineProperty(Tr,Symbol.toStringTag,{value:"Module"})});
|
|
225
225
|
//# sourceMappingURL=s3-explorer.umd.cjs.map
|