(()=>{"use strict";const o=window.wp.blocks,e=window.wp.primitives,n=window.ReactJSXRuntime,i=(0,n.jsx)(e.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,n.jsx)(e.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm9 1V8h-1.5v3.5h-2V13H13Z"})}),r=JSON.parse('{"UU":"woocommerce-bookings/booking-duration"}'),t=window.wp.blockEditor,c=window.wp.coreData,s=window.wp.i18n;function a(o){var e,n,i="";if("string"==typeof o||"number"==typeof o)i+=o;else if("object"==typeof o)if(Array.isArray(o)){var r=o.length;for(e=0;e<r;e++)o[e]&&(n=a(o[e]))&&(i&&(i+=" "),i+=n)}else for(n in o)o[n]&&(i&&(i+=" "),i+=n);return i}const l=function(){for(var o,e,n=0,i="",r=arguments.length;n<r;n++)(o=arguments[n])&&(e=a(o))&&(i&&(i+=" "),i+=e);return i},m=["core/bold","core/image","core/italic","core/link","core/strikethrough","core/text-color"];(0,o.registerBlockType)(r.UU,{icon:i,edit:({attributes:o,setAttributes:e,isSelected:i,context:r})=>{const a="default"===(0,t.useBlockEditingMode)(),{prefix:d,suffix:u,textAlign:g}=o,w=(0,t.useBlockProps)({className:l({[`has-text-align-${g}`]:g})}),{postId:h}=r,{record:f}=(0,c.useEntityRecord)("root","product",h),x=f?.booking_duration,b=f?.booking_duration_unit;let p;if(null!=x&&b){let o="";o="minute"===b?(0,s.__)("min","woocommerce-bookings"):"hour"===b?(0,s._n)("hour","hours",x,"woocommerce-bookings"):"day"===b?(0,s._n)("day","days",x,"woocommerce-bookings"):"month"===b?(0,s._n)("month","months",x,"woocommerce-bookings"):"night"===b?(0,s._n)("night","nights",x,"woocommerce-bookings"):b,p=`${x} ${o}`}else p=(0,s.__)("Booking Duration","woocommerce-bookings");return(0,n.jsxs)(n.Fragment,{children:[a&&(0,n.jsx)(t.BlockControls,{children:(0,n.jsx)(t.AlignmentToolbar,{value:g,onChange:o=>{e({textAlign:o})}})}),(0,n.jsxs)("div",{...w,children:[(i||d)&&(0,n.jsx)(t.RichText,{className:"wc-bookings-block-components-booking-duration__prefix",allowedFormats:m,tagName:"span",placeholder:(0,s.__)("Prefix","woocommerce"),"aria-label":(0,s.__)("Prefix","woocommerce"),value:d,onChange:o=>e({prefix:o})}),(0,n.jsx)("span",{children:p}),(i||u)&&(0,n.jsx)(t.RichText,{className:"wc-bookings-block-components-booking-duration__suffix",allowedFormats:m,tagName:"span",placeholder:" "+(0,s.__)("Suffix","woocommerce"),"aria-label":(0,s.__)("Suffix","woocommerce"),value:u,onChange:o=>e({suffix:o})})]})]})}})})();