{"version":3,"file":"BookingSection.DmDMly6J.mjs","names":["useRef","__esmMin","init_ssg_sandbox_shims","window","c","J","init_jsx_runtime","ce","init_npm_react_18_3_1","de","init_framer_DJ_0WPVq","RenderTarget","formTop","section","bookingEl","rect","max","navOffset","scrollToBooking","stopActive","cancelled","events","cancel","done","started","last","y","onTarget","tick","top","dt","now","smooth","step","useSectionRef","element","value","forwardedRef","withBookingSection","setRef","isCanvas","el","pendingBooking","Component","props","withKontaktaiBooking","lastHistoryNavigation","onClick","href","event","withBookingCTA","host","PHONE","init_BookingSection"],"sources":["https:/framerusercontent.com/modules/aB87GA8cmzimRinkjtxQ/IzbCwtmW8qNPJuf14e5z/BookingSection.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect,useRef}from\"react\";import{RenderTarget}from\"framer\";// Booking-form navigation (QA Round 4, reworked in Round 6). Path-independent: Framer drops the\n// \"#contact-us\" hash from rendered links and Preview runs on a different URL path.\n//   withKontaktaiBooking — CONTACT US 2 on /kontaktai: opens that page at the booking form.\n//   withBookingSection   — booking section on a page: registers the form for the page's CTA, and\n//                          opens at the form when a CTA on another page linked here.\n//   withBookingCTA       — \"Rezervuoti laiką\": scrolls to the form on the same page; when the page\n//                          has no registered form, keeps its normal link and lands on that page's form.\n//\n// Round 6 root cause: the Smooth Scroll component (Lenis) also handled the button's built-in\n// \"#contact-us\" link and ran its own smooth scroll to the section top (without the navbar offset).\n// While Lenis animates it ignores other scrolling, so the page crept past the form and was then\n// corrected with a jump. Now the click is taken in the capture phase (before Lenis / the link), and\n// one animation follows the form's live position every frame, so moving content never needs a jump.\nconst PHONE=\"(max-width: 809.98px)\";const navOffset=()=>window.matchMedia(PHONE).matches?90:110;const isCanvas=()=>RenderTarget.current()===RenderTarget.canvas;let bookingEl=null;let stopActive=null;let pendingBooking=0;let lastHistoryNavigation=0;if(typeof window!==\"undefined\"){window.addEventListener(\"popstate\",()=>{lastHistoryNavigation=Date.now();});// B7 fix: a click that is not on a booking CTA (e.g. a doctor card) clears any pending\n// \"open at the form\" request and stops a running booking scroll, so ordinary navigation\n// always opens the destination page at the top. This document capture listener runs before\n// the CTA's own capture listener, which then sets its request again.\ndocument.addEventListener(\"click\",event=>{const t=event.target;if(t?.closest?.(\"[data-upe-booking-cta]\"))return;pendingBooking=0;stopActive?.();},true);}function formTop(){const section=bookingEl;if(!section||!section.isConnected)return null;const target=section.querySelector(\"form\")??section;const rect=target.getBoundingClientRect();if(rect.height===0)return null;const max=document.documentElement.scrollHeight-window.innerHeight;return Math.max(0,Math.min(max,Math.round(window.scrollY+rect.top-navOffset())));}// Smooth: eases towards the form, re-reading its position every frame (images, appear effects),\n// ends when it has stayed on the form for a few frames. Instant: jumps, then keeps the form in\n// place while the page settles. Stops as soon as the visitor scrolls, touches or types.\nfunction scrollToBooking(smooth){stopActive?.();if(formTop()===null)return;let cancelled=false;const events=[\"wheel\",\"touchstart\",\"keydown\"];const cancel=()=>{cancelled=true;};events.forEach(e=>window.addEventListener(e,cancel,{passive:true}));const done=()=>{cancelled=true;events.forEach(e=>window.removeEventListener(e,cancel));if(stopActive===done)stopActive=null;};stopActive=done;const started=performance.now();let last=started,y=window.scrollY,onTarget=0;const tick=now=>{if(cancelled)return done();const top=formTop();if(top===null)return done();const dt=Math.min(64,now-last);last=now;if(smooth){const step=1-Math.exp(-dt/160);y=Math.abs(top-y)<1?top:y+(top-y)*step;}else{y=top;}if(Math.abs(window.scrollY-y)>=.5)window.scrollTo(0,y);onTarget=Math.abs(window.scrollY-top)<=1?onTarget+1:0;if(onTarget>=12||now-started>4e3)return done();requestAnimationFrame(tick);};requestAnimationFrame(tick);}function useSectionRef(forwardedRef){const element=useRef(null);const setRef=value=>{element.current=value;if(typeof forwardedRef===\"function\")forwardedRef(value);else if(forwardedRef)forwardedRef.current=value;};return[element,setRef];}export function withBookingSection(Component){return /*#__PURE__*/forwardRef(function BookingSection(props,forwardedRef){const[element,setRef]=useSectionRef(forwardedRef);useEffect(()=>{if(isCanvas())return;const el=element.current;bookingEl=el;// Arrived from a \"Rezervuoti laiką\" button on another page: open at the form.\nif(Date.now()<pendingBooking){pendingBooking=0;requestAnimationFrame(()=>scrollToBooking(false));}return()=>{if(bookingEl===el){bookingEl=null;stopActive?.();}};},[]);return /*#__PURE__*/_jsx(Component,{...props,ref:setRef});});}export function withKontaktaiBooking(Component){return /*#__PURE__*/forwardRef(function KontaktaiBooking(props,forwardedRef){const[element,setRef]=useSectionRef(forwardedRef);useEffect(()=>{if(isCanvas())return;const el=element.current;bookingEl=el;pendingBooking=0;el?.setAttribute(\"data-upe-kontaktai\",\"\");// Arriving on /kontaktai (from any page): open at the booking form, except Back/Forward.\nif(Date.now()-lastHistoryNavigation>1500)requestAnimationFrame(()=>scrollToBooking(false));// \"Kontaktai\" clicked while already on /kontaktai: Framer keeps the page mounted.\nconst onClick=event=>{const a=event.target?.closest?.(\"a\");const href=a?.getAttribute(\"href\")||\"\";if(!/(^|\\/)kontaktai\\/?(#.*)?$/.test(href))return;requestAnimationFrame(()=>requestAnimationFrame(()=>scrollToBooking(true)));};document.addEventListener(\"click\",onClick);return()=>{document.removeEventListener(\"click\",onClick);if(bookingEl===el){bookingEl=null;stopActive?.();}};},[]);return /*#__PURE__*/_jsx(Component,{...props,ref:setRef});});}export function withBookingCTA(Component){// Phase 3 fix: the Button component does not hand its DOM element to an override ref, so the\n// earlier version never attached (no data-upe-booking-cta on the live site; clicks fell through to\n// the plain \"#contact-us\" link). The listener now sits on a display:contents wrapper (same pattern\n// as QA/TeamCarousel.tsx), which takes no space and leaves the button's layout and design unchanged.\nreturn /*#__PURE__*/forwardRef(function BookingCTA(props,forwardedRef){const host=useRef(null);useEffect(()=>{if(isCanvas())return;const el=host.current;if(!el)return;const onClick=event=>{if(formTop()===null){// No booking form registered on this page: follow the button's own link and\n// open the destination page at its form.\npendingBooking=Date.now()+5e3;return;}// Same page has the form: smooth-scroll to it without following the \"#…\" link,\n// so no fragment is added to the address bar.\nevent.preventDefault();event.stopPropagation();scrollToBooking(true);};// Capture phase: runs before the link and the Smooth Scroll anchor handling.\nel.addEventListener(\"click\",onClick,true);return()=>el.removeEventListener(\"click\",onClick,true);},[]);return /*#__PURE__*/_jsx(\"div\",{ref:host,\"data-upe-booking-cta\":\"\",style:{display:\"contents\"},children:/*#__PURE__*/_jsx(Component,{...props,ref:forwardedRef})});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withBookingCTA\":{\"type\":\"reactHoc\",\"name\":\"withBookingCTA\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withKontaktaiBooking\":{\"type\":\"reactHoc\",\"name\":\"withKontaktaiBooking\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withBookingSection\":{\"type\":\"reactHoc\",\"name\":\"withBookingSection\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BookingSection.map"],"mappings":"A,gMAiByJ,SAASY,GAAS,CAAC,IAAMC,EAAQC,EAAU,GAAG,CAACD,GAAS,CAACA,EAAQ,YAAY,OAAO,KAAyD,IAAME,GAA7CF,EAAQ,cAAc,MAAM,GAAGA,EAAA,CAA0B,sBAAsB,EAAE,GAAGE,EAAK,SAAS,EAAE,OAAO,KAAK,IAAMC,EAAI,SAAS,gBAAgB,aAAab,EAAO,YAAY,OAAO,KAAK,IAAI,EAAE,KAAK,IAAIa,EAAI,KAAK,MAAMb,EAAO,QAAQY,EAAK,IAAIE,EAAU,CAAC,CAAC,CAAC,CAAE,CAGngB,SAASC,EAAgB,EAAO,CAAgB,GAAfC,IAAa,EAAKP,EAAQ,IAAI,KAAK,OAAO,IAAIQ,EAAU,GAAYC,EAAO,CAAC,QAAQ,aAAa,SAAS,EAAQC,MAAW,CAAC,EAAU,EAAK,EAAED,EAAO,QAAQ,GAAGlB,EAAO,iBAAiB,EAAEmB,EAAO,CAAC,QAAQ,EAAI,CAAC,CAAC,EAAE,IAAMC,MAAS,CAAC,EAAU,GAAKF,E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