1import{a0 as ve,r as a,t as h,f as u,j as e,G as A,q as he,d as ye,am as We,an as Be,ao as Fe,ap as Me,aq as Qe,as as Ie}from"./index-hq7kdXWa.js";import{M as Pe}from"./MemberLayout-CkjejYBW.js";import{I as T}from"./input-BDkUznem.js";import{L as k}from"./label-FxwjLyoS.js";import{G as pe}from"./gift-CBhGyxBR.js";import{L as b}from"./loader-circle-Bofk2w5-.js";import{C as ue}from"./check-C4VtWd-0.js";import{C as be}from"./copy-CJwrd4kf.js";import{W as je}from"./wallet-DgQEjSyR.js";import{C as Ne}from"./chevron-up-BOOxdRSL.js";import{C as Ee}from"./circle-x-Berpe4zV.js";import{C as ke}from"./circle-check-BZum3PIz.js";import{C as ge}from"./clock-CXFYO0zg.js";import{P as ze}from"./pencil-BY7nYGU7.js";import{U as qe}from"./upload-DB3gMa5F.js";import"./map-pin-CKcYtsMc.js";import"./shopping-bag-DtXSzJHO.js";import"./ticket-DfXTcvav.js";import"./coins-DigsVtIM.js";import"./key-round-BZ4p2KYQ.js";import"./log-out-s6rd0D91.js";import"./useComposition-CHcVJtpR.js";/** 2 * @license lucide-react v0.453.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Oe=ve("ArrowDownRight",[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]]);/** 7 * @license lucide-react v0.453.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Ge=ve("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]),fe={pending:{label:"çå¾ å貨",color:"text-yellow-600 bg-yellow-50",icon:ge},waiting:{label:"çå¾ ç¢ºèª",color:"text-blue-600 bg-blue-50",icon:ge},confirmed:{label:"已確èª",color:"text-green-600 bg-green-50",icon:ke},cancelled:{label:"已忶",color:"text-gray-500 bg-gray-50",icon:Ee},revoked:{label:"å·²æ£å",color:"text-red-500 bg-red-50",icon:ye}},we={pending:{label:"å¾ å¯©æ ¸",color:"text-yellow-600 bg-yellow-50"},reviewing:{label:"å¯©æ ¸ä¸",color:"text-blue-600 bg-blue-50"},approved:{label:"å·²æ ¸å",color:"text-green-600 bg-green-50"},rejected:{label:"å·²æçµ",color:"text-red-500 bg-red-50"},paid:{label:"已坿¬¾",color:"text-green-700 bg-green-50"}};function bt(){const[n,i]=a.useState(!1),[d,s]=a.useState(!1),[o,c]=a.useState(!1),[x,p]=a.useState(!0),[m,j]=a.useState(!1),[g,f]=a.useState(""),[C,B]=a.useState(!1),[V,F]=a.useState(""),[Y,M]=a.use
11State(""),[Z,Q]=a.useState(""),[ee,I]=a.useState(""),[te,P]=a.useState(""),[se,E]=a.useState(""),[ae,z]=a.useState(""),$=h.shop.referralSettings.useQuery(),S=$.data?.isActive===!0,re=h.shop.myReferralCode.useQuery(void 0,{enabled:S}),le=h.shop.myReferralWallet.useQuery(),ne=h.shop.myReferralRecords.useQuery(),ce=h.shop.myWithdrawals.useQuery();h.member.profile.get.useQuery();const ie=h.member.kyc.get.useQuery(),oe=h.useUtils(),q=h.shop.requestWithdrawal.useMutation({onSuccess:()=>{u.success("æé ç³è«å·²éåºï¼æåå°ç¡å¿«å¯©æ ¸æ¨çç³è«"),c(!1),Se(),oe.shop.myReferralWallet.invalidate(),oe.shop.myWithdrawals.invalidate()},onError:t=>{u.error(`ç³è«å¤±æï¼${t.message}`)}}),[D,O]=a.useState("idle"),G=D!=="idle",Ce=h.shop.memberUploadFile.useMutation(),H=async(t,l)=>{O("compressing");try{const v=await He(t,2097152);O("uploading");const y=await _e(v),N=await Ce.mutateAsync({fileName:t.name,fileBase64:y,contentType:v.type||"image/jpeg"}),W=N?.key||N?.url;W?(l(W),u.success("ä¸å³æå")):u.error("ä¸å³å¤±æ")}catch{u.error("ä¸å³å¤±æ")}finally{O("idle")}},Se=()=>{f(""),B(!1),F(""),M(""),Q(""),I(""),P(""),E(""),z("")},Ue=()=>{c(!0)},R=re.data?.code||"",de=R?`${window.location.origin}/?ref=${R}`:"",w=le.data,U=w?Number(w.availableBalance):0,Le=w?Number(w.totalEarned):0,Ae=w?Number(w.totalWithdrawn):0,L=ne.data||[],_=ce.data||[],Te=$.data?.rewardRate??.02,$e=a.useMemo(()=>L.filter(t=>t.status==="waiting").reduce((t,l)=>t+Number(l.rewardAmount),0),[L]),xe=async(t,l)=>{try{await navigator.clipboard.writeText(t),l==="code"?(i(!0),setTimeout(()=>i(!1),2e3)):(s(!0),setTimeout(()=>s(!1),2e3)),u.success("å·²è¤è£½å°åªè²¼ç°¿")}catch{u.error("è¤è£½å¤±æ")}},De=()=>{const t=Number(g);if(!t||t<=0){u.error("è«è¼¸å
¥ææéé¡");return}const l=C||!me?{bankName:V||void 0,branchName:Y||void 0,bankAccount:Z||void 0,accountName:ee||void 0,idCardFrontUrl:te||void 0,idCardBackUrl:se||void 0,bankBookUrl:ae||void 0}:{};q.mutate({amount:t,...l})},r=ie.data,me=!!(r?.idCardFrontUrl&&r?.idCardBackUrl&&r?.bankBookUrl&&r?.bankAccount);return e.jsxs(Pe,{title:"æ¨è¦è³ºçé",children:[$.isSuccess&&!S&&e.jsx("div",{className:"bg-yellow-50 border border-yellow-200 text-yellow-700 px-4 py-3 text-sm mb-4",children:"æ¨è¦æ´»åç®åæªéæ¾"}),S&&e.jsxs("div",{className:"bg-white border border-[#e5e5e5] p-6 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(pe,{className:"w-5 h-5 text-[#e8879b]"}),e.jsx("h3",{className:"text-sm font-bold text-[#333]",children:"æçæ¨è¦ç¢¼"})]}),re.isLoading?e.jsx(b,{className:"w-5 h-5 animate-spin text-[#999]"}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 bg-[#f9f9f9] border border-[#e5e5e5] px-4 py-2.5 font-mono text-lg font-bold text-[#333] tracking-wider text-center",children:R}),e.jsx(A,{variant:"outline",size:"sm",onClick:()=>xe(R,"code"),className:"flex-shrink-0",children:n?e.jsx(ue,{className:"w-4 h-4"}):e.jsx(be,{className:"w-4 h-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-[#999] mb-1",children:"æ¨è¦é£çµ"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1 bg-[#f9f9f9] border border-[#e5e5e5] px-3 py-2 text-xs text-[#666] truncate",children:de}),e.jsx(A,{variant:"outline",size:"sm",onClick:()=>xe(de,"link"),className:"flex-shrink-0",children:d?e.jsx(ue,{className:"w-4 h-4"}):e.jsx(be,{className:"w-4 h-4"})})]})]}),e.jsxs("p",{className:"text-[10px] text-[#999]",children:["å享æ¨è¦ç¢¼æé£çµçµ¦æåï¼æå宿è¨å®å貨å¾ï¼æ¨å¯ç²å¾è¨å®å¯¦ä»éé¡ ",(Te*100).toFixed(0),"% ççé"]})]})]}),e.jsxs("div",{className:"bg-white border border-[#e5e5e5] p-6 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(je,{className:"w-5 h-5 text-[#e8879b]"}),e.jsx("h3",{className:"text-sm font-bold text-[#333]",children:"çéé¢å
"})]}),le.isLoading?e.jsx(b,{className:"w-5 h-5 animate-spin text-[#999]"}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] text-[#999] mb-1",children:"å¯ç¨é¤é¡"}),e.jsxs("p",{className:"text-xl font-bold text-[#333]",children:["NT$",U.toLocaleStr
11ing()]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] text-[#999] mb-1",children:"çå¾
確èª"}),e.jsxs("p",{className:"text-xl font-bold text-blue-600",children:["NT$",$e.toLocaleString()]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] text-[#999] mb-1",children:"ç´¯è¨ç²å¾"}),e.jsxs("p",{className:"text-xl font-bold text-green-600",children:["NT$",Le.toLocaleString()]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[10px] text-[#999] mb-1",children:"å·²æé "}),e.jsxs("p",{className:"text-xl font-bold text-[#999]",children:["NT$",Ae.toLocaleString()]})]})]}),e.jsxs(A,{onClick:Ue,disabled:U<1e3||!S,className:"w-full bg-[#e8879b] hover:bg-[#d4768a] text-white",children:["ç³è«æé ",U<1e3&&"(滿 NT$1,000 å¯ç³è«)"]})]})]}),e.jsxs("div",{className:"bg-white border border-[#e5e5e5] mb-4",children:[e.jsxs("button",{onClick:()=>p(!x),className:"w-full flex items-center justify-between px-4 py-3 border-b border-[#f0f0f0] hover:bg-[#fafafa] transition-colors",children:[e.jsxs("h3",{className:"text-sm font-bold text-[#333]",children:["æ¨è¦ç´é (",L.length,")"]}),x?e.jsx(Ne,{className:"w-4 h-4 text-[#999]"}):e.jsx(he,{className:"w-4 h-4 text-[#999]"})]}),x&&e.jsx(e.Fragment,{children:ne.isLoading?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(b,{className:"w-6 h-6 animate-spin text-[#999]"})}):L.length===0?e.jsxs("div",{className:"py-12 text-center",children:[e.jsx(pe,{className:"w-8 h-8 text-[#ddd] mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-[#999]",children:"å°ç¡æ¨è¦ç´é"}),S&&e.jsx("p",{className:"text-xs text-[#ccc] mt-1",children:"å享æ¨è¦ç¢¼çµ¦æåéå§è³ºçé"})]}):e.jsx("div",{className:"divide-y divide-[#f0f0f0]",children:L.map(t=>{const l=fe[t.status]||fe.pending,v=l.icon,y=Number(t.rewardAmount),N=Number(t.orderAmount),W=$.data?.confirmDays??8;let K=0;if(t.status==="waiting"&&t.pickedUpAt){const Re=new Date(t.pickedUpAt),X=new Date(Re);X.setDate(X.getDate()+W),K=Math.max(0,Math.ceil((X.getTime()-Date.now())/(1e3*60*60*24)))}return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${l.color}`,children:e.jsx(v,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs font-medium text-[#333]",children:["è¨å® #",t.orderNumber]}),e.jsxs("p",{className:"text-[10px] text-[#999] mt-0.5",children:["è¨å®éé¡ NT$",N.toLocaleString()," · ",new Date(t.createdAt).toLocaleDateString("zh-TW")]}),t.status==="waiting"&&K>0&&e.jsxs("p",{className:"text-[10px] text-blue-500 mt-0.5",children:["é è¨ ",K," 天å¾ç¢ºèª"]})]}),e.jsxs("div",{className:"flex flex-col items-end flex-shrink-0",children:[e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${l.color}`,children:l.label}),e.jsxs("span",{className:`text-sm font-bold mt-1 ${t.status==="confirmed"?"text-green-600":t.status==="revoked"?"text-red-500":"text-[#999]"}`,children:["+NT$",y.toLocaleString()]})]})]},t.id)})})})]}),e.jsxs("div",{className:"bg-white border border-[#e5e5e5]",children:[e.jsxs("button",{onClick:()=>j(!m),className:"w-full flex items-center justify-between px-4 py-3 border-b border-[#f0f0f0] hover:bg-[#fafafa] transition-colors",children:[e.jsxs("h3",{className:"text-sm font-bold text-[#333]",children:["æé ç´é (",_.length,")"]}),m?e.jsx(Ne,{className:"w-4 h-4 text-[#999]"}):e.jsx(he,{className:"w-4 h-4 text-[#999]"})]}),m&&e.jsx(e.Fragment,{children:ce.isLoading?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(b,{className:"w-6 h-6 animate-spin text-[#999]"})}):_.length===0?e.jsxs("div",{className:"py-12 text-center",children:[e.jsx(je,{className:"w-8 h-8 text-[#ddd] mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-[#999]",children:"å°ç¡æé ç´é"})]}):e.jsx("div",{className:"divide-y divide-[#f0f0f0]",children:_.map(t=>{const l=we[t.status]||we.pending,v=Number(t.amount),y=Number(t.
11netAmount),N=Number(t.taxAmount);return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${t.status==="paid"?"bg-green-50":"bg-gray-50"}`,children:t.status==="paid"?e.jsx(Ge,{className:"w-4 h-4 text-green-600"}):e.jsx(Oe,{className:"w-4 h-4 text-gray-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-xs font-medium text-[#333]",children:["æé NT$",v.toLocaleString()]}),e.jsxs("p",{className:"text-[10px] text-[#999] mt-0.5",children:[N>0?`ç¨
é¡ NT$${N.toLocaleString()} · 實é NT$${y.toLocaleString()}`:`å
ç¨
· 實é NT$${y.toLocaleString()}`," · ",new Date(t.requestedAt).toLocaleDateString("zh-TW")]}),t.adminNote&&e.jsxs("p",{className:"text-[10px] text-[#999] mt-0.5",children:["å註: ",t.adminNote]})]}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded flex-shrink-0 ${l.color}`,children:l.label})]},t.id)})})})]}),e.jsx(We,{open:o,onOpenChange:c,children:e.jsxs(Be,{className:"max-w-md max-h-[90vh] overflow-y-auto",children:[e.jsx(Fe,{children:e.jsx(Me,{children:"ç³è«æé çé"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-[#f9f9f9] border border-[#e5e5e5] p-3 text-sm",children:[e.jsx("p",{className:"text-[#999]",children:"å¯ç¨é¤é¡"}),e.jsxs("p",{className:"text-lg font-bold text-[#333]",children:["NT$",U.toLocaleString()]})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-xs",children:"æé éé¡"}),e.jsx(T,{type:"number",value:g,onChange:t=>f(t.target.value),placeholder:"æä½ 1,000 å
",min:1e3,max:U}),Number(g)>=2e4&&e.jsx("p",{className:"text-[10px] text-orange-500 mt-1",children:"宿¬¡æé NT$20,000 以ä¸éæ£ç¹³ 10% æå¾ç¨
"})]}),e.jsx("div",{className:"border-t border-[#f0f0f0] pt-4",children:ie.isLoading?e.jsxs("div",{className:"flex items-center gap-2 py-2",children:[e.jsx(b,{className:"w-4 h-4 animate-spin text-[#999]"}),e.jsx("span",{className:"text-xs text-[#999]",children:"è¼å
¥é©èè³æ..."})]}):me&&!C?e.jsxs("div",{className:"bg-green-50 border border-green-200 p-3 rounded",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"w-4 h-4 text-green-500"}),e.jsx("p",{className:"text-xs font-bold text-green-700",children:"å·²å®æèº«ä»½é©è"})]}),e.jsxs("button",{type:"button",className:"text-[10px] text-[#999] flex items-center gap-1 hover:text-[#333]",onClick:()=>{B(!0),F(r?.bankName||""),M(r?.branchName||""),Q(r?.bankAccount||""),I(r?.accountName||""),P(r?.idCardFrontUrl||""),E(r?.idCardBackUrl||""),z(r?.bankBookUrl||"")},children:[e.jsx(ze,{className:"w-3 h-3"}),"æ´æ°è³æ"]})]}),e.jsxs("p",{className:"text-xs text-green-700",children:[r?.bankName," ",r?.branchName?`${r.branchName} `:"","****",r?.bankAccount?.slice(-4)]}),e.jsx("p",{className:"text-[10px] text-green-600 mt-1",children:"æ¬æ¬¡æé å°æ²¿ç¨å·²é©èç身份åéè¡è³æ"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("p",{className:"text-xs font-bold text-[#333]",children:C?"æ´æ°èº«ä»½é©èè³æ":"身份é©è & éè¡å¸³æ¶"}),C&&e.jsx("button",{type:"button",className:"text-[10px] text-[#999] underline",onClick:()=>{B(!1)},children:"åæ¶æ´æ°"})]}),!C&&e.jsxs("div",{className:"flex items-center gap-2 bg-amber-50 border border-amber-200 p-2 rounded mb-3",children:[e.jsx(ye,{className:"w-3.5 h-3.5 text-amber-500 flex-shrink-0"}),e.jsx("p",{className:"text-[10px] text-amber-700",children:"馿¬¡æé éä¸å³èº«ä»½èæ£åé¢åéè¡åæºå°é¢"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-xs",children:"æ¶å"}),e.jsx(T,{value:ee,onChange:t=>I(t.target.value),placeholder:"è«è¼¸å
¥æ¶å"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(k,{className:"text-xs",children:"éè¡å稱"}),e.jsx(T,{value:V,onChange:t=>F(t.target.value),placeholder:"å¦ï¼ä¸åä¿¡è¨"})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-xs",children:"åè¡å稱"}),e.jsx(T,{value:Y,onChange:t=>M(t.target.value),placeholder:"å¦ï¼å¿ ååè¡"})]})]}),e.jsxs("div",{children:[e.jsx(k,{className:"text-xs",children:"éè¡å¸³è"}),e.jsx(T,{value:Z,onChange:t=>Q(t.target.value),placeholder:"è«è¼¸å
¥éè¡å¸³è"})]}),e.jsx(J,{label:"èº«ä»½èæ£é¢",value:te,onUpload:t=>H(t,P),uploading:G,uploadStatus:D}),e.jsx(J,{label:"身份èåé¢",value:se,onUpload:t=>H(t,E),uploading:G,uploadStatus:D}),e.jsx(J,{label:"éè¡åæºå°é¢",value:ae,onUpload:t=>H(t,z),uploading:G,uploadStatus:D})]})]})})]}),e.jsxs(Qe,{children:[e.jsx(A,{variant:"outline",onClick:()=>c(!1),children:"åæ¶"}),e.jsxs(A,{onClick:De,disabled:q.isPending||!g||Number(g)<1e3,className:"bg-[#e8879b] hover:bg-[#d4768a] text-white",children:[q.isPending?e.jsx(b,{className:"w-4 h-4 animate-spin mr-1"}):null,"éåºç³è«"]})]})]})})]})}function J({label:n,value:i,onUpload:d,uploading:s,uploadStatus:o}){const{url:c,isLoading:x}=Ie(i||null,!!i),p=o==="compressing"?"å£ç¸®ä¸...":o==="uploading"?"ä¸å³ä¸...":"黿ä¸å³";return e.jsxs("div",{children:[e.jsx(k,{className:"text-xs",children:n}),i?e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[x?e.jsx("div",{className:"w-16 h-10 border border-[#e5e5e5] rounded bg-gray-100 flex items-center justify-center",children:e.jsx(b,{className:"w-4 h-4 animate-spin text-[#999]"})}):e.jsx("img",{src:c??"",alt:n,className:"w-16 h-10 object-cover border border-[#e5e5e5] rounded"}),e.jsx("span",{className:"text-[10px] text-green-600",children:"å·²ä¸å³"})]}):e.jsxs("label",{className:`flex items-center gap-2 mt-1 px-3 py-2 border border-dashed rounded transition-colors ${s?"border-[#e8879b] cursor-not-allowed":"border-[#ccc] cursor-pointer hover:border-[#999]"}`,children:[s?e.jsx(b,{className:"w-4 h-4 animate-spin text-[#e8879b]"}):e.jsx(qe,{className:"w-4 h-4 text-[#999]"}),e.jsx("span",{className:`text-xs ${s?"text-[#e8879b]":"text-[#999]"}`,children:p}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:s,onChange:m=>{const j=m.target.files?.[0];j&&!s&&d(j)}})]})]})}function He(n,i){return new Promise(d=>{if(n.size<=i){d(n);return}const s=new Image,o=URL.createObjectURL(n);s.onload=()=>{URL.revokeObjectURL(o);const c=document.createElement("canvas");let{width:x,height:p}=s,m=.85;const j=()=>{c.width=x,c.height=p,c.getContext("2d").drawImage(s,0,0,x,p),c.toBlob(f=>{if(!f){d(n);return}f.size<=i||m<=.3?d(new File([f],n.name,{type:"image/jpeg"})):(m>.5?m-=.15:(x=Math.floor(x*.8),p=Math.floor(p*.8)),j())},"image/jpeg",m)};j()},s.onerror=()=>{URL.revokeObjectURL(o),d(n)},s.src=o})}function _e(n){return new Promise((i,d)=>{const s=new FileReader;s.onload=()=>{const o=s.result,c=o.split(",")[1]||o;i(c)},s.onerror=d,s.readAsDataURL(n)})}
11export{bt 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.