{"version":3,"file":"ShareButton.C2a7f2Jf.mjs","names":["useState","useRef","useCallback","shareError","useMemo","_Fragment","startTransition"],"sources":["https:/framerusercontent.com/modules/YzfUdyRbCGmi8UPjp1D6/IYe02cYC6pPt5HdzZROF/ShareButton.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useCallback,useEffect,useMemo,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function ShareButton(props){const{buttonText,fontSize,fontWeight,iconSize,gap,paddingX,paddingY,borderRadius,backgroundColor,textColor}=props;const[isPressed,setIsPressed]=useState(false);const[isHovered,setIsHovered]=useState(false);const[isCopied,setIsCopied]=useState(false);const resetTimerRef=useRef(null);useEffect(()=>{return()=>{if(typeof window!==\"undefined\"&&resetTimerRef.current!==null){window.clearTimeout(resetTimerRef.current);}};},[]);const startCopiedFeedback=useCallback(()=>{if(typeof window!==\"undefined\"&&resetTimerRef.current!==null){window.clearTimeout(resetTimerRef.current);}startTransition(()=>setIsCopied(true));if(typeof window!==\"undefined\"){resetTimerRef.current=window.setTimeout(()=>{startTransition(()=>setIsCopied(false));resetTimerRef.current=null;},1800);}},[]);const fallbackCopyWithTextarea=useCallback(text=>{if(typeof document===\"undefined\")return false;if(typeof document.execCommand!==\"function\")return false;try{const textarea=document.createElement(\"textarea\");textarea.value=text;textarea.setAttribute(\"readonly\",\"\");textarea.setAttribute(\"aria-hidden\",\"true\");textarea.style.position=\"fixed\";textarea.style.top=\"-9999px\";textarea.style.left=\"-9999px\";textarea.style.opacity=\"0\";document.body.appendChild(textarea);textarea.focus();textarea.select();const copied=document.execCommand(\"copy\");document.body.removeChild(textarea);return copied;}catch{return false;}},[]);const handleClick=useCallback(async()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\"||typeof navigator===\"undefined\"){return;}const title=document.title||\"\";const url=window.location.href||\"\";try{if(typeof navigator.share===\"function\"){await navigator.share({title,url});return;}}catch(error){const shareError=error;if(shareError?.name===\"AbortError\"){return;}}try{if(navigator.clipboard&&typeof navigator.clipboard.writeText===\"function\"){await navigator.clipboard.writeText(url);startCopiedFeedback();return;}}catch{// Continue to execCommand fallback\n}const copied=fallbackCopyWithTextarea(url);if(copied){startCopiedFeedback();}},[fallbackCopyWithTextarea,startCopiedFeedback]);const label=isCopied?\"Kopiert!\":buttonText;const buttonStyle=useMemo(()=>({position:\"relative\",display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",width:\"fit-content\",minWidth:\"max-content\",minHeight:40,padding:`${paddingY}px ${paddingX}px`,gap:`${gap}px`,border:\"none\",borderRadius:`${borderRadius}px`,background:backgroundColor,color:textColor,cursor:\"pointer\",userSelect:\"none\",WebkitTapHighlightColor:\"transparent\",fontFamily:\"Satoshi, Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif\",fontSize:`${fontSize}px`,fontWeight,lineHeight:1,transform:isPressed?\"scale(0.98)\":\"scale(1)\",transition:\"transform 120ms ease, filter 120ms ease, opacity 120ms ease\",opacity:isHovered?.94:1,filter:isHovered?\"brightness(0.98)\":\"none\",appearance:\"none\",WebkitAppearance:\"none\"}),[paddingY,paddingX,gap,borderRadius,backgroundColor,textColor,fontSize,fontWeight,isPressed,isHovered]);return /*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:`\n                .share-button:focus-visible {\n                    outline: 2px solid rgba(255, 255, 255, 0.9);\n                    outline-offset: 2px;\n                }\n                @media (hover: none) {\n                    .share-button {\n                        opacity: 1 !important;\n                        filter: none !important;\n                    }\n                }\n            `}),/*#__PURE__*/_jsxs(\"button\",{type:\"button\",className:\"share-button\",\"aria-label\":\"Del denne artikkelen\",style:buttonStyle,onClick:handleClick,onMouseEnter:()=>{if(typeof window!==\"undefined\"&&window.matchMedia&&window.matchMedia(\"(hover: hover)\").matches){startTransition(()=>setIsHovered(true));}},onMouseLeave:()=>{startTransition(()=>setIsHovered(false));startTransition(()=>setIsPressed(false));},onMouseDown:()=>startTransition(()=>setIsPressed(true)),onMouseUp:()=>startTransition(()=>setIsPressed(false)),onTouchStart:()=>startTransition(()=>setIsPressed(true)),onTouchEnd:()=>startTransition(()=>setIsPressed(false)),onTouchCancel:()=>startTransition(()=>setIsPressed(false)),children:[/*#__PURE__*/_jsxs(\"svg\",{width:iconSize*1.3*.858,height:iconSize*1.3,viewBox:\"0 0 461.2 537.3\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",\"aria-hidden\":\"true\",style:{display:\"block\",color:\"currentColor\",flexShrink:0},children:[/*#__PURE__*/_jsx(\"path\",{d:\"M230.6,231c-45.9,1.4-87.9,23.4-115.1,57.4-30.2,37.7-40.5,86.1-29.2,132.1,15.9,64.9,70.6,109.8,136.8,116.8C96.4,534-2.1,427.5,0,303.3,2.2,178.1,104.9,76.4,230.8,76.9V0c-.1,0,230.4,153.6,230.4,153.6l-230.4,153.5-.2-76.2Z\",fill:\"#FFFFFF\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M230.6,231l.2,76.2,230.4-153.5L230.7,0v76.9C104.9,76.4,2.2,178.1,0,303.3c-2.2,124.2,96.4,230.6,223,234-66.2-7-120.9-51.9-136.8-116.8-11.3-46-.9-94.4,29.2-132.1,27.2-34,69.2-56,115.1-57.4Z\",fill:\"#FFFFFF\"})]}),/*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-block\",minWidth:\"max-content\"},children:label})]})]});}addPropertyControls(ShareButton,{buttonText:{type:ControlType.String,title:\"Text\",defaultValue:\"Del\"},fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:14,min:11,max:24,step:1,unit:\"px\"},fontWeight:{type:ControlType.Enum,title:\"Weight\",defaultValue:600,options:[400,500,600,700],optionTitles:[\"400\",\"500\",\"600\",\"700\"]},iconSize:{type:ControlType.Number,title:\"Icon\",defaultValue:18,min:12,max:24,step:1,unit:\"px\"},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:7,min:4,max:16,step:1,unit:\"px\"},paddingX:{type:ControlType.Number,title:\"Pad X\",defaultValue:12,min:6,max:24,step:1,unit:\"px\"},paddingY:{type:ControlType.Number,title:\"Pad Y\",defaultValue:9,min:6,max:20,step:1,unit:\"px\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:10,min:0,max:20,step:1},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"var(--token-5e232d3a-da8f-41c5-80f0-8d98fe037fa3, rgb(124, 54, 181))\"},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#FFFFFF\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ShareButton\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ShareButton.map"],"mappings":"4OAGG,SAAwB,EAAY,EAAM,CAAC,GAAK,CAAC,aAAW,WAAS,aAAW,WAAS,MAAI,WAAS,WAAS,eAAa,kBAAgB,aAAW,EAAW,CAAC,EAAU,GAAcA,EAAS,EAAK,EAAO,CAAC,EAAU,GAAcA,EAAS,EAAK,EAAO,CAAC,EAAS,GAAaA,EAAS,EAAK,EAAQ,EAAcC,EAAO,IAAI,EAAE,UAAyB,CAAW,IAAS,QAAa,EAAc,UAAU,MAAM,EAAO,aAAa,EAAc,OAAO,CAAG,EAAI,CAAC,CAAC,EAAE,IAAM,EAAoBC,MAAgB,CAAW,IAAS,QAAa,EAAc,UAAU,MAAM,EAAO,aAAa,EAAc,OAAO,EAAG,MAAoB,EAAY,EAAI,CAAC,EAAY,IAAS,SAAa,EAAc,QAAQ,EAAO,eAAe,CAAC,MAAoB,EAAY,EAAK,CAAC,EAAE,EAAc,QAAQ,IAAK,EAAE,IAAI,EAAG,EAAE,CAAC,CAAC,EAAQ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