import{k as st,j as h,t as at,h as M,m as p,n as S,p as n,q as W,i as g,v as T,A as v,e as F,w as it,x as y,s as rt}from"./web.Os7kOAdY.js";import{c as ot}from"./clipboard.BNxbz_oK.js";import{g as O,t as ct}from"./i18n-runtime._BAkvU05.js";var ut=v('<div class=panel style=display:flex;flex-direction:column;gap:14px><div class=tool-grid-3><div class=tool-field><span class=tool-label></span><input class=tool-input type=text></div><div class=tool-field><span class=tool-label></span><input class=tool-input type=number min=2 max=36><div class=tool-actions style=gap:4px></div></div><div class=tool-field><span class=tool-label></span><input class=tool-input type=number min=2 max=36><div class=tool-actions style=gap:4px></div></div></div><!$><!/><div class=tool-actions><button class="tool-btn is-primary"></button></div><!$><!/><p class=tool-hint>'),D=v("<button>"),$t=v("<pre class=tool-pre style=font-size:18px>"),pt=v("<div class=tool-error>× <!$><!/>"),dt=v("<dl class=tool-kv>"),mt=v("<dt>Base <!$><!/>"),vt=v("<dd style=font-family:ui-monospace,monospace>");const K="0123456789abcdefghijklmnopqrstuvwxyz";function _t(o,c){const i=o.trim().toLowerCase().replace(/^[+-]/,u=>u).replace(/_/g,"");let r=!1,s=i;if(s.startsWith("-")?(r=!0,s=s.slice(1)):s.startsWith("+")&&(s=s.slice(1)),!s)throw new Error("空输入");let a=0n;const b=BigInt(c);for(const u of s){const _=K.indexOf(u);if(_<0||_>=c)throw new Error(`字符 "${u}" 不属于 ${c} 进制`);a=a*b+BigInt(_)}return r?-a:a}function G(o,c){if(o===0n)return"0";const i=o<0n;let r=i?-o:o;const s=BigInt(c);let a="";for(;r>0n;)a=K[Number(r%s)]+a,r=r/s;return i?"-"+a:a}const J=[2,8,10,16];function bt(){const[o,c]=h(O(),{equals:!1}),i=l=>ct(l,o());at(()=>{const l=d=>{const x=d.detail?.locale;x&&c(x)};window.addEventListener("taitan:locale-change",l),c(O()),rt(()=>window.removeEventListener("taitan:locale-change",l))});const[r,s]=h("255"),[a,b]=h(10),[u,_]=h(16),L=M(()=>{try{return{ok:!0,v:_t(r(),a())}}catch(l){return{ok:!1,v:0n,err:l.message}}}),f=M(()=>{const l=L();return l.ok?{ok:!0,out:G(l.v,u())}:{ok:!1,out:l.err}}),A=M(()=>{const l=L();return l.ok?[2,8,10,16,32,36].map(d=>({base:d,out:G(l.v,d)})):[]});return(()=>{var l=p(ut),d=l.firstChild,x=d.firstChild,N=x.firstChild,k=N.nextSibling,q=x.nextSibling,P=q.firstChild,w=P.nextSibling,Q=w.nextSibling,U=q.nextSibling,j=U.firstChild,B=j.nextSibling,V=B.nextSibling,X=d.nextSibling,[z,Y]=S(X.nextSibling),H=z.nextSibling,C=H.firstChild,Z=H.nextSibling,[R,tt]=S(Z.nextSibling),et=R.nextSibling;return n(N,()=>i("输入")),k.$$input=t=>s(t.currentTarget.value),n(P,()=>i("来源进制")),w.$$input=t=>b(Math.max(2,Math.min(36,parseInt(t.currentTarget.value,10)||10))),n(Q,()=>J.map(t=>(()=>{var e=p(D);return e.$$click=()=>b(t),n(e,t),g(()=>F(e,`tool-btn ${a()===t?"is-primary":"is-ghost"}`)),T(),e})())),n(j,()=>i("目标进制")),B.$$input=t=>_(Math.max(2,Math.min(36,parseInt(t.currentTarget.value,10)||10))),n(V,()=>J.map(t=>(()=>{var e=p(D);return e.$$click=()=>_(t),n(e,t),g(()=>F(e,`tool-btn ${u()===t?"is-primary":"is-ghost"}`)),T(),e})())),n(l,(()=>{var t=W(()=>!!f().ok);return()=>t()?(()=>{var e=p($t);return n(e,()=>f().out),e})():(()=>{var e=p(pt),m=e.firstChild,$=m.nextSibling,[E,I]=S($.nextSibling);return n(e,()=>f().out,E,I),e})()})(),z,Y),C.$$click=()=>ot(f().out),n(C,()=>i("复制结果")),n(l,(()=>{var t=W(()=>A().length>0);return()=>t()&&(()=>{var e=p(dt);return n(e,()=>A().map(m=>[(()=>{var $=p(mt),E=$.firstChild,I=E.nextSibling,[lt,nt]=S(I.nextSibling);return n($,()=>m.base,lt,nt),$})(),(()=>{var $=p(vt);return n($,()=>m.out),$})()])),e})()})(),R,tt),n(et,()=>i("支持 2..36 任意进制，BigInt 大整数无溢出；输入可包含 _ 分隔符。")),g(t=>{var e=i("支持负号、_ 分隔符"),m=!f().ok;return e!==t.e&&it(k,"placeholder",t.e=e),m!==t.t&&y(C,"disabled",t.t=m),t},{e:void 0,t:void 0}),g(()=>y(k,"value",r())),g(()=>y(w,"value",a())),g(()=>y(B,"value",u())),T(),l})()}st(["input","click"]);export{bt as default};
