(()=>{"use strict";var e,r={3154(e,r,t){const l=window.wp.blocks,a=window.wp.i18n,o=window.wp.blockEditor,n=window.wp.apiFetch;var s=t.n(n);const i=window.wp.url,c=window.React,v=window.ReactJSXRuntime,{Fragment:u}=wp.element,{PanelBody:p,RadioControl:d,SelectControl:m}=wp.components,_=JSON.parse('{"UU":"rsvpmaker/calendar"}');(0,l.registerBlockType)(_.UU,{edit:function(e){const{attributes:r,setAttributes:t}=e,{itembg:l,itemcolor:n,nav:_,type:b,event_type_colors:h={}}=r,[g,f]=(0,c.useState)(null),[k,y]=(0,c.useState)([{value:"",label:(0,a.__)("Any","rsvpmaker")}]);return(0,c.useEffect)(()=>{const e={...r,event_type_colors:JSON.stringify(r.event_type_colors||{})};s()({path:(0,i.addQueryArgs)("/rsvpmaker/v1/calendar",e)}).then(e=>{f(e.calendar)})},[r]),(0,c.useEffect)(()=>{s()({path:"rsvpmaker/v1/types"}).then(e=>{const r=Array.isArray(e)?e:Object.values(e||{}),t=[{value:"",label:(0,a.__)("Any","rsvpmaker")}];r.forEach(e=>{e?.slug&&e?.name&&t.push({value:e.slug,label:e.name})}),y(t)}).catch(e=>{console.log(e)})},[]),(0,v.jsx)(u,{children:(0,v.jsxs)("div",{...(0,o.useBlockProps)(),children:[(0,v.jsxs)(o.InspectorControls,{children:[(0,v.jsxs)(p,{title:(0,a.__)("RSVPMaker Calendar","rsvpmaker"),children:[(0,v.jsx)(d,{label:(0,a.__)("Position of Navigation Links","rsvpmaker"),selected:_,options:[{label:"bottom",value:"bottom"},{label:"top",value:"top"},{label:"both",value:"both"}],onChange:e=>t({nav:e})}),(0,v.jsx)(m,{label:(0,a.__)("Event Type","rsvpmaker"),value:b,options:k,onChange:e=>t({type:e})})]}),(0,v.jsx)(o.PanelColorSettings,{title:(0,a.__)("Default Calendar Item Colors","rsvpmaker"),colorSettings:[{label:(0,a.__)("Text color","rsvpmaker"),onChange:e=>t({itemcolor:e}),value:n},{label:(0,a.__)("Background color","rsvpmaker"),onChange:e=>t({itembg:e}),value:l}]}),(0,v.jsx)(p,{title:(0,a.__)("Event Type Background Colors","rsvpmaker"),initialOpen:!1,children:k.filter(e=>e.value).map(e=>{const r=!!h[e.value];return(0,v.jsxs)("div",{style:{marginBottom:"16px"},children:[(0,v.jsx)(m,{label:(0,a.sprintf)((0,a.__)("%s background","rsvpmaker"),e.label),value:r?"custom":"default",options:[{label:(0,a.__)("Use default","rsvpmaker"),value:"default"},{label:(0,a.__)("Use custom color","rsvpmaker"),value:"custom"}],onChange:r=>((e,r)=>{const a={...h};"default"===r?delete a[e]:a[e]||(a[e]=l),t({event_type_colors:a})})(e.value,r)}),r&&(0,v.jsx)(o.PanelColorSettings,{title:(0,a.sprintf)((0,a.__)("%s custom color","rsvpmaker"),e.label),colorSettings:[{label:(0,a.__)("Background color","rsvpmaker"),onChange:r=>((e,r)=>{const l={...h};r?l[e]=r:delete l[e],t({event_type_colors:l})})(e.value,r),value:h[e.value]}]})]},e.value)})})]},"calendarinspector"),g&&(0,v.jsx)(v.Fragment,{children:(0,v.jsx)("div",{dangerouslySetInnerHTML:{__html:g}})}),!g&&(0,v.jsx)(v.Fragment,{children:(0,v.jsx)("p",{children:"Loading ..."})})]})})},save:function(){return null}})}},t={};function l(e){var a=t[e];if(void 0!==a)return a.exports;var o=t[e]={exports:{}};return r[e](o,o.exports,l),o.exports}l.m=r,e=[],l.O=(r,t,a,o)=>{if(!t){var n=1/0;for(v=0;v<e.length;v++){for(var[t,a,o]=e[v],s=!0,i=0;i<t.length;i++)(!1&o||n>=o)&&Object.keys(l.O).every(e=>l.O[e](t[i]))?t.splice(i--,1):(s=!1,o<n&&(n=o));if(s){e.splice(v--,1);var c=a();void 0!==c&&(r=c)}}return r}o=o||0;for(var v=e.length;v>0&&e[v-1][2]>o;v--)e[v]=e[v-1];e[v]=[t,a,o]},l.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return l.d(r,{a:r}),r},l.d=(e,r)=>{for(var t in r)l.o(r,t)&&!l.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},l.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{var e={9076:0,4108:0};l.O.j=r=>0===e[r];var r=(r,t)=>{var a,o,[n,s,i]=t,c=0;if(n.some(r=>0!==e[r])){for(a in s)l.o(s,a)&&(l.m[a]=s[a]);if(i)var v=i(l)}for(r&&r(t);c<n.length;c++)o=n[c],l.o(e,o)&&e[o]&&e[o][0](),e[o]=0;return l.O(v)},t=globalThis.webpackChunkadmin=globalThis.webpackChunkadmin||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})();var a=l.O(void 0,[4108],()=>l(3154));a=l.O(a)})();