@mapfirst.ai/core 0.0.26 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- function N(n,{insertAt:e}={}){if(!n||typeof document=="undefined")return;let t=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",e==="top"&&t.firstChild?t.insertBefore(a,t.firstChild):t.appendChild(a),a.styleSheet?a.styleSheet.cssText=n:a.appendChild(document.createTextNode(n))}N(`.mapfirst-marker-root{display:flex;z-index:20;flex-direction:column;align-items:center;pointer-events:auto}.mapfirst-marker-pill{border:2px solid;border-radius:999px;padding:8px;font-size:16px;font-weight:600;font-family:system-ui,-apple-system,sans-serif;box-shadow:0 4px 6px #6b728080;display:flex;align-items:center;justify-content:center;position:relative;transition:transform .2s;transform-origin:center bottom}.mapfirst-marker-pill-pending{background:#ffffff80;backdrop-filter:blur(4px);border-color:transparent;cursor:default}.mapfirst-marker-pill-active{background:#012b11;border-color:#fff;color:#fff;cursor:pointer}.mapfirst-marker-pill-active.mapfirst-marker-non-primary{background:#ffffffb3;border-color:#03852e80;color:#03852e80;padding:4px}.mapfirst-marker-pill-active.mapfirst-marker-selected{background:#fff;border-color:#03852e;color:#03852e;transform:scale(1.2)}.mapfirst-marker-pill-active:hover{transform:scale(1.2)}.mapfirst-marker-badge{position:absolute;top:-12px;right:-20px}.mapfirst-marker-award-container{position:relative;width:32px;height:32px}.mapfirst-marker-award-back{position:absolute;stroke:#f5f5f5;stroke-width:2px}.mapfirst-marker-award-dot{position:absolute;top:6.2px;left:6.3px;width:18.5px;height:18.5px;border-radius:50%;z-index:1}.mapfirst-marker-award-dot-type-0{background:#ffef0e}.mapfirst-marker-award-dot-type-1{background:#01ea5b}.mapfirst-marker-award-front{position:relative;z-index:2;color:#012b11}.mapfirst-marker-rating-badge{display:flex;align-items:center;justify-content:center;border-radius:999px;background:#03852e;color:#fff;font-size:12px;line-height:1;box-shadow:0 2px 4px #0003;padding:2px 6px;border:2px solid #ffffff;font-weight:400}.mapfirst-marker-content{display:flex;align-items:center}.mapfirst-marker-loading-video{width:20px;height:20px;display:block}.mapfirst-dot-marker-container{display:flex;z-index:10;align-items:center;justify-content:center;pointer-events:auto}.mapfirst-dot-marker-button{width:20px;height:20px;border-radius:999px;border:2px solid #ffffff;box-shadow:0 2px 4px #6b728066;transition:transform .2s;outline:none;transform-origin:center center}.mapfirst-dot-marker-button-pending{background:#d1d5db;cursor:default}.mapfirst-dot-marker-button-active{background:#012b11;cursor:pointer}.mapfirst-dot-marker-button-active.mapfirst-dot-marker-non-primary{background:#ffffffb3;border-color:#03852e33}.mapfirst-dot-marker-button-active.mapfirst-dot-marker-selected{background:#fff;border-color:#03852e}.mapfirst-dot-marker-button-active:hover{transform:scale(1.2)}.mapfirst-dot-marker-button-active:focus{outline:2px solid #ffffff;outline-offset:2px}.mapfirst-property-hover-card{position:absolute;width:270px;background:#fff;border-radius:8px;box-shadow:0 4px 12px #00000026;overflow:hidden;display:flex;pointer-events:auto;z-index:9999;transition:opacity .2s;height:120px;text-decoration:none;color:inherit}.mapfirst-property-hover-card img{width:120px;height:120px;object-fit:cover;flex-shrink:0}.mapfirst-property-hover-image{width:120px;height:120px;flex-shrink:0}.mapfirst-property-hover-image-placeholder{background-color:#e5e7eb}.mapfirst-property-hover-details{display:flex;flex-direction:column;padding:8px 12px;flex:1;gap:4px}.mapfirst-property-hover-name{font-size:12px;font-weight:600;color:#1a1a1a;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;line-height:1.3}.mapfirst-property-hover-rating{display:flex;align-items:center;gap:4px;font-size:12px}.mapfirst-property-hover-rating .rating-value{font-weight:600;color:#1a1a1a}.mapfirst-property-hover-rating .stars{display:flex;gap:1px;font-size:10px;line-height:1;align-items:center}.mapfirst-property-hover-rating .reviews{color:#666;font-size:11px}.mapfirst-property-hover-price{font-size:12px;color:#666;margin-top:2px}.mapfirst-property-hover-price strong{color:#1a1a1a;font-weight:600}.mapfirst-property-hover-learn-more{font-size:12px;color:#03852e;text-decoration:none;font-weight:500;margin-top:auto;pointer-events:auto;display:inline-block}.mapfirst-property-hover-learn-more:hover{text-decoration:underline}
2
- `);function G(n,e,t,a){var M,c,p;if(typeof document=="undefined")return null;let r=n.marker,i=r.type===e,s=t===r.tripadvisor_id,l=r.type==="Accommodation"&&((c=(M=r.pricing)==null?void 0:M.offer)==null?void 0:c.availability)!=="available",u=document.createElement("div");u.className="mapfirst-dot-marker-container",u.style.zIndex=s?"20":i?"3":"1";let y=document.createElement("div");return y.className=l?"mapfirst-dot-marker-button mapfirst-dot-marker-button-pending":`mapfirst-dot-marker-button mapfirst-dot-marker-button-active${s?" mapfirst-dot-marker-selected":i?"":" mapfirst-dot-marker-non-primary"}`,y.title=(p=r.name)!=null?p:String(r.tripadvisor_id),y.addEventListener("click",b=>{b.stopPropagation(),l||a==null||a(r)}),u.appendChild(y),u}var ie='<svg viewBox="0 0 24 24" width="32" height="32" fill="currentColor"><path d="M12 3.953a7.442 7.442 0 1 0 .001 14.884A7.442 7.442 0 0 0 12 3.953m0 14.05a6.61 6.61 0 1 1 0-13.218 6.61 6.61 0 0 1 0 13.219M10.343 11.9a.91.91 0 1 1-1.821 0 .91.91 0 0 1 1.821 0m5.134 0a.91.91 0 1 1-1.821 0 .91.91 0 0 1 1.82 0m.82-1.897.84-.913h-1.863A5.8 5.8 0 0 0 12 8.08a5.77 5.77 0 0 0-3.27 1.008H6.862l.84.913a2.567 2.567 0 1 0 3.475 3.78l.823.896.823-.895a2.568 2.568 0 1 0 3.474-3.78m-6.865 3.634a1.738 1.738 0 1 1 0-3.476 1.738 1.738 0 0 1 0 3.476M12 11.85c0-1.143-.832-2.124-1.929-2.543A5 5 0 0 1 12 8.92a5 5 0 0 1 1.928.386c-1.096.42-1.927 1.4-1.927 2.543m2.566 1.787a1.738 1.738 0 1 1 .001-3.476 1.738 1.738 0 0 1 0 3.476m-8.456 3.719s-.377-.946-1.396-1.903c-1.02-.957-2.303-1.132-2.303-1.132s.457 1.02 1.54 2.04c1.086 1.017 2.159.995 2.159.995m2.568 1.41s-.524-.511-1.479-.883-1.861-.191-1.861-.191.598.54 1.615.935c1.016.397 1.725.139 1.725.139m2.493.505s-.545-.224-1.357-.196-1.415.47-1.415.47.608.222 1.473.193 1.3-.467 1.3-.467m-6.186-4.203s-.175-1.008-.974-2.154c-.8-1.147-2.015-1.578-2.015-1.578s.238 1.098 1.089 2.319c.85 1.22 1.9 1.413 1.9 1.413m-1.003-3.071s.195-1.021-.134-2.393c-.328-1.371-1.294-2.21-1.294-2.21s-.17 1.128.18 2.589c.35 1.46 1.248 2.014 1.248 2.014"></path><path d="M17.887 17.355s.377-.946 1.396-1.903c1.02-.957 2.303-1.132 2.303-1.132s-.457 1.02-1.54 2.04c-1.086 1.017-2.159.995-2.159.995m-2.567 1.41s.524-.511 1.479-.883 1.861-.191 1.861-.191-.598.54-1.615.935c-1.016.397-1.725.139-1.725.139m-2.493.505s.545-.224 1.357-.196 1.415.47 1.415.47-.608.222-1.473.193-1.3-.467-1.3-.467m6.186-4.203s.175-1.008.974-2.154c.8-1.147 2.015-1.578 2.015-1.578s-.238 1.098-1.089 2.319c-.85 1.22-1.9 1.413-1.9 1.413m1.003-3.071s-.195-1.021.133-2.393c.33-1.371 1.293-2.21 1.293-2.21s.17 1.128-.18 2.589c-.349 1.46-1.246 2.014-1.246 2.014M12 20.047a.413.413 0 1 0 0-.827.413.413 0 0 0 0 .827"></path></svg>',ne='<svg viewBox="0 0 24 24" width="32" height="32"><path d="M12 3.953a7.442 7.442 0 1 0 .001 14.884A7.442 7.442 0 0 0 12 3.953m0 14.05a6.61 6.61 0 1 1 0-13.218 6.61 6.61 0 0 1 0 13.219M10.343 11.9a.91.91 0 1 1-1.821 0 .91.91 0 0 1 1.821 0m5.134 0a.91.91 0 1 1-1.821 0 .91.91 0 0 1 1.82 0m.82-1.897.84-.913h-1.863A5.8 5.8 0 0 0 12 8.08a5.77 5.77 0 0 0-3.27 1.008H6.862l.84.913a2.567 2.567 0 1 0 3.475 3.78l.823.896.823-.895a2.568 2.568 0 1 0 3.474-3.78m-6.865 3.634a1.738 1.738 0 1 1 0-3.476 1.738 1.738 0 0 1 0 3.476M12 11.85c0-1.143-.832-2.124-1.929-2.543A5 5 0 0 1 12 8.92a5 5 0 0 1 1.928.386c-1.096.42-1.927 1.4-1.927 2.543m2.566 1.787a1.738 1.738 0 1 1 .001-3.476 1.738 1.738 0 0 1 0 3.476m-8.456 3.719s-.377-.946-1.396-1.903c-1.02-.957-2.303-1.132-2.303-1.132s.457 1.02 1.54 2.04c1.086 1.017 2.159.995 2.159.995m2.568 1.41s-.524-.511-1.479-.883-1.861-.191-1.861-.191.598.54 1.615.935c1.016.397 1.725.139 1.725.139m2.493.505s-.545-.224-1.357-.196-1.415.47-1.415.47.608.222 1.473.193 1.3-.467 1.3-.467m-6.186-4.203s-.175-1.008-.974-2.154c-.8-1.147-2.015-1.578-2.015-1.578s.238 1.098 1.089 2.319c.85 1.22 1.9 1.413 1.9 1.413m-1.003-3.071s.195-1.021-.134-2.393c-.328-1.371-1.294-2.21-1.294-2.21s-.17 1.128.18 2.589c.35 1.46 1.248 2.014 1.248 2.014"></path><path d="M17.887 17.355s.377-.946 1.396-1.903c1.02-.957 2.303-1.132 2.303-1.132s-.457 1.02-1.54 2.04c-1.086 1.017-2.159.995-2.159.995m-2.567 1.41s.524-.511 1.479-.883 1.861-.191 1.861-.191-.598.54-1.615.935c-1.016.397-1.725.139-1.725.139m-2.493.505s.545-.224 1.357-.196 1.415.47 1.415.47-.608.222-1.473.193-1.3-.467-1.3-.467m6.186-4.203s.175-1.008.974-2.154c.8-1.147 2.015-1.578 2.015-1.578s-.238 1.098-1.089 2.319c-.85 1.22-1.9 1.413-1.9 1.413m1.003-3.071s-.195-1.021.133-2.393c.33-1.371 1.293-2.21 1.293-2.21s.17 1.128-.18 2.589c-.349 1.46-1.246 2.014-1.246 2.014M12 20.047a.413.413 0 1 0 0-.827.413.413 0 0 0 0 .827"></path></svg>',se='<svg viewBox="0 0 24 24" width="20" height="20" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M14.051 6.549v.003l1.134 1.14 3.241-3.25.003-.002 1.134 1.136-3.243 3.252 1.134 1.14a1 1 0 0 0 .09-.008c.293-.05.573-.324.72-.474l.005-.006 2.596-2.603L22 8.016l-2.597 2.604a3.73 3.73 0 0 1-1.982 1.015 4.3 4.3 0 0 1-3.162-.657l-.023-.016-.026-.018-1.366 1.407 8.509 8.512L20.219 22l-.002-.002-6.654-6.663-2.597 2.76-7.3-7.315C1.967 8.948 1.531 6.274 2.524 4.198c.241-.504.566-.973.978-1.386l8.154 8.416 1.418-1.423-.039-.045c-.858-1.002-1.048-2.368-.62-3.595a4.15 4.15 0 0 1 .983-1.561L16 2l1.135 1.138-2.598 2.602-.047.045c-.16.151-.394.374-.433.678zM3.809 5.523c-.362 1.319-.037 2.905 1.06 4.103L10.93 15.7l1.408-1.496zM2.205 20.697 3.34 21.84l4.543-4.552-1.135-1.143z"/></svg>',oe='<svg viewBox="0 0 24 24" width="20" height="20" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M7.56 7.5H3.75a.25.25 0 0 0-.25.25v10c0 .138.112.25.25.25h16.5a.25.25 0 0 0 .25-.25v-10a.25.25 0 0 0-.25-.25h-3.81l-2-2H9.56zM8.94 4h6.12l2 2h3.19c.966 0 1.75.784 1.75 1.75v10a1.75 1.75 0 0 1-1.75 1.75H3.75A1.75 1.75 0 0 1 2 17.75v-10C2 6.784 2.784 6 3.75 6h3.19z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M12 9.25a2.75 2.75 0 1 0 0 5.5 2.75 2.75 0 0 0 0-5.5M7.75 12a4.25 4.25 0 1 1 8.5 0 4.25 4.25 0 0 1-8.5 0"/></svg>',pe='<video class="mapfirst-marker-loading-video" src="https://api.mapfirst.ai/static/images/loading.webm" autoplay loop muted></video>';function O(n,e,t,a){if(n.dataset.hasHoverCard==="true")return;n.dataset.hasHoverCard="true";let r=ce(t),i=null,s=null,o=null,l=()=>{i&&(clearTimeout(i),i=null),s&&(clearTimeout(s),s=null),o&&(cancelAnimationFrame(o),o=null),r.parentElement&&r.remove()},u=()=>{if(r.parentElement){let p=n.parentElement;for(;p&&getComputedStyle(p).position==="static";)p=p.parentElement;p&&(V(r,n,p),o=requestAnimationFrame(u))}},y=(p=!1)=>{s&&(clearTimeout(s),s=null);let b=()=>{let d=n.parentElement;for(;d&&getComputedStyle(d).position==="static";)d=d.parentElement;d&&(d.appendChild(r),V(r,n,d),me(r,t),o=requestAnimationFrame(u))};p?b():i=setTimeout(b,300)},M=()=>{a||(i&&(clearTimeout(i),i=null),o&&(cancelAnimationFrame(o),o=null),s=setTimeout(()=>{r.parentElement&&r.remove()},100))};a&&y(!0),e.addEventListener("mouseenter",()=>y(!1)),e.addEventListener("mouseleave",M),r.addEventListener("mouseenter",()=>{s&&(clearTimeout(s),s=null),!o&&r.parentElement&&(o=requestAnimationFrame(u))}),r.addEventListener("mouseleave",M);let c=new MutationObserver(p=>{for(let b of p)for(let d of b.removedNodes)if(d===n||d.contains(n)){l(),c.disconnect();return}});if(n.parentElement)c.observe(n.parentElement,{childList:!0,subtree:!0});else{let p=setInterval(()=>{n.parentElement&&(c.observe(n.parentElement,{childList:!0,subtree:!0}),clearInterval(p))},100)}}function le(n){return`/img/${n.toLowerCase().replace(/\s+/g,"").replace(/&/g,"")}.webp`}function ce(n){var l,u,y,M,c,p;let e=(y=(u=(l=n.pricing)==null?void 0:l.offer)==null?void 0:u.clickUrl)!=null?y:n.url,t=document.createElement(e?"a":"div");t.className="mapfirst-property-hover-card",t.setAttribute("data-marker-id",n.tripadvisor_id.toString()),e&&(t.href=e,t.target="_blank");let a=n.rating||0,r=n.reviews||0,i=(p=(c=(M=n.pricing)==null?void 0:M.offer)==null?void 0:c.displayPrice)!=null?p:n.price_level,s=()=>{let b=Math.floor(a),d=a%1!==0,g=[],f=`
1
+ function O(n,{insertAt:e}={}){if(!n||typeof document=="undefined")return;let t=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",e==="top"&&t.firstChild?t.insertBefore(a,t.firstChild):t.appendChild(a),a.styleSheet?a.styleSheet.cssText=n:a.appendChild(document.createTextNode(n))}O(`.mapfirst-marker-root{display:flex;z-index:20;flex-direction:column;align-items:center;pointer-events:auto}.mapfirst-marker-pill{border:2px solid;border-radius:999px;padding:8px;font-size:16px;font-weight:600;font-family:system-ui,-apple-system,sans-serif;box-shadow:0 4px 6px #6b728080;display:flex;align-items:center;justify-content:center;position:relative;transition:transform .2s;transform-origin:center bottom}.mapfirst-marker-pill-pending{background:#ffffff80;backdrop-filter:blur(4px);border-color:transparent;cursor:default}.mapfirst-marker-pill-active{background:#012b11;border-color:#fff;color:#fff;cursor:pointer}.mapfirst-marker-pill-active.mapfirst-marker-non-primary{background:#ffffffb3;border-color:#03852e80;color:#03852e80;padding:4px}.mapfirst-marker-pill-active.mapfirst-marker-selected{background:#fff;border-color:#03852e;color:#03852e;transform:scale(1.2)}.mapfirst-marker-pill-active:hover{transform:scale(1.2)}.mapfirst-marker-badge{position:absolute;top:-12px;right:-20px}.mapfirst-marker-award-container{position:relative;width:32px;height:32px}.mapfirst-marker-award-back{position:absolute;stroke:#f5f5f5;stroke-width:2px}.mapfirst-marker-award-dot{position:absolute;top:6.2px;left:6.3px;width:18.5px;height:18.5px;border-radius:50%;z-index:1}.mapfirst-marker-award-dot-type-0{background:#ffef0e}.mapfirst-marker-award-dot-type-1{background:#01ea5b}.mapfirst-marker-award-front{position:relative;z-index:2;color:#012b11}.mapfirst-marker-rating-badge{display:flex;align-items:center;justify-content:center;border-radius:999px;background:#03852e;color:#fff;font-size:12px;line-height:1;box-shadow:0 2px 4px #0003;padding:2px 6px;border:2px solid #ffffff;font-weight:400}.mapfirst-marker-content{display:flex;align-items:center}.mapfirst-marker-loading-video{width:20px;height:20px;display:block}.mapfirst-dot-marker-container{display:flex;z-index:10;align-items:center;justify-content:center;pointer-events:auto}.mapfirst-dot-marker-button{width:20px;height:20px;border-radius:999px;border:2px solid #ffffff;box-shadow:0 2px 4px #6b728066;transition:transform .2s;outline:none;transform-origin:center center}.mapfirst-dot-marker-button-pending{background:#d1d5db;cursor:default}.mapfirst-dot-marker-button-active{background:#012b11;cursor:pointer}.mapfirst-dot-marker-button-active.mapfirst-dot-marker-non-primary{background:#ffffffb3;border-color:#03852e33}.mapfirst-dot-marker-button-active.mapfirst-dot-marker-selected{background:#fff;border-color:#03852e}.mapfirst-dot-marker-button-active:hover{transform:scale(1.2)}.mapfirst-dot-marker-button-active:focus{outline:2px solid #ffffff;outline-offset:2px}.mapfirst-property-hover-card{position:absolute;width:270px;background:#fff;border-radius:8px;box-shadow:0 4px 12px #00000026;overflow:hidden;display:flex;pointer-events:auto;z-index:9999;transition:opacity .2s;height:120px;text-decoration:none;color:inherit}.mapfirst-property-hover-card img{width:120px;height:120px;object-fit:cover;flex-shrink:0}.mapfirst-property-hover-image{width:120px;height:120px;flex-shrink:0}.mapfirst-property-hover-image-placeholder{background-color:#e5e7eb}.mapfirst-property-hover-details{display:flex;flex-direction:column;padding:8px 12px;flex:1;gap:4px}.mapfirst-property-hover-name{font-size:12px;font-weight:600;color:#1a1a1a;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;line-height:1.3}.mapfirst-property-hover-rating{display:flex;align-items:center;gap:4px;font-size:12px}.mapfirst-property-hover-rating .rating-value{font-weight:600;color:#1a1a1a}.mapfirst-property-hover-rating .stars{display:flex;gap:1px;font-size:10px;line-height:1;align-items:center}.mapfirst-property-hover-rating .reviews{color:#666;font-size:11px}.mapfirst-property-hover-price{font-size:12px;color:#666;margin-top:2px}.mapfirst-property-hover-price strong{color:#1a1a1a;font-weight:600}.mapfirst-property-hover-learn-more{font-size:12px;color:#03852e;text-decoration:none;font-weight:500;margin-top:auto;pointer-events:auto;display:inline-block}.mapfirst-property-hover-learn-more:hover{text-decoration:underline}
2
+ `);var ie='<svg viewBox="0 0 24 24" width="32" height="32" fill="currentColor"><path d="M12 3.953a7.442 7.442 0 1 0 .001 14.884A7.442 7.442 0 0 0 12 3.953m0 14.05a6.61 6.61 0 1 1 0-13.218 6.61 6.61 0 0 1 0 13.219M10.343 11.9a.91.91 0 1 1-1.821 0 .91.91 0 0 1 1.821 0m5.134 0a.91.91 0 1 1-1.821 0 .91.91 0 0 1 1.82 0m.82-1.897.84-.913h-1.863A5.8 5.8 0 0 0 12 8.08a5.77 5.77 0 0 0-3.27 1.008H6.862l.84.913a2.567 2.567 0 1 0 3.475 3.78l.823.896.823-.895a2.568 2.568 0 1 0 3.474-3.78m-6.865 3.634a1.738 1.738 0 1 1 0-3.476 1.738 1.738 0 0 1 0 3.476M12 11.85c0-1.143-.832-2.124-1.929-2.543A5 5 0 0 1 12 8.92a5 5 0 0 1 1.928.386c-1.096.42-1.927 1.4-1.927 2.543m2.566 1.787a1.738 1.738 0 1 1 .001-3.476 1.738 1.738 0 0 1 0 3.476m-8.456 3.719s-.377-.946-1.396-1.903c-1.02-.957-2.303-1.132-2.303-1.132s.457 1.02 1.54 2.04c1.086 1.017 2.159.995 2.159.995m2.568 1.41s-.524-.511-1.479-.883-1.861-.191-1.861-.191.598.54 1.615.935c1.016.397 1.725.139 1.725.139m2.493.505s-.545-.224-1.357-.196-1.415.47-1.415.47.608.222 1.473.193 1.3-.467 1.3-.467m-6.186-4.203s-.175-1.008-.974-2.154c-.8-1.147-2.015-1.578-2.015-1.578s.238 1.098 1.089 2.319c.85 1.22 1.9 1.413 1.9 1.413m-1.003-3.071s.195-1.021-.134-2.393c-.328-1.371-1.294-2.21-1.294-2.21s-.17 1.128.18 2.589c.35 1.46 1.248 2.014 1.248 2.014"></path><path d="M17.887 17.355s.377-.946 1.396-1.903c1.02-.957 2.303-1.132 2.303-1.132s-.457 1.02-1.54 2.04c-1.086 1.017-2.159.995-2.159.995m-2.567 1.41s.524-.511 1.479-.883 1.861-.191 1.861-.191-.598.54-1.615.935c-1.016.397-1.725.139-1.725.139m-2.493.505s.545-.224 1.357-.196 1.415.47 1.415.47-.608.222-1.473.193-1.3-.467-1.3-.467m6.186-4.203s.175-1.008.974-2.154c.8-1.147 2.015-1.578 2.015-1.578s-.238 1.098-1.089 2.319c-.85 1.22-1.9 1.413-1.9 1.413m1.003-3.071s-.195-1.021.133-2.393c.33-1.371 1.293-2.21 1.293-2.21s.17 1.128-.18 2.589c-.349 1.46-1.246 2.014-1.246 2.014M12 20.047a.413.413 0 1 0 0-.827.413.413 0 0 0 0 .827"></path></svg>',ne='<svg viewBox="0 0 24 24" width="32" height="32"><path d="M12 3.953a7.442 7.442 0 1 0 .001 14.884A7.442 7.442 0 0 0 12 3.953m0 14.05a6.61 6.61 0 1 1 0-13.218 6.61 6.61 0 0 1 0 13.219M10.343 11.9a.91.91 0 1 1-1.821 0 .91.91 0 0 1 1.821 0m5.134 0a.91.91 0 1 1-1.821 0 .91.91 0 0 1 1.82 0m.82-1.897.84-.913h-1.863A5.8 5.8 0 0 0 12 8.08a5.77 5.77 0 0 0-3.27 1.008H6.862l.84.913a2.567 2.567 0 1 0 3.475 3.78l.823.896.823-.895a2.568 2.568 0 1 0 3.474-3.78m-6.865 3.634a1.738 1.738 0 1 1 0-3.476 1.738 1.738 0 0 1 0 3.476M12 11.85c0-1.143-.832-2.124-1.929-2.543A5 5 0 0 1 12 8.92a5 5 0 0 1 1.928.386c-1.096.42-1.927 1.4-1.927 2.543m2.566 1.787a1.738 1.738 0 1 1 .001-3.476 1.738 1.738 0 0 1 0 3.476m-8.456 3.719s-.377-.946-1.396-1.903c-1.02-.957-2.303-1.132-2.303-1.132s.457 1.02 1.54 2.04c1.086 1.017 2.159.995 2.159.995m2.568 1.41s-.524-.511-1.479-.883-1.861-.191-1.861-.191.598.54 1.615.935c1.016.397 1.725.139 1.725.139m2.493.505s-.545-.224-1.357-.196-1.415.47-1.415.47.608.222 1.473.193 1.3-.467 1.3-.467m-6.186-4.203s-.175-1.008-.974-2.154c-.8-1.147-2.015-1.578-2.015-1.578s.238 1.098 1.089 2.319c.85 1.22 1.9 1.413 1.9 1.413m-1.003-3.071s.195-1.021-.134-2.393c-.328-1.371-1.294-2.21-1.294-2.21s-.17 1.128.18 2.589c.35 1.46 1.248 2.014 1.248 2.014"></path><path d="M17.887 17.355s.377-.946 1.396-1.903c1.02-.957 2.303-1.132 2.303-1.132s-.457 1.02-1.54 2.04c-1.086 1.017-2.159.995-2.159.995m-2.567 1.41s.524-.511 1.479-.883 1.861-.191 1.861-.191-.598.54-1.615.935c-1.016.397-1.725.139-1.725.139m-2.493.505s.545-.224 1.357-.196 1.415.47 1.415.47-.608.222-1.473.193-1.3-.467-1.3-.467m6.186-4.203s.175-1.008.974-2.154c.8-1.147 2.015-1.578 2.015-1.578s-.238 1.098-1.089 2.319c-.85 1.22-1.9 1.413-1.9 1.413m1.003-3.071s-.195-1.021.133-2.393c.33-1.371 1.293-2.21 1.293-2.21s.17 1.128-.18 2.589c-.349 1.46-1.246 2.014-1.246 2.014M12 20.047a.413.413 0 1 0 0-.827.413.413 0 0 0 0 .827"></path></svg>',se='<svg viewBox="0 0 24 24" width="20" height="20" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M14.051 6.549v.003l1.134 1.14 3.241-3.25.003-.002 1.134 1.136-3.243 3.252 1.134 1.14a1 1 0 0 0 .09-.008c.293-.05.573-.324.72-.474l.005-.006 2.596-2.603L22 8.016l-2.597 2.604a3.73 3.73 0 0 1-1.982 1.015 4.3 4.3 0 0 1-3.162-.657l-.023-.016-.026-.018-1.366 1.407 8.509 8.512L20.219 22l-.002-.002-6.654-6.663-2.597 2.76-7.3-7.315C1.967 8.948 1.531 6.274 2.524 4.198c.241-.504.566-.973.978-1.386l8.154 8.416 1.418-1.423-.039-.045c-.858-1.002-1.048-2.368-.62-3.595a4.15 4.15 0 0 1 .983-1.561L16 2l1.135 1.138-2.598 2.602-.047.045c-.16.151-.394.374-.433.678zM3.809 5.523c-.362 1.319-.037 2.905 1.06 4.103L10.93 15.7l1.408-1.496zM2.205 20.697 3.34 21.84l4.543-4.552-1.135-1.143z"/></svg>',oe='<svg viewBox="0 0 24 24" width="20" height="20" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M7.56 7.5H3.75a.25.25 0 0 0-.25.25v10c0 .138.112.25.25.25h16.5a.25.25 0 0 0 .25-.25v-10a.25.25 0 0 0-.25-.25h-3.81l-2-2H9.56zM8.94 4h6.12l2 2h3.19c.966 0 1.75.784 1.75 1.75v10a1.75 1.75 0 0 1-1.75 1.75H3.75A1.75 1.75 0 0 1 2 17.75v-10C2 6.784 2.784 6 3.75 6h3.19z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M12 9.25a2.75 2.75 0 1 0 0 5.5 2.75 2.75 0 0 0 0-5.5M7.75 12a4.25 4.25 0 1 1 8.5 0 4.25 4.25 0 0 1-8.5 0"/></svg>',pe='<video class="mapfirst-marker-loading-video" src="https://api.mapfirst.ai/static/images/loading.webm" autoplay loop muted></video>';function S(n,e,t,a){if(n.dataset.hasHoverCard==="true")return;n.dataset.hasHoverCard="true";let r=ce(t),i=null,s=null,o=null,p=()=>{i&&(clearTimeout(i),i=null),s&&(clearTimeout(s),s=null),o&&(cancelAnimationFrame(o),o=null),r.parentElement&&r.remove()},u=()=>{if(r.parentElement){let l=n.parentElement;for(;l&&getComputedStyle(l).position==="static";)l=l.parentElement;l&&(G(r,n,l),o=requestAnimationFrame(u))}},y=(l=!1)=>{s&&(clearTimeout(s),s=null);let b=()=>{let d=n.parentElement;for(;d&&getComputedStyle(d).position==="static";)d=d.parentElement;d&&(d.appendChild(r),G(r,n,d),me(r,t),o=requestAnimationFrame(u))};l?b():i=setTimeout(b,300)},M=()=>{a||(i&&(clearTimeout(i),i=null),o&&(cancelAnimationFrame(o),o=null),s=setTimeout(()=>{r.parentElement&&r.remove()},100))};a&&y(!0),e.addEventListener("mouseenter",()=>y(!1)),e.addEventListener("mouseleave",M),r.addEventListener("mouseenter",()=>{s&&(clearTimeout(s),s=null),!o&&r.parentElement&&(o=requestAnimationFrame(u))}),r.addEventListener("mouseleave",M);let c=new MutationObserver(l=>{for(let b of l)for(let d of b.removedNodes)if(d===n||d.contains(n)){p(),c.disconnect();return}});if(n.parentElement)c.observe(n.parentElement,{childList:!0,subtree:!0});else{let l=setInterval(()=>{n.parentElement&&(c.observe(n.parentElement,{childList:!0,subtree:!0}),clearInterval(l))},100)}}function le(n){return`/img/${n.toLowerCase().replace(/\s+/g,"").replace(/&/g,"")}.webp`}function ce(n){var p,u,y,M,c,l;let e=(y=(u=(p=n.pricing)==null?void 0:p.offer)==null?void 0:u.clickUrl)!=null?y:n.url,t=document.createElement(e?"a":"div");t.className="mapfirst-property-hover-card",t.setAttribute("data-marker-id",n.tripadvisor_id.toString()),e&&(t.href=e,t.target="_blank");let a=n.rating||0,r=n.reviews||0,i=(l=(c=(M=n.pricing)==null?void 0:M.offer)==null?void 0:c.displayPrice)!=null?l:n.price_level,s=()=>{let b=Math.floor(a),d=a%1!==0,g=[],f=`
3
3
  display: inline-block;
4
4
  width: 8px;
5
5
  height: 8px;
@@ -29,5 +29,5 @@ function N(n,{insertAt:e}={}){if(!n||typeof document=="undefined")return;let t=d
29
29
  </span>
30
30
  `:""}
31
31
  </div>
32
- `,t}function me(n,e){let t=n.querySelector(".mapfirst-property-hover-image");if(t&&e.tripadvisor_id&&!t.dataset.imageLoaded){t.dataset.imageLoaded="loading";let a=t.dataset.defaultImage;K(e.tripadvisor_id,1).then(r=>{if(r&&t){let i=document.createElement("img");i.src=r,i.alt=e.name,i.style.width="100%",i.style.height="100%",i.style.objectFit="cover",t.innerHTML="",t.appendChild(i),t.classList.remove("mapfirst-property-hover-image-placeholder"),t.dataset.imageLoaded="true"}else throw new Error("No image URL")}).catch(()=>{if(a&&t){let r=document.createElement("img");r.src=a,r.alt=e.name,r.style.width="100%",r.style.height="100%",r.style.objectFit="cover",t.innerHTML="",t.appendChild(r),t.classList.remove("mapfirst-property-hover-image-placeholder"),t.dataset.imageLoaded="false"}})}}function V(n,e,t){let a=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=270,s=120,o=12,l=r.right-a.right,u=a.left-r.left,y=r.bottom-a.bottom,M=a.top-r.top,c=a.left-r.left+a.width/2-i/2,p=a.top-r.top+a.height+o;c<0?c=8:c+i>r.width&&(c=r.width-i-8),y<s+o&&M>y&&(p=a.top-r.top-s-o),n.style.left=`${c}px`,n.style.top=`${p}px`}function U(n,e,t,a){var d,g,f,m,h,P,T,x,C;if(typeof document=="undefined")return null;let r=n.marker,i=r.type===e,s=t===r.tripadvisor_id,o=r.type==="Accommodation",l=(g=(d=r.pricing)==null?void 0:d.offer)==null?void 0:g.displayPrice,u=o&&!l,y=(()=>{if(r.rating===void 0||r.rating===null)return null;let L=typeof r.rating=="number"?r.rating:Number(r.rating);return Number.isNaN(L)||L<=0?null:L.toFixed(1)})(),M=document.createElement("div");M.className="mapfirst-marker-root",M.style.zIndex=s?"20":i?"12":"11";let c=(h=(m=(f=r.pricing)==null?void 0:f.offer)==null?void 0:m.clickUrl)!=null?h:r.url,p=document.createElement(c?"a":"div");if(c&&(p.href=c,p.target="_blank",p.style.textDecoration="none"),p.className=u?"mapfirst-marker-pill mapfirst-marker-pill-pending":`mapfirst-marker-pill mapfirst-marker-pill-active${s?" mapfirst-marker-selected":i?"":" mapfirst-marker-non-primary"}`,!u&&((P=r.awards)!=null&&P.length||y)){let L=document.createElement("div");if(L.className="mapfirst-marker-badge",i||(L.style.opacity="0.2"),L.className="mapfirst-marker-badge",(T=r.awards)!=null&&T.length&&r.awards[0].type){let k=document.createElement("div");k.className="mapfirst-marker-award-container";let v=document.createElement("div");v.className="mapfirst-marker-award-back",v.innerHTML=ne;let A=document.createElement("div");A.className=`mapfirst-marker-award-dot mapfirst-marker-award-dot-type-${r.awards[0].type}`;let w=document.createElement("div");w.className="mapfirst-marker-award-front",w.innerHTML=ie,k.appendChild(v),k.appendChild(A),k.appendChild(w),L.appendChild(k)}else y&&(L.className="mapfirst-marker-badge mapfirst-marker-rating-badge",L.textContent=y);p.appendChild(L)}let b=document.createElement("span");return b.className="mapfirst-marker-content",o?(C=(x=r.pricing)==null?void 0:x.offer)!=null&&C.displayPrice?(b.innerHTML=r.pricing.offer.displayPrice,b.dataset.price=r.pricing.offer.displayPrice):(b.innerHTML=pe,b.dataset.price=""):r.type==="Eat & Drink"?b.innerHTML=se:r.type==="Attraction"&&(b.innerHTML=oe),p.appendChild(b),p.addEventListener("click",L=>{L.stopPropagation(),u||a==null||a(r)}),u||O(M,p,r,s),M.appendChild(p),M}var de='<video class="mapfirst-marker-loading-video" src="https://api.mapfirst.ai/static/images/loading.webm" autoplay loop muted></video>';function $(n,e,t,a,r){var u,y,M,c,p,b,d,g,f,m;let i=(y=(u=n.querySelector(".mapfirst-marker-pill"))==null?void 0:u.classList.contains("mapfirst-marker-pill-pending"))!=null?y:!1,s=n;s.style.zIndex=t?"20":e?"12":"11";let o=s.querySelector(".mapfirst-marker-pill");o&&(a?o.className="mapfirst-marker-pill mapfirst-marker-pill-pending":o.className=`mapfirst-marker-pill mapfirst-marker-pill-active${t?" mapfirst-marker-selected":e?"":" mapfirst-marker-non-primary"}`);let l=s.querySelector(".mapfirst-marker-badge");if(l instanceof HTMLElement&&(l.style.opacity=!e&&!t?"0.2":""),i&&!a&&r){let h=s.querySelector(".mapfirst-marker-pill");h instanceof HTMLElement&&O(s,h,r,t)}if(r&&r.type==="Accommodation"){let h=s.querySelector(".mapfirst-marker-content");if(h instanceof HTMLElement){let P=(c=(M=r.pricing)==null?void 0:M.offer)==null?void 0:c.displayPrice;h.dataset.price!==P&&(P?(h.innerHTML=P,h.dataset.price=P):(h.innerHTML=de,h.dataset.price=""))}}if(r){let h=document.querySelector(`.mapfirst-property-hover-card[data-marker-id="${r.tripadvisor_id}"]`);if(h){let P=r.rating||0,T=r.reviews||0,x=(d=(b=(p=r.pricing)==null?void 0:p.offer)==null?void 0:b.displayPrice)!=null?d:r.price_level,C=h.querySelector(".rating-value");if(C){let v=P.toFixed(1);C.textContent!==v&&(C.textContent=v)}let L=h.querySelector(".reviews");if(L){let v=`(${T})`;L.textContent!==v&&(L.textContent=v)}if(r.type==="Accommodation"&&x){let v=h.querySelector(".mapfirst-property-hover-price");if(!v){v=document.createElement("div"),v.className="mapfirst-property-hover-price";let A=h.querySelector(".mapfirst-property-hover-details"),w=h.querySelector(".mapfirst-property-hover-learn-more");A&&(w?A.insertBefore(v,w):A.appendChild(v))}if(v){let A=`Starting at <strong>${x}</strong>`;v.innerHTML!==A&&(v.innerHTML=A)}}let k=(m=(f=(g=r.pricing)==null?void 0:g.offer)==null?void 0:f.clickUrl)!=null?m:r.url;k&&h instanceof HTMLAnchorElement&&h.href!==k&&(h.href=k)}}}function z(n,e,t,a){let r=n;r.style.zIndex=t?"20":e?"3":"1";let i=r.querySelector(".mapfirst-dot-marker-button");i&&(a?i.className="mapfirst-dot-marker-button mapfirst-dot-marker-button-pending":i.className=`mapfirst-dot-marker-button mapfirst-dot-marker-button-active${t?" mapfirst-dot-marker-selected":e?"":" mapfirst-dot-marker-non-primary"}`)}function Z(n){let e=n.match(/^(?:primary|dot)-(\d+)-/);return e?parseInt(e[1],10):null}var I=class{constructor(e,t){this.markerCache=new Map;this.primaryType="Accommodation";this.selectedMarkerId=null;this.mapInstance=e,this.onMarkerClick=t}render(e,t,a){var i,s,o,l,u,y,M,c;t&&t!==this.primaryType&&(this.primaryType=t),a!==void 0&&(this.selectedMarkerId=a);let r=new Set(e.map(p=>p.key));for(let[p,b]of this.markerCache.entries())r.has(p)||(this.removeMarkerFromMap(b.marker),this.markerCache.delete(p));for(let p of e){let b=ue(p.marker.location);if(!b)continue;let d=this.markerCache.get(p.key);if(d){let g=p.marker.type===this.primaryType,f=this.selectedMarkerId===p.marker.tripadvisor_id,m=p.marker.type==="Accommodation",h=p.kind==="primary"?m&&!((s=(i=p.marker.pricing)==null?void 0:i.offer)!=null&&s.displayPrice):m&&((l=(o=p.marker.pricing)==null?void 0:o.offer)==null?void 0:l.availability)!=="available",P=this.getMarkerElement(d.marker);P&&(p.kind==="primary"?$(P,g,f,h,p.marker):z(P,g,f,h));try{this.updateMarkerPosition(d.marker,b)}catch{this.removeMarkerFromMap(d.marker),this.markerCache.delete(p.key),this.createAndAddMarker(p,b)}}else{let g=p.marker.tripadvisor_id,f,m;for(let[h,P]of this.markerCache.entries())if(Z(h)===g&&P.kind===p.kind){f=P,m=h;break}if(f&&m){let h=p.marker.type===this.primaryType,P=this.selectedMarkerId===p.marker.tripadvisor_id,T=p.marker.type==="Accommodation",x=p.kind==="primary"?T&&!((y=(u=p.marker.pricing)==null?void 0:u.offer)!=null&&y.displayPrice):T&&((c=(M=p.marker.pricing)==null?void 0:M.offer)==null?void 0:c.availability)!=="available",C=this.getMarkerElement(f.marker);C&&(p.kind==="primary"?$(C,h,P,x,p.marker):z(C,h,P,x)),this.updateMarkerZIndex(f.marker,p,h,P),this.markerCache.delete(m),this.markerCache.set(p.key,f);try{this.updateMarkerPosition(f.marker,b)}catch{}}else this.createAndAddMarker(p,b)}}}destroy(){for(let e of this.markerCache.values())this.removeMarkerFromMap(e.marker);this.markerCache.clear()}createAndAddMarker(e,t){let a=e.kind==="primary"?U(e,this.primaryType,this.selectedMarkerId,this.onMarkerClick):G(e,this.primaryType,this.selectedMarkerId,this.onMarkerClick);if(!a)return;let r=e.marker.type===this.primaryType,i=this.selectedMarkerId===e.marker.tripadvisor_id;try{let s=this.createMarker(a,t,e,r,i);s&&this.markerCache.set(e.key,{key:e.key,marker:s,kind:e.kind,parentId:e.kind==="dot"?e.parentId:void 0})}catch(s){console.error("Error creating marker",s)}}updateMarkerZIndex(e,t,a,r){}};function ue(n){return typeof(n==null?void 0:n.lon)!="number"||typeof(n==null?void 0:n.lat)!="number"||Number.isNaN(n.lon)||Number.isNaN(n.lat)?null:{lon:n.lon,lat:n.lat}}var S=class extends I{constructor(e){var t;super(e.mapInstance,e.onMarkerClick),this.MarkerCtor=(t=e.maplibregl)==null?void 0:t.Marker}render(e,t,a){this.MarkerCtor&&super.render(e,t,a)}createMarker(e,t,a){return this.MarkerCtor?new this.MarkerCtor({element:e,anchor:a.kind==="primary"?"bottom":"center"}).setLngLat([t.lon,t.lat]).addTo(this.mapInstance):null}removeMarkerFromMap(e){try{e.remove()}catch{}}updateMarkerPosition(e,t){e.setLngLat([t.lon,t.lat])}getMarkerElement(e){return e.getElement()}};var B=class extends I{constructor(e){super(e.mapInstance,e.onMarkerClick),this.google=e.google}render(e,t,a){var r,i;if(!((i=(r=this.google)==null?void 0:r.marker)!=null&&i.AdvancedMarkerElement)){console.warn("AdvancedMarkerElement not available");return}super.render(e,t,a)}createMarker(e,t,a,r,i){var o,l;if(!((l=(o=this.google)==null?void 0:o.marker)!=null&&l.AdvancedMarkerElement))return null;let s=a.kind==="primary"?i?20:r?12:11:i?20:r?3:1;return new this.google.marker.AdvancedMarkerElement({map:this.mapInstance,position:{lat:t.lat,lng:t.lon},content:e,zIndex:s})}removeMarkerFromMap(e){try{e.map=null}catch(t){console.error("Error removing marker",t)}}updateMarkerPosition(e,t){e.position={lat:t.lat,lng:t.lon}}getMarkerElement(e){let t=e.content;return t instanceof HTMLElement?t:null}updateMarkerZIndex(e,t,a,r){let i=t.kind==="primary"?r?20:a?12:11:r?20:a?3:1;e.zIndex=i}};var _=class extends I{constructor(e){var t;super(e.mapInstance,e.onMarkerClick),this.MarkerCtor=(t=e.mapboxgl)==null?void 0:t.Marker}render(e,t,a){this.MarkerCtor&&super.render(e,t,a)}createMarker(e,t,a){return this.MarkerCtor?new this.MarkerCtor({element:e,anchor:a.kind==="primary"?"bottom":"center"}).setLngLat([t.lon,t.lat]).addTo(this.mapInstance):null}removeMarkerFromMap(e){try{e.remove()}catch{}}updateMarkerPosition(e,t){e.setLngLat([t.lon,t.lat])}getMarkerElement(e){return e.getElement()}};var E=class{constructor(e){this.map=e}getMap(){return this.map}setupImpressionTracking(e){if(typeof window=="undefined"||!window.IntersectionObserver)return;let t=this.getContainer();if(!t)return;let a=new IntersectionObserver(s=>{s.forEach(o=>{o.isIntersecting&&(e(),a.disconnect())})},{threshold:.1});a.observe(t);let r=()=>a.disconnect(),i=this.cleanup.bind(this);this.cleanup=()=>{r(),i()}}};var R=class extends E{constructor(t){super(t);this.cleanupFns=[]}initialize(t){return this.markerManager=new S({mapInstance:this.map,maplibregl:t.maplibregl,onMarkerClick:t.onMarkerClick}),t.onRefresh&&this.attachEventListeners(t.onRefresh),t.onMapMoveEnd&&this.attachBoundsTracking(t.onMapMoveEnd),this.markerManager}attachBoundsTracking(t){if(!this.map||typeof this.map.on!="function")return;let a=()=>{let i=this.getMapBounds();t(i)},r=()=>{let i=this.getMapBounds();t(i)};this.map.loaded&&this.map.loaded()?r():(this.map.once("load",r),this.cleanupFns.push(()=>{typeof this.map.off=="function"&&this.map.off("load",r)})),this.map.on("moveend",a),this.cleanupFns.push(()=>{typeof this.map.off=="function"&&this.map.off("moveend",a)})}attachEventListeners(t){if(!this.map||typeof this.map.on!="function")return;["move","zoom","dragend","pitch","rotate"].forEach(r=>{this.map.on(r,t),this.cleanupFns.push(()=>{typeof this.map.off=="function"&&this.map.off(r,t)})})}getMarkerManager(){return this.markerManager}getContainer(){var t,a;return((a=(t=this.map)==null?void 0:t.getContainer)==null?void 0:a.call(t))||null}cleanup(){for(let t of this.cleanupFns)try{t()}catch{}this.cleanupFns.length=0}getMap(){return this.map}getCenter(){let t=this.map.getCenter();return{lng:t.lng,lat:t.lat}}getZoom(){return this.map.getZoom()}getBearing(){return this.map.getBearing()}getPitch(){return this.map.getPitch()}getMapBounds(){let t=this.map.getBounds(),a=t.getSouthWest(),r=t.getNorthEast();return{sw:{lat:a.lat,lng:a.lng},ne:{lat:r.lat,lng:r.lng}}}project(t){return this.map.project({lng:t[0],lat:t[1]})}on(t,a){this.map.on(t,a)}off(t,a){this.map.off(t,a)}resize(){this.map.resize()}remove(){this.cleanup(),this.map.remove()}};var F=class extends E{constructor(t){super(t);this.cleanupFns=[];this.initializeOverlayView()}initialize(t){return this.markerManager=new B({mapInstance:this.map,google:t.google,onMarkerClick:t.onMarkerClick}),t.onRefresh&&this.attachEventListeners(t.onRefresh),t.onMapMoveEnd&&this.attachBoundsTracking(t.onMapMoveEnd,t.google),this.markerManager}attachBoundsTracking(t,a){if(!this.map)return;let r=()=>{let s=this.getMapBounds();t(s)};r();let i=a.event.addListener(this.map,"idle",r);this.cleanupFns.push(()=>{a.event.removeListener(i)})}attachEventListeners(t){let a=["center_changed","zoom_changed","drag","heading_changed","tilt_changed"],r=[];a.forEach(i=>{let s=this.map.addListener(i,t);r.push(s)}),this.cleanupFns.push(()=>{r.forEach(i=>{try{i.remove()}catch{}})})}getMarkerManager(){return this.markerManager}getContainer(){var t,a;return((a=(t=this.map)==null?void 0:t.getDiv)==null?void 0:a.call(t))||null}cleanup(){for(let t of this.cleanupFns)try{t()}catch{}this.cleanupFns.length=0}initializeOverlayView(){var r;let t=(r=globalThis.google)==null?void 0:r.maps;if(!t)return;let a=t.OverlayView;a&&(this.overlayView=new a,this.overlayView.draw=function(){},this.overlayView.setMap(this.map))}getMap(){return this.map}getCenter(){let t=this.map.getCenter();return t?{lng:t.lng(),lat:t.lat()}:{lng:0,lat:0}}getZoom(){var t;return(t=this.map.getZoom())!=null?t:0}getBearing(){var t;return(t=this.map.getHeading())!=null?t:0}getPitch(){var t;return(t=this.map.getTilt())!=null?t:0}getMapBounds(){let t=this.map.getBounds();if(!t)return{sw:{lat:0,lng:0},ne:{lat:0,lng:0}};let a=t.getSouthWest(),r=t.getNorthEast();return{sw:{lat:a.lat(),lng:a.lng()},ne:{lat:r.lat(),lng:r.lng()}}}project(t){var o;if(!this.overlayView)return{x:0,y:0};let a=this.overlayView.getProjection();if(!a)return{x:0,y:0};let r=(o=globalThis.google)==null?void 0:o.maps;if(!r)return{x:0,y:0};let i=new r.LatLng(t[1],t[0]),s=a.fromLatLngToContainerPixel(i);return s?{x:s.x,y:s.y}:{x:0,y:0}}on(t,a){this.map.addListener(t,a)}off(t,a){var i;let r=(i=globalThis.google)==null?void 0:i.maps;r!=null&&r.event&&r.event.clearListeners(this.map,t)}resize(){var a;let t=(a=globalThis.google)==null?void 0:a.maps;t!=null&&t.event&&t.event.trigger(this.map,"resize")}remove(){this.cleanup(),this.overlayView&&(this.overlayView.setMap(null),this.overlayView=null)}};var H=class extends E{constructor(t){super(t);this.cleanupFns=[]}initialize(t){return this.markerManager=new _({mapInstance:this.map,mapboxgl:t.mapboxgl,onMarkerClick:t.onMarkerClick}),t.onRefresh&&this.attachEventListeners(t.onRefresh),t.onMapMoveEnd&&this.attachBoundsTracking(t.onMapMoveEnd),this.markerManager}attachBoundsTracking(t){if(!this.map||typeof this.map.on!="function")return;let a=()=>{let i=this.getMapBounds();t(i)},r=()=>{let i=this.getMapBounds();t(i)};this.map.loaded&&this.map.loaded()?r():(this.map.once("load",r),this.cleanupFns.push(()=>{typeof this.map.off=="function"&&this.map.off("load",r)})),this.map.on("moveend",a),this.cleanupFns.push(()=>{typeof this.map.off=="function"&&this.map.off("moveend",a)})}attachEventListeners(t){if(!this.map||typeof this.map.on!="function")return;["move","zoom","dragend","pitch","rotate"].forEach(r=>{this.map.on(r,t),this.cleanupFns.push(()=>{typeof this.map.off=="function"&&this.map.off(r,t)})})}getMarkerManager(){return this.markerManager}getContainer(){var t,a;return((a=(t=this.map)==null?void 0:t.getContainer)==null?void 0:a.call(t))||null}cleanup(){for(let t of this.cleanupFns)try{t()}catch{}this.cleanupFns.length=0}getMap(){return this.map}getCenter(){let t=this.map.getCenter();return{lng:t.lng,lat:t.lat}}getZoom(){return this.map.getZoom()}getBearing(){return this.map.getBearing()}getPitch(){return this.map.getPitch()}getMapBounds(){let t=this.map.getBounds(),a=t.getSouthWest(),r=t.getNorthEast();return{sw:{lat:a.lat,lng:a.lng},ne:{lat:r.lat,lng:r.lng}}}project(t){return this.map.project({lng:t[0],lat:t[1]})}on(t,a){this.map.on(t,a)}off(t,a){this.map.off(t,a)}resize(){this.map.resize()}remove(){this.cleanup(),this.map.remove()}};function J(n){let e=n.getCenter();return{longitude:e.lng,latitude:e.lat,zoom:n.getZoom(),bearing:n.getBearing(),pitch:n.getPitch()}}var fe=[{zoom:6,threshold:120},{zoom:8,threshold:108},{zoom:10,threshold:92},{zoom:12,threshold:80},{zoom:14,threshold:68},{zoom:16,threshold:56}];function Y(n){for(let e of fe)if(n<=e.zoom)return e.threshold;return 48}function q({primaryType:n,markers:e,map:t,selectedMarkerId:a,zoom:r,collisionThresholdPx:i,dotCollisionThresholdPx:s}){if(!e.length)return[];if(!t)return e.map(d=>({kind:"primary",marker:d,key:`primary-${d.tripadvisor_id}`}));let o=e.map((d,g)=>{let f=d.location;if(typeof(f==null?void 0:f.lon)!="number"||typeof(f==null?void 0:f.lat)!="number")return null;let{x:m,y:h}=t.project([f.lon,f.lat]);return{marker:d,index:g,x:m,y:h}}).filter(d=>!!d);if(!o.length)return[];let l=Y(r),u=ge(r),y=o.map((d,g)=>g),M=d=>y[d]===d?d:(y[d]=M(y[d]),y[d]),c=(d,g)=>{let f=M(d),m=M(g);f!==m&&(y[m]=f)};for(let d=0;d<o.length;d+=1)for(let g=d+1;g<o.length;g+=1){let f=o[d].x-o[g].x,m=o[d].y-o[g].y;Math.hypot(f,m)<=l&&c(d,g)}let p=new Map;for(let d of o){let g=M(d.index),f=p.get(g);f?f.push(d):p.set(g,[d])}let b=[];return p.forEach(d=>{var C,L;if(d.length===1){let[{marker:k}]=d,v=k.type===n,A=a===k.tripadvisor_id;b.push({kind:"primary",marker:k,key:`primary-${k.tripadvisor_id}-p${v?1:0}-s${A?1:0}-${(C=k.pricing)==null?void 0:C.availability}`});return}let g=[...d].sort((k,v)=>ye(v.marker,k.marker,n)),[f,...m]=g,h=f.marker.type===n,P=a===f.marker.tripadvisor_id;if(b.push({kind:"primary",marker:f.marker,key:`primary-${f.marker.tripadvisor_id}-p${h?1:0}-s${P?1:0}-${(L=f.marker.pricing)==null?void 0:L.availability}`}),!m.length)return;let T=[],x=[];if(m.forEach(k=>{var v;if(a&&k.marker.tripadvisor_id===a){let A=k.marker.type===n;b.push({kind:"primary",marker:k.marker,key:`primary-${k.marker.tripadvisor_id}-p${A?1:0}-s1-${(v=k.marker.pricing)==null?void 0:v.availability}`});return}he(f,k)<=u?T.push(k):x.push(k)}),T.forEach(k=>{var A;let v=k.marker.type===n;b.push({kind:"dot",marker:k.marker,key:`dot-${k.marker.tripadvisor_id}-p${v?1:0}-s0-${(A=k.marker.pricing)==null?void 0:A.availability}`,parentId:f.marker.tripadvisor_id})}),x.length){let k=q({markers:x.map(v=>v.marker),map:t,selectedMarkerId:a,zoom:r,primaryType:n,collisionThresholdPx:i,dotCollisionThresholdPx:s});b.push(...k)}}),b}function he(n,e){return Math.hypot(n.x-e.x,n.y-e.y)}function ge(n){let e=Y(n);return Math.max(48,e)}function ye(n,e,t){var l,u;let a=n.type===t,r=e.type===t;if(a&&!r)return 1;if(!a&&r)return-1;let i=W(n)-W(e);if(i!==0)return i;let s=X(n)-X(e);if(s!==0)return s;let o=((l=n.reviews)!=null?l:0)-((u=e.reviews)!=null?u:0);return o!==0?o:n.tripadvisor_id-e.tripadvisor_id}function W(n){if(typeof n.rating=="number")return n.rating;if(n.rating===void 0||n.rating===null)return-1/0;let e=Number(n.rating);return Number.isNaN(e)?-1/0:e}function X(n){var t,a,r;if(!((a=(t=n.pricing)==null?void 0:t.offer)!=null&&a.price))return-1/0;let e=Number(((r=n.pricing.offer.displayPrice)!=null?r:"0").replace(/[^0-9.,-]+/g,"").replace(/,/g,""));return Number.isNaN(e)?-1/0:e}function be(n){let e=[];return n.amenities&&Array.isArray(n.amenities)&&n.amenities.forEach(t=>{e.push({id:`amenity-${t}`,label:t,type:"amenity",value:t})}),n.hotelStyle&&Array.isArray(n.hotelStyle)&&n.hotelStyle.forEach(t=>{e.push({id:`hotelStyle-${t}`,label:t,type:"hotelStyle",value:t})}),n.price&&e.push({id:"priceRange",label:"Price Range",type:"priceRange",value:`${n.price.min}-${n.price.max}`,priceRange:n.price}),typeof n.minRating=="number"&&Number.isFinite(n.minRating)&&e.push({id:"minRating",label:`${n.minRating}+`,type:"minRating",value:String(n.minRating),numericValue:n.minRating}),typeof n.starRating=="number"&&Number.isFinite(n.starRating)&&e.push({id:"starRating",label:`${n.starRating} Stars`,type:"starRating",value:String(n.starRating),numericValue:n.starRating}),n.transformed_query&&e.push({id:"transformed_query",label:n.transformed_query,type:"transformed_query",value:n.transformed_query}),n.selected_restaurant_price_levels&&e.push({id:"selected_restaurant_price_levels",label:n.selected_restaurant_price_levels.join(", "),type:"selected_restaurant_price_levels",value:n.selected_restaurant_price_levels.join(", "),priceLevels:n.selected_restaurant_price_levels}),e}function Me(n){return n.map(e=>{let t={id:e.id,label:typeof e.label=="string"?e.label:String(e.label||""),type:e.type,value:e.value};if(e.numericValue!==void 0&&(t.numericValue=e.numericValue),e.priceRange){let a=e.priceRange.min,r=e.priceRange.max;a!==void 0&&(t.priceRange={min:a,...r!==void 0&&{max:r}})}return e.priceLevels&&(t.priceLevels=e.priceLevels),t})}var ke={prod:"https://api.mapfirst.ai",test:"https://api.mapfirst.ai/test"},D=class extends Error{constructor({message:e,status:t,code:a}){super(e),this.name="PropertiesFetchError",this.status=t,this.code=a}};async function K(n,e=1){try{let t=await fetch(`https://l4detuz832.execute-api.us-east-1.amazonaws.com/dev/photo?id=${n}&limit=${e}`);if(!t.ok)return null;let a=await t.json();if(a.photos&&a.photos.length>0){let r=a.photos[0].FullSizeURL.url;if((await fetch(r)).ok)return r}return null}catch(t){return console.debug("Failed to fetch images:",t),null}}async function ve(n,e,t,{signal:a}={}){var i,s;let r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",...t&&{"X-API-Key":t}},body:JSON.stringify(e),signal:a});if(!r.ok){let o=`Unexpected response: ${r.status}`,l;try{let u=await r.json();o=(s=(i=u.detail)!=null?i:u.error)!=null?s:o,l=u.code}catch{}throw new D({message:o,status:r.status,code:l})}return await r.json()}function Q(n){return typeof n=="string"?n:n.toISOString().slice(0,10)}var ee="Accommodation";function Pe(){let e=new Date(Date.now()+864e6),t=(6-e.getDay()+7)%7,a=new Date(e.getTime()+t*864e5),r=a.getDay(),i=r===0?6:6-r,s=new Date(a.getTime()+(i+1)*864e5);return{checkIn:a,checkOut:s}}var te=class{constructor(e){this.options=e;this.adapter=null;this.properties=[];this.selectedMarkerId=null;this.destroyed=!1;this.clusterItems=[];this.isMapAttached=!1;var r,i,s,o,l,u,y,M,c,p,b,d,g,f,m,h;if(this.properties=[...(r=e.properties)!=null?r:[]],this.primaryType=e.primaryType,this.selectedMarkerId=(i=e.selectedMarkerId)!=null?i:null,this.useApi=(s=e.useApi)!=null?s:!0,this.environment=(o=e.environment)!=null?o:"prod",this.apiUrl=(l=e.apiUrl)!=null?l:ke[this.environment],this.apiKey=e.apiKey,this.requestBody=e.requestBody,this.currentPlatform=e.platform,!this.useApi&&e.platform&&e.platform!=="maplibre")throw new Error("When useApi is false, only maplibre platform is supported. Google Maps and Mapbox require API usage.");let t=re(e);this.fitBoundsPadding={top:(y=(u=e.fitBoundsPadding)==null?void 0:u.top)!=null?y:t?0:50,bottom:(c=(M=e.fitBoundsPadding)==null?void 0:M.bottom)!=null?c:t?0:160,left:(b=(p=e.fitBoundsPadding)==null?void 0:p.left)!=null?b:t?0:50,right:(g=(d=e.fitBoundsPadding)==null?void 0:d.right)!=null?g:t?0:50};let a=Pe();this.state={center:[0,0],zoom:0,bounds:null,pendingBounds:null,tempBounds:null,properties:this.properties,primary:(f=this.primaryType)!=null?f:ee,selectedPropertyId:this.selectedMarkerId,initialLoading:!0,isSearching:!1,firstCallDone:!1,filters:{checkIn:a.checkIn,checkOut:a.checkOut,numAdults:2,numRooms:1,...((m=e.initialLocationData)==null?void 0:m.currency)&&{currency:e.initialLocationData.currency}},activeLocation:{country:"",location_id:null,locationName:"",coordinates:[0,0]},isFlyToAnimating:!1,...e.state},this.callbacks=(h=e.callbacks)!=null?h:{},this.hasMapInstance(e)&&(this.adapter=this.createAdapter(e),this.isMapAttached=!0,this.refresh()),e.initialLocationData?this.initializeFromLocationData(e.initialLocationData):this.requestBody&&this.isMapAttached&&this.autoLoadProperties()}hasMapInstance(e){return!!("adapter"in e&&e.adapter||"mapInstance"in e&&e.mapInstance)}async initializeFromLocationData(e){if(!this.useApi){console.warn("initializeFromLocationData requires API usage. Set useApi to true.");return}try{let{city:t,country:a,query:r}=e,i={filters:this.getFilters(),initial:!0};if(t&&a||a){let s=await fetch(`${this.apiUrl}/geo-lookup?country=${encodeURIComponent(a)}${t?`&city=${encodeURIComponent(t)}`:""}`,{headers:{...this.apiKey&&{"X-API-Key":this.apiKey}}});if(s.ok){let o=await s.json(),l=t;o.location_name&&o.path3_name&&o.location_name===o.path3_name&&(l=void 0),o.location_name&&(l=o.location_name);let u=o.path3_name||a;i={...i,city:l,country:u,location_id:o.location_id,longitude:o.longitude,latitude:o.latitude},this.setActiveLocation({city:l,country:u,location_id:o.location_id,locationName:l&&u?`${l}, ${u}`:u||"",coordinates:[o.latitude,o.longitude]}),this.setState({center:[o.latitude,o.longitude],zoom:12})}else this.handleError(new Error(`Geo mapping fetch failed: ${s.statusText}`),"initializeFromLocationData")}else r&&(i.query=r);this.requestBody=i,this.isMapAttached&&await this.autoLoadProperties()}catch(t){this.handleError(t,"initializeFromLocationData")}}async autoLoadProperties(){if(!this.useApi){console.warn("autoLoadProperties requires API usage. Set useApi to true.");return}if(!this.requestBody)return;let e={filters:this.getFilters(),initial:!0,...this.requestBody};await this.runPropertiesSearch({body:e,onError:t=>{var a,r;this.handleError(t,"autoLoadProperties"),(r=(a=this.callbacks).onPropertiesLoadError)==null||r.call(a,t)}})}attachMap(e,t){if(!this.useApi&&t.platform!=="maplibre")throw new Error("When useApi is false, only maplibre platform is supported. Google Maps and Mapbox require API usage.");if(this.isMapAttached&&(console.warn("Map is already attached. Destroying previous adapter."),this.adapter)){let r=this.adapter.getMarkerManager();r==null||r.destroy(),this.adapter.cleanup()}let a={...this.options,platform:t.platform,mapInstance:e,maplibregl:t.maplibregl,google:t.google,mapboxgl:t.mapboxgl,onMarkerClick:t.onMarkerClick};this.currentPlatform=t.platform,this.adapter=this.createAdapter(a),this.isMapAttached=!0,this.refresh(),this.requestBody&&!this.state.firstCallDone&&this.autoLoadProperties()}createAdapter(e){return xe(e)&&e.mapInstance?this.initializeAdapter(new R(e.mapInstance),{maplibregl:e.maplibregl,onMarkerClick:e.onMarkerClick}):re(e)&&e.mapInstance?this.initializeAdapter(new F(e.mapInstance),{google:e.google,onMarkerClick:e.onMarkerClick}):Le(e)&&e.mapInstance?this.initializeAdapter(new H(e.mapInstance),{mapboxgl:e.mapboxgl,onMarkerClick:e.onMarkerClick}):"adapter"in e&&e.adapter?e.adapter:null}initializeAdapter(e,t){var r;let a=(r=this.options.autoSelectOnClick)!=null?r:!0;return e.initialize({...t,onMarkerClick:i=>{var s;i.location&&this.flyMapTo(i.location.lon,i.location.lat,14),i.type!==this.primaryType&&this.setPrimaryType(i.type),a&&this.setSelectedMarker(i.tripadvisor_id===this.selectedMarkerId?null:i.tripadvisor_id),(s=t.onMarkerClick)==null||s.call(t,i)},onRefresh:()=>this.refresh(),onMapMoveEnd:i=>{this.state.tempBounds===null?(this.setTempBounds(i),this.setPendingBounds(null)):this.handleMapMoveEnd(i)}}),this.useApi&&e.setupImpressionTracking(()=>{console.log("ToDo: Track Map Impression")}),e}_setProperties(e){var t,a;this.ensureAlive(),this.properties=[...e.filter(r=>{var i;return r.type==="Accommodation"?((i=r.pricing)==null?void 0:i.availability)!=="unavailable":!0})],this.updateState({properties:this.properties}),(a=(t=this.callbacks).onPropertiesChange)==null||a.call(t,e),this.refresh()}addProperty(e){var t,a;this.ensureAlive(),this.properties=[...this.properties,e],this.updateState({properties:this.properties}),(a=(t=this.callbacks).onPropertiesChange)==null||a.call(t,this.properties),this.refresh()}clearProperties(){var e,t;this.ensureAlive(),this.properties=[],this.updateState({properties:[]}),(t=(e=this.callbacks).onPropertiesChange)==null||t.call(e,[]),this.refresh()}setPrimaryType(e){var t,a;this.ensureAlive(),this.primaryType!==e&&(this.primaryType=e,this.updateState({primary:e}),(a=(t=this.callbacks).onPrimaryTypeChange)==null||a.call(t,e),this.refresh())}setSelectedMarker(e){var t,a;if(this.ensureAlive(),this.selectedMarkerId!==e){if(e!==null){let r=this.properties.find(i=>i.tripadvisor_id===e);r&&r.type!==this.primaryType&&this.setPrimaryType(r.type)}this.selectedMarkerId=e,this.updateState({selectedPropertyId:e}),(a=(t=this.callbacks).onSelectedPropertyChange)==null||a.call(t,e),this.refresh()}}getState(){return{...this.state}}handleError(e,t="MapFirstCore"){let a=e instanceof Error?e.message:String(e),r=e instanceof Error?e:new Error(a);console.error(`[${t}]`,a),this.callbacks.onError&&this.callbacks.onError(r,t)}updateState(e){this.state={...this.state,...e}}setState(e){var a,r,i,s,o,l,u,y,M,c,p,b,d,g,f,m;let t={...this.state};this.updateState(e),e.center!==void 0&&e.center!==t.center&&((r=(a=this.callbacks).onCenterChange)==null||r.call(a,e.center,this.state.zoom)),e.zoom!==void 0&&e.zoom!==t.zoom&&((s=(i=this.callbacks).onZoomChange)==null||s.call(i,e.zoom)),e.bounds!==void 0&&e.bounds!==t.bounds&&((l=(o=this.callbacks).onBoundsChange)==null||l.call(o,e.bounds)),e.pendingBounds!==void 0&&e.pendingBounds!==t.pendingBounds&&((y=(u=this.callbacks).onPendingBoundsChange)==null||y.call(u,e.pendingBounds)),e.filters!==void 0&&e.filters!==t.filters&&((c=(M=this.callbacks).onFiltersChange)==null||c.call(M,e.filters)),e.activeLocation!==void 0&&e.activeLocation!==t.activeLocation&&((b=(p=this.callbacks).onActiveLocationChange)==null||b.call(p,e.activeLocation)),e.initialLoading!==void 0&&e.initialLoading!==t.initialLoading&&((g=(d=this.callbacks).onLoadingStateChange)==null||g.call(d,e.initialLoading)),e.isSearching!==void 0&&e.isSearching!==t.isSearching&&((m=(f=this.callbacks).onSearchingStateChange)==null||m.call(f,e.isSearching))}setFilters(e){this.setState({filters:e})}setActiveLocation(e){this.setState({activeLocation:e})}setBounds(e){this.setState({bounds:e})}setPendingBounds(e){this.setState({pendingBounds:e})}setTempBounds(e){this.setState({tempBounds:e})}setLoading(e){this.setState({initialLoading:e})}setSearching(e){this.setState({isSearching:e})}setFlyToAnimating(e){this.setState({isFlyToAnimating:e})}handleMapMoveEnd(e){if(this.state.isFlyToAnimating){this.setState({isFlyToAnimating:!1,tempBounds:e,pendingBounds:null});return}let t=this.state.tempBounds;if(!t){this.setState({tempBounds:e,pendingBounds:e});return}let a=.01;Math.abs(e.sw.lat-t.sw.lat)>a||Math.abs(e.sw.lng-t.sw.lng)>a||Math.abs(e.ne.lat-t.ne.lat)>a||Math.abs(e.ne.lng-t.ne.lng)>a?this.setState({pendingBounds:e}):this.setState({pendingBounds:null})}flyMapTo(e,t,a,r=!0){if(this.ensureAlive(),this.setState({center:[t,e]}),typeof a=="number"&&this.setState({zoom:a}),!this.adapter)return;let i=this.adapter.getMap();if(i){if(this.currentPlatform==="google"){this.setFlyToAnimating(!1),i.setCenter({lat:t,lng:e}),a!==null&&typeof a=="number"&&i.setZoom(a!=null?a:13);return}if(r===!1){this.setFlyToAnimating(!1),i.jumpTo&&i.jumpTo({center:[e,t],...a!==null&&{zoom:a!=null?a:13}});return}this.setFlyToAnimating(!0),i.flyTo&&i.flyTo({center:[e,t],...a!==null&&{zoom:a!=null?a:13}})}}flyToPOIs(e,t,a=!0){var s,o;if(this.ensureAlive(),!this.adapter)return;let r=this.adapter.getMap();if(!r)return;let i=e;if((!i||i.length===0)&&(i=this.properties.filter(l=>l.location!==void 0&&(t!==void 0?l.type===t:!0)).map(l=>({lat:l.location.lat,lng:l.location.lon}))),!(!i||i.length===0)){if(i.length===1){let l=i[0];this.currentPlatform==="google"?(r.setCenter({lat:l.lat,lng:l.lng}),r.setZoom(13)):r.flyTo&&r.flyTo({center:[l.lng,l.lat],zoom:13})}else if(this.currentPlatform==="google"){let l=(o=(s=window.google)==null?void 0:s.maps)==null?void 0:o.LatLngBounds;if(l){let u=new l;i.forEach(y=>{u.extend({lat:y.lat,lng:y.lng})}),a&&this.setFlyToAnimating(!0),r.fitBounds(u,this.fitBoundsPadding)}}else if(r.fitBounds){let l=[[i[0].lng,i[0].lat],[i[0].lng,i[0].lat]];i.forEach(u=>{l[0][0]=Math.min(l[0][0],u.lng),l[0][1]=Math.min(l[0][1],u.lat),l[1][0]=Math.max(l[1][0],u.lng),l[1][1]=Math.max(l[1][1],u.lat)}),a&&this.setFlyToAnimating(!0),r.fitBounds(l,{padding:this.fitBoundsPadding,animate:a})}}}getFilters(){let e={...this.state.filters};return e.checkIn instanceof Date&&(e.checkIn=Q(e.checkIn)),e.checkOut instanceof Date&&(e.checkOut=Q(e.checkOut)),e}async pollForPricing({pollingLink:e,maxAttempts:t=15,delayMs:a=2e3,isCancelled:r,price:i,limit:s}){var M,c,p,b,d;if(this.ensureAlive(),!this.useApi)return console.warn("pollForPricing requires API usage. Set useApi to true."),{completed:!1};if(!e)return{completed:!1};let o=!1,l,u=this.getFilters();s&&(u.limit=s);let y={filters:u,pollingLink:e};for(let g=0;g<t;g++){if(r!=null&&r())return{completed:o,pollData:l};try{let f=await fetch(`${this.apiUrl}/ta-polling?pollingNumber=${g}`,{method:"POST",body:JSON.stringify(y),headers:{"Content-Type":"application/json",...this.apiKey&&{"X-API-Key":this.apiKey}}});if(!f.ok)throw new D({message:`Poll failed: ${f.status}`,status:f.status});if(l=await f.json(),r!=null&&r())return{completed:o,pollData:l};let m=(c=(M=l==null?void 0:l.success)==null?void 0:M.results)!=null?c:[];if(m.length>0&&this.setProperties(h=>{let P=new Set(m.map(x=>x.tripadvisor_id)),T=h.filter(x=>x.type!=="Accommodation"||P.has(x.tripadvisor_id));return m.forEach(x=>{var L,k,v,A,w,j;if(!x.location)return;(k=(L=x.pricing)==null?void 0:L.offer)!=null&&k.price&&i&&(((A=(v=x.pricing)==null?void 0:v.offer)==null?void 0:A.price)<(i==null?void 0:i.min)||((j=(w=x.pricing)==null?void 0:w.offer)==null?void 0:j.price)>(i==null?void 0:i.max))&&(x.pricing.availability="unavailable");let C=T.findIndex(ae=>ae.tripadvisor_id===x.tripadvisor_id);C>=0?T[C]=x:T.push(x)}),T}),(p=l==null?void 0:l.success)!=null&&p.isComplete){o=!0;break}}catch(f){this.handleError(f,"pollForPricing"),(d=(b=this.callbacks).onPropertiesLoadError)==null||d.call(b,f);break}g<t-1&&await new Promise(f=>setTimeout(f,a))}return{completed:o,pollData:l}}setProperties(e){let t=e(this.properties);this._setProperties(t)}mostCommonTypeFromProperties(e){let t=e.reduce((a,r)=>(a[r.type]=(a[r.type]||0)+1,a),{});return Object.entries(t).reduce((a,r)=>t[a[0]]>t[r[0]]?a:r)[0]}async runPropertiesSearch({body:e,beforeApplyProperties:t,smartFiltersClearable:a,onError:r}){var i,s,o,l,u,y,M;if(this.ensureAlive(),!this.useApi)return console.warn("runPropertiesSearch requires API usage. Set useApi to true."),r==null||r(new Error("API usage is disabled")),null;this.setState({firstCallDone:!1}),this.setSearching(!0),this.clearProperties();try{let c=await ve(`${this.apiUrl}/properties`,e,this.apiKey);this.updateActiveLocationFromResponse(c);let p=null,b=30,d=c.filters.primary_type;if(t){let m=t(c);p=(i=m.price)!=null?i:null,b=(s=m.limit)!=null?s:30}let g=c.properties.some(m=>!!m.location),f=p?c.properties.map(m=>{var h;return(h=m.pricing)!=null&&h.offer?{...m,pricing:{...m.pricing,availability:m.pricing.offer.price&&(m.pricing.offer.price<p.min||m.pricing.offer.price>p.max)?"unavailable":m.pricing.availability}}:m}):c.properties;if(this._setProperties(f),g&&this.flyToPOIs(c.properties.filter(m=>!!m.location&&(c.filters.primary_type?m.type===c.filters.primary_type:!0)).map(m=>({lat:m.location.lat,lng:m.location.lon})),void 0,e.initial!==!0),c.filters.primary_type&&c.properties.filter(m=>{var h;return m.type===c.filters.primary_type&&(m.type==="Accommodation"?((h=m.pricing)==null?void 0:h.availability)!=="unavailable":!0)}).length>0)d=c.filters.primary_type,this.setPrimaryType(c.filters.primary_type);else if(c.properties.length>0){let m=this.mostCommonTypeFromProperties(c.properties);this.setPrimaryType(m),d=m}if(this.setState({firstCallDone:!0}),c.isComplete===!1&&c.pollingLink){let{completed:m,pollData:h}=await this.pollForPricing({pollingLink:c.pollingLink,...p&&{price:p},...b&&{limit:b}});if(m&&((o=h==null?void 0:h.success)!=null&&o.results)&&h.success.results.filter(P=>{var T;return P.type===c.filters.primary_type&&(P.type==="Accommodation"?((T=P.pricing)==null?void 0:T.availability)!=="unavailable":!0)}).length===0&&d&&d!==c.filters.primary_type){let P=this.mostCommonTypeFromProperties(c.properties);this.setPrimaryType(P)}m&&this.refresh()}return g||(c.properties.some(m=>!!m.location)?this.flyToPOIs(c.properties.filter(m=>!!m.location&&(c.filters.primary_type?m.type===c.filters.primary_type:!0)).map(m=>({lat:m.location.lat,lng:m.location.lon})),void 0,e.initial!==!0):(l=c.filters.location)!=null&&l.latitude&&((u=c.filters.location)!=null&&u.longitude)&&this.flyMapTo(c.filters.location.longitude,c.filters.location.latitude,12,e.initial!==!0)),c}catch(c){return this.handleError(c,"runPropertiesSearch"),r==null||r(c),(M=(y=this.callbacks).onPropertiesLoadError)==null||M.call(y,c),this.clearProperties(),this.setState({firstCallDone:!0}),null}finally{this.setSearching(!1),this.setState({firstCallDone:!0})}}async performBoundsSearch(){var i;if(this.ensureAlive(),!this.useApi)return console.warn("performBoundsSearch requires API usage. Set useApi to true."),null;if(!this.state.pendingBounds)return null;let e=this.getFilters(),t={bounds:this.state.pendingBounds,filters:e},a=(i=e==null?void 0:e.price)!=null?i:void 0,r=await this.runPropertiesSearch({body:t,beforeApplyProperties:()=>({price:a!=null?a:null})});return r&&(this.setBounds(this.state.pendingBounds),this.setTempBounds(this.state.pendingBounds),this.setPendingBounds(null)),r}updateActiveLocationFromResponse(e){var o,l,u,y;let t=(o=e.location_id)!=null?o:null,a=(u=(l=e.filters.location)==null?void 0:l.city)!=null?u:void 0,r=((y=e.filters.location)==null?void 0:y.country)||"",i=e.filters.location?[e.filters.location.latitude,e.filters.location.longitude]:void 0;if(!i)return;let s=this.state.activeLocation;(t!==(s==null?void 0:s.location_id)||a!==(s==null?void 0:s.city)||r!==(s==null?void 0:s.country))&&this.setActiveLocation({city:a,country:r,location_id:t,locationName:a&&r?`${a}, ${r}`:r||"",coordinates:i})}async runSmartFilterSearch({query:e,filters:t,onProcessFilters:a,onError:r}){if(this.ensureAlive(),!this.useApi)return console.warn("runSmartFilterSearch requires API usage. Set useApi to true."),r==null||r(new Error("API usage is disabled")),null;let i=this.getFilters(),s=this.getState();if(t&&t.length>0){let l=new Set,u=new Set,y,M,c,p,b,d;t.forEach(g=>{var f,m,h;switch(g.type){case"amenity":l.add(g.value);break;case"hotelStyle":u.add(g.value);break;case"priceRange":g.priceRange&&(y={min:g.priceRange.min,max:(f=g.priceRange.max)!=null?f:0});break;case"minRating":M=(m=g.numericValue)!=null?m:Number(g.value);break;case"starRating":c=(h=g.numericValue)!=null?h:Number(g.value);break;case"primary_type":p=g.propertyType;break;case"transformed_query":b=g.value;break;case"selected_restaurant_price_levels":d=g.priceLevels;break}}),i={...i,...l.size>0&&{amenities:Array.from(l)},...u.size>0&&{hotelStyle:Array.from(u)},...y&&{price:y},...M!==void 0&&{minRating:M},...c!==void 0&&{starRating:c},...p&&{primary_type:p},...b&&{transformed_query:b},...d&&{selected_restaurant_price_levels:d}}}else e||(i.minRating=4);let o={filters:i,...e&&{query:e},...s.bounds?{bounds:s.bounds}:s.activeLocation.location_id?{location_id:s.activeLocation.location_id}:s.activeLocation.coordinates?{latitude:s.activeLocation.coordinates[0],longitude:s.activeLocation.coordinates[1]}:{}};return this.runPropertiesSearch({body:o,beforeApplyProperties:a?l=>{var y,M;let u=a(l.filters,l.location_id);return{price:(y=u.price)!=null?y:null,limit:(M=u.limit)!=null?M:30}}:void 0,smartFiltersClearable:!!e,onError:r})}getClusters(){return this.ensureAlive(),[...this.clusterItems]}setUseApi(e,t=!0){this.ensureAlive(),this.useApi=e,!e&&this.currentPlatform&&this.currentPlatform!=="maplibre"&&console.warn("When useApi is false, only maplibre platform is supported. Please switch to maplibre."),e||this.clearProperties(),e&&t&&(this.options.initialLocationData?this.initializeFromLocationData(this.options.initialLocationData):this.requestBody&&this.isMapAttached&&this.autoLoadProperties())}setApiKey(e){this.ensureAlive();let t=this.apiKey;this.apiKey=e,t!==this.apiKey&&this.isMapAttached&&(this.refresh(),this.useApi&&(this.options.initialLocationData?this.initializeFromLocationData(this.options.initialLocationData):this.requestBody&&this.autoLoadProperties()))}getApiKey(){return this.apiKey}refresh(){var r,i,s;if(this.ensureAlive(),!this.adapter)return;let e=this.safeExtractViewState(),t=this.resolvePrimaryType();this.clusterItems=q({primaryType:t,markers:this.properties,map:this.adapter,selectedMarkerId:this.selectedMarkerId,zoom:(r=e==null?void 0:e.zoom)!=null?r:0}),this.adapter.getMarkerManager().render(this.clusterItems,t,this.selectedMarkerId),(s=(i=this.options).onClusterUpdate)==null||s.call(i,this.clusterItems,e)}destroy(){this.destroyed||(this.adapter&&(this.adapter.getMarkerManager().destroy(),this.adapter.cleanup()),this.clusterItems=[],this.properties=[],this.destroyed=!0,this.isMapAttached=!1)}resolvePrimaryType(){var e,t,a;return(a=(t=this.primaryType)!=null?t:(e=this.properties.find(r=>r.type))==null?void 0:e.type)!=null?a:ee}safeExtractViewState(){if(!this.adapter)return null;try{return J(this.adapter)}catch{return null}}ensureAlive(){if(this.destroyed)throw new Error("MapFirstCore instance has been destroyed")}};function xe(n){return n.platform==="maplibre"}function re(n){return n.platform==="google"}function Le(n){return n.platform==="mapbox"}export{te as MapFirstCore,D as PropertiesFetchError,Me as convertToApiFilters,K as fetchImages,ve as fetchProperties,be as processApiFilters};
32
+ `,t}function me(n,e){let t=n.querySelector(".mapfirst-property-hover-image");if(t&&e.tripadvisor_id&&!t.dataset.imageLoaded){t.dataset.imageLoaded="loading";let a=t.dataset.defaultImage;U(e.tripadvisor_id,1).then(r=>{if(r&&t){let i=document.createElement("img");i.src=r,i.alt=e.name,i.style.width="100%",i.style.height="100%",i.style.objectFit="cover",t.innerHTML="",t.appendChild(i),t.classList.remove("mapfirst-property-hover-image-placeholder"),t.dataset.imageLoaded="true"}else throw new Error("No image URL")}).catch(()=>{if(a&&t){let r=document.createElement("img");r.src=a,r.alt=e.name,r.style.width="100%",r.style.height="100%",r.style.objectFit="cover",t.innerHTML="",t.appendChild(r),t.classList.remove("mapfirst-property-hover-image-placeholder"),t.dataset.imageLoaded="false"}})}}function G(n,e,t){let a=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=270,s=120,o=12,p=r.right-a.right,u=a.left-r.left,y=r.bottom-a.bottom,M=a.top-r.top,c=a.left-r.left+a.width/2-i/2,l=a.top-r.top+a.height+o;c<0?c=8:c+i>r.width&&(c=r.width-i-8),y<s+o&&M>y&&(l=a.top-r.top-s-o),n.style.left=`${c}px`,n.style.top=`${l}px`}function V(n,e,t,a){var d,g,f,m,h,P,T,x,C;if(typeof document=="undefined")return null;let r=n.marker,i=r.type===e,s=t===r.tripadvisor_id,o=r.type==="Accommodation",p=(g=(d=r.pricing)==null?void 0:d.offer)==null?void 0:g.displayPrice,u=o&&!p,y=(()=>{if(r.rating===void 0||r.rating===null)return null;let L=typeof r.rating=="number"?r.rating:Number(r.rating);return Number.isNaN(L)||L<=0?null:L.toFixed(1)})(),M=document.createElement("div");M.className="mapfirst-marker-root",M.style.zIndex=s?"20":i?"12":"11";let c=(h=(m=(f=r.pricing)==null?void 0:f.offer)==null?void 0:m.clickUrl)!=null?h:r.url,l=document.createElement(c?"a":"div");if(c&&(l.href=c,l.target="_blank",l.style.textDecoration="none"),l.className=u?"mapfirst-marker-pill mapfirst-marker-pill-pending":`mapfirst-marker-pill mapfirst-marker-pill-active${s?" mapfirst-marker-selected":i?"":" mapfirst-marker-non-primary"}`,!u&&((P=r.awards)!=null&&P.length||y)){let L=document.createElement("div");if(L.className="mapfirst-marker-badge",i||(L.style.opacity="0.2"),L.className="mapfirst-marker-badge",(T=r.awards)!=null&&T.length&&r.awards[0].type){let k=document.createElement("div");k.className="mapfirst-marker-award-container";let v=document.createElement("div");v.className="mapfirst-marker-award-back",v.innerHTML=ne;let A=document.createElement("div");A.className=`mapfirst-marker-award-dot mapfirst-marker-award-dot-type-${r.awards[0].type}`;let w=document.createElement("div");w.className="mapfirst-marker-award-front",w.innerHTML=ie,k.appendChild(v),k.appendChild(A),k.appendChild(w),L.appendChild(k)}else y&&(L.className="mapfirst-marker-badge mapfirst-marker-rating-badge",L.textContent=y);l.appendChild(L)}let b=document.createElement("span");return b.className="mapfirst-marker-content",o?(C=(x=r.pricing)==null?void 0:x.offer)!=null&&C.displayPrice?(b.innerHTML=r.pricing.offer.displayPrice,b.dataset.price=r.pricing.offer.displayPrice):(b.innerHTML=pe,b.dataset.price=""):r.type==="Eat & Drink"?b.innerHTML=se:r.type==="Attraction"&&(b.innerHTML=oe),l.appendChild(b),l.addEventListener("click",L=>{L.stopPropagation(),u||a==null||a(r)}),u||S(M,l,r,s),M.appendChild(l),M}function K(n,e,t,a){var M,c,l;if(typeof document=="undefined")return null;let r=n.marker,i=r.type===e,s=t===r.tripadvisor_id,p=r.type==="Accommodation"&&((c=(M=r.pricing)==null?void 0:M.offer)==null?void 0:c.availability)!=="available",u=document.createElement("div");u.className="mapfirst-dot-marker-container",u.style.zIndex=s?"20":i?"3":"1";let y=document.createElement("div");return y.className=p?"mapfirst-dot-marker-button mapfirst-dot-marker-button-pending":`mapfirst-dot-marker-button mapfirst-dot-marker-button-active${s?" mapfirst-dot-marker-selected":i?"":" mapfirst-dot-marker-non-primary"}`,y.title=(l=r.name)!=null?l:String(r.tripadvisor_id),y.addEventListener("click",b=>{b.stopPropagation(),p||a==null||a(r)}),u.appendChild(y),p||S(u,y,r,s),u}var de='<video class="mapfirst-marker-loading-video" src="https://api.mapfirst.ai/static/images/loading.webm" autoplay loop muted></video>';function $(n,e,t,a,r){var u,y,M,c,l,b,d,g,f,m;let i=(y=(u=n.querySelector(".mapfirst-marker-pill"))==null?void 0:u.classList.contains("mapfirst-marker-pill-pending"))!=null?y:!1,s=n;s.style.zIndex=t?"20":e?"12":"11";let o=s.querySelector(".mapfirst-marker-pill");o&&(a?o.className="mapfirst-marker-pill mapfirst-marker-pill-pending":o.className=`mapfirst-marker-pill mapfirst-marker-pill-active${t?" mapfirst-marker-selected":e?"":" mapfirst-marker-non-primary"}`);let p=s.querySelector(".mapfirst-marker-badge");if(p instanceof HTMLElement&&(p.style.opacity=!e&&!t?"0.2":""),i&&!a&&r){let h=s.querySelector(".mapfirst-marker-pill");h instanceof HTMLElement&&S(s,h,r,t)}if(r&&r.type==="Accommodation"){let h=s.querySelector(".mapfirst-marker-content");if(h instanceof HTMLElement){let P=(c=(M=r.pricing)==null?void 0:M.offer)==null?void 0:c.displayPrice;h.dataset.price!==P&&(P?(h.innerHTML=P,h.dataset.price=P):(h.innerHTML=de,h.dataset.price=""))}}if(r){let h=document.querySelector(`.mapfirst-property-hover-card[data-marker-id="${r.tripadvisor_id}"]`);if(h){let P=r.rating||0,T=r.reviews||0,x=(d=(b=(l=r.pricing)==null?void 0:l.offer)==null?void 0:b.displayPrice)!=null?d:r.price_level,C=h.querySelector(".rating-value");if(C){let v=P.toFixed(1);C.textContent!==v&&(C.textContent=v)}let L=h.querySelector(".reviews");if(L){let v=`(${T})`;L.textContent!==v&&(L.textContent=v)}if(r.type==="Accommodation"&&x){let v=h.querySelector(".mapfirst-property-hover-price");if(!v){v=document.createElement("div"),v.className="mapfirst-property-hover-price";let A=h.querySelector(".mapfirst-property-hover-details"),w=h.querySelector(".mapfirst-property-hover-learn-more");A&&(w?A.insertBefore(v,w):A.appendChild(v))}if(v){let A=`Starting at <strong>${x}</strong>`;v.innerHTML!==A&&(v.innerHTML=A)}}let k=(m=(f=(g=r.pricing)==null?void 0:g.offer)==null?void 0:f.clickUrl)!=null?m:r.url;k&&h instanceof HTMLAnchorElement&&h.href!==k&&(h.href=k)}}}function z(n,e,t,a){let r=n;r.style.zIndex=t?"20":e?"3":"1";let i=r.querySelector(".mapfirst-dot-marker-button");i&&(a?i.className="mapfirst-dot-marker-button mapfirst-dot-marker-button-pending":i.className=`mapfirst-dot-marker-button mapfirst-dot-marker-button-active${t?" mapfirst-dot-marker-selected":e?"":" mapfirst-dot-marker-non-primary"}`)}function Z(n){let e=n.match(/^(?:primary|dot)-(\d+)-/);return e?parseInt(e[1],10):null}var I=class{constructor(e,t){this.markerCache=new Map;this.primaryType="Accommodation";this.selectedMarkerId=null;this.mapInstance=e,this.onMarkerClick=t}render(e,t,a){var i,s,o,p,u,y,M,c;t&&t!==this.primaryType&&(this.primaryType=t),a!==void 0&&(this.selectedMarkerId=a);let r=new Set(e.map(l=>l.key));for(let[l,b]of this.markerCache.entries())r.has(l)||(this.removeMarkerFromMap(b.marker),this.markerCache.delete(l));for(let l of e){let b=ue(l.marker.location);if(!b)continue;let d=this.markerCache.get(l.key);if(d){let g=l.marker.type===this.primaryType,f=this.selectedMarkerId===l.marker.tripadvisor_id,m=l.marker.type==="Accommodation",h=l.kind==="primary"?m&&!((s=(i=l.marker.pricing)==null?void 0:i.offer)!=null&&s.displayPrice):m&&((p=(o=l.marker.pricing)==null?void 0:o.offer)==null?void 0:p.availability)!=="available",P=this.getMarkerElement(d.marker);P&&(l.kind==="primary"?$(P,g,f,h,l.marker):z(P,g,f,h));try{this.updateMarkerPosition(d.marker,b)}catch{this.removeMarkerFromMap(d.marker),this.markerCache.delete(l.key),this.createAndAddMarker(l,b)}}else{let g=l.marker.tripadvisor_id,f,m;for(let[h,P]of this.markerCache.entries())if(Z(h)===g&&P.kind===l.kind){f=P,m=h;break}if(f&&m){let h=l.marker.type===this.primaryType,P=this.selectedMarkerId===l.marker.tripadvisor_id,T=l.marker.type==="Accommodation",x=l.kind==="primary"?T&&!((y=(u=l.marker.pricing)==null?void 0:u.offer)!=null&&y.displayPrice):T&&((c=(M=l.marker.pricing)==null?void 0:M.offer)==null?void 0:c.availability)!=="available",C=this.getMarkerElement(f.marker);C&&(l.kind==="primary"?$(C,h,P,x,l.marker):z(C,h,P,x)),this.updateMarkerZIndex(f.marker,l,h,P),this.markerCache.delete(m),this.markerCache.set(l.key,f);try{this.updateMarkerPosition(f.marker,b)}catch{}}else this.createAndAddMarker(l,b)}}}destroy(){for(let e of this.markerCache.values())this.removeMarkerFromMap(e.marker);this.markerCache.clear()}createAndAddMarker(e,t){let a=e.kind==="primary"?V(e,this.primaryType,this.selectedMarkerId,this.onMarkerClick):K(e,this.primaryType,this.selectedMarkerId,this.onMarkerClick);if(!a)return;let r=e.marker.type===this.primaryType,i=this.selectedMarkerId===e.marker.tripadvisor_id;try{let s=this.createMarker(a,t,e,r,i);s&&this.markerCache.set(e.key,{key:e.key,marker:s,kind:e.kind,parentId:e.kind==="dot"?e.parentId:void 0})}catch(s){console.error("Error creating marker",s)}}updateMarkerZIndex(e,t,a,r){}};function ue(n){return typeof(n==null?void 0:n.lon)!="number"||typeof(n==null?void 0:n.lat)!="number"||Number.isNaN(n.lon)||Number.isNaN(n.lat)?null:{lon:n.lon,lat:n.lat}}var B=class extends I{constructor(e){var t;super(e.mapInstance,e.onMarkerClick),this.MarkerCtor=(t=e.maplibregl)==null?void 0:t.Marker}render(e,t,a){this.MarkerCtor&&super.render(e,t,a)}createMarker(e,t,a){return this.MarkerCtor?new this.MarkerCtor({element:e,anchor:a.kind==="primary"?"bottom":"center"}).setLngLat([t.lon,t.lat]).addTo(this.mapInstance):null}removeMarkerFromMap(e){try{e.remove()}catch{}}updateMarkerPosition(e,t){e.setLngLat([t.lon,t.lat])}getMarkerElement(e){return e.getElement()}};var _=class extends I{constructor(e){super(e.mapInstance,e.onMarkerClick),this.google=e.google}render(e,t,a){var r,i;if(!((i=(r=this.google)==null?void 0:r.marker)!=null&&i.AdvancedMarkerElement)){console.warn("AdvancedMarkerElement not available");return}super.render(e,t,a)}createMarker(e,t,a,r,i){var o,p;if(!((p=(o=this.google)==null?void 0:o.marker)!=null&&p.AdvancedMarkerElement))return null;let s=a.kind==="primary"?i?20:r?12:11:i?20:r?3:1;return new this.google.marker.AdvancedMarkerElement({map:this.mapInstance,position:{lat:t.lat,lng:t.lon},content:e,zIndex:s})}removeMarkerFromMap(e){try{e.map=null}catch(t){console.error("Error removing marker",t)}}updateMarkerPosition(e,t){e.position={lat:t.lat,lng:t.lon}}getMarkerElement(e){let t=e.content;return t instanceof HTMLElement?t:null}updateMarkerZIndex(e,t,a,r){let i=t.kind==="primary"?r?20:a?12:11:r?20:a?3:1;e.zIndex=i}};var R=class extends I{constructor(e){var t;super(e.mapInstance,e.onMarkerClick),this.MarkerCtor=(t=e.mapboxgl)==null?void 0:t.Marker}render(e,t,a){this.MarkerCtor&&super.render(e,t,a)}createMarker(e,t,a){return this.MarkerCtor?new this.MarkerCtor({element:e,anchor:a.kind==="primary"?"bottom":"center"}).setLngLat([t.lon,t.lat]).addTo(this.mapInstance):null}removeMarkerFromMap(e){try{e.remove()}catch{}}updateMarkerPosition(e,t){e.setLngLat([t.lon,t.lat])}getMarkerElement(e){return e.getElement()}};var E=class{constructor(e){this.map=e}getMap(){return this.map}setupImpressionTracking(e){if(typeof window=="undefined"||!window.IntersectionObserver)return;let t=this.getContainer();if(!t)return;let a=new IntersectionObserver(s=>{s.forEach(o=>{o.isIntersecting&&(e(),a.disconnect())})},{threshold:.1});a.observe(t);let r=()=>a.disconnect(),i=this.cleanup.bind(this);this.cleanup=()=>{r(),i()}}};var F=class extends E{constructor(t){super(t);this.cleanupFns=[]}initialize(t){return this.markerManager=new B({mapInstance:this.map,maplibregl:t.maplibregl,onMarkerClick:t.onMarkerClick}),t.onRefresh&&this.attachEventListeners(t.onRefresh),t.onMapMoveEnd&&this.attachBoundsTracking(t.onMapMoveEnd),this.markerManager}attachBoundsTracking(t){if(!this.map||typeof this.map.on!="function")return;let a=()=>{let i=this.getMapBounds();t(i)},r=()=>{let i=this.getMapBounds();t(i)};this.map.loaded&&this.map.loaded()?r():(this.map.once("load",r),this.cleanupFns.push(()=>{typeof this.map.off=="function"&&this.map.off("load",r)})),this.map.on("moveend",a),this.cleanupFns.push(()=>{typeof this.map.off=="function"&&this.map.off("moveend",a)})}attachEventListeners(t){if(!this.map||typeof this.map.on!="function")return;["move","zoom","dragend","pitch","rotate"].forEach(r=>{this.map.on(r,t),this.cleanupFns.push(()=>{typeof this.map.off=="function"&&this.map.off(r,t)})})}getMarkerManager(){return this.markerManager}getContainer(){var t,a;return((a=(t=this.map)==null?void 0:t.getContainer)==null?void 0:a.call(t))||null}cleanup(){for(let t of this.cleanupFns)try{t()}catch{}this.cleanupFns.length=0}getMap(){return this.map}getCenter(){let t=this.map.getCenter();return{lng:t.lng,lat:t.lat}}getZoom(){return this.map.getZoom()}getBearing(){return this.map.getBearing()}getPitch(){return this.map.getPitch()}getMapBounds(){let t=this.map.getBounds(),a=t.getSouthWest(),r=t.getNorthEast();return{sw:{lat:a.lat,lng:a.lng},ne:{lat:r.lat,lng:r.lng}}}project(t){return this.map.project({lng:t[0],lat:t[1]})}on(t,a){this.map.on(t,a)}off(t,a){this.map.off(t,a)}resize(){this.map.resize()}remove(){this.cleanup(),this.map.remove()}};var H=class extends E{constructor(t){super(t);this.cleanupFns=[];this.initializeOverlayView()}initialize(t){return this.markerManager=new _({mapInstance:this.map,google:t.google,onMarkerClick:t.onMarkerClick}),t.onRefresh&&this.attachEventListeners(t.onRefresh),t.onMapMoveEnd&&this.attachBoundsTracking(t.onMapMoveEnd,t.google),this.markerManager}attachBoundsTracking(t,a){if(!this.map)return;let r=()=>{let s=this.getMapBounds();t(s)};r();let i=a.event.addListener(this.map,"idle",r);this.cleanupFns.push(()=>{a.event.removeListener(i)})}attachEventListeners(t){let a=["center_changed","zoom_changed","drag","heading_changed","tilt_changed"],r=[];a.forEach(i=>{let s=this.map.addListener(i,t);r.push(s)}),this.cleanupFns.push(()=>{r.forEach(i=>{try{i.remove()}catch{}})})}getMarkerManager(){return this.markerManager}getContainer(){var t,a;return((a=(t=this.map)==null?void 0:t.getDiv)==null?void 0:a.call(t))||null}cleanup(){for(let t of this.cleanupFns)try{t()}catch{}this.cleanupFns.length=0}initializeOverlayView(){var r;let t=(r=globalThis.google)==null?void 0:r.maps;if(!t)return;let a=t.OverlayView;a&&(this.overlayView=new a,this.overlayView.draw=function(){},this.overlayView.setMap(this.map))}getMap(){return this.map}getCenter(){let t=this.map.getCenter();return t?{lng:t.lng(),lat:t.lat()}:{lng:0,lat:0}}getZoom(){var t;return(t=this.map.getZoom())!=null?t:0}getBearing(){var t;return(t=this.map.getHeading())!=null?t:0}getPitch(){var t;return(t=this.map.getTilt())!=null?t:0}getMapBounds(){let t=this.map.getBounds();if(!t)return{sw:{lat:0,lng:0},ne:{lat:0,lng:0}};let a=t.getSouthWest(),r=t.getNorthEast();return{sw:{lat:a.lat(),lng:a.lng()},ne:{lat:r.lat(),lng:r.lng()}}}project(t){var o;if(!this.overlayView)return{x:0,y:0};let a=this.overlayView.getProjection();if(!a)return{x:0,y:0};let r=(o=globalThis.google)==null?void 0:o.maps;if(!r)return{x:0,y:0};let i=new r.LatLng(t[1],t[0]),s=a.fromLatLngToContainerPixel(i);return s?{x:s.x,y:s.y}:{x:0,y:0}}on(t,a){this.map.addListener(t,a)}off(t,a){var i;let r=(i=globalThis.google)==null?void 0:i.maps;r!=null&&r.event&&r.event.clearListeners(this.map,t)}resize(){var a;let t=(a=globalThis.google)==null?void 0:a.maps;t!=null&&t.event&&t.event.trigger(this.map,"resize")}remove(){this.cleanup(),this.overlayView&&(this.overlayView.setMap(null),this.overlayView=null)}};var D=class extends E{constructor(t){super(t);this.cleanupFns=[]}initialize(t){return this.markerManager=new R({mapInstance:this.map,mapboxgl:t.mapboxgl,onMarkerClick:t.onMarkerClick}),t.onRefresh&&this.attachEventListeners(t.onRefresh),t.onMapMoveEnd&&this.attachBoundsTracking(t.onMapMoveEnd),this.markerManager}attachBoundsTracking(t){if(!this.map||typeof this.map.on!="function")return;let a=()=>{let i=this.getMapBounds();t(i)},r=()=>{let i=this.getMapBounds();t(i)};this.map.loaded&&this.map.loaded()?r():(this.map.once("load",r),this.cleanupFns.push(()=>{typeof this.map.off=="function"&&this.map.off("load",r)})),this.map.on("moveend",a),this.cleanupFns.push(()=>{typeof this.map.off=="function"&&this.map.off("moveend",a)})}attachEventListeners(t){if(!this.map||typeof this.map.on!="function")return;["move","zoom","dragend","pitch","rotate"].forEach(r=>{this.map.on(r,t),this.cleanupFns.push(()=>{typeof this.map.off=="function"&&this.map.off(r,t)})})}getMarkerManager(){return this.markerManager}getContainer(){var t,a;return((a=(t=this.map)==null?void 0:t.getContainer)==null?void 0:a.call(t))||null}cleanup(){for(let t of this.cleanupFns)try{t()}catch{}this.cleanupFns.length=0}getMap(){return this.map}getCenter(){let t=this.map.getCenter();return{lng:t.lng,lat:t.lat}}getZoom(){return this.map.getZoom()}getBearing(){return this.map.getBearing()}getPitch(){return this.map.getPitch()}getMapBounds(){let t=this.map.getBounds(),a=t.getSouthWest(),r=t.getNorthEast();return{sw:{lat:a.lat,lng:a.lng},ne:{lat:r.lat,lng:r.lng}}}project(t){return this.map.project({lng:t[0],lat:t[1]})}on(t,a){this.map.on(t,a)}off(t,a){this.map.off(t,a)}resize(){this.map.resize()}remove(){this.cleanup(),this.map.remove()}};function J(n){let e=n.getCenter();return{longitude:e.lng,latitude:e.lat,zoom:n.getZoom(),bearing:n.getBearing(),pitch:n.getPitch()}}var fe=[{zoom:6,threshold:120},{zoom:8,threshold:108},{zoom:10,threshold:92},{zoom:12,threshold:80},{zoom:14,threshold:68},{zoom:16,threshold:56}];function Y(n){for(let e of fe)if(n<=e.zoom)return e.threshold;return 48}function q({primaryType:n,markers:e,map:t,selectedMarkerId:a,zoom:r,collisionThresholdPx:i,dotCollisionThresholdPx:s}){if(!e.length)return[];if(!t)return e.map(d=>({kind:"primary",marker:d,key:`primary-${d.tripadvisor_id}`}));let o=e.map((d,g)=>{let f=d.location;if(typeof(f==null?void 0:f.lon)!="number"||typeof(f==null?void 0:f.lat)!="number")return null;let{x:m,y:h}=t.project([f.lon,f.lat]);return{marker:d,index:g,x:m,y:h}}).filter(d=>!!d);if(!o.length)return[];let p=Y(r),u=ge(r),y=o.map((d,g)=>g),M=d=>y[d]===d?d:(y[d]=M(y[d]),y[d]),c=(d,g)=>{let f=M(d),m=M(g);f!==m&&(y[m]=f)};for(let d=0;d<o.length;d+=1)for(let g=d+1;g<o.length;g+=1){let f=o[d].x-o[g].x,m=o[d].y-o[g].y;Math.hypot(f,m)<=p&&c(d,g)}let l=new Map;for(let d of o){let g=M(d.index),f=l.get(g);f?f.push(d):l.set(g,[d])}let b=[];return l.forEach(d=>{var C,L;if(d.length===1){let[{marker:k}]=d,v=k.type===n,A=a===k.tripadvisor_id;b.push({kind:"primary",marker:k,key:`primary-${k.tripadvisor_id}-p${v?1:0}-s${A?1:0}-${(C=k.pricing)==null?void 0:C.availability}`});return}let g=[...d].sort((k,v)=>ye(v.marker,k.marker,n)),[f,...m]=g,h=f.marker.type===n,P=a===f.marker.tripadvisor_id;if(b.push({kind:"primary",marker:f.marker,key:`primary-${f.marker.tripadvisor_id}-p${h?1:0}-s${P?1:0}-${(L=f.marker.pricing)==null?void 0:L.availability}`}),!m.length)return;let T=[],x=[];if(m.forEach(k=>{var v;if(a&&k.marker.tripadvisor_id===a){let A=k.marker.type===n;b.push({kind:"primary",marker:k.marker,key:`primary-${k.marker.tripadvisor_id}-p${A?1:0}-s1-${(v=k.marker.pricing)==null?void 0:v.availability}`});return}he(f,k)<=u?T.push(k):x.push(k)}),T.forEach(k=>{var A;let v=k.marker.type===n;b.push({kind:"dot",marker:k.marker,key:`dot-${k.marker.tripadvisor_id}-p${v?1:0}-s0-${(A=k.marker.pricing)==null?void 0:A.availability}`,parentId:f.marker.tripadvisor_id})}),x.length){let k=q({markers:x.map(v=>v.marker),map:t,selectedMarkerId:a,zoom:r,primaryType:n,collisionThresholdPx:i,dotCollisionThresholdPx:s});b.push(...k)}}),b}function he(n,e){return Math.hypot(n.x-e.x,n.y-e.y)}function ge(n){let e=Y(n);return Math.max(48,e)}function ye(n,e,t){var p,u;let a=n.type===t,r=e.type===t;if(a&&!r)return 1;if(!a&&r)return-1;let i=W(n)-W(e);if(i!==0)return i;let s=X(n)-X(e);if(s!==0)return s;let o=((p=n.reviews)!=null?p:0)-((u=e.reviews)!=null?u:0);return o!==0?o:n.tripadvisor_id-e.tripadvisor_id}function W(n){if(typeof n.rating=="number")return n.rating;if(n.rating===void 0||n.rating===null)return-1/0;let e=Number(n.rating);return Number.isNaN(e)?-1/0:e}function X(n){var t,a,r;if(!((a=(t=n.pricing)==null?void 0:t.offer)!=null&&a.price))return-1/0;let e=Number(((r=n.pricing.offer.displayPrice)!=null?r:"0").replace(/[^0-9.,-]+/g,"").replace(/,/g,""));return Number.isNaN(e)?-1/0:e}function be(n){let e=[];return n.amenities&&Array.isArray(n.amenities)&&n.amenities.forEach(t=>{e.push({id:`amenity-${t}`,label:t,type:"amenity",value:t})}),n.hotelStyle&&Array.isArray(n.hotelStyle)&&n.hotelStyle.forEach(t=>{e.push({id:`hotelStyle-${t}`,label:t,type:"hotelStyle",value:t})}),n.price&&e.push({id:"priceRange",label:"Price Range",type:"priceRange",value:`${n.price.min}-${n.price.max}`,priceRange:n.price}),typeof n.minRating=="number"&&Number.isFinite(n.minRating)&&e.push({id:"minRating",label:`${n.minRating}+`,type:"minRating",value:String(n.minRating),numericValue:n.minRating}),typeof n.starRating=="number"&&Number.isFinite(n.starRating)&&e.push({id:"starRating",label:`${n.starRating} Stars`,type:"starRating",value:String(n.starRating),numericValue:n.starRating}),n.transformed_query&&e.push({id:"transformed_query",label:n.transformed_query,type:"transformed_query",value:n.transformed_query}),n.selected_restaurant_price_levels&&e.push({id:"selected_restaurant_price_levels",label:n.selected_restaurant_price_levels.join(", "),type:"selected_restaurant_price_levels",value:n.selected_restaurant_price_levels.join(", "),priceLevels:n.selected_restaurant_price_levels}),e}function Me(n){return n.map(e=>{let t={id:e.id,label:typeof e.label=="string"?e.label:String(e.label||""),type:e.type,value:e.value};if(e.numericValue!==void 0&&(t.numericValue=e.numericValue),e.priceRange){let a=e.priceRange.min,r=e.priceRange.max;a!==void 0&&(t.priceRange={min:a,...r!==void 0&&{max:r}})}return e.priceLevels&&(t.priceLevels=e.priceLevels),t})}var ke={prod:"https://api.mapfirst.ai",test:"https://api.mapfirst.ai/test"},N=class extends Error{constructor({message:e,status:t,code:a}){super(e),this.name="PropertiesFetchError",this.status=t,this.code=a}};async function U(n,e=1){try{let t=await fetch(`https://l4detuz832.execute-api.us-east-1.amazonaws.com/dev/photo?id=${n}&limit=${e}`);if(!t.ok)return null;let a=await t.json();if(a.photos&&a.photos.length>0){let r=a.photos[0].FullSizeURL.url;if((await fetch(r)).ok)return r}return null}catch(t){return console.debug("Failed to fetch images:",t),null}}async function ve(n,e,t,{signal:a}={}){var i,s;let r=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",...t&&{"X-API-Key":t}},body:JSON.stringify(e),signal:a});if(!r.ok){let o=`Unexpected response: ${r.status}`,p;try{let u=await r.json();o=(s=(i=u.detail)!=null?i:u.error)!=null?s:o,p=u.code}catch{}throw new N({message:o,status:r.status,code:p})}return await r.json()}function Q(n){return typeof n=="string"?n:n.toISOString().slice(0,10)}var ee="Accommodation";function Pe(){let e=new Date(Date.now()+864e6),t=(6-e.getDay()+7)%7,a=new Date(e.getTime()+t*864e5),r=a.getDay(),i=r===0?6:6-r,s=new Date(a.getTime()+(i+1)*864e5);return{checkIn:a,checkOut:s}}var te=class{constructor(e){this.options=e;this.adapter=null;this.properties=[];this.selectedMarkerId=null;this.destroyed=!1;this.clusterItems=[];this.isMapAttached=!1;var r,i,s,o,p,u,y,M,c,l,b,d,g,f,m,h;if(this.properties=[...(r=e.properties)!=null?r:[]],this.primaryType=e.primaryType,this.selectedMarkerId=(i=e.selectedMarkerId)!=null?i:null,this.useApi=(s=e.useApi)!=null?s:!0,this.environment=(o=e.environment)!=null?o:"prod",this.apiUrl=(p=e.apiUrl)!=null?p:ke[this.environment],this.apiKey=e.apiKey,this.requestBody=e.requestBody,this.currentPlatform=e.platform,!this.useApi&&e.platform&&e.platform!=="maplibre")throw new Error("When useApi is false, only maplibre platform is supported. Google Maps and Mapbox require API usage.");let t=re(e);this.fitBoundsPadding={top:(y=(u=e.fitBoundsPadding)==null?void 0:u.top)!=null?y:t?0:50,bottom:(c=(M=e.fitBoundsPadding)==null?void 0:M.bottom)!=null?c:t?0:160,left:(b=(l=e.fitBoundsPadding)==null?void 0:l.left)!=null?b:t?0:50,right:(g=(d=e.fitBoundsPadding)==null?void 0:d.right)!=null?g:t?0:50};let a=Pe();this.state={center:[0,0],zoom:0,bounds:null,pendingBounds:null,tempBounds:null,properties:this.properties,primary:(f=this.primaryType)!=null?f:ee,selectedPropertyId:this.selectedMarkerId,initialLoading:!0,isSearching:!1,firstCallDone:!1,filters:{checkIn:a.checkIn,checkOut:a.checkOut,numAdults:2,numRooms:1,...((m=e.initialLocationData)==null?void 0:m.currency)&&{currency:e.initialLocationData.currency}},activeLocation:{country:"",location_id:null,locationName:"",coordinates:[0,0]},isFlyToAnimating:!1,...e.state},this.callbacks=(h=e.callbacks)!=null?h:{},this.hasMapInstance(e)&&(this.adapter=this.createAdapter(e),this.isMapAttached=!0,this.refresh()),e.initialLocationData?this.initializeFromLocationData(e.initialLocationData):this.requestBody&&this.isMapAttached&&this.autoLoadProperties()}hasMapInstance(e){return!!("adapter"in e&&e.adapter||"mapInstance"in e&&e.mapInstance)}async initializeFromLocationData(e){if(!this.useApi){console.warn("initializeFromLocationData requires API usage. Set useApi to true.");return}try{let{city:t,country:a,query:r}=e,i={filters:this.getFilters(),initial:!0};if(t&&a||a){let s=await fetch(`${this.apiUrl}/geo-lookup?country=${encodeURIComponent(a)}${t?`&city=${encodeURIComponent(t)}`:""}`,{headers:{...this.apiKey&&{"X-API-Key":this.apiKey}}});if(s.ok){let o=await s.json(),p=t;o.location_name&&o.path3_name&&o.location_name===o.path3_name&&(p=void 0),o.location_name&&(p=o.location_name);let u=o.path3_name||a;i={...i,city:p,country:u,location_id:o.location_id,longitude:o.longitude,latitude:o.latitude},this.setActiveLocation({city:p,country:u,location_id:o.location_id,locationName:p&&u?`${p}, ${u}`:u||"",coordinates:[o.latitude,o.longitude]}),this.setState({center:[o.latitude,o.longitude],zoom:12})}else this.handleError(new Error(`Geo mapping fetch failed: ${s.statusText}`),"initializeFromLocationData")}else r&&(i.query=r);this.requestBody=i,this.isMapAttached&&await this.autoLoadProperties()}catch(t){this.handleError(t,"initializeFromLocationData")}}async autoLoadProperties(){if(!this.useApi){console.warn("autoLoadProperties requires API usage. Set useApi to true.");return}if(!this.requestBody)return;let e={filters:this.getFilters(),initial:!0,...this.requestBody};await this.runPropertiesSearch({body:e,onError:t=>{var a,r;this.handleError(t,"autoLoadProperties"),(r=(a=this.callbacks).onPropertiesLoadError)==null||r.call(a,t)}})}attachMap(e,t){if(!this.useApi&&t.platform!=="maplibre")throw new Error("When useApi is false, only maplibre platform is supported. Google Maps and Mapbox require API usage.");if(this.isMapAttached&&(console.warn("Map is already attached. Destroying previous adapter."),this.adapter)){let r=this.adapter.getMarkerManager();r==null||r.destroy(),this.adapter.cleanup()}let a={...this.options,platform:t.platform,mapInstance:e,maplibregl:t.maplibregl,google:t.google,mapboxgl:t.mapboxgl,onMarkerClick:t.onMarkerClick};this.currentPlatform=t.platform,this.adapter=this.createAdapter(a),this.isMapAttached=!0,this.refresh(),this.requestBody&&!this.state.firstCallDone&&this.autoLoadProperties()}createAdapter(e){return xe(e)&&e.mapInstance?this.initializeAdapter(new F(e.mapInstance),{maplibregl:e.maplibregl,onMarkerClick:e.onMarkerClick}):re(e)&&e.mapInstance?this.initializeAdapter(new H(e.mapInstance),{google:e.google,onMarkerClick:e.onMarkerClick}):Le(e)&&e.mapInstance?this.initializeAdapter(new D(e.mapInstance),{mapboxgl:e.mapboxgl,onMarkerClick:e.onMarkerClick}):"adapter"in e&&e.adapter?e.adapter:null}initializeAdapter(e,t){var r;let a=(r=this.options.autoSelectOnClick)!=null?r:!0;return e.initialize({...t,onMarkerClick:i=>{var s;i.location&&this.flyMapTo(i.location.lon,i.location.lat,14),i.type!==this.primaryType&&this.setPrimaryType(i.type),a&&this.setSelectedMarker(i.tripadvisor_id===this.selectedMarkerId?null:i.tripadvisor_id),(s=t.onMarkerClick)==null||s.call(t,i)},onRefresh:()=>this.refresh(),onMapMoveEnd:i=>{this.state.tempBounds===null?(this.setTempBounds(i),this.setPendingBounds(null)):this.handleMapMoveEnd(i)}}),this.useApi&&e.setupImpressionTracking(()=>{console.log("ToDo: Track Map Impression")}),e}_setProperties(e){var t,a;this.ensureAlive(),this.properties=[...e.filter(r=>{var i;return r.type==="Accommodation"?((i=r.pricing)==null?void 0:i.availability)!=="unavailable":!0})],this.updateState({properties:this.properties}),(a=(t=this.callbacks).onPropertiesChange)==null||a.call(t,e),this.refresh()}addProperty(e){var t,a;this.ensureAlive(),this.properties=[...this.properties,e],this.updateState({properties:this.properties}),(a=(t=this.callbacks).onPropertiesChange)==null||a.call(t,this.properties),this.refresh()}clearProperties(){var e,t;this.ensureAlive(),this.properties=[],this.updateState({properties:[]}),(t=(e=this.callbacks).onPropertiesChange)==null||t.call(e,[]),this.refresh()}setPrimaryType(e){var t,a;this.ensureAlive(),this.primaryType!==e&&(this.primaryType=e,this.updateState({primary:e}),(a=(t=this.callbacks).onPrimaryTypeChange)==null||a.call(t,e),this.refresh())}setSelectedMarker(e){var t,a;if(this.ensureAlive(),this.selectedMarkerId!==e){if(e!==null){let r=this.properties.find(i=>i.tripadvisor_id===e);r&&r.type!==this.primaryType&&this.setPrimaryType(r.type)}this.selectedMarkerId=e,this.updateState({selectedPropertyId:e}),(a=(t=this.callbacks).onSelectedPropertyChange)==null||a.call(t,e),this.refresh()}}getState(){return{...this.state}}handleError(e,t="MapFirstCore"){let a=e instanceof Error?e.message:String(e),r=e instanceof Error?e:new Error(a);console.error(`[${t}]`,a),this.callbacks.onError&&this.callbacks.onError(r,t)}updateState(e){this.state={...this.state,...e}}setState(e){var a,r,i,s,o,p,u,y,M,c,l,b,d,g,f,m;let t={...this.state};this.updateState(e),e.center!==void 0&&e.center!==t.center&&((r=(a=this.callbacks).onCenterChange)==null||r.call(a,e.center,this.state.zoom)),e.zoom!==void 0&&e.zoom!==t.zoom&&((s=(i=this.callbacks).onZoomChange)==null||s.call(i,e.zoom)),e.bounds!==void 0&&e.bounds!==t.bounds&&((p=(o=this.callbacks).onBoundsChange)==null||p.call(o,e.bounds)),e.pendingBounds!==void 0&&e.pendingBounds!==t.pendingBounds&&((y=(u=this.callbacks).onPendingBoundsChange)==null||y.call(u,e.pendingBounds)),e.filters!==void 0&&e.filters!==t.filters&&((c=(M=this.callbacks).onFiltersChange)==null||c.call(M,e.filters)),e.activeLocation!==void 0&&e.activeLocation!==t.activeLocation&&((b=(l=this.callbacks).onActiveLocationChange)==null||b.call(l,e.activeLocation)),e.initialLoading!==void 0&&e.initialLoading!==t.initialLoading&&((g=(d=this.callbacks).onLoadingStateChange)==null||g.call(d,e.initialLoading)),e.isSearching!==void 0&&e.isSearching!==t.isSearching&&((m=(f=this.callbacks).onSearchingStateChange)==null||m.call(f,e.isSearching))}setFilters(e){this.setState({filters:e})}setActiveLocation(e){this.setState({activeLocation:e})}setBounds(e){this.setState({bounds:e})}setPendingBounds(e){this.setState({pendingBounds:e})}setTempBounds(e){this.setState({tempBounds:e})}setLoading(e){this.setState({initialLoading:e})}setSearching(e){this.setState({isSearching:e})}setFlyToAnimating(e){this.setState({isFlyToAnimating:e})}handleMapMoveEnd(e){if(this.state.isFlyToAnimating){this.setState({isFlyToAnimating:!1,tempBounds:e,pendingBounds:null});return}let t=this.state.tempBounds;if(!t){this.setState({tempBounds:e,pendingBounds:e});return}let a=.01;Math.abs(e.sw.lat-t.sw.lat)>a||Math.abs(e.sw.lng-t.sw.lng)>a||Math.abs(e.ne.lat-t.ne.lat)>a||Math.abs(e.ne.lng-t.ne.lng)>a?this.setState({pendingBounds:e}):this.setState({pendingBounds:null})}flyMapTo(e,t,a,r=!0){if(this.ensureAlive(),this.setState({center:[t,e]}),typeof a=="number"&&this.setState({zoom:a}),!this.adapter)return;let i=this.adapter.getMap();if(i){if(this.currentPlatform==="google"){this.setFlyToAnimating(!1),i.setCenter({lat:t,lng:e}),a!==null&&typeof a=="number"&&i.setZoom(a!=null?a:13);return}if(r===!1){this.setFlyToAnimating(!1),i.jumpTo&&i.jumpTo({center:[e,t],...a!==null&&{zoom:a!=null?a:13}});return}this.setFlyToAnimating(!0),i.flyTo&&i.flyTo({center:[e,t],...a!==null&&{zoom:a!=null?a:13}})}}flyToPOIs(e,t,a=!0){var s,o;if(this.ensureAlive(),!this.adapter)return;let r=this.adapter.getMap();if(!r)return;let i=e;if((!i||i.length===0)&&(i=this.properties.filter(p=>p.location!==void 0&&(t!==void 0?p.type===t:!0)).map(p=>({lat:p.location.lat,lng:p.location.lon}))),!(!i||i.length===0)){if(i.length===1){let p=i[0];this.currentPlatform==="google"?(r.setCenter({lat:p.lat,lng:p.lng}),r.setZoom(13)):r.flyTo&&r.flyTo({center:[p.lng,p.lat],zoom:13})}else if(this.currentPlatform==="google"){let p=(o=(s=window.google)==null?void 0:s.maps)==null?void 0:o.LatLngBounds;if(p){let u=new p;i.forEach(y=>{u.extend({lat:y.lat,lng:y.lng})}),a&&this.setFlyToAnimating(!0),r.fitBounds(u,this.fitBoundsPadding)}}else if(r.fitBounds){let p=[[i[0].lng,i[0].lat],[i[0].lng,i[0].lat]];i.forEach(u=>{p[0][0]=Math.min(p[0][0],u.lng),p[0][1]=Math.min(p[0][1],u.lat),p[1][0]=Math.max(p[1][0],u.lng),p[1][1]=Math.max(p[1][1],u.lat)}),a&&this.setFlyToAnimating(!0),r.fitBounds(p,{padding:this.fitBoundsPadding,animate:a})}}}getFilters(){let e={...this.state.filters};return e.checkIn instanceof Date&&(e.checkIn=Q(e.checkIn)),e.checkOut instanceof Date&&(e.checkOut=Q(e.checkOut)),e}async pollForPricing({pollingLink:e,maxAttempts:t=15,delayMs:a=2e3,isCancelled:r,price:i,limit:s}){var M,c,l,b,d;if(this.ensureAlive(),!this.useApi)return console.warn("pollForPricing requires API usage. Set useApi to true."),{completed:!1};if(!e)return{completed:!1};let o=!1,p,u=this.getFilters();s&&(u.limit=s);let y={filters:u,pollingLink:e};for(let g=0;g<t;g++){if(r!=null&&r())return{completed:o,pollData:p};try{let f=await fetch(`${this.apiUrl}/ta-polling?pollingNumber=${g}`,{method:"POST",body:JSON.stringify(y),headers:{"Content-Type":"application/json",...this.apiKey&&{"X-API-Key":this.apiKey}}});if(!f.ok)throw new N({message:`Poll failed: ${f.status}`,status:f.status});if(p=await f.json(),r!=null&&r())return{completed:o,pollData:p};let m=(c=(M=p==null?void 0:p.success)==null?void 0:M.results)!=null?c:[];if(m.length>0&&this.setProperties(h=>{let P=new Set(m.map(x=>x.tripadvisor_id)),T=h.filter(x=>x.type!=="Accommodation"||P.has(x.tripadvisor_id));return m.forEach(x=>{var L,k,v,A,w,j;if(!x.location)return;(k=(L=x.pricing)==null?void 0:L.offer)!=null&&k.price&&i&&(((A=(v=x.pricing)==null?void 0:v.offer)==null?void 0:A.price)<(i==null?void 0:i.min)||((j=(w=x.pricing)==null?void 0:w.offer)==null?void 0:j.price)>(i==null?void 0:i.max))&&(x.pricing.availability="unavailable");let C=T.findIndex(ae=>ae.tripadvisor_id===x.tripadvisor_id);C>=0?T[C]=x:T.push(x)}),T}),(l=p==null?void 0:p.success)!=null&&l.isComplete){o=!0;break}}catch(f){this.handleError(f,"pollForPricing"),(d=(b=this.callbacks).onPropertiesLoadError)==null||d.call(b,f);break}g<t-1&&await new Promise(f=>setTimeout(f,a))}return{completed:o,pollData:p}}setProperties(e){let t=e(this.properties);this._setProperties(t)}mostCommonTypeFromProperties(e){let t=e.reduce((a,r)=>(a[r.type]=(a[r.type]||0)+1,a),{});return Object.entries(t).reduce((a,r)=>t[a[0]]>t[r[0]]?a:r)[0]}async runPropertiesSearch({body:e,beforeApplyProperties:t,smartFiltersClearable:a,onError:r}){var i,s,o,p,u,y,M;if(this.ensureAlive(),!this.useApi)return console.warn("runPropertiesSearch requires API usage. Set useApi to true."),r==null||r(new Error("API usage is disabled")),null;this.setState({firstCallDone:!1}),this.setSearching(!0),this.clearProperties();try{let c=await ve(`${this.apiUrl}/properties`,e,this.apiKey);this.updateActiveLocationFromResponse(c);let l=null,b=30,d=c.filters.primary_type;if(t){let m=t(c);l=(i=m.price)!=null?i:null,b=(s=m.limit)!=null?s:30}let g=c.properties.some(m=>!!m.location),f=l?c.properties.map(m=>{var h;return(h=m.pricing)!=null&&h.offer?{...m,pricing:{...m.pricing,availability:m.pricing.offer.price&&(m.pricing.offer.price<l.min||m.pricing.offer.price>l.max)?"unavailable":m.pricing.availability}}:m}):c.properties;if(this._setProperties(f),g&&this.flyToPOIs(c.properties.filter(m=>!!m.location&&(c.filters.primary_type?m.type===c.filters.primary_type:!0)).map(m=>({lat:m.location.lat,lng:m.location.lon})),void 0,e.initial!==!0),c.filters.primary_type&&c.properties.filter(m=>{var h;return m.type===c.filters.primary_type&&(m.type==="Accommodation"?((h=m.pricing)==null?void 0:h.availability)!=="unavailable":!0)}).length>0)d=c.filters.primary_type,this.setPrimaryType(c.filters.primary_type);else if(c.properties.length>0){let m=this.mostCommonTypeFromProperties(c.properties);this.setPrimaryType(m),d=m}if(this.setState({firstCallDone:!0}),c.isComplete===!1&&c.pollingLink){let{completed:m,pollData:h}=await this.pollForPricing({pollingLink:c.pollingLink,...l&&{price:l},...b&&{limit:b}});if(m&&((o=h==null?void 0:h.success)!=null&&o.results)&&h.success.results.filter(P=>{var T;return P.type===c.filters.primary_type&&(P.type==="Accommodation"?((T=P.pricing)==null?void 0:T.availability)!=="unavailable":!0)}).length===0&&d&&d!==c.filters.primary_type){let P=this.mostCommonTypeFromProperties(c.properties);this.setPrimaryType(P)}m&&this.refresh()}return g||(c.properties.some(m=>!!m.location)?this.flyToPOIs(c.properties.filter(m=>!!m.location&&(c.filters.primary_type?m.type===c.filters.primary_type:!0)).map(m=>({lat:m.location.lat,lng:m.location.lon})),void 0,e.initial!==!0):(p=c.filters.location)!=null&&p.latitude&&((u=c.filters.location)!=null&&u.longitude)&&this.flyMapTo(c.filters.location.longitude,c.filters.location.latitude,12,e.initial!==!0)),c}catch(c){return this.handleError(c,"runPropertiesSearch"),r==null||r(c),(M=(y=this.callbacks).onPropertiesLoadError)==null||M.call(y,c),this.clearProperties(),this.setState({firstCallDone:!0}),null}finally{this.setSearching(!1),this.setState({firstCallDone:!0})}}async performBoundsSearch(){var i;if(this.ensureAlive(),!this.useApi)return console.warn("performBoundsSearch requires API usage. Set useApi to true."),null;if(!this.state.pendingBounds)return null;let e=this.getFilters(),t={bounds:this.state.pendingBounds,filters:e},a=(i=e==null?void 0:e.price)!=null?i:void 0,r=await this.runPropertiesSearch({body:t,beforeApplyProperties:()=>({price:a!=null?a:null})});return r&&(this.setBounds(this.state.pendingBounds),this.setTempBounds(this.state.pendingBounds),this.setPendingBounds(null)),r}updateActiveLocationFromResponse(e){var o,p,u,y;let t=(o=e.location_id)!=null?o:null,a=(u=(p=e.filters.location)==null?void 0:p.city)!=null?u:void 0,r=((y=e.filters.location)==null?void 0:y.country)||"",i=e.filters.location?[e.filters.location.latitude,e.filters.location.longitude]:void 0;if(!i)return;let s=this.state.activeLocation;(t!==(s==null?void 0:s.location_id)||a!==(s==null?void 0:s.city)||r!==(s==null?void 0:s.country))&&this.setActiveLocation({city:a,country:r,location_id:t,locationName:a&&r?`${a}, ${r}`:r||"",coordinates:i})}async runSmartFilterSearch({query:e,filters:t,onProcessFilters:a,onError:r}){if(this.ensureAlive(),!this.useApi)return console.warn("runSmartFilterSearch requires API usage. Set useApi to true."),r==null||r(new Error("API usage is disabled")),null;let i=this.getFilters(),s=this.getState();if(t&&t.length>0){let p=new Set,u=new Set,y,M,c,l,b,d;t.forEach(g=>{var f,m,h;switch(g.type){case"amenity":p.add(g.value);break;case"hotelStyle":u.add(g.value);break;case"priceRange":g.priceRange&&(y={min:g.priceRange.min,max:(f=g.priceRange.max)!=null?f:0});break;case"minRating":M=(m=g.numericValue)!=null?m:Number(g.value);break;case"starRating":c=(h=g.numericValue)!=null?h:Number(g.value);break;case"primary_type":l=g.propertyType;break;case"transformed_query":b=g.value;break;case"selected_restaurant_price_levels":d=g.priceLevels;break}}),i={...i,...p.size>0&&{amenities:Array.from(p)},...u.size>0&&{hotelStyle:Array.from(u)},...y&&{price:y},...M!==void 0&&{minRating:M},...c!==void 0&&{starRating:c},...l&&{primary_type:l},...b&&{transformed_query:b},...d&&{selected_restaurant_price_levels:d}}}else e||(i.minRating=4);let o={filters:i,...e&&{query:e},...s.bounds?{bounds:s.bounds}:s.activeLocation.location_id?{location_id:s.activeLocation.location_id}:s.activeLocation.coordinates?{latitude:s.activeLocation.coordinates[0],longitude:s.activeLocation.coordinates[1]}:{}};return this.runPropertiesSearch({body:o,beforeApplyProperties:a?p=>{var y,M;let u=a(p.filters,p.location_id);return{price:(y=u.price)!=null?y:null,limit:(M=u.limit)!=null?M:30}}:void 0,smartFiltersClearable:!!e,onError:r})}getClusters(){return this.ensureAlive(),[...this.clusterItems]}setUseApi(e,t=!0){this.ensureAlive(),this.useApi=e,!e&&this.currentPlatform&&this.currentPlatform!=="maplibre"&&console.warn("When useApi is false, only maplibre platform is supported. Please switch to maplibre."),e||this.clearProperties(),e&&t&&(this.options.initialLocationData?this.initializeFromLocationData(this.options.initialLocationData):this.requestBody&&this.isMapAttached&&this.autoLoadProperties())}setApiKey(e){this.ensureAlive();let t=this.apiKey;this.apiKey=e,t!==this.apiKey&&this.isMapAttached&&(this.refresh(),this.useApi&&(this.options.initialLocationData?this.initializeFromLocationData(this.options.initialLocationData):this.requestBody&&this.autoLoadProperties()))}getApiKey(){return this.apiKey}refresh(){var r,i,s;if(this.ensureAlive(),!this.adapter)return;let e=this.safeExtractViewState(),t=this.resolvePrimaryType();this.clusterItems=q({primaryType:t,markers:this.properties,map:this.adapter,selectedMarkerId:this.selectedMarkerId,zoom:(r=e==null?void 0:e.zoom)!=null?r:0}),this.adapter.getMarkerManager().render(this.clusterItems,t,this.selectedMarkerId),(s=(i=this.options).onClusterUpdate)==null||s.call(i,this.clusterItems,e)}destroy(){this.destroyed||(this.adapter&&(this.adapter.getMarkerManager().destroy(),this.adapter.cleanup()),this.clusterItems=[],this.properties=[],this.destroyed=!0,this.isMapAttached=!1)}resolvePrimaryType(){var e,t,a;return(a=(t=this.primaryType)!=null?t:(e=this.properties.find(r=>r.type))==null?void 0:e.type)!=null?a:ee}safeExtractViewState(){if(!this.adapter)return null;try{return J(this.adapter)}catch{return null}}ensureAlive(){if(this.destroyed)throw new Error("MapFirstCore instance has been destroyed")}};function xe(n){return n.platform==="maplibre"}function re(n){return n.platform==="google"}function Le(n){return n.platform==="mapbox"}export{te as MapFirstCore,N as PropertiesFetchError,Me as convertToApiFilters,U as fetchImages,ve as fetchProperties,be as processApiFilters};
33
33
  //# sourceMappingURL=index.mjs.map