{"version":3,"file":"Copy_Button.BiAxFOsR.mjs","names":["useState","useRef","useCallback"],"sources":["https:/framerusercontent.com/modules/GlxHoGgTI0EgPO7aeyEA/aM5C2VwdPSVJTIKsHLb7/Copy_Button.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useRef,useEffect,useCallback,startTransition}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";export default function CopyButton(props){const{source,value,label,copiedLabel,resetAfterMs,showCopyIcon,showCheckIcon,transition,fadeDurationMs,padding,align,radius,font,textColor,bgColor,borderColor,borderWidth,hoverTextColor,hoverBgColor,hoverBorderColor,activeTextColor,activeBgColor,activeBorderColor,style}=props;const[state,setState]=useState(\"idle\");const resetTimeout=useRef(null);const reduceMotion=typeof window!==\"undefined\"&&window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches;const fading=transition===\"fade\"&&!reduceMotion;useEffect(()=>{return()=>{if(resetTimeout.current)window.clearTimeout(resetTimeout.current);};},[]);useEffect(()=>{if(state!==\"active\"||resetAfterMs<=0)return;if(resetTimeout.current)window.clearTimeout(resetTimeout.current);resetTimeout.current=window.setTimeout(()=>{startTransition(()=>setState(\"idle\"));},resetAfterMs);return()=>{if(resetTimeout.current)window.clearTimeout(resetTimeout.current);};},[state,resetAfterMs]);const resolveTextToCopy=()=>{if(source===\"pageUrl\"){return typeof window!==\"undefined\"?window.location.href:\"\";}return value??\"\";};const copyWithFallback=async text=>{if(!text)return false;try{if(typeof navigator!==\"undefined\"&&\"clipboard\"in navigator&&window.isSecureContext){await navigator.clipboard.writeText(text);return true;}}catch{}try{if(typeof document===\"undefined\")return false;const ta=document.createElement(\"textarea\");ta.value=text;ta.setAttribute(\"readonly\",\"\");ta.style.position=\"fixed\";ta.style.opacity=\"0\";ta.style.pointerEvents=\"none\";document.body.appendChild(ta);ta.select();const ok=document.execCommand(\"copy\");document.body.removeChild(ta);return ok;}catch{return false;}};const handleCopy=useCallback(async()=>{if(state===\"active\")return;const text=resolveTextToCopy();const ok=await copyWithFallback(text);if(ok)startTransition(()=>setState(\"active\"));},[state,source,value]);const handleMouseEnter=()=>{if(state===\"idle\")startTransition(()=>setState(\"hover\"));};const handleMouseLeave=()=>{if(state===\"hover\")startTransition(()=>setState(\"idle\"));};const handleFocus=()=>{if(state===\"idle\")startTransition(()=>setState(\"hover\"));};const handleBlur=()=>{if(state===\"hover\")startTransition(()=>setState(\"idle\"));};const justifyItems=align===\"left\"?\"start\":align===\"right\"?\"end\":\"center\";const isActive=state===\"active\";const isHover=state===\"hover\";const palette=isActive?{color:activeTextColor,bg:activeBgColor,border:activeBorderColor}:isHover?{color:hoverTextColor,bg:hoverBgColor,border:hoverBorderColor}:{color:textColor,bg:bgColor,border:borderColor};const fontSize=parseFloat(font?.fontSize??\"14\")||14;const lineHeight=(()=>{const lh=font?.lineHeight;if(typeof lh===\"number\")return lh;if(typeof lh===\"string\"){const n=parseFloat(lh);if(!isNaN(n))return n;}return 1.5;})();const minContentHeight=Math.max(32,fontSize*lineHeight);const btnStyle={...style,display:\"inline-grid\",gridAutoFlow:\"row\",placeItems:`center ${justifyItems}`,position:\"relative\",padding:`${padding}px`,borderRadius:radius,border:`${borderWidth}px solid ${palette.border}`,backgroundColor:palette.bg,color:palette.color,cursor:isActive?\"default\":\"pointer\",userSelect:\"none\",outline:\"none\",minHeight:minContentHeight,...font,transition:fading?`background-color ${fadeDurationMs}ms, color ${fadeDurationMs}ms, border-color ${fadeDurationMs}ms`:undefined};const layerCommon={gridArea:\"1 / 1 / 2 / 2\",display:\"inline-flex\",alignItems:\"center\",pointerEvents:\"none\"};const idleLayer=fading?{...layerCommon,opacity:isActive?0:1,transition:`opacity ${fadeDurationMs}ms`}:{...layerCommon,display:isActive?\"none\":\"inline-flex\"};const activeLayer=fading?{...layerCommon,opacity:isActive?1:0,transition:`opacity ${fadeDurationMs}ms`}:{...layerCommon,display:isActive?\"inline-flex\":\"none\"};if(RenderTarget.current()===RenderTarget.thumbnail)return null;return /*#__PURE__*/_jsxs(\"button\",{type:\"button\",\"aria-label\":isActive?props.copiedLabel:props.label,style:btnStyle,onMouseEnter:handleMouseEnter,onMouseLeave:handleMouseLeave,onFocus:handleFocus,onBlur:handleBlur,onClick:handleCopy,disabled:isActive,children:[/*#__PURE__*/_jsxs(\"span\",{style:idleLayer,\"aria-hidden\":true,children:[props.showCopyIcon&&/*#__PURE__*/_jsx(\"span\",{style:{marginRight:4,display:\"inline-flex\"},children:/*#__PURE__*/_jsxs(\"svg\",{width:\"1em\",height:\"1em\",viewBox:\"0 0 20 20\",fill:\"none\",\"aria-hidden\":\"true\",style:{display:\"block\"},children:[/*#__PURE__*/_jsx(\"rect\",{x:\"7\",y:\"7\",width:\"9\",height:\"9\",rx:\"2\",stroke:\"currentColor\",strokeWidth:\"1.5\"}),/*#__PURE__*/_jsx(\"rect\",{x:\"4\",y:\"4\",width:\"9\",height:\"9\",rx:\"2\",stroke:\"currentColor\",strokeWidth:\"1.5\",opacity:\"0.5\"})]})}),/*#__PURE__*/_jsx(\"span\",{children:props.label})]}),/*#__PURE__*/_jsxs(\"span\",{style:activeLayer,\"aria-hidden\":true,children:[props.showCheckIcon&&/*#__PURE__*/_jsx(\"span\",{style:{marginRight:8,display:\"inline-flex\"},children:/*#__PURE__*/_jsx(\"svg\",{width:\"1em\",height:\"1em\",viewBox:\"0 0 20 20\",fill:\"none\",\"aria-hidden\":\"true\",style:{display:\"block\"},children:/*#__PURE__*/_jsx(\"path\",{d:\"M5 10.5L9 14.5L15 7.5\",stroke:\"currentColor\",strokeWidth:\"1.5\",strokeLinecap:\"round\",strokeLinejoin:\"round\"})})}),/*#__PURE__*/_jsx(\"span\",{children:props.copiedLabel})]}),/*#__PURE__*/_jsx(\"span\",{\"aria-live\":\"polite\",style:{position:\"absolute\",width:1,height:1,margin:-1,padding:0,overflow:\"hidden\",clip:\"rect(0 0 0 0)\",whiteSpace:\"nowrap\",border:0},children:isActive?props.copiedLabel:props.label})]});}addPropertyControls(CopyButton,{source:{type:ControlType.Enum,title:\"Source\",options:[\"custom\",\"pageUrl\"],optionTitles:[\"Custom\",\"Page URL\"],defaultValue:\"custom\"},value:{type:ControlType.String,title:\"Value\",defaultValue:\"\",placeholder:\"Text to copy…\",hidden:({source})=>source!==\"custom\",description:\"The text to be copied.\"},label:{type:ControlType.String,title:\"Label\",defaultValue:\"Copy\"},copiedLabel:{type:ControlType.String,title:\"Copied Label\",defaultValue:\"Copied!\"},resetAfterMs:{type:ControlType.Number,title:\"Delay (ms)\",defaultValue:1600,min:0,max:1e4,step:100,displayStepper:true,description:\"The delay after which the button returns to idle state.\"},showCopyIcon:{type:ControlType.Boolean,title:\"Copy Icon\",defaultValue:true},showCheckIcon:{type:ControlType.Boolean,title:\"Check Icon\",defaultValue:true},transition:{type:ControlType.Enum,title:\"Transition\",options:[\"none\",\"fade\"],optionTitles:[\"None\",\"Fade\"],defaultValue:\"fade\",description:\"Set a transition between the button states.\"},fadeDurationMs:{type:ControlType.Number,title:\"Fade Duration (ms)\",defaultValue:180,min:60,max:1e3,step:10,displayStepper:true,hidden:({transition})=>transition!==\"fade\"},padding:{type:ControlType.Number,title:\"Padding\",defaultValue:12,min:0,max:128,step:1,displayStepper:true},align:{type:ControlType.Enum,title:\"Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"center\",displaySegmentedControl:true},radius:{type:ControlType.Number,title:\"Radius\",defaultValue:10,min:0,max:128,step:1,displayStepper:true},// Typography via Font control (inherits by default)\nfont:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"14px\",variant:\"Medium\",lineHeight:\"1.5em\",letterSpacing:\"0em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},borderWidth:{type:ControlType.Number,title:\"Border Width\",defaultValue:1,min:0,max:8,step:1,displayStepper:true},// Colors & borders\ntextColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#111827\"},bgColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#F3F4F6\"},borderColor:{type:ControlType.Color,title:\"Border\",defaultValue:\"#E5E7EB\",description:\"Customize idle state.\"},hoverTextColor:{type:ControlType.Color,title:\"Hover Text\",defaultValue:\"#1F2937\"},hoverBgColor:{type:ControlType.Color,title:\"Hover BG\",defaultValue:\"#E5E7EB\"},hoverBorderColor:{type:ControlType.Color,title:\"Hover Border\",defaultValue:\"#D1D5DB\",description:\"Customize hover state.\"},activeTextColor:{type:ControlType.Color,title:\"Active Text\",defaultValue:\"#FFFFFF\"},activeBgColor:{type:ControlType.Color,title:\"Active BG\",defaultValue:\"#10B981\"},activeBorderColor:{type:ControlType.Color,title:\"Active Border\",defaultValue:\"#10B981\",description:\"Customize copied state.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CopyButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Copy_Button.map"],"mappings":"2OAAmM,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,SAAO,QAAM,QAAM,eAAY,eAAa,eAAa,gBAAc,aAAW,iBAAe,UAAQ,QAAM,SAAO,OAAK,YAAU,UAAQ,cAAY,cAAY,iBAAe,eAAa,mBAAiB,kBAAgB,gBAAc,oBAAkB,SAAO,EAAW,CAAC,EAAM,GAAUA,EAAS,OAAO,CAAO,EAAaC,EAAO,KAAK,CAAO,EAAoB,IAAS,QAAa,EAAO,aAAa,mCAAmC,CAAC,QAAc,EAAO,IAAa,QAAQ,CAAC,EAAa,UAAyB,CAAI,EAAa,SAAQ,EAAO,aAAa,EAAa,QAAQ,EAAK,EAAE,CAAC,CAAC,MAAc,CAAI,SAAQ,UAAU,GAAc,GAA6K,OAAjK,EAAa,SAAQ,EAAO,aAAa,EAAa,QAAQ,CAAC,EAAa,QAAQ,EAAO,eAAe,CAAC,MAAoB,EAAS,OAAO,CAAC,EAAG,EAAa,KAAW,CAAI,EA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