import{k as ut,j as S,t as dt,h as $t,m as W,n as C,p as n,f as bt,q as gt,i as k,v as j,A as G,e as y,w as ft,z as xt,x as T,s as pt,F as vt}from"./web.Os7kOAdY.js";import{c as mt}from"./clipboard.BNxbz_oK.js";import{u as z,g as _t,b as ht,e as St,s as Ct,f as kt,h as yt}from"./utils.BiOoVwDh.js";import{g as O,t as Tt}from"./i18n-runtime._BAkvU05.js";var Et=G('<div class=panel style=display:flex;flex-direction:column;gap:14px><div class=tool-tabs role=tablist></div><div class=tool-tabs><button></button><button></button></div><div class=tool-grid-2><div class=tool-field><span class=tool-label></span><textarea class="tool-textarea is-wrap"></textarea><span class=tool-hint><!$><!/> <!$><!/><!$><!/> <!$><!/></span></div><div class=tool-field><span class=tool-label></span><textarea class="tool-textarea is-wrap"readonly></textarea><span></span></div></div><div class=tool-actions><button class="tool-btn is-primary"></button><button class=tool-btn></button><button class="tool-btn is-ghost"></button><button class="tool-btn is-ghost">'),Lt=G("<button>");const wt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},It={amp:"&",lt:"<",gt:">",quot:'"',"#39":"'",apos:"'",nbsp:" "};function Ht($){let s="";for(const e of $){const u=e.codePointAt(0);u<128&&/[\x20-\x7e]/.test(e)?s+=e:u<=65535?s+=`\\u${u.toString(16).padStart(4,"0")}`:s+=`\\u{${u.toString(16)}}`}return s}function Mt($){return $.replace(/\\u\{([0-9a-fA-F]+)\}/g,(s,e)=>String.fromCodePoint(parseInt(e,16))).replace(/\\u([0-9a-fA-F]{4})/g,(s,e)=>String.fromCharCode(parseInt(e,16))).replace(/\\x([0-9a-fA-F]{2})/g,(s,e)=>String.fromCharCode(parseInt(e,16)))}function qt(){const[$,s]=S(O(),{equals:!1}),e=o=>Tt(o,$());dt(()=>{const o=a=>{const i=a.detail?.locale;i&&s(i)};window.addEventListener("taitan:locale-change",o),s(O()),pt(()=>window.removeEventListener("taitan:locale-change",o))});const[u,J]=S("base64"),[f,x]=S(""),[b,p]=S("enc"),l=$t(()=>{const o=f(),a=u(),i=b();if(!o)return{ok:!0,out:""};try{return a==="base64"?{ok:!0,out:i==="enc"?_t(o):ht(o.trim())}:a==="hex"?{ok:!0,out:i==="enc"?St(Ct(o)):kt(yt(o))}:a==="url"?{ok:!0,out:i==="enc"?encodeURIComponent(o):decodeURIComponent(o)}:a==="html"?{ok:!0,out:i==="enc"?o.replace(/[&<>"']/g,c=>wt[c]):o.replace(/&(#?\w+);/g,(c,r)=>r.startsWith("#x")?String.fromCodePoint(parseInt(r.slice(2),16)):r.startsWith("#")?String.fromCodePoint(parseInt(r.slice(1),10)):It[r]??`&${r};`)}:a==="unicode"?{ok:!0,out:i==="enc"?Ht(o):Mt(o)}:{ok:!1,out:""}}catch(c){return{ok:!1,out:c.message}}}),K=()=>{x(l().out),p(b()==="enc"?"dec":"enc")},Q=()=>{x({base64:"在线工具 LvOnce",hex:"Hello, 世界",url:"https://lvonce.com/查询?key=值&v=1",html:'<script>alert("xss")<\/script>',unicode:"你好，世界 🌏"}[u()]),p("enc")};return(()=>{var o=W(Et),a=o.firstChild,i=a.nextSibling,c=i.firstChild,r=c.nextSibling,w=i.nextSibling,I=w.firstChild,H=I.firstChild,v=H.nextSibling,g=v.nextSibling,V=g.firstChild,[M,X]=C(V.nextSibling),Y=M.nextSibling,Z=Y.nextSibling,[A,tt]=C(Z.nextSibling),et=A.nextSibling,[U,ot]=C(et.nextSibling),nt=U.nextSibling,lt=nt.nextSibling,[it,st]=C(lt.nextSibling),at=I.nextSibling,F=at.firstChild,P=F.nextSibling,E=P.nextSibling,rt=w.nextSibling,m=rt.firstChild,_=m.nextSibling,L=_.nextSibling,q=L.nextSibling;return n(a,bt(vt,{each:[["base64","Base64"],["hex","Hex"],["url","URL"],["html","HTML 实体"],["unicode","Unicode"]],children:([t,h])=>(()=>{var d=W(Lt);return d.$$click=()=>J(t),n(d,h),k(()=>y(d,`tool-tab ${u()===t?"is-active":""}`)),j(),d})()})),c.$$click=()=>p("enc"),n(c,()=>e("编码")),r.$$click=()=>p("dec"),n(r,()=>e("解码")),n(H,()=>e("输入")),v.$$input=t=>x(t.currentTarget.value),n(g,()=>z(f()),M,X),n(g,()=>e("字节 ·"),A,tt),n(g,()=>f().length,U,ot),n(g,()=>e("字符"),it,st),n(F,()=>e("输出")),n(E,(()=>{var t=gt(()=>!!l().ok);return()=>t()?`${z(l().out)} 字节`:`× ${l().out}`})()),m.$$click=()=>mt(l().out),n(m,()=>e("复制结果")),_.$$click=K,n(_,()=>e("↑↓ 交换")),L.$$click=()=>x(""),n(L,()=>e("清空")),q.$$click=Q,n(q,()=>e("示例")),k(t=>{var h=`tool-tab ${b()==="enc"?"is-active":""}`,d=`tool-tab ${b()==="dec"?"is-active":""}`,B=b()==="enc"?"输入原文…":"输入要解码的字符串…",N=`tool-hint ${l().ok?"":"tool-error"}`,ct=l().ok?"":"padding:6px 10px;",R=!l().ok||!l().out,D=!l().ok;return h!==t.e&&y(c,t.e=h),d!==t.t&&y(r,t.t=d),B!==t.a&&ft(v,"placeholder",t.a=B),N!==t.o&&y(E,t.o=N),t.i=xt(E,ct,t.i),R!==t.n&&T(m,"disabled",t.n=R),D!==t.s&&T(_,"disabled",t.s=D),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),k(()=>T(v,"value",f())),k(()=>T(P,"value",l().out)),j(),o})()}ut(["click","input"]);export{qt as default};
