{"version":3,"file":"TimedLinkButton.3fWdyqFP.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/Eooq1zooUjldOVy7z4xt/w7ALcpKlTSQw7CWU11cQ/TimedLinkButton.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion}from\"framer-motion\";/**\n * Time-based Button\n * \n * @framerIntrinsicWidth 200\n * @framerIntrinsicHeight 50\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function TimedLinkButton(props){const{text,links,autoTimezone,timezone,backgroundColor,hoverColor,textColor,borderRadius,padding,font,showIcon,iconPosition,iconSize,iconColor,style}=props;const[currentUrl,setCurrentUrl]=useState(\"\");const[currentLabel,setCurrentLabel]=useState(\"\");useEffect(()=>{const updateCurrentLink=()=>{const now=new Date;const tz=autoTimezone?Intl.DateTimeFormat().resolvedOptions().timeZone:timezone;const localTime=new Date(now.toLocaleString(\"en-US\",{timeZone:tz}));const currentHour=localTime.getHours();const currentMinutes=localTime.getMinutes();const currentTimeInMinutes=currentHour*60+currentMinutes;const sortedLinks=[...links].sort((a,b)=>{const[aHours,aMinutes]=a.time.split(\":\").map(Number);const[bHours,bMinutes]=b.time.split(\":\").map(Number);return aHours*60+aMinutes-(bHours*60+bMinutes);});const activeLink=sortedLinks.reduce((prev,curr)=>{const[hours,minutes]=curr.time.split(\":\").map(Number);const linkTimeInMinutes=hours*60+minutes;if(linkTimeInMinutes<=currentTimeInMinutes)return curr;return prev;},sortedLinks[sortedLinks.length-1]);if(activeLink){setCurrentUrl(activeLink.url);setCurrentLabel(activeLink.label||text);}};updateCurrentLink();const interval=setInterval(updateCurrentLink,6e4);return()=>clearInterval(interval);},[links,autoTimezone,timezone,text]);const handleClick=()=>{if(currentUrl){if(typeof window!==\"undefined\"){window.location.href=currentUrl;}}};const Icon=()=>/*#__PURE__*/_jsx(\"svg\",{width:iconSize,height:iconSize,viewBox:\"0 0 24 24\",fill:\"none\",stroke:iconColor,strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M5 12h14M12 5l7 7-7 7\"})});return /*#__PURE__*/_jsxs(motion.button,{onClick:handleClick,whileHover:{backgroundColor:hoverColor},transition:{duration:.2},style:{...style,position:\"relative\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",gap:\"8px\",backgroundColor,color:textColor,border:\"none\",borderRadius,padding:padding,cursor:\"pointer\",...font,minWidth:\"max-content\"},children:[showIcon&&iconPosition===\"left\"&&/*#__PURE__*/_jsx(Icon,{}),/*#__PURE__*/_jsx(\"span\",{children:currentLabel||text}),showIcon&&iconPosition===\"right\"&&/*#__PURE__*/_jsx(Icon,{})]});}addPropertyControls(TimedLinkButton,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Click me\"},links:{type:ControlType.Array,title:\"Time Links\",control:{type:ControlType.Object,controls:{time:{type:ControlType.String,title:\"Time (HH:MM)\",defaultValue:\"12:00\"},url:{type:ControlType.String,title:\"URL\",defaultValue:\"https://example.com\"},label:{type:ControlType.String,title:\"Label (optional)\",defaultValue:\"\"}}},defaultValue:[{time:\"09:00\",url:\"https://morning.example.com\",label:\"Morning Link\"},{time:\"18:00\",url:\"https://evening.example.com\",label:\"Evening Link\"}]},autoTimezone:{type:ControlType.Boolean,title:\"Auto Timezone\",defaultValue:true},timezone:{type:ControlType.String,title:\"Timezone\",defaultValue:\"UTC\",hidden:({autoTimezone})=>autoTimezone},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#007AFF\"},hoverColor:{type:ControlType.Color,title:\"Hover Color\",defaultValue:\"#0056b3\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:8,min:0,max:100,unit:\"px\"},padding:{type:ControlType.Number,title:\"Padding\",defaultValue:16,min:0,max:100,unit:\"px\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:16,lineHeight:1.5,letterSpacing:0,textAlign:\"center\",variant:\"Medium\"}},showIcon:{type:ControlType.Boolean,title:\"Show Icon\",defaultValue:true},iconPosition:{type:ControlType.Enum,title:\"Icon Position\",options:[\"left\",\"right\"],optionTitles:[\"Left\",\"Right\"],defaultValue:\"right\",hidden:({showIcon})=>!showIcon},iconSize:{type:ControlType.Number,title:\"Icon Size\",defaultValue:24,min:12,max:48,unit:\"px\",hidden:({showIcon})=>!showIcon},iconColor:{type:ControlType.Color,title:\"Icon Color\",defaultValue:\"#FFFFFF\",hidden:({showIcon})=>!showIcon}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TimedLinkButton\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"50\",\"framerIntrinsicWidth\":\"200\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TimedLinkButton.map"],"mappings":"uPAOG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,OAAK,QAAM,eAAa,WAAS,kBAAgB,aAAW,YAAU,eAAa,UAAQ,OAAK,WAAS,eAAa,WAAS,YAAU,SAAO,EAAW,CAAC,EAAW,GAAeA,EAAS,GAAG,CAAM,CAAC,EAAa,GAAiBA,EAAS,GAAG,CAAC,MAAc,CAAC,IAAM,MAAsB,CAAC,IAAM,EAAI,IAAI,KAAW,EAAG,EAAa,KAAK,gBAAgB,CAAC,iBAAiB,CAAC,SAAS,EAAe,EAAU,IAAI,KAAK,EAAI,eAAe,QAAQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAO,EAAY,EAAU,UAAU,CAAO,EAAe,EAAU,YAAY,CAAO,EAAqB,EAA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