import{aY as M,D as t,I as A,o as v,S as i,K as g,aw as y,M as I,E as O,bu as K,F as x,G as B,J as H,L as _,B as f,dF as N,an as E,C as R,ab as T,bU as W,dG as X,b9 as Y,dJ as q,_ as Q,dH as Z,aj as p,aM as $,aE as w,dI as ee,ag as te,l as ne,$ as re,ah as oe,R as ae,z as le,bt as ce}from"./index-CNZMR1GT.js";import{o as de,E as ue}from"./index-DsSWFirV.js";const z=N(),D=e=>{var a;const[l,n]=f("/");return(a=e.handle)==null||a.call(e,{setPath:n}),t(E,{class:"folder-tree-box",w:"$full",overflowX:"auto",get children(){return t(z.Provider,{get value(){var r,c,u,o;return{value:l,onChange:h=>{n(h),e.onChange(h)},autoOpen:(r=e.autoOpen)!=null?r:!1,forceRoot:(c=e.forceRoot)!=null?c:!1,showEmptyIcon:(u=e.showEmptyIcon)!=null?u:!1,showHiddenFolder:(o=e.showHiddenFolder)!=null?o:!0}},get children(){return t(P,{path:"/"})}})}})},P=e=>{const{isHidePath:l}=W(),[n,a]=f(),{value:r,onChange:c,forceRoot:u,autoOpen:o,showEmptyIcon:h,showHiddenFolder:V}=X(z),J=()=>{var d;return!!(h&&n()!==void 0&&!((d=n())!=null&&d.length))},[G,L]=Y(()=>q(e.path,Q(),u));let m=!1;const b=async()=>{var k;if((k=n())!=null&&k.length)return;const d=await L();ce(d,j=>{m=!0,a(j)},()=>{s()&&C()})},{isOpen:s,onToggle:C}=M(),F=()=>r()===e.path,S=Z(e.path);R(p(r,async d=>{o&&S(d)&&(s()||C(),m||b())}));const U=()=>l(e.path)&&!S(r());return t(i,{get when(){return V||!U()},get children(){return t(E,{get children(){return[t(y,{spacing:"$2",get children(){return[t(i,{get when(){return!G()},get fallback(){return t(ee,{size:"sm",get color(){return w()}})},get children(){return t(i,{get when(){return!J()},get fallback(){return t($,{get color(){return w()},as:ue})},get children(){return t($,{get color(){return w()},as:de,get transform(){return s()?"rotate(90deg)":"none"},transition:"transform 0.2s",cursor:"pointer",onClick:()=>{C(),s()&&b()}})}})}}),t(te,{css:{whiteSpace:"nowrap"},fontSize:"$md",cursor:"pointer",px:"$1",rounded:"$md",get bgColor(){return F()?"$info8":"transparent"},get _hover(){return{bgColor:F()?"$info8":re()}},onClick:()=>{c(e.path)},get children(){return T(()=>e.path==="/")()?"root":ne(e.path)}})]}}),t(i,{get when(){return s()},get children(){return t(oe,{mt:"$1",pl:"$4",alignItems:"start",spacing:"$1",get children(){return t(ae,{get each(){return n()},children:d=>t(P,{get path(){return le(e.path,d.name)}})})}})}})]}})}})},ge=e=>{var u;const l=v(),[n,a]=f((u=e.defaultValue)!=null?u:"/"),[r,c]=f();return R(()=>{var o;e.opened&&((o=r())==null||o.setPath(n()))}),t(_,{size:"xl",blockScrollOnMount:!1,get opened(){return e.opened},get onClose(){return e.onClose},get children(){return[t(I,{}),t(O,{get children(){return[t(x,{w:"$full",css:{overflowWrap:"break-word"},get children(){return e.header}}),t(B,{get children(){return[T(()=>e.children),t(D,{onChange:a,handle:o=>c(o),autoOpen:!0})]}}),t(H,{display:"flex",gap:"$2",get children(){return[t(i,{get when(){return e.footerSlot},get children(){return e.footerSlot}}),t(g,{get onClick(){return e.onClose},colorScheme:"neutral",get children(){return l("global.cancel")}}),t(g,{get loading(){return e.loading},onClick:()=>{var o;return(o=e.onSubmit)==null?void 0:o.call(e,n())},get children(){return l("global.ok")}})]}})]}})]}})},fe=e=>{const{isOpen:l,onOpen:n,onClose:a}=M(),r=v();return[t(y,{w:"$full",spacing:"$2",get children(){return[t(A,{get id(){return e.id},get value(){return e.value},onInput:c=>e.onChange(c.currentTarget.value),get readOnly(){return e.onlyFolder},get onClick(){return e.onlyFolder?n:()=>{}},get placeholder(){return r("global.".concat(e.onlyFolder?"choose_folder":"choose_or_input_path"))}}),t(i,{get when(){return!e.onlyFolder},get children(){return t(g,{onClick:n,get children(){return r("global.choose")}})}})]}}),t(_,{size:"xl",get opened(){return l()},onClose:a,get children(){return[t(I,{}),t(O,{get children(){return[t(K,{}),t(x,{get children(){return r("global.choose_folder")}}),t(B,{get children(){return t(D,{forceRoot:!0,get onChange(){return e.onChange}})}}),t(H,{get children(){return t(g,{onClick:a,get children(){return r("global.confirm")}})}})]}})]}})]};export{D as F,ge as M,fe as a};
