{"version":3,"file":"StructuredData.DF42GAJ1.mjs","names":[],"sources":["https:/framerusercontent.com/modules/T49l51CHO1zV71SfXloT/wGVz8z5MJ3vjiOtATXpn/StructuredData.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useEffect}from\"react\";const ID=\"horizon-structured-data\";/* Guesty titles carry channel SEO (\"… - BBQ, Hot Tub, Pool,Gym\"). That is the\n   name a search engine would show, so strip it back to the home itself. */const TITLE_STOP=new Set([\"bbq\",\"hot\",\"tub\",\"pool\",\"gym\",\"sauna\",\"cozy\",\"luxury\",\"getaway\",\"retreat\",\"acre\",\"acres\",\"invermere\",\"radium\",\"windermere\",\"with\",\"w\"]);function cleanTitle(raw){if(!raw)return null;const piped=raw.split(\"|\").map(s=>s.trim());let s=piped.sort((a,b)=>b.length-a.length)[0]??raw;s=s.split(/\\s+[-–—]\\s+/)[0].split(\",\")[0].trim();const out=[];for(const w of s.split(/\\s+/)){if(out.length>=2&&TITLE_STOP.has(w.toLowerCase().replace(/[^a-z]/g,\"\")))break;out.push(w);}while(out.length>2&&/^\\d+$/.test(out[out.length-1]))out.pop();return out.join(\" \")||null;}function write(json){if(typeof document===\"undefined\")return;const existing=document.getElementById(ID);if(!json){existing?.remove();return;}const el=existing??document.createElement(\"script\");el.id=ID;el.type=\"application/ld+json\";el.textContent=JSON.stringify(json);if(!existing)document.head.appendChild(el);}export default function StructuredData(props){const{apiBase=\"https://stayinvermere-guesty-proxy.john37nicholson.workers.dev\",mode=\"site\",listingId=\"\",siteName=\"Horizon Properties\",siteUrl=\"https://www.horizonproperties.ca\",telephone=\"+1-250-409-4660\",email=\"john@horizonproperties.ca\",style}=props;useEffect(()=>{// The canvas has no crawler to serve and cannot fetch; writing there\n// would only pollute the editor's own document.\nif(RenderTarget.current()!==RenderTarget.preview&&RenderTarget.current()!==RenderTarget.export){if(typeof window===\"undefined\")return;}let cancelled=false;const org={\"@type\":\"RealEstateAgent\",\"@id\":`${siteUrl}/#organization`,name:siteName,url:siteUrl,telephone,email,areaServed:{\"@type\":\"Place\",name:\"Columbia Valley, British Columbia\"},address:{\"@type\":\"PostalAddress\",addressLocality:\"Invermere\",addressRegion:\"BC\",addressCountry:\"CA\"}};async function build(){if(mode===\"site\"){const graph=[org,{\"@type\":\"WebSite\",\"@id\":`${siteUrl}/#website`,url:siteUrl,name:siteName,publisher:{\"@id\":`${siteUrl}/#organization`}}];try{const r=await fetch(`${apiBase}/api/reviews`);const d=r.ok?await r.json():null;if(d?.average&&d?.count){graph[0]={...org,aggregateRating:{\"@type\":\"AggregateRating\",ratingValue:d.average,reviewCount:d.count,bestRating:5,worstRating:1}};}}catch{/* the entity description is still worth emitting alone */}return{\"@context\":\"https://schema.org\",\"@graph\":graph};}if(!listingId)return null;const[listingRes,reviewRes]=await Promise.all([fetch(`${apiBase}/api/listings/${encodeURIComponent(listingId)}`).catch(()=>null),fetch(`${apiBase}/api/reviews?listingId=${encodeURIComponent(listingId)}`).catch(()=>null)]);const listing=listingRes?.ok?await listingRes.json():null;const reviews=reviewRes?.ok?await reviewRes.json():null;if(!listing)return null;const a=listing.address??{};const node={\"@type\":\"LodgingBusiness\",name:cleanTitle(listing.title)??listing.nickname??siteName,url:typeof window!==\"undefined\"?window.location.href:siteUrl,parentOrganization:{\"@id\":`${siteUrl}/#organization`},address:{\"@type\":\"PostalAddress\",streetAddress:a.street??undefined,addressLocality:a.city??\"Invermere\",addressRegion:a.state??\"BC\",addressCountry:a.country??\"CA\"}};if(listing.description)node.description=String(listing.description).slice(0,600);if(Number.isFinite(a.lat)&&Number.isFinite(a.lng)){node.geo={\"@type\":\"GeoCoordinates\",latitude:a.lat,longitude:a.lng};}if(Array.isArray(listing.pictures)&&listing.pictures.length){node.photo=listing.pictures.slice(0,6).map(p=>p.url);}if(Number.isFinite(listing.accommodates)){node.numberOfRooms=listing.bedrooms??undefined;node.petsAllowed=undefined;}if(Array.isArray(listing.amenities)&&listing.amenities.length){node.amenityFeature=listing.amenities.slice(0,20).map(name=>({\"@type\":\"LocationFeatureSpecification\",name,value:true}));}// Only this listing's own reviews, never the portfolio figure — an\n// aggregate borrowed from other properties would be a fabrication.\nif(reviews?.average&&reviews?.count){node.aggregateRating={\"@type\":\"AggregateRating\",ratingValue:reviews.average,reviewCount:reviews.count,bestRating:5,worstRating:1};}if(Array.isArray(reviews?.channels)&&reviews.channels.length){node.sameAs=reviews.channels.map(c=>c.url);}return{\"@context\":\"https://schema.org\",\"@graph\":[org,node]};}build().then(json=>{if(!cancelled)write(json);}).catch(()=>{});return()=>{cancelled=true;write(null);};},[apiBase,mode,listingId,siteName,siteUrl,telephone,email]);// Nothing visible. Framer still needs a node to mount.\nreturn /*#__PURE__*/_jsx(\"span\",{style:{display:\"none\",...style},\"aria-hidden\":\"true\"});}addPropertyControls(StructuredData,{apiBase:{type:ControlType.String,title:\"API Base\",defaultValue:\"https://stayinvermere-guesty-proxy.john37nicholson.workers.dev\"},mode:{type:ControlType.Enum,title:\"Mode\",options:[\"site\",\"property\"],optionTitles:[\"Site / organisation\",\"Single property\"],defaultValue:\"site\"},listingId:{type:ControlType.String,title:\"Listing ID\",defaultValue:\"\",description:\"Property mode only. Bind to the Stays Listing ID field.\",hidden:p=>p.mode!==\"property\"},siteName:{type:ControlType.String,title:\"Business Name\",defaultValue:\"Horizon Properties\"},siteUrl:{type:ControlType.String,title:\"Site URL\",defaultValue:\"https://www.horizonproperties.ca\"},telephone:{type:ControlType.String,title:\"Phone\",defaultValue:\"+1-250-409-4660\"},email:{type:ControlType.String,title:\"Email\",defaultValue:\"john@horizonproperties.ca\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"StructuredData\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./StructuredData.map"],"mappings":"+LAC8O,SAAS,EAAW,EAAI,CAAC,GAAG,CAAC,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