1import{j as e}from"./vendor-react-pdf-pjc_U7TD.js";import{r as t,u as l,z as S,i as w}from"./services-storage-Xz-a_gZY.js";import{r as j,q as v,ar as P}from"./ScrollToTop-B8_Nrzte.js";import{u as _}from"./useSubscription-B7O2YIs0.js";import{P as b}from"./Paywall-DI3Ws2f-.js";import{L as N}from"./index-C2Te0sSM.js";import"./vendor-pdf-BRIgg-Uy.js";import"./card-CvJZeYL5.js";import"./label-CgdjeQfk.js";import"./sparkles-B534pqx_.js";import"./lock-DCI7Amm8.js";import"./crown-CxO_Fr9j.js";import"./minus-nuv7erzK.js";import"./plus-DSmdTu5K.js";import"./arrow-right-DyDVxQnJ.js";const O=()=>{const o=j(),{user:r}=v(),n=P(),{canCreateScenario:m}=_(),[k,u]=t.useState(!0),[d,h]=t.useState(!1),p=t.useRef(!1);return t.useEffect(()=>{r&&(async()=>{var g;const f=sessionStorage.getItem("pending_linkedin_scenario");if(!f){l.error("No pending scenario found."),o("/actions/create-from-linkedin-sales-rep");return}if(r&&!p.current){p.current=!0;try{if(!await m()){h(!0),u(!1);return}const s=JSON.parse(f),x={...s,username:((g=r.user_metadata)==null?void 0:g.username)||"Anonymous",createdBy:r.email||r.id,isFeatured:!1,attachments:s.attachments||[],goal:s.goal||"Complete the roleplay.",aiRole:s.aiRole||"AI Assistant"},c=await S(x);n.invalidateQueries({queryKey:["scenarios"]}),n.setQueryData(["scenario",c.id],c),sessionStorage.removeItem("pending_linkedin_scenario"),l.success("Scenario created successfully!");const a=s.team_id;if(a)try{const{error:i}=await w.rpc("join_team",{team_id:a});i?console.warn("Failed to join team:",i):console.log("Successfully joined team:",a)}catch(i){console.error("Error joining team:",i)}o(`/?scenario=${c.id}&team_invite=${a||""}`)}catch(y){console.error("Error saving pending scenario:",y),l.error("Failed to save your scenario. Please try again.")}finally{d||u(!1)}}})()},[r,o,n,m]),d?e.jsx("div",{className:"flex flex-col items-center justify-center min-h-screen bg-background p-4",children:e.jsx(b,{mode:"limit_reached",title:"Scenario Limit Reached",description:"You've reached your free scenario creation limit. Upgrade to continue building.",successUrl:window.location.href})}):e.jsx("div",{className:"flex flex-col items-center justify-center min-h-screen bg-background",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx(N,{className:"h-12 w-12 animate-spin text-primary mx-auto"}),e.jsx("h2",{className:"text-xl font-semibold",children:"Setting up your roleplay..."}),e.jsx("p",{className:"text-muted-foreground",children:"Please wait while we prepare your scenario."})]})})};export{O 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.