{"version":3,"file":"ColorWaveText.DcBp3jfX.mjs","names":["React.useRef","__legacyOverrideHOC_DataObserverContext","_jsx"],"sources":["https:/framerusercontent.com/modules/QZcobI21bAefEyOwJBLf/9FTltZOdhfwO2Z0nspit/ColorWaveText.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";// ─────────────────────────────\n// Color Wave Configuration & Helpers\n// ─────────────────────────────\nconst defaultColors=[\"#FFB592\",\"#FABA17\",\"#60E21B\",\"#24E0AF\",\"#6CD5FD\",\"#A7ABFF\",\"#F6AFFF\",\"#FFB0CD\"];let activeColors=[...defaultColors];const config={frequency:{min:2e3,max:6e3},startPoints:4,propagationLimit:6,waveSpeed:200,propagationDelay:250};function randomBetween(min,max){return Math.floor(Math.random()*(max-min+1))+min;}function isSameLine(span1,span2){const rect1=span1.getBoundingClientRect();const rect2=span2.getBoundingClientRect();return Math.abs(rect1.top-rect2.top)<2;}// ─────────────────────────────\n// Recursively wrap text nodes without altering existing HTML structure\n// ─────────────────────────────\nfunction wrapTextNodes(node){if(node.nodeType===Node.TEXT_NODE){const text=node.textContent;if(text&&text.length>0){const fragment=document.createDocumentFragment();// Wrap every character—even spaces—to preserve the layout\nfor(const char of text){const span=document.createElement(\"span\");span.textContent=char;// Add only the color transition (do not override other styles)\nspan.style.transition=`color ${config.waveSpeed}ms ease`;// Mark this span so we can target it later\nspan.setAttribute(\"data-color-wave-char\",\"true\");fragment.appendChild(span);}node.parentNode?.replaceChild(fragment,node);}}else if(node.nodeType===Node.ELEMENT_NODE){// Skip nodes that are already marked as a color-wave span.\nif(node.getAttribute(\"data-color-wave-char\")===\"true\"){return;}// Process child nodes recursively.\nconst childNodes=Array.from(node.childNodes);for(const child of childNodes){wrapTextNodes(child);}}}// ─────────────────────────────\n// ColorWaveText Override\n// ─────────────────────────────\nexport function ColorWaveText(){const ref=React.useRef(null);const timers=React.useRef([]);React.useEffect(()=>{const element=ref.current;if(!element)return;// Only wrap text nodes once so we don't interfere with any custom styling.\nif(!element.getAttribute(\"data-color-wave-initialized\")){wrapTextNodes(element);element.setAttribute(\"data-color-wave-initialized\",\"true\");}// Query only the spans that we inserted.\nconst spans=element.querySelectorAll(\"span[data-color-wave-char='true']\");// Helper: Clear any active timers.\nfunction clearTimers(){timers.current.forEach(timerId=>clearTimeout(timerId));timers.current=[];}// Function to start a wave effect from a given starting index.\nfunction startColorWave(spans,startIndex,colorCycle){const targetColors=[...colorCycle];const totalStages=targetColors.length+1;let propagationCount=0;function applyWave(index,stage){if(index<0||index>=spans.length||stage>=totalStages)return;const span=spans[index];if(stage<targetColors.length){span.style.color=targetColors[stage];}else{// Reset to inherit the original color from the parent styling.\nspan.style.color=\"\";}const timerId=window.setTimeout(()=>applyWave(index,stage+1),config.waveSpeed);timers.current.push(timerId);// Propagate to the next character only if on stage 0 and within our propagation limit.\nif(stage===0&&propagationCount<config.propagationLimit){propagationCount++;const nextIndex=index+1;if(nextIndex<spans.length&&isSameLine(spans[index],spans[nextIndex])){const timerId2=window.setTimeout(()=>applyWave(nextIndex,0),config.propagationDelay);timers.current.push(timerId2);}}}applyWave(startIndex,0);}// Function to trigger color wave effects periodically.\nfunction triggerColorEffect(){for(let i=0;i<config.startPoints;i++){const randomIndex=Math.floor(Math.random()*spans.length);const firstColorIndex=Math.floor(Math.random()*activeColors.length);const firstColor=activeColors[firstColorIndex];const secondColorIndex=(firstColorIndex+1)%activeColors.length;const secondColor=activeColors[secondColorIndex];startColorWave(spans,randomIndex,[firstColor,secondColor]);}const nextTriggerDelay=randomBetween(config.frequency.min,config.frequency.max);const timerId=window.setTimeout(triggerColorEffect,nextTriggerDelay);timers.current.push(timerId);}clearTimers();triggerColorEffect();// Cleanup on unmount.\nreturn()=>{clearTimers();};},[]);return{ref};}import{useContext as __legacyOverrideHOC_useContext}from\"react\";import{DataObserverContext as __legacyOverrideHOC_DataObserverContext}from\"framer\";export function withColorWaveText(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...ColorWaveText(props)});};}withColorWaveText.displayName=\"ColorWaveText\";\nexport const __FramerMetadata__ = {\"exports\":{\"withColorWaveText\":{\"type\":\"reactHoc\",\"name\":\"withColorWaveText\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"ColorWaveText\":{\"type\":\"override\",\"name\":\"ColorWaveText\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ColorWaveText.map"],"mappings":"2LAGyP,SAAS,EAAc,EAAI,EAAI,CAAC,OAAO,KAAK,MAAM,KAAK,OAAO,GAAG,EAAI,EAAI,EAAE,EAAE,CAAI,CAAC,SAAS,EAAW,EAAM,EAAM,CAAC,IAAM,EAAM,EAAM,sBAAsB,EAAQ,EAAM,EAAM,sBAAsB,EAAE,OAAO,KAAK,IAAI,EAAM,IAAI,EAAM,GAAG,EAAE,CAAE,CAGve,SAAS,EAAc,EAAK,CAAC,GAAG,EAAK,WAAW,KAAK,UAAU,CAAC,IAAM,EAAK,EAAK,YAAY,GAAG,GAAM,EAAK,OAAO,EAAE,CAAC,IAAM,EAAS,SAAS,uBAAuB,EACnK,IAAI,IAAM,KAAQ,EAAK,CAAC,IAAM,EAAK,SAAS,cAAc,MAAM,EAAE,EAAK,YAAY,EACnF,EAAK,MAAM,WAAW,SAAS,EAAO,UAAU,SAChD,EAAK,aAAa,uBAAuB,MAAM,EAAE,EAAS,YAAY,CAAI,CAAE,CAAC,EAAK,YAAY,aAAa,EAAS,CAAI,CAAE,CAAC,MAAM,GAAG,EAAK,WAAW,KAAK,aAAa,CACtK,GAAG,EAAK,aAAa,sBAAsB,IAAI,OAAQ,OACvD,IAAM,EAAW,MAAM,KAAK,EAAK,UAAU,EAAE,IAAI,IAAM,KAAS,EAAY,EAAc,CAAK,CAAG,CAAC,CAGnG,SAAgB,GAAe,CAAC,IAAM,EAAIA,EAAa,IAAI,EAAQ,EAAOA,EAAa,CAAC,CAAC,EA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