{"version":3,"file":"WithFilteredEvents.DEFOzbBD.mjs","names":["useSyncExternalStore","useMemo","useState","useRef"],"sources":["https:/framerusercontent.com/modules/boqN9HCwSOYHyYEWrAGJ/A1CAtMiDKh0F94rlFwmm/type_store.js","https:/framerusercontent.com/modules/rS423lvBxZbN1kBFVlzY/47YQYzumEJcKHWZ8lQ6T/WithFilteredEvents.js"],"sourcesContent":["import{useSyncExternalStore}from\"react\";const defaultFilters={type:null,topic:null,format:null};let filters={...defaultFilters};const listeners=new Set;/**\n * Toggle the provided value for a given filter key.\n * Selecting the same value twice clears it.\n */export function toggleFilter(key,value){const next=sanitize(value);const current=filters[key];const nextValue=next&&current===next?null:next;updateFilters({[key]:nextValue});}export function clearFilter(key){if(filters[key]===null){return;}updateFilters({[key]:null});}export function clearAllFilters(){updateFilters({...defaultFilters});}/**\n * Hook for reading a specific filter key.\n */export function useSelectedFilter(key){const snapshot=useSyncExternalStore(subscribe,getSnapshot,getSnapshot);return snapshot[key];}/**\n * Backwards-compatible helpers for existing overrides.\n */export function toggleType(value){toggleFilter(\"type\",value);}export function clearType(){clearFilter(\"type\");}export function useSelectedType(){return useSelectedFilter(\"type\");}function updateFilters(partial){const nextFilters={...filters,...partial};const hasChanged=Object.keys(nextFilters).some(key=>nextFilters[key]!==filters[key]);if(!hasChanged){return;}filters=nextFilters;listeners.forEach(listener=>listener());}function subscribe(listener){listeners.add(listener);return()=>listeners.delete(listener);}function getSnapshot(){return filters;}function sanitize(value){if(typeof value!==\"string\"){return null;}const trimmed=value.trim();return trimmed.length>0?trimmed:null;}\nexport const __FramerMetadata__ = {\"exports\":{\"clearFilter\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"toggleFilter\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"toggleType\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"clearAllFilters\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"FilterKey\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useSelectedFilter\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useSelectedType\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"clearType\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./type_store.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect,useMemo,useRef,useState}from\"react\";import{useSelectedFilter}from\"https://framerusercontent.com/modules/boqN9HCwSOYHyYEWrAGJ/A1CAtMiDKh0F94rlFwmm/type_store.js\";const FILTER_KEYS=[\"type\",\"topic\",\"format\"];export function withFilteredEvents(Component){return /*#__PURE__*/forwardRef(function WithFilteredEvents(props,ref){const selectedFilters={type:useSelectedFilter(\"type\"),topic:useSelectedFilter(\"topic\"),format:useSelectedFilter(\"format\")};const cardValues=useMemo(()=>({type:resolveFilterValues(\"type\",props),topic:resolveFilterValues(\"topic\",props),format:resolveFilterValues(\"format\",props)}),[props]);const isMatch=shouldRender(selectedFilters,cardValues);logDebug(1,{title:props.title??props.item?.title??\"unknown\",selectedFilters,cardValues,topicValue:cardValues.topic,isMatch});const[shouldMount,setShouldMount]=useState(isMatch);const animationStyle=mergeAnimatedStyle(props.style,isMatch);const wrapperRef=useRef(null);useEffect(()=>{if(isMatch){setShouldMount(true);return;}const timeout=setTimeout(()=>{setShouldMount(false);},HIDE_DELAY_MS);return()=>clearTimeout(timeout);},[isMatch]);useEffect(()=>{const host=wrapperRef.current?.parentElement;if(!host){return;}if(!shouldMount&&!isMatch){host.style.display=\"none\";host.setAttribute(\"data-filter-hidden-host\",\"true\");}else{host.style.removeProperty(\"display\");host.removeAttribute(\"data-filter-hidden-host\");}},[shouldMount,isMatch]);return /*#__PURE__*/_jsx(\"div\",{ref:wrapperRef,\"data-filter-wrapper\":\"\",children:shouldMount||isMatch?/*#__PURE__*/_jsx(Component,{...props,ref:ref,style:animationStyle,\"aria-hidden\":isMatch?undefined:true,\"data-filter-hidden\":isMatch?undefined:\"true\"}):null});});}export default withFilteredEvents;function shouldRender(selected,cardValues){return FILTER_KEYS.every(key=>{const normalizedRequired=normalize(selected[key]);if(!normalizedRequired){return true;}const normalizedValue=normalize(cardValues[key]);return normalizedValue===normalizedRequired;});}function resolveFilterValues(filterKey,props){if(filterKey===\"topic\"){const direct=firstValid(props.filterTopic,props.topic,props.tagTitle,props.item?.topic,props.eventTopic?.title);if(direct){return direct;}const topicCollections=[props.topics,readCollection(props[\"eventsTopics\"]),readCollection(props[\"events_topics\"]),props.item?.topics,readCollection(props.item?.[\"eventsTopics\"]),readCollection(props.item?.[\"events_topics\"])];for(const collection of topicCollections){const match=pickFromArray(collection);if(match){return match;}}return undefined;}const candidates=filterKey===\"type\"?[props.filterType,props.type,props.tag,props.tagTitle,props.category,props.item?.type,props.item?.tag,props.item?.category,props.eventType?.title]:[props.filterFormat,props.format,props.mode,props.delivery,props.tagTitle,props.item?.format,props.item?.formats&&pickFromArray(props.item.formats),props.eventFormat?.title];return firstValid(...candidates);}function readCollection(value){return Array.isArray(value)?value:undefined;}function pickFromArray(values){if(!values||values.length===0){return undefined;}for(const value of values){if(typeof value===\"string\"&&value.trim().length>0){return value;}if(value&&typeof value===\"object\"&&typeof value.title===\"string\"&&value.title.trim().length>0){return value.title;}if(value&&typeof value===\"object\"&&typeof value.name===\"string\"&&value.name.trim().length>0){return value.name;}}return undefined;}function firstValid(...values){for(const value of values){const cleaned=coerce(value);if(cleaned){return cleaned;}}return undefined;}function coerce(value){if(typeof value!==\"string\"){return undefined;}const trimmed=value.trim();return trimmed.length>0?trimmed:undefined;}function normalize(value){const cleaned=coerce(value);return cleaned?cleaned.toLocaleLowerCase():undefined;}const HIDE_DELAY_MS=180;function mergeAnimatedStyle(existing,isMatch){const next={...existing,opacity:isMatch?1:0,transform:isMatch?existing?.transform??\"scale(1)\":\"scale(0.98)\",pointerEvents:isMatch?existing?.pointerEvents:\"none\"};if(!existing?.transition){next.transition=`opacity ${HIDE_DELAY_MS}ms ease, transform ${HIDE_DELAY_MS}ms ease`;}return next;}function logDebug(action,payload){console.log(`[Filters#${action}]`,payload);}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactHoc\",\"name\":\"withFilteredEvents\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFilteredEvents\":{\"type\":\"reactHoc\",\"name\":\"withFilteredEvents\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./WithFilteredEvents.map"],"mappings":"qJAKG,SAAgB,EAAkB,EAAI,CAAwE,OAAxDA,EAAqB,EAAU,EAAY,EAAY,CAAiB,GAEyS,SAAS,EAAU,EAAS,CAAyB,OAAxB,EAAU,IAAI,EAAS,KAAW,EAAU,OAAO,EAAS,CAAE,SAAS,GAAa,CAAC,OAAO,yBAP3f,CAAM,EAAe,CAAC,KAAK,KAAK,MAAM,KAAK,OAAO,KAAK,CAAK,EAAQ,CAAC,GAAG,EAAe,CAAO,EAAU,IAAI,OCAgI,SAAgB,EAAmB,EAAU,CAAC,OAAoB,EAAW,SAA4B,EAAM,EAAI,CAAC,IAAM,EAAgB,CAAC,KAAK,EAAkB,OAAO,CAAC,MAAM,EAAkB,QAAQ,CAAC,OAAO,EAAkB,SAAS,CAAC,CAAO,EAAWC,OAAa,CAAC,KAAK,EAAoB,OAAO,EAAM,CAAC,MAAM,EAAoB,QAAQ,EAAM,CAAC,OAAO,EAAoB,SAAS,EAAM,CAAC,EAAE,CAAC,EAAM,CAAC,CAAO,EAAQ,EAAa,EAAgB,EAAW,CAAC,EAAS,EAAE,CAAC,MAAM,EAAM,OAAO,EAAM,MAAM,OAAO,UAAU,kBAAgB,aAAW,WAAW,EAAW,MAAM,UAAQ,CAAC,CAAC,GAAK,CAAC,EAAY,GAAgBC,EAAS,EAAQ,CAAO,EAAe,EA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