1import{ab as X,cX as W,cY as z,cM as H,j as e,cK as V}from"./dashboard-CqpNaWIC.js";import{a as Y,r as o}from"./react-vendor-BwQoNBTn.js";import{E as Z,l as ee,u as te,a as se,P as le}from"./react-stripe.esm-B7sitzw4.js";import"./ui-vendor-C9OEygMn.js";const re=ee("pk_test_51SuLBA2N1ub58wfBKmcq3pyGSjkTKOckbx0wgebfESgg7J19Z93q22qlxT4OJBXsVMH3atzmhbQWD1GutJmh9IOX00ORdi6CD5");function ne({clientSecret:C,orderId:g,artistId:F,onSuccess:m,onError:b}){const s=te(),j=se(),[v,x]=o.useState(!1),w=async c=>{if(c.preventDefault(),!(!s||!j)){x(!0);try{const{error:r}=await j.submit();if(r){b(r.message||"Payment form validation failed"),x(!1);return}const{error:d,paymentIntent:i}=await s.confirmPayment({elements:j,clientSecret:C,confirmParams:{return_url:`${window.location.origin}/checkout/confirmation?orderId=${g}`},redirect:"if_required"});d?b(d.message||"Payment failed"):i&&i.status==="succeeded"?m():b("Payment was not completed")}catch(r){b(r instanceof Error?r.message:"An unexpected error occurred")}finally{x(!1)}}};return e.jsxs("form",{onSubmit:w,className:"space-y-4",children:[e.jsx(le,{}),e.jsx("button",{type:"submit",disabled:!s||!j||v,className:"w-full px-6 py-3 bg-[#6d60ff] text-white rounded-lg hover:bg-[#5d50ef] transition-colors text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:v?"Processing...":"Complete Payment"})]})}function me(){var $;const{artistSlug:C}=Y(),[g,F]=o.useState(C||null),[m,b]=o.useState(null),[s,j]=o.useState(null),[v,x]=o.useState(!0),[w,c]=o.useState(null),[r,d]=o.useState("order"),[i,L]=o.useState(null),[O,q]=o.useState(!1),[E,U]=o.useState(!1),[N,R]=o.use
1State(null),[S,B]=o.useState(null),[Q,T]=o.useState(!1),[y,P]=o.useState([]),[I,D]=o.useState(new Set),[l,p]=o.useState({email:"",fullName:"",addressLine1:"",addressLine2:"",city:"",state:"",postalCode:"",country:"US"});o.useEffect(()=>{if(g)return;const t=typeof window<"u"?window.location.hostname:"";if(!t){c("Artist not found"),x(!1);return}const n="fanflowy.co",a=`.${n}`;if(t.endsWith(a)||t===n){c("Artist not found"),x(!1);return}if(t==="localhost"||t==="127.0.0.1"){c("Artist not found"),x(!1);return}X(t).then(u=>{u?(F(u.artistSlug),b(u.artistId)):(c("Artist not found"),x(!1))}).catch(u=>{console.error("Failed to lookup custom domain:",u),c("Artist not found"),x(!1)})},[g]),o.useEffect(()=>{g&&(x(!0),W(g).then(t=>{t?(j(t),t.config.primaryProductId&&P([{productId:t.config.primaryProductId,quantity:1}]),b(t.config.artistId)):c("FanPack not configured")}).catch(t=>{console.error("Failed to load FanPack config:",t),c("Failed to load FanPack page")}).finally(()=>{x(!1)}))},[g]),o.useEffect(()=>{if(!m||!y.length||!l.country||!l.postalCode){L(null);return}(async()=>{try{q(!0);const n=await V(m,{items:y,address:{country:l.country,state:l.state,city:l.city,postalCode:l.postalCode,addressLine1:l.addressLine1}});L(n)}catch(n){console.error("Failed to calculate quote:",n)}finally{q(!1)}})()},[m,y,l.country,l.postalCode,l.state,l.city,l.addressLine1]);const K=(t,n)=>{if(n)P([...y,{productId:t,quantity:1}]),D(new Set([...I,t]));else{P(y.filter(u=>u.productId!==t));const a=new Set(I);a.delete(t),D(a)}},k=()=>{if(r==="order"){if(!l.email||!l.fullName||!l.addressLine1||!l.city||!l.postalCode||!l.country){c("Please fill in all required fields");return}s!=null&&s.config.upsellProductId?d("upsell1"):s!=null&&s.config.upsell2ProductId?d("upsell2"):s!=null&&s.config.upsell3ProductId?d("upsell3"):d("payment")}else r==="upsell1"?s!=null&&s.config.upsell2ProductId?d("upsell2"):s!=null&&s.config.upsell3ProductId?d("upsell3"):d("payment"):r==="upsell2"?s!=null&&s.config.upsell3ProductId?d("upsell3"):d("payment"):r==="upsell3"&&d("payment");c(null)};o.useEffect(()=>{r==="payment"&&!N&&!E&&m&&i&&G()},[r]);const M=()=>{k()},G=async()=>{var t;if(!(!m||!i))try{U(!0),c(null);const n=await z(m,{email:l.email,fullName:l.fullName,addressLine1:l.addressLine1,addressLine2:l.addressLine2||void 0,city:l.city,state:l.state||void 0,postalCode:l.postalCode,country:l.country,shippingCents:i.shippingCents,taxCents:i.taxCents,items:y});R(n.id);try{const a=await H(m,n.id,i.totalCents,"usd");B(a.clientSecret),T(!0)}catch(a){if((t=a.message)!=null&&t.includes("STRIPE_NOT_CONFIGURED"))T(!1),d("confirmation");else throw a}}catch(n){console.error("Failed to place order:",n),c(n instanceof Error?n.message:"Failed to place order")}finally{U(!1)}},J=()=>{d("confirmation")},h=t=>t==null?"$0.00":`$${(t/100).toFixed(2)}`;if(v)return e.jsx("div",{className:"min-h-screen text-white flex items-center justify-center",style:{backgroundColor:"#050509"},children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-r-transparent",style:{borderColor:"#a855f7",borderRightColor:"transparent"}}),e.jsx("p",{className:"mt-4 text-white/60 text-sm",children:"Loading..."})]})});if(w&&!s)return e.jsx("div",{className:"min-h-screen text-white flex items-center justify-center",style:{backgroundColor:"#050509"},children:e.jsxs("div",{className:"text-center px-4",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Error"}),e.jsx("p",{className:"text-white/60",children:w})]})});if(!s||!s.product)return e.jsx("div",{className:"min-h-screen text-white flex items-center justify-center",style:{backgroundColor:"#050509"},children:e.jsxs("div",{className:"text-center px-4",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"FanPack Not Available"}),e.jsx("p",{className:"text-white/60",children:"This FanPack is not configured yet."})]})});const f=r==="upsell1"&&s.config.upsellProductId?s.upsellProducts.find(t=>t.id===s.config.upsellProductId):r==="upsell2"&&s.config.upsell2ProductId?s.upsellProducts.find(t=>
1t.id===s.config.upsell2ProductId):r==="upsell3"&&s.config.upsell3ProductId?s.upsellProducts.find(t=>t.id===s.config.upsell3ProductId):null,_=f?I.has(f.id):!1;return e.jsx("div",{className:"min-h-screen",style:{backgroundColor:"#050509"},children:e.jsxs("div",{className:"container mx-auto px-4 py-12 max-w-4xl",children:[e.jsx("div",{className:"mb-8",children:e.jsx("div",{className:"flex items-center justify-between mb-4",children:["order","upsell1","upsell2","upsell3","payment","confirmation"].map((t,n)=>{const a=t,u=r===a,A=["order","upsell1","upsell2","upsell3","payment","confirmation"].indexOf(r)>n;return a==="order"||a==="payment"||a==="confirmation"||a==="upsell1"&&s.config.upsellProductId||a==="upsell2"&&s.config.upsell2ProductId||a==="upsell3"&&s.config.upsell3ProductId?e.jsxs("div",{className:"flex items-center flex-1",children:[e.jsxs("div",{className:"flex flex-col items-center flex-1",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium ${u?"bg-[#6d60ff] text-white":A?"bg-green-500 text-white":"bg-white/10 text-white/40"}`,children:A?"â":n+1}),e.jsx("span",{className:`text-xs mt-2 ${u?"text-white":"text-white/40"}`,children:a==="order"?"Order":a==="payment"?"Payment":a==="confirmation"?"Done":"Upsell"})]}),n<5&&e.jsx("div",{className:`h-0.5 flex-1 mx-2 ${A?"bg-green-500":"bg-white/10"}`})]},t):null})})}),w&&e.jsx("div",{className:"mb-6 bg-red-500/10 border border-red-500/30 rounded-lg p-4",children:e.jsx("p",{className:"text-red-300 text-sm",children:w})}),r==="order"&&e.jsxs("div",{className:"bg-white/5 border border-white/10 rounded-2xl p-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-white mb-6",children:"Shipping Information"}),e.jsxs("form",{onSubmit:t=>{t.preventDefault(),k()},className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:["Email ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"email",required:!0,value:l.email,onChange:t=>p({...l,email:t.target.value}),className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff]",placeholder:"[email protected]"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:["Full Name ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:l.fullName,onChange:t=>p({...l,fullName:t.target.value}),className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff]",placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:["Address Line 1 ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:l.addressLine1,onChange:t=>p({...l,addressLine1:t.target.value}),className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff]",placeholder:"123 Main St"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"Address Line 2"}),e.jsx("input",{type:"text",value:l.addressLine2,onChange:t=>p({...l,addressLine2:t.target.value}),className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff]",placeholder:"Apt 4"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:["City ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:l.city,onChange:t=>p({...l,city:t.target.value}),className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff]",placeholder:"Boston"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:"State"}),e.jsx("input",{type:"text",value:l.state,onChange:t=>p({...l,state:t.target.value}),className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff]",placeholder:"MA"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:["Postal Code ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",required:!0,value:l.postalCode,onChange:t=>p({...l,postalCode:t.target.value}),className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#6d60ff]",placeholder:"02101"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-300 mb-2",children:["Country ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsxs("select",{required:!0,value:l.country,onChange:t=>p({...l,country:t.target.value}),className:"w-full px-4 py-2 bg-[#0a0a0a] border border-white/10 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-[#6d60ff]",children:[e.jsx("option",{value:"US",children:"United States"}),e.jsx("option",{value:"CA",children:"Canada"}),e.jsx("option",{value:"GB",children:"United Kingdom"}),e.jsx("option",{value:"AU",children:"Australia"})]})]})]}),i&&e.jsxs("div",{className:"mt-6 p-4 bg-white/5 border border-white/10 rounded-lg",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-3",children:"Order Summary"}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between text-white/80",children:[e.jsx("span",{children:"Subtotal"}),e.jsx("span",{children:h((i.manualSubtotalCents||0)+(i.printfulSubtotalCents||0))})]}),e.jsxs("div",{className:"flex justify-between text-white/80",children:[e.jsx("span",{children:"Shipping"}),e.jsx("span",{children:h(i.shippingCents)})]}),e.jsxs("div",{className:"flex justify-between text-white/80",children:[e.jsx("span",{children:"Tax"}),e.jsx("span",{children:h(i.taxCents)})]}),e.jsxs("div",{className:"border-t border-white/10 pt-2 mt-2 flex justify-between text-white font-semibold",children:[e.jsx("span",{children:"Total"}),e.jsx("span",{children:h(i.totalCents)})]})]})]}),e.jsx("button",{type:"submit",disabled:O,className:"w-full px-6 py-3 bg-[#6d60ff] text-white rounded-lg hover:bg-[#5d50ef] transition-colors text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:O?"Calculating...":"Continue to Payment"})]})]}),(r==="upsell1"||r==="upsell2"||r==="upsell3")&&f&&e.jsxs("div",{className:"bg-white/5 border border-white/10 rounded-2xl p-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-white mb-4",children:"Special Offer!"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mb-6",children:[(($=f.images)==null?void 0:$[0])&&e.jsx("img",{src:f.images[0].url,alt:f.name,className:"w-full rounded-lg"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-semibold text-white mb-2",children:f.name}),f.description&&e.jsx("p",{className:"text-white/70 mb-4",children:f.description}),e.jsx("div",{className:"text-2xl font-bold text-[#6d60ff] mb-4",children:h(f.priceCents)})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>{K(f.id,!_),setTimeout(k,300)},className:"flex-1 px-6 py-3 bg-[#6d60ff] text-white rounded-lg hover:bg-[#5d50ef] transition-colors text-sm font-medium",children:_?"Added! Continue":"Add to Order"}),e.jsx("button",{onClick:M,className:"px-6 py-3 bg-white/10 text-white rounded-lg hover:bg-white/20 transition-colors text-sm font-medium",children:"No Thanks"})]})]}),r==="payment"&&e.jsxs("div",{className:"bg-white/5 border border-white/10 rounded-2xl p-8",children:[e.jsx("h2",{className:"text-2xl font-bold text-white mb-6",children:"Payment"}),i&&e.jsxs("div",{className:"mb-6 p-4 bg-white/5 border border-white/10 rounded-lg",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-3",children:"Order Summary"}),e.jsxs("div",{className:"space-y-2 text-sm",children:[y.map(t=>{var a;const n=((a=s.product)==null?void 0:a.id)===t.productId?s.product:s.upsellProducts.find(u=>u.id===t.productId);return n?e.jsxs("div",{className:"flex justify-between text-white/80",children:[e.jsxs("span",{children:[n.name," Ã ",t.quantity]}),e.jsx("span",{children:h((n.priceCents||0)*t.quantity)})]},t.productId):null}),e.jsxs("div",{className:"border-t border-white/10 pt-2 mt-2 space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-white/80",children:[e.jsx("span",{children:"Subtotal"}),e.jsx("span",{children:h((i.manualSubtotalCents||0)+(i.printfulSubtotalCents||0))})]}),e.jsxs("div",{className:"flex justify-between text-white/80",children:[e.jsx("span",{children:"Shipping"}),e.jsx("span",{children:h(i.shippingCents)})]}),e.jsxs("div",{className:"flex justify-between text-white/80",children:[e.jsx("span",{children:"Tax"}),e.jsx("span",{children:h(i.taxCents)})]}),e.jsxs("div",{className:"flex justify-between text-white font-semibold text-lg",children:[e.jsx("span",{children:"Total"}),e.jsx("span",{children:h(i.totalCents)})]})]})]})]}),E?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-r-transparent",style:{borderColor:"#a85
15f7",borderRightColor:"transparent"}}),e.jsx("p",{className:"mt-4 text-white/60 text-sm",children:"Creating order..."})]}):S&&Q&&N&&m?e.jsx(Z,{stripe:re,options:{clientSecret:S,appearance:{theme:"night",variables:{colorPrimary:"#6d60ff",colorBackground:"#0a0a0a",colorText:"#ffffff",colorDanger:"#ef4444",fontFamily:"system-ui, sans-serif",spacingUnit:"4px",borderRadius:"8px"}}},children:e.jsx(ne,{clientSecret:S,orderId:N,artistId:m,onSuccess:J,onError:t=>c(t)})}):e.jsx("div",{className:"mb-6 p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:e.jsx("p",{className:"text-yellow-300 text-sm",children:"Payment processing is not available. Please contact the artist to complete your order."})})]}),r==="confirmation"&&N&&e.jsxs("div",{className:"bg-white/5 border border-white/10 rounded-2xl p-8 text-center",children:[e.jsx("div",{className:"text-6xl mb-4",children:"â"}),e.jsx("h2",{className:"text-3xl font-bold text-white mb-4",children:"Order Confirmed!"}),s.config.confirmationCopy&&e.jsx("p",{className:"text-white/80 text-lg mb-6",children:s.config.confirmationCopy}),e.jsxs("p",{className:"text-white/60 mb-4",children:["Order #",N.slice(-8)]}),e.jsx("p",{className:"text-white/60",children:"Check your email for order confirmation and tracking information."})]})]})})}export{me 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.