{"version":3,"file":"TimeConverter.CRpFYpdK.mjs","names":["useMemo"],"sources":["https:/framerusercontent.com/modules/OZZlGrjWjElu66tbfx9O/4whnWysRGMzInEgutrqX/TimeConverter.js"],"sourcesContent":["// Text tool that takes a CMS ISO time and displays it in the user’s local time and timezone\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useMemo}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Local Time Converter\n * Displays the given CMS time converted to the user's local time and displays the timezone\n *\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 80\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function TimeConverter(props){const{cmsTime,label,font,color,displayMode=\"datetime\"}=props;const{localDate,localTime,timezone}=useMemo(()=>{let date=null;if(cmsTime){// Always treat input as UTC\nconst parsed=Date.parse(cmsTime);date=!isNaN(parsed)?new Date(parsed):null;}let localDate=\"-\";let localTime=\"-\";let timezone=\"-\";if(date){// Convert the UTC time as input to the user's local time\nconst local=new Date(date.getTime()+date.getTimezoneOffset()*6e4*-1);const day=local.getDate();const suffix=day%10===1&&day!==11?\"st\":day%10===2&&day!==12?\"nd\":day%10===3&&day!==13?\"rd\":\"th\";const weekday=local.toLocaleString(undefined,{weekday:\"long\"});const month=local.toLocaleString(undefined,{month:\"short\"});localDate=`${weekday}, ${month} ${day}${suffix}`;localTime=local.toLocaleTimeString(undefined,{hour:\"2-digit\",minute:\"2-digit\",hour12:true});if(typeof Intl!==\"undefined\"&&Intl.DateTimeFormat().resolvedOptions){timezone=Intl.DateTimeFormat(undefined,{timeZoneName:\"short\"}).format(local).split(\" \").pop()||\"Unknown Timezone\";}}return{localDate,localTime,timezone};},[cmsTime]);let displayContent;if(displayMode===\"datetime\"){displayContent=`${localDate} ${localTime} ${timezone}`;}else if(displayMode===\"date\"){displayContent=`${localDate}`;}else{displayContent=`${localTime} ${timezone}`;}return /*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",flexDirection:\"column\",gap:8,...font,color,width:\"100%\",minWidth:\"max-content\"},children:/*#__PURE__*/_jsx(\"span\",{children:displayContent})});}addPropertyControls(TimeConverter,{label:{type:ControlType.String,title:\"Label\",defaultValue:\"Event Time\"},cmsTime:{type:ControlType.String,title:\"CMS Time\",defaultValue:\"2024-06-01T14:00:00Z\",placeholder:\"ISO8601 string\",displayTextArea:false},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"18px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#111111\"},displayMode:{type:ControlType.Enum,title:\"Display\",options:[\"datetime\",\"date\",\"time\"],optionTitles:[\"Date & Time\",\"Date only\",\"Time only\"],defaultValue:\"datetime\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TimeConverter\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"80\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"400\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TimeConverter.map"],"mappings":"0KAUG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,UAAQ,QAAM,OAAK,QAAM,cAAY,YAAY,EAAW,CAAC,YAAU,YAAU,YAAUA,MAAY,CAAC,IAAI,EAAK,KAAK,GAAG,EAAQ,CACvL,IAAM,EAAO,KAAK,MAAM,CAAO,EAAE,EAAM,MAAM,CAAM,EAAmB,KAAjB,IAAI,KAAK,CAAM,CAAO,CAAC,IAAI,EAAU,IAAQ,EAAU,IAAQ,EAAS,IAAI,GAAG,EAAK,CACzI,IAAM,EAAM,IAAI,KAAK,EAAK,QAAQ,EAAE,EAAK,kBAAkB,EAAE,IAAI,EAAE,EAAQ,EAAI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