PageSourceSearch

https://nekowa.com/assets/RemunerationMaster-DriJz1tb.js

js nekowa.com collected 2026-09-24 14:48:42 UTC 68,447 bytes, 2 lines download raw bytes

1import{j as e,m as we,n as Oe,o as Ht,p as ut,q as Ut,I as tt,s as Pt,v as Wt,w as Yt,T as qt,C as de,x as Vt,y as Gt,z as Kt,c as Qt,A as Xt,B as Zt,S as fe,H as at,E as rt,F as st,G as ge,P as Fe}from"./index-Ci3s9Vyp.js";import{E as Jt}from"./EmptyState-DnRCpYKD.js";import{r as i,R as ea}from"./react-DBTFCQ9V.js";import{v as ta,X as Z,c as Be,p as aa,x as bt,al as ra,V as ht,a as sa,a0 as nt,S as na,am as lt,a2 as ot,an as la,ao as oa,O as ca,q as ct,F as dt,ap as da,R as it,T as ia,aq as xt,ar as xa,j as ma,as as ua,o as ba,C as ha,aa as ie,ab as pa,at as fa}from"./utils-DRBGurlB.js";import{p as ga,F as va,D as ja,P as Na,S as ya,V as g,T as x,I as Le,a as wa}from"./FileSaver.min-4ypyifxH.js";import{q as pt,o as ft,h as ye,u as gt,r as Ca,E as Sa,B as ka,l as Ta,n as Aa}from"./firebase-DUmv6NEE.js";import{C as ve}from"./CountUp-lmPQUSKx.js";import{T as Da}from"./TableSkeleton-Dv2e2avs.js";wa.register({family:"NotoSansTC",src:"/fonts/NotoSansTC-Regular.ttf"});const l=ya.create({page:{padding:20,paddingBottom:35,fontFamily:"NotoSansTC",fontSize:10,backgroundColor:"#ffffff"},header:{marginBottom:10,borderBottom:"2 solid #1e3a5f",paddingBottom:8},headerRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",position:"relative"},companyName:{fontSize:16,fontWeight:"bold",color:"#1e3a5f",flex:1},title:{fontSize:22,fontWeight:"bold",color:"#1e3a5f",letterSpacing:6,position:"absolute",left:0,right:0,textAlign:"center"},dateText:{fontSize:9,color:"#666666",flex:1,textAlign:"right"},sectionRow:{flexDirection:"row",marginBottom:8,gap:8},section:{flex:1,border:"1 solid #d0d0d0",borderRadius:3,padding:10,paddingTop:8,backgroundColor:"#fafafa"},sectionTitle:{fontSize:11,fontWeight:"bold",color:"#1e3a5f",marginBottom:10,paddingBottom:5,borderBottom:"1 solid #e0e0e0"},row:{marginBottom:6},rowInline:{flexDirection:"row",marginBottom:6,alignItems:"flex-start"},label:{fontSize:9,color:"#555555",marginBottom:2},labelInline:{width:60,fontSize:9,color:"#555555",flexShrink:0},value:{flex:1,fontSize:10,color:"#222222",lineHeight:1.4},valueAddress:{fontSize:9,color:"#222222",lineHeight:1.4},amountSection:{border:"2 solid #1e3a5f",borderRadius:4,padding:12,marginBottom:8,backgroundColor:"#f0f5fa"},amountRow:{flexDirection:"row",justifyContent:"space-around",alignItems:"center"},amountBox:{alignItems:"center",flex:1},amountLabel:{fontSize:8,color:"#555555",marginBottom:3,textAlign:"center"},amountValue:{fontSize:14,fontWeight:"bold",color:"#1e3a5f"},amountDeduct:{fontSize:14,fontWeight:"bold",color:"#dc2626"},amountNet:{fontSize:16,fontWeight:"bold",color:"#16a34a"},operator:{fontSize:14,color:"#666666",marginHorizontal:2},imageRow:{flexDirection:"row",marginBottom:8,gap:8},imageSection:{flex:1,border:"1 solid #d0d0d0",borderRadius:3,padding:8,backgroundColor:"#fafafa",alignItems:"center"},imageTitle:{fontSize:10,fontWeight:"bold",color:"#1e3a5f",marginBottom:6},idImage:{width:240,height:150,objectFit:"contain",borderRadius:2},signatureSection:{border:"1 solid #d0d0d0",borderRadius:3,padding:10,marginBottom:8,backgroundColor:"#fafafa",alignItems:"center",minHeight:80},signatureImage:{width:200,height:70,objectFit:"contain"},noteSection:{border:"1 solid #d0d0d0",borderRadius:3,padding:10,backgroundColor:"#fffbeb",marginBottom:8},noteText:{fontSize:10,color:"#92400e",lineHeight:1.4},footer:{position:"absolute",bottom:12,left:20,right:20,textAlign:"center",fontSize:8,color:"#888888",borderTop:"1 solid #e0e0e0",paddingTop:6},noImage:{width:240,height:150,backgroundColor:"#eeeeee",borderRadius:2,justifyContent:"center",alignItems:"center"},noImageSmall:{width:200,height:70,backgroundColor:"#eeeeee",borderRadius:2,justifyContent:"center",alignItems:"center"},noImageText:{fontSize:9,color:"#999999"},addressSection:{border:"1 solid #d0d0d0",borderRadius:3,padding:10,marginBottom:8,backgroundColor:"#fafafa"},addressRow:{flexDirection:"row",gap:20},addressCol:{flex:1}}),Ia=o=>o?o.replace(/-/g,"/"):"-",je=o=>o==null||o===""?"NT$0":`NT$${(typeof o=="string"?parseFloat(o):o).toLocaleString()}`,$a=o=>{switch(o){case"50":return"50 (薪資所得)";case"9A":return"9A (執行業務)";case"9B":return"9B (稿費)";default:return o||"50"}},Ra=(o,s=18)=>{let d="",c=0;for(const p of o){const N=/[\u4e00-\u9fa5\u3000-\u303f\uff00-\uff60]/.test(p)?1.4:1;c+N>s*1.4&&(d+=`
2`,c=0),d+=p,c+=N}return d},za=({record:o,employee:s})=>e.jsx(ja,{children:e.jsxs(Na,{size:"A4",style:l.page,children:[e.jsx(g,{style:l.header,children:e.jsxs(g,{style:l.headerRow,children:[e.jsx(x,{style:l.companyName,children:o.companyName||""}),e.jsx(x,{style:l.title,children:"勞務報酬單"}),e.jsx(g,{style:{flex:1}})]})}),e.jsxs(g,{style:l.sectionRow,children:[e.jsxs(g,{style:l.section,children:[e.jsx(x,{style:l.sectionTitle,children:"人員資訊"}),e.jsxs(g,{style:l.rowInline,children:[e.jsx(x,{style:l.labelInline,children:"姓名"}),e.jsx(x,{style:l.value,children:o.name||"-"})]}),e.jsxs(g,{style:l.rowInline,children:[e.jsx(x,{style:l.labelInline,children:"身分證字號"}),e.jsx(x,{style:l.value,children:o.idNumber||"-"})]}),e.jsxs(g,{style:l.rowInline,children:[e.jsx(x,{style:l.labelInline,children:"聯絡電話"}),e.jsx(x,{style:l.value,children:(s==null?void 0:s.phone)||"-"})]})]}),e.jsxs(g,{style:l.section,children:[e.jsx(x,{style:l.sectionTitle,children:"勞務資訊"}),e.jsxs(g,{style:l.rowInline,children:[e.jsx(x,{style:l.labelInline,children:"勞務內容"}),e.jsx(x,{style:l.value,children:Ra(o.note||"勞務報酬")})]}),e.jsxs(g,{style:l.rowInline,children:[e.jsx(x,{style:l.labelInline,children:"勞務日期"}),e.jsx(x,{style:l.value,children:Ia(o.date)})]}),e.jsxs(g,{style:l.rowInline,children:[e.jsx(x,{style:l.labelInline,children:"所得類別"}),e.jsx(x,{style:l.value,children:$a(o.itemCode)})]})]})]}),e.jsxs(g,{style:l.addressSection,children:[e.jsx(x,{style:l.sectionTitle,children:"地址資訊"}),e.jsxs(g,{style:l.addressRow,children:[e.jsxs(g,{style:l.addressCol,children:[e.jsx(x,{style:l.label,children:"戶籍地址"}),e.jsx(x,{style:l.valueAddress,children:o.regAddress||"-"})]}),e.jsxs(g,{style:l.addressCol,children:[e.jsx(x,{style:l.label,children:"現居地址"}),e.jsx(x,{style:l.valueAddress,children:o.address||"-"})]})]})]}),e.jsxs(g,{style:l.amountSection,children:[e.jsx(x,{style:l.sectionTitle,children:"金額明細"}),e.jsxs(g,{style:l.amountRow,children:[e.jsxs(g,{style:l.amountBox,children:[e.jsx(x,{style:l.amountLabel,children:"付款金額"}),e.jsx(x,{style:l.amountValue,children:je(o.totalAmount)})]}),e.jsx(x,{style:l.operator,children:"−"}),e.jsxs(g,{style:l.amountBox,children:[e.jsx(x,{style:l.amountLabel,children:"二代健保(2.11%)"}),e.jsx(x,{style:l.amountDeduct,children:je(o.healthTax)})]}),e.jsx(x,{style:l.operator,children:"−"}),e.jsxs(g,{style:l.amountBox,children:[e.jsx(x,{style:l.amountLabel,children:o.itemCode==="9A"?"執行業務稅(10%)":"兼職人員稅(5%)"}),e.jsx(x,{style:l.amountDeduct,children:je(o.itemCode==="9A"?o.professionalTax:o.partTimeTax)})]}),e.jsx(x,{style:l.operator,children:"="}),e.jsxs(g,{style:l.amountBox,children:[e.jsx(x,{style:l.amountLabel,children:"實領金額"}),e.jsx(x,{style:l.amountNet,children:je(o.netAmount)})]})]})]}),e.jsxs(g,{style:l.imageRow,children:[e.jsxs(g,{style:l.imageSection,children:[e.jsx(x,{style:l.imageTitle,children:"身分證正面"}),s!=null&&s.idFrontUrl?e.jsx(Le,{src:s.idFrontUrl,style:l.idImage}):e.jsx(g,{style:l.noImage,children:e.jsx(x,{style:l.noImageText,children:"尚未上傳"})})]}),e.jsxs(g,{style:l.imageSection,children:[e.jsx(x,{style:l.imageTitle,children:"身分證反面"}),s!=null&&s.idBackUrl?e.jsx(Le,{src:s.idBackUrl,style:l.idImage}):e.jsx(g,{style:l.noImage,children:e.jsx(x,{style:l.noImageText,children:"尚未上傳"})})]})]}),e.jsxs(g,{style:l.signatureSection,children:[e.jsx(x,{style:l.imageTitle,children:"簽名"}),s!=null&&s.signatureUrl?e.jsx(Le,{src:s.signatureUrl,style:l.signatureImage}):e.jsx(g,{style:l.noImageSmall,children:e.jsx(x,{style:l.noImageText,children:"尚未上傳簽名"})})]}),(o.note||o.collabNote)&&e.jsxs(g,{style:l.noteSection,children:[e.jsx(x,{style:l.sectionTitle,children:"備註"}),e.jsx(x,{style:l.noteText,children:[o.note,o.collabNote].filter(
2Boolean).join(" | ")})]}),e.jsx(x,{style:l.footer,children:"Nekowa"})]})}),Ea=async(o,s)=>{const d=`${o.name||"未命名"}_勞務報酬單_${o.date||"unknown"}.pdf`,c=await ga(e.jsx(za,{record:o,employee:s})).toBlob();va.saveAs(c,d)},J="invoice_headers";let P=null;const Fa=async()=>P||(P=(async()=>{try{const o=pt(we(J),ft("createdAt","asc"));let d=(await ye(o)).docs.map(c=>({id:c.id,...c.data()}));if(d.length===0){let c;if(Oe().type==="personal")c="Nekowa";else{const u=await Ht();c=(u==null?void 0:u.name)||(u==null?void 0:u.displayTitle)||"預設公司"}await vt(c,!0,!0),d=(await ye(o)).docs.map(u=>({id:u.id,...u.data()}))}else if(!d.some(c=>c.isLocked)){const c=d[0];await gt(ut(J,c.id),{isLocked:!0}),c.isLocked=!0}return d}catch(o){return console.error("Error getting companies:",o),[]}finally{setTimeout(()=>{P=null},500)}})(),P),vt=async(o,s=!1,d=!1)=>{try{const c=await Ca(we(J),{name:o,isDefault:s,isLocked:d,createdAt:Sa()});return P=null,c.id}catch(c){throw console.error("Error adding company:",c),c}},La=async o=>{try{const s=we(J),d=await ye(s),c=ka(s.firestore);d.docs.forEach(p=>{const u=p.id===o;p.data().isDefault===!0!==u&&c.update(p.ref,{isDefault:u})}),await c.commit(),P=null}catch(s){throw console.error("Error setting default company:",s),s}},Ba=async o=>{try{const s=ut(J,o),c=(await Ta(s)).data();if(c!=null&&c.isLocked)throw new Error("LOCKED");const p=(c==null?void 0:c.isDefault)===!0;if(await Aa(s),p){const u=we(J),N=await ye(pt(u,ft("createdAt","asc"))),k=N.docs.find(O=>O.data().isLocked)||N.docs[0];k&&await gt(k.ref,{isDefault:!0})}P=null}catch(s){throw console.error("Error deleting company:",s),s}},Oa=({isOpen:o,onClose:s,companies:d,onRefresh:c,showToast:p})=>{const u=i.useId(),N=Ut(o),[k,O]=i.useState(""),[_,F]=i.useState(!1),T=Oe().type==="personal",y={title:T?"標頭設置":"公司設定",subtitle:T?"自訂勞報單抬頭(預設 Nekowa)":"管理勞報單抬頭",addLabel:T?"新增自訂抬頭":"新增客戶公司",placeholder:T?"輸入抬頭名稱...":"輸入新公司名稱...",deleteConfirm:T?"確定要刪除此抬頭嗎?":"確定要刪除此公司名稱嗎?",deleteLocked:"原始抬頭無法刪除",addSuccess:T?"抬頭新增成功":"公司新增成功",setDefaultSuccess:"已更新預設抬頭",empty:T?"尚未設定任何抬頭":"尚未設定任何公司"},ee=async()=>{if(k.trim())try{F(!0),await vt(k.trim()),O(""),c(),p(y.addSuccess,"success")}catch{p("新增失敗","error")}finally{F(!1)}},te=async j=>{try{F(!0),await La(j),c(),p(y.setDefaultSuccess,"success")}catch{p("設定失敗","error")}finally{F(!1)}},xe=async(j,q)=>{if(q){p(y.deleteLocked,"error");return}if(window.confirm(y.deleteConfirm))try{F(!0),await Ba(j),c(),p("刪除成功","success")}catch(V){p(V instanceof Error&&V.message==="LOCKED"?y.deleteLocked:"刪除失敗","error")}finally{F(!1)}};return o?e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-50 flex items-center justify-center p-4 nk-in",children:e.jsxs("div",{ref:N,className:"nk-in-origin bg-[var(--bg-card)] rounded-2xl shadow-2xl w-full max-w-md overflow-hidden border border-[var(--border)] flex flex-col max-h-[85vh]",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-[var(--border)] flex items-center justify-between bg-[var(--bg-card)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2.5 bg-[var(--accent)]/10 text-[var(--accent)] rounded-xl border border-[var(--accent)]/20 shadow-lg shadow-blue-500/5",children:e.jsx(ta,{size:20})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-[var(--text-primary)]",children:y.title}),e.jsx("p",{className:"text-xs text-[var(--text-secondary)] font-medium",children:y.subtitle})]})]}),e.jsx("button",{onClick:s,className:"p-2 hover:bg-[var(--bg-card-alt)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] rounded-xl transition-all",children:e.jsx(Z,{size:20})})]}),e.jsxs("div",{className:"p-6 overflow-y-auto custom-scrollbar",children:[e.jsxs("div",{className:"flex flex-col gap-2 mb-6",children:[e.jsx("label",{htmlFor:u,className:"text-xs font-bold text-[var(--text-muted)] uppercase tracking-wider ml-1",children:y.addLabel}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{id:u,type:"text",onCh
2ange:j=>O(j.target.value),placeholder:y.placeholder,className:"flex-1 px-4 py-2.5 bg-[var(--bg-card-alt)] border border-[var(--border)] rounded-xl text-[var(--text-primary)] placeholder-[var(--text-muted)] focus:outline-none focus:ring-2 focus:ring-[var(--accent)]/50 focus:border-[var(--accent)] transition-all font-medium",onKeyPress:j=>j.key==="Enter"&&ee()}),e.jsxs("button",{onClick:ee,disabled:_||!k.trim(),className:"px-4 py-2 bg-[var(--accent)] hover:bg-[var(--accent-hover)] text-[var(--button-text)] rounded-xl shadow-lg shadow-blue-500/20 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 transition-all active:scale-95 font-bold",children:[e.jsx(Be,{size:18}),e.jsx("span",{children:"新增"})]})]})]}),e.jsx("div",{className:"space-y-2",children:d.length===0?e.jsx("div",{className:"text-center py-6 text-[var(--text-muted)] bg-[var(--bg-card-alt)] rounded-xl border border-dashed border-[var(--border)] text-sm",children:y.empty}):d.map(j=>e.jsxs("div",{className:`flex items-center justify-between p-3.5 rounded-xl border transition-all group ${j.isDefault?"bg-[var(--accent)]/5 border-[var(--accent)]/20":"bg-[var(--bg-card-alt)] border-[var(--border)] hover:border-[var(--border-hover)]"}`,children:[e.jsxs("span",{className:`font-bold flex items-center gap-1.5 ${j.isDefault?"text-[var(--accent)]":"text-[var(--text-primary)]"}`,children:[j.name,j.isLocked&&e.jsx(aa,{size:12,className:"text-[var(--text-muted)]"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[j.isDefault?e.jsxs("span",{className:"text-12 font-bold bg-[var(--accent)]/10 text-[var(--accent)] px-2 py-1 rounded-lg border border-[var(--accent)]/20 flex items-center gap-1",children:[e.jsx(bt,{size:11})," 預設"]}):e.jsxs("button",{onClick:()=>te(j.id),disabled:_,className:"text-12 font-bold text-[var(--text-secondary)] hover:text-[var(--accent)] hover:bg-[var(--accent)]/10 px-2 py-1 rounded-lg border border-[var(--border)] hover:border-[var(--accent)]/30 transition-all flex items-center gap-1 disabled:opacity-50",title:"設為預設",children:[e.jsx(ra,{size:11})," 設為預設"]}),j.isLocked?e.jsx("span",{className:"text-12 font-bold bg-[var(--bg-card-alt)] text-[var(--text-secondary)] px-2 py-1 rounded-lg border border-[var(--border)]",children:"原始"}):e.jsx("button",{onClick:()=>xe(j.id,!!j.isLocked),disabled:_,className:"p-2 text-[var(--text-muted)] hover:text-[var(--error)] hover:bg-[var(--error)]/10 rounded-lg opacity-0 group-hover:opacity-100 transition-all disabled:opacity-50",title:"刪除",children:e.jsx(ht,{size:16})})]})]},j.id))})]})]})}):null},Ne=o=>{const s=o.totalAmount===""?0:Number(o.totalAmount);let{itemCode:d,healthTax:c,partTimeTax:p,professionalTax:u}=o;o.isAutoCalc?(d=s>=fe?"9A":"50",c=null,p=null,u=null,o.hasHealthRecord&&(d==="50"&&s>=at||d==="9A"&&s>=rt)&&(c=Math.round(s*st)),d==="50"&&s>=fe&&(p=Math.round(s*ge[50])),d==="9A"&&s>=Fe&&(u=Math.round(s*ge["9A"]))):(o.hasHealthRecord&&(d==="50"&&s>=at||d==="9A"&&s>=rt)?c=Math.round(s*st):c=null,d==="50"?(s>=fe&&p==null&&(p=Math.round(s*ge[50])),s<fe&&(p=null)):p=null,d==="9A"?(s>=Fe&&u==null&&(u=Math.round(s*ge["9A"])),s<Fe&&(u=null)):u=null);const N=Number(c)||0,k=Number(p)||0,O=Number(u)||0,_=s-N-k-O;return{...o,itemCode:d,healthTax:c,partTimeTax:p,professionalTax:u,netAmount:_}},mt=o=>o?o.length>8?o.substring(0,8)+"***":o:"",X=async o=>{if(!o)return"";try{const s=new AbortController,d=setTimeout(()=>s.abort(),15e3),c=await fetch(o,{signal:s.signal,mode:"cors"});if(clearTimeout(d),!c.ok)throw new Error(`HTTP error! status: ${c.status}`);const p=await c.blob();return new Promise(u=>{const N=new FileReader;N.onloadend=()=>{const k=N.result;k&&k.startsWith("data:")?u(k):u("")},N.onerror=()=>{u("")},N.readAsDataURL(p)})}catch{return""}},Ka=({permission:o})=>{const s=i.useId(),[d,c]=i.useState([]),[p,u]=i.useState([]),[N,k]=i.useState([]),[O,_]=i.useState(!0),[F,T]=i.useState(!1),[y,ee]=i.useState(null),[te,xe]=i.useState(null),[j,q]=i.useState(!1),V=i.useRef(null),[jt,ae]=i.useState(!1),Ce=i.useRef(null),[W,Nt]=i.useState({key:"date",direction:"desc"}),[_e,me]=i.useState({isOpen:!1,recordId:null}),[yt,Me]=i.useState(!1),[I,wt]=i.useState([]),[_a,He]=i.useState(!1),[Ct,ue]=i.useState(!1),Se=i.useRef(null),[St,G]=i.useState(!1),[ke,Ue]=i.useState("xlsx"),[re,be]=i.useState({isOpen:!1,record:null,employee:void 0,missingItems:[]}),[Te,se]=i.useState(null),[B,Pe]=i.useState(""),[Ae,We]=i.useState(null),[b,K]=i.useState({...tt,serialNumber:0}
2),[kt,De]=i.useState(!1),Ye=new Date(new Date().toLocaleString("en-US",{timeZone:"Asia/Taipei"})),qe=Ye.getFullYear(),[A,Ve]=i.useState(qe),[M,Ie]=i.useState([Ye.getMonth()+1]),C=(t,a="success")=>{xe({id:Date.now(),message:t,type:a})};i.useEffect(()=>{$e(),Tt(),Re(),Ge();const t=a=>{V.current&&!V.current.contains(a.target)&&q(!1),Ce.current&&!Ce.current.contains(a.target)&&ae(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]);const $e=async()=>{_(!0);try{const a=(await Pt()).map(r=>({...r,id:r.id}));c(a)}catch(t){console.error("Error fetching data:",t),C("載入資料失敗","error")}finally{_(!1)}},Tt=async()=>{try{const t=await Wt();u(t)}catch(t){console.error("Error fetching health records:",t)}},Re=async()=>{try{const t=await Yt();return k(t),t}catch(t){return console.error("Error fetching employees:",t),[]}},Ge=async()=>{He(!0);try{const t=await Fa();wt(t)}catch(t){console.error("Error fetching companies:",t)}finally{He(!1)}};i.useEffect(()=>{if(F&&!y&&!b.companyName&&I.length>0){const t=I.find(a=>a.isDefault)||I[0];t&&K(a=>({...a,companyName:t.name}))}},[I,F,y,b.companyName]);const ne=i.useMemo(()=>{const t=new Set;return t.add(qe),d.forEach(a=>{const n=new Date(a.date).getFullYear();isNaN(n)||t.add(n)}),Array.from(t).sort((a,r)=>r-a)},[d]);i.useEffect(()=>{ne.length>0&&!ne.includes(A)&&Ve(ne[0])},[ne,A]);const At=i.useMemo(()=>{const t=new Array(13).fill(0);d.forEach(r=>{const n=new Date(r.date);if(n.getFullYear()===A){const h=n.getMonth()+1,m=typeof r.totalAmount=="number"?r.totalAmount:0;t[h]+=m}});const a=Math.max(...t);return{stats:t,max:a===0?1:a}},[d,A]),Ke=()=>{const t=new Date,a=t.getTimezoneOffset();return new Date(t.getTime()-a*60*1e3).toISOString().split("T")[0]},Qe=t=>{if(t)ee(t.id||null),K(t),ze(t.idNumber,t.date,!1);else{const a=d.length>0?Math.max(...d.map(n=>n.serialNumber)):0;ee(null),De(!1);const r=Ke();K({...tt,serialNumber:a+1,date:r,hasHealthRecord:!1,companyName:""})}ae(!1),T(!0)},ze=(t,a,r)=>{if(!t){De(!1);return}const n=t.trim().toUpperCase(),h=p.some(m=>!((m.idNumber||"").trim().toUpperCase()!==n||a<m.effectiveDate||m.expiryDate&&a>m.expiryDate));De(h),r&&h&&K(m=>Ne({...m,hasHealthRecord:!0}))},S=(t,a)=>{K(r=>{let n={...r,[t]:a};return t==="idNumber"&&(n.idNumber=a.toUpperCase()),t==="totalAmount"&&(n.totalAmount=a===""||a==="0"?"":Number(a)),(t==="idNumber"||t==="date")&&ze(n.idNumber,n.date,!0),["totalAmount","isAutoCalc","hasHealthRecord","itemCode","healthTax","partTimeTax","professionalTax"].includes(t)?Ne(n):n})},Dt=t=>{K(a=>{const r={...a,name:t.name,idNumber:t.idNumber.toUpperCase(),address:t.address||"",regAddress:t.regAddress||""};return ze(r.idNumber,r.date,!0),Ne(r)}),ae(!1)},Xe=i.useMemo(()=>{if(!b.name||b.name.trim().length===0)return[];const t=b.name.toLowerCase().trim();return N.filter(a=>a.name.toLowerCase().includes(t)||a.idNumber.toLowerCase().includes(t)).slice(0,5)},[b.name,N]),It=async t=>{t.preventDefault();try{const a={...Ne(b),totalAmount:b.totalAmount===""?0:b.totalAmount};y?await Xt(y,a):await Zt(a),T(!1),$e(),C(y?"更新成功":"新增成功")}catch(a){console.error("Error saving:",a),C("儲存失敗,請檢查網路連線","error")}},$t=t=>{t&&me({isOpen:!0,recordId:t})},Rt=async()=>{const t=_e.recordId;if(t)try{await Gt(t),c(a=>a.filter(r=>r.id!==t)),me({isOpen:!1,recordId:null}),C("刪除成功")}catch(a){console.error("Deletion failed:",a),C("刪除失敗,請檢查網路連線","error")}},zt=t=>{var n;const a=(n=t.target.files)==null?void 0:n[0];if(!a)return;const r=new FileReader;r.onload=async h=>{var m;try{const v=(m=h.target)==null?void 0:m.result,D=fa(v,{type:"binary"}),w=D.SheetNames[0],L=D.Sheets[w],z=ie.sheet_to_json(L),$=[];let oe=d.length>0?Math.max(...d.map(f=>f.serialNumber)):0;const Q=f=>{if(!f)return 0;const R=String(f).replace(/NT\$/g,"").replace(/,/g,"").trim();return R?Number(R):0},ce=f=>{if(!f)return null;const R=Q(f);return R===0?null:R};z.forEach(f=>{if(f.本名&&f.總額){let R=Ke();const H=f.日期;if(typeof H=="number")R=new Date((H-25569)*86400*1e3).toISOString().split("T")[0];else if(typeof H=="string"&&H.includes("/")){const E=H.split("/");if(E.length===2){const U=E[0].padStart(2,"0"),Ee=E[1].padStart(2,"0");R=`${A}-${U}-${Ee}`}else if(E.length===3){let U=E[0];const Ee=E[1].padStart(2,"0"),Mt=E[2].padStart(2,"0");U.length===2&&(U="20"+U),R=`${U}-${Ee}-${Mt}`}}oe++;const Y={serialNumber:f.勞報編號?Number(f.勞報編號):oe,name:f.本名,i
2dNumber:f.身份證字號?String(f.身份證字號).trim().toUpperCase():"",date:R,totalAmount:Q(f.總額),healthTax:ce(f["2.11% 二代健保稅金"]),partTimeTax:ce(f["5% 兼職人員扣稅"]),professionalTax:ce(f["10% 執行業務扣稅"]),netAmount:Q(f.實領金額),address:f.現居地址||"",regAddress:f.戶籍地址||"",itemCode:f.項目?String(f.項目).trim():"50",note:f.工作內容||"",collabNote:f.合作備註||"",hasHealthRecord:!1,isAutoCalc:!1};$.push(Y)}}),$.length>0?(await Kt($),$e(),ue(!1),C(`成功匯入 ${$.length} 筆資料`,"success")):C("找不到有效資料,請檢查 Excel 標題是否正確","error")}catch(v){console.error("Import Error",v),C("匯入失敗,請檢查檔案格式","error")}finally{Se.current&&(Se.current.value="")}},r.readAsBinaryString(a)},Et=async(t,a)=>{if(t.preventDefault(),t.stopPropagation(),!a||!a.id){C("錯誤:無效的資料紀錄","error");return}se(a.id||null);try{let r=N;(!r||r.length===0)&&(r=await Re());const n=D=>(D||"").trim().toUpperCase(),h=n(a.idNumber),m=r.find(D=>n(D.idNumber)===h),v=[];if(m?(m.signatureUrl||v.push("簽名檔 (未上傳)"),m.idFrontUrl||v.push("身分證正面 (未上傳)"),m.idBackUrl||v.push("身分證反面 (未上傳)")):v.push("人員資料不存在 (請至資料設定新增)"),v.length>0){se(null),be({isOpen:!0,record:a,employee:m,missingItems:v});return}await Ze(a,m)}catch(r){console.error("[PDF] 檢查過程錯誤:",r),se(null),C("檢查過程發生錯誤","error")}},Ze=async(t,a)=>{var r;se(t.id||null);try{const n=(a==null?void 0:a.signatureUrl)||"",h=(a==null?void 0:a.idFrontUrl)||"",m=(a==null?void 0:a.idBackUrl)||"",v=(a==null?void 0:a.phone)||"",[D,w,L]=await Promise.all([X(n),X(h),X(m)]),z=await((r=Qt.currentUser)==null?void 0:r.getIdToken(!0));let $=t.companyName;if(!$&&I.length>0){const E=I.find(U=>U.isDefault)||I[0];E&&($=E.name)}const oe={template_name:"勞務報酬單.pdf",output_filename:`${t.name||"未命名"}_勞務報酬單_${t.itemCode||"50"}_${t.date}.pdf`,signature:D,id_card_front:w,id_card_back:L,fields:{title:$?`[${$}] 勞務報酬單`:"勞務報酬單",name:t.name||"",id_number:t.idNumber||"",amount:`NT$${t.totalAmount||0}`,nhifee:`NT$${t.healthTax||0}`,tax_5:`NT$${t.partTimeTax||0}`,tax_10:`NT$${t.professionalTax||0}`,net:`NT$${t.netAmount}`,content:t.note||"勞務報酬",residential_address:t.regAddress||t.address||"",mailing_address:t.address||"",household_address:t.regAddress||t.address||"",phone:v,...t.itemCode==="50"?{date:(t.date||"").replace(/-/g,"/"),50:"Value_gehs"}:{},...t.itemCode==="9A"?{report_date:(t.date||"").replace(/-/g,"/"),"9A":"Value_blej"}:{},...t.itemCode==="9B"?{report_date:(t.date||"").replace(/-/g,"/"),"9B":"Value_iqaz"}:{}}},Q=new AbortController,ce=setTimeout(()=>Q.abort(),6e4),f=await fetch("https://api.pin.alincy.com/api/pdf/fill",{method:"POST",headers:{"Content-Type":"application/json",Authorization:z?`Bearer ${z}`:""},body:JSON.stringify(oe),signal:Q.signal});if(clearTimeout(ce),!f.ok)throw new Error(`API 錯誤 ${f.status}`);const R=await f.blob(),H=window.URL.createObjectURL(R),Y=document.createElement("a");Y.href=H,Y.download=oe.output_filename,document.body.appendChild(Y),Y.click(),document.body.removeChild(Y),window.URL.revokeObjectURL(H)}catch(n){console.error("[PDF] 下載失敗:",n),C("PDF 生成失敗: "+(n instanceof Error?n.message:String(n)),"error")}finally{se(null)}},Ft=async(t,a)=>{if(t.preventDefault(),t.stopPropagation(),!(!a||!a.id)){We(a.id);try{let r=N;(!r||r.length===0)&&(r=await Re());const n=w=>(w||"").trim().toUpperCase(),h=n(a.idNumber),m=r.find(w=>n(w.idNumber)===h);let v=a;if(!a.companyName&&I.length>0){const w=I.find(L=>L.isDefault)||I[0];w&&(v={...a,companyName:w.name})}let D=m;if(m){const[w,L,z]=await Promise.all([X(m.idFrontUrl||""),X(m.idBackUrl||""),X(m.signatureUrl||"")]);D={...m,idFrontUrl:w,idBackUrl:L,signatureUrl:z}}await Ea(v,D),C("PDF 生成成功","success")}catch(r){console.error("[NewPDF] 下載失敗:",r),C("PDF 生成失敗: "+(r instanceof Error?r.message:String(r)),"error")}finally{We(null)}}},he=i.useMemo(()=>{if(B.trim()){const t=B.trim().toLowerCase();return d.filter(a=>{var r;return(r=a.name)==null?void 0:r.toLowerCase().includes(t)})}return d.filter(t=>{const a=new Date(t.date),r=a.getFullYear(),n=a.getMonth()+1;return r===A&&(M.length===0||M.includes(n))})},[d,A,M,B]),Je=i.useMemo(()=>{const t=new Map,a={};return d.forEach(r=>{const n=r.createdAt;let h;n!=null&&n.toDate?h=n.toDate().getFullYear():n?h=new Date(n).getFullYear():h=new Date(r.date).getFullYear(),a[h]||(a[h]=[]),a[h].push(r)}
2),Object.keys(a).forEach(r=>{const n=a[parseInt(r)];n.sort((h,m)=>{var w,L,z,$;const v=((L=(w=h.createdAt)==null?void 0:w.toMillis)==null?void 0:L.call(w))||(h.createdAt?new Date(h.createdAt).getTime():0),D=(($=(z=m.createdAt)==null?void 0:z.toMillis)==null?void 0:$.call(z))||(m.createdAt?new Date(m.createdAt).getTime():0);return v-D}),n.forEach((h,m)=>{h.id&&t.set(h.id,m+1)})}),t},[d]),Lt=t=>{Nt(a=>({key:t,direction:a.key===t&&a.direction==="desc"?"asc":"desc"}))},le=i.useMemo(()=>{let t=[...he];return t.sort((a,r)=>{if(W.key==="date"){const n=new Date(a.date).getTime(),h=new Date(r.date).getTime();return n!==h?W.direction==="asc"?n-h:h-n:r.serialNumber-a.serialNumber}return 0}),t},[he,W]),Bt=()=>{if(le.length===0){C("沒有資料可以匯出","info"),G(!1);return}const t=le.map(n=>({序列號:Je.get(n.id||"")||n.serialNumber,本名:n.name,身分證字號:n.idNumber,日期:n.date,總額:n.totalAmount,"二代健保(2.11%)":n.healthTax||0,"兼職扣稅(5%)":n.partTimeTax||0,"執業扣稅(10%)":n.professionalTax||0,實領金額:n.netAmount,現居地址:n.address,戶籍地址:n.regAddress,項目:n.itemCode,工作內容:n.note,合作備註:n.collabNote})),a=ie.json_to_sheet(t),r=`勞報單總表_${A}_${new Date().toISOString().split("T")[0]}`;if(ke==="xlsx"){const n=ie.book_new();ie.book_append_sheet(n,a,"勞報單"),pa(n,`${r}.xlsx`)}else{const n=ie.sheet_to_csv(a),h=new Blob(["\uFEFF"+n],{type:"text/csv;charset=utf-8;"}),m=URL.createObjectURL(h),v=document.createElement("a");v.href=m,v.download=`${r}.csv`,document.body.appendChild(v),v.click(),document.body.removeChild(v)}G(!1),C("匯出成功","success")},et=i.useMemo(()=>{const t={};return le.forEach(a=>{const r=B.trim()?a.date.substring(0,4):a.date.substring(0,7);t[r]||(t[r]={records:[],totalAmount:0,totalHealthTax:0,totalIncomeTax:0}),t[r].records.push(a);const n=typeof a.totalAmount=="number"?a.totalAmount:0;t[r].totalAmount+=n,t[r].totalHealthTax+=Number(a.healthTax)||0,t[r].totalIncomeTax+=(Number(a.partTimeTax)||0)+(Number(a.professionalTax)||0)}),t},[le,B]),pe=i.useMemo(()=>he.reduce((t,a)=>{const r=typeof a.totalAmount=="number"?a.totalAmount:0;return{totalExpenditure:t.totalExpenditure+r,totalHealthTax:t.totalHealthTax+(Number(a.healthTax)||0),totalIncomeTax:t.totalIncomeTax+(Number(a.partTimeTax)||0)+(Number(a.professionalTax)||0),count:t.count+1}},{totalExpenditure:0,totalHealthTax:0,totalIncomeTax:0,count:0}),[he]),Ot=t=>{Ie(a=>a.includes(t)?a.filter(r=>r!==t):[...a,t])},_t=()=>q(!j);return e.jsxs("div",{className:"p-4 md:p-6 lg:p-8 h-full flex flex-col relative font-sans",children:[te&&e.jsx(qt,{message:te.message,type:te.type,onClose:()=>xe(null)}),e.jsxs("div",{className:"flex flex-col gap-6 mb-4 flex-shrink-0",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2",children:[e.jsxs("h2",{className:"text-xl md:text-3xl font-bold text-[var(--text-primary)] tracking-tight flex items-center gap-2 md:gap-3",children:["勞報單總表",e.jsx("span",{className:"text-12 md:text-xs font-medium bg-[var(--bg-card-alt)] text-[var(--text-secondary)] px-2 py-1 rounded-full border border-[var(--border)]",children:"v1.3"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)] text-xs md:text-sm",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-[var(--success)] shadow-lg shadow-green-500/50"}),"系統連線正常"]})]}),e.jsxs("div",{className:"flex flex-col md:flex-row md:items-end gap-4 md:gap-8 border-b border-[var(--border)] pb-4 md:pb-6",children:[e.jsxs("div",{className:"relative z-40",ref:V,children:[e.jsx("span",{className:"text-xs text-[var(--text-muted)] font-bold uppercase tracking-wider mb-2 block",children:"選擇年份"}),e.jsxs("button",{onClick:_t,className:"flex items-center gap-2 text-3xl md:text-5xl font-bold text-[var(--text-primary)] hover:text-[var(--accent)] transition-colors group outline-none",children:[e.jsx("span",{className:"font-mono",children:A}),e.jsx("div",{className:`transition-transform duration-300 ${j?"rotate-180":""}`,children:e.jsx(sa,{className:"text-[var(--text-muted)] group-hover:text-[var(--accent)]",size:24})})]}),j&&e.jsx("div",{className:"absolute top-full left-0 mt-2 w-48 bg-[var(--bg-card)]/95 backdrop-blur-xl border border-[var(--border)] rounded-2xl shadow-2xl overflow-hidden py-2 nk-in-down",children:ne.map(t=>e.jsx("button",{onClick:()=>{Ve(t),q(!1)},className:`w-full text-left px-6 py-3 font-mono text-xl font-bold transition-colors ${t===A?"text-[var(--accent)] bg-[var(--accent)]/10":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-card-alt)]"}`,children:t},t))})]}),e.jsx("div",{className:"h-16 w-px bg-[var(--border)] hidden md:block"}),e.jsxs("div",{className:"flex-1 max-w-xs",children:[e.jsx("label",{htmlFor:`${s}-0`,className:"text-xs text-[var(--text-muted)] font-bold uppercase tracking-wider mb-2 block",children:"搜尋人名"}),e.jsxs("div",{className:"relative",children:[e.jsx(nt,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-muted)]",size:16}),e.jsx("input",{id:`${s}-0`,type:"text",value:B,onChange:t=>Pe(t.target.value),placeholder:"輸入人名搜尋全部資料...",className:"w-full bg-[var(--bg-card-alt)] border border-[var(--border)] text-[var(--text-primary)] rounded-xl py-2.5 pl-10 pr-10 text-sm outline-none focus:border-[var(--accent)] placeholder:text-[var(--text-muted)]"}),B&&e.jsx("button",{onClick:()=>Pe(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:e.jsx(Z,{size:14})})]}),B.trim()&&e.jsx("p",{className:"text-12 text-[var(--accent)] mt-1",children:"🔍 搜尋模式:顯示所有年份的資料"})]}),e.jsx("div",{className:"h-16 w-px bg-[var(--border)] hidden md:block"}),e.jsxs("div",{className:"grid grid-cols-2 md:flex md:flex-wrap md:items-center gap-4 md:gap-10",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-12 md:text-xs text-[var(--text-muted)] font-bold uppercase tracking-wider mb-1",children:"年度總支出"}),e.jsx("div",{className:"text-lg md:text-3xl font-bold text-[var(--accent)] font-mono tracking-tight",children:e.jsx(ve,{value:pe.totalExpenditure,prefix:"NT$"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-12 md:text-xs text-[var(--text-muted)] font-bold uppercase tracking-wider mb-1",children:"年度二代健保"}),e.jsx("div",{className:"text-lg md:text-3xl font-bold text-[var(--error)] font-mono tracking-tight",children:e.jsx(ve,{value:pe.totalHealthTax,prefix:"NT$"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-12 md:text-xs text-[var(--text-muted)] font-bold uppercase tracking-wider mb-1",children:"年度所得稅"}),e.jsx("div",{className:"text-lg md:text-3xl font-bold text-[var(--warning)] font-mono tracking-tight",children:e.jsx(ve,{value:pe.totalIncomeTax,prefix:"NT$"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-12 md:text-xs text-[var(--text-muted)] font-bold uppercase tracking-wider mb-1",children:"總筆數"}),e.jsxs("div",{className:"text-lg md:text-3xl font-bold text-[var(--accent)] font-mono tracking-tight",children:[e.jsx(ve,{value:pe.count})," ",e.jsx("span",{className:"text-sm md:text-base text-[var(--text-muted)] font-medium",children:"筆"})]})]})]})]}),e.jsxs("div",{className:"flex flex-col md:flex-row items-end justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-2 w-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between pr-4",children:[e.jsx("span",{className:"text-xs font-bold text-[var(--text-muted)] uppercase tracking-wider",children:"月份篩選"}),M.length>0&&e.jsx("button",{onClick:()=>Ie([]),className:"text-xs text-[var(--accent)] hover:text-[var(--accent-hover)] transition-colors",children:"清除篩選"})]}),e.jsxs("div",{className:"flex gap-2 overflow-x-auto pb-2 scrollbar-hide w-full",children:[e.jsx("button",{onClick:()=>Ie([]),className:`nk-press flex-shrink-0 w-10 h-10 rounded-lg border transition-all flex flex-col items-center justify-center relative ${M.length===0?"bg-[var(--accent)] border-[var(--accent)] text-[var(--button-text)] shadow-lg shadow-blue-900/40":"bg-[var(--bg-card)] border-[var(--border)] text-[var(--text-muted)] hover:bg-[var(--bg-card-alt)]"}`,children:e.jsx("span",{className:"text-xs font-bold",children:"全部"})}),Array.from({length:12},(t,a)=>a+1).map(t=>{const a=At.stats[t],r=M.includes(t),n=a>0;return e.jsxs("button",{onClick:()=>Ot(t),className:`nk-press flex-shrink-0 w-10 h-10 rounded-lg border transition-all flex flex-col items-center justify-center relative group ${r?"bg-[var(--accent)] border-[var(--accent)] text-[var(--button-text)] shadow-lg shadow-blue-500/20":n?"bg-[var(--bg-card-alt)] border-[var(--border)] text-[var(--text-primary)] hover:bg-[var(--bg-card-alt)] hover:border-[var(--border-hover)]":"bg-transparent border-[var(--border)] text-[var(--text-muted)] hover:border-[var(--border-hover)]"}`,children:[n&&!r&&e.jsx("div",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-[var(--success)] shadow shadow-green-900/50"}),r&&e.jsx("div",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-[var(--button-text)] shadow-sm"}),e.jsx("span",{className:"text-sm font-bold leading-none font-mono",children:t})]},t)})]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0 pb-2",children:[o.create&&e.jsxs("button",{onClick:()=>Me(!0),className:"flex items-center gap-2 px-4 py-2 bg-[var(--bg-card-alt)] hover:bg-[var(--bg-card-alt)] text-[var(--text-secondary)] rounded-xl transition-all border border-[var(--border)] hover:border-[var(--border-hover)] font-medium active:scale-95 text-sm h-10",children:[e.jsx(na,{size:16}),e.jsx("span",{className:"hidden md:inline",children:Oe().type==="personal"?"標頭設置":"公司設定"})]}),o.create&&e.jsxs("button",{onClick:()=>ue(!0),className:"flex items-center gap-2 px-4 py-2 bg-[var(--bg-card-alt)] hover:bg-[var(--bg-card-alt)] text-[var(--text-secondary)] rounded-xl transition-all border border-[var(--border)] hover:border-[var(--border-hover)] font-medium active:scale-95 text-sm h-10",children:[e.jsx(lt,{size:16}),e.jsx("span",{children:"匯入"})]}),e.jsxs("button",{onClick:()=>G(!0),className:"flex items-center gap-2 px-4 py-2 bg-[var(--bg-card-alt)] hover:bg-[var(--bg-card-alt)] text-[var(--text-secondary)] rounded-xl transition-all border border-[var(--border)] hover:border-[var(--border-hover)] font-medium active:scale-95 text-sm h-10",children:[e.jsx(ot,{size:16}),e.jsx("span",{children:"匯出"})]}),o.create&&e.jsxs("button",{onClick:()=>Qe(),className:"flex items-center gap-2 px-5 py-2 bg-[var(--accent)] hover:bg-[var(--accent-hover)] text-[var(--button-text)] rounded-xl transition-all shadow-lg shadow-blue-500/25 font-bold active:scale-95 text-sm h-10",children:[e.jsx(Be,{size:16}),e.jsx("span",{children:"新增"})]})]})]})]}),e.jsx("div",{className:"flex-1 overflow-auto bg-[var(--bg-card)] rounded-3xl border border-[var(--border)] shadow-2xl relative",children:O?e.jsx(Da,{rows:
27,cols:7}):Object.keys(et).length===0?e.jsx(Jt,{icon:nt,title:e.jsxs(e.Fragment,{children:["沒有 ",A,"年的符合資料"]}),className:"h-64"}):e.jsxs("table",{className:"w-full text-left border-collapse",children:[e.jsx("thead",{className:"sticky top-0 z-30 bg-[var(--bg-card-alt)] shadow-md",children:e.jsxs("tr",{children:[e.jsx("th",{className:"py-3 px-2 w-14 text-center text-sm font-bold text-[var(--text-primary)] border-b border-[var(--border)] whitespace-nowrap",children:"序列號"}),e.jsx("th",{className:"py-3 px-2 text-center text-sm font-bold text-[var(--text-primary)] border-b border-[var(--border)] whitespace-nowrap",children:"本名"}),e.jsx("th",{className:"py-3 px-2 text-center text-sm font-bold text-[var(--text-primary)] border-b border-[var(--border)] whitespace-nowrap",children:"身分證字號"}),e.jsx("th",{className:"py-3 px-2 w-24 text-center border-b border-[var(--border)] whitespace-nowrap cursor-pointer hover:bg-[var(--bg-card-alt)] transition-colors group select-none",onClick:()=>Lt("date"),children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx("span",{className:"text-sm font-bold text-[var(--text-primary)] group-hover:text-[var(--accent)]",children:"日期"}),e.jsx("div",{className:"text-[var(--text-muted)] group-hover:text-[var(--accent)]",children:W.key==="date"&&W.direction==="asc"?e.jsx(la,{size:14}):W.key==="date"&&W.direction==="desc"?e.jsx(oa,{size:14}):e.jsx(ca,{size:14})})]})}),e.jsx("th",{className:"py-3 px-2 text-center text-sm font-bold text-[var(--accent)] border-b border-[var(--border)] whitespace-nowrap",children:"總額"}),e.jsx("th",{className:"py-3 px-2 text-center border-b border-[var(--border)]",children:e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-sm font-bold text-[var(--error)] whitespace-nowrap",children:"二代健保"}),e.jsx("span",{className:"text-12 text-[var(--error)]/70 font-mono mt-0.5 whitespace-nowrap",children:"(2.11%)"})]})}),e.jsx("th",{className:"py-3 px-2 text-center border-b border-[var(--border)]",children:e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-sm font-bold text-[var(--error)] whitespace-nowrap",children:"兼職人員"}),e.jsx("span",{className:"text-12 text-[var(--error)]/70 font-mono mt-0.5 whitespace-nowrap",children:"(5%)"})]})}),e.jsx("th",{className:"py-3 px-2 text-center border-b border-[var(--border)]",children:e.jsxs("div",{className:"flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-sm font-bold text-[var(--error)] whitespace-nowrap",children:"執行業務"}),e.jsx("span",{className:"text-12 text-[var(--error)]/70 font-mono mt-0.5 whitespace-nowrap",children:"(10%)"})]})}),e.jsx("th",{className:"py-3 px-2 text-center text-sm font-bold text-[var(--success)] border-b border-[var(--border)] whitespace-nowrap",children:"實領金額"}),e.jsx("th",{className:"py-3 px-2 text-center text-sm font-bold text-[var(--text-primary)] border-b border-[var(--border)] whitespace-nowrap truncate max-w-[120px]",children:"現居地址"}),e.jsx("th",{className:"py-3 px-2 text-center text-sm font-bold text-[var(--text-primary)] border-b border-[var(--border)] whitespace-nowrap truncate max-w-[120px]",children:"戶籍地址"}),e.jsx("th",{className:"py-3 px-2 w-16 text-center text-sm font-bold text-[var(--text-primary)] border-b border-[var(--border)] whitespace-nowrap",children:"項目"}),e.jsx("th",{className:"py-3 px-2 text-center text-sm font-bold text-[var(--text-primary)] border-b border-[var(--border)] whitespace-nowrap truncate max-w-[140px]",children:"工作內容 / 合作"}),e.jsx("th",{className:"py-3 px-2 w-32 text-center text-sm font-bold text-[var(--text-primary)] border-b border-[var(--border)] sticky right-0 z-30 bg-[var(--bg-card-alt)] whitespace-nowrap",children:"操作"})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border)] nk-list nk-zebra",children:Object.entries(et).sort((t,a)=>a[0].localeCompare(t[0])).map(([t,a])=>e.jsxs(ea.Fragment,{children:[e.jsx("tr",{className:"bg-transparent",children:e.jsx("td",{colSpan:14,className:"p-0 border-none",children:e.jsx("div",{className:"sticky left-0 right-0 mx-2 mt-6 mb-2 bg-[var(--bg-card)]/95 backdrop-blur-sm rounded-xl border border-[var(--border)] p-1.5 flex items-center shadow-xl z-20",children:e.jsxs("div",{className:"flex items-center gap-4 px-2 w-full",children:[e.jsx("div",{className:"w-1 h-6 bg-[var(--accent)] rounded-full"}),B.trim()?e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{className:"text-xl font-bold text-[var(--text-primary)] tracking-tight",children:t}),e.jsx("span",{className:"text-xs font-bold text-[var(--text-muted)]",children:"年"})]}):e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{className:"text-xl font-bold text-[var(--text-primary)] tracking-tight",children:t.split("-")[1]}),e.jsx("span",{className:"text-xs font-bold text-[var(--text-muted)]",children:"月"})]}),e.jsx("div",{className:"w-px h-6 bg-[var(--border)] mx-2"}),e.jsxs("div",{className:"px-2 py-0.5 rounded-full bg-[var(--bg-card-alt)] border border-[var(--border)] flex items-center gap-2",children:[e.jsx("span",{className:"text-12 text-[var(--text-secondary)] font-medium",children:"資料"}),e.jsx("span",{className:"text-xs font-bold text-[var(--text-primary)]",children:a.records.length})]}),e.jsxs("div",{className:"flex items-center gap-4 lg:gap-6 ml-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 pl-3 border-l border-[var(--border)]",children:[e.jsx("span",{className:"text-12 text-[var(--text-muted)] font-bold uppercase tracking-wider",children:"健保"}),e.jsxs("span",{className:"text-base font-bold text-[var(--error)] font-mono tracking-tight",children:["NT$",a.totalHealthTax.toLocaleStr
2ing()]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 pl-3 border-l border-[var(--border)]",children:[e.jsx("span",{className:"text-12 text-[var(--text-muted)] font-bold uppercase tracking-wider",children:"稅金"}),e.jsxs("span",{className:"text-base font-bold text-[var(--warning)] font-mono tracking-tight",children:["NT$",a.totalIncomeTax.toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 pl-3 border-l border-[var(--border)]",children:[e.jsx("span",{className:"text-12 text-[var(--text-muted)] font-bold uppercase tracking-wider",children:"總支出"}),e.jsxs("span",{className:"text-base font-bold text-[var(--accent)] font-mono tracking-tight",children:["NT$",a.totalAmount.toLocaleString()]})]})]})]})})})}),a.records.map(r=>e.jsxs("tr",{className:"hover:bg-[var(--bg-card-alt)] transition-colors group nk-lift",children:[e.jsx("td",{className:"p-2 text-center text-[var(--text-muted)] font-mono text-sm",children:Je.get(r.id||"")||r.serialNumber}),e.jsx("td",{className:"p-2 text-center font-bold text-[var(--text-primary)] text-sm",children:r.name}),e.jsx("td",{className:"p-2 text-center text-[var(--text-primary)] font-mono text-sm font-medium tracking-wide",children:r.idNumber}),e.jsx("td",{className:"p-2 text-center text-[var(--text-secondary)] font-medium text-sm",children:new Date(r.date).toLocaleDateString("zh-TW",{month:"numeric",day:"numeric"})}),e.jsx("td",{className:"p-2 text-center font-mono text-base text-[var(--accent)] font-bold",children:typeof r.totalAmount=="number"?r.totalAmount.toLocaleString():r.totalAmount}),e.jsx("td",{className:"p-2 text-center font-mono text-[var(--error)]/80 text-sm",children:r.healthTax?`-${r.healthTax}`:"-"}),e.jsx("td",{className:"p-2 text-center font-mono text-[var(--error)]/80 text-sm",children:r.partTimeTax?`-${r.partTimeTax}`:"-"}),e.jsx("td",{className:"p-2 text-center font-mono text-[var(--error)]/80 text-sm",children:r.professionalTax?`-${r.professionalTax}`:"-"}),e.jsx("td",{className:"p-2 text-center font-mono font-bold text-base text-[var(--success)]",children:r.netAmount.toLocaleString()}),e.jsx("td",{className:"p-2 text-center text-[var(--text-secondary)] text-xs truncate max-w-[120px]",title:r.address,children:mt(r.address)}),e.jsx("td",{className:"p-2 text-center text-[var(--text-secondary)] text-xs truncate max-w-[120px]",title:r.regAddress,children:mt(r.regAddress)}),e.jsx("td",{className:"p-2 text-center",children:e.jsx("span",{className:`px-2 py-0.5 rounded text-12 font-bold ${r.itemCode==="9A"?"bg-[var(--id-purple)]/20 text-[var(--id-purple)] border border-[var(--id-purple)]/30":"bg-[var(--bg-card-alt)] text-[var(--text-secondary)] border border-[var(--border)]"}`,children:r.itemCode})}),e.jsx("td",{className:"p-2 text-left text-xs max-w-[140px]",children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[r.note&&e.jsxs("div",{className:"truncate text-[var(--text-secondary)] flex items-center",title:`註: ${r.note}`,children:[e.jsx("span",{className:"text-[var(--text-muted)] font-bold mr-1 text-12",children:"註:"}),r.note]}),r.collabNote&&e.jsxs("div",{className:"truncate text-[var(--accent)] flex items-center",title:`合: ${r.collabNote}`,children:[e.jsx("span",{className:"text-[var(--accent)] font-bold mr-1 text-12",children:"合:"}),r.collabNote]})]})}),e.jsx("td",{className:"p-2 sticky right-0 bg-[var(--bg-card)] group-hover:bg-[var(--bg-card-alt)] transition-colors border-l border-[var(--border)] text-center z-10",children:e.jsxs("div",{className:"flex justify-center gap-1.5 relative z-50",children:[e.jsx("button",{type:"button",onClick:n=>Et(n,r),disabled:Te===r.id,className:`p-1.5 rounded-lg transition-colors cursor-pointer ${Te===r.id?"bg-[var(--id-purple)]/20 text-[var(--id-purple)] cursor-not-allowed":"text-[var(--id-purple)] hover:bg-[var(--id-purple)]/10 hover:text-[var(--id-purple)]"}`,title:"下載勞報單PDF (舊版)",children:Te===r.id?e.jsx(ct,{size:16,className:"animate-spin"}):e.jsx(dt,{size:16})}),e.jsx("button",{type:"button",onClick:n=>Ft(n,r),disabled:Ae===r.id,className:`p-1.5 rounded-lg transition-colors cursor-pointer ${Ae===r.id?"bg-emerald-500/20 text-emerald-300 cursor-not-allowed":"text-emerald-400 hover:bg-emerald-500/10 hover:text-emerald-300"}`,title:"下載勞報單PDF (新版)",children:Ae===r.id?e.jsx(ct,{size:16,className:"animate-spin"}):e.jsx(da,{size:16})}),o.edit&&e.jsx("button",{onClick:()=>Qe(r),className:"p-1.5 text-[var(--accent)] hover:bg-[var(--accent)]/10 hover:text-[var(--accent-hover)] rounded-lg transition-colors",title:"編輯",children:e.jsx(it,{size:16})}),o.delete&&e.jsx("button",{onClick:()=>$t(r.id),className:"p-1.5 text-[var(--error)] hover:bg-[var(--error)]/10 hover:text-[var(--error)] rounded-lg transition-colors",title:"刪除",children:e.jsx(ht,{size:16})})]})})]},r.id))]},t))})]})}),e.jsx(de,{isOpen:_e.isOpen,onClose:()=>me({isOpen:!1,recordId:null}),zIndex:60,maxWidth:"max-w-sm",contentClassName:"bg-[var(--bg-card)] rounded-2xl border border-[var(--error)]/50 w-full shadow-2xl p-6",children:e.jsxs("div",{className:"flex flex-col items-center text-center gap-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-[var(--error)]/10 flex items-center justify-center mb-2",children:e.jsx(ia,{size:32,className:"text-[var(--error)]"})}),e.jsx("h3",{className:"text-xl font-bold text-[var(--text-primary)]",children:"確認刪除"}),e.jsxs("p",{className:"text-[var(--text-secondary)] text-sm leading-relaxed",children:["您確定要永久刪除這筆資料嗎?",e.jsx("br",{}),"此動作執行後將",e.jsx("span",{className:"text-[var(--error)] font-bold",children:"無法復原"}),"。"]}),e.jsxs("div",{className:"flex gap-3 w-full mt-4",children:[e.jsx("button",{onClick:()=>me({isOpen:!1,recordId:null}),className:"flex-1 py-2.5 rounded-xl bg-[var(--bg-card-alt)] text-[var(--text-secondary)] hover:bg-[var(--bg-card-alt)] transition-colors font-medium",children:"取消"}),e.jsx("button",{onClick:Rt,className:"flex-1 py-2.5 rounded-xl bg-[var(--error)] text-[var(--button-text)] hover:bg-[var(--error)] transition-colors font-medium shadow-lg shadow-red-900/20",children:"確認刪除"})]})]})}),e.jsxs(de,{isOpen:St,onClose:()=>G(!1),maxWidth:"max-w-md",contentClassName:"bg-[var(--bg-card)] rounded-2xl border border-[var(--border)] w-full shadow-2xl p-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsxs("h3",{className:"text-xl font-bold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(ot,{size:20,className:"text-[var(--accent)]"}),"匯出資料設定"]}),e.jsx("button",{onClick:()=>G(!1),className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:e.jsx(Z,{size:24})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("span",{className:"text-xs font-bold text-[var(--text-secondary)] uppercase",children:"選擇檔案格式"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("button",{onClick:()=>Ue("xlsx"),className:`flex-1 flex flex-col items-center justify-center gap-2 p-3 rounded-xl border transition-all ${ke==="xlsx"?"bg-[var(--success)]/10 border-[var(--success)] text-[var(--success)]":"bg-[var(--bg-card-alt)] border-[var(--border)] text-[var(--text-secondary)] hover:bg-[var(--bg-card-alt)]"}`,children:[e.jsx(xt,{size:24}),e.jsx("span",{className:"text-sm font-bold",children:"Excel (.xlsx)"})]}),e.jsxs("button",{onClick:()=>Ue("csv"),className:`flex-1 flex flex-col items-center justify-center gap-2 p-3 rounded-xl border transition-all ${ke==="csv"?"bg-[var(--warning)]/10 border-[var(--warning)] text-[var(--warning)]":"bg-[var(--bg-card-alt)] border-[var(--border)] text-[var(--text-secondary)] hover:bg-[var(--bg-card-alt)]"}`,children:[e.jsx(dt,{size:24}),e.jsx("span",{className:"text-sm font-bold",children:"CSV (.csv)"})]})]})]}),e.jsxs("div",{className:"bg-[var(--accent)]/10 p-4 rounded-xl border border-[var(--accent)]/20 flex items-start gap-3",children:[e.jsx(bt,{className:"text-[var(--accent)] shrink-0 mt-0.5",size:16}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-[var(--accent)]",children:"將匯出目前篩選結果"}),e.jsxs("p",{className:"text-xs text-[var(--accent)]/70 mt-1",children:["年份: ",e.jsx("span",{className:"font-mono font-bold text-[var(--text-primary)]",children:A}),e.jsx("span",{className:"mx-2",children:"•"}),"月份: ",e.jsx("span",{className:"font-mono font-bold text-[var(--text-primary)]",children:M.length===0?"全部":M.join(", ")}),e.jsx("span",{className:"mx-2",children:"•"}),"筆數: ",e.jsx("span",{className:"font-mono font-bold text-[var(--text-primary)]",children:le.length})]})]})]})]}),e.jsxs("div",{className:"flex gap-3 mt-8",children:[e.jsx("button",{onClick:()=>G(!1),className:"flex-1 py-3 rounded-xl bg-[var(--bg-card-alt)] text-[var(--text-secondary)] hover:bg-[var(--bg-card-alt)] font-bold",children:"取消"}),e.jsx("button",{onClick:Bt,className:"flex-1 py-3 rounded-xl bg-[var(--accent)] text-[var(--button-text)] hover:bg-[var(--accent-hover)] font-bold shadow-lg shadow-blue-500/20",children:"確認匯出"})]})]}),e.jsxs(de,{isOpen:Ct,onClose:()=>ue(!1),maxWidth:"max-w-md",contentClassName:"bg-[var(--bg-card)] rounded-2xl border border-[var(--border)] w-full shadow-2xl p-6",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsxs("h3",{className:"text-xl font-bold text-[var(--text-primary)] flex items-center gap-2",children:[e.jsx(xt,{className:"text-[var(--success)]"}),"匯入舊版勞報資料"]}),e.jsx("button",{onClick:()=>ue(!1),className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)] z-20 relative",children:e.jsx(Z,{size:24})})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"relative p-4 bg-[var(--bg-card-alt)] rounded-xl border border-[var(--border)] border-dashed flex flex-col items-center justify-center text-center gap-2 min-h-[150px]",children:[e.jsx(lt,{size:32,className:"text-[var(--text-muted)] mb-2"}),e.jsx("p",{className:"text-sm text-[var(--text-secondary)] font-medium",children:"點擊或拖曳檔案至此"}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"支援 .xlsx, .csv 格式"}),e.jsx("input",{"aria-label":"選擇要匯入的勞報單檔案",ref:Se,type:"file",accept:".xlsx, .xls, .csv",onChange:zt,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"})]}),e.jsx("div",{className:"bg-[var(--warning)]/10 p-3 rounded-lg border border-[var(--warning)]/20",children:e.jsxs("p",{className:"text-xs text-[var(--warning)] leading-relaxed",children:[e.jsx("span",{className:"font-bold block mb-1",children:"⚠️ 匯入注意事項:"}),"1. 系統將根據標題自動對應欄位 (如:本名, 總額, 實領金額等)。",e.jsx("br",{}),"2. 日期若為「2/3」格式,將自動補上目前選擇年份 (",A,")。",e.jsx("br",{}),"3. 匯入的資料將",e.jsx("b",{children:"停用自動計算"}),",以保留原始 Excel 的金額。"]})})]})]}),e.jsx(de,{isOpen:re.isOpen,onClose:()=>be(t=>({...t,isOpen:!1})),zIndex:70,maxWidth:"max-w-md",contentClassName:"bg-[var(--bg-card)] rounded-2xl border border-[var(--warning)]/50 w-full shadow-2xl p-6 transform transition-all",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-[var(--warning)]/10 flex items-center justify-center mb-1",children:e.jsx(xa,{size:32,className:"text-[var(--warning)]"})}),e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-xl font-bold text-[var(--text-primary)] mb-2",children:"資料缺失警告"}),e.jsxs("p",{className:"text-[var(--text-secondary)] text-sm mb-4",children:["檢測到以下必要資料未設定,生成的 PDF 將",e.jsx("span",{className:"text-[var(--warning)] font-bold",children:"不包含"}),"這些項目:"]}),e.jsx("div",{className:"bg-[var(--bg-card-alt)] rounded-xl p-4 border border-[var(--border)] text-left mb-4",children:e.jsx("ul",{className:"space-y-2",children:re.missingItems.map((t,a)=>e.jsxs("li",{className:"flex items-center gap-2 text-sm text-[var(--error)]",children:[e.jsx(Z,{size:14,className:"flex-shrink-0"}),e.jsx("span",{children:t})]},a))})}),e.jsx("p",{className:"text-[var(--text-muted)] text-xs",children:"是否仍要強制下載?"})]}),e.jsxs("div",{className:"flex gap-3 w-full mt-2",children:[e.jsx("button",{onClick:()=>be(t=>({...t,isOpen:!1})),className:"flex-1 py-2.5 rounded-xl bg-[var(--bg-card-alt)] text-[var(--text-secondary)] hover:bg-[var(--bg-card-alt)] transition-colors font-medium",children:"取消"}),e.jsx("button",{onClick:()=>{re.record&&Ze(re.record,re.employee),be(t=>({...t,isOpen:!1}))},className:"flex-1 py-2.5 rounded-xl bg-gradient-to-r from-orange-600 to-red-600 hover:from-orange-500 hover:to-red-500 text-white shadow-lg shadow-orange-900/20 transition-all font-bold",children:"仍要下載"})]})]})}),e.jsxs(de,{isOpen:F,onClose:()=>T(!1),maxWidth:"max-w-4xl",contentClassName:"bg-[var(--bg-card)] rounded-3xl border border-[var(--border)] w-full shadow-2xl flex flex-col max-h-[90vh]",children:[e.jsxs("div",{className:"p-6 border-b border-[var(--border)] flex justify-between items-center bg-[var(--bg-card-alt)] rounded-t-3xl",children:[e.jsxs("h3",{className:"text-xl font-bold text-[var(--text-primary)] flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-xl ${y?"bg-[var(--accent)]/20 text-[var(--accent)]":"bg-[var(--success)]/20 text-[var(--success)]"}`,children:y?e.jsx(it,{size:20}):e.jsx(Be,{size:20})}),y?"編輯勞報單":"新增勞報單"]}),e.jsx("button",{onClick:()=>T(!1),className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-card-alt)] p-2 rounded-xl transition-all",children:e.jsx(Z,{size:24})})]}),e.jsxs("form",{onSubmit:It,className:"overflow-y-auto p-8 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 custom-scrollbar",children:[e.jsxs("div",{className:"lg:col-span-4 flex items-center gap-4 bg-[var(--bg-card-alt)] p-4 rounded-2xl border border-[var(--border)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("label",{htmlFor:`${s}-1`,className:"text-sm font-medium text-[var(--text-secondary)]",children:"序列號"}),e.jsx("input",{id:`${s}-1`,type:"number",value:b.serialNumber,disabled:!0,className:"bg-[var(--bg-card-alt)] text-[var(--text-secondary)] rounded-lg px-3 py-1.5 w-20 border border-[var(--border)] text-center font-mono font-bold"})]}),e.jsx("div",{className:"h-8 w-px bg-[var(--border)] mx-2"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer select-none hover:text-[var(--text-primary)] transition-colors",children:[e.jsx("input",{type:"checkbox",checked:b.isAutoCalc,onChange:t=>S("isAutoCalc",t.target.checked),className:"w-5 h-5 rounded border-[var(--border)] bg-[var(--bg-card-alt)] text-[var(--accent)] focu
2s:ring-offset-gray-900"}),e.jsxs("div",{className:"flex items-center gap-1.5 bg-[var(--accent)]/10 px-2 py-1 rounded text-[var(--accent)]",children:[e.jsx(ma,{size:14}),e.jsx("span",{children:"啟用自動計算"})]})]})}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer select-none hover:text-[var(--text-primary)] transition-colors",children:[e.jsx("input",{type:"checkbox",checked:b.hasHealthRecord,onChange:t=>S("hasHealthRecord",t.target.checked),className:"w-5 h-5 rounded border-[var(--border)] bg-[var(--bg-card-alt)] text-[var(--accent)] focus:ring-offset-gray-900"}),"符合健保扣稅資格"]}),kt&&e.jsxs("div",{className:"flex items-center gap-1 text-12 bg-[var(--success)]/10 text-[var(--success)] px-2 py-0.5 rounded-full border border-[var(--success)]/20 font-bold animate-pulse",children:[e.jsx(ua,{size:12}),e.jsx("span",{children:"已於健保紀錄中"})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 relative",ref:Ce,children:[e.jsxs("label",{htmlFor:`${s}-2`,className:"text-sm font-medium text-[var(--text-secondary)]",children:["本名 ",e.jsx("span",{className:"text-[var(--error)]",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:`${s}-2`,required:!0,type:"text",value:b.name,onFocus:()=>ae(!0),onChange:t=>{S("name",t.target.value),ae(!0)},className:"w-full bg-[var(--bg-card-alt)] border border-[var(--border)] text-[var(--text-primary)] rounded-xl p-3 focus:border-[var(--accent)] focus:ring-1 focus:ring-[var(--accent)]/50 outline-none transition-all",placeholder:"輸入姓名進行搜尋",autoComplete:"off"}),e.jsx(ba,{size:18,className:"absolute right-3 top-1/2 -translate-y-1/2 text-[var(--text-muted)] pointer-events-none"})]}),jt&&Xe.length>0&&e.jsxs("div",{className:"absolute top-full left-0 right-0 mt-2 bg-[var(--bg-card-alt)] border border-[var(--border)] rounded-xl shadow-2xl z-[100] overflow-hidden nk-in-down",children:[e.jsx("div",{className:"p-2 text-12 font-bold text-[var(--text-muted)] uppercase tracking-widest bg-[var(--bg-card)]/50 border-b border-[var(--border)]",children:"選擇現有人員"}),Xe.map(t=>e.jsxs("div",{...Vt(()=>Dt(t)),className:"p-3 hover:bg-[var(--accent)]/10 cursor-pointer border-b border-[var(--border)] last:border-0 transition-colors group",children:[e.jsx("div",{className:"text-sm font-bold text-[var(--text-primary)] group-hover:text-[var(--accent)] transition-colors",children:t.name}),e.jsx("div",{className:"text-xs text-[var(--text-muted)] font-mono mt-0.5",children:t.idNumber})]},t.id))]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{htmlFor:`${s}-3`,className:"text-sm font-medium text-[var(--text-secondary)]",children:["身分證字號 ",e.jsx("span",{className:"text-[var(--error)]",children:"*"})]}),e.jsx("input",{id:`${s}-3`,required:!0,type:"text",value:b.idNumber,onChange:t=>S("idNumber",t.target.value),className:"bg-[var(--bg-card-alt)] border border-[var(--border)] text-[var(--text-primary)] rounded-xl p-3 focus:border-[var(--accent)] outline-none uppercase font-mono tracking-wide transition-all"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{htmlFor:`${s}-4`,className:"text-sm font-medium text-[var(--text-secondary)]",children:["日期 ",e.jsx("span",{className:"text-[var(--error)]",children:"*"})]}),e.jsx("input",{id:`${s}-4`,required:!0,type:"date",value:b.date,onChange:t=>S("date",t.target.value),className:"bg-[var(--bg-card-alt)] border border-[var(--border)] text-[var(--text-primary)] rounded-xl p-3 focus:border-[var(--accent)] outline-none transition-all"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{htmlFor:`${s}-5`,className:"text-sm font-medium text-[var(--accent)]",children:["總額 (NT$) ",e.jsx("span",{className:"text-[var(--error)]",children:"*"})]}),e.jsx("input",{id:`${s}-5`,type:"number",value:b.totalAmount,onChange:t=>S("totalAmount",t.target.value),placeholder:"輸入金額",className:"bg-[var(--bg-card-alt)] border border-[var(--accent)]/50 text-[var(--text-primary)] rounded-xl p-3 focus:border-[var(--accent)] outline-none font-mono text-lg font-bold placeholder-[var(--text-muted)] transition-all focus:bg-[var(--bg-card-alt)]",required:!0})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{htmlFor:`${s}-6`,className:"text-sm font-medium text-[var(--text-secondary)]",children:"勞報單抬頭"}),e.jsxs("select",{id:`${s}-6`,value:b.companyName||"",onChange:t=>S("companyName",t.target.value),className:"bg-[var(--bg-card-alt)] border border-[var(--border)] text-[var(--text-primary)] rounded-xl p-3 focus:border-[var(--accent)] outline-none transition-all",children:[e.jsx("option",{value:"",className:"text-[var(--text-muted)]",children:"請選擇公司"}),I.map(t=>e.jsxs("option",{value:t.name,className:"text-[var(--text-primary)]",children:[t.name,t.isDefault?" (預設)":""]},t.id))]})]}),e.jsxs("div",{className:"lg:col-span-4 grid grid-cols-2 lg:grid-cols-5 ga
2p-4 bg-[var(--bg-card-alt)] p-5 rounded-2xl border border-[var(--border)] mt-2",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{htmlFor:`${s}-7`,className:"text-xs text-[var(--text-muted)] font-bold uppercase",children:"項目 (M欄)"}),e.jsxs("select",{id:`${s}-7`,disabled:b.isAutoCalc,value:b.itemCode,onChange:t=>S("itemCode",t.target.value),className:`bg-[var(--bg-card-alt)] border border-[var(--border)] text-[var(--text-primary)] rounded-lg p-2.5 text-sm ${b.isAutoCalc?"opacity-60 cursor-not-allowed":""}`,children:[e.jsx("option",{value:"50",children:"50 (薪資)"}),e.jsx("option",{value:"9A",children:"9A (執業)"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{htmlFor:`${s}-8`,className:"text-xs text-[var(--error)] font-bold uppercase",children:"2.11% 健保"}),e.jsx("input",{id:`${s}-8`,type:"number",disabled:b.isAutoCalc,value:b.healthTax??"",onChange:t=>S("healthTax",t.target.value),className:`bg-[var(--bg-card-alt)] border border-[var(--border)] text-[var(--text-secondary)] rounded-lg p-2.5 text-sm font-mono ${b.isAutoCalc?"opacity-60":"bg-[var(--bg-card-alt)] border-[var(--border)] focus:border-[var(--accent)]"}`,placeholder:"-"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{htmlFor:`${s}-9`,className:"text-xs text-[var(--error)] font-bold uppercase",children:"5% 兼職"}),e.jsx("input",{id:`${s}-9`,type:"number",disabled:b.isAutoCalc,value:b.partTimeTax??"",onChange:t=>S("partTimeTax",t.target.value),className:`bg-[var(--bg-card-alt)] border border-[var(--border)] text-[var(--text-secondary)] rounded-lg p-2.5 text-sm font-mono ${b.isAutoCalc?"opacity-60":"bg-[var(--bg-card-alt)] border-[var(--border)] focus:border-[var(--accent)]"}`,placeholder:"-"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{htmlFor:`${s}-10`,className:"text-xs text-[var(--error)] font-bold uppercase",children:"10% 執業"}),e.jsx("input",{id:`${s}-10`,type:"number",disabled:b.isAutoCalc,value:b.professionalTax??"",onChange:t=>S("professionalTax",t.target.value),className:`bg-[var(--bg-card-alt)] border border-[var(--border)] text-[var(--text-secondary)] rounded-lg p-2.5 text-sm font-mono ${b.isAutoCalc?"opacity-60":"bg-[var(--bg-card-alt)] border-[var(--border)] focus:border-[var(--accent)]"}`,placeholder:"-"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs text-[var(--success)] font-bold uppercase",children:"實領金額"}),e.jsxs("div",{className:"bg-[var(--bg-card-alt)] border border-[var(--success)]/50 text-[var(--success)] font-bold rounded-lg p-2.5 text-lg font-mono shadow-inner",children:["NT$",b.netAmount.toLocaleString()]})]})]}),e.jsxs("div",{className:"lg:col-span-2 flex flex-col gap-2",children:[e.jsx("label",{htmlFor:`${s}-11`,className:"text-sm font-medium text-[var(--text-secondary)]",children:"現居地址"}),e.jsx("input",{id:`${s}-11`,type:"text",value:b.address,onChange:t=>S("address",t.target.value),className:"bg-[var(--bg-card-alt)] border border-[var(--border)] text-[var(--text-primary)] rounded-xl p-3 focus:border-[var(--accent)] outline-none transition-all",placeholder:"自動帶入或手動輸入"})]}),e.jsxs("div",{className:"lg:col-span-2 flex flex-col gap-2",children:[e.jsx("label",{htmlFor:`${s}-12`,className:"text-sm font-medium text-[var(--text-secondary)]",children:"戶籍地址"}),e.jsx("input",{id:`${s}-12`,type:"text",value:b.regAddress,onChange:t=>S("regAddress",t.target.value),className:"bg-[var(--bg-card-alt)] border border-[var(--border)] text-[var(--text-primary)] rounded-xl p-3 focus:border-[var(--accent)] outline-none transition-all",placeholder:"自動帶入或手動輸入"})]}),e.jsxs("div",{className:"lg:col-span-2 flex flex-col gap-2",children:[e.jsx("label",{htmlFor:`${s}-13`,className:"text-sm font-medium text-[var(--text-secondary)]",children:"工作內容"}),e.jsx("input",{id:`${s}-13`,type:"text",value:b.note,onChange:t=>S("note",t.target.value),className:"bg-[var(--bg-card-alt)] border border-[var(--border)] text-[var(--text-primary)] rounded-xl p-3 focus:border-[var(--accent)] outline-none transition-all"})]}),e.jsxs("div",{className:"lg:col-span-2 flex flex-col gap-2",children:[e.jsx("label",{htmlFor:`${s}-14`,className:"text-sm font-medium text-[var(--text-secondary)]",children:"合作備註"}),e.jsx("input",{id:`${s}-14`,type:"text",value:b.collabNote,onChange:t=>S("collabNote",t.target.value),className:"bg-[var(--bg-card-alt)] border border-[var(--border)] text-[var(--text-primary)] rounded-xl p-3 focus:border-[var(--accent)] outline-none transition-all"})]}),e.jsxs("div",{className:"lg:col-span-4 mt-6 flex justify-end gap-3 pt-6 border-t border-[var(--border)]",children:[e.jsx("button",{type:"button",onClick:()=>T(!1),className:"px-6 py-3 rounded-xl text-[var(--text-secondary)] hover:bg-[var(--bg-card-alt)] transition-colors font-medium",children:"取消"}),e.jsxs("button",{type:"submit",className:"px-8 py-3 bg-[var(--accent)] hover:bg-[var(--accent-hover)] text-[var(--button-text)] rounded-xl shadow-lg shadow-blue-500/20 font-bold transition-all active:scale-95 flex items-center gap-2",children:[e.jsx(ha,{size:20}),"確認儲存"]}
2)]})]})]}),e.jsx(Oa,{isOpen:yt,onClose:()=>Me(!1),companies:I,onRefresh:Ge,showToast:C})]})};export{Ka 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.