{"version":3,"file":"FAQAccessibility.HBg_VypL.mjs","names":["React.useRef","React.useId"],"sources":["https:/framerusercontent.com/modules/buIlbyNbInJvkYnggYOO/c80Ex7IfHzSrafTOdVjo/FAQAccessibility.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";const questionOwnerMap=new WeakMap;function getToggleEl(questionEl){const toggle=questionEl.querySelector(\"[data-framer-name='Toggle']\");if(!toggle)return null;const value=(toggle.textContent||\"\").trim();if(value===\"+\"||value===\"–\"||value===\"−\")return toggle;return null;}function normalizeQuestionText(questionEl){const clone=questionEl.cloneNode(true);const toggle=clone.querySelector(\"[data-framer-name='Toggle']\");if(toggle)toggle.remove();const fallback=clone.textContent||\"\";return fallback.replace(/\\s+/g,\" \").trim();}function inferExpanded(questionEl){const toggle=getToggleEl(questionEl);if(!toggle)return false;return(toggle.textContent||\"\").trim()!==\"+\";}function findAnswerRegion(questionEl,containerEl){if(questionEl.nextElementSibling instanceof HTMLElement)return questionEl.nextElementSibling;const children=Array.from(containerEl.children);const idx=children.indexOf(questionEl);if(idx>=0&&children[idx+1]instanceof HTMLElement){return children[idx+1];}return null;}/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function FAQAccessibility(props){const{enabled=true,style}=props;const rootRef=React.useRef(null);const instanceId=React.useId().replace(/:/g,\"\");const questionAttr=`data-faq-a11y-question-${instanceId}`;React.useEffect(()=>{if(!enabled)return;if(typeof window===\"undefined\"||typeof document===\"undefined\")return;const scope=document;let cleanupFns=[];let updateTimer=0;let observer=null;let pendingFocusLabel=\"\";const cleanupListeners=()=>{cleanupFns.forEach(fn=>fn());cleanupFns=[];};const scheduleUpdate=()=>{if(updateTimer)window.clearTimeout(updateTimer);updateTimer=window.setTimeout(()=>{updateA11y();},20);};const updateA11y=()=>{cleanupListeners();const candidates=Array.from(scope.querySelectorAll(\"[data-framer-name='Question']\"));const faqQuestions=candidates.filter(el=>{return!!getToggleEl(el);});faqQuestions.forEach((questionEl,index)=>{const container=questionEl.parentElement;if(!container)return;const labelText=normalizeQuestionText(questionEl);const expanded=inferExpanded(questionEl);const qId=`${questionAttr}-${index}`;if(questionEl.getAttribute(\"role\")!==\"button\")questionEl.setAttribute(\"role\",\"button\");if(questionEl.tabIndex!==0)questionEl.tabIndex=0;if(questionEl.getAttribute(\"aria-expanded\")!==String(expanded)){questionEl.setAttribute(\"aria-expanded\",String(expanded));}if(questionEl.getAttribute(\"aria-label\")!==labelText){questionEl.setAttribute(\"aria-label\",labelText);}if(questionEl.getAttribute(questionAttr)!==qId){questionEl.setAttribute(questionAttr,qId);}const answerRegion=findAnswerRegion(questionEl,container);if(answerRegion){const regionId=`${questionAttr}-region-${index}`;if(answerRegion.id!==regionId)answerRegion.id=regionId;if(questionEl.getAttribute(\"aria-controls\")!==regionId){questionEl.setAttribute(\"aria-controls\",regionId);}const hiddenValue=String(!expanded);if(answerRegion.getAttribute(\"aria-hidden\")!==hiddenValue){answerRegion.setAttribute(\"aria-hidden\",hiddenValue);}}const onKeyDown=event=>{if(event.key!==\"Enter\"&&event.key!==\" \")return;event.preventDefault();event.stopImmediatePropagation();pendingFocusLabel=labelText;if(typeof PointerEvent!==\"undefined\"){const pointerDown=new PointerEvent(\"pointerdown\",{bubbles:true,pointerId:1,pointerType:\"mouse\",isPrimary:true,button:0,buttons:1});const pointerUp=new PointerEvent(\"pointerup\",{bubbles:true,pointerId:1,pointerType:\"mouse\",isPrimary:true,button:0,buttons:0});questionEl.dispatchEvent(pointerDown);questionEl.dispatchEvent(pointerUp);}else{questionEl.click();}};const owner=questionOwnerMap.get(questionEl);if(owner&&owner!==instanceId)return;questionOwnerMap.set(questionEl,instanceId);questionEl.addEventListener(\"keydown\",onKeyDown,true);cleanupFns.push(()=>{questionEl.removeEventListener(\"keydown\",onKeyDown,true);if(questionOwnerMap.get(questionEl)===instanceId){questionOwnerMap.delete(questionEl);}});});if(pendingFocusLabel){const match=faqQuestions.find(el=>{return normalizeQuestionText(el)===pendingFocusLabel;});if(match)match.focus();pendingFocusLabel=\"\";}};updateA11y();observer=new MutationObserver(()=>{scheduleUpdate();});observer.observe(scope,{childList:true,subtree:true,characterData:true});return()=>{if(updateTimer)window.clearTimeout(updateTimer);cleanupListeners();if(observer)observer.disconnect();};},[enabled,questionAttr]);return /*#__PURE__*/_jsx(\"div\",{ref:rootRef,style:{position:\"absolute\",width:0,height:0,overflow:\"hidden\",pointerEvents:\"none\",...style},\"aria-hidden\":\"true\",children:/*#__PURE__*/_jsx(\"style\",{children:`\n                [${questionAttr}]:focus-visible {\n                    outline: 2px solid #6B3237 !important;\n                    outline-offset: 2px !important;\n                }\n            `})});}addPropertyControls(FAQAccessibility,{enabled:{type:ControlType.Boolean,title:\"Enabled\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FAQAccessibility\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FAQAccessibility.map"],"mappings":"sMAA8J,SAAS,EAAY,EAAW,CAAC,IAAM,EAAO,EAAW,cAAc,6BAA6B,EAAE,GAAG,CAAC,EAAO,OAAO,KAAK,IAAM,GAAO,EAAO,aAAa,GAAA,CAAI,KAAK,EAAyD,OAApD,IAAQ,KAAK,IAAQ,KAAK,IAAQ,IAAW,EAAc,IAAK,CAAC,SAAS,EAAsB,EAAW,CAAC,IAAM,EAAM,EAAW,UAAU,EAAI,EAAQ,EAAO,EAAM,cAAc,6BAA6B,EAAiE,OAA5D,GAAO,EAAO,OAAO,GAAiB,EAAM,aAAa,GAAA,CAAmB,QAAQ,OAAO,GAAG,CAAC,CAAC,KAAK,CAAE,CAAC,SAAS,EAAc,EAAW,CAAC,IAAM,E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