1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7840],{7840:(e,t,s)=>{s.r(t),s.d(t,{GiftTaxPanel:()=>C,TaxCalendarPanel:()=>D});var a=s(85047),r=s(31615),n=s(82520),l=s(866),d=s(96968),i=s(21582),c=s(58552),x=s(62557),m=s(63533),o=s(24385),u=s(80746);let h=[7,3,1];function j({taxConfig:e,reminder:t,year:s,onToggle:l,onUpdateReminderDays:i,loading:c=!1}){let[p,f]=(0,r.useState)(!1),y=t?.enabled??!1,v=t?.reminderDays??[],N=new Date(s,e.startDate.month-1,e.startDate.day),g=new Date(s,e.endDate.month-1,e.endDate.day),b=async e=>{f(!0);try{await l(e)}catch(e){console.error("åææé失æ:",e)}finally{f(!1)}},D=async(e,t)=>{if(!c&&!p){f(!0);try{let s=t?[...v,e].sort((e,t)=>t-e):v.filter(t=>t!==e);await i(s)}catch(e){console.error("æ´æ°æé天æ¸å¤±æ:",e)}finally{f(!1)}}};return(0,a.jsxs)(n.Zp,{children:[(0,a.jsx)(n.aR,{className:"pb-3",children:(0,a.jsx)("div",{className:"flex items-center justify-between",children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(x.S,{id:`tax-${e.type}-${s}`,checked:y,onCheckedChange:b,disabled:c||p}),(0,a.jsxs)("div",{children:[(0,a.jsx)(n.ZB,{className:"text-lg",children:e.name}),(0,a.jsx)(n.BT,{className:"mt-1",children:e.description})]})]})})}),(0,a.jsx)(n.Wu,{children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-start gap-2 text-sm",children:[(0,a.jsx)(m.A,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:"ç¹³ç´æéï¼"}),(0,a.jsxs)("span",{className:"font-medium",children:[(0,o.GP)(N,"yyyyå¹´MMæddæ¥",{locale:u.G})," - ",(0,o.GP)(g,"yyyyå¹´MMæddæ¥",{locale:u.G})]})]})]}),y?(0,a.jsxs)("div",{className:"space-y-2 pt-2 border-t",children:[(0,a.jsx)(d.J,{className:"text-sm font-medium",children:"æéè¨å®"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-4",children:h.map(t=>(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(x.S,{id:`reminder-${e.type}-${s}-${t}`,checked:v.includes(t),onCheckedChange:e=>D(t,e),disabled:c||p}),(0,a.jsxs)(d.J,{htmlFor:`reminder-${e.type}-${s}-${t}`,className:"text-sm cursor-pointer",children:["æå",t,"天"]})]},t))}),0===v.length&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"è«è³å°é¸æä¸åæéæé"})]}):(0,a.jsx)("div",{className:"pt-2 border-t",children:(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"åç¨æéå¾å¯è¨å®æåéç¥æé"})})]})})]})}var p=s(41717),f=s(73521),y=s(41178),v=s(11787);function N(){let{user:e}=(0,f.A)(),{toast:t}=(0,y.dj)(),[s,l]=(0,r.useState)(!1),d=(0,p.hk)(),{reminders:i,loading:x,loadReminders:m,createReminder:o,updateReminder:u,checkReminderExists:h}=(0,c.e)({userId:e?.uid,autoLoad:!0}),N=(0,p.cG)(d),g=async(s,a)=>{if(!e?.uid)return void t({title:"é¯èª¤",description:"è«å
ç»å
¥",variant:"destructive"});try{let r=h(s,d),n=p.V5[s],c=N.find(e=>e.taxType===s);if(!c)throw Error("æ¾ä¸å°ç¨
忥æé
ç½®");if(a)if(r){let e=i.find(e=>e.taxType===s&&e.year===d);e&&(await u(e.id,{enabled:!0}),t({title:"å·²åç¨æé",description:`${n.name}æéå·²åç¨`}))}else l(!0),await o({userId:e.uid,taxType:s,taxName:n.name,year:d,startDate:c.startDate,endDate:c.endDate,enabled:!0,reminderDays:[7]}),t({title:"å·²åç¨æé",description:`${n.name}æéå·²åç¨`});else{let e=i.find(e=>e.taxType===s&&e.year===d);e&&(await u(e.id,{enabled:!1}),t({title:"å·²åç¨æé",description:`${n.name}æéå·²åç¨`}))}}catch(e){console.error("åææé失æ:",e),t({title:"é¯èª¤",description:e.message||"æä½å¤±æï¼è«ç¨å¾å試",variant:"destructive"})}finally{l(!1)}},b=async(s,a)=>{if(e?.uid)try{let e=i.find(e=>e.taxType===s&&e.year===d);e&&await u(e.id,{reminderDays:a})}catch(e){console.error("æ´æ°æé天æ¸å¤±æ:",e),t({title:"é¯èª¤",description:"æ´æ°æéè¨å®å¤±æ",variant:"destructive"})}},D=(0,r.useMemo)(()=>{let e=new Date;return e.setHours(23,59,59,999),(0,p.Ko)().filter(t=>{let s=p.V5[t],a=new Date(d,s.endDate.month-1,s.endDate.day);return a.setHours(23,59,59,999),a>=e}).sort((e,t)=>
1{let s=p.V5[e],a=p.V5[t],r=new Date(d,s.endDate.month-1,s.endDate.day),n=new Date(d,a.endDate.month-1,a.endDate.day);return r.getTime()-n.getTime()})},[d]);return x?(0,a.jsx)(n.Zp,{children:(0,a.jsx)(n.Wu,{className:"flex items-center justify-center py-12",children:(0,a.jsx)(v.A,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):(0,a.jsx)("div",{className:"space-y-4",children:(0,a.jsxs)(n.Zp,{children:[(0,a.jsxs)(n.aR,{children:[(0,a.jsxs)(n.ZB,{children:["ç¨
忥æ - ",d,"年度"]}),(0,a.jsx)(n.BT,{children:"å¾é¸éè¦æéçç¨
åé
ç®ï¼ç³»çµ±æå¨å°æåéç¥æ¨"})]}),(0,a.jsx)(n.Wu,{children:(0,a.jsx)("div",{className:"space-y-4",children:D.map(e=>{let t=p.V5[e],r=i.find(t=>t.taxType===e&&t.year===d);return(0,a.jsx)(j,{taxConfig:t,reminder:r,year:d,onToggle:t=>g(e,t),onUpdateReminderDays:t=>b(e,t),loading:s},`${e}-${d}`)})})})]})})}function g(e){let t=Math.max(0,e-244e4),s=0,a=0;t<=2811e4?(s=.1,a=0):t<=5621e4?(s=.15,a=1405500):(s=.2,a=4216e3);let r=Math.max(0,t*s-a);return{giftAmount:e,exemption:244e4,taxableAmount:t,taxRate:s,progressiveDifference:a,taxAmount:Math.round(r)}}var b=s(35617);function D(){return(0,a.jsx)(N,{})}let w=[1,2,3,4,5,6,8,10];function C(){let[e,t]=(0,r.useState)(""),[s,c]=(0,r.useState)(1),x=1e4*Math.max(0,Number(e)||0),m=s>0?Math.floor(x/s):0,o=(0,r.useMemo)(()=>x>0?g(x):null,[x]),u=(0,r.useMemo)(()=>x>0&&s>1?function(e,t,s){let a,r,n=e>0?g(e).taxAmount:0,{totalTax:l}=(r=(a=Array(t).fill(s).map(e=>e<=0?0:g(e).taxAmount)).reduce((e,t)=>e+t,0),{yearlyTaxes:a,totalTax:Math.round(r)});return{singleYearTax:n,multiYearTotalTax:l,multiYearSavings:Math.round(n-l)}}(x,s,m):null,[x,s,m]);return(0,a.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,a.jsxs)(n.Zp,{children:[(0,a.jsxs)(n.aR,{children:[(0,a.jsx)(n.ZB,{className:"text-base",children:"è´èç¨
試ç®"}),(0,a.jsx)(n.BT,{children:"å
ç¨
顿¯äººæ¯å¹´ 244 è¬ï¼ç¨
ç 10%ï¼15%ï¼20% ç´¯é²"})]}),(0,a.jsxs)(n.Wu,{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(d.J,{htmlFor:"gift-amount",children:"總è´èéé¡ï¼è¬å
ï¼"}),(0,a.jsx)(l.p,{id:"gift-amount",type:"number",min:0,value:e,onChange:e=>t(e.target.value),placeholder:"ä¾å¦ï¼1000"})]}),(0,a.jsxs)("div",{className:"space-y-1.5",children:[(0,a.jsx)(d.J,{children:"åå¹´è´èå¹´æ¸"}),(0,a.jsxs)(i.l6,{value:String(s),onValueChange:e=>c(Number(e)),children:[(0,a.jsx)(i.bq,{children:(0,a.jsx)(i.yv,{})}),(0,a.jsx)(i.gC,{children:w.map(e=>(0,a.jsxs)(i.eb,{value:String(e),children:[e," å¹´",e>1?`ï¼æ¯å¹´ç´ ${(0,b.C)(Math.floor(x/e))}ï¼`:""]},e))})]})]}),o&&(0,a.jsxs)("div",{className:"space-y-1.5 rounded-lg border bg-muted/30 p-4 text-sm",children:[(0,a.jsx)(T,{label:"è´èéé¡",value:(0,b.C)(o.giftAmount)}),(0,a.jsx)(T,{label:"å
ç¨
é¡",value:`- ${(0,b.C)(o.exemption)}`}),(0,a.jsx)(T,{label:"課ç¨
è´èæ·¨é¡",value:(0,b.C)(o.taxableAmount)}),(0,a.jsx)(T,{label:"é©ç¨ç¨
ç",value:o.taxableAmount>0?`${Math.round(100*o.taxRate)}%`:"â"}),o.progressiveDifference>0&&(0,a.jsx)(T,{label:"ç´¯é²å·®é¡",value:`- ${(0,b.C)(o.progressiveDifference)}`}),(0,a.jsxs)("div",{className:"mt-2 flex items-center justify-between border-t pt-2 text-base font-bold",children:[(0,a.jsx)("span",{children:"䏿¬¡è´èæç´ç¨
é¡"}),(0,a.jsx)("span",{className:"text-red-500",children:(0,b.C)(o.taxAmount)})]})]})]})]}),(0,a.jsxs)(n.Zp,{children:[(0,a.jsxs)(n.aR,{children:[(0,a.jsx)(n.ZB,{className:"text-base",children:"å®å¹´ vs åå¹´æ¯è¼"}),(0,a.jsx)(n.BT,{children:"åå¹´è´èå¯é年使ç¨å
ç¨
é¡ï¼é常å¯å¤§å¹
ç¯ç¨
"})]}),(0,a.jsx)(n.Wu,{children:u?(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"rounded-lg border p-4",children:[(0,a.jsx)("div",{className:"text-xs text-muted-foreground",children:"䏿¬¡è´èï¼å®å¹´ï¼"}),(0,a.jsx)("div",{className:"mt-1 text-xl font-bold",children:(0,b.C)(u.singleYearTax)})]}),(0,a.jsxs)("div",{className:"rounded-lg border p-4",children:[(0,a.jsxs)("div",{className:"text-xs text-muted-foreground",children:["å ",s," å¹´è´èï¼æ¯å¹´ ",(0,b.C)(m),"ï¼"]}),(0,a.jsx)("div",{className:"mt-1 text-xl font-bold",children:(0,b.C)(u.multiYearTotalTax)})]}),(0,a.jsxs)("div",{className:"rounded-lg border border-emerald-500/40 bg-emerald-500/8 p-4",children:[(0,a.jsx)("div",{className:"text-xs text-muted-foreground",children:"åå¹´å¯ç¯ç"}),(0,a.jsx)("div",{className:"mt-1 text-xl font-bold text-emerald-600 dark:text-emerald-400",children:(0,b.C)(u.multiYearSavings)})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"ï¼è©¦ç®å
ä¾åèï¼å¯¦éæç´ç¨
é¡ä»¥åç¨
屿 ¸å®çºæºï¼è·¨å¹´åº¦è´èéçææ¯å¹´ 12/31 åå®æç§»è½ã"})]}):(0,a.jsx)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:x>0?"鏿 2 年以ä¸å¯æ¥çåå¹´ç¯ç¨
æ¯è¼":"輸å
¥ç¸½è´èéé¡éå§è©¦ç®"})})]})]})}function T({label:e,value:t}){return(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:e}),(0,a.jsx)("span",{className:"tabular-nums",children:t})]})}}}]);
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.