{"version":3,"file":"Masktest.Du95ObPD.mjs","names":["React.useRef","React.useCallback","p"],"sources":["https:/framerusercontent.com/modules/9Cqu3ZEy3l55brdky1Uu/Nkizzi54jBBXxKIerTTy/Masktest.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";export default function MaskCutout({targetName,mode=\"hide-inside\",radius=0,showOutline=false,outlineColor=\"rgba(255,255,255,0.5)\",outlineWidth=1,applyToAllMatches=false}){const hostRef=React.useRef(null);// 1 mask per target (so coordinates are local to each target)\nconst targetMasksRef=React.useRef(new Map);const targetsRef=React.useRef([]);const findTargets=React.useCallback(()=>{if(!targetName)return[];const selector=`[data-framer-name=\"${CSS.escape(targetName)}\"]`;return Array.from(document.querySelectorAll(selector));},[targetName]);function ensurePerTargetMask(target){const map=targetMasksRef.current;if(map.has(target))return map.get(target);// Create tiny offscreen SVG with a <mask> just for this target\nconst svg=document.createElementNS(\"http://www.w3.org/2000/svg\",\"svg\");svg.setAttribute(\"width\",\"0\");svg.setAttribute(\"height\",\"0\");svg.style.position=\"absolute\";svg.style.width=\"0\";svg.style.height=\"0\";svg.setAttribute(\"aria-hidden\",\"true\");const defs=document.createElementNS(\"http://www.w3.org/2000/svg\",\"defs\");const mask=document.createElementNS(\"http://www.w3.org/2000/svg\",\"mask\");// objectBoundingBox => mask coords in 0..1 of the target’s own box\nmask.setAttribute(\"maskUnits\",\"objectBoundingBox\");mask.setAttribute(\"maskContentUnits\",\"objectBoundingBox\");mask.style=\"mask-type: luminance;\";// Give this mask a unique id\nconst id=`mk-${Math.random().toString(36).slice(2)}`;mask.setAttribute(\"id\",id);defs.appendChild(mask);svg.appendChild(defs);document.body.appendChild(svg);// Apply the mask to the target using shorthand (more robust across engines)\nconst refUrl=`url(#${id})`;target.style.mask=refUrl;target.style.WebkitMask=refUrl;target.style.maskRepeat=\"no-repeat\";target.style.WebkitMaskRepeat=\"no-repeat\";target.style.maskMode=\"luminance\";const entry={svg,mask};map.set(target,entry);return entry;}function clearAllMasks(){const map=targetMasksRef.current;map.forEach(({svg},el)=>{el.style.removeProperty(\"mask\");el.style.removeProperty(\"-webkit-mask\");el.style.removeProperty(\"mask-repeat\");el.style.removeProperty(\"-webkit-mask-repeat\");el.style.removeProperty(\"mask-mode\");svg.remove();});map.clear();targetsRef.current=[];}// Compute normalized overlap rect of host within target (both via getBoundingClientRect)\nfunction computeNormalizedOverlap(target){const host=hostRef.current;if(!host)return null;const tr=target.getBoundingClientRect();const hr=host.getBoundingClientRect();const ix=Math.max(tr.left,hr.left);const iy=Math.max(tr.top,hr.top);const ax=Math.min(tr.right,hr.right);const ay=Math.min(tr.bottom,hr.bottom);const iw=Math.max(0,ax-ix);const ih=Math.max(0,ay-iy);if(iw<=0||ih<=0||tr.width<=0||tr.height<=0)return null;// Normalize to 0..1 relative to target box\nconst nx=(ix-tr.left)/tr.width;const ny=(iy-tr.top)/tr.height;const nw=iw/tr.width;const nh=ih/tr.height;return{nx,ny,nw,nh};}// Update a mask’s geometry in objectBoundingBox space (0..1)\nfunction updatePerTargetMask(target){const entry=ensurePerTargetMask(target);const{mask}=entry;// Clear children\nwhile(mask.firstChild)mask.removeChild(mask.firstChild);// Helper to add a rect in 0..1 space\nconst addRect=(x,y,w,h,fill,r)=>{const el=document.createElementNS(\"http://www.w3.org/2000/svg\",\"rect\");el.setAttribute(\"x\",String(Math.max(0,Math.min(1,x))));el.setAttribute(\"y\",String(Math.max(0,Math.min(1,y))));el.setAttribute(\"width\",String(Math.max(0,Math.min(1,w))));el.setAttribute(\"height\",String(Math.max(0,Math.min(1,h))));if(r&&r>0){// radius also normalized (approx): divide host radius by target min-dimension\nel.setAttribute(\"rx\",String(r));el.setAttribute(\"ry\",String(r));}el.setAttribute(\"fill\",fill);mask.appendChild(el);};// Default backgrounds\nif(mode===\"hide-inside\"){// Everything visible by default (white)\naddRect(0,0,1,1,\"white\");}else{// show-inside: everything hidden by default (black)\naddRect(0,0,1,1,\"black\");}const ov=computeNormalizedOverlap(target);if(!ov){// no overlap → use just the default rect ⇒ target fully visible (hide-inside) or fully hidden (show-inside)\n// For your requested behavior use mode=\"hide-inside\".\nreturn;}// Optional: convert pixel radius to normalized value roughly based on target box\nlet rNorm=0;if(radius>0){const tr=target.getBoundingClientRect();const minDim=Math.max(1,Math.min(tr.width,tr.height));rNorm=Math.max(0,Math.min(1,radius/minDim));}if(mode===\"hide-inside\"){// Paint the overlap black (hidden)\naddRect(ov.nx,ov.ny,ov.nw,ov.nh,\"black\",rNorm);}else{// show-inside: paint the overlap white (visible)\naddRect(ov.nx,ov.ny,ov.nw,ov.nh,\"white\",rNorm);}}// Refresh masks for all targets\nconst refreshAll=React.useCallback(()=>{const nodes=findTargets();targetsRef.current=applyToAllMatches?nodes:nodes.slice(0,1);// Ensure masks exist & update geometry\ntargetsRef.current.forEach(el=>{ensurePerTargetMask(el);updatePerTargetMask(el);});},[applyToAllMatches,findTargets,mode,radius]);// Observe scroll/resize and element resizes to keep the overlap correct\nReact.useEffect(()=>{refreshAll();const onScrollOrResize=()=>{targetsRef.current.forEach(el=>updatePerTargetMask(el));};window.addEventListener(\"scroll\",onScrollOrResize,{passive:true});window.addEventListener(\"resize\",onScrollOrResize);const roHost=new ResizeObserver(onScrollOrResize);if(hostRef.current)roHost.observe(hostRef.current);const roTargets=[];targetsRef.current.forEach(el=>{const ro=new ResizeObserver(onScrollOrResize);ro.observe(el);roTargets.push(ro);});return()=>{window.removeEventListener(\"scroll\",onScrollOrResize);window.removeEventListener(\"resize\",onScrollOrResize);roHost.disconnect();roTargets.forEach(r=>r.disconnect());clearAllMasks();};},[refreshAll]);// Recreate when props change\nReact.useEffect(()=>{// On prop changes, just recompute\ntargetsRef.current.forEach(el=>updatePerTargetMask(el));},[mode,radius]);React.useEffect(()=>{// If targetName/applyToAll changes, rebuild masks\nclearAllMasks();refreshAll();},[targetName,applyToAllMatches,refreshAll]);return /*#__PURE__*/_jsx(\"div\",{ref:hostRef,style:{position:\"relative\",width:\"100%\",height:\"100%\",background:\"transparent\",pointerEvents:\"none\",outline:showOutline?`${outlineWidth}px solid ${outlineColor}`:\"none\",borderRadius:radius,boxSizing:\"border-box\"},\"aria-label\":\"MaskCutout\"});}addPropertyControls(MaskCutout,{targetName:{type:ControlType.String,title:\"Target Name\",defaultValue:\"Sticky Text\"},mode:{type:ControlType.Enum,title:\"Mode\",options:[\"hide-inside\",\"show-inside\"],optionTitles:[\"Hide Inside\",\"Show Inside\"],defaultValue:\"hide-inside\"},applyToAllMatches:{type:ControlType.Boolean,title:\"Apply to All\",defaultValue:false},radius:{type:ControlType.Number,title:\"Radius\",defaultValue:0,min:0,max:120,step:1},showOutline:{type:ControlType.Boolean,title:\"Show Outline\",defaultValue:false},outlineColor:{type:ControlType.Color,title:\"Outline Color\",defaultValue:\"rgba(255,255,255,0.5)\",hidden:p=>!p.showOutline},outlineWidth:{type:ControlType.Number,title:\"Outline Width\",defaultValue:1,min:0,max:8,step:1,hidden:p=>!p.showOutline}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"MaskCutout\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Masktest.map"],"mappings":"0TAA2H,SAAwB,EAAW,CAAC,aAAW,OAAK,cAAc,SAAO,EAAE,cAAY,GAAM,eAAa,wBAAwB,eAAa,EAAE,oBAAkB,IAAO,CAAC,IAAM,EAAQA,EAAa,KAAK,CAChU,EAAeA,EAAa,IAAI,IAAI,CAAO,EAAWA,EAAa,EAAE,CAAC,CAAO,EAAYC,MAAsB,CAAC,GAAG,CAAC,EAAW,MAAM,EAAE,CAAC,IAAM,EAAS,sBAAsB,IAAI,OAAO,EAAW,CAAC,IAAI,OAAO,MAAM,KAAK,SAAS,iBAAiB,EAAS,CAAC,EAAG,CAAC,EAAW,CAAC,CAAC,SAAS,EAAoB,EAAO,CAAC,IAAM,EAAI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