{"version":3,"file":"CurrentWeather.DXZPHLKA.mjs","names":["useState","error"],"sources":["https:/framerusercontent.com/modules/rbaIm3r9Wyr18rs1rV98/aQ7F3P6NP6B5GGHMqmKI/CurrentWeather.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";const apiKey=\"d245617337db4565819225609241301\"// Your WeatherAPI.com API key\n;/**\n\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth 100%\n * @framerSupportedLayoutHeight 100%\n */export default function CurrentWeather({location:{country,city},showLocation,showTemperature,showCondition,prefixText,countryFirst,temperatureUnit,font,textColor,fontSize,style}){const[weatherCondition,setWeatherCondition]=useState(\"\");const[temperature,setTemperature]=useState(\"\");const[error,setError]=useState(\"\");useEffect(()=>{const fetchWeather=async()=>{try{const query=country?`${city}, ${country}`:city;const url=`https://api.weatherapi.com/v1/current.json?key=${apiKey}&q=${query}&aqi=no`;const response=await fetch(url);if(!response.ok){throw new Error(`Error: ${response.status} - ${response.statusText}`);}const data=await response.json();setWeatherCondition(showCondition?data.current.condition.text:\"\");const temp=temperatureUnit===\"C\"?data.current.temp_c:data.current.temp_f;setTemperature(showTemperature?`${temp}\\xb0${temperatureUnit}`:\"\");}catch(error){console.error(\"Error fetching weather data: \",error);setError(\"Failed to load weather data.\");}};fetchWeather();},[country,city,showCondition,showTemperature,temperatureUnit]);const locationText=(()=>{if(showLocation===\"none\")return\"\";const location=countryFirst?`${country}, ${city}`:`${city}, ${country}`;return showLocation===\"both\"?location:showLocation===\"country\"?country:city;})();const displayText=`${prefixText} ${locationText?`${locationText}: `:\"\"}${weatherCondition}${showTemperature&&showCondition?\", \":\" \"} ${temperature}`;const textStyle={fontSize:`${fontSize}px`,color:textColor,...font};return /*#__PURE__*/_jsx(\"div\",{style:{...style,...textStyle,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",height:\"100%\",width:\"100%\",padding:0,margin:0},children:error?/*#__PURE__*/_jsx(\"p\",{style:{margin:0},children:error}):/*#__PURE__*/_jsx(\"p\",{style:{margin:0},children:displayText.trim()})});}CurrentWeather.defaultProps={location:{country:\"USA\",city:\"New York\"},showLocation:\"both\",showTemperature:true,showCondition:true,countryFirst:false,temperatureUnit:\"C\",font:{},textColor:\"#999999\",fontSize:20};addPropertyControls(CurrentWeather,{location:{type:ControlType.Object,title:\"Location\",controls:{country:{type:ControlType.String,title:\"Country\",defaultValue:CurrentWeather.defaultProps.location.country},city:{type:ControlType.String,title:\"City\",defaultValue:CurrentWeather.defaultProps.location.city}}},font:{type:ControlType.Font,title:\"Font\",defaultValue:\"Inter\",controls:\"extended\"},textColor:{type:ControlType.Color,title:\"Font Color\",defaultValue:\"#999999\"},showLocation:{type:ControlType.Enum,title:\"Location\",options:[\"country\",\"city\",\"both\",\"none\"],optionTitles:[\"Country\",\"City\",\"Both\",\"None\"],defaultValue:\"both\"},showTemperature:{type:ControlType.Boolean,title:\"Temperature\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"},showCondition:{type:ControlType.Boolean,title:\"Condition\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"},prefixText:{type:ControlType.String,title:\"Prefix\",placeholder:\"For none, leave empty\"},countryFirst:{type:ControlType.Boolean,title:\"Country First\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"},temperatureUnit:{type:ControlType.SegmentedEnum,title:\"Unit\",options:[\"C\",\"F\"],optionTitles:[\"\\xb0C\",\"\\xb0F\"],defaultValue:\"C\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CurrentWeather\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutHeight\":\"100%\",\"framerSupportedLayoutWidth\":\"100%\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CurrentWeather.map"],"mappings":"iLAOG,SAAwB,EAA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