{"version":3,"sources":["webpack:///./app/javascript/packs/form_toggle.js"],"names":["document","addEventListener","console","log","formToggle","querySelector","tourForm","formBody","formChevron","isFormOpen","handleToggle","bookNowText","chevronIcon","e","contains","target","updateFormState","key","stopPropagation","$","off","on","open","classList","add","remove","style","transform","setTimeout","scrollIntoView","behavior","preventDefault"],"mappings":"+EAAA,YACAA,SAASC,iBAAiB,mBAAmB,WACzCC,QAAQC,IAAI,6BAGZ,IAAMC,EAAaJ,SAASK,cAAc,6BACpCC,EAAWN,SAASK,cAAc,sBAClCE,EAAWP,SAASK,cAAc,mBAClCG,EAAcR,SAASK,cAAc,iBAE3C,GAAKD,GAAeE,GAAaC,EAAjC,CASAL,QAAQC,IAAI,0DAGZ,IAAIM,GAAa,EAqCjBL,EAAWH,iBAAiB,QAASS,GAGrC,IAAMC,EAAcP,EAAWC,cAAc,KACvCO,EAAcR,EAAWC,cAAc,iBAEzCM,GACAA,EAAYV,iBAAiB,QAASS,GAEtCE,GACAA,EAAYX,iBAAiB,QAASS,GAI1CV,SAASC,iBAAiB,SAAS,SAASY,IACpCJ,GAAeH,EAASQ,SAASD,EAAEE,SAAYX,EAAWU,SAASD,EAAEE,UACrEb,QAAQC,IAAI,yBACZM,GAAa,EACbO,GAAgB,GAExB,IAGAA,GAAgB,GAGhBhB,SAASC,iBAAiB,WAAW,SAASY,GAC5B,WAAVA,EAAEI,KAAoBR,IACtBA,GAAa,EACbO,GAAgB,GAExB,IAGIT,GACAA,EAASN,iBAAiB,SAAS,SAASY,GACpCJ,GACAI,EAAEK,iBAEV,IAIa,qBAANC,GACPA,EAAE,6BAA6BC,IAAI,SAASC,GAAG,SAAS,SAASR,GAC7DH,EAAaG,EACjB,GAxFJ,MANIX,QAAQC,IAAI,uCAAwC,CAChDC,aAAcA,EACdE,WAAYA,EACZC,WAAYA,IAWpB,SAASS,EAAgBM,GACrBpB,QAAQC,IAAI,uBAAwBmB,GAEhCA,GACAhB,EAASiB,UAAUC,IAAI,UACvBjB,EAASgB,UAAUE,OAAO,UAC1BlB,EAASgB,UAAUC,IAAI,SACnBhB,IACAA,EAAYkB,MAAMC,UAAY,kBAGlCC,YAAW,WACPrB,EAASsB,eAAe,CAAEC,SAAU,UACxC,GAAG,OAEHxB,EAASiB,UAAUE,OAAO,UAC1BlB,EAASgB,UAAUC,IAAI,UACvBjB,EAASgB,UAAUE,OAAO,SACtBjB,IACAA,EAAYkB,MAAMC,UAAY,gBAG1C,CAGA,SAASjB,EAAaG,GAClBX,QAAQC,IAAI,iBAAkBU,EAAEE,QAChCF,EAAEkB,iBACFlB,EAAEK,kBAEFF,EADAP,GAAcA,EAElB,CAmDJ,G","file":"js/10-0a303c51d97536679bb2.chunk.js","sourcesContent":["// Shows/Hides Tour Form\ndocument.addEventListener(\"turbolinks:load\", function() {\n console.log('Form toggle script loaded');\n\n // Variables\n const formToggle = document.querySelector('.tour-form-header-actions');\n const tourForm = document.querySelector('.tour-form-wrapper');\n const formBody = document.querySelector('.tour-form-body');\n const formChevron = document.querySelector('.form-chevron');\n \n if (!formToggle || !tourForm || !formBody) {\n console.log('Form elements not found on this page', {\n formToggle: !!formToggle,\n tourForm: !!tourForm,\n formBody: !!formBody\n });\n return;\n }\n\n console.log('Form elements found, initializing toggle functionality');\n\n // Estado inicial\n let isFormOpen = false;\n\n // Función para actualizar el estado visual\n function updateFormState(open) {\n console.log('Updating form state:', open);\n \n if (open) {\n tourForm.classList.add('active');\n formBody.classList.remove('hidden');\n formBody.classList.add('shown');\n if (formChevron) {\n formChevron.style.transform = 'rotate(180deg)';\n }\n // Scroll al formulario\n setTimeout(() => {\n formBody.scrollIntoView({ behavior: 'smooth' });\n }, 100);\n } else {\n tourForm.classList.remove('active');\n formBody.classList.add('hidden');\n formBody.classList.remove('shown');\n if (formChevron) {\n formChevron.style.transform = 'rotate(0deg)';\n }\n }\n }\n\n // Función para manejar el toggle\n function handleToggle(e) {\n console.log('Toggle clicked', e.target);\n e.preventDefault();\n e.stopPropagation();\n isFormOpen = !isFormOpen;\n updateFormState(isFormOpen);\n }\n\n // Agregar eventos de click\n formToggle.addEventListener('click', handleToggle);\n \n // También agregar el evento al párrafo y al ícono dentro del botón\n const bookNowText = formToggle.querySelector('p');\n const chevronIcon = formToggle.querySelector('.form-chevron');\n \n if (bookNowText) {\n bookNowText.addEventListener('click', handleToggle);\n }\n if (chevronIcon) {\n chevronIcon.addEventListener('click', handleToggle);\n }\n\n // Cerrar al hacer click fuera\n document.addEventListener('click', function(e) {\n if (isFormOpen && !tourForm.contains(e.target) && !formToggle.contains(e.target)) {\n console.log('Clicking outside form');\n isFormOpen = false;\n updateFormState(false);\n }\n });\n\n // Asegurarse de que el formulario esté cerrado al cargar la página\n updateFormState(false);\n\n // Manejar el evento de escape para cerrar el formulario\n document.addEventListener('keydown', function(e) {\n if (e.key === 'Escape' && isFormOpen) {\n isFormOpen = false;\n updateFormState(false);\n }\n });\n\n // Prevenir que el scroll del formulario afecte a la página\n if (formBody) {\n formBody.addEventListener('wheel', function(e) {\n if (isFormOpen) {\n e.stopPropagation();\n }\n });\n }\n\n // Backup con jQuery por si acaso\n if (typeof $ !== 'undefined') {\n $('.tour-form-header-actions').off('click').on('click', function(e) {\n handleToggle(e);\n });\n }\n});"],"sourceRoot":""}