import{k as fe,j as b,t as pe,h as $e,m as g,n as _,p as i,i as m,v as y,A as D,e as A,x as O,s as ue}from"./web.Os7kOAdY.js";import{c as be}from"./clipboard.BNxbz_oK.js";import{g as U,t as me}from"./i18n-runtime._BAkvU05.js";var he=D('<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><div class=tool-tabs></div></div><div class=tool-field style="grid-column:span 2"><span class=tool-label></span><div style=display:flex;flex-wrap:wrap;gap:6px></div></div></div><div class=tool-grid-2><div class=tool-field><span class=tool-label></span><textarea class="tool-textarea is-wrap"></textarea></div><div class=tool-field><span class=tool-label></span><textarea class="tool-textarea is-wrap"></textarea></div></div><div class=tool-actions><span class=tool-label style=margin-right:6px></span><!$><!/></div><div class=tool-field><span class=tool-label><!$><!/><!$><!/> <!$><!/></span><textarea class="tool-textarea is-wrap"readonly></textarea></div><div class=tool-actions><button class="tool-btn is-primary"></button><button class=tool-btn>'),B=D("<button>");function xe(f,a,s){let t=f.split(s===`
`?/\r?\n/:s).map(e=>e);if(a.has("trim")&&(t=t.map(e=>e.trim())),a.has("lower")&&(t=t.map(e=>e.toLowerCase())),a.has("upper")&&(t=t.map(e=>e.toUpperCase())),a.has("dedup")){const e=new Set;t=t.filter(l=>e.has(l)?!1:(e.add(l),!0))}if(a.has("sort-asc")&&(t=[...t].sort((e,l)=>e.localeCompare(l,"zh"))),a.has("sort-desc")&&(t=[...t].sort((e,l)=>l.localeCompare(e,"zh"))),a.has("sort-num-asc")&&(t=[...t].sort((e,l)=>parseFloat(e)-parseFloat(l))),a.has("sort-num-desc")&&(t=[...t].sort((e,l)=>parseFloat(l)-parseFloat(e))),a.has("reverse")&&(t=[...t].reverse()),a.has("shuffle")){const e=[...t];for(let l=e.length-1;l>0;l--){const n=Math.floor(Math.random()*(l+1));[e[l],e[n]]=[e[n],e[l]]}t=e}return a.has("numbered")&&(t=t.map((e,l)=>`${l+1}. ${e}`)),t.join(s===`
`?`
`:s)}function ve(f,a,s){const t=new Set(f),e=new Set(a);if(s==="union")return[...new Set([...f,...a])];if(s==="intersect")return f.filter(n=>e.has(n)).filter((n,r,h)=>h.indexOf(n)===r);if(s==="diff")return f.filter(n=>!e.has(n)).filter((n,r,h)=>h.indexOf(n)===r);const l=[];for(const n of new Set([...f,...a]))t.has(n)!==e.has(n)&&l.push(n);return l}const ge=[{key:"trim",label:"Trim"},{key:"dedup",label:"去重"},{key:"sort-asc",label:"升序"},{key:"sort-desc",label:"降序"},{key:"sort-num-asc",label:"数字升"},{key:"sort-num-desc",label:"数字降"},{key:"reverse",label:"反转"},{key:"shuffle",label:"洗牌"},{key:"lower",label:"小写"},{key:"upper",label:"大写"},{key:"numbered",label:"加序号"}];function we(){const[f,a]=b(U(),{equals:!1}),s=o=>me(o,f());pe(()=>{const o=d=>{const p=d.detail?.locale;p&&a(p)};window.addEventListener("taitan:locale-change",o),a(U()),ue(()=>window.removeEventListener("taitan:locale-change",o))});const[t,e]=b(`apple
banana
cherry
apple
  date  `),[l,n]=b(`banana
elderberry
cherry
fig`),[r,h]=b(`
`),[S,G]=b(new Set(["trim","dedup"])),[w,I]=b(""),v=$e(()=>{if(w()){const o=t().split(r()===`
`?/\r?\n/:r()).map(p=>p.trim()).filter(Boolean),d=l().split(r()===`
`?/\r?\n/:r()).map(p=>p.trim()).filter(Boolean);return ve(o,d,w()).join(r()===`
`?`
`:r())}return xe(t(),S(),r())}),J=o=>{const d=new Set(S());d.has(o)?d.delete(o):d.add(o),G(d)};return(()=>{var o=g(he),d=o.firstChild,p=d.firstChild,E=p.firstChild,Q=E.nextSibling,V=p.nextSibling,L=V.firstChild,W=L.nextSibling,T=d.nextSibling,M=T.firstChild,j=M.firstChild,F=j.nextSibling,X=M.nextSibling,N=X.firstChild,z=N.nextSibling,k=T.nextSibling,K=k.firstChild,Y=K.nextSibling,[Z,ee]=_(Y.nextSibling),P=k.nextSibling,x=P.firstChild,te=x.firstChild,[q,le]=_(te.nextSibling),ae=q.nextSibling,[H,se]=_(ae.nextSibling),ne=H.nextSibling,ie=ne.nextSibling,[re,oe]=_(ie.nextSibling),ce=x.nextSibling,de=P.nextSibling,C=de.firstChild,R=C.nextSibling;return i(E,()=>s("分隔符")),i(Q,()=>[[`
`,"换行"],[",",","],["|","|"],["	","Tab"]].map(([c,u])=>(()=>{var $=g(B);return $.$$click=()=>h(c),i($,u),m(()=>A($,`tool-tab ${r()===c?"is-active":""}`)),y(),$})())),i(L,()=>s("操作（可叠加）")),i(W,()=>ge.map(c=>(()=>{var u=g(B);return u.$$click=()=>J(c.key),i(u,()=>c.label),m(()=>A(u,`tool-cat-pill ${S().has(c.key)?"is-active":""}`)),y(),u})())),i(j,()=>s("列表 A")),F.$$input=c=>e(c.currentTarget.value),i(N,()=>s("列表 B（集合操作时需要）")),z.$$input=c=>n(c.currentTarget.value),i(K,()=>s("集合：")),i(k,()=>[["","关闭"],["union","并集 A∪B"],["intersect","交集 A∩B"],["diff","差集 A\\B"],["symdiff","对称差"]].map(([c,u])=>(()=>{var $=g(B);return $.$$click=()=>I(c),i($,u),m(()=>A($,`tool-cat-pill ${w()===c?"is-active":""}`)),y(),$})()),Z,ee),i(x,()=>s("结果（"),q,le),i(x,()=>v().split(r()===`
`?/\r?\n/:r()).length,H,se),i(x,()=>s("项）"),re,oe),C.$$click=()=>be(v()),i(C,()=>s("复制结果")),R.$$click=()=>e(v()),i(R,()=>s("结果回填到 A")),m(()=>O(F,"value",t())),m(()=>O(z,"value",l())),m(()=>O(ce,"value",v())),y(),o})()}fe(["input","click"]);export{we as default};
