1import{j as e,a1 as $,r as h,a2 as E,l as j,a3 as z,o as _,a4 as K,a5 as Q,D as L,p as X,q as Z,s as G,t as J,a6 as ee}from"./vendor-ui-Ba-ouzjt.js";import{h as k,u as v,O as se,B as y,Q as O,a as T,U as te,V as P,W as F,X as re,Y as ae,w as g,b,r as le,Z as oe,_ as ne,$ as ie,a0 as ce,a1 as de,a2 as A,a3 as U,T as me,a4 as I,d as fe,I as ue,a5 as pe,a6 as xe}from"./index-BP85Yjle.js";import{B as w}from"./Bubble-CvIEMx4I.js";import{u as he}from"./useArts--Apnoaaz.js";import{L as be}from"./index-Dx_n99cn.js";import{A as ge}from"./Artwork-Dbzj8H49.js";import{S as je,P as ve}from"./StoreIcon-JkGZH7su.js";import{u as ye}from"./useSuspenseQuery-D53SB-kM.js";import{M as Ne,P as we}from"./ProfileDetails-D3fLdZhg.js";import{u as ke}from"./useEvents-CQLEYTbH.js";import{P as Ee}from"./PostBookPurchaseSurvey-B0nFYSZn.js";import"./vendor-react-CWc6w16D.js";import"./vendor-utils-cJ19xB3v.js";import"./useCurrentLanguage-CARayGiE.js";import"./image-assets-helper-DirV3Ez-.js";import"./MyInfoButtonIcon-BwqJrxIP.js";const D=()=>{const{isMobile:s}=k(),{t:r}=v(),t=se(),o={className:"text-small text-800 font-normal bg-white rounded-lg data-[hover=true]:bg-primary-50 px-[1rem] py-[0.5rem] flex-shrink-0",buttonType:"primary",size:s?"md":"lg",role:"button"};return e.jsx("div",{className:"bg-primary-10 w-full md:mt-[1.5rem]",children:e.jsx($,{orientation:"horizontal",hideScrollBar:!0,className:"relative overflow-x-auto scroll-smooth flex-grow w-full",children:e.jsxs("div",{className:"flex bg-primary-10 gap-[1rem] md:gap-[1.5rem] px-[1rem] py-[0.5rem] md:py-[1rem] items-center md:border-1 md:border-default-300 md:rounded w-full",children:[e.jsx("span",{className:"text-small flex-shrink-0",children:r("profile.discover.discover")}),e.jsxs("div",{className:"flex gap-[1rem]",children:[h.createElement(y,{...o,key:"discover-events-button",startContent:e.jsx(O,{className:"text-primary size-[1.5rem] md:size-[1.875rem]"}),onPress:()=>t({to:"/events"}),"aria-label":r("profile.discover.eventsCta")},r("profile.discover.eventsCta")),h.createElement(y,{...o,key:"discover-bookstores-button",startContent:e.jsx(je,{className:"text-primary size-[1.5rem] md:size-[1.875rem]"}),onPress:()=>t({to:"/bookstores"}),"aria-label":r("profile.discover.bookstoresCta")},r("profile.discover.bookstoresCta"))]})]})})})},Te=()=>{const[s,r]=h.useState(!1),[t,o]=h.useState(null),{t:l}=v(),{user:n,updateUser:m}=T(),d=F(),{isMobile:f}=k(),{refetch:p,data:i,isFetching:c}=ye(ae({queryKey:["users","myInfo"],queryFn:()=>P.getCurrentUserInfo(),enabled:!1,refetchOnWindowFocus:!1})),u=()=>{window.scroll({top:0,behavior:"instant"})},a=te({mutationKey:["users","updateProfile"],mutationFn:P.updateUser,onSuccess:N=>{d.success(l("profile.profileData.updateSuccessMessage")),r(!1),m(N.data.data),u()},onError:()=>{d.error(l("profile.profileData.errorMessage")),u()}}),x=()=>{g.clickEvent(b.EditProfile,s?"Close":"Edit"),r(!s),s&&t&&o(null)},q=()=>{g.clickEvent(b.EditProfile,"View Singpass Myinfo FAQ")},H=async()=>{g.clickEvent(b.EditProfile,"Retrieve Myinfo with Singpass");const{isFetched:N,isError:C}=await p();N&&!C?(d.success(l("profile.profileData.fetchSuccessMessage")),i&&o({name:i.name,otherDetails:{sex:i.sex,race:i.race,email:i.email,address:i.address,foreignAddress:i.foreignAddress}})):C&&d.error(l("profile.profileData.fetchErrorMessage"))},V=()=>{g.clickEvent(b.EditProfile,"Save changes"),a.mutate({}),o(null)},Y=()=>{g.clickEvent(b.EditProfile,"Cancel"),r(!1),o(null),u()},W=()=>{const N=t||n;return N?e.jsx(we,{userData:N}):null};return e.jsx(E,{className:j("p-[1rem] md:p-[1.5rem] !pt-0 border rounded border-default-300 relative",{"border-primary":s}),shadow:"none",children:e.jsxs(z,{className:"flex flex-col p-0 gap-[1rem] overflow-x-hidden text-800",children:[e.jsxs("div",{className:"flex justify-between mt-[1rem] md:mt-[1.875rem] -mb-[0.5rem] md:mb-0",children:[e.jsx("h3",{className:"text-h3 self-center",children:l("profile.profileData.personalDetails")}),e.jsx(y,{isIconOnly:!0,buttonType:"text","aria-label":s?"Close":"Edit",className:"p-0 min-w-[1.5rem] size-[1.5rem] md:min-w-[2.5rem] md:size-[2.5rem]",onPress:x,children:s?e.jsx(re,{className:"md:size-[1.875rem]"}):e.jsx(ve,{className:"md:size-[1.875rem]"})})]}),s&&e.jsx(Ne,{onClickRetrieve:H,loading:c,onViewFaqClick:q}),W(),s&&e.jsxs("div",{className:"flex flex-col-reverse md:flex-row w-full md:w-fit gap-2 md:gap-4 mt-4 md:mt-8",children:[e.jsx(y,{size:"xl",width:f?"full":"fixed",buttonType:"secondary",onPress:Y,children:l("profile.profileData.cancelButton")}),e.jsx(y,{size:"xl",width:f?"full":"fixed",isDisabled:c||!t,isLoading:a.isPending,onPress:V,children:l("profile.profileData.saveButton")})]})]})})},Ce=({current:s="profile",onChange:r})=>{const{t}=v();return e.jsxs("div",{className:"flex w-full list-none mt-[0.5rem] lg:flex-col lg:gap-[1.5rem] lg:w-[10rem] lg:mt-[1.25rem] lg:h-fit",role:"tablist",children:[e.jsx(S,{id:"tab-profile","aria-controls":"tabpanel-profile",isActive:s==="profile",tabIndex:s==="profile"?0:-1,onClick:()=>{g.clickEvent(b.ProfileSection,"Profile"),r&&r("profile")},children:t("profile.tabs.profile")},"profile"),e.jsx(S,{id:"tab-transactions","aria-controls":"tabpanel-transactions",isActive:s==="transactions",tabIndex:s==="transactions"?0:-1,onClick:()=>{g.clickEvent(b.ProfileSection,"Transaction History"),r&&r("transactions")},children:t("profile.tabs.transactions")},"transactions")]})},S=({children:s,isActive:r,className:t,...o}
1)=>e.jsxs("div",{className:"flex-1",children:[e.jsxs("button",{type:"button",role:"tab","aria-selected":r,className:j("group text-800 text-large font-normal flex flex-col w-full items-center lg:items-start lg:text-left pt-[0.75rem] lg:pt-0 px-[0.75rem] lg:px-0",{"font-semibold text-h3 text-primary":r},t),...o,children:[s,e.jsx("div",{className:j("w-[3rem] h-[0.25rem] mt-[0.25rem] hidden lg:block","group-hover:bg-skyblue",{"bg-skyblue":r})})]}),e.jsx("div",{className:j("w-full h-[0.25rem] mt-[1rem] lg:hidden",{"bg-skyblue":r})})]}),M=500,Pe=({transaction:s,variant:r})=>{const{t}=v(),{payment:o}=s,l=F(),n=r==="books",m=a=>{switch(a){case"Credits":return t("profile.transactions.credits");case"Card":return t("profile.transactions.creditCard");case"PayNow":return t("profile.transactions.paynow");case"Total":return s.type==="PAYMENT_REFUND"?t("profile.transactions.totalRefunded"):t("profile.transactions.total");default:return t("profile.transactions.others")}},d=()=>{const{payment:a}=s;let x=0;return a!=null&&a.credits&&(x+=a.credits.amountCents),!n&&(a!=null&&a.outOfPocket)&&(x+=a.outOfPocket.amountCents),x},f=async()=>{if(g.clickEvent(b.TransactionHistory,"Copy transaction ID"),s.transactionId)try{await navigator.clipboard.writeText(s.transactionId),setTimeout(()=>l.success(t("action.copyToClipboard.success")),M)}catch{setTimeout(()=>l.error(t("action.copyToClipboard.error")),M)}},p=()=>{const{credits:a,outOfPocket:x}=o||{};return e.jsxs(e.Fragment,{children:[a&&i("Credits",a.amountCents),x&&!n&&i(x.method,x.amountCents),i("Total",d())]})},i=(a,x)=>e.jsxs("div",{className:"flex justify-between gap-[1rem]",children:[e.jsx("p",{className:j("font-semibold text-small",{"text-h4":a==="Total"}),children:m(a)}),e.jsx("p",{className:j("font-light text-small",{"text-base font-normal":a==="Total"}),children:oe.formatCentsToDisplay(x)})]}),c=()=>{let a,x;switch(s.type){case"PAYMENT_CREATE":a=t("profile.transactions.pending"),x="bg-default-300 text-black";break;case"PAYMENT_REFUND":a=t("profile.transactions.refunded"),x="bg-default-500 text-white";break;default:return null}return e.jsx(_,{className:j("rounded self-end text-tiny",x),children:a})},u=()=>e.jsxs("button",{type:"button",className:"flex flex-col min-w-0 w-fit text-left gap-[2px] mt-[0.5rem] min-[390px]:pr-[0.5rem]","aria-label":"Copy to clipboard",onClick:f,children:[e.jsx("span",{className:"text-tiny font-semibold",children:t("profile.transactions.transactionId")}),e.jsxs("div",{className:"flex items-start sm:items-center gap-[0.5rem] w-fit max-w-full min-w-0 relative mr-[1.5rem]",children:[e.jsx("span",{className:"text-small font-normal text-default-500 min-w-0 break-all",children:s.transactionId}),e.jsx(le,{className:"w-[20px] h-[20px] text-primary shrink-0"})]})]});return e.jsxs("div",{className:"flex flex-col gap-[0.5rem]",children:[c(),p(),s.transactionId&&u()]})},R=({transaction:s,items:r,footnote:t,variant:o})=>{const{i18n:l,t:n}=v(),m=()=>ne.formatTransactionItemDate(ie(s.modified),l.language),d=()=>{let f,p;switch(o){case"books":f=e.jsx(ce,{}),p=n("profile.transactions.books");break;case"events":f=e.jsx(O,{}),p=n("profile.transactions.events");break;default:f=null,p=""}return e.jsxs("div",{className:"flex md:gap-[1rem] justify-between",children:[e.jsx("span",{className:"font-light text-small text-default-500",children:m()}),f&&p&&e.jsx(_,{classNames:{base:"bg-primary-10 text-tiny text-800 max-w-auto gap-[0.5rem] px-[1rem] py-[0.5rem]",content:"p-0"},size:"lg",startContent:f,children:p})]})};return e.jsx(E,{className:"p-4 md:p-[1.5rem] border rounded border-default-300 text-800 relative",shadow:"none",children:e.jsxs(z,{className:"flex flex-col p-0 gap-[1rem] md:gap-[1.5rem] overflow-hidden",children:[d(),r,e.jsx(K,{}),e.jsx(Pe,{transaction:s,variant:o}),!!t&&e.jsx("span",{className:"text-small font-normal text-default-500",children:t})]})})},Ie=({transaction:s,showPostBookPurchaseSurvey:r})=>{const t=l=>{const{itemId:n,itemName:m,quantity:d}=l;return e.jsxs("div",{className:"flex gap-[1rem] w-full items-start justify-between text-800",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-small font-medium line-clamp-2",children:m}),e.jsxs("span",{className:"text-tiny text-500",children:["ISBN: ",n]})]}),e.jsxs("span",{className:"text-small font-normal",children:["x",d]})]},n)},o=()=>
1{if(!(s.details&&s.details.length>0))return null;const l=s.details[0],n=`${l.storeName}${l.storeOutletName?` (${l.storeOutletName})`:""}`,m=s.details.map(d=>t(d));return e.jsxs("div",{className:"flex flex-col gap-y-[1rem] md:gap-y-[1.5rem]",children:[r&&e.jsx(Ee,{className:"max-w-full"}),e.jsxs("div",{className:"flex flex-col gap-[0.5rem] md:gap-[1rem] w-full mb-[0.5rem] md:mb-0",children:[e.jsx("span",{className:"text-h4",children:n}),m]})]})};return e.jsx(R,{transaction:s,items:o(),variant:"books"})},De=({transaction:s,eventData:r})=>{var i;const{isMobile:t}=k(),{t:o}=v(),l=s.type==="PAYMENT_COMPLETE",n=(i=s.details)!=null&&i.length?s.details[0].partnerName:o("profile.transactions.partnerPlaceholderLabel"),m=c=>{if(!c)return;const u=r.find(a=>a.eventId===c);return u!=null&&u.images&&u.images.length>0?u.images[0].imageUrl:void 0},d=c=>{const{itemId:u,itemName:a}=c;return e.jsx("div",{className:"flex gap-[1rem] w-full items-center justify-between text-800",children:e.jsxs("div",{className:"flex flex-1 gap-[1rem] items-center",children:[e.jsx(Q,{src:m(u),height:t?40:72,width:t?64:120,classNames:{img:"object-cover rounded-none",wrapper:"bg-default-100 rounded-none shrink-0"},alt:""}),e.jsx("span",{className:"text-small font-semibold line-clamp-2",children:a})]})},u)},f=()=>{if(s.details&&s.details.length>0){const u=de(s.details,a=>a.itemId).map(a=>d(a));return e.jsx("div",{className:"flex flex-col gap-[1.5rem] w-full mb-[0.5rem] md:mb-[1rem]",children:u})}return null},p=h.useMemo(()=>l?o("profile.transactions.ticketDetailsDisclaimer",{tpName:n}):void 0,[n,o,l]);return e.jsx(R,{transaction:s,items:f(),variant:"events",footnote:p})},Se=()=>{const{t:s}=v(),{data:r,isLoading:t}=A(),{data:o,isLoading:l}=ke({includePastEvents:!0}),n=U.useNavigate(),m=i=>{g.clickEvent(b.ExploreMore,"Profile - Find an event"),i.preventDefault(),n({to:"/events"})},d=i=>{i.preventDefault(),n({to:"/bookstores"})},f=r==null?void 0:r.transactions,p=()=>{if(f===null)return null;if(f===void 0||!f.length)return e.jsxs("div",{className:"flex flex-col w-full text-center items-center justify-center font-light h-[19rem] gap-[2rem]",children:[e.jsx("span",{className:"text-base",children:s("profile.transactions.emptyMainTitle")}),e.jsx("p",{className:"text-base",children:e.jsx(me,{i18nKey:"profile.transactions.emptySecondaryTitle",components:[e.jsx("a",{href:"/",onClick:m,className:"text-primary font-semibold cursor-pointer hover:underline hover:underline-offset-4"}),e.jsx("a",{href:"/bookstores",onClick:d,className:"text-primary font-semibold cursor-pointer hover:underline hover:underline-offset-4"})]})})]});let i="";for(let c=f.length-1;c>=0;c--){const u=f[c];if(I.isBookTransaction(u)){i=u.transactionId;break}}return f.map(c=>I.isBookTransaction(c)?e.jsx(Ie,{transaction:c,showPostBookPurchaseSurvey:i===c.transactionId},c.transactionId):e.jsx(De,{transaction:c,eventData:o},c.transactionId))};return e.jsx("div",{className:"flex flex-col gap-[1.5rem]",children:t||l?e.jsx("div",{className:"flex justify-center",children:e.jsx(L,{role:"status"})}):e.jsx(e.Fragment,{children:p()})})},Me=()=>{const[s,r]=h.useState("profile"),t=fe({from:"/_auth/profile"}),o=U.useNavigate(),{data:l}=he(),n=l.images[1],{isTablet:m,isDesktop:d}=k();h.useEffect(()=>{r(t.current||"profile")},[t.current]),h.useEffect(()=>{window.scroll({top:0,left:0})},[]);const f=c=>{r(c),o({search:{...t,current:c}})},p=()=>e.jsxs("div",{className:"absolute w-full h-full top-0",children:[e.jsx(w,{color:"skyblue",size:"large",className:"hidden xl:block top-0 -left-[2.5rem]"}),e.jsx(w,{color:"lightpink",size:"small",className:"top-[24rem] left-[16rem] lg:left-[1rem] xl:left-[21rem]"}),e.jsx(w,{color:"lightgreen",size:"medium",className:"top-[18rem] right-0"}),e.jsx("div",{className:"hidden xl:block absolute top-[18rem] -left-[2.5rem]",children:e.jsx(ge,{image:n,className:"h-[17.5rem] md:h-[17.5rem]",disableHoverEffect:!0})})]}),i=()=>e.jsxs("div",{className:"absolute w-full h-full top-0",children:[e.jsx(w,{color:"lightpink",size:"small",className:"top-[24rem] left-[8rem]"}),e.jsx(w,{color:"lightgreen",size:"medium",className:"top-[18rem] right-0"})]});return e.jsxs(be.Section,{className:"flex flex-col min-h-[43.75rem] lg:flex-row mb-[1.5rem] lg:mb-[5rem] relative px-0 mt-[
10.25rem] md:mt-[2.5rem] lg:mt-[4rem]",children:[d?p():null,m?i():null,!d&&e.jsxs("div",{className:"lg:hidden",children:[e.jsx(B,{}),e.jsx(D,{})]}),e.jsxs("div",{className:"w-full flex flex-col lg:flex-row gap-[0.5rem] lg:gap-[5rem] z-20",children:[e.jsx("div",{className:"flex lg:justify-end lg:w-[20rem]",children:e.jsx(Ce,{onChange:f,current:s})}),e.jsxs("div",{className:"flex flex-col flex-1 gap-[1.5rem]",children:[d&&e.jsxs("div",{className:"hidden lg:block h-max",children:[e.jsx(B,{}),e.jsx(D,{})]}),e.jsx("div",{id:"tabpanel-profile",role:"tabpanel","aria-labelledby":"tab-profile",hidden:s!=="profile",tabIndex:s==="profile"?0:-1,className:j("px-[0.5rem] sm:px-0",{hidden:s!=="profile"}),children:e.jsx(Te,{})}),e.jsx("div",{id:"tabpanel-transactions",role:"tabpanel","aria-labelledby":"tab-transactions",hidden:s!=="transactions",tabIndex:s==="transactions"?0:-1,className:j("px-[0.5rem] sm:px-0",{hidden:s!=="transactions"}),children:e.jsx(Se,{})})]})]})]})},Be=({isOpen:s,onDismiss:r,onRetry:t})=>{const{t:o}=v(),l=T(n=>n.isLoading);return e.jsx(X,{size:"lg",classNames:{base:"rounded py-[2.5rem] px-[1.5rem] md:px-[2.5rem] text-center m-[1.5rem]",wrapper:"z-modal"},hideCloseButton:!0,placement:"center",isOpen:s,children:e.jsxs(Z,{children:[e.jsxs(G,{className:"items-center gap-y-[1.5rem] p-0",children:[e.jsx(ue,{variant:"modalCreditsError",className:"mx-auto md:h-[7.5rem] h-[5rem] text-primary-illust"}),e.jsx("h3",{className:"text-700 text-h3",children:o("error.creditError.title")}),e.jsx("p",{children:o("error.creditError.description")})]}),e.jsxs(J,{className:"flex flex-col-reverse md:flex-row gap-[1rem] p-0 mt-[2.5rem]",children:[e.jsx(y,{size:"xl",buttonType:"secondary",onPress:r,width:"full",isDisabled:l,children:o("error.creditError.dismissButton")}),e.jsx(y,{size:"xl",buttonType:"primary",onPress:t,width:"full",isDisabled:l,children:l?e.jsx(L,{color:"white"}):o("error.creditError.retryButton")})]})]})})},B=()=>{const{hasCreditErrorModalShown:s,isAuthenticated:r,setHasCreditErrorModalShown:t}=T(),o=pe(a=>a.setIsUserMenuOpen),[l,n]=h.useState(!1),{data:m,isError:d,isLoading:f,refetch:p}=A(),i=((m==null?void 0:m.account)===null||d)&&!f;h.useEffect(()=>{i&&r&&!s&&(n(!0),o(!1))},[i,r,s]),h.useEffect(()=>{(m==null?void 0:m.account)!==null&&!d&&n(!1)},[m,d]);const c=()=>{n(!1),t(!0)},u=()=>{p(),t(!0)};return e.jsxs(E,{className:"p-4 md:p-6 md:border md:border-citron rounded-none md:rounded relative",shadow:"none",children:[e.jsx("div",{className:"rounded-full bg-skyblue size-28 absolute -end-6 -top-6"}),e.jsx("div",{className:"rounded-full bg-lightpink size-24 absolute end-[33%] md:end-[38%] -bottom-6"}),e.jsx("div",{className:"rounded-full bg-lightgreen size-16 absolute end-[30%] md:end-[35%] bottom-8"}),e.jsx(ee,{className:"p-0",children:e.jsx(xe,{trackingCategory:b.Profile,trackingLabel:"Profile - Pay in store"})}),l&&e.jsx(Be,{isOpen:l,onDismiss:c,onRetry:u})]})},Xe=()=>e.jsx(Me,{});export{Xe as component};
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.