{"version":3,"file":"AddToCalender.BuTm3oby.mjs","names":[],"sources":["https:/framerusercontent.com/modules/fGDajRc8Bcxz9DEZYVaO/vCjrK75WbG4SJCOM9HLa/AddToCalender.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";export default function AddToCalendar(props){const{eventName,eventDescription,eventLocation,startDate,endDate,text,font,backgroundColor,textColor,paddingTop,paddingRight,paddingBottom,paddingLeft,radius,iconSVG,iconSize,timeZone=\"Europe/Rome\",style}=props;// YYYYMMDDTHHMMSSZ (UTC) per Google Calendar\nconst toGoogleUTC=dateStr=>{const d=new Date(dateStr);if(isNaN(d.getTime()))return\"\";return d.toISOString().replace(/[-:]/g,\"\").replace(/\\.\\d{3}Z$/,\"Z\");};// per ICS accetta anche Z; usiamo UTC per semplicità\nconst toICSUTC=dateStr=>toGoogleUTC(dateStr);const generateGoogleCalendarUrl=()=>{const dates=`${toGoogleUTC(startDate)}/${toGoogleUTC(endDate)}`;const params=new URLSearchParams({action:\"TEMPLATE\",text:eventName,details:eventDescription,location:eventLocation,dates,ctz:timeZone});return`https://calendar.google.com/calendar/render?${params.toString()}`;};const escapeICS=v=>(v||\"\").replace(/\\\\/g,\"\\\\\\\\\").replace(/;/g,\"\\\\;\").replace(/,/g,\"\\\\,\").replace(/\\n/g,\"\\\\n\");const generateICSFile=()=>{const uid=`${Date.now()}@apishare.cloud`;const dtstamp=new Date().toISOString().replace(/[-:]/g,\"\").replace(/\\.\\d{3}Z$/,\"Z\");const icsLines=[\"BEGIN:VCALENDAR\",\"VERSION:2.0\",\"PRODID:-//ApiShare//AddToCalendar//EN\",\"CALSCALE:GREGORIAN\",\"METHOD:PUBLISH\",\"BEGIN:VEVENT\",`UID:${uid}`,`DTSTAMP:${dtstamp}`,`DTSTART:${toICSUTC(startDate)}`,`DTEND:${toICSUTC(endDate)}`,`SUMMARY:${escapeICS(eventName)}`,`DESCRIPTION:${escapeICS(eventDescription)}`,`LOCATION:${escapeICS(eventLocation)}`,\"END:VEVENT\",\"END:VCALENDAR\"].join(\"\\r\\n\");const blob=new Blob([icsLines],{type:\"text/calendar;charset=utf-8\"});const url=URL.createObjectURL(blob);const a=document.createElement(\"a\");a.href=url;a.download=\"event.ics\";document.body.appendChild(a);a.click();document.body.removeChild(a);URL.revokeObjectURL(url);};const handleClick=()=>{const ua=navigator.userAgent||\"\";const isiOS=/iPhone|iPad|iPod/.test(ua);// su iOS preferiamo .ics (apre Calendario nativo). Su altri apriamo GCal con template\nif(isiOS){generateICSFile();}else{window.open(generateGoogleCalendarUrl(),\"_blank\",\"noopener,noreferrer\");}};return /*#__PURE__*/_jsxs(\"div\",{onClick:handleClick,style:{backgroundColor,color:textColor,borderRadius:radius,padding:`${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`,cursor:\"pointer\",display:\"flex\",alignItems:\"center\",gap:12,userSelect:\"none\",transition:\"all 0.15s ease\",width:\"fit-content\",...font,...style},onMouseEnter:e=>{e.currentTarget.style.opacity=\"0.9\";e.currentTarget.style.transform=\"translateY(-1px)\";},onMouseLeave:e=>{e.currentTarget.style.opacity=\"1\";e.currentTarget.style.transform=\"translateY(0)\";},children:[iconSVG&&/*#__PURE__*/_jsx(\"div\",{style:{width:iconSize,height:iconSize,color:textColor},dangerouslySetInnerHTML:{__html:iconSVG}}),/*#__PURE__*/_jsx(\"span\",{children:text})]});}addPropertyControls(AddToCalendar,{eventName:{type:ControlType.String,title:\"Event Name\",defaultValue:\"My Event\"},eventDescription:{type:ControlType.String,title:\"Description\",defaultValue:\"Description here...\"},eventLocation:{type:ControlType.String,title:\"Location\",defaultValue:\"123 Main St\"},startDate:{type:ControlType.String,title:\"Start Date\",defaultValue:\"2024-09-10T12:00:00\"},endDate:{type:ControlType.String,title:\"End Date\",defaultValue:\"2024-09-10T13:00:00\"},timeZone:{type:ControlType.String,title:\"Time Zone\",defaultValue:\"Europe/Rome\"},text:{type:ControlType.String,title:\"Button Text\",defaultValue:\"Add to Calendar\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:14,lineHeight:1.4}},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#ffffff\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#222357\"},radius:{type:ControlType.Number,title:\"Radius\",defaultValue:4,min:0},paddingTop:{type:ControlType.Number,title:\"Padding T\",defaultValue:10,min:0},paddingRight:{type:ControlType.Number,title:\"Padding R\",defaultValue:20,min:0},paddingBottom:{type:ControlType.Number,title:\"Padding B\",defaultValue:10,min:0},paddingLeft:{type:ControlType.Number,title:\"Padding L\",defaultValue:20,min:0},iconSVG:{type:ControlType.String,title:\"Icon SVG\",defaultValue:\"\",display:\"textarea\"},iconSize:{type:ControlType.Number,title:\"Icon Size\",defaultValue:24,min:8,max:100}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AddToCalendar\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AddToCalender.map"],"mappings":"wLAA6G,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,YAAU,mBAAiB,gBAAc,YAAU,UAAQ,OAAK,OAAK,kBAAgB,YAAU,aAAW,eAAa,gBAAc,cAAY,SAAO,UAAQ,WAAS,WAAS,cAAc,SAAO,EACjW,EAAY,GAAS,CAAC,IAAM,EAAE,IAAI,KAAK,EAAQ,CAAgC,OAA5B,MAAM,EAAE,SAAS,CAAC,CAAO,GAAU,EAAE,aAAa,CAAC,QAAQ,QAAQ,GAAG,CAAC,QAAQ,YAAY,IAAI,EAClJ,EAAS,GAAS,EAAY,EAAQ,CAAO,MAA8B,CAAC,IAAM,EAAM,GAAG,EAAY,EAAU,CAAC,GAAG,EAAY,EAAQ,GAA2I,MAAM,+CAAjI,IAAI,gBAAgB,CAAC,OAAO,WAA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