1import{_ as se}from"./CkNZ_VXv.js";import{_ as oe}from"./FCbK7UYk.js";import{_ as ae}from"./DHHte8yu.js";import{aQ as re,ee as ne,ew as ue,dZ as ce,es as le,eU as z,cH as ie,aw as $,eZ as de,as as n,c$ as c,cL as s,av as u,aA as o,dH as a,ax as l,dT as D,f as g,d6 as R,cv as C,aH as _e,f0 as he,aI as ve,bs as B,a0 as pe}from"./Bvar31K0.js";import{r as me}from"./KI3naYzN.js";import{r as ye}from"./DTzB5GU3.js";import{u as fe}from"./D26wpjqQ.js";import"./B0tXIqJN.js";import"./Bkj-NMf9.js";import"./BxBi1_Sw.js";import"./8QESn_fu.js";import"./Bk6k-oHp.js";import"./DLoSOc9j.js";import"./BXLgHFVY.js";import"./bDWHkiKe.js";import"./BQawY1YM.js";import"./CXrjN5r8.js";import"./B2qdGcuk.js";import"./C9lZP1Li.js";import"./D9-srlUO.js";import"./B8QAxleW.js";import"./zL1zXNpF.js";import"./BgRtxhC8.js";import"./DWRWTEWV.js";import"./DW4JbKmU.js";import"./PUTlPuMM.js";import"./KNeBdjIC.js";const we={class:"wc-vouchers"},ge={key:0,class:"wc-vouchers__banner is-wait"},ke={key:1,class:"wc-vouchers__banner is-ok"},be={key:2,class:"wc-vouchers__banner"},$e={key:3,class:"wc-vouchers__state"},Ce={key:4,class:"wc-vouchers__state"},Ae={key:5,class:"wc-vouchers__state"},Te={key:6,class:"wc-vouchers__state"},Ie={class:"wc-vouchers__tabs",role:"tablist"},Ue=["aria-selected","onClick"],qe={class:"wc-num"},Le={key:0,class:"wc-vouchers__state"},Me={key:1,class:"wc-vouchers__list"},Ne=["onClick"],Pe=["src","alt"],Se={class:"wc-vouchers__body"},Ve={class:"wc-vouchers__head"},ze={class:"wc-vouchers__title"},De={key:0,class:"wc-vouchers__channel"},Re=["onClick"],Be={key:2,class:"wc-vouchers__expired"},Ee={class:"wc-vouchers__meta wc-num"},He={class:"wc-vouchers__paid"},xe={class:"wc-vouchers__code"},Fe={key:2,class:"wc-vouchers__state"},Oe=["disabled"],Ze=3e3,E=10,Ke=re({__name:"vouchers",setup(We){const{t:p}=ne(),A=ue(),H=ye(),d=ce();fe({title:()=>p("voucher.mine_title")});const T=c([]),I=c(null),_=c(!1),k=c(!1),b=c(null),h=n(()=>String(A.query.order??"").trim()),m=n(()=>String(A.query.paid??"").trim()),v=c(!1),y=c(0),U=n(()=>v.value&&y.value<E),{data:q,isLoading:x,isError:F,dataUpdatedAt:O}=le({queryKey:["my-vouchers"],queryFn:async()=>{const e=await $fetch("/api/app/vouchers/mine",{headers:B(),credentials:"include",query:{take:20}});return me(e?.nowUtc),e},enabled:n(()=>d.isAuthenticated.value),staleTime:3e4,refetchInterval:n(()=>U.value?Ze:!1)}),f=n(()=>[...q.value?.items??[],...T.value.flat()]),L=n(()=>h.value.length>0&&f.value.some(e=>e.orderId===h.value&&e.status!=="pending_payment")),Z=n(()=>m.value==="1"&&h.value.length>0&&!L.value&&U.value);z(L,e=>{e&&(v.value=!1)}),z(O,()=>{v.value&&(y.value+=1,y.value>=E&&(v.value=!1))});const M=n(()=>I.value??q.value?.nextCursor??""),N=n(()=>M.value.length>0),K=n(()=>d.resolved.value&&!d.isAuthenticated.value),W=n(()=>!d.resolved.value||d.isAuthenticated.value&&x.value);function w(e){switch(e){case"redeemed":return"used";case"expired":case"invalid":case"void":case"refunded":return"gone";default:return"usable"}}const i=c("usable"),P=n(()=>{const e=f.value.filter(r=>w(r.status)===i.value);return i.value!=="usable"?e:[...e.filter(r=>r.status==="pending_payment"),...e.filter(r=>r.status!=="pending_payment")]});function Q(e){return f.value.filter(r=>w(r.status)===e).length}async function G(){if(!(_.value||!N.value)){_.value=!0,k.value=!1;try{const e=await $fetch("/api/app/vouchers/mine",{headers:B(),credentials:"include",query:{take:20,cursor:M.value}});T.value.push(e?.items??[]),I.value=e?.nextCursor??""}catch{k.value=!0}finally{_.value=!1}}}function X(e){switch(e){case"redeemed":return"voucher.status_redeemed";case"invalid":return"voucher.status_invalid";case"expired":return"voucher.status_expired";case"upcoming":return"voucher.status_upcoming";case"pending_payment":return"voucher.status_pending_payment";case"void":return"voucher.status_void";case"refunded":return"voucher.status_refunded";default:return"voucher.status_active"}}function j(e){if((e.salePriceCents??0)<=0)return p("deal.free");const r=(e.paidText||"").trim();return r?p("voucher.paid_amount",{price:r}):p("voucher.paid")}function J(e){return(e.checkoutUrl||"").trim().length>0}function Y(e){const r=(e.checkoutUrl||"").trim();r&&(window.location.href=r)}return ie(()=>{m.value==="1"&&h.value.length>0&&(v.value=!0,y.value=0)}),(e,r)=>{const S=se,ee=oe,te=ae;return s(),$(te,{"active-mode":"vouchers","header-title":e.$t("voucher.mine_title"),"back-to":"/","show-compose":!1,"hide-content-header-on-mobile":!0},{default:de(()=>[u("div",we,[Z.value?(s(),o("p",ge,a(e.$t("voucher.pay_confirming")),1)):m.value==="1"&&h.value?(s(),o("p",ke,a(e.$t("voucher.pay_done")),1)):m.value==="0"?(s(),o("p",be,a(e.$t("voucher.pay_cancelled")),1)):l("",!0),W.value?(s(),o("p",$e,a(e.$t("common.loading")),1)):K.value?(s(),o("div",Ce,[u("p",null,a(e.$t("voucher.login_required")),1),u("button",{type:"button",class:"wc-vouchers__more",onClick:r[0]||(r[0]=t=>D(H)())},a(e.$t("voucher.go_login")),1)])):D(F)?(s(),o("p",Ae,a(e.$t("voucher.load_failed")),1)):f.value.length===0?(s(),o("p",Te,a(e.$t("voucher.mine_empty")),1)):(s(),o(g,{key:7},[u("div",Ie,[(s(),o(g,null,R(["usable","used","gone"],t=>u("button",{key:t,type:"button",role:"tab",class:C(["wc-vouchers__tab",{"is-active":i.value===t}]),"aria-selected":i.value===t,onClick:V=>i.value=t},[_e(a(e.$t(`voucher.tab_${t}`))+" ",1),u("span",qe,a(Q(t)),1)],10,Ue)),64))]),P.value.length===0?(s(),o("p",Le,a(e.$t(`voucher.tab_empty_${i.value}`)),1)):(s(),o("ul",Me,[(s(!0),o(g,null,R(P.value,t=>(s(),o("li",{key:t.voucherId,class:C(["wc-vouchers__item",{"is-gone":w(t.status)==="gone"}]),onClick:V=>b.value=t},[t.coverUrl?(s(),o("img",{key:0,class:"wc-vouchers__cover",src:t.coverUrl,alt:t.dealTitle,loading:"lazy"},null,8,Pe)):l("",!0),u("div",Se,[u("div",Ve,[u("h2",ze,a(t.dealTitle),1),u("span",{class:C(["wc-vouchers__chip",`is-${t.status}`])},a(e.$t(X(t.status))),3)]),t.channelName?(s(),o("p",De,a(t.channelName),1)):l("",!0),t.status==="pending_payment"?(s(),o(g,{key:1},[t.holdExpiresAtUtc?(s(),$(S,{key:0,"ends-at-utc":t.holdExpiresAtUtc,variant:"inline",label:e.$t("voucher.hold_label"),"time-zone-id":t.dealTimeZoneId}
1,null,8,["ends-at-utc","label","time-zone-id"])):l("",!0),J(t)?(s(),o("button",{key:1,type:"button",class:"wc-vouchers__pay",onClick:he(V=>Y(t),["stop"])},a(e.$t("deal.order_pay_now")),9,Re)):(s(),o("p",Be,a(e.$t("deal.order_pay_expired")),1))],64)):t.redeemDeadlineUtc&&w(t.status)==="usable"?(s(),$(S,{key:2,"ends-at-utc":t.redeemDeadlineUtc,variant:"inline",label:e.$t("voucher.redeem_by"),"time-zone-id":t.dealTimeZoneId},null,8,["ends-at-utc","label","time-zone-id"])):l("",!0),u("p",Ee,[u("span",He,a(j(t)),1),u("span",xe,a(t.codeDisplay),1)])])],10,Ne))),128))])),k.value?(s(),o("p",Fe,a(e.$t("voucher.load_failed")),1)):l("",!0),N.value?(s(),o("button",{key:3,type:"button",class:"wc-vouchers__more",disabled:_.value,onClick:G},a(_.value?e.$t("common.loading"):e.$t("voucher.load_more")),9,Oe)):l("",!0)],64)),ve(ee,{voucher:b.value,onClose:r[1]||(r[1]=t=>b.value=null)},null,8,["voucher"])])]),_:1},8,["header-title"])}}}),kt=pe(Ke,[["__scopeId","data-v-83135fc6"]]);export{kt 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.