(()=>{"use strict";var e,n={845(){const e=window.wp.blocks,n=JSON.parse('{"apiVersion":3,"name":"vk-booking-manager/menu-search","title":"Service menu search","description":"You can search by resource, service tag, etc. in conjunction with the menu loop.","category":"widgets","icon":"search","textdomain":"vk-booking-manager","keywords":["booking","search"],"attributes":{"targetId":{"type":"string","default":""},"submitLabel":{"type":"string","default":"Search with these conditions"}},"providesContext":{"vk-booking-manager/menuSearchTargetId":"targetId"},"supports":{"anchor":true,"customClassName":true,"spacing":{"margin":true,"padding":true}},"style":"file:./style-index.css","editorStyle":"file:./index.css","editorScript":"file:./index.js"}'),o=window.wp.i18n,r=window.wp.blockEditor,t=window.wp.components,a=window.wp.element,s=window.wp.data,i=(e="")=>e.toString().trim().toLowerCase().replace(/[^a-z0-9_-]/g,""),l=(e=[])=>e.reduce((e,n)=>n?(e.push(n),Array.isArray(n.innerBlocks)&&n.innerBlocks.length&&e.push(...l(n.innerBlocks)),e):e,[]),c=window.ReactJSXRuntime,g=[["vk-booking-manager/menu-search-field-staff"],["vk-booking-manager/menu-search-field-category"],["vk-booking-manager/menu-search-field-keyword"]],d=["vk-booking-manager/menu-search-field-staff","vk-booking-manager/menu-search-field-category","vk-booking-manager/menu-search-field-keyword","core/columns","core/column","core/group","core/row","core/spacer","core/paragraph","core/heading"];(0,e.registerBlockType)(n,{edit:({attributes:e,setAttributes:u})=>{const k=(0,r.useBlockProps)({className:"vkbm-menu-search"}),{loopBlocks:m,searchBlocks:b}=(0,s.useSelect)(e=>{const o=l(e("core/block-editor").getBlocks());return{loopBlocks:o.filter(e=>"vk-booking-manager/menu-loop"===e?.name),searchBlocks:o.filter(e=>e?.name===n.name)}},[]),h=(0,a.useMemo)(()=>m.map(e=>e?.attributes?.loopId).filter(Boolean),[m]),p=!e.targetId||h.length>0&&!h.includes(e.targetId),v=b.length>1;return f=v,w="vkbm-menu-search-limit",y=(0,o.__)("Only one scheduled search block can be placed on this page.","vk-booking-manager"),(0,a.useEffect)(()=>{const e=(()=>{const e=(0,s.dispatch)("core/editor");if(e?.lockPostSaving)return e;const n=(0,s.dispatch)("core/edit-site");return n?.lockPostSaving?n:null})();if(e)return f?e.lockPostSaving(w,{message:y}):e.unlockPostSaving(w),()=>e.unlockPostSaving(w)},[f,w,y]),(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(r.InspectorControls,{children:[(0,c.jsxs)(t.PanelBody,{title:(0,o.__)("Cooperation settings","vk-booking-manager"),children:[(0,c.jsx)(t.TextControl,{label:(0,o.__)("target ID","vk-booking-manager"),value:e.targetId,onChange:e=>u({targetId:i(e)})}),p&&(0,c.jsxs)(t.Notice,{status:"warning",isDismissible:!1,children:[(0,o.__)("There are no menu loop blocks to display.","vk-booking-manager"),h.length>0&&(0,c.jsx)("div",{style:{marginTop:"0.75rem"},children:(0,c.jsx)(t.Button,{variant:"secondary",onClick:()=>{h.length&&u({targetId:h[0]})},children:(0,o.__)("Automatically obtain menu loop ID","vk-booking-manager")})})]}),(0,c.jsx)(t.TextControl,{label:(0,o.__)("send button label","vk-booking-manager"),value:e.submitLabel,onChange:e=>u({submitLabel:e})})]}),v&&(0,c.jsx)(t.PanelBody,{title:(0,o.__)("caveat","vk-booking-manager"),initialOpen:!0,children:(0,c.jsx)(t.Notice,{status:"error",isDismissible:!1,children:(0,o.__)("Only one scheduled search block can be used per page. Delete extra blocks.","vk-booking-manager")})})]}),(0,c.jsxs)("div",{...k,children:[(0,c.jsx)("div",{className:"vkbm-menu-search__fields",children:(0,c.jsx)(r.InnerBlocks,{allowedBlocks:d,template:g,templateLock:!1,renderAppender:r.InnerBlocks.ButtonBlockAppender})}),(0,c.jsx)("div",{className:"vkbm-menu-search__actions vkbm-buttons vkbm-buttons__center",children:(0,c.jsx)("button",{type:"button",className:"vkbm-button vkbm-button__primary",children:e.submitLabel||n.attributes.submitLabel.default})})]})]});var f,w,y},save:()=>null})}},o={};function r(e){var t=o[e];if(void 0!==t)return t.exports;var a=o[e]={exports:{}};return n[e](a,a.exports,r),a.exports}r.m=n,e=[],r.O=(n,o,t,a)=>{if(!o){var s=1/0;for(g=0;g<e.length;g++){for(var[o,t,a]=e[g],i=!0,l=0;l<o.length;l++)(!1&a||s>=a)&&Object.keys(r.O).every(e=>r.O[e](o[l]))?o.splice(l--,1):(i=!1,a<s&&(s=a));if(i){e.splice(g--,1);var c=t();void 0!==c&&(n=c)}}return n}a=a||0;for(var g=e.length;g>0&&e[g-1][2]>a;g--)e[g]=e[g-1];e[g]=[o,t,a]},r.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),(()=>{var e={295:0,367:0};r.O.j=n=>0===e[n];var n=(n,o)=>{var t,a,[s,i,l]=o,c=0;if(s.some(n=>0!==e[n])){for(t in i)r.o(i,t)&&(r.m[t]=i[t]);if(l)var g=l(r)}for(n&&n(o);c<s.length;c++)a=s[c],r.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return r.O(g)},o=globalThis.webpackChunkvk_booking_manager=globalThis.webpackChunkvk_booking_manager||[];o.forEach(n.bind(null,0)),o.push=n.bind(null,o.push.bind(o))})();var t=r.O(void 0,[367],()=>r(845));t=r.O(t)})();