(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[277],{3482:function(e,t,a){Promise.resolve().then(a.bind(a,574)),Promise.resolve().then(a.bind(a,4729))},4729:function(e,t,a){"use strict";a.d(t,{default:function(){return v}});var n=a(3229),r=a(2273),l=a(8355),s=a(8521),i=a(8593),o=a(574),d=a(4166);let c={},u=(e,t,a)=>((0,l.useEffect)(()=>{t&&"markup"in t?c[e]=t:void 0!==a&&"markup"in a&&void 0===c[e]&&(c[e]=a)},[t,e,a]),t&&"error"in t?c[e]:t),m=e=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"absolute inset-0 z-50 bg-black/80"}),(0,n.jsx)("div",{className:"md:max-w-[568px] lg:max-w-[968px] absolute left-[50%] top-[50%] min-h-[50vh] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-t-4 bg-white text-black p-6 shadow-lg duration-200 sm:rounded-lg rounded-t-sm",children:(0,n.jsxs)("div",{className:"flex flex-col max-w-full min-w-0 space-y-1.5",children:[(0,n.jsxs)("h2",{className:"text-lg flex items-center flex-shrink gap-4 font-semibold pb-2 leading-none tracking-tight",children:[(0,n.jsxs)("svg",{className:"h-6 w-6 text-red-600 font-extrabold",fill:"none",height:"24",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",width:"24",xmlns:"http://www.w3.org/2000/svg",children:[(0,n.jsx)("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"}),(0,n.jsx)("path",{d:"M12 9v4"}),(0,n.jsx)("path",{d:"M12 17h.01"})]}),e.error.name,": ",e.error.message]}),e.error.stack?(0,n.jsx)("div",{className:"text-sm p-2 flex-grow scroll-px-4 overflow-x-auto bg-red-500 rounded-lg text-gray-100",children:(0,n.jsx)("pre",{className:"font-mono w-full min-w-0 leading-7",children:e.error.stack})}):void 0]})})]});var p=a(9385),h=a(6404),v=e=>{var t;let{slug:a,documentPath:c,pathSeparator:v,renderingResult:g,schema:x}=e,f=(0,r.useRouter)(),w=(0,r.usePathname)(),b=(0,r.useSearchParams)(),k=null!==(t=b.get("view"))&&void 0!==t?t:"desktop",{useDocumentRenderingResult:j,setPageConfig:N}=(0,d.s)(),S=j(c,g),z=u(c,S,g),[P,_]=l.useState("iframe1"),[y,E]=l.useState({iframe1:null==z?void 0:z.markup}),C=e=>{let t=0;for(let a=0;a<e.length;a++)t=(t<<5)-t+e.charCodeAt(a)|0;return"iframe-".concat(Math.abs(t))};l.useEffect(()=>{if(!(null==z?void 0:z.markup))return;console.debug("renderedDocumentMetadata.markup changed:",{length:z.markup.length,timestamp:new Date().toISOString()});let e=C(z.markup);e!==P&&(E(t=>({...t,[e]:z.markup})),D(e))},[null==z?void 0:z.markup,P]);let[O,D]=l.useState(null),L=l.useCallback(e=>{if("layoutComplete"===e.data.type&&O){if(console.debug("Received layoutComplete message:",{documentSize:e.data.documentSize,documentOrientation:e.data.documentOrientation,timestamp:e.data.timestamp}),e.data.documentSize){let t=e.data.documentSize;["A3","A4","A5","letter","legal"].includes(t)||/^\d+(?:in|cm|mm|px)\s+\d+(?:in|cm|mm|px)$/.test(t)?N(c,{size:t,orientation:"landscape"===e.data.documentOrientation?"landscape":"portrait"}):console.warn("Invalid document size format: ".concat(t))}E(e=>{let t={...e};return delete t[P],t}),_(O),D(null)}},[P,O,c,N]);l.useEffect(()=>(window.addEventListener("message",L),console.debug("Message event listener added"),()=>{window.removeEventListener("message",L),console.debug("Message event listener removed")}),[L]),"true"!==h.env.NEXT_PUBLIC_IS_BUILDING&&(0,i.z)(e=>{let t=e.find(e=>e.filename.includes(a));void 0!==t&&"unlink"===t.event&&f.push("/")});let A=void 0!==z,I=(e,t)=>{let r=y[e];return r?(0,n.jsx)("div",{className:"relative h-full",children:(0,n.jsx)("iframe",{allow:"same-origin",className:"absolute top-0 left-0 w-full h-[calc(100vh_-_70px)] print:h-[100vh] bg-white ".concat(t?"z-20 opacity-100":"z-10 opacity-0"," ").concat("mobile"===k?"w-[360px] mx-auto right-0":""),srcDoc:r,title:"".concat(a,"-").concat(e)})},e):null},M="previewProps"in S?S.previewProps:{};return(0,n.jsx)(p.B,{initialDocumentPreviewProps:M,initialDocumentSchema:x,children:(0,n.jsx)(o.Shell,{documentPath:c,activeView:A?k:void 0,currentDocumentOpenSlug:a,markup:null==z?void 0:z.markup,pathSeparator:v,setActiveView:A?e=>{let t=new URLSearchParams(b);t.set("view",e),f.push("".concat(w,"?").concat(t.toString()))}:void 0,children:(0,n.jsxs)("div",{className:"relative h-full",children:["error"in S?(0,n.jsx)(m,{error:S.error}):null,A?(0,n.jsxs)("div",{className:"relative h-full",children:[O&&(0,n.jsx)("div",{className:"absolute top-0 left-0 w-full h-0.5 bg-gradient-to-r from-transparent via-green-500 to-transparent animate-loading-bar z-30"}),Object.keys(y).map(e=>I(e,e===P))]}):null,(0,n.jsx)(s.x7,{})]})})})}}},function(e){e.O(0,[960,1,832,574,698,267,744],function(){return e(e.s=3482)}),_N_E=e.O()}]);