(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{default:()=>x});const r=window.ReactJSXRuntime,n=window.wp.element,o=window.wp.i18n,s=window.wp.components,c=window.wp.data,l=window.wp.compose,a=window.wp.apiFetch;var i=e.n(a);const u=window.wp.url,d=window.wp.blocks;function p(e){const[t,r]=(0,n.useState)({status:"idle"}),o=(0,n.useRef)(!1),{attributes:s,block:c,skipBlockSupportAttributes:a=!1,httpMethod:p="GET",urlQueryArgs:w}=e;let f=s&&(0,d.__experimentalSanitizeBlockAttributes)(c,s);a&&(f=function(e){const{backgroundColor:t,borderColor:r,fontFamily:n,fontSize:o,gradient:s,textColor:c,className:l,...a}=e,{border:i,color:u,elements:d,shadow:p,spacing:w,typography:f,...m}=e?.style||{};return{...a,style:m}}(f));const m="POST"===p,h=function(e,t=null,r={}){return(0,u.addQueryArgs)(`/wp/v2/block-renderer/${e}`,{context:"edit",...null!==t?{attributes:t}:{},...r})}(c,m?null:f,w),y=m?JSON.stringify({attributes:f??null}):void 0;return(0,n.useEffect)(()=>{const e=new AbortController,t=(0,l.debounce)(function(){r({status:"loading"}),i()({path:h,method:m?"POST":"GET",body:y,headers:m?{"Content-Type":"application/json"}:{},signal:e.signal}).then(e=>{r({status:"success",content:e?e.rendered:""})}).catch(e=>{"AbortError"!==e.name&&r({status:"error",error:e.message})}).finally(()=>{o.current=!0})},o.current?500:0);return t(),()=>{e.abort(),t.cancel()}},[h,m,y]),t}const w={};function f({className:e}){return(0,r.jsx)(s.Placeholder,{className:e,children:(0,o.__)("Block rendered as empty.")})}function m({message:e,className:t}){const n=(0,o.sprintf)((0,o.__)("Error loading block: %s"),e);return(0,r.jsx)(s.Placeholder,{className:t,children:n})}function h({children:e}){const[t,o]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{const e=setTimeout(()=>{o(!0)},1e3);return()=>clearTimeout(e)},[]),(0,r.jsxs)("div",{style:{position:"relative"},children:[t&&(0,r.jsx)("div",{style:{position:"absolute",top:"50%",left:"50%",marginTop:"-9px",marginLeft:"-9px"},children:(0,r.jsx)(s.Spinner,{})}),(0,r.jsx)("div",{style:{opacity:t?"0.3":1},children:e})]})}function y(e){const t=(0,n.useRef)(""),{className:o,EmptyResponsePlaceholder:s=f,ErrorResponsePlaceholder:c=m,LoadingResponsePlaceholder:l=h,...a}=e,{content:i,status:u,error:d}=p(a);return(0,n.useEffect)(()=>{i&&(t.current=i)},[i]),"loading"===u?(0,r.jsx)(l,{...e,children:!!t.current&&(0,r.jsx)(n.RawHTML,{className:o,children:t.current})}):"success"!==u||i?"error"===u?(0,r.jsx)(c,{message:d,...e}):(0,r.jsx)(n.RawHTML,{className:o,children:i}):(0,r.jsx)(s,{...e})}function b({urlQueryArgs:e=w,...t}){const o=(0,c.useSelect)(e=>{const t=e("core/editor")?.getCurrentPostId();return t&&"number"==typeof t?t:null},[]),s=(0,n.useMemo)(()=>o?{post_id:o,...e}:e,[o,e]);return(0,r.jsx)(y,{urlQueryArgs:s,...t})}const g=b;g.ServerSideRender=b,g.useServerSideRender=p;var x=g;(window.wp=window.wp||{}).serverSideRender=t.default})();