1import{S as Re,G as W,bL as Te,F as Pe,H as De,E as Ue,bM as _e,bN as Be,V as _,bI as X,bO as Le,j as e,T as Me,d as he,i as pe,bo as Oe,e as He,bP as ze}from"./index-BqXoy4fy.js";import{r as d,u as Ge,c as qe}from"./react-DBTFCQ9V.js";import{l as ge,m as E,E as I,t as M,j as fe,s as Ye}from"./firebase-DUmv6NEE.js";import{I as Xe,P as Ve,B as We,a as Je,v as Ke,g as Qe}from"./BankAccountInput-nfuoivLb.js";import{C as Ze}from"./CreditBalanceBadge-D75EsrmY.js";import{S as er}from"./CreditConfirmDialogs-BgQug1vB.js";import{I as V}from"./ImagePreview-COtiKfH5.js";import{a as rr}from"./format-CdRYU-v6.js";import{w as tr,o as sr,F as ar,j as nr,f as ve,am as O,bj as lr,S as ir,bk as or,a as cr,q as je,N as dr,aG as mr}from"./utils-DRBGurlB.js";import"./index-8JwjhRSi.js";const F=317,xr=4,ur=[48271,81371,57349,69403];function br(x,s){let i=x*s>>>0;return i=(i>>>16^i)>>>0,i=i*73244475>>>0,i=(i>>>16^i)>>>0,(i%F+F)%F}function hr(x){if(x<0||x>99999)throw new Error(`feistelEncrypt: input ${x} out of range [0, 99999]`);let s=x;do{let i=Math.floor(s/F),g=s%F;for(let h=0;h<xr;h++){const t=g,y=(i+br(g,ur[h]))%F;i=t,g=y}s=i*F+g}while(s>=1e5);return s}const pr=(x,s,i=!1)=>{let g;if(s==="50")g=x>=Re?Math.round(x*W[s]):0;else{const y=x*W[s];g=y>Te?Math.round(y):0}let h=0;i||(h=x>=(s==="50"?De:Ue)?Math.round(x*Pe):0);const t=x-g-h;return{withholdingTax:g,healthInsurance:h,netAmount:t}},gr=[{value:"æ¬åç±(å°ç£)",label:"æ¬åç±(å°ç£)"},{value:"å¤ç±(å±
çæ»¿183天)",label:"å¤ç±(å±
çæ»¿183天)"},{value:"å¤ç±(å±
çæªæ»¿183天)",label:"å¤ç±(å±
çæªæ»¿183天)"}],fr=[{value:"transfer",label:"坿¬¾"},{value:"cash",label:"ç¾é"}],Ne=x=>{const s={...x};return Object.keys(s).forEach(i=>{s[i]===void 0&&delete s[i]}),s},ye=async x=>{const s=He(),i=ze(x),h=new Date().toISOString().slice(2,7).replace("-",""),t=await Ye(s,async w=>{const B=await w.get(i),S=(B.exists()?B.data().count:0)+1;return w.set(i,{count:S,lastUpdated:I()},{merge:!0}),S}),y=hr(t%1e5),f=String(y).padStart(5,"0");return`NKL${h}${f}`},$r=({mode:x="create"})=>{var xe,ue;const s=d.useId(),i=Ge(),{id:g}=qe(),h=x==="edit"&&!!g,[t,y]=d.useState(_e),[f,w]=d.useState(Be),[B,J]=d.useState(h),[S,K]=d.useState(!1),[H,Q]=d.useState(!1),[z,v]=d.useState(null),[u,Z]=d.useState({}),[R,ee]=d.useState(null),[T,re]=d.useState(null),[P,te]=d.useState(null),[vr,A]=d.useState(!1),[se,ae]=d.useState(""),[ne,le]=d.useState(""),[ie,oe]=d.useState(""),[ke,G]=d.useState(!1),[q,we]=d.useState(!1),[j,ce]=d.useState(!1);d.useEffect(()=>{h&&g&&Ce(g)},[h,g]),d.useEffect(()=>{Ee()},[]);const Ce=async r=>{try{const a=_();if(!a)throw new Error("Company ID not set");const n=X(a),l=await ge(E(n,r));if(l.exists()){const c=l.data();if(["sending","send_failed","pending","completed","voided","signed"].includes(c.status)){v({type:"error",message:"æ¤åå ±å®çæ
ä¸å
許編輯"}),i(`/labor-receipts/${r}`);return}y({...c,id:l.id}),c.fieldConfig&&(w(c.fieldConfig),ce(!0))}else v({type:"error",message:"æ¾ä¸å°æ¤åå ±å®"}),i("/labor-receipts")}catch(a){console.error("Error loading receipt:",a),v({type:"error",message:"è¼å
¥å¤±æ"})}finally{J(!1)}},Ee=async()=>{try{const r=_();if(!r)return;const a=Le(r),n=await ge(a);n.exists()&&w(n.data())}catch(r){console.error("Error loading field config:",r)}},o=d.useCallback((r,a)=>{y(n=>{const l={...n,[r]:a};if(r==="paymentAmount"||r==="incomeType"||r==="hasSecondGenHealthInsurance"){const c=r==="paymentAmount"?a:n.paymentAmount||0,b=r==="incomeType"?a:n.incomeType||"50",p=r==="hasSecondGenHealthInsurance"?a:n.hasSecondGenHealthInsurance||!1,{withholdingTax:m,healthInsurance:k,netAmount:N}=pr(c,b,p);l.withholdingTax=m,l.healthInsurance=k,l.netAmount=N}return l}),u[r]&&Z(n=>{const l={...n};return delete l[r],l})},[u]),Y=(r,a,n,l)=>{if(a(r),r){const c=new FileReader;c.onloadend=()=>{n(c.result)},c.readAsDataURL(r)}else n(""),o(l,"")},de=(r,a)=>{w(n=>({...n,fields:{...n.fields,[r]:{...n.fields[r],enabled:a}}}))},Ie=(r,a,n)=>{w(l=>({...l,fields:{...l.fields,[r]:{...l.fields[r],[a]:n}}}))},Fe=()=>{var a,n,l,c,b,p,m,k,N,D,$;const r={};return(a=t.signerEmail)!=null&&a.trim()?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.signerEmail)||(r.signerEmail="è«è¼¸å
¥ææçé»åéµä»¶æ ¼å¼"):r.signerEmail="è«è¼¸å
¥é»åéµä»¶",(n=t.serviceDescription)!=null&&n.trim()||(r.serviceDescription="è«è¼¸å
¥ååå
§å®¹"),t.servicePeriodStart||(r.servicePeriodStart="è«é¸æååæéèµ·å§æ¥"),t.servicePeriodEnd||(r.servicePeriodEnd="è«é¸æååæéçµææ¥"),(!t.paymentAmount||t.paymentAmount<=0)&&(r.paymentAmount="è«è¼¸å
¥ä»æ¬¾éé¡"),t.paymentDate||(r.paymentDate="è«é¸æä»æ¬¾æ¥æ"),t.fillingMode==="company_fill"&&((l=t.signerName)!=null&&l.trim()||(r.signerName="è«è¼¸å
¥å§å"),(c=t.signerIdNumber)!=null&&c.trim()?
1Ke(t.signerIdNumber,"taiwan")||(r.signerIdNumber=Qe("taiwan")):r.signerIdNumber="è«è¼¸å
¥èº«åèåè",(b=t.signerPhone)!=null&&b.trim()||(r.signerPhone="è«è¼¸å
¥è¯çµ¡é»è©±"),(p=t.signerAddress)!=null&&p.trim()||(r.signerAddress="è«è¼¸å
¥ç¾å±
å°å"),(m=t.signerRegAddress)!=null&&m.trim()||(r.signerRegAddress="è«è¼¸å
¥æ¶ç±å°å"),t.paymentMethod!=="cash"&&((k=t.bankCode)!=null&&k.trim()||(r.bankCode="è«é¸æéè¡"),(N=t.bankAccountNumber)!=null&&N.trim()||(r.bankAccountNumber="è«è¼¸å
¥éè¡å¸³è"),(D=t.bankAccountName)!=null&&D.trim()||(r.bankAccountName="è«è¼¸å
¥æ¶å"),(!j||f.fields.payment.bankBranch!==!1)&&!(($=t.bankBranch)!=null&&$.trim())&&(r.bankBranch="è«é¸æåè¡"),(!j||f.fields.bankbook.enabled)&&!P&&!t.bankbookUrl&&(r.bankbook="è«ä¸å³åæºå°é¢")),(!j||f.fields.idPhotos.enabled)&&(!R&&!t.idFrontUrl&&(r.idFront="è«ä¸å³èº«åèæ£é¢"),!T&&!t.idBackUrl&&(r.idBack="è«ä¸å³èº«åèåé¢"))),Z(r),Object.keys(r).length===0},me=async r=>{const a=pe(),n=_(),l={},c=fe(a,"uploadLaborReceiptImage"),b=async(m,k)=>{const N=new FileReader,D=new Promise((U,be)=>{N.onload=()=>{const $e=N.result.split(",")[1];U($e)},N.onerror=()=>be(new Error("Failed to read file"))});N.readAsDataURL(m);const $=await D,C=await c({companyId:n,receiptId:r,imageType:k,imageData:$});if(!C.data.success||!C.data.url)throw new Error(C.data.error||"ä¸å³å¤±æ");return C.data.url},p=[];return R&&p.push(b(R,"id_front").then(m=>{l.idFrontUrl=m})),T&&p.push(b(T,"id_back").then(m=>{l.idBackUrl=m})),P&&p.push(b(P,"bankbook").then(m=>{l.bankbookUrl=m})),await Promise.all(p),l},Se=async()=>{K(!0);try{const r=_();if(!r)throw new Error("Company ID not set");const n=he().currentUser;if(!n)throw new Error("User not authenticated");const l=X(r);let c=t.id,b=t.serialNumber;h||(b=await ye(r),c=E(l).id);const p={...t,serialNumber:b,status:"draft",fieldConfig:j?f:void 0,updatedAt:I()};h||(p.createdBy=n.uid,p.createdAt=I()),await M(E(l,c),Ne(p),{merge:!0});let m={};(R||T||P)&&(A(!0),m=await me(c),A(!1),Object.keys(m).length>0&&await M(E(l,c),{...m,updatedAt:I()},{merge:!0})),v({type:"success",message:"è稿已å²å"}),i("/labor-receipts")}catch(r){console.error("Error saving draft:",r),v({type:"error",message:r.message||"å²å失æ"})}finally{K(!1),A(!1)}},Ae=async()=>{var r;if(!Fe()){v({type:"error",message:"è«å¡«å¯«å¿
å¡«æ¬ä½"});return}Q(!0);try{const a=_();if(!a)throw new Error("Company ID not set");const l=he().currentUser;if(!l)throw new Error("User not authenticated");const c=X(a);let b=t.id,p=t.serialNumber;(!h||!p)&&(p=await ye(a),b=b||E(c).id);const m={...t,serialNumber:p,status:"draft",fieldConfig:j?f:void 0,updatedAt:I()};h||(m.createdBy=l.uid,m.createdAt=I()),await M(E(c,b),Ne(m),{merge:!0});const k=pe(),N=fe(k,"sendLaborReceiptEmail"),$=R||T||P?(async()=>{A(!0);const U=await me(b);A(!1),Object.keys(U).length>0&&await M(E(c,b),{...U,updatedAt:I()},{merge:!0})})():Promise.resolve(),C=N({companyId:a,receiptId:b});await Promise.all([$,C]),Oe("labor_receipt_sent"),v({type:"success",message:"確èªä¿¡å·²ç¼é"}),G(!1),i("/labor-receipts")}catch(a){console.error("Error sending email:",a);const n=a.message||((r=a.details)==null?void 0:r.message)||"";n.includes("INSUFFICIENT_CREDITS")?v({type:"error",message:"黿¸ä¸è¶³ï¼è«å
å²å¼å¾åç¼é"}):n.includes("OPERATION_IN_PROGRESS")?v({type:"error",message:"æä½é²è¡ä¸ï¼è«ç¨å¾å試"}):v({type:"error",message:n||"ç¼é失æ"})}finally{Q(!1),A(!1)}},L=r=>rr(r,{symbol:!1});return B?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"w-8 h-8 border-4 border-[var(--accent)]/30 border-t-[var(--accent)] rounded-full animate-spin"})}):e.jsxs("div",{className:"p-6 max-w-3xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx("button",{onClick:()=>i("/labor-receipts"),className:"p-2 text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-card-alt)] rounded-lg transition-colors",children:e.jsx(tr,{size:20})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-xl font-bold text-[var(--text-primary)]",children:h?"編輯åå ±å®":"建ç«åå ±å®"}),t.serialNumber&&e.jsx("p",{className:"text-xs text-[var(--text-muted)] font-mono",children:t.serialNumber})]}),e.jsx(Ze,{showRefresh:!0})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>o("fillingMode","signer_fill"),className:`p-4 border-2 rounded-xl text-left transition-all ${t.fillingMode==="signer_fill"?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent)]/50 bg-[var(--bg-card)]"}`,children:[e.jsx("div",{className:"font-medium text-[var(--text-primary)] text-sm",children:"æå¾äººèªè¡å¡«å¯«"}),e.jsx("div",{className:"text-xs text-[var(--text-muted)] mt-1",children:"簽署ä
1ººå¡«å¯«åäººè³æ"})]}),e.jsxs("button",{type:"button",onClick:()=>o("fillingMode","company_fill"),className:`p-4 border-2 rounded-xl text-left transition-all ${t.fillingMode==="company_fill"?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent)]/50 bg-[var(--bg-card)]"}`,children:[e.jsx("div",{className:"font-medium text-[var(--text-primary)] text-sm",children:"å
¬å¸é å
填寫"}),e.jsx("div",{className:"text-xs text-[var(--text-muted)] mt-1",children:"簽署人å
é確èªç°½å"})]})]}),e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border)] rounded-xl p-5",children:[e.jsxs("h2",{className:"text-sm font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2 uppercase tracking-wide",children:[e.jsx(sr,{size:16}),"簽署人è³è¨"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-0`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["é»åéµä»¶ ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${s}-0`,type:"email",value:t.signerEmail||"",onChange:r=>o("signerEmail",r.target.value),placeholder:"[email protected]",className:`w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50 ${u.signerEmail?"border-red-500":"border-[var(--border)]"}`}),u.signerEmail&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:u.signerEmail})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-1`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["åç± ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("select",{id:`${s}-1`,value:t.signerNationality||"æ¬åç±(å°ç£)",onChange:r=>o("signerNationality",r.target.value),className:"w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border border-[var(--border)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50",children:gr.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-2`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["æå¾é¡å¥ ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("select",{id:`${s}-2`,value:t.incomeType||"50",onChange:r=>o("incomeType",r.target.value),className:"w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border border-[var(--border)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50",children:[e.jsx("option",{value:"50",children:"50 èªè³ (5%)"}),e.jsx("option",{value:"9A",children:"9A å·è¡æ¥å (10%)"}),e.jsx("option",{value:"9B",children:"9B 稿費 (10%)"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-3`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["äºä»£å¥ä¿ ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("select",{id:`${s}-3`,value:t.hasSecondGenHealthInsurance?"yes":"no",onChange:r=>o("hasSecondGenHealthInsurance",r.target.value==="yes"),className:"w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border border-[var(--border)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50",children:[e.jsx("option",{value:"no",children:"é æ£ç¹³"}),e.jsx("option",{value:"yes",children:"å
æ£ç¹³"})]})]})]}),e.jsxs("div",{className:"bg-blue-500/5 border border-blue-500/15 rounded-lg px-4 py-3.5",children:[e.jsx("p",{className:"text-xs font-semibold text-blue-400 mb-2",children:"115年度ï¼2026ï¼æ£ç¹³è¦å"}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-5 gap-y-1.5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-13 text-[var(--text-muted)] mb-0.5",children:"ä»£æ£æå¾ç¨
"}),e.jsx("p",{className:"text-14 text-[var(--text-primary)]",children:(t.incomeType||"50")==="50"?e.jsxs(e.Fragment,{children:["ç¨
ç 5%ï¼çµ¦ä» ⥠",e.jsx("strong",{children:"$90,501"})," èµ·æ£"]}):e.jsxs(e.Fragment,{children:["ç¨
ç 10%ï¼çµ¦ä» > ",e.jsx("strong",{children:"$20,000"})," èµ·æ£"]})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-13 text-[var(--text-muted)] mb-0.5",children:"äºä»£å¥ä¿è£å
ä¿è²»"}),e.jsx("p",{className:"text-14 text-[var(--text-primary)]",children:(t.incomeType||"50")==="50"?e.jsxs(e.Fragment,{children:["è²»ç 2.11%ï¼çµ¦ä» ⥠",e.jsx("strong",{children:"$29,500"})," èµ·æ£"]}):e.jsxs(e.Fragment,{children:["è²»ç 2.11%ï¼çµ¦ä» ⥠",e.jsx("strong",{children:"$20,000"})," èµ·æ£"]})})]})]})]}),t.fillingMode==="company_fill"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-[var(--border)] pt-4 mt-4",children:[e.jsx("p",{className:"text-xs text-[var(--text-muted)] mb-3",children:"æå¾äººåäººè³æ"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-4`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["å§å ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${s}-4`,type:"text",value:t.signerName||"",onChange:r=>o("signerName",r.target.value),placeholder:"æ¬å",className:`date-input-dark w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50 ${u.signerName?"border-red-500":"border-[var(--border)]"}`}),u.signerName&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:u.signerName})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-0`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["身åèåè ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Xe,{id:`${s}-0`,value:t.signerIdNumber||"",onChange:r=>o("signerIdNumber",r),error:!!u.signerIdNumber,errorMessage:u.signerIdNumber,format:"taiwan"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-1`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["è¯çµ¡é»è©± ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Ve,{id:`${s}-1`,value:t.signerPhone||"",onChange:r=>o("signerPhone",r),placeholder:"è«è¼¸å
¥é»è©±è碼",error:!!u.signerPhone}),u.signerPhone&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:u.signerPhone})]})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-5`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["ç¾å±
å°å ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${s}-5`,type:"text",value:t.signerAddress||"",onChange:r=>o("signerAddress",r.target.value),placeholder:"ç¾å±
å°å",className:"w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border border-[var(--border)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("span",{className:"block text-xs font-medium text-[var(--text-muted)]",children:["æ¶ç±å°å ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.signerRegAddress===t.signerAddress&&!!t.signerAddress,onChange:r=>{r.target.checked&&t.signerAddress&&o("signerRegAddress",t.signerAddress)},className:"w-3.5 h-3.5 rounded border-gray-400"}),e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"åç¾å±
å°å"})]})]}),e.jsx("input",{"aria-label":"æ¶ç±å°å",type:"text",value:t.signerRegAddress||"",onChange:r=>o("signerRegAddress",r.target.value),placeholder:"æ¶ç±å°å",className:"w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border border-[var(--border)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50"})]})]})]})]}),e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border)] rounded-xl p-5",children:[e.jsxs("h2",{className:"text-sm font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2 uppercase tracking-wide",children:[e.jsx(ar,{size:16}),"ååå
§å®¹"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-6`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["ååæè¿° ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("textarea",{id:`${s}-6`,value:t.serviceDescription||"",onChange:r=>o("serviceDescription",r.target.value),placeholder:"è«æè¿°ååå
§å®¹...",rows:2,className:`w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50 resize-none ${u.serviceDescription?"border-red-500":"border-[var(--border)]"}`}),u.serviceDescription&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:u.serviceDescription})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-7`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["æéèµ· ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${s}-7`,type:"date",value:t.servicePeriodStart||"",onChange:r=>o("servicePeriodStart",r.target.value),className:`date-input-dark w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50 ${u.servicePeriodStart?"border-red-500":"border-[var(--border)]"}`})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-8`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["æéè¿ ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${s}-8`,type:"date",value:t.servicePeriodEnd||"",onChange:r=>o("servicePeriodEnd",r.target.value),className:`date-input-dark w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50 ${u.servicePeriodEnd?"border-red-500":"border-[var(--border)]"}`})]})]})]})]}),e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border)] rounded-xl p-5",children:[e.jsxs("h2",{className:"text-sm font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2 uppercase tracking-wide",children:[e.jsx(nr,{size:16}),"éé¡è仿¬¾"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-9`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["仿¬¾éé¡ (æªç¨
) ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-muted)] text-sm",children:"$"}),e.jsx("input",{id:`${s}-9`,type:"number",value:t.paymentAmount||"",onChange:r=>o("paymentAmount",Number(r.target.value)),placeholder:"0",min:"0",className:`w-full pl-7 pr-3 py-2.5 text-sm bg-[var(--bg-page)] border rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50 ${u.paymentAmount?"border-red-500":"border-[var(--border)]"}`})]})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-10`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["仿¬¾æ¥æ ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${s}-10`,type:"date",value:t.paymentDate||"",onChange:r=>o("paymentDate",r.target.value),className:"w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border border-[var(--border)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50"})]})]}),e.jsxs("div",{className:"bg-[var(--bg-page)] rounded-lg p-4 space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"仿¬¾éé¡"}),e.jsxs("span",{className:"text-[var(--text-primary)]",children:["$",L(t.paymentAmount||0)]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-[var(--text-muted)]",children:["ä»£æ£æå¾ç¨
(",W[t.incomeType||"50"]*100,"%)",t.with
1holdingTax===0&&(t.paymentAmount||0)>0&&e.jsx("span",{className:"text-xs ml-1",children:"(æªéèµ·æ£é»)"})]}),e.jsxs("span",{className:"text-red-500",children:["-$",L(t.withholdingTax||0)]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-[var(--text-muted)]",children:["äºä»£å¥ä¿ (2.11%)",t.healthInsurance===0&&(t.paymentAmount||0)>0&&e.jsx("span",{className:"text-xs ml-1",children:"(æªééæª»)"})]}),e.jsxs("span",{className:"text-red-500",children:["-$",L(t.healthInsurance||0)]})]}),e.jsxs("div",{className:"border-t border-[var(--border)] pt-2 flex justify-between items-center",children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:"實é éé¡"}),e.jsxs("span",{className:"text-lg font-bold text-[var(--accent)]",children:["$",L(t.netAmount||0)]})]})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[e.jsxs("span",{id:`${s}-g1`,className:"block text-xs font-medium text-[var(--text-muted)] mb-2",children:["仿¬¾æ¹å¼ ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{role:"group","aria-labelledby":`${s}-g1`,className:"flex gap-4",children:fr.map(r=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"paymentMethod",value:r.value,checked:t.paymentMethod===r.value||!t.paymentMethod&&r.value==="transfer",onChange:a=>o("paymentMethod",a.target.value),className:"w-4 h-4 text-[var(--accent)]"}),e.jsx("span",{className:"text-sm text-[var(--text-primary)]",children:r.label})]},r.value))}),t.paymentMethod==="cash"&&e.jsx("p",{className:"text-xs text-yellow-500 mt-2",children:"ç¾é仿¬¾ä¸é填寫éè¡è³æ"})]})]}),t.fillingMode==="company_fill"&&t.paymentMethod!=="cash"&&e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border)] rounded-xl p-5",children:[e.jsxs("h2",{className:"text-sm font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2 uppercase tracking-wide",children:[e.jsx(ve,{size:16}),"éè¡è³æ ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(We,{bankCode:t.bankCode||"",bankName:t.bankName||"",branchCode:((xe=t.bankBranch)==null?void 0:xe.split(" ")[0])||"",branchName:((ue=t.bankBranch)==null?void 0:ue.split(" ").slice(1).join(" "))||t.bankBranch||"",onBankChange:(r,a)=>{o("bankCode",r),o("bankName",a)},onBranchChange:(r,a)=>{o("bankBranch",r?`${r} ${a}`:a)},showBranch:!0,branchRequired:!j||f.fields.payment.bankBranch!==!1}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-2`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["帳è ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Je,{id:`${s}-2`,value:t.bankAccountNumber||"",onChange:r=>o("bankAccountNumber",r),placeholder:"éè¡å¸³è"})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`${s}-11`,className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:["æ¶å ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${s}-11`,type:"text",value:t.bankAccountName||"",onChange:r=>o("bankAccountName",r.target.value),placeholder:"å¸³æ¶æ¶å",className:"w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border border-[var(--border)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50"})]})]})]})]}),t.fillingMode==="company_fill"&&(!j||f.fields.idPhotos.enabled)&&e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border)] rounded-xl p-5",children:[e.jsxs("h2",{className:"text-sm font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2 uppercase tracking-wide",children:[e.jsx(O,{size:16}),"身åèå½±æ¬ ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:"æ£é¢"}),se||t.idFrontUrl?e.jsx(V,{src:se||t.idFrontUrl||"",alt:"身åèæ£é¢",onRemove:()=>{ee(null),ae(""),o("idFrontUrl","")}}):e.jsx("div",{className:"border-2 border-dashed border-[var(--border)] rounded-lg p-3 text-center hover:border-[var(--accent)] transition-colors",children:e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(O,{size:20,className:"mx-auto text-[var(--text-muted)] mb-1"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"黿ä¸å³"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:r=>{var a;return Y(((a=r.target.files)==null?void 0:a[0])||null,ee,ae,"idFrontUrl")}})]})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs font-medium text-[var(--text-muted)] mb-1.5",children:"åé¢"}),ne||t.idBackUrl?e.jsx(V,{src:ne||t.idBackUrl||"",alt:"身åèåé¢",onRemove:()=>{re(null),le(""),o("idBackUrl","")}}):e.jsx("div",{className:"border-2 border-dashed border-[var(--border)] rounded-lg p-3 text-center hover:border-[var(--accent)] transition-colors",children:e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(O,{size:20,className:"mx-auto text-[var(--text-muted)] mb-1"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"黿ä¸å³"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:r=>{var a;return Y(((a=r.target.files)==null?void 0:a[0])||null,re,le,"idB
1ackUrl")}})]})})]})]})]}),t.fillingMode==="company_fill"&&t.paymentMethod!=="cash"&&(!j||f.fields.bankbook.enabled)&&e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border)] rounded-xl p-5",children:[e.jsxs("h2",{className:"text-sm font-semibold text-[var(--text-primary)] mb-4 flex items-center gap-2 uppercase tracking-wide",children:[e.jsx(ve,{size:16}),"åæºå°é¢ ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-1/2",children:ie||t.bankbookUrl?e.jsx(V,{src:ie||t.bankbookUrl||"",alt:"åæºå°é¢",onRemove:()=>{te(null),oe(""),o("bankbookUrl","")}}):e.jsx("div",{className:"border-2 border-dashed border-[var(--border)] rounded-lg p-4 text-center hover:border-[var(--accent)] transition-colors",children:e.jsxs("label",{className:"cursor-pointer block py-2",children:[e.jsx(O,{size:24,className:"mx-auto text-[var(--text-muted)] mb-2"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"黿ä¸å³åæºå°é¢"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:r=>{var a;return Y(((a=r.target.files)==null?void 0:a[0])||null,te,oe,"bankbookUrl")}})]})})})})]}),e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border)] rounded-xl p-5",children:[e.jsxs("h2",{className:"text-sm font-semibold text-[var(--text-primary)] mb-3 flex items-center gap-2 uppercase tracking-wide",children:[e.jsx(lr,{size:16}),"å註"]}),e.jsx("textarea",{"aria-label":"å
¶ä»éè¦èªªæçäºé
...",value:t.note||"",onChange:r=>o("note",r.target.value),placeholder:"å
¶ä»éè¦èªªæçäºé
...",rows:2,className:"w-full px-3 py-2.5 text-sm bg-[var(--bg-page)] border border-[var(--border)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50 resize-none"})]}),e.jsxs("div",{className:"bg-[var(--bg-card)] border border-[var(--border)] rounded-xl overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>we(!q),className:"w-full px-5 py-3 flex items-center justify-between text-left hover:bg-[var(--bg-card-alt)] transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ir,{size:16,className:"text-[var(--text-muted)]"}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-[var(--text-primary)]",children:"ç°½æ¶æ¬ä½è¨å®"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:j?"èªè¨è¨å®":"å
¬å¸é è¨"})]})]}),q?e.jsx(or,{size:16,className:"text-[var(--text-muted)]"}):e.jsx(cr,{size:16,className:"text-[var(--text-muted)]"})]}),q&&e.jsxs("div",{className:"px-5 pb-5 border-t border-[var(--border)]",children:[e.jsxs("div",{className:"flex items-center justify-between py-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-[var(--text-primary)]",children:"è¦å¯«é è¨è¨å®"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"çºæ¤åå ±å®ä½¿ç¨èªè¨æ¬ä½"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{"aria-label":"è¦å¯«é è¨è¨å®",type:"checkbox",checked:j,onChange:r=>ce(r.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-10 h-5 bg-[var(--border)] peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-[var(--accent)]/50 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[var(--accent)]"})]})]}),j&&e.jsxs("div",{className:"space-y-3 pt-3 border-t border-[var(--border)]",children:[e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t.fillingMode==="company_fill"?"ééçæ¬ä½å°ä¸éè¦å¡«å¯«":"é¸æè¦æ±ç°½ç½²äººå¡«å¯«çæ¬ä½"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:"身åèå½±æ¬"}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{"aria-label":"è¦æ±èº«åèå½±æ¬",type:"checkbox",checked:f.fields.idPhotos.enabled,onChange:r=>de("idPhotos",r.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-8 h-4 bg-[var(--border)] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-[var(--accent)]"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:"åè¡ä»£è"}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{"aria-label":"è¦æ±åè¡ä»£è",type:"checkbox",checked:f.fields.payment.bankBranch!==!1,onChange:r=>Ie("payment","bankBranch",r.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-8 h-4 bg-[var(--border)] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-[var(--accent)]"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:"åæºå°é¢"}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{"aria-label":"è¦æ±åæºå°é¢",type:"checkbox",checked:f.fields.bankbook.enabled,onChange:r=>de("bankbook",r.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-8 h-4 bg-[var(--border)] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-3 after:w-3 after:transition-all peer-checked:bg-[var(--accent)]"})]})]})]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row justify-end gap-2 pt-3",children:[e.jsx("button",{type:"button",onClick:()=>i("/labor-receipts"),className:"px-5 py-2 text-sm font-medium text-[var(--text-secondary)] bg-[var(--bg-card)] border border-[var(--border)] rounded-lg hover:bg-[var(--bg-card-alt)] transition-colors",children:"åæ¶"}),e.jsxs("button",{type:"button",onClick:Se,disabled:S||H,className:"flex items-center justify-center gap-2 px-5 py-2 text-sm font-medium text-[var(--text-primary)] bg-[var(--bg-card)] border border-[var(--border)] rounded-lg hover:bg-[var(--bg-card-alt)] transition-colors disabled:opacity-50",children:[S?e.jsx(je,{size:14,className:"animate-spin"}):e.jsx(dr,{size:14}),"å²åè稿"]}),e.jsxs("button",{type:"button",onClick:()=>G(!0),disabled:S||H,className:"flex items-center justify-center gap-2 px-5 py-2 text-sm font-medium text-[var(--button-text)] bg-[var(--accent)] rounded-lg hover:bg-[var(--accent-hover)] transition-colors disabled:opacity-50",children:[H?e.jsx(je,{size:14,className:"animate-spin"}):e.jsx(mr,{size:14}),"å¯åºç¢ºèªä¿¡"]})]})]}),e.jsx(er,{isOpen:ke,onClose:()=>G(!1),onConfirm:Ae,signerEmail:t.signerEmail||"",serialNumber:t.serialNumber}),z&&e.jsx(Me,{message:z.message,type:z.type,onClose:()=>v(null)})]})};export{$r as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.