1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/flipbookPreview_BFShCqeT.js","assets/pdf_Mnd01EoD.js"])))=>i.map(i=>d[i]); 2import{u as H,_ as ne,a_ as q,aT as le,j as ce,aU as de,an as ue,V as pe,aH as me,aI as he}from"./index_SWRF64zM.js";import{k as we,f as fe,r as l,j as t}from"./vendor-react_DA5Tp51z.js";import{O as ve,Q as ge,K as V,u as xe,I as Pe}from"./BookOpenIcon_BwxjCEsZ.js";import{H as be}from"./HeaderBar_BiiWrVkJ.js";import{u as ke,a as je,R as W}from"./useFastPreviewPages_CXZqVaHI.js";import{b as ye}from"./usePhotobook_BU94sF-A.js";import{u as Ne}from"./useOwnChildren_CtUg_Ujo.js";import{u as Ee}from"./useCheckoutDiscountSuggestions_nKG4kLwl.js";import{v as Y,S as Se,T as Ie}from"./photobookService_BIovPY7n.js";import{F as Ue}from"./pricingService_bRpNHVnQ.js";import{u as Re}from"./usePricing_B2gW-kIY.js";import{E as Fe}from"./eye_BzCNbtvj.js";import{T as Be}from"./tag_BewKjcGj.js";import{C as Te}from"./clock_BwamcZrs.js";import"./vendor-supabase_peh8412e.js";import"./vendor-sentry_ionc-ycS.js";import"./vendor-motion_Cx3YYs0B.js";import"./designTokens_NOlPXS3W.js";import"./calendarSpec_B1lIx289.js";import"./dateOnly_BEk_jueR.js";/* empty css */(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};s.SENTRY_RELEASE={id:"1.37"};var i=new s.Error().stack;i&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[i]="0d261d44-848d-4fbe-b9c1-62217f83cbf4",s._sentryDebugIdIdentifier="sentry-dbid-0d261d44-848d-4fbe-b9c1-62217f83cbf4")}catch{}})();const Ce=s=>{if(!s)return[];const i=new Set,r=[],e=o=>{const c=o.id||o.cfImageId||o.thumbnail||o.url;i.has(c)||(i.add(c),r.push(o))};for(const o of s.sections)if(o.isActive){for(const c of o.pages)for(const u of c.photos)if(e(u),r.length>=10)return r}return r},De=({photo:s,eager:i=!1})=>{const r=(s==null?void 0:s.thumbnail)||(s==null?void 0:s.url)||"",{imageUrl:e}=xe(s,"thumb",r);return!s||!e&&!r?t.jsx("span",{}):t.jsx("img",{src:e||r,alt:"",loading:i?"eager":"lazy",draggable:!1})},_e=({book:s,hasError:i,isDone:r})=>{var g,j,P;const e=s.coverConfig,o=(e==null?void 0:e.layoutStyle)||1,c=o===4||o===5,u=(e==null?void 0:e.imageUrl)||s.coverImage,{imageUrl:d}=V(s,e==null?void 0:e.imageId,u,"lg"),{imageUrl:k}=V(s,e==null?void 0:e.imageId2,c?e==null?void 0:e.imageUrl2:"","lg"),m=`${((e==null?void 0:e.cropX)??.5)*100}% ${((e==null?void 0:e.cropY)??.5)*100}%`,p=`${((e==null?void 0:e.cropX2)??.5)*100}% ${((e==null?void 0:e.cropY2)??.5)*100}%`,h=(e==null?void 0:e.overlayColor)||"#000000",w=(e==null?void 0:e.overlayOpacity)??.1,N=(e==null?void 0:e.title)||s.title,f=(e==null?void 0:e.year)??String(new Date().getFullYear()),E=c?"#1F2937":(e==null?void 0:e.textColor)||"#FFFFFF",U=((g=Se.find(b=>{var x;return b.value===(((x=s.settings)==null?void 0:x.spineColor)||"terracotta")}))==null?void 0:g.hex)||"#EC6437",R=((j=Ie.find(b=>{var x;return b.value===(((x=s.settings)==null?void 0:x.titleStyle)||"modern")}))==null?void 0:j.fontFamily)||"Raleway";return t.jsxs("div",{className:`checkout-preview-book checkout-preview-cover layout-${o} ${r?"is-done":""} ${i?"is-error":""}`,style:{...((P=s.settings)==null?void 0:P.orientation)==="portrait"?{aspectRatio:"297 / 420",width:"min(140px, 54%)"}:{},"--cover-text-color":E,"--cover-overlay-color":h,"--cover-overlay-opacity":w,"--cover-spine-color":U,"--cover-title-font-family":`"${R}", "DM Sans", system-ui, sans-serif`},children:[t.jsx("div",{className:"checkout-preview-cover-spine"}),c?t.jsxs("div",{className:"checkout-preview-cover-two-portraits",children:[t.jsx("div",{className:"checkout-preview-cover-portrait portrait-1",children:d?t.jsx("img",{src:d,alt:"",draggable:!1,style:{objectPosition:m}}):null}),t.jsx("div",{className:"checkout-preview-cover-portrait portrait-2",children:k?t.jsx("img",{src:k,alt:"",draggable:!1,style:{objectPosition:p}}):null})]}):t.jsxs(t.Fragment,{children:[d?t.jsx("img",{className:"checkout-preview-cover-image",src:d,alt:"",draggable:!1,style:{objectPosition:m}}):null,t.jsx("div",{className:"checkout-preview-cover-overlay"})]}),t.jsxs("div",{className:"checkout-preview-cover-copy",children:[t.jsx("span",{className:"checkout-preview-cover-year",children:f}),t.jsx("span",{className:"checkout-preview-cover-title",children:N})]})]})},$e=({book:s,photos:i,percent:r,isDone:e,hasError:o,statusText:c})=>{var m;const u=i.slice(0,8),d=Array.from({length:6},(p,h)=>u[h%Math.max(u.length,1)]),k=e?100:Math.max(8,Math.min(r||18,96));return t.jsxs("div",{className:"checkout-preview-animation-stack",children:[t.jsxs("div",{className:`checkout-preview-animation ${((m=s.settings)==null?void 0:m.orientation)==="portrait"?"is-portrait":""}`,"aria-hidden":"true",children:[t.jsx("div",{className:`checkout-preview-center-glow ${e?"is-done":""} ${o?"is-error":""}`}),t.jsx(_e,{book:s,isDone:e,hasError:o}),!o&&!e&&d.map((p,h)=>t.jsx("div",{className:`checkout-preview-orbit-photo orbit-${h+1}`,style:{"--orbit-delay":`${h*.5}s`},children:t.jsx(De,{photo:p,eager:!0})},`orbit-${h}-${(p==null?void 0:p.id)||"empty"}`)),t.jsx("div",{className:"checkout-preview-shelf",children:t.jsx("div",{className:`checkout-preview-shelf-fill ${o?"is-error":""} ${e?"is-done":""}`,style:{width:`${k}%`}})})]}),c?t.jsx("p",{className:"checkout-preview-animation-status",children:c}):null]})},Me=s=>{const i=Math.max(0,Math.floor(s/1e3)),r=Math.floor(i/86400),e=Math.floor(i%86400/3600),o=Math.floor(i%3600/60),c=i%60;return r>0?`${r}d ${e}u`:[e,o,c].map(u=>u.toString().padStart(2,"0")).join(":")},Oe=({serverNow:s,validUntil:i})=>{const[r,e]=l.useState(()=>{const o=new Date(s).getTime()-Date.now();return new Date(i).getTime()-(Date.now()+o)});return l.useEffect(()=>{const o=new Date(s).getTime()-Date.now(),c=()=>{e(new Date(i).getTime()-(Date.now()+o))};c();const u=window.setInterval(c,1e3);return()=>window.clearInterval(u)},[s,i]),r<=0?null:t.jsx("span",{className:"tabular-nums",children:Me(r)})},Ae=({code:s,description:i,serverNow:r,validUntil:e})=>{const{t:o}=H();return t.jsxs("div",{className:"relative flex items-center gap-3 overflow-hidden border border-[#509B6C]/25 bg-gradient-to-br from-[#FCF6E8] to-[#F6EFD9] p-3 shadow-sm sm:gap-4 sm:p-4",children:[t.jsx("span",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 w-1 bg-[#509B6C]"}),t.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center bg-[#509B6C]/12 text-[#509B6C] sm:h-11 sm:w-11",children:t.jsx(Be,{size:18})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("p",{className:"font-sans text-[11px] font-semibold uppercase tracking-wider text-[#111]/45",children:o("photobook.checkoutBookSelection.previewReview.discount.activeOffer")}),t.jsx("span",{className:"border border-dashed border-[#509B6C]/50 bg-white px-2 py-0.5 font-mono text-sm font-bold tracking-wider text-[#333]",children:s})]}),i?t.jsx("p",{className:"mt-1 font-sans text-xs leading-snug text-[#111]/60",children:i}):null]}),e?t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 self-center border border-[#
2E75E30]/25 bg-[#E75E30]/[0.08] px-2 py-1 font-sans text-[11px] font-semibold uppercase tracking-wide text-[#E75E30]",children:[t.jsx(Te,{size:13}),t.jsx("span",{className:"hidden xs:inline",children:o("photobook.checkoutBookSelection.previewReview.discount.endsIn")}),t.jsx(Oe,{serverNow:r,validUntil:e})]}):null]})},Le=s=>!pe.isNativePlatform()||!s.previewPdfUrl,dt=()=>{const{storybookId:s}=we(),i=fe(),{t:r}=H(),{data:e,isLoading:o}=ye(s||"");ke(!!e);const[c,u]=l.useState(!1),[d,k]=l.useState(!1),{pages:m,progress:p,failed:h}=je(d?null:e);l.useEffect(()=>{h&&k(!0)},[h]);const[w,N]=l.useState(null),[f,E]=l.useState(null),[U,R]=l.useState(null),g=l.useRef(null),[j,P]=l.useState(null),[b,x]=l.useState(!1),[y,D]=l.useState(null),v=l.useRef(0),G=l.useMemo(()=>Ce(e),[e]),_=e?Y(e.sections)+Ue:null,{children:X}=Ne(),K=!!(e!=null&&e.childId)&&X.some(n=>n.id===e.childId&&!n.is_shared),Q=e?Y(e.sections):0,$=()=>{u(!1),K&&s&&Q>=me&&he({milestoneId:`photobook_preview:${s}`,trigger:"photobook_preview"})},J=Re(_??24),Z=_?Math.round(J.classic.price*100):null,{suggestions:M}=Ee(Z,{enabled:!!e,limit:3}),O=l.useCallback(()=>{var n;(n=g.current)==null||n.dispose(),g.current=null,R(null)},[]),ee=b&&j!==null?r("photobook.checkoutBookSelection.previewReview.preparingFlipbook",{progress:Math.round(j*100)}):b&&(f!=null&&f.totalPages)?r("photobook.preview.processingPage",{current:Math.max(1,f.currentPage),total:f.totalPages}):b?r("photobook.checkoutBookSelection.previewReview.generatingSubtext"):null,F=l.useMemo(()=>e?e.sections.reduce((n,a)=>a.isActive?n+a.pages.length:n,0):0,[e]),te=!d&&!!e&&!m?p>=.5&&F>0?r("photobook.preview.processingPage",{current:Math.min(F,Math.max(1,Math.ceil((p-.5)*2*F))),total:F}):r("photobook.checkoutBookSelection.previewReview.preparingFlipbook",{progress:Math.round(p*100)}):null,C=l.useCallback(async()=>{if(!s)return;const n=++v.current;x(!0),D(null),N(null),E(null),P(null),O();try{let a=await ve(s,"classic",e!=null&&e.id&&e.id!=="new"?e.id:void 0);if(n!==v.current)return;for(E(a);a.status==="queued"||a.status==="processing";){if(await new Promise(I=>setTimeout(I,1500)),n!==v.current||(a=await ge(a.id),n!==v.current))return;E(a)}if(a.status==="failed")throw new Error(a.errorMessage||"Preview generation failed");if(!a.previewPdfUrl&&(!a.coverUrl||!a.innerPagesUrl))throw new Error("Preview generation finished without preview URLs");if(!a.innerPageCount)throw new Error("Preview generation finished without page count");const L={coverUrl:a.coverUrl,innerPagesUrl:a.innerPagesUrl,previewPdfUrl:a.previewPdfUrl,innerPageCount:a.innerPageCount};if(!Le(a)){N(L);return}P(0);const{buildFlipbookPages:ae,buildFlipbookPagesFromPdf:oe}=await ne(async()=>{const{buildFlipbookPages:I,buildFlipbookPagesFromPdf:ie}=await import("./flipbookPreview_BFShCqeT.js");return{buildFlipbookPages:I,buildFlipbookPagesFromPdf:ie}},__vite__mapDeps([0,1])),z={maxPageWidth:900,format:"image/jpeg",jpegQuality:.82,onProgress:I=>{n===v.current&&P(I)}},T=a.coverUrl&&a.innerPagesUrl?await ae({coverUrl:a.coverUrl,innerPdfUrl:a.innerPagesUrl,skipInitialInnerPages:1,options:z}):a.previewPdfUrl?await oe({pdfUrl:a.previewPdfUrl,options:z}):null;if(!T)throw new Error("Preview PDF is not available");if(n!==v.current){T.dispose();return}g.current=T,R(T),P(null),N(L)}catch(a){if(n!==v.current)return;D(a instanceof Error?a:new Error("Preview generation failed"))}finally{n===v.current&&x(!1)}},[e==null?void 0:e.id,O,s]),A=l.useCallback(()=>{v.current++},[]);l.useEffect(()=>{if(d)return C(),A},[A,d,C]);const S=d?!!w:!!m;l.useEffect(()=>()=>{var n;(n=g.current)==null||n.dispose(),g.current=null},[]);const B=e!=null&&e.id&&e.id!=="new"?e.id:void 0,se=()=>{i(`/photobook/checkout/${s}${B?`?design=${B}`:""}`)},re=()=>{if(!s){i(-1);return}i(B?`/photobook/editor/${s}/${B}`:`/photobook/editor/${s}`,{replace:!0})};return o?t.jsx("div",{className:"min-h-screen bg-lc-cream flex items-center justify-center",children:t.jsx(q,{className:"h-24 w-24 bg-transparent",size:"md"})}):t.jsxs("div",{className:"min-h-screen bg-lc-cream pb-28",children:[t.jsx(be,{title:r("photobook.checkoutBookSelection.previewReview.pageTitle"),onBack:re}),t.jsxs("main",{className:"max-w-4xl mx-auto px-4 py-6 md:py-10",children:[t.jsxs("section",{className:"grid gap-6 md:grid-cols-[minmax(0,1fr)_300px] md:items-center",children:[t.jsxs("div",{className:"flex flex-col gap-5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("h1",{className:"font-poppins text-xl md:text-2xl font-bold text-[#333] mb-2 flex items-center gap-2",children:[t.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center",children:y?t.jsx(le,{size:20,className:"text-[#E75E30]"}):S?t.jsx(ce,{size:20,className:"text-[#509B6C]",strokeWidth:3}):t.jsx(q,{className:"h-6 w-6 bg-transparent",size:"xs"})}),t.jsx("span",{className:"min-w-0",children:r(y?"photobook.checkoutBookSelection.previewReview.errorTitle":S?"photobook.checkoutBookSelection.previewReview.readyTitle":"photobook.checkoutBookSelection.previewReview.generatingTitle")})]}),t.jsx("p",{className:"font-sans text-sm md:text-base text-[#111]/70 leading-relaxed",children:r("photobook.checkoutBookSelection.previewReview.description")}),t.jsx("p",{className:"font-sans text-sm md:text-base text-[#111]/60 mt-2 leading-relaxed",children:r("photobook.checkoutBookSelection.previewReview.checkInstruction")}),y&&t.jsx("p",{className:"font-sans text-xs text-[#E75E30] mt-3",children:y.message})]}),t.jsx("div",{className:"flex flex-col sm:flex-row gap-2 sm:justify-end",children:y?t.jsxs("button",{type:"button",onClick:C,className:"h-11 px-4 bg-[#E75E30] text-white font-sans font-semibold text-sm flex items-center justify-center gap-2 transition-transform active:scale-[0.98]",children:[t.jsx(de,{size:16}),r("photobook.checkoutBookSelection.previewReview.retry")]}):t.jsxs("button",{type:"button",onClick:()=>u(!0),disabled:!S||!e,className:`h-11 px-4 font-sans font-semibold text-sm flex items-center justify-center gap-2 transition-all ${S&&e?"bg-[#F1914A] text-white hover:scale-[1.02] active:scale-[0.98]":"bg-[#111]/15 text-[#111]/35 cursor-wait"}`,children:[t.jsx(Fe,{size:16}),r("photobook.checkoutBookSelection.previewReview.openPreview")]})})]}),t.jsx($e,{book:e,photos:G,percent:d?j!==null?96:f==null?void 0:f.percent:Math.round(p*100),isDone:S,hasError:!!y,statusText:d?ee:te})]}),M.length>0?t.jsx("section",{className:"mt-6 flex flex-col gap-3",children:M.map(n=>t.jsx(Ae,{code:n.code,description:n.description,serverNow:n.serverNow,validUntil:n.validUntil},n.code))}):null]}),t.jsx("div",{className:"fixed bottom-0 left-0 right-0 bg-[#FCF6E8] border-t border-[#111]/10 p-3 md:p-5 z-20 pb-[calc(0.75rem+env(safe-area-inset-bottom))] md:pb-[calc(1.25rem+env(safe-area-inset-bottom))]",children:t.jsx("div",{className:"max-w-4xl mx-auto flex items-center justify-end",children:t.jsxs("button",{onClick:se,className:"h-12 px-6 md:px-8 font-sans font-medium text-base flex items-center justify-center gap-2 transition-all duration-200 bg-[#F1914A] text-white hover:scale-[1.02] active:scale-[0.98]",children:[r("photobook.checkoutBookSelection.previewReview.continueToBookSelection"),t.jsx(ue,{size:16,className:"rotate-180"})]})})}),c&&!d&&m&&t.jsx(W,{preparedPages:m,innerPageCount:Math.max(0,m.pages.length-2),skipTechnicalOpeningPages:!1,onClose:$}),c&&e&&d&&w&&t.jsx(W,{coverUrl:w.coverUrl,innerPagesUrl:w.innerPagesUrl,previewPdfUrl:U&&w.coverUrl&&w.innerPagesUrl?null:w.previewPdfUrl,innerPageCount:w.innerPageCount,preparedPages:U,skipTechnicalOpeningPages:!0,onClose:$})]})};Pe();export{dt as default}; 3//# sourceMappingURL=CheckoutPreview_KSsgOThd.js.map
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.