{"version":3,"file":"CopyCodeBlock.BhNdfqzi.mjs","names":["updated"],"sources":["https:/framerusercontent.com/modules/kpIzmRHU6h5b3UCraPfK/m9JbDepQtZqJ7DqdZTgu/CopyCodeBlock.js"],"sourcesContent":["/* \n*Copy button for Framer code blocks. Automatically detects code blocks (standalone or from CMS), shows a copy icon, animates to a check icon on click, then returns. The text content inside the code-block is stored in the clipboard.\n\n* The component is designed to appear only on the live website.\n\n* We are using the \".sp-pristine\" CSS Class to select the code blocks and store them in a variable. Framer could change or modify the classname in the future. \nIf the code override stops working, feel free to reach out at dotstudio.agency@gmail.com and I'll happily assist you.\n\n* Code by Alexander Belt.\n*/import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{RenderTarget}from\"framer\";export default function CopyButtons(props){const{padding,copyIconColor,copiedIconColor,copyIconSvg,copiedIconSvg,background,hoverColor,border:{borderWidth,borderStyle,borderColor},radius}=props;useEffect(()=>{// Prevent code component from running and showing on the canvas to improve UX and allow users to focus on their designs.\nif(RenderTarget.current()===RenderTarget.canvas)return;const selector=\".sp-pristine\";const buttons=new Map;const createStyles=()=>{const existingStyle=document.getElementById(\"copy-button-styles\");if(existingStyle)existingStyle.remove();const style=document.createElement(\"style\");style.id=\"copy-button-styles\";style.textContent=`\n                .copy-icon * {\n                    stroke: ${copyIconColor};\n                }\n                .copied-icon * {\n                    stroke: ${copiedIconColor};\n                }\n            `;document.head.appendChild(style);};const applyCssClass=(svgContent,className)=>{if(!svgContent.trim())return\"\";if(svgContent.includes(\"<svg\")){return svgContent.replace(\"<svg\",`<svg class=\"${className}\"`);}return`<svg class=\"${className}\" xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${svgContent}</svg>`;};createStyles();const copyIcon=applyCssClass(copyIconSvg,\"copy-icon\");const checkIcon=applyCssClass(copiedIconSvg,\"copied-icon\");function positionButtonFor(block){const entry=buttons.get(block);if(!entry)return;const pre=block.closest(\"pre\")||block.parentElement;if(!pre)return;const rect=pre.getBoundingClientRect();const scrollY=window.scrollY||window.pageYOffset;const scrollX=window.scrollX||window.pageXOffset;const buttonSize=24// px\n;const top=rect.top+scrollY+8;const left=rect.left+scrollX+rect.width-buttonSize-8;entry.button.style.top=`${top}px`;entry.button.style.left=`${left}px`;}function createButtonFor(block){if(buttons.has(block))return;const pre=block.closest(\"pre\")||block.parentElement;if(!pre)return;const button=document.createElement(\"button\");button.className=\"copy-btn\";button.setAttribute(\"aria-label\",\"Copy code\");button.style.cssText=`\n        position: absolute;\n        width: 24px;\n        height: 24px;\n        padding: ${padding};\n        background: ${background};\n        border: ${borderWidth}px ${borderStyle} ${borderColor};\n        border-radius: ${radius};\n        cursor: pointer;\n        display: flex;\n        align-items: center;\n        justify-content: center;\n        z-index: 10;\n        transition: background;\n        transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n        transition-duration: .15s\n      `;// hover in\nbutton.addEventListener(\"mouseover\",()=>{button.style.background=hoverColor;});// hover out (reset)\nbutton.addEventListener(\"mouseleave\",()=>{button.style.background=background;});button.innerHTML=copyIcon;const clickHandler=ev=>{ev.stopPropagation();const text=(block.textContent||\"\").trim();navigator.clipboard.writeText(text).then(()=>{button.innerHTML=checkIcon;const current=buttons.get(block);if(current?.timeoutId){clearTimeout(current.timeoutId);}const id=window.setTimeout(()=>{button.innerHTML=copyIcon;const updated=buttons.get(block);if(updated)updated.timeoutId=undefined;},2e3);const updated=buttons.get(block);if(updated)updated.timeoutId=id;}).catch(err=>{console.error(\"Clipboard write failed:\",err);button.innerHTML=copyIcon;});};button.addEventListener(\"click\",clickHandler);document.body.appendChild(button);buttons.set(block,{button,timeoutId:undefined});positionButtonFor(block);}function scanAndCreate(){const nodes=Array.from(document.querySelectorAll(selector));nodes.forEach(block=>{if(!(block.offsetWidth||block.offsetHeight))return;createButtonFor(block);});Array.from(buttons.keys()).forEach(positionButtonFor);}const repositionAll=()=>Array.from(buttons.keys()).forEach(positionButtonFor);window.addEventListener(\"resize\",repositionAll);window.addEventListener(\"scroll\",repositionAll);const observer=new MutationObserver(()=>{scanAndCreate();});observer.observe(document.body,{childList:true,subtree:true});const initTimeout=window.setTimeout(scanAndCreate,50);// Cleanup\nreturn()=>{observer.disconnect();window.clearTimeout(initTimeout);window.removeEventListener(\"resize\",repositionAll);window.removeEventListener(\"scroll\",repositionAll);buttons.forEach(({button,timeoutId})=>{if(timeoutId)clearTimeout(timeoutId);button.remove();});buttons.clear();const styles=document.getElementById(\"copy-button-styles\");if(styles)styles.remove();};},[padding,copyIconColor,copiedIconColor,copyIconSvg,copiedIconSvg,background,hoverColor,borderWidth,borderStyle,borderColor,radius]);return /*#__PURE__*/_jsx(\"div\",{style:{width:1,height:1,opacity:0,pointerEvents:\"none\"}});}addPropertyControls(CopyButtons,{background:{type:ControlType.Color,title:\"Background\",defaultValue:\"rgba(0, 0, 0, 0)\"},hoverColor:{type:ControlType.Color,title:\"Hover\",defaultValue:\"rgba(49, 49, 49, 1.0)\",description:\"Button fill on Hover\"},border:{type:ControlType.Border,title:\"Border\",defaultValue:{borderWidth:1,borderStyle:\"solid\",borderColor:\"rgba(49, 49, 49, 1.0)\"}},copyIconSvg:{type:ControlType.String,title:\"Copy Icon (SVG)\",defaultValue:'<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-copy-icon lucide-copy\"><rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"/></svg>',displayTextArea:false,description:\"Paste an SVG\"},copyIconColor:{type:ControlType.Color,title:\"Copy Icon Color\",defaultValue:\"rgba(140, 140, 140, 1)\"},copiedIconSvg:{type:ControlType.String,title:\"Success Icon (SVG)\",defaultValue:'<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"lucide lucide-check-icon lucide-check\"><path d=\"M20 6 9 17l-5-5\"/></svg>',displayTextArea:false,description:\"Paste an SVG\"},copiedIconColor:{type:ControlType.Color,title:\"Success Icon Color\",defaultValue:\"rgba(140, 140, 140, 1)\"},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"4px\"},radius:{type:ControlType.BorderRadius,title:\"Radius\",defaultValue:\"7px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CopyButtons\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CopyCodeBlock.map"],"mappings":"uMAS+J,SAAwB,EAAY,EAAM,CAAC,GAAK,CAAC,UAAQ,gBAAc,kBAAgB,cAAY,gBAAc,aAAW,aAAW,OAAO,CAAC,cAAY,cAAY,eAAa,UAAQ,EA4ByJ,OA5BnJ,MAAc,CAC/W,GAAG,EAAa,SAAS,GAAG,EAAa,OAAO,OAAO,IAAoC,EAAQ,IAAI,IAAU,MAAiB,CAAC,IAAM,EAAc,SAAS,eAAe,qBAAqB,CAAI,GAAc,EAAc,QAAQ,CAAC,IAAM,EAAM,SAAS,cAAc,QAAQ,CAAC,EAAM,GAAG,qBAAqB,EAAM,YAAY;;8BAE3S,EAAc;;;8BAGd,EAAgB;;cAEhC,SAAS,KAAK,YAAY,EAAM,EAAS,GAAe,EAAW,IAAiB,EAAW,MAAM,CAAa,EAAW,SAAS,OAAO,CAAS,EAAW,QAAQ,OAAO,eAAe,EAAU,GAAG,CAAQ,eAAe,EAAU,8JAA8J,EAAW,QAA1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