import{k as $e,j as o,t as xe,g as q,m as x,n as c,p as r,f as G,i as b,x as v,v as R,B as be,A as S,z as ve,w as me,s as he,S as Z}from"./web.Os7kOAdY.js";import{g as J,t as _e}from"./i18n-runtime._BAkvU05.js";var we=S("<div style=display:flex;flex-wrap:wrap;gap:12px;margin-bottom:12px;align-items:center><label style=font-size:13px><!$><!/><input type=range min=0.1 max=3 step=0.01></label><label style=font-size:13px><!$><!/><input type=range min=-300 max=300 step=1></label><label style=font-size:13px><!$><!/><input type=range min=-300 max=300 step=1>"),Q=S("<button class=tool-btn>"),Se=S('<div class=tool-container><div style=display:flex;flex-wrap:wrap;gap:12px;margin-bottom:16px><label class=tool-btn style=cursor:pointer><!$><!/><input type=file accept=image/* style=display:none></label><select class=tool-select></select><div style=display:flex;gap:6px;align-items:center></div></div><!$><!/><div style="display:flex;justify-content:center;margin-bottom:16px;background:repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 50%/16px 16px;padding:16px;border-radius:8px"><canvas style="max-width:100%;height:auto;border:1px solid var(--border);border-radius:4px"></canvas></div><!$><!/>'),ye=S("<option>");const O={"1inch":{w:295,h:413,label:"一寸 (25×35mm)"},"2inch":{w:413,h:579,label:"二寸 (35×49mm)"},visa:{w:354,h:472,label:"签证 (35×45mm)"}},Ce=[{value:"#ffffff",label:"白色"},{value:"#438edb",label:"蓝色"},{value:"#d03030",label:"红色"}];function Le(){const[V,T]=o(J(),{equals:!1}),d=e=>_e(e,V());xe(()=>{const e=n=>{const t=n.detail?.locale;t&&T(t)};window.addEventListener("taitan:locale-change",e),T(J()),he(()=>window.removeEventListener("taitan:locale-change",e))});const[g,ee]=o(null),[y,te]=o("#ffffff"),[f,le]=o("1inch"),[C,j]=o(0),[E,A]=o(0),[k,B]=o(1);let s,p;function ne(e){const n=e.target.files?.[0];if(!n)return;const t=new FileReader;t.onload=()=>ee(t.result),t.readAsDataURL(n)}function F(){if(!s||!p||!g())return;const e=O[f()];s.width=e.w,s.height=e.h;const n=s.getContext("2d");n.fillStyle=y(),n.fillRect(0,0,e.w,e.h);const t=k(),m=p.naturalWidth*t,u=p.naturalHeight*t,L=(e.w-m)/2+C(),z=(e.h-u)/2+E();n.drawImage(p,L,z,m,u)}q(()=>{if(g()){const e=new Image;e.onload=()=>{p=e;const n=O[f()],t=Math.max(n.w/e.naturalWidth,n.h/e.naturalHeight);B(t),j(0),A(0),F()},e.src=g()}}),q(()=>{y(),f(),C(),E(),k(),F()});function ae(){if(!s)return;const e=document.createElement("a");e.download=`id-photo-${f()}.png`,e.href=s.toDataURL("image/png"),e.click()}return(()=>{var e=x(Se),n=e.firstChild,t=n.firstChild,m=t.firstChild,[u,L]=c(m.nextSibling),z=u.nextSibling,h=t.nextSibling,ie=h.nextSibling,re=n.nextSibling,[H,se]=c(re.nextSibling),M=H.nextSibling,X=M.firstChild,oe=M.nextSibling,[ce,de]=c(oe.nextSibling);r(t,()=>d("上传照片"),u,L),z.addEventListener("change",ne),h.addEventListener("change",l=>le(l.currentTarget.value)),r(h,()=>Object.entries(O).map(([l,i])=>(()=>{var a=x(ye);return v(a,"value",l),r(a,()=>i.label),a})())),r(ie,()=>Ce.map(l=>(()=>{var i=x(Q);return i.$$click=()=>te(l.value),b(a=>{var _=`background:${l.value};width:28px;height:28px;border-radius:50%;border:2px solid ${y()===l.value?"var(--accent)":"var(--border)"};padding:0;`,w=l.label;return a.e=ve(i,_,a.e),w!==a.t&&me(i,"title",a.t=w),a},{e:void 0,t:void 0}),R(),i})())),r(e,G(Z,{get when(){return g()},get children(){var l=x(we),i=l.firstChild,a=i.firstChild,[_,w]=c(a.nextSibling),D=_.nextSibling,I=i.nextSibling,ge=I.firstChild,[K,fe]=c(ge.nextSibling),N=K.nextSibling,P=I.nextSibling,pe=P.firstChild,[U,ue]=c(pe.nextSibling),W=U.nextSibling;return r(i,()=>d("缩放:"),_,w),D.$$input=$=>B(parseFloat($.currentTarget.value)),r(I,()=>d("X偏移:"),K,fe),N.$$input=$=>j(parseInt($.currentTarget.value)),r(P,()=>d("Y偏移:"),U,ue),W.$$input=$=>A(parseInt($.currentTarget.value)),b(()=>v(D,"value",k())),b(()=>v(N,"value",C())),b(()=>v(W,"value",E())),R(),l}}),H,se);var Y=s;return typeof Y=="function"?be(Y,X):s=X,r(e,G(Z,{get when(){return g()},get children(){var l=x(Q);return l.$$click=ae,r(l,()=>d("下载证件照")),R(),l}}),ce,de),b(()=>v(h,"value",f())),e})()}$e(["input","click"]);export{Le as default};
