(()=>{var e={};e.id=2131,e.ids=[2131],e.modules={72934:e=>{"use strict";e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{"use strict";e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{"use strict";e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},20399:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},33217:(e,t,r)=>{"use strict";r.r(t),r.d(t,{GlobalError:()=>i.a,__next_app__:()=>p,originalPathname:()=>u,pages:()=>l,routeModule:()=>h,tree:()=>d}),r(46656),r(88242),r(35866);var n=r(23191),o=r(88716),s=r(37922),i=r.n(s),a=r(95231),c={};for(let e in a)0>["default","tree","pages","GlobalError","originalPathname","__next_app__","routeModule"].indexOf(e)&&(c[e]=()=>a[e]);r.d(t,c);let d=["",{children:["storefront",{children:["[accountId]",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(r.bind(r,46656)),"/root/ShiftedOffRoad/app/storefront/[accountId]/page.tsx"]}]},{}]},{}]},{layout:[()=>Promise.resolve().then(r.bind(r,88242)),"/root/ShiftedOffRoad/app/layout.tsx"],"not-found":[()=>Promise.resolve().then(r.t.bind(r,35866,23)),"next/dist/client/components/not-found-error"]}],l=["/root/ShiftedOffRoad/app/storefront/[accountId]/page.tsx"],u="/storefront/[accountId]/page",p={require:r,loadChunk:()=>Promise.resolve()},h=new n.AppPageRouteModule({definition:{kind:o.x.APP_PAGE,page:"/storefront/[accountId]/page",pathname:"/storefront/[accountId]",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:d}})},13233:(e,t,r)=>{Promise.resolve().then(r.bind(r,17488))},99369:(e,t,r)=>{Promise.resolve().then(r.bind(r,6844))},90486:(e,t,r)=>{Promise.resolve().then(r.t.bind(r,12994,23)),Promise.resolve().then(r.t.bind(r,96114,23)),Promise.resolve().then(r.t.bind(r,9727,23)),Promise.resolve().then(r.t.bind(r,79671,23)),Promise.resolve().then(r.t.bind(r,41868,23)),Promise.resolve().then(r.t.bind(r,84759,23))},17488:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>s});var n=r(10326),o=r(17577);function s({params:e}){let{accountId:t}=e,[r,s]=(0,o.useState)([]),[i,a]=(0,o.useState)(!1),[c,d]=(0,o.useState)(""),[l,u]=(0,o.useState)("");async function p(e){if(!e.unitAmount||!e.currency||!l){d("Product is missing a price.");return}a(!0),d("");try{let t=await fetch("/api/connect/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accountId:l,name:e.name,description:e.description,unitAmount:e.unitAmount,currency:e.currency,quantity:1})}),r=await t.json();if(!t.ok)throw Error(r.error||"Failed to start checkout");window.location.href=r.url}catch(e){d(e.message||"Checkout failed.")}finally{a(!1)}}async function h(e){if(!e.unitAmount||!e.currency||!e.stripePriceId){d("Product is missing a price.");return}a(!0),d("");try{let r=await fetch("/api/cart/add",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:t,productId:e.id,priceId:e.stripePriceId,name:e.name,unitAmount:e.unitAmount,currency:e.currency,quantity:1})}),n=await r.json();if(!r.ok)throw Error(n.error||"Failed to add to cart");d("Added to cart.")}catch(e){d(e.message||"Failed to add to cart.")}finally{a(!1)}}return n.jsx("main",{className:"storefront-page",children:n.jsx("section",{className:"section",children:(0,n.jsxs)("div",{className:"container storefront-page__inner",children:[n.jsx("h1",{className:"page-title",children:"Storefront"}),(0,n.jsxs)("p",{className:"storefront-muted",children:["Store: ",t," (mapped to a connected account)"]}),c?n.jsx("div",{className:"connect-message",children:c}):null,(0,n.jsxs)("div",{className:"storefront-grid",children:[r.map(e=>(0,n.jsxs)("div",{className:"storefront-card",children:[n.jsx("h3",{children:e.name}),n.jsx("p",{children:e.description||"No description provided."}),n.jsx("div",{className:"storefront-price",children:e.unitAmount?`${(e.unitAmount/100).toFixed(2)} ${e.currency?.toUpperCase()||"USD"}`:"No price"}),(0,n.jsxs)("div",{className:"storefront-actions",children:[n.jsx("button",{className:"btn",onClick:()=>p(e),disabled:i,children:"Buy now (Checkout)"}),n.jsx("a",{className:"btn btn--ghost",href:`/storefront/${t}/pay?productId=${e.id}`,children:"Pay with card"}),n.jsx("button",{className:"btn btn--ghost",onClick:()=>h(e),disabled:i,children:"Add to cart"}),n.jsx("a",{className:"btn btn--ghost",href:"/cart",children:"View cart"})]})]},e.id)),r.length||i?null:n.jsx("div",{className:"storefront-muted",children:"No products yet."})]})]})})})}},6844:(e,t,r)=>{"use strict";r.d(t,{default:()=>s});var n=r(10326),o=r(77109);function s({children:e}){return n.jsx(o.SessionProvider,{children:e})}},88242:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>i,metadata:()=>s});var n=r(19510);r(7633);let o=(0,r(68570).createProxy)(String.raw`/root/ShiftedOffRoad/components/Providers.tsx#default`),s={title:"ShiftedFDev",description:"Next.js app"};function i({children:e}){return n.jsx("html",{lang:"en",children:n.jsx("body",{children:n.jsx(o,{children:e})})})}},46656:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>n});let n=(0,r(68570).createProxy)(String.raw`/root/ShiftedOffRoad/app/storefront/[accountId]/page.tsx#default`)},7633:()=>{}};var t=require("../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),n=t.X(0,[9276,1159],()=>r(33217));module.exports=n})();