{"version":3,"file":"IconsPro.C2Edld7B.mjs","names":["useState","useCallback"],"sources":["https:/framerusercontent.com/modules/n4tHvlEbpQYM7qFYjcs3/w3rdzWzOuFIQgVBeYOCQ/IconsPro.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect,useCallback}from\"react\";import{motion,AnimatePresence}from\"framer-motion\";//import * as xIcons from \"https://esm.sh/@phosphor-icons/react?external=react,react-dom\"\n// import * as xIcons from \"@phosphor-icons/react\"\nimport{colorpattle}from\"https://framerusercontent.com/modules/niZ6YpK06zTaQeX49VIS/kyUI2MH03eq9506I17so/Theme.js\";// import * as xIcons from \"https://esm.sh/phosphor-react@1.4.1\"\nimport{addPropertyControls,ControlType}from\"framer\";const iconCache=new Map;let iconsModule=null;//https://esm.sh/@phosphor-icons/react@2.1.10?external=react,react-dom\n// 预加载整个图标库（只加载一次）\nconst loadIconsModule=async()=>{if(!iconsModule){iconsModule=await import(\"https://esm.sh/@phosphor-icons/react@2.1.10?external=react,react-dom\");}return iconsModule;};/**\n * @framerDisableUnlink\n */// /**\n//  * @framerSupportedLayoutWidth fit\n//  * @framerSupportedLayoutHeight fit\n//  * @framerIntrinsicWidth 400\n//  * @framerIntrinsicHeight 200\n//  */\nexport default function Icons(props){const{iconsName=\"Heart\",// iconList = [],\niconcolor,sysColor,iconsize,iconindex,iconweight,onClick,clickChange,animation,...otherProps}=props;const[iconsArray,setArray]=useState([]);const[Icon,setIcon]=useState(null);const[render,setrender]=useState(false);const[iIndex,setIconIndex]=useState(iconindex);const[ani,setani]=useState(false);const tColor=sysColor!==\"none\"?\"var(\"+sysColor+\")\":iconcolor;// 新旧图标的动画状态\nconst V1={enter:{opacity:0,y:30,scale:.8},center:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-30,scale:.8}};const V2={enter:{opacity:0,rotateX:-90},center:{opacity:1,rotateX:0},exit:{opacity:0,rotateX:90}};// Styles are written in object syntax\n// Learn more: https://reactjs.org/docs/dom-elements.html#style\nconst containerStyle={position:\"relative\",width:`${iconsize}px`,height:`${iconsize}px`,//    height: \"100%\",\ndisplay:\"flex\",justifyContent:\"center\",alignItems:\"center\",overflow:\"visible\"};// ✅ 加载图标（带缓存）\nconst loadIcon=useCallback(async iconName=>{if(!iconName)return;// 检查缓存\nif(iconCache.has(iconName)){setIcon(()=>iconCache.get(iconName));setrender(true);return;}try{const icons=await loadIconsModule();if(icons[iconName]){iconCache.set(iconName,icons[iconName]);setIcon(()=>icons[iconName]);setrender(true);}else{console.warn(`Icon \"${iconName}\" not found`);// 回退到 Heart\nif(!iconCache.has(\"Heart\")){iconCache.set(\"Heart\",icons.Heart);}setIcon(()=>icons.Heart);setrender(true);}}catch(error){console.error(\"Failed to load icon:\",error);}},[]);const handleChildClick=useCallback(()=>{onClick();if(clickChange){if(iconsArray.length>0){setIconIndex(prevIndex=>(prevIndex+1)%iconsArray.length);}setani(true);}},[onClick,iconsArray.length]);useEffect(()=>{// const iconsArray = iconsName.split(\",\")\nif(iconsName!==\"\"){const trimmedIconsArray=iconsName.split(\",\").map(icon=>icon.trim());setArray(trimmedIconsArray);}},[iconsName]);useEffect(()=>{if(iconsArray.length>0){const index=iconsArray.length>iIndex?iIndex:0;loadIcon(iconsArray[index]);}},[iconsArray,iIndex,loadIcon]);// useEffect(() => {\n//     if (iconsArray.length > 0) {\n//         const index = iconsArray.length > iIndex ? iIndex : 0\n//         setIcon(xIcons[iconsArray[index]])\n//         setrender(true)\n//     }\n// }, [iconsArray, iIndex])\nuseEffect(()=>{if(iconindex!==iIndex){setani(true);}setIconIndex(iconindex);},[iconindex]);if(render){if(!Icon){return null//<div>Icon not found</div>\n;}if(ani){return /*#__PURE__*/_jsx(\"div\",{style:containerStyle,onClick:handleChildClick,children:/*#__PURE__*/_jsx(AnimatePresence,{exitBeforeEnter:true,children:/*#__PURE__*/_jsx(motion.div,{initial:\"enter\",animate:\"center\",exit:\"exit\",variants:animation===\"slide\"?V1:V2,transition:{duration:.3},style:{position:\"absolute\",display:\"flex\",justifyContent:\"center\",alignItems:\"center\"},children:/*#__PURE__*/_jsx(Icon,{size:iconsize,color:tColor,weight:iconweight})},iIndex)})});}else{return /*#__PURE__*/_jsx(\"div\",{style:containerStyle,onClick:handleChildClick,children:/*#__PURE__*/_jsx(Icon,{size:iconsize,color:tColor,weight:iconweight})});}}}Icons.displayName=\"Icons Pro\";Icons.defaultProps={onClick:()=>{}};addPropertyControls(Icons,{iconsName:{type:ControlType.String,title:\"iconName\",defaultValue:\"At\"},// iconList: {\n//     type: ControlType.Array,\n//     control: {\n//         type: ControlType.String,\n//     },\n//     title: \"Icon List\",\n// },\niconindex:{type:ControlType.Number,defaultValue:0,title:\"Index\"},// iconStringList: {\n//     type: ControlType.String,\n//     title: \"icon String List\",\n// },\nsysColor:{type:ControlType.Enum,defaultValue:\"none\",options:[\"none\",...Object.keys(colorpattle)]},iconcolor:{type:ControlType.Color,defaultValue:\"#000\",title:\"Color\",hidden(props){return props.sysColor!==\"none\";}},clickChange:{type:ControlType.Boolean,defaultValue:false,title:\"Click change icons\"},iconsize:{type:ControlType.Number,defaultValue:16,title:\"Size\"},iconweight:{type:ControlType.Enum,defaultValue:\"regular\",// displaySegmentedControl: true,\n// segmentedControlDirection: \"vertical\",\noptions:[\"thin\",\"light\",\"regular\",\"bold\",\"fill\",\"duotone\"],optionTitles:[\"Thin\",\"Light\",\"Regular\",\"Bold\",\"Fill\",\"Duotone\"]},animation:{type:ControlType.Enum,defaultValue:\"slide\",options:[\"slide\",\"rotate\"]},onClick:{type:ControlType.EventHandler}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Icons\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"\",\"framerSupportedLayoutHeight\":\"\",\"framerIntrinsicHeight\":\"\",\"framerIntrinsicWidth\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMapping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