{"version":3,"file":"CopyEmailOnDesktop.DG5bE4M7.mjs","names":["useRef","useCallback"],"sources":["https:/framerusercontent.com/modules/zfiwlrp9XZeYQzfomiqx/38H8HWBpDyhi4NcM7m2z/CopyEmailOnDesktop.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useCallback,useEffect,useRef}from\"react\";// User request: 1) Update `ContactProductInquiryEmail.tsx` so the Contact email CTA behaves as follows:\n// - On desktop/tablet viewports (width 810px or wider), clicking copies `ofaa.atelier@gmail.com` to the clipboard, prevents the email navigation, and temporarily changes only the CTA’s visible label to `Copied ✓` for about 1.6 seconds before restoring it. Use `navigator.clipboard.writeText` with a safe fallback when unavailable. Preserve canvas styling and accessibility. This behavior wins even when a `product` query parameter is present.\n// - On phone widths (below 810px), keep the existing behavior exactly: when `product` is in the query, open the current prefilled product mailto; otherwise preserve the component’s native email action.\n//\n// 2) Create a code override export named `CopyEmailOnDesktop` in a new file. It will be applied to a simple canvas email link wrapper. On width 810px or wider, it copies `ofaa.atelier@gmail.com`, prevents mailto navigation, and temporarily changes the wrapper’s visible text to `Copied ✓` for 1.6 seconds before restoring it. On phone widths, it must allow the canvas element’s normal mailto link behavior unchanged. Preserve ref, props, styling, keyboard activation, and add a safe clipboard fallback. Do not create a new visual component; overrides only.\nexport function CopyEmailOnDesktop(Component){return /*#__PURE__*/forwardRef(function CopyEmailOnDesktopOverride(props,ref){const rootRef=useRef(null);const restoreTextRef=useRef(null);const timeoutRef=useRef(null);const assignRefs=useCallback(node=>{rootRef.current=node;if(typeof ref===\"function\"){ref(node);}else if(ref&&typeof ref===\"object\"){ref.current=node;}},[ref]);const isDesktopOrTablet=()=>{if(typeof window===\"undefined\")return false;return window.innerWidth>=810;};const clearFeedbackTimeout=useCallback(()=>{if(timeoutRef.current===null||typeof window===\"undefined\")return;window.clearTimeout(timeoutRef.current);timeoutRef.current=null;},[]);const restoreLabel=useCallback(()=>{if(!restoreTextRef.current)return;restoreTextRef.current.node.textContent=restoreTextRef.current.value;restoreTextRef.current=null;},[]);const findFirstTextNode=rootElement=>{const walker=document.createTreeWalker(rootElement,NodeFilter.SHOW_TEXT);let current=walker.nextNode();while(current){if(current.textContent?.trim())return current;current=walker.nextNode();}return null;};const showCopiedFeedback=useCallback(()=>{if(typeof document===\"undefined\")return;const rootElement=rootRef.current;if(!rootElement)return;clearFeedbackTimeout();restoreLabel();const textNode=findFirstTextNode(rootElement);if(!textNode)return;restoreTextRef.current={node:textNode,value:textNode.textContent??\"\"};textNode.textContent=\"Copied ✓\";timeoutRef.current=window.setTimeout(()=>{restoreLabel();timeoutRef.current=null;},1600);},[clearFeedbackTimeout,restoreLabel]);const copyEmailToClipboard=async()=>{const email=\"ofaa.atelier@gmail.com\";if(typeof navigator!==\"undefined\"&&navigator.clipboard?.writeText){try{await navigator.clipboard.writeText(email);return true;}catch(_error){}}if(typeof document===\"undefined\")return false;try{const textArea=document.createElement(\"textarea\");textArea.value=email;textArea.setAttribute(\"readonly\",\"\");textArea.style.position=\"fixed\";textArea.style.opacity=\"0\";textArea.style.pointerEvents=\"none\";document.body.appendChild(textArea);textArea.focus();textArea.select();const didCopy=document.execCommand(\"copy\");document.body.removeChild(textArea);return didCopy;}catch(_error){return false;}};const handleDesktopCopy=async()=>{const copied=await copyEmailToClipboard();if(copied)showCopiedFeedback();};const handleClick=event=>{if(!isDesktopOrTablet()){if(typeof props.onClick===\"function\"){props.onClick(event);}return;}event.preventDefault();event.stopPropagation();void handleDesktopCopy();};const handleKeyDown=event=>{const isActivateKey=event.key===\"Enter\"||event.key===\" \";if(!isActivateKey){if(typeof props.onKeyDown===\"function\"){props.onKeyDown(event);}return;}if(!isDesktopOrTablet()){if(typeof props.onKeyDown===\"function\"){props.onKeyDown(event);}return;}event.preventDefault();event.stopPropagation();void handleDesktopCopy();};useEffect(()=>{return()=>{clearFeedbackTimeout();restoreLabel();};},[clearFeedbackTimeout,restoreLabel]);return /*#__PURE__*/_jsx(Component,{ref:assignRefs,...props,onClick:handleClick,onKeyDown:handleKeyDown});});}\nexport const __FramerMetadata__ = {\"exports\":{\"CopyEmailOnDesktop\":{\"type\":\"reactHoc\",\"name\":\"CopyEmailOnDesktop\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CopyEmailOnDesktop.map"],"mappings":"4JAKA,SAAgB,EAAmB,EAAU,CAAC,OAAoB,EAAW,SAAoC,EAAM,EAAI,CAAC,IAAM,EAAQA,EAAO,IAAI,EAAQ,EAAeA,EAAO,IAAI,EAAQ,EAAWA,EAAO,IAAI,EAAQ,EAAWC,EAAY,GAAM,CAAC,EAAQ,QAAQ,EAAQ,OAAO,GAAM,WAAY,EAAI,CAAI,EAAW,GAAK,OAAO,GAAM,WAAU,EAAI,QAAQ,EAAM,EAAE,CAAC,CAAG,CAAC,EAAQ,MAAiC,IAAS,QAAgC,EAAO,YAAY,IAAY,EAAqBA,MAAgB,CAAI,EAAW,UAAU,MAAa,IAAS,SAAmB,EAAO,aAAa,EAAW,OAAO,EAAE,EAAW,QAAQ,KAAK,EAAE,CAAC,CAAC,EAAQ,EAAaA,MAAgB,CAAK,AAAmG,EAAe,WAApF,EAAe,QAAQ,KAAK,YAAY,EAAe,QAAQ,MAA6B,KAAK,EAAE,CAAC,CAAC,EAAQ,EAAkB,GAAa,CAAC,IAAM,EAAO,SAAS,iBAAiB,EAAY,WAAW,SAAS,EAAM,EAAQ,EAAO,SAAS,EAAE,KAAM,GAAQ,CAAC,GAAG,EAAQ,aAAa,KAAK,EAAE,OAAO,EAAQ,EAAQ,EAAO,SAAS,CAAE,CAAC,OAAO,IAAK,EAAQ,EAAmBA,MAAgB,CAAC,GAAG,OAAO,SAAW,IAAY,OAAO,IAAM,EAAY,EAAQ,QAAQ,GAAG,CAAC,EAAY,OAAO,EAAqB,EAAE,EAAa,EAAE,IAAM,EAAS,EAAkB,CAAW,EAAM,IAAgB,EAAe,QAAQ,CAAC,KAAK,EAA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