(()=>{"use strict";var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var n in a)e.o(a,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:a[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.blocks,a=window.wp.blockEditor,n=window.wp.components,o=window.wp.element,i=window.wp.i18n,s=window.wp.primitives,l=window.ReactJSXRuntime,r=(0,l.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,l.jsx)(s.Path,{d:"M14.103 7.128l2.26-2.26a4 4 0 00-5.207 4.804L5.828 15a2 2 0 102.828 2.828l5.329-5.328a4 4 0 004.804-5.208l-2.261 2.26-1.912-.512-.513-1.912zm-7.214 9.64a.5.5 0 11.707-.707.5.5 0 01-.707.707z"})}),c=window.wp.apiFetch;var d=e.n(c);const h=JSON.parse('{"uK":{"eventId":{"type":"number"},"viewOptionValue":{"type":"string","default":"table"},"showMetaDataLabel":{"type":"boolean","default":false},"showMetaDataStatus":{"type":"boolean","default":false},"showReservationInterface":{"type":"boolean","default":false}}}');(0,t.registerBlockType)("ticketleo-events/event",{...h.uK,edit:function(e){const t=(0,a.useBlockProps)(),{attributes:s,setAttributes:c}=e,[h,w]=(0,o.useState)(""),u=[{label:(0,i.__)("Tabellarisch","ticketleo-events"),value:"table"},{label:(0,i.__)("Liste","ticketleo-events"),value:"list"},{label:(0,i.__)("Kacheln","ticketleo-events"),value:"grid"}];function v(e){"label"===e&&c({showMetaDataLabel:!s.showMetaDataLabel}),"status"===e&&c({showMetaDataStatus:!s.showMetaDataStatus})}(0,o.useEffect)((()=>{if("grid"===s.viewOptionValue)void 0===s.showMetaDataLabel&&void 0===s.showMetaDataStatus||c({showMetaDataLabel:void 0,showMetaDataStatus:void 0});else{const e={};void 0===s.showMetaDataLabel&&(e.showMetaDataLabel=!1),void 0===s.showMetaDataStatus&&(e.showMetaDataStatus=!1),Object.keys(e).length>0&&c(e)}}),[s.viewOptionValue,s.showMetaDataLabel,s.showMetaDataStatus]),(0,o.useEffect)((()=>{d()({path:`/wp/v2/block-renderer/${e.name}`,method:"POST",data:{context:"edit",attributes:s}}).then((e=>{w(e.rendered)})).catch((e=>{console.error("Error fetching block content:",e),w("")}))}),[s,e.name]);const p="grid"!==s.viewOptionValue;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(a.InspectorControls,{children:(0,l.jsxs)(n.PanelBody,{title:(0,i.__)("Einstellungen","ticketleo-events"),initialOpen:!0,icon:r,children:[(0,l.jsx)(n.TextControl,{label:(0,i.__)("Event-ID","ticketleo-events"),value:s.eventId,onChange:function(e){const t=""===e?void 0:Number(e);c({eventId:t})},type:"number",__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,help:(0,o.createInterpolateElement)((0,i.__)("Wie Sie diese herausfinden, können Sie <a>hier</a> sehen.","ticketleo-events"),{a:(0,l.jsx)("a",{href:`${window.location.origin}/wp-content/plugins/ticketleo-events/docs/find-ids.pdf`,target:"_blank",rel:"noopener noreferrer"})})}),(0,l.jsx)("div",{style:{marginTop:"10px",marginBottom:"20px"},children:(0,l.jsx)(n.CheckboxControl,{label:(0,i.__)("Reservierungsoberfläche integrieren","ticketleo-events"),checked:!!s.showReservationInterface,onChange:function(){c({showReservationInterface:!s.showReservationInterface})},__nextHasNoMarginBottom:!0,help:(0,o.createInterpolateElement)((0,i.__)("Wie Sie diese integrieren, finden Sie <a>hier</a>.","ticketleo-events"),{a:(0,l.jsx)("a",{href:`${window.location.origin}/wp-content/plugins/ticketleo-events/docs/integrate-reservation.pdf`,target:"_blank",rel:"noopener noreferrer"})})})}),!s.showReservationInterface&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(n.SelectControl,{label:(0,i.__)("Ansicht","ticketleo-events"),value:s.viewOptionValue,options:u,onChange:function(e){c({viewOptionValue:e})},__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),p&&(0,l.jsxs)("div",{style:{marginBlock:"20px"},children:[(0,l.jsx)("label",{children:(0,i.__)("Metadaten einblenden","ticketleo-events")}),(0,l.jsxs)("div",{style:{marginTop:"10px"},children:[(0,l.jsx)(n.CheckboxControl,{label:(0,i.__)("Bezeichnung","ticketleo-events"),checked:!!s.showMetaDataLabel,onChange:()=>v("label"),__nextHasNoMarginBottom:!0}),(0,l.jsx)(n.CheckboxControl,{label:(0,i.__)("Status","ticketleo-events"),checked:!!s.showMetaDataStatus,onChange:()=>v("status"),__nextHasNoMarginBottom:!0})]})]})]})]})}),(0,l.jsx)("div",{...t,children:(0,l.jsx)("div",{dangerouslySetInnerHTML:{__html:h}})})]})},save:()=>null})})();