import{k as rt,j as p,t as st,h as q,m as w,n as y,p as a,i as $,v as at,q as ct,A as L,w as z,x as E,s as ut}from"./web.Os7kOAdY.js";import{c as A}from"./clipboard.BNxbz_oK.js";import{g as F,t as dt}from"./i18n-runtime._BAkvU05.js";var xt=L('<div class=panel style=display:flex;flex-direction:column;gap:14px><div class=tool-grid-2><div class=tool-field><span class=tool-label></span><input class=tool-input></div><div class=tool-field><span class=tool-label></span><input class=tool-input></div></div><div class=chmod-grid><div></div><div style=text-align:center;font-weight:600>Read</div><div style=text-align:center;font-weight:600>Write</div><div style=text-align:center;font-weight:600>Exec</div><!$><!/></div><pre class=tool-pre style=font-size:18px;text-align:center>chmod <!$><!/> file.txt → -<!$><!/></pre><div class=tool-actions><button class="tool-btn is-primary"></button><button class=tool-btn>'),pt=L("<div style=font-weight:600;color:var(--muted);text-transform:capitalize>"),$t=L("<label class=chmod-cell style=justify-content:center><input type=checkbox><span style=font-family:ui-monospace,monospace;color:var(--muted)>");const gt=["user","group","other"],N=["r","w","x"];function vt(n){const t=n.replace(/^0o?/,"").padStart(3,"0").slice(-3);if(!/^[0-7]{3}$/.test(t))throw new Error("八进制必须 3 位 0..7");const e=[];for(const c of t){const u=parseInt(c,10);e.push((u&4)!==0,(u&2)!==0,(u&1)!==0)}return e}function ft(n){const t=n.replace(/^[d-]/,"");if(t.length!==9||!/^[r-][w-][x-][r-][w-][x-][r-][w-][x-]$/.test(t))throw new Error("符号格式应为 9 位，如 rwxr-xr--");return[t[0]==="r",t[1]==="w",t[2]==="x",t[3]==="r",t[4]==="w",t[5]==="x",t[6]==="r",t[7]==="w",t[8]==="x"]}function C(n){let t="";for(let e=0;e<3;e++){const c=(n[e*3]?4:0)+(n[e*3+1]?2:0)+(n[e*3+2]?1:0);t+=String(c)}return t}function k(n){let t="";for(let e=0;e<9;e++)t+=n[e]?N[e%3]:"-";return t}function _t(){const[n,t]=p(F(),{equals:!1}),e=r=>dt(r,n());st(()=>{const r=s=>{const d=s.detail?.locale;d&&t(d)};window.addEventListener("taitan:locale-change",r),t(F()),ut(()=>window.removeEventListener("taitan:locale-change",r))});const[c,u]=p([!0,!0,!0,!0,!1,!0,!0,!1,!0]),[P,g]=p("755"),[B,v]=p("rwxr-xr-x"),f=q(()=>C(c())),H=q(()=>k(c())),W=r=>{const s=c().slice();s[r]=!s[r],u(s),g(C(s)),v(k(s))};return(()=>{var r=w(xt),s=r.firstChild,d=s.firstChild,T=d.firstChild,m=T.nextSibling,j=d.nextSibling,I=j.firstChild,b=I.nextSibling,h=s.nextSibling,D=h.firstChild,G=D.nextSibling,J=G.nextSibling,K=J.nextSibling,Q=K.nextSibling,[U,V]=y(Q.nextSibling),x=h.nextSibling,X=x.firstChild,Y=X.nextSibling,[M,Z]=y(Y.nextSibling),tt=M.nextSibling,et=tt.nextSibling,[lt,nt]=y(et.nextSibling),it=x.nextSibling,_=it.firstChild,O=_.nextSibling;return a(T,()=>e("八进制")),m.$$input=i=>{const o=i.currentTarget.value;g(o);try{const l=vt(o);u(l),v(k(l))}catch{}},a(I,()=>e("符号")),b.$$input=i=>{const o=i.currentTarget.value;v(o);try{const l=ft(o);u(l),g(C(l))}catch{}},a(h,()=>gt.map((i,o)=>[(()=>{var l=w(pt);return a(l,i),l})(),ct(()=>[0,1,2].map(l=>(()=>{var R=w($t),S=R.firstChild,ot=S.nextSibling;return S.addEventListener("change",()=>W(o*3+l)),a(ot,()=>N[l]),$(()=>E(S,"checked",c()[o*3+l])),R})()))]),U,V),a(x,f,M,Z),a(x,H,lt,nt),_.$$click=()=>A(`chmod ${f()}`),a(_,()=>e("复制 chmod 命令")),O.$$click=()=>A(f()),a(O,()=>e("仅复制八进制")),$(i=>{var o=e("如 755"),l=e("如 rwxr-xr-x");return o!==i.e&&z(m,"placeholder",i.e=o),l!==i.t&&z(b,"placeholder",i.t=l),i},{e:void 0,t:void 0}),$(()=>E(m,"value",P())),$(()=>E(b,"value",B())),at(),r})()}rt(["input","click"]);export{_t as default};
