import{r as o,u as H,bD as T,bE as D,bF as U,bG as I,j as e,z as F,D as B,L as z,p as K,a4 as Y,a2 as W,n as Q,aA as V,C as L,bH as $,bI as R}from"./index-4soFh7YW.js";import{C as Z,a as q,b as J}from"./collapsible-CX96IudD.js";import{g as X}from"./guesty-logo-DM9Z1Vp9.js";import{h as ee}from"./hostaway-logo-Bo3NdUra.js";import{l as te}from"./lodgify-logo-B-2VP9bo.js";import{C as se}from"./chevron-up-rz0gXHgw.js";import"./analytics-Bu8LxldC.js";const oe="https://pms.botel.ai/api",ae=()=>{const[s,l]=o.useState([]),[i,u]=o.useState(!0),[p,y]=o.useState(null),n=o.useRef(!0),c=o.useCallback(async()=>{u(!0),y(null);try{const r=await fetch(`${oe}/Lookup/Get?LookupType=CalryPmsList`);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);const C=await r.json();n.current&&l(C||[])}catch(r){n.current&&(console.error("[useCalryPmsLookup] Failed to fetch:",r),y(r?.message||"Failed to load CalryPmsList lookup"))}finally{n.current&&u(!1)}},[]);o.useEffect(()=>(n.current=!0,c(),()=>{n.current=!1}),[c]);const b=o.useMemo(()=>s.map(r=>({key:r.lookupKey,name:r.lookupValue})),[s]);return o.useMemo(()=>({data:s,options:b,loading:i,error:p,refetch:c}),[s,b,i,p,c])},m="https://app.cendra.ai",f="cendra_auth_state",x="cendra_auth_pms",ne=["https://cendra.ai","https://www.cendra.ai"],E=()=>{const s=window.location.origin;return ne.includes(s),s},O=()=>{const s=window.screen.width,l=window.screen.height,i=Math.min(l-100,Math.max(800,Math.round(l*.85))),u=Math.min(s-100,Math.max(550,Math.round(i*.7))),p=Math.round((s-u)/2),y=Math.round((l-i)/2);return`width=${u},height=${i},left=${p},top=${y},popup=yes,resizable=yes,scrollbars=yes`},re=[{id:"guesty",name:"Guesty",logo:X,available:!0,logoHeight:"h-8"},{id:"hostaway",name:"Hostaway",logo:ee,available:!0,logoHeight:"h-8"},{id:"lodgify",name:"LODGIFY",logo:te,available:!0,logoHeight:"h-8"}],ie=[{key:"apaleo",name:"Apaleo"},{key:"avaibook",name:"AvaiBook"},{key:"avantio",name:"Avantio"},{key:"beds24",name:"Beds24"},{key:"bookingsync",name:"BookingSync"},{key:"cloudbeds",name:"Cloudbeds"},{key:"direct",name:"Direct Software"},{key:"elina",name:"Elina"},{key:"escapia",name:"Escapia"},{key:"fantasticstay",name:"FantasticStay"},{key:"guesty-for-hosts",name:"Guesty for Hosts"},{key:"guestwisely",name:"Guestwise"},{key:"hospitable",name:"Hospitable"},{key:"host-tools",name:"Host Tools"},{key:"hostex",name:"Hostex"},{key:"hostfully",name:"Hostfully"},{key:"hostify",name:"Hostify"},{key:"lodgix",name:"Lodgix"},{key:"mews",name:"Mews"},{key:"mralfred",name:"Mr Alfred"},{key:"ownerrez",name:"OwnerRez"},{key:"resly",name:"Resly"},{key:"rms",name:"RMS Cloud"},{key:"smoobu",name:"Smoobu"},{key:"streamline",name:"Streamline"},{key:"tokeet",name:"Tokeet"},{key:"track",name:"Track"},{key:"uplisting",name:"Uplisting"},{key:"wholesaletourism",name:"Wholesale Tourism"},{key:"your-rentals",name:"Your Rentals"},{key:"zeevou",name:"Zeevou"}],ge=()=>{const{t:s}=H("getStarted"),{toast:l}=T(),[i,u]=o.useState(!1),[p,y]=o.useState(""),[n,c]=o.useState(null),{options:b,loading:M}=ae();o.useEffect(()=>{D()},[]);const C=o.useMemo(()=>b.length>0?b:ie,[b]).filter(t=>t.name.toLowerCase().includes(p.toLowerCase())),N=o.useCallback(t=>{if(t.origin!==m)return;const a=t.data;if(!a||typeof a!="object")return;const{type:k,ok:w,state:h,error:d,alreadyLoggedIn:S,redirectTo:G}=a;if(k!=="BOTEL_POPUP_AUTH_DONE")return;if(typeof w!="boolean"||typeof h!="string"){console.warn("[GetStarted] Ignoring invalid auth message shape",a);return}const P=sessionStorage.getItem(f);if(!P||P!==h){console.warn("[GetStarted] State mismatch or missing state. Expected:",P,"Got:",h),sessionStorage.removeItem(f),sessionStorage.removeItem(x);return}const v=sessionStorage.getItem(x);if(sessionStorage.removeItem(f),sessionStorage.removeItem(x),n&&!n.closed&&n.close(),c(null),w){U(!0,v||void 0);const g=I();if(S||G==="dashboard"){const j=`${m}/dashboard`;console.log("[GetStarted] User already logged in, redirecting to dashboard:",j),window.location.href=j}else{const j=v?`${m}/onboarding?pms=${encodeURIComponent(v)}&ph_id=${encodeURIComponent(g)}`:`${m}/onboarding?ph_id=${encodeURIComponent(g)}`;console.log("[GetStarted] Auth success, redirecting to:",j),window.location.href=j}}else{const g=typeof d=="string"?d:void 0;U(!1,v||void 0,g),console.error("[GetStarted] Auth popup returned ok:false",g?`Error: ${g}`:""),l({title:"Authentication failed",description:g||"Please try again.",variant:"destructive"})}},[n,l]);o.useEffect(()=>(window.addEventListener("message",N),()=>{window.removeEventListener("message",N)}),[N]);const A=t=>{$(t,!0);const a=crypto.randomUUID();sessionStorage.setItem(f,a),sessionStorage.setItem(x,t);const k=I(),w=E(),h=`${m}/popup-auth?state=${encodeURIComponent(a)}&pms=${encodeURIComponent(t)}&mode=signup&ph_id=${encodeURIComponent(k)}&origin=${encodeURIComponent(w)}`;console.log("[GetStarted] Opening auth popup for PMS:",t),R(t);const d=window.open(h,"cendra-auth",O());d?(c(d),d.focus()):(console.warn("[GetStarted] Popup blocked, falling back to redirect"),sessionStorage.removeItem(f),sessionStorage.removeItem(x),window.location.href=`${m}/onboarding?pms=${encodeURIComponent(t)}`)},_=t=>{$(t.name,!1);const a=t.key,k=crypto.randomUUID();sessionStorage.setItem(f,k),sessionStorage.setItem(x,a);const w=I(),h=E(),d=`${m}/popup-auth?state=${encodeURIComponent(k)}&pms=${encodeURIComponent(a)}&mode=signup&ph_id=${encodeURIComponent(w)}&origin=${encodeURIComponent(h)}`;console.log("[GetStarted] Opening auth popup for non-native PMS (Calry flow):",a),R(a);const S=window.open(d,"cendra-auth",O());S?(c(S),S.focus()):(console.warn("[GetStarted] Popup blocked, falling back to redirect"),sessionStorage.removeItem(f),sessionStorage.removeItem(x),window.location.href=`${m}/onboarding?pms=${encodeURIComponent(a)}`)};return e.jsxs(e.Fragment,{children:[e.jsx(F,{title:s("meta.title"),description:s("meta.description"),canonicalPath:"/get-started"}),e.jsx(B,{items:[{name:"Home",path:"/"},{name:"Get Started",path:"/get-started"}]}),e.jsxs("div",{className:"min-h-screen flex flex-col lg:flex-row",children:[e.jsxs("div",{className:"flex-1 bg-background px-6 py-8 lg:px-16 lg:py-12",children:[e.jsx(z,{to:"/",className:"inline-block mb-12",children:e.jsx("img",{src:K,alt:"Cendra",className:"h-7"})}),e.jsxs("div",{className:"max-w-lg",children:[e.jsx("h1",{className:"text-2xl font-semibold text-foreground mb-8",children:s("leftPanel.title")}),e.jsx("div",{className:"flex flex-wrap gap-3 mb-6",children:re.map(t=>e.jsx("button",{onClick:()=>A(t.id),className:"flex items-center justify-center h-14 px-6 rounded-lg border transition-all duration-150 active:scale-95 border-border bg-background hover:border-muted-foreground/30 hover:shadow-sm",children:e.jsx("img",{src:t.logo,alt:t.name,className:`${t.logoHeight} object-contain`})},t.id))}),e.jsxs(Z,{open:i,onOpenChange:u,children:[e.jsxs(q,{className:"flex items-center gap-1 text-sm font-medium text-foreground mb-4 hover:text-primary transition-colors",children:[s("leftPanel.onAnotherPMS"),i?e.jsx(se,{className:"h-4 w-4"}):e.jsx(Y,{className:"h-4 w-4"})]}),e.jsxs(J,{className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(W,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(Q,{placeholder:s("leftPanel.searchPlaceholder"),value:p,onChange:t=>y(t.target.value),className:"pl-10 bg-background border-border"})]}),e.jsx("div",{className:"border border-border rounded-lg max-h-48 overflow-y-auto",children:M?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(V,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"grid grid-cols-2 divide-x divide-border",children:C.map(t=>e.jsx("button",{onClick:()=>_(t),className:"px-4 py-2.5 text-left text-sm transition-colors text-muted-foreground hover:bg-muted hover:text-foreground",children:t.name},t.key))})})]})]})]})]}),e.jsx("div",{className:"lg:flex-1 bg-primary px-6 py-12 lg:px-16 flex items-center",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("span",{className:"inline-block px-3 py-1.5 text-xs font-medium rounded-full border border-accent/30 text-accent mb-6",children:s("rightPanel.badge")}),e.jsx("h2",{className:"text-3xl lg:text-4xl font-bold text-primary-foreground mb-4",children:s("rightPanel.title")}),e.jsx("p",{className:"text-primary-foreground/70 mb-8 text-base leading-relaxed",children:s("rightPanel.description")}),e.jsxs("ul",{className:"space-y-4",children:[e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-success/20 flex items-center justify-center mt-0.5",children:e.jsx(L,{className:"w-3 h-3 text-success"})}),e.jsx("span",{className:"text-primary-foreground/90 text-sm",children:s("rightPanel.benefits.brandVoice")})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-success/20 flex items-center justify-center mt-0.5",children:e.jsx(L,{className:"w-3 h-3 text-success"})}),e.jsx("span",{className:"text-primary-foreground/90 text-sm",children:s("rightPanel.benefits.noMessagesSent")})]}),e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-success/20 flex items-center justify-center mt-0.5",children:e.jsx(L,{className:"w-3 h-3 text-success"})}),e.jsx("span",{className:"text-primary-foreground/90 text-sm",children:s("rightPanel.benefits.customizeSettings")})]})]})]})})]})]})};export{ge as default};