1import{r as a,a as S,j as e}from"./index-BoTbwFO0.js";import{l as N,g as j}from"./stripeConnect-IWD5d8VV.js";import{C as k,f as E}from"./react-connect.esm-Qzo3GW00.js";import{B as y}from"./BusinessNavigation-DpmoCv2O.js";/* empty css *//* empty css */import"./logout-CVXWdjbX.js";function I(r){const i={"business_profile.mcc":"Business category (Merchant Category Code)","business_profile.url":"Business website URL",business_type:"Business type (individual or company)",external_account:"Bank account information","representative.dob.day":"Representative date of birth (day)","representative.dob.month":"Representative date of birth (month)","representative.dob.year":"Representative date of birth (year)","representative.email":"Representative email address","representative.first_name":"Representative first name","representative.last_name":"Representative last name","settings.payments.statement_descriptor":"Payment statement descriptor","business_profile.name":"Business name","business_profile.product_description":"Product or service description","business_profile.support_email":"Support email address","business_profile.support_phone":"Support phone number","business_profile.support_url":"Support website URL","company.address.city":"Company city","company.address.country":"Company country","company.address.line1":"Company street address","company.address.postal_code":"Company postal code","company.address.state":"Company state","company.name":"Company legal name","company.phone":"Company phone number","company.tax_id":"Company tax ID","individual.address.city":"Individual city","individual.address.country":"Individual country","individual.address.line1":"Individual street address","individual.address.postal_code":"Individual postal code","individual.address.state":"Individual state","individual.dob.day":"Date of birth (day)","individual.dob.month":"Date of birth (month)","individual.dob.year":"Date of birth (year)","individual.email":"Email address","individual.first_name":"First name","individual.last_name":"Last name","individual.phone":"Phone number","individual.ssn_last_4":"Last 4 digits of SSN","tos_acceptance.date":"Terms of service acceptance date","tos_acceptance.ip":"Terms of service acceptance IP address"};return i[r]?i[r]:r.replace(/\./g," ").replace(/_/g," ").replace(/\b\w/g,g=>g.toUpperCase())}function T(){const[r,i]=a.useState(""),[g,w]=a.useState(!0),[p,x]=a.useState(null),[f,_]=a.useState(window.innerWidth<=768),[v,C]=a.useState(()=>window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),d=S();a.useEffect(()=>{const t=()=>{_(window.innerWidth<=768)};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),a.useEffect(()=>{if(!window.matchMedia)return;const t=window.matchMedia("(prefers-color-scheme: dark)"),n=o=>C(o.matches);return t.addEventListener?t.addEventListener("change",n):t.addListener(n),()=>{t.removeEventListener?t.removeEventListener("change",n):t.removeListener(n)}},[]);const[l]=a.useState(()=>{const t=sessionStorage.getItem("business_auth_token");if(!t)return console.warn("No business auth token found"),null;const n=sessionStorage.getItem("merchant_id")||"default_merchant",o="pk_live_51SqnAo5EQK2yXNtMIQ9mT4wfBmJ2EM76E21dztXC5LBOvoXC4sf5Nsapx9wTRz3wP602KwQo5aoL0q52wpNPbgOO00UCRac3yN";console.log("Initializing Stripe Connect with:",{merchantId:n,publishableKey:o.substring(0,20)+"..."});const c=async s=>{try{console.log("[Payouts] Fetching account session for merchant:",n),console.log("[Payouts] Components requested:",s);let u=s;
1(!s||typeof s!="object"||Object.keys(s).length===0)&&(console.warn("[Payouts] Components missing or empty, using default for payouts"),u={payouts:{enabled:!0}});const m=await fetch("/api/connect/account-session",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({merchant_id:n,components:u})});if(m.ok){const h=await m.json();return console.log("Account session created successfully"),i(""),h.client_secret}else{const h=await m.json().catch(()=>({error:"Unknown error"})),b=h.error||"Failed to create account session";if(console.error("Account session error:",b,m.status),m.status===404||h.requires_onboarding){console.log("Account not found, redirecting to onboarding..."),d("/business/connect/onboarding");return}i(b);return}}catch(u){console.error("Exception fetching account session:",u),i(u.message||"Failed to create account session");return}};try{const s=N({publishableKey:o,fetchClientSecret:c,appearance:j(v)});return console.log("Stripe Connect instance created"),s}catch(s){return console.error("Failed to initialize Connect:",s),i("Failed to initialize Stripe Connect"),null}});return a.useEffect(()=>{!l||typeof l.update!="function"||l.update({appearance:j(v)})},[l,v]),a.useEffect(()=>{(async()=>{const n=sessionStorage.getItem("business_auth_token");if(!n){d("/business-login");return}try{const o=sessionStorage.getItem("merchant_id")||"default_merchant",c=await fetch(`/api/connect/account-status/${o}`,{headers:{Authorization:`Bearer ${n}`}});if(c.ok){const s=await c.json();x(s)}else if(c.status===404)console.log("Account status not found, will be created on first use"),x(null);else if(c.status===429){console.warn("Rate limited when checking account status, continuing...");const s=await c.json().catch(()=>null);s&&x(s)}}catch(o){console.error("Error checking account status:",o),i(o.message||"Failed to check account status")}finally{w(!1)}})()},[d]),g?e.jsxs("div",{children:[e.jsx(y,{}),e.jsx("div",{className:"payments-activity-page",children:e.jsx("div",{className:"loading-state",children:"Loading payment information..."})})]}):r?e.jsxs("div",{children:[e.jsx(y,{}),e.jsx("div",{className:"payments-activity-page",children:e.jsx("div",{className:"payments-activity-container",style:{maxWidth:"800px"},children:e.jsxs("div",{className:"dashboard-card",children:[e.jsx("h1",{children:"Error"}),e.jsx("div",{style:{color:"#ef4444",marginBottom:"24px"},children:r}),e.jsxs("button",{className:"btn-primary-obsidian",onClick:()=>d("/business/connect/onboarding"),children:[e.jsx("span",{className:"btn-icon",children:"+"}),e.jsx("span",{children:"Set Up Payment Account"})]})]})})})]}):p&&!p.charges_enabled?e.jsxs("div",{children:[e.jsx(y,{}),e.jsx("div",{className:"payments-activity-page",children:e.jsx("div",{className:"payments-activity-container",style:{maxWidth:"800px"},children:e.jsxs("div",{className:"dashboard-card",children:[e.jsx("h1",{children:"Payment Account Setup Required"}),e.jsx("p",{style:{marginBottom:"24px",color:"var(--color-slate-500)"},children:"You need to complete your Stripe account setup before you can view payouts."}),p.currently_due&&p.currently_due.length>0&&e.jsxs("div",{style:{background:"#fef3c7",padding:"16px",borderRadius:"8px",marginBottom:"24px"},children:[e.jsx("p",{style:{margin:0,fontWeight:"600",color:"#92400e",marginBottom:"8px"},children:"To complete your account setup, please provide:"}),e.jsx("ul",{style:{marginTop:"8px",marginBottom:0,color:"#92400e",paddingLeft:"20px"},children:p.currently_due.map((t,n)=>e.jsx("li",{style:{marginBottom:"4px"},children:I(t)},n))})]}),e.jsxs("button",{className:"btn-primary-obsidian",onClick:()=>d("/business/connect/onboarding"),children:[e.jsx("span",{className:"btn-icon",children:"+"}),e.jsx("span",{children:"Complete Account Setup"})]})]})})})]}):e.jsxs("div",{children:[e.jsx(y,{}),e.jsx("div",{className:"payments-activity-page",style:{padding:f?"16px 0":void 0},children:e.jsxs("div",{className:"payments-activity-container",style:{padding:f?"0 16px":void 0},children:[e.jsxs("div",{className:"payments-header",style:{padding:f?"0 8px":void 0},children:[e.jsx("h1",{className:"payments-title",children:"Payouts"}),e.jsx("p",{className:"payments-description",children:"View your transactions and payout information."})]}),!1,r?e.jsxs("div",{className:"dashboard-card",style:{maxWidth:"800px"}
1,children:[e.jsx("h2",{style:{color:"#ef4444",marginBottom:"16px"},children:"Error Loading Stripe Components"}),e.jsxs("div",{style:{color:"#ef4444",marginBottom:"24px",padding:"16px",background:"#fee2e2",borderRadius:"8px"},children:[e.jsx("strong",{children:"Error Details:"}),e.jsx("pre",{style:{marginTop:"8px",whiteSpace:"pre-wrap",fontSize:"0.9em"},children:r})]}),e.jsxs("div",{style:{display:"flex",gap:"12px"},children:[e.jsxs("button",{className:"btn-primary-obsidian",onClick:()=>{i(""),window.location.reload()},children:[e.jsx("span",{className:"btn-icon",children:"â»"}),e.jsx("span",{children:"Retry"})]}),e.jsxs("button",{className:"btn-primary-obsidian",onClick:()=>d("/business/connect/onboarding"),children:[e.jsx("span",{className:"btn-icon",children:"+"}),e.jsx("span",{children:"Set Up Account"})]})]})]}):l?e.jsx(k,{connectInstance:l,children:e.jsx("div",{className:"embedded-connect-panel",children:e.jsx(E,{})})}):e.jsxs("div",{className:"dashboard-card",style:{maxWidth:"800px"},children:[e.jsx("h2",{children:"Initializing Stripe Connect..."}),e.jsx("p",{style:{color:"var(--color-slate-500)",marginTop:"16px",marginBottom:"16px"},children:"Please wait while we set up your payment dashboard."}),e.jsx("div",{style:{width:"100%",height:"4px",background:"var(--color-slate-200)",borderRadius:"2px",overflow:"hidden"},children:e.jsx("div",{style:{width:"100%",height:"100%",background:"linear-gradient(90deg, #3b82f6, #2563eb)",animation:"pulse 2s ease-in-out infinite"}})})]}),e.jsx("div",{style:{background:"var(--color-surface-0)",padding:"16px",borderRadius:"8px",marginTop:"32px",border:"1px solid var(--color-slate-200)"},children:e.jsxs("p",{style:{fontSize:"0.9em",color:"var(--color-slate-500)",margin:0},children:[e.jsx("strong",{children:"Legal Notice:"})," You are the Merchant of Record for all transactions. You manage refunds and disputes directly through Stripe."]})})]})})]})}export{T 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.