{"version":3,"file":"LeaderPro.CpIssyy7.mjs","names":["_Fragment"],"sources":["https:/framerusercontent.com/modules/lfM9wQ53RTva0nHSOMAz/MNZUqveG4dI49KVKoFNd/LeaderPro.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{addPropertyControls,ControlType,// @ts-ignore\ngetPropertyControls}from\"framer\";import{rootstyles,changetheme}from\"https://framerusercontent.com/modules/niZ6YpK06zTaQeX49VIS/kyUI2MH03eq9506I17so/Theme.js\";import ButtonX from\"https://framerusercontent.com/modules/4qsgEiJMwmhCjkYCC8G4/fEES53bW4JVYu0FJxZcH/ButtonX.js\";const btnProps=getPropertyControls(ButtonX);import{createStore}from\"https://framer.com/m/framer/store.js\";let sharedParams=\"\";export function loadParams(){const isClient=typeof window!==\"undefined\";if(isClient){const params=new URLSearchParams(window.location.search);sharedParams=params;return String(params);}else{return\"\";}}// export function getParam(key: string) {\n//     return sharedParams\n// }\nexport const useStoretheme=createStore({// Set the starting theme below, otherwise default to system.\ntheme:\"system\"});const changeThemeMode=theme=>{const htmlElement=document.getElementsByTagName(\"html\")[0];const bodyElement=document.getElementsByTagName(\"body\")[0];htmlElement.setAttribute(\"toggle-theme\",`${theme}`);bodyElement.setAttribute(\"toggle-theme\",`${theme}`);localStorage.setItem(\"theme\",`${theme}`);// Trigger event that is compatible with Framestack Theme Image Component\nconst event=new Event(\"themeChange\");window.dispatchEvent(event);return;};const FetchJSON=url=>{if(url===\"\"||url===undefined){return null;}const[jsonData,setJsonData]=useState(null)// 存储 JSON 数据\n;useEffect(()=>{// 定义异步函数来获取数据\nconst fetchData=async()=>{try{const response=await fetch(url)// 使用 fetch 请求数据\n;if(!response.ok){throw new Error(`HTTP error! status: ${response.status}`);}const data=await response.json()// 解析 JSON 内容\n;setJsonData(data)// 存储到 state\n;}catch(error){console.error(\"Error fetching the JSON:\",error);}};fetchData()// 调用函数\n;},[url])// 依赖项为 url\n;return jsonData;};/**\n * @framerDisableUnlink\n */export default function LeaderPro(props){const[primaryColor,setPrimaryColor]=useState(props.primaryColor);const[actColor,setActColor]=useState(props.actColor);const[scale,setscale]=useState(props.radiusScale);const[bgColor,setBGColor]=useState(props.bgColor);const[fontF,setFontF]=useState(props.fontF);const[SwitchOnce,setswitch]=useState(false);useEffect(()=>{if(bgColor.key===\"NickDuDesigned\"){const badge=document.getElementById(\"__framer-badge-container\");if(badge){badge.style.zIndex=\"-999\";}}const observer=new MutationObserver(()=>{const framerEditorBar=document.getElementById(\"__framer-editorbar\");if(framerEditorBar){framerEditorBar.remove();console.log(\"Framer editor bar removed.\");observer.disconnect()// 删除后停止监听\n;}});observer.observe(document.body,{childList:true,subtree:true});},[])// 空数组确保该副作用只在组件挂载时运行一次\n;const themefile=FetchJSON(props.theme);if(themefile!==null){//console.log(\"here\")\nchangetheme(themefile);}const[store,setStore]=useStoretheme();useEffect(()=>{// If starting theme is other than light/dark then match device theme.\nif(store.theme!==\"dark\"&&store.theme!==\"light\"){// Detect system theme\nconst mediaQuery=window.matchMedia(\"(prefers-color-scheme: dark)\");let newTheme=mediaQuery.matches?\"dark\":\"light\";// Set store theme\nconst DLM=props.darktheme;if(DLM!==\"auto\"&&DLM!==newTheme){setswitch(true);}setStore({theme:newTheme});localStorage.setItem(\"theme\",`${newTheme}`);}else{// Set the starting theme based on store\nlocalStorage.setItem(\"theme\",`${store.theme}`);}// Create attributes on html and body so that theme will be applied based on store\nconst htmlElement=document.getElementsByTagName(\"html\")[0];const bodyElement=document.getElementsByTagName(\"body\")[0];htmlElement&&htmlElement.setAttribute(\"toggle-theme\",`${store.theme}`);bodyElement&&bodyElement.setAttribute(\"toggle-theme\",`${store.theme}`);// Create sets of light and dark mode tokens\nlet lightThemeTokens=[];let darkThemeTokens=[];for(let i=0;i<document.styleSheets.length;i++){const sheet=document.styleSheets[i];try{for(let rule of sheet.cssRules){// Get light and dark mode tokens\nif(rule.selectorText===\"body\"){const style=rule.style;for(let j=0;j<style.length;j++){const propertyName=style[j];if(propertyName.includes(\"--token\")){const value=style.getPropertyValue(propertyName);// Check for specific tokens or list all\nconst combinedCssRule=`${propertyName}: ${value};`;lightThemeTokens.push(combinedCssRule);}}lightThemeTokens=lightThemeTokens.join(\" \");}else if(rule.conditionText===\"(prefers-color-scheme: dark)\"){const cssTextIgnore=\"body:not([data-framer-theme])\";if(!rule.cssText.includes(cssTextIgnore)){const mediaRulesString=rule.cssRules[0].cssText.replace(\"body\",\"\").replace(/\\s*{\\s*/,\"\").replace(/\\s*}\\s*$/,\"\");darkThemeTokens=mediaRulesString;}}}}catch(e){//console.warn(\"Cannot access stylesheet:\", sheet.href)\n}}// Create styleSheet with id and populate with correct CSS text\nlet styleElement=document.createElement(\"style\");styleElement.id=\"toggle-theme\";const customCssRule=`body[toggle-theme=\"light\"] {${lightThemeTokens}} body[toggle-theme=\"dark\"]{${darkThemeTokens}} html[toggle-theme=\"light\"] { color-scheme: light; } html[toggle-theme=\"dark\"] { color-scheme: dark; }`;styleElement.textContent=customCssRule;document.head.appendChild(styleElement);// Cleanup function\nreturn()=>{// Check if the style element exists and remove it\nconst existingStyleElement=document.getElementById(\"toggle-theme\");if(existingStyleElement){document.head.removeChild(existingStyleElement);}htmlElement&&htmlElement.setAttribute(\"toggle-theme\",\"system\");bodyElement&&bodyElement.setAttribute(\"toggle-theme\",\"system\");};},[]);useEffect(()=>{// 这里通过监听让被动leader执行mode 切换\nif(props.unvisible){const handleStorageChange=event=>{if(event.key===\"theme\"&&event.newValue){// console.log(\"here\")\n// console.log(event.newValue)\nif(event.newValue!==store.theme){setStore({theme:event.newValue});changeThemeMode(event.newValue);}}};window.addEventListener(\"storage\",handleStorageChange);// 在组件卸载时移除监听器\nreturn()=>{window.removeEventListener(\"storage\",handleStorageChange);};}},[]);useEffect(()=>{if(store.theme===\"dark\"){// console.log(\"Adding dark class\")\ndocument.documentElement.classList.add(\"darkn\");document.documentElement.classList.remove(\"lightn\");}else{document.documentElement.classList.add(\"lightn\");document.documentElement.classList.remove(\"darkn\");}},[store.theme]);useEffect(()=>{if(SwitchOnce){setswitch(false);handleTap();}},[SwitchOnce]);const handleTap=()=>{let newTheme=store.theme===\"light\"?\"dark\":\"light\";setStore({theme:newTheme});changeThemeMode(newTheme);};return /*#__PURE__*/_jsxs(_Fragment,{children:[rootstyles({primarycolor:primaryColor,scale:scale,bgcolorlight:bgColor.light,bgcolordark:bgColor.dark,actcolor:actColor,fontF:fontF}),props.unvisible?null:/*#__PURE__*/_jsx(ButtonX,{...props.button,onTap:()=>handleTap(),ToggleDetail:{...props.button.ToggleDetail,On:store.theme===\"light\"?true:false}})]});}addPropertyControls(LeaderPro,{fontF:{type:ControlType.String,title:\"Font Family\",defaultValue:\"SF Pro, Helvetica, Arial, sans-serif\"},primaryColor:{type:ControlType.Color,title:\"Primary Color\",defaultValue:\"#06B6D4\"},actColor:{type:ControlType.Color,title:\"Active Color\",defaultValue:\"#06B6D4\"},bgColor:{type:ControlType.Object,title:\"Background Color\",controls:{light:{type:ControlType.Color,title:\"Light Color\",defaultValue:\"#fefefe\"},dark:{type:ControlType.Color,title:\"Dark Color\",defaultValue:\"#1d1d1d\"},key:{type:ControlType.String,defaultValue:\"\"}}},radiusScale:{type:ControlType.Enum,title:\"Radius Scale\",options:[1.5,1.25,1,.75,.5,.3,0],defaultValue:1},theme:{type:ControlType.File,allowedFileTypes:[\"json\"]},darktheme:{type:ControlType.Enum,title:\"Theme\",options:[\"dark\",\"light\",\"auto\"],defaultValue:\"auto\"},button:{type:ControlType.Object,controls:{...btnProps}},unvisible:{type:ControlType.Boolean,defaultValue:false}});\nexport const __FramerMetadata__ = {\"exports\":{\"loadParams\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"default\":{\"type\":\"reactComponent\",\"name\":\"LeaderPro\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerContractVersion\":\"1\"}},\"useStoretheme\":{\"type\":\"variable\",\"annotations\":{\"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