{"version":3,"file":"CodeBookTicketCalendarWidgetButton.DT-R5zq4.mjs","names":["_Fragment","GetUpdatesFormDialog","CtaButton","GetUpdatesForm","GiftCardsBanner"],"sources":["https:/framerusercontent.com/modules/YzRFGBlKPCgcFc01Mfb8/VVgH5gLuddTKZOqdPssd/CodeBookTicketCalendarWidgetButton.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget,useLocaleInfo}from\"framer\";import{useEffect}from\"react\";import{GetUpdatesFormDialog,GetUpdatesForm,GiftCardsBanner,CtaButton}from\"https://framer-tkd-ui.vercel.app/framer/britishtheatre.js\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */const CALENDAR_ID=\"calendar-widget\";export default function CodeBookTicketCalendarWidgetButton(props){const isCanvas=RenderTarget.current()===RenderTarget.canvas;const{activeLocale}=useLocaleInfo();const{openCalendarWidget}=useOpenCalendarWidget();const handleOnClick=()=>{if(!props.productId){console.warn(\"Calendar: No product ID configured\");return;}openCalendarWidget(props.productId,activeLocale,props.provider);};return /*#__PURE__*/_jsx(_Fragment,{children:props.mode===\"get-updates\"?/*#__PURE__*/_jsxs(GetUpdatesFormDialog,{trigger:/*#__PURE__*/_jsx(CtaButton,{type:\"button\",id:\"cta-get-updates\",\"aria-label\":props.buttonTitle,variant:\"secondary\",className:\"pr-5\",onClick:handleOnClick,disabled:props.disabled,twScope:isCanvas,children:props.buttonTitle}),content:{...props.dialogContent},children:[/*#__PURE__*/_jsx(GetUpdatesForm,{twScope:false,content:{...props.formContent}}),/*#__PURE__*/_jsx(\"p\",{style:{textAlign:\"center\",margin:\"1.25rem auto 0\"},children:\"- Or -\"}),/*#__PURE__*/_jsx(GiftCardsBanner,{twScope:false,content:{...props.bannerContent}})]}):/*#__PURE__*/_jsx(CtaButton,{type:\"button\",id:\"cta-book-tickets\",\"aria-label\":props.buttonTitle,className:\"pr-5\",onClick:handleOnClick,disabled:props.disabled,twScope:true,showChevron:true,children:props.buttonTitle})});}CodeBookTicketCalendarWidgetButton.displayName=\"Code BookTicket CalendarWidget Button\";addPropertyControls(CodeBookTicketCalendarWidgetButton,{mode:{type:ControlType.Enum,options:[\"redirect\",\"calendar\",\"get-updates\"],defaultValue:\"get-updates\"},poweredBySlot:{type:ControlType.Slot,hidden(props){return props.mode!==\"calendar\";}},dialogContent:{type:ControlType.Object,hidden(props){return props.mode!==\"get-updates\";},controls:{title:{type:ControlType.String,defaultValue:\"Stay Updated\"},description:{type:ControlType.String,defaultValue:\"Get notified when this show goes on sale\"}}},formContent:{type:ControlType.Object,hidden(props){return props.mode!==\"get-updates\";},controls:{buttonText:{type:ControlType.String,defaultValue:\"Get Updates\"},newsletterLabel:{type:ControlType.String,defaultValue:\"Sign me up to the newsletter as well\"},successMessage:{type:ControlType.String,defaultValue:\"You're all set! You'll receive updates in your inbox shortly.\"},errorMessage:{type:ControlType.String,defaultValue:\"Oops! We couldn't add your information. Please check and try again.\"},emailLabel:{type:ControlType.String,defaultValue:\"Email\"},givenNameLabel:{type:ControlType.String,defaultValue:\"First Name\"},familyNameLabel:{type:ControlType.String,defaultValue:\"Last Name\"}}},bannerContent:{type:ControlType.Object,hidden(props){return props.mode!==\"get-updates\";},controls:{buttonText:{type:ControlType.String,defaultValue:\"Buy Gift Card\"},title:{type:ControlType.String,defaultValue:\"Theater & Experience Digital Gift Cards\"},description:{type:ControlType.String,defaultValue:\"Give the gift of theatre with a tickadoo gift voucher. They choose where and when to go. You just give them the key.\"},benefits:{type:ControlType.Array,control:{type:ControlType.String},defaultValue:[\"700+ cities—from London's West End to Dubai's deserts\",\"Complete flexibility—no fixed dates or restrictions\",\"Valid for 12 months\"]}}},productId:{type:ControlType.String,title:\"Product ID\",defaultValue:\"\",preventLocalization:true},provider:{type:ControlType.String,defaultValue:\"\",preventLocalization:true},buttonTitle:{type:ControlType.String,defaultValue:\"Book tickets\"},disabled:{type:ControlType.Boolean,title:\"Disabled\",defaultValue:false},variant:{type:ControlType.Enum,title:\"Variant\",options:[\"primary\",\"secondary\"],defaultValue:\"primary\"},onTap:{type:ControlType.EventHandler}});// --- HELPERS ---\nfunction useOpenCalendarWidget(){const openCalendarWidget=async(productId,localeCode,provider)=>{try{await AppendCalendarContainerToBody(productId,localeCode,provider);// Add a small delay to ensure DOM is ready and prevent race conditions\nawait new Promise(resolve=>setTimeout(resolve,50));if(typeof window.showCalendarWidget!==\"function\"){const error=new Error(\"Calendar: JS is not loaded. showCalendarWidget is not a function.\");throw error;}window.showCalendarWidget();}catch(error){console.error(\"Failed to open calendar widget:\",error);window?.Sentry?.captureException(error);alert(\"CalendarWidget couldn't be loaded. Please try again later.\");}};const cleanupCalendar=()=>{try{const container=document.getElementById(CALENDAR_ID);if(container){container.remove();}if(typeof window.hideCalendarWidget===\"function\"){window.hideCalendarWidget();}}catch(error){console.error(\"Calendar: Error during cleanup:\",error);window?.Sentry?.captureException(error);}};useEffect(()=>{if(typeof window===\"undefined\")return;cleanupCalendar();return typeof window!==\"undefined\"?()=>cleanupCalendar():undefined;},[]);return{openCalendarWidget};}function AppendCalendarContainerToBody(productId,localeCode,provider){return new Promise((resolve,reject)=>{try{// Remove any existing container\nconst existingContainer=document.getElementById(CALENDAR_ID);if(existingContainer)existingContainer.remove();// Validate required props before creating container\nif(!productId)throw new Error(\"Calendar: No product ID provided\");// Create a new container\nconst calendar_container=document.createElement(\"div\");calendar_container.id=CALENDAR_ID;try{calendar_container.dataset.productId=productId;}catch(error){console.error(\"Calendar: Failed to process product ID:\",error);reject(error);return;}if(localeCode){calendar_container.dataset.locale=localeCode;}if(provider){calendar_container.dataset.provider=provider;}//calendar_container.dataset.test = \"true\"\ncalendar_container.dataset.partner=\"britishtheatre\";document.body.appendChild(calendar_container);resolve();}catch(error){console.error(\"Calendar: Error in AppendCalendarContainerToBody:\",error);reject(error);}});}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CodeB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