(()=>{var e={};e.id=5580,e.ids=[5580],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")},3401:(e,t,n)=>{"use strict";n.r(t),n.d(t,{GlobalError:()=>o.a,__next_app__:()=>h,originalPathname:()=>u,pages:()=>d,routeModule:()=>p,tree:()=>l}),n(12022),n(88242),n(35866);var a=n(23191),s=n(88716),c=n(37922),o=n.n(c),r=n(95231),i={};for(let e in r)0>["default","tree","pages","GlobalError","originalPathname","__next_app__","routeModule"].indexOf(e)&&(i[e]=()=>r[e]);n.d(t,i);let l=["",{children:["connect",{children:["__PAGE__",{},{page:[()=>Promise.resolve().then(n.bind(n,12022)),"/root/ShiftedOffRoad/app/connect/page.tsx"]}]},{}]},{layout:[()=>Promise.resolve().then(n.bind(n,88242)),"/root/ShiftedOffRoad/app/layout.tsx"],"not-found":[()=>Promise.resolve().then(n.t.bind(n,35866,23)),"next/dist/client/components/not-found-error"]}],d=["/root/ShiftedOffRoad/app/connect/page.tsx"],u="/connect/page",h={require:n,loadChunk:()=>Promise.resolve()},p=new a.AppPageRouteModule({definition:{kind:s.x.APP_PAGE,page:"/connect/page",pathname:"/connect",bundlePath:"",filename:"",appPaths:[]},userland:{loaderTree:l}})},33728:(e,t,n)=>{Promise.resolve().then(n.bind(n,40092))},99369:(e,t,n)=>{Promise.resolve().then(n.bind(n,6844))},90486:(e,t,n)=>{Promise.resolve().then(n.t.bind(n,12994,23)),Promise.resolve().then(n.t.bind(n,96114,23)),Promise.resolve().then(n.t.bind(n,9727,23)),Promise.resolve().then(n.t.bind(n,79671,23)),Promise.resolve().then(n.t.bind(n,41868,23)),Promise.resolve().then(n.t.bind(n,84759,23))},40092:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>i});var a=n(10326),s=n(17577),c=n(35047),o=n(77109);function r(){let[e,t]=(0,s.useState)("Shifted Offroad"),[n,r]=(0,s.useState)(""),[i,l]=(0,s.useState)(""),[d,u]=(0,s.useState)("storeshifted"),[h,p]=(0,s.useState)(null),[m,f]=(0,s.useState)(!1),[x,j]=(0,s.useState)(""),[g,b]=(0,s.useState)(""),[v,y]=(0,s.useState)(""),[S,P]=(0,s.useState)("4999"),[N,C]=(0,s.useState)("usd");(0,c.useSearchParams)();let{data:w,status:O}=(0,o.useSession)(),k="authenticated"===O,_=(0,s.useMemo)(()=>d?`/storefront/${d}`:"",[d]);async function T(){if(!k){j("Please sign in first.");return}j(""),f(!0);try{let t=await fetch("/api/connect/account/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:e,contactEmail:n,slug:d})}),a=await t.json();if(!t.ok)throw Error(a.error||"Failed to create account");l(a.accountId),j("Connected account created.")}catch(e){j(e.message||"Failed to create account.")}finally{f(!1)}}async function F(){if(i){j(""),f(!0);try{let e=await fetch(`/api/connect/account/status?accountId=${i}`),t=await e.json();if(!e.ok)throw Error(t.error||"Failed to fetch status");p(t)}catch(e){j(e.message||"Failed to fetch status.")}finally{f(!1)}}}async function R(){if(i){j(""),f(!0);try{let e=await fetch("/api/connect/account/link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accountId:i})}),t=await e.json();if(!e.ok)throw Error(t.error||"Failed to create account link");window.location.href=t.url}catch(e){j(e.message||"Failed to start onboarding.")}finally{f(!1)}}}async function E(){if(i){j(""),f(!0);try{let e=await fetch("/api/connect/products/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accountId:i,name:g,description:v,priceInCents:Number(S),currency:N})}),t=await e.json();if(!e.ok)throw Error(t.error||"Failed to create product");j(`Product created: ${t.productId}`)}catch(e){j(e.message||"Failed to create product.")}finally{f(!1)}}}async function q(){if(i){j(""),f(!0);try{let e=await fetch("/api/connect/subscription/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accountId:i})}),t=await e.json();if(!e.ok)throw Error(t.error||"Failed to create subscription");window.location.href=t.url}catch(e){j(e.message||"Failed to create subscription.")}finally{f(!1)}}}async function A(){if(i){j(""),f(!0);try{let e=await fetch("/api/connect/subscription/portal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({accountId:i})}),t=await e.json();if(!e.ok)throw Error(t.error||"Failed to create portal session");window.location.href=t.url}catch(e){j(e.message||"Failed to open billing portal.")}finally{f(!1)}}}return a.jsx("main",{className:"connect-page",children:a.jsx("section",{className:"section",children:(0,a.jsxs)("div",{className:"container connect-page__inner",children:[a.jsx("h1",{className:"page-title",children:"Stripe Connect Demo"}),a.jsx("p",{className:"connect-page__subtitle",children:"This demo onboards connected accounts, creates products on their account, and provides a storefront for customers to purchase."}),(0,a.jsxs)("div",{className:"connect-card",children:[a.jsx("h2",{children:"Account Access"}),k?(0,a.jsxs)("div",{className:"connect-actions",children:[(0,a.jsxs)("div",{className:"connect-muted",children:["Signed in as ",w.user.email]}),a.jsx("button",{className:"btn btn--ghost",onClick:()=>(0,o.signOut)(),children:"Sign out"})]}):(0,a.jsxs)("div",{className:"connect-actions",children:[a.jsx("div",{className:"connect-muted",children:"Sign in to create an account."}),a.jsx("button",{className:"btn",onClick:()=>(0,o.signIn)(),children:"Sign in"})]})]}),(0,a.jsxs)("div",{className:"connect-card",children:[a.jsx("h2",{children:"Create Connected Account"}),(0,a.jsxs)("div",{className:"connect-form",children:[a.jsx("input",{value:e,onChange:e=>t(e.target.value),placeholder:"Display name"}),a.jsx("input",{value:n,onChange:e=>r(e.target.value),placeholder:"Contact email"}),a.jsx("input",{value:d,onChange:e=>u(e.target.value),placeholder:"Store slug (e.g. storeshifted)"}),a.jsx("button",{className:"btn",onClick:T,disabled:m,children:"Create Account"})]}),i?(0,a.jsxs)("div",{className:"connect-muted",children:["Connected account: ",i]}):null]}),(0,a.jsxs)("div",{className:"connect-card",children:[a.jsx("h2",{children:"Onboard to Collect Payments"}),(0,a.jsxs)("div",{className:"connect-actions",children:[a.jsx("button",{className:"btn",onClick:R,disabled:m,children:"Onboard to collect payments"}),a.jsx("button",{className:"btn",onClick:F,disabled:m,children:"Refresh status"})]}),h?(0,a.jsxs)("div",{className:"connect-status",children:[(0,a.jsxs)("div",{children:["Ready to process payments: ",String(h.readyToProcessPayments)]}),(0,a.jsxs)("div",{children:["Onboarding complete: ",String(h.onboardingComplete)]}),(0,a.jsxs)("div",{children:["Requirements status: ",h.requirementsStatus||"unknown"]})]}):null]}),(0,a.jsxs)("div",{className:"connect-card",children:[a.jsx("h2",{children:"Create Product on Connected Account"}),(0,a.jsxs)("div",{className:"connect-form",children:[a.jsx("input",{value:g,onChange:e=>b(e.target.value),placeholder:"Product name"}),a.jsx("input",{value:v,onChange:e=>y(e.target.value),placeholder:"Description"}),a.jsx("input",{value:S,onChange:e=>P(e.target.value),placeholder:"Price in cents"}),a.jsx("input",{value:N,onChange:e=>C(e.target.value),placeholder:"Currency (usd)"}),a.jsx("button",{className:"btn",onClick:E,disabled:m,children:"Create Product"})]})]}),(0,a.jsxs)("div",{className:"connect-card",children:[a.jsx("h2",{children:"Storefront"}),a.jsx("p",{className:"connect-muted",children:"This demo uses the connected account ID in the URL. Replace this with your own identifier in production."}),a.jsx("div",{className:"connect-actions",children:a.jsx("a",{className:"btn",href:_||"#",children:"Open Storefront"})})]}),(0,a.jsxs)("div",{className:"connect-card",children:[a.jsx("h2",{children:"Subscription (Platform Billing)"}),a.jsx("p",{className:"connect-muted",children:"Creates a hosted subscription checkout session and a billing portal for the connected account."}),(0,a.jsxs)("div",{className:"connect-actions",children:[a.jsx("button",{className:"btn",onClick:q,disabled:m,children:"Subscribe"}),a.jsx("button",{className:"btn",onClick:A,disabled:m,children:"Open Billing Portal"})]})]}),x?a.jsx("div",{className:"connect-message",children:x}):null]})})})}function i(){return a.jsx(s.Suspense,{fallback:null,children:a.jsx(r,{})})}},6844:(e,t,n)=>{"use strict";n.d(t,{default:()=>c});var a=n(10326),s=n(77109);function c({children:e}){return a.jsx(s.SessionProvider,{children:e})}},35047:(e,t,n)=>{"use strict";var a=n(77389);n.o(a,"useSearchParams")&&n.d(t,{useSearchParams:function(){return a.useSearchParams}})},12022:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>a});let a=(0,n(68570).createProxy)(String.raw`/root/ShiftedOffRoad/app/connect/page.tsx#default`)},88242:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>o,metadata:()=>c});var a=n(19510);n(7633);let s=(0,n(68570).createProxy)(String.raw`/root/ShiftedOffRoad/components/Providers.tsx#default`),c={title:"ShiftedFDev",description:"Next.js app"};function o({children:e}){return a.jsx("html",{lang:"en",children:a.jsx("body",{children:a.jsx(s,{children:e})})})}},7633:()=>{}};var t=require("../../webpack-runtime.js");t.C(e);var n=e=>t(t.s=e),a=t.X(0,[9276,1159],()=>n(3401));module.exports=a})();