{"version":3,"file":"TicketButton.DWLA-oNR.mjs","names":["useState","_Fragment","_jsx"],"sources":["https:/framerusercontent.com/modules/kXocIZTwnqiUUEBTxOQu/vJJL2VCzOPaoBCwNvrjx/TicketButton.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{createPortal}from\"react-dom\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * MaHalla — Ticket Button\n *\n * A text link styled with MaHalla's type settings that opens the Ticket Tailor\n * checkout in a modal overlay.\n *\n * Reusable for every event: set Checkout URL, Event name, TT event ID and Price\n * per instance in the properties panel — or bind them to CMS fields / component\n * variables in Framer, so each event page fills them automatically.\n *\n * Tracking:\n * - carries the visitor's source (utm_source, or \"meta\" if only fbclid is\n *   present) into Ticket Tailor as the order's ref= tag\n * - fires GA4 `begin_checkout` (with value + EUR) when the modal opens, once\n *   per page view and event. Meta receives it as `InitiateCheckout` through the\n *   Google tag → Conversions API connection — no direct fbq call, which would\n *   double-count.\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n * @framerIntrinsicWidth 140\n * @framerIntrinsicHeight 40\n */const TRACKING_KEY=\"mh_utm_source\";// Haelt die Quelle fuer die Session fest. Ohne das waere sie weg, sobald\n// jemand von der Landingpage weiterklickt.\nfunction readSource(){if(typeof window===\"undefined\")return\"\";try{const params=new URLSearchParams(window.location.search);const utm=params.get(\"utm_source\");if(utm){sessionStorage.setItem(TRACKING_KEY,utm);return utm;}// Meta-Klick ohne UTM-Parameter: trotzdem als Meta markieren.\nif(params.get(\"fbclid\")){sessionStorage.setItem(TRACKING_KEY,\"meta\");return\"meta\";}return sessionStorage.getItem(TRACKING_KEY)||\"\";}catch{return\"\";}}// Setzt ref= auf die echte Quelle, damit sie in Ticket Tailor auf der\n// Bestellung steht. Ohne Quelle bleibt der Default aus der URL stehen.\nfunction withRef(base,source){if(!source)return base;try{const url=new URL(base);url.searchParams.set(\"ref\",source);return url.toString();}catch{return base;}}// Ein Event pro Seitenaufruf und Event — mehrfaches Oeffnen zaehlt nicht doppelt.\nconst firedFor=new Set;// Schlaegt bewusst still fehl: Tracking darf den Kauf nie blockieren.\nfunction trackOpen(source,eventName,eventId,price){if(typeof window===\"undefined\")return;const key=eventId||eventName;if(firedFor.has(key))return;firedFor.add(key);const w=window;const id=eventId||eventName;try{if(typeof w.gtag===\"function\"){w.gtag(\"event\",\"begin_checkout\",{currency:\"EUR\",value:price,items:[{item_id:id,item_name:eventName,price,quantity:1}],traffic_source:source||\"(none)\"});}// Kein direkter fbq-Aufruf: Meta bekommt InitiateCheckout ueber die\n// Google-Tag/Conversions-API-Verbindung (begin_checkout -> InitiateCheckout).\n// Ein zusaetzliches fbq() wuerde jeden Klick doppelt zaehlen.\n}catch{}}export default function TicketButton(props){const{label,checkoutUrl,eventName,eventId,price,font,textColor,hoverColor,hoverUnderline,background,paddingX,paddingY,radius,modalMaxWidth,modalHeight,modalRadius,overlayColor,style}=props;const[open,setOpen]=useState(false);const[hover,setHover]=useState(false);const[loaded,setLoaded]=useState(false)// iframe loads on first open only\n;const[source,setSource]=useState(\"\");const onCanvas=RenderTarget.current()===RenderTarget.canvas;useEffect(()=>{setSource(readSource());},[]);// Escape to close + lock background scroll while the modal is open\nuseEffect(()=>{if(!open)return;const onKey=e=>{if(e.key===\"Escape\")setOpen(false);};document.addEventListener(\"keydown\",onKey);const previousOverflow=document.body.style.overflow;document.body.style.overflow=\"hidden\";return()=>{document.removeEventListener(\"keydown\",onKey);document.body.style.overflow=previousOverflow;};},[open]);// Hard defaults first, then whatever the Font control provides. A <button>\n// does not inherit page typography, so if `font` is ever undefined the\n// browser falls back to ~13px — these defaults prevent that.\nconst fontStyle={fontFamily:'\"Inter Display\", \"Inter\", sans-serif',fontSize:30,fontWeight:700,letterSpacing:\"-0.02em\",lineHeight:\"1.2em\",...font||{}};function handleClick(){// On the Framer canvas the iframe would just show an error, so do nothing.\nif(onCanvas||!checkoutUrl)return;trackOpen(source,eventName,eventId,Number(price)||0);setLoaded(true);setOpen(true);}const button=/*#__PURE__*/_jsx(\"button\",{onClick:handleClick,onMouseEnter:()=>setHover(true),onMouseLeave:()=>setHover(false),title:onCanvas&&!checkoutUrl?\"Checkout URL fehlt\":undefined,style:{// Framer's own layout styles go first so our typography wins.\n...style,...fontStyle,display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",whiteSpace:\"nowrap\",color:hover?hoverColor:textColor,background,border:\"none\",borderRadius:radius,padding:`${paddingY}px ${paddingX}px`,margin:0,textDecoration:hover&&hoverUnderline?\"underline\":\"none\",textUnderlineOffset:\"0.12em\",cursor:\"pointer\",transition:\"color 160ms ease, background 160ms ease\",WebkitTapHighlightColor:\"transparent\",opacity:onCanvas&&!checkoutUrl?.4:1},children:label});// The overlay is rendered into document.body. Framer applies CSS\n// transforms to its containers, and position:fixed inside a transformed\n// ancestor is positioned against that ancestor instead of the viewport.\nconst modal=open&&typeof document!==\"undefined\"?/*#__PURE__*/createPortal(/*#__PURE__*/_jsx(\"div\",{role:\"dialog\",\"aria-modal\":\"true\",\"aria-label\":label,onClick:e=>{if(e.target===e.currentTarget)setOpen(false);},style:{position:\"fixed\",inset:0,zIndex:2147483e3,background:overlayColor,display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},children:/*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"100%\",maxWidth:modalMaxWidth,height:`${modalHeight}vh`,background:\"#fff\",borderRadius:modalRadius,overflow:\"hidden\"},children:[/*#__PURE__*/_jsx(\"button\",{onClick:()=>setOpen(false),\"aria-label\":\"Close\",style:{position:\"absolute\",top:8,right:10,zIndex:2,width:36,height:36,borderRadius:\"50%\",border:\"none\",background:\"rgba(255,255,255,0.92)\",color:\"#000\",fontSize:24,lineHeight:\"34px\",cursor:\"pointer\"},children:\"\\xd7\"}),loaded&&/*#__PURE__*/_jsx(\"iframe\",{src:withRef(checkoutUrl,source),title:\"Ticket checkout\",allow:\"payment *\",style:{width:\"100%\",height:\"100%\",border:0,display:\"block\"}})]})}),document.body):null;return /*#__PURE__*/_jsxs(_Fragment,{children:[button,modal]});}TicketButton.defaultProps={label:\"Tickets\",checkoutUrl:\"\",eventName:\"\",eventId:\"\",price:0,font:{fontFamily:'\"Inter Display\", \"Inter\", sans-serif',fontSize:30,fontWeight:700,letterSpacing:\"-0.02em\",lineHeight:\"1.2em\"},textColor:\"#FB0007\",hoverColor:\"#FFFFFF\",hoverUnderline:false,background:\"rgba(0,0,0,0)\",paddingX:0,paddingY:0,radius:0,modalMaxWidth:860,modalHeight:88,modalRadius:6,overlayColor:\"rgba(0,0,0,0.85)\"};addPropertyControls(TicketButton,{label:{type:ControlType.String,title:\"Label\",defaultValue:\"Tickets\"},// --- Per event: set these, or bind them to CMS fields / variables ---\ncheckoutUrl:{type:ControlType.String,title:\"Checkout URL\",description:\"Ticket Tailor link on tickets.mahalla.berlin. A new-session link opens directly on Select tickets.\",defaultValue:\"\"},eventName:{type:ControlType.String,title:\"Event name\",description:\"Shown in GA4 and Meta, e.g. Totenpicknick.\",defaultValue:\"\"},eventId:{type:ControlType.String,title:\"TT event ID\",description:\"Number from the Ticket Tailor event URL, e.g. 2436870.\",defaultValue:\"\"},price:{type:ControlType.Number,title:\"Price €\",min:0,max:1e3,step:1,defaultValue:0,description:\"Sent as value to GA4 and Meta.\"},// --- Style ---\nfont:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans\",defaultValue:{fontSize:30,fontWeight:700,letterSpacing:\"-0.02em\",lineHeight:\"1.2em\"}},textColor:{type:ControlType.Color,title:\"Color\"},hoverColor:{type:ControlType.Color,title:\"Hover\"},hoverUnderline:{type:ControlType.Boolean,title:\"Underline\",enabledTitle:\"On hover\",disabledTitle:\"Never\"},background:{type:ControlType.Color,title:\"Fill\",description:\"Transparent by default. Set a colour for a boxed button.\"},paddingX:{type:ControlType.Number,title:\"Pad X\",min:0,max:80,step:2},paddingY:{type:ControlType.Number,title:\"Pad Y\",min:0,max:60,step:2},radius:{type:ControlType.Number,title:\"Radius\",min:0,max:60,step:1},// --- Modal ---\nmodalMaxWidth:{type:ControlType.Number,title:\"Modal width\",min:400,max:1400,step:20},modalHeight:{type:ControlType.Number,title:\"Modal height\",min:50,max:100,step:1,description:\"Percent of the viewport height.\"},modalRadius:{type:ControlType.Number,title:\"Modal radius\",min:0,max:40,step:1},overlayColor:{type:ControlType.Color,title:\"Overlay\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TicketButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TicketButton.map"],"mappings":"6NAwBA,SAAS,GAAY,CAAC,GAAU,IAAS,OAAY,MAAM,GAAG,GAAG,CAAC,IAAM,EAAO,IAAI,gBAAgB,EAAO,SAAS,MAAM,EAAQ,EAAI,EAAO,IAAI,YAAY,EACzE,OAD8E,GAAK,eAAe,QAAQ,EAAa,CAAG,EAAS,GACnN,EAAO,IAAI,QAAQ,GAAG,eAAe,QAAQ,EAAa,MAAM,EAAQ,QAAe,eAAe,QAAQ,CAAY,GAAG,EAAG,MAAM,CAAC,MAAM,EAAG,CAAC,CAEpJ,SAAS,EAAQ,EAAK,EAAO,CAAC,GAAG,CAAC,EAAO,OAAO,EAAK,GAAG,CAAC,IAAM,EAAI,IAAI,IAAI,CAAI,EAAqC,OAAnC,EAAI,aAAa,IAAI,MAAM,CAAM,EAAS,EAAI,SAAS,CAAE,MAAM,CAAC,OAAO,CAAK,CAAC,CAE9J,SAAS,EAAU,EAAO,EAAU,EAAQ,EAAM,CAAC,GAAU,IAAS,OAAY,OAAO,IAAM,EAAI,GAAS,EAAU,GAAG,EAAS,IAAI,CAAG,EAAE,OAAO,EAAS,IAAI,CAAG,EAAE,IAAM,EAAE,EAAa,EAAG,GAAS,EAAU,GAAG,CAAI,OAAO,EAAE,MAAO,Y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