{"version":3,"file":"SharePro.BAUlwTAo.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/WPKvQ2Ij7o5shwjwNT8T/LvpSWj6TkCHllRsVcsel/SharePro.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,cloneElement,isValidElement}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion}from\"framer-motion\";function useCurrentUrl(){const[currentUrl,setCurrentUrl]=useState(\"\");useEffect(()=>{if(typeof window!==\"undefined\"){setCurrentUrl(window.location.href);}},[]);return currentUrl;}function usePageTitle(){const[pageTitle,setPageTitle]=useState(\"\");useEffect(()=>{if(typeof document!==\"undefined\"){setPageTitle(document.title);}},[]);return pageTitle;}function useOgImage(){const[ogImage,setOgImage]=useState(\"\");useEffect(()=>{if(typeof document!==\"undefined\"){const ogImageMeta=document.querySelector('meta[property=\"og:image\"]');if(ogImageMeta){setOgImage(ogImageMeta.getAttribute(\"content\")||\"\");}}},[]);return ogImage;}/**\n * SHARE\n * @framerDisableUnlink\n */export default function SharePro(props){const{TriggleItem,TriggleMobile,UsePageTitle,ShareTitle,ShareCurrent,ShareUrl,UsePageImage,ShareImage,ShowNotifications,UnsupportedMessage,...elseprops}=props;const[isSupported,setIsSupported]=useState(false);const[isLoading,setIsLoading]=useState(false);const currentUrl=useCurrentUrl();const pageTitle=usePageTitle();const ogImage=useOgImage();// 处理 TriggleMobile 组件\nconst cItem=Array.isArray(TriggleMobile)&&TriggleMobile.length>0?TriggleMobile[0]:TriggleMobile;const rItem=/*#__PURE__*/isValidElement(cItem)?/*#__PURE__*/cloneElement(cItem,{style:{...cItem.props.style,width:\"100%\",height:\"100%\"}}):null;// 处理 TriggleItem 组件\nconst ditem=Array.isArray(TriggleItem)&&TriggleItem.length>0?TriggleItem[0]:TriggleItem;const titem=/*#__PURE__*/isValidElement(ditem)?/*#__PURE__*/cloneElement(ditem,{style:{...ditem.props.style,width:\"100%\",height:\"100%\"}}):null;// 检测是否为iOS系统\nconst isIOS=()=>{if(typeof navigator===\"undefined\")return false;return/iPad|iPhone|iPod/.test(navigator.userAgent)||navigator.platform===\"MacIntel\"&&navigator.maxTouchPoints>1;};// 检测是否为Safari浏览器\nconst isSafari=()=>{if(typeof navigator===\"undefined\")return false;const userAgent=navigator.userAgent.toLowerCase();return userAgent.includes(\"safari\")&&!userAgent.includes(\"chrome\")&&!userAgent.includes(\"chromium\")&&!userAgent.includes(\"edg\")&&!userAgent.includes(\"firefox\");};// 更全面的支持检测\nconst checkShareSupport=()=>{if(typeof navigator===\"undefined\")return false;const hasWebShareAPI=\"share\"in navigator&&typeof navigator.share===\"function\";const isPlatformSupported=isIOS()||isSafari();return hasWebShareAPI&&isPlatformSupported;};useEffect(()=>{setIsSupported(checkShareSupport());},[]);const handleShare=async()=>{if(!checkShareSupport()){if(ShowNotifications){// toast.error(UnsupportedMessage, {\n//     duration: 2500,\n// })\n}console.warn(\"分享功能在当前环境下不支持\");return;}setIsLoading(true);try{// 根据 UsePageTitle 决定使用页面标题还是自定义标题\nconst finalTitle=UsePageTitle?pageTitle:ShareTitle||\"Nick's website\";const shareUrl=ShareCurrent?currentUrl:ShareUrl||\"https://nickdu.art\";// 根据 UsePageImage 决定使用 og:image 还是自定义图片\nconst finalImage=UsePageImage?ogImage:ShareImage;// 基础分享数据\nconst shareData={title:finalTitle,url:shareUrl};// // 如果有图片URL，尝试添加图片文件\n// if (finalImage) {\n//     try {\n//         const response = await fetch(finalImage)\n//         const blob = await response.blob()\n//         const file = new File([blob], \"thumbnail.jpg\", {\n//             type: blob.type,\n//         })\n//         shareData.files = [file]\n//     } catch (err) {\n//         console.warn(\"无法加载分享图片\", err)\n//     }\n// }\n// 检查是否支持分享这些数据\nif(navigator.canShare&&!navigator.canShare(shareData)){delete shareData.files;}await navigator.share(shareData);console.log(\"分享成功\");}catch(err){if(err.name===\"AbortError\"){// 用户取消分享，不显示任何提示\n}else if(err.name===\"NotAllowedError\"){console.error(\"分享权限被拒绝\",err);}else if(err.name===\"DataError\"){console.error(\"分享数据无效\",err);}else{console.error(\"分享失败\",err);}}finally{setIsLoading(false);}};// 如果没有任何触发器组件，返回 null\nif(!titem&&!rItem){return null;}return /*#__PURE__*/_jsx(motion.div,{onTap:isSupported?handleShare:()=>{if(ShowNotifications){}},style:{width:\"100%\",height:\"100%\",cursor:isLoading?\"wait\":\"pointer\"},...elseprops,children:isSupported&&rItem?rItem:titem});}addPropertyControls(SharePro,{TriggleItem:{type:ControlType.ComponentInstance,title:\"Default Trigger\"},TriggleMobile:{type:ControlType.ComponentInstance,title:\"Mobile Trigger\"},ShowNotifications:{type:ControlType.Boolean,title:\"Show Notifications\",defaultValue:true},UnsupportedMessage:{type:ControlType.String,title:\"Unsupported Message\",defaultValue:\"Share feature is not supported on this browser or device. Please try Safari or iOS devices.\",hidden:({ShowNotifications})=>ShowNotifications===false,displayTextArea:true},UsePageTitle:{type:ControlType.Boolean,title:\"Use Page Title\",defaultValue:true},ShareTitle:{type:ControlType.String,title:\"Custom Title\",defaultValue:\"Nick's website\",hidden:({UsePageTitle})=>UsePageTitle===true},ShareCurrent:{type:ControlType.Boolean,title:\"Share Current URL\",defaultValue:true},ShareUrl:{type:ControlType.String,title:\"Share URL\",defaultValue:\"https://nickdu.art\",hidden:({ShareCurrent})=>ShareCurrent===true},UsePageImage:{type:ControlType.Boolean,title:\"Use Page OG Image\",defaultValue:true},ShareImage:{type:ControlType.Image,title:\"Custom Image\",hidden:({UsePageImage})=>UsePageImage===true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SharePro\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SharePro.map"],"mappings":"qQAAmM,SAAS,GAAe,CAAC,GAAK,CAAC,EAAW,GAAeA,EAAS,GAAG,CAA2F,OAA1F,MAAc,CAAW,IAAS,QAAa,EAAc,EAAO,S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