(()=>{"use strict";var e,t={7314:(e,t,r)=>{var n=r(434),a=r(9408);document.addEventListener("DOMContentLoaded",(function(){!function(){var e=document.querySelector('[data-side-panel="preview"]');if(e){var t=e.querySelector("[data-preview-panel]"),r=t.querySelectorAll("[data-device-width]"),o=t.querySelector("[data-default-size]"),i=function(e){var n,a,i,c=e.target.value;n=e.target.dataset.deviceWidth,a=t.classList.contains("preview-panel--unavailable"),i=n,n&&!a||(i=o.dataset.deviceWidth),t.style.setProperty("--preview-device-width",i);try{localStorage.setItem("wagtail:preview-panel-device",c)}catch(e){}r.forEach((function(e){t.classList.toggle("preview-panel--".concat(e.value),e.value===c)}))};r.forEach((function(e){return e.addEventListener("change",i)})),new ResizeObserver((function(e){return t.style.setProperty("--preview-panel-width",e[0].contentRect.width)})).observe(t);var c,l,s=t.querySelector("[data-preview-new-tab]"),d=t.querySelector("[data-refresh-preview]"),u=t.querySelector("[data-preview-spinner]"),v=document.querySelector("[data-edit-form]"),f=t.dataset.action,h=document.querySelector("[data-preview-mode-select]"),w=t.querySelector("[data-preview-iframe]"),p=!1,g=function(){clearTimeout(c),u.classList.add("w-hidden"),p=!1},m=function(){var e=document.createElement("iframe");e.style.width=0,e.style.height=0,e.style.opacity=0,e.style.position="absolute",e.src=w.src,w.insertAdjacentElement("afterend",e);var t=function(){Array.from(w.attributes).forEach((function(t){"src"!==t.nodeName&&e.setAttribute(t.nodeName,t.nodeValue)})),e.contentWindow.scroll(w.contentWindow.scrollX,w.contentWindow.scrollY),w.remove(),w=e,e.style=null,g(),e.removeEventListener("load",t)};e.addEventListener("load",t)},y=function(){return p?Promise.resolve():(p=!0,c=setTimeout((function(){return u.classList.remove("w-hidden")}),2e3),fetch(f,{method:"POST",body:new FormData(v)}).then((function(e){return e.json()})).then((function(e){return t.classList.toggle("preview-panel--has-errors",!e.is_valid),t.classList.toggle("preview-panel--unavailable",!e.is_available),e.is_valid?m():g(),e.is_valid})).catch((function(e){throw g(),e})))},b=function(){return y().catch((function(){window.alert((0,a.gettext)("Error while sending preview data."))}))};if(s.addEventListener("click",(function(e){e.preventDefault();var t=window.open("",f);t.focus(),b().then((function(e){if(e){var r=new URL(s.href);t.document.location=r.toString()}else window.focus(),t.close()}))})),d&&d.addEventListener("click",b),n.WAGTAIL_CONFIG.WAGTAIL_AUTO_UPDATE_PREVIEW){var E,L=new URLSearchParams(new FormData(v)).toString(),S=function(){var e,t;!p&&(e=new URLSearchParams(new FormData(v)).toString(),t=L!==e,L=e,t)&&y()};e.addEventListener("show",(function(){S(),E=setInterval(S,n.WAGTAIL_CONFIG.WAGTAIL_AUTO_UPDATE_PREVIEW_INTERVAL)})),e.addEventListener("hide",(function(){clearInterval(E)}))}h&&h.addEventListener("change",(function(e){var t=e.target.value,r=new URL(w.src);r.searchParams.set("mode",t),w.src=r.toString(),r.searchParams.delete("in_preview_panel"),s.href=r.toString(),b()})),fetch(f,{headers:(l={},l[n.WAGTAIL_CONFIG.CSRF_HEADER_NAME]=n.WAGTAIL_CONFIG.CSRF_TOKEN,l),method:"DELETE"}).then((function(){return y()})).then((function(){return m()}));var _=null;try{_=localStorage.getItem("wagtail:preview-panel-device")}catch(e){}(t.querySelector('[data-device-width][value="'.concat(_,'"]'))||o).click()}}()}))}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var o=r[e]={exports:{}};return t[e].call(o.exports,o,o.exports,n),o.exports}n.m=t,e=[],n.O=(t,r,a,o)=>{if(!r){var i=1/0;for(d=0;d<e.length;d++){for(var[r,a,o]=e[d],c=!0,l=0;l<r.length;l++)(!1&o||i>=o)&&Object.keys(n.O).every((e=>n.O[e](r[l])))?r.splice(l--,1):(c=!1,o<i&&(i=o));if(c){e.splice(d--,1);var s=a();void 0!==s&&(t=s)}}return t}o=o||0;for(var d=e.length;d>0&&e[d-1][2]>o;d--)e[d]=e[d-1];e[d]=[r,a,o]},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.j=673,(()=>{var e={673:0};n.O.j=t=>0===e[t];var t=(t,r)=>{var a,o,[i,c,l]=r,s=0;if(i.some((t=>0!==e[t]))){for(a in c)n.o(c,a)&&(n.m[a]=c[a]);if(l)var d=l(n)}for(t&&t(r);s<i.length;s++)o=i[s],n.o(e,o)&&e[o]&&e[o][0](),e[o]=0;return n.O(d)},r=globalThis.webpackChunkwagtail=globalThis.webpackChunkwagtail||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var a=n.O(void 0,[751],(()=>n(7314)));a=n.O(a)})();